Insert Headers and Footers - Version 1.4

Version Description

  • Tested with WordPress 4.7.2
  • cleaned up code
Download this release

Release Info

Developer deb255
Plugin Icon 128x128 Insert Headers and Footers
Version 1.4
Comparing to
See all releases

Code changes from version 1.3.3 to 1.4

_modules/dashboard/css/admin.css DELETED
@@ -1,4 +0,0 @@
1
- #wpbeginner a { text-decoration: none; }
2
- #wpbeginner a.rss { background: url(http://cdn.wpbeginner.com/pluginimages/feed.png) 0 50% no-repeat; padding: 0 15px 0 20px; }
3
- #wpbeginner a.email { background: url(http://cdn.wpbeginner.com/pluginimages/email.gif) 0 50% no-repeat; padding: 0 15px 0 20px; }
4
- #wpbeginner a.facebook { background: url(http://cdn.wpbeginner.com/pluginimages/facebook.png) 0 50% no-repeat; padding: 0 0 0 20px; }
 
 
 
 
_modules/dashboard/dashboard.php DELETED
@@ -1,61 +0,0 @@
1
- <?php
2
- /**
3
- * Dashboard Widget
4
- */
5
- class WPBeginnerDashboardWidget {
6
- /**
7
- * Constructor
8
- *
9
- * @param object $plugin Plugin Object (name, displayName, version, folder, url)
10
- */
11
- function __construct($plugin) {
12
- // Plugin Details
13
- $this->dashboard = $plugin;
14
- $this->dashboardURL = WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__));
15
-
16
- // Hooks
17
- add_action('admin_enqueue_scripts', array(&$this, 'adminScriptsAndCSS'));
18
- add_action('wp_dashboard_setup', array(&$this, 'dashboardWidget'));
19
- add_action('wp_network_dashboard_setup', array(&$this, 'dashboardWidget'));
20
- }
21
-
22
- /**
23
- * Register and enqueue dashboard CSS
24
- */
25
- function adminScriptsAndCSS() {
26
- // CSS
27
- // This will only enqueue once, despite this hook being called by up to several plugins,
28
- // as we have set a single, distinct name
29
- wp_enqueue_style('wpbeginner', $this->dashboardURL.'css/admin.css');
30
- }
31
-
32
- /**
33
- * Adds a dashboard widget to output WPBeginner RSS
34
- *
35
- * Checks if another WPBeginner plugin has already created this widget - if so, doesn't duplicate it
36
- */
37
- function dashboardWidget() {
38
- global $wp_meta_boxes;
39
-
40
- if (isset($wp_meta_boxes['dashboard']['normal']['core']['wpbeginner'])) return; // Another plugin has already registered this widget
41
- wp_add_dashboard_widget('wpbeginner', __('Latest from WPBeginner', $this->dashboard->name), array(&$this, 'outputDashboardWidget'));
42
- }
43
-
44
- /**
45
- * Called by dashboardWidget(), includes dashboard.php to output the Dashboard Widget
46
- */
47
- function outputDashboardWidget() {
48
- $result = wp_remote_get('http://wpbeginner.com/feed/');
49
- if (!is_wp_error($result)) {
50
- if ($result['response']['code'] == 200) {
51
- $xml = simplexml_load_string($result['body']);
52
- $rssPosts = $xml->channel;
53
- }
54
-
55
- include_once(WP_PLUGIN_DIR.'/'.$this->dashboard->name.'/_modules/dashboard/views/dashboard.php');
56
- } else {
57
- include_once(WP_PLUGIN_DIR.'/'.$this->dashboard->name.'/_modules/dashboard/views/dashboard-nodata.php');
58
- }
59
- }
60
- }
61
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
_modules/dashboard/views/dashboard-nodata.php DELETED
@@ -1,8 +0,0 @@
1
- <?php
2
- /**
3
- * Dashboard Widget (no RSS data available)
4
- */
5
- ?>
6
- <div class="rss-widget">
7
- <img src="http://cdn.wpbeginner.com/pluginimages/wpbeginner.gif" class="alignright" />
8
- </div>
 
 
 
 
 
 
 
 
_modules/dashboard/views/dashboard.php DELETED
@@ -1,28 +0,0 @@
1
- <?php
2
- /**
3
- * Dashboard RSS Feed Widget
4
- */
5
- ?>
6
- <div class="rss-widget">
7
- <img src="http://cdn.wpbeginner.com/pluginimages/wpbeginner.gif" class="alignright" />
8
-
9
- <ul>
10
- <?php
11
- foreach ($rssPosts->item as $key=>$rssPost) {
12
- ?>
13
- <li>
14
- <a href="<?php echo (string) $rssPost->link; ?>" target="_blank" class="rsswidget"><?php echo (string) $rssPost->title; ?></a>
15
- <span class="rss-date"><?php echo date('F j, Y', strtotime($rssPost->pubDate)); ?></span>
16
- </li>
17
- <?php
18
- }
19
- ?>
20
-
21
- <li>
22
- <hr />
23
- <a href="http://feeds2.feedburner.com/wpbeginner" class="rss" target="_blank"><?php _e('Subscribe with RSS', $this->dashboard->name); ?></a>
24
- <a href="http://www.wpbeginner.com/wordpress-newsletter/" class="email" target="_blank"><?php _e('Subscribe by email', $this->dashboard->name); ?></a>
25
- <a href="http://facebook.com/wpbeginner/" class="facebook" target="_blank"><?php _e('Join us on Facebook', $this->dashboard->name); ?></a>
26
- </li>
27
- </ul>
28
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
_modules/dashboard/views/sidebar-donate.php DELETED
@@ -1,44 +0,0 @@
1
- <?php
2
- /**
3
- * Donations Sidebar
4
- */
5
- ?>
6
- <!-- Improve Your Site -->
7
- <div class="postbox">
8
- <h3 class="hndle">
9
- <span><?php _e('Improve Your Site', $this->plugin->name); ?></span>
10
- </h3>
11
-
12
- <div class="inside">
13
- <p>
14
- <?php _e('Want to take your site to the next level? Look behind the scenes of WPBeginner to see what you can do!', $this->plugin->name); ?>
15
- </p>
16
-
17
- <a href="http://www.wpbeginner.com/blueprint/" class="button" target="_blank">
18
- <?php _e('WPBeginner\'s Blueprint &raquo;', $this->plugin->name); ?>
19
- </a>
20
- </div>
21
- </div>
22
-
23
- <!-- Donate -->
24
- <div class="postbox">
25
- <h3 class="hndle">
26
- <span><?php _e('Spread The Word', $this->plugin->name); ?></span>
27
- </h3>
28
-
29
- <div class="inside">
30
- <p>
31
- <?php _e('Want to help make this plugin even better? All donations are used to improve this plugin, so donate $10, $20 or $50 now!', $this->plugin->name); ?>
32
- </p>
33
- <p>
34
- <a href="#" target="_blank">
35
- <?php _e('Find out more.', $this->plugin->name); ?>
36
- </a>
37
- </p>
38
- <p>
39
- <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=RK3BGVNS5L4ZW" target="_blank">
40
- <img src="https://www.paypal.com/en_US/i/btn/x-click-but21.gif" alt="<?php _e('Donate to WPBeginner', $this->plugin->name); ?>">
41
- </a>
42
- </p>
43
- </div>
44
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ihaf.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * Plugin Name: Insert Headers and Footers
4
  * Plugin URI: http://www.wpbeginner.com/
5
- * Version: 1.3.3
6
  * Author: WPBeginner
7
  * Author URI: http://www.wpbeginner.com/
8
  * Description: Allows you to insert code or text in the header or footer of your WordPress blog
@@ -12,7 +12,7 @@
12
  /* Copyright 2014 WPBeginner
13
 
14
  This program is free software; you can redistribute it and/or modify
15
- it under the terms of the GNU General Public License, version 2, as
16
  published by the Free Software Foundation.
17
 
18
  This program is distributed in the hope that it will be useful,
@@ -41,115 +41,185 @@ class InsertHeadersAndFooters {
41
  $this->plugin->version = '1.3.3';
42
  $this->plugin->folder = plugin_dir_path( __FILE__ );
43
  $this->plugin->url = plugin_dir_url( __FILE__ );
 
 
 
 
 
 
44
 
45
- // Dashboard Submodule
46
- if (!class_exists('WPBeginnerDashboardWidget')) {
47
- require_once($this->plugin->folder.'/_modules/dashboard/dashboard.php');
48
- }
49
- $this->dashboard = new WPBeginnerDashboardWidget($this->plugin);
50
-
51
  // Hooks
52
- add_action('admin_init', array(&$this, 'registerSettings'));
53
- add_action('admin_menu', array(&$this, 'adminPanelsAndMetaBoxes'));
54
-
 
 
 
55
  // Frontend Hooks
56
- add_action('wp_head', array(&$this, 'frontendHeader'));
57
- add_action('wp_footer', array(&$this, 'frontendFooter'));
 
 
 
58
  }
59
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  /**
61
  * Register Settings
62
  */
63
  function registerSettings() {
64
- register_setting($this->plugin->name, 'ihaf_insert_header', 'trim');
65
- register_setting($this->plugin->name, 'ihaf_insert_footer', 'trim');
66
  }
67
-
68
  /**
69
  * Register the plugin settings panel
70
  */
71
  function adminPanelsAndMetaBoxes() {
72
- add_submenu_page('options-general.php', $this->plugin->displayName, $this->plugin->displayName, 'manage_options', $this->plugin->name, array(&$this, 'adminPanel'));
73
  }
74
-
75
  /**
76
  * Output the Administration Panel
77
  * Save POSTed data from the Administration Panel into a WordPress option
78
  */
79
  function adminPanel() {
 
 
 
 
 
 
80
  // Save Settings
81
- if (isset($_POST['submit'])) {
82
  // Check nonce
83
- if (!isset($_POST[$this->plugin->name.'_nonce'])) {
84
- // Missing nonce
85
- $this->errorMessage = __('nonce field is missing. Settings NOT saved.', $this->plugin->name);
86
- } elseif (!wp_verify_nonce($_POST[$this->plugin->name.'_nonce'], $this->plugin->name)) {
87
  // Invalid nonce
88
- $this->errorMessage = __('Invalid nonce specified. Settings NOT saved.', $this->plugin->name);
89
- } else {
90
  // Save
91
- update_option('ihaf_insert_header', $_POST['ihaf_insert_header']);
92
- update_option('ihaf_insert_footer', $_POST['ihaf_insert_footer']);
93
- $this->message = __('Settings Saved.', $this->plugin->name);
 
 
 
94
  }
95
  }
96
-
97
  // Get latest settings
98
  $this->settings = array(
99
- 'ihaf_insert_header' => stripslashes(get_option('ihaf_insert_header')),
100
- 'ihaf_insert_footer' => stripslashes(get_option('ihaf_insert_footer')),
101
  );
102
-
103
  // Load Settings Form
104
- include_once(WP_PLUGIN_DIR.'/'.$this->plugin->name.'/views/settings.php');
105
  }
106
-
107
  /**
108
  * Loads plugin textdomain
109
  */
110
  function loadLanguageFiles() {
111
- load_plugin_textdomain($this->plugin->name, false, $this->plugin->name.'/languages/');
112
  }
113
-
114
  /**
115
  * Outputs script / CSS to the frontend header
116
  */
117
  function frontendHeader() {
118
- $this->output('ihaf_insert_header');
119
  }
120
-
121
  /**
122
  * Outputs script / CSS to the frontend footer
123
  */
124
  function frontendFooter() {
125
- $this->output('ihaf_insert_footer');
126
  }
127
-
128
  /**
129
  * Outputs the given setting, if conditions are met
130
  *
131
  * @param string $setting Setting Name
132
  * @return output
133
  */
134
- function output($setting) {
135
  // Ignore admin, feed, robots or trackbacks
136
- if (is_admin() OR is_feed() OR is_robots() OR is_trackback()) {
137
  return;
138
  }
139
-
140
  // Get meta
141
- $meta = get_option($setting);
142
- if (empty($meta)) {
143
  return;
144
- }
145
- if (trim($meta) == '') {
146
  return;
147
  }
148
-
149
  // Output
150
- echo stripslashes($meta);
151
  }
152
  }
153
-
154
  $ihaf = new InsertHeadersAndFooters();
155
  ?>
2
  /**
3
  * Plugin Name: Insert Headers and Footers
4
  * Plugin URI: http://www.wpbeginner.com/
5
+ * Version: 1.4
6
  * Author: WPBeginner
7
  * Author URI: http://www.wpbeginner.com/
8
  * Description: Allows you to insert code or text in the header or footer of your WordPress blog
12
  /* Copyright 2014 WPBeginner
13
 
14
  This program is free software; you can redistribute it and/or modify
15
+ it under the terms of the GNU General Public License, version 2, as
16
  published by the Free Software Foundation.
17
 
18
  This program is distributed in the hope that it will be useful,
41
  $this->plugin->version = '1.3.3';
42
  $this->plugin->folder = plugin_dir_path( __FILE__ );
43
  $this->plugin->url = plugin_dir_url( __FILE__ );
44
+ $this->plugin->db_welcome_dismissed_key = $this->plugin->name . '_welcome_dismissed_key';
45
+
46
+ // Check if the global wpb_feed_append variable exists. If not, set it.
47
+ if ( ! array_key_exists( 'wpb_feed_append', $GLOBALS ) ) {
48
+ $GLOBALS['wpb_feed_append'] = false;
49
+ }
50
 
 
 
 
 
 
 
51
  // Hooks
52
+ add_action( 'admin_init', array( &$this, 'registerSettings' ) );
53
+ add_action( 'admin_menu', array( &$this, 'adminPanelsAndMetaBoxes' ) );
54
+ add_action( 'wp_feed_options', array( &$this, 'dashBoardRss' ), 10, 2 );
55
+ add_action( 'admin_notices', array( &$this, 'dashboardNotices' ) );
56
+ add_action( 'wp_ajax_' . $this->plugin->name . '_dismiss_dashboard_notices', array( &$this, 'dismissDashboardNotices' ) );
57
+
58
  // Frontend Hooks
59
+ add_action( 'wp_head', array( &$this, 'frontendHeader' ) );
60
+ add_action( 'wp_footer', array( &$this, 'frontendFooter' ) );
61
+
62
+ // Filters
63
+ add_filter( 'dashboard_secondary_items', array( &$this, 'dashboardSecondaryItems' ) );
64
  }
65
+
66
+ /**
67
+ * Number of Secondary feed items to show
68
+ */
69
+ function dashboardSecondaryItems() {
70
+ return 6;
71
+ }
72
+
73
+ /**
74
+ * Update the planet feed to add the WPB feed
75
+ */
76
+ function dashboardRss( $feed, $url ) {
77
+ // Return early if not on the right page.
78
+ global $pagenow;
79
+ if ( 'admin-ajax.php' !== $pagenow ) {
80
+ return;
81
+ }
82
+
83
+ // Return early if not on the right feed.
84
+ if ( strpos( $url, 'planet.wordpress.org' ) === false ) {
85
+ return;
86
+ }
87
+
88
+ // Only move forward if this action hasn't been done already.
89
+ if ( ! $GLOBALS['wpb_feed_append'] ) {
90
+ $GLOBALS['wpb_feed_append'] = true;
91
+ $urls = array( 'http://www.wpbeginner.com/feed/', $url );
92
+ $feed->set_feed_url( $urls );
93
+ }
94
+ }
95
+
96
+ /**
97
+ * Show relevant notices for the plugin
98
+ */
99
+ function dashboardNotices() {
100
+ global $pagenow;
101
+
102
+ if ( empty( get_option( $this->plugin->db_welcome_dismissed_key ) ) ) {
103
+ if ( ! ( $pagenow == 'options-general.php' && isset( $_GET['page'] ) && $_GET['page'] == 'insert-headers-and-footers' ) ) {
104
+ $setting_page = admin_url( 'options-general.php?page=' . $this->plugin->name );
105
+ // load the notices view
106
+ include_once( WP_PLUGIN_DIR . '/' . $this->plugin->name . '/views/dashboard-notices.php' );
107
+ }
108
+ }
109
+ }
110
+
111
+ /**
112
+ * Dismiss the welcome notice for the plugin
113
+ */
114
+ function dismissDashboardNotices() {
115
+ check_ajax_referer( $this->plugin->name . '-nonce', 'nonce' );
116
+ // user has dismissed the welcome notice
117
+ update_option( $this->plugin->db_welcome_dismissed_key, 1 );
118
+ exit;
119
+ }
120
+
121
  /**
122
  * Register Settings
123
  */
124
  function registerSettings() {
125
+ register_setting( $this->plugin->name, 'ihaf_insert_header', 'trim' );
126
+ register_setting( $this->plugin->name, 'ihaf_insert_footer', 'trim' );
127
  }
128
+
129
  /**
130
  * Register the plugin settings panel
131
  */
132
  function adminPanelsAndMetaBoxes() {
133
+ add_submenu_page( 'options-general.php', $this->plugin->displayName, $this->plugin->displayName, 'manage_options', $this->plugin->name, array( &$this, 'adminPanel' ) );
134
  }
135
+
136
  /**
137
  * Output the Administration Panel
138
  * Save POSTed data from the Administration Panel into a WordPress option
139
  */
140
  function adminPanel() {
141
+ // only admin user can access this page
142
+ if ( !current_user_can( 'administrator' ) ) {
143
+ echo '<p>' . __( 'Sorry, you are not allowed to access this page.', $this->plugin->name ) . '</p>';
144
+ return;
145
+ }
146
+
147
  // Save Settings
148
+ if ( isset( $_REQUEST['submit'] ) ) {
149
  // Check nonce
150
+ if ( !isset( $_REQUEST[$this->plugin->name.'_nonce'] ) ) {
151
+ // Missing nonce
152
+ $this->errorMessage = __( 'nonce field is missing. Settings NOT saved.', $this->plugin->name );
153
+ } elseif ( !wp_verify_nonce( $_REQUEST[$this->plugin->name.'_nonce'], $this->plugin->name ) ) {
154
  // Invalid nonce
155
+ $this->errorMessage = __( 'Invalid nonce specified. Settings NOT saved.', $this->plugin->name );
156
+ } else {
157
  // Save
158
+ // $_REQUEST has already been slashed by wp_magic_quotes in wp-settings
159
+ // so do nothing before saving
160
+ update_option( 'ihaf_insert_header', $_REQUEST['ihaf_insert_header'] );
161
+ update_option( 'ihaf_insert_footer', $_REQUEST['ihaf_insert_footer'] );
162
+ update_option( $this->plugin->db_welcome_dismissed_key, 1 );
163
+ $this->message = __( 'Settings Saved.', $this->plugin->name );
164
  }
165
  }
166
+
167
  // Get latest settings
168
  $this->settings = array(
169
+ 'ihaf_insert_header' => esc_html( wp_unslash( get_option( 'ihaf_insert_header' ) ) ),
170
+ 'ihaf_insert_footer' => esc_html( wp_unslash( get_option( 'ihaf_insert_footer' ) ) ),
171
  );
172
+
173
  // Load Settings Form
174
+ include_once( WP_PLUGIN_DIR . '/' . $this->plugin->name . '/views/settings.php' );
175
  }
176
+
177
  /**
178
  * Loads plugin textdomain
179
  */
180
  function loadLanguageFiles() {
181
+ load_plugin_textdomain( $this->plugin->name, false, $this->plugin->name . '/languages/' );
182
  }
183
+
184
  /**
185
  * Outputs script / CSS to the frontend header
186
  */
187
  function frontendHeader() {
188
+ $this->output( 'ihaf_insert_header' );
189
  }
190
+
191
  /**
192
  * Outputs script / CSS to the frontend footer
193
  */
194
  function frontendFooter() {
195
+ $this->output( 'ihaf_insert_footer' );
196
  }
197
+
198
  /**
199
  * Outputs the given setting, if conditions are met
200
  *
201
  * @param string $setting Setting Name
202
  * @return output
203
  */
204
+ function output( $setting ) {
205
  // Ignore admin, feed, robots or trackbacks
206
+ if ( is_admin() || is_feed() || is_robots() || is_trackback() ) {
207
  return;
208
  }
209
+
210
  // Get meta
211
+ $meta = get_option( $setting );
212
+ if ( empty( $meta ) ) {
213
  return;
214
+ }
215
+ if ( trim( $meta ) == '' ) {
216
  return;
217
  }
218
+
219
  // Output
220
+ echo wp_unslash( $meta );
221
  }
222
  }
223
+
224
  $ihaf = new InsertHeadersAndFooters();
225
  ?>
readme.txt CHANGED
@@ -1,8 +1,8 @@
1
  === Insert Headers and Footers ===
2
- Contributors: WPbeginner, iamdpegg, smub, n7studios
3
- Tags: header, footer, headers, footers, content, wpmu, meta, meta tags, scripts, js, css, google analytics
4
  Requires at least: 3.6
5
- Tested up to: 4.3
6
  Stable tag: trunk
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -11,31 +11,76 @@ This plugin allows you to add extra scripts to the header and footer of your blo
11
 
12
  == Description ==
13
 
14
- 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.
15
 
16
- If you enjoy using this plugin and want to learn more about how to use WordPress then I would suggest visiting [WPBeginner](http://www.wpbeginner.com "WPBeginner"). It's one of the largest free WordPress resource sites in the world and has tons of [WordPress tutorials](http://www.wpbeginner.com/category/wp-tutorials/ "WordPress tutorials") that will explain everything you need to know about setting up and using WordPress.
17
 
18
- On the site you will also find [free WordPress video tutorials](http://videos.wpbeginner.com "Checkout out WPBeginner's WordPress tutorial videos"), and numerous other guides such as [how to choose the best WordPress hosting](http://www.wpbeginner.com/wordpress-hosting/ "How to Choose the Best WordPress Web Hosting"), [how to install WordPress](http://www.wpbeginner.com/how-to-install-wordpress/ "How to install WordPress") and many more.
19
 
20
- People often ask me what are the [best WordPress plugins](http://www.wpbeginner.com/category/plugins/ "best WordPress plugins")? How do I decide which plugins I should use on my site? Are there any must have plugins? To answer all these questions I created a blueprint of WPBeginner that shows exactly what I use to run the site. [Take a look at plugins I'm using at WPBeginner](http://www.wpbeginner.com/blueprint/ "Take a look at plugins I'm using at WPBeginner")
21
 
22
- Note for Beginners: Like all plugins available for download, Insert Headers And Footers is only available for self-hosted WordPress sites. This means you will need to [switch from WordPress.com to WordPress.org](http://www.wpbeginner.com/wp-tutorials/how-to-properly-move-your-blog-from-wordpress-com-to-wordpress-org/ "switch from WordPress.com to WordPress.org") if you want to use this plugin on your WordPress site. For more details, see my infographic on [Self hosted WordPress.org vs Free WordPress.com](http://www.wpbeginner.com/beginners-guide/self-hosted-wordpress-org-vs-free-wordpress-com-infograph/ "Self Hosted WordPress.org vs free WordPress.com")
 
 
 
 
23
 
24
- If you like using this plugin, then please leave us a good rating. If you have support questions just ask them here in the support forum.
25
 
26
- Lastly, if you like this plugin then follow WPBeginner on:
27
- [Twitter](http://twitter.com/wpbeginner "Twitter")
28
- [Facebook](http://facebook.com/wpbeginner "Facebook")
29
- [Google+](https://plus.google.com/101634180904808003404/ "Google+")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
 
31
  == Installation ==
32
 
33
- 1. Upload `insert-headers-and-footers` directory to the `/wp-content/plugins/` directory
34
- 2. Activate the plugin through the 'Plugins' menu in WordPress
35
- 3. Configure plugin (go to the Settings/Insert Headers and Footers)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
  == Changelog ==
38
 
 
 
 
 
39
  = 1.3.3 =
40
  * Tested with WordPress 4.3
41
  * Fix: plugin_dir_path() and plugin_dir_url() used for Multisite / symlink support
@@ -59,7 +104,4 @@ Lastly, if you like this plugin then follow WPBeginner on:
59
  * fixed unecessary CSS loading
60
 
61
  = 1.0 =
62
- * Initial version
63
-
64
-
65
-
1
  === Insert Headers and Footers ===
2
+ Contributors: WPbeginner, smub, deb255
3
+ Tags: code, content, css, footer, footer code, footer scripts, footers, google analytics, head, header, header code, header scripts, headers, insert, insert code, insert scripts, js, meta, meta tags, scripts, wpmu
4
  Requires at least: 3.6
5
+ Tested up to: 4.7.2
6
  Stable tag: trunk
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
12
  == Description ==
13
 
14
+ = Easily Insert Header and Footer Code =
15
 
16
+ Insert Headers and Footers is a simple plugin that lets you insert code like Google Analytics to your WordPress site header and footer. No need to edit your theme files!
17
 
18
+ The simple interface of the Insert Headers and Footers plugin gives you one place where you can insert scripts, rather than dealing with dozens of different plugins.
19
 
20
+ = Features of Insert Headers and Footers =
21
 
22
+ * Quick to set up
23
+ * Simple to insert scripts
24
+ * Insert header code and/or footer code
25
+ * Add Google Analytics code to any theme
26
+ * Insert any code or script, including HTML and Javascript
27
 
28
+ = Credits =
29
 
30
+ This plugin is created by <a href="https://syedbalkhi.com/" rel="friend" title="Syed Balkhi">Syed Balkhi</a> and the <a href="http://www.wpbeginner.com/" rel="friend" title="WPBeginner">WPBeginner</a> team.
31
+
32
+ = What's Next =
33
+
34
+ If you find this plugin useful to insert header and footer scripts, please leave a good rating and consider checking out our other projects:
35
+
36
+ * <a href="http://optinmonster.com/" rel="friend" title="OptinMonster">OptinMonster</a> - Get More Email Subscribers
37
+ * <a href="http://wpforms.com/" rel="friend" title="WPForms">WPForms</a> - Best Contact Form Builder Plugin
38
+ * <a href="http://soliloquywp.com/" rel="friend" title="Soliloquy">Soliloquy</a> - Best WordPress Slider Plugin
39
+ * <a href="http://enviragallery.com/" rel="friend" title="Envira Gallery">Envira Gallery</a> - Best WordPress Gallery Plugin
40
+ * <a href="http://monsterinsights.com/" rel="friend" title="MonsterInsights">MonsterInsights</a> - Best Google Analytics Plugin
41
+
42
+ To learn more about WordPress, you can also visit <a href="http://www.wpbeginner.com/" rel="friend" title="WPBeginner">WPBeginner</a> for tutorials on topics like:
43
+
44
+ * <a href="http://www.wpbeginner.com/wordpress-performance-speed/" rel="friend" title="Ultimate Guide to WordPress Speed and Performance">WordPress Speed and Performance</a>
45
+ * <a href="http://www.wpbeginner.com/wordpress-security/" rel="friend" title="Ultimate WordPress Security Guide">WordPress Security</a>
46
+ * <a href="http://www.wpbeginner.com/wordpress-seo/" rel="friend" title="Ultimate WordPress SEO Guide for Beginners">WordPress Security</a>WordPress SEO</a>
47
+
48
+ ...and many more <a href="http://www.wpbeginner.com/category/wp-tutorials/" rel="friend" title="WordPress Tutorials">WordPress tutorials</a>.
49
 
50
  == Installation ==
51
 
52
+ 1. Install Insert Headers and Footers by uploading the `insert-headers-and-footers` directory to the `/wp-content/plugins/` directory. (See instructions on <a href="http://www.wpbeginner.com/beginners-guide/step-by-step-guide-to-install-a-wordpress-plugin-for-beginners/" rel="friend">how to install a WordPress plugin</a>.)
53
+ 2. Activate Insert Headers and Footers through the `Plugins` menu in WordPress.
54
+ 3. Insert code in your header or footer by going to the `Settings > Insert Headers and Footers` menu.
55
+
56
+ [youtube https://www.youtube.com/watch?v=AXM1QgMODW0]
57
+
58
+ == Screenshots ==
59
+
60
+ 1. Settings Screen
61
+
62
+ == Frequently Asked Questions ==
63
+
64
+ = Can I use Insert Headers and Footers to install Google Analytics? =
65
+
66
+ Yes, you can insert your Google Analytics code in the `Scripts in Header` field.
67
+
68
+ == Notes ==
69
+ Insert Headers and Footers is the easiest way to insert code in your WordPress headers and footers.
70
+
71
+ Our goal is to make using WordPress easy, both with our <a href="http://www.wpbeginner.com/wordpress-plugins/" rel="friend" title="WordPress Plugins">WordPress plugins</a> and resources like <a href="http://www.wpbeginner.com/" rel="friend">WPBeginner</a>, the largest WordPress resource site for beginners.
72
+
73
+ I feel that we have done that here. I hope find Insert Headers and Footers useful to insert scripts on your site.
74
+
75
+ Thank you
76
+ Syed Balkhi
77
 
78
  == Changelog ==
79
 
80
+ = 1.4 =
81
+ * Tested with WordPress 4.7.2
82
+ * cleaned up code
83
+
84
  = 1.3.3 =
85
  * Tested with WordPress 4.3
86
  * Fix: plugin_dir_path() and plugin_dir_url() used for Multisite / symlink support
104
  * fixed unecessary CSS loading
105
 
106
  = 1.0 =
107
+ * Initial version
 
 
 
views/dashboard-notices.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Notices template
4
+ */
5
+ ?>
6
+ <div class="notice notice-success is-dismissible <?= $this->plugin->name ?>-notice-welcome">
7
+ <p>Thank you for installing <?= $this->plugin->displayName ?>! <a href="<?= $setting_page ?>">Click here</a> to configure the plugin.</p>
8
+ </div>
9
+ <script type="text/javascript">
10
+ jQuery(document).ready( function($) {
11
+ $(document).on( 'click', '.<?= $this->plugin->name ?>-notice-welcome button.notice-dismiss', function( event ) {
12
+ event.preventDefault();
13
+ $.post( ajaxurl, {
14
+ action: '<?= $this->plugin->name . '_dismiss_dashboard_notices' ?>',
15
+ nonce: '<?= wp_create_nonce( $this->plugin->name . '-nonce' ) ?>'
16
+ });
17
+ $('.<?= $this->plugin->name ?>-notice-welcome').remove();
18
+ });
19
+ });
20
+ </script>
views/settings.php CHANGED
@@ -1,75 +1,57 @@
1
  <div class="wrap">
2
- <h2><?php echo $this->plugin->displayName; ?> &raquo; <?php _e('Settings', $this->plugin->name); ?></h2>
3
-
4
- <?php
5
- if (isset($this->message)) {
6
  ?>
7
- <div class="updated fade"><p><?php echo $this->message; ?></p></div>
8
  <?php
9
  }
10
- if (isset($this->errorMessage)) {
11
  ?>
12
- <div class="error fade"><p><?php echo $this->errorMessage; ?></p></div>
13
  <?php
14
  }
15
- ?>
16
-
17
  <div id="poststuff">
18
  <div id="post-body" class="metabox-holder columns-2">
19
  <!-- Content -->
20
  <div id="post-body-content">
21
- <div id="normal-sortables" class="meta-box-sortables ui-sortable">
22
  <div class="postbox">
23
- <h3 class="hndle"><?php _e('Settings', $this->plugin->name); ?></h3>
24
-
25
  <div class="inside">
26
  <form action="options-general.php?page=<?php echo $this->plugin->name; ?>" method="post">
27
  <p>
28
- <label for="ihaf_insert_header"><strong><?php _e('Scripts in Header', $this->plugin->name); ?></strong></label>
29
- <textarea name="ihaf_insert_header" id="ihaf_insert_header" class="widefat" rows="8" style="font-family:Courier New;"><?php echo $this->settings['ihaf_insert_header']; ?></textarea>
30
- <?php _e('These scripts will be printed in the <code>&lt;head&gt;</code> section.', $this->plugin->name); ?>
31
  </p>
32
  <p>
33
- <label for="ihaf_insert_footer"><strong><?php _e('Scripts in Footer', $this->plugin->name); ?></strong></label>
34
- <textarea name="ihaf_insert_footer" id="ihaf_insert_footer" class="widefat" rows="8" style="font-family:Courier New;"><?php echo $this->settings['ihaf_insert_footer']; ?></textarea>
35
- <?php _e('These scripts will be printed above the <code>&lt;/body&gt;</code> tag.', $this->plugin->name); ?>
36
  </p>
37
- <?php wp_nonce_field($this->plugin->name, $this->plugin->name.'_nonce'); ?>
38
  <p>
39
- <input name="submit" type="submit" name="Submit" class="button button-primary" value="<?php _e('Save', $this->plugin->name); ?>" />
40
  </p>
41
  </form>
42
  </div>
43
  </div>
44
  <!-- /postbox -->
45
-
46
- <?php
47
- // RSS Feed
48
- if (isset($this->dashboard)) {
49
- ?>
50
- <div id="wpbeginner" class="postbox">
51
- <h3 class="hndle"><?php _e('Latest from WPBeginner', $this->plugin->name); ?></h3>
52
-
53
- <div class="inside">
54
- <?php
55
- $this->dashboard->outputDashboardWidget();
56
- ?>
57
- </div>
58
- </div>
59
- <!-- /postbox -->
60
- <?php
61
- }
62
- ?>
63
  </div>
64
  <!-- /normal-sortables -->
65
  </div>
66
  <!-- /post-body-content -->
67
-
68
  <!-- Sidebar -->
69
  <div id="postbox-container-1" class="postbox-container">
70
- <?php require_once($this->plugin->folder.'/_modules/dashboard/views/sidebar-donate.php'); ?>
71
  </div>
72
  <!-- /postbox-container -->
73
  </div>
74
- </div>
75
  </div>
1
  <div class="wrap">
2
+ <h2><?php echo $this->plugin->displayName; ?> &raquo; <?php _e( 'Settings', $this->plugin->name ); ?></h2>
3
+
4
+ <?php
5
+ if ( isset( $this->message ) ) {
6
  ?>
7
+ <div class="updated fade"><p><?php echo $this->message; ?></p></div>
8
  <?php
9
  }
10
+ if ( isset( $this->errorMessage ) ) {
11
  ?>
12
+ <div class="error fade"><p><?php echo $this->errorMessage; ?></p></div>
13
  <?php
14
  }
15
+ ?>
16
+
17
  <div id="poststuff">
18
  <div id="post-body" class="metabox-holder columns-2">
19
  <!-- Content -->
20
  <div id="post-body-content">
21
+ <div id="normal-sortables" class="meta-box-sortables ui-sortable">
22
  <div class="postbox">
23
+ <h3 class="hndle"><?php _e( 'Settings', $this->plugin->name ); ?></h3>
24
+
25
  <div class="inside">
26
  <form action="options-general.php?page=<?php echo $this->plugin->name; ?>" method="post">
27
  <p>
28
+ <label for="ihaf_insert_header"><strong><?php _e( 'Scripts in Header', $this->plugin->name ); ?></strong></label>
29
+ <textarea name="ihaf_insert_header" id="ihaf_insert_header" class="widefat" rows="8" style="font-family:Courier New;"><?php echo $this->settings['ihaf_insert_header']; ?></textarea>
30
+ <?php _e( 'These scripts will be printed in the <code>&lt;head&gt;</code> section.', $this->plugin->name ); ?>
31
  </p>
32
  <p>
33
+ <label for="ihaf_insert_footer"><strong><?php _e( 'Scripts in Footer', $this->plugin->name ); ?></strong></label>
34
+ <textarea name="ihaf_insert_footer" id="ihaf_insert_footer" class="widefat" rows="8" style="font-family:Courier New;"><?php echo $this->settings['ihaf_insert_footer']; ?></textarea>
35
+ <?php _e( 'These scripts will be printed above the <code>&lt;/body&gt;</code> tag.', $this->plugin->name ); ?>
36
  </p>
37
+ <?php wp_nonce_field( $this->plugin->name, $this->plugin->name.'_nonce' ); ?>
38
  <p>
39
+ <input name="submit" type="submit" name="Submit" class="button button-primary" value="<?php _e( 'Save', $this->plugin->name ); ?>" />
40
  </p>
41
  </form>
42
  </div>
43
  </div>
44
  <!-- /postbox -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  </div>
46
  <!-- /normal-sortables -->
47
  </div>
48
  <!-- /post-body-content -->
49
+
50
  <!-- Sidebar -->
51
  <div id="postbox-container-1" class="postbox-container">
52
+ <?php require_once( $this->plugin->folder . '/views/sidebar.php' ); ?>
53
  </div>
54
  <!-- /postbox-container -->
55
  </div>
56
+ </div>
57
  </div>
views/sidebar.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Donations Sidebar
4
+ */
5
+ ?>
6
+ <!-- Improve Your Site -->
7
+ <div class="postbox">
8
+ <h3 class="hndle">
9
+ <span><?php _e('Improve Your Site', $this->plugin->name); ?></span>
10
+ </h3>
11
+
12
+ <div class="inside">
13
+ <p>
14
+ <?php _e( 'Want to take your site to the next level? Check out our daily free WordPress tutorials on ', $this->plugin->name ); ?>
15
+ <a href="http://www.wpbeginner.com/?utm_source=wpadmin&utm_campaign=freeplugins"><?php _e( 'WPBeginner blog' ); ?></a>.
16
+ </p>
17
+
18
+ <p>
19
+ <?php _e( 'Some of our popular guides:', $this->plugin->name ); ?>
20
+ </p>
21
+
22
+ <ul>
23
+ <li><a href="http://www.wpbeginner.com/wordpress-performance-speed/?utm_source=wpadmin&utm_campaign=freeplugins" target="_blank">
24
+ <?php _e( 'Speed Up WordPress', $this->plugin->name ); ?>
25
+ </a></li>
26
+ <li><a href="http://www.wpbeginner.com/wordpress-security/?utm_source=wpadmin&utm_campaign=freeplugins" target="_blank">
27
+ <?php _e( 'Improve WordPress Security', $this->plugin->name ); ?>
28
+ </a></li>
29
+
30
+ <li><a href="http://www.wpbeginner.com/wordpress-seo/?utm_source=wpadmin&utm_campaign=freeplugins" target="_blank">
31
+ <?php _e( 'Boost Your WordPress SEO', $this->plugin->name ); ?>
32
+ </a></li>
33
+ </ul>
34
+
35
+ </div>
36
+ </div>
37
+
38
+ <!-- Donate -->
39
+ <div class="postbox">
40
+ <h3 class="hndle">
41
+ <span><?php _e( 'Our WordPress Plugins', $this->plugin->name); ?></span>
42
+ </h3>
43
+ <div class="inside">
44
+ <p>
45
+ <?php _e( 'Like this plugin? Check out our other WordPress plugins:', $this->plugin->name ); ?>
46
+ </p>
47
+ <p>
48
+ <a href="https://wordpress.org/plugins/wpforms-lite/" target="_blank">
49
+ <?php _e( 'WPForms', $this->plugin->name ); ?>
50
+ </a>
51
+ <?php _e( ' - Drag & Drop WordPress Form Builder', $this->plugin->name ); ?>
52
+ </p>
53
+ <p>
54
+ <a href="https://wordpress.org/plugins/envira-gallery-lite/" target="_blank">
55
+ <?php _e( 'Envira Gallery', $this->plugin->name ); ?>
56
+ </a>
57
+ <?php _e( ' - Responsive WordPress Gallery plugin', $this->plugin->name ); ?>
58
+ </p>
59
+ <p>
60
+ <a href="https://wordpress.org/plugins/google-analytics-for-wordpress/" target="_blank">
61
+ <?php _e( 'MonsterInsights', $this->plugin->name ); ?>
62
+ </a>
63
+ <?php _e( ' - Google Analytics Made Easy for WordPress', $this->plugin->name ); ?>
64
+ </p>
65
+ <p>
66
+ <a href="https://wordpress.org/plugins/soliloquy-lite/" target="_blank">
67
+ <?php _e( 'Soliloquy', $this->plugin->name ); ?>
68
+ </a>
69
+ <?php _e( ' - Responsive WordPress Slider Plugin', $this->plugin->name ); ?>
70
+ </p>
71
+ <p>
72
+ <a href="http://optinmonster.com/" target="_blank">
73
+ <?php _e( 'OptinMonster', $this->plugin->name ); ?>
74
+ </a>
75
+ <?php _e( ' - Best WordPress Lead Generation Plugin', $this->plugin->name ); ?>
76
+ </p>
77
+ </div>
78
+ </div>