Version Description
- Fix: Fatal Error on Multisite WP's (thanks @kunzemarketing for reporting)
- Improve: DRI for front-end debugging
Download this release
Release Info
Developer | urkekg |
Plugin | Head & Footer Code |
Version | 1.0.9.1 |
Comparing to | |
See all releases |
Code changes from version 1.0.9 to 1.0.9.1
- head-footer-code.php +3 -2
- inc/front.php +10 -26
- inc/helpers.php +30 -3
- readme.txt +6 -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 </head> or </body>) by hooking to <code>wp_head</code> and <code>wp_footer</code>.
|
11 |
-
* Version: 1.0.9
|
12 |
* Author: Aleksandar Urosevic
|
13 |
* Author URI: https://urosevic.net
|
14 |
* License: GPL-3.0+
|
@@ -22,9 +22,10 @@ if ( ! defined( 'WPINC' ) ) {
|
|
22 |
die;
|
23 |
}
|
24 |
|
25 |
-
define( 'WPAU_HEAD_FOOTER_CODE_VER', '1.0.9' );
|
26 |
define( 'WPAU_HEAD_FOOTER_CODE_DB_VER', '2' );
|
27 |
define( 'WPAU_HEAD_FOOTER_CODE_FILE', basename( __FILE__ ) );
|
|
|
28 |
|
29 |
// Load files.
|
30 |
require_once 'inc/helpers.php';
|
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 </head> or </body>) by hooking to <code>wp_head</code> and <code>wp_footer</code>.
|
11 |
+
* Version: 1.0.9.1
|
12 |
* Author: Aleksandar Urosevic
|
13 |
* Author URI: https://urosevic.net
|
14 |
* License: GPL-3.0+
|
22 |
die;
|
23 |
}
|
24 |
|
25 |
+
define( 'WPAU_HEAD_FOOTER_CODE_VER', '1.0.9.1' );
|
26 |
define( 'WPAU_HEAD_FOOTER_CODE_DB_VER', '2' );
|
27 |
define( 'WPAU_HEAD_FOOTER_CODE_FILE', basename( __FILE__ ) );
|
28 |
+
define( 'WPAU_HEAD_FOOTER_CODE_INC', dirname( __FILE__ ) . '/inc/' );
|
29 |
|
30 |
// Load files.
|
31 |
require_once 'inc/helpers.php';
|
inc/front.php
CHANGED
@@ -38,16 +38,12 @@ function auhfc_wp_head() {
|
|
38 |
// Get meta for post only if it's singular
|
39 |
if ( 'not singular' !== $auhfc_post_type && in_array( $auhfc_post_type, $auhfc_settings['post_types'] ) ) {
|
40 |
$auhfc_meta = auhfc_get_meta( 'head' );
|
41 |
-
$behavior
|
42 |
-
|
43 |
-
$dbg_set = "(type: {$auhfc_post_type}; bahavior: {$behavior}; priority: {$auhfc_settings['priority_h']}; do_shortcode: {$auhfc_settings['do_shortcode']})";
|
44 |
-
}
|
45 |
} else {
|
46 |
$auhfc_meta = '';
|
47 |
-
$behavior
|
48 |
-
|
49 |
-
$dbg_set = "({$auhfc_post_type})";
|
50 |
-
}
|
51 |
}
|
52 |
|
53 |
// If no code to inject, simple exit
|
@@ -67,16 +63,12 @@ function auhfc_wp_head() {
|
|
67 |
( 'replace' == $behavior && in_array( $auhfc_post_type, $auhfc_settings['post_types'] ) && empty( $auhfc_meta ) )
|
68 |
)
|
69 |
) {
|
70 |
-
$out .=
|
71 |
-
$out .= $auhfc_settings['head'];
|
72 |
-
$out .= WP_DEBUG ? $out .= "<!-- Head & Footer Code: Site-wide head section end {$dbg_set} -->\n" : '';
|
73 |
}
|
74 |
|
75 |
// Inject article specific head code if post_type is allowed
|
76 |
if ( ! empty( $auhfc_meta ) && in_array( $auhfc_post_type, $auhfc_settings['post_types'] ) ) {
|
77 |
-
$out .=
|
78 |
-
$out .= $auhfc_meta;
|
79 |
-
$out .= WP_DEBUG ? "<!-- Head & Footer Code: Article specific head section end {$dbg_set} -->\n" : '';
|
80 |
}
|
81 |
|
82 |
// Print prepared code.
|
@@ -108,15 +100,11 @@ function auhfc_wp_footer() {
|
|
108 |
if ( 'not singular' !== $auhfc_post_type && in_array( $auhfc_post_type, $auhfc_settings['post_types'] ) ) {
|
109 |
$auhfc_meta = auhfc_get_meta( 'footer' );
|
110 |
$behavior = auhfc_get_meta( 'behavior' );
|
111 |
-
|
112 |
-
$dbg_set = "(type: {$auhfc_post_type}; bahavior: {$behavior}; priority: {$auhfc_settings['priority_f']}; do_shortcode: {$auhfc_settings['do_shortcode']})";
|
113 |
-
}
|
114 |
} else {
|
115 |
$auhfc_meta = '';
|
116 |
$behavior = '';
|
117 |
-
|
118 |
-
$dbg_set = "({$auhfc_post_type})";
|
119 |
-
}
|
120 |
}
|
121 |
|
122 |
// If no code to inject, simple exit
|
@@ -136,16 +124,12 @@ function auhfc_wp_footer() {
|
|
136 |
( 'replace' == $behavior && in_array( $auhfc_post_type, $auhfc_settings['post_types'] ) && empty( $auhfc_meta ) )
|
137 |
)
|
138 |
) {
|
139 |
-
$out .=
|
140 |
-
$out .= $auhfc_settings['footer'];
|
141 |
-
$out .= WP_DEBUG ? "<!-- Head & Footer Code: Site-wide footer section end {$dbg_set} -->\n" : '';
|
142 |
}
|
143 |
|
144 |
// Inject article specific head code if post_type is allowed
|
145 |
if ( ! empty( $auhfc_meta ) && in_array( $auhfc_post_type, $auhfc_settings['post_types'] ) ) {
|
146 |
-
$out .=
|
147 |
-
$out .= trim( $auhfc_meta );
|
148 |
-
$out .= WP_DEBUG ? "<!-- Head & Footer Code: Article specific footer section end {$dbg_set} -->\n" : '';
|
149 |
}
|
150 |
|
151 |
// Print prepared code.
|
38 |
// Get meta for post only if it's singular
|
39 |
if ( 'not singular' !== $auhfc_post_type && in_array( $auhfc_post_type, $auhfc_settings['post_types'] ) ) {
|
40 |
$auhfc_meta = auhfc_get_meta( 'head' );
|
41 |
+
$behavior = auhfc_get_meta( 'behavior' );
|
42 |
+
$dbg_set = "type: {$auhfc_post_type}; bahavior: {$behavior}; priority: {$auhfc_settings['priority_h']}; do_shortcode: {$auhfc_settings['do_shortcode']}";
|
|
|
|
|
43 |
} else {
|
44 |
$auhfc_meta = '';
|
45 |
+
$behavior = '';
|
46 |
+
$dbg_set = $auhfc_post_type;
|
|
|
|
|
47 |
}
|
48 |
|
49 |
// If no code to inject, simple exit
|
63 |
( 'replace' == $behavior && in_array( $auhfc_post_type, $auhfc_settings['post_types'] ) && empty( $auhfc_meta ) )
|
64 |
)
|
65 |
) {
|
66 |
+
$out .= auhfc_out( 's', 'h', $dbg_set, $auhfc_settings['head'] );
|
|
|
|
|
67 |
}
|
68 |
|
69 |
// Inject article specific head code if post_type is allowed
|
70 |
if ( ! empty( $auhfc_meta ) && in_array( $auhfc_post_type, $auhfc_settings['post_types'] ) ) {
|
71 |
+
$out .= auhfc_out( 'a', 'h', $dbg_set, $auhfc_meta );
|
|
|
|
|
72 |
}
|
73 |
|
74 |
// Print prepared code.
|
100 |
if ( 'not singular' !== $auhfc_post_type && in_array( $auhfc_post_type, $auhfc_settings['post_types'] ) ) {
|
101 |
$auhfc_meta = auhfc_get_meta( 'footer' );
|
102 |
$behavior = auhfc_get_meta( 'behavior' );
|
103 |
+
$dbg_set = "type: {$auhfc_post_type}; bahavior: {$behavior}; priority: {$auhfc_settings['priority_f']}; do_shortcode: {$auhfc_settings['do_shortcode']}";
|
|
|
|
|
104 |
} else {
|
105 |
$auhfc_meta = '';
|
106 |
$behavior = '';
|
107 |
+
$dbg_set = $auhfc_post_type;
|
|
|
|
|
108 |
}
|
109 |
|
110 |
// If no code to inject, simple exit
|
124 |
( 'replace' == $behavior && in_array( $auhfc_post_type, $auhfc_settings['post_types'] ) && empty( $auhfc_meta ) )
|
125 |
)
|
126 |
) {
|
127 |
+
$out .= auhfc_out( 's', 'f', $dbg_set, $auhfc_settings['footer'] );
|
|
|
|
|
128 |
}
|
129 |
|
130 |
// Inject article specific head code if post_type is allowed
|
131 |
if ( ! empty( $auhfc_meta ) && in_array( $auhfc_post_type, $auhfc_settings['post_types'] ) ) {
|
132 |
+
$out .= auhfc_out( 'a', 'f', $dbg_set, $auhfc_meta );
|
|
|
|
|
133 |
}
|
134 |
|
135 |
// Print prepared code.
|
inc/helpers.php
CHANGED
@@ -6,10 +6,10 @@ if ( ! defined( 'WPINC' ) ) {
|
|
6 |
|
7 |
// Include back-end/front-end resources.
|
8 |
if ( is_admin() ) {
|
9 |
-
require_once 'settings.php';
|
10 |
-
require_once 'class-auhfc-meta-box.php';
|
11 |
} else {
|
12 |
-
require_once 'front.php';
|
13 |
}
|
14 |
|
15 |
register_activation_hook( WPAU_HEAD_FOOTER_CODE_FILE, 'auhfc_activate' );
|
@@ -132,3 +132,30 @@ function auhfc_get_meta( $field_name = '' ) {
|
|
132 |
return false;
|
133 |
}
|
134 |
} // END function auhfc_get_meta( $field_name )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
// Include back-end/front-end resources.
|
8 |
if ( is_admin() ) {
|
9 |
+
require_once WPAU_HEAD_FOOTER_CODE_INC . 'settings.php';
|
10 |
+
require_once WPAU_HEAD_FOOTER_CODE_INC . 'class-auhfc-meta-box.php';
|
11 |
} else {
|
12 |
+
require_once WPAU_HEAD_FOOTER_CODE_INC . 'front.php';
|
13 |
}
|
14 |
|
15 |
register_activation_hook( WPAU_HEAD_FOOTER_CODE_FILE, 'auhfc_activate' );
|
132 |
return false;
|
133 |
}
|
134 |
} // END function auhfc_get_meta( $field_name )
|
135 |
+
|
136 |
+
/**
|
137 |
+
* Return debugging string if WP_DEBUG constant is true.
|
138 |
+
* @param string $scope Scope of output (s - SITE WIDE, a - ARTICLE SPECIFIC)
|
139 |
+
* @param string $location Location of output (h - HEAD, f - FOOTER)
|
140 |
+
* @param string $message Output message
|
141 |
+
* @param string $code Code for output
|
142 |
+
* @return string Composed string
|
143 |
+
*/
|
144 |
+
function auhfc_out( $scope = null, $location = null, $message = null, $code = null ) {
|
145 |
+
if ( ! WP_DEBUG ) {
|
146 |
+
return $code;
|
147 |
+
}
|
148 |
+
if ( null == $scope || null == $location || null == $message ) {
|
149 |
+
return;
|
150 |
+
}
|
151 |
+
$scope = 's' == $scope ? 'Site-wide' : 'Article specific';
|
152 |
+
$location = 'h' == $location ? 'HEAD' : 'FOOTER';
|
153 |
+
return sprintf(
|
154 |
+
'<!-- Head & Footer Code: %1$s %2$s section start (%3$s) -->%5$s %4$s%5$s<!-- Head & Footer Code: %1$s %2$s section end (%3$s) -->%5$s',
|
155 |
+
$scope, // 1
|
156 |
+
$location, // 2
|
157 |
+
trim( $message ), // 3
|
158 |
+
trim( $code ), // 4
|
159 |
+
"\n" // 5
|
160 |
+
);
|
161 |
+
} // END function auhfc_out( $scope = null, $location = null, $message = null, $code = null )
|
readme.txt
CHANGED
@@ -4,12 +4,12 @@ Donate link: https://urosevic.net/wordpress/donate/?donate_for=head-footer-code
|
|
4 |
Tags: wp_head, wp_footer, head footer code, custom head script, custom footer script, google analytics, pixel tracking, tracking code, javascript, scripts, site verification, css
|
5 |
Requires at least: 4.9
|
6 |
Tested up to: 5.1.1
|
7 |
-
Stable tag: 1.0.9
|
8 |
Requires PHP: 5.6
|
9 |
License: GPLv3 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
11 |
|
12 |
-
Easy add site-wide and/or article specific custom code before the </head> or </body> by hooking to wp_head and wp_footer.
|
13 |
|
14 |
== Description ==
|
15 |
|
@@ -86,6 +86,10 @@ Initial release of new plugin developed by Aleksandar Urosevic.
|
|
86 |
|
87 |
== Changelog ==
|
88 |
|
|
|
|
|
|
|
|
|
89 |
= 1.0.9 =
|
90 |
* Add: Descriptive post types and descriptions for article specific sections
|
91 |
* Add: Option to process shortcodes in FOOTER section (global setting for site-wide and article specific)
|
4 |
Tags: wp_head, wp_footer, head footer code, custom head script, custom footer script, google analytics, pixel tracking, tracking code, javascript, scripts, site verification, css
|
5 |
Requires at least: 4.9
|
6 |
Tested up to: 5.1.1
|
7 |
+
Stable tag: 1.0.9.1
|
8 |
Requires PHP: 5.6
|
9 |
License: GPLv3 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
11 |
|
12 |
+
Easy add site-wide and/or article specific custom code before the </head> or </body> by hooking to wp_head and wp_footer. Multisite is supported!
|
13 |
|
14 |
== Description ==
|
15 |
|
86 |
|
87 |
== Changelog ==
|
88 |
|
89 |
+
= 1.0.9.1 =
|
90 |
+
* Fix: Fatal Error on Multisite WP's (thanks @kunzemarketing for reporting)
|
91 |
+
* Improve: DRI for front-end debugging
|
92 |
+
|
93 |
= 1.0.9 =
|
94 |
* Add: Descriptive post types and descriptions for article specific sections
|
95 |
* Add: Option to process shortcodes in FOOTER section (global setting for site-wide and article specific)
|