class-settings-addons.php
4 months ago
class-settings-base.php
5 months ago
class-settings-builder.php
5 months ago
class-settings-capabilities.php
5 months ago
class-settings-folders.php
4 months ago
class-settings-galleries.php
5 months ago
class-settings-general.php
5 months ago
class-settings-licenses.php
4 months ago
class-settings-lightboxes.php
4 months ago
class-settings-remote-library.php
5 months ago
class-settings-lightboxes.php
711 lines
| 1 | <?php |
| 2 | // exit if accessed directly |
| 3 | if ( ! defined( 'ABSPATH' ) ) |
| 4 | exit; |
| 5 | |
| 6 | /** |
| 7 | * Responsive_Lightbox_Settings_Lightboxes class. |
| 8 | * |
| 9 | * Settings page class for Lightboxes tab migration to new Settings API. |
| 10 | * |
| 11 | * @class Responsive_Lightbox_Settings_Lightboxes |
| 12 | */ |
| 13 | class Responsive_Lightbox_Settings_Lightboxes extends Responsive_Lightbox_Settings_Base { |
| 14 | |
| 15 | /** |
| 16 | * Tab key identifier. |
| 17 | * |
| 18 | * @var string |
| 19 | */ |
| 20 | const TAB_KEY = 'configuration'; |
| 21 | |
| 22 | /** |
| 23 | * Validate settings for Lightboxes tab. |
| 24 | * |
| 25 | * Handles script-specific configuration, ensuring only the active |
| 26 | * script is reset without affecting other lightbox scripts. |
| 27 | * |
| 28 | * @param array $input Input data from form submission. |
| 29 | * @return array Validated data. |
| 30 | */ |
| 31 | public function validate( $input ) { |
| 32 | $rl = Responsive_Lightbox(); |
| 33 | $input = is_array( $input ) ? $input : []; |
| 34 | $current_configuration = isset( $rl->options['configuration'] ) && is_array( $rl->options['configuration'] ) ? $rl->options['configuration'] : []; |
| 35 | |
| 36 | // check if this is a reset operation |
| 37 | if ( $this->is_reset_request() ) { |
| 38 | // determine which script to reset from input (e.g., ['glightbox' => []]) |
| 39 | $script = key( $input ); |
| 40 | |
| 41 | if ( $script ) { |
| 42 | $defaults = null; |
| 43 | |
| 44 | if ( isset( $rl->defaults['configuration'][$script] ) ) { |
| 45 | $defaults = $rl->defaults['configuration'][$script]; |
| 46 | } else { |
| 47 | $scripts = Responsive_Lightbox_Settings_Data::get_scripts(); |
| 48 | if ( isset( $scripts[$script]['reset'] ) ) { |
| 49 | $defaults = $scripts[$script]['reset']; |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | // reset only this script's settings |
| 54 | if ( is_array( $defaults ) ) { |
| 55 | $input[$script] = $defaults; |
| 56 | // merge with saved config to preserve other scripts |
| 57 | $input = array_merge( $current_configuration, $input ); |
| 58 | add_settings_error( 'reset_rl_configuration', 'settings_restored', esc_html__( 'Settings restored to defaults.', 'responsive-lightbox' ), 'updated' ); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | return $input; |
| 63 | } |
| 64 | |
| 65 | // Sanitize only the submitted script section. |
| 66 | // options.php saves do not preserve ?section in $_GET, so detect script from payload first. |
| 67 | $script_key = ''; |
| 68 | if ( is_array( $input ) && ! empty( $input ) ) { |
| 69 | $payload_script = key( $input ); |
| 70 | if ( is_string( $payload_script ) && $payload_script !== '' ) |
| 71 | $script_key = sanitize_key( $payload_script ); |
| 72 | } |
| 73 | |
| 74 | if ( $script_key === '' ) |
| 75 | $script_key = $this->get_current_section(); |
| 76 | |
| 77 | if ( $script_key === '' && ! empty( $rl->options['settings']['script'] ) ) |
| 78 | $script_key = sanitize_key( $rl->options['settings']['script'] ); |
| 79 | |
| 80 | if ( $script_key !== '' ) { |
| 81 | $fields = $this->get_configuration_fields( $script_key ); |
| 82 | if ( ! empty( $fields ) && is_array( $fields ) ) |
| 83 | $input = $this->sanitize_fields( $input, 'configuration', $fields ); |
| 84 | } |
| 85 | |
| 86 | // merge with saved configuration to preserve other lightbox scripts |
| 87 | $input = array_merge( $current_configuration, $input ); |
| 88 | |
| 89 | return $input; |
| 90 | } |
| 91 | |
| 92 | /** * Provide settings data for configuration. |
| 93 | * |
| 94 | * @param array $data Settings data. |
| 95 | * @return array |
| 96 | */ |
| 97 | public function settings_data( $data ) { |
| 98 | $rl = Responsive_Lightbox(); |
| 99 | |
| 100 | // get scripts from helper class |
| 101 | $scripts = Responsive_Lightbox_Settings_Data::get_scripts(); |
| 102 | |
| 103 | // resolve active script from URL section parameter or fallback to saved setting |
| 104 | $active_script = $rl->options['settings']['script']; |
| 105 | if ( isset( $_GET['section'] ) && is_string( $_GET['section'] ) ) { |
| 106 | $section = sanitize_key( $_GET['section'] ); |
| 107 | if ( isset( $scripts[$section] ) ) { |
| 108 | $active_script = $section; |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | $data[self::TAB_KEY] = [ |
| 113 | 'option_name' => 'responsive_lightbox_configuration', |
| 114 | 'option_group' => 'responsive_lightbox_configuration', |
| 115 | 'validate' => [ $this, 'validate' ], |
| 116 | 'sections' => [], |
| 117 | 'fields' => [] |
| 118 | ]; |
| 119 | |
| 120 | // add section for active script only |
| 121 | if ( isset( $scripts[$active_script] ) ) { |
| 122 | $data[self::TAB_KEY]['sections'][$active_script] = [ |
| 123 | 'title' => $scripts[$active_script]['name'] . ' ' . __( 'Settings', 'responsive-lightbox' ) |
| 124 | ]; |
| 125 | |
| 126 | // add fields for active script |
| 127 | $script_fields = $this->get_configuration_fields( $active_script ); |
| 128 | foreach ( $script_fields as $field_key => $field ) { |
| 129 | $data[self::TAB_KEY]['fields'][$field_key] = $field; |
| 130 | $data[self::TAB_KEY]['fields'][$field_key]['section'] = $active_script; |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | return $data; |
| 135 | } |
| 136 | |
| 137 | /** |
| 138 | * Get configuration fields for a specific script. |
| 139 | * |
| 140 | * @param string $script Script name. |
| 141 | * @return array |
| 142 | */ |
| 143 | private function get_configuration_fields( $script ) { |
| 144 | $scripts = Responsive_Lightbox_Settings_Data::get_scripts(); |
| 145 | |
| 146 | switch ( $script ) { |
| 147 | case 'swipebox': |
| 148 | return [ |
| 149 | 'animation' => [ |
| 150 | 'title' => __( 'Animation Type', 'responsive-lightbox' ), |
| 151 | 'type' => 'radio', |
| 152 | 'label' => '', |
| 153 | 'description' => __( 'Select a method of applying a lightbox effect.', 'responsive-lightbox' ), |
| 154 | 'options' => isset( $scripts['swipebox']['animations'] ) ? $scripts['swipebox']['animations'] : [], |
| 155 | 'parent' => 'swipebox' |
| 156 | ], |
| 157 | 'force_png_icons' => [ |
| 158 | 'title' => __( 'Force PNG Icons', 'responsive-lightbox' ), |
| 159 | 'type' => 'boolean', |
| 160 | 'label' => __( 'Enable this if you\'re having problems with navigation icons not visible on some devices.', 'responsive-lightbox' ), |
| 161 | 'parent' => 'swipebox' |
| 162 | ], |
| 163 | 'hide_close_mobile' => [ |
| 164 | 'title' => __( 'Hide Close on Mobile', 'responsive-lightbox' ), |
| 165 | 'type' => 'boolean', |
| 166 | 'label' => __( 'Hide the close button on mobile devices.', 'responsive-lightbox' ), |
| 167 | 'parent' => 'swipebox' |
| 168 | ], |
| 169 | 'remove_bars_mobile' => [ |
| 170 | 'title' => __( 'Remove Bars on Mobile', 'responsive-lightbox' ), |
| 171 | 'type' => 'boolean', |
| 172 | 'label' => __( 'Hide the top and bottom bars on mobile devices.', 'responsive-lightbox' ), |
| 173 | 'parent' => 'swipebox' |
| 174 | ], |
| 175 | 'hide_bars' => [ |
| 176 | 'title' => __( 'Top and Bottom Bars', 'responsive-lightbox' ), |
| 177 | 'type' => 'multiple', |
| 178 | 'description' => __( 'Hide top and bottom bars after a period of time.', 'responsive-lightbox' ), |
| 179 | 'fields' => [ |
| 180 | 'hide_bars' => [ |
| 181 | 'type' => 'boolean', |
| 182 | 'label' => __( 'Hide top and bottom bars after a period of time.', 'responsive-lightbox' ), |
| 183 | 'parent' => 'swipebox' |
| 184 | ], |
| 185 | 'hide_bars_delay' => [ |
| 186 | 'type' => 'number', |
| 187 | 'description' => __( 'Enter the time after which the top and bottom bars will be hidden (when hiding is enabled).', 'responsive-lightbox' ), |
| 188 | 'append' => 'ms', |
| 189 | 'parent' => 'swipebox' |
| 190 | ] |
| 191 | ], |
| 192 | 'parent' => 'swipebox' |
| 193 | ], |
| 194 | 'video_max_width' => [ |
| 195 | 'title' => __( 'Video Max Width', 'responsive-lightbox' ), |
| 196 | 'type' => 'number', |
| 197 | 'description' => __( 'Enter the max video width in a lightbox.', 'responsive-lightbox' ), |
| 198 | 'append' => 'px', |
| 199 | 'parent' => 'swipebox' |
| 200 | ], |
| 201 | 'loop_at_end' => [ |
| 202 | 'title' => __( 'Loop at End', 'responsive-lightbox' ), |
| 203 | 'type' => 'boolean', |
| 204 | 'label' => __( 'True will return to the first image after the last image is reached.', 'responsive-lightbox' ), |
| 205 | 'parent' => 'swipebox' |
| 206 | ] |
| 207 | ]; |
| 208 | |
| 209 | case 'prettyphoto': |
| 210 | return [ |
| 211 | 'animation_speed' => [ |
| 212 | 'title' => __( 'Animation Speed', 'responsive-lightbox' ), |
| 213 | 'type' => 'radio', |
| 214 | 'label' => '', |
| 215 | 'description' => __( 'Select animation speed for lightbox effect.', 'responsive-lightbox' ), |
| 216 | 'options' => isset( $scripts['prettyphoto']['animation_speeds'] ) ? $scripts['prettyphoto']['animation_speeds'] : [], |
| 217 | 'parent' => 'prettyphoto' |
| 218 | ], |
| 219 | 'slideshow' => [ |
| 220 | 'title' => __( 'Slideshow', 'responsive-lightbox' ), |
| 221 | 'type' => 'multiple', |
| 222 | 'fields' => [ |
| 223 | 'slideshow' => [ |
| 224 | 'type' => 'boolean', |
| 225 | 'label' => __( 'Display images as slideshow', 'responsive-lightbox' ), |
| 226 | 'parent' => 'prettyphoto' |
| 227 | ], |
| 228 | 'slideshow_delay' => [ |
| 229 | 'type' => 'number', |
| 230 | 'description' => __( 'Enter time (in miliseconds).', 'responsive-lightbox' ), |
| 231 | 'append' => 'ms', |
| 232 | 'parent' => 'prettyphoto' |
| 233 | ] |
| 234 | ], |
| 235 | 'parent' => 'prettyphoto' |
| 236 | ], |
| 237 | 'slideshow_autoplay' => [ |
| 238 | 'title' => __( 'Slideshow Autoplay', 'responsive-lightbox' ), |
| 239 | 'type' => 'boolean', |
| 240 | 'label' => __( 'Automatically start slideshow.', 'responsive-lightbox' ), |
| 241 | 'parent' => 'prettyphoto' |
| 242 | ], |
| 243 | 'opacity' => [ |
| 244 | 'title' => __( 'Opacity', 'responsive-lightbox' ), |
| 245 | 'type' => 'range', |
| 246 | 'description' => __( 'Value between 0 and 100, 100 for no opacity.', 'responsive-lightbox' ), |
| 247 | 'min' => 0, |
| 248 | 'max' => 100, |
| 249 | 'parent' => 'prettyphoto' |
| 250 | ], |
| 251 | 'show_title' => [ |
| 252 | 'title' => __( 'Show Title', 'responsive-lightbox' ), |
| 253 | 'type' => 'boolean', |
| 254 | 'label' => __( 'Display image title.', 'responsive-lightbox' ), |
| 255 | 'parent' => 'prettyphoto' |
| 256 | ], |
| 257 | 'allow_resize' => [ |
| 258 | 'title' => __( 'Allow Resize Big Images', 'responsive-lightbox' ), |
| 259 | 'type' => 'boolean', |
| 260 | 'label' => __( 'Resize the photos bigger than viewport.', 'responsive-lightbox' ), |
| 261 | 'parent' => 'prettyphoto' |
| 262 | ], |
| 263 | 'allow_expand' => [ |
| 264 | 'title' => __( 'Allow Expand', 'responsive-lightbox' ), |
| 265 | 'type' => 'boolean', |
| 266 | 'label' => __( 'Allow expanding images.', 'responsive-lightbox' ), |
| 267 | 'parent' => 'prettyphoto' |
| 268 | ], |
| 269 | 'width' => [ |
| 270 | 'title' => __( 'Video Width', 'responsive-lightbox' ), |
| 271 | 'type' => 'number', |
| 272 | 'append' => 'px', |
| 273 | 'parent' => 'prettyphoto' |
| 274 | ], |
| 275 | 'height' => [ |
| 276 | 'title' => __( 'Video Height', 'responsive-lightbox' ), |
| 277 | 'type' => 'number', |
| 278 | 'append' => 'px', |
| 279 | 'parent' => 'prettyphoto' |
| 280 | ], |
| 281 | 'theme' => [ |
| 282 | 'title' => __( 'Theme', 'responsive-lightbox' ), |
| 283 | 'type' => 'radio', |
| 284 | 'description' => __( 'Select the theme for lightbox effect.', 'responsive-lightbox' ), |
| 285 | 'options' => isset( $scripts['prettyphoto']['themes'] ) ? $scripts['prettyphoto']['themes'] : [], |
| 286 | 'parent' => 'prettyphoto' |
| 287 | ], |
| 288 | 'horizontal_padding' => [ |
| 289 | 'title' => __( 'Horizontal Padding', 'responsive-lightbox' ), |
| 290 | 'type' => 'number', |
| 291 | 'append' => 'px', |
| 292 | 'parent' => 'prettyphoto' |
| 293 | ], |
| 294 | 'hide_flash' => [ |
| 295 | 'title' => __( 'Hide Flash', 'responsive-lightbox' ), |
| 296 | 'type' => 'boolean', |
| 297 | 'label' => __( 'Hide all the flash objects on a page. Enable this if flash appears over prettyPhoto.', 'responsive-lightbox' ), |
| 298 | 'parent' => 'prettyphoto' |
| 299 | ], |
| 300 | 'wmode' => [ |
| 301 | 'title' => __( 'Flash Window Mode (wmode)', 'responsive-lightbox' ), |
| 302 | 'type' => 'radio', |
| 303 | 'description' => __( 'Select flash window mode.', 'responsive-lightbox' ), |
| 304 | 'options' => isset( $scripts['prettyphoto']['wmodes'] ) ? $scripts['prettyphoto']['wmodes'] : [], |
| 305 | 'parent' => 'prettyphoto' |
| 306 | ], |
| 307 | 'video_autoplay' => [ |
| 308 | 'title' => __( 'Video Autoplay', 'responsive-lightbox' ), |
| 309 | 'type' => 'boolean', |
| 310 | 'label' => __( 'Automatically start videos.', 'responsive-lightbox' ), |
| 311 | 'parent' => 'prettyphoto' |
| 312 | ], |
| 313 | 'modal' => [ |
| 314 | 'title' => __( 'Modal', 'responsive-lightbox' ), |
| 315 | 'type' => 'boolean', |
| 316 | 'label' => __( 'If set to true, only the close button will close the window.', 'responsive-lightbox' ), |
| 317 | 'parent' => 'prettyphoto' |
| 318 | ], |
| 319 | 'deeplinking' => [ |
| 320 | 'title' => __( 'Deeplinking', 'responsive-lightbox' ), |
| 321 | 'type' => 'boolean', |
| 322 | 'label' => __( 'Allow prettyPhoto to update the url to enable deeplinking.', 'responsive-lightbox' ), |
| 323 | 'parent' => 'prettyphoto' |
| 324 | ], |
| 325 | 'overlay_gallery' => [ |
| 326 | 'title' => __( 'Overlay Gallery', 'responsive-lightbox' ), |
| 327 | 'type' => 'boolean', |
| 328 | 'label' => __( 'If enabled, a gallery will overlay the fullscreen image on mouse over.', 'responsive-lightbox' ), |
| 329 | 'parent' => 'prettyphoto' |
| 330 | ], |
| 331 | 'keyboard_shortcuts' => [ |
| 332 | 'title' => __( 'Keyboard Shortcuts', 'responsive-lightbox' ), |
| 333 | 'type' => 'boolean', |
| 334 | 'label' => __( 'Set to false if you open forms inside prettyPhoto.', 'responsive-lightbox' ), |
| 335 | 'parent' => 'prettyphoto' |
| 336 | ], |
| 337 | 'social' => [ |
| 338 | 'title' => __( 'Social (Twitter, Facebook)', 'responsive-lightbox' ), |
| 339 | 'type' => 'boolean', |
| 340 | 'label' => __( 'Display links to Facebook and Twitter.', 'responsive-lightbox' ), |
| 341 | 'parent' => 'prettyphoto' |
| 342 | ] |
| 343 | ]; |
| 344 | |
| 345 | case 'nivo': |
| 346 | return [ |
| 347 | 'effect' => [ |
| 348 | 'title' => __( 'Effect', 'responsive-lightbox' ), |
| 349 | 'type' => 'radio', |
| 350 | 'description' => __( 'The effect to use when showing the lightbox.', 'responsive-lightbox' ), |
| 351 | 'options' => isset( $scripts['nivo']['effects'] ) ? $scripts['nivo']['effects'] : [], |
| 352 | 'parent' => 'nivo' |
| 353 | ], |
| 354 | 'keyboard_nav' => [ |
| 355 | 'title' => __( 'Keyboard Navigation', 'responsive-lightbox' ), |
| 356 | 'type' => 'boolean', |
| 357 | 'label' => __( 'Enable keyboard navigation (left/right/escape).', 'responsive-lightbox' ), |
| 358 | 'parent' => 'nivo' |
| 359 | ], |
| 360 | 'click_overlay_to_close' => [ |
| 361 | 'title' => __( 'Click Overlay to Close', 'responsive-lightbox' ), |
| 362 | 'type' => 'boolean', |
| 363 | 'label' => __( 'Enable to close lightbox on overlay click.', 'responsive-lightbox' ), |
| 364 | 'parent' => 'nivo' |
| 365 | ], |
| 366 | 'error_message' => [ |
| 367 | 'title' => __( 'Error Message', 'responsive-lightbox' ), |
| 368 | 'type' => 'text', |
| 369 | 'class' => 'large-text', |
| 370 | 'label' => __( 'Error message if the content cannot be loaded.', 'responsive-lightbox' ), |
| 371 | 'parent' => 'nivo' |
| 372 | ] |
| 373 | ]; |
| 374 | |
| 375 | case 'imagelightbox': |
| 376 | return [ |
| 377 | 'animation_speed' => [ |
| 378 | 'title' => __( 'Animation Speed', 'responsive-lightbox' ), |
| 379 | 'type' => 'number', |
| 380 | 'description' => __( 'Animation speed.', 'responsive-lightbox' ), |
| 381 | 'append' => 'ms', |
| 382 | 'parent' => 'imagelightbox' |
| 383 | ], |
| 384 | 'preload_next' => [ |
| 385 | 'title' => __( 'Preload Next Image', 'responsive-lightbox' ), |
| 386 | 'type' => 'boolean', |
| 387 | 'label' => __( 'Silently preload the next image.', 'responsive-lightbox' ), |
| 388 | 'parent' => 'imagelightbox' |
| 389 | ], |
| 390 | 'enable_keyboard' => [ |
| 391 | 'title' => __( 'Enable Keyboard Keys', 'responsive-lightbox' ), |
| 392 | 'type' => 'boolean', |
| 393 | 'label' => __( 'Enable keyboard shortcuts (arrows Left/Right and Esc).', 'responsive-lightbox' ), |
| 394 | 'parent' => 'imagelightbox' |
| 395 | ], |
| 396 | 'quit_on_end' => [ |
| 397 | 'title' => __( 'Quit After Last Image', 'responsive-lightbox' ), |
| 398 | 'type' => 'boolean', |
| 399 | 'label' => __( 'Quit after viewing the last image.', 'responsive-lightbox' ), |
| 400 | 'parent' => 'imagelightbox' |
| 401 | ], |
| 402 | 'quit_on_image_click' => [ |
| 403 | 'title' => __( 'Quit On Image Click', 'responsive-lightbox' ), |
| 404 | 'type' => 'boolean', |
| 405 | 'label' => __( 'Quit when the viewed image is clicked.', 'responsive-lightbox' ), |
| 406 | 'parent' => 'imagelightbox' |
| 407 | ], |
| 408 | 'quit_on_document_click' => [ |
| 409 | 'title' => __( 'Quit On Anything Click', 'responsive-lightbox' ), |
| 410 | 'type' => 'boolean', |
| 411 | 'label' => __( 'Quit when anything but the viewed image is clicked.', 'responsive-lightbox' ), |
| 412 | 'parent' => 'imagelightbox' |
| 413 | ] |
| 414 | ]; |
| 415 | |
| 416 | case 'tosrus': |
| 417 | return [ |
| 418 | 'effect' => [ |
| 419 | 'title' => __( 'Transition Effect', 'responsive-lightbox' ), |
| 420 | 'type' => 'radio', |
| 421 | 'description' => __( 'What effect to use for the transition.', 'responsive-lightbox' ), |
| 422 | 'options' => [ |
| 423 | 'slide' => __( 'slide', 'responsive-lightbox' ), |
| 424 | 'fade' => __( 'fade', 'responsive-lightbox' ) |
| 425 | ], |
| 426 | 'parent' => 'tosrus' |
| 427 | ], |
| 428 | 'infinite' => [ |
| 429 | 'title' => __( 'Infinite Loop', 'responsive-lightbox' ), |
| 430 | 'type' => 'boolean', |
| 431 | 'label' => __( 'Whether or not to slide back to the first slide when the last has been reached.', 'responsive-lightbox' ), |
| 432 | 'parent' => 'tosrus' |
| 433 | ], |
| 434 | 'keys' => [ |
| 435 | 'title' => __( 'Keyboard Navigation', 'responsive-lightbox' ), |
| 436 | 'type' => 'boolean', |
| 437 | 'label' => __( 'Enable keyboard navigation (left/right/escape).', 'responsive-lightbox' ), |
| 438 | 'parent' => 'tosrus' |
| 439 | ], |
| 440 | 'autoplay' => [ |
| 441 | 'title' => __( 'Autoplay', 'responsive-lightbox' ), |
| 442 | 'type' => 'multiple', |
| 443 | 'fields' => [ |
| 444 | 'autoplay' => [ |
| 445 | 'type' => 'boolean', |
| 446 | 'label' => __( 'Automatically start slideshow.', 'responsive-lightbox' ), |
| 447 | 'parent' => 'tosrus' |
| 448 | ], |
| 449 | 'timeout' => [ |
| 450 | 'type' => 'number', |
| 451 | 'description' => __( 'The timeout between sliding to the next slide in milliseconds.', 'responsive-lightbox' ), |
| 452 | 'append' => 'ms', |
| 453 | 'parent' => 'tosrus' |
| 454 | ] |
| 455 | ], |
| 456 | 'parent' => 'tosrus' |
| 457 | ], |
| 458 | 'pause_on_hover' => [ |
| 459 | 'title' => __( 'Pause On Hover', 'responsive-lightbox' ), |
| 460 | 'type' => 'boolean', |
| 461 | 'label' => __( 'Whether or not to pause on hover.', 'responsive-lightbox' ), |
| 462 | 'parent' => 'tosrus' |
| 463 | ], |
| 464 | 'pagination' => [ |
| 465 | 'title' => __( 'Pagination', 'responsive-lightbox' ), |
| 466 | 'type' => 'multiple', |
| 467 | 'fields' => [ |
| 468 | 'pagination' => [ |
| 469 | 'type' => 'boolean', |
| 470 | 'label' => __( 'Whether or not to add a pagination.', 'responsive-lightbox' ), |
| 471 | 'parent' => 'tosrus' |
| 472 | ], |
| 473 | 'pagination_type' => [ |
| 474 | 'type' => 'radio', |
| 475 | 'description' => __( 'What type of pagination to use.', 'responsive-lightbox' ), |
| 476 | 'options' => [ |
| 477 | 'bullets' => __( 'Bullets', 'responsive-lightbox' ), |
| 478 | 'thumbnails' => __( 'Thumbnails', 'responsive-lightbox' ) |
| 479 | ], |
| 480 | 'parent' => 'tosrus' |
| 481 | ] |
| 482 | ], |
| 483 | 'parent' => 'tosrus' |
| 484 | ], |
| 485 | 'close_on_click' => [ |
| 486 | 'title' => __( 'Overlay Close', 'responsive-lightbox' ), |
| 487 | 'type' => 'boolean', |
| 488 | 'label' => __( 'Enable to close lightbox on overlay click.', 'responsive-lightbox' ), |
| 489 | 'parent' => 'tosrus' |
| 490 | ] |
| 491 | ]; |
| 492 | |
| 493 | case 'featherlight': |
| 494 | return [ |
| 495 | 'open_speed' => [ |
| 496 | 'title' => __( 'Opening Speed', 'responsive-lightbox' ), |
| 497 | 'type' => 'number', |
| 498 | 'description' => __( 'Duration of opening animation.', 'responsive-lightbox' ), |
| 499 | 'append' => 'ms', |
| 500 | 'parent' => 'featherlight' |
| 501 | ], |
| 502 | 'close_speed' => [ |
| 503 | 'title' => __( 'Closing Speed', 'responsive-lightbox' ), |
| 504 | 'type' => 'number', |
| 505 | 'description' => __( 'Duration of closing animation.', 'responsive-lightbox' ), |
| 506 | 'append' => 'ms', |
| 507 | 'parent' => 'featherlight' |
| 508 | ], |
| 509 | 'close_on_click' => [ |
| 510 | 'title' => __( 'Close On Click', 'responsive-lightbox' ), |
| 511 | 'type' => 'radio', |
| 512 | 'label' => __( 'Select how to close lightbox.', 'responsive-lightbox' ), |
| 513 | 'options' => [ |
| 514 | 'background' => __( 'background', 'responsive-lightbox' ), |
| 515 | 'anywhere' => __( 'anywhere', 'responsive-lightbox' ), |
| 516 | 'false' => __( 'false', 'responsive-lightbox' ) |
| 517 | ], |
| 518 | 'parent' => 'featherlight' |
| 519 | ], |
| 520 | 'close_on_esc' => [ |
| 521 | 'title' => __( 'Close On Esc', 'responsive-lightbox' ), |
| 522 | 'type' => 'boolean', |
| 523 | 'label' => __( 'Toggle if pressing Esc button closes lightbox.', 'responsive-lightbox' ), |
| 524 | 'parent' => 'featherlight' |
| 525 | ], |
| 526 | 'gallery_fade_in' => [ |
| 527 | 'title' => __( 'Gallery Fade In', 'responsive-lightbox' ), |
| 528 | 'type' => 'number', |
| 529 | 'description' => __( 'Animation speed when image is loaded.', 'responsive-lightbox' ), |
| 530 | 'append' => 'ms', |
| 531 | 'parent' => 'featherlight' |
| 532 | ], |
| 533 | 'gallery_fade_out' => [ |
| 534 | 'title' => __( 'Gallery Fade Out', 'responsive-lightbox' ), |
| 535 | 'type' => 'number', |
| 536 | 'description' => __( 'Animation speed before image is loaded.', 'responsive-lightbox' ), |
| 537 | 'append' => 'ms', |
| 538 | 'parent' => 'featherlight' |
| 539 | ] |
| 540 | ]; |
| 541 | |
| 542 | case 'magnific': |
| 543 | return [ |
| 544 | 'disable_on' => [ |
| 545 | 'title' => __( 'Disable On', 'responsive-lightbox' ), |
| 546 | 'type' => 'number', |
| 547 | 'description' => __( 'If window width is less than the number in this option lightbox will not be opened and the default behavior of the element will be triggered. Set to 0 to disable behavior.', 'responsive-lightbox' ), |
| 548 | 'append' => 'px', |
| 549 | 'parent' => 'magnific' |
| 550 | ], |
| 551 | 'mid_click' => [ |
| 552 | 'title' => __( 'Middle Click', 'responsive-lightbox' ), |
| 553 | 'type' => 'boolean', |
| 554 | 'label' => __( 'If option enabled, lightbox is opened if the user clicked on the middle mouse button, or click with Command/Ctrl key.', 'responsive-lightbox' ), |
| 555 | 'parent' => 'magnific' |
| 556 | ], |
| 557 | 'preloader' => [ |
| 558 | 'title' => __( 'Preloader', 'responsive-lightbox' ), |
| 559 | 'type' => 'boolean', |
| 560 | 'label' => __( 'If option enabled, it\'s always present in DOM only text inside of it changes.', 'responsive-lightbox' ), |
| 561 | 'parent' => 'magnific' |
| 562 | ], |
| 563 | 'close_on_content_click' => [ |
| 564 | 'title' => __( 'Close On Content Click', 'responsive-lightbox' ), |
| 565 | 'type' => 'boolean', |
| 566 | 'label' => __( 'Close popup when user clicks on content of it. It\'s recommended to enable this option when you have only image in popup.', 'responsive-lightbox' ), |
| 567 | 'parent' => 'magnific' |
| 568 | ], |
| 569 | 'close_on_background_click' => [ |
| 570 | 'title' => __( 'Close On Background Click', 'responsive-lightbox' ), |
| 571 | 'type' => 'boolean', |
| 572 | 'label' => __( 'Close the popup when user clicks on the dark overlay.', 'responsive-lightbox' ), |
| 573 | 'parent' => 'magnific' |
| 574 | ], |
| 575 | 'close_button_inside' => [ |
| 576 | 'title' => __( 'Close Button Inside', 'responsive-lightbox' ), |
| 577 | 'type' => 'boolean', |
| 578 | 'label' => __( 'If enabled, Magnific Popup will put close button inside content of popup.', 'responsive-lightbox' ), |
| 579 | 'parent' => 'magnific' |
| 580 | ], |
| 581 | 'show_close_button' => [ |
| 582 | 'title' => __( 'Show Close Button', 'responsive-lightbox' ), |
| 583 | 'type' => 'boolean', |
| 584 | 'label' => __( 'Controls whether the close button will be displayed or not.', 'responsive-lightbox' ), |
| 585 | 'parent' => 'magnific' |
| 586 | ], |
| 587 | 'enable_escape_key' => [ |
| 588 | 'title' => __( 'Enable Escape Key', 'responsive-lightbox' ), |
| 589 | 'type' => 'boolean', |
| 590 | 'label' => __( 'Controls whether pressing the escape key will dismiss the active popup or not.', 'responsive-lightbox' ), |
| 591 | 'parent' => 'magnific' |
| 592 | ], |
| 593 | 'align_top' => [ |
| 594 | 'title' => __( 'Align Top', 'responsive-lightbox' ), |
| 595 | 'type' => 'boolean', |
| 596 | 'label' => __( 'If set to true popup is aligned to top instead of to center.', 'responsive-lightbox' ), |
| 597 | 'parent' => 'magnific' |
| 598 | ], |
| 599 | 'fixed_content_position' => [ |
| 600 | 'title' => __( 'Content Position Type', 'responsive-lightbox' ), |
| 601 | 'type' => 'select', |
| 602 | 'description' => __( 'Popup content position. If set to "auto" popup will automatically disable this option when browser doesn\'t support fixed position properly.', 'responsive-lightbox' ), |
| 603 | 'options' => [ |
| 604 | 'auto' => __( 'Auto', 'responsive-lightbox' ), |
| 605 | 'true' => __( 'Fixed', 'responsive-lightbox' ), |
| 606 | 'false' => __( 'Absolute', 'responsive-lightbox' ) |
| 607 | ], |
| 608 | 'parent' => 'magnific' |
| 609 | ], |
| 610 | 'fixed_background_position' => [ |
| 611 | 'title' => __( 'Fixed Background Position', 'responsive-lightbox' ), |
| 612 | 'type' => 'select', |
| 613 | 'description' => __( 'Dark transluscent overlay content position.', 'responsive-lightbox' ), |
| 614 | 'options' => [ |
| 615 | 'auto' => __( 'Auto', 'responsive-lightbox' ), |
| 616 | 'true' => __( 'Fixed', 'responsive-lightbox' ), |
| 617 | 'false' => __( 'Absolute', 'responsive-lightbox' ) |
| 618 | ], |
| 619 | 'parent' => 'magnific' |
| 620 | ], |
| 621 | 'auto_focus_last' => [ |
| 622 | 'title' => __( 'Auto Focus Last', 'responsive-lightbox' ), |
| 623 | 'type' => 'boolean', |
| 624 | 'label' => __( 'If set to true last focused element before popup showup will be focused after popup close.', 'responsive-lightbox' ), |
| 625 | 'parent' => 'magnific' |
| 626 | ] |
| 627 | ]; |
| 628 | |
| 629 | case 'glightbox': |
| 630 | return [ |
| 631 | 'slide_effect' => [ |
| 632 | 'title' => __( 'Slide Effect', 'responsive-lightbox' ), |
| 633 | 'type' => 'select', |
| 634 | 'description' => __( 'Select the slide effect.', 'responsive-lightbox' ), |
| 635 | 'options' => [ |
| 636 | 'slide' => __( 'Slide', 'responsive-lightbox' ), |
| 637 | 'fade' => __( 'Fade', 'responsive-lightbox' ), |
| 638 | 'zoom' => __( 'Zoom', 'responsive-lightbox' ), |
| 639 | 'none' => __( 'None', 'responsive-lightbox' ) |
| 640 | ], |
| 641 | 'parent' => 'glightbox' |
| 642 | ], |
| 643 | 'close_button' => [ |
| 644 | 'title' => __( 'Close Button', 'responsive-lightbox' ), |
| 645 | 'type' => 'boolean', |
| 646 | 'label' => __( 'Display the close button.', 'responsive-lightbox' ), |
| 647 | 'parent' => 'glightbox' |
| 648 | ], |
| 649 | 'touch_navigation' => [ |
| 650 | 'title' => __( 'Touch Navigation', 'responsive-lightbox' ), |
| 651 | 'type' => 'boolean', |
| 652 | 'label' => __( 'Enable touch navigation.', 'responsive-lightbox' ), |
| 653 | 'parent' => 'glightbox' |
| 654 | ], |
| 655 | 'keyboard_navigation' => [ |
| 656 | 'title' => __( 'Keyboard Navigation', 'responsive-lightbox' ), |
| 657 | 'type' => 'boolean', |
| 658 | 'label' => __( 'Enable keyboard navigation.', 'responsive-lightbox' ), |
| 659 | 'parent' => 'glightbox' |
| 660 | ], |
| 661 | 'close_on_outside_click' => [ |
| 662 | 'title' => __( 'Close on Outside Click', 'responsive-lightbox' ), |
| 663 | 'type' => 'boolean', |
| 664 | 'label' => __( 'Close the lightbox when clicking outside of the content.', 'responsive-lightbox' ), |
| 665 | 'parent' => 'glightbox' |
| 666 | ], |
| 667 | 'loop' => [ |
| 668 | 'title' => __( 'Loop', 'responsive-lightbox' ), |
| 669 | 'type' => 'boolean', |
| 670 | 'label' => __( 'Enable loop.', 'responsive-lightbox' ), |
| 671 | 'parent' => 'glightbox' |
| 672 | ], |
| 673 | 'zoomable' => [ |
| 674 | 'title' => __( 'Zoomable', 'responsive-lightbox' ), |
| 675 | 'type' => 'boolean', |
| 676 | 'label' => __( 'Enable zoomable images.', 'responsive-lightbox' ), |
| 677 | 'parent' => 'glightbox' |
| 678 | ] |
| 679 | ]; |
| 680 | |
| 681 | default: |
| 682 | $fields = apply_filters( 'rl_settings_' . $script . '_script_configuration_fields', [] ); |
| 683 | |
| 684 | if ( ! empty( $fields ) && is_array( $fields ) ) |
| 685 | return $fields; |
| 686 | |
| 687 | // Fallback to legacy filter used by add-ons. |
| 688 | $default_name = isset( $scripts[$script]['name'] ) ? $scripts[$script]['name'] : $script; |
| 689 | $legacy_config = apply_filters( |
| 690 | 'rl_settings_' . $script . '_script_configuration', |
| 691 | [ |
| 692 | 'option_group' => 'responsive_lightbox_configuration', |
| 693 | 'option_name' => 'responsive_lightbox_configuration', |
| 694 | 'sections' => [ |
| 695 | 'responsive_lightbox_configuration' => [ |
| 696 | 'title' => sprintf( __( '%s Settings', 'responsive-lightbox' ), $default_name ) |
| 697 | ] |
| 698 | ], |
| 699 | 'prefix' => 'rl', |
| 700 | 'fields' => [] |
| 701 | ] |
| 702 | ); |
| 703 | |
| 704 | if ( ! empty( $legacy_config['fields'] ) && is_array( $legacy_config['fields'] ) ) |
| 705 | return $legacy_config['fields']; |
| 706 | |
| 707 | return []; |
| 708 | } |
| 709 | } |
| 710 | } |
| 711 |