| @@ -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 | /** |
| @@ -121,33 +116,45 @@ | ||
| 121 | 116 | array( |
| 122 | 117 | 'id' => 'ayg_general_settings', |
| 123 | 118 | 'title' => __( 'General Settings', 'automatic-youtube-gallery' ), |
| 124 | 119 | 'description' => '', |
| 125 | - 'tab' => 'general' | |
| 120 | + 'tab' => 'general', | |
| 121 | + 'page' => 'ayg_general_settings' | |
| 126 | 122 | ), |
| 127 | 123 | array( |
| 124 | + 'id' => 'ayg_strings_settings', | |
| 125 | + 'title' => __( 'Button & Link Labels', 'automatic-youtube-gallery' ), | |
| 126 | + 'description' => '', | |
| 127 | + 'tab' => 'general', | |
| 128 | + 'page' => 'ayg_strings_settings' | |
| 129 | + ), | |
| 130 | + array( | |
| 128 | 131 | 'id' => 'ayg_gallery_settings', |
| 129 | 132 | 'title' => __( 'Gallery Settings', 'automatic-youtube-gallery' ), |
| 130 | 133 | 'description' => '', |
| 131 | - 'tab' => 'gallery' | |
| 134 | + 'tab' => 'gallery', | |
| 135 | + 'page' => 'ayg_gallery_settings' | |
| 132 | 136 | ), |
| 133 | 137 | array( |
| 134 | 138 | 'id' => 'ayg_player_settings', |
| 135 | 139 | 'title' => __( 'Player Settings', 'automatic-youtube-gallery' ), |
| 136 | 140 | 'description' => '', |
| 137 | - 'tab' => 'player' | |
| 141 | + 'tab' => 'player', | |
| 142 | + 'page' => 'ayg_player_settings' | |
| 138 | 143 | ), |
| 139 | 144 | array( |
| 140 | 145 | 'id' => 'ayg_livestream_settings', |
| 141 | 146 | 'title' => __( 'Livestream Settings', 'automatic-youtube-gallery' ), |
| 142 | 147 | 'description' => '', |
| 143 | - 'tab' => 'livestream' | |
| 148 | + 'tab' => 'livestream', | |
| 149 | + 'page' => 'ayg_livestream_settings' | |
| 144 | 150 | ), |
| 145 | 151 | array( |
| 146 | 152 | 'id' => 'ayg_privacy_settings', |
| 147 | 153 | 'title' => __( 'GDPR Compliance', 'automatic-youtube-gallery' ), |
| 148 | 154 | 'description' => __( 'These options will help with privacy restrictions such as GDPR and the EU Cookie Law.', 'automatic-youtube-gallery' ), |
| 149 | - 'tab' => 'privacy' | |
| 155 | + 'tab' => 'privacy', | |
| 156 | + 'page' => 'ayg_privacy_settings' | |
| 150 | 157 | ), |
| 151 | 158 | ); |
| 152 | 159 | |
| 153 | 160 | return apply_filters( 'ayg_settings_sections', $sections ); |
| @@ -158,62 +165,164 @@ | ||
| 158 | 165 | * |
| 159 | 166 | * @since 1.0.0 |
| 160 | 167 | * @return array $fields Setting fields array. |
| 161 | 168 | */ |
| 162 | - public function get_fields() { | |
| 163 | - $fields = array( | |
| 164 | - 'ayg_general_settings' => array( | |
| 165 | - array( | |
| 166 | - 'name' => 'api_key', | |
| 167 | - 'label' => __( 'Youtube API Key', 'automatic-youtube-gallery' ), | |
| 168 | - 'description' => sprintf( | |
| 169 | - __( 'Follow <a href="%s" target="_blank">this guide</a> to get your own API key.', 'automatic-youtube-gallery' ), | |
| 170 | - 'https://plugins360.com/automatic-youtube-gallery/how-to-get-youtube-api-key/' | |
| 171 | - ), | |
| 172 | - 'type' => 'text', | |
| 173 | - 'sanitize_callback' => 'sanitize_text_field' | |
| 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/' | |
| 174 | 178 | ), |
| 175 | - array( | |
| 176 | - 'name' => 'development_mode', | |
| 177 | - 'label' => __( 'Development Mode', 'automatic-youtube-gallery' ), | |
| 178 | - 'description' => __( 'Do not cache API results when checked. We strongly recommend disabling this option when your site is live.', 'automatic-youtube-gallery' ), | |
| 179 | - 'type' => 'checkbox', | |
| 180 | - 'sanitize_callback' => 'intval' | |
| 179 | + 'type' => 'text', | |
| 180 | + 'sanitize_callback' => 'sanitize_text_field' | |
| 181 | + ), | |
| 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' | |
| 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' ) | |
| 181 | 260 | ), |
| 261 | + 'sanitize_callback' => 'sanitize_text_field' | |
| 182 | 262 | ), |
| 183 | - 'ayg_gallery_settings' => ayg_get_gallery_settings_fields(), | |
| 184 | - 'ayg_player_settings' => ayg_get_player_settings_fields(), | |
| 185 | - 'ayg_livestream_settings' => array( | |
| 186 | - array( | |
| 187 | - 'name' => 'fallback_message', | |
| 188 | - 'label' => __( 'Fallback Message', 'automatic-youtube-gallery' ), | |
| 189 | - 'description' => __( 'Enter your Custom HTML message that should be displayed when there is no video streaming live.', 'automatic-youtube-gallery' ), | |
| 190 | - 'type' => 'wysiwyg', | |
| 191 | - 'sanitize_callback' => 'wp_kses_post' | |
| 192 | - ) | |
| 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' | |
| 193 | 311 | ), |
| 194 | - 'ayg_privacy_settings' => array( | |
| 195 | - array( | |
| 196 | - 'name' => 'cookie_consent', | |
| 197 | - 'label' => __( 'Cookie Consent', 'automatic-youtube-gallery' ), | |
| 198 | - 'description' => __( 'Ask for viewer consent to store YouTube cookies before showing videos.', 'automatic-youtube-gallery' ), | |
| 199 | - 'type' => 'checkbox', | |
| 200 | - 'sanitize_callback' => 'intval' | |
| 201 | - ), | |
| 202 | - array( | |
| 203 | - 'name' => 'consent_message', | |
| 204 | - 'label' => __( 'Consent Message', 'automatic-youtube-gallery' ), | |
| 205 | - 'description' => '', | |
| 206 | - 'type' => 'wysiwyg', | |
| 207 | - 'sanitize_callback' => 'wp_kses_post' | |
| 208 | - ), | |
| 209 | - array( | |
| 210 | - 'name' => 'button_label', | |
| 211 | - 'label' => __( 'Button Label', 'automatic-youtube-gallery' ), | |
| 212 | - 'description' => '', | |
| 213 | - 'type' => 'text', | |
| 214 | - 'sanitize_callback' => 'sanitize_text_field' | |
| 215 | - ) | |
| 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' | |
| 216 | 325 | ) |
| 217 | 326 | ); |
| 218 | 327 | |
| 219 | 328 | return apply_filters( 'ayg_settings_fields', $fields ); |
| @@ -226,10 +335,9 @@ | ||
| 226 | 335 | */ |
| 227 | 336 | public function initialize_settings() { |
| 228 | 337 | // Register settings sections & fields |
| 229 | 338 | foreach ( $this->sections as $section ) { |
| 230 | - | |
| 231 | - $page_hook = "ayg_{$section['tab']}_settings"; | |
| 339 | + $page_hook = isset( $section['page'] ) ? $section['page'] : $section['id']; | |
| 232 | 340 | |
| 233 | 341 | // Sections |
| 234 | 342 | if ( false == get_option( $section['id'] ) ) { |
| 235 | 343 | add_option( $section['id'] ); |
| @@ -286,9 +394,9 @@ | ||
| 286 | 394 | */ |
| 287 | 395 | public function settings_section_callback( $args ) { |
| 288 | 396 | foreach ( $this->sections as $section ) { |
| 289 | 397 | if ( $section['id'] == $args['id'] ) { |
| 290 | - printf( '<div class="inside">%s</div>', sanitize_text_field( $section['description'] ) ); | |
| 398 | + printf( '<div class="inside">%s</div>', wp_kses_post( $section['description'] ) ); | |
| 291 | 399 | break; |
| 292 | 400 | } |
| 293 | 401 | } |
| 294 | 402 | } |
| @@ -643,19 +751,12 @@ | ||
| 643 | 751 | */ |
| 644 | 752 | public function ajax_callback_delete_cache() { |
| 645 | 753 | check_ajax_referer( 'ayg_ajax_nonce', 'security' ); |
| 646 | 754 | |
| 647 | - // Get the current list of transients | |
| 648 | - $transient_keys = get_option( 'ayg_transient_keys', array() ); | |
| 649 | - | |
| 650 | - // For each key, delete that transient | |
| 651 | - foreach ( $transient_keys as $key ) { | |
| 652 | - delete_transient( $key ); | |
| 755 | + if ( current_user_can( 'manage_options' ) ) { | |
| 756 | + ayg_delete_cache(); | |
| 653 | 757 | } |
| 654 | 758 | |
| 655 | - // Reset our DB value | |
| 656 | - update_option( 'ayg_transient_keys', array() ); | |
| 657 | - | |
| 658 | 759 | wp_die(); |
| 659 | 760 | } |
| 660 | 761 | |
| 661 | 762 | } |