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 +222 -89 1.2.02.6.4 View file →
@@ -48,21 +48,20 @@
48 48 */
49 49 protected $fields = array();
50 50
51 51 /**
52 - * Add a settings menu for the plugin.
52 + * Add "Settings" menu.
53 53 *
54 54 * @since 1.0.0
55 55 */
56 - public function add_settings_menu() {
57 - add_menu_page(
58 - __( 'Automatic YouTube Gallery', 'automatic-youtube-gallery' ),
59 - __( 'YouTube Gallery', 'automatic-youtube-gallery' ),
60 - 'manage_options',
61 - 'automatic-youtube-gallery',
62 - array( $this, 'display_settings_form' ),
63 - 'dashicons-video-alt3',
64 - 10
56 + public function admin_menu() {
57 + add_submenu_page(
58 + 'automatic-youtube-gallery',
59 + __( 'Settings', 'automatic-youtube-gallery' ),
60 + __( 'Settings', 'automatic-youtube-gallery' ),
61 + 'manage_options',
62 + 'automatic-youtube-gallery-settings',
63 + array( $this, 'display_settings_form' )
65 64 );
66 65 }
67 66
68 67 /**
@@ -70,13 +69,8 @@
70 69 *
71 70 * @since 1.0.0
72 71 */
73 72 public function display_settings_form() {
74 - $gallery_settings = get_option( 'ayg_gallery_settings' );
75 -
76 - $active_tab = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $this->tabs ) ? sanitize_text_field( $_GET['tab'] ) : 'general';
77 - $active_theme = $gallery_settings['theme'];
78 -
79 73 require_once AYG_DIR . 'admin/templates/settings.php';
80 74 }
81 75
82 76 /**
@@ -100,11 +94,13 @@
100 94 * @return array $tabs Setting tabs array.
101 95 */
102 96 public function get_tabs() {
103 97 $tabs = array(
104 - 'general' => __( 'General', 'automatic-youtube-gallery' ),
105 - 'gallery' => __( 'Gallery', 'automatic-youtube-gallery' ),
106 - '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' )
107 103 );
108 104
109 105 return apply_filters( 'ayg_settings_tabs', $tabs );
110 106 }
@@ -117,22 +113,49 @@
117 113 */
118 114 public function get_sections() {
119 115 $sections = array(
120 116 array(
121 - 'id' => 'ayg_general_settings',
122 - 'title' => __( 'General Settings', 'automatic-youtube-gallery' ),
123 - 'tab' => 'general'
117 + 'id' => 'ayg_general_settings',
118 + 'title' => __( 'General Settings', 'automatic-youtube-gallery' ),
119 + 'description' => '',
120 + 'tab' => 'general',
121 + 'page' => 'ayg_general_settings'
124 122 ),
125 123 array(
126 - 'id' => 'ayg_gallery_settings',
127 - 'title' => __( 'Gallery Settings', 'automatic-youtube-gallery' ),
128 - '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'
129 129 ),
130 130 array(
131 - 'id' => 'ayg_player_settings',
132 - 'title' => __( 'Player Settings', 'automatic-youtube-gallery' ),
133 - 'tab' => 'player'
134 - )
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 + ),
135 158 );
136 159
137 160 return apply_filters( 'ayg_settings_sections', $sections );
138 161 }
@@ -142,25 +165,166 @@
142 165 *
143 166 * @since 1.0.0
144 167 * @return array $fields Setting fields array.
145 168 */
146 - public function get_fields() {
147 - $fields = array(
148 - 'ayg_general_settings' => array(
149 - array(
150 - 'name' => 'api_key',
151 - 'label' => __( 'Youtube API Key', 'automatic-youtube-gallery' ),
152 - 'description' => sprintf(
153 - __( 'Follow <a href="%s" target="_blank">this guide</a> to get your own API key.', 'automatic-youtube-gallery' ),
154 - 'https://plugins360.com/automatic-youtube-gallery/how-to-get-youtube-api-key/'
155 - ),
156 - 'type' => 'text',
157 - 'sanitize_callback' => 'sanitize_text_field'
158 - )
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'
159 181 ),
160 - 'ayg_gallery_settings' => ayg_get_gallery_settings_fields(),
161 - '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'
162 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 + );
163 327
164 328 return apply_filters( 'ayg_settings_fields', $fields );
165 329 }
166 330
@@ -171,10 +335,9 @@
171 335 */
172 336 public function initialize_settings() {
173 337 // Register settings sections & fields
174 338 foreach ( $this->sections as $section ) {
175 -
176 - $page_hook = "ayg_{$section['tab']}_settings";
339 + $page_hook = isset( $section['page'] ) ? $section['page'] : $section['id'];
177 340
178 341 // Sections
179 342 if ( false == get_option( $section['id'] ) ) {
180 343 add_option( $section['id'] );
@@ -231,9 +394,9 @@
231 394 */
232 395 public function settings_section_callback( $args ) {
233 396 foreach ( $this->sections as $section ) {
234 397 if ( $section['id'] == $args['id'] ) {
235 - printf( '<div class="inside">%s</div>', sanitize_text_field( $section['description'] ) );
398 + printf( '<div class="inside">%s</div>', wp_kses_post( $section['description'] ) );
236 399 break;
237 400 }
238 401 }
239 402 }
@@ -559,45 +722,11 @@
559 722 }
560 723 }
561 724
562 725 return false;
563 - }
726 + }
564 727
565 728 /**
566 - * Dump our plugin transients.
567 - *
568 - * @since 1.0.0
569 - */
570 - public function delete_cache() {
571 - // If delete cache button clicked
572 - if ( isset( $_POST[ 'ayg_delete_cache' ] ) ) {
573 -
574 - // Run a quick security check
575 - if ( ! check_admin_referer( 'ayg_delete_cache_nonce', 'ayg_delete_cache_nonce' ) ) {
576 - return;
577 - }
578 -
579 - // Get the current list of transients
580 - $transient_keys = get_option( 'ayg_transient_keys', array() );
581 -
582 - // For each key, delete that transient
583 - foreach ( $transient_keys as $key ) {
584 - delete_transient( $key );
585 - }
586 -
587 - // Reset our DB value
588 - update_option( 'ayg_transient_keys', array() );
589 -
590 - // Redirect
591 - $base_url = admin_url( 'admin.php?page=automatic-youtube-gallery' );
592 - $redirect = add_query_arg( 'cache_deleted', 1, $base_url );
593 -
594 - wp_redirect( $redirect );
595 - exit();
596 - }
597 - }
598 -
599 - /**
600 729 * Get the value of a settings field
601 730 *
602 731 * @since 1.0.0
603 732 * @param string $option Settings field name.
@@ -613,17 +742,21 @@
613 742 }
614 743
615 744 return $default;
616 745 }
617 -
746 +
618 747 /**
619 - * Display Admin Notices.
748 + * Dump our plugin transients.
620 749 *
621 - * @since 1.0.0
750 + * @since 1.3.0
622 751 */
623 - public function admin_notices() {
624 - if ( isset( $_GET['cache_deleted'] ) ) {
625 - printf( '<div class="notice notice-success"><p>%s</p></div>', __( 'Cache Deleted.', 'automatic-youtube-gallery' ) );
626 - }
627 - }
752 + public function ajax_callback_delete_cache() {
753 + check_ajax_referer( 'ayg_ajax_nonce', 'security' );
754 +
755 + if ( current_user_can( 'manage_options' ) ) {
756 + ayg_delete_cache();
757 + }
758 +
759 + wp_die();
760 + }
628 761
629 762 }