PluginProbe
Automatic YouTube Gallery – Embed Auto-Updating YouTube Video Galleries, Feeds, Playlists & Channels / 2.3.8
Automatic YouTube Gallery – Embed Auto-Updating YouTube Video Galleries, Feeds, Playlists & Channels v2.3.8
2.9.1 2.9.0 trunk 1.0.0 1.1.0 1.2.0 1.3.0 1.4.0 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 2.0.0 2.1.0 2.2.0 2.3.2 2.3.3 2.3.5 2.3.6 2.3.8 2.3.9 2.4.3 All 37 releases
← All changes | includes/functions.php +118 -61 2.1.02.3.8 View file →
@@ -37,9 +37,9 @@
37 37 $attributes = shortcode_atts( $defaults, $args );
38 38
39 39 $attributes['post_id'] = 0;
40 40 if ( isset( $post->ID ) ) {
41 - $attributes['post_id'] = $post->ID;
41 + $attributes['post_id'] = (int) $post->ID;
42 42 }
43 43
44 44 $attributes['columns'] = min( 12, (int) $attributes['columns'] );
45 45 if ( empty( $attributes['columns'] ) ) {
@@ -82,8 +82,19 @@
82 82 $response = $youtube_api->query( $api_params );
83 83
84 84 // Process output
85 85 if ( ! isset( $response->error ) ) {
86 + // Store Gallery ID
87 + if ( $attributes['post_id'] > 0 && isset( $attributes['deeplinking'] ) && 1 == $attributes['deeplinking'] ) {
88 + $pages = get_option( 'ayg_gallery_page_ids', array() );
89 + $page_id = $attributes['post_id'];
90 +
91 + if ( ! in_array( $page_id, $pages ) ) {
92 + $pages[] = $page_id;
93 + update_option( 'ayg_gallery_page_ids', $pages );
94 + }
95 + }
96 +
86 97 // Enqueue dependencies
87 98 wp_enqueue_style( AYG_SLUG . '-public' );
88 99 wp_enqueue_script( AYG_SLUG . '-public' );
89 100
@@ -89,10 +100,10 @@
89 100
90 101 // Gallery
91 102 $videos = array();
92 103
93 - $gallery_id_from_url = get_query_var( 'ayg_gallery' );
94 - $video_id_from_url = get_query_var( 'ayg_video' );
104 + $gallery_id_from_url = get_query_var( 'ayg_gallery_id' );
105 + $video_id_from_url = get_query_var( 'ayg_video_id' );
95 106
96 107 if ( $attributes['uid'] == $gallery_id_from_url ) {
97 108 $video = ayg_db_get_video( $video_id_from_url );
98 109
@@ -137,9 +148,9 @@
137 148 ob_start();
138 149 include ayg_get_template( AYG_DIR . "public/templates/theme-{$theme}.php", $attributes['theme'] );
139 150 return ob_get_clean();
140 151 } else {
141 - return '<p class="ayg-error">' . $response->error_message . '</p>';
152 + return sprintf( '<div class="ayg ayg-error">%s</div>', wp_kses_post( $response->error_message ) );
142 153 }
143 154 }
144 155
145 156 /**
@@ -272,18 +283,8 @@
272 283 array( '%d' )
273 284 );
274 285 }
275 286 }
276 -
277 - // Store Page ID
278 - if ( ! is_admin() ) {
279 - if ( isset( $post->ID ) ) {
280 - $page_ids = get_option( 'ayg_gallery_page_ids', array() );
281 - $page_ids[] = (int) $post->ID;
282 -
283 - update_option( 'ayg_gallery_page_ids', array_unique( $page_ids ) );
284 - }
285 - }
286 287 }
287 288
288 289 /**
289 290 * Get a single video record from our custom database table "{$wpdb->prefix}ayg_videos"
@@ -319,8 +320,10 @@
319 320 *
320 321 * @since 2.1.0
321 322 */
322 323 function ayg_delete_cache() {
324 + delete_option( 'ayg_gallery_page_ids' );
325 +
323 326 // Get the current list of transients
324 327 $transient_keys = get_option( 'ayg_transient_keys', array() );
325 328
326 329 // For each key, delete that transient
@@ -357,40 +360,46 @@
357 360 'api_key' => '',
358 361 'development_mode' => 1
359 362 ),
360 363 'ayg_gallery_settings' => array(
361 - 'theme' => 'classic',
362 - 'columns' => 3,
363 - 'per_page' => 12,
364 - 'thumb_ratio' => 56.25,
365 - 'thumb_title' => 1,
366 - 'thumb_title_length' => 0,
367 - 'thumb_excerpt' => 1,
368 - 'thumb_excerpt_length' => 75,
369 - 'pagination' => 1,
370 - 'pagination_type' => 'more'
364 + 'theme' => 'classic',
365 + 'columns' => 3,
366 + 'per_page' => 12,
367 + 'thumb_ratio' => 56.25,
368 + 'thumb_title' => 1,
369 + 'thumb_title_length' => 0,
370 + 'thumb_excerpt' => 1,
371 + 'thumb_excerpt_length' => 75,
372 + 'pagination' => 1,
373 + 'pagination_type' => 'more',
374 + 'more_button_label' => __( 'Load More', 'automatic-youtube-gallery' ),
375 + 'previous_button_label' => __( 'Previous', 'automatic-youtube-gallery' ),
376 + 'next_button_label' => __( 'Next', 'automatic-youtube-gallery' )
371 377 ),
372 378 'ayg_player_settings' => array(
373 - 'player_ratio' => 56.25,
374 - 'player_title' => 1,
375 - 'player_description' => 1,
376 - 'autoplay' => 0,
377 - 'autoadvance' => 1,
378 - 'loop' => 0,
379 - 'controls' => 1,
380 - 'modestbranding' => 1,
381 - 'cc_load_policy' => 0,
382 - 'iv_load_policy' => 0,
383 - 'hl' => '',
384 - 'cc_lang_pref' => ''
379 + 'player_ratio' => 56.25,
380 + 'player_title' => 1,
381 + 'player_description' => 1,
382 + 'autoplay' => 0,
383 + 'autoadvance' => 1,
384 + 'loop' => 0,
385 + 'muted' => 0,
386 + 'controls' => 1,
387 + 'modestbranding' => 1,
388 + 'cc_load_policy' => 0,
389 + 'iv_load_policy' => 0,
390 + 'hl' => '',
391 + 'cc_lang_pref' => '',
392 + 'privacy_enhanced_mode' => 0,
393 + 'origin' => 0
385 394 ),
386 395 'ayg_livestream_settings' => array(
387 396 'fallback_message' => __( 'Sorry, but the channel is not currently streaming live content. Please check back later.', 'automatic-youtube-gallery' )
388 397 ),
389 - 'ayg_privacy_settings' => array(
390 - 'cookie_consent' => 0,
391 - 'consent_message' => __( 'Please accept YouTube cookies to play this video. By accepting you will be accessing content from YouTube, a service provided by an external third party.', 'automatic-youtube-gallery' ),
392 - 'button_label' => __( 'Accept', 'automatic-youtube-gallery' )
398 + 'ayg_privacy_settings' => array(
399 + 'cookie_consent' => 0,
400 + 'consent_message' => __( 'Please accept YouTube cookies to play this video. By accepting you will be accessing content from YouTube, a service provided by an external third party.', 'automatic-youtube-gallery' ),
401 + 'button_label' => __( 'Accept', 'automatic-youtube-gallery' )
393 402 )
394 403 );
395 404
396 405 return $defaults;
@@ -503,14 +512,14 @@
503 512 'label' => __( 'Cache Duration', 'automatic-youtube-gallery' ),
504 513 'description' => __( 'Specifies how frequently we should check your YouTube source for new videos/updates.', 'automatic-youtube-gallery' ),
505 514 'type' => 'select',
506 515 'options' => array(
507 - '900' => __( '15 minutes', 'automatic-youtube-gallery' ),
508 - '1800' => __( '30 minutes', 'automatic-youtube-gallery' ),
516 + '900' => __( '15 Minutes', 'automatic-youtube-gallery' ),
517 + '1800' => __( '30 Minutes', 'automatic-youtube-gallery' ),
509 518 '3600' => __( '1 Hour', 'automatic-youtube-gallery' ),
510 519 '86400' => __( '1 Day', 'automatic-youtube-gallery' ),
511 520 '604800' => __( '1 Week', 'automatic-youtube-gallery' ),
512 - '2419200' => __( ' 1Month', 'automatic-youtube-gallery' )
521 + '2419200' => __( '1 Month', 'automatic-youtube-gallery' )
513 522 ),
514 523 'value' => 86400,
515 524 'sanitize_callback' => 'intval'
516 525 )
@@ -541,9 +550,9 @@
541 550 $fields = array(
542 551 array(
543 552 'name' => 'theme',
544 553 'label' => __( 'Select Theme (Layout)', 'automatic-youtube-gallery' ),
545 - 'description' => ( ayg_fs()->is_not_paying() ? sprintf( __( '<a href="%s">Upgrade Pro</a> for more themes (Inline, Popup, Slider, Playlist).', 'automatic-youtube-gallery' ), esc_url( ayg_fs()->get_upgrade_url() ) ) : '' ),
554 + 'description' => ( ayg_fs()->is_not_paying() ? sprintf( __( '<a href="%s">Upgrade Pro</a> for more themes (Popup, Inline, Slider, Playlist).', 'automatic-youtube-gallery' ), esc_url( ayg_fs()->get_upgrade_url() ) ) : '' ),
546 555 'type' => 'select',
547 556 'options' => array(
548 557 'classic' => __( 'Classic', 'automatic-youtube-gallery' )
549 558 ),
@@ -636,8 +645,32 @@
636 645
637 646 ),
638 647 'value' => $gallery_settings['pagination_type'],
639 648 'sanitize_callback' => 'sanitize_key'
649 + ),
650 + array(
651 + 'name' => 'more_button_label',
652 + 'label' => __( 'More Button Label', 'automatic-youtube-gallery' ),
653 + 'description' => __( 'Enter the more button label text.', 'automatic-youtube-gallery' ),
654 + 'type' => 'text',
655 + 'value' => isset( $gallery_settings['more_button_label'] ) ? $gallery_settings['more_button_label'] : __( 'Load More', 'automatic-youtube-gallery' ),
656 + 'sanitize_callback' => 'sanitize_text_field'
657 + ),
658 + array(
659 + 'name' => 'previous_button_label',
660 + 'label' => __( 'Previous Button Label', 'automatic-youtube-gallery' ),
661 + 'description' => __( 'Enter the previous button label text.', 'automatic-youtube-gallery' ),
662 + 'type' => 'text',
663 + 'value' => isset( $gallery_settings['previous_button_label'] ) ? $gallery_settings['previous_button_label'] : __( 'Previous', 'automatic-youtube-gallery' ),
664 + 'sanitize_callback' => 'sanitize_text_field'
665 + ),
666 + array(
667 + 'name' => 'next_button_label',
668 + 'label' => __( 'Next Button Label', 'automatic-youtube-gallery' ),
669 + 'description' => __( 'Enter the next button label text.', 'automatic-youtube-gallery' ),
670 + 'type' => 'text',
671 + 'value' => isset( $gallery_settings['next_button_label'] ) ? $gallery_settings['next_button_label'] : __( 'Next', 'automatic-youtube-gallery' ),
672 + 'sanitize_callback' => 'sanitize_text_field'
640 673 )
641 674 );
642 675
643 676 return apply_filters( 'ayg_gallery_settings_fields', $fields );
@@ -658,9 +691,9 @@
658 691 if ( count( $words_array ) > $words_count ) {
659 692 $words_array[ $words_count ] = '<span class="ayg-player-description-dots">...</span></span><span class="ayg-player-description-more">' . $words_array[ $words_count ];
660 693
661 694 $description = '<span class="ayg-player-description-less">' . implode( ' ', $words_array ) . '</span>';
662 - $description .= '<a href="javascript:void(0);" class="ayg-player-description-toggle-btn">[+] ' . __( 'Show More', 'automatic-youtube-gallery' ) . '</a>';
695 + $description .= '<a href="#" class="ayg-player-description-toggle-btn">[+] ' . __( 'Show More', 'automatic-youtube-gallery' ) . '</a>';
663 696 }
664 697
665 698 $description = nl2br( $description );
666 699 $description = make_clickable( $description );
@@ -728,10 +761,18 @@
728 761 'description' => __( 'In the case of a single video player, plays the initial video again and again. In the case of a gallery, plays the entire list in the gallery and then starts again at the first video.', 'automatic-youtube-gallery' ),
729 762 'type' => 'checkbox',
730 763 'value' => $player_settings['loop'],
731 764 'sanitize_callback' => 'intval'
732 - ),
765 + ),
733 766 array(
767 + 'name' => 'muted',
768 + 'label' => __( 'Muted', 'automatic-youtube-gallery' ),
769 + 'description' => __( 'Check this option to turn OFF the audio output of the video by default.', 'automatic-youtube-gallery' ),
770 + 'type' => 'checkbox',
771 + 'value' => isset( $player_settings['muted'] ) ? $player_settings['muted'] : 0,
772 + 'sanitize_callback' => 'intval'
773 + ),
774 + array(
734 775 'name' => 'controls',
735 776 'label' => __( 'Show Player Controls', 'automatic-youtube-gallery' ),
736 777 'description' => __( 'Uncheck this option to hide the video player controls.', 'automatic-youtube-gallery' ),
737 778 'type' => 'checkbox',
@@ -782,9 +823,25 @@
782 823 ),
783 824 'type' => 'text',
784 825 'value' => $player_settings['cc_lang_pref'],
785 826 'sanitize_callback' => 'sanitize_text_field'
786 - )
827 + ),
828 + array(
829 + 'name' => 'privacy_enhanced_mode',
830 + 'label' => __( 'Privacy Enhanced Mode', 'automatic-youtube-gallery' ),
831 + 'description' => __( "Prevent YouTube from leaving tracking cookies on your visitor's browsers unless they actually play the videos. Please uncheck this option if you see errors while testing your playlist embeds or watching your videos on mobile.", 'automatic-youtube-gallery' ),
832 + 'type' => 'checkbox',
833 + 'value' => isset( $player_settings['privacy_enhanced_mode'] ) ? $player_settings['privacy_enhanced_mode'] : 0,
834 + 'sanitize_callback' => 'intval'
835 + ),
836 + array(
837 + 'name' => 'origin',
838 + 'label' => __( 'Extra Player Security', 'automatic-youtube-gallery' ),
839 + 'description' => __( 'Add site origin information with each embed code as an extra security measure. In YouTube\'s own words, checking this option "protects against malicious third-party JavaScript being injected into your page and hijacking control of your YouTube player."', 'automatic-youtube-gallery' ),
840 + 'type' => 'checkbox',
841 + 'value' => isset( $player_settings['origin'] ) ? $player_settings['origin'] : 0,
842 + 'sanitize_callback' => 'intval'
843 + ),
787 844 );
788 845
789 846 return $fields;
790 847 }
@@ -793,14 +850,14 @@
793 850 /**
794 851 * Get a single video page URL.
795 852 *
796 853 * @since 2.1.0
797 - * @param string $video_id YouTube Video ID.
798 - * @param array $args An array of gallery options.
799 - * @return string Single video URL.
854 + * @param stdClass $video YouTube video object.
855 + * @param array $args An array of gallery options.
856 + * @return string Single video URL.
800 857 */
801 -function ayg_get_single_video_url( $video_id, $attributes ) {
802 - return apply_filters( 'ayg_single_video_url', '', $video_id, $attributes );
858 +function ayg_get_single_video_url( $video, $attributes ) {
859 + return apply_filters( 'ayg_single_video_url', '', $video, $attributes );
803 860 }
804 861
805 862 /**
806 863 * Get filtered php template file path.
@@ -830,22 +887,22 @@
830 887 return uniqid() . ++$ayg_uniqid;
831 888 }
832 889
833 890 /**
834 - * Check if Yoast SEO plugin is active.
891 + * Get YouTube domain.
835 892 *
836 - * @since 2.1.0
837 - * @return bool $has_yoast True if the Yoast plugin is installed and active, false if not.
893 + * @since 2.3.0
894 + * @return string YouTube embed domain.
838 895 */
839 -function ayg_has_yoast() {
840 - $has_yoast = false;
896 +function ayg_get_youtube_domain() {
897 + $player_settings = get_option( 'ayg_player_settings' );
841 898
842 - $active_plugins = apply_filters( 'active_plugins', get_option( 'active_plugins' ) );
843 - if ( in_array( 'wordpress-seo/wp-seo.php', $active_plugins ) || in_array( 'wordpress-seo-premium/wp-seo-premium.php', $active_plugins ) ) {
844 - $has_yoast = true;
899 + $domain = 'https://www.youtube.com';
900 + if ( isset( $player_settings['privacy_enhanced_mode'] ) && ! empty( $player_settings['privacy_enhanced_mode'] ) ) {
901 + $domain = 'https://www.youtube-nocookie.com';
845 902 }
846 903
847 - return $has_yoast;
904 + return $domain;
848 905 }
849 906
850 907 /**
851 908 * Inserts a new associative array after another associative array key.