responsive-lightbox
Last commit date
assets
11 years ago
css
11 years ago
images
12 years ago
includes
11 years ago
js
11 years ago
languages
11 years ago
index.php
12 years ago
readme.txt
11 years ago
responsive-lightbox.php
11 years ago
responsive-lightbox.php
575 lines
| 1 | <?php |
| 2 | /* |
| 3 | Plugin Name: Responsive Lightbox |
| 4 | Description: Responsive Lightbox allows users to view larger versions of images and galleries in a lightbox (overlay) effect optimized for mobile devices. |
| 5 | Version: 1.5.2 |
| 6 | Author: dFactory |
| 7 | Author URI: http://www.dfactory.eu/ |
| 8 | Plugin URI: http://www.dfactory.eu/plugins/responsive-lightbox/ |
| 9 | License: MIT License |
| 10 | License URI: http://opensource.org/licenses/MIT |
| 11 | Text Domain: responsive-lightbox |
| 12 | Domain Path: /languages |
| 13 | |
| 14 | Responsive Lightbox |
| 15 | Copyright (C) 2013-2015, Digital Factory - info@digitalfactory.pl |
| 16 | |
| 17 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: |
| 18 | |
| 19 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. |
| 20 | |
| 21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 22 | */ |
| 23 | |
| 24 | // exit if accessed directly |
| 25 | if ( ! defined( 'ABSPATH' ) ) |
| 26 | exit; |
| 27 | |
| 28 | define( 'RESPONSIVE_LIGHTBOX_URL', plugins_url( '', __FILE__ ) ); |
| 29 | define( 'RESPONSIVE_LIGHTBOX_PATH', plugin_dir_path( __FILE__ ) ); |
| 30 | define( 'RESPONSIVE_LIGHTBOX_REL_PATH', dirname( plugin_basename( __FILE__ ) ) . '/' ); |
| 31 | |
| 32 | include_once( RESPONSIVE_LIGHTBOX_PATH . 'includes/class-frontend.php' ); |
| 33 | include_once( RESPONSIVE_LIGHTBOX_PATH . 'includes/class-settings.php' ); |
| 34 | |
| 35 | /** |
| 36 | * Responsive Lightbox class. |
| 37 | * |
| 38 | * @class Responsive_Lightbox |
| 39 | * @version 1.5.2 |
| 40 | */ |
| 41 | class Responsive_Lightbox { |
| 42 | |
| 43 | public $defaults = array( |
| 44 | 'settings' => array( |
| 45 | 'script' => 'swipebox', |
| 46 | 'selector' => 'lightbox', |
| 47 | 'galleries' => true, |
| 48 | 'gallery_image_size' => 'full', |
| 49 | 'gallery_image_title' => 'default', |
| 50 | 'force_custom_gallery' => false, |
| 51 | 'videos' => true, |
| 52 | 'image_links' => true, |
| 53 | 'images_as_gallery' => false, |
| 54 | 'deactivation_delete' => false, |
| 55 | 'loading_place' => 'header', |
| 56 | 'enable_custom_events' => false, |
| 57 | 'custom_events' => 'ajaxComplete' |
| 58 | ), |
| 59 | 'configuration' => array( |
| 60 | 'prettyphoto' => array( |
| 61 | 'animation_speed' => 'normal', |
| 62 | 'slideshow' => false, |
| 63 | 'slideshow_delay' => 5000, |
| 64 | 'slideshow_autoplay' => false, |
| 65 | 'opacity' => 75, |
| 66 | 'show_title' => true, |
| 67 | 'allow_resize' => true, |
| 68 | 'allow_expand' => true, |
| 69 | 'width' => 1080, |
| 70 | 'height' => 720, |
| 71 | 'separator' => '/', |
| 72 | 'theme' => 'pp_default', |
| 73 | 'horizontal_padding' => 20, |
| 74 | 'hide_flash' => false, |
| 75 | 'wmode' => 'opaque', |
| 76 | 'video_autoplay' => false, |
| 77 | 'modal' => false, |
| 78 | 'deeplinking' => false, |
| 79 | 'overlay_gallery' => true, |
| 80 | 'keyboard_shortcuts' => true, |
| 81 | 'social' => false |
| 82 | ), |
| 83 | 'swipebox' => array( |
| 84 | 'animation' => 'css', |
| 85 | 'force_png_icons' => false, |
| 86 | 'hide_close_mobile' => false, |
| 87 | 'hide_bars' => true, |
| 88 | 'hide_bars_delay' => 5000, |
| 89 | 'video_max_width' => 1080, |
| 90 | 'loop_at_end' => false |
| 91 | ), |
| 92 | 'fancybox' => array( |
| 93 | 'modal' => false, |
| 94 | 'show_overlay' => true, |
| 95 | 'show_close_button' => true, |
| 96 | 'enable_escape_button' => true, |
| 97 | 'hide_on_overlay_click' => true, |
| 98 | 'hide_on_content_click' => false, |
| 99 | 'cyclic' => false, |
| 100 | 'show_nav_arrows' => true, |
| 101 | 'auto_scale' => true, |
| 102 | 'scrolling' => 'yes', |
| 103 | 'center_on_scroll' => true, |
| 104 | 'opacity' => true, |
| 105 | 'overlay_opacity' => 70, |
| 106 | 'overlay_color' => '#666', |
| 107 | 'title_show' => true, |
| 108 | 'title_position' => 'outside', |
| 109 | 'transitions' => 'fade', |
| 110 | 'easings' => 'swing', |
| 111 | 'speeds' => 300, |
| 112 | 'change_speed' => 300, |
| 113 | 'change_fade' => 100, |
| 114 | 'padding' => 5, |
| 115 | 'margin' => 5, |
| 116 | 'video_width' => 1080, |
| 117 | 'video_height' => 720 |
| 118 | ), |
| 119 | 'nivo' => array( |
| 120 | 'effect' => 'fade', |
| 121 | 'click_overlay_to_close' => true, |
| 122 | 'keyboard_nav' => true, |
| 123 | 'error_message' => 'The requested content cannot be loaded. Please try again later.' |
| 124 | ), |
| 125 | 'imagelightbox' => array( |
| 126 | 'animation_speed' => 250, |
| 127 | 'preload_next' => true, |
| 128 | 'enable_keyboard' => true, |
| 129 | 'quit_on_end' => false, |
| 130 | 'quit_on_image_click' => false, |
| 131 | 'quit_on_document_click' => true |
| 132 | ), |
| 133 | 'tosrus' => array( |
| 134 | 'effect' => 'slide', |
| 135 | 'infinite' => true, |
| 136 | 'keys' => false, |
| 137 | 'autoplay' => true, |
| 138 | 'pause_on_hover' => false, |
| 139 | 'timeout' => 4000, |
| 140 | 'pagination' => true, |
| 141 | 'pagination_type' => 'thumbnails' |
| 142 | ) |
| 143 | ), |
| 144 | 'version' => '1.5.2' |
| 145 | ); |
| 146 | public $options = array(); |
| 147 | private static $_instance; |
| 148 | |
| 149 | private function __clone() {} |
| 150 | |
| 151 | private function __wakeup() {} |
| 152 | |
| 153 | /** |
| 154 | * Main Responsive Lightbox instance. |
| 155 | */ |
| 156 | public static function instance() { |
| 157 | if ( self::$_instance === null ) { |
| 158 | self::$_instance = new self(); |
| 159 | } |
| 160 | return self::$_instance; |
| 161 | } |
| 162 | |
| 163 | public function __construct() { |
| 164 | register_activation_hook( __FILE__, array( &$this, 'activate_multisite' ) ); |
| 165 | register_deactivation_hook( __FILE__, array( &$this, 'deactivate_multisite' ) ); |
| 166 | |
| 167 | // change from older versions |
| 168 | $db_version = get_option( 'responsive_lightbox_version' ); |
| 169 | |
| 170 | if ( version_compare( ($db_version === false ? '1.0.0' : $db_version ), '1.0.5', '<' ) ) { |
| 171 | if ( ($array = get_option( 'rl_settings' )) !== false ) { |
| 172 | update_option( 'responsive_lightbox_settings', $array ); |
| 173 | delete_option( 'rl_settings' ); |
| 174 | } |
| 175 | |
| 176 | if ( ($array = get_option( 'rl_configuration' )) !== false ) { |
| 177 | update_option( 'responsive_lightbox_configuration', $array ); |
| 178 | delete_option( 'rl_configuration' ); |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | // update plugin version |
| 183 | update_option( 'responsive_lightbox_version', $this->defaults['version'], '', 'no' ); |
| 184 | |
| 185 | $this->options['settings'] = array_merge( $this->defaults['settings'], (($array = get_option( 'responsive_lightbox_settings' )) === false ? array() : $array ) ); |
| 186 | |
| 187 | // for multi arrays we have to merge them separately |
| 188 | $db_conf_opts = ( ( $base = get_option( 'responsive_lightbox_configuration' ) ) === false ? array() : $base ); |
| 189 | |
| 190 | foreach ( $this->defaults['configuration'] as $script => $settings ) { |
| 191 | $this->options['configuration'][$script] = array_merge( $settings, (isset( $db_conf_opts[$script] ) ? $db_conf_opts[$script] : array() ) ); |
| 192 | } |
| 193 | |
| 194 | // actions |
| 195 | add_action( 'plugins_loaded', array( &$this, 'load_textdomain' ) ); |
| 196 | add_action( 'wp_enqueue_scripts', array( &$this, 'front_scripts_styles' ) ); |
| 197 | add_action( 'admin_enqueue_scripts', array( &$this, 'admin_scripts_styles' ) ); |
| 198 | |
| 199 | // filters |
| 200 | add_filter( 'plugin_action_links', array( &$this, 'plugin_settings_link' ), 10, 2 ); |
| 201 | } |
| 202 | |
| 203 | public function activate_single() { |
| 204 | add_option( 'responsive_lightbox_settings', $this->defaults['settings'], '', 'no' ); |
| 205 | add_option( 'responsive_lightbox_configuration', $this->defaults['configuration'], '', 'no' ); |
| 206 | add_option( 'responsive_lightbox_version', $this->defaults['version'], '', 'no' ); |
| 207 | } |
| 208 | |
| 209 | public function deactivate_single( $multi = false ) { |
| 210 | if ( $multi === true ) { |
| 211 | $options = get_option( 'responsive_lightbox_settings' ); |
| 212 | $check = $options['deactivation_delete']; |
| 213 | } else |
| 214 | $check = $this->options['settings']['deactivation_delete']; |
| 215 | |
| 216 | if ( $check === true ) { |
| 217 | delete_option( 'responsive_lightbox_settings' ); |
| 218 | delete_option( 'responsive_lightbox_configuration' ); |
| 219 | delete_option( 'responsive_lightbox_version' ); |
| 220 | } |
| 221 | } |
| 222 | |
| 223 | public function activate_multisite( $networkwide ) { |
| 224 | if ( is_multisite() && $networkwide ) { |
| 225 | global $wpdb; |
| 226 | |
| 227 | $activated_blogs = array(); |
| 228 | $current_blog_id = $wpdb->blogid; |
| 229 | $blogs_ids = $wpdb->get_col( $wpdb->prepare( 'SELECT blog_id FROM ' . $wpdb->blogs, '' ) ); |
| 230 | |
| 231 | foreach ( $blogs_ids as $blog_id ) { |
| 232 | switch_to_blog( $blog_id ); |
| 233 | $this->activate_single(); |
| 234 | $activated_blogs[] = (int) $blog_id; |
| 235 | } |
| 236 | |
| 237 | switch_to_blog( $current_blog_id ); |
| 238 | update_site_option( 'responsive_lightbox_activated_blogs', $activated_blogs, array() ); |
| 239 | } else |
| 240 | $this->activate_single(); |
| 241 | } |
| 242 | |
| 243 | public function deactivate_multisite( $networkwide ) { |
| 244 | if ( is_multisite() && $networkwide ) { |
| 245 | global $wpdb; |
| 246 | |
| 247 | $current_blog_id = $wpdb->blogid; |
| 248 | $blogs_ids = $wpdb->get_col( $wpdb->prepare( 'SELECT blog_id FROM ' . $wpdb->blogs, '' ) ); |
| 249 | |
| 250 | if ( ($activated_blogs = get_site_option( 'responsive_lightbox_activated_blogs', false, false )) === false ) |
| 251 | $activated_blogs = array(); |
| 252 | |
| 253 | foreach ( $blogs_ids as $blog_id ) { |
| 254 | switch_to_blog( $blog_id ); |
| 255 | $this->deactivate_single( true ); |
| 256 | |
| 257 | if ( in_array( (int) $blog_id, $activated_blogs, true ) ) |
| 258 | unset( $activated_blogs[array_search( $blog_id, $activated_blogs )] ); |
| 259 | } |
| 260 | |
| 261 | switch_to_blog( $current_blog_id ); |
| 262 | update_site_option( 'responsive_lightbox_activated_blogs', $activated_blogs ); |
| 263 | } else |
| 264 | $this->deactivate_single(); |
| 265 | } |
| 266 | |
| 267 | /** |
| 268 | * Load textdomain |
| 269 | */ |
| 270 | public function load_textdomain() { |
| 271 | load_plugin_textdomain( 'responsive-lightbox', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); |
| 272 | } |
| 273 | |
| 274 | /** |
| 275 | * Add links to Support Forum |
| 276 | */ |
| 277 | public function plugin_extend_links( $links, $file ) { |
| 278 | if ( ! current_user_can( 'install_plugins' ) ) |
| 279 | return $links; |
| 280 | |
| 281 | $plugin = plugin_basename( __FILE__ ); |
| 282 | |
| 283 | if ( $file == $plugin ) { |
| 284 | return array_merge( |
| 285 | $links, array( sprintf( '<a href="http://www.dfactory.eu/support/forum/responsive-lightbox/" target="_blank">%s</a>', __( 'Support', 'responsive-lightbox' ) ) ) |
| 286 | ); |
| 287 | } |
| 288 | |
| 289 | return $links; |
| 290 | } |
| 291 | |
| 292 | /** |
| 293 | * Add links to Settings page |
| 294 | */ |
| 295 | public function plugin_settings_link( $links, $file ) { |
| 296 | if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) |
| 297 | return $links; |
| 298 | |
| 299 | static $plugin; |
| 300 | |
| 301 | $plugin = plugin_basename( __FILE__ ); |
| 302 | |
| 303 | if ( $file == $plugin ) { |
| 304 | $settings_link = sprintf( '<a href="%s">%s</a>', admin_url( 'options-general.php' ) . '?page=responsive-lightbox', __( 'Settings', 'responsive-lightbox' ) ); |
| 305 | array_unshift( $links, $settings_link ); |
| 306 | } |
| 307 | |
| 308 | return $links; |
| 309 | } |
| 310 | |
| 311 | /** |
| 312 | * Enqueue admin scripts and styles |
| 313 | */ |
| 314 | public function admin_scripts_styles( $page ) { |
| 315 | if ( $page === 'settings_page_responsive-lightbox' ) { |
| 316 | |
| 317 | wp_register_script( |
| 318 | 'responsive-lightbox-admin', plugins_url( 'js/admin.js', __FILE__ ), array( 'jquery', 'wp-color-picker' ) |
| 319 | ); |
| 320 | wp_enqueue_script( 'responsive-lightbox-admin' ); |
| 321 | |
| 322 | wp_localize_script( |
| 323 | 'responsive-lightbox-admin', 'rlArgs', array( |
| 324 | 'resetSettingsToDefaults' => __( 'Are you sure you want to reset these settings to defaults?', 'responsive-lightbox' ), |
| 325 | 'resetScriptToDefaults' => __( 'Are you sure you want to reset this script settings to defaults?', 'responsive-lightbox' ), |
| 326 | ) |
| 327 | ); |
| 328 | |
| 329 | wp_enqueue_style( 'wp-color-picker' ); |
| 330 | |
| 331 | wp_register_style( |
| 332 | 'responsive-lightbox-admin', plugins_url( 'css/admin.css', __FILE__ ) |
| 333 | ); |
| 334 | wp_enqueue_style( 'responsive-lightbox-admin' ); |
| 335 | } |
| 336 | } |
| 337 | |
| 338 | /** |
| 339 | * Enqueue frontend scripts and styles |
| 340 | */ |
| 341 | public function front_scripts_styles() { |
| 342 | $args = apply_filters( 'rl_lightbox_args', array( |
| 343 | 'script' => $this->options['settings']['script'], |
| 344 | 'selector' => $this->options['settings']['selector'], |
| 345 | 'custom_events' => ($this->options['settings']['enable_custom_events'] === true ? ' ' . $this->options['settings']['custom_events'] : ''), |
| 346 | 'activeGalleries' => $this->get_boolean_value( $this->options['settings']['galleries'] ) |
| 347 | ) ); |
| 348 | |
| 349 | if ( $args['script'] === 'prettyphoto' ) { |
| 350 | |
| 351 | wp_register_script( |
| 352 | 'responsive-lightbox-prettyphoto', plugins_url( 'assets/prettyphoto/js/jquery.prettyPhoto.js', __FILE__ ), array( 'jquery' ), '', ($this->options['settings']['loading_place'] === 'header' ? false : true ) |
| 353 | ); |
| 354 | |
| 355 | wp_enqueue_script( 'responsive-lightbox-prettyphoto' ); |
| 356 | |
| 357 | wp_register_style( |
| 358 | 'responsive-lightbox-prettyphoto', plugins_url( 'assets/prettyphoto/css/prettyPhoto.css', __FILE__ ) |
| 359 | ); |
| 360 | |
| 361 | wp_enqueue_style( 'responsive-lightbox-prettyphoto' ); |
| 362 | |
| 363 | $args = array_merge( |
| 364 | $args, array( |
| 365 | 'animationSpeed' => $this->options['configuration']['prettyphoto']['animation_speed'], |
| 366 | 'slideshow' => $this->get_boolean_value( $this->options['configuration']['prettyphoto']['slideshow'] ), |
| 367 | 'slideshowDelay' => $this->options['configuration']['prettyphoto']['slideshow_delay'], |
| 368 | 'slideshowAutoplay' => $this->get_boolean_value( $this->options['configuration']['prettyphoto']['slideshow_autoplay'] ), |
| 369 | 'opacity' => sprintf( '%.2f', ($this->options['configuration']['prettyphoto']['opacity'] / 100 ) ), |
| 370 | 'showTitle' => $this->get_boolean_value( $this->options['configuration']['prettyphoto']['show_title'] ), |
| 371 | 'allowResize' => $this->get_boolean_value( $this->options['configuration']['prettyphoto']['allow_resize'] ), |
| 372 | 'allowExpand' => $this->get_boolean_value( $this->options['configuration']['prettyphoto']['allow_expand'] ), |
| 373 | 'width' => $this->options['configuration']['prettyphoto']['width'], |
| 374 | 'height' => $this->options['configuration']['prettyphoto']['height'], |
| 375 | 'separator' => $this->options['configuration']['prettyphoto']['separator'], |
| 376 | 'theme' => $this->options['configuration']['prettyphoto']['theme'], |
| 377 | 'horizontalPadding' => $this->options['configuration']['prettyphoto']['horizontal_padding'], |
| 378 | 'hideFlash' => $this->get_boolean_value( $this->options['configuration']['prettyphoto']['hide_flash'] ), |
| 379 | 'wmode' => $this->options['configuration']['prettyphoto']['wmode'], |
| 380 | 'videoAutoplay' => $this->get_boolean_value( $this->options['configuration']['prettyphoto']['video_autoplay'] ), |
| 381 | 'modal' => $this->get_boolean_value( $this->options['configuration']['prettyphoto']['modal'] ), |
| 382 | 'deeplinking' => $this->get_boolean_value( $this->options['configuration']['prettyphoto']['deeplinking'] ), |
| 383 | 'overlayGallery' => $this->get_boolean_value( $this->options['configuration']['prettyphoto']['overlay_gallery'] ), |
| 384 | 'keyboardShortcuts' => $this->get_boolean_value( $this->options['configuration']['prettyphoto']['keyboard_shortcuts'] ), |
| 385 | 'social' => $this->get_boolean_value( $this->options['configuration']['prettyphoto']['social'] ) |
| 386 | ) |
| 387 | ); |
| 388 | |
| 389 | } elseif ( $args['script'] === 'swipebox' ) { |
| 390 | |
| 391 | wp_register_script( |
| 392 | 'responsive-lightbox-swipebox', plugins_url( 'assets/swipebox/js/jquery.swipebox.min.js', __FILE__ ), array( 'jquery' ), '', ($this->options['settings']['loading_place'] === 'header' ? false : true ) |
| 393 | ); |
| 394 | |
| 395 | wp_enqueue_script( 'responsive-lightbox-swipebox' ); |
| 396 | |
| 397 | wp_register_style( |
| 398 | 'responsive-lightbox-swipebox', plugins_url( 'assets/swipebox/css/swipebox.min.css', __FILE__ ) |
| 399 | ); |
| 400 | |
| 401 | wp_enqueue_style( 'responsive-lightbox-swipebox' ); |
| 402 | |
| 403 | $args = array_merge( |
| 404 | $args, array( |
| 405 | 'animation' => $this->get_boolean_value( ($this->options['configuration']['swipebox']['animation'] === 'css' ? true : false ) ), |
| 406 | 'hideCloseButtonOnMobile' => $this->get_boolean_value( $this->options['configuration']['swipebox']['hide_close_mobile'] ), |
| 407 | 'hideBars' => $this->get_boolean_value( $this->options['configuration']['swipebox']['hide_bars'] ), |
| 408 | 'hideBarsDelay' => $this->options['configuration']['swipebox']['hide_bars_delay'], |
| 409 | 'videoMaxWidth' => $this->options['configuration']['swipebox']['video_max_width'], |
| 410 | 'useSVG' => ! $this->options['configuration']['swipebox']['force_png_icons'], |
| 411 | 'loopAtEnd' => $this->get_boolean_value( $this->options['configuration']['swipebox']['loop_at_end'] ) |
| 412 | ) |
| 413 | ); |
| 414 | |
| 415 | } elseif ( $args['script'] === 'fancybox' ) { |
| 416 | |
| 417 | wp_register_script( |
| 418 | 'responsive-lightbox-fancybox', plugins_url( 'assets/fancybox/jquery.fancybox-1.3.4.js', __FILE__ ), array( 'jquery' ), '', ($this->options['settings']['loading_place'] === 'header' ? false : true ) |
| 419 | ); |
| 420 | |
| 421 | wp_enqueue_script( 'responsive-lightbox-fancybox' ); |
| 422 | |
| 423 | wp_register_style( |
| 424 | 'responsive-lightbox-fancybox', plugins_url( 'assets/fancybox/jquery.fancybox-1.3.4.css', __FILE__ ) |
| 425 | ); |
| 426 | |
| 427 | wp_enqueue_style( 'responsive-lightbox-fancybox' ); |
| 428 | |
| 429 | $args = array_merge( |
| 430 | $args, array( |
| 431 | 'modal' => $this->get_boolean_value( $this->options['configuration']['fancybox']['modal'] ), |
| 432 | 'showOverlay' => $this->get_boolean_value( $this->options['configuration']['fancybox']['show_overlay'] ), |
| 433 | 'showCloseButton' => $this->get_boolean_value( $this->options['configuration']['fancybox']['show_close_button'] ), |
| 434 | 'enableEscapeButton' => $this->get_boolean_value( $this->options['configuration']['fancybox']['enable_escape_button'] ), |
| 435 | 'hideOnOverlayClick' => $this->get_boolean_value( $this->options['configuration']['fancybox']['hide_on_overlay_click'] ), |
| 436 | 'hideOnContentClick' => $this->get_boolean_value( $this->options['configuration']['fancybox']['hide_on_content_click'] ), |
| 437 | 'cyclic' => $this->get_boolean_value( $this->options['configuration']['fancybox']['cyclic'] ), |
| 438 | 'showNavArrows' => $this->get_boolean_value( $this->options['configuration']['fancybox']['show_nav_arrows'] ), |
| 439 | 'autoScale' => $this->get_boolean_value( $this->options['configuration']['fancybox']['auto_scale'] ), |
| 440 | 'scrolling' => $this->options['configuration']['fancybox']['scrolling'], |
| 441 | 'centerOnScroll' => $this->get_boolean_value( $this->options['configuration']['fancybox']['center_on_scroll'] ), |
| 442 | 'opacity' => $this->get_boolean_value( $this->options['configuration']['fancybox']['opacity'] ), |
| 443 | 'overlayOpacity' => $this->options['configuration']['fancybox']['overlay_opacity'], |
| 444 | 'overlayColor' => $this->options['configuration']['fancybox']['overlay_color'], |
| 445 | 'titleShow' => $this->get_boolean_value( $this->options['configuration']['fancybox']['title_show'] ), |
| 446 | 'titlePosition' => $this->options['configuration']['fancybox']['title_position'], |
| 447 | 'transitions' => $this->options['configuration']['fancybox']['transitions'], |
| 448 | 'easings' => $this->options['configuration']['fancybox']['easings'], |
| 449 | 'speeds' => $this->options['configuration']['fancybox']['speeds'], |
| 450 | 'changeSpeed' => $this->options['configuration']['fancybox']['change_speed'], |
| 451 | 'changeFade' => $this->options['configuration']['fancybox']['change_fade'], |
| 452 | 'padding' => $this->options['configuration']['fancybox']['padding'], |
| 453 | 'margin' => $this->options['configuration']['fancybox']['margin'], |
| 454 | 'videoWidth' => $this->options['configuration']['fancybox']['video_width'], |
| 455 | 'videoHeight' => $this->options['configuration']['fancybox']['video_height'] |
| 456 | ) |
| 457 | ); |
| 458 | |
| 459 | } elseif ( $args['script'] === 'nivo' ) { |
| 460 | |
| 461 | wp_register_script( |
| 462 | 'responsive-lightbox-nivo', plugins_url( 'assets/nivo/nivo-lightbox.min.js', __FILE__ ), array( 'jquery' ), '', ($this->options['settings']['loading_place'] === 'header' ? false : true ) |
| 463 | ); |
| 464 | |
| 465 | wp_enqueue_script( 'responsive-lightbox-nivo' ); |
| 466 | |
| 467 | wp_register_style( |
| 468 | 'responsive-lightbox-nivo', plugins_url( 'assets/nivo/nivo-lightbox.css', __FILE__ ) |
| 469 | ); |
| 470 | |
| 471 | wp_enqueue_style( 'responsive-lightbox-nivo' ); |
| 472 | |
| 473 | wp_register_style( |
| 474 | 'responsive-lightbox-nivo', plugins_url( 'assets/nivo/themes/default/default.css', __FILE__ ) |
| 475 | ); |
| 476 | |
| 477 | wp_enqueue_style( 'responsive-lightbox-nivo' ); |
| 478 | |
| 479 | $args = array_merge( |
| 480 | $args, array( |
| 481 | 'effect' => $this->options['configuration']['nivo']['effect'], |
| 482 | 'clickOverlayToClose' => $this->get_boolean_value( $this->options['configuration']['nivo']['click_overlay_to_close'] ), |
| 483 | 'keyboardNav' => $this->get_boolean_value( $this->options['configuration']['nivo']['keyboard_nav'] ), |
| 484 | 'errorMessage' => esc_attr( $this->options['configuration']['nivo']['error_message'] ) |
| 485 | ) |
| 486 | ); |
| 487 | |
| 488 | } elseif ( $args['script'] === 'imagelightbox' ) { |
| 489 | |
| 490 | wp_register_script( |
| 491 | 'responsive-lightbox-imagelightbox', plugins_url( 'assets/imagelightbox/js/imagelightbox.min.js', __FILE__ ), array( 'jquery' ), '', ($this->options['settings']['loading_place'] === 'header' ? false : true ) |
| 492 | ); |
| 493 | wp_enqueue_script( 'responsive-lightbox-imagelightbox' ); |
| 494 | |
| 495 | wp_register_style( |
| 496 | 'responsive-lightbox-imagelightbox', plugins_url( 'assets/imagelightbox/css/imagelightbox.css', __FILE__ ) |
| 497 | ); |
| 498 | wp_enqueue_style( 'responsive-lightbox-imagelightbox' ); |
| 499 | |
| 500 | $args = array_merge( |
| 501 | $args, array( |
| 502 | 'animationSpeed' => $this->options['configuration']['imagelightbox']['animation_speed'], |
| 503 | 'preloadNext' => $this->get_boolean_value( $this->options['configuration']['imagelightbox']['preload_next'] ), |
| 504 | 'enableKeyboard' => $this->get_boolean_value( $this->options['configuration']['imagelightbox']['enable_keyboard'] ), |
| 505 | 'quitOnEnd' => $this->get_boolean_value( $this->options['configuration']['imagelightbox']['quit_on_end'] ), |
| 506 | 'quitOnImageClick' => $this->get_boolean_value( $this->options['configuration']['imagelightbox']['quit_on_image_click'] ), |
| 507 | 'quitOnDocumentClick' => $this->get_boolean_value( $this->options['configuration']['imagelightbox']['quit_on_document_click'] ), |
| 508 | ) |
| 509 | ); |
| 510 | |
| 511 | } elseif ( $args['script'] === 'tosrus' ) { |
| 512 | |
| 513 | wp_register_script( |
| 514 | 'responsive-lightbox-tosrus', plugins_url( 'assets/tosrus/js/jquery.tosrus.min.all.js', __FILE__ ), array( 'jquery' ), '', ($this->options['settings']['loading_place'] === 'header' ? false : true ) |
| 515 | ); |
| 516 | wp_enqueue_script( 'responsive-lightbox-tosrus' ); |
| 517 | |
| 518 | wp_register_style( |
| 519 | 'responsive-lightbox-tosrus', plugins_url( 'assets/tosrus/css/jquery.tosrus.all.min.css', __FILE__ ) |
| 520 | ); |
| 521 | wp_enqueue_style( 'responsive-lightbox-tosrus' ); |
| 522 | |
| 523 | $args = array_merge( |
| 524 | $args, array( |
| 525 | 'effect' => $this->options['configuration']['tosrus']['effect'], |
| 526 | 'infinite' => $this->get_boolean_value( $this->options['configuration']['tosrus']['infinite'] ), |
| 527 | 'keys' => $this->get_boolean_value( $this->options['configuration']['tosrus']['keys'] ), |
| 528 | 'autoplay' => $this->get_boolean_value( $this->options['configuration']['tosrus']['autoplay'] ), |
| 529 | 'pause_on_hover' => $this->get_boolean_value( $this->options['configuration']['tosrus']['pause_on_hover'] ), |
| 530 | 'timeout' => $this->options['configuration']['tosrus']['timeout'], |
| 531 | 'pagination' => $this->get_boolean_value( $this->options['configuration']['tosrus']['pagination'] ), |
| 532 | 'pagination_type' => $this->options['configuration']['tosrus']['pagination_type'] |
| 533 | ) |
| 534 | ); |
| 535 | } |
| 536 | |
| 537 | wp_register_script( |
| 538 | 'responsive-lightbox-front', plugins_url( 'js/front.js', __FILE__ ), array( 'jquery' ), '', ($this->options['settings']['loading_place'] === 'header' ? false : true ) |
| 539 | ); |
| 540 | |
| 541 | wp_enqueue_script( 'responsive-lightbox-front' ); |
| 542 | |
| 543 | wp_add_inline_style( |
| 544 | 'responsive-lightbox-swipebox', '#swipebox-action #swipebox-close, #swipebox-action #swipebox-prev, #swipebox-action #swipebox-next { background-image: url(\'assets/swipebox/source/img/icons.png\') !important; }' |
| 545 | ); |
| 546 | |
| 547 | wp_localize_script( |
| 548 | 'responsive-lightbox-front', 'rlArgs', $args |
| 549 | ); |
| 550 | } |
| 551 | |
| 552 | /** |
| 553 | * Helper: convert value to boolean |
| 554 | */ |
| 555 | private function get_boolean_value( $option ) { |
| 556 | return ( $option == true ? 1 : 0 ); |
| 557 | } |
| 558 | |
| 559 | } |
| 560 | |
| 561 | /** |
| 562 | * Initialise Responsive Lightbox. |
| 563 | */ |
| 564 | function Responsive_Lightbox() { |
| 565 | static $instance; |
| 566 | |
| 567 | // first call to instance() initializes the plugin |
| 568 | if ( $instance === null || ! ($instance instanceof Responsive_Lightbox) ) { |
| 569 | $instance = Responsive_Lightbox::instance(); |
| 570 | } |
| 571 | |
| 572 | return $instance; |
| 573 | } |
| 574 | |
| 575 | $responsive_lightbox = Responsive_Lightbox(); |