Version Description
- Visual Improvements
- better directory structure.
Download this release
Release Info
Developer | anand_kumar |
Plugin | Header and Footer Scripts |
Version | 2.0.0 |
Comparing to | |
See all releases |
Code changes from version 1.3.4 to 2.0.0
- images/blogsynthesis-100px.png +0 -0
- images/email-16px.png +0 -0
- meta.php → inc/meta.php +8 -8
- inc/options.php +34 -0
- inc/sidebar.php +34 -0
- readme.txt +97 -85
- shfs.php +212 -364
images/blogsynthesis-100px.png
DELETED
Binary file
|
images/email-16px.png
DELETED
Binary file
|
meta.php → inc/meta.php
RENAMED
@@ -1,8 +1,8 @@
|
|
1 |
-
<div class="shfs_meta_control">
|
2 |
-
|
3 |
-
<p>
|
4 |
-
<textarea name="_inpost_head_script[synth_header_script]" rows="5" style="width:98%;"><?php if(!empty($meta['synth_header_script'])) echo $meta['synth_header_script']; ?></textarea>
|
5 |
-
</p>
|
6 |
-
|
7 |
-
<p
|
8 |
-
</div>
|
1 |
+
<div class="shfs_meta_control">
|
2 |
+
|
3 |
+
<p>
|
4 |
+
<textarea name="_inpost_head_script[synth_header_script]" rows="5" style="width:98%;"><?php if(!empty($meta['synth_header_script'])) echo $meta['synth_header_script']; ?></textarea>
|
5 |
+
</p>
|
6 |
+
|
7 |
+
<p><?php _e('Add some code to <code><head></code>', 'header-and-footer-scripts'); ?>.</p>
|
8 |
+
</div>
|
inc/options.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="wrap">
|
2 |
+
<h2><?php _e( 'Header and Footer Scripts - Options', 'header-and-footer-scripts'); ?> <a class="add-new-h2" target="_blank" href="#"><?php _e( 'Read Tutorial', 'header-and-footer-scripts'); ?></a></h2>
|
3 |
+
|
4 |
+
<hr />
|
5 |
+
<div id="poststuff">
|
6 |
+
<div id="post-body" class="metabox-holder columns-2">
|
7 |
+
<div id="post-body-content">
|
8 |
+
<div class="postbox">
|
9 |
+
<div class="inside">
|
10 |
+
<form name="dofollow" action="options.php" method="post">
|
11 |
+
|
12 |
+
<?php settings_fields( 'header-and-footer-scripts' ); ?>
|
13 |
+
|
14 |
+
<h3 class="shfs-labels" for="shfs_insert_header"><?php _e( 'Scripts in header:', 'header-and-footer-scripts'); ?></h3>
|
15 |
+
<textarea style="width:98%;" rows="10" cols="57" id="insert_header" name="shfs_insert_header"><?php echo esc_html( get_option( 'shfs_insert_header' ) ); ?></textarea>
|
16 |
+
<p><?php _e( 'Above script will be inserted into the <code><head></code> section.', 'header-and-footer-scripts'); ?></p><hr />
|
17 |
+
|
18 |
+
<h3 class="shfs-labels footerlabel" for="shfs_insert_footer"><?php _e( 'Scripts in footer:', 'header-and-footer-scripts'); ?></h3>
|
19 |
+
<textarea style="width:98%;" rows="10" cols="57" id="shfs_insert_footer" name="shfs_insert_footer"><?php echo esc_html( get_option( 'shfs_insert_footer' ) ); ?></textarea>
|
20 |
+
<p><?php _e( 'Above script will be inserted just before <code></body></code> tag using <code>wp_footer</code> hook.', 'header-and-footer-scripts'); ?></p>
|
21 |
+
|
22 |
+
<p class="submit">
|
23 |
+
<input class="button button-primary" type="submit" name="Submit" value="<?php _e( 'Save settings', 'header-and-footer-scripts'); ?>" />
|
24 |
+
</p>
|
25 |
+
|
26 |
+
</form>
|
27 |
+
</div>
|
28 |
+
</div>
|
29 |
+
</div>
|
30 |
+
|
31 |
+
<?php require_once(SHFS_PLUGIN_DIR . '/inc/sidebar.php'); ?>
|
32 |
+
</div>
|
33 |
+
</div>
|
34 |
+
</div>
|
inc/sidebar.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Sidebar for admin info and selfpromotion purposes.
|
4 |
+
* It incudes links to help docs and support site.
|
5 |
+
*
|
6 |
+
*
|
7 |
+
*/?>
|
8 |
+
<div id="postbox-container-1" class="postbox-container">
|
9 |
+
|
10 |
+
<div class="postbox">
|
11 |
+
<h3 class="hndle"><?php _e( 'Need Help?', 'header-and-footer-scripts'); ?></h3>
|
12 |
+
<div class="inside">
|
13 |
+
<p><?php _e( 'Read plugin documentation for clarification or how to use the plugin. OR ask your query:', 'header-and-footer-scripts'); ?></p>
|
14 |
+
<p><strong><a href="http://digitalliberation.org/plugins/header-and-footer-scripts/" target="_blank" class="button"><?php _e('Explore Docs and Support', 'header-and-footer-scripts'); ?></a></strong></p>
|
15 |
+
</div>
|
16 |
+
</div>
|
17 |
+
|
18 |
+
<div class="postbox">
|
19 |
+
<h3 class="hndle"><?php _e( 'Contribute or Donate!', 'header-and-footer-scripts'); ?></h3>
|
20 |
+
<div class="inside">
|
21 |
+
<p><?php _e( 'Help us to make this plugin even better. Contribution doesn\'t always mean donation. Please follow the link to know more and contribute.', 'header-and-footer-scripts'); ?></p>
|
22 |
+
<p><a href="http://digitalliberation.org/contribute?utm_source=wpdash" target="_blank" class="button"><?php _e( 'Contribute', 'header-and-footer-scripts'); ?></a></p>
|
23 |
+
</div>
|
24 |
+
</div>
|
25 |
+
|
26 |
+
<div class="postbox">
|
27 |
+
<h3 class="hndle"><?php _e( 'More', 'header-and-footer-scripts'); ?></h3>
|
28 |
+
<div class="inside">
|
29 |
+
<p><?php _e( 'You may find more plugins and themes here.', 'header-and-footer-scripts'); ?></p>
|
30 |
+
<p><a href="http://digitalliberation.org/?utm_source=wpdash" target="_blank" class="button"><?php _e( 'Contribute', 'header-and-footer-scripts'); ?></a></p>
|
31 |
+
</div>
|
32 |
+
</div>
|
33 |
+
|
34 |
+
</div>
|
readme.txt
CHANGED
@@ -1,85 +1,97 @@
|
|
1 |
-
=== Header and Footer Scripts ===
|
2 |
-
|
3 |
-
Contributors: digitalliberation, anand_kumar
|
4 |
-
Donate link:
|
5 |
-
Tags: head, header, footer, scripts, post, admin
|
6 |
-
Requires at least:
|
7 |
-
Tested up to: 4.9.1
|
8 |
-
Stable tag:
|
9 |
-
Requires PHP: 5.
|
10 |
-
License: GPLv2 or later
|
11 |
-
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
-
|
13 |
-
Header and Footer Scripts plugin enables you to add scripts to WordPress header and footer.
|
14 |
-
|
15 |
-
== Description ==
|
16 |
-
|
17 |
-
Many WordPress Themes do not have any options to insert header and footer scripts in your site `<head>` or `<footer>`. It helps you to keep yourself from theme lock. But, sometimes it also causes some pain for many. like where should I insert Google Analytics code (or any other web-analytics codes). This plugin is one stop and lightweight solution for that. With this "Header and Footer Script" plugin will be able to inject HTML tags, JS and CSS codes to `<head>` and `<footer>` easily.
|
18 |
-
|
19 |
-
= Benefits of the plugin: =
|
20 |
-
* You will be able to insert
|
21 |
-
* You will be able to insert html and/or JavaScript codes to footer of your site. Good place for Clicky Web Analytics, Twitter, Facebook or any other social media script.
|
22 |
-
* Easily insert codes to single post and page headers, in addition to default codes.
|
23 |
-
|
24 |
-
Please note, If the plugin is not working check for `wp_head` and `wp_footer` hooks. [more information][3] or [ask for support][7].
|
25 |
-
|
26 |
-
= Important Links =
|
27 |
-
* **[Latest FAQs and Help Article][4]**
|
28 |
-
* **[GitHub Repo][8]**
|
29 |
-
* **[Support][5]**
|
30 |
-
* [Donate][6]
|
31 |
-
|
32 |
-
PS: For any troubleshooting ask your question in the BlogSynthesis Forums. I can't check WordPress forums regularly.
|
33 |
-
|
34 |
-
[1]: http://www.blogsynthesis.com/google-analytics-to-wordpress
|
35 |
-
[2]: http://bit.ly/ClickyWebAnalytics
|
36 |
-
[3]: http://www.blogsynthesis.com/plugins/header-and-footer-scripts/#FAQs
|
37 |
-
[4]: http://www.blogsynthesis.com/plugins/header-and-footer-scripts
|
38 |
-
[5]:
|
39 |
-
[6]: http://www.blogsynthesis.com/donate/
|
40 |
-
[7]:
|
41 |
-
[8]: https://github.com/anandkumar/header-and-footer-scripts
|
42 |
-
|
43 |
-
== Installation ==
|
44 |
-
|
45 |
-
Upload the plugin to `/wp-content/plugins` and activate. OR Search "Header and Footer Scripts" from `WP Dashbard --> Plugins --> Add New` then hit Install
|
46 |
-
|
47 |
-
== Screenshots ==
|
48 |
-
1. Access this page from `Dashboard --> Settings --> Header and Footer Scripts`
|
49 |
-
2. This box will appear below somewhere below on compose window on posts and pages.
|
50 |
-
|
51 |
-
== Frequently Asked Questions ==
|
52 |
-
|
53 |
-
**Q. I need plugin support. Where should I ask questions?**
|
54 |
-
|
55 |
-
A. You may ask support related questions at
|
56 |
-
|
57 |
-
**How do I disable the site-wide header and footer injection or the post specific header injection?**
|
58 |
-
|
59 |
-
A. To keep this plugin simple we have not added any such options. You may try another plugin for more or less functionality.
|
60 |
-
|
61 |
-
**Q:
|
62 |
-
|
63 |
-
A.
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
*
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Header and Footer Scripts ===
|
2 |
+
|
3 |
+
Contributors: digitalliberation, anand_kumar
|
4 |
+
Donate link: http://www.blogsynthesis.com/donate/
|
5 |
+
Tags: head, header, footer, scripts, post, admin
|
6 |
+
Requires at least: 3.6
|
7 |
+
Tested up to: 4.9.1
|
8 |
+
Stable tag: 2.0.0
|
9 |
+
Requires PHP: 5.3
|
10 |
+
License: GPLv2 or later
|
11 |
+
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
+
|
13 |
+
Header and Footer Scripts plugin enables you to add scripts to WordPress header and footer.
|
14 |
+
|
15 |
+
== Description ==
|
16 |
+
|
17 |
+
Many WordPress Themes do not have any options to insert header and footer scripts in your site `<head>` or `<footer>`. It helps you to keep yourself from theme lock. But, sometimes it also causes some pain for many. like where should I insert Google Analytics code (or any other web-analytics codes). This plugin is one stop and lightweight solution for that. With this "Header and Footer Script" plugin will be able to inject HTML tags, JS and CSS codes to `<head>` and `<footer>` easily.
|
18 |
+
|
19 |
+
= Benefits of the plugin: =
|
20 |
+
* You will be able to [insert Google Analytics][1] or other Web-analytics code, meta-informations, CSS and JS codes to `<head>`
|
21 |
+
* You will be able to insert html and/or JavaScript codes to footer of your site. Good place for [Clicky Web Analytics][2], Twitter, Facebook or any other social media script.
|
22 |
+
* Easily insert codes to single post and page headers, in addition to default codes.
|
23 |
+
|
24 |
+
Please note, If the plugin is not working check for `wp_head` and `wp_footer` hooks. [more information][3] or [ask for support][7].
|
25 |
+
|
26 |
+
= Important Links =
|
27 |
+
* **[Latest FAQs and Help Article][4]**
|
28 |
+
* **[GitHub Repo][8]**
|
29 |
+
* **[Support][5]**
|
30 |
+
* **[Donate][6]**
|
31 |
+
|
32 |
+
PS: For any troubleshooting ask your question in the BlogSynthesis Forums. I can't check WordPress forums regularly.
|
33 |
+
|
34 |
+
[1]: http://www.blogsynthesis.com/google-analytics-to-wordpress/#utm_source=wporg&utm_medium=wppluginpage&utm_campaign=wpshfs
|
35 |
+
[2]: http://bit.ly/ClickyWebAnalytics
|
36 |
+
[3]: http://www.blogsynthesis.com/plugins/header-and-footer-scripts/#FAQs
|
37 |
+
[4]: http://www.blogsynthesis.com/plugins/header-and-footer-scripts/#utm_source=wporg&utm_medium=wppluginpage&utm_campaign=wpshfs
|
38 |
+
[5]: http://www.blogsynthesis.com/support/#utm_source=wporg&utm_medium=wppluginpage&utm_campaign=wpshfs
|
39 |
+
[6]: http://www.blogsynthesis.com/donate/
|
40 |
+
[7]: http://www.blogsynthesis.com/support/#utm_source=wporg&utm_medium=wppluginpage&utm_campaign=wpshfs
|
41 |
+
[8]: https://github.com/anandkumar/header-and-footer-scripts
|
42 |
+
|
43 |
+
== Installation ==
|
44 |
+
|
45 |
+
Upload the plugin to `/wp-content/plugins` and activate. OR Search "Header and Footer Scripts" from `WP Dashbard --> Plugins --> Add New` then hit Install
|
46 |
+
|
47 |
+
== Screenshots ==
|
48 |
+
1. Access this page from `Dashboard --> Settings --> Header and Footer Scripts`
|
49 |
+
2. This box will appear below somewhere below on compose window on posts and pages.
|
50 |
+
|
51 |
+
== Frequently Asked Questions ==
|
52 |
+
|
53 |
+
**Q. I need plugin support. Where should I ask questions?**
|
54 |
+
|
55 |
+
A. You may ask support related questions at (http://digitalliberation.org/wordpress/#utm_source=wporg&utm_medium=wppluginpage&utm_campaign=wpshfs). Meanwhile, you should take a look on [this FAQ](http://www.blogsynthesis.com/plugins/header-and-footer-scripts/#utm_source=wporg&utm_medium=wppluginpage&utm_campaign=wpshfs) This page will have most latest FAQs (that depends upon what user asks.) Read that article before asking any questions. It may solve your questions and save time.
|
56 |
+
|
57 |
+
**How do I disable the site-wide header and footer injection or the post specific header injection?**
|
58 |
+
|
59 |
+
A. To keep this plugin simple we have not added any such options. You may try another plugin for more or less functionality.
|
60 |
+
|
61 |
+
**Q: I need more functionality. What should I do?**
|
62 |
+
|
63 |
+
A. If you want more functionality then check [Enhanced Header/Footer Scripts](http://bit.ly/wp-ehfi).
|
64 |
+
|
65 |
+
**Q: I need less functionality. What should I do?**
|
66 |
+
|
67 |
+
A. If you are looking for less functionality then check [Insert Header and Footers](http://bit.ly/wpb-ihf) plugin.
|
68 |
+
|
69 |
+
**Q: Is there any paid version of the plugin available?**
|
70 |
+
|
71 |
+
A. No, There is no paid version of this plugin is available.
|
72 |
+
|
73 |
+
== Changelog ==
|
74 |
+
|
75 |
+
= 2.0.0 =
|
76 |
+
* Visual Improvements
|
77 |
+
* better directory structure.
|
78 |
+
|
79 |
+
= 1.3.4 =
|
80 |
+
* Fixed variable undefined notice
|
81 |
+
|
82 |
+
= 1.3.3 =
|
83 |
+
* Started using PHP5 style construct
|
84 |
+
|
85 |
+
= 1.3.2 =
|
86 |
+
* Fixed https issue
|
87 |
+
|
88 |
+
= 1.1.0 =
|
89 |
+
* Made for official WordPress Repo.
|
90 |
+
* Added Single post Header script metabox
|
91 |
+
* Minor Bug Fixes
|
92 |
+
|
93 |
+
= 1.0.0 =
|
94 |
+
* Initial Public Release
|
95 |
+
|
96 |
+
== Upgrade Notice ==
|
97 |
+
Upgrade for more functionality and bug fixes.
|
shfs.php
CHANGED
@@ -1,364 +1,212 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
Plugin Name: Header and Footer Scripts
|
4 |
-
Plugin URI: http://
|
5 |
-
Description: Allows you to insert code or text in the header or footer of your WordPress blog
|
6 |
-
Version:
|
7 |
-
Author: Anand Kumar
|
8 |
-
Author URI: http://www.
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
*/
|
31 |
-
|
32 |
-
define('SHFS_PLUGIN_DIR',str_replace('\\','/',dirname(__FILE__)));
|
33 |
-
|
34 |
-
if ( !class_exists( 'HeaderAndFooterScripts' ) ) {
|
35 |
-
|
36 |
-
class HeaderAndFooterScripts {
|
37 |
-
|
38 |
-
function __construct() {
|
39 |
-
|
40 |
-
add_action( 'init', array( &$this, 'init' ) );
|
41 |
-
add_action( 'admin_init', array( &$this, 'admin_init' ) );
|
42 |
-
add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
|
43 |
-
add_action( 'wp_head', array( &$this, 'wp_head' ) );
|
44 |
-
add_action( 'wp_footer', array( &$this, 'wp_footer' ) );
|
45 |
-
|
46 |
-
}
|
47 |
-
|
48 |
-
|
49 |
-
function init() {
|
50 |
-
load_plugin_textdomain( '
|
51 |
-
}
|
52 |
-
|
53 |
-
function admin_init() {
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
function
|
70 |
-
$
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
$
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
}(document, 'script', 'facebook-jssdk'));</script>
|
214 |
-
|
215 |
-
<?php
|
216 |
-
}
|
217 |
-
}
|
218 |
-
|
219 |
-
function shfs_meta_setup()
|
220 |
-
{
|
221 |
-
global $post;
|
222 |
-
|
223 |
-
// using an underscore, prevents the meta variable
|
224 |
-
// from showing up in the custom fields section
|
225 |
-
$meta = get_post_meta($post->ID,'_inpost_head_script',TRUE);
|
226 |
-
|
227 |
-
// instead of writing HTML here, lets do an include
|
228 |
-
include(SHFS_PLUGIN_DIR . '/meta.php');
|
229 |
-
|
230 |
-
// create a custom nonce for submit verification later
|
231 |
-
echo '<input type="hidden" name="shfs_post_meta_noncename" value="' . wp_create_nonce(__FILE__) . '" />';
|
232 |
-
}
|
233 |
-
|
234 |
-
function shfs_post_meta_save($post_id)
|
235 |
-
{
|
236 |
-
// authentication checks
|
237 |
-
|
238 |
-
// make sure data came from our meta box
|
239 |
-
if ( ! isset( $_POST['shfs_post_meta_noncename'] )
|
240 |
-
|| !wp_verify_nonce($_POST['shfs_post_meta_noncename'],__FILE__)) return $post_id;
|
241 |
-
|
242 |
-
// check user permissions
|
243 |
-
if ($_POST['post_type'] == 'page')
|
244 |
-
{
|
245 |
-
if (!current_user_can('edit_page', $post_id)) return $post_id;
|
246 |
-
}
|
247 |
-
else
|
248 |
-
{
|
249 |
-
if (!current_user_can('edit_post', $post_id)) return $post_id;
|
250 |
-
}
|
251 |
-
|
252 |
-
$current_data = get_post_meta($post_id, '_inpost_head_script', TRUE);
|
253 |
-
|
254 |
-
$new_data = $_POST['_inpost_head_script'];
|
255 |
-
|
256 |
-
shfs_post_meta_clean($new_data);
|
257 |
-
|
258 |
-
if ($current_data)
|
259 |
-
{
|
260 |
-
if (is_null($new_data)) delete_post_meta($post_id,'_inpost_head_script');
|
261 |
-
else update_post_meta($post_id,'_inpost_head_script',$new_data);
|
262 |
-
}
|
263 |
-
elseif (!is_null($new_data))
|
264 |
-
{
|
265 |
-
add_post_meta($post_id,'_inpost_head_script',$new_data,TRUE);
|
266 |
-
}
|
267 |
-
|
268 |
-
return $post_id;
|
269 |
-
}
|
270 |
-
|
271 |
-
function shfs_post_meta_clean(&$arr)
|
272 |
-
{
|
273 |
-
if (is_array($arr))
|
274 |
-
{
|
275 |
-
foreach ($arr as $i => $v)
|
276 |
-
{
|
277 |
-
if (is_array($arr[$i]))
|
278 |
-
{
|
279 |
-
shfs_post_meta_clean($arr[$i]);
|
280 |
-
|
281 |
-
if (!count($arr[$i]))
|
282 |
-
{
|
283 |
-
unset($arr[$i]);
|
284 |
-
}
|
285 |
-
}
|
286 |
-
else
|
287 |
-
{
|
288 |
-
if (trim($arr[$i]) == '')
|
289 |
-
{
|
290 |
-
unset($arr[$i]);
|
291 |
-
}
|
292 |
-
}
|
293 |
-
}
|
294 |
-
|
295 |
-
if (!count($arr))
|
296 |
-
{
|
297 |
-
$arr = NULL;
|
298 |
-
}
|
299 |
-
}
|
300 |
-
}
|
301 |
-
|
302 |
-
|
303 |
-
add_action('wp_dashboard_setup', 'shfs_dashboard_widgets');
|
304 |
-
|
305 |
-
function shfs_dashboard_widgets() {
|
306 |
-
global $wp_meta_boxes;
|
307 |
-
wp_add_dashboard_widget('blogsynthesisshfswidget', 'Latest from BlogSynthesis', 'shfs_widget');
|
308 |
-
}
|
309 |
-
|
310 |
-
function shfs_widget() {
|
311 |
-
include_once( ABSPATH . WPINC . '/feed.php' );
|
312 |
-
|
313 |
-
$rss = fetch_feed( 'http://feeds2.feedburner.com/blogsynthesis' );
|
314 |
-
|
315 |
-
if ( ! is_wp_error( $rss ) ) :
|
316 |
-
|
317 |
-
// Figure out how many total items there are, but limit it to 10.
|
318 |
-
$maxitems = $rss->get_item_quantity( 10 );
|
319 |
-
|
320 |
-
// Build an array of all the items, starting with element 0 (first element).
|
321 |
-
$rss_items = $rss->get_items( 0, $maxitems );
|
322 |
-
|
323 |
-
endif;
|
324 |
-
|
325 |
-
{ ?>
|
326 |
-
<div class="rss-widget">
|
327 |
-
<a href="http://www.blogsynthesis.com/#utm_source=wpadmin&utm_medium=dashboardwidget&utm_term=newsitemlogo&utm_campaign=shfs" title="BlogSynthesis - For Bloggers" target="_blank"><img src="<?php echo plugin_dir_url( __FILE__ ); ?>images/blogsynthesis-100px.png" class="alignright" alt="BlogSynthesis"/></a>
|
328 |
-
<ul>
|
329 |
-
<?php if ( $maxitems == 0 ) : ?>
|
330 |
-
<li><?php _e( 'No items', 'shfs-text-domain' ); ?></li>
|
331 |
-
<?php else : ?>
|
332 |
-
<?php // Loop through each feed item and display each item as a hyperlink. ?>
|
333 |
-
<?php foreach ( $rss_items as $item ) : ?>
|
334 |
-
<li>
|
335 |
-
<a href="<?php echo esc_url( $item->get_permalink() ); ?>#utm_source=wpadmin&utm_medium=dashboardwidget&utm_term=newsitem&utm_campaign=shfs"
|
336 |
-
title="<?php printf( __( 'Posted %s', 'shfs-text-domain' ), $item->get_date('j F Y | g:i a') ); ?>" target="_blank">
|
337 |
-
<?php echo esc_html( $item->get_title() ); ?>
|
338 |
-
</a>
|
339 |
-
</li>
|
340 |
-
<?php endforeach; ?>
|
341 |
-
<?php endif; ?>
|
342 |
-
</ul>
|
343 |
-
<div style="border-top: 1px solid #ddd; padding-top: 10px; text-align:center;">
|
344 |
-
<span class="addthis_toolbox addthis_default_style" style="float:left;">
|
345 |
-
<a class="addthis_button_facebook_follow" addthis:userid="blogsynthesis"></a>
|
346 |
-
<a class="addthis_button_twitter_follow" addthis:userid="blogsynthesis"></a>
|
347 |
-
<a class="addthis_button_google_follow" addthis:userid="+BlogSynthesis"></a>
|
348 |
-
<a class="addthis_button_rss_follow" addthis:userid="http://feeds2.feedburner.com/blogsynthesis"></a>
|
349 |
-
</span>
|
350 |
-
|
351 |
-
<a href="http://www.blogsynthesis.com/newsletter/"><img src="<?php echo plugin_dir_url( __FILE__ ); ?>images/email-16px.png" alt="Subscribe via Email"/> Subscribe by email</a>
|
352 |
-
|
353 |
-
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-525ab1d176544441"></script>
|
354 |
-
</div>
|
355 |
-
</div>
|
356 |
-
<?php }
|
357 |
-
|
358 |
-
}
|
359 |
-
|
360 |
-
$shfs_header_and_footer_scripts = new HeaderAndFooterScripts();
|
361 |
-
|
362 |
-
}
|
363 |
-
|
364 |
-
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Plugin Name: Header and Footer Scripts
|
4 |
+
* Plugin URI: http://digitalliberation.org/plugins/header-and-footer-scripts
|
5 |
+
* Description: Allows you to insert code or text in the header or footer of your WordPress blog
|
6 |
+
* Version: 2.0.0
|
7 |
+
* Author: Anand Kumar
|
8 |
+
* Author URI: http://www.anandkumar.net
|
9 |
+
* Text Domain: header-and-footer-scripts
|
10 |
+
* Domain Path: /lang
|
11 |
+
* License: GPLv2 or later
|
12 |
+
*/
|
13 |
+
|
14 |
+
/*
|
15 |
+
Header and Footer Scripts
|
16 |
+
Copyright (C) 2013 - 2018, Anand Kumar <anand@anandkumar.net>
|
17 |
+
|
18 |
+
This program is free software; you can redistribute it and/or modify
|
19 |
+
it under the terms of the GNU General Public License, version 2, as
|
20 |
+
published by the Free Software Foundation.
|
21 |
+
|
22 |
+
This program is distributed in the hope that it will be useful,
|
23 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
24 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
25 |
+
GNU General Public License for more details.
|
26 |
+
|
27 |
+
You should have received a copy of the GNU General Public License
|
28 |
+
along with this program; if not, write to the Free Software
|
29 |
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
30 |
+
*/
|
31 |
+
|
32 |
+
define('SHFS_PLUGIN_DIR',str_replace('\\','/',dirname(__FILE__)));
|
33 |
+
|
34 |
+
if ( !class_exists( 'HeaderAndFooterScripts' ) ) {
|
35 |
+
|
36 |
+
class HeaderAndFooterScripts {
|
37 |
+
|
38 |
+
function __construct() {
|
39 |
+
|
40 |
+
add_action( 'init', array( &$this, 'init' ) );
|
41 |
+
add_action( 'admin_init', array( &$this, 'admin_init' ) );
|
42 |
+
add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
|
43 |
+
add_action( 'wp_head', array( &$this, 'wp_head' ) );
|
44 |
+
add_action( 'wp_footer', array( &$this, 'wp_footer' ) );
|
45 |
+
|
46 |
+
}
|
47 |
+
|
48 |
+
|
49 |
+
function init() {
|
50 |
+
load_plugin_textdomain( 'header-and-footer-scripts', false, dirname( plugin_basename ( __FILE__ ) ).'/lang' );
|
51 |
+
}
|
52 |
+
|
53 |
+
function admin_init() {
|
54 |
+
|
55 |
+
// register settings for sitewide script
|
56 |
+
register_setting( 'header-and-footer-scripts', 'shfs_insert_header', 'trim' );
|
57 |
+
register_setting( 'header-and-footer-scripts', 'shfs_insert_footer', 'trim' );
|
58 |
+
|
59 |
+
// add meta box to singgular post types
|
60 |
+
foreach (array('post','page') as $type)
|
61 |
+
{
|
62 |
+
add_meta_box('shfs_all_post_meta', esc_html__('Insert Script to <head>', 'header-and-footer-scripts'), 'shfs_meta_setup', $type, 'normal', 'high');
|
63 |
+
}
|
64 |
+
|
65 |
+
add_action('save_post','shfs_post_meta_save');
|
66 |
+
}
|
67 |
+
|
68 |
+
// adds menu item to wordpress admin dashboard
|
69 |
+
function admin_menu() {
|
70 |
+
$page = add_submenu_page( 'options-general.php', __('Header and Footer Scripts', 'header-and-footer-scripts'), __('Header and Footer Scripts', 'header-and-footer-scripts'), 'manage_options', __FILE__, array( &$this, 'shfs_options_panel' ) );
|
71 |
+
}
|
72 |
+
|
73 |
+
function wp_head() {
|
74 |
+
$meta = get_option( 'shfs_insert_header', '' );
|
75 |
+
if ( $meta != '' ) {
|
76 |
+
echo $meta, "\n";
|
77 |
+
}
|
78 |
+
|
79 |
+
$shfs_post_meta = get_post_meta( get_the_ID(), '_inpost_head_script' , TRUE );
|
80 |
+
if ( $shfs_post_meta != '' ) {
|
81 |
+
echo $shfs_post_meta['synth_header_script'], "\n";
|
82 |
+
}
|
83 |
+
|
84 |
+
}
|
85 |
+
|
86 |
+
function wp_footer() {
|
87 |
+
if ( !is_admin() && !is_feed() && !is_robots() && !is_trackback() ) {
|
88 |
+
$text = get_option( 'shfs_insert_footer', '' );
|
89 |
+
$text = convert_smilies( $text );
|
90 |
+
$text = do_shortcode( $text );
|
91 |
+
|
92 |
+
if ( $text != '' ) {
|
93 |
+
echo $text, "\n";
|
94 |
+
}
|
95 |
+
}
|
96 |
+
}
|
97 |
+
|
98 |
+
|
99 |
+
function fetch_rss_items( $num, $feed ) {
|
100 |
+
include_once( ABSPATH . WPINC . '/feed.php' );
|
101 |
+
$rss = fetch_feed( $feed );
|
102 |
+
|
103 |
+
// Bail if feed doesn't work
|
104 |
+
if ( !$rss || is_wp_error( $rss ) )
|
105 |
+
return false;
|
106 |
+
|
107 |
+
$rss_items = $rss->get_items( 0, $rss->get_item_quantity( $num ) );
|
108 |
+
|
109 |
+
// If the feed was erroneous
|
110 |
+
if ( !$rss_items ) {
|
111 |
+
$md5 = md5( $feed );
|
112 |
+
delete_transient( 'feed_' . $md5 );
|
113 |
+
delete_transient( 'feed_mod_' . $md5 );
|
114 |
+
$rss = fetch_feed( $feed );
|
115 |
+
$rss_items = $rss->get_items( 0, $rss->get_item_quantity( $num ) );
|
116 |
+
}
|
117 |
+
|
118 |
+
return $rss_items;
|
119 |
+
}
|
120 |
+
|
121 |
+
function shfs_options_panel() {
|
122 |
+
// Load options page
|
123 |
+
require_once(SHFS_PLUGIN_DIR . '/inc/options.php');
|
124 |
+
}
|
125 |
+
}
|
126 |
+
|
127 |
+
function shfs_meta_setup()
|
128 |
+
{
|
129 |
+
global $post;
|
130 |
+
|
131 |
+
// using an underscore, prevents the meta variable
|
132 |
+
// from showing up in the custom fields section
|
133 |
+
$meta = get_post_meta($post->ID,'_inpost_head_script',TRUE);
|
134 |
+
|
135 |
+
// instead of writing HTML here, lets do an include
|
136 |
+
include_once(SHFS_PLUGIN_DIR . '/inc/meta.php');
|
137 |
+
|
138 |
+
// create a custom nonce for submit verification later
|
139 |
+
echo '<input type="hidden" name="shfs_post_meta_noncename" value="' . wp_create_nonce(__FILE__) . '" />';
|
140 |
+
}
|
141 |
+
|
142 |
+
function shfs_post_meta_save($post_id)
|
143 |
+
{
|
144 |
+
// authentication checks
|
145 |
+
|
146 |
+
// make sure data came from our meta box
|
147 |
+
if ( ! isset( $_POST['shfs_post_meta_noncename'] )
|
148 |
+
|| !wp_verify_nonce($_POST['shfs_post_meta_noncename'],__FILE__)) return $post_id;
|
149 |
+
|
150 |
+
// check user permissions
|
151 |
+
if ($_POST['post_type'] == 'page')
|
152 |
+
{
|
153 |
+
if (!current_user_can('edit_page', $post_id)) return $post_id;
|
154 |
+
}
|
155 |
+
else
|
156 |
+
{
|
157 |
+
if (!current_user_can('edit_post', $post_id)) return $post_id;
|
158 |
+
}
|
159 |
+
|
160 |
+
$current_data = get_post_meta($post_id, '_inpost_head_script', TRUE);
|
161 |
+
|
162 |
+
$new_data = $_POST['_inpost_head_script'];
|
163 |
+
|
164 |
+
shfs_post_meta_clean($new_data);
|
165 |
+
|
166 |
+
if ($current_data)
|
167 |
+
{
|
168 |
+
if (is_null($new_data)) delete_post_meta($post_id,'_inpost_head_script');
|
169 |
+
else update_post_meta($post_id,'_inpost_head_script',$new_data);
|
170 |
+
}
|
171 |
+
elseif (!is_null($new_data))
|
172 |
+
{
|
173 |
+
add_post_meta($post_id,'_inpost_head_script',$new_data,TRUE);
|
174 |
+
}
|
175 |
+
|
176 |
+
return $post_id;
|
177 |
+
}
|
178 |
+
|
179 |
+
function shfs_post_meta_clean(&$arr)
|
180 |
+
{
|
181 |
+
if (is_array($arr))
|
182 |
+
{
|
183 |
+
foreach ($arr as $i => $v)
|
184 |
+
{
|
185 |
+
if (is_array($arr[$i]))
|
186 |
+
{
|
187 |
+
shfs_post_meta_clean($arr[$i]);
|
188 |
+
|
189 |
+
if (!count($arr[$i]))
|
190 |
+
{
|
191 |
+
unset($arr[$i]);
|
192 |
+
}
|
193 |
+
}
|
194 |
+
else
|
195 |
+
{
|
196 |
+
if (trim($arr[$i]) == '')
|
197 |
+
{
|
198 |
+
unset($arr[$i]);
|
199 |
+
}
|
200 |
+
}
|
201 |
+
}
|
202 |
+
|
203 |
+
if (!count($arr))
|
204 |
+
{
|
205 |
+
$arr = NULL;
|
206 |
+
}
|
207 |
+
}
|
208 |
+
}
|
209 |
+
|
210 |
+
$shfs_header_and_footer_scripts = new HeaderAndFooterScripts();
|
211 |
+
|
212 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|