Version Description
- Added new setting to exclude FooBox assets by default
- Added metabox on all public post types to include/exclude FooBox assets
- Major version bump to avoid confusion with FooBox PRO 2.4.0.0
Download this release
Release Info
Developer | bradvin |
Plugin | FooBox Image Lightbox WordPress Plugin |
Version | 2.5.0 |
Comparing to | |
See all releases |
Code changes from version 1.2.34 to 2.5.0
- foobox-free.php +2 -2
- free/foobox-free.php +11 -0
- free/includes/class-exclude.php +142 -0
- free/includes/class-settings.php +9 -0
- readme.txt +13 -0
foobox-free.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
Plugin Name: FooBox Image Lightbox
|
5 |
Plugin URI: http://fooplugins.com/plugins/foobox/
|
6 |
Description: The best responsive lightbox for WordPress.
|
7 |
-
Version:
|
8 |
Author: FooPlugins
|
9 |
Author URI: http://fooplugins.com
|
10 |
License: GPL2
|
@@ -21,7 +21,7 @@ if ( !class_exists( 'FooBox' ) ) {
|
|
21 |
define( 'FOOBOX_BASE_ACTIVATION_REDIRECT_TRANSIENT_KEY', '_foobox_activation_redirect' );
|
22 |
define( 'FOOBOX_BASE_PATH', plugin_dir_path( __FILE__ ) );
|
23 |
define( 'FOOBOX_BASE_URL', plugin_dir_url( __FILE__ ) );
|
24 |
-
define( 'FOOBOX_BASE_VERSION', '
|
25 |
// Create a helper function for easy SDK access.
|
26 |
function foobox_fs()
|
27 |
{
|
4 |
Plugin Name: FooBox Image Lightbox
|
5 |
Plugin URI: http://fooplugins.com/plugins/foobox/
|
6 |
Description: The best responsive lightbox for WordPress.
|
7 |
+
Version: 2.5.0
|
8 |
Author: FooPlugins
|
9 |
Author URI: http://fooplugins.com
|
10 |
License: GPL2
|
21 |
define( 'FOOBOX_BASE_ACTIVATION_REDIRECT_TRANSIENT_KEY', '_foobox_activation_redirect' );
|
22 |
define( 'FOOBOX_BASE_PATH', plugin_dir_path( __FILE__ ) );
|
23 |
define( 'FOOBOX_BASE_URL', plugin_dir_url( __FILE__ ) );
|
24 |
+
define( 'FOOBOX_BASE_VERSION', '2.5.0' );
|
25 |
// Create a helper function for easy SDK access.
|
26 |
function foobox_fs()
|
27 |
{
|
free/foobox-free.php
CHANGED
@@ -15,6 +15,7 @@ if (!class_exists('Foobox_Free')) {
|
|
15 |
require_once FOOBOXFREE_PATH . "includes/class-script-generator.php";
|
16 |
require_once FOOBOXFREE_PATH . "includes/class-foogallery-foobox-free-extension.php";
|
17 |
require_once FOOBOXFREE_PATH . "includes/foopluginbase/bootstrapper.php";
|
|
|
18 |
|
19 |
class Foobox_Free extends Foo_Plugin_Base_v2_1 {
|
20 |
|
@@ -64,6 +65,8 @@ if (!class_exists('Foobox_Free')) {
|
|
64 |
add_action('wp_footer', array($this, 'disable_other_lightboxes'), 200);
|
65 |
}
|
66 |
}
|
|
|
|
|
67 |
}
|
68 |
|
69 |
function custom_admin_settings_render($args = array()) {
|
@@ -129,6 +132,8 @@ if (!class_exists('Foobox_Free')) {
|
|
129 |
}
|
130 |
|
131 |
function frontend_print_styles() {
|
|
|
|
|
132 |
//enqueue foobox CSS
|
133 |
if ( $this->is_option_checked( 'dropie7support' ) ) {
|
134 |
$this->register_and_enqueue_css(self::CSS_NOIE7);
|
@@ -138,6 +143,8 @@ if (!class_exists('Foobox_Free')) {
|
|
138 |
}
|
139 |
|
140 |
function frontend_print_scripts() {
|
|
|
|
|
141 |
$this->register_and_enqueue_js(
|
142 |
$file = self::JS,
|
143 |
$d = array('jquery'),
|
@@ -146,6 +153,8 @@ if (!class_exists('Foobox_Free')) {
|
|
146 |
}
|
147 |
|
148 |
function inline_dynamic_js() {
|
|
|
|
|
149 |
$foobox_js = $this->generate_javascript();
|
150 |
|
151 |
$defer_js = !$this->is_option_checked( 'disable_defer_js', true );
|
@@ -182,6 +191,8 @@ if (!class_exists('Foobox_Free')) {
|
|
182 |
* This can be turned off in the FooBox settings page
|
183 |
*/
|
184 |
function disable_other_lightboxes() {
|
|
|
|
|
185 |
?>
|
186 |
<script type="text/javascript">
|
187 |
jQuery.fn.prettyPhoto = function () { return this; };
|
15 |
require_once FOOBOXFREE_PATH . "includes/class-script-generator.php";
|
16 |
require_once FOOBOXFREE_PATH . "includes/class-foogallery-foobox-free-extension.php";
|
17 |
require_once FOOBOXFREE_PATH . "includes/foopluginbase/bootstrapper.php";
|
18 |
+
require_once FOOBOXFREE_PATH . 'includes/class-exclude.php';
|
19 |
|
20 |
class Foobox_Free extends Foo_Plugin_Base_v2_1 {
|
21 |
|
65 |
add_action('wp_footer', array($this, 'disable_other_lightboxes'), 200);
|
66 |
}
|
67 |
}
|
68 |
+
|
69 |
+
new FooBox_Free_Exclude();
|
70 |
}
|
71 |
|
72 |
function custom_admin_settings_render($args = array()) {
|
132 |
}
|
133 |
|
134 |
function frontend_print_styles() {
|
135 |
+
if ( !apply_filters('foobox_enqueue_styles', true) ) return;
|
136 |
+
|
137 |
//enqueue foobox CSS
|
138 |
if ( $this->is_option_checked( 'dropie7support' ) ) {
|
139 |
$this->register_and_enqueue_css(self::CSS_NOIE7);
|
143 |
}
|
144 |
|
145 |
function frontend_print_scripts() {
|
146 |
+
if (!apply_filters('foobox_enqueue_scripts', true)) return;
|
147 |
+
|
148 |
$this->register_and_enqueue_js(
|
149 |
$file = self::JS,
|
150 |
$d = array('jquery'),
|
153 |
}
|
154 |
|
155 |
function inline_dynamic_js() {
|
156 |
+
if (!apply_filters('foobox_enqueue_scripts', true)) return;
|
157 |
+
|
158 |
$foobox_js = $this->generate_javascript();
|
159 |
|
160 |
$defer_js = !$this->is_option_checked( 'disable_defer_js', true );
|
191 |
* This can be turned off in the FooBox settings page
|
192 |
*/
|
193 |
function disable_other_lightboxes() {
|
194 |
+
if ( !apply_filters('foobox_enqueue_scripts', true ) ) return;
|
195 |
+
|
196 |
?>
|
197 |
<script type="text/javascript">
|
198 |
jQuery.fn.prettyPhoto = function () { return this; };
|
free/includes/class-exclude.php
ADDED
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Foobox_Free_Exclude class
|
4 |
+
* class which allows you to exclude FooBox from specific pages and posts
|
5 |
+
*/
|
6 |
+
|
7 |
+
if ( !class_exists( 'FooBox_Free_Exclude' ) ) {
|
8 |
+
|
9 |
+
class FooBox_Free_Exclude {
|
10 |
+
|
11 |
+
function __construct() {
|
12 |
+
add_action( 'init', array($this, 'init') );
|
13 |
+
}
|
14 |
+
|
15 |
+
function init() {
|
16 |
+
if ( is_admin() ) {
|
17 |
+
add_action( 'add_meta_boxes', array($this, 'add_metaboxes') );
|
18 |
+
add_action( 'save_post', array($this, 'save_meta') );
|
19 |
+
} else {
|
20 |
+
add_filter( 'foobox_enqueue_scripts', array($this, 'enqueue_scripts_or_styles'), 99 );
|
21 |
+
add_filter( 'foobox_enqueue_styles', array($this, 'enqueue_scripts_or_styles'), 99 );
|
22 |
+
}
|
23 |
+
}
|
24 |
+
|
25 |
+
function add_metaboxes() {
|
26 |
+
$public_post_types = get_post_types( array( 'public' => true ), 'names' );
|
27 |
+
|
28 |
+
$post_types = apply_filters( 'foobox_metabox_post_types', $public_post_types );
|
29 |
+
|
30 |
+
foreach ( $post_types as $post_type ) {
|
31 |
+
|
32 |
+
$metabox_title = apply_filters( 'foobox_metabox_title', __( 'FooBox Javascript & CSS', 'foobox' ) );
|
33 |
+
|
34 |
+
add_meta_box(
|
35 |
+
$post_type . '_foobox_exclude'
|
36 |
+
, $metabox_title
|
37 |
+
, array($this, 'render_meta_box')
|
38 |
+
, $post_type
|
39 |
+
, 'side'
|
40 |
+
, 'default'
|
41 |
+
);
|
42 |
+
|
43 |
+
}
|
44 |
+
}
|
45 |
+
|
46 |
+
function exclude_by_default_option_checked() {
|
47 |
+
$instance = Foobox_Free::get_instance();
|
48 |
+
return $instance->is_option_checked( 'excludebydefault' );
|
49 |
+
}
|
50 |
+
|
51 |
+
function render_meta_box($post) {
|
52 |
+
$show_include = $this->exclude_by_default_option_checked();
|
53 |
+
|
54 |
+
$exclude = get_post_meta( $post->ID, '_foobox_exclude', true );
|
55 |
+
$include = get_post_meta( $post->ID, '_foobox_include', true );
|
56 |
+
$metabox_desc_exclude = apply_filters( 'foobox_metabox_desc_exclude', __( 'Exclude FooBox from this page or post? By default, FooBox will be included.', 'foobox' ) );
|
57 |
+
$metabox_desc_include = apply_filters( 'foobox_metabox_desc_include', __( 'Include FooBox on this page or post? By default, FooBox will be excluded!', 'foobox' ) );
|
58 |
+
?>
|
59 |
+
<input type="hidden" name="foobox_exclude_nonce"
|
60 |
+
value="<?php echo wp_create_nonce( plugin_basename( __FILE__ ) ); ?>"/>
|
61 |
+
<table class="form-table">
|
62 |
+
<?php if ( !$show_include ) { ?>
|
63 |
+
<tr>
|
64 |
+
<td colspan="2">
|
65 |
+
<input id="foobox_exclude_check"
|
66 |
+
name="foobox_exclude_check" <?php echo ($exclude == "exclude") ? 'checked="checked"' : ""; ?>
|
67 |
+
type="checkbox" value="exclude">
|
68 |
+
<label for="foobox_exclude_check"><?php echo $metabox_desc_exclude; ?></label>
|
69 |
+
</td>
|
70 |
+
</tr>
|
71 |
+
<?php } else { ?>
|
72 |
+
<tr>
|
73 |
+
<td colspan="2">
|
74 |
+
<input id="foobox_include_check"
|
75 |
+
name="foobox_include_check" <?php echo ($include == "include") ? 'checked="checked"' : ""; ?>
|
76 |
+
type="checkbox" value="include">
|
77 |
+
<label for="foobox_include_check"><?php echo $metabox_desc_include; ?></label>
|
78 |
+
</td>
|
79 |
+
</tr>
|
80 |
+
<?php } ?>
|
81 |
+
</table>
|
82 |
+
<?php
|
83 |
+
}
|
84 |
+
|
85 |
+
function save_meta($post_id) {
|
86 |
+
|
87 |
+
// check autosave
|
88 |
+
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
|
89 |
+
return $post_id;
|
90 |
+
}
|
91 |
+
|
92 |
+
// verify nonce
|
93 |
+
if ( array_key_exists( 'foobox_exclude_nonce', $_POST ) &&
|
94 |
+
wp_verify_nonce( $_POST['foobox_exclude_nonce'], plugin_basename( __FILE__ ) )
|
95 |
+
) {
|
96 |
+
|
97 |
+
if ( !$this->exclude_by_default_option_checked() ) {
|
98 |
+
|
99 |
+
$exclude = array_key_exists( 'foobox_exclude_check', $_POST ) ? $_POST['foobox_exclude_check'] : '';
|
100 |
+
if ( empty( $exclude ) ) {
|
101 |
+
delete_post_meta( $post_id, '_foobox_exclude' );
|
102 |
+
} else {
|
103 |
+
update_post_meta( $post_id, '_foobox_exclude', $exclude );
|
104 |
+
}
|
105 |
+
|
106 |
+
} else {
|
107 |
+
|
108 |
+
$include = array_key_exists( 'foobox_include_check', $_POST ) ? $_POST['foobox_include_check'] : '';
|
109 |
+
if ( empty($include) ) {
|
110 |
+
delete_post_meta( $post_id, '_foobox_include' );
|
111 |
+
} else {
|
112 |
+
update_post_meta( $post_id, '_foobox_include', $include );
|
113 |
+
}
|
114 |
+
}
|
115 |
+
}
|
116 |
+
}
|
117 |
+
|
118 |
+
function enqueue_scripts_or_styles() {
|
119 |
+
global $post;
|
120 |
+
if (isset($post) && is_singular($post)) {
|
121 |
+
if ( !$this->exclude_by_default_option_checked() ) {
|
122 |
+
|
123 |
+
//check if we are excluding
|
124 |
+
$exclude = get_post_meta( $post->ID, '_foobox_exclude', true );
|
125 |
+
if ( 'exclude' === $exclude ) {
|
126 |
+
return false;
|
127 |
+
}
|
128 |
+
} else {
|
129 |
+
|
130 |
+
$include = get_post_meta( $post->ID, '_foobox_include', true );
|
131 |
+
if ( 'include' === $include ) {
|
132 |
+
return true;
|
133 |
+
}
|
134 |
+
|
135 |
+
//otherwise, by default, do not include the assets
|
136 |
+
return false;
|
137 |
+
}
|
138 |
+
}
|
139 |
+
return true;
|
140 |
+
}
|
141 |
+
}
|
142 |
+
}
|
free/includes/class-settings.php
CHANGED
@@ -167,6 +167,15 @@ if ( !class_exists( 'FooBox_Free_Settings' ) ) {
|
|
167 |
'tab' => 'advanced'
|
168 |
);
|
169 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
//endregion
|
171 |
|
172 |
//region Debug Tab
|
167 |
'tab' => 'advanced'
|
168 |
);
|
169 |
|
170 |
+
$settings[] = array(
|
171 |
+
'id' => 'excludebydefault',
|
172 |
+
'title' => __( 'Exclude FooBox Assets', 'foobox-image-lightbox' ),
|
173 |
+
'desc' => __( 'By default, FooBox includes javascript and stylesheet assets into all your pages. We do this, because we do not know if the page content contains media or not.<br>If you want more control over when FooBox assets are included, you can now exclude FooBox assets by default, by enabling this setting. Then on each page, you can choose to include the assets if required.<br>Or you can leave the setting disabled, and then choose to exclude FooBox assets from particular pages. A new FooBox metabox is now available when editing your pages or posts.', 'foobox-image-lightbox' ),
|
174 |
+
'type' => 'checkbox',
|
175 |
+
'section' => __( 'JS & CSS', 'foobox-image-lightbox' ),
|
176 |
+
'tab' => 'advanced'
|
177 |
+
);
|
178 |
+
|
179 |
//endregion
|
180 |
|
181 |
//region Debug Tab
|
readme.txt
CHANGED
@@ -16,6 +16,13 @@ FooBox was the first lightbox to take responsive layout seriously. Not only does
|
|
16 |
|
17 |
Works with most image gallery plugins, but works best with our [FooGallery Image Gallery WordPress Plugin](http://foo.gallery).
|
18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
**Now includes a 7-day free trial of FooBox Pro!**
|
20 |
|
21 |
**FooBox Image Lightbox Features:**
|
@@ -25,6 +32,7 @@ Works with most image gallery plugins, but works best with our [FooGallery Image
|
|
25 |
* Zero configuration!
|
26 |
* Works with WordPress galleries
|
27 |
* Works with WordPress captioned images
|
|
|
28 |
|
29 |
**[FooBox PRO](http://fooplugins.com/plugins/foobox/?utm_source=fooboxfreeplugin&utm_medium=fooboxfreeprolink&utm_campaign=foobox_free_wprepo) Features:**
|
30 |
|
@@ -76,6 +84,11 @@ There is a setting to try and disable hard coded lightboxes, but this is not a s
|
|
76 |
|
77 |
== Changelog ==
|
78 |
|
|
|
|
|
|
|
|
|
|
|
79 |
= 1.2.34 =
|
80 |
* Fix : lightbox was not working with FooGallery paging
|
81 |
* Updated to latest client CSS
|
16 |
|
17 |
Works with most image gallery plugins, but works best with our [FooGallery Image Gallery WordPress Plugin](http://foo.gallery).
|
18 |
|
19 |
+
**New Feature : Complete FooBox Asset Control!**
|
20 |
+
|
21 |
+
By default, FooBox includes javascript and stylesheet assets into all your pages. We do this, because we do not know if the page content contains media or not.
|
22 |
+
If you want more control over when FooBox assets are included, you can now exclude the assets by default, by enabling a setting. Then on each page, you can choose to include them when required.
|
23 |
+
Alternatively, you can leave the setting disabled, and then choose to exclude the FooBox assets from particular pages. A new metabox is now available when editing your pages or posts.
|
24 |
+
This new feature was only available in the PRO version beforehand, but we feel control over your website performance is something you should not have to pay for. Enjoy!
|
25 |
+
|
26 |
**Now includes a 7-day free trial of FooBox Pro!**
|
27 |
|
28 |
**FooBox Image Lightbox Features:**
|
32 |
* Zero configuration!
|
33 |
* Works with WordPress galleries
|
34 |
* Works with WordPress captioned images
|
35 |
+
* Control when to exclude / include FooBox JS & CSS assets
|
36 |
|
37 |
**[FooBox PRO](http://fooplugins.com/plugins/foobox/?utm_source=fooboxfreeplugin&utm_medium=fooboxfreeprolink&utm_campaign=foobox_free_wprepo) Features:**
|
38 |
|
84 |
|
85 |
== Changelog ==
|
86 |
|
87 |
+
= 2.5.0 =
|
88 |
+
* Added new setting to exclude FooBox assets by default
|
89 |
+
* Added metabox on all public post types to include/exclude FooBox assets
|
90 |
+
* Major version bump to avoid confusion with FooBox PRO 2.4.0.0
|
91 |
+
|
92 |
= 1.2.34 =
|
93 |
* Fix : lightbox was not working with FooGallery paging
|
94 |
* Updated to latest client CSS
|