Changeset 2268880
- Timestamp:
- 03/27/2020 07:18:22 AM (6 years ago)
- Location:
- wp-my-instagram
- Files:
-
- 24 added
- 6 edited
-
tags/1.3.0 (added)
-
tags/1.3.0/css (added)
-
tags/1.3.0/css/.sassbuilder-config.json (added)
-
tags/1.3.0/css/style.css (added)
-
tags/1.3.0/css/style.css.map (added)
-
tags/1.3.0/css/style.min.css (added)
-
tags/1.3.0/css/style.scss (added)
-
tags/1.3.0/inc (added)
-
tags/1.3.0/inc/public (added)
-
tags/1.3.0/inc/public/main.php (added)
-
tags/1.3.0/inc/public/shortcode.php (added)
-
tags/1.3.0/inc/public/widget.php (added)
-
tags/1.3.0/inc/templates (added)
-
tags/1.3.0/inc/templates/item.php (added)
-
tags/1.3.0/index.php (added)
-
tags/1.3.0/js (added)
-
tags/1.3.0/js/script.js (added)
-
tags/1.3.0/js/script.min.js (added)
-
tags/1.3.0/langs (added)
-
tags/1.3.0/langs/wp-my-instagram.pot (added)
-
tags/1.3.0/license.txt (added)
-
tags/1.3.0/readme.txt (added)
-
tags/1.3.0/task.txt (added)
-
tags/1.3.0/wp-my-instagram.php (added)
-
trunk/inc/public/main.php (modified) (1 diff)
-
trunk/js/script.js (modified) (2 diffs)
-
trunk/js/script.min.js (modified) (1 diff)
-
trunk/langs/wp-my-instagram.pot (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/wp-my-instagram.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-my-instagram/trunk/inc/public/main.php
r2153183 r2268880 128 128 129 129 $output = ''; 130 131 $media_array = array();132 130 133 131 if( self::get_cache( $scrape_key, (int) $args['limit'], $use_hashtag ) ){ -
wp-my-instagram/trunk/js/script.js
r1694302 r2268880 1 1 /** 2 * WP Social Counter2 * wp-my-instagram 3 3 * This only run once to reduce page load time. 4 4 * … … 12 12 $(document).ready(function(){ 13 13 14 var $blocks = $('.wp-my-instagram.wpmi[data-cached="false"]'), 15 args = {}; 14 var $blocks = $('.wp-my-instagram.wpmi[data-cached="false"]'); 16 15 17 if( $blocks.length ){16 var data_storage = []; 18 17 19 $blocks.each(function(){ 18 var fetch_data = function( id, args ){ 19 20 var settings = { 21 username: '', 22 hashtag: '', 23 limit: 6, 24 popular: false 25 }; 26 27 28 $.extend( true, settings, args ); 29 30 31 var username = settings.username || false, 32 hashtag = settings.hashtag || false, 33 hashtag_popular = settings.popular || false, 34 base_url = 'https://instagram.com/', 35 url = base_url + username; 36 37 38 if( !username && !hashtag ){ 39 console.log( 'No hashtag or username provided.'); 40 return; 41 } 42 43 // if use hashtag 44 if( hashtag ){ 45 url = base_url + 'explore/tags/' + hashtag; 46 } 47 48 $.ajax({ 49 type: 'GET', 50 url: url, 51 async: true, 52 cache: false 53 }).done( function (data) { 54 55 if( hashtag ){ 56 var hashtag_media_key = hashtag_popular ? 'edge_hashtag_to_top_posts' : 'edge_hashtag_to_media'; 57 58 data = JSON.parse(data.split("window._sharedData = ")[1].split(";<\/script>")[0]).entry_data.TagPage[0].graphql.hashtag[hashtag_media_key].edges; 59 }else{ 60 data = JSON.parse(data.split("window._sharedData = ")[1].split(";<\/script>")[0]).entry_data.ProfilePage[0].graphql.user.edge_owner_to_timeline_media.edges; 61 } 62 63 if( data ){ 64 65 var images = []; 66 67 for (var property in data) { 68 var image_data = data[property]['node']; 69 var image_args = {}; 70 71 // thumbnail 72 image_args['thumbnail'] = ( ( image_data || {} ).thumbnail_resources[0] || {} ).src || ''; 73 74 // xsmall 75 image_args['xsmall'] = ( ( image_data || {} ).thumbnail_resources[1] || {} ).src || ''; 76 77 // small 78 image_args['small'] = ( ( image_data || {} ).thumbnail_resources[2] || {} ).src || ''; 79 80 // medium 81 image_args['medium'] = ( ( image_data || {} ).thumbnail_resources[3] || {} ).src || ''; 82 83 // Large 84 image_args['large'] = ( image_data || {} ).thumbnail_src || ''; 85 86 // Full 87 image_args['original'] = ( image_data || {} ).display_url || '';; 88 89 // link 90 image_args['url'] = image_data.shortcode ? '//instagram.com/p/' + image_data.shortcode : ''; 91 92 // type 93 image_args['type'] = image_data.is_video ? 'video' : 'image'; 94 95 // description 96 image_args['description'] = (((( image_data || {} ).edge_media_to_caption || {}).edges[0] || {} ).node || {} ).text || ''; 97 98 // time 99 image_args['time'] = image_data['taken_at_timestamp'] || ''; 100 101 // Comments: 102 image_args['comments'] = (( image_data || {} ).edge_media_to_comment || {}).count || ''; 103 104 // Likes 105 image_args['likes'] = image_data['edge_liked_by']['count'] || ''; 106 107 // finally push image data to images 108 images[images.length] = image_args; 109 110 // Break when reaches the limit 111 if( images.length === parseInt(settings.limit) ){ 112 break; 113 } 114 } 115 116 if( images.length ){ 117 $(document.body).trigger( 'wp-my-instagram-load', { id: id, args: settings, images: images } ); 118 } 119 120 } 121 122 }); 123 } 124 125 // fetch_data({ username: 'aesthetic', limit: 7, hashtag: 'pixel4', popular: false }); 126 // fetch_data({ username: 'aesthetic', limit: 10, hashtag: '', popular: false }); 127 128 129 $(document.body).on( 'wp-my-instagram-load', function( e, data ){ 130 131 $.ajax({ 132 url: wpMyInstagramVars.ajaxurl, 133 type: 'POST', 134 async: true, 135 cache: false, 136 // dataType: 'json', 137 data: { 138 action: 'wpmi-request-cache', 139 security: wpMyInstagramVars.nonce, 140 data: data 141 } 142 }).done( function( response ){ 143 144 if( response && response.data ){ 145 for (var key in response.data ) { 146 var $wmmi = $( '#' + key + '.wp-my-instagram.wpmi' ); 147 $('.wpmi-list', $wmmi).html( response.data[key] ), 148 $wmmi.attr('data-cached', 'true' ); 149 } 150 151 } 152 153 }); 154 }); 155 156 if( $blocks.length ){ 157 158 $blocks.each(function( index ){ 20 159 var $el = $(this), 21 160 id = $el.attr('id'); 22 161 23 args[id] = $el.data('args'); 162 // init data 163 fetch_data( id, $el.data('args') ); 164 24 165 }); 25 26 if( args ){ 27 28 $.ajax({ 29 url: wpMyInstagramVars.ajaxurl, 30 type: 'GET', 31 async: true, 32 cache: false, 33 // dataType: 'json', 34 data: { 35 action: 'wpmi-init-cache', 36 security: wpMyInstagramVars.nonce, 37 args: args 38 } 39 }).done( function( response ){ 40 41 if( response && response.data ){ 42 for (var key in response.data ) { 43 var $wmmi = $( '#' + key + '.wp-my-instagram.wpmi' ); 44 $('.wpmi-list', $wmmi).html( response.data[key] ), 45 $wmmi.attr('data-cached', 'true' ); 46 } 47 } 48 49 }); 50 } 51 } 166 } 52 167 53 168 }); -
wp-my-instagram/trunk/js/script.min.js
r1694302 r2268880 1 !function( a){"use strict";a(document).ready(function(){var t=a('.wp-my-instagram.wpmi[data-cached="false"]'),n={};t.length&&(t.each(function(){var t=a(this),r=t.attr("id");n[r]=t.data("args")}),n&&a.ajax({url:wpMyInstagramVars.ajaxurl,type:"GET",async:!0,cache:!1,data:{action:"wpmi-init-cache",security:wpMyInstagramVars.nonce,args:n}}).done(function(t){if(t&&t.data)for(var n in t.data){var r=a("#"+n+".wp-my-instagram.wpmi");a(".wpmi-list",r).html(t.data[n]),r.attr("data-cached","true")}}))})}(window.jQuery);1 !function(c){"use strict";c(document).ready(function(){var a=c('.wp-my-instagram.wpmi[data-cached="false"]');c(document.body).on("wp-my-instagram-load",function(a,e){c.ajax({url:wpMyInstagramVars.ajaxurl,type:"POST",async:!0,cache:!1,data:{action:"wpmi-request-cache",security:wpMyInstagramVars.nonce,data:e}}).done(function(a){if(a&&a.data)for(var e in a.data){var t=c("#"+e+".wp-my-instagram.wpmi");c(".wpmi-list",t).html(a.data[e]),t.attr("data-cached","true")}})}),a.length&&a.each(function(a){var e=c(this);!function(n,a){var o={username:"",hashtag:"",limit:6,popular:!1};c.extend(!0,o,a);var e=o.username||!1,d=o.hashtag||!1,m=o.popular||!1,t="https://instagram.com/",r=t+e;e||d?(d&&(r=t+"explore/tags/"+d),c.ajax({type:"GET",url:r,async:!0,cache:!1}).done(function(a){if(d){var e=m?"edge_hashtag_to_top_posts":"edge_hashtag_to_media";a=JSON.parse(a.split("window._sharedData = ")[1].split(";<\/script>")[0]).entry_data.TagPage[0].graphql.hashtag[e].edges}else a=JSON.parse(a.split("window._sharedData = ")[1].split(";<\/script>")[0]).entry_data.ProfilePage[0].graphql.user.edge_owner_to_timeline_media.edges;if(a){var t=[];for(var r in a){var s=a[r].node,i={};if(i.thumbnail=((s||{}).thumbnail_resources[0]||{}).src||"",i.xsmall=((s||{}).thumbnail_resources[1]||{}).src||"",i.small=((s||{}).thumbnail_resources[2]||{}).src||"",i.medium=((s||{}).thumbnail_resources[3]||{}).src||"",i.large=(s||{}).thumbnail_src||"",i.original=(s||{}).display_url||"",i.url=s.shortcode?"//instagram.com/p/"+s.shortcode:"",i.type=s.is_video?"video":"image",i.description=((((s||{}).edge_media_to_caption||{}).edges[0]||{}).node||{}).text||"",i.time=s.taken_at_timestamp||"",i.comments=((s||{}).edge_media_to_comment||{}).count||"",i.likes=s.edge_liked_by.count||"",t[t.length]=i,t.length===parseInt(o.limit))break}t.length&&c(document.body).trigger("wp-my-instagram-load",{id:n,args:o,images:t})}})):console.log("No hashtag or username provided.")}(e.attr("id"),e.data("args"))})})}(window.jQuery); -
wp-my-instagram/trunk/langs/wp-my-instagram.pot
r2153183 r2268880 1 # Copyright (C) 20 19WP Instant Feeds1 # Copyright (C) 2020 WP Instant Feeds 2 2 # This file is distributed under the same license as the WP Instant Feeds package. 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: WP Instant Feeds 1. 2.0\n"5 "Project-Id-Version: WP Instant Feeds 1.3.0\n" 6 6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wp-my-instagram\n" 7 "POT-Creation-Date: 20 19-09-08 22:02:19+00:00\n"7 "POT-Creation-Date: 2020-03-27 07:14:58+00:00\n" 8 8 "MIME-Version: 1.0\n" 9 9 "Content-Type: text/plain; charset=UTF-8\n" 10 10 "Content-Transfer-Encoding: 8bit\n" 11 "PO-Revision-Date: 20 19-MO-DA HO:MI+ZONE\n"11 "PO-Revision-Date: 2020-MO-DA HO:MI+ZONE\n" 12 12 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" 13 13 "Language-Team: LANGUAGE <LL@li.org>\n" … … 17 17 msgstr "" 18 18 19 #: inc/public/main.php:22 219 #: inc/public/main.php:220 20 20 msgid "Unable to communicate with Instagram." 21 21 msgstr "" 22 22 23 #: inc/public/main.php:22 523 #: inc/public/main.php:223 24 24 msgid "Instagram did not return a 200." 25 25 msgstr "" 26 26 27 #: inc/public/main.php:23 3 inc/public/main.php:256 inc/public/main.php:26027 #: inc/public/main.php:231 inc/public/main.php:254 inc/public/main.php:258 28 28 msgid "Instagram has returned invalid data." 29 29 msgstr "" 30 30 31 #: inc/public/main.php:37 331 #: inc/public/main.php:371 32 32 msgid "Instagram did not return any images." 33 33 msgstr "" 34 34 35 #: inc/public/main.php:38 435 #: inc/public/main.php:382 36 36 msgid "This param must be array." 37 37 msgstr "" -
wp-my-instagram/trunk/readme.txt
r2153183 r2268880 5 5 Requires at least: 3.9 6 6 Tested up to: 5.2.3 7 Stable tag: 1. 2.07 Stable tag: 1.3.0 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 64 64 65 65 == Changelog == 66 67 = 1.3.0 - Mar 26 2020 = 68 * Better feed getter ;) 66 69 67 70 = 1.2.0 - SEP 8 2019 = -
wp-my-instagram/trunk/wp-my-instagram.php
r2153183 r2268880 4 4 Plugin URI: https://wordpress.org/plugins/wp-my-instagram 5 5 Description: Display Instagram feeds on your site from your Instagram account 6 Version: 1. 2.06 Version: 1.3.0 7 7 Author: mnmlthms 8 8 Author URI: http://mnmlthms.com … … 29 29 if ( ! defined( 'ABSPATH' ) ) exit; 30 30 31 define( 'WP_MY_INSTAGRAM_VERSION', '1. 2.0' );31 define( 'WP_MY_INSTAGRAM_VERSION', '1.3.0' ); 32 32 define( 'WP_MY_INSTAGRAM_OPTION', 'wp_my_instagram' ); 33 33 … … 97 97 add_action( 'wp_ajax_nopriv_wpmi-init-cache', array( $this, 'ajax_load_cache') ); 98 98 99 add_action( 'wp_ajax_wpmi-request-cache', array( $this, 'ajax_load_cache_js') ); 100 add_action( 'wp_ajax_nopriv_wpmi-request-cache', array( $this, 'ajax_load_cache_js') ); 101 102 99 103 } 100 104 … … 120 124 'ajaxurl' => admin_url( 'admin-ajax.php' ) 121 125 ) ); 126 } 127 128 public function ajax_load_cache_js(){ 129 130 $nonce_key = 'wpmi-init-cache-nonce'; 131 132 check_ajax_referer( $nonce_key, 'security' ); 133 134 $response = array( 135 'success' => true 136 ); 137 138 $data = $_REQUEST['data']; 139 140 $output = array(); 141 142 if( !class_exists( 'WP_My_Instagram_Main' ) ){ 143 144 require_once( 'inc/public/main.php' ); 145 146 } 147 148 if( !empty( $data['images'] ) ){ 149 $scrape_key = !empty( $data['args']['hashtag'] ) ? $data['args']['hashtag'] : $data['args']['username']; 150 $scrape_key = strtolower( $scrape_key ); 151 $scrape_key = str_replace( '@', '', $scrape_key ); 152 $scrape_key = trim( $scrape_key ); 153 $scrape_key = !empty( $data['args']['hashtag'] ) ? $data['args']['hashtag'] : $data['args']['username']; 154 155 $cache_name = WP_My_Instagram_Main::get_cache_name( $scrape_key, $data['args']['limit'], (boolean) $data['args']['hashtag'] ); 156 $cache_time = apply_filters( 'wpmi_cache_time', HOUR_IN_SECONDS*2 ); 157 158 // do not set an empty transient - should help catch private or empty accounts 159 if ( ! empty( $data['images'] ) ) { 160 set_transient( $cache_name, base64_encode( serialize( $data['images'] ) ), $cache_time ); 161 } 162 163 ob_start(); 164 // cache 165 WP_My_Instagram_Main::make_items( $data['images'], $data['args'] ); 166 $items = ob_get_clean(); 167 $output[$data['id']] = $items; 168 169 $response['data'] = $output; 170 }else{ 171 $response['success'] = false; 172 $response['data'] = esc_html( 'Something went wrong! Please try again' ); 173 } 174 175 wp_send_json( $response ); 176 177 wp_die(1); 122 178 } 123 179 /**
Note: See TracChangeset
for help on using the changeset viewer.