PluginProbe
Automatic YouTube Gallery – Embed Auto-Updating YouTube Video Galleries, Feeds, Playlists & Channels / 2.6.4
Automatic YouTube Gallery – Embed Auto-Updating YouTube Video Galleries, Feeds, Playlists & Channels v2.6.4
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 | admin/settings.php +203 -46 1.5.02.6.4 View file →
@@ -69,13 +69,8 @@
69 69 *
70 70 * @since 1.0.0
71 71 */
72 72 public function display_settings_form() {
73 - $gallery_settings = get_option( 'ayg_gallery_settings' );
74 -
75 - $active_tab = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $this->tabs ) ? sanitize_text_field( $_GET['tab'] ) : 'general';
76 - $active_theme = $gallery_settings['theme'];
77 -
78 73 require_once AYG_DIR . 'admin/templates/settings.php';
79 74 }
80 75
81 76 /**
@@ -99,11 +94,13 @@
99 94 * @return array $tabs Setting tabs array.
100 95 */
101 96 public function get_tabs() {
102 97 $tabs = array(
103 - 'general' => __( 'General', 'automatic-youtube-gallery' ),
104 - 'gallery' => __( 'Gallery', 'automatic-youtube-gallery' ),
105 - 'player' => __( 'Player', 'automatic-youtube-gallery' )
98 + 'general' => __( 'General', 'automatic-youtube-gallery' ),
99 + 'gallery' => __( 'Gallery', 'automatic-youtube-gallery' ),
100 + 'player' => __( 'Player', 'automatic-youtube-gallery' ),
101 + 'livestream' => __( 'Livestream', 'automatic-youtube-gallery' ),
102 + 'privacy' => __( 'GDPR Compliance', 'automatic-youtube-gallery' )
106 103 );
107 104
108 105 return apply_filters( 'ayg_settings_tabs', $tabs );
109 106 }
@@ -116,22 +113,49 @@
116 113 */
117 114 public function get_sections() {
118 115 $sections = array(
119 116 array(
120 - 'id' => 'ayg_general_settings',
121 - 'title' => __( 'General Settings', 'automatic-youtube-gallery' ),
122 - 'tab' => 'general'
117 + 'id' => 'ayg_general_settings',
118 + 'title' => __( 'General Settings', 'automatic-youtube-gallery' ),
119 + 'description' => '',
120 + 'tab' => 'general',
121 + 'page' => 'ayg_general_settings'
123 122 ),
124 123 array(
125 - 'id' => 'ayg_gallery_settings',
126 - 'title' => __( 'Gallery Settings', 'automatic-youtube-gallery' ),
127 - 'tab' => 'gallery'
124 + 'id' => 'ayg_strings_settings',
125 + 'title' => __( 'Button & Link Labels', 'automatic-youtube-gallery' ),
126 + 'description' => '',
127 + 'tab' => 'general',
128 + 'page' => 'ayg_strings_settings'
128 129 ),
129 130 array(
130 - 'id' => 'ayg_player_settings',
131 - 'title' => __( 'Player Settings', 'automatic-youtube-gallery' ),
132 - 'tab' => 'player'
133 - )
131 + 'id' => 'ayg_gallery_settings',
132 + 'title' => __( 'Gallery Settings', 'automatic-youtube-gallery' ),
133 + 'description' => '',
134 + 'tab' => 'gallery',
135 + 'page' => 'ayg_gallery_settings'
136 + ),
137 + array(
138 + 'id' => 'ayg_player_settings',
139 + 'title' => __( 'Player Settings', 'automatic-youtube-gallery' ),
140 + 'description' => '',
141 + 'tab' => 'player',
142 + 'page' => 'ayg_player_settings'
143 + ),
144 + array(
145 + 'id' => 'ayg_livestream_settings',
146 + 'title' => __( 'Livestream Settings', 'automatic-youtube-gallery' ),
147 + 'description' => '',
148 + 'tab' => 'livestream',
149 + 'page' => 'ayg_livestream_settings'
150 + ),
151 + array(
152 + 'id' => 'ayg_privacy_settings',
153 + 'title' => __( 'GDPR Compliance', 'automatic-youtube-gallery' ),
154 + 'description' => __( 'These options will help with privacy restrictions such as GDPR and the EU Cookie Law.', 'automatic-youtube-gallery' ),
155 + 'tab' => 'privacy',
156 + 'page' => 'ayg_privacy_settings'
157 + ),
134 158 );
135 159
136 160 return apply_filters( 'ayg_settings_sections', $sections );
137 161 }
@@ -141,25 +165,166 @@
141 165 *
142 166 * @since 1.0.0
143 167 * @return array $fields Setting fields array.
144 168 */
145 - public function get_fields() {
146 - $fields = array(
147 - 'ayg_general_settings' => array(
148 - array(
149 - 'name' => 'api_key',
150 - 'label' => __( 'Youtube API Key', 'automatic-youtube-gallery' ),
151 - 'description' => sprintf(
152 - __( 'Follow <a href="%s" target="_blank">this guide</a> to get your own API key.', 'automatic-youtube-gallery' ),
153 - 'https://plugins360.com/automatic-youtube-gallery/how-to-get-youtube-api-key/'
154 - ),
155 - 'type' => 'text',
156 - 'sanitize_callback' => 'sanitize_text_field'
157 - )
169 + public function get_fields() {
170 + // General Settings
171 + $fields['ayg_general_settings'] = array(
172 + array(
173 + 'name' => 'api_key',
174 + 'label' => __( 'Youtube API Key', 'automatic-youtube-gallery' ),
175 + 'description' => sprintf(
176 + __( 'Follow <a href="%s" target="_blank" rel="noopener noreferrer">this guide</a> to get your own API key.', 'automatic-youtube-gallery' ),
177 + 'https://plugins360.com/automatic-youtube-gallery/how-to-get-youtube-api-key/'
178 + ),
179 + 'type' => 'text',
180 + 'sanitize_callback' => 'sanitize_text_field'
158 181 ),
159 - 'ayg_gallery_settings' => ayg_get_gallery_settings_fields(),
160 - 'ayg_player_settings' => ayg_get_player_settings_fields()
182 + array(
183 + 'name' => 'lazyload',
184 + 'label' => __( 'Lazyload Images / Videos', 'automatic-youtube-gallery' ),
185 + 'description' => __( 'Enable this option to lazy load images and videos added by the plugin to enhance page load speed and performance. If you experience any issues with content display, try disabling this option.', 'automatic-youtube-gallery' ),
186 + 'type' => 'checkbox',
187 + 'sanitize_callback' => 'intval'
188 + ),
189 + array(
190 + 'name' => 'development_mode',
191 + 'label' => __( 'Development Mode', 'automatic-youtube-gallery' ),
192 + 'description' => __( 'Does not cache API results when checked. We strongly recommend disabling this option when your site is live.', 'automatic-youtube-gallery' ),
193 + 'type' => 'checkbox',
194 + 'sanitize_callback' => 'intval'
195 + )
196 + );
197 +
198 + // Strings Settings
199 + $fields['ayg_strings_settings'] = array(
200 + array(
201 + 'name' => 'more_button_label',
202 + 'label' => __( 'More Button Label', 'automatic-youtube-gallery' ),
203 + 'description' => __( 'Text for the "Load More" button when pagination type is set to "More Button".', 'automatic-youtube-gallery' ),
204 + 'type' => 'text',
205 + 'sanitize_callback' => 'sanitize_text_field'
206 + ),
207 + array(
208 + 'name' => 'previous_button_label',
209 + 'label' => __( 'Previous Button Label', 'automatic-youtube-gallery' ),
210 + 'description' => __( 'Text for the "Previous" button when pagination type is set to "Pager".', 'automatic-youtube-gallery' ),
211 + 'type' => 'text',
212 + 'sanitize_callback' => 'sanitize_text_field'
213 + ),
214 + array(
215 + 'name' => 'next_button_label',
216 + 'label' => __( 'Next Button Label', 'automatic-youtube-gallery' ),
217 + 'description' => __( 'Text for the "Next" button when pagination type is set to "Pager".', 'automatic-youtube-gallery' ),
218 + 'type' => 'text',
219 + 'sanitize_callback' => 'sanitize_text_field'
220 + ),
221 + array(
222 + 'name' => 'show_more_label',
223 + 'label' => __( 'Show More Label', 'automatic-youtube-gallery' ),
224 + 'description' => __( 'Text for the "Show More" link that expands the video description below the player.', 'automatic-youtube-gallery' ),
225 + 'type' => 'text',
226 + 'sanitize_callback' => 'sanitize_text_field'
227 + ),
228 + array(
229 + 'name' => 'show_less_label',
230 + 'label' => __( 'Show Less Label', 'automatic-youtube-gallery' ),
231 + 'description' => __( 'Text for the "Show Less" link that collapses the video description below the player.', 'automatic-youtube-gallery' ),
232 + 'type' => 'text',
233 + 'sanitize_callback' => 'sanitize_text_field'
234 + )
235 + );
236 +
237 + // Gallery Settings
238 + $gallery_settings = ayg_get_gallery_settings_fields();
239 +
240 + $gallery_settings[] = array(
241 + 'name' => 'scroll_top_offset',
242 + 'label' => __( 'Page Scroll Top Offset', 'automatic-youtube-gallery' ),
243 + 'description' => __( 'Set the top offset in pixels for scrolling to the video player after a thumbnail is clicked. Enter <code>-1</code> to disable automatic scrolling.', 'automatic-youtube-gallery' ),
244 + 'type' => 'text',
245 + 'sanitize_callback' => 'ayg_sanitize_int'
161 246 );
247 +
248 + $fields['ayg_gallery_settings'] = $gallery_settings;
249 +
250 + // Player Settings
251 + $player_settings = array(
252 + array(
253 + 'name' => 'player_type',
254 + 'label' => __( 'Player Type', 'automatic-youtube-gallery' ),
255 + 'description' => '',
256 + 'type' => 'radio',
257 + 'options' => array(
258 + 'youtube' => __( 'Native YouTube Embed', 'automatic-youtube-gallery' ),
259 + 'custom' => __( 'Custom Video Player', 'automatic-youtube-gallery' )
260 + ),
261 + 'sanitize_callback' => 'sanitize_text_field'
262 + ),
263 + array(
264 + 'name' => 'player_color',
265 + 'label' => __( 'Player Color', 'automatic-youtube-gallery' ),
266 + 'description' => __( 'Set the theme color for your video player.', 'automatic-youtube-gallery' ),
267 + 'type' => 'color',
268 + 'sanitize_callback' => 'sanitize_text_field'
269 + )
270 + );
271 +
272 + $player_settings = array_merge( $player_settings, ayg_get_player_settings_fields() );
273 +
274 + $player_settings[] = array(
275 + 'name' => 'privacy_enhanced_mode',
276 + 'label' => __( 'Privacy Enhanced Mode', 'automatic-youtube-gallery' ),
277 + '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' ),
278 + 'type' => 'checkbox',
279 + 'sanitize_callback' => 'intval'
280 + );
281 +
282 + $player_settings[] = array(
283 + 'name' => 'origin',
284 + 'label' => __( 'Extra Player Security', 'automatic-youtube-gallery' ),
285 + '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' ),
286 + 'type' => 'checkbox',
287 + 'sanitize_callback' => 'intval'
288 + );
289 +
290 + $fields['ayg_player_settings'] = $player_settings;
291 +
292 + // Livestream Settings
293 + $fields['ayg_livestream_settings'] = array(
294 + array(
295 + 'name' => 'fallback_message',
296 + 'label' => __( 'Fallback Message', 'automatic-youtube-gallery' ),
297 + 'description' => __( 'Enter your Custom HTML message that should be displayed when there is no video streaming live.', 'automatic-youtube-gallery' ),
298 + 'type' => 'wysiwyg',
299 + 'sanitize_callback' => 'wp_kses_post'
300 + )
301 + );
302 +
303 + // Privacy Settings
304 + $fields['ayg_privacy_settings'] = array(
305 + array(
306 + 'name' => 'cookie_consent',
307 + 'label' => __( 'Cookie Consent', 'automatic-youtube-gallery' ),
308 + 'description' => __( 'Ask for viewer consent to store YouTube cookies before showing videos.', 'automatic-youtube-gallery' ),
309 + 'type' => 'checkbox',
310 + 'sanitize_callback' => 'intval'
311 + ),
312 + array(
313 + 'name' => 'consent_message',
314 + 'label' => __( 'Consent Message', 'automatic-youtube-gallery' ),
315 + 'description' => '',
316 + 'type' => 'wysiwyg',
317 + 'sanitize_callback' => 'wp_kses_post'
318 + ),
319 + array(
320 + 'name' => 'button_label',
321 + 'label' => __( 'Button Label', 'automatic-youtube-gallery' ),
322 + 'description' => '',
323 + 'type' => 'text',
324 + 'sanitize_callback' => 'sanitize_text_field'
325 + )
326 + );
162 327
163 328 return apply_filters( 'ayg_settings_fields', $fields );
164 329 }
165 330
@@ -170,10 +335,9 @@
170 335 */
171 336 public function initialize_settings() {
172 337 // Register settings sections & fields
173 338 foreach ( $this->sections as $section ) {
174 -
175 - $page_hook = "ayg_{$section['tab']}_settings";
339 + $page_hook = isset( $section['page'] ) ? $section['page'] : $section['id'];
176 340
177 341 // Sections
178 342 if ( false == get_option( $section['id'] ) ) {
179 343 add_option( $section['id'] );
@@ -230,9 +394,9 @@
230 394 */
231 395 public function settings_section_callback( $args ) {
232 396 foreach ( $this->sections as $section ) {
233 397 if ( $section['id'] == $args['id'] ) {
234 - printf( '<div class="inside">%s</div>', sanitize_text_field( $section['description'] ) );
398 + printf( '<div class="inside">%s</div>', wp_kses_post( $section['description'] ) );
235 399 break;
236 400 }
237 401 }
238 402 }
@@ -585,21 +749,14 @@
585 749 *
586 750 * @since 1.3.0
587 751 */
588 752 public function ajax_callback_delete_cache() {
589 - check_ajax_referer( 'ayg_admin_ajax_nonce', 'security' );
753 + check_ajax_referer( 'ayg_ajax_nonce', 'security' );
590 754
591 - // Get the current list of transients
592 - $transient_keys = get_option( 'ayg_transient_keys', array() );
593 -
594 - // For each key, delete that transient
595 - foreach ( $transient_keys as $key ) {
596 - delete_transient( $key );
755 + if ( current_user_can( 'manage_options' ) ) {
756 + ayg_delete_cache();
597 757 }
598 758
599 - // Reset our DB value
600 - update_option( 'ayg_transient_keys', array() );
601 -
602 759 wp_die();
603 760 }
604 761
605 762 }