• > 'a', 'html_atts' => [ 'target' => '_blank', 'href' => 'https://instagram.com/p/' . $photo['code'], ], 'img_atts' => [ 'alt' => esc_attr( $photo['description'] ), 'title' => esc_attr( $photo['description'] ), ], ] ) ?>
  • |', $source['body'], $matches ); if ( ! isset( $matches[1] ) ) { return null; } $json_data = "{{$matches[1]}}"; $json_data = json_decode( $json_data, true ); if ( ! $json_data ) { return new WP_Error( 'bad_json', __( 'Instagram has returned invalid data.', 'ct' ) ); } // Get instagram images. if ( isset( $json_data['entry_data']['ProfilePage'][0]['graphql']['user']['edge_owner_to_timeline_media']['edges'] ) ) { $images = $json_data['entry_data']['ProfilePage'][0]['graphql']['user']['edge_owner_to_timeline_media']['edges']; } else { return $instagram_photos; } if ( count( $images ) ) { foreach ( $images as $image ) { if ( count( $instagram_photos ) > $items ) { break; } $image = $image['node']; if ( ! isset( $image['edge_media_to_caption'] ) ) { $image['edge_media_to_caption'] = array( 'edges' => array( array( 'node' => array( 'text' => '', ), ), ), ); } if ( empty( $iamge['edge_media_to_caption']['edges'] ) ) { $image['edge_media_to_caption'] = array( 'edges' => array( array( 'node' => array( 'text' => '', ), ), ), ); } $instagram_photos[] = array( 'code' => $image['shortcode'], 'img' => $image['thumbnail_src'], 'likes' => $image['edge_liked_by']['count'], 'description' => $image['edge_media_to_caption']['edges'][0]['node']['text'], 'is_video' => $image['is_video'], ); } } set_transient( $transient_name, $instagram_photos, 7 * 24 * HOUR_IN_SECONDS ); return $instagram_photos; }