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