class-frontend.php
8 years ago
class-galleries.php
8 years ago
class-settings.php
8 years ago
class-tour.php
8 years ago
class-welcome.php
8 years ago
class-widgets.php
8 years ago
functions.php
8 years ago
class-settings.php
2356 lines
| 1 | <?php |
| 2 | // exit if accessed directly |
| 3 | if ( ! defined( 'ABSPATH' ) ) |
| 4 | exit; |
| 5 | |
| 6 | new Responsive_Lightbox_Settings(); |
| 7 | |
| 8 | /** |
| 9 | * Responsive Lightbox settings class. |
| 10 | * |
| 11 | * @class Responsive_Lightbox_Settings |
| 12 | */ |
| 13 | class Responsive_Lightbox_Settings { |
| 14 | |
| 15 | public $settings = array(); |
| 16 | public $tabs = array(); |
| 17 | public $scripts = array(); |
| 18 | private $choices = array(); |
| 19 | private $loading_places = array(); |
| 20 | private $api_url = 'http://dfactory.eu'; |
| 21 | |
| 22 | public function __construct() { |
| 23 | |
| 24 | // set instance |
| 25 | Responsive_Lightbox()->settings = $this; |
| 26 | |
| 27 | // actions |
| 28 | add_action( 'admin_init', array( $this, 'register_settings' ) ); |
| 29 | add_action( 'admin_menu', array( $this, 'admin_menu_options' ) ); |
| 30 | add_action( 'after_setup_theme', array( $this, 'load_defaults' ) ); |
| 31 | add_action( 'init', array( $this, 'init_builder' ) ); |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Initialize additional stuff for builder. |
| 36 | * |
| 37 | * @return void |
| 38 | */ |
| 39 | public function init_builder() { |
| 40 | // add categories |
| 41 | if ( Responsive_Lightbox()->options['builder']['gallery_builder'] && Responsive_Lightbox()->options['builder']['categories'] && Responsive_Lightbox()->options['builder']['archives'] ) { |
| 42 | $terms = get_terms( array( 'taxonomy' => 'rl_category', 'hide_empty' => false ) ); |
| 43 | |
| 44 | if ( ! empty( $terms ) ) { |
| 45 | foreach ( $terms as $term ) { |
| 46 | $this->settings['builder']['fields']['archives_category']['options'][$term->slug] = $term->name; |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | // flush rewrite rules if needed |
| 52 | if ( isset( $_GET['flush_rules'] ) ) |
| 53 | flush_rewrite_rules(); |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Load default settings. |
| 58 | * |
| 59 | * @return void |
| 60 | */ |
| 61 | public function load_defaults() { |
| 62 | $this->scripts = apply_filters( 'rl_settings_scripts', array( |
| 63 | 'swipebox' => array( |
| 64 | 'name' => __( 'SwipeBox', 'responsive-lightbox' ), |
| 65 | 'animations' => array( |
| 66 | 'css' => __( 'CSS', 'responsive-lightbox' ), |
| 67 | 'jquery' => __( 'jQuery', 'responsive-lightbox' ) |
| 68 | ), |
| 69 | 'supports' => array( 'title' ) |
| 70 | ), |
| 71 | 'prettyphoto' => array( |
| 72 | 'name' => __( 'prettyPhoto', 'responsive-lightbox' ), |
| 73 | 'animation_speeds' => array( |
| 74 | 'slow' => __( 'slow', 'responsive-lightbox' ), |
| 75 | 'normal' => __( 'normal', 'responsive-lightbox' ), |
| 76 | 'fast' => __( 'fast', 'responsive-lightbox' ) |
| 77 | ), |
| 78 | 'themes' => array( |
| 79 | 'pp_default' => __( 'default', 'responsive-lightbox' ), |
| 80 | 'light_rounded' => __( 'light rounded', 'responsive-lightbox' ), |
| 81 | 'dark_rounded' => __( 'dark rounded', 'responsive-lightbox' ), |
| 82 | 'light_square' => __( 'light square', 'responsive-lightbox' ), |
| 83 | 'dark_square' => __( 'dark square', 'responsive-lightbox' ), |
| 84 | 'facebook' => __( 'facebook', 'responsive-lightbox' ) |
| 85 | ), |
| 86 | 'wmodes' => array( |
| 87 | 'window' => __( 'window', 'responsive-lightbox' ), |
| 88 | 'transparent' => __( 'transparent', 'responsive-lightbox' ), |
| 89 | 'opaque' => __( 'opaque', 'responsive-lightbox' ), |
| 90 | 'direct' => __( 'direct', 'responsive-lightbox' ), |
| 91 | 'gpu' => __( 'gpu', 'responsive-lightbox' ) |
| 92 | ), |
| 93 | 'supports' => array( 'inline', 'iframe', 'ajax', 'title', 'caption' ) |
| 94 | ), |
| 95 | 'fancybox' => array( |
| 96 | 'name' => __( 'FancyBox', 'responsive-lightbox' ), |
| 97 | 'transitions' => array( |
| 98 | 'elastic' => __( 'elastic', 'responsive-lightbox' ), |
| 99 | 'fade' => __( 'fade', 'responsive-lightbox' ), |
| 100 | 'none' => __( 'none', 'responsive-lightbox' ) |
| 101 | ), |
| 102 | 'scrollings' => array( |
| 103 | 'auto' => __( 'auto', 'responsive-lightbox' ), |
| 104 | 'yes' => __( 'yes', 'responsive-lightbox' ), |
| 105 | 'no' => __( 'no', 'responsive-lightbox' ) |
| 106 | ), |
| 107 | 'easings' => array( |
| 108 | 'swing' => __( 'swing', 'responsive-lightbox' ), |
| 109 | 'linear' => __( 'linear', 'responsive-lightbox' ) |
| 110 | ), |
| 111 | 'positions' => array( |
| 112 | 'outside' => __( 'outside', 'responsive-lightbox' ), |
| 113 | 'inside' => __( 'inside', 'responsive-lightbox' ), |
| 114 | 'over' => __( 'over', 'responsive-lightbox' ) |
| 115 | ), |
| 116 | 'supports' => array( 'inline', 'iframe', 'ajax', 'title' ) |
| 117 | ), |
| 118 | 'nivo' => array( |
| 119 | 'name' => __( 'Nivo Lightbox', 'responsive-lightbox' ), |
| 120 | 'effects' => array( |
| 121 | 'fade' => __( 'fade', 'responsive-lightbox' ), |
| 122 | 'fadeScale' => __( 'fade scale', 'responsive-lightbox' ), |
| 123 | 'slideLeft' => __( 'slide left', 'responsive-lightbox' ), |
| 124 | 'slideRight' => __( 'slide right', 'responsive-lightbox' ), |
| 125 | 'slideUp' => __( 'slide up', 'responsive-lightbox' ), |
| 126 | 'slideDown' => __( 'slide down', 'responsive-lightbox' ), |
| 127 | 'fall' => __( 'fall', 'responsive-lightbox' ) |
| 128 | ), |
| 129 | 'supports' => array( 'inline', 'iframe', 'ajax', 'title' ) |
| 130 | ), |
| 131 | 'imagelightbox' => array( |
| 132 | 'name' => __( 'Image Lightbox', 'responsive-lightbox' ), |
| 133 | 'supports' => array() |
| 134 | ), |
| 135 | 'tosrus' => array( |
| 136 | 'name' => __( 'TosRUs', 'responsive-lightbox' ), |
| 137 | 'supports' => array( 'inline', 'title' ) |
| 138 | ), |
| 139 | 'featherlight' => array( |
| 140 | 'name' => __( 'Featherlight', 'responsive-lightbox' ), |
| 141 | 'supports' => array( 'inline', 'iframe', 'ajax' ) |
| 142 | ), |
| 143 | 'magnific' => array( |
| 144 | 'name' => __( 'Magnific Popup', 'responsive-lightbox' ), |
| 145 | 'supports' => array( 'inline', 'iframe', 'ajax', 'title', 'caption' ) |
| 146 | ) |
| 147 | ) ); |
| 148 | |
| 149 | $this->image_titles = array( |
| 150 | 'default' => __( 'None', 'responsive-lightbox' ), |
| 151 | 'title' => __( 'Image Title', 'responsive-lightbox' ), |
| 152 | 'caption' => __( 'Image Caption', 'responsive-lightbox' ), |
| 153 | 'alt' => __( 'Image Alt Text', 'responsive-lightbox' ), |
| 154 | 'description' => __( 'Image Description', 'responsive-lightbox' ) |
| 155 | ); |
| 156 | |
| 157 | $this->image_icons = array( |
| 158 | '0' => __( 'none', 'responsive-lightbox' ), |
| 159 | '1' => '', |
| 160 | '2' => '', |
| 161 | '3' => '', |
| 162 | '4' => '', |
| 163 | '5' => '', |
| 164 | '6' => '', |
| 165 | '7' => '', |
| 166 | '8' => '', |
| 167 | '9' => '', |
| 168 | '10' => '' |
| 169 | ); |
| 170 | |
| 171 | $this->loading_places = array( |
| 172 | 'header' => __( 'Header', 'responsive-lightbox' ), |
| 173 | 'footer' => __( 'Footer', 'responsive-lightbox' ) |
| 174 | ); |
| 175 | |
| 176 | // get scripts |
| 177 | foreach ( $this->scripts as $key => $value ) { |
| 178 | $scripts[$key] = $value['name']; |
| 179 | } |
| 180 | |
| 181 | // get image sizes |
| 182 | $sizes = apply_filters( 'image_size_names_choose', array( |
| 183 | 'thumbnail' => __( 'Thumbnail', 'responsive-lightbox' ), |
| 184 | 'medium' => __( 'Medium', 'responsive-lightbox' ), |
| 185 | 'large' => __( 'Large', 'responsive-lightbox' ), |
| 186 | 'full' => __( 'Full Size', 'responsive-lightbox' ), |
| 187 | ) ); |
| 188 | |
| 189 | // prepare galeries |
| 190 | $galleries = $builder_galleries = wp_parse_args( apply_filters( 'rl_gallery_types', array() ), Responsive_Lightbox()->gallery_types ); |
| 191 | |
| 192 | unset( $builder_galleries['default'] ); |
| 193 | |
| 194 | $this->settings = array( |
| 195 | 'settings' => array( |
| 196 | 'option_group' => 'responsive_lightbox_settings', |
| 197 | 'option_name' => 'responsive_lightbox_settings', |
| 198 | 'sections' => array( |
| 199 | 'responsive_lightbox_settings' => array( |
| 200 | 'title' => __( 'General settings', 'responsive-lightbox' ) |
| 201 | ) |
| 202 | ), |
| 203 | 'prefix' => 'rl', |
| 204 | 'fields' => array( |
| 205 | 'tour' => array( |
| 206 | 'title' => __( 'Introduction Tour', 'responsive-lightbox' ), |
| 207 | 'section' => 'responsive_lightbox_settings', |
| 208 | 'type' => 'button', |
| 209 | 'label' => __( 'Start Tour', 'responsive-lightbox' ), |
| 210 | 'description' => __( 'Take this tour to quickly learn about the use of this plugin.', 'responsive-lightbox' ) |
| 211 | ), |
| 212 | 'script' => array( |
| 213 | // 'name' => '', |
| 214 | 'title' => __( 'Default lightbox', 'responsive-lightbox' ), |
| 215 | // 'callback' => '', |
| 216 | // 'page' => '', |
| 217 | 'section' => 'responsive_lightbox_settings', |
| 218 | 'type' => 'radio', |
| 219 | 'label' => '', |
| 220 | 'description' => sprintf(__( 'Select your preffered ligthbox effect script or get our <a href="%s">premium extensions</a>.', 'responsive-lightbox' ), wp_nonce_url( add_query_arg( array( 'action' => 'rl-hide-notice' ), admin_url( 'admin.php?page=responsive-lightbox-addons' ) ), 'rl_action', 'rl_nonce' ) ), |
| 221 | 'options' => $scripts |
| 222 | // 'options_cb' => '', |
| 223 | // 'id' => '', |
| 224 | // 'class' => array(), |
| 225 | ), |
| 226 | 'selector' => array( |
| 227 | 'title' => __( 'Selector', 'responsive-lightbox' ), |
| 228 | 'section' => 'responsive_lightbox_settings', |
| 229 | 'type' => 'text', |
| 230 | 'description' => __( 'Enter the rel selector lightbox effect will be applied to.', 'responsive-lightbox' ) |
| 231 | ), |
| 232 | 'image_links' => array( |
| 233 | 'title' => __( 'Images', 'responsive-lightbox' ), |
| 234 | 'section' => 'responsive_lightbox_settings', |
| 235 | 'type' => 'boolean', |
| 236 | 'label' => __( 'Enable lightbox for WordPress image links.', 'responsive-lightbox' ) |
| 237 | ), |
| 238 | 'image_title' => array( |
| 239 | 'title' => __( 'Single image title', 'responsive-lightbox' ), |
| 240 | 'section' => 'responsive_lightbox_settings', |
| 241 | 'type' => 'select', |
| 242 | 'description' => __( 'Select title for single images.', 'responsive-lightbox' ), |
| 243 | 'options' => $this->image_titles |
| 244 | ), |
| 245 | 'image_caption' => array( |
| 246 | 'title' => __( 'Single image caption', 'responsive-lightbox' ), |
| 247 | 'section' => 'responsive_lightbox_settings', |
| 248 | 'type' => 'select', |
| 249 | 'description' => __( 'Select caption for single images (if supported by selected lightbox and/or gallery).', 'responsive-lightbox' ), |
| 250 | 'options' => $this->image_titles |
| 251 | ), |
| 252 | 'images_as_gallery' => array( |
| 253 | 'title' => __( 'Single images as gallery', 'responsive-lightbox' ), |
| 254 | 'section' => 'responsive_lightbox_settings', |
| 255 | 'type' => 'boolean', |
| 256 | 'label' => __( 'Display single post images as a gallery.', 'responsive-lightbox' ) |
| 257 | ), |
| 258 | 'galleries' => array( |
| 259 | 'title' => __( 'Galleries', 'responsive-lightbox' ), |
| 260 | 'section' => 'responsive_lightbox_settings', |
| 261 | 'type' => 'boolean', |
| 262 | 'label' => __( 'Enable lightbox for WordPress image galleries.', 'responsive-lightbox' ) |
| 263 | ), |
| 264 | 'default_gallery' => array( |
| 265 | 'title' => __( 'WordPress gallery', 'responsive-lightbox' ), |
| 266 | 'section' => 'responsive_lightbox_settings', |
| 267 | 'type' => 'radio', |
| 268 | 'description' => __( 'Select your preffered default WordPress gallery style.', 'responsive-lightbox' ), |
| 269 | 'options' => $galleries |
| 270 | ), |
| 271 | 'builder_gallery' => array( |
| 272 | 'title' => __( 'Builder gallery', 'responsive-lightbox' ), |
| 273 | 'section' => 'responsive_lightbox_settings', |
| 274 | 'type' => 'radio', |
| 275 | 'description' => __( 'Select your preffered default builder gallery style.', 'responsive-lightbox' ), |
| 276 | 'options' => $builder_galleries |
| 277 | ), |
| 278 | 'default_woocommerce_gallery' => array( |
| 279 | 'title' => __( 'WooCommerce gallery', 'rl-justified-gallery' ), |
| 280 | 'section' => 'responsive_lightbox_settings', |
| 281 | 'type' => 'radio', |
| 282 | 'disabled' => ! class_exists( 'WooCommerce' ), |
| 283 | 'description' => __( 'Select your preffered gallery style for WooCommerce product gallery.', 'responsive-lightbox' ), |
| 284 | 'options' => $galleries |
| 285 | ), |
| 286 | 'gallery_image_size' => array( |
| 287 | 'title' => __( 'Gallery image size', 'responsive-lightbox' ), |
| 288 | 'section' => 'responsive_lightbox_settings', |
| 289 | 'type' => 'select', |
| 290 | 'description' => __( 'Select image size for gallery image links.', 'responsive-lightbox' ), |
| 291 | 'options' => $sizes |
| 292 | ), |
| 293 | 'gallery_image_title' => array( |
| 294 | 'title' => __( 'Gallery image title', 'responsive-lightbox' ), |
| 295 | 'section' => 'responsive_lightbox_settings', |
| 296 | 'type' => 'select', |
| 297 | 'description' => __( 'Select title for the gallery images.', 'responsive-lightbox' ), |
| 298 | 'options' => $this->image_titles |
| 299 | ), |
| 300 | 'gallery_image_caption' => array( |
| 301 | 'title' => __( 'Gallery image caption', 'responsive-lightbox' ), |
| 302 | 'section' => 'responsive_lightbox_settings', |
| 303 | 'type' => 'select', |
| 304 | 'description' => __( 'Select caption for the gallery images (if supported by selected lightbox and/or gallery).', 'responsive-lightbox' ), |
| 305 | 'options' => $this->image_titles |
| 306 | ), |
| 307 | 'videos' => array( |
| 308 | 'title' => __( 'Videos', 'responsive-lightbox' ), |
| 309 | 'section' => 'responsive_lightbox_settings', |
| 310 | 'type' => 'boolean', |
| 311 | 'label' => __( 'Enable lightbox for YouTube and Vimeo video links.', 'responsive-lightbox' ) |
| 312 | ), |
| 313 | 'widgets' => array( |
| 314 | 'title' => __( 'Widgets', 'responsive-lightbox' ), |
| 315 | 'section' => 'responsive_lightbox_settings', |
| 316 | 'type' => 'boolean', |
| 317 | 'label' => __( 'Enable lightbox for widgets content.', 'responsive-lightbox' ) |
| 318 | ), |
| 319 | 'comments' => array( |
| 320 | 'title' => __( 'Comments', 'responsive-lightbox' ), |
| 321 | 'section' => 'responsive_lightbox_settings', |
| 322 | 'type' => 'boolean', |
| 323 | 'label' => __( 'Enable lightbox for comments content.', 'responsive-lightbox' ) |
| 324 | ), |
| 325 | 'force_custom_gallery' => array( |
| 326 | 'title' => __( 'Force lightbox', 'responsive-lightbox' ), |
| 327 | 'section' => 'responsive_lightbox_settings', |
| 328 | 'type' => 'boolean', |
| 329 | 'label' => __( 'Try to force lightbox for custom WP gallery replacements, like Jetpack or Visual Composer galleries.', 'responsive-lightbox' ) |
| 330 | ), |
| 331 | 'woocommerce_gallery_lightbox' => array( |
| 332 | 'title' => __( 'WooCommerce lightbox', 'responsive-lightbox' ), |
| 333 | 'section' => 'responsive_lightbox_settings', |
| 334 | 'type' => 'boolean', |
| 335 | 'label' => __( 'Replace WooCommerce product gallery lightbox.', 'responsive-lightbox' ), |
| 336 | 'disabled' => ! class_exists( 'WooCommerce' ) |
| 337 | ), |
| 338 | 'enable_custom_events' => array( |
| 339 | 'title' => __( 'Custom events', 'responsive-lightbox' ), |
| 340 | 'section' => 'responsive_lightbox_settings', |
| 341 | 'type' => 'multiple', |
| 342 | 'fields' => array( |
| 343 | 'enable_custom_events' => array( |
| 344 | 'type' => 'boolean', |
| 345 | 'label' => __( 'Enable triggering lightbox on custom jQuery events.', 'responsive-lightbox' ) |
| 346 | ), |
| 347 | 'custom_events' => array( |
| 348 | 'type' => 'text', |
| 349 | 'description' => __( 'Enter a space separated list of events.', 'responsive-lightbox' ) |
| 350 | ) |
| 351 | ) |
| 352 | ), |
| 353 | 'loading_place' => array( |
| 354 | 'title' => __( 'Loading place', 'responsive-lightbox' ), |
| 355 | 'section' => 'responsive_lightbox_settings', |
| 356 | 'type' => 'radio', |
| 357 | 'description' => __( 'Select where all the lightbox scripts should be placed.', 'responsive-lightbox' ), |
| 358 | 'options' => $this->loading_places |
| 359 | ), |
| 360 | 'conditional_loading' => array( |
| 361 | 'title' => __( 'Conditional loading', 'responsive-lightbox' ), |
| 362 | 'section' => 'responsive_lightbox_settings', |
| 363 | 'type' => 'boolean', |
| 364 | 'label' => __( 'Enable to load scripts and styles only on pages that have images or galleries in post content.', 'responsive-lightbox' ) |
| 365 | ), |
| 366 | 'deactivation_delete' => array( |
| 367 | 'title' => __( 'Delete data', 'responsive-lightbox' ), |
| 368 | 'section' => 'responsive_lightbox_settings', |
| 369 | 'type' => 'boolean', |
| 370 | 'label' => __( 'Delete all plugin settings on deactivation.', 'responsive-lightbox' ) |
| 371 | ) |
| 372 | ) |
| 373 | ), |
| 374 | 'builder' => array( |
| 375 | 'option_group' => 'responsive_lightbox_builder', |
| 376 | 'option_name' => 'responsive_lightbox_builder', |
| 377 | 'sections' => array( |
| 378 | 'responsive_lightbox_builder' => array( |
| 379 | 'title' => __( 'Gallery Builder Settings', 'responsive-lightbox' ) |
| 380 | ) |
| 381 | ), |
| 382 | 'prefix' => 'rl', |
| 383 | 'fields' => array( |
| 384 | 'gallery_builder' => array( |
| 385 | 'title' => __( 'Gallery Builder', 'responsive-lightbox' ), |
| 386 | 'section' => 'responsive_lightbox_builder', |
| 387 | 'type' => 'boolean', |
| 388 | 'label' => __( 'Enable advanced gallery builder.', 'responsive-lightbox' ) |
| 389 | ), |
| 390 | 'categories' => array( |
| 391 | 'title' => __( 'Categories', 'responsive-lightbox' ), |
| 392 | 'section' => 'responsive_lightbox_builder', |
| 393 | 'type' => 'boolean', |
| 394 | 'label' => __( 'Enable Gallery Categories.', 'responsive-lightbox' ), |
| 395 | 'description' => __( 'Enable if you want to use Gallery Categories.', 'responsive-lightbox' ) |
| 396 | ), |
| 397 | 'tags' => array( |
| 398 | 'title' => __( 'Tags', 'responsive-lightbox' ), |
| 399 | 'section' => 'responsive_lightbox_builder', |
| 400 | 'type' => 'boolean', |
| 401 | 'label' => __( 'Enable Gallery Tags.', 'responsive-lightbox' ), |
| 402 | 'description' => __( 'Enable if you want to use Gallery Tags.', 'responsive-lightbox' ) |
| 403 | ), |
| 404 | 'permalink' => array( |
| 405 | 'title' => __( 'Gallery Permalink', 'responsive-lightbox' ), |
| 406 | 'section' => 'responsive_lightbox_builder', |
| 407 | 'type' => 'text', |
| 408 | 'description' => '<code>' . site_url() . '/<strong>' . untrailingslashit( esc_html( Responsive_Lightbox()->options['builder']['permalink'] ) ) . '</strong>/</code><br />' . __( 'Enter gallery page slug.', 'responsive-lightbox' ) |
| 409 | ), |
| 410 | 'permalink_categories' => array( |
| 411 | 'title' => __( 'Categories Permalink', 'responsive-lightbox' ), |
| 412 | 'section' => 'responsive_lightbox_builder', |
| 413 | 'type' => 'text', |
| 414 | 'description' => '<code>' . site_url() . '/<strong>' . untrailingslashit( esc_html( Responsive_Lightbox()->options['builder']['permalink_categories'] ) ) . '</strong>/</code><br />' . __( 'Enter gallery categories archive page slug.', 'responsive-lightbox' ) |
| 415 | ), |
| 416 | 'permalink_tags' => array( |
| 417 | 'title' => __( 'Tags Permalink', 'responsive-lightbox' ), |
| 418 | 'section' => 'responsive_lightbox_builder', |
| 419 | 'type' => 'text', |
| 420 | 'description' => '<code>' . site_url() . '/<strong>' . untrailingslashit( esc_html( Responsive_Lightbox()->options['builder']['permalink_tags'] ) ) . '</strong>/</code><br />' . __( 'Enter gallery tags archive page slug.', 'responsive-lightbox' ) |
| 421 | ), |
| 422 | 'archives' => array( |
| 423 | 'title' => __( 'Archives', 'responsive-lightbox' ), |
| 424 | 'section' => 'responsive_lightbox_builder', |
| 425 | 'type' => 'boolean', |
| 426 | 'label' => __( 'Enable gallery archives.', 'responsive-lightbox' ) |
| 427 | ), |
| 428 | 'archives_category' => array( |
| 429 | 'title' => __( 'Archives category', 'responsive-lightbox' ), |
| 430 | 'section' => 'responsive_lightbox_builder', |
| 431 | 'type' => 'select', |
| 432 | 'description' => __( 'Select category for gallery archives.', 'responsive-lightbox' ), |
| 433 | 'options' => array( |
| 434 | 'all' => __( 'All', 'responsive-lightbox' ) |
| 435 | ) |
| 436 | ) |
| 437 | ) |
| 438 | ), |
| 439 | 'configuration' => array( |
| 440 | 'option_group' => 'responsive_lightbox_configuration', |
| 441 | 'option_name' => 'responsive_lightbox_configuration', |
| 442 | 'sections' => array( |
| 443 | 'responsive_lightbox_configuration' => array( |
| 444 | 'title' => sprintf( __( '%s settings', 'responsive-lightbox' ), ( isset( $this->scripts[Responsive_Lightbox()->options['settings']['script']]['name'] ) ? $this->scripts[Responsive_Lightbox()->options['settings']['script']]['name'] : $this->scripts[Responsive_Lightbox()->defaults['settings']['script']]['name'] ) ) |
| 445 | ), |
| 446 | ), |
| 447 | 'prefix' => 'rl', |
| 448 | 'fields' => array( |
| 449 | ) |
| 450 | ), |
| 451 | 'basicgrid_gallery' => array( |
| 452 | 'option_group' => 'responsive_lightbox_basicgrid_gallery', |
| 453 | 'option_name' => 'responsive_lightbox_basicgrid_gallery', |
| 454 | 'sections' => array( |
| 455 | 'responsive_lightbox_basicgrid_gallery' => array( |
| 456 | 'title' => __( 'Basic Grid Gallery settings', 'responsive-lightbox' ) |
| 457 | ) |
| 458 | ), |
| 459 | 'prefix' => 'rl', |
| 460 | 'fields' => array( |
| 461 | 'screen_size_columns' => array( |
| 462 | 'title' => __( 'Screen sizes', 'responsive-lightbox' ), |
| 463 | 'section' => 'responsive_lightbox_basicgrid_gallery', |
| 464 | 'type' => 'multiple', |
| 465 | 'description' => __( 'Number of columns in a gallery depending on the device screen size. (if greater than 0 overrides the Columns option)', 'responsive-lightbox' ), |
| 466 | 'fields' => array( |
| 467 | 'columns_lg' => array( |
| 468 | 'type' => 'number', |
| 469 | 'min' => 0, |
| 470 | 'max' => 6, |
| 471 | 'append' => __( 'large devices / desktops (>1200px)', 'responsive-lightbox' ) |
| 472 | ), |
| 473 | 'columns_md' => array( |
| 474 | 'type' => 'number', |
| 475 | 'min' => 0, |
| 476 | 'max' => 6, |
| 477 | 'append' => __( 'medium devices / desktops (>992px)', 'responsive-lightbox' ) |
| 478 | ), |
| 479 | 'columns_sm' => array( |
| 480 | 'type' => 'number', |
| 481 | 'min' => 0, |
| 482 | 'max' => 6, |
| 483 | 'append' => __( 'small devices / tablets (>768px)', 'responsive-lightbox' ) |
| 484 | ), |
| 485 | 'columns_xs' => array( |
| 486 | 'type' => 'number', |
| 487 | 'min' => 0, |
| 488 | 'max' => 6, |
| 489 | 'append' => __( 'extra small devices / phones (<768px)', 'responsive-lightbox' ) |
| 490 | ) |
| 491 | ), |
| 492 | ), |
| 493 | 'gutter' => array( |
| 494 | 'title' => __( 'Gutter', 'responsive-lightbox' ), |
| 495 | 'section' => 'responsive_lightbox_basicgrid_gallery', |
| 496 | 'type' => 'number', |
| 497 | 'min' => 0, |
| 498 | 'description' => __( 'Set the pixel width between the columns and rows.', 'responsive-lightbox' ), |
| 499 | 'append' => 'px' |
| 500 | ), |
| 501 | 'force_height' => array( |
| 502 | 'title' => __( 'Force height', 'responsive-lightbox' ), |
| 503 | 'section' => 'responsive_lightbox_basicgrid_gallery', |
| 504 | 'type' => 'boolean', |
| 505 | 'label' => __( 'Enable to force the thumbnail row height.', 'responsive-lightbox' ) |
| 506 | ), |
| 507 | 'row_height' => array( |
| 508 | 'title' => __( 'Row height', 'responsive-lightbox' ), |
| 509 | 'section' => 'responsive_lightbox_basicgrid_gallery', |
| 510 | 'type' => 'number', |
| 511 | 'min' => 50, |
| 512 | 'description' => __( 'Enter the thumbnail row height in pixels (used if Force height is enabled). Defaults to 150px.', 'responsive-lightbox' ), |
| 513 | 'append' => 'px' |
| 514 | ) |
| 515 | ) |
| 516 | ), |
| 517 | 'basicslider_gallery' => array( |
| 518 | 'option_group' => 'responsive_lightbox_basicslider_gallery', |
| 519 | 'option_name' => 'responsive_lightbox_basicslider_gallery', |
| 520 | 'sections' => array( |
| 521 | 'responsive_lightbox_basicslider_gallery' => array( |
| 522 | 'title' => __( 'Basic Slider Gallery settings', 'responsive-lightbox' ) |
| 523 | ) |
| 524 | ), |
| 525 | 'prefix' => 'rl', |
| 526 | 'fields' => array( |
| 527 | 'adaptive_height' => array( |
| 528 | 'title' => __( 'Adaptive Height', 'responsive-lightbox' ), |
| 529 | 'section' => 'responsive_lightbox_basicslider_gallery', |
| 530 | 'type' => 'boolean', |
| 531 | 'label' => __( 'The slider height should change on the fly according to the current slide.', 'responsive-lightbox' ) |
| 532 | ), |
| 533 | 'loop' => array( |
| 534 | 'title' => __( 'Loop', 'responsive-lightbox' ), |
| 535 | 'section' => 'responsive_lightbox_basicslider_gallery', |
| 536 | 'type' => 'boolean', |
| 537 | 'label' => __( 'Whether the slider should loop (i.e. the first slide goes to the last, the last slide goes to the first).', 'responsive-lightbox' ) |
| 538 | ), |
| 539 | 'captions' => array( |
| 540 | 'title' => __( 'Captions Position', 'responsive-lightbox' ), |
| 541 | 'section' => 'responsive_lightbox_basicslider_gallery', |
| 542 | 'type' => 'select', |
| 543 | 'description' => __( 'Specifies the position of captions or no captions at all.', 'responsive-lightbox' ), |
| 544 | 'options' => array( |
| 545 | 'none' => __( 'None', 'responsive-lightbox' ), |
| 546 | 'overlay' => __( 'Overlay', 'responsive-lightbox' ), |
| 547 | 'below' => __( 'Below', 'responsive-lightbox' ) |
| 548 | ) |
| 549 | ), |
| 550 | 'init_single' => array( |
| 551 | 'title' => __( 'Single Image Slider', 'responsive-lightbox' ), |
| 552 | 'section' => 'responsive_lightbox_basicslider_gallery', |
| 553 | 'type' => 'boolean', |
| 554 | 'label' => __( 'Whether the slider should initialize even if there is only one slide element.', 'responsive-lightbox' ) |
| 555 | ), |
| 556 | 'responsive' => array( |
| 557 | 'title' => __( 'Responsive', 'responsive-lightbox' ), |
| 558 | 'section' => 'responsive_lightbox_basicslider_gallery', |
| 559 | 'type' => 'boolean', |
| 560 | 'label' => __( 'Whether the slider should be responsive.', 'responsive-lightbox' ) |
| 561 | ), |
| 562 | 'preload' => array( |
| 563 | 'title' => __( 'Preload', 'responsive-lightbox' ), |
| 564 | 'section' => 'responsive_lightbox_basicslider_gallery', |
| 565 | 'type' => 'select', |
| 566 | 'description' => __( 'Elements that are preloaded before slider shows.', 'responsive-lightbox' ), |
| 567 | 'options' => array( |
| 568 | 'all' => __( 'All', 'responsive-lightbox' ), |
| 569 | 'visible' => __( 'Only visible', 'responsive-lightbox' ) |
| 570 | ) |
| 571 | ), |
| 572 | 'pager' => array( |
| 573 | 'title' => __( 'Pager', 'responsive-lightbox' ), |
| 574 | 'section' => 'responsive_lightbox_basicslider_gallery', |
| 575 | 'type' => 'boolean', |
| 576 | 'label' => __( 'Whether the slider should have a pager.', 'responsive-lightbox' ) |
| 577 | ), |
| 578 | 'controls' => array( |
| 579 | 'title' => __( 'Controls', 'responsive-lightbox' ), |
| 580 | 'section' => 'responsive_lightbox_basicslider_gallery', |
| 581 | 'type' => 'boolean', |
| 582 | 'label' => __( 'Whether the slider should have controls (next, previous arrows).', 'responsive-lightbox' ) |
| 583 | ), |
| 584 | 'hide_on_end' => array( |
| 585 | 'title' => __( 'Hide Controls on End', 'responsive-lightbox' ), |
| 586 | 'section' => 'responsive_lightbox_basicslider_gallery', |
| 587 | 'type' => 'boolean', |
| 588 | 'label' => __( 'Hide the previous or next control when it reaches the first or last slide respectively.', 'responsive-lightbox' ) |
| 589 | ), |
| 590 | 'slide_margin' => array( |
| 591 | 'title' => __( 'Slide Margin', 'responsive-lightbox' ), |
| 592 | 'section' => 'responsive_lightbox_basicslider_gallery', |
| 593 | 'type' => 'number', |
| 594 | 'min' => 0, |
| 595 | 'description' => __( 'The spacing between slides.', 'responsive-lightbox' ), |
| 596 | 'append' => '%' |
| 597 | ), |
| 598 | 'transition' => array( |
| 599 | 'title' => __( 'Transition', 'responsive-lightbox' ), |
| 600 | 'section' => 'responsive_lightbox_basicslider_gallery', |
| 601 | 'type' => 'select', |
| 602 | 'description' => __( 'Transition type to use, or no transitions.', 'responsive-lightbox' ), |
| 603 | 'options' => array( |
| 604 | 'none' => __( 'None', 'responsive-lightbox' ), |
| 605 | 'fade' => __( 'Fade', 'responsive-lightbox' ), |
| 606 | 'horizontal' => __( 'Horizontal', 'responsive-lightbox' ), |
| 607 | 'vertical' => __( 'Vertical', 'responsive-lightbox' ), |
| 608 | 'kenburns' => __( 'Ken Burns', 'responsive-lightbox' ) |
| 609 | ) |
| 610 | ), |
| 611 | 'kenburns_zoom' => array( |
| 612 | 'title' => __( 'Ken Burns Zoom', 'responsive-lightbox' ), |
| 613 | 'section' => 'responsive_lightbox_basicslider_gallery', |
| 614 | 'type' => 'number', |
| 615 | 'min' => 0, |
| 616 | 'description' => __( 'Max zoom level use for the Ken Burns transition.', 'responsive-lightbox' ), |
| 617 | 'append' => '%' |
| 618 | ), |
| 619 | 'speed' => array( |
| 620 | 'title' => __( 'Transition Speed', 'responsive-lightbox' ), |
| 621 | 'section' => 'responsive_lightbox_basicslider_gallery', |
| 622 | 'type' => 'number', |
| 623 | 'min' => 0, |
| 624 | 'description' => __( 'The time the transition takes to complete.', 'responsive-lightbox' ), |
| 625 | 'append' => 'ms' |
| 626 | ), |
| 627 | 'easing' => array( |
| 628 | 'title' => __( 'Easing Effect', 'responsive-lightbox' ), |
| 629 | 'section' => 'responsive_lightbox_basicslider_gallery', |
| 630 | 'type' => 'select', |
| 631 | 'description' => __( 'The easing effect to use for the selected transition.', 'responsive-lightbox' ), |
| 632 | 'options' => array( |
| 633 | 'linear' => 'linear', |
| 634 | 'swing' => 'swing', |
| 635 | 'easeInQuad' => 'easeInQuad', |
| 636 | 'easeOutQuad' => 'easeOutQuad', |
| 637 | 'easeInOutQuad' => 'easeInOutQuad', |
| 638 | 'easeInCubic' => 'easeInCubic', |
| 639 | 'easeOutCubic' => 'easeOutCubic', |
| 640 | 'easeInOutCubic' => 'easeInOutCubic', |
| 641 | 'easeInQuart' => 'easeInQuart', |
| 642 | 'easeOutQuart' => 'easeOutQuart', |
| 643 | 'easeInOutQuart' => 'easeInOutQuart', |
| 644 | 'easeInQuint' => 'easeInQuint', |
| 645 | 'easeOutQuint' => 'easeOutQuint', |
| 646 | 'easeInOutQuint' => 'easeInOutQuint', |
| 647 | 'easeInExpo' => 'easeInExpo', |
| 648 | 'easeOutExpo' => 'easeOutExpo', |
| 649 | 'easeInOutExpo' => 'easeInOutExpo', |
| 650 | 'easeInSine' => 'easeInSine', |
| 651 | 'easeOutSine' => 'easeOutSine', |
| 652 | 'easeInOutSine' => 'easeInOutSine', |
| 653 | 'easeInCirc' => 'easeInCirc', |
| 654 | 'easeOutCirc' => 'easeOutCirc', |
| 655 | 'easeInOutCirc' => 'easeInOutCirc', |
| 656 | 'easeInElastic' => 'easeInElastic', |
| 657 | 'easeOutElastic' => 'easeOutElastic', |
| 658 | 'easeInOutElastic' => 'easeInOutElastic', |
| 659 | 'easeInBack' => 'easeInBack', |
| 660 | 'easeOutBack' => 'easeOutBack', |
| 661 | 'easeInOutBack' => 'easeInOutBack', |
| 662 | 'easeInBounce' => 'easeInBounce', |
| 663 | 'easeOutBounce' => 'easeOutBounce', |
| 664 | 'easeInOutBounce' => 'easeInOutBounce' |
| 665 | ) |
| 666 | ), |
| 667 | 'continuous' => array( |
| 668 | 'title' => __( 'Continuous', 'responsive-lightbox' ), |
| 669 | 'section' => 'responsive_lightbox_basicslider_gallery', |
| 670 | 'type' => 'boolean', |
| 671 | 'label' => __( 'Whether the slider should run continuously (seamless transition between the first and last slides).', 'responsive-lightbox' ) |
| 672 | ), |
| 673 | 'use_css' => array( |
| 674 | 'title' => __( 'Use CSS', 'responsive-lightbox' ), |
| 675 | 'section' => 'responsive_lightbox_basicslider_gallery', |
| 676 | 'type' => 'boolean', |
| 677 | 'label' => __( 'Whether the slider should use CSS transitions. If the user\'s browser doesn\'t support CSS transitions the slider will fallback to jQuery.', 'responsive-lightbox' ) |
| 678 | ), |
| 679 | 'slideshow' => array( |
| 680 | 'title' => __( 'Slideshow', 'responsive-lightbox' ), |
| 681 | 'section' => 'responsive_lightbox_basicslider_gallery', |
| 682 | 'type' => 'boolean', |
| 683 | 'label' => __( 'Whether the slider should run automatically on load.', 'responsive-lightbox' ) |
| 684 | ), |
| 685 | 'slideshow_direction' => array( |
| 686 | 'title' => __( 'Slideshow Direction', 'responsive-lightbox' ), |
| 687 | 'section' => 'responsive_lightbox_basicslider_gallery', |
| 688 | 'type' => 'select', |
| 689 | 'description' => __( 'Which direction the slider should move in if in slideshow mode.', 'responsive-lightbox' ), |
| 690 | 'options' => array( |
| 691 | 'next' => __( 'Next', 'responsive-lightbox' ), |
| 692 | 'prev' => __( 'Previous', 'responsive-lightbox' ) |
| 693 | ) |
| 694 | ), |
| 695 | 'slideshow_hover' => array( |
| 696 | 'title' => __( 'Slideshow Hover', 'responsive-lightbox' ), |
| 697 | 'section' => 'responsive_lightbox_basicslider_gallery', |
| 698 | 'type' => 'boolean', |
| 699 | 'label' => __( 'Whether the slideshow should pause automatically on hover.', 'responsive-lightbox' ) |
| 700 | ), |
| 701 | 'slideshow_hover_delay' => array( |
| 702 | 'title' => __( 'Slideshow Hover Delay', 'responsive-lightbox' ), |
| 703 | 'section' => 'responsive_lightbox_basicslider_gallery', |
| 704 | 'type' => 'number', |
| 705 | 'min' => 0, |
| 706 | 'description' => __( 'The delay (if any) before the slider resumes automatically after hover.', 'responsive-lightbox' ), |
| 707 | 'append' => 'ms' |
| 708 | ), |
| 709 | 'slideshow_delay' => array( |
| 710 | 'title' => __( 'Slideshow Delay', 'responsive-lightbox' ), |
| 711 | 'section' => 'responsive_lightbox_basicslider_gallery', |
| 712 | 'type' => 'number', |
| 713 | 'min' => 0, |
| 714 | 'description' => __( 'The delay (if any) before the slider runs automatically on load.', 'responsive-lightbox' ), |
| 715 | 'append' => 'ms' |
| 716 | ), |
| 717 | 'slideshow_pause' => array( |
| 718 | 'title' => __( 'Slideshow Pause', 'responsive-lightbox' ), |
| 719 | 'section' => 'responsive_lightbox_basicslider_gallery', |
| 720 | 'type' => 'number', |
| 721 | 'min' => 0, |
| 722 | 'description' => __( 'The time a slide lasts.', 'responsive-lightbox' ), |
| 723 | 'append' => 'ms' |
| 724 | ) |
| 725 | ) |
| 726 | ), |
| 727 | 'basicmasonry_gallery' => array( |
| 728 | 'option_group' => 'responsive_lightbox_basicmasonry_gallery', |
| 729 | 'option_name' => 'responsive_lightbox_basicmasonry_gallery', |
| 730 | 'sections' => array( |
| 731 | 'responsive_lightbox_basicmasonry_gallery' => array( |
| 732 | 'title' => __( 'Basic Masonry Gallery settings', 'responsive-lightbox' ) |
| 733 | ) |
| 734 | ), |
| 735 | 'prefix' => 'rl', |
| 736 | 'fields' => array( |
| 737 | 'screen_size_columns' => array( |
| 738 | 'title' => __( 'Screen sizes', 'responsive-lightbox' ), |
| 739 | 'section' => 'responsive_lightbox_basicmasonry_gallery', |
| 740 | 'type' => 'multiple', |
| 741 | 'description' => __( 'Number of columns in a gallery depending on the device screen size. (if greater than 0 overrides the Columns option)', 'responsive-lightbox' ), |
| 742 | 'fields' => array( |
| 743 | 'columns_lg' => array( |
| 744 | 'type' => 'number', |
| 745 | 'min' => 0, |
| 746 | 'max' => 6, |
| 747 | 'default' => 4, |
| 748 | 'append' => __( 'large devices / desktops (≥1200px)', 'responsive-lightbox' ) |
| 749 | ), |
| 750 | 'columns_md' => array( |
| 751 | 'type' => 'number', |
| 752 | 'min' => 0, |
| 753 | 'max' => 6, |
| 754 | 'default' => 3, |
| 755 | 'append' => __( 'medium devices / desktops (≥992px)', 'responsive-lightbox' ) |
| 756 | ), |
| 757 | 'columns_sm' => array( |
| 758 | 'type' => 'number', |
| 759 | 'min' => 0, |
| 760 | 'max' => 6, |
| 761 | 'default' => 2, |
| 762 | 'append' => __( 'small devices / tablets (≥768px)', 'responsive-lightbox' ) |
| 763 | ), |
| 764 | 'columns_xs' => array( |
| 765 | 'type' => 'number', |
| 766 | 'min' => 0, |
| 767 | 'max' => 6, |
| 768 | 'default' => 2, |
| 769 | 'append' => __( 'extra small devices / phones (<768px)', 'responsive-lightbox' ) |
| 770 | ) |
| 771 | ), |
| 772 | ), |
| 773 | 'gutter' => array( |
| 774 | 'title' => __( 'Gutter', 'responsive-lightbox' ), |
| 775 | 'section' => 'responsive_lightbox_basicmasonry_gallery', |
| 776 | 'type' => 'number', |
| 777 | 'description' => __( 'Horizontal space between gallery items.', 'responsive-lightbox' ), |
| 778 | 'append' => 'px' |
| 779 | ), |
| 780 | 'margin' => array( |
| 781 | 'title' => __( 'Margin', 'responsive-lightbox' ), |
| 782 | 'section' => 'responsive_lightbox_basicmasonry_gallery', |
| 783 | 'type' => 'number', |
| 784 | 'description' => __( 'Vertical space between gallery items.', 'responsive-lightbox' ), |
| 785 | 'append' => 'px' |
| 786 | ), |
| 787 | 'origin_left' => array( |
| 788 | 'title' => __( 'Origin Left', 'responsive-lightbox' ), |
| 789 | 'section' => 'responsive_lightbox_basicmasonry_gallery', |
| 790 | 'type' => 'boolean', |
| 791 | 'label' => __( 'Enable left-to-right layouts.', 'responsive-lightbox' ), |
| 792 | 'description' => __( 'Controls the horizontal flow of the layout. By default, item elements start positioning at the left. Uncheck it for right-to-left layouts.', 'responsive-lightbox' ) |
| 793 | ), |
| 794 | 'origin_top' => array( |
| 795 | 'title' => __( 'Origin Top', 'responsive-lightbox' ), |
| 796 | 'section' => 'responsive_lightbox_basicmasonry_gallery', |
| 797 | 'type' => 'boolean', |
| 798 | 'label' => __( 'Enable top-to-bottom layouts.', 'responsive-lightbox' ), |
| 799 | 'description' => __( 'Controls the vetical flow of the layout. By default, item elements start positioning at the top. Uncheck it for bottom-up layouts.', 'responsive-lightbox' ) |
| 800 | ) |
| 801 | ) |
| 802 | ) |
| 803 | ); |
| 804 | |
| 805 | $this->tabs = apply_filters( 'rl_settings_tabs', array( |
| 806 | 'settings' => array( |
| 807 | 'name' => __( 'General', 'responsive-lightbox' ), |
| 808 | 'key' => 'responsive_lightbox_settings', |
| 809 | 'submit' => 'save_rl_settings', |
| 810 | 'reset' => 'reset_rl_settings', |
| 811 | ), |
| 812 | 'configuration' => array( |
| 813 | 'name' => __( 'Lightboxes', 'responsive-lightbox' ), |
| 814 | 'key' => 'responsive_lightbox_configuration', |
| 815 | 'submit' => 'save_' . $this->settings['configuration']['prefix'] . '_configuration', |
| 816 | 'reset' => 'reset_' . $this->settings['configuration']['prefix'] . '_configuration', |
| 817 | 'sections' => $scripts, |
| 818 | 'default_section' => Responsive_Lightbox()->options['settings']['script'] |
| 819 | ), |
| 820 | 'basicgrid_gallery' => array( |
| 821 | 'name' => __( 'Basic Grid', 'responsive-lightbox' ), |
| 822 | 'key' => 'responsive_lightbox_basicgrid_gallery', |
| 823 | 'submit' => 'save_rl_basicgrid_gallery', |
| 824 | 'reset' => 'reset_rl_basicgrid_gallery', |
| 825 | ), |
| 826 | 'basicslider_gallery' => array( |
| 827 | 'name' => __( 'Basic Slider', 'responsive-lightbox' ), |
| 828 | 'key' => 'responsive_lightbox_basiclider_gallery', |
| 829 | 'submit' => 'save_rl_basiclider_gallery', |
| 830 | 'reset' => 'reset_rl_basiclider_gallery', |
| 831 | ), |
| 832 | 'basicmasonry_gallery' => array( |
| 833 | 'name' => __( 'Basic Masonry', 'responsive-lightbox' ), |
| 834 | 'key' => 'responsive_lightbox_basicmasonry_gallery', |
| 835 | 'submit' => 'save_rl_basicmasonry_gallery', |
| 836 | 'reset' => 'reset_rl_basicmasonry_gallery', |
| 837 | ) |
| 838 | ) ); |
| 839 | |
| 840 | $tabs_copy = $this->tabs; |
| 841 | $tab_key = ''; |
| 842 | $section_key = ''; |
| 843 | |
| 844 | // set current tab and section |
| 845 | if ( is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { |
| 846 | global $pagenow; |
| 847 | |
| 848 | // check settings page |
| 849 | if ( $pagenow === 'options.php' || ( $pagenow == 'admin.php' && isset( $_GET['page'] ) && preg_match( '/^responsive-lightbox-(' . implode( '|', array_keys( $this->tabs + array( 'gallery' => '', 'addons' => '' ) ) ) . ')$/', $_GET['page'], $tabs ) === 1 ) ) { |
| 850 | $tab_key = isset( $tabs[1] ) ? $tabs[1] : 'settings'; |
| 851 | $section_key = isset( $_REQUEST['section'] ) ? esc_attr( $_REQUEST['section'] ) : ( ! empty( $this->tabs[$tab_key]['default_section'] ) ? $this->tabs[$tab_key]['default_section'] : '' ); |
| 852 | } |
| 853 | } |
| 854 | |
| 855 | // get default gallery types |
| 856 | $gallery_types = Responsive_Lightbox()->gallery_types; |
| 857 | |
| 858 | // remove default gallery |
| 859 | unset( $gallery_types['default'] ); |
| 860 | |
| 861 | // get available galleries |
| 862 | $gallery_types = apply_filters( 'rl_gallery_types', $gallery_types ); |
| 863 | |
| 864 | if ( $gallery_types ) { |
| 865 | foreach ( $gallery_types as $key => $name ) { |
| 866 | unset( $gallery_types[$key] ); |
| 867 | |
| 868 | $gallery_types[$key . '_gallery'] = $name; |
| 869 | } |
| 870 | } |
| 871 | |
| 872 | // backward compatibility, remove from tabs |
| 873 | $gallery_tabs = array_intersect( array_keys( $this->tabs ), array_keys( $gallery_types ) ); |
| 874 | $galleries = array(); |
| 875 | |
| 876 | if ( ! empty( $gallery_tabs ) ) { |
| 877 | // unset tabs if exist |
| 878 | foreach ( $gallery_tabs as $gallery_tab ) { |
| 879 | $galleries[$gallery_tab] = $this->tabs[$gallery_tab]; |
| 880 | |
| 881 | unset( $this->tabs[$gallery_tab] ); |
| 882 | } |
| 883 | |
| 884 | foreach ( $galleries as $key => $gallery ) { |
| 885 | $gallery_sections[$key] = $gallery['name']; |
| 886 | } |
| 887 | |
| 888 | if ( $tab_key == 'gallery' ) |
| 889 | $section_key = isset( $_REQUEST['section'] ) ? esc_attr( $_REQUEST['section'] ) : ( in_array( Responsive_Lightbox()->options['settings']['default_gallery'] . '_gallery', array_keys( $gallery_sections ) ) ? Responsive_Lightbox()->options['settings']['default_gallery'] . '_gallery' : key( $gallery_sections ) ); |
| 890 | |
| 891 | $this->tabs['gallery'] = array( |
| 892 | 'name' => __( 'Galleries', 'responsive-lightbox' ), |
| 893 | 'key' => 'responsive_lightbox_' . $section_key, |
| 894 | 'submit' => array_key_exists( $section_key, $tabs_copy ) ? $tabs_copy[$section_key]['submit'] : 'save_' . $section_key . '_configuration', |
| 895 | 'reset' => array_key_exists( $section_key, $tabs_copy ) ? $tabs_copy[$section_key]['reset'] : 'reset_rl_' . $section_key, |
| 896 | 'sections' => $gallery_sections, |
| 897 | 'default_section' => $section_key |
| 898 | ); |
| 899 | } |
| 900 | |
| 901 | $this->tabs['builder'] = array( |
| 902 | 'name' => __( 'Builder', 'responsive-lightbox' ), |
| 903 | 'key' => 'responsive_lightbox_builder', |
| 904 | 'submit' => 'save_rl_builder', |
| 905 | 'reset' => 'reset_rl_builder', |
| 906 | ); |
| 907 | |
| 908 | // push licenses just beofre the addons |
| 909 | if ( isset( $this->tabs['licenses'] ) ) { |
| 910 | unset( $this->tabs['licenses'] ); |
| 911 | |
| 912 | $this->tabs['licenses'] = array( |
| 913 | 'name' => __( 'Licenses', 'responsive-lightbox' ), |
| 914 | 'key' => 'responsive_lightbox_licenses', |
| 915 | 'submit' => 'save_rl_licenses', |
| 916 | 'reset' => 'reset_rl_licenses', |
| 917 | ); |
| 918 | } |
| 919 | |
| 920 | $this->tabs['addons'] = array( |
| 921 | 'name' => __( 'Add-ons', 'responsive-lightbox' ), |
| 922 | 'key' => 'responsive_lightbox_configuration', |
| 923 | 'callback' => array( $this, 'addons_tab_cb' ) |
| 924 | ); |
| 925 | |
| 926 | if ( ! empty( $this->tabs[$tab_key]['sections'] ) && isset( $this->tabs[$tab_key]['sections'][$section_key] ) ) { |
| 927 | $this->settings[$tab_key]['sections']['responsive_lightbox_' . $tab_key]['title'] = sprintf( __( '%s settings', 'responsive-lightbox' ), $this->tabs[$tab_key]['sections'][$section_key] ); |
| 928 | } |
| 929 | |
| 930 | switch ( ! empty( $section_key ) ? $section_key : Responsive_Lightbox()->options['settings']['script'] ) { |
| 931 | case 'swipebox': |
| 932 | $this->settings['configuration']['prefix'] = 'rl_sb'; |
| 933 | $this->settings['configuration']['fields'] = array( |
| 934 | 'animation' => array( |
| 935 | 'title' => __( 'Animation type', 'responsive-lightbox' ), |
| 936 | 'section' => 'responsive_lightbox_configuration', |
| 937 | 'type' => 'radio', |
| 938 | 'label' => '', |
| 939 | 'description' => __( 'Select a method of applying a lightbox effect.', 'responsive-lightbox' ), |
| 940 | 'options' => $this->scripts['swipebox']['animations'], |
| 941 | 'parent' => 'swipebox' |
| 942 | ), |
| 943 | 'force_png_icons' => array( |
| 944 | 'title' => __( 'Force PNG icons', 'responsive-lightbox' ), |
| 945 | 'section' => 'responsive_lightbox_configuration', |
| 946 | 'type' => 'boolean', |
| 947 | 'label' => __( 'Enable this if you\'re having problems with navigation icons not visible on some devices.', 'responsive-lightbox' ), |
| 948 | 'parent' => 'swipebox' |
| 949 | ), |
| 950 | 'hide_close_mobile' => array( |
| 951 | 'title' => __( 'Hide close on mobile', 'responsive-lightbox' ), |
| 952 | 'section' => 'responsive_lightbox_configuration', |
| 953 | 'type' => 'boolean', |
| 954 | 'label' => __( 'Hide the close button on mobile devices.', 'responsive-lightbox' ), |
| 955 | 'parent' => 'swipebox' |
| 956 | ), |
| 957 | 'remove_bars_mobile' => array( |
| 958 | 'title' => __( 'Remove bars on mobile', 'responsive-lightbox' ), |
| 959 | 'section' => 'responsive_lightbox_configuration', |
| 960 | 'type' => 'boolean', |
| 961 | 'label' => __( 'Hide the top and bottom bars on mobile devices.', 'responsive-lightbox' ), |
| 962 | 'parent' => 'swipebox' |
| 963 | ), |
| 964 | 'hide_bars' => array( |
| 965 | 'title' => __( 'Top and bottom bars', 'responsive-lightbox' ), |
| 966 | 'section' => 'responsive_lightbox_configuration', |
| 967 | 'type' => 'multiple', |
| 968 | 'fields' => array( |
| 969 | 'hide_bars' => array( |
| 970 | 'type' => 'boolean', |
| 971 | 'label' => __( 'Hide top and bottom bars after a period of time.', 'responsive-lightbox' ), |
| 972 | 'parent' => 'swipebox' |
| 973 | ), |
| 974 | 'hide_bars_delay' => array( |
| 975 | 'type' => 'number', |
| 976 | 'description' => __( 'Enter the time after which the top and bottom bars will be hidden (when hiding is enabled).', 'responsive-lightbox' ), |
| 977 | 'append' => 'ms', |
| 978 | 'parent' => 'swipebox' |
| 979 | ) |
| 980 | ) |
| 981 | ), |
| 982 | 'video_max_width' => array( |
| 983 | 'title' => __( 'Video max width', 'responsive-lightbox' ), |
| 984 | 'section' => 'responsive_lightbox_configuration', |
| 985 | 'type' => 'number', |
| 986 | 'description' => __( 'Enter the max video width in a lightbox.', 'responsive-lightbox' ), |
| 987 | 'append' => 'px', |
| 988 | 'parent' => 'swipebox' |
| 989 | ), |
| 990 | 'loop_at_end' => array( |
| 991 | 'title' => __( 'Loop at end', 'responsive-lightbox' ), |
| 992 | 'section' => 'responsive_lightbox_configuration', |
| 993 | 'type' => 'boolean', |
| 994 | 'label' => __( 'True will return to the first image after the last image is reached.', 'responsive-lightbox' ), |
| 995 | 'parent' => 'swipebox' |
| 996 | ), |
| 997 | ); |
| 998 | break; |
| 999 | |
| 1000 | case 'prettyphoto': |
| 1001 | $this->settings['configuration']['prefix'] = 'rl_pp'; |
| 1002 | $this->settings['configuration']['fields'] = array( |
| 1003 | 'animation_speed' => array( |
| 1004 | 'title' => __( 'Animation speed', 'responsive-lightbox' ), |
| 1005 | 'section' => 'responsive_lightbox_configuration', |
| 1006 | 'type' => 'radio', |
| 1007 | 'label' => '', |
| 1008 | 'description' => __( 'Select animation speed for lightbox effect.', 'responsive-lightbox' ), |
| 1009 | 'options' => $this->scripts['prettyphoto']['animation_speeds'], |
| 1010 | 'parent' => 'prettyphoto' |
| 1011 | ), |
| 1012 | 'slideshow' => array( |
| 1013 | 'title' => __( 'Slideshow', 'responsive-lightbox' ), |
| 1014 | 'section' => 'responsive_lightbox_configuration', |
| 1015 | 'type' => 'multiple', |
| 1016 | 'fields' => array( |
| 1017 | 'slideshow' => array( |
| 1018 | 'type' => 'boolean', |
| 1019 | 'label' => __( 'Display images as slideshow', 'responsive-lightbox' ), |
| 1020 | 'parent' => 'prettyphoto' |
| 1021 | ), |
| 1022 | 'slideshow_delay' => array( |
| 1023 | 'type' => 'number', |
| 1024 | 'description' => __( 'Enter time (in miliseconds).', 'responsive-lightbox' ), |
| 1025 | 'append' => 'ms', |
| 1026 | 'parent' => 'prettyphoto' |
| 1027 | ) |
| 1028 | ) |
| 1029 | ), |
| 1030 | 'slideshow_autoplay' => array( |
| 1031 | 'title' => __( 'Slideshow autoplay', 'responsive-lightbox' ), |
| 1032 | 'section' => 'responsive_lightbox_configuration', |
| 1033 | 'type' => 'boolean', |
| 1034 | 'label' => __( 'Automatically start slideshow.', 'responsive-lightbox' ), |
| 1035 | 'parent' => 'prettyphoto' |
| 1036 | ), |
| 1037 | 'opacity' => array( |
| 1038 | 'title' => __( 'Opacity', 'responsive-lightbox' ), |
| 1039 | 'section' => 'responsive_lightbox_configuration', |
| 1040 | 'type' => 'range', |
| 1041 | 'description' => __( 'Value between 0 and 100, 100 for no opacity.', 'responsive-lightbox' ), |
| 1042 | 'min' => 0, |
| 1043 | 'max' => 100, |
| 1044 | 'parent' => 'prettyphoto' |
| 1045 | ), |
| 1046 | 'show_title' => array( |
| 1047 | 'title' => __( 'Show title', 'responsive-lightbox' ), |
| 1048 | 'section' => 'responsive_lightbox_configuration', |
| 1049 | 'type' => 'boolean', |
| 1050 | 'label' => __( 'Display image title.', 'responsive-lightbox' ), |
| 1051 | 'parent' => 'prettyphoto' |
| 1052 | ), |
| 1053 | 'allow_resize' => array( |
| 1054 | 'title' => __( 'Allow resize big images', 'responsive-lightbox' ), |
| 1055 | 'section' => 'responsive_lightbox_configuration', |
| 1056 | 'type' => 'boolean', |
| 1057 | 'label' => __( 'Resize the photos bigger than viewport.', 'responsive-lightbox' ), |
| 1058 | 'parent' => 'prettyphoto' |
| 1059 | ), |
| 1060 | 'allow_expand' => array( |
| 1061 | 'title' => __( 'Allow expand', 'responsive-lightbox' ), |
| 1062 | 'section' => 'responsive_lightbox_configuration', |
| 1063 | 'type' => 'boolean', |
| 1064 | 'label' => __( 'Allow expanding images.', 'responsive-lightbox' ), |
| 1065 | 'parent' => 'prettyphoto' |
| 1066 | ), |
| 1067 | 'width' => array( |
| 1068 | 'title' => __( 'Video width', 'responsive-lightbox' ), |
| 1069 | 'section' => 'responsive_lightbox_configuration', |
| 1070 | 'type' => 'number', |
| 1071 | 'append' => 'px', |
| 1072 | 'parent' => 'prettyphoto' |
| 1073 | ), |
| 1074 | 'height' => array( |
| 1075 | 'title' => __( 'Video height', 'responsive-lightbox' ), |
| 1076 | 'section' => 'responsive_lightbox_configuration', |
| 1077 | 'type' => 'number', |
| 1078 | 'append' => 'px', |
| 1079 | 'parent' => 'prettyphoto' |
| 1080 | ), |
| 1081 | 'theme' => array( |
| 1082 | 'title' => __( 'Theme', 'responsive-lightbox' ), |
| 1083 | 'section' => 'responsive_lightbox_configuration', |
| 1084 | 'type' => 'radio', |
| 1085 | 'description' => __( 'Select the theme for lightbox effect.', 'responsive-lightbox' ), |
| 1086 | 'options' => $this->scripts['prettyphoto']['themes'], |
| 1087 | 'parent' => 'prettyphoto' |
| 1088 | ), |
| 1089 | 'horizontal_padding' => array( |
| 1090 | 'title' => __( 'Horizontal padding', 'responsive-lightbox' ), |
| 1091 | 'section' => 'responsive_lightbox_configuration', |
| 1092 | 'type' => 'number', |
| 1093 | 'append' => 'px', |
| 1094 | 'parent' => 'prettyphoto' |
| 1095 | ), |
| 1096 | 'hide_flash' => array( |
| 1097 | 'title' => __( 'Hide Flash', 'responsive-lightbox' ), |
| 1098 | 'section' => 'responsive_lightbox_configuration', |
| 1099 | 'type' => 'boolean', |
| 1100 | 'label' => __( 'Hide all the flash objects on a page. Enable this if flash appears over prettyPhoto.', 'responsive-lightbox' ), |
| 1101 | 'parent' => 'prettyphoto' |
| 1102 | ), |
| 1103 | 'wmode' => array( |
| 1104 | 'title' => __( 'Flash Window Mode (wmode)', 'responsive-lightbox' ), |
| 1105 | 'section' => 'responsive_lightbox_configuration', |
| 1106 | 'type' => 'radio', |
| 1107 | 'description' => __( 'Select flash window mode.', 'responsive-lightbox' ), |
| 1108 | 'options' => $this->scripts['prettyphoto']['wmodes'], |
| 1109 | 'parent' => 'prettyphoto' |
| 1110 | ), |
| 1111 | 'video_autoplay' => array( |
| 1112 | 'title' => __( 'Video autoplay', 'responsive-lightbox' ), |
| 1113 | 'section' => 'responsive_lightbox_configuration', |
| 1114 | 'type' => 'boolean', |
| 1115 | 'label' => __( 'Automatically start videos.', 'responsive-lightbox' ), |
| 1116 | 'parent' => 'prettyphoto' |
| 1117 | ), |
| 1118 | 'modal' => array( |
| 1119 | 'title' => __( 'Modal', 'responsive-lightbox' ), |
| 1120 | 'section' => 'responsive_lightbox_configuration', |
| 1121 | 'type' => 'boolean', |
| 1122 | 'label' => __( 'If set to true, only the close button will close the window.', 'responsive-lightbox' ), |
| 1123 | 'parent' => 'prettyphoto' |
| 1124 | ), |
| 1125 | 'deeplinking' => array( |
| 1126 | 'title' => __( 'Deeplinking', 'responsive-lightbox' ), |
| 1127 | 'section' => 'responsive_lightbox_configuration', |
| 1128 | 'type' => 'boolean', |
| 1129 | 'label' => __( 'Allow prettyPhoto to update the url to enable deeplinking.', 'responsive-lightbox' ), |
| 1130 | 'parent' => 'prettyphoto' |
| 1131 | ), |
| 1132 | 'overlay_gallery' => array( |
| 1133 | 'title' => __( 'Overlay gallery', 'responsive-lightbox' ), |
| 1134 | 'section' => 'responsive_lightbox_configuration', |
| 1135 | 'type' => 'boolean', |
| 1136 | 'label' => __( 'If enabled, a gallery will overlay the fullscreen image on mouse over.', 'responsive-lightbox' ), |
| 1137 | 'parent' => 'prettyphoto' |
| 1138 | ), |
| 1139 | 'keyboard_shortcuts' => array( |
| 1140 | 'title' => __( 'Keyboard shortcuts', 'responsive-lightbox' ), |
| 1141 | 'section' => 'responsive_lightbox_configuration', |
| 1142 | 'type' => 'boolean', |
| 1143 | 'label' => __( 'Set to false if you open forms inside prettyPhoto.', 'responsive-lightbox' ), |
| 1144 | 'parent' => 'prettyphoto' |
| 1145 | ), |
| 1146 | 'social' => array( |
| 1147 | 'title' => __( 'Social (Twitter, Facebook)', 'responsive-lightbox' ), |
| 1148 | 'section' => 'responsive_lightbox_configuration', |
| 1149 | 'type' => 'boolean', |
| 1150 | 'label' => __( 'Display links to Facebook and Twitter.', 'responsive-lightbox' ), |
| 1151 | 'parent' => 'prettyphoto' |
| 1152 | ), |
| 1153 | ); |
| 1154 | break; |
| 1155 | |
| 1156 | case 'fancybox': |
| 1157 | $this->settings['configuration']['prefix'] = 'rl_fb'; |
| 1158 | $this->settings['configuration']['fields'] = array( |
| 1159 | 'modal' => array( |
| 1160 | 'title' => __( 'Modal', 'responsive-lightbox' ), |
| 1161 | 'section' => 'responsive_lightbox_configuration', |
| 1162 | 'type' => 'boolean', |
| 1163 | 'label' => __( 'When true, "overlayShow" is set to true and "hideOnOverlayClick", "hideOnContentClick", "enableEscapeButton", "showCloseButton" are set to false.', 'responsive-lightbox' ), |
| 1164 | 'parent' => 'fancybox' |
| 1165 | ), |
| 1166 | 'show_overlay' => array( |
| 1167 | 'title' => __( 'Show overlay', 'responsive-lightbox' ), |
| 1168 | 'section' => 'responsive_lightbox_configuration', |
| 1169 | 'type' => 'boolean', |
| 1170 | 'label' => __( 'Toggle overlay.', 'responsive-lightbox' ), |
| 1171 | 'parent' => 'fancybox' |
| 1172 | ), |
| 1173 | 'show_close_button' => array( |
| 1174 | 'title' => __( 'Show close button', 'responsive-lightbox' ), |
| 1175 | 'section' => 'responsive_lightbox_configuration', |
| 1176 | 'type' => 'boolean', |
| 1177 | 'label' => __( 'Toggle close button.', 'responsive-lightbox' ), |
| 1178 | 'parent' => 'fancybox' |
| 1179 | ), |
| 1180 | 'enable_escape_button' => array( |
| 1181 | 'title' => __( 'Enable escape button', 'responsive-lightbox' ), |
| 1182 | 'section' => 'responsive_lightbox_configuration', |
| 1183 | 'type' => 'boolean', |
| 1184 | 'label' => __( 'Toggle if pressing Esc button closes lightbox.', 'responsive-lightbox' ), |
| 1185 | 'parent' => 'fancybox' |
| 1186 | ), |
| 1187 | 'hide_on_overlay_click' => array( |
| 1188 | 'title' => __( 'Hide on overlay click', 'responsive-lightbox' ), |
| 1189 | 'section' => 'responsive_lightbox_configuration', |
| 1190 | 'type' => 'boolean', |
| 1191 | 'label' => __( 'Toggle if clicking the overlay should close FancyBox.', 'responsive-lightbox' ), |
| 1192 | 'parent' => 'fancybox' |
| 1193 | ), |
| 1194 | 'hide_on_content_click' => array( |
| 1195 | 'title' => __( 'Hide on content click', 'responsive-lightbox' ), |
| 1196 | 'section' => 'responsive_lightbox_configuration', |
| 1197 | 'type' => 'boolean', |
| 1198 | 'label' => __( 'Toggle if clicking the content should close FancyBox.', 'responsive-lightbox' ), |
| 1199 | 'parent' => 'fancybox' |
| 1200 | ), |
| 1201 | 'cyclic' => array( |
| 1202 | 'title' => __( 'Cyclic', 'responsive-lightbox' ), |
| 1203 | 'section' => 'responsive_lightbox_configuration', |
| 1204 | 'type' => 'boolean', |
| 1205 | 'label' => __( 'When true, galleries will be cyclic, allowing you to keep pressing next/back.', 'responsive-lightbox' ), |
| 1206 | 'parent' => 'fancybox' |
| 1207 | ), |
| 1208 | 'show_nav_arrows' => array( |
| 1209 | 'title' => __( 'Show nav arrows', 'responsive-lightbox' ), |
| 1210 | 'section' => 'responsive_lightbox_configuration', |
| 1211 | 'type' => 'boolean', |
| 1212 | 'label' => __( 'Toggle navigation arrows.', 'responsive-lightbox' ), |
| 1213 | 'parent' => 'fancybox' |
| 1214 | ), |
| 1215 | 'auto_scale' => array( |
| 1216 | 'title' => __( 'Auto scale', 'responsive-lightbox' ), |
| 1217 | 'section' => 'responsive_lightbox_configuration', |
| 1218 | 'type' => 'boolean', |
| 1219 | 'label' => __( 'If true, FancyBox is scaled to fit in viewport.', 'responsive-lightbox' ), |
| 1220 | 'parent' => 'fancybox' |
| 1221 | ), |
| 1222 | 'scrolling' => array( |
| 1223 | 'title' => __( 'Scrolling (in/out)', 'responsive-lightbox' ), |
| 1224 | 'section' => 'responsive_lightbox_configuration', |
| 1225 | 'type' => 'radio', |
| 1226 | 'description' => __( 'Set the overflow CSS property to create or hide scrollbars.', 'responsive-lightbox' ), |
| 1227 | 'options' => $this->scripts['fancybox']['scrollings'], |
| 1228 | 'parent' => 'fancybox' |
| 1229 | ), |
| 1230 | 'center_on_scroll' => array( |
| 1231 | 'title' => __( 'Center on scroll', 'responsive-lightbox' ), |
| 1232 | 'section' => 'responsive_lightbox_configuration', |
| 1233 | 'type' => 'boolean', |
| 1234 | 'label' => __( 'When true, FancyBox is centered while scrolling page.', 'responsive-lightbox' ), |
| 1235 | 'parent' => 'fancybox' |
| 1236 | ), |
| 1237 | 'opacity' => array( |
| 1238 | 'title' => __( 'Opacity', 'responsive-lightbox' ), |
| 1239 | 'section' => 'responsive_lightbox_configuration', |
| 1240 | 'type' => 'boolean', |
| 1241 | 'label' => __( 'When true, transparency of content is changed for elastic transitions.', 'responsive-lightbox' ), |
| 1242 | 'parent' => 'fancybox' |
| 1243 | ), |
| 1244 | 'overlay_opacity' => array( |
| 1245 | 'title' => __( 'Overlay opacity', 'responsive-lightbox' ), |
| 1246 | 'section' => 'responsive_lightbox_configuration', |
| 1247 | 'type' => 'range', |
| 1248 | 'description' => __( 'Opacity of the overlay.', 'responsive-lightbox' ), |
| 1249 | 'min' => 0, |
| 1250 | 'max' => 100, |
| 1251 | 'parent' => 'fancybox' |
| 1252 | ), |
| 1253 | 'overlay_color' => array( |
| 1254 | 'title' => __( 'Overlay color', 'responsive-lightbox' ), |
| 1255 | 'section' => 'responsive_lightbox_configuration', |
| 1256 | 'type' => 'color_picker', |
| 1257 | 'label' => __( 'Color of the overlay.', 'responsive-lightbox' ), |
| 1258 | 'parent' => 'fancybox' |
| 1259 | ), |
| 1260 | 'title_show' => array( |
| 1261 | 'title' => __( 'Title show', 'responsive-lightbox' ), |
| 1262 | 'section' => 'responsive_lightbox_configuration', |
| 1263 | 'type' => 'boolean', |
| 1264 | 'label' => __( 'Toggle title.', 'responsive-lightbox' ), |
| 1265 | 'parent' => 'fancybox' |
| 1266 | ), |
| 1267 | 'title_position' => array( |
| 1268 | 'title' => __( 'Title position', 'responsive-lightbox' ), |
| 1269 | 'section' => 'responsive_lightbox_configuration', |
| 1270 | 'type' => 'radio', |
| 1271 | 'description' => __( 'The position of title.', 'responsive-lightbox' ), |
| 1272 | 'options' => $this->scripts['fancybox']['positions'], |
| 1273 | 'parent' => 'fancybox' |
| 1274 | ), |
| 1275 | 'transitions' => array( |
| 1276 | 'title' => __( 'Transition (in/out)', 'responsive-lightbox' ), |
| 1277 | 'section' => 'responsive_lightbox_configuration', |
| 1278 | 'type' => 'radio', |
| 1279 | 'description' => __( 'The transition type.', 'responsive-lightbox' ), |
| 1280 | 'options' => $this->scripts['fancybox']['transitions'], |
| 1281 | 'parent' => 'fancybox' |
| 1282 | ), |
| 1283 | 'easings' => array( |
| 1284 | 'title' => __( 'Easings (in/out)', 'responsive-lightbox' ), |
| 1285 | 'section' => 'responsive_lightbox_configuration', |
| 1286 | 'type' => 'radio', |
| 1287 | 'description' => __( 'Easing used for elastic animations.', 'responsive-lightbox' ), |
| 1288 | 'options' => $this->scripts['fancybox']['easings'], |
| 1289 | 'parent' => 'fancybox' |
| 1290 | ), |
| 1291 | 'speeds' => array( |
| 1292 | 'title' => __( 'Speed (in/out)', 'responsive-lightbox' ), |
| 1293 | 'section' => 'responsive_lightbox_configuration', |
| 1294 | 'type' => 'number', |
| 1295 | 'description' => __( 'Speed of the fade and elastic transitions, in milliseconds.', 'responsive-lightbox' ), |
| 1296 | 'append' => 'ms', |
| 1297 | 'parent' => 'fancybox' |
| 1298 | ), |
| 1299 | 'change_speed' => array( |
| 1300 | 'title' => __( 'Change speed', 'responsive-lightbox' ), |
| 1301 | 'section' => 'responsive_lightbox_configuration', |
| 1302 | 'type' => 'number', |
| 1303 | 'description' => __( 'Speed of resizing when changing gallery items, in milliseconds.', 'responsive-lightbox' ), |
| 1304 | 'append' => 'ms', |
| 1305 | 'parent' => 'fancybox' |
| 1306 | ), |
| 1307 | 'change_fade' => array( |
| 1308 | 'title' => __( 'Change fade', 'responsive-lightbox' ), |
| 1309 | 'section' => 'responsive_lightbox_configuration', |
| 1310 | 'type' => 'number', |
| 1311 | 'description' => __( 'Speed of the content fading while changing gallery items.', 'responsive-lightbox' ), |
| 1312 | 'append' => 'ms', |
| 1313 | 'parent' => 'fancybox' |
| 1314 | ), |
| 1315 | 'padding' => array( |
| 1316 | 'title' => __( 'Padding', 'responsive-lightbox' ), |
| 1317 | 'section' => 'responsive_lightbox_configuration', |
| 1318 | 'type' => 'number', |
| 1319 | 'description' => __( 'Space between FancyBox wrapper and content.', 'responsive-lightbox' ), |
| 1320 | 'append' => 'px', |
| 1321 | 'parent' => 'fancybox' |
| 1322 | ), |
| 1323 | 'margin' => array( |
| 1324 | 'title' => __( 'Margin', 'responsive-lightbox' ), |
| 1325 | 'section' => 'responsive_lightbox_configuration', |
| 1326 | 'type' => 'number', |
| 1327 | 'description' => __( 'Space between viewport and FancyBox wrapper.', 'responsive-lightbox' ), |
| 1328 | 'append' => 'px', |
| 1329 | 'parent' => 'fancybox' |
| 1330 | ), |
| 1331 | 'video_width' => array( |
| 1332 | 'title' => __( 'Video width', 'responsive-lightbox' ), |
| 1333 | 'section' => 'responsive_lightbox_configuration', |
| 1334 | 'type' => 'number', |
| 1335 | 'description' => __( 'Width of the video.', 'responsive-lightbox' ), |
| 1336 | 'append' => 'px', |
| 1337 | 'parent' => 'fancybox' |
| 1338 | ), |
| 1339 | 'video_height' => array( |
| 1340 | 'title' => __( 'Video height', 'responsive-lightbox' ), |
| 1341 | 'section' => 'responsive_lightbox_configuration', |
| 1342 | 'type' => 'number', |
| 1343 | 'description' => __( 'Height of the video.', 'responsive-lightbox' ), |
| 1344 | 'append' => 'px', |
| 1345 | 'parent' => 'fancybox' |
| 1346 | ), |
| 1347 | ); |
| 1348 | break; |
| 1349 | |
| 1350 | case 'nivo': |
| 1351 | $this->settings['configuration']['prefix'] = 'rl_nv'; |
| 1352 | $this->settings['configuration']['fields'] = array( |
| 1353 | 'effect' => array( |
| 1354 | 'title' => __( 'Effect', 'responsive-lightbox' ), |
| 1355 | 'section' => 'responsive_lightbox_configuration', |
| 1356 | 'type' => 'radio', |
| 1357 | 'description' => __( 'The effect to use when showing the lightbox.', 'responsive-lightbox' ), |
| 1358 | 'options' => $this->scripts['nivo']['effects'], |
| 1359 | 'parent' => 'nivo' |
| 1360 | ), |
| 1361 | 'keyboard_nav' => array( |
| 1362 | 'title' => __( 'Keyboard navigation', 'responsive-lightbox' ), |
| 1363 | 'section' => 'responsive_lightbox_configuration', |
| 1364 | 'type' => 'boolean', |
| 1365 | 'label' => __( 'Enable keyboard navigation (left/right/escape).', 'responsive-lightbox' ), |
| 1366 | 'parent' => 'nivo' |
| 1367 | ), |
| 1368 | 'click_overlay_to_close' => array( |
| 1369 | 'title' => __( 'Click overlay to close', 'responsive-lightbox' ), |
| 1370 | 'section' => 'responsive_lightbox_configuration', |
| 1371 | 'type' => 'boolean', |
| 1372 | 'label' => __( 'Enable to close lightbox on overlay click.', 'responsive-lightbox' ), |
| 1373 | 'parent' => 'nivo' |
| 1374 | ), |
| 1375 | 'error_message' => array( |
| 1376 | 'title' => __( 'Error message', 'responsive-lightbox' ), |
| 1377 | 'section' => 'responsive_lightbox_configuration', |
| 1378 | 'type' => 'text', |
| 1379 | 'class' => 'large-text', |
| 1380 | 'label' => __( 'Error message if the content cannot be loaded.', 'responsive-lightbox' ), |
| 1381 | 'parent' => 'nivo' |
| 1382 | ), |
| 1383 | ); |
| 1384 | break; |
| 1385 | |
| 1386 | case 'imagelightbox': |
| 1387 | $this->settings['configuration']['prefix'] = 'rl_il'; |
| 1388 | $this->settings['configuration']['fields'] = array( |
| 1389 | 'animation_speed' => array( |
| 1390 | 'title' => __( 'Animation speed', 'responsive-lightbox' ), |
| 1391 | 'section' => 'responsive_lightbox_configuration', |
| 1392 | 'type' => 'number', |
| 1393 | 'description' => __( 'Animation speed.', 'responsive-lightbox' ), |
| 1394 | 'append' => 'ms', |
| 1395 | 'parent' => 'imagelightbox' |
| 1396 | ), |
| 1397 | 'preload_next' => array( |
| 1398 | 'title' => __( 'Preload next image', 'responsive-lightbox' ), |
| 1399 | 'section' => 'responsive_lightbox_configuration', |
| 1400 | 'type' => 'boolean', |
| 1401 | 'label' => __( 'Silently preload the next image.', 'responsive-lightbox' ), |
| 1402 | 'parent' => 'imagelightbox' |
| 1403 | ), |
| 1404 | 'enable_keyboard' => array( |
| 1405 | 'title' => __( 'Enable keyboard keys', 'responsive-lightbox' ), |
| 1406 | 'section' => 'responsive_lightbox_configuration', |
| 1407 | 'type' => 'boolean', |
| 1408 | 'label' => __( 'Enable keyboard shortcuts (arrows Left/Right and Esc).', 'responsive-lightbox' ), |
| 1409 | 'parent' => 'imagelightbox' |
| 1410 | ), |
| 1411 | 'quit_on_end' => array( |
| 1412 | 'title' => __( 'Quit after last image', 'responsive-lightbox' ), |
| 1413 | 'section' => 'responsive_lightbox_configuration', |
| 1414 | 'type' => 'boolean', |
| 1415 | 'label' => __( 'Quit after viewing the last image.', 'responsive-lightbox' ), |
| 1416 | 'parent' => 'imagelightbox' |
| 1417 | ), |
| 1418 | 'quit_on_image_click' => array( |
| 1419 | 'title' => __( 'Quit on image click', 'responsive-lightbox' ), |
| 1420 | 'section' => 'responsive_lightbox_configuration', |
| 1421 | 'type' => 'boolean', |
| 1422 | 'label' => __( 'Quit when the viewed image is clicked.', 'responsive-lightbox' ), |
| 1423 | 'parent' => 'imagelightbox' |
| 1424 | ), |
| 1425 | 'quit_on_document_click' => array( |
| 1426 | 'title' => __( 'Quit on anything click', 'responsive-lightbox' ), |
| 1427 | 'section' => 'responsive_lightbox_configuration', |
| 1428 | 'type' => 'boolean', |
| 1429 | 'label' => __( 'Quit when anything but the viewed image is clicked.', 'responsive-lightbox' ), |
| 1430 | 'parent' => 'imagelightbox' |
| 1431 | ), |
| 1432 | ); |
| 1433 | break; |
| 1434 | |
| 1435 | case 'tosrus': |
| 1436 | $this->settings['configuration']['prefix'] = 'rl_tr'; |
| 1437 | $this->settings['configuration']['fields'] = array( |
| 1438 | 'effect' => array( |
| 1439 | 'title' => __( 'Transition effect', 'responsive-lightbox' ), |
| 1440 | 'section' => 'responsive_lightbox_configuration', |
| 1441 | 'type' => 'radio', |
| 1442 | 'description' => __( 'What effect to use for the transition.', 'responsive-lightbox' ), |
| 1443 | 'options' => array( |
| 1444 | 'slide' => __( 'slide', 'responsive-lightbox' ), |
| 1445 | 'fade' => __( 'fade', 'responsive-lightbox' ) |
| 1446 | ), |
| 1447 | 'parent' => 'tosrus' |
| 1448 | ), |
| 1449 | 'infinite' => array( |
| 1450 | 'title' => __( 'Infinite loop', 'responsive-lightbox' ), |
| 1451 | 'section' => 'responsive_lightbox_configuration', |
| 1452 | 'type' => 'boolean', |
| 1453 | 'label' => __( 'Whether or not to slide back to the first slide when the last has been reached.', 'responsive-lightbox' ), |
| 1454 | 'parent' => 'tosrus' |
| 1455 | ), |
| 1456 | 'keys' => array( |
| 1457 | 'title' => __( 'Keyboard navigation', 'responsive-lightbox' ), |
| 1458 | 'section' => 'responsive_lightbox_configuration', |
| 1459 | 'type' => 'boolean', |
| 1460 | 'label' => __( 'Enable keyboard navigation (left/right/escape).', 'responsive-lightbox' ), |
| 1461 | 'parent' => 'tosrus' |
| 1462 | ), |
| 1463 | 'autoplay' => array( |
| 1464 | 'title' => __( 'Autoplay', 'responsive-lightbox' ), |
| 1465 | 'section' => 'responsive_lightbox_configuration', |
| 1466 | 'type' => 'multiple', |
| 1467 | 'fields' => array( |
| 1468 | 'autoplay' => array( |
| 1469 | 'type' => 'boolean', |
| 1470 | 'label' => __( 'Automatically start slideshow.', 'responsive-lightbox' ), |
| 1471 | 'parent' => 'tosrus' |
| 1472 | ), |
| 1473 | 'timeout' => array( |
| 1474 | 'type' => 'number', |
| 1475 | 'description' => __( 'The timeout between sliding to the next slide in milliseconds.', 'responsive-lightbox' ), |
| 1476 | 'append' => 'ms', |
| 1477 | 'parent' => 'tosrus' |
| 1478 | ) |
| 1479 | ) |
| 1480 | ), |
| 1481 | 'pause_on_hover' => array( |
| 1482 | 'title' => __( 'Pause on hover', 'responsive-lightbox' ), |
| 1483 | 'section' => 'responsive_lightbox_configuration', |
| 1484 | 'type' => 'boolean', |
| 1485 | 'label' => __( 'Whether or not to pause on hover.', 'responsive-lightbox' ), |
| 1486 | 'parent' => 'tosrus' |
| 1487 | ), |
| 1488 | 'pagination' => array( |
| 1489 | 'title' => __( 'Pagination', 'responsive-lightbox' ), |
| 1490 | 'section' => 'responsive_lightbox_configuration', |
| 1491 | 'type' => 'multiple', |
| 1492 | 'fields' => array( |
| 1493 | 'pagination' => array( |
| 1494 | 'type' => 'boolean', |
| 1495 | 'label' => __( 'Whether or not to add a pagination.', 'responsive-lightbox' ), |
| 1496 | 'parent' => 'tosrus' |
| 1497 | ), |
| 1498 | 'pagination_type' => array( |
| 1499 | 'type' => 'radio', |
| 1500 | 'description' => __( 'What type of pagination to use.', 'responsive-lightbox' ), |
| 1501 | 'options' => array( |
| 1502 | 'bullets' => __( 'Bullets', 'responsive-lightbox' ), |
| 1503 | 'thumbnails' => __( 'Thumbnails', 'responsive-lightbox' ) |
| 1504 | ), |
| 1505 | 'parent' => 'tosrus' |
| 1506 | ) |
| 1507 | ) |
| 1508 | ), |
| 1509 | 'close_on_click' => array( |
| 1510 | 'title' => __( 'Overlay close', 'responsive-lightbox' ), |
| 1511 | 'section' => 'responsive_lightbox_configuration', |
| 1512 | 'type' => 'boolean', |
| 1513 | 'label' => __( 'Enable to close lightbox on overlay click.', 'responsive-lightbox' ), |
| 1514 | 'parent' => 'tosrus' |
| 1515 | ) |
| 1516 | ); |
| 1517 | break; |
| 1518 | |
| 1519 | case 'featherlight': |
| 1520 | $this->settings['configuration']['prefix'] = 'rl_fl'; |
| 1521 | $this->settings['configuration']['fields'] = array( |
| 1522 | 'open_speed' => array( |
| 1523 | 'title' => __( 'Opening speed', 'responsive-lightbox' ), |
| 1524 | 'section' => 'responsive_lightbox_configuration', |
| 1525 | 'type' => 'number', |
| 1526 | 'description' => __( 'Duration of opening animation.', 'responsive-lightbox' ), |
| 1527 | 'append' => 'ms', |
| 1528 | 'parent' => 'featherlight' |
| 1529 | ), |
| 1530 | 'close_speed' => array( |
| 1531 | 'title' => __( 'Closing speed', 'responsive-lightbox' ), |
| 1532 | 'section' => 'responsive_lightbox_configuration', |
| 1533 | 'type' => 'number', |
| 1534 | 'description' => __( 'Duration of closing animation.', 'responsive-lightbox' ), |
| 1535 | 'append' => 'ms', |
| 1536 | 'parent' => 'featherlight' |
| 1537 | ), |
| 1538 | 'close_on_click' => array( |
| 1539 | 'title' => __( 'Close on click', 'responsive-lightbox' ), |
| 1540 | 'section' => 'responsive_lightbox_configuration', |
| 1541 | 'type' => 'radio', |
| 1542 | 'label' => __( 'Select how to close lightbox.', 'responsive-lightbox' ), |
| 1543 | 'options' => array( |
| 1544 | 'background' => __( 'background', 'responsive-lightbox' ), |
| 1545 | 'anywhere' => __( 'anywhere', 'responsive-lightbox' ), |
| 1546 | 'false' => __( 'false', 'responsive-lightbox' ) |
| 1547 | ), |
| 1548 | 'parent' => 'featherlight' |
| 1549 | ), |
| 1550 | 'close_on_esc' => array( |
| 1551 | 'title' => __( 'Close on Esc', 'responsive-lightbox' ), |
| 1552 | 'section' => 'responsive_lightbox_configuration', |
| 1553 | 'type' => 'boolean', |
| 1554 | 'label' => __( 'Toggle if pressing Esc button closes lightbox.', 'responsive-lightbox' ), |
| 1555 | 'parent' => 'featherlight' |
| 1556 | ), |
| 1557 | 'gallery_fade_in' => array( |
| 1558 | 'title' => __( 'Gallery fade in', 'responsive-lightbox' ), |
| 1559 | 'section' => 'responsive_lightbox_configuration', |
| 1560 | 'type' => 'number', |
| 1561 | 'description' => __( 'Animation speed when image is loaded.', 'responsive-lightbox' ), |
| 1562 | 'append' => 'ms', |
| 1563 | 'parent' => 'featherlight' |
| 1564 | ), |
| 1565 | 'gallery_fade_out' => array( |
| 1566 | 'title' => __( 'Gallery fade out', 'responsive-lightbox' ), |
| 1567 | 'section' => 'responsive_lightbox_configuration', |
| 1568 | 'type' => 'number', |
| 1569 | 'description' => __( 'Animation speed before image is loaded.', 'responsive-lightbox' ), |
| 1570 | 'append' => 'ms', |
| 1571 | 'parent' => 'featherlight' |
| 1572 | ) |
| 1573 | ); |
| 1574 | break; |
| 1575 | |
| 1576 | case 'magnific': |
| 1577 | $this->settings['configuration']['prefix'] = 'rl_mp'; |
| 1578 | $this->settings['configuration']['fields'] = array( |
| 1579 | 'disable_on' => array( |
| 1580 | 'title' => __( 'Disable on', 'responsive-lightbox' ), |
| 1581 | 'section' => 'responsive_lightbox_configuration', |
| 1582 | 'type' => 'number', |
| 1583 | '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' ), |
| 1584 | 'append' => 'px', |
| 1585 | 'parent' => 'magnific' |
| 1586 | ), |
| 1587 | 'mid_click' => array( |
| 1588 | 'title' => __( 'Middle click', 'responsive-lightbox' ), |
| 1589 | 'section' => 'responsive_lightbox_configuration', |
| 1590 | 'type' => 'boolean', |
| 1591 | 'label' => __( 'If option enabled, lightbox is opened if the user clicked on the middle mouse button, or click with Command/Ctrl key.', 'responsive-lightbox' ), |
| 1592 | 'parent' => 'magnific' |
| 1593 | ), |
| 1594 | 'preloader' => array( |
| 1595 | 'title' => __( 'Preloader', 'responsive-lightbox' ), |
| 1596 | 'section' => 'responsive_lightbox_configuration', |
| 1597 | 'type' => 'boolean', |
| 1598 | 'label' => __( 'If option enabled, it\'s always present in DOM only text inside of it changes.', 'responsive-lightbox' ), |
| 1599 | 'parent' => 'magnific' |
| 1600 | ), |
| 1601 | 'close_on_content_click' => array( |
| 1602 | 'title' => __( 'Close on content click', 'responsive-lightbox' ), |
| 1603 | 'section' => 'responsive_lightbox_configuration', |
| 1604 | 'type' => 'boolean', |
| 1605 | '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' ), |
| 1606 | 'parent' => 'magnific' |
| 1607 | ), |
| 1608 | 'close_on_background_click' => array( |
| 1609 | 'title' => __( 'Close on background click', 'responsive-lightbox' ), |
| 1610 | 'section' => 'responsive_lightbox_configuration', |
| 1611 | 'type' => 'boolean', |
| 1612 | 'label' => __( 'Close the popup when user clicks on the dark overlay.', 'responsive-lightbox' ), |
| 1613 | 'parent' => 'magnific' |
| 1614 | ), |
| 1615 | 'close_button_inside' => array( |
| 1616 | 'title' => __( 'Close button inside', 'responsive-lightbox' ), |
| 1617 | 'section' => 'responsive_lightbox_configuration', |
| 1618 | 'type' => 'boolean', |
| 1619 | 'label' => __( 'If enabled, Magnific Popup will put close button inside content of popup.', 'responsive-lightbox' ), |
| 1620 | 'parent' => 'magnific' |
| 1621 | ), |
| 1622 | 'show_close_button' => array( |
| 1623 | 'title' => __( 'Show close button', 'responsive-lightbox' ), |
| 1624 | 'section' => 'responsive_lightbox_configuration', |
| 1625 | 'type' => 'boolean', |
| 1626 | 'label' => __( 'Controls whether the close button will be displayed or not.', 'responsive-lightbox' ), |
| 1627 | 'parent' => 'magnific' |
| 1628 | ), |
| 1629 | 'enable_escape_key' => array( |
| 1630 | 'title' => __( 'Enable escape key', 'responsive-lightbox' ), |
| 1631 | 'section' => 'responsive_lightbox_configuration', |
| 1632 | 'type' => 'boolean', |
| 1633 | 'label' => __( 'Controls whether pressing the escape key will dismiss the active popup or not.', 'responsive-lightbox' ), |
| 1634 | 'parent' => 'magnific' |
| 1635 | ), |
| 1636 | 'align_top' => array( |
| 1637 | 'title' => __( 'Align top', 'responsive-lightbox' ), |
| 1638 | 'section' => 'responsive_lightbox_configuration', |
| 1639 | 'type' => 'boolean', |
| 1640 | 'label' => __( 'If set to true popup is aligned to top instead of to center.', 'responsive-lightbox' ), |
| 1641 | 'parent' => 'magnific' |
| 1642 | ), |
| 1643 | 'fixed_content_position' => array( |
| 1644 | 'title' => __( 'Content position type', 'responsive-lightbox' ), |
| 1645 | 'section' => 'responsive_lightbox_configuration', |
| 1646 | 'type' => 'select', |
| 1647 | 'description' => __( 'Popup content position. If set to "auto" popup will automatically disable this option when browser doesn\'t support fixed position properly.', 'responsive-lightbox' ), |
| 1648 | 'options' => array( |
| 1649 | 'auto' => __( 'Auto', 'responsive-lightbox' ), |
| 1650 | 'true' => __( 'Fixed', 'responsive-lightbox' ), |
| 1651 | 'false' => __( 'Absolute', 'responsive-lightbox' ) |
| 1652 | ), |
| 1653 | 'parent' => 'magnific' |
| 1654 | ), |
| 1655 | 'fixed_background_position' => array( |
| 1656 | 'title' => __( 'Fixed background position', 'responsive-lightbox' ), |
| 1657 | 'section' => 'responsive_lightbox_configuration', |
| 1658 | 'type' => 'select', |
| 1659 | 'description' => __( 'Dark transluscent overlay content position.', 'responsive-lightbox' ), |
| 1660 | 'options' => array( |
| 1661 | 'auto' => __( 'Auto', 'responsive-lightbox' ), |
| 1662 | 'true' => __( 'Fixed', 'responsive-lightbox' ), |
| 1663 | 'false' => __( 'Absolute', 'responsive-lightbox' ) |
| 1664 | ), |
| 1665 | 'parent' => 'magnific' |
| 1666 | ), |
| 1667 | 'auto_focus_last' => array( |
| 1668 | 'title' => __( 'Auto focus last', 'responsive-lightbox' ), |
| 1669 | 'section' => 'responsive_lightbox_configuration', |
| 1670 | 'type' => 'boolean', |
| 1671 | 'label' => __( 'If set to true last focused element before popup showup will be focused after popup close.', 'responsive-lightbox' ), |
| 1672 | 'parent' => 'magnific' |
| 1673 | ) |
| 1674 | ); |
| 1675 | break; |
| 1676 | |
| 1677 | default: |
| 1678 | $this->settings['configuration'] = apply_filters( 'rl_settings_' . ( ! empty( $section_key ) ? $section_key : Responsive_Lightbox()->options['settings']['script'] ) . '_script_configuration', $this->settings['configuration'] ); |
| 1679 | } |
| 1680 | |
| 1681 | if ( isset( $this->tabs[$tab_key]['submit'], $this->tabs[$tab_key]['reset'] ) && ! empty( $this->settings[$tab_key]['prefix'] ) ) { |
| 1682 | $this->tabs[$tab_key]['submit'] = 'save_' . $this->settings[$tab_key]['prefix'] . '_' . $tab_key; |
| 1683 | $this->tabs[$tab_key]['reset'] = 'reset_' . $this->settings[$tab_key]['prefix'] . '_' . $tab_key; |
| 1684 | } |
| 1685 | } |
| 1686 | |
| 1687 | /** |
| 1688 | * Register options page |
| 1689 | * |
| 1690 | * @return void |
| 1691 | */ |
| 1692 | public function admin_menu_options() { |
| 1693 | add_menu_page( __( 'General', 'responsive-lightbox' ), __( 'Lightbox', 'responsive-lightbox' ), apply_filters( 'rl_lightbox_settings_capability', 'manage_options' ), 'responsive-lightbox-settings', '', 'dashicons-format-image', '57.1' ); |
| 1694 | |
| 1695 | $capability = apply_filters( 'rl_lightbox_settings_capability', 'manage_options' ); |
| 1696 | |
| 1697 | foreach ( $this->tabs as $key => $options ) { |
| 1698 | add_submenu_page( 'responsive-lightbox-settings', $options['name'], $options['name'], $capability, 'responsive-lightbox-' . $key , array( $this, 'options_page' ) ); |
| 1699 | } |
| 1700 | } |
| 1701 | |
| 1702 | /** |
| 1703 | * Render options page |
| 1704 | * |
| 1705 | * @return void |
| 1706 | */ |
| 1707 | public function options_page() { |
| 1708 | // check settings page |
| 1709 | if ( isset( $_GET['page'] ) && preg_match( '/^responsive-lightbox-(' . implode( '|', array_keys( $this->tabs ) ) . ')$/', $_GET['page'], $tabs ) !== 1 ) |
| 1710 | return; |
| 1711 | |
| 1712 | $tab_key = isset( $tabs[1] ) ? $tabs[1] : 'settings'; |
| 1713 | $section_key = isset( $_GET['section'] ) ? esc_attr( $_GET['section'] ) : ( ! empty( $this->tabs[$tab_key]['default_section'] ) ? $this->tabs[$tab_key]['default_section'] : '' ); |
| 1714 | |
| 1715 | echo ' |
| 1716 | <div class="wrap"> |
| 1717 | <h2>' . __( 'Responsive Lightbox & Gallery', 'responsive-lightbox' ) . ' - ' . $this->tabs[$tab_key]['name'] . '</h2>'; |
| 1718 | |
| 1719 | settings_errors(); |
| 1720 | |
| 1721 | echo ' |
| 1722 | <h2 class="nav-tab-wrapper">'; |
| 1723 | |
| 1724 | foreach ( $this->tabs as $key => $options ) { |
| 1725 | echo ' |
| 1726 | <a class="nav-tab ' . ( $tab_key == $key ? 'nav-tab-active' : '' ) . '" href="' . esc_url( admin_url( 'admin.php?page=responsive-lightbox-' . $key ) ) . '">' . $options['name'] . '</a>'; |
| 1727 | } |
| 1728 | |
| 1729 | echo ' |
| 1730 | </h2> |
| 1731 | <div class="responsive-lightbox-settings"> |
| 1732 | |
| 1733 | <div class="df-credits"> |
| 1734 | <h3 class="hndle">' . __( 'Responsive Lightbox & Gallery', 'responsive-lightbox' ) . ' ' . Responsive_Lightbox()->defaults['version'] . '</h3> |
| 1735 | <div class="inside"> |
| 1736 | <h4 class="inner">' . __( 'Need support?', 'responsive-lightbox' ) . '</h4> |
| 1737 | <p class="inner">' . sprintf( __( 'If you are having problems with this plugin, please browse it\'s <a href="%s" target="_blank">Documentation</a> or talk about them in the <a href="%s" target="_blank">Support forum</a>', 'responsive-lightbox' ), 'https://www.dfactory.eu/docs/responsive-lightbox/?utm_source=responsive-lightbox-settings&utm_medium=link&utm_campaign=docs', 'https://www.dfactory.eu/support/?utm_source=responsive-lightbox-settings&utm_medium=link&utm_campaign=support' ) . '</p> |
| 1738 | <hr /> |
| 1739 | <h4 class="inner">' . __( 'Do you like this plugin?', 'responsive-lightbox' ) . '</h4> |
| 1740 | <p class="inner">' . sprintf( __( '<a href="%s" target="_blank">Rate it 5</a> on WordPress.org', 'responsive-lightbox' ), 'https://wordpress.org/support/plugin/responsive-lightbox/reviews/?filter=5' ) . '<br />' . |
| 1741 | sprintf( __( 'Blog about it & link to the <a href="%s" target="_blank">plugin page</a>.', 'responsive-lightbox' ), 'https://dfactory.eu/plugins/responsive-lightbox/?utm_source=responsive-lightbox-settings&utm_medium=link&utm_campaign=blog-about' ) . '<br />' . |
| 1742 | sprintf( __( 'Check out our other <a href="%s" target="_blank">WordPress plugins</a>.', 'responsive-lightbox' ), 'https://dfactory.eu/plugins/?utm_source=responsive-lightbox-settings&utm_medium=link&utm_campaign=other-plugins' ) . ' |
| 1743 | </p> |
| 1744 | <hr /> |
| 1745 | <p class="df-link inner">Created by <a href="http://www.dfactory.eu/?utm_source=responsive-lightbox-settings&utm_medium=link&utm_campaign=created-by" target="_blank" title="dFactory - Quality plugins for WordPress"><img src="' . RESPONSIVE_LIGHTBOX_URL . '/images/logo-dfactory.png' . '" title="dFactory - Quality plugins for WordPress" alt="dFactory - Quality plugins for WordPress" /></a></p> |
| 1746 | </div> |
| 1747 | </div> |
| 1748 | |
| 1749 | <form action="options.php" method="post">'; |
| 1750 | |
| 1751 | // views |
| 1752 | if ( ! empty( $this->tabs[$tab_key]['sections'] ) ) { |
| 1753 | $views = $this->tabs[$tab_key]['sections']; |
| 1754 | |
| 1755 | echo '<ul class="subsubsub">'; |
| 1756 | |
| 1757 | foreach ( $views as $key => $name ) { |
| 1758 | $view = '<a href="' . esc_url( admin_url( 'admin.php?page=responsive-lightbox-' . $tab_key . '§ion=' . $key ) ) . '" class="' . ( $key == $section_key ? 'current' : '' ) . '">' . $name . '</a>'; |
| 1759 | $views[$key] = "\t<li class='$key'>$view"; |
| 1760 | } |
| 1761 | |
| 1762 | echo implode( " |</li>\n", $views ) . "</li>\n"; |
| 1763 | echo '</ul><input type="hidden" name="section" value="' . $section_key . '" /><br class="clear">'; |
| 1764 | } |
| 1765 | |
| 1766 | // tab content callback |
| 1767 | if ( ! empty( $this->tabs[$tab_key]['callback'] ) ) |
| 1768 | call_user_func( $this->tabs[$tab_key]['callback'] ); |
| 1769 | else { |
| 1770 | wp_nonce_field( 'update-options' ); |
| 1771 | |
| 1772 | settings_fields( $this->tabs[$tab_key]['key'] ); |
| 1773 | do_settings_sections( $this->tabs[$tab_key]['key'] ); |
| 1774 | |
| 1775 | if ( $tab_key === 'builder' ) |
| 1776 | echo '<input type="hidden" name="_wp_http_referer" value="'. esc_attr( wp_unslash( add_query_arg( 'flush_rules', 1, $_SERVER['REQUEST_URI'] ) ) ) . '" />'; |
| 1777 | } |
| 1778 | |
| 1779 | if ( ! empty( $this->tabs[$tab_key]['submit'] ) || ! empty( $this->tabs[$tab_key]['reset'] ) ) { |
| 1780 | echo '<p class="submit">'; |
| 1781 | |
| 1782 | if ( ! empty( $this->tabs[$tab_key]['submit'] ) ) { |
| 1783 | submit_button( '', array( 'primary', 'save-' . $tab_key ), $this->tabs[$tab_key]['submit'], false ); |
| 1784 | echo ' '; |
| 1785 | } |
| 1786 | |
| 1787 | if ( ! empty( $this->tabs[$tab_key]['reset'] ) ) |
| 1788 | submit_button( __( 'Reset to defaults', 'responsive-lightbox' ), array( 'secondary', 'reset-' . $tab_key ), $this->tabs[$tab_key]['reset'], false ); |
| 1789 | |
| 1790 | echo '</p>'; |
| 1791 | } |
| 1792 | |
| 1793 | echo ' |
| 1794 | </form> |
| 1795 | </div> |
| 1796 | <div class="clear"></div> |
| 1797 | </div>'; |
| 1798 | } |
| 1799 | |
| 1800 | /** |
| 1801 | * Render settings function |
| 1802 | * |
| 1803 | * @return void |
| 1804 | */ |
| 1805 | public function register_settings() { |
| 1806 | foreach ( $this->settings as $setting_id => $setting ) { |
| 1807 | // set key |
| 1808 | $setting_key = $setting_id; |
| 1809 | $setting_id = 'responsive_lightbox_' . $setting_id; |
| 1810 | |
| 1811 | // register setting |
| 1812 | register_setting( |
| 1813 | esc_attr( $setting_id ), |
| 1814 | ! empty( $setting['option_name'] ) ? esc_attr( $setting['option_name'] ) : $setting_id, |
| 1815 | ! empty( $setting['callback'] ) ? $setting['callback'] : array( $this, 'validate_settings' ) |
| 1816 | ); |
| 1817 | |
| 1818 | // register sections |
| 1819 | if ( ! empty( $setting['sections'] ) && is_array( $setting['sections'] ) ) { |
| 1820 | foreach ( $setting['sections'] as $section_id => $section ) { |
| 1821 | add_settings_section( |
| 1822 | esc_attr( $section_id ), |
| 1823 | ! empty( $section['title'] ) ? esc_html( $section['title'] ) : '', |
| 1824 | ! empty( $section['callback'] ) ? $section['callback'] : '', |
| 1825 | ! empty( $section['page'] ) ? esc_attr( $section['page'] ) : $section_id |
| 1826 | ); |
| 1827 | } |
| 1828 | } |
| 1829 | |
| 1830 | // register fields |
| 1831 | if ( ! empty( $setting['fields'] ) && is_array( $setting['fields'] ) ) { |
| 1832 | foreach ( $setting['fields'] as $field_id => $field ) { |
| 1833 | // prefix field id? |
| 1834 | $field_key = $field_id; |
| 1835 | $field_id = ( ! empty( $setting['prefix'] ) ? $setting['prefix'] . '_' : '' ) . $field_id; |
| 1836 | |
| 1837 | // field args |
| 1838 | $args = array( |
| 1839 | 'id' => ! empty( $field['id'] ) ? $field['id'] : $field_id, |
| 1840 | 'class' => ! empty( $field['class'] ) ? $field['class'] : '', |
| 1841 | 'name' => $setting['option_name'] . ( ! empty( $field['parent'] ) ? '[' . $field['parent'] . ']' : '' ) . '[' . $field_key . ']', |
| 1842 | 'type' => ! empty( $field['type'] ) ? $field['type'] : 'text', |
| 1843 | 'label' => ! empty( $field['label'] ) ? $field['label'] : '', |
| 1844 | 'description' => ! empty( $field['description'] ) ? $field['description'] : '', |
| 1845 | 'disabled' => isset( $field['disabled'] ) ? (bool) $field['disabled'] : false, |
| 1846 | 'append' => ! empty( $field['append'] ) ? esc_html( $field['append'] ) : '', |
| 1847 | 'prepend' => ! empty( $field['prepend'] ) ? esc_html( $field['prepend'] ) : '', |
| 1848 | 'min' => ! empty( $field['min'] ) ? (int) $field['min'] : '', |
| 1849 | 'max' => ! empty( $field['max'] ) ? (int) $field['max'] : '', |
| 1850 | 'options' => ! empty( $field['options'] ) ? $field['options'] : '', |
| 1851 | 'fields' => ! empty( $field['fields'] ) ? $field['fields'] : '', |
| 1852 | 'default' => $field['type'] === 'multiple' ? '' : ( $this->sanitize_field( ! empty( $field['parent'] ) ? Responsive_Lightbox()->defaults[$setting_key][$field['parent']][$field_key] : Responsive_Lightbox()->defaults[$setting_key][$field_key], $field['type'] ) ), |
| 1853 | 'value' => $field['type'] === 'multiple' ? '' : ( $this->sanitize_field( ! empty( $field['parent'] ) ? Responsive_Lightbox()->options[$setting_key][$field['parent']][$field_key] : ( isset( Responsive_Lightbox()->options[$setting_key][$field_key] ) ? Responsive_Lightbox()->options[$setting_key][$field_key] : Responsive_Lightbox()->defaults[$setting_key][$field_key] ), $field['type'] ) ), |
| 1854 | 'label_for' => $field_id, |
| 1855 | 'return' => false |
| 1856 | ); |
| 1857 | |
| 1858 | if ( $args['type'] === 'multiple' ) { |
| 1859 | foreach ( $args['fields'] as $subfield_id => $subfield ) { |
| 1860 | $args['fields'][$subfield_id] = wp_parse_args( $subfield, array( |
| 1861 | 'id' => $field_id . '-' . $subfield_id, |
| 1862 | 'class' => ! empty( $subfield['class'] ) ? $subfield['class'] : '', |
| 1863 | 'name' => $setting['option_name'] . ( ! empty( $subfield['parent'] ) ? '[' . $subfield['parent'] . ']' : '' ) . '[' . $subfield_id . ']', |
| 1864 | 'default' => $this->sanitize_field( ! empty( $subfield['parent'] ) ? Responsive_Lightbox()->defaults[$setting_key][$subfield['parent']][$subfield_id] : Responsive_Lightbox()->defaults[$setting_key][$subfield_id], $subfield['type'] ), |
| 1865 | 'value' => $this->sanitize_field( ! empty( $subfield['parent'] ) ? Responsive_Lightbox()->options[$setting_key][$subfield['parent']][$subfield_id] : Responsive_Lightbox()->options[$setting_key][$subfield_id], $subfield['type'] ), |
| 1866 | 'return' => true |
| 1867 | ) ); |
| 1868 | } |
| 1869 | } |
| 1870 | |
| 1871 | add_settings_field( |
| 1872 | esc_attr( $field_id ), |
| 1873 | ! empty( $field['title'] ) ? esc_html( $field['title'] ) : '', |
| 1874 | array( $this, 'render_field' ), |
| 1875 | ! empty( $field['page'] ) ? esc_attr( $field['page'] ) : $setting_id, |
| 1876 | ! empty( $field['section'] ) ? esc_attr( $field['section'] ) : '', |
| 1877 | $args |
| 1878 | ); |
| 1879 | } |
| 1880 | } |
| 1881 | } |
| 1882 | |
| 1883 | // licenses |
| 1884 | $extensions = apply_filters( 'rl_settings_licenses', array() ); |
| 1885 | |
| 1886 | if ( $extensions ) { |
| 1887 | // register setting |
| 1888 | register_setting( |
| 1889 | 'responsive_lightbox_licenses', |
| 1890 | 'responsive_lightbox_licenses', |
| 1891 | array( $this, 'validate_licenses' ) |
| 1892 | ); |
| 1893 | |
| 1894 | add_settings_section( |
| 1895 | 'responsive_lightbox_licenses', |
| 1896 | __( 'Licenses', 'responsive-lightbox' ), |
| 1897 | array( $this, 'licenses_section_cb' ), |
| 1898 | 'responsive_lightbox_licenses' |
| 1899 | ); |
| 1900 | |
| 1901 | foreach ( $extensions as $id => $extension ) { |
| 1902 | add_settings_field( |
| 1903 | esc_attr( $id ), |
| 1904 | $extension['name'], |
| 1905 | array( $this, 'license_field_cb' ), |
| 1906 | 'responsive_lightbox_licenses', |
| 1907 | 'responsive_lightbox_licenses', |
| 1908 | $extension |
| 1909 | ); |
| 1910 | } |
| 1911 | } |
| 1912 | } |
| 1913 | |
| 1914 | /** |
| 1915 | * Render settings field function |
| 1916 | * |
| 1917 | * @param array $args |
| 1918 | * @return mixed |
| 1919 | */ |
| 1920 | public function render_field( $args ) { |
| 1921 | if ( empty( $args ) || ! is_array( $args ) ) |
| 1922 | return; |
| 1923 | |
| 1924 | $html = ''; |
| 1925 | |
| 1926 | switch ( $args['type'] ) { |
| 1927 | case 'boolean': |
| 1928 | |
| 1929 | $html .= '<label class="cb-checkbox"><input id="' . $args['id'] . '" type="checkbox" name="' . $args['name'] . '" value="1" ' . checked( (bool) $args['value'], true, false ) . ( isset( $args['disabled'] ) && $args['disabled'] == true ? ' disabled="disabled"' : '' ) . ' />' . $args['label'] . '</label>'; |
| 1930 | break; |
| 1931 | |
| 1932 | case 'radio': |
| 1933 | foreach ( $args['options'] as $key => $name ) { |
| 1934 | $html .= '<label class="cb-radio"><input id="' . $args['id'] . '-' . $key . '" type="radio" name="' . $args['name'] . '" value="' . $key . '" ' . checked( $key, $args['value'], false ) . ( isset( $args['disabled'] ) && $args['disabled'] == true ? ' disabled="disabled"' : '' ) . ' />' . $name . '</label> '; |
| 1935 | } |
| 1936 | break; |
| 1937 | |
| 1938 | case 'checkbox': |
| 1939 | foreach ( $args['options'] as $key => $name ) { |
| 1940 | $html .= '<label class="cb-checkbox"><input id="' . $args['id'] . '-' . $key . '" type="checkbox" name="' . $args['name'] . '[' . $key . ']" value="1" ' . checked( in_array( $key, $args['value'] ), true, false ) . ( isset( $args['disabled'] ) && $args['disabled'] == true ? ' disabled="disabled"' : '' ) . ' />' . $name . '</label> '; |
| 1941 | } |
| 1942 | break; |
| 1943 | |
| 1944 | case 'select': |
| 1945 | $html .= '<select id="' . $args['id'] . '" name="' . $args['name'] . '" value="' . $args['value'] . '" />'; |
| 1946 | |
| 1947 | foreach ( $args['options'] as $key => $name ) { |
| 1948 | $html .= '<option value="' . $key . '" ' . selected( $args['value'], $key, false ) . '>' . $name . '</option>'; |
| 1949 | } |
| 1950 | |
| 1951 | $html .= '</select>'; |
| 1952 | break; |
| 1953 | |
| 1954 | case 'multiple': |
| 1955 | $html .= '<fieldset>'; |
| 1956 | |
| 1957 | if ( $args['fields'] ) { |
| 1958 | $count = 1; |
| 1959 | $count_fields = count( $args['fields'] ); |
| 1960 | |
| 1961 | foreach ( $args['fields'] as $subfield_id => $subfield_args ) { |
| 1962 | $html .= $this->render_field( $subfield_args ) . ( $count < $count_fields ? '<br />' : '' ); |
| 1963 | $count++; |
| 1964 | } |
| 1965 | } |
| 1966 | |
| 1967 | $html .= '</fieldset>'; |
| 1968 | break; |
| 1969 | |
| 1970 | case 'range': |
| 1971 | $html .= '<input id="' . $args['id'] . '" type="range" name="' . $args['name'] . '" value="' . $args['value'] . '" min="' . $args['min'] . '" max="' . $args['max'] . '" oninput="this.form.' . $args['id'] . '_range.value=this.value" />'; |
| 1972 | $html .= '<output name="' . $args['id'] . '_range">' . (int) $args['value'] . '</output>'; |
| 1973 | break; |
| 1974 | |
| 1975 | case 'color_picker': |
| 1976 | $html .= '<input id="' . $args['id'] . '" class="color-picker" type="text" value="' . $args['value'] . '" name="' . $args['name'] . '" data-default-color="' . $args['default'] . '" />'; |
| 1977 | break; |
| 1978 | |
| 1979 | case 'number': |
| 1980 | $html .= ( ! empty( $args['prepend'] ) ? '<span>' . $args['prepend'] . '</span> ' : '' ); |
| 1981 | $html .= '<input id="' . $args['id'] . '" type="text" value="' . $args['value'] . '" name="' . $args['name'] . '" />'; |
| 1982 | $html .= ( ! empty( $args['append'] ) ? ' <span>' . $args['append'] . '</span>' : '' ); |
| 1983 | break; |
| 1984 | |
| 1985 | case 'button': |
| 1986 | $html .= ( ! empty( $args['prepend'] ) ? '<span>' . $args['prepend'] . '</span> ' : '' ); |
| 1987 | $html .= '<a href="' . esc_url( admin_url( 'admin.php?page=responsive-lightbox-tour' ) ) . '" id="' . $args['id'] . '" class="button button-secondary">' . esc_html( $args['label'] ) . '</a>'; |
| 1988 | // $html .= '<input id="' . $args['id'] . '" type="submit" value="' . esc_attr( $args['label'] ) . '" name="' . $args['name'] . '" class="button button-secondary" />'; |
| 1989 | $html .= ( ! empty( $args['append'] ) ? ' <span>' . $args['append'] . '</spbuilderan>' : '' ); |
| 1990 | break; |
| 1991 | |
| 1992 | case 'text': |
| 1993 | default : |
| 1994 | $html .= ( ! empty( $args['prepend'] ) ? '<span>' . $args['prepend'] . '</span> ' : '' ); |
| 1995 | $html .= '<input id="' . $args['id'] . '" class="' . $args['class'] . '" type="text" value="' . $args['value'] . '" name="' . $args['name'] . '" />'; |
| 1996 | $html .= ( ! empty( $args['append'] ) ? ' <span>' . $args['append'] . '</span>' : '' ); |
| 1997 | } |
| 1998 | |
| 1999 | if ( ! empty ( $args['description'] ) ) { |
| 2000 | $html .= '<p class="description">' . $args['description'] . '</p>'; |
| 2001 | } |
| 2002 | |
| 2003 | if ( ! empty( $args['return'] ) ) { |
| 2004 | return $html; |
| 2005 | } else { |
| 2006 | echo $html; |
| 2007 | } |
| 2008 | } |
| 2009 | |
| 2010 | /** |
| 2011 | * Sanitize field function |
| 2012 | * |
| 2013 | * @param mixed |
| 2014 | * @param string |
| 2015 | * @return mixed |
| 2016 | */ |
| 2017 | public function sanitize_field( $value = null, $type = '', $args = array() ) { |
| 2018 | if ( is_null( $value ) ) |
| 2019 | return null; |
| 2020 | |
| 2021 | switch ( $type ) { |
| 2022 | case 'button': |
| 2023 | case 'boolean': |
| 2024 | $value = empty( $value ) ? false : true; |
| 2025 | break; |
| 2026 | |
| 2027 | case 'checkbox': |
| 2028 | $value = is_array( $value ) && ! empty( $value ) ? array_map( 'sanitize_text_field', $value ) : array(); |
| 2029 | break; |
| 2030 | |
| 2031 | case 'radio': |
| 2032 | $value = is_array( $value ) ? false : sanitize_text_field( $value ); |
| 2033 | break; |
| 2034 | |
| 2035 | case 'textarea': |
| 2036 | case 'wysiwyg': |
| 2037 | $value = wp_kses_post( $value ); |
| 2038 | break; |
| 2039 | |
| 2040 | case 'color_picker': |
| 2041 | $value = ! $value || '#' == $value ? '' : esc_attr( $value ); |
| 2042 | break; |
| 2043 | |
| 2044 | case 'number': |
| 2045 | $value = (int) $value; |
| 2046 | |
| 2047 | // is value lower than? |
| 2048 | if ( isset( $args['min'] ) && $value < $args['min'] ) |
| 2049 | $value = $args['min']; |
| 2050 | |
| 2051 | // is value greater than? |
| 2052 | if ( isset( $args['max'] ) && $value > $args['max'] ) |
| 2053 | $value = $args['max']; |
| 2054 | break; |
| 2055 | |
| 2056 | case 'text': |
| 2057 | case 'select': |
| 2058 | default: |
| 2059 | $value = is_array( $value ) ? array_map( 'sanitize_text_field', $value ) : sanitize_text_field( $value ); |
| 2060 | break; |
| 2061 | } |
| 2062 | |
| 2063 | return stripslashes_deep( $value ); |
| 2064 | } |
| 2065 | |
| 2066 | /** |
| 2067 | * Validate settings function |
| 2068 | * |
| 2069 | * @param array $input |
| 2070 | * @return array |
| 2071 | */ |
| 2072 | public function validate_settings( $input ) { |
| 2073 | // check cap |
| 2074 | if ( ! current_user_can( apply_filters( 'rl_lightbox_settings_capability', 'manage_options' ) ) ) |
| 2075 | return $input; |
| 2076 | |
| 2077 | if ( isset( $_POST['responsive_lightbox_settings']['tour'] ) ) { |
| 2078 | |
| 2079 | } |
| 2080 | |
| 2081 | // check page |
| 2082 | if ( ! isset( $_POST['option_page'] ) || ! ( $option_page = esc_attr( $_POST['option_page'] ) ) ) |
| 2083 | return $input; |
| 2084 | |
| 2085 | foreach ( $this->settings as $id => $setting ) { |
| 2086 | $key = array_search( $option_page, $setting ); |
| 2087 | |
| 2088 | if ( $key ) { |
| 2089 | // set key |
| 2090 | $setting_id = $id; |
| 2091 | break; |
| 2092 | } |
| 2093 | } |
| 2094 | |
| 2095 | // check setting id |
| 2096 | if ( ! $setting_id ) |
| 2097 | return $input; |
| 2098 | |
| 2099 | // save settings |
| 2100 | if ( isset( $_POST['save' . '_' . $this->settings[$setting_id]['prefix'] . '_' . $setting_id] ) ) { |
| 2101 | if ( $this->settings[$setting_id]['fields'] ) { |
| 2102 | foreach ( $this->settings[$setting_id]['fields'] as $field_id => $field ) { |
| 2103 | if ( $field['type'] === 'multiple' ) { |
| 2104 | if ( $field['fields'] ) { |
| 2105 | foreach ( $field['fields'] as $subfield_id => $subfield ) { |
| 2106 | // if subfield has parent |
| 2107 | if ( ! empty( $this->settings[$setting_id]['fields'][$field_id]['fields'][$subfield_id]['parent'] ) ) { |
| 2108 | $field_parent = $this->settings[$setting_id]['fields'][$field_id]['fields'][$subfield_id]['parent']; |
| 2109 | |
| 2110 | $input[$field_parent][$subfield_id] = isset( $input[$field_parent][$subfield_id] ) ? $this->sanitize_field( $input[$field_parent][$subfield_id], $subfield['type'] ) : ( $subfield['type'] === 'boolean' ? false : Responsive_Lightbox()->defaults[$setting_id][$field_parent][$subfield_id] ); |
| 2111 | } else { |
| 2112 | $input[$subfield_id] = isset( $input[$subfield_id] ) ? $this->sanitize_field( $input[$subfield_id], $subfield['type'] ) : ( $subfield['type'] === 'boolean' ? false : Responsive_Lightbox()->defaults[$setting_id][$field_id][$subfield_id] ); |
| 2113 | } |
| 2114 | } |
| 2115 | } |
| 2116 | } else { |
| 2117 | // if field has parent |
| 2118 | if ( ! empty( $this->settings[$setting_id]['fields'][$field_id]['parent'] ) ) { |
| 2119 | $field_parent = $this->settings[$setting_id]['fields'][$field_id]['parent']; |
| 2120 | |
| 2121 | $input[$field_parent][$field_id] = isset( $input[$field_parent][$field_id] ) ? ( $field['type'] === 'checkbox' ? array_keys( $this->sanitize_field( $input[$field_parent][$field_id], $field['type'] ) ) : $this->sanitize_field( $input[$field_parent][$field_id], $field['type'] ) ) : ( in_array( $field['type'], array( 'boolean', 'checkbox' ) ) ? false : Responsive_Lightbox()->defaults[$setting_id][$field_parent][$field_id] ); |
| 2122 | } else { |
| 2123 | $input[$field_id] = isset( $input[$field_id] ) ? ( $field['type'] === 'checkbox' ? array_keys( $this->sanitize_field( $input[$field_id], $field['type'] ) ) : $this->sanitize_field( $input[$field_id], $field['type'] ) ) : ( in_array( $field['type'], array( 'boolean', 'checkbox' ) ) ? false : Responsive_Lightbox()->defaults[$setting_id][$field_id] ); |
| 2124 | } |
| 2125 | } |
| 2126 | } |
| 2127 | } |
| 2128 | |
| 2129 | if ( $setting_id === 'settings' ) { |
| 2130 | // merge scripts settings |
| 2131 | $input = array_merge( Responsive_Lightbox()->options['settings'], $input ); |
| 2132 | } |
| 2133 | |
| 2134 | if ( $setting_id === 'configuration' ) { |
| 2135 | // merge scripts settings |
| 2136 | $input = array_merge( Responsive_Lightbox()->options['configuration'], $input ); |
| 2137 | } |
| 2138 | } elseif ( isset( $_POST['reset' . '_' . $this->settings[$setting_id]['prefix'] . '_' . $setting_id] ) ) { |
| 2139 | if ( $setting_id === 'configuration' ) { |
| 2140 | $script = key( $input ); |
| 2141 | |
| 2142 | // merge scripts settings |
| 2143 | $input[$script] = Responsive_Lightbox()->defaults['configuration'][$script]; |
| 2144 | $input = array_merge( Responsive_Lightbox()->options['configuration'], $input ); |
| 2145 | } elseif ( $setting_id === 'settings' ) { |
| 2146 | $input = Responsive_Lightbox()->defaults[$setting_id]; |
| 2147 | $input['update_version'] = Responsive_Lightbox()->options['settings']['update_version']; |
| 2148 | $input['update_notice'] = Responsive_Lightbox()->options['settings']['update_notice']; |
| 2149 | } else |
| 2150 | $input = Responsive_Lightbox()->defaults[$setting_id]; |
| 2151 | |
| 2152 | add_settings_error( 'reset_' . $this->settings[$setting_id]['prefix'] . '_' . $setting_id, 'settings_restored', __( 'Settings restored to defaults.', 'responsive-lightbox' ), 'updated' ); |
| 2153 | } |
| 2154 | |
| 2155 | return $input; |
| 2156 | } |
| 2157 | |
| 2158 | /** |
| 2159 | * Add-ons tab callback |
| 2160 | * |
| 2161 | * @return mixed |
| 2162 | */ |
| 2163 | private function addons_tab_cb() { |
| 2164 | ?> |
| 2165 | <h3><?php _e( 'Add-ons / Extensions', 'responsive-lightbox' ); ?></h3> |
| 2166 | <p class="description"><?php _e( 'Enhance your website with these beautiful, easy to use extensions, designed with Responsive Lightbox & Gallery integration in mind.', 'responsive-lightbox' ); ?></p> |
| 2167 | <br /> |
| 2168 | <?php |
| 2169 | if ( ( $cache = get_transient( 'responsive_lightbox_addons_feed' ) ) === false ) { |
| 2170 | $url = 'https://dfactory.eu/?feed=addons&product=responsive-lightbox'; |
| 2171 | |
| 2172 | $feed = wp_remote_get( esc_url_raw( $url ), array( 'sslverify' => false ) ); |
| 2173 | |
| 2174 | if ( ! is_wp_error( $feed ) ) { |
| 2175 | if ( isset( $feed['body'] ) && strlen( $feed['body'] ) > 0 ) |
| 2176 | $cache = wp_remote_retrieve_body( $feed ); |
| 2177 | } else |
| 2178 | $cache = '<div class="error"><p>' . __( 'There was an error retrieving the extensions list from the server. Please try again later.', 'responsive-lightbox' ) . '</div>'; |
| 2179 | } |
| 2180 | |
| 2181 | echo $cache; |
| 2182 | } |
| 2183 | |
| 2184 | /** |
| 2185 | * Licenses section callback. |
| 2186 | * |
| 2187 | * @return mixed |
| 2188 | */ |
| 2189 | public function licenses_section_cb() { |
| 2190 | ?><p class="description"><?php _e( 'A list of licenses for your Responsive Lightbox & Gallery extensions.', 'responsive-lightbox' ); ?></p><?php |
| 2191 | } |
| 2192 | |
| 2193 | /** |
| 2194 | * License field callback. |
| 2195 | * |
| 2196 | * @return mixed |
| 2197 | */ |
| 2198 | public function license_field_cb( $args ) { |
| 2199 | $licenses = get_option( 'responsive_lightbox_licenses' ); |
| 2200 | $license = ! empty( $licenses ) && isset( $licenses[$args['id']]['license'] ) ? esc_attr( $licenses[$args['id']]['license'] ) : ''; |
| 2201 | $status = ! empty( $licenses ) && ! empty( $licenses[$args['id']]['status'] ) ? true : false; |
| 2202 | ?> |
| 2203 | <fieldset class="rl_license rl_license-<?php echo esc_attr( $args['id'] ); ?>"> |
| 2204 | <input type="text" class="regular-text" name="responsive_lightbox_licenses[<?php echo esc_attr( $args['id'] ); ?>][license]" value="<?php echo $license; ?>"><span class="dashicons <?php echo ! empty( $status ) ? 'dashicons-yes' : 'dashicons-no'; ?>"></span> |
| 2205 | <p class="description"><?php printf( __( 'Enter your license key to activate %s extension and enable automatic upgrade notices.', 'responsive-lightbox' ), $args['name'] ); ?></p> |
| 2206 | </fieldset> |
| 2207 | <?php |
| 2208 | } |
| 2209 | |
| 2210 | /** |
| 2211 | * Validate licenses function. |
| 2212 | * |
| 2213 | * @param array $input |
| 2214 | * @return array |
| 2215 | */ |
| 2216 | public function validate_licenses( $input ) { |
| 2217 | // check cap |
| 2218 | if ( ! current_user_can( apply_filters( 'rl_lightbox_settings_capability', 'manage_options' ) ) ) |
| 2219 | return $input; |
| 2220 | |
| 2221 | // check page |
| 2222 | if ( ! isset( $_POST['option_page'] ) || ! ( $option_page = esc_attr( $_POST['option_page'] ) ) ) |
| 2223 | return $input; |
| 2224 | |
| 2225 | // check data |
| 2226 | if ( ! isset( $_POST['responsive_lightbox_licenses'] ) || ! is_array( $_POST['responsive_lightbox_licenses'] )) |
| 2227 | return $input; |
| 2228 | |
| 2229 | $extensions = apply_filters( 'rl_settings_licenses', array() ); |
| 2230 | |
| 2231 | if ( empty( $extensions ) ) |
| 2232 | return $input; |
| 2233 | |
| 2234 | // save settings |
| 2235 | if ( isset( $_POST['save_rl_licenses'] ) ) { |
| 2236 | $licenses = get_option( 'responsive_lightbox_licenses' ); |
| 2237 | $statuses = array( 'updated' => 0, 'error' => 0 ); |
| 2238 | |
| 2239 | foreach ( $extensions as $extension ) { |
| 2240 | if ( ! isset( $_POST['responsive_lightbox_licenses'][$extension['id']] ) ) |
| 2241 | continue; |
| 2242 | |
| 2243 | $license = preg_replace('/[^a-zA-Z0-9]/', '', $_POST['responsive_lightbox_licenses'][$extension['id']]['license'] ); |
| 2244 | $status = ! empty( $licenses ) && ! empty( $licenses[$extension['id']]['status'] ) ? true : false; |
| 2245 | |
| 2246 | // request data |
| 2247 | $request_args = array( |
| 2248 | 'action' => 'activate_license', |
| 2249 | 'license' => trim( $license ), |
| 2250 | 'item_name' => $extension['item_name'] |
| 2251 | ); |
| 2252 | |
| 2253 | // request |
| 2254 | $response = $this->license_request( $request_args ); |
| 2255 | |
| 2256 | // validate request |
| 2257 | if ( is_wp_error( $response ) ) { |
| 2258 | $input[$extension['id']['status']] = false; |
| 2259 | $statuses['error']++; |
| 2260 | } else { |
| 2261 | // decode the license data |
| 2262 | $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
| 2263 | |
| 2264 | // assign the data |
| 2265 | if ( $license_data->license == 'valid' ) { |
| 2266 | $input[$extension['id']]['status'] = true; |
| 2267 | |
| 2268 | if ( $status === false ) |
| 2269 | $statuses['updated']++; |
| 2270 | } else { |
| 2271 | $input[$extension['id']]['status'] = false; |
| 2272 | $statuses['error']++; |
| 2273 | } |
| 2274 | } |
| 2275 | } |
| 2276 | |
| 2277 | // success notice |
| 2278 | if ( $statuses['updated'] > 0 ) |
| 2279 | add_settings_error( 'rl_licenses_settings', 'license_activated', sprintf( _n( '%s license successfully activated.', '%s licenses successfully activated.', (int) $statuses['updated'], 'responsive-lightbox' ), (int) $statuses['updated'] ), 'updated' ); |
| 2280 | |
| 2281 | // failed notice |
| 2282 | if ( $statuses['error'] > 0 ) |
| 2283 | add_settings_error( 'rl_licenses_settings', 'license_activation_failed', sprintf( _n( '%s license activation failed.', '%s licenses activation failed.', (int) $statuses['error'], 'responsive-lightbox' ), (int) $statuses['error'] ), 'error' ); |
| 2284 | } elseif ( isset( $_POST['reset_rl_licenses'] ) ) { |
| 2285 | $licenses = get_option( 'responsive_lightbox_licenses' ); |
| 2286 | $statuses = array( 'updated' => 0, 'error' => 0 ); |
| 2287 | |
| 2288 | foreach ( $extensions as $extension ) { |
| 2289 | $license = ! empty( $licenses ) && isset( $licenses[$extension['id']]['license'] ) ? $licenses[$extension['id']]['license'] : ''; |
| 2290 | $status = ! empty( $licenses ) && ! empty( $licenses[$extension['id']]['status'] ) ? true : false; |
| 2291 | |
| 2292 | if ( $status === true || ( $status === false && ! empty( $license ) ) ) { |
| 2293 | // request data |
| 2294 | $request_args = array( |
| 2295 | 'action' => 'deactivate_license', |
| 2296 | 'license' => trim( $license ), |
| 2297 | 'item_name' => $extension['item_name'] |
| 2298 | ); |
| 2299 | |
| 2300 | // request |
| 2301 | $response = $this->license_request( $request_args ); |
| 2302 | |
| 2303 | // validate request |
| 2304 | if ( is_wp_error( $response ) ) |
| 2305 | $statuses['error']++; |
| 2306 | else { |
| 2307 | // decode the license data |
| 2308 | $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
| 2309 | |
| 2310 | // assign the data |
| 2311 | if ( $license_data->license == 'deactivated' ) { |
| 2312 | $input[$extension['id']]['license'] = ''; |
| 2313 | $input[$extension['id']]['status'] = false; |
| 2314 | $statuses['updated']++; |
| 2315 | } else |
| 2316 | $statuses['error']++; |
| 2317 | } |
| 2318 | } |
| 2319 | } |
| 2320 | |
| 2321 | // success notice |
| 2322 | if ( $statuses['updated'] > 0 ) |
| 2323 | add_settings_error( 'rl_licenses_settings', 'license_deactivated', sprintf( _n( '%s license successfully deactivated.', '%s licenses successfully deactivated.', (int) $statuses['updated'], 'responsive-lightbox' ), (int) $statuses['updated'] ), 'updated' ); |
| 2324 | |
| 2325 | // failed notice |
| 2326 | if ( $statuses['error'] > 0 ) |
| 2327 | add_settings_error( 'rl_licenses_settings', 'license_deactivation_failed', sprintf( _n( '%s license deactivation failed.', '%s licenses deactivation failed.', (int) $statuses['error'], 'responsive-lightbox' ), (int) $statuses['error'] ), 'error' ); |
| 2328 | } |
| 2329 | |
| 2330 | return $input; |
| 2331 | } |
| 2332 | |
| 2333 | /** |
| 2334 | * License request function. |
| 2335 | * |
| 2336 | * @param array $args |
| 2337 | * @return mixed |
| 2338 | */ |
| 2339 | private function license_request( $args ) { |
| 2340 | // data to send in our API request |
| 2341 | $api_params = array( |
| 2342 | 'edd_action' => $args['action'], |
| 2343 | 'license' => $args['license'], |
| 2344 | 'item_name' => urlencode( $args['item_name'] ), |
| 2345 | // 'item_id' => $args['item_id'], |
| 2346 | 'url' => home_url(), |
| 2347 | 'timeout' => 60, |
| 2348 | 'sslverify' => false |
| 2349 | ); |
| 2350 | |
| 2351 | // call the custom API. |
| 2352 | $response = wp_remote_get( add_query_arg( $api_params, $this->api_url ) ); |
| 2353 | |
| 2354 | return $response; |
| 2355 | } |
| 2356 | } |