AddFunc Head & Footer Code - Version 1.2

Version Description

19-Jun-2015

  • Discovered addfunc-head-footer-code.php was saved with text encoding Western (Mac OS Roman). ~>:( Changed to Unicode (UTF-8)
  • 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
  • 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
Download this release

Release Info

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

Version 1.2

Files changed (4) hide show
  1. addfunc-head-footer-code.php +135 -0
  2. index.php +2 -0
  3. options.php +26 -0
  4. readme.txt +118 -0
addfunc-head-footer-code.php ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
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 code and any other general or page-specific JavaScript.
6
+ Version: 1.2
7
+ Author: AddFunc
8
+ Author URI: http://profiles.wordpress.org/addfunc
9
+ License: Public Domain
10
+ @since 3.0.1
11
+ ______
12
+ _ | ___/ _ _ __ ____
13
+ _| |_| |__| | | | '_ \ / __/™
14
+ |_ Add| _/| |_| | | | | (__
15
+ |_| |_| \__,_|_| |_|\___\
16
+ by Joe Rhoney
17
+ */
18
+
19
+
20
+
21
+ /*
22
+ S E T T I N G S P A G E
23
+ =========================
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
+ {
34
+ return ABSPATH.'wp-content/plugins/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__)).$file;
35
+ }
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
+ {
43
+ add_options_page(AFHDFTRCD_NICK.' Plugin Options', AFHDFTRCD_NICK, 'manage_options', AFHDFTRCD_ID.'_options', array('aFhfc_class', 'options_page'));
44
+ }
45
+ public static function options_page()
46
+ {
47
+ if (!current_user_can('manage_options'))
48
+ {
49
+ wp_die(__('You do not have sufficient permissions to access this page.'));
50
+ }
51
+ $plugin_id = AFHDFTRCD_ID;
52
+ include(self::file_path('options.php'));
53
+ }
54
+ public static function output_head_code($head)
55
+ {
56
+ $code = get_option('aFhfc_site_wide_head_code');
57
+ echo $head . $code;
58
+ }
59
+ public static function output_footer_code($footer)
60
+ {
61
+ $code = get_option('aFhfc_site_wide_footer_code');
62
+ echo $footer . $code;
63
+ }
64
+ }
65
+ if (is_admin())
66
+ {
67
+ add_action('admin_init', array('aFhfc_class', 'register'));
68
+ add_action('admin_menu', array('aFhfc_class', 'menu'));
69
+ }
70
+ add_action('wp_head', array('aFhfc_class', 'output_head_code'));
71
+ add_action('wp_footer', array('aFhfc_class', 'output_footer_code'));
72
+ endif;
73
+
74
+
75
+
76
+ /*
77
+ M E T A B O X F O R P O S T S
78
+ =================================
79
+ Metabox w/head & footer fields for all post types (including custom)
80
+ */
81
+
82
+ add_action( 'add_meta_boxes', 'aFhfc_add' );
83
+ function aFhfc_add()
84
+ {
85
+ if (current_user_can( 'manage_options' )) {
86
+ add_meta_box( 'aFhfcMetaBox', 'Head & Footer Code', 'aFhfc_mtbx', '', 'normal', 'high' );
87
+ }
88
+ }
89
+ function aFhfc_mtbx( $post )
90
+ {
91
+ $values = get_post_custom( $post->ID );
92
+ $head_text = isset( $values['aFhfc_head_code'] ) ? esc_attr( $values['aFhfc_head_code'][0] ) : '';
93
+ $footer_text = isset( $values['aFhfc_footer_code'] ) ? esc_attr( $values['aFhfc_footer_code'][0] ) : '';
94
+ wp_nonce_field( 'aFhfc_nonce', 'aFhfc_mb_nonce' );
95
+ ?>
96
+ <p>
97
+ <label for="aFhfc_head_code">Head:</label>
98
+ <textarea class="large-text" name="aFhfc_head_code" id="aFhfc_head_code"><?php echo $head_text; ?></textarea>
99
+ </p>
100
+ <p>
101
+ <label for="aFhfc_footer_code">Footer:</label>
102
+ <textarea class="large-text" name="aFhfc_footer_code" id="aFhfc_footer_code"><?php echo $footer_text; ?></textarea>
103
+ </p>
104
+ <?php
105
+ }
106
+ add_action( 'save_post', 'aFhfc_save' );
107
+ function aFhfc_save( $post_id )
108
+ {
109
+ if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
110
+ if( !isset( $_POST['aFhfc_mb_nonce'] ) || !wp_verify_nonce( $_POST['aFhfc_mb_nonce'], 'aFhfc_nonce' ) ) return;
111
+ if( !current_user_can( 'manage_options' ) ) return;
112
+ if( isset( $_POST['aFhfc_head_code'] ) )
113
+ update_post_meta( $post_id, 'aFhfc_head_code', $_POST['aFhfc_head_code'] );
114
+ if( isset( $_POST['aFhfc_footer_code'] ) )
115
+ update_post_meta( $post_id, 'aFhfc_footer_code', $_POST['aFhfc_footer_code'] );
116
+ }
117
+
118
+
119
+
120
+ /*
121
+ F R O N T E N D O U T P U T
122
+ ===============================
123
+ Outputs the head and footer code for individual posts
124
+ */
125
+
126
+ function aFhfc_head_output( $post ) {
127
+ $aFhfc_head_code = get_post_meta( get_the_ID(), 'aFhfc_head_code', true );
128
+ echo $aFhfc_head_code."\n";
129
+ }
130
+ add_action('wp_head', 'aFhfc_head_output');
131
+ function aFhfc_footer_output( $post ) {
132
+ $aFhfc_footer_code = get_post_meta( get_the_ID(), 'aFhfc_footer_code', true );
133
+ echo $aFhfc_footer_code."\n";
134
+ }
135
+ add_action('wp_footer', 'aFhfc_footer_output');
index.php ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ # Silence is golden.
options.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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">
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
+ </div> <!-- #postbox-container-1 .postbox-container -->
23
+ </div> <!-- #post-body .metabox-holder .columns-2 -->
24
+ <br class="clear">
25
+ </div> <!-- #poststuff -->
26
+ </div>
readme.txt ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ === AddFunc Head & Footer Code ===
3
+
4
+ Contributors: AddFunc,average.technology,joerhoney
5
+ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=7AF7P3TFKQ2C2
6
+ Tags: head code, footer code, head, footer, head footer code, add to head, add to footer, per page, header footer code, header footer, header code, header, custom head, custom footer, custom header, script, code script, head script, footer script, head footer script, header footer script, header script, custom head script, custom footer script, custom header script, head javascript, footer javascript, header javascript, javascript code, tracking code, tracking script, tracking javascript, Google Analytics code, Google Analytics, Google Analytics head code, Google Analytics footer code, Google Analytics tracking code, Google Analytics conversion code, Google Analytics remarketing code, Google Analytics script, Google Analytics, Google Analytics head script, Google Analytics footer script, Google Analytics tracking script, Google Analytics conversion script, Google Analytics remarketing script, Google Analytics javascript
7
+ Requires at least: 3.0.1
8
+ Tested up to: 4.2
9
+ Stable tag: 1.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 and/or footer, site-wide and/or on any individual page/post.
14
+
15
+ == Description ==
16
+
17
+ 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 code and any other general or page-specific JavaScript.
18
+
19
+ **Custom support tickets are available**
20
+
21
+ See [Other Notes][1] tab for details.
22
+
23
+ [1]: http://wordpress.org/plugins/addfunc-head-footer-code/other_notes/
24
+
25
+ == Installation ==
26
+
27
+ 1. Upload the entire `/addfunc-head-footer-code` folder to the `/wp-content/plugins/` directory
28
+ 2. Activate the plugin through the *Plugins* menu in WordPress
29
+ 3. Add code site-wide in *Settings>Head & Footer Code* or on individual pages/posts using the Head & Footer Code meta box when in edit mode in a page (or any post type)
30
+
31
+ == Frequently Asked Questions ==
32
+
33
+ = Where does the head code output? =
34
+
35
+ Wherever `wp_head()` is located in your theme.
36
+
37
+ = Where does the footer code output? =
38
+
39
+ Wherever `wp_footer()` is located in your theme.
40
+
41
+ = Does it really require WordPress 3.0.1 or later? =
42
+
43
+ I have not tested it on earlier versions. In fact, I could use help with testing. Feel free to try it out in an earlier version and let me know if it works! :)
44
+
45
+ = Does AddFunc have a website? =
46
+
47
+ The cobbler has no shoes. ...we're working on it.
48
+
49
+ == Screenshots ==
50
+
51
+ 1. Simply paste your code into one of these two fields and it will be included on every page of your website.
52
+
53
+ 2. Add your code to these fields respectively and it will output specifically to this page, post or custom post type.
54
+
55
+ == Changelog ==
56
+
57
+ = 1.2 =
58
+ 19-Jun-2015
59
+
60
+ * Discovered addfunc-head-footer-code.php was saved with text encoding Western (Mac OS Roman). ~>:( Changed to Unicode (UTF-8)
61
+ * 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
62
+ * 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
63
+
64
+ = 1.1 =
65
+ 28-Nov-2014
66
+
67
+ * Fixes meta box nounce
68
+ * Changes all references to Average (including but not limited to "avrg", "average", etc.) to relate to AddFunc (changing project name)
69
+ * Changes a few other function and variable names for namespacing purposes
70
+ * Submitted to WordPress under the name AddFunc
71
+
72
+ = 1.0 =
73
+ 7-Aug-2014
74
+
75
+ * Includes readme.txt
76
+ * Submitted to WordPress
77
+
78
+ = 0.4.1 =
79
+ 6-Aug-2014
80
+
81
+ * Code cleaned up (mostly comments removed)
82
+ * Excludes unnecessary file: style.css
83
+
84
+ = 0.4 =
85
+ 8-Jul-2014
86
+
87
+ * Bug fix: replaced "my-meta-box-id" with "avrghdftrcdMetaBox" (duh)
88
+
89
+ = 0.3 =
90
+ 27-Oct-2013
91
+
92
+ * Hid Head & Footer Code meta box from non-admin users
93
+
94
+ = 0.2 =
95
+ 15-Oct-2013
96
+
97
+ * Adds a Head & Footer Code settings page for site-wide code (for admins only)
98
+
99
+ = 0.1 =
100
+ 14-Aug-2013
101
+
102
+ * Adds Head & Footer Code meta box to all pages, posts and cusom post types
103
+ * Saves Head & Footer Code entry to the database as custom fields
104
+ * Outputs code to the website in `wp_head()` and `wp_footer()`
105
+
106
+ == Custom Support ==
107
+
108
+ If you have a custom support need, [please purchase your support ticket here](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=7AF7P3TFKQ2C2). Support tickets are responded to within 24 hours, but we answer them as soon as possible.
109
+
110
+ **How it works**
111
+
112
+ 1. [Purchase a support ticket via PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=7AF7P3TFKQ2C2)
113
+ 2. You get a chance to provide the best way to contact you and a description of your need
114
+ 3. I contact you as soon as I can (no less than 24 hours) and help resolve your issue
115
+
116
+ **Note:** This is for custom needs for help, not problems with the plugin, or instructions that should already be explain in the description. If you feel there are important details omitted from the description, installation steps, etc. of the plugin, please report them in the Support forum. Thanks!
117
+
118
+ == Upgrade Notice ==