Redirect 404 To Homepage - Version 1.0.8

Version Description

  • tested with WP 4.9
  • updated plugin meta
  • updated recommended plugins
  • added support for define('DISABLE_NAG_NOTICES', true);
Download this release

Release Info

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

Code changes from version 1.0.7 to 1.0.8

Files changed (3) hide show
  1. 404-to-homepage.php +2 -2
  2. admin-notices.php +25 -9
  3. readme.txt +72 -18
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.7
7
  Author: LittleBizzy
8
  Author URI: https://www.littlebizzy.com
9
  License: GPLv3
@@ -25,7 +25,7 @@ if (!function_exists('add_action'))
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 */
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.8
7
  Author: LittleBizzy
8
  Author URI: https://www.littlebizzy.com
9
  License: GPLv3
25
  // Plugin constants
26
  define('NTFTHP_FILE', __FILE__);
27
  define('NTFTHP_PATH', dirname(NTFTHP_FILE));
28
+ define('NTFTHP_VERSION', '1.0.8');
29
 
30
 
31
  /* 404 hooks */
admin-notices.php CHANGED
@@ -18,8 +18,8 @@ final class NTFTHP_Admin_Notices {
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
 
@@ -28,9 +28,14 @@ final class NTFTHP_Admin_Notices {
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).',
@@ -56,11 +61,6 @@ final class NTFTHP_Admin_Notices {
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.',
@@ -81,7 +81,6 @@ final class NTFTHP_Admin_Notices {
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
 
@@ -227,6 +226,10 @@ final class NTFTHP_Admin_Notices {
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'));
@@ -315,6 +318,10 @@ final class NTFTHP_Admin_Notices {
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)) {
@@ -449,6 +456,15 @@ final class NTFTHP_Admin_Notices {
449
 
450
 
451
 
 
 
 
 
 
 
 
 
 
452
  // Plugin related
453
  // ---------------------------------------------------------------------------------------------------
454
 
18
  /**
19
  * Rate Us
20
  */
21
+ private $days_before_display_rate_us = 3; // 3 days delay
22
+ private $days_dismissing_rate_us = 270; // 9 months reappear
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
 
28
  /**
29
  * Plugin suggestions
30
  */
31
+ private $days_dismissing_suggestions = 180; // 6 months reappear
32
  private $suggestions_message = '%plugin% recommends the following free plugins:';
33
  private $suggestions = array(
34
+ 'cf-littlebizzy' => array(
35
+ 'name' => 'CloudFlare',
36
+ 'desc' => 'Easily connect your WordPress website to free optimization features from CloudFlare, including one-click options to purge cache and enable dev mode.',
37
+ 'filename' => 'cloudflare.php',
38
+ ),
39
  'force-https-littlebizzy' => array(
40
  'name' => 'Force HTTPS',
41
  'desc' => 'Redirects all HTTP requests to the HTTPS version and fixes all insecure static resources without altering the database (also works with CloudFlare).',
61
  'desc' => 'Disables both external and internal embedding functions to avoid slow page render, instability and SEO issues, and to improve overall loading speed.',
62
  'filename' => 'disable-embeds.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.',
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
 
226
  // Admin area (except install or activate plugins page)
227
  } elseif (!in_array(basename($_SERVER['PHP_SELF']), array('plugins.php', 'plugin-install.php', 'update.php'))) {
228
 
229
+ // Check the disable nag constant
230
+ if ($this->disable_nag_notices())
231
+ return;
232
+
233
  // Admin hooks
234
  add_action('admin_footer', array(&$this, 'admin_footer_rate_us'));
235
  add_action('admin_notices', array(&$this, 'admin_notices_rate_us'));
318
  */
319
  public function plugins_loaded() {
320
 
321
+ // Check the disable nag constant
322
+ if ($this->disable_nag_notices())
323
+ return;
324
+
325
  // Collect missing plugins
326
  $this->missing = $this->get_missing_plugins();
327
  if (!empty($this->missing) && is_array($this->missing)) {
456
 
457
 
458
 
459
+ /**
460
+ * Determines the admin notices display
461
+ */
462
+ private function disable_nag_notices() {
463
+ return (defined('DISABLE_NAG_NOTICES') && DISABLE_NAG_NOTICES);
464
+ }
465
+
466
+
467
+
468
  // Plugin related
469
  // ---------------------------------------------------------------------------------------------------
470
 
readme.txt CHANGED
@@ -1,12 +1,12 @@
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
@@ -19,7 +19,7 @@ Redirects all 404 (Not Found) errors to the homepage for a better user experienc
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
 
@@ -33,28 +33,30 @@ This is a version that uses the early WP hook 'pre_handle_404' to avoid unnecess
33
 
34
  Before to do the redirection to the homepage, there is a procedure that removes any existing previous header, so only 301 header will be sent in response to the HTTP request. You can see the headers in chrome from Network tab and checking preserve log. For Firefox you can use the Live HTTP headers addon, for example.
35
 
36
- #### Compatibility ####
37
-
38
- This plugin has been designed for use on LEMP (Nginx) web servers with PHP 7.0 and MySQL 5.7 to achieve best performance. All of our plugins are meant for single site WordPress installations only; for both performance and security reasons, we highly recommend against using WordPress Multisite for the vast majority of projects.
39
-
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
 
@@ -68,25 +70,67 @@ This plugin was partially inspired either in "code or concept" by the open-sourc
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
 
84
  We thank the following groups for their generous contributions to the WordPress community which have particularly benefited us in developing our own free plugins and paid services:
85
 
86
  * [Automattic](https://automattic.com)
 
87
  * [Delicious Brains](https://deliciousbrains.com)
 
 
 
 
 
 
 
 
 
 
 
 
88
  * [Roots](https://roots.io)
89
  * [rtCamp](https://rtcamp.com)
 
90
  * [WP Tavern](https://wptavern.com)
91
 
92
  #### Disclaimer ####
@@ -103,7 +147,11 @@ We released this plugin in response to our managed hosting clients asking for be
103
 
104
  = Does this plugin alter my 404.php template? =
105
 
106
- No, it automatically adds a 404 header using WordPress filters/hooks.
 
 
 
 
107
 
108
  = How can I change this plugin's settings? =
109
 
@@ -115,6 +163,12 @@ Please avoid leaving negative reviews in order to get a feature implemented. Ins
115
 
116
  == Changelog ==
117
 
 
 
 
 
 
 
118
  = 1.0.7 =
119
  * optimize plugin code
120
  * updated recommended plugins
1
  === Redirect 404 To Homepage ===
2
 
3
  Contributors: littlebizzy
4
+ Tags: 404, errors, redirect, 301, homepage
5
  Requires at least: 4.4
6
+ Tested up to: 4.9
7
  Requires PHP: 7.0
8
  Multisite support: No
9
+ Stable tag: 1.0.8
10
  License: GPLv3
11
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
12
  Prefix: NTFTHP
19
 
20
  * [Plugin Homepage](https://www.littlebizzy.com/plugins/404-to-homepage)
21
  * [Plugin GitHub](https://github.com/littlebizzy/404-to-homepage)
22
+ * [SlickStack](https://slickstack.io)
23
 
24
  #### The Long Version ####
25
 
33
 
34
  Before to do the redirection to the homepage, there is a procedure that removes any existing previous header, so only 301 header will be sent in response to the HTTP request. You can see the headers in chrome from Network tab and checking preserve log. For Firefox you can use the Live HTTP headers addon, for example.
35
 
 
 
 
 
36
  #### Plugin Features ####
37
 
38
  * Settings Page: No
39
+ * Premium Version Available: Yes ([SEO Genius](https://www.littlebizzy.com/plugins/seo-genius))
40
  * Includes Media (Images, Icons, Etc): No
41
  * Includes CSS: No
42
  * Database Storage: Yes
43
  * Transients: No
44
  * Options: Yes
45
  * Creates New Tables: No
46
+ * Database Queries: Backend Only (Options API)
47
  * Must-Use Support: Yes (Use With [Autoloader](https://github.com/littlebizzy/autoloader))
48
  * Multisite Support: No
49
  * Uninstalls Data: Yes
50
 
51
  #### WP Admin Notices ####
52
 
53
+ 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 6 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 9 months. These notices can be dismissed by clicking the **(x)** symbol in the upper right of the notice box. These notices may annoy or 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 while providing valuable (free) recommendations for optimizing their website.
54
+
55
+ 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, or even consider developing your own plugins for WordPress, if supporting free plugin authors is too frustrating for you. A final alternative would be to place the defined constant mentioned below inside of your `wp-config.php` file to manually hide this plugin's nag notices:
56
+
57
+ define('DISABLE_NAG_NOTICES', true);
58
+
59
+ Note: This defined constant will only affect the notices mentioned above, and will not affect any other notices generated by this plugin or other plugins, such as one-time notices that communicate with admin-level users.
60
 
61
  #### Code Inspiration ####
62
 
70
 
71
  We invite you to check out a few other related free plugins that our team has also produced that you may find especially useful:
72
 
73
+ * [404 To Homepage](https://wordpress.org/plugins/404-to-homepage-littlebizzy/)
74
+ * [CloudFlare](https://wordpress.org/plugins/cf-littlebizzy/)
75
+ * [Disable Author Pages](https://wordpress.org/plugins/disable-author-pages-littlebizzy/)
76
+ * [Disable Cart Fragments](https://wordpress.org/plugins/disable-cart-fragments-littlebizzy/)
77
  * [Disable Embeds](https://wordpress.org/plugins/disable-embeds-littlebizzy/)
78
  * [Disable Emojis](https://wordpress.org/plugins/disable-emojis-littlebizzy/)
79
+ * [Disable Empty Trash](https://wordpress.org/plugins/disable-empty-trash-littlebizzy/)
80
+ * [Disable Image Compression](https://wordpress.org/plugins/disable-image-compression-littlebizzy/)
81
  * [Disable Search](https://wordpress.org/plugins/disable-search-littlebizzy/)
82
+ * [Disable WooCommerce Status](https://wordpress.org/plugins/disable-wc-status-littlebizzy/)
83
+ * [Disable WooCommerce Styles](https://wordpress.org/plugins/diable-wc-styles-littlebizzy/)
84
+ * [Disable XML-RPC](https://wordpress.org/plugins/disable-xml-rpc-littlebizzy/)
85
+ * [Download Media](https://wordpress.org/plugins/download-media-littlebizzy/)
86
+ * [Download Plugin](https://wordpress.org/plugins/download-plugin-littlebizzy/)
87
+ * [Download Theme](https://wordpress.org/plugins/download-theme-littlebizzy/)
88
+ * [Duplicate Post](https://wordpress.org/plugins/duplicate-post-littlebizzy/)
89
+ * [Export Database](https://wordpress.org/plugins/export-database-littlebizzy/)
90
+ * [Force HTTPS](https://wordpress.org/plugins/force-https-littlebizzy/)
91
+ * [Force Strong Hashing](https://wordpress.org/plugins/force-strong-hashing-littlebizzy/)
92
+ * [Google Analytics](https://wordpress.org/plugins/ga-littlebizzy/)
93
+ * [Index Autoload](https://wordpress.org/plugins/index-autoload-littlebizzy/)
94
+ * [Maintenance Mode](https://wordpress.org/plugins/maintenance-mode-littlebizzy/)
95
+ * [Profile Change Alerts](https://wordpress.org/plugins/profile-change-alerts-littlebizzy/)
96
+ * [Remove Category Base](https://wordpress.org/plugins/remove-category-base-littlebizzy/)
97
+ * [Remove Query Strings](https://wordpress.org/plugins/remove-query-strings-littlebizzy/)
98
+ * [Server Status](https://wordpress.org/plugins/server-status-littlebizzy/)
99
+ * [StatCounter](https://wordpress.org/plugins/sc-littlebizzy/)
100
+ * [View Defined Constants](https://wordpress.org/plugins/view-defined-constants-littlebizzy/)
101
  * [Virtual Robots.txt](https://wordpress.org/plugins/virtual-robotstxt-littlebizzy/)
102
 
103
+ #### Premium Plugins ####
104
+
105
+ We invite you to check out a few premium plugins that our team has also produced that you may find especially useful:
106
+
107
+ * [Purge Them All](https://www.littlebizzy.com/plugins/purge-them-all)
108
+ * [Speed Demon](https://www.littlebizzy.com/plugins/speed-demon)
109
+ * [SEO Genius](https://www.littlebizzy.com/plugins/seo-genius)
110
+ * [Great Migration](https://www.littlebizzy.com/plugins/great-migration)
111
+
112
  #### Special Thanks ####
113
 
114
  We thank the following groups for their generous contributions to the WordPress community which have particularly benefited us in developing our own free plugins and paid services:
115
 
116
  * [Automattic](https://automattic.com)
117
+ * [Daniel Auener](http://www.danielauener.com)
118
  * [Delicious Brains](https://deliciousbrains.com)
119
+ * [Greg Rickaby](https://gregrickaby.com)
120
+ * [Matt Mullenweg](https://ma.tt)
121
+ * [Mika Epstein](https://halfelf.org)
122
+ * [Samuel Wood](http://ottopress.com)
123
+ * [Scott Reilly](http://coffee2code.com)
124
+ * [Jan Dembowski](https://profiles.wordpress.org/jdembowski)
125
+ * [Jeff Starr](https://perishablepress.com)
126
+ * [Jeff Chandler](https://jeffc.me)
127
+ * [Jeff Matson](https://jeffmatson.net)
128
+ * [John James Jacoby](https://jjj.blog)
129
+ * [Leland Fiegel](https://leland.me)
130
+ * [Rahul Bansal](https://profiles.wordpress.org/rahul286)
131
  * [Roots](https://roots.io)
132
  * [rtCamp](https://rtcamp.com)
133
+ * [WP Chat](https://wpchat.com)
134
  * [WP Tavern](https://wptavern.com)
135
 
136
  #### Disclaimer ####
147
 
148
  = Does this plugin alter my 404.php template? =
149
 
150
+ No, it automatically adds a 404 header using WordPress hooks/filters. While you can use the `404.php` template file to redirect to the homepage, it is not as efficient as this plugin due to mixed HTTP headers and the fact that WordPress hooks/filters are loaded prior to any template files. You can even delete your `404.php` template file if you wish.
151
+
152
+ = After disabling this plugin, 404 pages are still redirecting? =
153
+
154
+ This is usually caused by your browser cache. Simply clear your browser cache (temp files) and try again.
155
 
156
  = How can I change this plugin's settings? =
157
 
163
 
164
  == Changelog ==
165
 
166
+ = 1.0.8 =
167
+ * tested with WP 4.9
168
+ * updated plugin meta
169
+ * updated recommended plugins
170
+ * added support for `define('DISABLE_NAG_NOTICES', true);`
171
+
172
  = 1.0.7 =
173
  * optimize plugin code
174
  * updated recommended plugins