Version Description
- Tested compatibility with WordPress 5.9
Download this release
Release Info
Developer | gripgrip |
Plugin | Insert Headers and Footers |
Version | 1.6.1 |
Comparing to | |
See all releases |
Code changes from version 1.6.0 to 1.6.1
- assets/js/admin/notice.js +89 -0
- assets/js/admin/notice.min.js +2 -0
- ihaf.php +67 -35
- inc/admin/class-review.php +245 -0
- readme.txt +20 -5
- views/sidebar.php +21 -1
assets/js/admin/notice.js
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* global ihaf_admin_notices */
|
2 |
+
|
3 |
+
/**
|
4 |
+
* IHAF Dismissible Notices.
|
5 |
+
*
|
6 |
+
* @since 1.6.1
|
7 |
+
*/
|
8 |
+
|
9 |
+
'use strict';
|
10 |
+
|
11 |
+
var IHAFAdminNotices = window.IHAFAdminNotices || (
|
12 |
+
function ( document, window, $ ) {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Public functions and properties.
|
16 |
+
*
|
17 |
+
* @since 1.6.1
|
18 |
+
*
|
19 |
+
* @type {object}
|
20 |
+
*/
|
21 |
+
var app = {
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Start the engine.
|
25 |
+
*
|
26 |
+
* @since 1.6.1
|
27 |
+
*/
|
28 |
+
init: function () {
|
29 |
+
|
30 |
+
$( app.ready );
|
31 |
+
},
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Document ready.
|
35 |
+
*
|
36 |
+
* @since 1.6.1
|
37 |
+
*/
|
38 |
+
ready: function () {
|
39 |
+
|
40 |
+
app.events();
|
41 |
+
},
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Dismissible notices events.
|
45 |
+
*
|
46 |
+
* @since 1.6.1
|
47 |
+
*/
|
48 |
+
events: function () {
|
49 |
+
|
50 |
+
$( document ).on(
|
51 |
+
'click',
|
52 |
+
'.ihaf-notice .notice-dismiss, .ihaf-notice .ihaf-notice-dismiss',
|
53 |
+
app.dismissNotice
|
54 |
+
);
|
55 |
+
},
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Dismiss notice event handler.
|
59 |
+
*
|
60 |
+
* @since 1.6.1
|
61 |
+
*
|
62 |
+
* @param {object} e Event object.
|
63 |
+
* */
|
64 |
+
dismissNotice: function ( e ) {
|
65 |
+
$.post(
|
66 |
+
ihaf_admin_notices.ajax_url,
|
67 |
+
{
|
68 |
+
action: 'ihaf_notice_dismiss',
|
69 |
+
nonce: ihaf_admin_notices.nonce,
|
70 |
+
}
|
71 |
+
);
|
72 |
+
|
73 |
+
var $el = $( e.target ).closest( '.ihaf-notice' );
|
74 |
+
// Do the same animation as the core one.
|
75 |
+
$el.fadeTo( 100, 0, function() {
|
76 |
+
$el.slideUp( 100, function() {
|
77 |
+
$el.remove();
|
78 |
+
} );
|
79 |
+
} );
|
80 |
+
},
|
81 |
+
};
|
82 |
+
|
83 |
+
return app;
|
84 |
+
|
85 |
+
}( document, window, jQuery )
|
86 |
+
);
|
87 |
+
|
88 |
+
// Initialize.
|
89 |
+
IHAFAdminNotices.init();
|
assets/js/admin/notice.min.js
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
"use strict";var IHAFAdminNotices=window.IHAFAdminNotices||function(document,window,$){var app={init:function(){$(app.ready)},ready:function(){app.events()},events:function(){$(document).on("click",".ihaf-notice .notice-dismiss, .ihaf-notice .ihaf-notice-dismiss",app.dismissNotice)},dismissNotice:function(e){$.post(ihaf_admin_notices.ajax_url,{action:"ihaf_notice_dismiss",nonce:ihaf_admin_notices.nonce});var $el=$(e.target).closest(".ihaf-notice");$el.fadeTo(100,0,function(){$el.slideUp(100,function(){$el.remove()})})}};return app}(document,window,jQuery);IHAFAdminNotices.init();
|
2 |
+
//# sourceMappingURL=notice.min.js.map
|
ihaf.php
CHANGED
@@ -1,16 +1,16 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Plugin Name: Insert Headers and Footers
|
4 |
-
* Plugin URI: http://www.wpbeginner.com/
|
5 |
-
* Version: 1.6.
|
6 |
-
* Requires at least: 4.6
|
7 |
-
* Requires PHP: 5.2
|
8 |
-
* Tested up to: 5.
|
9 |
-
* Author: WPBeginner
|
10 |
-
* Author URI: http://www.wpbeginner.com/
|
11 |
-
* Description: Allows you to insert code or text in the header or footer of your WordPress blog
|
12 |
-
* License: GPLv2 or later
|
13 |
-
*/
|
14 |
|
15 |
/* Copyright 2019 WPBeginner
|
16 |
|
@@ -29,13 +29,22 @@
|
|
29 |
*/
|
30 |
|
31 |
/**
|
32 |
-
* Insert Headers and Footers Class
|
33 |
-
*/
|
34 |
class InsertHeadersAndFooters {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
/**
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
$file_data = get_file_data( __FILE__, array( 'Version' => 'Version' ) );
|
40 |
|
41 |
// Plugin Details
|
@@ -49,6 +58,7 @@ class InsertHeadersAndFooters {
|
|
49 |
$this->body_open_supported = function_exists( 'wp_body_open' ) && version_compare( get_bloginfo( 'version' ), '5.2', '>=' );
|
50 |
|
51 |
// Hooks
|
|
|
52 |
add_action( 'admin_init', array( &$this, 'registerSettings' ) );
|
53 |
add_action( 'admin_enqueue_scripts', array( &$this, 'initCodeMirror' ) );
|
54 |
add_action( 'admin_menu', array( &$this, 'adminPanelsAndMetaBoxes' ) );
|
@@ -63,6 +73,19 @@ class InsertHeadersAndFooters {
|
|
63 |
}
|
64 |
}
|
65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
/**
|
67 |
* Show relevant notices for the plugin
|
68 |
*/
|
@@ -92,8 +115,8 @@ class InsertHeadersAndFooters {
|
|
92 |
}
|
93 |
|
94 |
/**
|
95 |
-
|
96 |
-
|
97 |
function registerSettings() {
|
98 |
register_setting( $this->plugin->name, 'ihaf_insert_header', 'trim' );
|
99 |
register_setting( $this->plugin->name, 'ihaf_insert_footer', 'trim' );
|
@@ -101,16 +124,16 @@ class InsertHeadersAndFooters {
|
|
101 |
}
|
102 |
|
103 |
/**
|
104 |
-
|
105 |
-
|
106 |
function adminPanelsAndMetaBoxes() {
|
107 |
add_submenu_page( 'options-general.php', $this->plugin->displayName, $this->plugin->displayName, 'manage_options', $this->plugin->name, array( &$this, 'adminPanel' ) );
|
108 |
}
|
109 |
|
110 |
/**
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
function adminPanel() {
|
115 |
/*
|
116 |
* Only users with manage_options can access this page.
|
@@ -202,32 +225,32 @@ class InsertHeadersAndFooters {
|
|
202 |
}
|
203 |
|
204 |
/**
|
205 |
-
|
206 |
-
|
207 |
function frontendHeader() {
|
208 |
$this->output( 'ihaf_insert_header' );
|
209 |
}
|
210 |
|
211 |
/**
|
212 |
-
|
213 |
-
|
214 |
function frontendFooter() {
|
215 |
$this->output( 'ihaf_insert_footer' );
|
216 |
}
|
217 |
|
218 |
/**
|
219 |
-
|
220 |
-
|
221 |
function frontendBody() {
|
222 |
$this->output( 'ihaf_insert_body' );
|
223 |
}
|
224 |
|
225 |
/**
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
function output( $setting ) {
|
232 |
// Ignore admin, feed, robots or trackbacks
|
233 |
if ( is_admin() || is_feed() || is_robots() || is_trackback() ) {
|
@@ -268,4 +291,13 @@ class InsertHeadersAndFooters {
|
|
268 |
}
|
269 |
}
|
270 |
|
271 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Plugin Name: Insert Headers and Footers
|
4 |
+
* Plugin URI: http://www.wpbeginner.com/
|
5 |
+
* Version: 1.6.1
|
6 |
+
* Requires at least: 4.6
|
7 |
+
* Requires PHP: 5.2
|
8 |
+
* Tested up to: 5.9
|
9 |
+
* Author: WPBeginner
|
10 |
+
* Author URI: http://www.wpbeginner.com/
|
11 |
+
* Description: Allows you to insert code or text in the header or footer of your WordPress blog
|
12 |
+
* License: GPLv2 or later
|
13 |
+
*/
|
14 |
|
15 |
/* Copyright 2019 WPBeginner
|
16 |
|
29 |
*/
|
30 |
|
31 |
/**
|
32 |
+
* Insert Headers and Footers Class
|
33 |
+
*/
|
34 |
class InsertHeadersAndFooters {
|
35 |
+
|
36 |
+
static $instance;
|
37 |
+
|
38 |
+
public static function get_instance() {
|
39 |
+
if ( ! isset( self::$instance ) ) {
|
40 |
+
self::$instance = new InsertHeadersAndFooters();
|
41 |
+
}
|
42 |
+
return self::$instance;
|
43 |
+
}
|
44 |
/**
|
45 |
+
* Constructor
|
46 |
+
*/
|
47 |
+
private function __construct() {
|
48 |
$file_data = get_file_data( __FILE__, array( 'Version' => 'Version' ) );
|
49 |
|
50 |
// Plugin Details
|
58 |
$this->body_open_supported = function_exists( 'wp_body_open' ) && version_compare( get_bloginfo( 'version' ), '5.2', '>=' );
|
59 |
|
60 |
// Hooks
|
61 |
+
add_action( 'plugins_loaded', array( $this, 'requireAdmin' ) );
|
62 |
add_action( 'admin_init', array( &$this, 'registerSettings' ) );
|
63 |
add_action( 'admin_enqueue_scripts', array( &$this, 'initCodeMirror' ) );
|
64 |
add_action( 'admin_menu', array( &$this, 'adminPanelsAndMetaBoxes' ) );
|
73 |
}
|
74 |
}
|
75 |
|
76 |
+
/**
|
77 |
+
* Require the admin files.
|
78 |
+
*
|
79 |
+
* @return void
|
80 |
+
*/
|
81 |
+
public function requireAdmin() {
|
82 |
+
if ( ! is_admin() ) {
|
83 |
+
// Only load in admin section.
|
84 |
+
return;
|
85 |
+
}
|
86 |
+
require_once $this->plugin->folder . 'inc/admin/class-review.php';
|
87 |
+
}
|
88 |
+
|
89 |
/**
|
90 |
* Show relevant notices for the plugin
|
91 |
*/
|
115 |
}
|
116 |
|
117 |
/**
|
118 |
+
* Register Settings
|
119 |
+
*/
|
120 |
function registerSettings() {
|
121 |
register_setting( $this->plugin->name, 'ihaf_insert_header', 'trim' );
|
122 |
register_setting( $this->plugin->name, 'ihaf_insert_footer', 'trim' );
|
124 |
}
|
125 |
|
126 |
/**
|
127 |
+
* Register the plugin settings panel
|
128 |
+
*/
|
129 |
function adminPanelsAndMetaBoxes() {
|
130 |
add_submenu_page( 'options-general.php', $this->plugin->displayName, $this->plugin->displayName, 'manage_options', $this->plugin->name, array( &$this, 'adminPanel' ) );
|
131 |
}
|
132 |
|
133 |
/**
|
134 |
+
* Output the Administration Panel
|
135 |
+
* Save POSTed data from the Administration Panel into a WordPress option
|
136 |
+
*/
|
137 |
function adminPanel() {
|
138 |
/*
|
139 |
* Only users with manage_options can access this page.
|
225 |
}
|
226 |
|
227 |
/**
|
228 |
+
* Outputs script / CSS to the frontend header
|
229 |
+
*/
|
230 |
function frontendHeader() {
|
231 |
$this->output( 'ihaf_insert_header' );
|
232 |
}
|
233 |
|
234 |
/**
|
235 |
+
* Outputs script / CSS to the frontend footer
|
236 |
+
*/
|
237 |
function frontendFooter() {
|
238 |
$this->output( 'ihaf_insert_footer' );
|
239 |
}
|
240 |
|
241 |
/**
|
242 |
+
* Outputs script / CSS to the frontend below opening body
|
243 |
+
*/
|
244 |
function frontendBody() {
|
245 |
$this->output( 'ihaf_insert_body' );
|
246 |
}
|
247 |
|
248 |
/**
|
249 |
+
* Outputs the given setting, if conditions are met
|
250 |
+
*
|
251 |
+
* @param string $setting Setting Name
|
252 |
+
* @return output
|
253 |
+
*/
|
254 |
function output( $setting ) {
|
255 |
// Ignore admin, feed, robots or trackbacks
|
256 |
if ( is_admin() || is_feed() || is_robots() || is_trackback() ) {
|
291 |
}
|
292 |
}
|
293 |
|
294 |
+
/**
|
295 |
+
* Instantiate the class a single time.
|
296 |
+
*
|
297 |
+
* @since 1.6.1
|
298 |
+
*/
|
299 |
+
function insert_headers_and_footers() {
|
300 |
+
return InsertHeadersAndFooters::get_instance();
|
301 |
+
}
|
302 |
+
|
303 |
+
insert_headers_and_footers();
|
inc/admin/class-review.php
ADDED
@@ -0,0 +1,245 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Review class.
|
5 |
+
*
|
6 |
+
* @since 1.6.1
|
7 |
+
*/
|
8 |
+
class IHAF_Review {
|
9 |
+
|
10 |
+
/**
|
11 |
+
* The HTML code for the review notice.
|
12 |
+
* Used to display the review notice at the proper time.
|
13 |
+
*
|
14 |
+
* @var string
|
15 |
+
*/
|
16 |
+
private $notice = '';
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Primary class constructor.
|
20 |
+
*
|
21 |
+
* @since 1.6.1
|
22 |
+
*/
|
23 |
+
public function __construct() {
|
24 |
+
|
25 |
+
// Admin notice requesting review.
|
26 |
+
add_action( 'admin_init', array( $this, 'review_request' ) );
|
27 |
+
add_action( 'wp_ajax_ihaf_notice_dismiss', array( $this, 'review_dismiss' ) );
|
28 |
+
add_action( 'admin_notices', array( $this, 'maybe_show_admin_notices' ) );
|
29 |
+
|
30 |
+
// Admin footer text.
|
31 |
+
add_filter( 'admin_footer_text', array( $this, 'admin_footer' ), 1, 2 );
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Add admin notices as needed for reviews.
|
36 |
+
*
|
37 |
+
* @since 1.6.1
|
38 |
+
*/
|
39 |
+
public function review_request() {
|
40 |
+
|
41 |
+
// Only consider showing the review request to admin users.
|
42 |
+
if ( ! is_super_admin() ) {
|
43 |
+
return;
|
44 |
+
}
|
45 |
+
|
46 |
+
// Verify that we can do a check for reviews.
|
47 |
+
$notices = get_option( 'ihaf_admin_notices', array() );
|
48 |
+
$time = time();
|
49 |
+
$load = false;
|
50 |
+
|
51 |
+
if ( empty( $notices['review_request'] ) ) {
|
52 |
+
$notices['review_request'] = array(
|
53 |
+
'time' => $time,
|
54 |
+
'dismissed' => false,
|
55 |
+
);
|
56 |
+
|
57 |
+
update_option( 'ihaf_admin_notices', $notices );
|
58 |
+
|
59 |
+
return;
|
60 |
+
}
|
61 |
+
|
62 |
+
// Check if it has been dismissed or not.
|
63 |
+
if ( ( isset( $notices['review_request']['dismissed'] ) && ! $notices['review_request']['dismissed'] ) ) {
|
64 |
+
$load = true;
|
65 |
+
}
|
66 |
+
|
67 |
+
// If we cannot load, return early.
|
68 |
+
if ( ! $load ) {
|
69 |
+
return;
|
70 |
+
}
|
71 |
+
|
72 |
+
// Show the notice.
|
73 |
+
$this->review_lite();
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Maybe show Lite review request.
|
78 |
+
*
|
79 |
+
* @since 1.6.1
|
80 |
+
*/
|
81 |
+
public function review_lite() {
|
82 |
+
|
83 |
+
// Fetch when plugin was initially installed.
|
84 |
+
$activated = get_option( 'ihaf_activated', array() );
|
85 |
+
|
86 |
+
if ( ! empty( $activated['lite'] ) ) {
|
87 |
+
// Only continue if plugin has been installed for at least 7 days.
|
88 |
+
if ( ( $activated['lite'] + ( DAY_IN_SECONDS * 7 ) ) > time() ) {
|
89 |
+
return;
|
90 |
+
}
|
91 |
+
} else {
|
92 |
+
$activated['lite'] = time();
|
93 |
+
|
94 |
+
update_option( 'ihaf_activated', $activated );
|
95 |
+
|
96 |
+
return;
|
97 |
+
}
|
98 |
+
|
99 |
+
// Only proceed with displaying if the user added a script using IHAF.
|
100 |
+
if ( ! $this->has_updated_settings() ) {
|
101 |
+
return;
|
102 |
+
}
|
103 |
+
|
104 |
+
ob_start();
|
105 |
+
|
106 |
+
// We have a candidate! Output a review message.
|
107 |
+
?>
|
108 |
+
<p><?php esc_html_e( 'Hey, I noticed you have been using Insert Headers and Footers for some time - that’s awesome! Could you please do me a BIG favor and give it a 5-star rating on WordPress to help us spread the word and boost our motivation?', 'insert-headers-and-footers' ); ?></p>
|
109 |
+
<p>
|
110 |
+
<strong><?php echo wp_kses( __( '~ Syed Balkhi<br>Founder of WPBeginner', 'insert-headers-and-footers' ), array( 'br' => array() ) ); ?></strong>
|
111 |
+
</p>
|
112 |
+
<p>
|
113 |
+
<a href="https://wordpress.org/support/plugin/insert-headers-and-footers/reviews/?filter=5#new-post" class="ihaf-notice-dismiss ihaf-review-out" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Ok, you deserve it', 'insert-headers-and-footers' ); ?></a><br>
|
114 |
+
<a href="#" class="ihaf-notice-dismiss" rel="noopener noreferrer"><?php esc_html_e( 'Nope, maybe later', 'insert-headers-and-footers' ); ?></a><br>
|
115 |
+
<a href="#" class="ihaf-notice-dismiss" rel="noopener noreferrer"><?php esc_html_e( 'I already did', 'insert-headers-and-footers' ); ?></a>
|
116 |
+
</p>
|
117 |
+
<?php
|
118 |
+
|
119 |
+
$this->notice = ob_get_clean();
|
120 |
+
// If we got this far, let's make sure we also load the needed js.
|
121 |
+
$this->add_enqueue_scripts_hook();
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* If the notice is available, show it.
|
126 |
+
*
|
127 |
+
* @return void
|
128 |
+
*/
|
129 |
+
public function maybe_show_admin_notices() {
|
130 |
+
if ( empty( $this->notice ) ) {
|
131 |
+
// If no notice to show, bail early.
|
132 |
+
return;
|
133 |
+
}
|
134 |
+
echo '<div class="ihaf-notice notice notice-info is-dismissible" id="ihaf-notice-review_request">';
|
135 |
+
echo '<p>' . $this->notice . '</p>';// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
136 |
+
echo '</div>';
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* Dismiss the review admin notice.
|
141 |
+
*
|
142 |
+
* @since 1.6.1
|
143 |
+
*/
|
144 |
+
public function review_dismiss() {
|
145 |
+
|
146 |
+
check_ajax_referer( 'ihaf_admin_notice', 'nonce' );
|
147 |
+
|
148 |
+
$notices = get_option( 'ihaf_admin_notices', array() );
|
149 |
+
|
150 |
+
$notices['review_request'] = array(
|
151 |
+
'time' => time(),
|
152 |
+
'dismissed' => true,
|
153 |
+
);
|
154 |
+
update_option( 'ihaf_admin_notices', $notices );
|
155 |
+
|
156 |
+
wp_send_json_success();
|
157 |
+
}
|
158 |
+
|
159 |
+
/**
|
160 |
+
* When user is on a IHAF related admin page, display footer text
|
161 |
+
* that graciously asks them to rate us.
|
162 |
+
*
|
163 |
+
* @param string $text Footer text.
|
164 |
+
*
|
165 |
+
* @return string
|
166 |
+
* @since 1.6.1
|
167 |
+
*
|
168 |
+
*/
|
169 |
+
public function admin_footer( $text ) {
|
170 |
+
|
171 |
+
global $current_screen;
|
172 |
+
|
173 |
+
if ( ! empty( $current_screen->id ) && strpos( $current_screen->id, 'insert-headers-and-footers' ) !== false ) {
|
174 |
+
$url = 'https://wordpress.org/support/plugin/insert-headers-and-footers/reviews/?filter=5#new-post';
|
175 |
+
$text = sprintf(
|
176 |
+
wp_kses( /* translators: $1$s - IHAF plugin name; $2$s - WP.org review link; $3$s - WP.org review link. */
|
177 |
+
__( 'Please rate %1$s <a href="%2$s" target="_blank" rel="noopener noreferrer">★★★★★</a> on <a href="%3$s" target="_blank" rel="noopener">WordPress.org</a> to help us spread the word. Thank you from the WPBeginner team!', 'insert-headers-and-footers' ),
|
178 |
+
array(
|
179 |
+
'a' => array(
|
180 |
+
'href' => array(),
|
181 |
+
'target' => array(),
|
182 |
+
'rel' => array(),
|
183 |
+
),
|
184 |
+
)
|
185 |
+
),
|
186 |
+
'<strong>Insert Headers and Footers</strong>',
|
187 |
+
$url,
|
188 |
+
$url
|
189 |
+
);
|
190 |
+
}
|
191 |
+
|
192 |
+
return $text;
|
193 |
+
}
|
194 |
+
|
195 |
+
/**
|
196 |
+
* Checks if the uses the plugin to load any scripts.
|
197 |
+
*
|
198 |
+
* @return bool
|
199 |
+
*/
|
200 |
+
public function has_updated_settings() {
|
201 |
+
$header_option = get_option( 'ihaf_insert_header' );
|
202 |
+
if ( ! empty( $header_option ) ) {
|
203 |
+
return true;
|
204 |
+
}
|
205 |
+
$body_option = get_option( 'ihaf_insert_body' );
|
206 |
+
if ( ! empty( $body_option ) ) {
|
207 |
+
return true;
|
208 |
+
}
|
209 |
+
$footer_option = get_option( 'ihaf_insert_footer' );
|
210 |
+
if ( ! empty( $footer_option ) ) {
|
211 |
+
return true;
|
212 |
+
}
|
213 |
+
|
214 |
+
return false;
|
215 |
+
}
|
216 |
+
|
217 |
+
/**
|
218 |
+
* Just adds an action to admin_enqueue_scripts.
|
219 |
+
*
|
220 |
+
* @return void
|
221 |
+
*/
|
222 |
+
public function add_enqueue_scripts_hook() {
|
223 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
|
224 |
+
}
|
225 |
+
|
226 |
+
/**
|
227 |
+
* Enqueue scripts needed to dismiss the admin notice.
|
228 |
+
*
|
229 |
+
* @return void
|
230 |
+
*/
|
231 |
+
public function enqueue_scripts() {
|
232 |
+
wp_enqueue_script( 'ihaf-admin-notice', insert_headers_and_footers()->plugin->url . 'assets/js/admin/notice.min.js', array( 'jquery' ), insert_headers_and_footers()->plugin->version, true );
|
233 |
+
wp_localize_script(
|
234 |
+
'ihaf-admin-notice',
|
235 |
+
'ihaf_admin_notices',
|
236 |
+
array(
|
237 |
+
'ajax_url' => admin_url( 'admin-ajax.php' ),
|
238 |
+
'nonce' => wp_create_nonce( 'ihaf_admin_notice' ),
|
239 |
+
)
|
240 |
+
);
|
241 |
+
}
|
242 |
+
|
243 |
+
}
|
244 |
+
|
245 |
+
new IHAF_Review();
|
readme.txt
CHANGED
@@ -2,9 +2,9 @@
|
|
2 |
Contributors: WPbeginner, smub, deb255
|
3 |
Tags: code, content, css, facebook pixel, 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: 4.6
|
5 |
-
Tested up to: 5.
|
6 |
Requires PHP: 5.2
|
7 |
-
Stable tag: 1.6.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -36,9 +36,21 @@ This plugin is created by <a href="https://syedbalkhi.com/" rel="friend" title="
|
|
36 |
|
37 |
If you find this plugin useful to insert header and footer scripts, please leave a good rating and consider checking out our other projects:
|
38 |
|
39 |
-
* <a href="http://optinmonster.com/" rel="friend" title="OptinMonster">OptinMonster</a> - Get
|
40 |
-
* <a href="http://wpforms.com/" rel="friend" title="WPForms">WPForms</a> -
|
41 |
-
* <a href="http://monsterinsights.com/" rel="friend" title="MonsterInsights">MonsterInsights</a> - Best Google Analytics
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
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:
|
44 |
|
@@ -86,6 +98,9 @@ Syed Balkhi
|
|
86 |
|
87 |
== Changelog ==
|
88 |
|
|
|
|
|
|
|
89 |
= 1.6.0 =
|
90 |
* Fix: Only show settings CTA to users able to visit the settings page.
|
91 |
* Enhancement: Improve settings page user experience on heavily customized WordPress installs.
|
2 |
Contributors: WPbeginner, smub, deb255
|
3 |
Tags: code, content, css, facebook pixel, 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: 4.6
|
5 |
+
Tested up to: 5.9
|
6 |
Requires PHP: 5.2
|
7 |
+
Stable tag: 1.6.1
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
36 |
|
37 |
If you find this plugin useful to insert header and footer scripts, please leave a good rating and consider checking out our other projects:
|
38 |
|
39 |
+
* <a href="http://optinmonster.com/" rel="friend" title="OptinMonster">OptinMonster</a> - Get more email subscribers with the most popular conversion optimization plugin for WordPress.
|
40 |
+
* <a href="http://wpforms.com/" rel="friend" title="WPForms">WPForms</a> - #1 drag & drop online form builder for WordPress (trusted by 5 million sites).
|
41 |
+
* <a href="http://www.monsterinsights.com/" rel="friend" title="MonsterInsights">MonsterInsights</a> - See the stats that matter and grow your business with confidence. Best Google Analytics plugin for WordPress.
|
42 |
+
* <a href="https://www.seedprod.com/" rel="friend" title="SeedProd">SeedProd</a> - Create beautiful landing pages with our powerful drag & drop landing page builder.
|
43 |
+
* <a href="https://wpmailsmtp.com/" rel="friend" title="WP Mail SMTP">WP Mail SMTP</a> - Improve email deliverability for your contact form with the most popular SMTP plugin for WordPress.
|
44 |
+
* <a href="https://rafflepress.com/" rel="friend" title="RafflePress">RafflePress</a> - Best WordPress giveaway and contest plugin to grow traffic and social followers.
|
45 |
+
* <a href="https://smashballoon.com/" rel="friend" title="Smash Balloon">Smash Balloon</a> - #1 social feeds plugin for WordPress - display social media content in WordPress without code.
|
46 |
+
* <a href="https://aioseo.com/" rel="friend" title="AIOSEO">AIOSEO</a> - The original WordPress SEO plugin to help you rank higher in search results (trusted by over 3 million sites).
|
47 |
+
* <a href="https://www.pushengage.com/" rel="friend" title="PushEngage">PushEngage</a> - Connect with visitors after they leave your website with the leading web push notification plugin.
|
48 |
+
* <a href="https://www.trustpulse.com/" rel="friend" title="TrustPulse">TrustPulse</a> - Add real-time social proof notifications to boost your store conversions by up to 15%.
|
49 |
+
* <a href="https://searchwp.com/" rel="friend" title="SearchWP">SearchWP</a> - The most advanced custom WordPress search plugin to improve WordPress search quality.
|
50 |
+
* <a href="https://affiliatewp.com/" rel="friend" title="AffiliateWP">AffiliateWP</a> - #1 affiliate management plugin for WordPress. Add a referral program to your online store.
|
51 |
+
* <a href="https://wpsimplepay.com/" rel="friend" title="WP Simple Pay">WP Simple Pay</a> - #1 Stripe payments plugin for WordPress. Start accepting one-time or recurring payments without a shopping cart.
|
52 |
+
* <a href="https://easydigitaldownloads.com/" rel="friend" title="Easy Digital Downloads">Easy Digital Downloads</a> - The best WordPress eCommerce plugin to sell digital products (eBooks, software, music, and more).
|
53 |
+
* <a href="https://sugarcalendar.com/" rel="friend" title="Sugar Calendar">Sugar Calendar</a> - A simple event calendar plugin for WordPress that’s both easy and powerful.
|
54 |
|
55 |
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:
|
56 |
|
98 |
|
99 |
== Changelog ==
|
100 |
|
101 |
+
= 1.6.1 =
|
102 |
+
* Tested compatibility with WordPress 5.9
|
103 |
+
|
104 |
= 1.6.0 =
|
105 |
* Fix: Only show settings CTA to users able to visit the settings page.
|
106 |
* Enhancement: Improve settings page user experience on heavily customized WordPress installs.
|
views/sidebar.php
CHANGED
@@ -93,7 +93,27 @@
|
|
93 |
'<a href="%1$s" target="_blank">%2$s</a> - %3$s',
|
94 |
esc_url( 'https://www.seedprod.com/' ),
|
95 |
esc_html__( 'SeedProd', 'insert-headers-and-footers' ),
|
96 |
-
esc_html__( 'Get the best
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
);
|
98 |
?>
|
99 |
</p>
|
93 |
'<a href="%1$s" target="_blank">%2$s</a> - %3$s',
|
94 |
esc_url( 'https://www.seedprod.com/' ),
|
95 |
esc_html__( 'SeedProd', 'insert-headers-and-footers' ),
|
96 |
+
esc_html__( 'Get the best Drag & Drop WordPress Website Builder', 'insert-headers-and-footers' )
|
97 |
+
);
|
98 |
+
?>
|
99 |
+
</p>
|
100 |
+
<p>
|
101 |
+
<?php
|
102 |
+
printf(
|
103 |
+
'<a href="%1$s" target="_blank">%2$s</a> - %3$s',
|
104 |
+
esc_url( 'https://wordpress.org/plugins/all-in-one-seo-pack/' ),
|
105 |
+
esc_html__( 'AIOSEO', 'insert-headers-and-footers' ),
|
106 |
+
esc_html__( 'Best WordPress SEO plugin (used by 3 million sites).', 'insert-headers-and-footers' )
|
107 |
+
);
|
108 |
+
?>
|
109 |
+
</p>
|
110 |
+
<p>
|
111 |
+
<?php
|
112 |
+
printf(
|
113 |
+
'<a href="%1$s" target="_blank">%2$s</a> - %3$s',
|
114 |
+
esc_url( 'https://wordpress.org/plugins/wp-mail-smtp/' ),
|
115 |
+
esc_html__( 'WP Mail SMTP', 'insert-headers-and-footers' ),
|
116 |
+
esc_html__( 'Fix WordPress email deliverability with the best SMTP plugin.', 'insert-headers-and-footers' )
|
117 |
);
|
118 |
?>
|
119 |
</p>
|