AddFunc Head & Footer Code - Version 1.5

Version Description

13-Sep-2017

  • Adds ability to set the output priority of the head code. Thanks to John Irvine at RD Technology Solutions for the suggestion.
  • Adds ability to set the output priority of the footer code.
  • Changes the metabox to a lower priority so it sits at the bottom by default instead of the top. Thanks to @enfueggo for the suggestion.
Download this release

Release Info

Developer joerhoney
Plugin Icon AddFunc Head & Footer Code
Version 1.5
Comparing to
See all releases

Code changes from version 1.4 to 1.5

Files changed (3) hide show
  1. addfunc-head-footer-code.php +20 -6
  2. options.php +18 -11
  3. readme.txt +8 -1
addfunc-head-footer-code.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: AddFunc Head & Footer Code
4
  Plugin URI:
5
  Description: Allows admins to add code to the <head> and/or <footer> of an individual post and/or site-wide. Ideal for scripts such as Google Analytics conversion tracking codes and any other general or page-specific JavaScript.
6
- Version: 1.4
7
  Author: AddFunc
8
  Author URI: http://profiles.wordpress.org/addfunc
9
  License: Public Domain
@@ -36,7 +36,9 @@ define('AFHDFTRCD_NICK', 'Head & Footer Code');
36
  public static function register()
37
  {
38
  register_setting(AFHDFTRCD_ID.'_options', 'aFhfc_site_wide_head_code');
 
39
  register_setting(AFHDFTRCD_ID.'_options', 'aFhfc_site_wide_footer_code');
 
40
  }
41
  public static function menu()
42
  {
@@ -76,11 +78,23 @@ define('AFHDFTRCD_NICK', 'Head & Footer Code');
76
  }
77
  if (is_admin())
78
  {
79
- add_action('admin_init', array('aFhfc_class', 'register'));
80
- add_action('admin_menu', array('aFhfc_class', 'menu'));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
  }
82
- add_action('wp_head', array('aFhfc_class', 'output_head_code'));
83
- add_action('wp_footer', array('aFhfc_class', 'output_footer_code'));
84
  endif;
85
 
86
 
@@ -95,7 +109,7 @@ add_action('add_meta_boxes','aFhfc_add');
95
  function aFhfc_add()
96
  {
97
  if(current_user_can('manage_options')){
98
- add_meta_box('aFhfcMetaBox','Head & Footer Code','aFhfc_mtbx','','normal','high');
99
  }
100
  }
101
  function aFhfc_mtbx($post)
3
  Plugin Name: AddFunc Head & Footer Code
4
  Plugin URI:
5
  Description: Allows admins to add code to the <head> and/or <footer> of an individual post and/or site-wide. Ideal for scripts such as Google Analytics conversion tracking codes and any other general or page-specific JavaScript.
6
+ Version: 1.5
7
  Author: AddFunc
8
  Author URI: http://profiles.wordpress.org/addfunc
9
  License: Public Domain
36
  public static function register()
37
  {
38
  register_setting(AFHDFTRCD_ID.'_options', 'aFhfc_site_wide_head_code');
39
+ register_setting(AFHDFTRCD_ID.'_options', 'aFhfc_head_code_priority');
40
  register_setting(AFHDFTRCD_ID.'_options', 'aFhfc_site_wide_footer_code');
41
+ register_setting(AFHDFTRCD_ID.'_options', 'aFhfc_footer_code_priority');
42
  }
43
  public static function menu()
44
  {
78
  }
79
  if (is_admin())
80
  {
81
+ add_action('admin_init', array('aFhfc_class','register'));
82
+ add_action('admin_menu', array('aFhfc_class','menu'));
83
+ }
84
+ $head_code_prior = get_option('aFhfc_head_code_priority');
85
+ if(!empty($head_code_prior)){
86
+ add_action('wp_head', array('aFhfc_class','output_head_code'),$head_code_prior);
87
+ }
88
+ else {
89
+ add_action('wp_head', array('aFhfc_class','output_head_code'));
90
+ }
91
+ $footer_code_prior = get_option('aFhfc_footer_code_priority');
92
+ if(!empty($footer_code_prior)){
93
+ add_action('wp_footer', array('aFhfc_class','output_footer_code'),$footer_code_prior);
94
+ }
95
+ else {
96
+ add_action('wp_footer', array('aFhfc_class','output_footer_code'));
97
  }
 
 
98
  endif;
99
 
100
 
109
  function aFhfc_add()
110
  {
111
  if(current_user_can('manage_options')){
112
+ add_meta_box('aFhfcMetaBox','Head & Footer Code','aFhfc_mtbx','','normal','low');
113
  }
114
  }
115
  function aFhfc_mtbx($post)
options.php CHANGED
@@ -6,23 +6,30 @@
6
  <div id="post-body-content">
7
  <form action="options.php" method="post" id="<?php echo $plugin_id; ?>_options_form" name="<?php echo $plugin_id; ?>_options_form">
8
  <?php settings_fields($plugin_id.'_options'); ?>
9
- <label for="aFhfc_site_wide_head_code">
10
- <h2 class="title">Site-wide Head Code</h2>
11
- <p><textarea name="aFhfc_site_wide_head_code" rows="10" cols="50" id="aFhfc_site_wide_head_code" class="large-text code"><?php echo get_option('aFhfc_site_wide_head_code'); ?></textarea></p>
12
- </label>
13
- <label for="aFhfc_site_wide_footer_code">
14
- <h2 class="title">Site-wide Footer Code</h2>
15
- <p><textarea name="aFhfc_site_wide_footer_code" rows="10" cols="50" id="aFhfc_site_wide_footer_code" class="large-text code"><?php echo get_option('aFhfc_site_wide_footer_code'); ?></textarea></p>
16
- </label>
 
 
 
 
 
 
 
 
 
17
  <?php submit_button(); ?>
18
  </form>
19
  </div> <!-- post-body-content -->
20
  <!-- sidebar -->
21
  <div id="postbox-container-1" class="postbox-container">
22
- <h2></h2>
23
- <p></p>
24
  </div> <!-- #postbox-container-1 .postbox-container -->
25
  </div> <!-- #post-body .metabox-holder .columns-2 -->
26
  <br class="clear">
27
  </div> <!-- #poststuff -->
28
- </div>
6
  <div id="post-body-content">
7
  <form action="options.php" method="post" id="<?php echo $plugin_id; ?>_options_form" name="<?php echo $plugin_id; ?>_options_form">
8
  <?php settings_fields($plugin_id.'_options'); ?>
9
+ <div>
10
+ <label for="aFhfc_site_wide_head_code">
11
+ <h3 class="title">Site-wide Head Code</h3>
12
+ <p><textarea name="aFhfc_site_wide_head_code" rows="10" cols="50" id="aFhfc_site_wide_head_code" class="large-text code"><?php echo get_option('aFhfc_site_wide_head_code'); ?></textarea></p>
13
+ </label>
14
+ <label class="aFtext" for="aFhfc_head_code_priority"><strong>Head code Priority:</strong></label> <input id="aFhfc_head_code_priority" class="small-text" type="number" min="0" step="1" name="aFhfc_head_code_priority" value="<?php echo get_option('aFhfc_head_code_priority'); ?>" />
15
+ <span class="description">Higher number = ealier output | Lower number = later output | Default = 10</span>
16
+ <p>&nbsp;</p>
17
+ </div>
18
+ <div>
19
+ <label for="aFhfc_site_wide_footer_code">
20
+ <h3 class="title">Site-wide Footer Code</h3>
21
+ <p><textarea name="aFhfc_site_wide_footer_code" rows="10" cols="50" id="aFhfc_site_wide_footer_code" class="large-text code"><?php echo get_option('aFhfc_site_wide_footer_code'); ?></textarea></p>
22
+ </label>
23
+ <label class="aFtext" for="aFhfc_footer_code_priority"><strong>Footer code Priority:</strong></label> <input id="aFhfc_footer_code_priority" class="small-text" type="number" min="0" step="1" name="aFhfc_footer_code_priority" value="<?php echo get_option('aFhfc_footer_code_priority'); ?>" />
24
+ <span class="description">Higher number = ealier output | Lower number = later output | Default = 10</span>
25
+ </div>
26
  <?php submit_button(); ?>
27
  </form>
28
  </div> <!-- post-body-content -->
29
  <!-- sidebar -->
30
  <div id="postbox-container-1" class="postbox-container">
 
 
31
  </div> <!-- #postbox-container-1 .postbox-container -->
32
  </div> <!-- #post-body .metabox-holder .columns-2 -->
33
  <br class="clear">
34
  </div> <!-- #poststuff -->
35
+ </div>
readme.txt CHANGED
@@ -6,7 +6,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
6
  Tags: head code, footer code, add to head, per page, script, tracking code, Google Analytics, javascript, meta tags, insert code, wp_head, wp_footer
7
  Requires at least: 3.0.1
8
  Tested up to: 4.8
9
- Stable tag: 1.4
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
@@ -64,6 +64,13 @@ Yes. [addfunc.com](http://addfunc.com/)
64
 
65
  == Changelog ==
66
 
 
 
 
 
 
 
 
67
  = 1.4 =
68
  3-Apr-2017
69
 
6
  Tags: head code, footer code, add to head, per page, script, tracking code, Google Analytics, javascript, meta tags, insert code, wp_head, wp_footer
7
  Requires at least: 3.0.1
8
  Tested up to: 4.8
9
+ Stable tag: 1.5
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
64
 
65
  == Changelog ==
66
 
67
+ = 1.5 =
68
+ 13-Sep-2017
69
+
70
+ * Adds ability to set the output priority of the head code. Thanks to John Irvine at [RD Technology Solutions](http://rdtechsol.com/) for the suggestion.
71
+ * Adds ability to set the output priority of the footer code.
72
+ * Changes the metabox to a lower priority so it sits at the bottom by default instead of the top. Thanks to [@enfueggo](https://wordpress.org/support/topic/lowering-metabox-priority/) for the suggestion.
73
+
74
  = 1.4 =
75
  3-Apr-2017
76