Plugin Directory

Changeset 1839618

Timestamp:
03/13/2018 09:03:54 PM (6 years ago)
Author:
scottsweb
Message:

Release 2.0.3, see readme.txt for the changelog.

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  
    8484
    8585## Changelog
     86
     87
     88
     89
    8690
    8791#### 2.0.2
  • wp-instagram-widget/tags/2.0.3/readme.txt

    r1801414 r1839618  
    33Tags: instagram, widget, photos, photography, hipster, sidebar, widgets, simple
    44Requires at least: 4.4
    5 Tested up to: 4.9.1
    6 Stable tag: 2.0.2
     5Tested up to: 4.9.
     6Stable tag: 2.0.
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    8080
    8181== Changelog ==
     82
     83
     84
     85
    8286
    8387= 2.0.2 =
  • wp-instagram-widget/tags/2.0.3/wp-instagram-widget.php

    r1801414 r1839618  
    44Plugin URI: https://github.com/scottsweb/wp-instagram-widget
    55Description: A WordPress widget for showing your latest Instagram photos.
    6 Version: 2.0.2
     6Version: 2.0.
    77Author: Scott Evans
    88Author URI: https://scott.ee
     
    189189        $username = trim( strtolower( $username ) );
    190190
    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 ) ) ) ) {
    202204
    203205            $remote = wp_remote_get( $url );
     
    211213            }
    212214
    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] );
    215217            $insta_array = json_decode( $insta_json[0], true );
    216218
     
    219221            }
    220222
    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'];
    223225            } elseif ( isset( $insta_array['entry_data']['TagPage'][0]['graphql']['hashtag']['edge_hashtag_to_media']['edges'] ) ) {
    224226                $images = $insta_array['entry_data']['TagPage'][0]['graphql']['hashtag']['edge_hashtag_to_media']['edges'];
     
    234236
    235237            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                );
    291261            } // End foreach().
    292262
     
    294264            if ( ! empty( $instagram ) ) {
    295265                $instagram = base64_encode( serialize( $instagram ) );
    296                 set_transient( 'instagram-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 ) );
    297267            }
    298268        }
  • wp-instagram-widget/trunk/readme.md

    r1801414 r1839618  
    8484
    8585## Changelog
     86
     87
     88
     89
    8690
    8791#### 2.0.2
  • wp-instagram-widget/trunk/readme.txt

    r1801414 r1839618  
    33Tags: instagram, widget, photos, photography, hipster, sidebar, widgets, simple
    44Requires at least: 4.4
    5 Tested up to: 4.9.1
    6 Stable tag: 2.0.2
     5Tested up to: 4.9.
     6Stable tag: 2.0.
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    8080
    8181== Changelog ==
     82
     83
     84
     85
    8286
    8387= 2.0.2 =
  • wp-instagram-widget/trunk/wp-instagram-widget.php

    r1801414 r1839618  
    44Plugin URI: https://github.com/scottsweb/wp-instagram-widget
    55Description: A WordPress widget for showing your latest Instagram photos.
    6 Version: 2.0.2
     6Version: 2.0.
    77Author: Scott Evans
    88Author URI: https://scott.ee
     
    189189        $username = trim( strtolower( $username ) );
    190190
    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 ) ) ) ) {
    202204
    203205            $remote = wp_remote_get( $url );
     
    211213            }
    212214
    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] );
    215217            $insta_array = json_decode( $insta_json[0], true );
    216218
     
    219221            }
    220222
    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'];
    223225            } elseif ( isset( $insta_array['entry_data']['TagPage'][0]['graphql']['hashtag']['edge_hashtag_to_media']['edges'] ) ) {
    224226                $images = $insta_array['entry_data']['TagPage'][0]['graphql']['hashtag']['edge_hashtag_to_media']['edges'];
     
    234236
    235237            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                );
    291261            } // End foreach().
    292262
     
    294264            if ( ! empty( $instagram ) ) {
    295265                $instagram = base64_encode( serialize( $instagram ) );
    296                 set_transient( 'instagram-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 ) );
    297267            }
    298268        }
Note: See TracChangeset for help on using the changeset viewer.