AddFunc Head & Footer Code - Version 2

Version Description

19 Sep 2018

  • Adds... drumroll please... Body Start Code!
    • Insert code immediately after the opening body tag!
    • Fields for individual page/post code as well as site-wide code.
    • Optionally replace site-wide code with individual page/post code.
    • All behaves the same as head code and footer code, except for priority (no priority setting).
    • Note: There is no standard for opening body tag code in WordPress yet (contact me if I'm wrong). If there ever is, AddFunc Head & Footer Code may change so as to conform to the standard. We don't think this will effect performance in anyway, but if it does, we will let you know through this change log. If necessary, we may even leave this feature in place along with the new standardized method.
Download this release

Release Info

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

Code changes from version 1.5 to 2

Files changed (3) hide show
  1. addfunc-head-footer-code.php +74 -27
  2. options.php +7 -1
  3. readme.txt +52 -30
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.5
7
  Author: AddFunc
8
  Author URI: http://profiles.wordpress.org/addfunc
9
  License: Public Domain
@@ -24,10 +24,10 @@
24
  For site-wide head and footer code
25
  */
26
 
27
- if(!class_exists('aFhfc_class')) :
28
- define('AFHDFTRCD_ID', 'aFhfc');
29
- define('AFHDFTRCD_NICK', 'Head & Footer Code');
30
- class aFhfc_class
31
  {
32
  public static function file_path($file)
33
  {
@@ -37,12 +37,13 @@ define('AFHDFTRCD_NICK', 'Head & Footer Code');
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
  {
45
- add_options_page(AFHDFTRCD_NICK.' Plugin Options', AFHDFTRCD_NICK, 'manage_options', AFHDFTRCD_ID.'_options', array('aFhfc_class', 'options_page'));
46
  }
47
  public static function options_page()
48
  {
@@ -56,7 +57,7 @@ define('AFHDFTRCD_NICK', 'Head & Footer Code');
56
  public static function output_head_code()
57
  {
58
  $site_head_code = get_option('aFhfc_site_wide_head_code');
59
- $meta_head_code = get_post_meta(get_the_ID(),'aFhfc_head_code',true);
60
  $head_replace = get_post_meta(get_the_ID(),'aFhfc_head_replace',true);
61
  if(!empty($head_replace)){
62
  echo $meta_head_code."\n";
@@ -64,10 +65,21 @@ define('AFHDFTRCD_NICK', 'Head & Footer Code');
64
  echo $site_head_code."\n".$meta_head_code."\n";
65
  }
66
  }
 
 
 
 
 
 
 
 
 
 
 
67
  public static function output_footer_code()
68
  {
69
  $site_footer_code = get_option('aFhfc_site_wide_footer_code');
70
- $meta_footer_code = get_post_meta( get_the_ID(),'aFhfc_footer_code',true);
71
  $footer_replace = get_post_meta(get_the_ID(),'aFhfc_footer_replace',true);
72
  if(!empty($footer_replace)){
73
  echo $meta_footer_code."\n";
@@ -78,22 +90,36 @@ define('AFHDFTRCD_NICK', 'Head & Footer Code');
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
 
@@ -117,6 +143,8 @@ function aFhfc_mtbx($post)
117
  $values = get_post_custom($post->ID);
118
  $head_text = isset($values['aFhfc_head_code']) ? esc_attr($values['aFhfc_head_code'][0]) : '';
119
  $head_replace = isset($values['aFhfc_head_replace']) ? esc_attr($values['aFhfc_head_replace'][0]) : '';
 
 
120
  $footer_text = isset($values['aFhfc_footer_code']) ? esc_attr($values['aFhfc_footer_code'][0]) : '';
121
  $footer_replace = isset($values['aFhfc_footer_replace']) ? esc_attr($values['aFhfc_footer_replace'][0]) : '';
122
  wp_nonce_field('aFhfc_nonce', 'aFhfc_mb_nonce');
@@ -127,6 +155,12 @@ function aFhfc_mtbx($post)
127
  <input id="aFhfc_head_replace" type="checkbox" name="aFhfc_head_replace" value="1" <?php checked($head_replace,'1'); ?> />
128
  <label for="aFhfc_head_replace">Replace Site-wide Head Code</label>
129
  </p>
 
 
 
 
 
 
130
  <p>
131
  <label for="aFhfc_footer_code">Footer:</label>
132
  <textarea class="large-text" name="aFhfc_footer_code" id="aFhfc_footer_code"><?php echo $footer_text; ?></textarea>
@@ -138,25 +172,38 @@ function aFhfc_mtbx($post)
138
  add_action('save_post','aFhfc_save');
139
  function aFhfc_save($post_id)
140
  {
141
- if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
142
- if( !isset( $_POST['aFhfc_mb_nonce'] ) || !wp_verify_nonce( $_POST['aFhfc_mb_nonce'], 'aFhfc_nonce' ) ) return;
143
- if( !current_user_can( 'manage_options' ) ) return;
144
- if( isset( $_POST['aFhfc_head_code'] ) )
145
- if( empty( $_POST['aFhfc_head_code'] ) )
146
- delete_post_meta( $post_id, 'aFhfc_head_code' );
 
147
  else
148
- update_post_meta( $post_id, 'aFhfc_head_code',$_POST['aFhfc_head_code'] );
149
- $aFHFCHRChk = (isset($_POST['aFhfc_head_replace']) && $_POST['aFhfc_head_replace'])? '1' : '';
150
  if(empty($_POST['aFhfc_head_replace']))
151
  delete_post_meta($post_id,'aFhfc_head_replace');
152
  else
153
  update_post_meta($post_id,'aFhfc_head_replace',$aFHFCHRChk);
154
- if( isset( $_POST['aFhfc_footer_code'] ) )
155
- if( empty( $_POST['aFhfc_footer_code'] ) )
156
- delete_post_meta( $post_id, 'aFhfc_footer_code' );
 
 
 
 
 
 
 
 
 
 
 
 
157
  else
158
- update_post_meta( $post_id, 'aFhfc_footer_code', $_POST['aFhfc_footer_code'] );
159
- $aFHFCFRChk = (isset($_POST['aFhfc_footer_replace']) && $_POST['aFhfc_footer_replace'])? '1' : '';
160
  if(empty($_POST['aFhfc_footer_replace']))
161
  delete_post_meta($post_id,'aFhfc_footer_replace');
162
  else
3
  Plugin Name: AddFunc Head & Footer Code
4
  Plugin URI:
5
  Description: Allows admins to add code to the &lt;head&gt; and/or &lt;footer&gt; 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: 2
7
  Author: AddFunc
8
  Author URI: http://profiles.wordpress.org/addfunc
9
  License: Public Domain
24
  For site-wide head and footer code
25
  */
26
 
27
+ if(!class_exists('aFHFCClass')) :
28
+ define('AFHDFTRCD_ID', 'aFhfc');
29
+ define('AFHDFTRCD_NICK', 'Head & Footer Code');
30
+ class aFHFCClass
31
  {
32
  public static function file_path($file)
33
  {
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_body_code');
41
  register_setting(AFHDFTRCD_ID.'_options', 'aFhfc_site_wide_footer_code');
42
  register_setting(AFHDFTRCD_ID.'_options', 'aFhfc_footer_code_priority');
43
  }
44
  public static function menu()
45
  {
46
+ add_options_page(AFHDFTRCD_NICK.' Plugin Options', AFHDFTRCD_NICK, 'manage_options', AFHDFTRCD_ID.'_options', array('aFHFCClass', 'options_page'));
47
  }
48
  public static function options_page()
49
  {
57
  public static function output_head_code()
58
  {
59
  $site_head_code = get_option('aFhfc_site_wide_head_code');
60
+ $meta_head_code = ((is_archive()) || (is_author()) || (is_category()) || (is_tag()) || (is_home()) || (is_search()) || (is_404())) ? '' : get_post_meta(get_the_ID(),'aFhfc_head_code',true);
61
  $head_replace = get_post_meta(get_the_ID(),'aFhfc_head_replace',true);
62
  if(!empty($head_replace)){
63
  echo $meta_head_code."\n";
65
  echo $site_head_code."\n".$meta_head_code."\n";
66
  }
67
  }
68
+ public static function output_body_code()
69
+ {
70
+ $site_body_code = get_option('aFhfc_site_wide_body_code');
71
+ $meta_body_code = ((is_archive()) || (is_author()) || (is_category()) || (is_tag()) || (is_home()) || (is_search()) || (is_404())) ? '' : get_post_meta(get_the_ID(),'aFhfc_body_code',true);
72
+ $body_replace = get_post_meta(get_the_ID(),'aFhfc_body_replace',true);
73
+ if(!empty($body_replace)){
74
+ return $meta_body_code."\n";
75
+ }else{
76
+ return $site_body_code."\n".$meta_body_code."\n";
77
+ }
78
+ }
79
  public static function output_footer_code()
80
  {
81
  $site_footer_code = get_option('aFhfc_site_wide_footer_code');
82
+ $meta_footer_code = ((is_archive()) || (is_author()) || (is_category()) || (is_tag()) || (is_home()) || (is_search()) || (is_404())) ? '' : get_post_meta(get_the_ID(),'aFhfc_footer_code',true);
83
  $footer_replace = get_post_meta(get_the_ID(),'aFhfc_footer_replace',true);
84
  if(!empty($footer_replace)){
85
  echo $meta_footer_code."\n";
90
  }
91
  if (is_admin())
92
  {
93
+ add_action('admin_init', array('aFHFCClass','register'));
94
+ add_action('admin_menu', array('aFHFCClass','menu'));
95
  }
96
  $head_code_prior = get_option('aFhfc_head_code_priority');
97
  if(!empty($head_code_prior)){
98
+ add_action('wp_head', array('aFHFCClass','output_head_code'),$head_code_prior);
99
  }
100
  else {
101
+ add_action('wp_head', array('aFHFCClass','output_head_code'));
102
  }
103
+ function aFHFCBuffRec(){
104
+ ob_start();
105
+ }
106
+ add_action('wp_head','aFHFCBuffRec');
107
+ function aFHFCBuffPlay(){
108
+ $body_code = new aFHFCClass;
109
+ $tape = ob_get_clean();
110
+ $pattern = '/<[bB][oO][dD][yY]\s[A-Za-z]{2,5}[A-Za-z0-9 "_,=%*\'\/():;\[\]\-\.]+>|<body>/';
111
+ preg_match($pattern,$tape,$queue);
112
+ $q = $queue[0];
113
+ $q = $q.$body_code->output_body_code();
114
+ echo preg_replace($pattern,$q,$tape);
115
+ }
116
+ add_action('wp_print_footer_scripts','aFHFCBuffPlay');
117
  $footer_code_prior = get_option('aFhfc_footer_code_priority');
118
  if(!empty($footer_code_prior)){
119
+ add_action('wp_footer', array('aFHFCClass','output_footer_code'),$footer_code_prior);
120
  }
121
  else {
122
+ add_action('wp_footer', array('aFHFCClass','output_footer_code'));
123
  }
124
  endif;
125
 
143
  $values = get_post_custom($post->ID);
144
  $head_text = isset($values['aFhfc_head_code']) ? esc_attr($values['aFhfc_head_code'][0]) : '';
145
  $head_replace = isset($values['aFhfc_head_replace']) ? esc_attr($values['aFhfc_head_replace'][0]) : '';
146
+ $body_text = isset($values['aFhfc_body_code']) ? esc_attr($values['aFhfc_body_code'][0]) : '';
147
+ $body_replace = isset($values['aFhfc_body_replace']) ? esc_attr($values['aFhfc_body_replace'][0]) : '';
148
  $footer_text = isset($values['aFhfc_footer_code']) ? esc_attr($values['aFhfc_footer_code'][0]) : '';
149
  $footer_replace = isset($values['aFhfc_footer_replace']) ? esc_attr($values['aFhfc_footer_replace'][0]) : '';
150
  wp_nonce_field('aFhfc_nonce', 'aFhfc_mb_nonce');
155
  <input id="aFhfc_head_replace" type="checkbox" name="aFhfc_head_replace" value="1" <?php checked($head_replace,'1'); ?> />
156
  <label for="aFhfc_head_replace">Replace Site-wide Head Code</label>
157
  </p>
158
+ <p>
159
+ <label for="aFhfc_body_code">Body Start: <span class="dashicons dashicons-info" title="Inserts immediately after the opening body tag."></span></label>
160
+ <textarea class="large-text" name="aFhfc_body_code" id="aFhfc_body_code"><?php echo $body_text; ?></textarea>
161
+ <input id="aFhfc_body_replace" type="checkbox" name="aFhfc_body_replace" value="1" <?php checked($body_replace,'1'); ?> />
162
+ <label for="aFhfc_body_replace">Replace Site-wide Body Code</label>
163
+ </p>
164
  <p>
165
  <label for="aFhfc_footer_code">Footer:</label>
166
  <textarea class="large-text" name="aFhfc_footer_code" id="aFhfc_footer_code"><?php echo $footer_text; ?></textarea>
172
  add_action('save_post','aFhfc_save');
173
  function aFhfc_save($post_id)
174
  {
175
+ if(defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)return;
176
+ if(!isset($_POST['aFhfc_mb_nonce']) || !wp_verify_nonce($_POST['aFhfc_mb_nonce'],'aFhfc_nonce'))return;
177
+ if(!current_user_can('manage_options'))return;
178
+
179
+ if(isset($_POST['aFhfc_head_code']))
180
+ if(empty($_POST['aFhfc_head_code']))
181
+ delete_post_meta($post_id,'aFhfc_head_code');
182
  else
183
+ update_post_meta($post_id,'aFhfc_head_code',$_POST['aFhfc_head_code']);
184
+ $aFHFCHRChk = (isset($_POST['aFhfc_head_replace']) && $_POST['aFhfc_head_replace'])?'1':'';
185
  if(empty($_POST['aFhfc_head_replace']))
186
  delete_post_meta($post_id,'aFhfc_head_replace');
187
  else
188
  update_post_meta($post_id,'aFhfc_head_replace',$aFHFCHRChk);
189
+
190
+ if(isset($_POST['aFhfc_body_code']))
191
+ if(empty($_POST['aFhfc_body_code']))
192
+ delete_post_meta($post_id,'aFhfc_body_code');
193
+ else
194
+ update_post_meta($post_id,'aFhfc_body_code',$_POST['aFhfc_body_code']);
195
+ $aFHFCHRChk = (isset($_POST['aFhfc_body_replace']) && $_POST['aFhfc_body_replace'])?'1':'';
196
+ if(empty($_POST['aFhfc_body_replace']))
197
+ delete_post_meta($post_id,'aFhfc_body_replace');
198
+ else
199
+ update_post_meta($post_id,'aFhfc_body_replace',$aFHFCHRChk);
200
+
201
+ if( isset($_POST['aFhfc_footer_code']))
202
+ if( empty($_POST['aFhfc_footer_code']))
203
+ delete_post_meta($post_id,'aFhfc_footer_code');
204
  else
205
+ update_post_meta($post_id,'aFhfc_footer_code',$_POST['aFhfc_footer_code']);
206
+ $aFHFCFRChk = (isset($_POST['aFhfc_footer_replace']) && $_POST['aFhfc_footer_replace'])?'1':'';
207
  if(empty($_POST['aFhfc_footer_replace']))
208
  delete_post_meta($post_id,'aFhfc_footer_replace');
209
  else
options.php CHANGED
@@ -1,5 +1,4 @@
1
  <div class="wrap">
2
- <?php screen_icon(); ?>
3
  <h2>Head & Footer Code</h2>
4
  <div id="poststuff">
5
  <div id="post-body" class="metabox-holder columns-2">
@@ -15,6 +14,13 @@
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>
1
  <div class="wrap">
 
2
  <h2>Head & Footer Code</h2>
3
  <div id="poststuff">
4
  <div id="post-body" class="metabox-holder columns-2">
14
  <span class="description">Higher number = ealier output | Lower number = later output | Default = 10</span>
15
  <p>&nbsp;</p>
16
  </div>
17
+ <div>
18
+ <label for="aFhfc_site_wide_body_code">
19
+ <h3 class="title">Site-wide Body Start Code <span class="dashicons dashicons-info" title="Inserts immediately after the opening body tag."></span></h3>
20
+ <p><textarea name="aFhfc_site_wide_body_code" rows="10" cols="50" id="aFhfc_site_wide_body_code" class="large-text code"><?php echo get_option('aFhfc_site_wide_body_code'); ?></textarea></p>
21
+ </label>
22
+ <p>&nbsp;</p>
23
+ </div>
24
  <div>
25
  <label for="aFhfc_site_wide_footer_code">
26
  <h3 class="title">Site-wide Footer Code</h3>
readme.txt CHANGED
@@ -3,14 +3,14 @@
3
 
4
  Contributors: AddFunc,joerhoney
5
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=7AF7P3TFKQ2C2
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
 
13
- Easily add code to your head and/or footer, site-wide and/or on any individual page/post.
14
 
15
  == Description ==
16
 
@@ -36,21 +36,21 @@ Yep! That's what this plugin is made for.
36
 
37
  For the site wide code yes, as long as the theme is set up properly with the `wp_head()` and `wp_footer()` functions. For individual custom content type "entries" (as we'll call them) it will work as long as the custom content type (or custom post type more precisely) is set up in the standard way, so that WordPress will recognize that it needs to add all the usual meta boxes to it. Basically, it will work in a standard setup.
38
 
39
- = Where does the head code output? =
40
 
41
  Wherever `wp_head()` is located in your theme.
42
 
43
- = Where does the footer code output? =
44
 
45
- Wherever `wp_footer()` is located in your theme.
46
 
47
- = Will AddFunc Head & Footer Code work if there is no `wp_head()` or `wp_footer()` in my theme? =
48
 
49
- Wherever one of those functions is missing, your code will not be output there. But omitting one of them does not stop the other one from working. AddFunc Head & Footer Code will also save your code regardless. It just can't output your code without the presence of those functions in the theme.
50
 
51
- = Does it really require WordPress 3.0.1 or later? =
52
 
53
- I have not tested it on earlier versions, but I believe `wp_head()` and `wp_footer()` have been a part of WordPress since the very beginning, so it should work on any version. Feel free to try it out and let us know if it works! :)
54
 
55
  = Does AddFunc have a website? =
56
 
@@ -58,79 +58,101 @@ Yes. [addfunc.com](http://addfunc.com/)
58
 
59
  == Screenshots ==
60
 
61
- 1. Simply paste your code into one of these two fields and it will be included on every page of your website.
62
 
63
  2. Add your code to these fields respectively and it will output specifically to this page, post or custom post type. Optionally replace or remove the site-wide code on any individual post or page.
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
 
77
  * Adds option for individual post code to replace the site-wide code:
78
- - Head and footer managed independently of each other
79
- - Individual post code appends to site-wide by default
80
- - Check the *Replace Site-wide Head/Footer Code* checkbox to replace or remove the Site-wide code for the respective area
81
  * Fixes post meta fields:
82
- - No longer saves post meta fields when not needed
83
- - Deletes post meta fields if empty when saved/updated
84
 
85
  = 1.3 =
86
- 23-Jun-2015
87
 
88
  * Corrects the generated path to options.php, so that the settings page can be found even on installs where the plugins directory is not at the standard /wp-content/plugins location.
89
 
90
  = 1.2 =
91
- 19-Jun-2015
92
 
93
  * Discovered addfunc-head-footer-code.php was saved with text encoding Western (Mac OS Roman). ~>:( Changed to Unicode (UTF-8).
94
  * This was probably changed during a recent update on the plugin's tags (the tags for the WordPress Plugin Repository), so maybe two weeks ago. Previous downloads should have been UTF-8.
95
  * Also changed version 1.1 to UTF-8 because leaving a Mac OS Roman version in the repository would be pointless. So 1.1 and 1.2 are the same, except for the readme.txt.
96
 
97
  = 1.1 =
98
- 28-Nov-2014
99
 
100
  * Fixes meta box nounce.
101
  * Changes all references to Average (including but not limited to "avrg", "average", etc.) to relate to AddFunc (changing project name).
102
  * Changes a few other function and variable names for namespacing purposes.
103
- * Submitted to WordPress under the name AddFunc.
104
 
105
  = 1.0 =
106
- 7-Aug-2014
107
 
108
  * Includes readme.txt.
109
- * Submitted to WordPress.
110
 
111
  = 0.4.1 =
112
- 6-Aug-2014
113
 
114
  * Code cleaned up (mostly comments removed).
115
  * Excludes unnecessary file: style.css.
116
 
117
  = 0.4 =
118
- 8-Jul-2014
119
 
120
  * Bug fix: replaced "my-meta-box-id" with "avrghdftrcdMetaBox" (duh).
121
 
122
  = 0.3 =
123
- 27-Oct-2013
124
 
125
  * Hid Head & Footer Code meta box from non-admin users.
126
 
127
  = 0.2 =
128
- 15-Oct-2013
129
 
130
  * Adds a Head & Footer Code settings page for site-wide code (for admins only).
131
 
132
  = 0.1 =
133
- 14-Aug-2013
134
 
135
  * Adds Head & Footer Code meta box to all pages, posts and cusom post types.
136
  * Saves Head & Footer Code entry to the database as custom fields.
3
 
4
  Contributors: AddFunc,joerhoney
5
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=7AF7P3TFKQ2C2
6
+ Tags: head code, footer code, add to head, per page, tracking code, Google Analytics, javascript, meta tags, wp_head, wp_footer, body tag code, opening body tag
7
  Requires at least: 3.0.1
8
+ Tested up to: 4.9
9
+ Stable tag: 2
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
13
+ Easily add code to your head, footer and/or immediately after the opening body tag, site-wide and/or on any individual page/post.
14
 
15
  == Description ==
16
 
36
 
37
  For the site wide code yes, as long as the theme is set up properly with the `wp_head()` and `wp_footer()` functions. For individual custom content type "entries" (as we'll call them) it will work as long as the custom content type (or custom post type more precisely) is set up in the standard way, so that WordPress will recognize that it needs to add all the usual meta boxes to it. Basically, it will work in a standard setup.
38
 
39
+ = Where does the Head Code output? =
40
 
41
  Wherever `wp_head()` is located in your theme.
42
 
43
+ = Where does the Body Start Code output? =
44
 
45
+ Immediately after the opening `body` tag. Note: other plugins can be made to do the same thing and one of them has to insert before the other, so other plugins could theoretically insert code before AddFunc Head & Footer Code's Body Start Code.
46
 
47
+ = Where does the Footer Code output? =
48
 
49
+ Wherever `wp_footer()` is located in your theme.
50
 
51
+ = Will AddFunc Head & Footer Code work if there is no `wp_head()` or `wp_footer()` in my theme? =
52
 
53
+ Wherever one of those functions is missing, your code will not be output there. But omitting one of them does not stop the other ones from working. AddFunc Head & Footer Code will also save your code regardless. It just can't output your code without the presence of those functions in the theme.
54
 
55
  = Does AddFunc have a website? =
56
 
58
 
59
  == Screenshots ==
60
 
61
+ 1. Simply paste your code into one of these three fields and it will be included on every page of your website.
62
 
63
  2. Add your code to these fields respectively and it will output specifically to this page, post or custom post type. Optionally replace or remove the site-wide code on any individual post or page.
64
 
65
  == Changelog ==
66
 
67
+ = 2 =
68
+ 19 Sep 2018
69
+
70
+ * Adds... drumroll please... Body Start Code!
71
+ - Insert code immediately after the opening `body` tag!
72
+ - Fields for individual page/post code as well as site-wide code.
73
+ - Optionally replace site-wide code with individual page/post code.
74
+ - All behaves the same as head code and footer code, except for priority (no priority setting).
75
+ - Note: There is no standard for opening `body` tag code in WordPress yet (contact me if I'm wrong). If there ever is, AddFunc Head & Footer Code may change so as to conform to the standard. We don't think this will effect performance in anyway, but if it does, we will let you know through this change log. If necessary, we may even leave this feature in place along with the new standardized method.
76
+
77
+ = 1.5.1 =
78
+ 17 Sep 2018
79
+
80
+ * Removes individual post output on various pages:
81
+ - archive
82
+ - author
83
+ - category
84
+ - tag
85
+ - home
86
+ - search
87
+ - 404
88
+
89
  = 1.5 =
90
+ 13 Sep 2017
91
 
92
  * 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.
93
  * Adds ability to set the output priority of the footer code.
94
  * 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.
95
 
96
  = 1.4 =
97
+ 3 Apr 2017
98
 
99
  * Adds option for individual post code to replace the site-wide code:
100
+ - Head and footer managed independently of each other.
101
+ - Individual post code appends to site-wide by default.
102
+ - Check the *Replace Site-wide Head/Footer Code* checkbox to replace or remove the Site-wide code for the respective area.
103
  * Fixes post meta fields:
104
+ - No longer saves post meta fields when not needed.
105
+ - Deletes post meta fields if empty when saved/updated.
106
 
107
  = 1.3 =
108
+ 23 Jun 2015
109
 
110
  * Corrects the generated path to options.php, so that the settings page can be found even on installs where the plugins directory is not at the standard /wp-content/plugins location.
111
 
112
  = 1.2 =
113
+ 19 Jun 2015
114
 
115
  * Discovered addfunc-head-footer-code.php was saved with text encoding Western (Mac OS Roman). ~>:( Changed to Unicode (UTF-8).
116
  * This was probably changed during a recent update on the plugin's tags (the tags for the WordPress Plugin Repository), so maybe two weeks ago. Previous downloads should have been UTF-8.
117
  * Also changed version 1.1 to UTF-8 because leaving a Mac OS Roman version in the repository would be pointless. So 1.1 and 1.2 are the same, except for the readme.txt.
118
 
119
  = 1.1 =
120
+ 28 Nov 2014
121
 
122
  * Fixes meta box nounce.
123
  * Changes all references to Average (including but not limited to "avrg", "average", etc.) to relate to AddFunc (changing project name).
124
  * Changes a few other function and variable names for namespacing purposes.
125
+ * Submitted to the WordPress Plugin Repository under the name AddFunc.
126
 
127
  = 1.0 =
128
+ 7 Aug 2014
129
 
130
  * Includes readme.txt.
131
+ * Submitted to the WordPress Plugin Repository.
132
 
133
  = 0.4.1 =
134
+ 6 Aug 2014
135
 
136
  * Code cleaned up (mostly comments removed).
137
  * Excludes unnecessary file: style.css.
138
 
139
  = 0.4 =
140
+ 8 Jul 2014
141
 
142
  * Bug fix: replaced "my-meta-box-id" with "avrghdftrcdMetaBox" (duh).
143
 
144
  = 0.3 =
145
+ 27 Oct 2013
146
 
147
  * Hid Head & Footer Code meta box from non-admin users.
148
 
149
  = 0.2 =
150
+ 15 Oct 2013
151
 
152
  * Adds a Head & Footer Code settings page for site-wide code (for admins only).
153
 
154
  = 0.1 =
155
+ 14 Aug 2013
156
 
157
  * Adds Head & Footer Code meta box to all pages, posts and cusom post types.
158
  * Saves Head & Footer Code entry to the database as custom fields.