Changeset 1839618
- Timestamp:
- 03/13/2018 09:03:54 PM (6 years ago)
- Location:
- wp-instagram-widget
- Files:
-
- 4 added
- 6 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
wp-instagram-widget/tags/2.0.3/readme.md
r1801414 r1839618 84 84 85 85 ## Changelog 86 87 88 89 86 90 87 91 #### 2.0.2 -
wp-instagram-widget/tags/2.0.3/readme.txt
r1801414 r1839618 3 3 Tags: instagram, widget, photos, photography, hipster, sidebar, widgets, simple 4 4 Requires at least: 4.4 5 Tested up to: 4.9. 16 Stable tag: 2.0. 25 Tested up to: 4.9. 6 Stable tag: 2.0. 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 80 80 81 81 == Changelog == 82 83 84 85 82 86 83 87 = 2.0.2 = -
wp-instagram-widget/tags/2.0.3/wp-instagram-widget.php
r1801414 r1839618 4 4 Plugin URI: https://github.com/scottsweb/wp-instagram-widget 5 5 Description: A WordPress widget for showing your latest Instagram photos. 6 Version: 2.0. 26 Version: 2.0. 7 7 Author: Scott Evans 8 8 Author URI: https://scott.ee … … 189 189 $username = trim( strtolower( $username ) ); 190 190 191 if ( false === ( $instagram = get_transient( 'instagram-a9-' . sanitize_title_with_dashes( $username ) ) ) ) { 192 193 switch ( substr( $username, 0, 1 ) ) { 194 case '#': 195 $url = 'https://instagram.com/explore/tags/' . str_replace( '#', '', $username ); 196 break; 197 198 default: 199 $url = 'https://instagram.com/' . str_replace( '@', '', $username ); 200 break; 201 } 191 switch ( substr( $username, 0, 1 ) ) { 192 case '#': 193 $url = 'https://instagram.com/explore/tags/' . str_replace( '#', '', $username ); 194 $transient_prefix = 'h'; 195 break; 196 197 default: 198 $url = 'https://instagram.com/' . str_replace( '@', '', $username ); 199 $transient_prefix = 'u'; 200 break; 201 } 202 203 if ( false === ( $instagram = get_transient( 'insta-a10-' . $transient_prefix . '-' . sanitize_title_with_dashes( $username ) ) ) ) { 202 204 203 205 $remote = wp_remote_get( $url ); … … 211 213 } 212 214 213 $shards = explode( 'window._sharedData = ', $remote['body'] );214 $insta_json = explode( ';</script>', $shards[1] );215 $shards = explode( 'window._sharedData = ', $remote['body'] ); 216 $insta_json = explode( ';</script>', $shards[1] ); 215 217 $insta_array = json_decode( $insta_json[0], true ); 216 218 … … 219 221 } 220 222 221 if ( isset( $insta_array['entry_data']['ProfilePage'][0][' user']['media']['nodes'] ) ) {222 $images = $insta_array['entry_data']['ProfilePage'][0][' user']['media']['nodes'];223 if ( isset( $insta_array['entry_data']['ProfilePage'][0]['es'] ) ) { 224 $images = $insta_array['entry_data']['ProfilePage'][0]['es']; 223 225 } elseif ( isset( $insta_array['entry_data']['TagPage'][0]['graphql']['hashtag']['edge_hashtag_to_media']['edges'] ) ) { 224 226 $images = $insta_array['entry_data']['TagPage'][0]['graphql']['hashtag']['edge_hashtag_to_media']['edges']; … … 234 236 235 237 foreach ( $images as $image ) { 236 // Note: keep hashtag support different until these JSON changes stabalise 237 // these are mostly the same again now 238 switch ( substr( $username, 0, 1 ) ) { 239 case '#': 240 if ( true === $image['node']['is_video'] ) { 241 $type = 'video'; 242 } else { 243 $type = 'image'; 244 } 245 246 $caption = __( 'Instagram Image', 'wp-instagram-widget' ); 247 if ( ! empty( $image['node']['edge_media_to_caption']['edges'][0]['node']['text'] ) ) { 248 $caption = $image['node']['edge_media_to_caption']['edges'][0]['node']['text']; 249 } 250 251 $instagram[] = array( 252 'description' => $caption, 253 'link' => trailingslashit( '//instagram.com/p/' . $image['node']['shortcode'] ), 254 'time' => $image['node']['taken_at_timestamp'], 255 'comments' => $image['node']['edge_media_to_comment']['count'], 256 'likes' => $image['node']['edge_liked_by']['count'], 257 'thumbnail' => preg_replace( '/^https?\:/i', '', $image['node']['thumbnail_resources'][0]['src'] ), 258 'small' => preg_replace( '/^https?\:/i', '', $image['node']['thumbnail_resources'][2]['src'] ), 259 'large' => preg_replace( '/^https?\:/i', '', $image['node']['thumbnail_resources'][4]['src'] ), 260 'original' => preg_replace( '/^https?\:/i', '', $image['node']['display_url'] ), 261 'type' => $type, 262 ); 263 break; 264 default: 265 if ( true === $image['is_video'] ) { 266 $type = 'video'; 267 } else { 268 $type = 'image'; 269 } 270 271 $caption = __( 'Instagram Image', 'wp-instagram-widget' ); 272 if ( ! empty( $image['caption'] ) ) { 273 $caption = $image['caption']; 274 } 275 276 $instagram[] = array( 277 'description' => $caption, 278 'link' => trailingslashit( '//instagram.com/p/' . $image['code'] ), 279 'time' => $image['date'], 280 'comments' => $image['comments']['count'], 281 'likes' => $image['likes']['count'], 282 'thumbnail' => preg_replace( '/^https?\:/i', '', $image['thumbnail_resources'][0]['src'] ), 283 'small' => preg_replace( '/^https?\:/i', '', $image['thumbnail_resources'][2]['src'] ), 284 'large' => preg_replace( '/^https?\:/i', '', $image['thumbnail_resources'][4]['src'] ), 285 'original' => preg_replace( '/^https?\:/i', '', $image['display_src'] ), 286 'type' => $type, 287 ); 288 289 break; 290 } 238 if ( true === $image['node']['is_video'] ) { 239 $type = 'video'; 240 } else { 241 $type = 'image'; 242 } 243 244 $caption = __( 'Instagram Image', 'wp-instagram-widget' ); 245 if ( ! empty( $image['node']['edge_media_to_caption']['edges'][0]['node']['text'] ) ) { 246 $caption = wp_kses( $image['node']['edge_media_to_caption']['edges'][0]['node']['text'], array() ); 247 } 248 249 $instagram[] = array( 250 'description' => $caption, 251 'link' => trailingslashit( '//instagram.com/p/' . $image['node']['shortcode'] ), 252 'time' => $image['node']['taken_at_timestamp'], 253 'comments' => $image['node']['edge_media_to_comment']['count'], 254 'likes' => $image['node']['edge_liked_by']['count'], 255 'thumbnail' => preg_replace( '/^https?\:/i', '', $image['node']['thumbnail_resources'][0]['src'] ), 256 'small' => preg_replace( '/^https?\:/i', '', $image['node']['thumbnail_resources'][2]['src'] ), 257 'large' => preg_replace( '/^https?\:/i', '', $image['node']['thumbnail_resources'][4]['src'] ), 258 'original' => preg_replace( '/^https?\:/i', '', $image['node']['display_url'] ), 259 'type' => $type, 260 ); 291 261 } // End foreach(). 292 262 … … 294 264 if ( ! empty( $instagram ) ) { 295 265 $instagram = base64_encode( serialize( $instagram ) ); 296 set_transient( 'insta gram-a9-' . sanitize_title_with_dashes( $username ), $instagram, apply_filters( 'null_instagram_cache_time', HOUR_IN_SECONDS * 2 ) );266 set_transient( 'insta-' . sanitize_title_with_dashes( $username ), $instagram, apply_filters( 'null_instagram_cache_time', HOUR_IN_SECONDS * 2 ) ); 297 267 } 298 268 } -
wp-instagram-widget/trunk/readme.md
r1801414 r1839618 84 84 85 85 ## Changelog 86 87 88 89 86 90 87 91 #### 2.0.2 -
wp-instagram-widget/trunk/readme.txt
r1801414 r1839618 3 3 Tags: instagram, widget, photos, photography, hipster, sidebar, widgets, simple 4 4 Requires at least: 4.4 5 Tested up to: 4.9. 16 Stable tag: 2.0. 25 Tested up to: 4.9. 6 Stable tag: 2.0. 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 80 80 81 81 == Changelog == 82 83 84 85 82 86 83 87 = 2.0.2 = -
wp-instagram-widget/trunk/wp-instagram-widget.php
r1801414 r1839618 4 4 Plugin URI: https://github.com/scottsweb/wp-instagram-widget 5 5 Description: A WordPress widget for showing your latest Instagram photos. 6 Version: 2.0. 26 Version: 2.0. 7 7 Author: Scott Evans 8 8 Author URI: https://scott.ee … … 189 189 $username = trim( strtolower( $username ) ); 190 190 191 if ( false === ( $instagram = get_transient( 'instagram-a9-' . sanitize_title_with_dashes( $username ) ) ) ) { 192 193 switch ( substr( $username, 0, 1 ) ) { 194 case '#': 195 $url = 'https://instagram.com/explore/tags/' . str_replace( '#', '', $username ); 196 break; 197 198 default: 199 $url = 'https://instagram.com/' . str_replace( '@', '', $username ); 200 break; 201 } 191 switch ( substr( $username, 0, 1 ) ) { 192 case '#': 193 $url = 'https://instagram.com/explore/tags/' . str_replace( '#', '', $username ); 194 $transient_prefix = 'h'; 195 break; 196 197 default: 198 $url = 'https://instagram.com/' . str_replace( '@', '', $username ); 199 $transient_prefix = 'u'; 200 break; 201 } 202 203 if ( false === ( $instagram = get_transient( 'insta-a10-' . $transient_prefix . '-' . sanitize_title_with_dashes( $username ) ) ) ) { 202 204 203 205 $remote = wp_remote_get( $url ); … … 211 213 } 212 214 213 $shards = explode( 'window._sharedData = ', $remote['body'] );214 $insta_json = explode( ';</script>', $shards[1] );215 $shards = explode( 'window._sharedData = ', $remote['body'] ); 216 $insta_json = explode( ';</script>', $shards[1] ); 215 217 $insta_array = json_decode( $insta_json[0], true ); 216 218 … … 219 221 } 220 222 221 if ( isset( $insta_array['entry_data']['ProfilePage'][0][' user']['media']['nodes'] ) ) {222 $images = $insta_array['entry_data']['ProfilePage'][0][' user']['media']['nodes'];223 if ( isset( $insta_array['entry_data']['ProfilePage'][0]['es'] ) ) { 224 $images = $insta_array['entry_data']['ProfilePage'][0]['es']; 223 225 } elseif ( isset( $insta_array['entry_data']['TagPage'][0]['graphql']['hashtag']['edge_hashtag_to_media']['edges'] ) ) { 224 226 $images = $insta_array['entry_data']['TagPage'][0]['graphql']['hashtag']['edge_hashtag_to_media']['edges']; … … 234 236 235 237 foreach ( $images as $image ) { 236 // Note: keep hashtag support different until these JSON changes stabalise 237 // these are mostly the same again now 238 switch ( substr( $username, 0, 1 ) ) { 239 case '#': 240 if ( true === $image['node']['is_video'] ) { 241 $type = 'video'; 242 } else { 243 $type = 'image'; 244 } 245 246 $caption = __( 'Instagram Image', 'wp-instagram-widget' ); 247 if ( ! empty( $image['node']['edge_media_to_caption']['edges'][0]['node']['text'] ) ) { 248 $caption = $image['node']['edge_media_to_caption']['edges'][0]['node']['text']; 249 } 250 251 $instagram[] = array( 252 'description' => $caption, 253 'link' => trailingslashit( '//instagram.com/p/' . $image['node']['shortcode'] ), 254 'time' => $image['node']['taken_at_timestamp'], 255 'comments' => $image['node']['edge_media_to_comment']['count'], 256 'likes' => $image['node']['edge_liked_by']['count'], 257 'thumbnail' => preg_replace( '/^https?\:/i', '', $image['node']['thumbnail_resources'][0]['src'] ), 258 'small' => preg_replace( '/^https?\:/i', '', $image['node']['thumbnail_resources'][2]['src'] ), 259 'large' => preg_replace( '/^https?\:/i', '', $image['node']['thumbnail_resources'][4]['src'] ), 260 'original' => preg_replace( '/^https?\:/i', '', $image['node']['display_url'] ), 261 'type' => $type, 262 ); 263 break; 264 default: 265 if ( true === $image['is_video'] ) { 266 $type = 'video'; 267 } else { 268 $type = 'image'; 269 } 270 271 $caption = __( 'Instagram Image', 'wp-instagram-widget' ); 272 if ( ! empty( $image['caption'] ) ) { 273 $caption = $image['caption']; 274 } 275 276 $instagram[] = array( 277 'description' => $caption, 278 'link' => trailingslashit( '//instagram.com/p/' . $image['code'] ), 279 'time' => $image['date'], 280 'comments' => $image['comments']['count'], 281 'likes' => $image['likes']['count'], 282 'thumbnail' => preg_replace( '/^https?\:/i', '', $image['thumbnail_resources'][0]['src'] ), 283 'small' => preg_replace( '/^https?\:/i', '', $image['thumbnail_resources'][2]['src'] ), 284 'large' => preg_replace( '/^https?\:/i', '', $image['thumbnail_resources'][4]['src'] ), 285 'original' => preg_replace( '/^https?\:/i', '', $image['display_src'] ), 286 'type' => $type, 287 ); 288 289 break; 290 } 238 if ( true === $image['node']['is_video'] ) { 239 $type = 'video'; 240 } else { 241 $type = 'image'; 242 } 243 244 $caption = __( 'Instagram Image', 'wp-instagram-widget' ); 245 if ( ! empty( $image['node']['edge_media_to_caption']['edges'][0]['node']['text'] ) ) { 246 $caption = wp_kses( $image['node']['edge_media_to_caption']['edges'][0]['node']['text'], array() ); 247 } 248 249 $instagram[] = array( 250 'description' => $caption, 251 'link' => trailingslashit( '//instagram.com/p/' . $image['node']['shortcode'] ), 252 'time' => $image['node']['taken_at_timestamp'], 253 'comments' => $image['node']['edge_media_to_comment']['count'], 254 'likes' => $image['node']['edge_liked_by']['count'], 255 'thumbnail' => preg_replace( '/^https?\:/i', '', $image['node']['thumbnail_resources'][0]['src'] ), 256 'small' => preg_replace( '/^https?\:/i', '', $image['node']['thumbnail_resources'][2]['src'] ), 257 'large' => preg_replace( '/^https?\:/i', '', $image['node']['thumbnail_resources'][4]['src'] ), 258 'original' => preg_replace( '/^https?\:/i', '', $image['node']['display_url'] ), 259 'type' => $type, 260 ); 291 261 } // End foreach(). 292 262 … … 294 264 if ( ! empty( $instagram ) ) { 295 265 $instagram = base64_encode( serialize( $instagram ) ); 296 set_transient( 'insta gram-a9-' . sanitize_title_with_dashes( $username ), $instagram, apply_filters( 'null_instagram_cache_time', HOUR_IN_SECONDS * 2 ) );266 set_transient( 'insta-' . sanitize_title_with_dashes( $username ), $instagram, apply_filters( 'null_instagram_cache_time', HOUR_IN_SECONDS * 2 ) ); 297 267 } 298 268 }
Note: See TracChangeset
for help on using the changeset viewer.