Scripts To Footer - Version 0.5

Version Description

Reverted metabox version to previous - invalid error was sneaking through.

Download this release

Release Info

Developer joshuadnelson
Plugin Icon wp plugin Scripts To Footer
Version 0.5
Comparing to
See all releases

Code changes from version 0.3 to 0.5

Files changed (3) hide show
  1. readme.txt +50 -14
  2. scripts-to-footer.php +34 -30
  3. uninstall.php +0 -0
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Scripts To Footer ===
2
  Contributors: joshuadnelson
3
  Tags: javascript, footer, speed, head, performance
4
- Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FGQXZEW8S9UPC
5
- Requires at least: 3.0.1
6
- Tested up to: 3.9
7
- Stable tag: 0.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -14,10 +14,34 @@ This small plugin moves scripts to the footer to help speed up page load times,
14
 
15
  This small plugin moves scripts to the footer to help speed up page load times, while keeping stylesheets in the header. Note that this only works if you have plugins and a theme that utilizes `wp_enqueue_scripts` correctly.
16
 
17
- Now includes an option to disable the plugin on a specific page.
18
-
19
- Finally, if you're comfortable with code you can use the `scripts_to_footer_post_types` filter to change the post types this applies to (it only applies to pages and posts by default).
20
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  [View this plugin on GitHub](https://github.com/joshuadavidnelson/scripts-to-footer)
22
 
23
  == Installation ==
@@ -27,8 +51,8 @@ This section describes how to install the plugin and get it working.
27
  e.g.
28
 
29
  1. Upload `scripts-to-footer.php` to the `/wp-content/plugins/` directory
30
- 1. Activate the plugin through the 'Plugins' menu in WordPress
31
- 1. Once activated, it should work.
32
 
33
  == Screenshots ==
34
 
@@ -36,9 +60,15 @@ e.g.
36
 
37
  == Changelog ==
38
 
39
- = 0.3 =
40
- Added conditional to disable on plugin on admin dashboard, version bump.
41
 
 
 
 
 
 
 
42
  = 0.2 =
43
  Updating code to be object-oriented and added page metabox to disable plugin on specific pages.
44
 
@@ -47,8 +77,14 @@ Initial release
47
 
48
  == Upgrade Notice ==
49
 
 
 
 
 
 
 
50
  = 0.3 =
51
- Adds safeguard to avoid conflicts on admin dashboard.
52
 
53
  = 0.2 =
54
- This upgrade adds options to disable plugin on specific pages.
1
  === Scripts To Footer ===
2
  Contributors: joshuadnelson
3
  Tags: javascript, footer, speed, head, performance
4
+ Donate link: http://jdn.im/donate
5
+ Requires at least: 3.6
6
+ Tested up to: 4.0
7
+ Stable tag: 0.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
14
 
15
  This small plugin moves scripts to the footer to help speed up page load times, while keeping stylesheets in the header. Note that this only works if you have plugins and a theme that utilizes `wp_enqueue_scripts` correctly.
16
 
17
+ Now includes an option to disable the plugin on a specific page or post.
18
+
19
+ = Custom Post Type Support =
20
+ If you're comfortable with code you can use the `scripts_to_footer_post_types` filter to change the post types this applies to (it only applies to pages and posts by default). For example, if you have a custom post type called "project" you could add support for this metabox via the post type filter like this:
21
+
22
+ `
23
+ function stf_add_cpt_support( $post_types ) {
24
+ $post_types[] = 'project';
25
+
26
+ return $post_types;
27
+ }
28
+ add_filter( 'scripts_to_footer_post_types', 'stf_add_cpt_support' );
29
+ `
30
+
31
+ = Excluding Pages/Posts Via Filter =
32
+ As of version 0.5 you can either use the checkbox option to disable the plugin's action on a specific page/post, or you can utilize a filter. The filter also passes the post/page id, which might be useful for more advanced development. For example:
33
+
34
+ `
35
+ function stf_exclude_my_page( $exclude_page, $post_id ) {
36
+ if( is_front_page() ) {
37
+ $exclude_page = 'on'; // this turns on the "exclude" option
38
+ }
39
+ return $exclude_page;
40
+ }
41
+ add_filter( 'scripts_to_footer_exclude_page', 'stf_exclude_my_page' );
42
+ `
43
+
44
+ = View on GitHub =
45
  [View this plugin on GitHub](https://github.com/joshuadavidnelson/scripts-to-footer)
46
 
47
  == Installation ==
51
  e.g.
52
 
53
  1. Upload `scripts-to-footer.php` to the `/wp-content/plugins/` directory
54
+ 2. Activate the plugin through the 'Plugins' menu in WordPress
55
+ 3. You can disable the plugin on specific pages or posts via a checkbox.
56
 
57
  == Screenshots ==
58
 
60
 
61
  == Changelog ==
62
 
63
+ = 0.5 =
64
+ Reverted metabox version to previous - invalid error was sneaking through.
65
 
66
+ = 0.4 =
67
+ Added filter to exclude pages, updated metabox version, plugin version bump and updated readme.txt file.
68
+
69
+ = 0.3 =
70
+ Added conditional to disable on plugin on admin dashboard, version bump.
71
+
72
  = 0.2 =
73
  Updating code to be object-oriented and added page metabox to disable plugin on specific pages.
74
 
77
 
78
  == Upgrade Notice ==
79
 
80
+ = 0.5 =
81
+ Please update to avoid an error on 0.4 version. If you're updating from version 0.3 or earlier, you'll get a new filter.
82
+
83
+ = 0.4 =
84
+ Adds filter for excluded page ids and updated to most current metabox system.
85
+
86
  = 0.3 =
87
+ Adds safeguard to avoid conflicts on admin dashboard.
88
 
89
  = 0.2 =
90
+ This upgrade adds options to disable plugin on specific pages.
scripts-to-footer.php CHANGED
@@ -12,7 +12,7 @@
12
  * Plugin Name: Scripts-To-Footer
13
  * Plugin URI: http://wordpress.org/plugins/scripts-to-footerphp/
14
  * Description: Moves scripts to the footer to decrease page load times, while keeping stylesheets in the header. Requires that plugins and theme correctly utilizes wp_enqueue_scripts hook. Can be disabled via a checkbox on specific pages and posts.
15
- * Version: 0.3
16
  * Author: Joshua David Nelson
17
  * Author URI: http://joshuadnelson.com
18
  * License: GPL2
@@ -43,7 +43,7 @@ if( !defined( 'STF_DOMAIN' ) )
43
 
44
  // Plugin Verison
45
  if( !defined( 'STF_VERSION' ) )
46
- define( 'STF_VERSION', '0.3' );
47
 
48
  /**
49
  * Scripts to Footer Class.
@@ -65,7 +65,6 @@ class JDN_Scripts_To_Footer {
65
  */
66
  function __construct() {
67
  add_action( 'init', array( $this, 'init' ) );
68
- add_action( 'init', array( $this, 'initialize_cmb_meta_boxes' ), 50 );
69
  }
70
 
71
  /**
@@ -83,6 +82,7 @@ class JDN_Scripts_To_Footer {
83
 
84
  // Metabox on Edit screen, for Page Override
85
  add_filter( 'cmb_meta_boxes', array( $this, 'create_metaboxes' ) );
 
86
 
87
  // Add Links to Plugin Bar
88
  if( function_exists( 'stf_plugin_links' ) )
@@ -97,12 +97,16 @@ class JDN_Scripts_To_Footer {
97
  * @since 0.1
98
  **/
99
  function clean_head() {
100
- $excluded_pages = get_post_meta( get_queried_object_id(), 'stf_exclude', true );
101
-
102
- if( 'on' !== $excluded_pages && !is_admin() ) {
103
- remove_action( 'wp_head', 'wp_print_scripts' );
104
- remove_action( 'wp_head', 'wp_print_head_scripts', 9 );
105
- remove_action( 'wp_head', 'wp_enqueue_scripts', 1 );
 
 
 
 
106
  }
107
  }
108
 
@@ -147,9 +151,9 @@ class JDN_Scripts_To_Footer {
147
  **/
148
  function initialize_cmb_meta_boxes() {
149
  $post_types = apply_filters( 'scripts_to_footer_post_types', array( 'page', 'post' ) );
150
- if( !class_exists( 'cmb_Meta_Box' ) && !empty( $post_types ) ) {
151
- require_once( dirname( __FILE__) . '/lib/metabox/init.php' );
152
- }
153
  }
154
 
155
  }
@@ -166,24 +170,24 @@ $stf_scripts_to_footer = new JDN_Scripts_To_Footer();
166
  *
167
  * @return strings plugin links
168
  */
169
- function stf_plugin_links( $links, $file ) {
170
- static $this_plugin;
171
-
172
- /** Capability Check */
173
- if( ! current_user_can( 'install_plugins' ) )
 
 
 
 
 
 
 
 
 
 
 
 
 
174
  return $links;
175
-
176
- if( !$this_plugin ) {
177
- $this_plugin = plugin_basename(__FILE__);
178
- }
179
-
180
- if( $file == $this_plugin ) {
181
- $links[] = '<a href="http://wordpress.org/support/plugin/scripts-to-footerphp" title="' . __( 'Support', STF_DOMAIN ) . '">' . __( 'Support', STF_DOMAIN ) . '</a>';
182
-
183
- $links[] = '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FGQXZEW8S9UPC" title="' . __( 'Donate', STF_DOMAIN ) . '">' . __( 'Donate', STF_DOMAIN ) . '</a>';
184
  }
185
-
186
- return $links;
187
  }
188
-
189
- ?>
12
  * Plugin Name: Scripts-To-Footer
13
  * Plugin URI: http://wordpress.org/plugins/scripts-to-footerphp/
14
  * Description: Moves scripts to the footer to decrease page load times, while keeping stylesheets in the header. Requires that plugins and theme correctly utilizes wp_enqueue_scripts hook. Can be disabled via a checkbox on specific pages and posts.
15
+ * Version: 0.5
16
  * Author: Joshua David Nelson
17
  * Author URI: http://joshuadnelson.com
18
  * License: GPL2
43
 
44
  // Plugin Verison
45
  if( !defined( 'STF_VERSION' ) )
46
+ define( 'STF_VERSION', '0.5' );
47
 
48
  /**
49
  * Scripts to Footer Class.
65
  */
66
  function __construct() {
67
  add_action( 'init', array( $this, 'init' ) );
 
68
  }
69
 
70
  /**
82
 
83
  // Metabox on Edit screen, for Page Override
84
  add_filter( 'cmb_meta_boxes', array( $this, 'create_metaboxes' ) );
85
+ add_action( 'init', array( $this, 'initialize_cmb_meta_boxes' ), 50 );
86
 
87
  // Add Links to Plugin Bar
88
  if( function_exists( 'stf_plugin_links' ) )
97
  * @since 0.1
98
  **/
99
  function clean_head() {
100
+ if( get_queried_object_id() ) {
101
+ $queried_object_id = get_queried_object_id();
102
+ $exclude_page = get_post_meta( $queried_object_id, 'stf_exclude', true );
103
+ $exclude_page = apply_filters( 'scripts_to_footer_exclude_page', $exclude_page, $queried_object_id );
104
+
105
+ if( 'on' !== $exclude_page && !is_admin() ) {
106
+ remove_action( 'wp_head', 'wp_print_scripts' );
107
+ remove_action( 'wp_head', 'wp_print_head_scripts', 9 );
108
+ remove_action( 'wp_head', 'wp_enqueue_scripts', 1 );
109
+ }
110
  }
111
  }
112
 
151
  **/
152
  function initialize_cmb_meta_boxes() {
153
  $post_types = apply_filters( 'scripts_to_footer_post_types', array( 'page', 'post' ) );
154
+ if( !class_exists( 'cmb_Meta_Box' ) && !empty( $post_types ) ) {
155
+ require_once( dirname( __FILE__) . '/lib/metabox/init.php' );
156
+ }
157
  }
158
 
159
  }
170
  *
171
  * @return strings plugin links
172
  */
173
+ if( !function_exists( 'stf_plugin_links' ) ) {
174
+ function stf_plugin_links( $links, $file ) {
175
+ static $this_plugin;
176
+
177
+ /** Capability Check */
178
+ if( ! current_user_can( 'install_plugins' ) )
179
+ return $links;
180
+
181
+ if( !$this_plugin ) {
182
+ $this_plugin = plugin_basename(__FILE__);
183
+ }
184
+
185
+ if( $file == $this_plugin ) {
186
+ $links[] = '<a href="http://wordpress.org/support/plugin/scripts-to-footerphp" title="' . __( 'Support', STF_DOMAIN ) . '">' . __( 'Support', STF_DOMAIN ) . '</a>';
187
+
188
+ $links[] = '<a href="http://jdn.im/donate" title="' . __( 'Donate', STF_DOMAIN ) . '">' . __( 'Donate', STF_DOMAIN ) . '</a>';
189
+ }
190
+
191
  return $links;
 
 
 
 
 
 
 
 
 
192
  }
 
 
193
  }
 
 
uninstall.php CHANGED
File without changes