Head & Footer Code - Version 1.2.2

Version Description

(2021-04-24) = * Tested: on WordPress 5.7.1 * (2021-02-01) Fix: Noice errors in update script (thanks to @swinggraphics) * Improve: wording on post/page listing

Download this release

Release Info

Developer urkekg
Plugin Icon Head & Footer Code
Version 1.2.2
Comparing to
See all releases

Code changes from version 1.2.1 to 1.2.2

head-footer-code.php CHANGED
@@ -8,7 +8,7 @@
8
  * Plugin Name: Head & Footer Code
9
  * Plugin URI: https://urosevic.net/wordpress/plugins/head-footer-code/
10
  * Description: Easy add site-wide and/or article specific custom code to head and/or footer sections (before the &lt;/head&gt; or &lt;/body&gt; or opening &lt;body&gt;) by hooking to <code>wp_head</code>, <code>wp_footer</code> and <code>wp_body_open</code>.
11
- * Version: 1.2.1
12
  * Author: Aleksandar Urosevic
13
  * Author URI: https://urosevic.net/
14
  * License: GPLv3
@@ -21,7 +21,7 @@ if ( ! defined( 'WPINC' ) ) {
21
  die;
22
  }
23
 
24
- define( 'WPAU_HEAD_FOOTER_CODE_VER', '1.2.1' );
25
  define( 'WPAU_HEAD_FOOTER_CODE_DB_VER', '6' );
26
  define( 'WPAU_HEAD_FOOTER_CODE_FILE', __FILE__ );
27
  define( 'WPAU_HEAD_FOOTER_CODE_DIR', dirname( WPAU_HEAD_FOOTER_CODE_FILE ) . '/');
8
  * Plugin Name: Head & Footer Code
9
  * Plugin URI: https://urosevic.net/wordpress/plugins/head-footer-code/
10
  * Description: Easy add site-wide and/or article specific custom code to head and/or footer sections (before the &lt;/head&gt; or &lt;/body&gt; or opening &lt;body&gt;) by hooking to <code>wp_head</code>, <code>wp_footer</code> and <code>wp_body_open</code>.
11
+ * Version: 1.2.2
12
  * Author: Aleksandar Urosevic
13
  * Author URI: https://urosevic.net/
14
  * License: GPLv3
21
  die;
22
  }
23
 
24
+ define( 'WPAU_HEAD_FOOTER_CODE_VER', '1.2.2' );
25
  define( 'WPAU_HEAD_FOOTER_CODE_DB_VER', '6' );
26
  define( 'WPAU_HEAD_FOOTER_CODE_FILE', __FILE__ );
27
  define( 'WPAU_HEAD_FOOTER_CODE_DIR', dirname( WPAU_HEAD_FOOTER_CODE_FILE ) . '/');
inc/posts-custom-columns.php CHANGED
@@ -71,7 +71,7 @@ function auhfc_posts_custom_columns( $column, $post_id ) {
71
  /* translators: This is description for article without defined code */
72
  esc_html__( 'No article specific code defined in any section', 'head-footer-code' ),
73
  /* translators: This is label for article without defined code */
74
- esc_html__( 'Not article code', 'head-footer-code' )
75
  );
76
  } else {
77
  $mode = auhfc_get_meta( 'behavior', $post_id );
71
  /* translators: This is description for article without defined code */
72
  esc_html__( 'No article specific code defined in any section', 'head-footer-code' ),
73
  /* translators: This is label for article without defined code */
74
+ esc_html__( 'No custom code', 'head-footer-code' )
75
  );
76
  } else {
77
  $mode = auhfc_get_meta( 'behavior', $post_id );
inc/update.php CHANGED
@@ -86,7 +86,6 @@ function auhfc_update_2() {
86
 
87
  } // END function auhfc_update_2()
88
 
89
-
90
  /**
91
  * Initialize updater
92
  */
@@ -139,7 +138,6 @@ function auhfc_update_4() {
139
 
140
  } // END function auhfc_update_4()
141
 
142
-
143
  /**
144
  * Split settings to 3 options (v1.2)
145
  */
@@ -149,23 +147,23 @@ function auhfc_update_5() {
149
  $defaults = get_option( 'auhfc_settings' );
150
 
151
  $sitewide = [
152
- 'head' => $defaults['head'],
153
- 'body' => $defaults['body'],
154
- 'footer' => $defaults['footer'],
155
- 'do_shortcode' => $defaults['do_shortcode'],
156
  ];
157
  update_option( 'auhfc_settings_sitewide', $sitewide );
158
 
159
  $homepage = [
160
- 'head' => $defaults['homepage_head'],
161
- 'body' => $defaults['homepage_body'],
162
- 'footer' => $defaults['homepage_footer'],
163
- 'behavior' => $defaults['homepage_behavior'],
164
  ];
165
  update_option( 'auhfc_settings_homepage', $homepage );
166
 
167
  $article = [
168
- 'post_types' => $defaults['post_types'],
169
  ];
170
  update_option( 'auhfc_settings_article', $article );
171
 
86
 
87
  } // END function auhfc_update_2()
88
 
 
89
  /**
90
  * Initialize updater
91
  */
138
 
139
  } // END function auhfc_update_4()
140
 
 
141
  /**
142
  * Split settings to 3 options (v1.2)
143
  */
147
  $defaults = get_option( 'auhfc_settings' );
148
 
149
  $sitewide = [
150
+ 'head' => ! empty( $defaults['head'] ) ? $defaults['head'] : '',
151
+ 'body' => ! empty( $defaults['body'] ) ? $defaults['body'] : '',
152
+ 'footer' => ! empty( $defaults['footer'] ) ? $defaults['footer'] : '',
153
+ 'do_shortcode' => ! empty( $defaults['do_shortcode'] ) ? $defaults['do_shortcode'] : 'n',
154
  ];
155
  update_option( 'auhfc_settings_sitewide', $sitewide );
156
 
157
  $homepage = [
158
+ 'head' => ! empty( $defaults['homepage_head'] ) ? $defaults['homepage_head'] : '',
159
+ 'body' => ! empty( $defaults['homepage_body'] ) ? $defaults['homepage_body'] : '',
160
+ 'footer' => ! empty( $defaults['homepage_footer'] ) ? $defaults['homepage_footer'] : '',
161
+ 'behavior' => ! empty( $defaults['homepage_behavior'] ) ? $defaults['homepage_behavior'] : 'append',
162
  ];
163
  update_option( 'auhfc_settings_homepage', $homepage );
164
 
165
  $article = [
166
+ 'post_types' => ! empty( $defaults['post_types'] ) ? $defaults['post_types'] : [],
167
  ];
168
  update_option( 'auhfc_settings_article', $article );
169
 
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Head & Footer Code ===
2
  Contributors: urkekg, techwebux
3
  Donate link: https://urosevic.net/wordpress/donate/?donate_for=head-footer-code
4
- Tags: wp_head, wp_footer, wp_body_open, head footer code, custom script
5
  Requires at least: 4.9
6
- Tested up to: 5.6
7
- Stable tag: 1.2.1
8
  Requires PHP: 5.6
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
@@ -13,27 +13,38 @@ Easy add site-wide and/or article specific custom code before the closing &lt;/h
13
 
14
  == Description ==
15
 
16
- Let we say that you have been told to add some custom code (HTML, JavaScript or CSS style) to page's `<head>` (like site verification code, custom styles, webfont link, etc), just before `</body>` or right after opening `<body>` (like pixel tracking, analytics code, heatmap code, etc), but you are not programmer. Then you can use Head &amp; Footer Code to do that.
17
 
18
- Simply go to Tools &rarr; Head &amp; Footer Code in your website admin dashboard, and insert custom code to HEAD, BODY or FOOTER section (depending what you have to do).
19
 
20
- If your WordPress show latest blog posts on homepage, you can also add specific code only for homepage on **Tools** &rarr; **Head &amp; Footer Code** (there will be section **Head, body and footer code on Homepage in Blog Posts mode**)
21
 
22
- If you have to insert some custom code specific for individual article (post, page, custom post type), then you can use Article specific metabox while you editing post/page/custom post type (check out [Screenshots](https://wordpress.org/plugins/head-footer-code/#screenshots)). There you can also set should that specific code be appended to site-wide code defined on **Tools** &rarr; **Head &amp; Footer Code**, or should be overwritten.
23
 
24
- Please note that taxonomies does not have own specific code but global code is added on those pages (category, tag and custom taxonomy listing, individual category, tags and custom taxonomies).
25
 
26
  This magic is done by hooking to WordPress hooks `wp_head`, `wp_footer` and `wp_body_open`.
27
 
28
  https://www.youtube.com/watch?v=Gd41Dv09UC4
29
 
30
- **Works or broken?**
 
 
 
 
 
 
 
 
 
 
 
31
 
32
- Please, consider to vote for this plugin. When you vote for broken, be so kind and tell in the [Forum](https://wordpress.org/support/plugin/head-footer-code/) what is broken. Maybe I might be able to fix it to make the plugin also work for you.
33
 
34
- **I need your support**
35
 
36
- It is very hard to continue development and support for this and my other free plugisn without contributions from users like you. If you enjoy using Head &amp; Footer Code and find it useful, please consider [making a donation](https://urosevic.net/wordpress/donate/?donate_for=head-footer-code). Your donation will help encourage and support the plugin's continued development and better user support.
37
 
38
  **Features**
39
 
@@ -52,43 +63,46 @@ It is very hard to continue development and support for this and my other free p
52
  * If you have set WP_DEBUG constant in `wp-config.php` to `true`, you'll see site-wide and article specific entries in page source code wrapped to comments.
53
  * Multisite is supported.
54
 
55
- General settings, including HEAD, BODY, FOOTER global code and priority, and also homepage code and behavior have been saved to WordPress option `auhfc_settings`.
56
- Each post/page/custom post type specific HEAD, BODY and FOOTER code and behavior have been saved to post meta `_auhfc`.
57
- On plugin uninstall these data is also deleted from database.
58
 
59
  == Installation ==
60
 
61
- Installation of this plugin is fairly easy as any other WordPress plugin.
62
 
63
  **Standard procedure**
64
 
65
- 1. Go to **Plugins** &rarr; **Add New**.
66
- 1. Search for **head footer code**.
67
- 1. Enter to **Search Plugin** field `had footer code` and press Enter key.
68
- 1. Locate plugin **Head &amp; Footer Code** and click **Install Now** button.
69
- 1. After successfully installed plugin click link **Activate Plugin**.
70
- 1. Visit the **Tools** &rarr; **Head &amp; Footer Code**.
71
- 1. Add the desired code to proper section.
72
 
73
  **FTP procedure**
74
 
75
- 1. Unpack `head-footer-code.zip`
76
- 1. Upload the whole directory and everything underneath to the `/wp-content/plugins/` directory.
77
- 1. Activate the plugin through the 'Plugins' menu in WordPress.
78
- 1. Visit the **Tools** &rarr; **Head &amp; Footer Code** (**Settings** link).
79
- 1. Add the desired code to proper section.
 
80
 
81
  == Frequently Asked Questions ==
82
 
83
- = Why another one custom code plugin? =
84
 
85
- Because all other similar plugins could not satisfy my requirements. In general, they have too much features or lack some features I need.
86
 
87
- = I entered code to BODY section but nothing output on front-end =
88
 
89
- This feature is implemented since WordPress version 5.2, but also require compatibility theme. Make sure that your theme support [wp_body_open](https://developer.wordpress.org/reference/hooks/wp_body_open/) hook.
 
 
 
 
90
 
91
- Open in code editor `header.php` file from theme you use, and check if right after opening `<BODY>` tag there is following code (if it does not exists, add it or ask some developer to do that for you):
92
  ```if ( function_exists( 'wp_body_open' ) ) {
93
  wp_body_open();
94
  }```
@@ -101,7 +115,7 @@ Open in code editor `header.php` file from theme you use, and check if right aft
101
  4. Example of custom code inserted to HEAD section (site-wide with appended article specific)
102
  5. Example of custom code inserted to BODY section (site-wide with appended article specific)
103
  6. Example of custom code inserted to FOOTER section (site-wide with appended article specific)
104
- 7. Example of Head & Footer Code column on Pages listing, to identify which pages have set custom code, which one and what mode is selected
105
 
106
  == Upgrade Notice ==
107
 
@@ -109,6 +123,11 @@ Open in code editor `header.php` file from theme you use, and check if right aft
109
  Initial release of new plugin developed by Aleksandar Urosevic.
110
 
111
  == Changelog ==
 
 
 
 
 
112
  = 1.2.1 =
113
  * Add: Head & Footer Code column to post/page/custom post type listing to show if/what article specific custom code is defined
114
  * Fix: in_array() expects parameter 2 to be array, null given in head-footer-code/inc/front.php on line 46, 111, and 176
1
  === Head & Footer Code ===
2
  Contributors: urkekg, techwebux
3
  Donate link: https://urosevic.net/wordpress/donate/?donate_for=head-footer-code
4
+ Tags: head, header, footer, body, scripts, wp_head, wp_footer, wp_body_open, head footer code, custom script
5
  Requires at least: 4.9
6
+ Tested up to: 5.7
7
+ Stable tag: 1.2.2
8
  Requires PHP: 5.6
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
13
 
14
  == Description ==
15
 
16
+ **Head &amp; Footer Code** plugin helps you add custom code snippets (JavaScript, CSS, or HTML) to the page even if you are not a programmer. It could be `<head>` (site verification code for various services, custom styles, meta or Webfont link), just before `</body>` or right after opening `<body>` (pixel tracking, analytics or heatmap code).
17
 
18
+ Go to **Tools** &rarr; **Head &amp; Footer Code** in WordPress Dashboard. Insert custom code to HEAD, BODY or FOOTER section (depending on what you have to do).
19
 
20
+ If your WordPress shows the latest blog posts on the homepage, you can also add specific code only for the homepage on **Tools** &rarr; **Head &amp; Footer Code** (there will be section **Head, body and footer code on Homepage in Blog Posts mode**)
21
 
22
+ To insert custom code specific for individual article (post, page or custom post type), use article-specific Metabox while editing post/page/custom post type (check out [Screenshots](https://wordpress.org/plugins/head-footer-code/#screenshots)). There choose if that specific code appends to site-wide code defined on **Tools** &rarr; **Head &amp; Footer Code**, or to replace it.
23
 
24
+ Taxonomies (category, tag and custom taxonomy listing, individual category, tags and custom taxonomies) do not have their specific code. Global code uses instead.
25
 
26
  This magic is done by hooking to WordPress hooks `wp_head`, `wp_footer` and `wp_body_open`.
27
 
28
  https://www.youtube.com/watch?v=Gd41Dv09UC4
29
 
30
+ Various code snippets are supported, including but not limited to:
31
+
32
+ * Google Analytics
33
+ * Google Tag Manager
34
+ * Google Ads Conversion
35
+ * Facebook Pixel
36
+ * Hotjar
37
+ * FullStory
38
+ * Google site verification
39
+ * Bing site verification
40
+ * Yandex site verification
41
+ * Alexa site verification
42
 
43
+ **Works or broken?**
44
 
45
+ If **Head &amp; Footer Code** does not work on your WordPress project, please let us know by [raising a new support ticket](https://wordpress.org/support/plugin/head-footer-code/#new-topic-0) in the [Community Forum](https://wordpress.org/support/plugin/head-footer-code/) and describe what does not works and how to reproduce the issue. We will make sure to resolve the issue as soon as possible.
46
 
47
+ If you find **Head &amp; Footer Code** useful for your project, please [review plugin](https://wordpress.org/support/plugin/head-footer-code/reviews/#new-post).
48
 
49
  **Features**
50
 
63
  * If you have set WP_DEBUG constant in `wp-config.php` to `true`, you'll see site-wide and article specific entries in page source code wrapped to comments.
64
  * Multisite is supported.
65
 
66
+ General settings (HEAD, BODY, FOOTER global code and priority, Homepage code and behaviour) saves in WordPress option `auhfc_settings`.
67
+ Each post/page/custom post type specific HEAD, BODY and FOOTER code and behaviour saves to post meta `_auhfc`.
68
+ This data deletes from the database on uninstall.
69
 
70
  == Installation ==
71
 
72
+ Installation of the **Head &amp; Footer Code** is easy as any other WordPress plugin.
73
 
74
  **Standard procedure**
75
 
76
+ 1. In WordPress Dashboard go to **Plugins** &rarr; **Add New**.
77
+ 1. Enter `head footer code` to the **Search plugins...** field and wait for the moment.
78
+ 1. Locate **Head &amp; Footer Code** and click the **Install Now** button.
79
+ 1. After successful installation, click the **Activate** button.
80
+ 1. Click **Settings** link for **Head &amp; Footer Code** or visit the **Tools** &rarr; **Head &amp; Footer Code**.
81
+ 1. Add the desired code to the target section.
 
82
 
83
  **FTP procedure**
84
 
85
+ 1. Click on the **Download** button to get **Head &amp; Footer Code** installation package.
86
+ 1. Unpack archive **head-footer-code.zip** on local computer.
87
+ 1. Upload the entire directory **head-footer-code** to the `/wp-content/plugins/` directory on your server.
88
+ 1. In WordPress Dashboard go to **Plugins** &rarr; **Installed Plugins** and click the link **Activate** for the **Head &amp; Footer Code** plugin.
89
+ 1. Click **Settings** link for **Head &amp; Footer Code** or visit the **Tools** &rarr; **Head &amp; Footer Code**.
90
+ 1. Add the desired code to the target section.
91
 
92
  == Frequently Asked Questions ==
93
 
94
+ = Is supported PHP code in code snippets? =
95
 
96
+ As it's a security risk, the **Head &amp; Footer Code** does not process PHP code if entered into any plugin field (global or article specific).
97
 
98
+ Any content added to HFC fields is printed on the front-end as is.
99
 
100
+ = I entered code to BODY section, but nothing outputs on front-end =
101
+
102
+ This feature is implemented since WordPress version 5.2 and requires theme compatibility.
103
+
104
+ To make sure if theme you use supports [wp_body_open](https://developer.wordpress.org/reference/hooks/wp_body_open/) hook, open in code editor `header.php` file from theme you use, and check if right after opening `<BODY>` tag there is following code (if it does not exists, add it or ask some developer to do that for you):
105
 
 
106
  ```if ( function_exists( 'wp_body_open' ) ) {
107
  wp_body_open();
108
  }```
115
  4. Example of custom code inserted to HEAD section (site-wide with appended article specific)
116
  5. Example of custom code inserted to BODY section (site-wide with appended article specific)
117
  6. Example of custom code inserted to FOOTER section (site-wide with appended article specific)
118
+ 7. Example of **Head &amp; Footer Code** column on Pages listing, to identify which pages have set custom code, which one and what mode is selected
119
 
120
  == Upgrade Notice ==
121
 
123
  Initial release of new plugin developed by Aleksandar Urosevic.
124
 
125
  == Changelog ==
126
+ = 1.2.2 (2021-04-24) =
127
+ * Tested: on WordPress 5.7.1
128
+ * (2021-02-01) Fix: Noice errors in update script (thanks to @swinggraphics)
129
+ * Improve: wording on post/page listing
130
+
131
  = 1.2.1 =
132
  * Add: Head & Footer Code column to post/page/custom post type listing to show if/what article specific custom code is defined
133
  * Fix: in_array() expects parameter 2 to be array, null given in head-footer-code/inc/front.php on line 46, 111, and 176