Version Description
- Enhance: Add uninstall routine to make some housekeeping on plugin removal.
- Enhance: Add post type in debug comments.
- Readme: Test on WordPress v4.4-beta1 and updated compatibility.
Download this release
Release Info
Developer | urkekg |
Plugin | Head & Footer Code |
Version | 1.0.5 |
Comparing to | |
See all releases |
Code changes from version 1.0.4 to 1.0.5
- head-footer-code.php +1 -1
- inc/front.php +8 -8
- readme.txt +11 -2
- uninstall.php +21 -0
head-footer-code.php
CHANGED
@@ -8,7 +8,7 @@
|
|
8 |
* Plugin Name: Head & Footer Code
|
9 |
* Plugin URI: http://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.
|
12 |
* Author: Aleksandar Urosevic
|
13 |
* Author URI: http://urosevic.net
|
14 |
* License: GPL-2.0+
|
8 |
* Plugin Name: Head & Footer Code
|
9 |
* Plugin URI: http://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.5
|
12 |
* Author: Aleksandar Urosevic
|
13 |
* Author URI: http://urosevic.net
|
14 |
* License: GPL-2.0+
|
inc/front.php
CHANGED
@@ -38,16 +38,16 @@ function auhfc_wp_head() {
|
|
38 |
( 'replace' == $behavior && in_array( $post->post_type, $auhfc_settings['post_types'] ) && empty( $auhfc_meta ) )
|
39 |
)
|
40 |
) {
|
41 |
-
if ( WP_DEBUG ) { $out .= "<!-- Head & Footer Code: Site-wide head section start -->\n"; }
|
42 |
$out .= $auhfc_settings['head'];
|
43 |
-
if ( WP_DEBUG ) { $out .= "<!-- Head & Footer Code: Site-wide head section end -->\n"; }
|
44 |
}
|
45 |
|
46 |
// Inject article specific head code if post_type is allowed
|
47 |
if ( ! empty( $auhfc_meta ) && in_array( $post->post_type, $auhfc_settings['post_types'] ) ) {
|
48 |
-
if ( WP_DEBUG ) { $out .= "<!-- Head & Footer Code: Article specific head section start -->\n"; }
|
49 |
$out .= $auhfc_meta;
|
50 |
-
if ( WP_DEBUG ) { $out .= "<!-- Head & Footer Code: Article specific head section end -->\n"; }
|
51 |
}
|
52 |
|
53 |
// Print prepared code.
|
@@ -87,16 +87,16 @@ function auhfc_wp_footer() {
|
|
87 |
( 'replace' == $behavior && in_array( $post->post_type, $auhfc_settings['post_types'] ) && empty( $auhfc_meta ) )
|
88 |
)
|
89 |
) {
|
90 |
-
if ( WP_DEBUG ) { $out .= "<!-- Head & Footer Code: Site-wide footer section start -->\n"; }
|
91 |
$out .= $auhfc_settings['footer'];
|
92 |
-
if ( WP_DEBUG ) { $out .= "<!-- Head & Footer Code: Site-wide footer section end -->\n"; }
|
93 |
}
|
94 |
|
95 |
// Inject article specific head code if post_type is allowed
|
96 |
if ( ! empty( $auhfc_meta ) && in_array( $post->post_type, $auhfc_settings['post_types'] ) ) {
|
97 |
-
if ( WP_DEBUG ) { $out .= "<!-- Head & Footer Code: Article specific footer section start -->\n"; }
|
98 |
$out .= trim( $auhfc_meta );
|
99 |
-
if ( WP_DEBUG ) { $out .= "<!-- Head & Footer Code: Article specific footer section end -->\n"; }
|
100 |
}
|
101 |
|
102 |
// Print prepared code.
|
38 |
( 'replace' == $behavior && in_array( $post->post_type, $auhfc_settings['post_types'] ) && empty( $auhfc_meta ) )
|
39 |
)
|
40 |
) {
|
41 |
+
if ( WP_DEBUG ) { $out .= "<!-- Head & Footer Code: Site-wide head section start ({$post->post_type}) -->\n"; }
|
42 |
$out .= $auhfc_settings['head'];
|
43 |
+
if ( WP_DEBUG ) { $out .= "<!-- Head & Footer Code: Site-wide head section end ({$post->post_type}) -->\n"; }
|
44 |
}
|
45 |
|
46 |
// Inject article specific head code if post_type is allowed
|
47 |
if ( ! empty( $auhfc_meta ) && in_array( $post->post_type, $auhfc_settings['post_types'] ) ) {
|
48 |
+
if ( WP_DEBUG ) { $out .= "<!-- Head & Footer Code: Article specific head section start ({$post->post_type}) -->\n"; }
|
49 |
$out .= $auhfc_meta;
|
50 |
+
if ( WP_DEBUG ) { $out .= "<!-- Head & Footer Code: Article specific head section end ({$post->post_type}) -->\n"; }
|
51 |
}
|
52 |
|
53 |
// Print prepared code.
|
87 |
( 'replace' == $behavior && in_array( $post->post_type, $auhfc_settings['post_types'] ) && empty( $auhfc_meta ) )
|
88 |
)
|
89 |
) {
|
90 |
+
if ( WP_DEBUG ) { $out .= "<!-- Head & Footer Code: Site-wide footer section start ({$post->post_type}) -->\n"; }
|
91 |
$out .= $auhfc_settings['footer'];
|
92 |
+
if ( WP_DEBUG ) { $out .= "<!-- Head & Footer Code: Site-wide footer section end ({$post->post_type}) -->\n"; }
|
93 |
}
|
94 |
|
95 |
// Inject article specific head code if post_type is allowed
|
96 |
if ( ! empty( $auhfc_meta ) && in_array( $post->post_type, $auhfc_settings['post_types'] ) ) {
|
97 |
+
if ( WP_DEBUG ) { $out .= "<!-- Head & Footer Code: Article specific footer section start ({$post->post_type}) -->\n"; }
|
98 |
$out .= trim( $auhfc_meta );
|
99 |
+
if ( WP_DEBUG ) { $out .= "<!-- Head & Footer Code: Article specific footer section end ({$post->post_type}) -->\n"; }
|
100 |
}
|
101 |
|
102 |
// Print prepared code.
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: urkekg
|
|
3 |
Donate link: http://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: 3.9
|
6 |
-
Tested up to: 4.
|
7 |
-
Stable tag: 1.0.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -38,6 +38,10 @@ It is very hard to continue development and support for this and my other free p
|
|
38 |
* Site-wide section located under **Tools** > **Head & Footer Code**
|
39 |
* If you have enabled WP_DEBUG constant in `wp-config.php`, you'll see site-wide and article specific entries in page source code wrapped to comments.
|
40 |
|
|
|
|
|
|
|
|
|
41 |
== Installation ==
|
42 |
|
43 |
Installation of this plugin is fairly easy as any other WordPress plugin.
|
@@ -81,6 +85,11 @@ Initial release of new plugin developed by Aleksandar Urosevic.
|
|
81 |
|
82 |
== Changelog ==
|
83 |
|
|
|
|
|
|
|
|
|
|
|
84 |
= 1.0.4 =
|
85 |
* Fix: PHP Warning: in_array() expects parameter 2 to be array, string given (introduced in v1.0.3)
|
86 |
|
3 |
Donate link: http://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: 3.9
|
6 |
+
Tested up to: 4.4
|
7 |
+
Stable tag: 1.0.5
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
38 |
* Site-wide section located under **Tools** > **Head & Footer Code**
|
39 |
* If you have enabled WP_DEBUG constant in `wp-config.php`, you'll see site-wide and article specific entries in page source code wrapped to comments.
|
40 |
|
41 |
+
General settings, including HEAD, FOOTER global code and priority, have been saved to WordPress option `auhfc_settings`.
|
42 |
+
Each post/page/custom post type specific HEAD and FOOTER code have been saved to post meta `_auhfc`.
|
43 |
+
On plugin uninstall these data is also deleted from database.
|
44 |
+
|
45 |
== Installation ==
|
46 |
|
47 |
Installation of this plugin is fairly easy as any other WordPress plugin.
|
85 |
|
86 |
== Changelog ==
|
87 |
|
88 |
+
= 1.0.5 =
|
89 |
+
* Enhance: Add uninstall routine to make some housekeeping on plugin removal.
|
90 |
+
* Enhance: Add post type in debug comments.
|
91 |
+
* Readme: Test on WordPress v4.4-beta1 and updated compatibility.
|
92 |
+
|
93 |
= 1.0.4 =
|
94 |
* Fix: PHP Warning: in_array() expects parameter 2 to be array, string given (introduced in v1.0.3)
|
95 |
|
uninstall.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @link http://urosevic.net
|
4 |
+
* @since 1.0.5
|
5 |
+
* @package Head_Footer_Code
|
6 |
+
*/
|
7 |
+
|
8 |
+
// If uninstall is not called from WordPress, exit
|
9 |
+
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
10 |
+
exit();
|
11 |
+
}
|
12 |
+
|
13 |
+
$option_name = 'auhfc_settings';
|
14 |
+
delete_option( $option_name );
|
15 |
+
|
16 |
+
// For site options in Multisite
|
17 |
+
delete_site_option( $option_name );
|
18 |
+
|
19 |
+
// Delete post meta values
|
20 |
+
$post_meta_key = '_auhfc';
|
21 |
+
delete_post_meta_by_key( $post_meta_key );
|