class-settings.php
1580 lines
| 1 | <?php |
| 2 | if ( ! defined( 'ABSPATH' ) ) |
| 3 | exit; |
| 4 | |
| 5 | new Responsive_Lightbox_Settings(); |
| 6 | |
| 7 | /** |
| 8 | * Responsive Lightbox settings class. |
| 9 | * |
| 10 | * @class Responsive_Lightbox_Settings |
| 11 | */ |
| 12 | class Responsive_Lightbox_Settings { |
| 13 | |
| 14 | public $settings = array(); |
| 15 | private $scripts = array(); |
| 16 | private $tabs = array(); |
| 17 | private $choices = array(); |
| 18 | private $loading_places = array(); |
| 19 | private $api_url = 'http://dfactory.eu'; |
| 20 | |
| 21 | public function __construct() { |
| 22 | |
| 23 | // set instance |
| 24 | Responsive_Lightbox()->settings = $this; |
| 25 | |
| 26 | // actions |
| 27 | add_action( 'admin_init', array( &$this, 'register_settings' ) ); |
| 28 | add_action( 'admin_menu', array( &$this, 'admin_menu_options' ) ); |
| 29 | add_action( 'after_setup_theme', array( &$this, 'load_defaults' ) ); |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Load default settings. |
| 34 | * |
| 35 | * @return void |
| 36 | */ |
| 37 | public function load_defaults() { |
| 38 | |
| 39 | $this->scripts = apply_filters( 'rl_settings_scripts', array( |
| 40 | 'prettyphoto' => array( |
| 41 | 'name' => __( 'prettyPhoto', 'responsive-lightbox' ), |
| 42 | 'animation_speeds' => array( |
| 43 | 'slow' => __( 'slow', 'responsive-lightbox' ), |
| 44 | 'normal' => __( 'normal', 'responsive-lightbox' ), |
| 45 | 'fast' => __( 'fast', 'responsive-lightbox' ) |
| 46 | ), |
| 47 | 'themes' => array( |
| 48 | 'pp_default' => __( 'default', 'responsive-lightbox' ), |
| 49 | 'light_rounded' => __( 'light rounded', 'responsive-lightbox' ), |
| 50 | 'dark_rounded' => __( 'dark rounded', 'responsive-lightbox' ), |
| 51 | 'light_square' => __( 'light square', 'responsive-lightbox' ), |
| 52 | 'dark_square' => __( 'dark square', 'responsive-lightbox' ), |
| 53 | 'facebook' => __( 'facebook', 'responsive-lightbox' ) |
| 54 | ), |
| 55 | 'wmodes' => array( |
| 56 | 'window' => __( 'window', 'responsive-lightbox' ), |
| 57 | 'transparent' => __( 'transparent', 'responsive-lightbox' ), |
| 58 | 'opaque' => __( 'opaque', 'responsive-lightbox' ), |
| 59 | 'direct' => __( 'direct', 'responsive-lightbox' ), |
| 60 | 'gpu' => __( 'gpu', 'responsive-lightbox' ) |
| 61 | ) |
| 62 | ), |
| 63 | 'swipebox' => array( |
| 64 | 'name' => __( 'SwipeBox', 'responsive-lightbox' ), |
| 65 | 'animations' => array( |
| 66 | 'css' => __( 'CSS', 'responsive-lightbox' ), |
| 67 | 'jquery' => __( 'jQuery', 'responsive-lightbox' ) |
| 68 | ) |
| 69 | ), |
| 70 | 'fancybox' => array( |
| 71 | 'name' => __( 'FancyBox', 'responsive-lightbox' ), |
| 72 | 'transitions' => array( |
| 73 | 'elastic' => __( 'elastic', 'responsive-lightbox' ), |
| 74 | 'fade' => __( 'fade', 'responsive-lightbox' ), |
| 75 | 'none' => __( 'none', 'responsive-lightbox' ) |
| 76 | ), |
| 77 | 'scrollings' => array( |
| 78 | 'auto' => __( 'auto', 'responsive-lightbox' ), |
| 79 | 'yes' => __( 'yes', 'responsive-lightbox' ), |
| 80 | 'no' => __( 'no', 'responsive-lightbox' ) |
| 81 | ), |
| 82 | 'easings' => array( |
| 83 | 'swing' => __( 'swing', 'responsive-lightbox' ), |
| 84 | 'linear' => __( 'linear', 'responsive-lightbox' ) |
| 85 | ), |
| 86 | 'positions' => array( |
| 87 | 'outside' => __( 'outside', 'responsive-lightbox' ), |
| 88 | 'inside' => __( 'inside', 'responsive-lightbox' ), |
| 89 | 'over' => __( 'over', 'responsive-lightbox' ) |
| 90 | ) |
| 91 | ), |
| 92 | 'nivo' => array( |
| 93 | 'name' => __( 'Nivo Lightbox', 'responsive-lightbox' ), |
| 94 | 'effects' => array( |
| 95 | 'fade' => __( 'fade', 'responsive-lightbox' ), |
| 96 | 'fadeScale' => __( 'fade scale', 'responsive-lightbox' ), |
| 97 | 'slideLeft' => __( 'slide left', 'responsive-lightbox' ), |
| 98 | 'slideRight' => __( 'slide right', 'responsive-lightbox' ), |
| 99 | 'slideUp' => __( 'slide up', 'responsive-lightbox' ), |
| 100 | 'slideDown' => __( 'slide down', 'responsive-lightbox' ), |
| 101 | 'fall' => __( 'fall', 'responsive-lightbox' ) |
| 102 | ) |
| 103 | ), |
| 104 | 'imagelightbox' => array( |
| 105 | 'name' => __( 'Image Lightbox', 'responsive-lightbox' ) |
| 106 | ), |
| 107 | 'tosrus' => array( |
| 108 | 'name' => __( 'TosRUs', 'responsive-lightbox' ), |
| 109 | ), |
| 110 | ) ); |
| 111 | |
| 112 | $this->image_titles = array( |
| 113 | 'default' => __( 'None (default)', 'responsive-lightbox' ), |
| 114 | 'title' => __( 'Image Title', 'responsive-lightbox' ), |
| 115 | 'caption' => __( 'Image Caption', 'responsive-lightbox' ), |
| 116 | 'alt' => __( 'Image Alt Text', 'responsive-lightbox' ), |
| 117 | 'description' => __( 'Image Description', 'responsive-lightbox' ) |
| 118 | ); |
| 119 | |
| 120 | $this->loading_places = array( |
| 121 | 'header' => __( 'Header', 'responsive-lightbox' ), |
| 122 | 'footer' => __( 'Footer', 'responsive-lightbox' ) |
| 123 | ); |
| 124 | |
| 125 | // get scripts |
| 126 | foreach ( $this->scripts as $key => $value ) { |
| 127 | $scripts[$key] = $value['name']; |
| 128 | } |
| 129 | |
| 130 | // get image sizes |
| 131 | $sizes = apply_filters( 'image_size_names_choose', array( |
| 132 | 'thumbnail' => __( 'Thumbnail', 'responsive-lightbox' ), |
| 133 | 'medium' => __( 'Medium', 'responsive-lightbox' ), |
| 134 | 'large' => __( 'Large', 'responsive-lightbox' ), |
| 135 | 'full' => __( 'Full Size (default)', 'responsive-lightbox' ), |
| 136 | ) ); |
| 137 | |
| 138 | $this->settings = array( |
| 139 | 'settings' => array( |
| 140 | 'option_group' => 'responsive_lightbox_settings', |
| 141 | 'option_name' => 'responsive_lightbox_settings', |
| 142 | // 'callback' => array( &$this, 'validate_options' ), |
| 143 | 'sections' => array( |
| 144 | 'responsive_lightbox_settings' => array( |
| 145 | 'title' => __( 'General settings', 'responsive-lightbox' ), |
| 146 | // 'callback' => '', |
| 147 | // 'page' => '', |
| 148 | ), |
| 149 | ), |
| 150 | 'prefix' => 'rl', |
| 151 | 'fields' => array( |
| 152 | 'script' => array( |
| 153 | // 'name' => '', |
| 154 | 'title' => __( 'Lightbox script', 'responsive-lightbox' ), |
| 155 | // 'callback' => '', |
| 156 | // 'page' => '', |
| 157 | 'section' => 'responsive_lightbox_settings', |
| 158 | 'type' => 'radio', |
| 159 | 'label' => '', |
| 160 | 'description' => sprintf(__( 'Select your preffered ligthbox effect script or get our <a href="%s">premium extensions</a>.', 'responsive-lightbox' ), esc_url( add_query_arg( array( 'rl_action' => 'hide_notice' ), admin_url( 'options-general.php?page=responsive-lightbox&tab=addons' ) ) ) ), |
| 161 | 'options' => $scripts, |
| 162 | // 'options_cb' => '', |
| 163 | // 'id' => '', |
| 164 | // 'class' => array(), |
| 165 | ), |
| 166 | 'selector' => array( |
| 167 | 'title' => __( 'Selector', 'responsive-lightbox' ), |
| 168 | 'section' => 'responsive_lightbox_settings', |
| 169 | 'type' => 'text', |
| 170 | 'description' => __( 'Enter the rel selector lightbox effect will be applied to.', 'responsive-lightbox' ), |
| 171 | ), |
| 172 | 'image_links' => array( |
| 173 | 'title' => __( 'Image links', 'responsive-lightbox' ), |
| 174 | 'section' => 'responsive_lightbox_settings', |
| 175 | 'type' => 'boolean', |
| 176 | 'label' => __( 'Add lightbox to WordPress image links by default.', 'responsive-lightbox' ), |
| 177 | ), |
| 178 | 'image_title' => array( |
| 179 | 'title' => __( 'Single image title', 'responsive-lightbox' ), |
| 180 | 'section' => 'responsive_lightbox_settings', |
| 181 | 'type' => 'select', |
| 182 | 'description' => __( 'Select title for single images.', 'responsive-lightbox' ), |
| 183 | 'options' => $this->image_titles, |
| 184 | ), |
| 185 | 'images_as_gallery' => array( |
| 186 | 'title' => __( 'Single images as gallery', 'responsive-lightbox' ), |
| 187 | 'section' => 'responsive_lightbox_settings', |
| 188 | 'type' => 'boolean', |
| 189 | 'label' => __( 'Display single post images as a gallery.', 'responsive-lightbox' ), |
| 190 | ), |
| 191 | 'galleries' => array( |
| 192 | 'title' => __( 'Galleries', 'responsive-lightbox' ), |
| 193 | 'section' => 'responsive_lightbox_settings', |
| 194 | 'type' => 'boolean', |
| 195 | 'label' => __( 'Add lightbox to WordPress image galleries by default.', 'responsive-lightbox' ), |
| 196 | ), |
| 197 | 'gallery_image_size' => array( |
| 198 | 'title' => __( 'Gallery image size', 'responsive-lightbox' ), |
| 199 | 'section' => 'responsive_lightbox_settings', |
| 200 | 'type' => 'select', |
| 201 | 'description' => __( 'Select image size for gallery image links.', 'responsive-lightbox' ), |
| 202 | 'options' => $sizes, |
| 203 | ), |
| 204 | 'gallery_image_title' => array( |
| 205 | 'title' => __( 'Gallery image title', 'responsive-lightbox' ), |
| 206 | 'section' => 'responsive_lightbox_settings', |
| 207 | 'type' => 'select', |
| 208 | 'description' => __( 'Select title for images in native WordPress galleries.', 'responsive-lightbox' ), |
| 209 | 'options' => $this->image_titles, |
| 210 | ), |
| 211 | 'force_custom_gallery' => array( |
| 212 | 'title' => __( 'Force gallery lightbox', 'responsive-lightbox' ), |
| 213 | 'section' => 'responsive_lightbox_settings', |
| 214 | 'type' => 'boolean', |
| 215 | 'label' => __( 'Try to force lightbox for custom WP gallery replacements, like Jetpack tiled galleries.', 'responsive-lightbox' ), |
| 216 | ), |
| 217 | 'videos' => array( |
| 218 | 'title' => __( 'Video links', 'responsive-lightbox' ), |
| 219 | 'section' => 'responsive_lightbox_settings', |
| 220 | 'type' => 'boolean', |
| 221 | 'label' => __( 'Add lightbox to YouTube and Vimeo video links by default.', 'responsive-lightbox' ), |
| 222 | ), |
| 223 | 'enable_custom_events' => array( |
| 224 | 'title' => __( 'Custom events', 'responsive-lightbox' ), |
| 225 | 'section' => 'responsive_lightbox_settings', |
| 226 | 'type' => 'multiple', |
| 227 | 'fields' => array( |
| 228 | 'enable_custom_events' => array( |
| 229 | 'type' => 'boolean', |
| 230 | 'label' => __( 'Enable triggering lightbox on custom jQuery events.', 'responsive-lightbox' ), |
| 231 | ), |
| 232 | 'custom_events' => array( |
| 233 | 'type' => 'text', |
| 234 | 'description' => __( 'Enter a space separated list of events.', 'responsive-lightbox' ), |
| 235 | ) |
| 236 | ), |
| 237 | ), |
| 238 | 'loading_place' => array( |
| 239 | 'title' => __( 'Loading place', 'responsive-lightbox' ), |
| 240 | 'section' => 'responsive_lightbox_settings', |
| 241 | 'type' => 'radio', |
| 242 | 'description' => __( 'Select where all the lightbox scripts should be placed.', 'responsive-lightbox' ), |
| 243 | 'options' => $this->loading_places, |
| 244 | ), |
| 245 | 'conditional_loading' => array( |
| 246 | 'title' => __( 'Conditional loading', 'responsive-lightbox' ), |
| 247 | 'section' => 'responsive_lightbox_settings', |
| 248 | 'type' => 'boolean', |
| 249 | 'label' => __( 'Enable to load scripts and styles only on pages that have images or galleries in post content.', 'responsive-lightbox' ), |
| 250 | ), |
| 251 | 'deactivation_delete' => array( |
| 252 | 'title' => __( 'Delete data', 'responsive-lightbox' ), |
| 253 | 'section' => 'responsive_lightbox_settings', |
| 254 | 'type' => 'boolean', |
| 255 | 'label' => __( 'Delete all plugin settings on deactivation.', 'responsive-lightbox' ), |
| 256 | ), |
| 257 | ), |
| 258 | ), |
| 259 | 'configuration' => array( |
| 260 | 'option_group' => 'responsive_lightbox_configuration', |
| 261 | 'option_name' => 'responsive_lightbox_configuration', |
| 262 | // 'callback' => array( &$this, 'validate_options' ), |
| 263 | 'sections' => array( |
| 264 | 'responsive_lightbox_configuration' => array( |
| 265 | 'title' => __( 'Lightbox settings', 'responsive-lightbox' ) . ': ' . $this->scripts[Responsive_Lightbox()->options['settings']['script']]['name'], |
| 266 | // 'callback' => '', |
| 267 | // 'page' => '', |
| 268 | ), |
| 269 | ), |
| 270 | 'prefix' => 'rl', |
| 271 | 'fields' => array( |
| 272 | ) |
| 273 | ) |
| 274 | ); |
| 275 | |
| 276 | switch ( Responsive_Lightbox()->options['settings']['script'] ) { |
| 277 | |
| 278 | case ( 'swipebox' ) : |
| 279 | |
| 280 | $this->settings['configuration']['prefix'] = 'rl_sb'; |
| 281 | $this->settings['configuration']['fields'] = array( |
| 282 | 'animation' => array( |
| 283 | 'title' => __( 'Animation type', 'responsive-lightbox' ), |
| 284 | 'section' => 'responsive_lightbox_configuration', |
| 285 | 'type' => 'radio', |
| 286 | 'label' => '', |
| 287 | 'description' => __( 'Select a method of applying a lightbox effect.', 'responsive-lightbox' ), |
| 288 | 'options' => $this->scripts['swipebox']['animations'], |
| 289 | 'parent' => 'swipebox' |
| 290 | ), |
| 291 | 'force_png_icons' => array( |
| 292 | 'title' => __( 'Force PNG icons', 'responsive-lightbox' ), |
| 293 | 'section' => 'responsive_lightbox_configuration', |
| 294 | 'type' => 'boolean', |
| 295 | 'label' => __( 'Enable this if you\'re having problems with navigation icons not visible on some devices.', 'responsive-lightbox' ), |
| 296 | 'parent' => 'swipebox' |
| 297 | ), |
| 298 | 'hide_close_mobile' => array( |
| 299 | 'title' => __( 'Hide close on mobile', 'responsive-lightbox' ), |
| 300 | 'section' => 'responsive_lightbox_configuration', |
| 301 | 'type' => 'boolean', |
| 302 | 'label' => __( 'Hide the close button on mobile devices.', 'responsive-lightbox' ), |
| 303 | 'parent' => 'swipebox' |
| 304 | ), |
| 305 | 'remove_bars_mobile' => array( |
| 306 | 'title' => __( 'Remove bars on mobile', 'responsive-lightbox' ), |
| 307 | 'section' => 'responsive_lightbox_configuration', |
| 308 | 'type' => 'boolean', |
| 309 | 'label' => __( 'Hide the top and bottom bars on mobile devices.', 'responsive-lightbox' ), |
| 310 | 'parent' => 'swipebox' |
| 311 | ), |
| 312 | 'hide_bars' => array( |
| 313 | 'title' => __( 'Top and bottom bars', 'responsive-lightbox' ), |
| 314 | 'section' => 'responsive_lightbox_configuration', |
| 315 | 'type' => 'multiple', |
| 316 | 'fields' => array( |
| 317 | 'hide_bars' => array( |
| 318 | 'type' => 'boolean', |
| 319 | 'label' => __( 'Hide top and bottom bars after a period of time.', 'responsive-lightbox' ), |
| 320 | 'parent' => 'swipebox' |
| 321 | ), |
| 322 | 'hide_bars_delay' => array( |
| 323 | 'type' => 'number', |
| 324 | 'description' => __( 'Enter the time after which the top and bottom bars will be hidden (when hiding is enabled).', 'responsive-lightbox' ), |
| 325 | 'append' => 'ms', |
| 326 | 'parent' => 'swipebox' |
| 327 | ) |
| 328 | ) |
| 329 | ), |
| 330 | 'video_max_width' => array( |
| 331 | 'title' => __( 'Video max width', 'responsive-lightbox' ), |
| 332 | 'section' => 'responsive_lightbox_configuration', |
| 333 | 'type' => 'number', |
| 334 | 'description' => __( 'Enter the max video width in a lightbox.', 'responsive-lightbox' ), |
| 335 | 'append' => 'px', |
| 336 | 'parent' => 'swipebox' |
| 337 | ), |
| 338 | 'loop_at_end' => array( |
| 339 | 'title' => __( 'Loop at end', 'responsive-lightbox' ), |
| 340 | 'section' => 'responsive_lightbox_configuration', |
| 341 | 'type' => 'boolean', |
| 342 | 'label' => __( 'True will return to the first image after the last image is reached.', 'responsive-lightbox' ), |
| 343 | 'parent' => 'swipebox' |
| 344 | ), |
| 345 | ); |
| 346 | |
| 347 | break; |
| 348 | |
| 349 | case ( 'prettyphoto' ) : |
| 350 | |
| 351 | $this->settings['configuration']['prefix'] = 'rl_pp'; |
| 352 | $this->settings['configuration']['fields'] = array( |
| 353 | 'animation_speed' => array( |
| 354 | 'title' => __( 'Animation speed', 'responsive-lightbox' ), |
| 355 | 'section' => 'responsive_lightbox_configuration', |
| 356 | 'type' => 'radio', |
| 357 | 'label' => '', |
| 358 | 'description' => __( 'Select animation speed for lightbox effect.', 'responsive-lightbox' ), |
| 359 | 'options' => $this->scripts['prettyphoto']['animation_speeds'], |
| 360 | 'parent' => 'prettyphoto' |
| 361 | ), |
| 362 | 'slideshow' => array( |
| 363 | 'title' => __( 'Slideshow', 'responsive-lightbox' ), |
| 364 | 'section' => 'responsive_lightbox_configuration', |
| 365 | 'type' => 'multiple', |
| 366 | 'fields' => array( |
| 367 | 'slideshow' => array( |
| 368 | 'type' => 'boolean', |
| 369 | 'label' => __( 'Display images as slideshow', 'responsive-lightbox' ), |
| 370 | 'parent' => 'prettyphoto' |
| 371 | ), |
| 372 | 'slideshow_delay' => array( |
| 373 | 'type' => 'number', |
| 374 | 'description' => __( 'Enter time (in miliseconds).', 'responsive-lightbox' ), |
| 375 | 'append' => 'ms', |
| 376 | 'parent' => 'prettyphoto' |
| 377 | ) |
| 378 | ) |
| 379 | ), |
| 380 | 'slideshow_autoplay' => array( |
| 381 | 'title' => __( 'Slideshow autoplay', 'responsive-lightbox' ), |
| 382 | 'section' => 'responsive_lightbox_configuration', |
| 383 | 'type' => 'boolean', |
| 384 | 'label' => __( 'Automatically start slideshow.', 'responsive-lightbox' ), |
| 385 | 'parent' => 'prettyphoto' |
| 386 | ), |
| 387 | 'opacity' => array( |
| 388 | 'title' => __( 'Opacity', 'responsive-lightbox' ), |
| 389 | 'section' => 'responsive_lightbox_configuration', |
| 390 | 'type' => 'range', |
| 391 | 'description' => __( 'Value between 0 and 100, 100 for no opacity.', 'responsive-lightbox' ), |
| 392 | 'min' => 0, |
| 393 | 'max' => 100, |
| 394 | 'parent' => 'prettyphoto' |
| 395 | ), |
| 396 | 'show_title' => array( |
| 397 | 'title' => __( 'Show title', 'responsive-lightbox' ), |
| 398 | 'section' => 'responsive_lightbox_configuration', |
| 399 | 'type' => 'boolean', |
| 400 | 'label' => __( 'Display image title.', 'responsive-lightbox' ), |
| 401 | 'parent' => 'prettyphoto' |
| 402 | ), |
| 403 | 'allow_resize' => array( |
| 404 | 'title' => __( 'Allow resize big images', 'responsive-lightbox' ), |
| 405 | 'section' => 'responsive_lightbox_configuration', |
| 406 | 'type' => 'boolean', |
| 407 | 'label' => __( 'Resize the photos bigger than viewport.', 'responsive-lightbox' ), |
| 408 | 'parent' => 'prettyphoto' |
| 409 | ), |
| 410 | 'allow_expand' => array( |
| 411 | 'title' => __( 'Allow expand', 'responsive-lightbox' ), |
| 412 | 'section' => 'responsive_lightbox_configuration', |
| 413 | 'type' => 'boolean', |
| 414 | 'label' => __( 'Allow expanding images.', 'responsive-lightbox' ), |
| 415 | 'parent' => 'prettyphoto' |
| 416 | ), |
| 417 | 'width' => array( |
| 418 | 'title' => __( 'Video width', 'responsive-lightbox' ), |
| 419 | 'section' => 'responsive_lightbox_configuration', |
| 420 | 'type' => 'number', |
| 421 | 'append' => 'px', |
| 422 | 'parent' => 'prettyphoto' |
| 423 | ), |
| 424 | 'height' => array( |
| 425 | 'title' => __( 'Video height', 'responsive-lightbox' ), |
| 426 | 'section' => 'responsive_lightbox_configuration', |
| 427 | 'type' => 'number', |
| 428 | 'append' => 'px', |
| 429 | 'parent' => 'prettyphoto' |
| 430 | ), |
| 431 | 'theme' => array( |
| 432 | 'title' => __( 'Theme', 'responsive-lightbox' ), |
| 433 | 'section' => 'responsive_lightbox_configuration', |
| 434 | 'type' => 'radio', |
| 435 | 'description' => __( 'Select the theme for lightbox effect.', 'responsive-lightbox' ), |
| 436 | 'options' => $this->scripts['prettyphoto']['themes'], |
| 437 | 'parent' => 'prettyphoto' |
| 438 | ), |
| 439 | 'horizontal_padding' => array( |
| 440 | 'title' => __( 'Horizontal padding', 'responsive-lightbox' ), |
| 441 | 'section' => 'responsive_lightbox_configuration', |
| 442 | 'type' => 'number', |
| 443 | 'append' => 'px', |
| 444 | 'parent' => 'prettyphoto' |
| 445 | ), |
| 446 | 'hide_flash' => array( |
| 447 | 'title' => __( 'Hide Flash', 'responsive-lightbox' ), |
| 448 | 'section' => 'responsive_lightbox_configuration', |
| 449 | 'type' => 'boolean', |
| 450 | 'label' => __( 'Hide all the flash objects on a page. Enable this if flash appears over prettyPhoto.', 'responsive-lightbox' ), |
| 451 | 'parent' => 'prettyphoto' |
| 452 | ), |
| 453 | 'wmode' => array( |
| 454 | 'title' => __( 'Flash Window Mode (wmode)', 'responsive-lightbox' ), |
| 455 | 'section' => 'responsive_lightbox_configuration', |
| 456 | 'type' => 'radio', |
| 457 | 'description' => __( 'Select flash window mode.', 'responsive-lightbox' ), |
| 458 | 'options' => $this->scripts['prettyphoto']['wmodes'], |
| 459 | 'parent' => 'prettyphoto' |
| 460 | ), |
| 461 | 'video_autoplay' => array( |
| 462 | 'title' => __( 'Video autoplay', 'responsive-lightbox' ), |
| 463 | 'section' => 'responsive_lightbox_configuration', |
| 464 | 'type' => 'boolean', |
| 465 | 'label' => __( 'Automatically start videos.', 'responsive-lightbox' ), |
| 466 | 'parent' => 'prettyphoto' |
| 467 | ), |
| 468 | 'modal' => array( |
| 469 | 'title' => __( 'Modal', 'responsive-lightbox' ), |
| 470 | 'section' => 'responsive_lightbox_configuration', |
| 471 | 'type' => 'boolean', |
| 472 | 'label' => __( 'If set to true, only the close button will close the window.', 'responsive-lightbox' ), |
| 473 | 'parent' => 'prettyphoto' |
| 474 | ), |
| 475 | 'deeplinking' => array( |
| 476 | 'title' => __( 'Deeplinking', 'responsive-lightbox' ), |
| 477 | 'section' => 'responsive_lightbox_configuration', |
| 478 | 'type' => 'boolean', |
| 479 | 'label' => __( 'Allow prettyPhoto to update the url to enable deeplinking.', 'responsive-lightbox' ), |
| 480 | 'parent' => 'prettyphoto' |
| 481 | ), |
| 482 | 'overlay_gallery' => array( |
| 483 | 'title' => __( 'Overlay gallery', 'responsive-lightbox' ), |
| 484 | 'section' => 'responsive_lightbox_configuration', |
| 485 | 'type' => 'boolean', |
| 486 | 'label' => __( 'If enabled, a gallery will overlay the fullscreen image on mouse over.', 'responsive-lightbox' ), |
| 487 | 'parent' => 'prettyphoto' |
| 488 | ), |
| 489 | 'keyboard_shortcuts' => array( |
| 490 | 'title' => __( 'Keyboard shortcuts', 'responsive-lightbox' ), |
| 491 | 'section' => 'responsive_lightbox_configuration', |
| 492 | 'type' => 'boolean', |
| 493 | 'label' => __( 'Set to false if you open forms inside prettyPhoto.', 'responsive-lightbox' ), |
| 494 | 'parent' => 'prettyphoto' |
| 495 | ), |
| 496 | 'social' => array( |
| 497 | 'title' => __( 'Social (Twitter, Facebook)', 'responsive-lightbox' ), |
| 498 | 'section' => 'responsive_lightbox_configuration', |
| 499 | 'type' => 'boolean', |
| 500 | 'label' => __( 'Display links to Facebook and Twitter.', 'responsive-lightbox' ), |
| 501 | 'parent' => 'prettyphoto' |
| 502 | ), |
| 503 | ); |
| 504 | |
| 505 | break; |
| 506 | |
| 507 | case ( 'fancybox' ) : |
| 508 | |
| 509 | $this->settings['configuration']['prefix'] = 'rl_fb'; |
| 510 | $this->settings['configuration']['fields'] = array( |
| 511 | 'modal' => array( |
| 512 | 'title' => __( 'Modal', 'responsive-lightbox' ), |
| 513 | 'section' => 'responsive_lightbox_configuration', |
| 514 | 'type' => 'boolean', |
| 515 | 'label' => __( 'When true, "overlayShow" is set to true and "hideOnOverlayClick", "hideOnContentClick", "enableEscapeButton", "showCloseButton" are set to false.', 'responsive-lightbox' ), |
| 516 | 'parent' => 'fancybox' |
| 517 | ), |
| 518 | 'show_overlay' => array( |
| 519 | 'title' => __( 'Show overlay', 'responsive-lightbox' ), |
| 520 | 'section' => 'responsive_lightbox_configuration', |
| 521 | 'type' => 'boolean', |
| 522 | 'label' => __( 'Toggle overlay.', 'responsive-lightbox' ), |
| 523 | 'parent' => 'fancybox' |
| 524 | ), |
| 525 | 'show_close_button' => array( |
| 526 | 'title' => __( 'Show close button', 'responsive-lightbox' ), |
| 527 | 'section' => 'responsive_lightbox_configuration', |
| 528 | 'type' => 'boolean', |
| 529 | 'label' => __( 'Toggle close button.', 'responsive-lightbox' ), |
| 530 | 'parent' => 'fancybox' |
| 531 | ), |
| 532 | 'enable_escape_button' => array( |
| 533 | 'title' => __( 'Enable escape button', 'responsive-lightbox' ), |
| 534 | 'section' => 'responsive_lightbox_configuration', |
| 535 | 'type' => 'boolean', |
| 536 | 'label' => __( 'Toggle if pressing Esc button closes FancyBox.', 'responsive-lightbox' ), |
| 537 | 'parent' => 'fancybox' |
| 538 | ), |
| 539 | 'hide_on_overlay_click' => array( |
| 540 | 'title' => __( 'Hide on overlay click', 'responsive-lightbox' ), |
| 541 | 'section' => 'responsive_lightbox_configuration', |
| 542 | 'type' => 'boolean', |
| 543 | 'label' => __( 'Toggle if clicking the overlay should close FancyBox.', 'responsive-lightbox' ), |
| 544 | 'parent' => 'fancybox' |
| 545 | ), |
| 546 | 'hide_on_content_click' => array( |
| 547 | 'title' => __( 'Hide on content click', 'responsive-lightbox' ), |
| 548 | 'section' => 'responsive_lightbox_configuration', |
| 549 | 'type' => 'boolean', |
| 550 | 'label' => __( 'Toggle if clicking the content should close FancyBox.', 'responsive-lightbox' ), |
| 551 | 'parent' => 'fancybox' |
| 552 | ), |
| 553 | 'cyclic' => array( |
| 554 | 'title' => __( 'Cyclic', 'responsive-lightbox' ), |
| 555 | 'section' => 'responsive_lightbox_configuration', |
| 556 | 'type' => 'boolean', |
| 557 | 'label' => __( 'When true, galleries will be cyclic, allowing you to keep pressing next/back.', 'responsive-lightbox' ), |
| 558 | 'parent' => 'fancybox' |
| 559 | ), |
| 560 | 'show_nav_arrows' => array( |
| 561 | 'title' => __( 'Show nav arrows', 'responsive-lightbox' ), |
| 562 | 'section' => 'responsive_lightbox_configuration', |
| 563 | 'type' => 'boolean', |
| 564 | 'label' => __( 'Toggle navigation arrows.', 'responsive-lightbox' ), |
| 565 | 'parent' => 'fancybox' |
| 566 | ), |
| 567 | 'auto_scale' => array( |
| 568 | 'title' => __( 'Auto scale', 'responsive-lightbox' ), |
| 569 | 'section' => 'responsive_lightbox_configuration', |
| 570 | 'type' => 'boolean', |
| 571 | 'label' => __( 'If true, FancyBox is scaled to fit in viewport.', 'responsive-lightbox' ), |
| 572 | 'parent' => 'fancybox' |
| 573 | ), |
| 574 | 'scrolling' => array( |
| 575 | 'title' => __( 'Scrolling (in/out)', 'responsive-lightbox' ), |
| 576 | 'section' => 'responsive_lightbox_configuration', |
| 577 | 'type' => 'radio', |
| 578 | 'description' => __( 'Set the overflow CSS property to create or hide scrollbars.', 'responsive-lightbox' ), |
| 579 | 'options' => $this->scripts['fancybox']['scrollings'], |
| 580 | 'parent' => 'fancybox' |
| 581 | ), |
| 582 | 'center_on_scroll' => array( |
| 583 | 'title' => __( 'Center on scroll', 'responsive-lightbox' ), |
| 584 | 'section' => 'responsive_lightbox_configuration', |
| 585 | 'type' => 'boolean', |
| 586 | 'label' => __( 'When true, FancyBox is centered while scrolling page.', 'responsive-lightbox' ), |
| 587 | 'parent' => 'fancybox' |
| 588 | ), |
| 589 | 'opacity' => array( |
| 590 | 'title' => __( 'Opacity', 'responsive-lightbox' ), |
| 591 | 'section' => 'responsive_lightbox_configuration', |
| 592 | 'type' => 'boolean', |
| 593 | 'label' => __( 'When true, transparency of content is changed for elastic transitions.', 'responsive-lightbox' ), |
| 594 | 'parent' => 'fancybox' |
| 595 | ), |
| 596 | 'overlay_opacity' => array( |
| 597 | 'title' => __( 'Overlay opacity', 'responsive-lightbox' ), |
| 598 | 'section' => 'responsive_lightbox_configuration', |
| 599 | 'type' => 'range', |
| 600 | 'description' => __( 'Opacity of the overlay.', 'responsive-lightbox' ), |
| 601 | 'min' => 0, |
| 602 | 'max' => 100, |
| 603 | 'parent' => 'fancybox' |
| 604 | ), |
| 605 | 'overlay_color' => array( |
| 606 | 'title' => __( 'Overlay color', 'responsive-lightbox' ), |
| 607 | 'section' => 'responsive_lightbox_configuration', |
| 608 | 'type' => 'color_picker', |
| 609 | 'label' => __( 'Color of the overlay.', 'responsive-lightbox' ), |
| 610 | 'parent' => 'fancybox' |
| 611 | ), |
| 612 | 'title_show' => array( |
| 613 | 'title' => __( 'Title show', 'responsive-lightbox' ), |
| 614 | 'section' => 'responsive_lightbox_configuration', |
| 615 | 'type' => 'boolean', |
| 616 | 'label' => __( 'Toggle title.', 'responsive-lightbox' ), |
| 617 | 'parent' => 'fancybox' |
| 618 | ), |
| 619 | 'title_position' => array( |
| 620 | 'title' => __( 'Title position', 'responsive-lightbox' ), |
| 621 | 'section' => 'responsive_lightbox_configuration', |
| 622 | 'type' => 'radio', |
| 623 | 'description' => __( 'The position of title.', 'responsive-lightbox' ), |
| 624 | 'options' => $this->scripts['fancybox']['positions'], |
| 625 | 'parent' => 'fancybox' |
| 626 | ), |
| 627 | 'transitions' => array( |
| 628 | 'title' => __( 'Transition (in/out)', 'responsive-lightbox' ), |
| 629 | 'section' => 'responsive_lightbox_configuration', |
| 630 | 'type' => 'radio', |
| 631 | 'description' => __( 'The transition type.', 'responsive-lightbox' ), |
| 632 | 'options' => $this->scripts['fancybox']['transitions'], |
| 633 | 'parent' => 'fancybox' |
| 634 | ), |
| 635 | 'easings' => array( |
| 636 | 'title' => __( 'Easings (in/out)', 'responsive-lightbox' ), |
| 637 | 'section' => 'responsive_lightbox_configuration', |
| 638 | 'type' => 'radio', |
| 639 | 'description' => __( 'Easing used for elastic animations.', 'responsive-lightbox' ), |
| 640 | 'options' => $this->scripts['fancybox']['easings'], |
| 641 | 'parent' => 'fancybox' |
| 642 | ), |
| 643 | 'speeds' => array( |
| 644 | 'title' => __( 'Speed (in/out)', 'responsive-lightbox' ), |
| 645 | 'section' => 'responsive_lightbox_configuration', |
| 646 | 'type' => 'number', |
| 647 | 'description' => __( 'Speed of the fade and elastic transitions, in milliseconds.', 'responsive-lightbox' ), |
| 648 | 'append' => 'ms', |
| 649 | 'parent' => 'fancybox' |
| 650 | ), |
| 651 | 'change_speed' => array( |
| 652 | 'title' => __( 'Change speed', 'responsive-lightbox' ), |
| 653 | 'section' => 'responsive_lightbox_configuration', |
| 654 | 'type' => 'number', |
| 655 | 'description' => __( 'Speed of resizing when changing gallery items, in milliseconds.', 'responsive-lightbox' ), |
| 656 | 'append' => 'ms', |
| 657 | 'parent' => 'fancybox' |
| 658 | ), |
| 659 | 'change_fade' => array( |
| 660 | 'title' => __( 'Change fade', 'responsive-lightbox' ), |
| 661 | 'section' => 'responsive_lightbox_configuration', |
| 662 | 'type' => 'number', |
| 663 | 'description' => __( 'Speed of the content fading while changing gallery items.', 'responsive-lightbox' ), |
| 664 | 'append' => 'ms', |
| 665 | 'parent' => 'fancybox' |
| 666 | ), |
| 667 | 'padding' => array( |
| 668 | 'title' => __( 'Padding', 'responsive-lightbox' ), |
| 669 | 'section' => 'responsive_lightbox_configuration', |
| 670 | 'type' => 'number', |
| 671 | 'description' => __( 'Space between FancyBox wrapper and content.', 'responsive-lightbox' ), |
| 672 | 'append' => 'px', |
| 673 | 'parent' => 'fancybox' |
| 674 | ), |
| 675 | 'margin' => array( |
| 676 | 'title' => __( 'Margin', 'responsive-lightbox' ), |
| 677 | 'section' => 'responsive_lightbox_configuration', |
| 678 | 'type' => 'number', |
| 679 | 'description' => __( 'Space between viewport and FancyBox wrapper.', 'responsive-lightbox' ), |
| 680 | 'append' => 'px', |
| 681 | 'parent' => 'fancybox' |
| 682 | ), |
| 683 | 'video_width' => array( |
| 684 | 'title' => __( 'Video width', 'responsive-lightbox' ), |
| 685 | 'section' => 'responsive_lightbox_configuration', |
| 686 | 'type' => 'number', |
| 687 | 'description' => __( 'Width of the video.', 'responsive-lightbox' ), |
| 688 | 'append' => 'px', |
| 689 | 'parent' => 'fancybox' |
| 690 | ), |
| 691 | 'video_height' => array( |
| 692 | 'title' => __( 'Video height', 'responsive-lightbox' ), |
| 693 | 'section' => 'responsive_lightbox_configuration', |
| 694 | 'type' => 'number', |
| 695 | 'description' => __( 'Height of the video.', 'responsive-lightbox' ), |
| 696 | 'append' => 'px', |
| 697 | 'parent' => 'fancybox' |
| 698 | ), |
| 699 | ); |
| 700 | |
| 701 | break; |
| 702 | |
| 703 | case ( 'nivo' ) : |
| 704 | |
| 705 | $this->settings['configuration']['prefix'] = 'rl_nv'; |
| 706 | $this->settings['configuration']['fields'] = array( |
| 707 | 'effect' => array( |
| 708 | 'title' => __( 'Effect', 'responsive-lightbox' ), |
| 709 | 'section' => 'responsive_lightbox_configuration', |
| 710 | 'type' => 'radio', |
| 711 | 'description' => __( 'The effect to use when showing the lightbox.', 'responsive-lightbox' ), |
| 712 | 'options' => $this->scripts['nivo']['effects'], |
| 713 | 'parent' => 'nivo' |
| 714 | ), |
| 715 | 'keyboard_nav' => array( |
| 716 | 'title' => __( 'Keyboard navigation', 'responsive-lightbox' ), |
| 717 | 'section' => 'responsive_lightbox_configuration', |
| 718 | 'type' => 'boolean', |
| 719 | 'label' => __( 'Enable keyboard navigation (left/right/escape).', 'responsive-lightbox' ), |
| 720 | 'parent' => 'nivo' |
| 721 | ), |
| 722 | 'click_overlay_to_close' => array( |
| 723 | 'title' => __( 'Click overlay to close', 'responsive-lightbox' ), |
| 724 | 'section' => 'responsive_lightbox_configuration', |
| 725 | 'type' => 'boolean', |
| 726 | 'label' => __( 'Enable to close lightbox on overlay click.', 'responsive-lightbox' ), |
| 727 | 'parent' => 'nivo' |
| 728 | ), |
| 729 | 'error_message' => array( |
| 730 | 'title' => __( 'Error message', 'responsive-lightbox' ), |
| 731 | 'section' => 'responsive_lightbox_configuration', |
| 732 | 'type' => 'text', |
| 733 | 'class' => 'large-text', |
| 734 | 'label' => __( 'Error message if the content cannot be loaded.', 'responsive-lightbox' ), |
| 735 | 'parent' => 'nivo' |
| 736 | ), |
| 737 | ); |
| 738 | |
| 739 | break; |
| 740 | |
| 741 | case ( 'imagelightbox' ) : |
| 742 | |
| 743 | $this->settings['configuration']['prefix'] = 'rl_il'; |
| 744 | $this->settings['configuration']['fields'] = array( |
| 745 | 'animation_speed' => array( |
| 746 | 'title' => __( 'Animation speed', 'responsive-lightbox' ), |
| 747 | 'section' => 'responsive_lightbox_configuration', |
| 748 | 'type' => 'number', |
| 749 | 'description' => __( 'Animation speed.', 'responsive-lightbox' ), |
| 750 | 'append' => 'ms', |
| 751 | 'parent' => 'imagelightbox' |
| 752 | ), |
| 753 | 'preload_next' => array( |
| 754 | 'title' => __( 'Preload next image', 'responsive-lightbox' ), |
| 755 | 'section' => 'responsive_lightbox_configuration', |
| 756 | 'type' => 'boolean', |
| 757 | 'label' => __( 'Silently preload the next image.', 'responsive-lightbox' ), |
| 758 | 'parent' => 'imagelightbox' |
| 759 | ), |
| 760 | 'enable_keyboard' => array( |
| 761 | 'title' => __( 'Enable keyboard keys', 'responsive-lightbox' ), |
| 762 | 'section' => 'responsive_lightbox_configuration', |
| 763 | 'type' => 'boolean', |
| 764 | 'label' => __( 'Enable keyboard shortcuts (arrows Left/Right and Esc).', 'responsive-lightbox' ), |
| 765 | 'parent' => 'imagelightbox' |
| 766 | ), |
| 767 | 'quit_on_end' => array( |
| 768 | 'title' => __( 'Quit after last image', 'responsive-lightbox' ), |
| 769 | 'section' => 'responsive_lightbox_configuration', |
| 770 | 'type' => 'boolean', |
| 771 | 'label' => __( 'Quit after viewing the last image.', 'responsive-lightbox' ), |
| 772 | 'parent' => 'imagelightbox' |
| 773 | ), |
| 774 | 'quit_on_image_click' => array( |
| 775 | 'title' => __( 'Quit on image click', 'responsive-lightbox' ), |
| 776 | 'section' => 'responsive_lightbox_configuration', |
| 777 | 'type' => 'boolean', |
| 778 | 'label' => __( 'Quit when the viewed image is clicked.', 'responsive-lightbox' ), |
| 779 | 'parent' => 'imagelightbox' |
| 780 | ), |
| 781 | 'quit_on_document_click' => array( |
| 782 | 'title' => __( 'Quit on anything click', 'responsive-lightbox' ), |
| 783 | 'section' => 'responsive_lightbox_configuration', |
| 784 | 'type' => 'boolean', |
| 785 | 'label' => __( 'Quit when anything but the viewed image is clicked.', 'responsive-lightbox' ), |
| 786 | 'parent' => 'imagelightbox' |
| 787 | ), |
| 788 | ); |
| 789 | |
| 790 | break; |
| 791 | |
| 792 | case ( 'tosrus' ) : |
| 793 | |
| 794 | $this->settings['configuration']['prefix'] = 'rl_tr'; |
| 795 | $this->settings['configuration']['fields'] = array( |
| 796 | 'effect' => array( |
| 797 | 'title' => __( 'Transition effect', 'responsive-lightbox' ), |
| 798 | 'section' => 'responsive_lightbox_configuration', |
| 799 | 'type' => 'radio', |
| 800 | 'description' => __( 'What effect to use for the transition.', 'responsive-lightbox' ), |
| 801 | 'options' => array( |
| 802 | 'slide' => __( 'slide', 'responsive-lightbox' ), |
| 803 | 'fade' => __( 'fade', 'responsive-lightbox' ) |
| 804 | ), |
| 805 | 'parent' => 'tosrus' |
| 806 | ), |
| 807 | 'infinite' => array( |
| 808 | 'title' => __( 'Infinite loop', 'responsive-lightbox' ), |
| 809 | 'section' => 'responsive_lightbox_configuration', |
| 810 | 'type' => 'boolean', |
| 811 | 'label' => __( 'Whether or not to slide back to the first slide when the last has been reached.', 'responsive-lightbox' ), |
| 812 | 'parent' => 'tosrus' |
| 813 | ), |
| 814 | 'keys' => array( |
| 815 | 'title' => __( 'Keyboard navigation', 'responsive-lightbox' ), |
| 816 | 'section' => 'responsive_lightbox_configuration', |
| 817 | 'type' => 'boolean', |
| 818 | 'label' => __( 'Enable keyboard navigation (left/right/escape).', 'responsive-lightbox' ), |
| 819 | 'parent' => 'tosrus' |
| 820 | ), |
| 821 | 'autoplay' => array( |
| 822 | 'title' => __( 'Autoplay', 'responsive-lightbox' ), |
| 823 | 'section' => 'responsive_lightbox_configuration', |
| 824 | 'type' => 'multiple', |
| 825 | 'fields' => array( |
| 826 | 'autoplay' => array( |
| 827 | 'type' => 'boolean', |
| 828 | 'label' => __( 'Automatically start slideshow.', 'responsive-lightbox' ), |
| 829 | 'parent' => 'tosrus' |
| 830 | ), |
| 831 | 'timeout' => array( |
| 832 | 'type' => 'number', |
| 833 | 'description' => __( 'The timeout between sliding to the next slide in milliseconds.', 'responsive-lightbox' ), |
| 834 | 'append' => 'ms', |
| 835 | 'parent' => 'tosrus' |
| 836 | ) |
| 837 | ) |
| 838 | ), |
| 839 | 'pause_on_hover' => array( |
| 840 | 'title' => __( 'Pause on hover', 'responsive-lightbox' ), |
| 841 | 'section' => 'responsive_lightbox_configuration', |
| 842 | 'type' => 'boolean', |
| 843 | 'label' => __( 'Whether or not to pause on hover.', 'responsive-lightbox' ), |
| 844 | 'parent' => 'tosrus' |
| 845 | ), |
| 846 | 'pagination' => array( |
| 847 | 'title' => __( 'Pagination', 'responsive-lightbox' ), |
| 848 | 'section' => 'responsive_lightbox_configuration', |
| 849 | 'type' => 'multiple', |
| 850 | 'fields' => array( |
| 851 | 'pagination' => array( |
| 852 | 'type' => 'boolean', |
| 853 | 'label' => __( 'Whether or not to add a pagination.', 'responsive-lightbox' ), |
| 854 | 'parent' => 'tosrus' |
| 855 | ), |
| 856 | 'pagination_type' => array( |
| 857 | 'type' => 'radio', |
| 858 | 'description' => __( 'What type of pagination to use.', 'responsive-lightbox' ), |
| 859 | 'options' => array( |
| 860 | 'bullets' => __( 'Bullets', 'responsive-lightbox' ), |
| 861 | 'thumbnails' => __( 'Thumbnails', 'responsive-lightbox' ) |
| 862 | ), |
| 863 | 'parent' => 'tosrus' |
| 864 | ) |
| 865 | ) |
| 866 | ) |
| 867 | ); |
| 868 | |
| 869 | break; |
| 870 | |
| 871 | default : |
| 872 | |
| 873 | $this->settings['configuration'] = apply_filters( 'rl_settings_' . Responsive_Lightbox()->options['settings']['script'] . '_script_configuration', $this->settings['configuration'] ); |
| 874 | |
| 875 | break; |
| 876 | } |
| 877 | |
| 878 | $this->tabs = apply_filters( 'rl_settings_tabs', array( |
| 879 | 'settings' => array( |
| 880 | 'name' => __( 'General settings', 'responsive-lightbox' ), |
| 881 | 'key' => 'responsive_lightbox_settings', |
| 882 | 'submit' => 'save_rl_settings', |
| 883 | 'reset' => 'reset_rl_settings', |
| 884 | ), |
| 885 | 'configuration' => array( |
| 886 | 'name' => __( 'Lightbox settings', 'responsive-lightbox' ), |
| 887 | 'key' => 'responsive_lightbox_configuration', |
| 888 | 'submit' => 'save_' . $this->settings['configuration']['prefix'] . '_configuration', |
| 889 | 'reset' => 'reset_' . $this->settings['configuration']['prefix'] . '_configuration' |
| 890 | ) |
| 891 | ) ); |
| 892 | |
| 893 | $this->tabs['addons'] = array( |
| 894 | 'name' => __( 'Add-ons', 'responsive-lightbox' ), |
| 895 | 'key' => 'responsive_lightbox_configuration', |
| 896 | 'callback' => array( &$this, 'addons_tab_cb' ) |
| 897 | ); |
| 898 | |
| 899 | } |
| 900 | |
| 901 | /** |
| 902 | * Register options page |
| 903 | * |
| 904 | * @return void |
| 905 | */ |
| 906 | public function admin_menu_options() { |
| 907 | add_options_page( |
| 908 | __( 'Responsive Lightbox', 'responsive-lightbox' ), __( 'Responsive Lightbox', 'responsive-lightbox' ), 'manage_options', 'responsive-lightbox', array( &$this, 'options_page' ) |
| 909 | ); |
| 910 | } |
| 911 | |
| 912 | /** |
| 913 | * Render options page |
| 914 | * |
| 915 | * @return void |
| 916 | */ |
| 917 | public function options_page() { |
| 918 | $tab_key = ( isset( $_GET['tab'] ) ? $_GET['tab'] : 'settings' ); |
| 919 | |
| 920 | echo ' |
| 921 | <div class="wrap">' . screen_icon() . ' |
| 922 | <h2>' . __( 'Responsive Lightbox', 'responsive-lightbox' ) . '</h2> |
| 923 | <h2 class="nav-tab-wrapper">'; |
| 924 | |
| 925 | foreach ( $this->tabs as $key => $name ) { |
| 926 | echo ' |
| 927 | <a class="nav-tab ' . ($tab_key == $key ? 'nav-tab-active' : '') . '" href="' . esc_url( admin_url( 'options-general.php?page=responsive-lightbox&tab=' . $key ) ) . '">' . $name['name'] . '</a>'; |
| 928 | } |
| 929 | |
| 930 | echo ' |
| 931 | </h2> |
| 932 | <div class="responsive-lightbox-settings"> |
| 933 | |
| 934 | <div class="df-credits"> |
| 935 | <h3 class="hndle">' . __( 'Responsive Lightbox', 'responsive-lightbox' ) . ' ' . Responsive_Lightbox()->defaults['version'] . '</h3> |
| 936 | <div class="inside"> |
| 937 | <h4 class="inner">' . __( 'Need support?', 'responsive-lightbox' ) . '</h4> |
| 938 | <p class="inner">' . __( 'If you are having problems with this plugin, please talk about them in the', 'responsive-lightbox' ) . ' <a href="http://www.dfactory.eu/support/?utm_source=responsive-lightbox-settings&utm_medium=link&utm_campaign=support" target="_blank" title="' . __( 'Support forum', 'responsive-lightbox' ) . '">' . __( 'Support forum', 'responsive-lightbox' ) . '</a></p> |
| 939 | <hr /> |
| 940 | <h4 class="inner">' . __( 'Do you like this plugin?', 'responsive-lightbox' ) . '</h4> |
| 941 | <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank" class="inner"> |
| 942 | <input type="hidden" name="cmd" value="_s-xclick"> |
| 943 | <input type="hidden" name="hosted_button_id" value="8AL8ULUN9R76U"> |
| 944 | <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> |
| 945 | <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1"> |
| 946 | </form> |
| 947 | <p class="inner"><a href="http://wordpress.org/support/view/plugin-reviews/responsive-lightbox" target="_blank" title="' . __( 'Rate it 5', 'responsive-lightbox' ) . '">' . __( 'Rate it 5', 'responsive-lightbox' ) . '</a> ' . __( 'on WordPress.org', 'responsive-lightbox' ) . '<br />' . |
| 948 | __( 'Blog about it & link to the', 'responsive-lightbox' ) . ' <a href="http://www.dfactory.eu/plugins/responsive-lightbox/?utm_source=responsive-lightbox-settings&utm_medium=link&utm_campaign=blog-about" target="_blank" title="' . __( 'plugin page', 'responsive-lightbox' ) . '">' . __( 'plugin page', 'responsive-lightbox' ) . '</a><br />' . |
| 949 | __( 'Check out our other', 'responsive-lightbox' ) . ' <a href="http://www.dfactory.eu/?utm_source=responsive-lightbox-settings&utm_medium=link&utm_campaign=other-plugins" target="_blank" title="' . __( 'WordPress plugins', 'responsive-lightbox' ) . '">' . __( 'WordPress plugins', 'responsive-lightbox' ) . '</a> |
| 950 | </p> |
| 951 | <hr /> |
| 952 | <p class="df-link inner">Created by <a href="http://www.dfactory.eu/?utm_source=responsive-lightbox-settings&utm_medium=link&utm_campaign=created-by" target="_blank" title="dFactory - Quality plugins for WordPress"><img src="' . RESPONSIVE_LIGHTBOX_URL . '/images/logo-dfactory.png' . '" title="dFactory - Quality plugins for WordPress" alt="dFactory - Quality plugins for WordPress" /></a></p> |
| 953 | </div> |
| 954 | </div> |
| 955 | |
| 956 | <form action="options.php" method="post">'; |
| 957 | |
| 958 | // tab content callback |
| 959 | if ( ! empty( $this->tabs[$tab_key]['callback'] ) ) { |
| 960 | call_user_func( $this->tabs[$tab_key]['callback'] ); |
| 961 | } else { |
| 962 | wp_nonce_field( 'update-options' ); |
| 963 | settings_fields( $this->tabs[$tab_key]['key'] ); |
| 964 | do_settings_sections( $this->tabs[$tab_key]['key'] ); |
| 965 | } |
| 966 | |
| 967 | if ( ! empty( $this->tabs[$tab_key]['submit'] ) || ! empty( $this->tabs[$tab_key]['reset'] ) ) { |
| 968 | |
| 969 | echo ' <p class="submit">'; |
| 970 | if ( ! empty( $this->tabs[$tab_key]['submit'] ) ) { |
| 971 | submit_button( '', array( 'primary', 'save-' . $tab_key ), $this->tabs[$tab_key]['submit'], false ); |
| 972 | echo ' '; |
| 973 | } |
| 974 | if ( ! empty( $this->tabs[$tab_key]['reset'] ) ) { |
| 975 | submit_button( __( 'Reset to defaults', 'responsive-lightbox' ), array( 'secondary', 'reset-' . $tab_key ), $this->tabs[$tab_key]['reset'], false ); |
| 976 | } |
| 977 | echo ' </p>'; |
| 978 | |
| 979 | } |
| 980 | |
| 981 | echo ' |
| 982 | </form> |
| 983 | </div> |
| 984 | <div class="clear"></div> |
| 985 | </div>'; |
| 986 | } |
| 987 | |
| 988 | /** |
| 989 | * Render settings function |
| 990 | * |
| 991 | * @return void |
| 992 | */ |
| 993 | public function register_settings() { |
| 994 | |
| 995 | foreach ( $this->settings as $setting_id => $setting ) { |
| 996 | |
| 997 | // set key |
| 998 | $setting_key = $setting_id; |
| 999 | $setting_id = 'responsive_lightbox_' . $setting_id; |
| 1000 | |
| 1001 | // register setting |
| 1002 | register_setting( |
| 1003 | esc_attr( $setting_id ), |
| 1004 | ! empty( $setting['option_name'] ) ? esc_attr( $setting['option_name'] ) : $setting_id, |
| 1005 | ! empty( $setting['callback'] ) ? $setting['callback'] : array( &$this, 'validate_settings' ) |
| 1006 | ); |
| 1007 | |
| 1008 | // register sections |
| 1009 | if ( ! empty( $setting['sections'] ) && is_array( $setting['sections'] ) ) { |
| 1010 | |
| 1011 | foreach ( $setting['sections'] as $section_id => $section ) { |
| 1012 | |
| 1013 | add_settings_section( |
| 1014 | esc_attr( $section_id ), |
| 1015 | ! empty( $section['title'] ) ? esc_html( $section['title'] ) : '', |
| 1016 | ! empty( $section['callback'] ) ? $section['callback'] : '', |
| 1017 | ! empty( $section['page'] ) ? esc_attr( $section['page'] ) : $section_id |
| 1018 | ); |
| 1019 | } |
| 1020 | |
| 1021 | } |
| 1022 | |
| 1023 | // register fields |
| 1024 | if ( ! empty( $setting['fields'] ) && is_array( $setting['fields'] ) ) { |
| 1025 | |
| 1026 | foreach ( $setting['fields'] as $field_id => $field ) { |
| 1027 | |
| 1028 | // prefix field id? |
| 1029 | $field_key = $field_id; |
| 1030 | $field_id = ( ! empty( $setting['prefix'] ) ? $setting['prefix'] . '_' : '' ) . $field_id; |
| 1031 | |
| 1032 | // field args |
| 1033 | $args = array( |
| 1034 | 'id' => ! empty( $field['id'] ) ? $field['id'] : $field_id, |
| 1035 | 'class' => ! empty( $field['class'] ) ? $field['class'] : '', |
| 1036 | 'name' => $setting['option_name'] . ( ! empty( $field['parent'] ) ? '[' . $field['parent'] . ']' : '' ) . '[' . $field_key . ']', |
| 1037 | 'type' => ! empty( $field['type'] ) ? $field['type'] : 'text', |
| 1038 | 'label' => ! empty( $field['label'] ) ? $field['label'] : '', |
| 1039 | 'description' => ! empty( $field['description'] ) ? $field['description'] : '', |
| 1040 | 'append' => ! empty( $field['append'] ) ? esc_html( $field['append'] ) : '', |
| 1041 | 'prepend' => ! empty( $field['prepend'] ) ? esc_html( $field['prepend'] ) : '', |
| 1042 | 'min' => ! empty( $field['min'] ) ? (int) $field['min'] : '', |
| 1043 | 'max' => ! empty( $field['max'] ) ? (int) $field['max'] : '', |
| 1044 | 'options' => ! empty( $field['options'] ) ? $field['options'] : '', |
| 1045 | 'fields' => ! empty( $field['fields'] ) ? $field['fields'] : '', |
| 1046 | 'default' => $field['type'] === 'multiple' ? '' : ( $this->sanitize_field( ! empty( $field['parent'] ) ? Responsive_Lightbox()->defaults[$setting_key][$field['parent']][$field_key] : Responsive_Lightbox()->defaults[$setting_key][$field_key], $field['type'] ) ), |
| 1047 | 'value' => $field['type'] === 'multiple' ? '' : ( $this->sanitize_field( ! empty( $field['parent'] ) ? Responsive_Lightbox()->options[$setting_key][$field['parent']][$field_key] : ( isset( Responsive_Lightbox()->options[$setting_key][$field_key] ) ? Responsive_Lightbox()->options[$setting_key][$field_key] : Responsive_Lightbox()->defaults[$setting_key][$field_key] ), $field['type'] ) ), |
| 1048 | 'label_for' => $field_id, |
| 1049 | 'return' => false |
| 1050 | ); |
| 1051 | |
| 1052 | if ( $args['type'] === 'multiple' ) { |
| 1053 | foreach ( $args['fields'] as $subfield_id => $subfield ) { |
| 1054 | $args['fields'][$subfield_id] = wp_parse_args( $subfield, array( |
| 1055 | 'id' => $field_id . '-' . $subfield_id, |
| 1056 | 'class' => ! empty( $subfield['class'] ) ? $subfield['class'] : '', |
| 1057 | 'name' => $setting['option_name'] . ( ! empty( $subfield['parent'] ) ? '[' . $subfield['parent'] . ']' : '' ) . '[' . $subfield_id . ']', |
| 1058 | 'default' => $this->sanitize_field( ! empty( $subfield['parent'] ) ? Responsive_Lightbox()->defaults[$setting_key][$subfield['parent']][$subfield_id] : Responsive_Lightbox()->defaults[$setting_key][$subfield_id], $subfield['type'] ), |
| 1059 | 'value' => $this->sanitize_field( ! empty( $subfield['parent'] ) ? Responsive_Lightbox()->options[$setting_key][$subfield['parent']][$subfield_id] : Responsive_Lightbox()->options[$setting_key][$subfield_id], $subfield['type'] ), |
| 1060 | 'return' => true |
| 1061 | ) ); |
| 1062 | } |
| 1063 | } |
| 1064 | |
| 1065 | add_settings_field( |
| 1066 | esc_attr( $field_id ), |
| 1067 | ! empty( $field['title'] ) ? esc_html( $field['title'] ) : '', |
| 1068 | array( &$this, 'render_field' ), |
| 1069 | ! empty( $field['page'] ) ? esc_attr( $field['page'] ) : $setting_id, |
| 1070 | ! empty( $field['section'] ) ? esc_attr( $field['section'] ) : '', |
| 1071 | $args |
| 1072 | ); |
| 1073 | |
| 1074 | } |
| 1075 | |
| 1076 | } |
| 1077 | |
| 1078 | } |
| 1079 | |
| 1080 | // licenses |
| 1081 | $extensions = apply_filters( 'rl_settings_licenses', array() ); |
| 1082 | |
| 1083 | if ( $extensions ) { |
| 1084 | // register setting |
| 1085 | register_setting( |
| 1086 | 'responsive_lightbox_licenses', |
| 1087 | 'responsive_lightbox_licenses', |
| 1088 | array( &$this, 'validate_licenses' ) |
| 1089 | ); |
| 1090 | |
| 1091 | add_settings_section( |
| 1092 | 'responsive_lightbox_licenses', |
| 1093 | __( 'Licenses', 'responsive-lightbox' ), |
| 1094 | array( &$this, 'licenses_section_cb' ), |
| 1095 | 'responsive_lightbox_licenses' |
| 1096 | ); |
| 1097 | |
| 1098 | foreach ( $extensions as $id => $extension ) { |
| 1099 | add_settings_field( |
| 1100 | esc_attr( $id ), |
| 1101 | $extension['name'], |
| 1102 | array( &$this, 'license_field_cb' ), |
| 1103 | 'responsive_lightbox_licenses', |
| 1104 | 'responsive_lightbox_licenses', |
| 1105 | $extension |
| 1106 | ); |
| 1107 | } |
| 1108 | } |
| 1109 | |
| 1110 | } |
| 1111 | |
| 1112 | /** |
| 1113 | * Render settings field function |
| 1114 | * |
| 1115 | * @param array $args |
| 1116 | * @return mixed |
| 1117 | */ |
| 1118 | public function render_field( $args ) { |
| 1119 | |
| 1120 | if ( empty( $args ) || ! is_array( $args ) ) |
| 1121 | return; |
| 1122 | |
| 1123 | $html = ''; |
| 1124 | |
| 1125 | switch ( $args['type'] ) { |
| 1126 | |
| 1127 | case ( 'boolean' ) : |
| 1128 | |
| 1129 | $html .= '<label class="cb-checkbox"><input id="' . $args['id'] . '" type="checkbox" name="' . $args['name'] . '" value="1" ' . checked( (bool) $args['value'], true, false ) . ' />' . $args['label'] . '</label>'; |
| 1130 | break; |
| 1131 | |
| 1132 | case ( 'radio' ) : |
| 1133 | |
| 1134 | foreach ( $args['options'] as $key => $name ) { |
| 1135 | $html .= '<label class="cb-radio"><input id="' . $args['id'] . '-' . $key . '" type="radio" name="' . $args['name'] . '" value="' . $key . '" ' . checked( $key, $args['value'], false ) . ' />' . $name . '</label> '; |
| 1136 | } |
| 1137 | break; |
| 1138 | |
| 1139 | case ( 'checkbox' ) : |
| 1140 | |
| 1141 | foreach ( $args['options'] as $key => $name ) { |
| 1142 | $html .= '<label class="cb-checkbox"><input id="' . $args['id'] . '-' . $key . '" type="checkbox" name="' . $args['name'] . '" value="' . $key . '" ' . checked( $key, $args['value'], false ) . ' />' . $name . '</label> '; |
| 1143 | } |
| 1144 | break; |
| 1145 | |
| 1146 | case ( 'select' ) : |
| 1147 | |
| 1148 | $html .= '<select id="' . $args['id'] . '" name="' . $args['name'] . '" value="' . $args['value'] . '" />'; |
| 1149 | |
| 1150 | foreach ( $args['options'] as $key => $name ) { |
| 1151 | $html .= '<option value="' . $key . '" ' . selected( $args['value'], $key, false ) . '>' . $name . '</option>'; |
| 1152 | } |
| 1153 | |
| 1154 | $html .= '</select>'; |
| 1155 | break; |
| 1156 | |
| 1157 | case ( 'multiple' ) : |
| 1158 | |
| 1159 | $html .= '<fieldset>'; |
| 1160 | |
| 1161 | if ( $args['fields'] ) { |
| 1162 | |
| 1163 | $count = 1; |
| 1164 | $count_fields = count( $args['fields'] ); |
| 1165 | |
| 1166 | foreach ( $args['fields'] as $subfield_id => $subfield_args ) { |
| 1167 | $html .= $this->render_field( $subfield_args ) . ( $count < $count_fields ? '<br />' : '' ); |
| 1168 | $count++; |
| 1169 | } |
| 1170 | |
| 1171 | } |
| 1172 | |
| 1173 | $html .= '</fieldset>'; |
| 1174 | break; |
| 1175 | |
| 1176 | case ( 'range' ) : |
| 1177 | $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" />'; |
| 1178 | $html .= '<output name="' . $args['id'] . '_range">' . esc_attr( Responsive_Lightbox()->options['configuration']['prettyphoto']['opacity'] ) . '</output>'; |
| 1179 | break; |
| 1180 | |
| 1181 | case ( 'color_picker' ) : |
| 1182 | $html .= '<input id="' . $args['id'] . '" class="color-picker" type="text" value="' . $args['value'] . '" name="' . $args['name'] . '" data-default-color="' . $args['default'] . '" />'; |
| 1183 | break; |
| 1184 | |
| 1185 | case ( 'number' ) : |
| 1186 | $html .= ( ! empty( $args['prepend'] ) ? '<span>' . $args['prepend'] . '</span> ' : '' ); |
| 1187 | $html .= '<input id="' . $args['id'] . '" type="text" value="' . $args['value'] . '" name="' . $args['name'] . '" />'; |
| 1188 | $html .= ( ! empty( $args['append'] ) ? ' <span>' . $args['append'] . '</span>' : '' ); |
| 1189 | break; |
| 1190 | |
| 1191 | case ( 'text' ) : |
| 1192 | default : |
| 1193 | $html .= ( ! empty( $args['prepend'] ) ? '<span>' . $args['prepend'] . '</span> ' : '' ); |
| 1194 | $html .= '<input id="' . $args['id'] . '" class="' . $args['class'] . '" type="text" value="' . $args['value'] . '" name="' . $args['name'] . '" />'; |
| 1195 | $html .= ( ! empty( $args['append'] ) ? ' <span>' . $args['append'] . '</span>' : '' ); |
| 1196 | break; |
| 1197 | |
| 1198 | } |
| 1199 | |
| 1200 | if ( ! empty ( $args['description'] ) ) { |
| 1201 | $html .= '<p class="description">' . $args['description'] . '</p>'; |
| 1202 | } |
| 1203 | |
| 1204 | if ( ! empty( $args['return'] ) ) { |
| 1205 | return $html; |
| 1206 | } else { |
| 1207 | echo $html; |
| 1208 | } |
| 1209 | } |
| 1210 | |
| 1211 | /** |
| 1212 | * Sanitize field function |
| 1213 | * |
| 1214 | * @param mixed |
| 1215 | * @param string |
| 1216 | * @return mixed |
| 1217 | */ |
| 1218 | public function sanitize_field( $value = null, $type = '', $args = array() ) { |
| 1219 | if ( is_null( $value ) ) |
| 1220 | return null; |
| 1221 | |
| 1222 | switch ( $type ) { |
| 1223 | |
| 1224 | case 'boolean': |
| 1225 | $value = empty( $value ) ? false : true; |
| 1226 | break; |
| 1227 | |
| 1228 | case 'checkbox': |
| 1229 | $value = is_array( $value ) ? array_map( 'sanitize_text_field', $value ) : false; |
| 1230 | break; |
| 1231 | |
| 1232 | case 'radio': |
| 1233 | $value = is_array( $value ) ? false : sanitize_text_field( $value ); |
| 1234 | break; |
| 1235 | |
| 1236 | case 'textarea': |
| 1237 | case 'wysiwyg': |
| 1238 | $value = wp_kses_post( $value ); |
| 1239 | break; |
| 1240 | |
| 1241 | case 'color_picker': |
| 1242 | $value = ! $value || '#' == $value ? '' : esc_attr( $value ); |
| 1243 | break; |
| 1244 | |
| 1245 | case 'number': |
| 1246 | $value = ! $value || is_array( $value ) ? '' : str_replace( ',', '', $value ); |
| 1247 | |
| 1248 | if ( ! empty( $args['type'] ) ) { |
| 1249 | switch ( $args['type'] ) { |
| 1250 | case 'int': |
| 1251 | $value = (int) $value; |
| 1252 | break; |
| 1253 | |
| 1254 | case 'absint': |
| 1255 | $value = absint( $value ); |
| 1256 | break; |
| 1257 | |
| 1258 | case 'float': |
| 1259 | default: |
| 1260 | $value = floatval( $value ); |
| 1261 | break; |
| 1262 | } |
| 1263 | } else { |
| 1264 | $value = floatval( $value ); |
| 1265 | } |
| 1266 | break; |
| 1267 | |
| 1268 | case 'text': |
| 1269 | case 'select': |
| 1270 | default: |
| 1271 | $value = is_array( $value ) ? array_map( 'sanitize_text_field', $value ) : sanitize_text_field( $value ); |
| 1272 | break; |
| 1273 | } |
| 1274 | |
| 1275 | return stripslashes_deep( $value ); |
| 1276 | } |
| 1277 | |
| 1278 | /** |
| 1279 | * Validate settings function |
| 1280 | * |
| 1281 | * @param array $input |
| 1282 | * @return array |
| 1283 | */ |
| 1284 | public function validate_settings( $input ) { |
| 1285 | // check cap |
| 1286 | if ( ! current_user_can( 'manage_options') ) { |
| 1287 | return $input; |
| 1288 | } |
| 1289 | |
| 1290 | // check page |
| 1291 | if ( ! ( $option_page = esc_attr( $_POST['option_page'] ) ) ) |
| 1292 | return $input; |
| 1293 | |
| 1294 | foreach ( $this->settings as $id => $setting ) { |
| 1295 | |
| 1296 | $key = array_search( $option_page, $setting ); |
| 1297 | |
| 1298 | if ( $key ) { |
| 1299 | // set key |
| 1300 | $setting_id = $id; |
| 1301 | continue; |
| 1302 | } |
| 1303 | } |
| 1304 | |
| 1305 | // check setting id |
| 1306 | if ( ! $setting_id ) |
| 1307 | return $input; |
| 1308 | |
| 1309 | // save settings |
| 1310 | if ( isset( $_POST['save' . '_' . $this->settings[$setting_id]['prefix'] . '_' . $setting_id] ) ) { |
| 1311 | |
| 1312 | if ( $this->settings[$setting_id]['fields'] ) { |
| 1313 | |
| 1314 | foreach ( $this->settings[$setting_id]['fields'] as $field_id => $field ) { |
| 1315 | |
| 1316 | if ( $field['type'] === 'multiple' ) { |
| 1317 | |
| 1318 | if ( $field['fields'] ) { |
| 1319 | |
| 1320 | foreach ( $field['fields'] as $subfield_id => $subfield ) { |
| 1321 | |
| 1322 | // if subfield has parent |
| 1323 | if ( ! empty( $this->settings[$setting_id]['fields'][$field_id]['fields'][$subfield_id]['parent'] ) ) { |
| 1324 | |
| 1325 | $field_parent = $this->settings[$setting_id]['fields'][$field_id]['fields'][$subfield_id]['parent']; |
| 1326 | |
| 1327 | $input[$field_parent][$subfield_id] = isset( $input[$field_parent][$subfield_id] ) ? $this->sanitize_field( $input[$field_parent][$subfield_id], $subfield['type'] ) : ( $subfield['type'] === 'boolean' ? false : Responsive_Lightbox()->defaults[$setting_id][$field_parent][$subfield_id] ); |
| 1328 | |
| 1329 | } else { |
| 1330 | |
| 1331 | $input[$subfield_id] = isset( $input[$subfield_id] ) ? $this->sanitize_field( $input[$subfield_id], $subfield['type'] ) : ( $subfield['type'] === 'boolean' ? false : Responsive_Lightbox()->defaults[$setting_id][$field_id][$subfield_id] ); |
| 1332 | |
| 1333 | } |
| 1334 | |
| 1335 | } |
| 1336 | |
| 1337 | } |
| 1338 | |
| 1339 | } else { |
| 1340 | |
| 1341 | // if field has parent |
| 1342 | if ( ! empty( $this->settings[$setting_id]['fields'][$field_id]['parent'] ) ) { |
| 1343 | |
| 1344 | $field_parent = $this->settings[$setting_id]['fields'][$field_id]['parent']; |
| 1345 | |
| 1346 | $input[$field_parent][$field_id] = isset( $input[$field_parent][$field_id] ) ? $this->sanitize_field( $input[$field_parent][$field_id], $field['type'] ) : ( $field['type'] === 'boolean' ? false : Responsive_Lightbox()->defaults[$setting_id][$field_parent][$field_id] ); |
| 1347 | |
| 1348 | } else { |
| 1349 | |
| 1350 | $input[$field_id] = isset( $input[$field_id] ) ? $this->sanitize_field( $input[$field_id], $field['type'] ) : ( $field['type'] === 'boolean' ? false : Responsive_Lightbox()->defaults[$setting_id][$field_id] ); |
| 1351 | |
| 1352 | } |
| 1353 | |
| 1354 | } |
| 1355 | |
| 1356 | } |
| 1357 | |
| 1358 | } |
| 1359 | |
| 1360 | if ( $setting_id === 'settings' ) { |
| 1361 | // merge scripts settings |
| 1362 | $input = array_merge( Responsive_Lightbox()->options['settings'], $input ); |
| 1363 | } |
| 1364 | |
| 1365 | if ( $setting_id === 'configuration' ) { |
| 1366 | // merge scripts settings |
| 1367 | $input = array_merge( Responsive_Lightbox()->options['configuration'], $input ); |
| 1368 | } |
| 1369 | |
| 1370 | } elseif ( isset( $_POST['reset' . '_' . $this->settings[$setting_id]['prefix'] . '_' . $setting_id] ) ) { |
| 1371 | |
| 1372 | if ( $setting_id === 'configuration' ) { |
| 1373 | // merge scripts settings |
| 1374 | $input[Responsive_Lightbox()->options['settings']['script']] = Responsive_Lightbox()->defaults['configuration'][Responsive_Lightbox()->options['settings']['script']]; |
| 1375 | $input = array_merge( Responsive_Lightbox()->options['configuration'], $input ); |
| 1376 | } elseif ( $setting_id === 'settings' ) { |
| 1377 | $input = Responsive_Lightbox()->defaults[$setting_id]; |
| 1378 | $input['update_version'] = Responsive_Lightbox()->options['settings']['update_version']; |
| 1379 | $input['update_notice'] = Responsive_Lightbox()->options['settings']['update_notice']; |
| 1380 | } else { |
| 1381 | $input = Responsive_Lightbox()->defaults[$setting_id]; |
| 1382 | } |
| 1383 | |
| 1384 | add_settings_error( 'reset' . '_' . $this->settings[$setting_id]['prefix'] . '_' . $setting_id, 'settings_restored', __( 'Settings restored to defaults.', 'responsive-lightbox' ), 'updated' ); |
| 1385 | |
| 1386 | } |
| 1387 | |
| 1388 | return $input; |
| 1389 | } |
| 1390 | |
| 1391 | /** |
| 1392 | * Add-ons tab callback |
| 1393 | * |
| 1394 | * @return mixed |
| 1395 | */ |
| 1396 | private function addons_tab_cb() { |
| 1397 | ?> |
| 1398 | <h3><?php _e( 'Add-ons / Extensions', 'responsive-lightbox' ); ?></h3> |
| 1399 | <p class="description"><?php _e( 'Enhance your website with these beautiful, easy to use extensions, designed with Responsive Lightbox integration in mind.', 'responsive-lightbox' ); ?></p> |
| 1400 | <br /> |
| 1401 | <?php |
| 1402 | if ( ( $cache = get_transient( 'responsive_lightbox_addons_feed' ) ) === false ) { |
| 1403 | $url = 'https://dfactory.eu/?feed=addons&product=responsive-lightbox'; |
| 1404 | |
| 1405 | $feed = wp_remote_get( esc_url_raw( $url ), array( 'sslverify' => false ) ); |
| 1406 | |
| 1407 | if ( ! is_wp_error( $feed ) ) { |
| 1408 | if ( isset( $feed['body'] ) && strlen( $feed['body'] ) > 0 ) { |
| 1409 | $cache = wp_remote_retrieve_body( $feed ); |
| 1410 | // set_transient( 'responsive_lightbox_addons_feed', $cache, 3600 ); |
| 1411 | } |
| 1412 | } else { |
| 1413 | $cache = '<div class="error"><p>' . __( 'There was an error retrieving the extensions list from the server. Please try again later.', 'responsive-lightbox' ) . '</div>'; |
| 1414 | } |
| 1415 | } |
| 1416 | |
| 1417 | echo $cache; |
| 1418 | } |
| 1419 | |
| 1420 | /** |
| 1421 | * Licenses section callback. |
| 1422 | * |
| 1423 | * @return mixed |
| 1424 | */ |
| 1425 | public function licenses_section_cb() { |
| 1426 | ?><p class="description"><?php _e( 'A list of licenses for your Responsive Lightbox extensions.', 'responsive-lightbox' ); ?></p><?php |
| 1427 | } |
| 1428 | |
| 1429 | /** |
| 1430 | * License field callback. |
| 1431 | * |
| 1432 | * @return mixed |
| 1433 | */ |
| 1434 | public function license_field_cb( $args ) { |
| 1435 | $licenses = get_option( 'responsive_lightbox_licenses' ); |
| 1436 | |
| 1437 | $license = ! empty( $licenses ) && isset( $licenses[$args['id']]['license'] ) ? esc_attr( $licenses[$args['id']]['license'] ) : ''; |
| 1438 | $status = ! empty( $licenses ) && ! empty( $licenses[$args['id']]['status'] ) ? true : false; |
| 1439 | ?> |
| 1440 | <fieldset class="rl_license rl_license-<?php echo esc_attr( $args['id'] ); ?>"> |
| 1441 | <input type="text" class="regular-text" name="responsive_lightbox_licenses[<?php echo esc_attr( $args['id'] ); ?>][license]" value="<?php echo $license; ?>"><span class="dashicons <?php echo ! empty( $status ) ? 'dashicons-yes' : 'dashicons-no'; ?>"></span> |
| 1442 | <p class="description"><?php printf( __( 'Enter your license key to activate %s extension and enable automatic upgrade notices.', 'responsive-lightbox' ), $args['name'] ); ?></p> |
| 1443 | </fieldset> |
| 1444 | <?php |
| 1445 | } |
| 1446 | |
| 1447 | /** |
| 1448 | * Validate licenses function. |
| 1449 | * |
| 1450 | * @param array $input |
| 1451 | * @return array |
| 1452 | */ |
| 1453 | public function validate_licenses( $input ) { |
| 1454 | |
| 1455 | // check cap |
| 1456 | if ( ! current_user_can( 'manage_options') ) { |
| 1457 | return $input; |
| 1458 | } |
| 1459 | |
| 1460 | // check page |
| 1461 | if ( ! ( $option_page = esc_attr( $_POST['option_page'] ) ) ) |
| 1462 | return $input; |
| 1463 | |
| 1464 | // check data |
| 1465 | if ( ! isset( $_POST['responsive_lightbox_licenses'] ) || ! is_array( $_POST['responsive_lightbox_licenses'] )) |
| 1466 | return $input; |
| 1467 | |
| 1468 | $extensions = apply_filters( 'rl_settings_licenses', array() ); |
| 1469 | |
| 1470 | if ( empty( $extensions ) ) |
| 1471 | return $input; |
| 1472 | |
| 1473 | // save settings |
| 1474 | if ( isset( $_POST['save_rl_licenses'] ) ) { |
| 1475 | $licenses = get_option( 'responsive_lightbox_licenses' ); |
| 1476 | |
| 1477 | foreach ( $extensions as $extension ) { |
| 1478 | if ( ! isset( $_POST['responsive_lightbox_licenses'][$extension['id']] ) ) |
| 1479 | continue; |
| 1480 | |
| 1481 | $license = preg_replace('/[^a-zA-Z0-9]/', '', $_POST['responsive_lightbox_licenses'][$extension['id']]['license'] ); |
| 1482 | $status = ! empty( $licenses ) && ! empty( $licenses[$extension['id']]['status'] ) ? true : false; |
| 1483 | |
| 1484 | // request data |
| 1485 | $request_args = array( |
| 1486 | 'action' => 'activate_license', |
| 1487 | 'license' => trim( $license ), |
| 1488 | 'item_name' => $extension['item_name'] |
| 1489 | ); |
| 1490 | // request |
| 1491 | $response = $this->license_request( $request_args ); |
| 1492 | |
| 1493 | // echo '<pre>'; print_r( $response ); echo '</pre>'; |
| 1494 | |
| 1495 | // validate request |
| 1496 | if ( is_wp_error( $response ) ) { |
| 1497 | $input[$extension['id']['status']] = false; |
| 1498 | add_settings_error( 'rl_licenses_settings', 'license_activation_failed', __( 'License activation failed.', 'responsive-lightbox' ), 'error' ); |
| 1499 | } else { |
| 1500 | // decode the license data |
| 1501 | $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
| 1502 | |
| 1503 | // assign the data |
| 1504 | if ( $license_data->license == 'valid' ) { |
| 1505 | $input[$extension['id']]['status'] = true; |
| 1506 | |
| 1507 | if ( $status === false ) |
| 1508 | add_settings_error( 'rl_licenses_settings', 'license_activated', __( 'License successfully activated.', 'responsive-lightbox' ), 'updated' ); |
| 1509 | } else { |
| 1510 | $input[$extension['id']]['status'] = false; |
| 1511 | add_settings_error( 'rl_licenses_settings', 'license_activation_failed', __( 'License activation failed.', 'responsive-lightbox' ), 'error' ); |
| 1512 | } |
| 1513 | } |
| 1514 | } |
| 1515 | } elseif ( isset( $_POST['reset_rl_licenses'] ) ) { |
| 1516 | $licenses = get_option( 'responsive_lightbox_licenses' ); |
| 1517 | |
| 1518 | foreach ( $extensions as $extension ) { |
| 1519 | $license = ! empty( $licenses ) && isset( $licenses[$extension['id']]['license'] ) ? $licenses[$extension['id']]['license'] : ''; |
| 1520 | $status = ! empty( $licenses ) && ! empty( $licenses[$extension['id']]['status'] ) ? true : false; |
| 1521 | |
| 1522 | if ( $status === true ) { |
| 1523 | // request data |
| 1524 | $request_args = array( |
| 1525 | 'action' => 'deactivate_license', |
| 1526 | 'license' => trim( $license ), |
| 1527 | 'item_name' => $extension['item_name'] |
| 1528 | ); |
| 1529 | // request |
| 1530 | $response = $this->license_request( $request_args ); |
| 1531 | |
| 1532 | // echo '<pre>'; print_r( $response ); echo '</pre>'; |
| 1533 | |
| 1534 | // validate request |
| 1535 | if ( is_wp_error( $response ) ) { |
| 1536 | add_settings_error( 'rl_licenses_settings', 'license_activation_failed', __( 'License activation failed.', 'responsive-lightbox' ), 'error' ); |
| 1537 | } else { |
| 1538 | // decode the license data |
| 1539 | $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
| 1540 | |
| 1541 | // assign the data |
| 1542 | if ( $license_data->license == 'deactivated' ) { |
| 1543 | $input[$extension['id']]['license'] = ''; |
| 1544 | $input[$extension['id']]['status'] = false; |
| 1545 | add_settings_error( 'rl_licenses_settings', 'license_deactivated', __( 'License successfully deactivated.', 'responsive-lightbox' ), 'updated' ); |
| 1546 | } else { |
| 1547 | add_settings_error( 'rl_licenses_settings', 'license_deactivation_failed', __( 'License activation failed.', 'responsive-lightbox' ), 'error' ); |
| 1548 | } |
| 1549 | } |
| 1550 | } |
| 1551 | } |
| 1552 | } |
| 1553 | |
| 1554 | return $input; |
| 1555 | } |
| 1556 | |
| 1557 | /** |
| 1558 | * License request function. |
| 1559 | * |
| 1560 | * @param array $args |
| 1561 | * @return mixed |
| 1562 | */ |
| 1563 | private function license_request( $args ) { |
| 1564 | // data to send in our API request |
| 1565 | $api_params = array( |
| 1566 | 'edd_action' => $args['action'], |
| 1567 | 'license' => $args['license'], |
| 1568 | 'item_name' => urlencode( $args['item_name'] ), |
| 1569 | // 'item_id' => $args['item_id'], |
| 1570 | 'url' => home_url(), |
| 1571 | 'timeout' => 15, |
| 1572 | 'sslverify' => false |
| 1573 | ); |
| 1574 | // call the custom API. |
| 1575 | $response = wp_remote_get( add_query_arg( $api_params, $this->api_url ) ); |
| 1576 | |
| 1577 | return $response; |
| 1578 | } |
| 1579 | } |
| 1580 |