PluginProbe
Automatic YouTube Gallery – Embed Auto-Updating YouTube Video Galleries, Feeds, Playlists & Channels / 2.6.3
Automatic YouTube Gallery – Embed Auto-Updating YouTube Video Galleries, Feeds, Playlists & Channels v2.6.3
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 | public/public.php +104 -24 2.1.0 → 2.6.3 View file →
@@ -35,12 +35,27 @@
35 35 *
36 36 * @since 1.0.0
37 37 */
38 38 public function register_styles() {
39 + $player_settings = get_option( 'ayg_player_settings' );
40 +
41 + $deps = array();
42 + if ( isset( $player_settings['player_type'] ) && 'custom' == $player_settings['player_type'] ) {
43 + $deps[] = AYG_SLUG . '-plyr';
44 + }
45 +
39 46 wp_register_style(
47 + AYG_SLUG . '-plyr',
48 + AYG_URL . 'vendor/plyr/plyr.css',
49 + array(),
50 + '3.7.8',
51 + 'all'
52 + );
53 +
54 + wp_register_style(
40 55 AYG_SLUG . '-public',
41 - AYG_URL . 'public/assets/css/public.css',
42 - array(),
56 + AYG_URL . 'public/assets/css/public.min.css',
57 + $deps,
43 58 AYG_VERSION,
44 59 'all'
45 60 );
46 61 }
@@ -50,45 +65,84 @@
50 65 *
51 66 * @since 1.0.0
52 67 */
53 68 public function register_scripts() {
69 + $strings_settings = get_option( 'ayg_strings_settings' );
70 + $gallery_settings = get_option( 'ayg_gallery_settings' );
71 + $player_settings = get_option( 'ayg_player_settings' );
72 + $privacy_settings = get_option( 'ayg_privacy_settings' );
73 +
74 + $deps = array( 'jquery' );
75 + if ( isset( $player_settings['player_type'] ) && 'custom' == $player_settings['player_type'] ) {
76 + $deps[] = AYG_SLUG . '-plyr';
77 + }
78 +
54 79 wp_register_script(
80 + AYG_SLUG . '-plyr',
81 + AYG_URL . 'vendor/plyr/plyr.polyfilled.js',
82 + array(),
83 + '3.7.8',
84 + array( 'strategy' => 'defer' )
85 + );
86 +
87 + wp_register_script(
55 88 AYG_SLUG . '-public',
56 - AYG_URL . 'public/assets/js/public.js',
57 - array( 'jquery' ),
89 + AYG_URL . 'public/assets/js/public.min.js',
90 + $deps,
58 91 AYG_VERSION,
59 - false
92 + array( 'strategy' => 'defer' )
60 93 );
61 94
95 + $scroll_top_offset = ( isset( $gallery_settings['scroll_top_offset'] ) && ! empty( $gallery_settings['scroll_top_offset'] ) ) ? (int) $gallery_settings['scroll_top_offset'] : 10;
96 + $scroll_top_offset = apply_filters( 'ayg_gallery_scrolltop_offset', $scroll_top_offset ); // Backward compatibility to 2.4.3
97 + $scroll_top_offset = apply_filters( 'ayg_gallery_scroll_top_offset', $scroll_top_offset );
98 +
99 + $show_more_label = ! empty( $strings_settings['show_more_label'] ) ? sanitize_text_field( $strings_settings['show_more_label'] ) : __( 'Show More', 'automatic-youtube-gallery' );
100 + $show_less_label = ! empty( $strings_settings['show_less_label'] ) ? sanitize_text_field( $strings_settings['show_less_label'] ) : __( 'Show Less', 'automatic-youtube-gallery' );
101 +
62 102 $script_args = array(
63 - 'current_url' => get_permalink(),
64 - 'ajax_url' => admin_url( 'admin-ajax.php' ),
65 - 'ajax_nonce' => wp_create_nonce( 'ayg_ajax_nonce' ),
66 - 'gallery_id' => get_query_var( 'ayg_gallery' ),
67 - 'video_id' => get_query_var( 'ayg_video' ),
68 - 'cookie_consent'=> 0,
69 - 'top_offset' => apply_filters( 'ayg_gallery_scrolltop_offset', 10 ),
70 - 'i18n' => array(
71 - 'show_more' => '[+] ' . __( 'Show More', 'automatic-youtube-gallery' ),
72 - 'show_less' => '[-] ' . __( 'Show Less', 'automatic-youtube-gallery' )
103 + 'ajax_url' => admin_url( 'admin-ajax.php' ),
104 + 'ajax_nonce' => wp_create_nonce( 'ayg_ajax_nonce' ),
105 + 'current_page_url' => get_permalink(),
106 + 'current_gallery_id' => get_query_var( 'ayg_gallery_id' ),
107 + 'player_type' => isset( $player_settings['player_type'] ) ? sanitize_text_field( $player_settings['player_type'] ) : 'youtube',
108 + 'player_color' => isset( $player_settings['player_color'] ) ? sanitize_text_field( $player_settings['player_color'] ) : '#00b3ff',
109 + 'privacy_enhanced_mode' => isset( $player_settings['privacy_enhanced_mode'] ) ? (int) $player_settings['privacy_enhanced_mode'] : 0,
110 + 'origin' => '',
111 + 'cookieconsent' => 0,
112 + 'top_offset' => $scroll_top_offset,
113 + 'i18n' => array(
114 + 'show_more' => $show_more_label,
115 + 'show_less' => $show_less_label
73 116 )
74 117 );
75 118
119 + if ( isset( $player_settings['origin'] ) && ! empty( $player_settings['origin'] ) ) {
120 + $url_parts = parse_url( site_url() );
121 + $script_args['origin'] = $url_parts['scheme'] . '://' . $url_parts['host'];
122 + }
123 +
76 124 if ( ! isset( $_COOKIE['ayg_gdpr_consent'] ) ) {
77 - $privacy_settings = get_option( 'ayg_privacy_settings' );
78 -
79 125 if ( ! empty( $privacy_settings['cookie_consent'] ) && ! empty( $privacy_settings['consent_message'] ) && ! empty( $privacy_settings['button_label'] ) ) {
80 - $script_args['cookie_consent'] = 1;
81 - $script_args['consent_message'] = wp_kses_post( trim( $privacy_settings['consent_message'] ) );
82 - $script_args['button_label'] = esc_html( $privacy_settings['button_label'] );
126 + $script_args['cookieconsent'] = 1;
127 + $script_args['cookieconsent_message'] = wp_kses_post( trim( $privacy_settings['consent_message'] ) );
128 + $script_args['cookieconsent_button_label'] = esc_html( $privacy_settings['button_label'] );
83 129 }
84 130 }
85 131
86 132 wp_localize_script(
87 133 AYG_SLUG . '-public',
88 - 'ayg_public',
134 + 'ayg_config',
89 135 $script_args
90 136 );
137 +
138 + wp_register_script(
139 + AYG_SLUG . '-theme-classic',
140 + AYG_URL . 'public/assets/js/theme-classic.min.js',
141 + array( 'jquery' ),
142 + AYG_VERSION,
143 + array( 'strategy' => 'defer' )
144 + );
91 145 }
92 146
93 147 /**
94 148 * Enqueue Gutenberg block assets for backend editor.
@@ -101,9 +155,11 @@
101 155 wp_enqueue_style( AYG_SLUG . '-public' );
102 156
103 157 // Scripts
104 158 $this->register_scripts();
159 +
105 160 wp_enqueue_script( AYG_SLUG . '-public' );
161 + wp_enqueue_script( AYG_SLUG . '-theme-classic' );
106 162 }
107 163
108 164 /**
109 165 * Process the shortcode [automatic_youtube_gallery].
@@ -109,11 +165,16 @@
109 165 * Process the shortcode [automatic_youtube_gallery].
110 166 *
111 167 * @since 1.0.0
112 168 * @param array $attributes An associative array of attributes.
169 + * @param string $content Enclosing content.
113 170 * @return string Shortcode HTML output.
114 171 */
115 - public function shortcode_automatic_youtube_gallery( $attributes ) {
172 + public function shortcode_automatic_youtube_gallery( $attributes, $content = null ) {
173 + if ( ! empty( $content ) ) {
174 + $attributes['content'] = $content;
175 + }
176 +
116 177 return ayg_build_gallery( $attributes );
117 178 }
118 179
119 180 /**
@@ -120,9 +181,9 @@
120 181 * Load more videos.
121 182 *
122 183 * @since 1.0.0
123 184 */
124 - public function ajax_callback_load_more_videos() {
185 + public function ajax_callback_load_videos() {
125 186 // Security check
126 187 check_ajax_referer( 'ayg_ajax_nonce', 'security' );
127 188
128 189 // Proceed safe
@@ -130,16 +191,22 @@
130 191 $attributes = array_map( 'sanitize_text_field', $_POST );
131 192 $source_type = $attributes['type'];
132 193
133 194 $api_params = array(
195 + 'uid' => $attributes['uid'],
134 196 'type' => $source_type,
135 197 'src' => $attributes['src'],
136 198 'order' => $attributes['order'], // works only when type=search
199 + 'limit' => (int) $attributes['limit'],
137 200 'maxResults' => (int) $attributes['per_page'],
138 201 'cache' => (int) $attributes['cache'],
139 202 'pageToken' => $attributes['pageToken']
140 203 );
141 204
205 + if ( ! empty( $attributes['searchTerm'] ) ) {
206 + $api_params['searchTerm'] = $attributes['searchTerm'];
207 + }
208 +
142 209 $youtube_api = new AYG_YouTube_API();
143 210 $response = $youtube_api->query( $api_params );
144 211
145 212 if ( ! isset( $response->error ) ) {
@@ -144,16 +211,29 @@
144 211
145 212 if ( ! isset( $response->error ) ) {
146 213 if ( isset( $response->page_info ) ) {
147 214 $json = $response->page_info;
215 + $json['message'] = sprintf(
216 + _n( '%s video found matching your query.', '%s videos found matching your query.', $json['videos_found'], 'automatic-youtube-gallery' ),
217 + number_format_i18n( $json['videos_found'] )
218 + );
148 219 }
149 220
150 221 if ( isset( $response->videos ) ) {
151 222 $videos = $response->videos;
223 + $columns = (int) $attributes['columns'];
152 224
153 225 ob_start();
154 226 foreach ( $videos as $index => $video ) {
155 - echo'<div class="ayg-item ayg-col ayg-col-' . (int) $attributes['columns'] . '">';
227 + $classes = array();
228 + $classes[] = 'ayg-video';
229 + $classes[] = 'ayg-video-' . $video->id;
230 + $classes[] = 'ayg-col';
231 + $classes[] = 'ayg-col-' . $columns;
232 + if ( $columns > 3 ) $classes[] = 'ayg-col-sm-3';
233 + if ( $columns > 2 ) $classes[] = 'ayg-col-xs-2';
234 +
235 + echo'<div class="' . implode( ' ', $classes ) . '">';
156 236 the_ayg_gallery_thumbnail( $video, $attributes );
157 237 echo '</div>';
158 238 }
159 239 $json['html'] = ob_get_clean();