Version Description
- Added: Customizable UI label text (close, next, and prev button images can be replaced in
images
directory) - Added: Group image links by Post (separate slideshow for each post)
- Added: Reset settings link on plugin listings page
- Optimized: Organized settings page
Download this release
Release Info
Developer | Archetyped |
Plugin | Simple Lightbox |
Version | 1.3 |
Comparing to | |
See all releases |
Code changes from version 1.2 to 1.3
- css/admin.css +3 -0
- includes/class.utilities.php +200 -42
- js/dev/lightbox.js +2 -4
- js/lib.js +1 -1
- main.php +1 -1
- model.php +170 -19
- readme.txt +16 -2
- screenshot-1.gif +0 -0
- screenshot-2.gif +0 -0
css/admin.css
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
.subhead {
|
2 |
+
margin-bottom: .2em;
|
3 |
+
}
|
includes/class.utilities.php
CHANGED
@@ -84,6 +84,57 @@ class SLB_Utilities {
|
|
84 |
);
|
85 |
}
|
86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
/**
|
88 |
* Returns URL of file (assumes that it is in plugin directory)
|
89 |
* @param string $file name of file get URL
|
@@ -91,12 +142,34 @@ class SLB_Utilities {
|
|
91 |
*/
|
92 |
function get_file_url($file) {
|
93 |
if (is_string($file) && '' != trim($file)) {
|
94 |
-
$file =
|
95 |
-
$file = sprintf('%s/%s', $this->get_url_base(), $file);
|
96 |
}
|
97 |
return $file;
|
98 |
}
|
99 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
/**
|
101 |
* Retrieve base URL for plugin-specific files
|
102 |
* @return string Base URL
|
@@ -104,10 +177,7 @@ class SLB_Utilities {
|
|
104 |
function get_url_base() {
|
105 |
static $url_base = '';
|
106 |
if ( '' == $url_base ) {
|
107 |
-
$
|
108 |
-
$sl_b = '\\';
|
109 |
-
$plugin_dir = str_replace(str_replace($sl_f, $sl_b, WP_PLUGIN_DIR), '', str_replace($sl_f, $sl_b, dirname(dirname(__FILE__))));
|
110 |
-
$url_base = str_replace($sl_b, $sl_f, WP_PLUGIN_URL . $plugin_dir);
|
111 |
}
|
112 |
return $url_base;
|
113 |
}
|
@@ -115,14 +185,18 @@ class SLB_Utilities {
|
|
115 |
function get_path_base() {
|
116 |
static $path_base = '';
|
117 |
if ( '' == $path_base ) {
|
118 |
-
$
|
119 |
-
$sl_b = '\\';
|
120 |
-
$plugin_dir = str_replace(str_replace($sl_f, $sl_b, WP_PLUGIN_DIR), '', str_replace($sl_f, $sl_b, dirname(dirname(__FILE__))));
|
121 |
-
$path_base = str_replace($sl_b, $sl_f, WP_PLUGIN_DIR . $plugin_dir);
|
122 |
}
|
123 |
-
|
124 |
return $path_base;
|
125 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
|
127 |
function get_plugin_base_file() {
|
128 |
$file = 'main.php';
|
@@ -131,21 +205,40 @@ class SLB_Utilities {
|
|
131 |
|
132 |
function get_plugin_base_name() {
|
133 |
$file = $this->get_plugin_base_file();
|
134 |
-
|
135 |
-
$name = substr($file, strlen($front) + 1);
|
136 |
-
return $name;
|
137 |
}
|
138 |
|
139 |
/**
|
140 |
* Retrieve current action based on URL query variables
|
|
|
141 |
* @return string Current action
|
142 |
*/
|
143 |
function get_action($default = null) {
|
144 |
$action = '';
|
|
|
|
|
145 |
if ( isset($_GET['action']) )
|
146 |
$action = $_GET['action'];
|
|
|
147 |
elseif ( isset($_GET['page']) && ($pos = strrpos($_GET['page'], '-')) && $pos !== false && ( $pos != count($_GET['page']) - 1 ) )
|
148 |
-
$action = trim(substr($_GET['page'], $pos + 1), '-_');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
if ( empty($action) )
|
150 |
$action = $default;
|
151 |
return $action;
|
@@ -204,9 +297,10 @@ class SLB_Utilities {
|
|
204 |
* - If the current item's value OR the corresponding item in the base array is NOT an array, current item overwrites base item
|
205 |
* @todo Append numerical elements (as opposed to overwriting element at same index in base array)
|
206 |
* @param array Variable number of arrays
|
|
|
207 |
* @return array Merged array
|
208 |
*/
|
209 |
-
function array_merge_recursive_distinct() {
|
210 |
//Get all arrays passed to function
|
211 |
$args = func_get_args();
|
212 |
if (empty($args))
|
@@ -346,15 +440,80 @@ class SLB_Utilities {
|
|
346 |
return $path;
|
347 |
}
|
348 |
|
349 |
-
|
|
|
|
|
|
|
|
|
|
|
350 |
$ret = '';
|
351 |
-
if (
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
$
|
|
|
|
|
|
|
|
|
356 |
}
|
357 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
358 |
}
|
359 |
|
360 |
/*-** Admin **-*/
|
@@ -362,7 +521,7 @@ class SLB_Utilities {
|
|
362 |
/**
|
363 |
* Add submenu page in the admin menu
|
364 |
* Adds ability to set the position of the page in the menu
|
365 |
-
* @see
|
366 |
*
|
367 |
* @param $parent
|
368 |
* @param $page_title
|
@@ -374,30 +533,29 @@ class SLB_Utilities {
|
|
374 |
*
|
375 |
* @global array $submenu Admin page submenus
|
376 |
*/
|
377 |
-
function add_submenu_page($parent, $page_title, $menu_title, $
|
378 |
-
global $submenu;
|
379 |
-
|
380 |
//Add submenu page as usual
|
381 |
$args = func_get_args();
|
382 |
$hookname = call_user_func_array('add_submenu_page', $args);
|
383 |
-
|
384 |
if ( is_int($pos) ) {
|
|
|
385 |
//Get last submenu added
|
386 |
$parent = $this->get_submenu_parent_file($parent);
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
|
|
401 |
}
|
402 |
}
|
403 |
}
|
84 |
);
|
85 |
}
|
86 |
|
87 |
+
/**
|
88 |
+
* Joins and normalizes the slashes in the paths passed to method
|
89 |
+
* All forward/back slashes are converted to forward slashes
|
90 |
+
* Multiple path segments can be passed as additional argments
|
91 |
+
* @param string $path Path to normalize
|
92 |
+
* @param bool $trailing_slash (optional) Whether or not normalized path should have a trailing slash or not (Default: FALSE)
|
93 |
+
* If multiple path segments are passed, $trailing_slash will be the LAST parameter (default value used if omitted)
|
94 |
+
*/
|
95 |
+
function normalize_path($path, $trailing_slash = false) {
|
96 |
+
$sl_f = '/';
|
97 |
+
$sl_b = '\\';
|
98 |
+
$parts = func_get_args();
|
99 |
+
if ( func_num_args() > 1 ) {
|
100 |
+
if ( is_bool(($tr = $parts[count($parts) - 1])) ) {
|
101 |
+
$trailing_slash = $tr;
|
102 |
+
//Remove from args array
|
103 |
+
array_pop($parts);
|
104 |
+
} else {
|
105 |
+
$trailing_slash = false;
|
106 |
+
}
|
107 |
+
$first = true;
|
108 |
+
//Trim trailing slashes from path parts
|
109 |
+
foreach ( $parts as $key => $part ) {
|
110 |
+
$part = trim($part);
|
111 |
+
//Special Trim
|
112 |
+
$parts[$key] = trim($part, $sl_f . $sl_b);
|
113 |
+
//Verify path still contains value
|
114 |
+
if ( empty($parts[$key]) ) {
|
115 |
+
unset($parts[$key]);
|
116 |
+
continue;
|
117 |
+
}
|
118 |
+
//Only continue processing the first valid path segment
|
119 |
+
if ( $first )
|
120 |
+
$first = !$first;
|
121 |
+
else
|
122 |
+
continue;
|
123 |
+
//Add back leading slash if necessary
|
124 |
+
if ( $part[0] == $sl_f || $part[0] == $sl_b )
|
125 |
+
$parts[$key] = $sl_f . $parts[$key];
|
126 |
+
|
127 |
+
}
|
128 |
+
}
|
129 |
+
//Join path parts together
|
130 |
+
$parts = implode($sl_b, $parts);
|
131 |
+
$parts = str_replace($sl_b, $sl_f, $parts);
|
132 |
+
//Add trailing slash (if necessary)
|
133 |
+
if ( $trailing_slash )
|
134 |
+
$parts . $sl_f;
|
135 |
+
return $parts;
|
136 |
+
}
|
137 |
+
|
138 |
/**
|
139 |
* Returns URL of file (assumes that it is in plugin directory)
|
140 |
* @param string $file name of file get URL
|
142 |
*/
|
143 |
function get_file_url($file) {
|
144 |
if (is_string($file) && '' != trim($file)) {
|
145 |
+
$file = $this->normalize_path($this->get_url_base(), $file);
|
|
|
146 |
}
|
147 |
return $file;
|
148 |
}
|
149 |
|
150 |
+
/**
|
151 |
+
* Retrieves file extension
|
152 |
+
* @param string $file file name/path
|
153 |
+
* @return string File's extension
|
154 |
+
*/
|
155 |
+
function get_file_extension($file) {
|
156 |
+
$ret = '';
|
157 |
+
$sep = '.';
|
158 |
+
if ( is_string($icon) && ( $rpos = strrpos($file, $sep) ) !== false )
|
159 |
+
$ret = substr($file, $rpos + 1);
|
160 |
+
return $ret;
|
161 |
+
}
|
162 |
+
|
163 |
+
/**
|
164 |
+
* Checks if file has specified extension
|
165 |
+
* @param string $file File name/path
|
166 |
+
* @param string $extension File ending to check $file for
|
167 |
+
* @return bool TRUE if file has extension
|
168 |
+
*/
|
169 |
+
function has_file_extension($file, $extension) {
|
170 |
+
return ( $this->get_file_extension($file) == $extension ) ? true : false;
|
171 |
+
}
|
172 |
+
|
173 |
/**
|
174 |
* Retrieve base URL for plugin-specific files
|
175 |
* @return string Base URL
|
177 |
function get_url_base() {
|
178 |
static $url_base = '';
|
179 |
if ( '' == $url_base ) {
|
180 |
+
$url_base = $this->normalize_path(WP_PLUGIN_URL, $this->get_plugin_base());
|
|
|
|
|
|
|
181 |
}
|
182 |
return $url_base;
|
183 |
}
|
185 |
function get_path_base() {
|
186 |
static $path_base = '';
|
187 |
if ( '' == $path_base ) {
|
188 |
+
$path_base = $this->normalize_path(WP_PLUGIN_DIR, $this->get_plugin_base());
|
|
|
|
|
|
|
189 |
}
|
|
|
190 |
return $path_base;
|
191 |
}
|
192 |
+
|
193 |
+
function get_plugin_base() {
|
194 |
+
static $plugin_dir = '';
|
195 |
+
if ( '' == $plugin_dir ) {
|
196 |
+
$plugin_dir = str_replace($this->normalize_path(WP_PLUGIN_DIR), '', $this->normalize_path(dirname(dirname(__FILE__))));
|
197 |
+
}
|
198 |
+
return $plugin_dir;
|
199 |
+
}
|
200 |
|
201 |
function get_plugin_base_file() {
|
202 |
$file = 'main.php';
|
205 |
|
206 |
function get_plugin_base_name() {
|
207 |
$file = $this->get_plugin_base_file();
|
208 |
+
return plugin_basename($file);
|
|
|
|
|
209 |
}
|
210 |
|
211 |
/**
|
212 |
* Retrieve current action based on URL query variables
|
213 |
+
* @param mixed $default (optional) Default action if no action exists
|
214 |
* @return string Current action
|
215 |
*/
|
216 |
function get_action($default = null) {
|
217 |
$action = '';
|
218 |
+
|
219 |
+
//Check if action is set in URL
|
220 |
if ( isset($_GET['action']) )
|
221 |
$action = $_GET['action'];
|
222 |
+
//Otherwise, Determine action based on plugin plugin admin page suffix
|
223 |
elseif ( isset($_GET['page']) && ($pos = strrpos($_GET['page'], '-')) && $pos !== false && ( $pos != count($_GET['page']) - 1 ) )
|
224 |
+
$action = trim(substr($_GET['page'], $pos + 1), '-_');
|
225 |
+
|
226 |
+
//Determine action for core admin pages
|
227 |
+
if ( ! isset($_GET['page']) || empty($action) ) {
|
228 |
+
$actions = array(
|
229 |
+
'add' => array('page-new', 'post-new'),
|
230 |
+
'edit-item' => array('page', 'post'),
|
231 |
+
'edit' => array('edit', 'edit-pages')
|
232 |
+
);
|
233 |
+
$page = basename($_SERVER['SCRIPT_NAME'], '.php');
|
234 |
+
|
235 |
+
foreach ( $actions as $act => $pages ) {
|
236 |
+
if ( in_array($page, $pages) ) {
|
237 |
+
$action = $act;
|
238 |
+
break;
|
239 |
+
}
|
240 |
+
}
|
241 |
+
}
|
242 |
if ( empty($action) )
|
243 |
$action = $default;
|
244 |
return $action;
|
297 |
* - If the current item's value OR the corresponding item in the base array is NOT an array, current item overwrites base item
|
298 |
* @todo Append numerical elements (as opposed to overwriting element at same index in base array)
|
299 |
* @param array Variable number of arrays
|
300 |
+
* @param array $arr1 Default array
|
301 |
* @return array Merged array
|
302 |
*/
|
303 |
+
function array_merge_recursive_distinct($arr1) {
|
304 |
//Get all arrays passed to function
|
305 |
$args = func_get_args();
|
306 |
if (empty($args))
|
440 |
return $path;
|
441 |
}
|
442 |
|
443 |
+
/**
|
444 |
+
* Builds attribute string for HTML element
|
445 |
+
* @param array $attr Attributes
|
446 |
+
* @return string Formatted attribute string
|
447 |
+
*/
|
448 |
+
function build_attribute_string($attr) {
|
449 |
$ret = '';
|
450 |
+
if ( is_object($attr) )
|
451 |
+
$attr = (array) $attr;
|
452 |
+
if ( is_array($attr) ) {
|
453 |
+
array_map('esc_attr', $attr);
|
454 |
+
$attr_str = array();
|
455 |
+
foreach ( $attr as $key => $val ) {
|
456 |
+
$attr_str[] = $key . '="' . $val . '"';
|
457 |
+
}
|
458 |
+
$ret = implode(' ', $attr_str);
|
459 |
}
|
460 |
+
return $ret;
|
461 |
+
}
|
462 |
+
|
463 |
+
/**
|
464 |
+
* Generate external stylesheet element
|
465 |
+
* @param $url Stylesheet URL
|
466 |
+
* @return string Stylesheet element
|
467 |
+
*/
|
468 |
+
function build_stylesheet_element($url = '') {
|
469 |
+
$attributes = array('href' => $url, 'type' => 'text/css', 'rel' => 'stylesheet');
|
470 |
+
return $this->build_html_element(array('tag' => 'link', 'wrap' => false, 'attributes' => $attributes));
|
471 |
+
}
|
472 |
+
|
473 |
+
/**
|
474 |
+
* Generate external script element
|
475 |
+
* @param $url Script URL
|
476 |
+
* @return string Script element
|
477 |
+
*/
|
478 |
+
function build_ext_script_element($url = '') {
|
479 |
+
$attributes = array('src' => $url, 'type' => 'text/javascript');
|
480 |
+
return $this->build_html_element(array('tag' => 'script', 'attributes' => $attributes));
|
481 |
+
}
|
482 |
+
|
483 |
+
/**
|
484 |
+
* Generate HTML element based on values
|
485 |
+
* @param $args Element arguments
|
486 |
+
* @return string Generated HTML element
|
487 |
+
*/
|
488 |
+
function build_html_element($args) {
|
489 |
+
$defaults = array(
|
490 |
+
'tag' => 'span',
|
491 |
+
'wrap' => true,
|
492 |
+
'content' => '',
|
493 |
+
'attributes' => array()
|
494 |
+
);
|
495 |
+
$el_start = '<';
|
496 |
+
$el_end = '>';
|
497 |
+
$el_close = '/';
|
498 |
+
extract(wp_parse_args($args, $defaults), EXTR_SKIP);
|
499 |
+
$content = trim($content);
|
500 |
+
|
501 |
+
if ( !$wrap && strlen($content) > 0 )
|
502 |
+
$wrap = true;
|
503 |
+
|
504 |
+
$attributes = $this->build_attribute_string($attributes);
|
505 |
+
if ( strlen($attributes) > 0 )
|
506 |
+
$attributes = ' ' . $attributes;
|
507 |
+
|
508 |
+
$ret = $el_start . $tag . $attributes;
|
509 |
+
|
510 |
+
if ( $wrap )
|
511 |
+
$ret .= $el_end . $content . $el_start . $el_close . $tag;
|
512 |
+
else
|
513 |
+
$ret .= ' ' . $el_close;
|
514 |
+
|
515 |
+
$ret .= $el_end;
|
516 |
+
return $ret;
|
517 |
}
|
518 |
|
519 |
/*-** Admin **-*/
|
521 |
/**
|
522 |
* Add submenu page in the admin menu
|
523 |
* Adds ability to set the position of the page in the menu
|
524 |
+
* @see add_submenu_page (Wraps functionality)
|
525 |
*
|
526 |
* @param $parent
|
527 |
* @param $page_title
|
533 |
*
|
534 |
* @global array $submenu Admin page submenus
|
535 |
*/
|
536 |
+
function add_submenu_page($parent, $page_title, $menu_title, $capability, $file, $function = '', $pos = false) {
|
|
|
|
|
537 |
//Add submenu page as usual
|
538 |
$args = func_get_args();
|
539 |
$hookname = call_user_func_array('add_submenu_page', $args);
|
|
|
540 |
if ( is_int($pos) ) {
|
541 |
+
global $submenu;
|
542 |
//Get last submenu added
|
543 |
$parent = $this->get_submenu_parent_file($parent);
|
544 |
+
if ( isset($submenu[$parent]) ) {
|
545 |
+
$subs =& $submenu[$parent];
|
546 |
+
//Make sure menu isn't already in the desired position
|
547 |
+
if ( $pos <= ( count($subs) - 1 ) ) {
|
548 |
+
//Get submenu that was just added
|
549 |
+
$sub = array_pop($subs);
|
550 |
+
//Insert into desired position
|
551 |
+
if ( 0 == $pos ) {
|
552 |
+
array_unshift($subs, $sub);
|
553 |
+
} else {
|
554 |
+
$top = array_slice($subs, 0, $pos);
|
555 |
+
$bottom = array_slice($subs, $pos);
|
556 |
+
array_push($top, $sub);
|
557 |
+
$subs = array_merge($top, $bottom);
|
558 |
+
}
|
559 |
}
|
560 |
}
|
561 |
}
|
js/dev/lightbox.js
CHANGED
@@ -269,7 +269,7 @@ var Lightbox = {
|
|
269 |
if ( caption == '' ) {
|
270 |
var inner = $(imageLink).getElementsBySelector('img').first();
|
271 |
if ( inner )
|
272 |
-
caption = inner.getAttribute('
|
273 |
if ( !caption )
|
274 |
caption = imageLink.innerHTML.stripTags() || imageLink.href || '';
|
275 |
}
|
@@ -716,6 +716,4 @@ var Lightbox = {
|
|
716 |
}
|
717 |
}
|
718 |
|
719 |
-
// -----------------------------------------------------------------------------------
|
720 |
-
|
721 |
-
//Event.observe(window,'load',function(){ Lightbox.initialize(); });
|
269 |
if ( caption == '' ) {
|
270 |
var inner = $(imageLink).getElementsBySelector('img').first();
|
271 |
if ( inner )
|
272 |
+
caption = inner.getAttribute('title') || inner.getAttribute('alt');
|
273 |
if ( !caption )
|
274 |
caption = imageLink.innerHTML.stripTags() || imageLink.href || '';
|
275 |
}
|
716 |
}
|
717 |
}
|
718 |
|
719 |
+
// -----------------------------------------------------------------------------------
|
|
|
|
js/lib.js
CHANGED
@@ -190,7 +190,7 @@ e=document.createElement("div");e.setAttribute("id",this.getID("close"));c.appen
|
|
190 |
c.setAttribute("id",this.getID("imageContainer"));e.appendChild(c);e=document.createElement("img");e.setAttribute("id",this.getID("lightboxImage"));c.appendChild(e);e=document.createElement("div");e.setAttribute("id",this.getID("hoverNav"));c.appendChild(e);d=document.createElement("a");d.setAttribute("id",this.getID("prevLinkImg"));d.setAttribute("href","javascript:void(0);");e.appendChild(d);Event.observe(d,"click",this.showPrev.bindAsEventListener(this));d=document.createElement("a");d.setAttribute("id",
|
191 |
this.getID("nextLinkImg"));d.setAttribute("href","javascript:void(0);");e.appendChild(d);Event.observe(d,"click",this.showNext.bindAsEventListener(this));e=document.createElement("div");e.setAttribute("id",this.getID("loading"));c.appendChild(e);c=document.createElement("a");c.setAttribute("id",this.getID("loadingLink"));c.setAttribute("href","javascript:void(0);");c.innerHTML=this.options.strings.loadingMsg;e.appendChild(c);Event.observe(c,"click",this.end.bindAsEventListener(this));this.options.imageDataLocation!=
|
192 |
"north"&&a.appendChild(b);this.options.initImage!=""&&this.start($(this.options.initImage))}},updateImageList:function(){for(var a,b,c,d=0;d<this.refTags.length;d++){b=this.container.getElementsByTagName(this.refTags[d]);for(var e=0;e<b.length;e++){a=b[e];c=String(a.getAttribute("rel"));if(a.getAttribute("href")&&c.toLowerCase().match(this.relAttribute))a.onclick=function(){Lightbox.start(this);return false}}}},getCaption:function(a){var b=a.title||"";if(b==""){var c=$(a).getElementsBySelector("img").first();
|
193 |
-
if(c)b=c.getAttribute("
|
194 |
title:d});this.startImage=0}else{for(var e=this.container.getElementsByTagName(a.tagName),f=0;f<e.length;f++){var g=e[f];if(g.getAttribute("href")&&g.getAttribute("rel")==c){d=this.getCaption(g);this.imageArray.push({link:g.getAttribute("href"),title:d});if(g==a)this.startImage=this.imageArray.length-1}}this.groupName=c.substring(this.relAttribute.length+1,c.length-1)}a=this.getPageScroll().y+b.winHeight/15;$(this.getID("lightbox")).setStyle({top:a+"px"}).show();this.changeImage(this.startImage)},
|
195 |
changeImage:function(a){this.activeImage=a;this.disableKeyboardNav();this.pauseSlideShow();$(this.getID("loading")).show();$(this.getID("lightboxImage")).hide();$(this.getID("hoverNav")).hide();$(this.getID("imageDataContainer")).hide();$(this.getID("numberDisplay")).hide();$(this.getID("detailsNav")).hide();var b=new Image;b.onload=function(){$(Lightbox.getID("lightboxImage")).src=b.src;Lightbox.resizeImageContainer(b.width,b.height)};b.src=this.imageArray[this.activeImage].link;this.options.googleAnalytics&&
|
196 |
urchinTracker(this.imageArray[this.activeImage].link)},resizeImageContainer:function(a,b){var c=$(this.getID("outerImageContainer")).getDimensions(),d=(a+this.options.borderSize*2)/c.width*100,e=(b+this.options.borderSize*2)/c.height*100,f=c.width-this.options.borderSize*2-a;c=c.height-this.options.borderSize*2-b;c!=0&&new Effect.Scale(this.getID("outerImageContainer"),e,{scaleX:false,duration:this.resizeDuration,queue:"front"});f!=0&&new Effect.Scale(this.getID("outerImageContainer"),d,{scaleY:false,
|
190 |
c.setAttribute("id",this.getID("imageContainer"));e.appendChild(c);e=document.createElement("img");e.setAttribute("id",this.getID("lightboxImage"));c.appendChild(e);e=document.createElement("div");e.setAttribute("id",this.getID("hoverNav"));c.appendChild(e);d=document.createElement("a");d.setAttribute("id",this.getID("prevLinkImg"));d.setAttribute("href","javascript:void(0);");e.appendChild(d);Event.observe(d,"click",this.showPrev.bindAsEventListener(this));d=document.createElement("a");d.setAttribute("id",
|
191 |
this.getID("nextLinkImg"));d.setAttribute("href","javascript:void(0);");e.appendChild(d);Event.observe(d,"click",this.showNext.bindAsEventListener(this));e=document.createElement("div");e.setAttribute("id",this.getID("loading"));c.appendChild(e);c=document.createElement("a");c.setAttribute("id",this.getID("loadingLink"));c.setAttribute("href","javascript:void(0);");c.innerHTML=this.options.strings.loadingMsg;e.appendChild(c);Event.observe(c,"click",this.end.bindAsEventListener(this));this.options.imageDataLocation!=
|
192 |
"north"&&a.appendChild(b);this.options.initImage!=""&&this.start($(this.options.initImage))}},updateImageList:function(){for(var a,b,c,d=0;d<this.refTags.length;d++){b=this.container.getElementsByTagName(this.refTags[d]);for(var e=0;e<b.length;e++){a=b[e];c=String(a.getAttribute("rel"));if(a.getAttribute("href")&&c.toLowerCase().match(this.relAttribute))a.onclick=function(){Lightbox.start(this);return false}}}},getCaption:function(a){var b=a.title||"";if(b==""){var c=$(a).getElementsBySelector("img").first();
|
193 |
+
if(c)b=c.getAttribute("title")||c.getAttribute("alt");b||(b=a.innerHTML.stripTags()||a.href||"")}return b},start:function(a){this.hideBadObjects();var b=this.getPageSize();$(this.getID("overlay")).setStyle({height:b.pageHeight+"px"});new Effect.Appear(this.getID("overlay"),{duration:this.overlayDuration,from:0,to:this.overlayOpacity});this.imageArray=[];this.groupName=null;var c=a.getAttribute("rel"),d="";if(c==this.relAttribute){d=this.getCaption(a);this.imageArray.push({link:a.getAttribute("href"),
|
194 |
title:d});this.startImage=0}else{for(var e=this.container.getElementsByTagName(a.tagName),f=0;f<e.length;f++){var g=e[f];if(g.getAttribute("href")&&g.getAttribute("rel")==c){d=this.getCaption(g);this.imageArray.push({link:g.getAttribute("href"),title:d});if(g==a)this.startImage=this.imageArray.length-1}}this.groupName=c.substring(this.relAttribute.length+1,c.length-1)}a=this.getPageScroll().y+b.winHeight/15;$(this.getID("lightbox")).setStyle({top:a+"px"}).show();this.changeImage(this.startImage)},
|
195 |
changeImage:function(a){this.activeImage=a;this.disableKeyboardNav();this.pauseSlideShow();$(this.getID("loading")).show();$(this.getID("lightboxImage")).hide();$(this.getID("hoverNav")).hide();$(this.getID("imageDataContainer")).hide();$(this.getID("numberDisplay")).hide();$(this.getID("detailsNav")).hide();var b=new Image;b.onload=function(){$(Lightbox.getID("lightboxImage")).src=b.src;Lightbox.resizeImageContainer(b.width,b.height)};b.src=this.imageArray[this.activeImage].link;this.options.googleAnalytics&&
|
196 |
urchinTracker(this.imageArray[this.activeImage].link)},resizeImageContainer:function(a,b){var c=$(this.getID("outerImageContainer")).getDimensions(),d=(a+this.options.borderSize*2)/c.width*100,e=(b+this.options.borderSize*2)/c.height*100,f=c.width-this.options.borderSize*2-a;c=c.height-this.options.borderSize*2-b;c!=0&&new Effect.Scale(this.getID("outerImageContainer"),e,{scaleX:false,duration:this.resizeDuration,queue:"front"});f!=0&&new Effect.Scale(this.getID("outerImageContainer"),d,{scaleY:false,
|
main.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Simple Lightbox
|
4 |
Plugin URI: http://archetyped.com/tools/simple-lightbox/
|
5 |
Description: Customizable Lightbox for Wordpress
|
6 |
-
Version: 1.
|
7 |
Author: Archetyped
|
8 |
Author URI: http://archetyped.com
|
9 |
*/
|
3 |
Plugin Name: Simple Lightbox
|
4 |
Plugin URI: http://archetyped.com/tools/simple-lightbox/
|
5 |
Description: Customizable Lightbox for Wordpress
|
6 |
+
Version: 1.3.1
|
7 |
Author: Archetyped
|
8 |
Author URI: http://archetyped.com
|
9 |
*/
|
model.php
CHANGED
@@ -30,16 +30,29 @@ class SLB_Lightbox extends SLB_Base {
|
|
30 |
* @var array
|
31 |
*/
|
32 |
var $options_default = array (
|
33 |
-
'
|
34 |
-
'
|
35 |
-
'
|
36 |
-
'
|
37 |
-
'
|
38 |
-
'
|
39 |
-
'
|
40 |
-
'
|
41 |
-
'
|
42 |
-
'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
);
|
44 |
|
45 |
/*-** Init **-*/
|
@@ -59,14 +72,21 @@ class SLB_Lightbox extends SLB_Base {
|
|
59 |
|
60 |
function register_hooks() {
|
61 |
register_activation_hook($this->util->get_plugin_base_file(), $this->m('activate'));
|
|
|
62 |
//Init lightbox admin
|
63 |
add_action('admin_init', $this->m('admin_settings'));
|
|
|
|
|
|
|
|
|
|
|
64 |
|
|
|
65 |
//Init lightbox (client-side)
|
66 |
add_action('wp_enqueue_scripts', $this->m('enqueue_files'));
|
67 |
add_action('wp_head', $this->m('client_init'));
|
68 |
add_filter('plugin_action_links_' . $this->util->get_plugin_base_name(), $this->m('admin_plugin_action_links'), 10, 4);
|
69 |
-
|
70 |
}
|
71 |
|
72 |
function activate() {
|
@@ -96,7 +116,7 @@ class SLB_Lightbox extends SLB_Base {
|
|
96 |
*/
|
97 |
function is_enabled($check_request = true) {
|
98 |
$ret = ( get_option($this->add_prefix('enabled')) ) ? true : false;
|
99 |
-
if ( $ret &&
|
100 |
$opt = '';
|
101 |
//Determine option to check
|
102 |
if ( is_home() )
|
@@ -171,13 +191,53 @@ class SLB_Lightbox extends SLB_Base {
|
|
171 |
$ret = ( $ret ) ? 'Enabled' : 'Disabled';
|
172 |
if ( is_numeric($ret) )
|
173 |
$ret = strval($ret);
|
|
|
174 |
}
|
|
|
|
|
175 |
}
|
176 |
return $ret;
|
177 |
}
|
178 |
|
179 |
/*-** Frontend **-*/
|
180 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
181 |
/**
|
182 |
* Enqueue files in template head
|
183 |
*/
|
@@ -225,10 +285,31 @@ class SLB_Lightbox extends SLB_Base {
|
|
225 |
$val = 'false';
|
226 |
$lb_obj[] = "'{$option}':{$val}";
|
227 |
}
|
|
|
|
|
|
|
228 |
$js_code[] = 'Lightbox.initialize({' . implode(',', $lb_obj) . '});';
|
229 |
echo $out['script_start'] . implode('', $js_code) . $out['script_end'];
|
230 |
}
|
231 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
232 |
|
233 |
/*-** Admin **-*/
|
234 |
|
@@ -242,11 +323,58 @@ class SLB_Lightbox extends SLB_Base {
|
|
242 |
function admin_plugin_action_links($actions, $plugin_file, $plugin_data, $context) {
|
243 |
//Add link to settings (only if active)
|
244 |
if ( is_plugin_active($this->util->get_plugin_base_name()) ) {
|
245 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
246 |
}
|
247 |
return $actions;
|
248 |
}
|
249 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
250 |
/**
|
251 |
* Adds settings section for Lightbox functionality
|
252 |
* Section is added to Settings > Media Admin menu
|
@@ -267,15 +395,29 @@ class SLB_Lightbox extends SLB_Base {
|
|
267 |
foreach ($this->options_default as $key => $defaults) {
|
268 |
$id = $this->add_prefix($key);
|
269 |
$func = 'admin_field_' . $key;
|
|
|
270 |
$callback = ( method_exists($this, $func) ) ? $this->m($func) : $this->m('admin_field_default');
|
271 |
-
|
272 |
-
if
|
273 |
-
|
274 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
275 |
register_setting($page, $id);
|
276 |
}
|
277 |
}
|
278 |
|
|
|
|
|
|
|
|
|
|
|
|
|
279 |
/**
|
280 |
* Get ID of settings section on admin page
|
281 |
* @return string ID of settings section
|
@@ -304,7 +446,7 @@ class SLB_Lightbox extends SLB_Base {
|
|
304 |
function admin_the_field($option, $format = '', $type = '') {
|
305 |
$opt = $this->get_option($option);
|
306 |
$format_default = '<input id="%1$s" name="%1$s" %4$s class="code" /> (Default: %3$s)';
|
307 |
-
if ( empty($format) )
|
308 |
$format = $format_default;
|
309 |
if ( empty($type) || !is_string($type) ) {
|
310 |
$type_default = 'text';
|
@@ -328,7 +470,16 @@ class SLB_Lightbox extends SLB_Base {
|
|
328 |
$attr = $this->util->build_attribute_string($opt->attr);
|
329 |
}
|
330 |
|
331 |
-
echo sprintf($format, $opt->id, $opt->value, $opt->value_default_formatted, $attr);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
332 |
}
|
333 |
|
334 |
/**
|
30 |
* @var array
|
31 |
*/
|
32 |
var $options_default = array (
|
33 |
+
'header_enabled' => 'Activation',
|
34 |
+
'enabled' => array(true, 'Enable Lightbox Functionality'),
|
35 |
+
'enabled_home' => array(true, 'Enable on Home page'),
|
36 |
+
'enabled_single' => array(true, 'Enable on Single Posts/Pages'),
|
37 |
+
'enabled_archive' => array(true, 'Enable on Archive Pages (tags, categories, etc.)'),
|
38 |
+
'activate_links' => array(true, 'Activate all image links on page'),
|
39 |
+
'header_activation' => 'Grouping',
|
40 |
+
'group_links' => array(true, 'Group automatically activated links (for displaying as a slideshow)'),
|
41 |
+
'group_post' => array(true, 'Group image links by Post (e.g. on pages with multiple posts)'),
|
42 |
+
'header_ui' => 'UI',
|
43 |
+
'autostart' => array(true, 'Automatically Start Slideshow'),
|
44 |
+
'duration' => array(6, 'Slide Duration (Seconds)', array('size' => 3, 'maxlength' => 3)),
|
45 |
+
'loop' => array(true, 'Loop through images'),
|
46 |
+
'overlay_opacity' => array(0.8, 'Overlay Opacity (0 - 1)', array('size' => 3, 'maxlength' => 3)),
|
47 |
+
'header_strings' => 'Labels',
|
48 |
+
'txt_closeLink' => array('close', 'Close link (for accessibility only, image used for button)'),
|
49 |
+
'txt_loadingMsg' => array('loading', 'Loading indicator'),
|
50 |
+
'txt_nextLink' => array('next »', 'Next Image link'),
|
51 |
+
'txt_prevLink' => array('« prev', 'Previous Image link'),
|
52 |
+
'txt_startSlideshow' => array('start slideshow', 'Start Slideshow link'),
|
53 |
+
'txt_stopSlideshow' => array('stop slideshow', 'Stop Slideshow link'),
|
54 |
+
'txt_numDisplayPrefix' => array('Image', 'Image number prefix (e.g. <strong>Image</strong> x of y)'),
|
55 |
+
'txt_numDisplaySeparator' => array('of', 'Image number separator (e.g. Image x <strong>of</strong> y)')
|
56 |
);
|
57 |
|
58 |
/*-** Init **-*/
|
72 |
|
73 |
function register_hooks() {
|
74 |
register_activation_hook($this->util->get_plugin_base_file(), $this->m('activate'));
|
75 |
+
/* Admin */
|
76 |
//Init lightbox admin
|
77 |
add_action('admin_init', $this->m('admin_settings'));
|
78 |
+
//Enqueue header files (CSS/JS)
|
79 |
+
add_action('admin_enqueue_scripts', $this->m('admin_enqueue_files'));
|
80 |
+
//Reset Settings
|
81 |
+
add_action('admin_action_' . $this->add_prefix('reset'), $this->m('admin_reset'));
|
82 |
+
add_action('admin_notices', $this->m('admin_notices'));
|
83 |
|
84 |
+
/* Client-side */
|
85 |
//Init lightbox (client-side)
|
86 |
add_action('wp_enqueue_scripts', $this->m('enqueue_files'));
|
87 |
add_action('wp_head', $this->m('client_init'));
|
88 |
add_filter('plugin_action_links_' . $this->util->get_plugin_base_name(), $this->m('admin_plugin_action_links'), 10, 4);
|
89 |
+
add_filter('the_content', $this->m('activate_post_links'));
|
90 |
}
|
91 |
|
92 |
function activate() {
|
116 |
*/
|
117 |
function is_enabled($check_request = true) {
|
118 |
$ret = ( get_option($this->add_prefix('enabled')) ) ? true : false;
|
119 |
+
if ( $ret && $check_request ) {
|
120 |
$opt = '';
|
121 |
//Determine option to check
|
122 |
if ( is_home() )
|
191 |
$ret = ( $ret ) ? 'Enabled' : 'Disabled';
|
192 |
if ( is_numeric($ret) )
|
193 |
$ret = strval($ret);
|
194 |
+
$ret = htmlentities($ret);
|
195 |
}
|
196 |
+
} elseif ( ! is_array($this->options_default[$option]) ) {
|
197 |
+
$ret = $this->options_default[$option];
|
198 |
}
|
199 |
return $ret;
|
200 |
}
|
201 |
|
202 |
/*-** Frontend **-*/
|
203 |
|
204 |
+
/**
|
205 |
+
* Scans post content for image links and activates them
|
206 |
+
*
|
207 |
+
* Lightbox will not be activated for feeds
|
208 |
+
* @param $content
|
209 |
+
*/
|
210 |
+
function activate_post_links($content) {
|
211 |
+
//Check option
|
212 |
+
if ( ! is_feed() && $this->is_enabled() && $this->get_option_value('activate_links') && $this->get_option_value('group_links') && $this->get_option_value('group_post') ) {
|
213 |
+
//Scan for links
|
214 |
+
$matches = array();
|
215 |
+
if ( preg_match_all("/\<a[^\>]*href=[^\s]+\.(?:jp[e]*g|gif|png).*?\>/i", $content, $matches) ) {
|
216 |
+
global $post;
|
217 |
+
//Iterate through links & add lightbox if necessary
|
218 |
+
foreach ($matches[0] as $link) {
|
219 |
+
//Check if rel attribute exists
|
220 |
+
$link_new = $link;
|
221 |
+
$rel = '';
|
222 |
+
if ( strpos(strtolower($link_new), ' rel=') !== false && preg_match("/\s+rel=(?:\"|')(.*?)(?:\"|')(\s|\>)/i", $link_new, $rel) ) {
|
223 |
+
//Check if lightbox is already set in rel attribute
|
224 |
+
$link_new = str_replace($rel[0], $rel[2], $link_new);
|
225 |
+
$rel = $rel[1];
|
226 |
+
}
|
227 |
+
|
228 |
+
if ( strpos($rel, 'lightbox') === false) {
|
229 |
+
//Add rel attribute to link
|
230 |
+
$rel .= ' lightbox[' . $this->add_prefix($post->ID) . ']';
|
231 |
+
$link_new = '<a rel="' . $rel . '"' . substr($link_new,2);
|
232 |
+
//Insert modified link
|
233 |
+
$content = str_replace($link, $link_new, $content);
|
234 |
+
}
|
235 |
+
}
|
236 |
+
}
|
237 |
+
}
|
238 |
+
return $content;
|
239 |
+
}
|
240 |
+
|
241 |
/**
|
242 |
* Enqueue files in template head
|
243 |
*/
|
285 |
$val = 'false';
|
286 |
$lb_obj[] = "'{$option}':{$val}";
|
287 |
}
|
288 |
+
//Load UI Strings
|
289 |
+
if ( ($strings = $this->build_strings()) && !empty($strings) )
|
290 |
+
$lb_obj[] = $strings;
|
291 |
$js_code[] = 'Lightbox.initialize({' . implode(',', $lb_obj) . '});';
|
292 |
echo $out['script_start'] . implode('', $js_code) . $out['script_end'];
|
293 |
}
|
294 |
|
295 |
+
/**
|
296 |
+
* Build JS object of UI strings when initializing lightbox
|
297 |
+
* @return string JS object of UI strings
|
298 |
+
*/
|
299 |
+
function build_strings() {
|
300 |
+
$ret = '';
|
301 |
+
$prefix = 'txt_';
|
302 |
+
$opt_strings = array_filter(array_keys($this->options_default), create_function('$opt', 'return ( strpos($opt, "' . $prefix . '") === 0 );'));
|
303 |
+
if ( $opt_strings ) {
|
304 |
+
$strings = array();
|
305 |
+
foreach ( $opt_strings as $key ) {
|
306 |
+
$name = substr($key, strlen($prefix));
|
307 |
+
$strings[] = "'" . $name . "':'" . $this->get_option_value($key) . "'";
|
308 |
+
}
|
309 |
+
$ret = "'strings':{" . implode(',', $strings) . "}";
|
310 |
+
}
|
311 |
+
return $ret;
|
312 |
+
}
|
313 |
|
314 |
/*-** Admin **-*/
|
315 |
|
323 |
function admin_plugin_action_links($actions, $plugin_file, $plugin_data, $context) {
|
324 |
//Add link to settings (only if active)
|
325 |
if ( is_plugin_active($this->util->get_plugin_base_name()) ) {
|
326 |
+
$settings = __('Settings');
|
327 |
+
$reset = __('Reset');
|
328 |
+
$reset_confirm = "'" . __('Are you sure you want to reset your settings?') . "'";
|
329 |
+
$action = $this->add_prefix('reset');
|
330 |
+
$reset_link = wp_nonce_url(add_query_arg('action', $action, remove_query_arg(array($this->add_prefix('action'), 'action'), $_SERVER['REQUEST_URI'])), $action);
|
331 |
+
array_unshift($actions, '<a class="delete" href="options-media.php#' . $this->admin_get_settings_section() . '" title="' . $settings . '">' . $settings . '</a>');
|
332 |
+
array_splice($actions, 1, 0, '<a id="' . $this->add_prefix('reset') . '" href="' . $reset_link . '" onclick="return confirm(' . $reset_confirm . ');" title="' . $reset . '">' . $reset . '</a>');
|
333 |
}
|
334 |
return $actions;
|
335 |
}
|
336 |
|
337 |
+
/**
|
338 |
+
* Reset plugin settings
|
339 |
+
* Redirects to referring page upon completion
|
340 |
+
*/
|
341 |
+
function admin_reset() {
|
342 |
+
//Validate user
|
343 |
+
if ( ! current_user_can('activate_plugins') || ! check_admin_referer($this->add_prefix('reset')) )
|
344 |
+
wp_die(__('You do not have sufficient permissions to manage plugins for this blog.'));
|
345 |
+
$action = 'reset';
|
346 |
+
if ( isset($_REQUEST['action']) && $this->add_prefix($action) == $_REQUEST['action'] ) {
|
347 |
+
//Reset settings
|
348 |
+
$this->reset_options(true);
|
349 |
+
$uri = remove_query_arg(array('_wpnonce', 'action'), add_query_arg(array($this->add_prefix('action') => $action), $_SERVER['REQUEST_URI']));
|
350 |
+
//Redirect user
|
351 |
+
wp_redirect($uri);
|
352 |
+
exit;
|
353 |
+
}
|
354 |
+
}
|
355 |
+
|
356 |
+
/**
|
357 |
+
* Displays notices for admin operations
|
358 |
+
*/
|
359 |
+
function admin_notices() {
|
360 |
+
if ( is_admin() && isset($_REQUEST[$this->add_prefix('action')]) ) {
|
361 |
+
$action = $_REQUEST[$this->add_prefix('action')];
|
362 |
+
$msg = null;
|
363 |
+
if ( $action ) {
|
364 |
+
switch ( $action ) {
|
365 |
+
case 'reset':
|
366 |
+
$msg = "Simple Lightbox's settings have been <strong>reset</strong>";
|
367 |
+
break;
|
368 |
+
}
|
369 |
+
if ( ! is_null($msg) ) {
|
370 |
+
?>
|
371 |
+
<div id="message" class="updated fade"><p><?php _e($msg); ?></p></div>
|
372 |
+
<?php
|
373 |
+
}
|
374 |
+
}
|
375 |
+
}
|
376 |
+
}
|
377 |
+
|
378 |
/**
|
379 |
* Adds settings section for Lightbox functionality
|
380 |
* Section is added to Settings > Media Admin menu
|
395 |
foreach ($this->options_default as $key => $defaults) {
|
396 |
$id = $this->add_prefix($key);
|
397 |
$func = 'admin_field_' . $key;
|
398 |
+
$label = ( isset($defaults[1]) ) ? $defaults[1] : '';
|
399 |
$callback = ( method_exists($this, $func) ) ? $this->m($func) : $this->m('admin_field_default');
|
400 |
+
$args = array('opt' => $key);
|
401 |
+
//Check if option is a section header
|
402 |
+
if ( ! is_array($defaults) ) {
|
403 |
+
$label = '<h4 class="subhead">' . $defaults . '</h4>';
|
404 |
+
$callback = $this->m('admin_field_header');
|
405 |
+
} elseif ( is_null(get_option($id, null)) ) {
|
406 |
+
//Add option to DB if not yet set
|
407 |
+
$args['label_for'] = $id;
|
408 |
+
update_option($id, htmlentities2($defaults[0]));
|
409 |
+
}
|
410 |
+
add_settings_field($id, __($label), $callback, $page, $section, $args);
|
411 |
register_setting($page, $id);
|
412 |
}
|
413 |
}
|
414 |
|
415 |
+
function admin_enqueue_files() {
|
416 |
+
if ( is_admin() && basename($_SERVER['SCRIPT_NAME']) == $this->options_admin_page ) {
|
417 |
+
wp_enqueue_style($this->add_prefix('admin_styles'), $this->util->get_file_url('css/admin.css'));
|
418 |
+
}
|
419 |
+
}
|
420 |
+
|
421 |
/**
|
422 |
* Get ID of settings section on admin page
|
423 |
* @return string ID of settings section
|
446 |
function admin_the_field($option, $format = '', $type = '') {
|
447 |
$opt = $this->get_option($option);
|
448 |
$format_default = '<input id="%1$s" name="%1$s" %4$s class="code" /> (Default: %3$s)';
|
449 |
+
if ( empty($format) && $format !== false )
|
450 |
$format = $format_default;
|
451 |
if ( empty($type) || !is_string($type) ) {
|
452 |
$type_default = 'text';
|
470 |
$attr = $this->util->build_attribute_string($opt->attr);
|
471 |
}
|
472 |
|
473 |
+
echo sprintf($format, $opt->id, htmlentities($opt->value), $opt->value_default_formatted, $attr);
|
474 |
+
}
|
475 |
+
|
476 |
+
/**
|
477 |
+
* Builds header for settings subsection
|
478 |
+
* @param array $args Arguments set in admin_settings
|
479 |
+
*/
|
480 |
+
function admin_field_header($args) {
|
481 |
+
$opt = ( isset($args['opt']) ) ? $args['opt'] : '';
|
482 |
+
$this->admin_the_field($opt, false, 'header');
|
483 |
}
|
484 |
|
485 |
/**
|
readme.txt
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
Contributors: archetyped
|
3 |
Tags: lightbox, gallery, photography, images
|
4 |
Requires at least: 2.9.2
|
5 |
-
Tested up to:
|
6 |
Stable tag: trunk
|
7 |
|
8 |
A simple and customizable Lightbox for Wordpress
|
@@ -14,10 +14,12 @@ Simple Lightbox is a very simple and customizable lightbox that is easy to add t
|
|
14 |
#### Customization
|
15 |
Options for customizing the lightbox behavior are located in the **Settings > Media** admin menu in the **Lightbox Settings** section (or just click the **Settings** link below the plugin's name when viewing the list of installed plugins)
|
16 |
|
|
|
17 |
* Enable/Disable Lightbox Functionality (Default: Enabled)
|
18 |
* Enable Lightbox depending on Page Type (Home, Pages, Archive, etc.)
|
19 |
* Automatically activate lightbox for links to images on page (no need to add `rel="lightbox"` attribute to link)
|
20 |
* Group automatically-activated links (play as a slideshow)
|
|
|
21 |
* Automatically Start Slideshow (Default: Enabled)
|
22 |
* Slide Duration (Seconds) (Default: 6)
|
23 |
* Loop through images (Default: Enabled)
|
@@ -44,9 +46,21 @@ Send your questions to wp@archetyped.com
|
|
44 |
|
45 |
== Screenshots ==
|
46 |
|
47 |
-
1. Lightbox Options
|
|
|
48 |
|
49 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
= 1.2 =
|
51 |
* Added: Option to group automatically activated links
|
52 |
* Optimized: Lightbox caption retrieval
|
2 |
Contributors: archetyped
|
3 |
Tags: lightbox, gallery, photography, images
|
4 |
Requires at least: 2.9.2
|
5 |
+
Tested up to: 3.0
|
6 |
Stable tag: trunk
|
7 |
|
8 |
A simple and customizable Lightbox for Wordpress
|
14 |
#### Customization
|
15 |
Options for customizing the lightbox behavior are located in the **Settings > Media** admin menu in the **Lightbox Settings** section (or just click the **Settings** link below the plugin's name when viewing the list of installed plugins)
|
16 |
|
17 |
+
* Customizable UI Text
|
18 |
* Enable/Disable Lightbox Functionality (Default: Enabled)
|
19 |
* Enable Lightbox depending on Page Type (Home, Pages, Archive, etc.)
|
20 |
* Automatically activate lightbox for links to images on page (no need to add `rel="lightbox"` attribute to link)
|
21 |
* Group automatically-activated links (play as a slideshow)
|
22 |
+
* Group image links by Post (separate slideshow for each Post on page)
|
23 |
* Automatically Start Slideshow (Default: Enabled)
|
24 |
* Slide Duration (Seconds) (Default: 6)
|
25 |
* Loop through images (Default: Enabled)
|
46 |
|
47 |
== Screenshots ==
|
48 |
|
49 |
+
1. Lightbox Customization Options
|
50 |
+
2. Customized UI Text
|
51 |
|
52 |
== Changelog ==
|
53 |
+
= 1.3.1 =
|
54 |
+
* Updated: Utilities code (internal)
|
55 |
+
= 1.3 =
|
56 |
+
* Added: Customizable UI label text (close, next, and prev button images can be replaced in `images` directory)
|
57 |
+
* Added: Group image links by Post (separate slideshow for each post)
|
58 |
+
* Added: Reset settings link on plugin listings page
|
59 |
+
* Optimized: Organized settings page
|
60 |
+
|
61 |
+
= 1.2.1 =
|
62 |
+
* Fixed: Image title given higher precedence than Image alt (more compatible w/WP workflow)
|
63 |
+
|
64 |
= 1.2 =
|
65 |
* Added: Option to group automatically activated links
|
66 |
* Optimized: Lightbox caption retrieval
|
screenshot-1.gif
CHANGED
Binary file
|
screenshot-2.gif
ADDED
Binary file
|