Insert Headers and Footers - Version 1.1

Version Description

  • fixed unecessary CSS loading
Download this release

Release Info

Developer iamdpegg
Plugin Icon 128x128 Insert Headers and Footers
Version 1.1
Comparing to
See all releases

Version 1.1

ihaf.css ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @charset "utf-8";
2
+ /* CSS Document */
3
+
4
+ #ihaf-wrap .wrap {float: left; width: 100%;}
5
+
6
+ .ihaf-labels {display: block; margin: 0 0 10px 0;}
7
+
8
+ .footerlabel {margin-top: 25px;}
9
+
10
+ .ihaf-wrap { margin: 40px 0 0 40px; float: left; width: 70%;}
11
+
12
+ /* Sidebar */
13
+
14
+ .ihaf-sidebar {float: left; width: 20%; min-width: 200px;}
15
+
16
+ .ihaf-sidebar h2 { color: #00000; font-size: 16px;}
17
+
18
+ .ihaf-improve-site {background: #CFC; padding: 10px 15px; border: 1px solid green; }
19
+
20
+ .ihaf-improve-site a {text-decoration: none; background: #21759B; color: #EAF2FA; padding: 4px 10px; line-height: 15px; border-radius: 10px; font-weight: bold;}
21
+
22
+ .ihaf-improve-site a:hover {color: #EAF2FA;}
23
+
24
+ .ihaf-support {margin: 15px 0 0 0; border: 1px solid #CCC; padding: 10px 15px;}
25
+
26
+ .ihaf-donate {background: #CFC; padding: 10px 15px; border: 1px solid green; margin: 15px 0 0 0;}
27
+
28
+ .ihaf-donate a {display: block; text-indent: -9999px; background: url(images/donate.png) no-repeat; width: 150px; height: 50px;}
29
+
30
+ .ihaf-wpb-recent {margin: 15px 0 0 0; border: 1px solid #CCC; padding: 10px 15px;}
31
+
32
+ .ihaf-list {list-style-image: url(images/favicon.png); margin: 0 0 5px 20px;}
33
+
34
+ .ihaf-wpb-recent .facebook {list-style-image: url(images/facebook.png); margin: 0 0 5px 20px;}
35
+
36
+ .ihaf-wpb-recent .twitter {list-style-image: url(images/twitter.png); margin: 0 0 5px 20px;}
37
+
38
+ .ihaf-wpb-recent .googleplus {list-style-image: url(images/googleplus.png); margin: 0 0 5px 20px;}
39
+
40
+ .ihaf-wpb-recent .email {list-style-image: url(images/email.png); margin: 0 0 5px 20px;}
ihaf.php ADDED
@@ -0,0 +1,209 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Insert Headers and Footers
4
+ Plugin URI:
5
+ Description: Allows you to insert code or text in the header or footer of your WordPress blog
6
+ Version: 1.1
7
+ Author: iamdpegg
8
+ Author URI:
9
+ License: This software is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
+ */
13
+
14
+
15
+ if ( !class_exists( 'InsertHeadersAndFooters' ) ) {
16
+
17
+ define('IHAFURL', plugins_url('', __FILE__));
18
+ wp_register_style('IHAFStyleSheet', IHAFURL . '/ihaf.css');
19
+ wp_enqueue_style( 'IHAFStyleSheet');
20
+
21
+ class InsertHeadersAndFooters {
22
+
23
+ function InsertHeadersAndFooters() {
24
+
25
+ add_action( 'init', array( &$this, 'init' ) );
26
+ add_action( 'admin_init', array( &$this, 'admin_init' ) );
27
+ add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
28
+ add_action( 'wp_head', array( &$this, 'wp_head' ) );
29
+ add_action( 'wp_footer', array( &$this, 'wp_footer' ) );
30
+
31
+ }
32
+
33
+ function init() {
34
+ load_plugin_textdomain( 'insert-headers-and-footers', false, dirname( plugin_basename ( __FILE__ ) ).'/lang' );
35
+ }
36
+
37
+ function admin_init() {
38
+ register_setting( 'insert-headers-and-footers', 'ihaf_insert_header', 'trim' );
39
+ register_setting( 'insert-headers-and-footers', 'ihaf_insert_footer', 'trim' );
40
+ }
41
+
42
+ function admin_menu() {
43
+ add_submenu_page( 'options-general.php', 'Insert Headers and Footers',
44
+ 'Insert Headers and Footers', 'manage_options', __FILE__, array( &$this, 'options_panel' ) );
45
+ }
46
+
47
+ function wp_head() {
48
+ $meta = get_option( 'ihaf_insert_header', '' );
49
+ if ( $meta != '' ) {
50
+ echo $meta, "\n";
51
+ }
52
+ }
53
+
54
+ function wp_footer() {
55
+ if ( !is_admin() && !is_feed() && !is_robots() && !is_trackback() ) {
56
+ $text = get_option( 'ihaf_insert_footer', '' );
57
+
58
+ $text = convert_smilies( $text );
59
+ $text = do_shortcode( $text );
60
+
61
+ if ( $text != '' ) {
62
+ echo $text, "\n";
63
+ }
64
+ }
65
+ }
66
+
67
+ function fetch_rss_items( $num, $feed ) {
68
+ include_once( ABSPATH . WPINC . '/feed.php' );
69
+ $rss = fetch_feed( $feed );
70
+
71
+ // Bail if feed doesn't work
72
+ if ( !$rss || is_wp_error( $rss ) )
73
+ return false;
74
+
75
+ $rss_items = $rss->get_items( 0, $rss->get_item_quantity( $num ) );
76
+
77
+ // If the feed was erroneous
78
+ if ( !$rss_items ) {
79
+ $md5 = md5( $feed );
80
+ delete_transient( 'feed_' . $md5 );
81
+ delete_transient( 'feed_mod_' . $md5 );
82
+ $rss = fetch_feed( $feed );
83
+ $rss_items = $rss->get_items( 0, $rss->get_item_quantity( $num ) );
84
+ }
85
+
86
+ return $rss_items;
87
+ }
88
+
89
+
90
+ function options_panel() {
91
+ ?>
92
+ <div id="ihaf-wrap">
93
+ <div class="wrap">
94
+ <?php screen_icon(); ?>
95
+ <h2>Insert Headers and Footers - Options</h2>
96
+ <div class="ihaf-wrap">
97
+ <form name="dofollow" action="options.php" method="post">
98
+ <?php settings_fields( 'insert-headers-and-footers' ); ?>
99
+
100
+ <label class="ihaf-labels" for="ihaf_insert_header">Scripts in header:</label>
101
+
102
+ <textarea rows="5" cols="57" id="insert_header" name="ihaf_insert_header"><?php echo esc_html( get_option( 'ihaf_insert_header' ) ); ?></textarea><br />
103
+ These scripts will be printed to the <code>&lt;head&gt;</code> section.
104
+
105
+ <label class="ihaf-labels footerlabel" for="ihaf_insert_footer">Scripts in footer:</label>
106
+
107
+ <textarea rows="5" cols="57" id="ihaf_insert_footer" name="ihaf_insert_footer"><?php echo esc_html( get_option( 'ihaf_insert_footer' ) ); ?></textarea><br />
108
+ These scripts will be printed to the <code>&lt;footer&gt;</code> section.
109
+
110
+ <p class="submit">
111
+ <input type="submit" name="Submit" value="Save settings" />
112
+ </p>
113
+
114
+ </form>
115
+ </div>
116
+
117
+ <div class="ihaf-sidebar">
118
+ <div class="ihaf-improve-site">
119
+ <h2>Improve Your Site!</h2>
120
+ <p>Want to take your site to the next level? Look behind the scenes of WPBeginner to see what you can do!</p>
121
+ <p><a href="http://www.wpbeginner.com/blueprint/" target="_blank">WPBeginner's Blueprint &raquo;</a></p>
122
+ </div>
123
+ <div class="ihaf-support">
124
+ <h2>Need Support?</h2>
125
+ <p>If you are having problems with this plugin, please talk about them in the</p>
126
+ <p><a href="http://www.wpbeginner.com/contact/" target="_blank">Support Forums</a></p>
127
+ </div>
128
+ <div class="ihaf-donate">
129
+ <h2>Spread the Word!</h2>
130
+ <p>Want to help make this plugin even better? All donations are used to improve this plugin, so donate $10, $20 or $50 now!</p>
131
+ <p><a href="http://www.wpbeginner.com/wpbeginner-needs-your-help/" target="_blank">Donate!</a></p>
132
+ </div>
133
+ <div class="ihaf-wpb-recent">
134
+ <h2>Latest News From WPBeginner</h2>
135
+ <?php
136
+ $rss_items = $this->fetch_rss_items( 3, 'http://wpbeginner.com/feed/' );
137
+
138
+ $content = '<ul>';
139
+ if ( !$rss_items ) {
140
+ $content .= '<li class="ihaf-list">No news items, feed might be broken...</li>';
141
+ } else {
142
+ foreach ( $rss_items as $item ) {
143
+ $url = preg_replace( '/#.*/', '', esc_url( $item->get_permalink(), null, 'display' ) );
144
+ $content .= '<li class="ihaf-list">';
145
+ $content .= '<a href="' . $url . '#utm_source=wpadmin&utm_medium=sidebarwidget&utm_term=newsitem&utm_campaign=ihaf">' . esc_html( $item->get_title() ) . '</a> ';
146
+ $content .= '</li>';
147
+ }
148
+ }
149
+ $content .= '<li class="facebook"><a href="https://www.facebook.com/wpbeginner" target="_blank">Like WPBeginner on Facebook</a></li>';
150
+ $content .= '<li class="twitter"><a href="http://twitter.com/wpbeginner"target="_blank">Follow WPBeginner on Twitter</a></li>';
151
+ $content .= '<li class="googleplus"><a href="https://plus.google.com/101634180904808003404/posts" target="_blank">Circle WPBeginner on Google+</a></li>';
152
+ $content .= '<li class="email"><a href="http://wpbeginner.us1.list-manage.com/subscribe?u=549b83cc29ff23c36e5796c38&id=4c340fd3aa" target="_blank">Subscribe by email</a></li>';
153
+ $content .= '</ul>';
154
+ echo $content;
155
+ ?>
156
+ </div>
157
+ </div>
158
+
159
+ </div>
160
+ </div>
161
+ <?php
162
+ }
163
+ }
164
+
165
+
166
+ add_action('wp_dashboard_setup', 'ihaf_dashboard_widgets');
167
+
168
+ function ihaf_dashboard_widgets() {
169
+ global $wp_meta_boxes;
170
+
171
+ wp_add_dashboard_widget('wpbeginnerihafwidget', 'Latest from WPBeginner', 'ihaf_widget');
172
+ }
173
+
174
+ function ihaf_widget() {
175
+ require_once(ABSPATH.WPINC.'/rss.php');
176
+ if ( $rss = fetch_rss( 'http://wpbeginner.com/feed/' ) ) { ?>
177
+ <div class="rss-widget">
178
+
179
+ <a href="http://www.wpbeginner.com/" title="WPBeginner - Beginner's guide to WordPress"><img src="http://cdn.wpbeginner.com/pluginimages/wpbeginner.gif" class="alignright" alt="WPBeginner"/></a>
180
+ <ul>
181
+ <?php
182
+ $rss->items = array_slice( $rss->items, 0, 5 );
183
+ foreach ( (array) $rss->items as $item ) {
184
+ echo '<li>';
185
+ echo '<a class="rsswidget" href="'.clean_url( $item['link'], $protocolls=null, 'display' ).'">'. ($item['title']) .'</a> ';
186
+ echo '<span class="rss-date">'. date('F j, Y', strtotime($item['pubdate'])) .'</span>';
187
+
188
+ echo '</li>';
189
+ }
190
+ ?>
191
+ </ul>
192
+ <div style="border-top: 1px solid #ddd; padding-top: 10px; text-align:center;">
193
+ <a href="http://feeds2.feedburner.com/wpbeginner"><img src="http://cdn.wpbeginner.com/pluginimages/feed.png" alt="Subscribe to our Blog" style="margin: 0 5px 0 0; vertical-align: top; line-height: 18px;"/> Subscribe with RSS</a>
194
+ &nbsp; &nbsp; &nbsp;
195
+ <a href="http://wpbeginner.us1.list-manage.com/subscribe?u=549b83cc29ff23c36e5796c38&id=4c340fd3aa"><img src="http://cdn.wpbeginner.com/pluginimages/email.gif" alt="Subscribe via Email"/> Subscribe by email</a>
196
+ &nbsp; &nbsp; &nbsp;
197
+ <a href="http://facebook.com/wpbeginner/"><img src="http://cdn.wpbeginner.com/pluginimages/facebook.png" alt="Join us on Facebook" style="margin: 0 5px 0 0; vertical-align: middle; line-height: 18px;" />Join us on Facebook</a>
198
+ </div>
199
+ </div>
200
+ <?php }
201
+ }
202
+
203
+
204
+
205
+ $wp_insert_headers_and_footers = new InsertHeadersAndFooters();
206
+
207
+ }
208
+
209
+
images/donate.png ADDED
Binary file
images/email.png ADDED
Binary file
images/facebook.png ADDED
Binary file
images/favicon.png ADDED
Binary file
images/googleplus.png ADDED
Binary file
images/twitter.png ADDED
Binary file
readme.txt ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Plugin Name ===
2
+ Contributors: iamdpegg, smub
3
+ Tags: header, footer, headers, footers, content, wpmu, meta, meta tags
4
+ Requires at least: 2.7
5
+ Tested up to: 3.4.1
6
+ Stable tag: 1.1
7
+ License: GPLv2 or later
8
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
+
10
+
11
+ This plugin allows you to add extra scripts to the header and footer of your blog by hooking into wp_head and wp_footer.
12
+
13
+ == Description ==
14
+
15
+ Insert Headers and Footers is a simple plugin that lets you add scripts like Google Analytics to your WordPress site without having to get your hands dirty in code. Moreover, the simple interface gives you one place where you can add all of you scripts rather than dealing with dozens of plugins.
16
+
17
+
18
+ [Visit WPBeginner for any tutorials or support](http://www.wpbeginner.com "Visit WPBeginner for any tutorials or support")
19
+
20
+ [Take a look behind the scenes of WPBeginner](http://www.wpbeginner.com/blueprint/ "Checkout out WPBeginner's WordPress tutorial videos")
21
+
22
+ [Learn WordPress with free WPBeginner videos](http://videos.wpbeginner.com "Checkout out WPBeginner's WordPress tutorial videos")
23
+
24
+
25
+
26
+
27
+ == Installation ==
28
+
29
+ 1. Upload `insert-headers-and-footers` directory to the `/wp-content/plugins/` directory
30
+ 1. Activate the plugin through the 'Plugins' menu in WordPress
31
+ 1. Configure plugin (go to the Settings/Insert Headers and Footers)
32
+ 1. Enjoy :)
33
+
34
+
35
+
36
+ == Changelog ==
37
+
38
+ = 1.0 =
39
+ * Initial version
40
+
41
+ = 1.1 =
42
+ * fixed unecessary CSS loading