responsive-lightbox
Last commit date
assets
12 years ago
css
12 years ago
images
12 years ago
js
12 years ago
languages
12 years ago
index.php
12 years ago
readme.txt
12 years ago
responsive-lightbox.php
12 years ago
responsive-lightbox.php
1028 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 (overaly) effect optimized for mobile devices. |
| 5 | Version: 1.0.0 |
| 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 | |
| 12 | Responsive Lightbox |
| 13 | Copyright (C) 2013, Digital Factory - info@digitalfactory.pl |
| 14 | |
| 15 | 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: |
| 16 | |
| 17 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. |
| 18 | |
| 19 | 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. |
| 20 | */ |
| 21 | |
| 22 | |
| 23 | class Responsive_Lightbox |
| 24 | { |
| 25 | private $defaults = array( |
| 26 | 'settings' => array( |
| 27 | 'script' => 'swipebox', |
| 28 | 'selector' => 'lightbox', |
| 29 | 'galleries' => TRUE, |
| 30 | 'image_links' => TRUE, |
| 31 | 'deactivation_delete' => FALSE |
| 32 | ), |
| 33 | 'configuration' => array( |
| 34 | 'prettyphoto' => array( |
| 35 | 'animation_speed' => 'normal', |
| 36 | 'slideshow' => FALSE, |
| 37 | 'slideshow_delay' => 5000, |
| 38 | 'slideshow_autoplay' => FALSE, |
| 39 | 'opacity' => 75, |
| 40 | 'show_title' => TRUE, |
| 41 | 'allow_resize' => TRUE, |
| 42 | 'width' => 600, |
| 43 | 'height' => 360, |
| 44 | 'separator' => '/', |
| 45 | 'theme' => 'pp_default', |
| 46 | 'horizontal_padding' => 20, |
| 47 | 'hide_flash' => FALSE, |
| 48 | 'wmode' => 'opaque', |
| 49 | 'video_autoplay' => FALSE, |
| 50 | 'modal' => FALSE, |
| 51 | 'deeplinking' => FALSE, |
| 52 | 'overlay_gallery' => TRUE, |
| 53 | 'keyboard_shortcuts' => TRUE, |
| 54 | 'social' => FALSE |
| 55 | ), |
| 56 | 'swipebox' => array( |
| 57 | 'animation' => 'css', |
| 58 | 'hide_bars' => TRUE, |
| 59 | 'hide_bars_delay' => 5000 |
| 60 | ) |
| 61 | ) |
| 62 | ); |
| 63 | private $scripts = array(); |
| 64 | private $options = array(); |
| 65 | private $selectors = array(); |
| 66 | private $tabs = array(); |
| 67 | private $galleries = array(); |
| 68 | private $gallery_no = 0; |
| 69 | |
| 70 | |
| 71 | public function __construct() |
| 72 | { |
| 73 | register_activation_hook(__FILE__, array(&$this, 'activation')); |
| 74 | register_deactivation_hook(__FILE__, array(&$this, 'deactivation')); |
| 75 | |
| 76 | $this->options = array_merge(array('settings' => get_option('rl_settings')), array('configuration' => get_option('rl_configuration'))); |
| 77 | |
| 78 | //actions |
| 79 | add_action('plugins_loaded', array(&$this, 'load_textdomain')); |
| 80 | add_action('plugins_loaded', array(&$this, 'load_defaults')); |
| 81 | add_action('admin_init', array(&$this, 'register_settings')); |
| 82 | add_action('admin_menu', array(&$this, 'admin_menu_options')); |
| 83 | add_action('wp_enqueue_scripts', array(&$this, 'front_comments_scripts_styles')); |
| 84 | add_action('admin_enqueue_scripts', array(&$this, 'admin_comments_scripts_styles')); |
| 85 | |
| 86 | //filters |
| 87 | add_filter('plugin_action_links', array(&$this, 'plugin_settings_link'), 10, 2); |
| 88 | add_filter('plugin_row_meta', array(&$this, 'plugin_extend_links'), 10, 2); |
| 89 | add_filter('post_gallery', array(&$this, 'gallery_attributes'), 1000); |
| 90 | |
| 91 | if($this->options['settings']['galleries'] === TRUE) |
| 92 | { |
| 93 | add_filter('wp_get_attachment_link', array(&$this, 'add_gallery_lightbox_selector'), 1000, 6); |
| 94 | } |
| 95 | |
| 96 | if($this->options['settings']['image_links'] === TRUE) |
| 97 | { |
| 98 | add_filter('image_send_to_editor', array(&$this, 'add_links_lightbox_selector'), 1000); |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | |
| 103 | public function gallery_attributes($style) |
| 104 | { |
| 105 | ++$this->gallery_no; |
| 106 | |
| 107 | return $style; |
| 108 | } |
| 109 | |
| 110 | |
| 111 | public function add_gallery_lightbox_selector($link, $id, $size, $permalink, $icon, $text) |
| 112 | { |
| 113 | $link = (preg_match('/<a.*? rel=("|\').*?("|\')>/', $link) === 1 ? preg_replace('/(<a.*? rel=(?:"|\').*?)((?:"|\').*?>)/', '$1 '.$this->options['settings']['selector'].'[gallery-'.$this->gallery_no.']'.'$2', $link) : preg_replace('/(<a.*?)>/', '$1 rel="'.$this->options['settings']['selector'].'[gallery-'.$this->gallery_no.']'.'">', $link)); |
| 114 | |
| 115 | return (preg_match('/<a.*? href=("|\').*?("|\')>/', $link) === 1 ? preg_replace('/(<a.*? href=(?:"|\')).*?((?:"|\').*?>)/', '$1'.wp_get_attachment_url($id).'$2', $link) : preg_replace('/(<a.*?)>/', '$1 href="'.wp_get_attachment_url($id).'">', $link)); |
| 116 | } |
| 117 | |
| 118 | |
| 119 | public function add_links_lightbox_selector($link) |
| 120 | { |
| 121 | return (preg_match('/<a.*? rel=".*?">/', $link) === 1 ? preg_replace('/(<a.*? rel=".*?)(".*?>)/', '$1 '.$this->options['settings']['selector'].'$2', $link) : preg_replace('/(<a.*?)>/', '$1 rel="'.$this->options['settings']['selector'].'">', $link)); |
| 122 | } |
| 123 | |
| 124 | |
| 125 | public function load_defaults() |
| 126 | { |
| 127 | $this->scripts = array( |
| 128 | 'prettyphoto' => array( |
| 129 | 'name' => __('prettyPhoto', 'responsive-lightbox'), |
| 130 | 'animation_speeds' => array( |
| 131 | 'slow' => __('slow', 'responsive-lightbox'), |
| 132 | 'normal' => __('normal', 'responsive-lightbox'), |
| 133 | 'fast' => __('fast', 'responsive-lightbox') |
| 134 | ), |
| 135 | 'themes' => array( |
| 136 | 'pp_default' => __('default', 'responsive-lightbox'), |
| 137 | 'light_rounded' => __('light rounded', 'responsive-lightbox'), |
| 138 | 'dark_rounded' => __('dark rounded', 'responsive-lightbox'), |
| 139 | 'light_square' => __('light square', 'responsive-lightbox'), |
| 140 | 'dark_square' => __('dark square', 'responsive-lightbox'), |
| 141 | 'facebook' => __('facebook', 'responsive-lightbox') |
| 142 | ), |
| 143 | 'wmodes' => array( |
| 144 | 'window' => __('window', 'responsive-lightbox'), |
| 145 | 'transparent' => __('transparent', 'responsive-lightbox'), |
| 146 | 'opaque' => __('opaque', 'responsive-lightbox'), |
| 147 | 'direct' => __('direct', 'responsive-lightbox'), |
| 148 | 'gpu' => __('gpu', 'responsive-lightbox') |
| 149 | ) |
| 150 | |
| 151 | ), |
| 152 | 'swipebox' => array( |
| 153 | 'name' => __('SwipeBox', 'responsive-lightbox'), |
| 154 | 'animations' => array( |
| 155 | 'css' => __('CSS', 'responsive-lightbox'), |
| 156 | 'jquery' => __('jQuery', 'responsive-lightbox') |
| 157 | ) |
| 158 | ) |
| 159 | ); |
| 160 | |
| 161 | $this->selectors = array( |
| 162 | 'rel' => __('rel', 'responsive-lightbox'), |
| 163 | 'class' => __('class', 'responsive-lightbox') |
| 164 | ); |
| 165 | |
| 166 | $this->choices = array( |
| 167 | 'yes' => __('Enable', 'responsive-lightbox'), |
| 168 | 'no' => __('Disable', 'responsive-lightbox') |
| 169 | ); |
| 170 | |
| 171 | $this->tabs = array( |
| 172 | 'general-settings' => array( |
| 173 | 'name' => __('General settings', 'responsive-lightbox'), |
| 174 | 'key' => 'rl_settings', |
| 175 | 'submit' => 'save_rl_settings' |
| 176 | ), |
| 177 | 'configuration' => array( |
| 178 | 'name' => __('Lightbox settings', 'responsive-lightbox'), |
| 179 | 'key' => 'rl_configuration', |
| 180 | 'submit' => 'save_rl_configuration', |
| 181 | 'reset' => 'reset_rl_configuration' |
| 182 | ) |
| 183 | ); |
| 184 | } |
| 185 | |
| 186 | |
| 187 | public function activation() |
| 188 | { |
| 189 | add_option('rl_settings', $this->defaults['settings'], '', 'no'); |
| 190 | add_option('rl_configuration', $this->defaults['configuration'], '', 'no'); |
| 191 | } |
| 192 | |
| 193 | |
| 194 | public function deactivation() |
| 195 | { |
| 196 | if($this->options['settings']['deactivation_delete'] === TRUE) |
| 197 | { |
| 198 | delete_option('rl_settings'); |
| 199 | delete_option('rl_configuration'); |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | |
| 204 | public function register_settings() |
| 205 | { |
| 206 | register_setting('rl_settings', 'rl_settings', array(&$this, 'validate_options')); |
| 207 | |
| 208 | //general settings |
| 209 | add_settings_section('rl_settings', __('General settings', 'responsive-lightbox'), '', 'rl_settings'); |
| 210 | add_settings_field('rl_script', __('Lightbox script', 'responsive-lightbox'), array(&$this, 'rl_script'), 'rl_settings', 'rl_settings'); |
| 211 | add_settings_field('rl_selector', __('Selector', 'responsive-lightbox'), array(&$this, 'rl_selector'), 'rl_settings', 'rl_settings'); |
| 212 | add_settings_field('rl_galleries', __('Galleries', 'responsive-lightbox'), array(&$this, 'rl_galleries'), 'rl_settings', 'rl_settings'); |
| 213 | add_settings_field('rl_image_links', __('Image links', 'responsive-lightbox'), array(&$this, 'rl_image_links'), 'rl_settings', 'rl_settings'); |
| 214 | add_settings_field('rl_deactivation_delete', __('Deactivation', 'responsive-lightbox'), array(&$this, 'rl_deactivation_delete'), 'rl_settings', 'rl_settings'); |
| 215 | |
| 216 | //configuration |
| 217 | register_setting('rl_configuration', 'rl_configuration', array(&$this, 'validate_options')); |
| 218 | add_settings_section('rl_configuration', __('Lightbox settings', 'responsive-lightbox').': '.$this->scripts[$this->options['settings']['script']]['name'], '', 'rl_configuration'); |
| 219 | |
| 220 | if($this->options['settings']['script'] === 'swipebox') |
| 221 | { |
| 222 | add_settings_field('rl_sw_animation', __('Animation type', 'responsive-lightbox'), array(&$this, 'rl_sw_animation'), 'rl_configuration', 'rl_configuration'); |
| 223 | add_settings_field('rl_sw_hide_bars', __('Top and bottom bars', 'responsive-lightbox'), array(&$this, 'rl_sw_hide_bars'), 'rl_configuration', 'rl_configuration'); |
| 224 | } |
| 225 | elseif($this->options['settings']['script'] === 'prettyphoto') |
| 226 | { |
| 227 | add_settings_field('rl_pp_animation_speed', __('Animation speed', 'responsive-lightbox'), array(&$this, 'rl_pp_animation_speed'), 'rl_configuration', 'rl_configuration'); |
| 228 | add_settings_field('rl_pp_slideshow', __('Slideshow', 'responsive-lightbox'), array(&$this, 'rl_pp_slideshow'), 'rl_configuration', 'rl_configuration'); |
| 229 | add_settings_field('rl_pp_slideshow_autoplay', __('Slideshow autoplay', 'responsive-lightbox'), array(&$this, 'rl_pp_slideshow_autoplay'), 'rl_configuration', 'rl_configuration'); |
| 230 | add_settings_field('rl_pp_opacity', __('Opacity', 'responsive-lightbox'), array(&$this, 'rl_pp_opacity'), 'rl_configuration', 'rl_configuration'); |
| 231 | add_settings_field('rl_pp_title', __('Show title', 'responsive-lightbox'), array(&$this, 'rl_pp_title'), 'rl_configuration', 'rl_configuration'); |
| 232 | add_settings_field('rl_pp_allow_resize', __('Allow resize big images', 'responsive-lightbox'), array(&$this, 'rl_pp_allow_resize'), 'rl_configuration', 'rl_configuration'); |
| 233 | add_settings_field('rl_pp_width', __('Width', 'responsive-lightbox'), array(&$this, 'rl_pp_width'), 'rl_configuration', 'rl_configuration'); |
| 234 | add_settings_field('rl_pp_height', __('Height', 'responsive-lightbox'), array(&$this, 'rl_pp_height'), 'rl_configuration', 'rl_configuration'); |
| 235 | add_settings_field('rl_pp_theme', __('Theme', 'responsive-lightbox'), array(&$this, 'rl_pp_theme'), 'rl_configuration', 'rl_configuration'); |
| 236 | add_settings_field('rl_pp_horizontal_padding', __('Horizontal padding', 'responsive-lightbox'), array(&$this, 'rl_pp_horizontal_padding'), 'rl_configuration', 'rl_configuration'); |
| 237 | add_settings_field('rl_pp_hide_flash', __('Hide Flash', 'responsive-lightbox'), array(&$this, 'rl_pp_hide_flash'), 'rl_configuration', 'rl_configuration'); |
| 238 | add_settings_field('rl_pp_wmode', __('Flash Window Mode (wmode)', 'responsive-lightbox'), array(&$this, 'rl_pp_wmode'), 'rl_configuration', 'rl_configuration'); |
| 239 | add_settings_field('rl_pp_video_autoplay', __('Video autoplay', 'responsive-lightbox'), array(&$this, 'rl_pp_video_autoplay'), 'rl_configuration', 'rl_configuration'); |
| 240 | add_settings_field('rl_pp_modal', __('Modal', 'responsive-lightbox'), array(&$this, 'rl_pp_modal'), 'rl_configuration', 'rl_configuration'); |
| 241 | add_settings_field('rl_pp_deeplinking', __('Deeplinking', 'responsive-lightbox'), array(&$this, 'rl_pp_deeplinking'), 'rl_configuration', 'rl_configuration'); |
| 242 | add_settings_field('rl_pp_overlay_gallery', __('Overlay gallery', 'responsive-lightbox'), array(&$this, 'rl_pp_overlay_gallery'), 'rl_configuration', 'rl_configuration'); |
| 243 | add_settings_field('rl_pp_keyboard_shortcuts', __('Keyboard shortcuts', 'responsive-lightbox'), array(&$this, 'rl_pp_keyboard_shortcuts'), 'rl_configuration', 'rl_configuration'); |
| 244 | add_settings_field('rl_pp_social', __('Social (Twitter, Facebook)', 'responsive-lightbox'), array(&$this, 'rl_pp_social'), 'rl_configuration', 'rl_configuration'); |
| 245 | } |
| 246 | } |
| 247 | |
| 248 | |
| 249 | public function rl_script() |
| 250 | { |
| 251 | echo ' |
| 252 | <div id="rl_script">'; |
| 253 | |
| 254 | foreach($this->scripts as $val => $trans) |
| 255 | { |
| 256 | echo ' |
| 257 | <input id="rl-script-'.$val.'" type="radio" name="rl_settings[script]" value="'.$val.'" '.checked($val, $this->options['settings']['script'], FALSE).' /> |
| 258 | <label for="rl-script-'.$val.'">'.$trans['name'].'</label>'; |
| 259 | } |
| 260 | |
| 261 | echo ' |
| 262 | <p class="description">'.__('Select your preffered ligthbox effect script.', 'responsive-lightbox').'</p> |
| 263 | </div>'; |
| 264 | } |
| 265 | |
| 266 | |
| 267 | public function rl_selector() |
| 268 | { |
| 269 | echo ' |
| 270 | <div id="rl_selector"> |
| 271 | <input type="text" value="'.$this->options['settings']['selector'].'" name="rl_settings[selector]" /> |
| 272 | <p class="description">'.__('Select to which rel selector lightbox effect will be applied to.', 'responsive-lightbox').'</p> |
| 273 | </div>'; |
| 274 | } |
| 275 | |
| 276 | |
| 277 | public function rl_galleries() |
| 278 | { |
| 279 | echo ' |
| 280 | <div id="rl_galleries">'; |
| 281 | |
| 282 | foreach($this->choices as $val => $trans) |
| 283 | { |
| 284 | echo ' |
| 285 | <input id="rl-galleries-'.$val.'" type="radio" name="rl_settings[galleries]" value="'.$val.'" '.checked(($val === 'yes' ? TRUE : FALSE), $this->options['settings']['galleries'], FALSE).' /> |
| 286 | <label for="rl-galleries-'.$val.'">'.$trans.'</label>'; |
| 287 | } |
| 288 | |
| 289 | echo ' |
| 290 | <p class="description">'.__('Add lightbox to WordPress image galleries by default', 'responsive-lightbox').'</p> |
| 291 | </div>'; |
| 292 | } |
| 293 | |
| 294 | |
| 295 | public function rl_image_links() |
| 296 | { |
| 297 | echo ' |
| 298 | <div id="rl_image_links">'; |
| 299 | |
| 300 | foreach($this->choices as $val => $trans) |
| 301 | { |
| 302 | echo ' |
| 303 | <input id="rl-image-links-'.$val.'" type="radio" name="rl_settings[image_links]" value="'.$val.'" '.checked(($val === 'yes' ? TRUE : FALSE), $this->options['settings']['image_links'], FALSE).' /> |
| 304 | <label for="rl-image-links-'.$val.'">'.$trans.'</label>'; |
| 305 | } |
| 306 | |
| 307 | echo ' |
| 308 | <p class="description">'.__('Add lightbox to WordPress image links by default', 'responsive-lightbox').'</p> |
| 309 | </div>'; |
| 310 | } |
| 311 | |
| 312 | |
| 313 | public function rl_deactivation_delete() |
| 314 | { |
| 315 | echo ' |
| 316 | <div id="rl_deactivation_delete">'; |
| 317 | |
| 318 | foreach($this->choices as $val => $trans) |
| 319 | { |
| 320 | echo ' |
| 321 | <input id="rl-deactivation-delete-'.$val.'" type="radio" name="rl_settings[deactivation_delete]" value="'.$val.'" '.checked(($val === 'yes' ? TRUE : FALSE), $this->options['settings']['deactivation_delete'], FALSE).' /> |
| 322 | <label for="rl-deactivation-delete-'.$val.'">'.$trans.'</label>'; |
| 323 | } |
| 324 | |
| 325 | echo ' |
| 326 | <p class="description">'.__('Delete settings on plugin deactivation', 'responsive-lightbox').'</p> |
| 327 | </div>'; |
| 328 | } |
| 329 | |
| 330 | |
| 331 | public function rl_sw_animation() |
| 332 | { |
| 333 | echo ' |
| 334 | <div id="rl_sw_animation">'; |
| 335 | |
| 336 | foreach($this->scripts['swipebox']['animations'] as $val => $trans) |
| 337 | { |
| 338 | echo ' |
| 339 | <input id="rl-animation-'.$val.'" type="radio" name="rl_configuration[swipebox][animation]" value="'.$val.'" '.checked($val, $this->options['configuration']['swipebox']['animation'], FALSE).' /> |
| 340 | <label for="rl-animation-'.$val.'">'.$trans.'</label>'; |
| 341 | } |
| 342 | |
| 343 | echo ' |
| 344 | <p class="description">'.__('Select a method of applying a lightbox effect.', 'responsive-lightbox').'</p> |
| 345 | </div>'; |
| 346 | } |
| 347 | |
| 348 | |
| 349 | public function rl_sw_hide_bars() |
| 350 | { |
| 351 | echo ' |
| 352 | <div id="rl_sw_hide_bars">'; |
| 353 | |
| 354 | foreach($this->choices as $val => $trans) |
| 355 | { |
| 356 | echo ' |
| 357 | <input id="rl-hide-bars-'.$val.'" type="radio" name="rl_configuration[swipebox][hide_bars]" value="'.$val.'" '.checked(($val === 'yes' ? TRUE : FALSE), $this->options['configuration']['swipebox']['hide_bars'], FALSE).' /> |
| 358 | <label for="rl-hide-bars-'.$val.'">'.$trans.'</label>'; |
| 359 | } |
| 360 | |
| 361 | echo ' |
| 362 | <p class="description">'.__('Disable if you don\'t want to display top and bottom bars.', 'responsive-lightbox').'</p> |
| 363 | </div> |
| 364 | <div id="rl_sw_hide_bars_delay"'.($this->options['configuration']['swipebox']['hide_bars'] === FALSE ? ' style="display: none;"' : '').'> |
| 365 | <input type="text" name="rl_configuration[swipebox][hide_bars_delay]" value="'.$this->options['configuration']['swipebox']['hide_bars_delay'].'" /> |
| 366 | <p class="description">'.__('Enter the time for images animation (in miliseconds)', 'responsive-lightbox').'</p> |
| 367 | </div>'; |
| 368 | } |
| 369 | |
| 370 | |
| 371 | public function rl_pp_animation_speed() |
| 372 | { |
| 373 | echo ' |
| 374 | <div id="rl_pp_animation_speed">'; |
| 375 | |
| 376 | foreach($this->scripts['prettyphoto']['animation_speeds'] as $val => $trans) |
| 377 | { |
| 378 | echo ' |
| 379 | <input id="rl-animation-speed-'.$val.'" type="radio" name="rl_configuration[prettyphoto][animation_speed]" value="'.$val.'" '.checked($val, $this->options['configuration']['prettyphoto']['animation_speed'], FALSE).' /> |
| 380 | <label for="rl-animation-speed-'.$val.'">'.$trans.'</label>'; |
| 381 | } |
| 382 | |
| 383 | echo ' |
| 384 | <p class="description">'.__('Select animation speed for lightbox effect', 'responsive-lightbox').'</p> |
| 385 | </div>'; |
| 386 | } |
| 387 | |
| 388 | |
| 389 | public function rl_pp_slideshow() |
| 390 | { |
| 391 | echo ' |
| 392 | <div id="rl_pp_slideshow">'; |
| 393 | |
| 394 | foreach($this->choices as $val => $trans) |
| 395 | { |
| 396 | echo ' |
| 397 | <input id="rl-slideshow-'.$val.'" type="radio" name="rl_configuration[prettyphoto][slideshow]" value="'.$val.'" '.checked(($val === 'yes' ? TRUE : FALSE), $this->options['configuration']['prettyphoto']['slideshow'], FALSE).' /> |
| 398 | <label for="rl-slideshow-'.$val.'">'.$trans.'</label>'; |
| 399 | } |
| 400 | |
| 401 | echo ' |
| 402 | <p class="description">'.__('Display images as slideshow', 'responsive-lightbox').'</p> |
| 403 | </div> |
| 404 | <div id="rl_pp_slideshow_delay"'.($this->options['configuration']['prettyphoto']['slideshow'] === FALSE ? ' style="display: none;"' : '').'> |
| 405 | <input type="text" name="rl_configuration[prettyphoto][slideshow_delay]" value="'.$this->options['configuration']['prettyphoto']['slideshow_delay'].'" /> |
| 406 | <p class="description">'.__('Enter time (in miliseconds)', 'responsive-lightbox').'</p> |
| 407 | </div>'; |
| 408 | } |
| 409 | |
| 410 | |
| 411 | public function rl_pp_slideshow_autoplay() |
| 412 | { |
| 413 | echo ' |
| 414 | <div id="rl_pp_slideshow_autoplay">'; |
| 415 | |
| 416 | foreach($this->choices as $val => $trans) |
| 417 | { |
| 418 | echo ' |
| 419 | <input id="rl-slideshow-autoplay-'.$val.'" type="radio" name="rl_configuration[prettyphoto][slideshow_autoplay]" value="'.$val.'" '.checked(($val === 'yes' ? TRUE : FALSE), $this->options['configuration']['prettyphoto']['slideshow_autoplay'], FALSE).' /> |
| 420 | <label for="rl-slideshow-autoplay-'.$val.'">'.$trans.'</label>'; |
| 421 | } |
| 422 | |
| 423 | echo ' |
| 424 | <p class="description">'.__('Automatically start slideshow', 'responsive-lightbox').'</p> |
| 425 | </div>'; |
| 426 | } |
| 427 | |
| 428 | |
| 429 | public function rl_pp_opacity() |
| 430 | { |
| 431 | echo ' |
| 432 | <div id="rl_pp_opacity"> |
| 433 | <input type="text" name="rl_configuration[prettyphoto][opacity]" value="'.$this->options['configuration']['prettyphoto']['opacity'].'" /> |
| 434 | <p class="description">'.__('Value between 0 and 1 (for e.g. 0.5)', 'responsive-lightbox').'</p> |
| 435 | </div>'; |
| 436 | } |
| 437 | |
| 438 | |
| 439 | public function rl_pp_title() |
| 440 | { |
| 441 | echo ' |
| 442 | <div id="rl_pp_title">'; |
| 443 | |
| 444 | foreach($this->choices as $val => $trans) |
| 445 | { |
| 446 | echo ' |
| 447 | <input id="rl-show-title-'.$val.'" type="radio" name="rl_configuration[prettyphoto][show_title]" value="'.$val.'" '.checked(($val === 'yes' ? TRUE : FALSE), $this->options['configuration']['prettyphoto']['show_title'], FALSE).' /> |
| 448 | <label for="rl-show-title-'.$val.'">'.$trans.'</label>'; |
| 449 | } |
| 450 | |
| 451 | echo ' |
| 452 | <p class="description">'.__('Display image tiltle', 'responsive-lightbox').'</p> |
| 453 | </div>'; |
| 454 | } |
| 455 | |
| 456 | |
| 457 | public function rl_pp_allow_resize() |
| 458 | { |
| 459 | echo ' |
| 460 | <div id="rl_pp_allow_resize">'; |
| 461 | |
| 462 | foreach($this->choices as $val => $trans) |
| 463 | { |
| 464 | echo ' |
| 465 | <input id="rl-allow-resize-'.$val.'" type="radio" name="rl_configuration[prettyphoto][allow_resize]" value="'.$val.'" '.checked(($val === 'yes' ? TRUE : FALSE), $this->options['configuration']['prettyphoto']['allow_resize'], FALSE).' /> |
| 466 | <label for="rl-allow-resize-'.$val.'">'.$trans.'</label>'; |
| 467 | } |
| 468 | |
| 469 | echo ' |
| 470 | <p class="description">'.__('Resize the photos bigger than viewport.', 'responsive-lightbox').'</p> |
| 471 | </div>'; |
| 472 | } |
| 473 | |
| 474 | |
| 475 | public function rl_pp_width() |
| 476 | { |
| 477 | echo ' |
| 478 | <div id="rl_pp_width"> |
| 479 | <input type="text" name="rl_configuration[prettyphoto][width]" value="'.$this->options['configuration']['prettyphoto']['width'].'" /> |
| 480 | <p class="description">'.__('in pixels', 'responsive-lightbox').'</p> |
| 481 | </div>'; |
| 482 | } |
| 483 | |
| 484 | |
| 485 | public function rl_pp_height() |
| 486 | { |
| 487 | echo ' |
| 488 | <div id="rl_pp_height"> |
| 489 | <input type="text" name="rl_configuration[prettyphoto][height]" value="'.$this->options['configuration']['prettyphoto']['height'].'" /> |
| 490 | <p class="description">'.__('in pixels', 'responsive-lightbox').'</p> |
| 491 | </div>'; |
| 492 | } |
| 493 | |
| 494 | |
| 495 | public function rl_pp_theme() |
| 496 | { |
| 497 | echo ' |
| 498 | <div id="rl_pp_theme">'; |
| 499 | |
| 500 | foreach($this->scripts['prettyphoto']['themes'] as $val => $trans) |
| 501 | { |
| 502 | echo ' |
| 503 | <input id="rl-theme-'.$val.'" type="radio" name="rl_configuration[prettyphoto][theme]" value="'.$val.'" '.checked($val, $this->options['configuration']['prettyphoto']['theme'], FALSE).' /> |
| 504 | <label for="rl-theme-'.$val.'">'.$trans.'</label>'; |
| 505 | } |
| 506 | |
| 507 | echo ' |
| 508 | <p class="description">'.__('Select theme for lightbox effect', 'responsive-lightbox').'</p> |
| 509 | </div>'; |
| 510 | } |
| 511 | |
| 512 | |
| 513 | public function rl_pp_horizontal_padding() |
| 514 | { |
| 515 | echo ' |
| 516 | <div id="rl_pp_horizontal_padding"> |
| 517 | <input type="text" name="rl_configuration[prettyphoto][horizontal_padding]" value="'.$this->options['configuration']['prettyphoto']['horizontal_padding'].'" /> |
| 518 | <p class="description">'.__('Horizontal padding (in pixels)', 'responsive-lightbox').'</p> |
| 519 | </div>'; |
| 520 | } |
| 521 | |
| 522 | |
| 523 | public function rl_pp_hide_flash() |
| 524 | { |
| 525 | echo ' |
| 526 | <div id="rl_pp_hide_flash">'; |
| 527 | |
| 528 | foreach($this->choices as $val => $trans) |
| 529 | { |
| 530 | echo ' |
| 531 | <input id="rl-hide-flash-'.$val.'" type="radio" name="rl_configuration[prettyphoto][hide_flash]" value="'.$val.'" '.checked(($val === 'yes' ? TRUE : FALSE), $this->options['configuration']['prettyphoto']['hide_flash'], FALSE).' /> |
| 532 | <label for="rl-hide-flash-'.$val.'">'.$trans.'</label>'; |
| 533 | } |
| 534 | |
| 535 | echo ' |
| 536 | <p class="description">'.__('Hides all the flash object on a page. Enable this if flash appears over prettyPhoto', 'responsive-lightbox').'</p> |
| 537 | </div>'; |
| 538 | } |
| 539 | |
| 540 | |
| 541 | public function rl_pp_wmode() |
| 542 | { |
| 543 | echo ' |
| 544 | <div id="rl_pp_wmode">'; |
| 545 | |
| 546 | foreach($this->scripts['prettyphoto']['wmodes'] as $val => $trans) |
| 547 | { |
| 548 | echo ' |
| 549 | <input id="rl-wmode-'.$val.'" type="radio" name="rl_configuration[prettyphoto][wmode]" value="'.$val.'" '.checked($val, $this->options['configuration']['prettyphoto']['wmode'], FALSE).' /> |
| 550 | <label for="rl-wmode-'.$val.'">'.$trans.'</label>'; |
| 551 | } |
| 552 | |
| 553 | echo ' |
| 554 | <p class="description">'.__('Select flash window mode', 'responsive-lightbox').'</p> |
| 555 | </div>'; |
| 556 | } |
| 557 | |
| 558 | |
| 559 | public function rl_pp_video_autoplay() |
| 560 | { |
| 561 | echo ' |
| 562 | <div id="rl_pp_video_autoplay">'; |
| 563 | |
| 564 | foreach($this->choices as $val => $trans) |
| 565 | { |
| 566 | echo ' |
| 567 | <input id="rl-video-autoplay-'.$val.'" type="radio" name="rl_configuration[prettyphoto][video_autoplay]" value="'.$val.'" '.checked(($val === 'yes' ? TRUE : FALSE), $this->options['configuration']['prettyphoto']['video_autoplay'], FALSE).' /> |
| 568 | <label for="rl-video-autoplay-'.$val.'">'.$trans.'</label>'; |
| 569 | } |
| 570 | |
| 571 | echo ' |
| 572 | <p class="description">'.__('Automatically start videos', 'responsive-lightbox').'</p> |
| 573 | </div>'; |
| 574 | } |
| 575 | |
| 576 | |
| 577 | public function rl_pp_modal() |
| 578 | { |
| 579 | echo ' |
| 580 | <div id="rl_pp_modal">'; |
| 581 | |
| 582 | foreach($this->choices as $val => $trans) |
| 583 | { |
| 584 | echo ' |
| 585 | <input id="rl-modal-close-'.$val.'" type="radio" name="rl_configuration[prettyphoto][modal]" value="'.$val.'" '.checked(($val === 'yes' ? TRUE : FALSE), $this->options['configuration']['prettyphoto']['modal'], FALSE).' /> |
| 586 | <label for="rl-modal-close-'.$val.'">'.$trans.'</label>'; |
| 587 | } |
| 588 | |
| 589 | echo ' |
| 590 | <p class="description">'.__('If set to true, only the close button will close the window', 'responsive-lightbox').'</p> |
| 591 | </div>'; |
| 592 | } |
| 593 | |
| 594 | |
| 595 | public function rl_pp_deeplinking() |
| 596 | { |
| 597 | echo ' |
| 598 | <div id="rl_pp_deeplinking">'; |
| 599 | |
| 600 | foreach($this->choices as $val => $trans) |
| 601 | { |
| 602 | echo ' |
| 603 | <input id="rl-deeplinking-'.$val.'" type="radio" name="rl_configuration[prettyphoto][deeplinking]" value="'.$val.'" '.checked(($val === 'yes' ? TRUE : FALSE), $this->options['configuration']['prettyphoto']['deeplinking'], FALSE).' /> |
| 604 | <label for="rl-deeplinking-'.$val.'">'.$trans.'</label>'; |
| 605 | } |
| 606 | |
| 607 | echo ' |
| 608 | <p class="description">'.__('Allow prettyPhoto to update the url to enable deeplinking', 'responsive-lightbox').'</p> |
| 609 | </div>'; |
| 610 | } |
| 611 | |
| 612 | |
| 613 | public function rl_pp_overlay_gallery() |
| 614 | { |
| 615 | echo ' |
| 616 | <div id="rl_pp_overlay_gallery">'; |
| 617 | |
| 618 | foreach($this->choices as $val => $trans) |
| 619 | { |
| 620 | echo ' |
| 621 | <input id="rl-overlay-gallery-'.$val.'" type="radio" name="rl_configuration[prettyphoto][overlay_gallery]" value="'.$val.'" '.checked(($val === 'yes' ? TRUE : FALSE), $this->options['configuration']['prettyphoto']['overlay_gallery'], FALSE).' /> |
| 622 | <label for="rl-overlay-gallery-'.$val.'">'.$trans.'</label>'; |
| 623 | } |
| 624 | |
| 625 | echo ' |
| 626 | <p class="description">'.__('If enabled, a gallery will overlay the fullscreen image on mouse over', 'responsive-lightbox').'</p> |
| 627 | </div>'; |
| 628 | } |
| 629 | |
| 630 | |
| 631 | public function rl_pp_keyboard_shortcuts() |
| 632 | { |
| 633 | echo ' |
| 634 | <div id="rl_pp_keyboard_shortcuts">'; |
| 635 | |
| 636 | foreach($this->choices as $val => $trans) |
| 637 | { |
| 638 | echo ' |
| 639 | <input id="rl-keyboard-shortcuts-'.$val.'" type="radio" name="rl_configuration[prettyphoto][keyboard_shortcuts]" value="'.$val.'" '.checked(($val === 'yes' ? TRUE : FALSE), $this->options['configuration']['prettyphoto']['keyboard_shortcuts'], FALSE).' /> |
| 640 | <label for="rl-keyboard-shortcuts-'.$val.'">'.$trans.'</label>'; |
| 641 | } |
| 642 | |
| 643 | echo ' |
| 644 | <p class="description">'.__('Set to false if you open forms inside prettyPhoto', 'responsive-lightbox').'</p> |
| 645 | </div>'; |
| 646 | } |
| 647 | |
| 648 | |
| 649 | public function rl_pp_social() |
| 650 | { |
| 651 | echo ' |
| 652 | <div id="rl_pp_social">'; |
| 653 | |
| 654 | foreach($this->choices as $val => $trans) |
| 655 | { |
| 656 | echo ' |
| 657 | <input id="rl-social-'.$val.'" type="radio" name="rl_configuration[prettyphoto][social]" value="'.$val.'" '.checked(($val === 'yes' ? TRUE : FALSE), $this->options['configuration']['prettyphoto']['social'], FALSE).' /> |
| 658 | <label for="rl-social-'.$val.'">'.$trans.'</label>'; |
| 659 | } |
| 660 | |
| 661 | echo ' |
| 662 | <p class="description">'.__('Display links to Facebook and Twitter', 'responsive-lightbox').'</p> |
| 663 | </div>'; |
| 664 | } |
| 665 | |
| 666 | |
| 667 | /** |
| 668 | * Validates settings |
| 669 | */ |
| 670 | public function validate_options($input) |
| 671 | { |
| 672 | if(isset($_POST['save_rl_settings'])) |
| 673 | { |
| 674 | //script |
| 675 | $input['script'] = (isset($input['script']) && in_array($input['script'], array_keys($this->scripts)) ? $input['script'] : $this->options['settings']['script']); |
| 676 | |
| 677 | //selector |
| 678 | $input['selector'] = sanitize_text_field(isset($input['selector']) && $input['selector'] !== '' ? $input['selector'] : $this->options['settings']['selector']); |
| 679 | |
| 680 | //checkboxes |
| 681 | $input['galleries'] = (isset($input['galleries']) && in_array($input['galleries'], array_keys($this->choices)) ? ($input['galleries'] === 'yes' ? TRUE : FALSE) : $this->options['settings']['galleries']); |
| 682 | $input['image_links'] = (isset($input['image_links']) && in_array($input['image_links'], array_keys($this->choices)) ? ($input['image_links'] === 'yes' ? TRUE : FALSE) : $this->options['settings']['image_links']); |
| 683 | $input['deactivation_delete'] = (isset($input['deactivation_delete']) && in_array($input['deactivation_delete'], array_keys($this->choices)) ? ($input['deactivation_delete'] === 'yes' ? TRUE : FALSE) : $this->options['settings']['deactivation_delete']); |
| 684 | } |
| 685 | elseif(isset($_POST['save_rl_configuration'])) |
| 686 | { |
| 687 | if($this->options['settings']['script'] === 'swipebox' && $_POST['script_r'] === 'swipebox') |
| 688 | { |
| 689 | //animation |
| 690 | $input['swipebox']['animation'] = (isset($input['swipebox']['animation']) && in_array($input['swipebox']['animation'], array_keys($this->scripts['swipebox']['animations'])) ? $input['swipebox']['animation'] : $this->options['configuration']['swipebox']['animation']); |
| 691 | |
| 692 | //hide bars |
| 693 | $input['swipebox']['hide_bars'] = (isset($input['swipebox']['hide_bars']) && in_array($input['swipebox']['hide_bars'], array_keys($this->choices)) ? ($input['swipebox']['hide_bars'] === 'yes' ? TRUE : FALSE) : $this->options['configuration']['swipebox']['hide_bars']); |
| 694 | $input['swipebox']['hide_bars_delay'] = (int)($input['swipebox']['hide_bars_delay'] > 0 ? $input['swipebox']['hide_bars_delay'] : $this->options['configuration']['swipebox']['hide_bars_delay']); |
| 695 | } |
| 696 | elseif($this->options['settings']['script'] === 'prettyphoto' && $_POST['script_r'] === 'prettyphoto') |
| 697 | { |
| 698 | //animation speed |
| 699 | $input['prettyphoto']['animation_speed'] = (isset($input['prettyphoto']['animation_speed']) && in_array($input['prettyphoto']['animation_speed'], array_keys($this->scripts['prettyphoto']['animation_speeds'])) ? $input['prettyphoto']['animation_speed'] : $this->options['configuration']['prettyphoto']['animation_speed']); |
| 700 | |
| 701 | //slideshows |
| 702 | $input['prettyphoto']['slideshow'] = (isset($input['prettyphoto']['slideshow']) && in_array($input['prettyphoto']['slideshow'], array_keys($this->choices)) ? ($input['prettyphoto']['slideshow'] === 'yes' ? TRUE : FALSE) : $this->options['configuration']['prettyphoto']['slideshow']); |
| 703 | $input['prettyphoto']['slideshow_delay'] = (int)($input['prettyphoto']['slideshow_delay'] > 0 ? $input['prettyphoto']['slideshow_delay'] : $this->options['configuration']['prettyphoto']['slideshow_delay']); |
| 704 | $input['prettyphoto']['slideshow_autoplay'] = (isset($input['prettyphoto']['slideshow_autoplay']) && in_array($input['prettyphoto']['slideshow_autoplay'], array_keys($this->choices)) ? ($input['prettyphoto']['slideshow_autoplay'] === 'yes' ? TRUE : FALSE) : $this->options['configuration']['prettyphoto']['slideshow_autoplay']); |
| 705 | |
| 706 | //opacity |
| 707 | $input['prettyphoto']['opacity'] = (int)$input['prettyphoto']['opacity']; |
| 708 | |
| 709 | //title |
| 710 | $input['prettyphoto']['show_title'] = (isset($input['prettyphoto']['show_title']) && in_array($input['prettyphoto']['show_title'], array_keys($this->choices)) ? ($input['prettyphoto']['show_title'] === 'yes' ? TRUE : FALSE) : $this->options['configuration']['prettyphoto']['show_title']); |
| 711 | |
| 712 | //resize |
| 713 | $input['prettyphoto']['allow_resize'] = (isset($input['prettyphoto']['allow_resize']) && in_array($input['prettyphoto']['allow_resize'], array_keys($this->choices)) ? ($input['prettyphoto']['allow_resize'] === 'yes' ? TRUE : FALSE) : $this->options['configuration']['prettyphoto']['allow_resize']); |
| 714 | |
| 715 | //dimensions |
| 716 | $input['prettyphoto']['width'] = (int)($input['prettyphoto']['width'] > 0 ? $input['prettyphoto']['width'] : $this->options['configuration']['prettyphoto']['width']); |
| 717 | $input['prettyphoto']['height'] = (int)($input['prettyphoto']['height'] > 0 ? $input['prettyphoto']['height'] : $this->options['configuration']['prettyphoto']['height']); |
| 718 | |
| 719 | //separator |
| 720 | $input['prettyphoto']['separator'] = sanitize_text_field(isset($input['prettyphoto']['separator']) && $input['prettyphoto']['separator'] !== '' ? $input['prettyphoto']['separator'] : $this->options['configuration']['prettyphoto']['separator']); |
| 721 | |
| 722 | //theme |
| 723 | $input['prettyphoto']['theme'] = (isset($input['prettyphoto']['theme']) && in_array($input['prettyphoto']['theme'], array_keys($this->scripts['prettyphoto']['themes'])) ? $input['prettyphoto']['theme'] : $this->options['configuration']['prettyphoto']['theme']); |
| 724 | |
| 725 | //padding |
| 726 | $input['prettyphoto']['horizontal_padding'] = (int)($input['prettyphoto']['horizontal_padding'] > 0 ? $input['prettyphoto']['horizontal_padding'] : $this->options['configuration']['prettyphoto']['horizontal_padding']); |
| 727 | |
| 728 | //flash |
| 729 | $input['prettyphoto']['hide_flash'] = (isset($input['prettyphoto']['hide_flash']) && in_array($input['prettyphoto']['hide_flash'], array_keys($this->choices)) ? ($input['prettyphoto']['hide_flash'] === 'yes' ? TRUE : FALSE) : $this->options['configuration']['prettyphoto']['hide_flash']); |
| 730 | $input['prettyphoto']['wmode'] = (isset($input['prettyphoto']['wmode']) && in_array($input['prettyphoto']['wmode'], array_keys($this->scripts['prettyphoto']['wmodes'])) ? $input['prettyphoto']['wmode'] : $this->options['configuration']['prettyphoto']['wmode']); |
| 731 | |
| 732 | //video autoplay |
| 733 | $input['prettyphoto']['video_autoplay'] = (isset($input['prettyphoto']['video_autoplay']) && in_array($input['prettyphoto']['video_autoplay'], array_keys($this->choices)) ? ($input['prettyphoto']['video_autoplay'] === 'yes' ? TRUE : FALSE) : $this->options['configuration']['prettyphoto']['video_autoplay']); |
| 734 | |
| 735 | //modal |
| 736 | $input['prettyphoto']['modal'] = (isset($input['prettyphoto']['modal']) && in_array($input['prettyphoto']['modal'], array_keys($this->choices)) ? ($input['prettyphoto']['modal'] === 'yes' ? TRUE : FALSE) : $this->options['configuration']['prettyphoto']['modal']); |
| 737 | |
| 738 | //deeplinking |
| 739 | $input['prettyphoto']['deeplinking'] = (isset($input['prettyphoto']['deeplinking']) && in_array($input['prettyphoto']['deeplinking'], array_keys($this->choices)) ? ($input['prettyphoto']['deeplinking'] === 'yes' ? TRUE : FALSE) : $this->options['configuration']['prettyphoto']['deeplinking']); |
| 740 | |
| 741 | //overlay gallery |
| 742 | $input['prettyphoto']['overlay_gallery'] = (isset($input['prettyphoto']['overlay_gallery']) && in_array($input['prettyphoto']['overlay_gallery'], array_keys($this->choices)) ? ($input['prettyphoto']['overlay_gallery'] === 'yes' ? TRUE : FALSE) : $this->options['configuration']['prettyphoto']['overlay_gallery']); |
| 743 | |
| 744 | //keyboard shortcuts |
| 745 | $input['prettyphoto']['keyboard_shortcuts'] = (isset($input['prettyphoto']['keyboard_shortcuts']) && in_array($input['prettyphoto']['keyboard_shortcuts'], array_keys($this->choices)) ? ($input['prettyphoto']['keyboard_shortcuts'] === 'yes' ? TRUE : FALSE) : $this->options['configuration']['prettyphoto']['keyboard_shortcuts']); |
| 746 | |
| 747 | //social |
| 748 | $input['prettyphoto']['social'] = (isset($input['prettyphoto']['social']) && in_array($input['prettyphoto']['social'], array_keys($this->choices)) ? ($input['prettyphoto']['social'] === 'yes' ? TRUE : FALSE) : $this->options['configuration']['prettyphoto']['social']); |
| 749 | } |
| 750 | else |
| 751 | { |
| 752 | //clear input to not change settings |
| 753 | $input = array(); |
| 754 | |
| 755 | add_settings_error('save_script_settings', 'invalid_script_page', __('Changes were not saved because there was attempt to save settings of inactive script. The site has been reloaded to the proper script settings.', 'responsive-lightbox'), 'error'); |
| 756 | } |
| 757 | |
| 758 | //we have to merge rest of the scripts settings |
| 759 | $input = array_merge($this->options['configuration'], $input); |
| 760 | } |
| 761 | elseif(isset($_POST['reset_rl_configuration'])) |
| 762 | { |
| 763 | if($this->options['settings']['script'] === 'swipebox' && $_POST['script_r'] === 'swipebox') |
| 764 | { |
| 765 | $input['swipebox'] = $this->defaults['configuration']['swipebox']; |
| 766 | |
| 767 | add_settings_error('reset_swipebox_settings', 'swipebox_reset', __('Settings of SwipeBox script were restored to defaults.', 'responsive-lightbox'), 'updated'); |
| 768 | } |
| 769 | elseif($this->options['settings']['script'] === 'prettyphoto' && $_POST['script_r'] === 'prettyphoto') |
| 770 | { |
| 771 | $input['prettyphoto'] = $this->defaults['configuration']['prettyphoto']; |
| 772 | |
| 773 | add_settings_error('reset_prettyphoto_settings', 'prettyphoto_reset', __('Settings of prettyPhoto script were restored to defaults.', 'responsive-lightbox'), 'updated'); |
| 774 | } |
| 775 | else |
| 776 | { |
| 777 | add_settings_error('reset_script_settings', 'reset_invalid_script_page', __('Changes were not set to defaults because there was attempt to reset settings of inactive script. The site has been reloaded to the proper script settings.', 'responsive-lightbox'), 'error'); |
| 778 | } |
| 779 | |
| 780 | //we have to merge rest of the scripts settings |
| 781 | $input = array_merge($this->options['configuration'], $input); |
| 782 | } |
| 783 | |
| 784 | return $input; |
| 785 | } |
| 786 | |
| 787 | |
| 788 | public function admin_menu_options() |
| 789 | { |
| 790 | $watermark_settings_page = add_options_page( |
| 791 | __('Responsive Lightbox', 'responsive-lightbox'), |
| 792 | __('Responsive Lightbox', 'responsive-lightbox'), |
| 793 | 'manage_options', |
| 794 | 'responsive-lightbox', |
| 795 | array(&$this, 'options_page') |
| 796 | ); |
| 797 | } |
| 798 | |
| 799 | |
| 800 | public function options_page() |
| 801 | { |
| 802 | $tab_key = (isset($_GET['tab']) ? $_GET['tab'] : 'general-settings'); |
| 803 | |
| 804 | echo ' |
| 805 | <div class="wrap">'.screen_icon().' |
| 806 | <h2>'.__('Responsive Lightbox', 'responsive-lightbox').'</h2> |
| 807 | <h2 class="nav-tab-wrapper">'; |
| 808 | |
| 809 | foreach($this->tabs as $key => $name) |
| 810 | { |
| 811 | echo ' |
| 812 | <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>'; |
| 813 | } |
| 814 | |
| 815 | echo ' |
| 816 | </h2> |
| 817 | <div class="metabox-holder postbox-container responsive-lightbox-settings"> |
| 818 | <form action="options.php" method="post"> |
| 819 | <input type="hidden" name="script_r" value="'.$this->options['settings']['script'].'" />'; |
| 820 | |
| 821 | wp_nonce_field('update-options'); |
| 822 | settings_fields($this->tabs[$tab_key]['key']); |
| 823 | do_settings_sections($this->tabs[$tab_key]['key']); |
| 824 | |
| 825 | echo ' |
| 826 | <p class="submit">'; |
| 827 | |
| 828 | submit_button('', 'primary', $this->tabs[$tab_key]['submit'], FALSE); |
| 829 | |
| 830 | echo ' '; |
| 831 | echo ($tab_key === 'configuration' ? submit_button(__('Reset to defaults', 'responsive-lightbox'), 'secondary', $this->tabs[$tab_key]['reset'], FALSE) : ''); |
| 832 | |
| 833 | echo ' |
| 834 | </p> |
| 835 | </form> |
| 836 | </div> |
| 837 | <div class="df-credits postbox-container"> |
| 838 | <h3 class="metabox-title">'.__('Responsive Lightbox', 'responsive-lightbox').'</h3> |
| 839 | <div class="inner"> |
| 840 | <h3>'.__('Need support?', 'responsive-lightbox').'</h3> |
| 841 | <p>'.__('If you are having problems with this plugin, please talk about them in the', 'responsive-lightbox').' <a href="http://dfactory.eu/support/" target="_blank" title="'.__('Support forum', 'responsive-lightbox').'">'.__('Support forum', 'responsive-lightbox').'</a></p> |
| 842 | <hr /> |
| 843 | <h3>'.__('Do you like this plugin?', 'responsive-lightbox').'</h3> |
| 844 | <p><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 />'. |
| 845 | __('Blog about it & link to the', 'responsive-lightbox').' <a href="http://dfactory.eu/plugins/responsive-lightbox/" target="_blank" title="'.__('plugin page', 'responsive-lightbox').'">'.__('plugin page', 'responsive-lightbox').'</a><br />'. |
| 846 | __('Check out our other', 'responsive-lightbox').' <a href="http://dfactory.eu/plugins/" target="_blank" title="'.__('WordPress plugins', 'responsive-lightbox').'">'.__('WordPress plugins', 'responsive-lightbox').'</a> |
| 847 | </p> |
| 848 | <hr /> |
| 849 | <p class="df-link">Created by <a href="http://www.dfactory.eu" target="_blank" title="dFactory - Quality plugins for WordPress"><img src="'.plugins_url('/images/logo-dfactory.png' , __FILE__ ).'" title="dFactory - Quality plugins for WordPress" alt="dFactory - Quality plugins for WordPress" /></a></p> |
| 850 | </div> |
| 851 | </div> |
| 852 | <div class="clear"></div> |
| 853 | </div>'; |
| 854 | } |
| 855 | |
| 856 | |
| 857 | public function admin_comments_scripts_styles($page) |
| 858 | { |
| 859 | if(is_admin() && $page === 'settings_page_responsive-lightbox') |
| 860 | { |
| 861 | wp_enqueue_script( |
| 862 | 'responsive-lightbox-admin', |
| 863 | plugins_url('js/responsive-lightbox-admin.js', __FILE__), |
| 864 | array('jquery', 'jquery-ui-core', 'jquery-ui-button') |
| 865 | ); |
| 866 | |
| 867 | wp_localize_script( |
| 868 | 'responsive-lightbox-admin', |
| 869 | 'rlArgs', |
| 870 | array( |
| 871 | 'resetScriptToDefaults' => __('Are you sure you want to reset scripts settings to defaults?', 'responsive-lightbox') |
| 872 | ) |
| 873 | ); |
| 874 | |
| 875 | wp_enqueue_style( |
| 876 | 'responsive-lightbox-admin', |
| 877 | plugins_url('css/responsive-lightbox-admin.css', __FILE__) |
| 878 | ); |
| 879 | |
| 880 | wp_enqueue_style( |
| 881 | 'responsive-lightbox-wplike', |
| 882 | plugins_url('css/wp-like-ui-theme.css', __FILE__) |
| 883 | ); |
| 884 | } |
| 885 | } |
| 886 | |
| 887 | |
| 888 | public function front_comments_scripts_styles() |
| 889 | { |
| 890 | $args = array( |
| 891 | 'script' => $this->options['settings']['script'], |
| 892 | 'selector' => $this->options['settings']['selector'], |
| 893 | 'activeGalleries' => $this->getBooleanValue($this->options['settings']['galleries']) |
| 894 | ); |
| 895 | |
| 896 | if($this->options['settings']['script'] === 'prettyphoto') |
| 897 | { |
| 898 | wp_enqueue_script( |
| 899 | 'responsive-lightbox-prettyphoto', |
| 900 | plugins_url('assets/prettyphoto/js/jquery.prettyPhoto.js', __FILE__), |
| 901 | array('jquery') |
| 902 | ); |
| 903 | |
| 904 | wp_enqueue_style( |
| 905 | 'responsive-lightbox-front', |
| 906 | plugins_url('assets/prettyphoto/css/prettyPhoto.css', __FILE__) |
| 907 | ); |
| 908 | |
| 909 | $args = array_merge( |
| 910 | $args, |
| 911 | array( |
| 912 | 'animationSpeed' => $this->options['configuration']['prettyphoto']['animation_speed'], |
| 913 | 'slideshow' => $this->getBooleanValue($this->options['configuration']['prettyphoto']['slideshow']), |
| 914 | 'slideshowDelay' => $this->options['configuration']['prettyphoto']['slideshow_delay'], |
| 915 | 'slideshowAutoplay' => $this->getBooleanValue($this->options['configuration']['prettyphoto']['slideshow_autoplay']), |
| 916 | 'opacity' => sprintf('%.2f', ($this->options['configuration']['prettyphoto']['opacity'] / 100)), |
| 917 | 'showTitle' => $this->getBooleanValue($this->options['configuration']['prettyphoto']['show_title']), |
| 918 | 'allowResize' => $this->getBooleanValue($this->options['configuration']['prettyphoto']['allow_resize']), |
| 919 | 'width' => $this->options['configuration']['prettyphoto']['width'], |
| 920 | 'height' => $this->options['configuration']['prettyphoto']['height'], |
| 921 | 'separator' => $this->options['configuration']['prettyphoto']['separator'], |
| 922 | 'theme' => $this->options['configuration']['prettyphoto']['theme'], |
| 923 | 'horizontalPadding' => $this->options['configuration']['prettyphoto']['horizontal_padding'], |
| 924 | 'hideFlash' => $this->getBooleanValue($this->options['configuration']['prettyphoto']['hide_flash']), |
| 925 | 'wmode' => $this->options['configuration']['prettyphoto']['wmode'], |
| 926 | 'videoAutoplay' => $this->getBooleanValue($this->options['configuration']['prettyphoto']['video_autoplay']), |
| 927 | 'modal' => $this->getBooleanValue($this->options['configuration']['prettyphoto']['modal']), |
| 928 | 'deeplinking' => $this->getBooleanValue($this->options['configuration']['prettyphoto']['deeplinking']), |
| 929 | 'overlayGallery' => $this->getBooleanValue($this->options['configuration']['prettyphoto']['overlay_gallery']), |
| 930 | 'keyboardShortcuts' => $this->getBooleanValue($this->options['configuration']['prettyphoto']['keyboard_shortcuts']), |
| 931 | 'social' => $this->getBooleanValue($this->options['configuration']['prettyphoto']['social']) |
| 932 | ) |
| 933 | ); |
| 934 | } |
| 935 | elseif($this->options['settings']['script'] === 'swipebox') |
| 936 | { |
| 937 | wp_enqueue_script( |
| 938 | 'responsive-lightbox-swipebox', |
| 939 | plugins_url('assets/swipebox/source/jquery.swipebox.min.js', __FILE__), |
| 940 | array('jquery') |
| 941 | ); |
| 942 | |
| 943 | wp_enqueue_style( |
| 944 | 'responsive-lightbox-front', |
| 945 | plugins_url('assets/swipebox/source/swipebox.css', __FILE__) |
| 946 | ); |
| 947 | |
| 948 | $args = array_merge( |
| 949 | $args, |
| 950 | array( |
| 951 | 'animation' => ($this->options['configuration']['swipebox']['animation'] === 'css' ? TRUE : FALSE), |
| 952 | 'hideBars' => $this->getBooleanValue($this->options['configuration']['swipebox']['hide_bars']), |
| 953 | 'hideBarsDelay' => $this->options['configuration']['swipebox']['hide_bars_delay'] |
| 954 | ) |
| 955 | ); |
| 956 | } |
| 957 | |
| 958 | wp_enqueue_script( |
| 959 | 'responsive-lightbox-front', |
| 960 | plugins_url('js/responsive-lightbox-front.js', __FILE__), |
| 961 | array('jquery') |
| 962 | ); |
| 963 | |
| 964 | wp_localize_script('responsive-lightbox-front', 'rlArgs', $args); |
| 965 | } |
| 966 | |
| 967 | |
| 968 | private function getBooleanValue($option) |
| 969 | { |
| 970 | return ($option === TRUE ? 1 : 0); |
| 971 | } |
| 972 | |
| 973 | |
| 974 | /** |
| 975 | * Loads textdomain |
| 976 | */ |
| 977 | public function load_textdomain() |
| 978 | { |
| 979 | load_plugin_textdomain('responsive-lightbox', FALSE, dirname(plugin_basename(__FILE__)).'/languages/'); |
| 980 | } |
| 981 | |
| 982 | |
| 983 | /** |
| 984 | * Add links to Support Forum |
| 985 | */ |
| 986 | public function plugin_extend_links($links, $file) |
| 987 | { |
| 988 | if (!current_user_can('install_plugins')) |
| 989 | return $links; |
| 990 | |
| 991 | $plugin = plugin_basename(__FILE__); |
| 992 | |
| 993 | if ($file == $plugin) |
| 994 | { |
| 995 | return array_merge( |
| 996 | $links, |
| 997 | array(sprintf('<a href="http://www.dfactory.eu/support/forum/responsive-lightbox/" target="_blank">%s</a>', __('Support', 'responsive-lightbox'))) |
| 998 | ); |
| 999 | } |
| 1000 | |
| 1001 | return $links; |
| 1002 | } |
| 1003 | |
| 1004 | |
| 1005 | /** |
| 1006 | * Add links to Settings page |
| 1007 | */ |
| 1008 | function plugin_settings_link($links, $file) |
| 1009 | { |
| 1010 | if(!is_admin() || !current_user_can('manage_options')) |
| 1011 | return $links; |
| 1012 | |
| 1013 | static $plugin; |
| 1014 | |
| 1015 | $plugin = plugin_basename(__FILE__); |
| 1016 | |
| 1017 | if($file == $plugin) |
| 1018 | { |
| 1019 | $settings_link = sprintf('<a href="%s">%s</a>', admin_url('options-general.php').'?page=responsive-lightbox', __('Settings', 'responsive-lightbox')); |
| 1020 | array_unshift($links, $settings_link); |
| 1021 | } |
| 1022 | |
| 1023 | return $links; |
| 1024 | } |
| 1025 | } |
| 1026 | |
| 1027 | $responsive_lightbox = new Responsive_Lightbox(); |
| 1028 | ?> |