Redirect 404 To Homepage - Version 1.0.7

Version Description

  • optimize plugin code
  • updated recommended plugins
  • added rating request
Download this release

Release Info

Developer littlebizzy
Plugin Icon 128x128 Redirect 404 To Homepage
Version 1.0.7
Comparing to
See all releases

Code changes from version 1.0.6 to 1.0.7

Files changed (3) hide show
  1. 404-to-homepage.php +8 -16
  2. admin-notices.php +355 -53
  3. readme.txt +32 -10
404-to-homepage.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: 404 To Homepage
4
  Plugin URI: https://www.littlebizzy.com/plugins/404-to-homepage
5
  Description: Redirects all 404 (Not Found) errors to the homepage for a better user experience, less abuse from bots, and 100% elimination of Google GSC warnings.
6
- Version: 1.0.6
7
  Author: LittleBizzy
8
  Author URI: https://www.littlebizzy.com
9
  License: GPLv3
@@ -11,17 +11,21 @@ License URI: http://www.gnu.org/licenses/gpl-3.0.html
11
  Prefix: NTFTHP
12
  */
13
 
 
 
 
 
14
 
15
  /* Initialization */
16
 
17
- // Avoid script calls via plugin URL
18
  if (!function_exists('add_action'))
19
  die;
20
 
21
- // This plugin constants
22
  define('NTFTHP_FILE', __FILE__);
23
  define('NTFTHP_PATH', dirname(NTFTHP_FILE));
24
- define('NTFTHP_VERSION', '1.0.6');
25
 
26
 
27
  /* 404 hooks */
@@ -57,15 +61,3 @@ function ntfthp_wp() {
57
  NTFTHP_Redirect::go();
58
  }
59
  }
60
-
61
-
62
- /* Plugin suggestions */
63
-
64
- // Admin loader
65
- if (is_admin()) {
66
- $timestamp = (int) get_option('ntfhp_dismissed_on');
67
- if (empty($timestamp) || (time() - $timestamp) > (180 * 86400)) {
68
- require_once(NTFTHP_PATH.'/admin-notices.php');
69
- NTFTHP_Admin_Suggestions::instance();
70
- }
71
- }
3
  Plugin Name: 404 To Homepage
4
  Plugin URI: https://www.littlebizzy.com/plugins/404-to-homepage
5
  Description: Redirects all 404 (Not Found) errors to the homepage for a better user experience, less abuse from bots, and 100% elimination of Google GSC warnings.
6
+ Version: 1.0.7
7
  Author: LittleBizzy
8
  Author URI: https://www.littlebizzy.com
9
  License: GPLv3
11
  Prefix: NTFTHP
12
  */
13
 
14
+ // Admin Notices module
15
+ require_once dirname(__FILE__).'/admin-notices.php';
16
+ NTFTHP_Admin_Notices::instance(__FILE__);
17
+
18
 
19
  /* Initialization */
20
 
21
+ // Block direct calls
22
  if (!function_exists('add_action'))
23
  die;
24
 
25
+ // Plugin constants
26
  define('NTFTHP_FILE', __FILE__);
27
  define('NTFTHP_PATH', dirname(NTFTHP_FILE));
28
+ define('NTFTHP_VERSION', '1.0.7');
29
 
30
 
31
  /* 404 hooks */
61
  NTFTHP_Redirect::go();
62
  }
63
  }
 
 
 
 
 
 
 
 
 
 
 
 
admin-notices.php CHANGED
@@ -1,32 +1,41 @@
1
  <?php
2
 
3
  /**
4
- * 404 To Homepage - Plugins Suggestions class
5
  *
6
- * @package 404 To Homepage
7
- * @subpackage 404 To Homepage Admin
8
  */
9
- final class NTFTHP_Admin_Suggestions {
10
 
11
 
12
 
13
- // Properties
14
  // ---------------------------------------------------------------------------------------------------
15
 
16
 
17
 
18
  /**
19
- * Single class instance
20
  */
21
- private static $instance;
 
 
 
22
 
23
 
24
 
25
  /**
26
- * Plugins directories
27
  */
28
- private $missing;
29
- private $required = array(
 
 
 
 
 
 
30
  'remove-query-strings-littlebizzy' => array(
31
  'name' => 'Remove Query Strings',
32
  'desc' => 'Removes all query strings from static resources meaning that proxy servers and beyond can better cache your site content (plus, better SEO scores).',
@@ -37,25 +46,80 @@ final class NTFTHP_Admin_Suggestions {
37
  'desc' => 'Completely disables the category base from all URLs generated by WordPress so that there is no category slug displayed on archive permalinks, etc.',
38
  'filename' => 'remove-category-base.php',
39
  ),
40
- 'force-https-littlebizzy' => array(
41
- 'name' => 'Force HTTPS',
42
- 'desc' => 'Redirects all HTTP requests to the HTTPS version and fixes all insecure static resources by implementing relative URLs without altering the database.',
43
- 'filename' => 'force-https.php',
 
 
 
 
 
44
  ),
45
  'disable-emojis-littlebizzy' => array(
46
  'name' => 'Disable Emojis',
47
  'desc' => 'Completely disables both the old and new versions of WordPress emojis, removes the corresponding javascript calls, and improves page loading times.',
48
  'filename' => 'disable-emojis.php',
49
  ),
50
- 'server-status-littlebizzy' => array(
51
- 'name' => 'Server Status',
52
- 'desc' => 'Useful statistics about the server OS, CPU, RAM, load average, memory usage, IP address, hostname, timezone, disk space, PHP, MySQL, caches, etc.',
53
- 'filename' => 'server-status.php',
 
 
 
 
 
 
 
 
 
 
54
  ),
 
 
 
 
 
 
55
  );
56
 
57
 
58
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  // Initialization
60
  // ---------------------------------------------------------------------------------------------------
61
 
@@ -64,11 +128,15 @@ final class NTFTHP_Admin_Suggestions {
64
  /**
65
  * Create or retrieve instance
66
  */
67
- public static function instance() {
 
 
 
 
68
 
69
  // Check instance
70
  if (!isset(self::$instance))
71
- self::$instance = new NTFTHP_Admin_Suggestions;
72
 
73
  // Done
74
  return self::$instance;
@@ -77,61 +145,117 @@ final class NTFTHP_Admin_Suggestions {
77
 
78
 
79
  /**
80
- * Constructor
81
- */
82
- private function __construct() {
 
 
 
83
 
84
- // Check AJAX submit
85
- if (defined('DOING_AJAX') && DOING_AJAX) {
86
- add_action( 'wp_ajax_ntfhp_dismiss', array(&$this, 'dismiss'));
87
 
88
- // Admin area (except install or activate plugins page)
89
- } elseif (!in_array(basename($_SERVER['PHP_SELF']), array('plugins.php', 'plugin-install.php', 'update.php'))) {
 
90
 
91
- // Admin hooks
92
- add_action('admin_footer', array(&$this, 'admin_footer'));
93
- add_action('plugins_loaded', array(&$this, 'plugins_loaded'));
 
 
94
  }
95
  }
96
 
97
 
98
 
 
 
 
 
 
99
  /**
100
- * Footer script
101
  */
102
- public function admin_footer() { ?>
103
- <script type="text/javascript">jQuery(function($) { $(document).on('click', '.ntfhp-dismiss .notice-dismiss', function() { $.post(ajaxurl, {'action':'ntfhp_dismiss','nonce':$(this).parent().attr('data-nonce')}); }); });</script>
104
- <?php }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
 
106
 
107
 
108
  /**
109
- * Dismissi timestamp
110
  */
111
- public function dismiss() {
112
- if (!empty($_POST['nonce']) && wp_verify_nonce($_POST['nonce'], NTFTHP_FILE.'-dismiss'))
113
- update_option('ntfhp_dismissed_on', time(), true);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  }
115
 
116
 
117
 
118
- // Plugins check
119
  // ---------------------------------------------------------------------------------------------------
120
 
121
 
122
 
123
  /**
124
- * Admin notices
125
  */
126
- public function admin_notices() {
127
 
128
- ?><div class="ntfhp-dismiss notice notice-success is-dismissible" data-nonce="<?php echo wp_create_nonce(NTFTHP_FILE.'-dismiss'); ?>">
129
 
130
- <p>404 To Homepage recommends the following free plugins:</p>
 
 
131
 
132
  <ul><?php foreach ($this->missing as $plugin) : ?>
133
 
134
- <li><strong><?php echo $this->required[$plugin]['name']; ?></strong> <a href="<?php echo esc_url($this->get_install_url($plugin)); ?>">Install now!</a><br /><?php echo $this->required[$plugin]['desc']; ?></li>
135
 
136
  <?php endforeach; ?></ul>
137
 
@@ -140,18 +264,63 @@ final class NTFTHP_Admin_Suggestions {
140
 
141
 
142
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143
  /**
144
  * Check current active plugins
145
  */
146
  public function plugins_loaded() {
147
 
148
- // Check missing plugins
149
  $this->missing = $this->get_missing_plugins();
150
- if (empty($this->missing) || !is_array($this->missing))
151
- return;
152
-
153
- // Notice action
154
- add_action('admin_notices', array(&$this, 'admin_notices'));
155
  }
156
 
157
 
@@ -167,7 +336,7 @@ final class NTFTHP_Admin_Suggestions {
167
  // Check plugins directory
168
  $directories = array_merge(self::get_mu_plugins_directories(), self::get_plugins_directories());
169
  if (!empty($directories)) {
170
- $required = array_keys($this->required);
171
  foreach ($required as $plugin) {
172
  if (!in_array($plugin, $directories))
173
  $inactive[] = $plugin;
@@ -267,7 +436,7 @@ final class NTFTHP_Admin_Suggestions {
267
  if ($exists) {
268
 
269
  // Existing plugin
270
- $path = $plugin.'/'.$this->required[$plugin]['filename'];
271
  return admin_url('plugins.php?action=activate&plugin='.$path.'&_wpnonce='.wp_create_nonce('activate-plugin_'.$path));
272
 
273
  // Install
@@ -280,4 +449,137 @@ final class NTFTHP_Admin_Suggestions {
280
 
281
 
282
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
283
  }
1
  <?php
2
 
3
  /**
4
+ * Admin Notices class
5
  *
6
+ * @package WordPress
7
+ * @subpackage Admin Notices
8
  */
9
+ final class NTFTHP_Admin_Notices {
10
 
11
 
12
 
13
+ // Configuration
14
  // ---------------------------------------------------------------------------------------------------
15
 
16
 
17
 
18
  /**
19
+ * Rate Us
20
  */
21
+ private $days_before_display_rate_us = 3;
22
+ private $days_dismissing_rate_us = 240; // 8 months
23
+ private $rate_us_url = 'https://wordpress.org/support/plugin/404-to-homepage-littlebizzy/reviews/#new-post';
24
+ private $rate_us_message = 'Thanks for using <strong>%plugin%</strong>. Please support our free work by rating this plugin with 5 stars on WordPress.org. <a href="%url%" target="_blank">Click here to rate us.</a>';
25
 
26
 
27
 
28
  /**
29
+ * Plugin suggestions
30
  */
31
+ private $days_dismissing_suggestions = 150; // 5 months
32
+ private $suggestions_message = '%plugin% recommends the following free plugins:';
33
+ private $suggestions = array(
34
+ 'force-https-littlebizzy' => array(
35
+ 'name' => 'Force HTTPS',
36
+ 'desc' => 'Redirects all HTTP requests to the HTTPS version and fixes all insecure static resources without altering the database (also works with CloudFlare).',
37
+ 'filename' => 'force-https.php',
38
+ ),
39
  'remove-query-strings-littlebizzy' => array(
40
  'name' => 'Remove Query Strings',
41
  'desc' => 'Removes all query strings from static resources meaning that proxy servers and beyond can better cache your site content (plus, better SEO scores).',
46
  'desc' => 'Completely disables the category base from all URLs generated by WordPress so that there is no category slug displayed on archive permalinks, etc.',
47
  'filename' => 'remove-category-base.php',
48
  ),
49
+ 'server-status-littlebizzy' => array(
50
+ 'name' => 'Server Status',
51
+ 'desc' => 'Useful statistics about the server OS, CPU, RAM, load average, memory usage, IP address, hostname, timezone, disk space, PHP, MySQL, caches, etc.',
52
+ 'filename' => 'server-status.php',
53
+ ),
54
+ 'disable-embeds-littlebizzy' => array(
55
+ 'name' => 'Disable Embeds',
56
+ 'desc' => 'Disables both external and internal embedding functions to avoid slow page render, instability and SEO issues, and to improve overall loading speed.',
57
+ 'filename' => 'disable-embeds.php',
58
  ),
59
  'disable-emojis-littlebizzy' => array(
60
  'name' => 'Disable Emojis',
61
  'desc' => 'Completely disables both the old and new versions of WordPress emojis, removes the corresponding javascript calls, and improves page loading times.',
62
  'filename' => 'disable-emojis.php',
63
  ),
64
+ 'disable-xml-rpc-littlebizzy' => array(
65
+ 'name' => 'Disable XML-RPC',
66
+ 'desc' => 'Completely disables all XML-RPC related functions in WordPress including pingbacks and trackbacks, and helps prevent attacks on the xmlrpc.php file.',
67
+ 'filename' => 'disable-xml-rpc.php',
68
+ ),
69
+ 'disable-author-pages-littlebizzy' => array(
70
+ 'name' => 'Disable Author Pages',
71
+ 'desc' => 'Completely disables author archives which then become 404 errors, converts author links to homepage links, and works with or without fancy permalinks.',
72
+ 'filename' => 'disable-author-pages.php',
73
+ ),
74
+ 'disable-search-littlebizzy' => array(
75
+ 'name' => 'Disable Search',
76
+ 'desc' => 'Completely disables the built-in WordPress search function to prevent snoopers or bots from querying your database or slowing down your website.',
77
+ 'filename' => 'disable-search.php',
78
  ),
79
+ 'virtual-robotstxt-littlebizzy' => array(
80
+ 'name' => 'Virtual Robots.txt',
81
+ 'desc' => 'Replaces the default virtual robots.txt generated by WordPress with an editable one, and deletes any physical robots.txt file that may already exist.',
82
+ 'filename' => 'virtual-robotstxt.php',
83
+ ),
84
+
85
  );
86
 
87
 
88
 
89
+ // Properties
90
+ // ---------------------------------------------------------------------------------------------------
91
+
92
+
93
+
94
+ /**
95
+ * Store missing plugins
96
+ */
97
+ private $missing;
98
+
99
+
100
+
101
+ /**
102
+ * Default prefix
103
+ * Can be changed by the external initialization.
104
+ */
105
+ private $prefix = 'lbladn';
106
+
107
+
108
+
109
+ /**
110
+ * Caller plugin file
111
+ */
112
+ private $plugin_file;
113
+
114
+
115
+
116
+ /**
117
+ * Single class instance
118
+ */
119
+ private static $instance;
120
+
121
+
122
+
123
  // Initialization
124
  // ---------------------------------------------------------------------------------------------------
125
 
128
  /**
129
  * Create or retrieve instance
130
  */
131
+ public static function instance($plugin_file = null) {
132
+
133
+ // Avoid direct calls
134
+ if (!function_exists('add_action'))
135
+ die;
136
 
137
  // Check instance
138
  if (!isset(self::$instance))
139
+ self::$instance = new self($plugin_file);
140
 
141
  // Done
142
  return self::$instance;
145
 
146
 
147
  /**
148
+ * Constructor
149
+ */
150
+ private function __construct($plugin_file = null) {
151
+
152
+ // Main plugin file
153
+ $this->plugin_file = isset($plugin_file)? $plugin_file : __FILE__;
154
 
155
+ // Uninstall hook endpoint
156
+ register_uninstall_hook($this->plugin_file, array(__CLASS__, 'uninstall'));
 
157
 
158
+ // Prefix from the class name
159
+ $classname = explode('_', __CLASS__);
160
+ $this->prefix = strtolower($classname[0]);
161
 
162
+ // Check notices
163
+ if (is_admin()) {
164
+ $this->check_timestamps();
165
+ $this->check_suggestions();
166
+ $this->check_rate_us();
167
  }
168
  }
169
 
170
 
171
 
172
+ // Timestamp checks
173
+ // ---------------------------------------------------------------------------------------------------
174
+
175
+
176
+
177
  /**
178
+ * Creates the activation timestamp only if it does not exist
179
  */
180
+ private function check_timestamps() {
181
+ $timestamp =$this->get_activation_timestamp();
182
+ if (empty($timestamp))
183
+ $this->update_activation_timestamp();
184
+ }
185
+
186
+
187
+
188
+ /**
189
+ * Check the suggestions dismissed timestamp
190
+ */
191
+ private function check_suggestions() {
192
+
193
+ // Compare timestamp
194
+ $timestamp = $this->get_dismissed_timestamp('suggestions');
195
+ if (empty($timestamp) || (time() - $timestamp) > ($this->days_dismissing_suggestions * 86400)) {
196
+
197
+ // Check AJAX submit
198
+ if (defined('DOING_AJAX') && DOING_AJAX) {
199
+ add_action('wp_ajax_'.$this->prefix.'_dismiss_suggestions', array(&$this, 'dismiss_suggestions'));
200
+
201
+ // Admin area (except install or activate plugins page)
202
+ } elseif (!in_array(basename($_SERVER['PHP_SELF']), array('plugins.php', 'plugin-install.php', 'update.php'))) {
203
+ add_action('plugins_loaded', array(&$this, 'plugins_loaded'));
204
+ }
205
+ }
206
+ }
207
 
208
 
209
 
210
  /**
211
+ * Check the rate us dismissed timestamp
212
  */
213
+ private function check_rate_us() {
214
+
215
+ // Check plugin activation timestamp
216
+ $timestamp = $this->get_activation_timestamp();
217
+ if (!empty($timestamp) && (time() - $timestamp) > ($this->days_before_display_rate_us * 86400)) {
218
+
219
+ // Compare dismissed timestamp
220
+ $timestamp = $this->get_dismissed_timestamp('rate_us');
221
+ if (empty($timestamp) || (time() - $timestamp) > ($this->days_dismissing_rate_us * 86400)) {
222
+
223
+ // Check AJAX submit
224
+ if (defined('DOING_AJAX') && DOING_AJAX) {
225
+ add_action('wp_ajax_'.$this->prefix.'_dismiss_rate_us', array(&$this, 'dismiss_rate_us'));
226
+
227
+ // Admin area (except install or activate plugins page)
228
+ } elseif (!in_array(basename($_SERVER['PHP_SELF']), array('plugins.php', 'plugin-install.php', 'update.php'))) {
229
+
230
+ // Admin hooks
231
+ add_action('admin_footer', array(&$this, 'admin_footer_rate_us'));
232
+ add_action('admin_notices', array(&$this, 'admin_notices_rate_us'));
233
+ }
234
+ }
235
+ }
236
  }
237
 
238
 
239
 
240
+ // Admin Notices display
241
  // ---------------------------------------------------------------------------------------------------
242
 
243
 
244
 
245
  /**
246
+ * Suggestions display
247
  */
248
+ public function admin_notices_suggestions() {
249
 
250
+ $plugin_data = get_plugin_data($this->plugin_file);
251
 
252
+ ?><div class="<?php echo esc_attr($this->prefix); ?>-dismiss-suggestions notice notice-success is-dismissible" data-nonce="<?php echo esc_attr(wp_create_nonce($this->prefix.'-dismiss-suggestions')); ?>">
253
+
254
+ <p><?php echo str_replace('%plugin%', $plugin_data['Name'], $this->suggestions_message); ?></p>
255
 
256
  <ul><?php foreach ($this->missing as $plugin) : ?>
257
 
258
+ <li><strong><?php echo $this->suggestions[$plugin]['name']; ?></strong> <a href="<?php echo esc_url($this->get_install_url($plugin)); ?>">Install now!</a><br /><?php echo $this->suggestions[$plugin]['desc']; ?></li>
259
 
260
  <?php endforeach; ?></ul>
261
 
264
 
265
 
266
 
267
+ /**
268
+ * Rate Us display
269
+ */
270
+ public function admin_notices_rate_us() {
271
+
272
+ $plugin_data = get_plugin_data($this->plugin_file);
273
+
274
+ ?><div class="<?php echo esc_attr($this->prefix); ?>-dismiss-rate-us notice notice-success is-dismissible" data-nonce="<?php echo esc_attr(wp_create_nonce($this->prefix.'-dismiss-rate-us')); ?>">
275
+
276
+ <p><?php echo str_replace('%url%', $this->rate_us_url, str_replace('%plugin%', $plugin_data['Name'], $this->rate_us_message)); ?></p>
277
+
278
+ </div><?php
279
+ }
280
+
281
+
282
+
283
+ // AJAX Handlers
284
+ // ---------------------------------------------------------------------------------------------------
285
+
286
+
287
+
288
+ /**
289
+ * Dismiss suggestions
290
+ */
291
+ public function dismiss_suggestions() {
292
+ if (!empty($_POST['nonce']) && wp_verify_nonce($_POST['nonce'], $this->prefix.'-dismiss-suggestions'))
293
+ $this->update_dismissed_timestamp('suggestions');
294
+ }
295
+
296
+
297
+
298
+ /**
299
+ * Dismiss rate plugin
300
+ */
301
+ public function dismiss_rate_us() {
302
+ if (!empty($_POST['nonce']) && wp_verify_nonce( $_POST['nonce'], $this->prefix.'-dismiss-rate-us'))
303
+ $this->update_dismissed_timestamp('rate_us');
304
+ }
305
+
306
+
307
+
308
+ // Plugins information retrieval
309
+ // ---------------------------------------------------------------------------------------------------
310
+
311
+
312
+
313
  /**
314
  * Check current active plugins
315
  */
316
  public function plugins_loaded() {
317
 
318
+ // Collect missing plugins
319
  $this->missing = $this->get_missing_plugins();
320
+ if (!empty($this->missing) && is_array($this->missing)) {
321
+ add_action('admin_footer', array(&$this, 'admin_footer_suggestions'));
322
+ add_action('admin_notices', array(&$this, 'admin_notices_suggestions'));
323
+ }
 
324
  }
325
 
326
 
336
  // Check plugins directory
337
  $directories = array_merge(self::get_mu_plugins_directories(), self::get_plugins_directories());
338
  if (!empty($directories)) {
339
+ $required = array_keys($this->suggestions);
340
  foreach ($required as $plugin) {
341
  if (!in_array($plugin, $directories))
342
  $inactive[] = $plugin;
436
  if ($exists) {
437
 
438
  // Existing plugin
439
+ $path = $plugin.'/'.$this->suggestions[$plugin]['filename'];
440
  return admin_url('plugins.php?action=activate&plugin='.$path.'&_wpnonce='.wp_create_nonce('activate-plugin_'.$path));
441
 
442
  // Install
449
 
450
 
451
 
452
+ // Plugin related
453
+ // ---------------------------------------------------------------------------------------------------
454
+
455
+
456
+
457
+ /**
458
+ * Plugin uninstall hook
459
+ */
460
+ public static function uninstall() {
461
+ $admin_notices = self::instance();
462
+ $admin_notices->delete_activation_timestamp();
463
+ $admin_notices->delete_dismissed_timestamp('suggestions');
464
+ $admin_notices->delete_dismissed_timestamp('rate_us');
465
+ }
466
+
467
+
468
+
469
+ // Activation timestamp management
470
+ // ---------------------------------------------------------------------------------------------------
471
+
472
+
473
+ /**
474
+ * Retrieves the plugin activation timestamp
475
+ */
476
+ private function get_activation_timestamp() {
477
+ return (int) get_option($this->prefix.'_activated_on');
478
+ }
479
+
480
+
481
+
482
+ /**
483
+ * Updates activation timestamp
484
+ */
485
+ private function update_activation_timestamp() {
486
+ update_option($this->prefix.'_activated_on', time(), true);
487
+ }
488
+
489
+
490
+
491
+ /**
492
+ * Removes activation timestamp
493
+ */
494
+ private function delete_activation_timestamp() {
495
+ delete_option($this->prefix.'_activated_on');
496
+ }
497
+
498
+
499
+
500
+ // Dismissed timestamp management
501
+ // ---------------------------------------------------------------------------------------------------
502
+
503
+
504
+
505
+ /**
506
+ * Current timestamp by key
507
+ */
508
+ private function get_dismissed_timestamp($key) {
509
+ return (int) get_option($this->prefix.'_dismissed_'.$key.'_on');
510
+ }
511
+
512
+
513
+
514
+ /**
515
+ * Update with the current timestamp
516
+ */
517
+ private function update_dismissed_timestamp($key) {
518
+ update_option($this->prefix.'_dismissed_'.$key.'_on', time(), true);
519
+ }
520
+
521
+
522
+
523
+ /**
524
+ * Removes dismissied option
525
+ */
526
+ private function delete_dismissed_timestamp($key) {
527
+ delete_option($this->prefix.'_dismissed_'.$key.'_on');
528
+ }
529
+
530
+
531
+
532
+ // Javascript code
533
+ // ---------------------------------------------------------------------------------------------------
534
+
535
+
536
+
537
+ /**
538
+ * Footer script for Suggestions
539
+ */
540
+ public function admin_footer_suggestions() { ?>
541
+
542
+ <script type="text/javascript">
543
+
544
+ jQuery(function($) {
545
+
546
+ $(document).on('click', '.<?php echo $this->prefix; ?>-dismiss-suggestions .notice-dismiss', function() {
547
+ $.post(ajaxurl, {
548
+ 'action' : '<?php echo $this->prefix; ?>_dismiss_suggestions',
549
+ 'nonce' : $(this).parent().attr('data-nonce')
550
+ });
551
+ });
552
+
553
+ });
554
+
555
+ </script>
556
+
557
+ <?php }
558
+
559
+
560
+
561
+ /**
562
+ * Footer script for Rate Us
563
+ */
564
+ public function admin_footer_rate_us() { ?>
565
+
566
+ <script type="text/javascript">
567
+
568
+ jQuery(function($) {
569
+
570
+ $(document).on('click', '.<?php echo $this->prefix; ?>-dismiss-rate-us .notice-dismiss', function() {
571
+ $.post(ajaxurl, {
572
+ 'action' : '<?php echo $this->prefix; ?>_dismiss_rate_us',
573
+ 'nonce' : $(this).parent().attr('data-nonce')
574
+ });
575
+ });
576
+
577
+ });
578
+
579
+ </script>
580
+
581
+ <?php }
582
+
583
+
584
+
585
  }
readme.txt CHANGED
@@ -1,11 +1,12 @@
1
  === Redirect 404 To Homepage ===
2
 
3
  Contributors: littlebizzy
4
- Tags: 404, homepage, home, not found, errors, page, missing, 301, redirect, htaccess
5
  Requires at least: 4.4
6
  Tested up to: 4.8
7
  Requires PHP: 7.0
8
- Stable tag: 1.0.6
 
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
11
  Prefix: NTFTHP
@@ -16,6 +17,12 @@ Redirects all 404 (Not Found) errors to the homepage for a better user experienc
16
 
17
  Redirects all 404 (Not Found) errors to the homepage for a better user experience, less abuse from bots, and 100% elimination of Google GSC warnings.
18
 
 
 
 
 
 
 
19
  404 To Homepage is a simple WordPress plugin for redirecting all 404 "Not Found" errors to the homepage. The reason for doing this is to avoid user confusion (or lost leads), and to avoid abuse causes by bots that ping your site with non-existent URLs which can negatively effect search engine indexing. Additionally, it can totally eliminate the warnings created in Google GSC (Webmasters) in regard to 404 errors that begin piling up over time, which quite often are not even the fault of your website.
20
 
21
  It should be noted, however, that this method is not recommended for all websites. For example, large blogs or magazines that rely heavily on search engine traffic (such as a newspaper) should probably not use this plugin. This is because in many cases, 404 errors should be analyzed on a regular basis and then 301 redirected to the appropriate page. Rather, this plugin is best suited for small businesses or websites with a limited amount of content, and limited staff, who are not publishing massive amounts of content. In such cases, we suggest monitoring 404 errors for perhaps a few months, redirecting the ones that are legitimate, and then consider activating this plugin after that point.
@@ -33,17 +40,22 @@ This plugin has been designed for use on LEMP (Nginx) web servers with PHP 7.0 a
33
  #### Plugin Features ####
34
 
35
  * Settings Page: No
36
- * PRO Version Available: No
37
- * Includes Media: No
38
  * Includes CSS: No
39
- * Database Storage: No
40
  * Transients: No
41
  * Options: Yes
42
- * Database Queries: None
43
- * Must-Use Support: Yes
 
44
  * Multisite Support: No
45
  * Uninstalls Data: Yes
46
 
 
 
 
 
47
  #### Code Inspiration ####
48
 
49
  This plugin was partially inspired either in "code or concept" by the open-source software and discussions mentioned below:
@@ -56,11 +68,16 @@ This plugin was partially inspired either in "code or concept" by the open-sourc
56
 
57
  We invite you to check out a few other related free plugins that our team has also produced that you may find especially useful:
58
 
 
59
  * [Remove Query Strings](https://wordpress.org/plugins/remove-query-strings-littlebizzy/)
60
  * [Remove Category Base](https://wordpress.org/plugins/remove-category-base-littlebizzy/)
61
- * [Force HTTPS](https://wordpress.org/plugins/force-https-littlebizzy/)
62
- * [Disable Emojis](https://wordpress.org/plugins/disable-emojis-littlebizzy/)
63
  * [Server Status](https://wordpress.org/plugins/server-status-littlebizzy/)
 
 
 
 
 
 
64
 
65
  #### Special Thanks ####
66
 
@@ -80,7 +97,7 @@ We released this plugin in response to our managed hosting clients asking for be
80
 
81
  1. Upload to `/wp-content/plugins/404-to-homepage-littlebizzy`
82
  2. Activate via WP Admin > Plugins
83
- 3. Test the plugin is working correctly by loading a non-existent URL of your website
84
 
85
  == FAQ ==
86
 
@@ -98,6 +115,11 @@ Please avoid leaving negative reviews in order to get a feature implemented. Ins
98
 
99
  == Changelog ==
100
 
 
 
 
 
 
101
  = 1.0.6 =
102
  * added filter to "skip" WP Admin, cron, and XML-RPC requests
103
  * updated recommended plugins
1
  === Redirect 404 To Homepage ===
2
 
3
  Contributors: littlebizzy
4
+ Tags: 404, homepage, errors, redirect, 301
5
  Requires at least: 4.4
6
  Tested up to: 4.8
7
  Requires PHP: 7.0
8
+ Multisite support: No
9
+ Stable tag: 1.0.7
10
  License: GPLv3
11
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
12
  Prefix: NTFTHP
17
 
18
  Redirects all 404 (Not Found) errors to the homepage for a better user experience, less abuse from bots, and 100% elimination of Google GSC warnings.
19
 
20
+ * [Plugin Homepage](https://www.littlebizzy.com/plugins/404-to-homepage)
21
+ * [Plugin GitHub](https://github.com/littlebizzy/404-to-homepage)
22
+ * [SlickStack.io](https://slickstack.io)
23
+
24
+ #### The Long Version ####
25
+
26
  404 To Homepage is a simple WordPress plugin for redirecting all 404 "Not Found" errors to the homepage. The reason for doing this is to avoid user confusion (or lost leads), and to avoid abuse causes by bots that ping your site with non-existent URLs which can negatively effect search engine indexing. Additionally, it can totally eliminate the warnings created in Google GSC (Webmasters) in regard to 404 errors that begin piling up over time, which quite often are not even the fault of your website.
27
 
28
  It should be noted, however, that this method is not recommended for all websites. For example, large blogs or magazines that rely heavily on search engine traffic (such as a newspaper) should probably not use this plugin. This is because in many cases, 404 errors should be analyzed on a regular basis and then 301 redirected to the appropriate page. Rather, this plugin is best suited for small businesses or websites with a limited amount of content, and limited staff, who are not publishing massive amounts of content. In such cases, we suggest monitoring 404 errors for perhaps a few months, redirecting the ones that are legitimate, and then consider activating this plugin after that point.
40
  #### Plugin Features ####
41
 
42
  * Settings Page: No
43
+ * Premium Version Available: No
44
+ * Includes Media (Images, Icons, Etc): No
45
  * Includes CSS: No
46
+ * Database Storage: Yes
47
  * Transients: No
48
  * Options: Yes
49
+ * Creates New Tables: No
50
+ * Database Queries: Backend Only
51
+ * Must-Use Support: Yes (Use With [Autoloader](https://github.com/littlebizzy/autoloader))
52
  * Multisite Support: No
53
  * Uninstalls Data: Yes
54
 
55
+ #### WP Admin Notices ####
56
+
57
+ This plugin generates multiple [Admin Notices](https://codex.wordpress.org/Plugin_API/Action_Reference/admin_notices) in the WP Admin dashboard. The first is a notice that fires during plugin activation which recommends several related free plugins that we believe will enhance this plugin's features; this notice will re-appear approximately once every 5 months as our code and recommendations evolve. The second is a notice that fires a few days after plugin activation which asks for a 5-star rating of this plugin on its WordPress.org profile page. This notice will re-appear approximately once every 8 months. These notices can be dismissed by clicking the **(x)** symbol in the upper right of the notice box. These notices may confuse certain users, but are appreciated by the majority of our userbase, who understand that these notices support our free contributions to the WordPress community. If you feel that these notices are too "annoying" than we encourage you to consider one or more of our upcoming premium plugins that combine several free plugin features into a single control panel. Another alternative would be to develop your own plugins for WordPress, if you feel that supporting free plugin authors is not something that interests you.
58
+
59
  #### Code Inspiration ####
60
 
61
  This plugin was partially inspired either in "code or concept" by the open-source software and discussions mentioned below:
68
 
69
  We invite you to check out a few other related free plugins that our team has also produced that you may find especially useful:
70
 
71
+ * [Force HTTPS](https://wordpress.org/plugins/force-https-littlebizzy/)
72
  * [Remove Query Strings](https://wordpress.org/plugins/remove-query-strings-littlebizzy/)
73
  * [Remove Category Base](https://wordpress.org/plugins/remove-category-base-littlebizzy/)
 
 
74
  * [Server Status](https://wordpress.org/plugins/server-status-littlebizzy/)
75
+ * [Disable Embeds](https://wordpress.org/plugins/disable-embeds-littlebizzy/)
76
+ * [Disable Emojis](https://wordpress.org/plugins/disable-emojis-littlebizzy/)
77
+ * [Disable XML-RPC](https://wordpress.org/plugins/disable-xml-rpc-littlebizzy/)
78
+ * [Disable Author Pages](https://wordpress.org/plugins/disable-author-pages-littlebizzy/)
79
+ * [Disable Search](https://wordpress.org/plugins/disable-search-littlebizzy/)
80
+ * [Virtual Robots.txt](https://wordpress.org/plugins/virtual-robotstxt-littlebizzy/)
81
 
82
  #### Special Thanks ####
83
 
97
 
98
  1. Upload to `/wp-content/plugins/404-to-homepage-littlebizzy`
99
  2. Activate via WP Admin > Plugins
100
+ 3. Test the plugin is working by loading a non-existent page URI on your website
101
 
102
  == FAQ ==
103
 
115
 
116
  == Changelog ==
117
 
118
+ = 1.0.7 =
119
+ * optimize plugin code
120
+ * updated recommended plugins
121
+ * added rating request
122
+
123
  = 1.0.6 =
124
  * added filter to "skip" WP Admin, cron, and XML-RPC requests
125
  * updated recommended plugins