PluginProbe
Responsive Lightbox & Gallery / 1.0.2
Responsive Lightbox & Gallery v1.0.2
2.7.8 trunk 1.0.0 1.0.1 1.0.1.1 1.0.2 1.0.3 1.0.4 1.1.0 1.1.1 1.1.2 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.4.0 1.4.0.1 1.4.1 All 105 releases
responsive-lightbox / responsive-lightbox.php

responsive-lightbox.php in Responsive Lightbox & Gallery 1.0.2, at responsive-lightbox.php

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