| @@ -69,8 +69,14 @@ | ||
| 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 | + $pagination_type = $gallery_settings['pagination_type']; | |
| 78 | + | |
| 73 | 79 | require_once AYG_DIR . 'admin/templates/settings.php'; |
| 74 | 80 | } |
| 75 | 81 | |
| 76 | 82 | /** |
| @@ -116,45 +122,33 @@ | ||
| 116 | 122 | array( |
| 117 | 123 | 'id' => 'ayg_general_settings', |
| 118 | 124 | 'title' => __( 'General Settings', 'automatic-youtube-gallery' ), |
| 119 | 125 | 'description' => '', |
| 120 | - 'tab' => 'general', | |
| 121 | - 'page' => 'ayg_general_settings' | |
| 126 | + 'tab' => 'general' | |
| 122 | 127 | ), |
| 123 | 128 | 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( | |
| 131 | 129 | 'id' => 'ayg_gallery_settings', |
| 132 | 130 | 'title' => __( 'Gallery Settings', 'automatic-youtube-gallery' ), |
| 133 | 131 | 'description' => '', |
| 134 | - 'tab' => 'gallery', | |
| 135 | - 'page' => 'ayg_gallery_settings' | |
| 132 | + 'tab' => 'gallery' | |
| 136 | 133 | ), |
| 137 | 134 | array( |
| 138 | 135 | 'id' => 'ayg_player_settings', |
| 139 | 136 | 'title' => __( 'Player Settings', 'automatic-youtube-gallery' ), |
| 140 | 137 | 'description' => '', |
| 141 | - 'tab' => 'player', | |
| 142 | - 'page' => 'ayg_player_settings' | |
| 138 | + 'tab' => 'player' | |
| 143 | 139 | ), |
| 144 | 140 | array( |
| 145 | 141 | 'id' => 'ayg_livestream_settings', |
| 146 | 142 | 'title' => __( 'Livestream Settings', 'automatic-youtube-gallery' ), |
| 147 | 143 | 'description' => '', |
| 148 | - 'tab' => 'livestream', | |
| 149 | - 'page' => 'ayg_livestream_settings' | |
| 144 | + 'tab' => 'livestream' | |
| 150 | 145 | ), |
| 151 | 146 | array( |
| 152 | 147 | 'id' => 'ayg_privacy_settings', |
| 153 | 148 | 'title' => __( 'GDPR Compliance', 'automatic-youtube-gallery' ), |
| 154 | - 'description' => '', | |
| 155 | - 'tab' => 'privacy', | |
| 156 | - 'page' => 'ayg_privacy_settings' | |
| 149 | + 'description' => __( 'These options will help with privacy restrictions such as GDPR and the EU Cookie Law.', 'automatic-youtube-gallery' ), | |
| 150 | + 'tab' => 'privacy' | |
| 157 | 151 | ), |
| 158 | 152 | ); |
| 159 | 153 | |
| 160 | 154 | return apply_filters( 'ayg_settings_sections', $sections ); |
| @@ -165,177 +159,64 @@ | ||
| 165 | 159 | * |
| 166 | 160 | * @since 1.0.0 |
| 167 | 161 | * @return array $fields Setting fields array. |
| 168 | 162 | */ |
| 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 | - __( 'A free YouTube Data API key is required to fetch your videos. <a href="%s" target="_blank" rel="noopener noreferrer">Get your API key</a> in just a few minutes.', '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' | |
| 163 | + public function get_fields() { | |
| 164 | + $fields = array( | |
| 165 | + 'ayg_general_settings' => array( | |
| 166 | + array( | |
| 167 | + 'name' => 'api_key', | |
| 168 | + 'label' => __( 'Youtube API Key', 'automatic-youtube-gallery' ), | |
| 169 | + 'description' => sprintf( | |
| 170 | + __( 'Follow <a href="%s" target="_blank">this guide</a> to get your own API key.', 'automatic-youtube-gallery' ), | |
| 171 | + 'https://plugins360.com/automatic-youtube-gallery/how-to-get-youtube-api-key/' | |
| 172 | + ), | |
| 173 | + 'type' => 'text', | |
| 174 | + 'sanitize_callback' => 'sanitize_text_field' | |
| 175 | + ), | |
| 176 | + array( | |
| 177 | + 'name' => 'development_mode', | |
| 178 | + 'label' => __( 'Development Mode', 'automatic-youtube-gallery' ), | |
| 179 | + 'description' => __( 'Does not cache API results when checked. We strongly recommend disabling this option when your site is live.', 'automatic-youtube-gallery' ), | |
| 180 | + 'type' => 'checkbox', | |
| 181 | + 'sanitize_callback' => 'intval' | |
| 182 | + ), | |
| 181 | 183 | ), |
| 182 | - array( | |
| 183 | - 'name' => 'force_load_assets', | |
| 184 | - 'label' => __( 'Force Load Plugin Assets', 'automatic-youtube-gallery' ), | |
| 185 | - 'description' => __( 'Force-load the plugin\'s CSS and/or JavaScript files on all front-end pages. Enable this option only if layouts do not render correctly due to page builders or theme conflicts.', 'automatic-youtube-gallery' ), | |
| 186 | - 'type' => 'multicheck', | |
| 187 | - 'options' => array( | |
| 188 | - 'css' => __( 'Force load CSS', 'automatic-youtube-gallery' ), | |
| 189 | - 'js' => __( 'Force load JavaScript', 'automatic-youtube-gallery' ), | |
| 190 | - ), | |
| 191 | - 'sanitize_callback' => 'ayg_sanitize_array' | |
| 184 | + 'ayg_gallery_settings' => ayg_get_gallery_settings_fields(), | |
| 185 | + 'ayg_player_settings' => ayg_get_player_settings_fields(), | |
| 186 | + 'ayg_livestream_settings' => array( | |
| 187 | + array( | |
| 188 | + 'name' => 'fallback_message', | |
| 189 | + 'label' => __( 'Fallback Message', 'automatic-youtube-gallery' ), | |
| 190 | + 'description' => __( 'Enter your Custom HTML message that should be displayed when there is no video streaming live.', 'automatic-youtube-gallery' ), | |
| 191 | + 'type' => 'wysiwyg', | |
| 192 | + 'sanitize_callback' => 'wp_kses_post' | |
| 193 | + ) | |
| 192 | 194 | ), |
| 193 | - array( | |
| 194 | - 'name' => 'lazyload', | |
| 195 | - 'label' => __( 'Lazy Load Images / Videos', 'automatic-youtube-gallery' ), | |
| 196 | - 'description' => __( 'Check 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' ), | |
| 197 | - 'type' => 'checkbox', | |
| 198 | - 'sanitize_callback' => 'intval' | |
| 199 | - ), | |
| 200 | - array( | |
| 201 | - 'name' => 'development_mode', | |
| 202 | - 'label' => __( 'Development Mode', 'automatic-youtube-gallery' ), | |
| 203 | - 'description' => __( 'Check this option to stop caching API results. We strongly recommend disabling this option when your site is live.', 'automatic-youtube-gallery' ), | |
| 204 | - 'type' => 'checkbox', | |
| 205 | - 'sanitize_callback' => 'intval' | |
| 206 | - ) | |
| 207 | - ); | |
| 208 | - | |
| 209 | - // Strings Settings | |
| 210 | - $fields['ayg_strings_settings'] = array( | |
| 211 | - array( | |
| 212 | - 'name' => 'more_button_label', | |
| 213 | - 'label' => __( 'More Button Label', 'automatic-youtube-gallery' ), | |
| 214 | - 'description' => __( 'Text for the "Load More" button when pagination type is set to "More Button".', 'automatic-youtube-gallery' ), | |
| 215 | - 'type' => 'text', | |
| 216 | - 'sanitize_callback' => 'sanitize_text_field' | |
| 217 | - ), | |
| 218 | - array( | |
| 219 | - 'name' => 'previous_button_label', | |
| 220 | - 'label' => __( 'Previous Button Label', 'automatic-youtube-gallery' ), | |
| 221 | - 'description' => __( 'Text for the "Previous" button when pagination type is set to "Pager".', 'automatic-youtube-gallery' ), | |
| 222 | - 'type' => 'text', | |
| 223 | - 'sanitize_callback' => 'sanitize_text_field' | |
| 224 | - ), | |
| 225 | - array( | |
| 226 | - 'name' => 'next_button_label', | |
| 227 | - 'label' => __( 'Next Button Label', 'automatic-youtube-gallery' ), | |
| 228 | - 'description' => __( 'Text for the "Next" button when pagination type is set to "Pager".', 'automatic-youtube-gallery' ), | |
| 229 | - 'type' => 'text', | |
| 230 | - 'sanitize_callback' => 'sanitize_text_field' | |
| 231 | - ), | |
| 232 | - array( | |
| 233 | - 'name' => 'show_more_label', | |
| 234 | - 'label' => __( 'Show More Label', 'automatic-youtube-gallery' ), | |
| 235 | - 'description' => __( 'Text for the "Show More" link that expands the video description below the player.', 'automatic-youtube-gallery' ), | |
| 236 | - 'type' => 'text', | |
| 237 | - 'sanitize_callback' => 'sanitize_text_field' | |
| 238 | - ), | |
| 239 | - array( | |
| 240 | - 'name' => 'show_less_label', | |
| 241 | - 'label' => __( 'Show Less Label', 'automatic-youtube-gallery' ), | |
| 242 | - 'description' => __( 'Text for the "Show Less" link that collapses the video description below the player.', 'automatic-youtube-gallery' ), | |
| 243 | - 'type' => 'text', | |
| 244 | - 'sanitize_callback' => 'sanitize_text_field' | |
| 245 | - ) | |
| 246 | - ); | |
| 247 | - | |
| 248 | - // Gallery Settings | |
| 249 | - $gallery_settings = ayg_get_gallery_settings_fields(); | |
| 250 | - | |
| 251 | - $gallery_settings[] = array( | |
| 252 | - 'name' => 'scroll_top_offset', | |
| 253 | - 'label' => __( 'Page Scroll Top Offset', 'automatic-youtube-gallery' ), | |
| 254 | - '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' ), | |
| 255 | - 'type' => 'text', | |
| 256 | - 'sanitize_callback' => 'ayg_sanitize_int' | |
| 257 | - ); | |
| 258 | - | |
| 259 | - $fields['ayg_gallery_settings'] = $gallery_settings; | |
| 260 | - | |
| 261 | - // Player Settings | |
| 262 | - $player_settings = array( | |
| 263 | - array( | |
| 264 | - 'name' => 'player_type', | |
| 265 | - 'label' => __( 'Player Type', 'automatic-youtube-gallery' ), | |
| 266 | - 'description' => __( 'Choose how videos are embedded. "Native YouTube Embed" uses YouTube\'s standard iframe, while "Custom Video Player" provides a lightweight, styled player with more control over its appearance.', 'automatic-youtube-gallery' ), | |
| 267 | - 'type' => 'radio', | |
| 268 | - 'options' => array( | |
| 269 | - 'youtube' => __( 'Native YouTube Embed', 'automatic-youtube-gallery' ), | |
| 270 | - 'custom' => __( 'Custom Video Player', 'automatic-youtube-gallery' ) | |
| 195 | + 'ayg_privacy_settings' => array( | |
| 196 | + array( | |
| 197 | + 'name' => 'cookie_consent', | |
| 198 | + 'label' => __( 'Cookie Consent', 'automatic-youtube-gallery' ), | |
| 199 | + 'description' => __( 'Ask for viewer consent to store YouTube cookies before showing videos.', 'automatic-youtube-gallery' ), | |
| 200 | + 'type' => 'checkbox', | |
| 201 | + 'sanitize_callback' => 'intval' | |
| 271 | 202 | ), |
| 272 | - 'sanitize_callback' => 'sanitize_text_field' | |
| 273 | - ), | |
| 274 | - array( | |
| 275 | - 'name' => 'player_color', | |
| 276 | - 'label' => __( 'Player Color', 'automatic-youtube-gallery' ), | |
| 277 | - 'description' => __( 'Set the theme color for your video player.', 'automatic-youtube-gallery' ), | |
| 278 | - 'type' => 'color', | |
| 279 | - 'sanitize_callback' => 'sanitize_text_field' | |
| 203 | + array( | |
| 204 | + 'name' => 'consent_message', | |
| 205 | + 'label' => __( 'Consent Message', 'automatic-youtube-gallery' ), | |
| 206 | + 'description' => '', | |
| 207 | + 'type' => 'wysiwyg', | |
| 208 | + 'sanitize_callback' => 'wp_kses_post' | |
| 209 | + ), | |
| 210 | + array( | |
| 211 | + 'name' => 'button_label', | |
| 212 | + 'label' => __( 'Button Label', 'automatic-youtube-gallery' ), | |
| 213 | + 'description' => '', | |
| 214 | + 'type' => 'text', | |
| 215 | + 'sanitize_callback' => 'sanitize_text_field' | |
| 216 | + ) | |
| 280 | 217 | ) |
| 281 | - ); | |
| 282 | - | |
| 283 | - $player_settings = array_merge( $player_settings, ayg_get_player_settings_fields() ); | |
| 284 | - | |
| 285 | - $player_settings[] = array( | |
| 286 | - 'name' => 'privacy_enhanced_mode', | |
| 287 | - 'label' => __( 'Privacy Enhanced Mode', 'automatic-youtube-gallery' ), | |
| 288 | - 'description' => __( "Check this option to 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' ), | |
| 289 | - 'type' => 'checkbox', | |
| 290 | - 'sanitize_callback' => 'intval' | |
| 291 | 218 | ); |
| 292 | - | |
| 293 | - $player_settings[] = array( | |
| 294 | - 'name' => 'origin', | |
| 295 | - 'label' => __( 'Extra Player Security', 'automatic-youtube-gallery' ), | |
| 296 | - 'description' => __( 'Check this option to 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' ), | |
| 297 | - 'type' => 'checkbox', | |
| 298 | - 'sanitize_callback' => 'intval' | |
| 299 | - ); | |
| 300 | - | |
| 301 | - $fields['ayg_player_settings'] = $player_settings; | |
| 302 | - | |
| 303 | - // Livestream Settings | |
| 304 | - $fields['ayg_livestream_settings'] = array( | |
| 305 | - array( | |
| 306 | - 'name' => 'fallback_message', | |
| 307 | - 'label' => __( 'Fallback Message', 'automatic-youtube-gallery' ), | |
| 308 | - 'description' => __( 'Enter your Custom HTML message that should be displayed when there is no video streaming live.', 'automatic-youtube-gallery' ), | |
| 309 | - 'type' => 'wysiwyg', | |
| 310 | - 'sanitize_callback' => 'wp_kses_post' | |
| 311 | - ) | |
| 312 | - ); | |
| 313 | - | |
| 314 | - // Privacy Settings | |
| 315 | - $fields['ayg_privacy_settings'] = array( | |
| 316 | - array( | |
| 317 | - 'name' => 'cookie_consent', | |
| 318 | - 'label' => __( 'Cookie Consent', 'automatic-youtube-gallery' ), | |
| 319 | - 'description' => __( 'Check this option to ask for viewer consent to store YouTube cookies before showing videos.', 'automatic-youtube-gallery' ), | |
| 320 | - 'type' => 'checkbox', | |
| 321 | - 'sanitize_callback' => 'intval' | |
| 322 | - ), | |
| 323 | - array( | |
| 324 | - 'name' => 'consent_message', | |
| 325 | - 'label' => __( 'Consent Message', 'automatic-youtube-gallery' ), | |
| 326 | - 'description' => __( 'The message shown to visitors asking for their permission before YouTube videos and cookies are loaded.', 'automatic-youtube-gallery' ), | |
| 327 | - 'type' => 'wysiwyg', | |
| 328 | - 'sanitize_callback' => 'wp_kses_post' | |
| 329 | - ), | |
| 330 | - array( | |
| 331 | - 'name' => 'button_label', | |
| 332 | - 'label' => __( 'Consent Button Label', 'automatic-youtube-gallery' ), | |
| 333 | - 'description' => __( 'Text for the button visitors click to accept and load the video (e.g. "Accept" or "Load video").', 'automatic-youtube-gallery' ), | |
| 334 | - 'type' => 'text', | |
| 335 | - 'sanitize_callback' => 'sanitize_text_field' | |
| 336 | - ) | |
| 337 | - ); | |
| 338 | 219 | |
| 339 | 220 | return apply_filters( 'ayg_settings_fields', $fields ); |
| 340 | 221 | } |
| 341 | 222 | |
| @@ -346,9 +227,10 @@ | ||
| 346 | 227 | */ |
| 347 | 228 | public function initialize_settings() { |
| 348 | 229 | // Register settings sections & fields |
| 349 | 230 | foreach ( $this->sections as $section ) { |
| 350 | - $page_hook = isset( $section['page'] ) ? $section['page'] : $section['id']; | |
| 231 | + | |
| 232 | + $page_hook = "ayg_{$section['tab']}_settings"; | |
| 351 | 233 | |
| 352 | 234 | // Sections |
| 353 | 235 | if ( false == get_option( $section['id'] ) ) { |
| 354 | 236 | add_option( $section['id'] ); |
| @@ -419,13 +301,13 @@ | ||
| 419 | 301 | * @param array $args Settings field args. |
| 420 | 302 | */ |
| 421 | 303 | public function callback_text( $args ) { |
| 422 | 304 | $value = esc_attr( $this->get_option( $args['id'], $args['section'], '' ) ); |
| 423 | - $size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : 'regular-text'; | |
| 305 | + $size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : 'regular'; | |
| 424 | 306 | $type = isset( $args['type'] ) ? $args['type'] : 'text'; |
| 425 | 307 | $placeholder = empty( $args['placeholder'] ) ? '' : ' placeholder="' . $args['placeholder'] . '"'; |
| 426 | 308 | |
| 427 | - $html = sprintf( '<input type="%1$s" class="%2$s" id="%3$s[%4$s]" name="%3$s[%4$s]" value="%5$s"%6$s/>', $type, $size, $args['section'], $args['id'], $value, $placeholder ); | |
| 309 | + $html = sprintf( '<input type="%1$s" class="%2$s-text" id="%3$s[%4$s]" name="%3$s[%4$s]" value="%5$s"%6$s/>', $type, $size, $args['section'], $args['id'], $value, $placeholder ); | |
| 428 | 310 | $html .= $this->get_field_description( $args ); |
| 429 | 311 | |
| 430 | 312 | echo $html; |
| 431 | 313 | } |
| @@ -447,9 +329,9 @@ | ||
| 447 | 329 | * @param array $args Settings field args. |
| 448 | 330 | */ |
| 449 | 331 | public function callback_number( $args ) { |
| 450 | 332 | $value = esc_attr( $this->get_option( $args['id'], $args['section'], 0 ) ); |
| 451 | - $size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : 'regular-text'; | |
| 333 | + $size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : 'regular'; | |
| 452 | 334 | $type = isset( $args['type'] ) ? $args['type'] : 'number'; |
| 453 | 335 | $placeholder = empty( $args['placeholder'] ) ? '' : ' placeholder="' . $args['placeholder'] . '"'; |
| 454 | 336 | $min = empty( $args['min'] ) ? '' : ' min="' . $args['min'] . '"'; |
| 455 | 337 | $max = empty( $args['max'] ) ? '' : ' max="' . $args['max'] . '"'; |
| @@ -454,9 +336,9 @@ | ||
| 454 | 336 | $min = empty( $args['min'] ) ? '' : ' min="' . $args['min'] . '"'; |
| 455 | 337 | $max = empty( $args['max'] ) ? '' : ' max="' . $args['max'] . '"'; |
| 456 | 338 | $step = empty( $args['max'] ) ? '' : ' step="' . $args['step'] . '"'; |
| 457 | 339 | |
| 458 | - $html = sprintf( '<input type="%1$s" class="%2$s" id="%3$s[%4$s]" name="%3$s[%4$s]" value="%5$s"%6$s%7$s%8$s%9$s/>', $type, $size, $args['section'], $args['id'], $value, $placeholder, $min, $max, $step ); | |
| 340 | + $html = sprintf( '<input type="%1$s" class="%2$s-number" id="%3$s[%4$s]" name="%3$s[%4$s]" value="%5$s"%6$s%7$s%8$s%9$s/>', $type, $size, $args['section'], $args['id'], $value, $placeholder, $min, $max, $step ); | |
| 459 | 341 | $html .= $this->get_field_description( $args ); |
| 460 | 342 | |
| 461 | 343 | echo $html; |
| 462 | 344 | } |
| @@ -531,9 +413,9 @@ | ||
| 531 | 413 | * @param array $args Settings field args. |
| 532 | 414 | */ |
| 533 | 415 | public function callback_select( $args ) { |
| 534 | 416 | $value = esc_attr( $this->get_option( $args['id'], $args['section'], '' ) ); |
| 535 | - $size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : 'regular-text'; | |
| 417 | + $size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : 'regular'; | |
| 536 | 418 | |
| 537 | 419 | $html = sprintf( '<select class="%1$s" name="%2$s[%3$s]" id="%2$s[%3$s]">', $size, $args['section'], $args['id'] ); |
| 538 | 420 | foreach ( $args['options'] as $key => $label ) { |
| 539 | 421 | $html .= sprintf( '<option value="%s"%s>%s</option>', $key, selected( $value, $key, false ), $label ); |
| @@ -551,12 +433,12 @@ | ||
| 551 | 433 | * @param array $args Settings field args. |
| 552 | 434 | */ |
| 553 | 435 | public function callback_textarea( $args ) { |
| 554 | 436 | $value = esc_textarea( $this->get_option( $args['id'], $args['section'], '' ) ); |
| 555 | - $size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : 'regular-text'; | |
| 437 | + $size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : 'regular'; | |
| 556 | 438 | $placeholder = empty( $args['placeholder'] ) ? '' : ' placeholder="'.$args['placeholder'].'"'; |
| 557 | 439 | |
| 558 | - $html = sprintf( '<textarea rows="5" cols="55" class="%1$s" id="%2$s[%3$s]" name="%2$s[%3$s]"%4$s>%5$s</textarea>', $size, $args['section'], $args['id'], $placeholder, $value ); | |
| 440 | + $html = sprintf( '<textarea rows="5" cols="55" class="%1$s-text" id="%2$s[%3$s]" name="%2$s[%3$s]"%4$s>%5$s</textarea>', $size, $args['section'], $args['id'], $placeholder, $value ); | |
| 559 | 441 | $html .= $this->get_field_description( $args ); |
| 560 | 442 | |
| 561 | 443 | echo $html; |
| 562 | 444 | } |
| @@ -602,14 +484,14 @@ | ||
| 602 | 484 | * @param array $args Settings field args. |
| 603 | 485 | */ |
| 604 | 486 | public function callback_file( $args ) { |
| 605 | 487 | $value = esc_attr( $this->get_option( $args['id'], $args['section'], '' ) ); |
| 606 | - $size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : 'regular-text'; | |
| 488 | + $size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : 'regular'; | |
| 607 | 489 | $id = $args['section'] . '[' . $args['id'] . ']'; |
| 608 | 490 | $label = isset( $args['options']['button_label'] ) ? $args['options']['button_label'] : __( 'Choose File', 'automatic-youtube-gallery' ); |
| 609 | 491 | |
| 610 | - $html = sprintf( '<input type="text" class="%1$s ayg-settings-url" id="%2$s[%3$s]" name="%2$s[%3$s]" value="%4$s"/>', $size, $args['section'], $args['id'], $value ); | |
| 611 | - $html .= '<input type="button" class="button ayg-button-upload-media" value="' . $label . '" />'; | |
| 492 | + $html = sprintf( '<input type="text" class="%1$s-text ayg-settings-url" id="%2$s[%3$s]" name="%2$s[%3$s]" value="%4$s"/>', $size, $args['section'], $args['id'], $value ); | |
| 493 | + $html .= '<input type="button" class="button ayg-settings-browse" value="' . $label . '" />'; | |
| 612 | 494 | $html .= $this->get_field_description( $args ); |
| 613 | 495 | |
| 614 | 496 | echo $html; |
| 615 | 497 | } |
| @@ -621,11 +503,11 @@ | ||
| 621 | 503 | * @param array $args Settings field args. |
| 622 | 504 | */ |
| 623 | 505 | public function callback_password( $args ) { |
| 624 | 506 | $value = esc_attr( $this->get_option( $args['id'], $args['section'], '' ) ); |
| 625 | - $size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : 'regular-text'; | |
| 507 | + $size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : 'regular'; | |
| 626 | 508 | |
| 627 | - $html = sprintf( '<input type="password" class="%1$s" id="%2$s[%3$s]" name="%2$s[%3$s]" value="%4$s"/>', $size, $args['section'], $args['id'], $value ); | |
| 509 | + $html = sprintf( '<input type="password" class="%1$s-text" id="%2$s[%3$s]" name="%2$s[%3$s]" value="%4$s"/>', $size, $args['section'], $args['id'], $value ); | |
| 628 | 510 | $html .= $this->get_field_description( $args ); |
| 629 | 511 | |
| 630 | 512 | echo $html; |
| 631 | 513 | } |
| @@ -637,11 +519,11 @@ | ||
| 637 | 519 | * @param array $args Settings field args. |
| 638 | 520 | */ |
| 639 | 521 | public function callback_color( $args ) { |
| 640 | 522 | $value = esc_attr( $this->get_option( $args['id'], $args['section'], '#ffffff' ) ); |
| 641 | - $size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : 'regular-text'; | |
| 523 | + $size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : 'regular'; | |
| 642 | 524 | |
| 643 | - $html = sprintf( '<input type="text" class="%1$s ayg-color-picker" id="%2$s[%3$s]" name="%2$s[%3$s]" value="%4$s" data-default-color="%5$s" />', $size, $args['section'], $args['id'], $value, '#ffffff' ); | |
| 525 | + $html = sprintf( '<input type="text" class="%1$s-text ayg-color-picker" id="%2$s[%3$s]" name="%2$s[%3$s]" value="%4$s" data-default-color="%5$s" />', $size, $args['section'], $args['id'], $value, '#ffffff' ); | |
| 644 | 526 | $html .= $this->get_field_description( $args ); |
| 645 | 527 | |
| 646 | 528 | echo $html; |
| 647 | 529 | } |
| @@ -762,14 +644,9 @@ | ||
| 762 | 644 | */ |
| 763 | 645 | public function ajax_callback_delete_cache() { |
| 764 | 646 | check_ajax_referer( 'ayg_ajax_nonce', 'security' ); |
| 765 | 647 | |
| 766 | - if ( ! current_user_can( 'manage_options' ) ) { | |
| 767 | - wp_send_json_error( array( 'message' => __( 'Permission denied.', 'automatic-youtube-gallery' ) ) ); | |
| 768 | - } | |
| 769 | - | |
| 770 | 648 | ayg_delete_cache(); |
| 771 | - | |
| 772 | - wp_send_json_success(); | |
| 649 | + wp_die(); | |
| 773 | 650 | } |
| 774 | 651 | |
| 775 | 652 | } |