Version Description
(2010-01-21) = * CHANGE: fixed settings page, options can be saved now * NEW: added settings deletion on uninstall and "delete settings from database" functionality to settings page * CHANGE: moved adding of CSS class priority lower, hopefully now the CSS class is added to pictures after other plugins update the HTML * CHANGE: updated the FAQ
Download this release
Release Info
Developer | techotronic |
Plugin | jQuery Colorbox |
Version | 1.3.3 |
Comparing to | |
See all releases |
Code changes from version 1.3.2 to 1.3.3
- jquery-colorbox.php +278 -90
- readme.txt +42 -19
jquery-colorbox.php
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
* Plugin Name: jQuery Colorbox
|
7 |
* Plugin URI: http://www.techotronic.de/index.php/plugins/jquery-colorbox/
|
8 |
* Description: Used to overlay images on the current page. Images in one post are grouped automatically.
|
9 |
-
* Version: 1.3.
|
10 |
* Author: Arne Franken
|
11 |
* Author URI: http://www.techotronic.de/
|
12 |
* License: GPL
|
@@ -27,6 +27,10 @@ class jQueryColorbox {
|
|
27 |
|
28 |
/**
|
29 |
* Plugin initialization
|
|
|
|
|
|
|
|
|
30 |
*/
|
31 |
function jQueryColorbox() {
|
32 |
if ( !function_exists('plugins_url') )
|
@@ -36,8 +40,15 @@ class jQueryColorbox {
|
|
36 |
load_plugin_textdomain( 'jquery-colorbox', false, '/jquery-colorbox/localization/' );
|
37 |
|
38 |
add_action( 'wp_head', array(&$this, 'buildWordpressHeader') );
|
39 |
-
add_action( 'admin_menu', array(&$this, 'registerSettingsPage') );
|
40 |
add_action( 'admin_init', array(&$this, 'registerSettings') );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
if ( !is_admin() ) {
|
43 |
wp_enqueue_script( 'colorbox', plugins_url( 'js/jquery.colorbox-min.js', __FILE__ ), array( 'jquery' ), '1.3.6' );
|
@@ -50,18 +61,17 @@ class jQueryColorbox {
|
|
50 |
}
|
51 |
|
52 |
// Create list of themes and their human readable names
|
53 |
-
$this->colorboxThemes =
|
54 |
'theme1' => __( 'Theme #1', 'jquery-colorbox' ),
|
55 |
'theme2' => __( 'Theme #2', 'jquery-colorbox' ),
|
56 |
'theme3' => __( 'Theme #3', 'jquery-colorbox' ),
|
57 |
'theme4' => __( 'Theme #4', 'jquery-colorbox' ),
|
58 |
'theme5' => __( 'Theme #5', 'jquery-colorbox' ),
|
59 |
-
)
|
60 |
|
61 |
-
// Create array of default settings
|
62 |
-
$colorboxDefaultTheme = key( $this->colorboxThemes );
|
63 |
$this->colorboxDefaultSettings = array(
|
64 |
-
'colorboxTheme' =>
|
65 |
'maxWidth' => 'false',
|
66 |
'maxHeight' => 'false',
|
67 |
'height' => 'false',
|
@@ -82,6 +92,10 @@ class jQueryColorbox {
|
|
82 |
|
83 |
/**
|
84 |
* Register the settings page in wordpress
|
|
|
|
|
|
|
|
|
85 |
*/
|
86 |
function registerSettingsPage() {
|
87 |
static $plugin_basename;
|
@@ -97,6 +111,10 @@ class jQueryColorbox {
|
|
97 |
/**
|
98 |
* Add settings link to plugin management page
|
99 |
*
|
|
|
|
|
|
|
|
|
100 |
* @param original action_links
|
101 |
* @return action_links with link to settings page
|
102 |
*/
|
@@ -113,6 +131,10 @@ class jQueryColorbox {
|
|
113 |
|
114 |
/**
|
115 |
* Register the plugins settings
|
|
|
|
|
|
|
|
|
116 |
*/
|
117 |
function registerSettings() {
|
118 |
register_setting( 'jquery-colorbox_settings', 'jquery-colorbox_settings', array(&$this, 'validateSettings') );
|
@@ -123,22 +145,26 @@ class jQueryColorbox {
|
|
123 |
/**
|
124 |
* Insert JavaScript for Colorbox into WP Header
|
125 |
*
|
|
|
|
|
|
|
|
|
126 |
* @return rewritten content or excerpt
|
127 |
*/
|
128 |
function buildWordpressHeader() {
|
129 |
?>
|
130 |
-
<!-- jQuery Colorbox | by Arne Franken, http://www.techotronic.de/ -->
|
131 |
<script type="text/javascript">
|
132 |
-
|
133 |
-
jQuery(document).ready(function($){
|
134 |
//gets all "a" elements that have a nested "img"
|
135 |
-
$("a:has(img)").each(function(index, obj){
|
136 |
//in this context, the first child is always an image if fundamental Wordpress functions are used
|
137 |
var $nestedElement = $(obj).children(0);
|
138 |
-
if($nestedElement.is("img")){
|
139 |
var $groupId = $nestedElement.attr("class").match('colorbox-[0-9]+');
|
140 |
//only call colorbox if there is a groupId for the image.
|
141 |
-
if($groupId && !$nestedElement.attr("class").match('colorbox-off')){
|
142 |
//and calls colorbox function on each img.
|
143 |
//elements with the same groupId in the class attribute are grouped
|
144 |
//the title of the img is used as the title for the colorbox.
|
@@ -150,103 +176,132 @@ class jQueryColorbox {
|
|
150 |
}
|
151 |
});
|
152 |
});
|
153 |
-
|
154 |
</script>
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
|
|
|
|
159 |
}
|
160 |
|
161 |
//buildWordpressHeader()
|
162 |
|
163 |
/**
|
164 |
* Render Settings page
|
|
|
|
|
|
|
|
|
165 |
*/
|
166 |
function renderSettingsPage() {
|
167 |
?>
|
|
|
168 |
<div class="wrap">
|
169 |
<?php screen_icon(); ?>
|
170 |
<h2><?php _e( 'jQuery Colorbox Settings', 'jquery-colorbox' ); ?></h2>
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
|
175 |
<?php settings_fields('jquery-colorbox_settings'); ?>
|
176 |
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
<
|
182 |
-
<
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
|
|
|
|
|
|
191 |
echo '<option value="' . esc_attr($theme) . '"';
|
192 |
selected( $this->colorboxSettings['colorboxTheme'], $theme );
|
193 |
echo '>' . htmlspecialchars($name) . "</option>\n";
|
194 |
}
|
195 |
-
?>
|
196 |
-
|
197 |
-
|
198 |
</td>
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
</td>
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
</td>
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
</td>
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
</td>
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
239 |
</p>
|
240 |
-
|
|
|
241 |
</div>
|
242 |
</div>
|
243 |
-
</div>
|
244 |
|
245 |
-
|
246 |
-
|
247 |
-
|
|
|
248 |
<div class="inside">
|
249 |
-
|
250 |
<span style="float: left;">
|
251 |
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
|
252 |
<input type="hidden" name="cmd" value="_s-xclick">
|
@@ -255,25 +310,68 @@ class jQueryColorbox {
|
|
255 |
<img alt="" border="0" src="https://www.paypal.com/de_DE/i/scr/pixel.gif" width="1" height="1">
|
256 |
</form>
|
257 |
</span>
|
258 |
-
|
259 |
-
|
260 |
<?php _e('If you would like to make a small (or large) contribution towards future development please consider making a donation.', 'jquery-colorbox') ?>
|
261 |
-
<br
|
262 |
-
|
|
|
263 |
</div>
|
264 |
</div>
|
265 |
</div>
|
266 |
-
</div>
|
267 |
|
268 |
-
<?php
|
269 |
|
270 |
}
|
271 |
|
272 |
//renderSettingsPage()
|
273 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
274 |
/**
|
275 |
* Validate the settings sent from the settings page
|
276 |
*
|
|
|
|
|
|
|
|
|
277 |
* @param $colorboxSettings settings to be validated
|
278 |
* @return valid settings
|
279 |
*/
|
@@ -285,19 +383,105 @@ class jQueryColorbox {
|
|
285 |
}
|
286 |
|
287 |
// validateSettings()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
288 |
}
|
289 |
|
290 |
// class jQueryColorbox()
|
291 |
?><?php
|
292 |
/**
|
293 |
-
* initialize plugin
|
|
|
|
|
|
|
|
|
294 |
*/
|
295 |
function jQueryColorbox() {
|
296 |
-
global
|
|
|
297 |
$jQueryColorbox = new jQueryColorbox();
|
298 |
}
|
299 |
|
300 |
//jQueryColorbox()
|
|
|
|
|
301 |
add_action( 'init', 'jQueryColorbox', 7 );
|
302 |
|
303 |
/**
|
@@ -308,12 +492,16 @@ add_action( 'init', 'jQueryColorbox', 7 );
|
|
308 |
* unfortunately, Wordpress does not offer a convenient way to get certain elements from the_content,
|
309 |
* so I had to do this by regexp replacement...
|
310 |
*
|
|
|
|
|
|
|
|
|
311 |
* @param the_content or the_excerpt
|
312 |
* @return replaced content or excerpt
|
313 |
*/
|
314 |
-
//TODO: get rid of this...
|
315 |
function addColorboxGroupIdToImages ($content) {
|
316 |
-
global
|
|
|
317 |
$pattern = "/<img(.*?)class=('|\")([A-Za-z0-9 \/_\.\~\:-]*?)('|\")([^\>]*?)>/i";
|
318 |
$replacement = '<img$1class=$2$3 colorbox-'.$post->ID.'$4$5>';
|
319 |
$content = preg_replace($pattern, $replacement, $content);
|
6 |
* Plugin Name: jQuery Colorbox
|
7 |
* Plugin URI: http://www.techotronic.de/index.php/plugins/jquery-colorbox/
|
8 |
* Description: Used to overlay images on the current page. Images in one post are grouped automatically.
|
9 |
+
* Version: 1.3.3
|
10 |
* Author: Arne Franken
|
11 |
* Author URI: http://www.techotronic.de/
|
12 |
* License: GPL
|
27 |
|
28 |
/**
|
29 |
* Plugin initialization
|
30 |
+
*
|
31 |
+
* @since 1.0
|
32 |
+
* @access private
|
33 |
+
* @author Arne Franken
|
34 |
*/
|
35 |
function jQueryColorbox() {
|
36 |
if ( !function_exists('plugins_url') )
|
40 |
load_plugin_textdomain( 'jquery-colorbox', false, '/jquery-colorbox/localization/' );
|
41 |
|
42 |
add_action( 'wp_head', array(&$this, 'buildWordpressHeader') );
|
|
|
43 |
add_action( 'admin_init', array(&$this, 'registerSettings') );
|
44 |
+
add_action('admin_post_jQueryDeleteSettings', array(&$this, 'jQueryDeleteSettings') );
|
45 |
+
add_action('admin_post_jQueryUpdateSettings', array(&$this, 'jQueryUpdateSettings') );
|
46 |
+
// add options page
|
47 |
+
add_action( 'admin_menu', array(&$this, 'registerAdminMenu') );
|
48 |
+
//register plugin for uninstall
|
49 |
+
if ( function_exists('register_uninstall_hook') ){
|
50 |
+
register_uninstall_hook(__FILE__, 'uninstallJqueryColorbox');
|
51 |
+
}
|
52 |
|
53 |
if ( !is_admin() ) {
|
54 |
wp_enqueue_script( 'colorbox', plugins_url( 'js/jquery.colorbox-min.js', __FILE__ ), array( 'jquery' ), '1.3.6' );
|
61 |
}
|
62 |
|
63 |
// Create list of themes and their human readable names
|
64 |
+
$this->colorboxThemes = array(
|
65 |
'theme1' => __( 'Theme #1', 'jquery-colorbox' ),
|
66 |
'theme2' => __( 'Theme #2', 'jquery-colorbox' ),
|
67 |
'theme3' => __( 'Theme #3', 'jquery-colorbox' ),
|
68 |
'theme4' => __( 'Theme #4', 'jquery-colorbox' ),
|
69 |
'theme5' => __( 'Theme #5', 'jquery-colorbox' ),
|
70 |
+
);
|
71 |
|
72 |
+
// Create array of default settings
|
|
|
73 |
$this->colorboxDefaultSettings = array(
|
74 |
+
'colorboxTheme' => 'theme1',
|
75 |
'maxWidth' => 'false',
|
76 |
'maxHeight' => 'false',
|
77 |
'height' => 'false',
|
92 |
|
93 |
/**
|
94 |
* Register the settings page in wordpress
|
95 |
+
*
|
96 |
+
* @since 1.0
|
97 |
+
* @access private
|
98 |
+
* @author Arne Franken
|
99 |
*/
|
100 |
function registerSettingsPage() {
|
101 |
static $plugin_basename;
|
111 |
/**
|
112 |
* Add settings link to plugin management page
|
113 |
*
|
114 |
+
* @since 1.0
|
115 |
+
* @access private
|
116 |
+
* @author Arne Franken
|
117 |
+
*
|
118 |
* @param original action_links
|
119 |
* @return action_links with link to settings page
|
120 |
*/
|
131 |
|
132 |
/**
|
133 |
* Register the plugins settings
|
134 |
+
*
|
135 |
+
* @since 1.0
|
136 |
+
* @access private
|
137 |
+
* @author Arne Franken
|
138 |
*/
|
139 |
function registerSettings() {
|
140 |
register_setting( 'jquery-colorbox_settings', 'jquery-colorbox_settings', array(&$this, 'validateSettings') );
|
145 |
/**
|
146 |
* Insert JavaScript for Colorbox into WP Header
|
147 |
*
|
148 |
+
* @since 1.0
|
149 |
+
* @access private
|
150 |
+
* @author Arne Franken
|
151 |
+
*
|
152 |
* @return rewritten content or excerpt
|
153 |
*/
|
154 |
function buildWordpressHeader() {
|
155 |
?>
|
156 |
+
<!-- jQuery Colorbox 1.3.3 | by Arne Franken, http://www.techotronic.de/ -->
|
157 |
<script type="text/javascript">
|
158 |
+
// <![CDATA[
|
159 |
+
jQuery(document).ready(function($) {
|
160 |
//gets all "a" elements that have a nested "img"
|
161 |
+
$("a:has(img)").each(function(index, obj) {
|
162 |
//in this context, the first child is always an image if fundamental Wordpress functions are used
|
163 |
var $nestedElement = $(obj).children(0);
|
164 |
+
if ($nestedElement.is("img")) {
|
165 |
var $groupId = $nestedElement.attr("class").match('colorbox-[0-9]+');
|
166 |
//only call colorbox if there is a groupId for the image.
|
167 |
+
if ($groupId && !$nestedElement.attr("class").match('colorbox-off')) {
|
168 |
//and calls colorbox function on each img.
|
169 |
//elements with the same groupId in the class attribute are grouped
|
170 |
//the title of the img is used as the title for the colorbox.
|
176 |
}
|
177 |
});
|
178 |
});
|
179 |
+
// ]]>
|
180 |
</script>
|
181 |
+
<!-- jQuery Colorbox | by Arne Franken, http://www.techotronic.de/ -->
|
182 |
+
<?php
|
183 |
+
//write "colorbox-postID" to "img"-tags class attribute.
|
184 |
+
//Priority = 100, hopefully the preg_replace is then executed after other plugins messed with the_content
|
185 |
+
add_filter('the_content', 'addColorboxGroupIdToImages', 100);
|
186 |
+
add_filter('the_excerpt', 'addColorboxGroupIdToImages', 100);
|
187 |
}
|
188 |
|
189 |
//buildWordpressHeader()
|
190 |
|
191 |
/**
|
192 |
* Render Settings page
|
193 |
+
*
|
194 |
+
* @since 1.0
|
195 |
+
* @access private
|
196 |
+
* @author Arne Franken
|
197 |
*/
|
198 |
function renderSettingsPage() {
|
199 |
?>
|
200 |
+
|
201 |
<div class="wrap">
|
202 |
<?php screen_icon(); ?>
|
203 |
<h2><?php _e( 'jQuery Colorbox Settings', 'jquery-colorbox' ); ?></h2>
|
204 |
+
<br class="clear"/>
|
|
|
|
|
205 |
|
206 |
<?php settings_fields('jquery-colorbox_settings'); ?>
|
207 |
|
208 |
+
<div id="poststuff" class="ui-sortable meta-box-sortables">
|
209 |
+
<div id="jquery-colorbox-settings" class="postbox">
|
210 |
+
<h3 id="settings"><?php _e( 'Settings', 'jquery-colorbox' ); ?></h3>
|
211 |
+
|
212 |
+
<div class="inside">
|
213 |
+
<form name="jquery-colorbox-settings-update" method="post" action="admin-post.php">
|
214 |
+
<?php if (function_exists('wp_nonce_field') === true) wp_nonce_field('jquery-colorbox-settings-form'); ?>
|
215 |
+
|
216 |
+
<table class="form-table">
|
217 |
+
<tr valign="top">
|
218 |
+
<th scope="row">
|
219 |
+
<label for="jquery-colorbox-theme"><?php _e('Theme', 'jquery-colorbox'); ?></label>
|
220 |
+
</th>
|
221 |
+
<td>
|
222 |
+
<select name="jquery-colorbox_settings[colorboxTheme]" id="jquery-colorbox-theme" class="postform" style="margin:0">
|
223 |
+
<?php
|
224 |
+
foreach ( $this->colorboxThemes as $theme => $name ) {
|
225 |
echo '<option value="' . esc_attr($theme) . '"';
|
226 |
selected( $this->colorboxSettings['colorboxTheme'], $theme );
|
227 |
echo '>' . htmlspecialchars($name) . "</option>\n";
|
228 |
}
|
229 |
+
?>
|
230 |
+
</select>
|
231 |
+
<br/><?php _e( 'Select the theme you want to use on your blog.', 'jquery-colorbox' ); ?>
|
232 |
</td>
|
233 |
+
</tr>
|
234 |
+
<tr>
|
235 |
+
<th scope="row">
|
236 |
+
<label for="jquery-colorbox-maxWidth"><?php _e('Maximum width of an image', 'jquery-colorbox'); ?>:</label>
|
237 |
+
</th>
|
238 |
+
<td>
|
239 |
+
<input type="text" name="jquery-colorbox_settings[maxWidth]" id="jquery-colorbox-maxWidth" value="<?php echo $this->colorboxSettings['maxWidth'] ?>"/>
|
240 |
+
<br/><?php _e('Set the maximum width of the picture in the Colorbox in relation to the browser window. The picture is resized to the appropriate size. Set to either "false" (no maximum width for the picture, picture is as wide as the Colorbox) or a percent value, e.g. "95%"', 'jquery-colorbox'); ?>
|
241 |
</td>
|
242 |
+
</tr>
|
243 |
+
<tr>
|
244 |
+
<th scope="row">
|
245 |
+
<label for="jquery-colorbox-maxHeight"><?php _e('Maximum height of an image', 'jquery-colorbox'); ?>:</label>
|
246 |
+
</th>
|
247 |
+
<td>
|
248 |
+
<input type="text" name="jquery-colorbox_settings[maxHeight]" id="jquery-colorbox-maxHeight" value="<?php echo $this->colorboxSettings['maxHeight'] ?>"/>
|
249 |
+
<br/><?php _e('Set the maximum height of the picture in the Colorbox in relation to the browser window. The picture is resized to the appropriate size. Set to either "false" (no maximum height for the picture, picture is as high as the Colorbox) or a percent value, e.g. "95%"', 'jquery-colorbox'); ?>
|
250 |
</td>
|
251 |
+
</tr>
|
252 |
+
<tr>
|
253 |
+
<th scope="row">
|
254 |
+
<label for="jquery-colorbox-width"><?php _e('Maximum width of the Colorbox', 'jquery-colorbox'); ?>:</label>
|
255 |
+
</th>
|
256 |
+
<td>
|
257 |
+
<input type="text" name="jquery-colorbox_settings[width]" id="jquery-colorbox-width" value="<?php echo $this->colorboxSettings['width'] ?>"/>
|
258 |
+
<br/><?php _e('Set the maximum width of the Colorbox itself in relation to the browser window. The picture is NOT resized, if bigger than the colorbox, scrollbars are displayed. Set to either "false" (no maximum width for Colorbox, Colorbox is as big as the picture in it) or a percent value, e.g. "95%"', 'jquery-colorbox'); ?>
|
259 |
</td>
|
260 |
+
</tr>
|
261 |
+
<tr>
|
262 |
+
<th scope="row">
|
263 |
+
<label for="jquery-colorbox-height"><?php _e('Maximum height of the Colorbox', 'jquery-colorbox'); ?>:</label>
|
264 |
+
</th>
|
265 |
+
<td>
|
266 |
+
<input type="text" name="jquery-colorbox_settings[height]" id="jquery-colorbox-height" value="<?php echo $this->colorboxSettings['height'] ?>"/>
|
267 |
+
<br/><?php _e('Set the maximum height of the Colorbox itself in relation to the browser window. The picture is NOT resized, if bigger than the colorbox, scrollbars are displayed. Set to either "false" (no maximum height for Colorbox, Colorbox is as big as the picture in it) or a percent value, e.g. "95%"', 'jquery-colorbox'); ?>
|
268 |
</td>
|
269 |
+
</tr>
|
270 |
+
</table>
|
271 |
+
<p class="submit">
|
272 |
+
<input type="hidden" name="action" value="jQueryUpdateSettings"/>
|
273 |
+
<input type="submit" name="jquery-colorbox-submit" class="button-primary" value="<?php _e('Save Changes') ?>"/>
|
274 |
+
</p>
|
275 |
+
</form>
|
276 |
+
</div>
|
277 |
+
</div>
|
278 |
+
</div>
|
279 |
+
|
280 |
+
<div id="poststuff" class="ui-sortable meta-box-sortables">
|
281 |
+
<div id="jquery-colorbox-delete_settings" class="postbox">
|
282 |
+
<h3 id="delete_options"><?php _e('Delete Settings','jquery-colorbox') ?></h3>
|
283 |
+
|
284 |
+
<div class="inside">
|
285 |
+
<p><?php _e('Check the box and click this button to delete settings of this plugin.','jquery-colorbox'); ?></p>
|
286 |
+
|
287 |
+
<form name="delete_settings" method="post" action="admin-post.php">
|
288 |
+
<?php if (function_exists('wp_nonce_field') === true) wp_nonce_field('jquery-delete_settings-form'); ?>
|
289 |
+
<p id="submitbutton">
|
290 |
+
<input type="hidden" name="action" value="jQueryDeleteSettings"/>
|
291 |
+
<input type="submit" value="<?php _e('Delete Settings','jquery-colorbox'); ?> »" class="button-secondary"/>
|
292 |
+
<input type="checkbox" name="delete_settings-true"/>
|
293 |
</p>
|
294 |
+
</form>
|
295 |
+
</div>
|
296 |
</div>
|
297 |
</div>
|
|
|
298 |
|
299 |
+
<div id="poststuff" class="ui-sortable meta-box-sortables">
|
300 |
+
<div id="jquery-colorbox-donate" class="postbox">
|
301 |
+
<h3 id="donate"><?php _e('Donate','jquery-colorbox') ?></h3>
|
302 |
+
|
303 |
<div class="inside">
|
304 |
+
<p>
|
305 |
<span style="float: left;">
|
306 |
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
|
307 |
<input type="hidden" name="cmd" value="_s-xclick">
|
310 |
<img alt="" border="0" src="https://www.paypal.com/de_DE/i/scr/pixel.gif" width="1" height="1">
|
311 |
</form>
|
312 |
</span>
|
313 |
+
</p>
|
314 |
+
<p>
|
315 |
<?php _e('If you would like to make a small (or large) contribution towards future development please consider making a donation.', 'jquery-colorbox') ?>
|
316 |
+
<br/>© Copyright 2009 - <?php echo date("Y"); ?> <a href="http://www.techotronic.de">Arne Franken</a>
|
317 |
+
</p>
|
318 |
+
</div>
|
319 |
</div>
|
320 |
</div>
|
321 |
</div>
|
|
|
322 |
|
323 |
+
<?php
|
324 |
|
325 |
}
|
326 |
|
327 |
//renderSettingsPage()
|
328 |
|
329 |
+
/**
|
330 |
+
* Registers the Settings Page in the Admin Menu
|
331 |
+
*
|
332 |
+
* @since 1.3.3
|
333 |
+
* @access private
|
334 |
+
* @author Arne Franken
|
335 |
+
*/
|
336 |
+
function registerAdminMenu() {
|
337 |
+
if ( function_exists('add_management_page') && current_user_can('manage_options') ) {
|
338 |
+
|
339 |
+
if ( !isset($_GET['update']) )
|
340 |
+
$_GET['update'] = 'false';
|
341 |
+
|
342 |
+
if ( !isset($_GET['uninstall']) )
|
343 |
+
$_GET['uninstall'] = 'false';
|
344 |
+
|
345 |
+
// update, uninstall message
|
346 |
+
if ( strpos($_SERVER['REQUEST_URI'], 'jquery-colorbox.php') && $_GET['update'] == 'true' ) {
|
347 |
+
$return_message = __('Sucessfully updated jQuery Colorbox Settings.', 'jquery-colorbox');
|
348 |
+
} elseif ( $_GET['uninstall'] == 'true' ) {
|
349 |
+
$return_message = __('jQuery Colorbox settings were successfully deleted. Please deactivate the plugin now.', 'jquery-colorbox');
|
350 |
+
} elseif (isset($_GET['delete_settings-true'])) {
|
351 |
+
$return_message = __('jQuery Colorbox settings were successfully deleted. Please deactivate the plugin now.', 'jquery-colorbox');
|
352 |
+
} else {
|
353 |
+
$return_message = '';
|
354 |
+
}
|
355 |
+
}
|
356 |
+
$message = '<div class="updated fade"><p>' . $return_message . '</p></div>';
|
357 |
+
|
358 |
+
if ( $return_message !== '' ) {
|
359 |
+
add_action('admin_notices', create_function( '', "echo '$message';" ) );
|
360 |
+
}
|
361 |
+
|
362 |
+
$this->registerSettingsPage();
|
363 |
+
}
|
364 |
+
|
365 |
+
|
366 |
+
// registerAdminMenu()
|
367 |
+
|
368 |
/**
|
369 |
* Validate the settings sent from the settings page
|
370 |
*
|
371 |
+
* @since 1.0
|
372 |
+
* @access private
|
373 |
+
* @author Arne Franken
|
374 |
+
*
|
375 |
* @param $colorboxSettings settings to be validated
|
376 |
* @return valid settings
|
377 |
*/
|
383 |
}
|
384 |
|
385 |
// validateSettings()
|
386 |
+
|
387 |
+
/**
|
388 |
+
* Update jQuery Colorbox settings
|
389 |
+
*
|
390 |
+
* handles checks and redirect
|
391 |
+
*
|
392 |
+
* @since 1.3.3
|
393 |
+
* @access private
|
394 |
+
* @author Arne Franken
|
395 |
+
*/
|
396 |
+
function jQueryUpdateSettings() {
|
397 |
+
|
398 |
+
if ( !current_user_can('manage_options') )
|
399 |
+
wp_die( __('Did not update options, you do not have the necessary rights.', 'jquery-colorbox') );
|
400 |
+
|
401 |
+
//cross check the given referer for nonce set in settings form
|
402 |
+
check_admin_referer('jquery-colorbox-settings-form');
|
403 |
+
|
404 |
+
$this->updateSettingsInDatabase();
|
405 |
+
|
406 |
+
$referer = str_replace('&update=true&update=true', '', $_POST['_wp_http_referer'] );
|
407 |
+
wp_redirect($referer . '&update=true' );
|
408 |
+
}
|
409 |
+
|
410 |
+
// jQueryUpdateSettings()
|
411 |
+
|
412 |
+
/**
|
413 |
+
* Update jQuery Colorbox settings
|
414 |
+
*
|
415 |
+
* handles updating settings in the WordPress database
|
416 |
+
*
|
417 |
+
* @since 1.3.3
|
418 |
+
* @access private
|
419 |
+
* @author Arne Franken
|
420 |
+
*/
|
421 |
+
function updateSettingsInDatabase() {
|
422 |
+
$this->colorboxSettings = $_POST['jquery-colorbox_settings'];
|
423 |
+
update_option('jquery-colorbox_settings', $this->colorboxSettings);
|
424 |
+
}
|
425 |
+
|
426 |
+
//updateSettings()
|
427 |
+
|
428 |
+
/**
|
429 |
+
* Delete jQuery Colorbox settings
|
430 |
+
*
|
431 |
+
* handles checks and redirect
|
432 |
+
*
|
433 |
+
* @since 1.3.3
|
434 |
+
* @access private
|
435 |
+
* @author Arne Franken
|
436 |
+
*/
|
437 |
+
function jQueryDeleteSettings() {
|
438 |
+
|
439 |
+
if ( current_user_can('manage_options') && isset($_POST['delete_settings-true']) ){
|
440 |
+
//cross check the given referer for nonce set in delete settings form
|
441 |
+
check_admin_referer('jquery-delete_settings-form');
|
442 |
+
$this->deleteSettingsFromDatabase();
|
443 |
+
} else {
|
444 |
+
wp_die( __('Did not delete jQuery Colorbox settings. Either you dont have the nececssary rights or you didnt check the checkbox.', 'jquery-colorbox') );
|
445 |
+
}
|
446 |
+
wp_redirect( 'plugins.php' );
|
447 |
+
}
|
448 |
+
|
449 |
+
// jQueryDeleteSettings()
|
450 |
+
|
451 |
+
/**
|
452 |
+
* Delete jQuery Colorbox settings
|
453 |
+
*
|
454 |
+
* handles deletion from WordPress database
|
455 |
+
*
|
456 |
+
* @since 1.3.3
|
457 |
+
* @access private
|
458 |
+
* @author Arne Franken
|
459 |
+
*/
|
460 |
+
function deleteSettingsFromDatabase() {
|
461 |
+
delete_option('jquery-colorbox_settings');
|
462 |
+
}
|
463 |
+
|
464 |
+
// deleteSettings()
|
465 |
}
|
466 |
|
467 |
// class jQueryColorbox()
|
468 |
?><?php
|
469 |
/**
|
470 |
+
* initialize plugin, call constructor
|
471 |
+
*
|
472 |
+
* @since 1.0
|
473 |
+
* @access public
|
474 |
+
* @author Arne Franken
|
475 |
*/
|
476 |
function jQueryColorbox() {
|
477 |
+
global
|
478 |
+
$jQueryColorbox;
|
479 |
$jQueryColorbox = new jQueryColorbox();
|
480 |
}
|
481 |
|
482 |
//jQueryColorbox()
|
483 |
+
|
484 |
+
// add jQueryColorbox() to WordPress initialization
|
485 |
add_action( 'init', 'jQueryColorbox', 7 );
|
486 |
|
487 |
/**
|
492 |
* unfortunately, Wordpress does not offer a convenient way to get certain elements from the_content,
|
493 |
* so I had to do this by regexp replacement...
|
494 |
*
|
495 |
+
* @since 1.0
|
496 |
+
* @access public
|
497 |
+
* @author Arne Franken
|
498 |
+
*
|
499 |
* @param the_content or the_excerpt
|
500 |
* @return replaced content or excerpt
|
501 |
*/
|
|
|
502 |
function addColorboxGroupIdToImages ($content) {
|
503 |
+
global
|
504 |
+
$post;
|
505 |
$pattern = "/<img(.*?)class=('|\")([A-Za-z0-9 \/_\.\~\:-]*?)('|\")([^\>]*?)>/i";
|
506 |
$replacement = '<img$1class=$2$3 colorbox-'.$post->ID.'$4$5>';
|
507 |
$content = preg_replace($pattern, $replacement, $content);
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.techotronic.de/index.php/donate/
|
|
4 |
Tags: jquery, colorbox, lightbox, images, gallery, javascript, overlay
|
5 |
Requires at least: 2.8.5
|
6 |
Tested up to: 2.9.1
|
7 |
-
Stable tag: 1.3.
|
8 |
|
9 |
Automatically adds Colorbox/Lightbox functionality to all images on the blog. Images are grouped by post.
|
10 |
|
@@ -26,7 +26,7 @@ Localization
|
|
26 |
* German (de_DE) by <a href="http://www.techotronic.de/">Arne Franken</a>
|
27 |
|
28 |
Includes <a href="http://colorpowered.com/colorbox/">ColorBox</a> 1.3.6 jQuery plugin from Jack Moore. Colorbox is licensed under the <a href="http://www.opensource.org/licenses/mit-license.php">MIT License</a>.
|
29 |
-
jQuery Colorbox uses the jQuery library bundled with Wordpress.
|
30 |
|
31 |
== Demo ==
|
32 |
|
@@ -58,36 +58,59 @@ This CSS class is then passed to the colorbox JavaScript.
|
|
58 |
* How do I exclude an image?
|
59 |
|
60 |
Add the CSS class "colorbox-off" to the image you want to exclude.
|
61 |
-
jQuery Colorbox does not add the colorbox
|
62 |
|
63 |
* How does jQuery Colorbox group images?
|
64 |
|
65 |
For all images in a post or page, the same CSS class is added. All images with the same CSS class are grouped.
|
66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
== Changelog ==
|
68 |
|
69 |
-
= 1.3.
|
70 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
|
72 |
-
= 1.3.1 =
|
73 |
-
* changed include calls for Colorbox JavaScript and CSS to version 1.3.6
|
74 |
-
* optimized modification of the_content
|
75 |
|
76 |
= 1.3 =
|
77 |
-
* jQuery-Colorbox won't add Colorbox functionality to images that have the CSS class "colorbox-off"
|
78 |
-
* Updated Colorbox version to 1.3.6
|
79 |
-
* should be compatible to jQuery 1.4, still using 1.3.2 at the moment because it is bundled in WordPress 2.9.1
|
80 |
-
* changed the way that the Colorbox CSS class is added to images to be more reliable
|
81 |
-
* changed layout of settings page
|
82 |
-
* updated the <a href="http://wordpress.org/extend/plugins/jquery-colorbox/faq/">FAQ</a>
|
83 |
|
84 |
= 1.2 =
|
85 |
-
* fixes bug where colorbox was not working if linked images were used (by the theme) outside of blog posts and pages.
|
86 |
-
* adds configuration for Colorbox and picture resizing
|
87 |
|
88 |
= 1.1 =
|
89 |
-
* fixes critical bug which would break rendering the blog. Sorry, was not aware that the plugin would be listed before I tagged the files as 1.0 in subversion...
|
90 |
|
91 |
= 1.0 =
|
92 |
-
* Initial release.
|
93 |
-
* Added Colorbox version 1.3.5
|
4 |
Tags: jquery, colorbox, lightbox, images, gallery, javascript, overlay
|
5 |
Requires at least: 2.8.5
|
6 |
Tested up to: 2.9.1
|
7 |
+
Stable tag: 1.3.3
|
8 |
|
9 |
Automatically adds Colorbox/Lightbox functionality to all images on the blog. Images are grouped by post.
|
10 |
|
26 |
* German (de_DE) by <a href="http://www.techotronic.de/">Arne Franken</a>
|
27 |
|
28 |
Includes <a href="http://colorpowered.com/colorbox/">ColorBox</a> 1.3.6 jQuery plugin from Jack Moore. Colorbox is licensed under the <a href="http://www.opensource.org/licenses/mit-license.php">MIT License</a>.
|
29 |
+
jQuery Colorbox uses the jQuery library version 1.3.2 bundled with Wordpress.
|
30 |
|
31 |
== Demo ==
|
32 |
|
58 |
* How do I exclude an image?
|
59 |
|
60 |
Add the CSS class "colorbox-off" to the image you want to exclude.
|
61 |
+
jQuery Colorbox does not add the colorbox effect to images that have the CSS class "colorbox-off".
|
62 |
|
63 |
* How does jQuery Colorbox group images?
|
64 |
|
65 |
For all images in a post or page, the same CSS class is added. All images with the same CSS class are grouped.
|
66 |
|
67 |
+
* I have Flash (e.g. Youtube videos) embedded on my website. Why do they show up over the layer when I click on an image?
|
68 |
+
|
69 |
+
This is a Flash issue, but relatively easy to solve. Adobe described on these sites what the problem is and how to fix it:
|
70 |
+
<a href="http://kb2.adobe.com/cps/155/tn_15523.html">Adobe Knowledgebase 1</a>
|
71 |
+
<a href="http://kb2.adobe.com/cps/142/tn_14201.html">Adobe Knowledgebase 2</a>
|
72 |
+
In short:
|
73 |
+
1. Add the following parameter to the OBJECT tag: <param name="wmode" value="transparent">
|
74 |
+
2. Add the following parameter to the EMBED tag: wmode="transparent"
|
75 |
+
|
76 |
+
* I installed your plugin, but when I click on a thumbnail, the original picture is loaded directly instead of in the Colorbox. What could be the problem?
|
77 |
+
|
78 |
+
Tricky.
|
79 |
+
I have seen problems where other plugins include older, incompatible versions of the jQuery library my plugin uses.
|
80 |
+
Since I include the jQuery library in a non-conflicting way, the other jQuery library is usually loaded.
|
81 |
+
|
82 |
+
Maybe the images you want jQuery Colorbox to work on are added by a plugin and the images are added after jQuery Colorbox manipulates the HTML when rendering your blog.
|
83 |
+
|
84 |
== Changelog ==
|
85 |
|
86 |
+
= 1.3.3 (2010-01-21) =
|
87 |
+
* CHANGE: fixed settings page, options can be saved now
|
88 |
+
* NEW: added settings deletion on uninstall and "delete settings from database" functionality to settings page
|
89 |
+
* CHANGE: moved adding of CSS class priority lower, hopefully now the CSS class is added to pictures after other plugins update the HTML
|
90 |
+
* CHANGE: updated the <a href="http://wordpress.org/extend/plugins/jquery-colorbox/faq/">FAQ</a>
|
91 |
+
|
92 |
+
= 1.3.2 (2010-01-19) =
|
93 |
+
* CHANGE: moved back to regexp replacement and implemented a workaround in the JavaScript to still allow images to be excluded by adding the class "colorbox-off"
|
94 |
|
95 |
+
= 1.3.1 (2010-01-18) =
|
96 |
+
* CHANGE: changed include calls for Colorbox JavaScript and CSS to version 1.3.6
|
97 |
+
* CHANGE: optimized modification of the_content
|
98 |
|
99 |
= 1.3 =
|
100 |
+
* NEW: jQuery-Colorbox won't add Colorbox functionality to images that have the CSS class "colorbox-off"
|
101 |
+
* CHANGE: Updated Colorbox version to 1.3.6
|
102 |
+
* CHANGE: should be compatible to jQuery 1.4, still using 1.3.2 at the moment because it is bundled in WordPress 2.9.1
|
103 |
+
* CHANGE: changed the way that the Colorbox CSS class is added to images to be more reliable
|
104 |
+
* CHANGE: changed layout of settings page
|
105 |
+
* CHANGE: updated the <a href="http://wordpress.org/extend/plugins/jquery-colorbox/faq/">FAQ</a>
|
106 |
|
107 |
= 1.2 =
|
108 |
+
* CHANGE: fixes bug where colorbox was not working if linked images were used (by the theme) outside of blog posts and pages.
|
109 |
+
* NEW: adds configuration for Colorbox and picture resizing
|
110 |
|
111 |
= 1.1 =
|
112 |
+
* CHANGE: fixes critical bug which would break rendering the blog. Sorry, was not aware that the plugin would be listed before I tagged the files as 1.0 in subversion...
|
113 |
|
114 |
= 1.0 =
|
115 |
+
* NEW: Initial release.
|
116 |
+
* NEW: Added Colorbox version 1.3.5
|