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