CHANGED: Modified Settings screen

* Added "Preview" links with ThickBox to "General - Display Style" setting
   * Resolved a conflict with resizing ThickBox code in media-upload.js
 * Defaults to "JavaScript" option instead of "WordPress Filters" option in "General - Auto ThickBox" setting, because ThickBox cannot be applied to codes output by current theme or plugins without using WordPress filters
 * Added "Image links to images" option to "General - Auto ThickBox" setting. It is useful when showing only image links with other than ThickBox.
   * Added the condition code to both WordPress filters callback and custom JavaScript
 * Changed "Use WordPress built-in thickbox.js/css" checkbox to "Modified ThickBox / Built-in ThickBox" drop-down list in "General - ThickBox Resources"
   * From `<input type="checkbox" />` to `<select><option></option></select>`
   * Selects disabled "Footer" option when selecting "Built-in ThickBox" option
This commit is contained in:
attosoft committed 2012-10-11 01:13:02 +00:00
1 parent 33724a0791
commit f07a809b58
4 files changed
+58 -20

No files matched your search

+14 -8
View File
@@ -63,16 +63,18 @@ class auto_thickbox_options {
} }
function general_metabox() { function general_metabox() {
$builtin_res_checked = $this->options['builtin_res'] == 'on'; $builtin_thickbox = $this->options['thickbox_type'] == 'built-in';
?> ?>
<table class="form-table"> <table class="form-table">
<tr> <tr>
<th scope="row"><?php $this->util->_e('Display Style'); ?></th> <th scope="row"><?php $this->util->_e('Display Style'); ?></th>
<td> <td>
<label><input type="radio" name="auto-thickbox-plus[thickbox_style]" value="single"<?php $this->util->checked($this->options['thickbox_style'], 'single'); ?> /> <label><input type="radio" name="auto-thickbox-plus[thickbox_style]" value="single"<?php $this->util->checked($this->options['thickbox_style'], 'single'); ?> />
<?php $this->util->_e('Single Image'); ?> (<code>&lt;a href="image">&lt;img />&lt;/a></code>)</label><br /> <?php $this->util->_e('Single Image'); ?></label>
(<a href="<?php echo $this->util->plugins_url('screenshot-1.jpg'); ?>" class="thickbox-image" title="<?php $this->util->_e('Single Image'); ?>"><?php $this->util->_e('Preview'); ?></a>)
<label><input type="radio" name="auto-thickbox-plus[thickbox_style]" value="gallery"<?php $this->util->checked($this->options['thickbox_style'], 'gallery'); ?> /> <label><input type="radio" name="auto-thickbox-plus[thickbox_style]" value="gallery"<?php $this->util->checked($this->options['thickbox_style'], 'gallery'); ?> />
<?php $this->util->_e('Gallery Images'); ?> (<code>&lt;a href="image" rel="gallery-id">&lt;img />&lt;/a></code>)</label> <?php $this->util->_e('Gallery Images'); ?></label>
(<a href="<?php echo $this->util->plugins_url('screenshot-2.jpg'); ?>" class="thickbox-image" title="<?php $this->util->_e('Gallery Images'); ?>" rel="gallery"><?php $this->util->_e('Preview'); ?></a>)
</td> </td>
</tr> </tr>
<tr> <tr>
@@ -96,6 +98,8 @@ class auto_thickbox_options {
<tr> <tr>
<th scope="row"></th> <th scope="row"></th>
<td> <td>
<label><input type="checkbox" name="auto-thickbox-plus[thickbox_img]"<?php $this->util->checked($this->options['thickbox_img'], 'on'); ?> />
<?php $this->util->_e('Image links to images'); ?> (<code>&lt;a href="image">&lt;img src="thumbnail" />&lt;/a></code>)</label><br />
<label><input type="checkbox" name="auto-thickbox-plus[thickbox_text]"<?php $this->util->checked($this->options['thickbox_text'], 'on'); ?> /> <label><input type="checkbox" name="auto-thickbox-plus[thickbox_text]"<?php $this->util->checked($this->options['thickbox_text'], 'on'); ?> />
<?php $this->util->_e('Text links to images'); ?> (<code>&lt;a href="image">text&lt;/a></code>)</label><br /> <?php $this->util->_e('Text links to images'); ?> (<code>&lt;a href="image">text&lt;/a></code>)</label><br />
<label><input type="checkbox" name="auto-thickbox-plus[thickbox_target]"<?php $this->util->checked($this->options['thickbox_target'], 'on'); ?> /> <label><input type="checkbox" name="auto-thickbox-plus[thickbox_target]"<?php $this->util->checked($this->options['thickbox_target'], 'on'); ?> />
@@ -121,17 +125,19 @@ class auto_thickbox_options {
<tr> <tr>
<th scope="row"><?php $this->util->_e('ThickBox Resources'); ?></th> <th scope="row"><?php $this->util->_e('ThickBox Resources'); ?></th>
<td> <td>
<label class="item"><input type="radio" name="auto-thickbox-plus[script_place]" value="header"<?php $this->util->checked($this->options['script_place'], 'header'); $this->util->disabled($builtin_res_checked); ?> /> <label class="item"><input type="radio" name="auto-thickbox-plus[script_place]" value="header"<?php $this->util->checked($this->options['script_place'], 'header'); $this->util->disabled($builtin_thickbox); ?> />
<?php $this->util->_e('Header'); ?></label> <?php $this->util->_e('Header'); ?></label>
<label class="item"><input type="radio" name="auto-thickbox-plus[script_place]" value="footer"<?php $this->util->checked($this->options['script_place'], 'footer'); $this->util->disabled($builtin_res_checked); ?> /> <label class="item"><input type="radio" name="auto-thickbox-plus[script_place]" value="footer"<?php $this->util->checked($this->options['script_place'], 'footer'); $this->util->disabled($builtin_thickbox); ?> />
<?php $this->util->_e('Footer'); ?></label> <?php $this->util->_e('Footer'); ?></label>
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row"></th> <th scope="row"></th>
<td> <td>
<label><input type="checkbox" name="auto-thickbox-plus[builtin_res]"<?php $this->util->checked($builtin_res_checked); ?> onclick="disablePlaceOption(this)" /> <select name="auto-thickbox-plus[thickbox_type]" onchange="disablePlaceOption(this)">
<?php $this->util->_e('Use WordPress built-in thickbox.js/css (some extra features will be disabled)'); ?></label> <option value="modified"<?php selected(!$builtin_thickbox); ?>><?php $this->util->_e('Modified ThickBox'); ?></option>
<option value="built-in"<?php selected($builtin_thickbox); ?>><?php $this->util->_e('Built-in ThickBox'); ?></option>
</select>
</td> </td>
</tr> </tr>
<tr> <tr>
@@ -935,7 +941,7 @@ class auto_thickbox_options {
register_setting( $this->option_group, 'auto-thickbox-plus', array(&$this, 'options_callback') ); register_setting( $this->option_group, 'auto-thickbox-plus', array(&$this, 'options_callback') );
} }
var $checkboxes_on = array('wp_gallery', 'thickbox_text', 'auto_resize_img', 'auto_resize_html', var $checkboxes_on = array('wp_gallery', 'thickbox_img', 'thickbox_text', 'auto_resize_img', 'auto_resize_html',
'key_close_esc', 'key_close_enter', 'key_close_esc', 'key_close_enter',
'key_prev_angle', 'key_prev_left', 'key_prev_angle', 'key_prev_left',
'key_next_angle', 'key_next_right', 'key_next_angle', 'key_next_right',
+18 -2
View File
@@ -74,6 +74,20 @@ jQuery(function($) {
return false; return false;
}); });
}); });
tb_init("a.thickbox-image"); // prevent href from being modified by media-upload.js
var tb_position2 = tb_position;
tb_position = function() {
if ($("#TB_iframeContent").length) { // tb_position() in media-upload.js
tb_position2();
} else { // tb_position() in built-in thickbox.js
var isIE6 = typeof document.body.style.maxHeight === "undefined";
jQuery("#TB_window").css({marginLeft: '-' + parseInt((TB_WIDTH / 2),10) + 'px', width: TB_WIDTH + 'px'});
if ( ! isIE6 ) { // take away IE6
jQuery("#TB_window").css({marginTop: '-' + parseInt((TB_HEIGHT / 2),10) + 'px'});
}
}
};
}); });
function updateEffectSpeed(radio) { function updateEffectSpeed(radio) {
@@ -100,9 +114,11 @@ function disableHideInitOption(radio) {
document.form[name].disabled = radio.value == 'none'; document.form[name].disabled = radio.value == 'none';
} }
function disablePlaceOption(checkbox) { function disablePlaceOption(select) {
for (var i = 0; i < document.form['auto-thickbox-plus[script_place]'].length; i++) for (var i = 0; i < document.form['auto-thickbox-plus[script_place]'].length; i++)
document.form['auto-thickbox-plus[script_place]'][i].disabled = checkbox.checked; document.form['auto-thickbox-plus[script_place]'][i].disabled = select.value == 'built-in';
if (select.value == 'built-in')
document.form['auto-thickbox-plus[script_place]'][1].checked = true;
} }
function disableClickOption(radio) { function disableClickOption(radio) {
+19 -8
View File
@@ -84,7 +84,8 @@ class auto_thickbox {
* @return anchor $anchor * @return anchor $anchor
**/ **/
function image($anchor) { function image($anchor) {
if ( ($this->options['thickbox_text'] == 'off' && !preg_match("/^\s*<\s*img\s.+?>\s*$/is", $anchor['body'])) if ( ($this->options['thickbox_img'] == 'off' && preg_match("/^\s*<\s*img\s.+?>\s*$/is", $anchor['body']))
|| ($this->options['thickbox_text'] == 'off' && !preg_match("/^\s*<\s*img\s.+?>\s*$/is", $anchor['body']))
|| ($this->options['thickbox_target'] == 'off' && !empty($anchor['attr']['target'])) ) || ($this->options['thickbox_target'] == 'off' && !empty($anchor['attr']['target'])) )
return $anchor; return $anchor;
@@ -129,13 +130,13 @@ class auto_thickbox {
* @return void * @return void
**/ **/
function scripts() { function scripts() {
if ( $this->options['builtin_res'] == 'off' ) { if ( $this->options['thickbox_type'] == 'modified' ) {
wp_deregister_script('thickbox'); wp_deregister_script('thickbox');
$in_footer = $this->options['script_place'] == 'footer'; $in_footer = $this->options['script_place'] == 'footer';
wp_register_script('thickbox', $this->util->plugins_url(WP_DEBUG ? 'thickbox.js' :'thickbox.min.js'), array('jquery'), AUTO_THICKBOX_PLUS_VER, $in_footer); wp_register_script('thickbox', $this->util->plugins_url(WP_DEBUG ? 'thickbox.js' :'thickbox.min.js'), array('jquery'), AUTO_THICKBOX_PLUS_VER, $in_footer);
} }
wp_enqueue_script('thickbox'); wp_enqueue_script('thickbox');
if ( $this->options['builtin_res'] == 'off' ) { if ( $this->options['thickbox_type'] == 'modified' ) {
$l10n = array( $l10n = array(
'next' => $this->texts['next'], 'next' => $this->texts['next'],
'prev' => $this->texts['prev'], 'prev' => $this->texts['prev'],
@@ -169,7 +170,7 @@ class auto_thickbox {
* @return void * @return void
**/ **/
function styles() { function styles() {
if ( $this->options['builtin_res'] == 'off' ) { if ( $this->options['thickbox_type'] == 'modified' ) {
wp_deregister_style('thickbox'); wp_deregister_style('thickbox');
wp_register_style('thickbox', $this->util->plugins_url(WP_DEBUG ? 'thickbox.css' : 'thickbox.min.css'), false, AUTO_THICKBOX_PLUS_VER); wp_register_style('thickbox', $this->util->plugins_url(WP_DEBUG ? 'thickbox.css' : 'thickbox.min.css'), false, AUTO_THICKBOX_PLUS_VER);
} }
@@ -195,6 +196,10 @@ jQuery(function($) {
var nothickbox = ['<?php echo str_replace(' ', '\', \'', trim($this->options['no_thickbox'])); ?>']; var nothickbox = ['<?php echo str_replace(' ', '\', \'', trim($this->options['no_thickbox'])); ?>'];
for (var i = 0; i < nothickbox.length; i++) for (var i = 0; i < nothickbox.length; i++)
if ($(this).hasClass(nothickbox[i])) return false; if ($(this).hasClass(nothickbox[i])) return false;
<?php if ($this->options['thickbox_img'] == 'off') : ?>
// Image links to images
if ($(this).is(':has(img)')) return false;
<?php endif; ?>
<?php if ($this->options['thickbox_text'] == 'off') : ?> <?php if ($this->options['thickbox_text'] == 'off') : ?>
// Text links to images // Text links to images
if (!$(this).is(':has(img)')) return false; if (!$(this).is(':has(img)')) return false;
@@ -253,7 +258,7 @@ jQuery(function($) {
}); });
<?php <?php
if ($this->options['builtin_res'] == 'on') { if ($this->options['thickbox_type'] == 'built-in') {
if ( version_compare('3.2', get_bloginfo('version')) > 0 ) { if ( version_compare('3.2', get_bloginfo('version')) > 0 ) {
$includes_url = includes_url(); $includes_url = includes_url();
echo <<<SCRIPT echo <<<SCRIPT
@@ -265,7 +270,7 @@ SCRIPT;
} }
} }
if ( $this->options['builtin_res'] == 'off') { if ( $this->options['thickbox_type'] == 'modified') {
$script = ''; $script = '';
if ( !$this->is_default_options('auto_resize_img') ) if ( !$this->is_default_options('auto_resize_img') )
@@ -582,13 +587,14 @@ SCRIPT;
$this->options_def = array( $this->options_def = array(
'thickbox_style' => 'single', 'thickbox_style' => 'single',
'wp_gallery' => 'on', 'wp_gallery' => 'on',
'auto_thickbox' => 'filter', 'auto_thickbox' => 'js',
'thickbox_img' => 'on',
'thickbox_text' => 'on', 'thickbox_text' => 'on',
'thickbox_target' => 'off', 'thickbox_target' => 'off',
'no_thickbox' => 'nothickbox no_thickbox ', 'no_thickbox' => 'nothickbox no_thickbox ',
'auto_resize_img' => 'on', 'auto_resize_img' => 'on',
'auto_resize_html' => 'off', 'auto_resize_html' => 'off',
'builtin_res' => 'off', 'thickbox_type' => 'modified',
'script_place' => 'header', 'script_place' => 'header',
'mobile_support' => 'no_margin', 'mobile_support' => 'no_margin',
'small_width' => '480', 'small_width' => '480',
@@ -782,6 +788,11 @@ SCRIPT;
unset($this->options['bgcolor_content']); unset($this->options['bgcolor_content']);
$updateOption = true; $updateOption = true;
} }
if (isset($this->options['builtin_res'])) {
$this->options['thickbox_type'] = $this->options['builtin_res'] == 'on' ? 'built-in' : 'modified';
unset($this->options['builtin_res']);
$updateOption = true;
}
if ($this->is_default_options('post_id')) { if ($this->is_default_options('post_id')) {
$args = array( $args = array(
+7 -2
View File
@@ -163,7 +163,7 @@ Then, perform the troubleshooting below.
* Deactivate current theme because some themes output invalid header/footer, or load built-in ThickBox directly * Deactivate current theme because some themes output invalid header/footer, or load built-in ThickBox directly
* Deactivate plugins that load built-in ThickBox directly, such as [Events Calendar](http://wordpress.org/extend/plugins/events-calendar/) * Deactivate plugins that load built-in ThickBox directly, such as [Events Calendar](http://wordpress.org/extend/plugins/events-calendar/)
* Deactivate plugins that optimizes JS/CSS files, such as [W3 Total Cache](http://wordpress.org/extend/plugins/w3-total-cache/), [WP Minify](http://wordpress.org/extend/plugins/wp-minify/), [CloudFlare](http://wordpress.org/extend/plugins/cloudflare/), [Head Cleaner](http://wordpress.org/extend/plugins/head-cleaner/) and [Head JS](http://headjs.com/) * Deactivate plugins that optimizes JS/CSS files, such as [W3 Total Cache](http://wordpress.org/extend/plugins/w3-total-cache/), [WP Minify](http://wordpress.org/extend/plugins/wp-minify/), [CloudFlare](http://wordpress.org/extend/plugins/cloudflare/), [Head Cleaner](http://wordpress.org/extend/plugins/head-cleaner/) and [Head JS](http://headjs.com/)
* Use built-in ThickBox in WordPress instead, by checking [General - ThickBox Resources - Use WordPress built-in thickbox.js/css] option in Settings screen * Use built-in ThickBox in WordPress instead, by selecting [General - ThickBox Resources - Built-in ThickBox] option in Settings screen
If the problem still persists, please send me your site URL via [support forum](http://wordpress.org/support/plugin/auto-thickbox-plus) or [contact form](http://attosoft.info/en/contact/). If the problem still persists, please send me your site URL via [support forum](http://wordpress.org/support/plugin/auto-thickbox-plus) or [contact form](http://attosoft.info/en/contact/).
@@ -245,7 +245,7 @@ When "View" setting is as follows, only an image will be displayed without margi
= How to use built-in ThickBox instead = = How to use built-in ThickBox instead =
1. Access [Dashboard] - [Settings] - [Auto ThickBox Plus] screen 1. Access [Dashboard] - [Settings] - [Auto ThickBox Plus] screen
1. Check [General] - [ThickBox Resources] - [Use WordPress built-in thickbox.js/css] option 1. Select [General] - [ThickBox Resources] - [Built-in ThickBox] option
\* Note: Functions only in modified ThickBox will be disabled, such as enhanced Auto Resize, most mouse/keyboard actions, animation effects, high compatibility with themes and plugins. Moreover, many improvements and bug fixes won't be applied. \* Note: Functions only in modified ThickBox will be disabled, such as enhanced Auto Resize, most mouse/keyboard actions, animation effects, high compatibility with themes and plugins. Moreover, many improvements and bug fixes won't be applied.
@@ -281,6 +281,11 @@ You can localize the plugin with [Poedit](http://www.poedit.net/) and "languages
* NEW: "View - Margin - Window (Image/HTML)" option * NEW: "View - Margin - Window (Image/HTML)" option
* CHANGED: Removed CSS hacks for IE6. Replaced CSS Expression with JavaScript. * CHANGED: Removed CSS hacks for IE6. Replaced CSS Expression with JavaScript.
* CHANGED: ThickBox window is displayed in the center of browser when resizing or drag-moving itself * CHANGED: ThickBox window is displayed in the center of browser when resizing or drag-moving itself
* CHANGED: Modified Settings screen
* Added "Preview" links with ThickBox to "General - Display Style" setting
* Defaults to "JavaScript" option instead of "WordPress Filters" option in "General - Auto ThickBox" setting, because ThickBox cannot be applied to codes output by current theme or plugins without using WordPress filters
* Added "Image links to images" option to "General - Auto ThickBox" setting. It is useful when showing only image links with other than ThickBox.
* Changed "Use WordPress built-in thickbox.js/css" checkbox to "Modified ThickBox / Built-in ThickBox" drop-down list in "General - ThickBox Resources"
* CHANGED: Replaced the word "Content" with "HTML" * CHANGED: Replaced the word "Content" with "HTML"
* FIXED: Invalid positioning on some mobile browsers such as older iOS (iPhone/iPad/iPod touch) and older Android, caused by not supporting `position:fixed` style. * FIXED: Invalid positioning on some mobile browsers such as older iOS (iPhone/iPad/iPod touch) and older Android, caused by not supporting `position:fixed` style.
* FIXED: Title/caption bar misaligns by "Resize", "Expand/Shrink" and "Scale" when using "Effect - Title/Caption" option * FIXED: Title/caption bar misaligns by "Resize", "Expand/Shrink" and "Scale" when using "Effect - Title/Caption" option