404page – your smart custom 404 error page - Version 2.5

Version Description

Hhide 404 page from search results, compatibility with DW Question & Answer plugin

Download this release

Release Info

Developer petersplugins
Plugin Icon 128x128 404page – your smart custom 404 error page
Version 2.5
Comparing to
See all releases

Code changes from version 2.4 to 2.5

Files changed (3) hide show
  1. 404page.php +18 -6
  2. pluginicon.png +0 -0
  3. readme.txt +67 -81
404page.php CHANGED
@@ -3,8 +3,8 @@
3
  Plugin Name: 404page - your smart custom 404 error page
4
  Plugin URI: http://petersplugins.com/free-wordpress-plugins/404page/
5
  Description: Custom 404 the easy way! Set any page as custom 404 error page. No coding needed. Works with (almost) every Theme.
6
- Version: 2.4
7
- Author: Peter's Plugins (formerly smartware.cc)
8
  Author URI: http://petersplugins.com
9
  Text Domain: 404page
10
  License: GPL2+
@@ -31,7 +31,7 @@ class Smart404Page {
31
  public function __construct() {
32
  $this->plugin_name = '404page';
33
  $this->plugin_slug = '404page';
34
- $this->version = '2.4';
35
  $this->get_settings();
36
  $this->load();
37
  }
@@ -100,8 +100,11 @@ class Smart404Page {
100
  } elseif ( $this->settings['404page_method'] != 'STD' ) {
101
 
102
  // Compatibility Mode
103
- // As of v 2.4 we use the the_posts filter instead of posts_results, because the posts array is internally processed after posts_results fires
104
  add_filter( 'the_posts', array( $this, 'show404_compatiblity_mode' ), 999 );
 
 
 
105
 
106
  } else {
107
 
@@ -134,6 +137,7 @@ class Smart404Page {
134
  }
135
  $this->do_404page_action();
136
  }
 
137
  return $template;
138
 
139
  }
@@ -212,6 +216,12 @@ class Smart404Page {
212
  return $posts;
213
  }
214
 
 
 
 
 
 
 
215
  // this function overrides the page template in compatibilty mode
216
  function change_404_template( $template ) {
217
 
@@ -373,10 +383,12 @@ class Smart404Page {
373
  $post_type = $query->get( 'post_type' );
374
 
375
  // as of v 2.3 we check the post_type on front end
376
- if( ( is_admin() && ( 'edit.php' == $pagenow && !current_user_can( 'create_users' ) ) ) || ( ! is_admin() && ( !empty( $post_type) && ( ('page' === $post_type || 'any' === $post_type) || ( is_array( $post_type ) && in_array( 'page', $post_type ) ) ) )) ) {
 
377
 
378
  // as of v 2.4 we hide all translations in admin for WPML
379
- if ( is_admin() ) {
 
380
  $pageids = $this->get_all_page_ids();
381
  } else {
382
  $pageids = array( $pageid );
3
  Plugin Name: 404page - your smart custom 404 error page
4
  Plugin URI: http://petersplugins.com/free-wordpress-plugins/404page/
5
  Description: Custom 404 the easy way! Set any page as custom 404 error page. No coding needed. Works with (almost) every Theme.
6
+ Version: 2.5
7
+ Author: Peter Raschendorfer
8
  Author URI: http://petersplugins.com
9
  Text Domain: 404page
10
  License: GPL2+
31
  public function __construct() {
32
  $this->plugin_name = '404page';
33
  $this->plugin_slug = '404page';
34
+ $this->version = '2.5';
35
  $this->get_settings();
36
  $this->load();
37
  }
100
  } elseif ( $this->settings['404page_method'] != 'STD' ) {
101
 
102
  // Compatibility Mode
103
+ // as of v 2.4 we use the the_posts filter instead of posts_results, because the posts array is internally processed after posts_results fires
104
  add_filter( 'the_posts', array( $this, 'show404_compatiblity_mode' ), 999 );
105
+
106
+ // as of v 2.5 we remove the filter if the DW Question & Answer plugin by DesignWall (https://www.designwall.com/wordpress/plugins/dw-question-answer/) is active and we're in the answers list
107
+ add_filter( 'dwqa_prepare_answers', array( $this, 'remove_show404_compatiblity_mode' ), 999 );
108
 
109
  } else {
110
 
137
  }
138
  $this->do_404page_action();
139
  }
140
+
141
  return $template;
142
 
143
  }
216
  return $posts;
217
  }
218
 
219
+ // this function is called by the dwqa_prepare_answers filter
220
+ function remove_show404_compatiblity_mode( $args ) {
221
+ remove_filter( 'the_posts', array( $this, 'show404_compatiblity_mode' ), 999 );
222
+ return $args;
223
+ }
224
+
225
  // this function overrides the page template in compatibilty mode
226
  function change_404_template( $template ) {
227
 
383
  $post_type = $query->get( 'post_type' );
384
 
385
  // as of v 2.3 we check the post_type on front end
386
+ // as of v 2.5 we also hide the page from search results on front end
387
+ if( ( is_admin() && ( 'edit.php' == $pagenow && !current_user_can( 'create_users' ) ) ) || ( ! is_admin() && ( is_search() || ( !empty( $post_type) && ( ('page' === $post_type || 'any' === $post_type) || ( is_array( $post_type ) && in_array( 'page', $post_type ) ) ) ) ) ) ) {
388
 
389
  // as of v 2.4 we hide all translations in admin for WPML
390
+ // as of v 2.5 we hide all translations from search results on front end for WPML
391
+ if ( is_admin() || ( ! is_admin() && is_search() ) ) {
392
  $pageids = $this->get_all_page_ids();
393
  } else {
394
  $pageids = array( $pageid );
pluginicon.png CHANGED
Binary file
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link:http://petersplugins.com/make-a-donation/
4
  Tags: page, 404, error, error page, 404 page, page not found, page not found error, 404 error page, missing, broken link, template, 404 link, seo, custom 404, custom 404 page, custom 404 error, custom 404 error page, customize 404, customize 404 page, customize 404 error page
5
  Requires at least: 3.0
6
  Tested up to: 4.7
7
- Stable tag: 2.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -12,31 +12,25 @@ Custom 404 the easy way! Set any page as custom 404 error page. No coding needed
12
 
13
  == Description ==
14
 
15
- Create your custom 404 Page as a normal WordPress Page using the full power of WordPress. You can use a Custom Page Template or Custom Fields, you can set a Featured Image - everything like on every other Page. Then go to 'Appearance' -> '404 Error Page' from your WordPress Dashbord and select the created Page as your 404 error page. That's it!
16
 
17
- = Watch the video =
18
 
19
- https://www.youtube.com/watch?v=VTL07Lf0IsY
20
 
21
  = Why you should choose this plugin =
22
 
23
  * Different from other similar plugins the 404page plugin **does not create redirects**. That’s **quite important** because a correct code 404 is delivered which tells search engines that the page does not exist and has to be removed from the index. A redirect would result in a HTTP code 301 or 302 and the URL would remain in the search index.
24
  * Different from other similar plugins the 404page plugin **does not create additional server requests**.
25
 
26
- = More information =
27
 
28
- See [Plugin Homepage](http://petersplugins.com/free-wordpress-plugins/404page/) and [Plugin Doc](http://petersplugins.com/docs/404page/).
29
 
30
  = Do you like the 404page Plugin? =
31
 
32
  Thanks, I appreciate that. You don’t need to make a donation. No money, no beer, no coffee. Please, just [tell the world that you like what I’m doing](http://petersplugins.com/make-a-donation/)! And that’s all.
33
 
34
- = Translations =
35
-
36
- The 404page Plugin uses GlotPress - the wordpress.org Translation System - for translations. Translations can be submitted at [translate.wordpress.org](https://translate.wordpress.org/projects/wp-plugins/404page).
37
-
38
- **Translation are highly appreciated**. It would be great if you'd support the 404page Plugin by adding a new translation or keeping an existing one up to date. If you're new to GlotPress take a look at the [Translator Handbook](https://make.wordpress.org/polyglots/handbook/tools/glotpress-translate-wordpress-org/).
39
-
40
  = More plugins from Peter =
41
 
42
  * **[hashtagger](https://wordpress.org/plugins/hashtagger/)** - Use hashtags in WordPress
@@ -44,20 +38,6 @@ The 404page Plugin uses GlotPress - the wordpress.org Translation System - for t
44
  * **[smart User Slug Hider](https://wordpress.org/plugins/smart-user-slug-hider/)** - Hide usernames in author pages URLs to enhance security
45
  * [See all](https://profiles.wordpress.org/petersplugins/#content-plugins)
46
 
47
- == Installation ==
48
-
49
- = From your WordPress dashboard =
50
-
51
- 1. Visit 'Plugins' -> 'Add New'
52
- 1. Search for '404page'
53
- 1. Activate the plugin through the 'Plugins' menu in WordPress
54
-
55
- = Manually from wordpress.org =
56
-
57
- 1. Download 404page from wordpress.org and unzip the archive
58
- 1. Upload the `404page` folder to your `/wp-content/plugins/` directory
59
- 1. Activate the plugin through the 'Plugins' menu in WordPress
60
-
61
  == Frequently Asked Questions ==
62
 
63
  = Are there any requirements? =
@@ -68,12 +48,62 @@ To enable the WordPress 404 error handling you have to set the Permalink Structu
68
 
69
  No, there is no redirection! The chosen page is delivered as a 'real' 404 error page. This results in a HTTP 404 code and not in 301 or 302, which is important for Search Engines to tell them, that the page does not exist and should be deleted from the index.
70
 
71
- = What about PHP Version 7? =
72
- The plugin works smoothly with PHP 7.
73
-
74
  = Is it possible to add custom CSS to the 404 page? =
 
75
  The 404page plugin adds a CSS class `error404` to the `<body>` tag which can be used for extra styling.
76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  == Screenshots ==
78
 
79
  1. Create your 404 Page as a normal WordPress Page
@@ -82,6 +112,10 @@ The 404page plugin adds a CSS class `error404` to the `<body>` tag which can be
82
 
83
  == Changelog ==
84
 
 
 
 
 
85
  = 2.4 (2017-03-08) =
86
  * ensure that all core files are loaded properly ([See Topic](https://wordpress.org/support/topic/had-to-deactivate-404page-to-make-wordpress-correctly))
87
  * Polylang plugin does no longer require Compatibility Mode ([See Topic](https://wordpress.org/support/topic/still-displaying-the-themes-404-page-with-polylang/))
@@ -144,6 +178,9 @@ The 404page plugin adds a CSS class `error404` to the `<body>` tag which can be
144
 
145
  == Upgrade Notice ==
146
 
 
 
 
147
  = 2.4 =
148
  Version 2.4 fixes several issues. See [changelog](https://wordpress.org/plugins/404page/changelog/) for details.
149
 
@@ -160,55 +197,4 @@ Introduced Compatibility Mode, improved compatibility with several plugins.
160
  Version 2.0 is more or less a completely new development and a big step forward. [Read more](http://petersplugins.com/blog/2016/02/23/the-404page-plugin-now-works-with-wpml-and-other-enhancements/)
161
 
162
  = 1.4 =
163
- Editing of the 404 page is now possible directly from settings page. Portuguese translation added.
164
-
165
- == Compatibility ==
166
-
167
- = The 404page plugin was sucessfully tested by the author with the following themes =
168
- * [Athena](https://wordpress.org/themes/athena/)
169
- * [Customizr](https://wordpress.org/themes/customizr/) (Read more about [Customizr Compatibility Mode](http://petersplugins.com/docs/404page/#settings_operating_method))
170
- * [Enfold](https://themeforest.net/item/enfold-responsive-multipurpose-theme/4519990?ref=petersplugins)
171
- * [evolve](https://wordpress.org/themes/evolve/)
172
- * [GeneratePress](https://wordpress.org/themes/generatepress/)
173
- * [Graphene](https://wordpress.org/themes/graphene/)
174
- * [Hemingway](https://wordpress.org/themes/hemingway/)
175
- * [Hueman](https://wordpress.org/themes/hueman/)
176
- * [Responsive](https://wordpress.org/themes/responsive/)
177
- * [Spacious](https://wordpress.org/themes/spacious/)
178
- * [Sparkling](https://wordpress.org/themes/sparkling/)
179
- * [Sydney](https://wordpress.org/themes/sydney/)
180
- * [Twenty Ten](https://wordpress.org/themes/twentyten/)
181
- * [Twenty Eleven](https://wordpress.org/themes/twentyeleven/)
182
- * [Twenty Twelve](https://wordpress.org/themes/twentytwelve/)
183
- * [Twenty Thirteen](https://wordpress.org/themes/twentythirteen/)
184
- * [Twenty Fourteen](https://wordpress.org/themes/twentyfourteen/)
185
- * [Twenty Fifteen](https://wordpress.org/themes/twentyfifteen/)
186
- * [Twenty Sixteen](https://wordpress.org/themes/twentysixteen/)
187
- * [Twenty Seventeen](https://wordpress.org/themes/twentyseventeen/)
188
- * [Vantage](https://wordpress.org/themes/vantage/)
189
- * [Virtue](https://wordpress.org/themes/virtue/)
190
- * [Zerif Lite](http://themeisle.com/themes/zerif-lite/)
191
-
192
- = The 404page plugin was sucessfully tested by the author with the following starter themes =
193
- * [Bones](http://themble.com/bones/)
194
- * [JointsWP](http://jointswp.com/)
195
- * [undersores](http://underscores.me/)
196
-
197
- = The 404page plugin was sucessfully tested by the author with the following plugins =
198
- * [bbPress](https://wordpress.org/plugins/bbpress/)
199
- * [BuddyPress](https://wordpress.org/plugins/buddypress/)
200
- * [hashtagger](https://wordpress.org/plugins/hashtagger/)
201
- * [Page Builder by SiteOrigin](https://wordpress.org/plugins/siteorigin-panels/)
202
- * [Polylang](https://wordpress.org/plugins/polylang/)
203
- * [User Submitted Posts](https://wordpress.org/plugins/user-submitted-posts/)
204
- * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
205
- * [WP Super Cache](https://wordpress.org/plugins/wp-super-cache/)(Read more about [WP Super Cache Compatibility](http://petersplugins.com/docs/404page/#wp_super_cache)
206
- * [WPML WordPress Multilingual Plugin](https://wpml.org/)([officially approved by WPML team](https://wpml.org/plugin/404page/))
207
-
208
- == For developers ==
209
-
210
- = Action Hook =
211
- The plugin adds an action hook 404page_after_404 which you can use to add extra functionality. The exact position the action occurs after an 404 error is detected depends on the Operating Method. Your function must not generate any output. There are no parameters.
212
-
213
- = Native Support =
214
- If you are a theme developer you can add native support for the 404page plugin to your theme for full control. [Read more](http://petersplugins.com/docs/404page/#theme_native_support).
4
  Tags: page, 404, error, error page, 404 page, page not found, page not found error, 404 error page, missing, broken link, template, 404 link, seo, custom 404, custom 404 page, custom 404 error, custom 404 error page, customize 404, customize 404 page, customize 404 error page
5
  Requires at least: 3.0
6
  Tested up to: 4.7
7
+ Stable tag: 2.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
12
 
13
  == Description ==
14
 
15
+ Create your custom 404 page just like any other page. Then go to 'Appearance' -> '404 Error Page' and select the created page as your custom 404 error page. That's it!
16
 
17
+ = Need more information? =
18
 
19
+ See [Plugin Homepage](http://petersplugins.com/free-wordpress-plugins/404page/) and [Plugin Doc](http://petersplugins.com/docs/404page/).
20
 
21
  = Why you should choose this plugin =
22
 
23
  * Different from other similar plugins the 404page plugin **does not create redirects**. That’s **quite important** because a correct code 404 is delivered which tells search engines that the page does not exist and has to be removed from the index. A redirect would result in a HTTP code 301 or 302 and the URL would remain in the search index.
24
  * Different from other similar plugins the 404page plugin **does not create additional server requests**.
25
 
26
+ = Watch the video =
27
 
28
+ https://www.youtube.com/watch?v=VTL07Lf0IsY
29
 
30
  = Do you like the 404page Plugin? =
31
 
32
  Thanks, I appreciate that. You don’t need to make a donation. No money, no beer, no coffee. Please, just [tell the world that you like what I’m doing](http://petersplugins.com/make-a-donation/)! And that’s all.
33
 
 
 
 
 
 
 
34
  = More plugins from Peter =
35
 
36
  * **[hashtagger](https://wordpress.org/plugins/hashtagger/)** - Use hashtags in WordPress
38
  * **[smart User Slug Hider](https://wordpress.org/plugins/smart-user-slug-hider/)** - Hide usernames in author pages URLs to enhance security
39
  * [See all](https://profiles.wordpress.org/petersplugins/#content-plugins)
40
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  == Frequently Asked Questions ==
42
 
43
  = Are there any requirements? =
48
 
49
  No, there is no redirection! The chosen page is delivered as a 'real' 404 error page. This results in a HTTP 404 code and not in 301 or 302, which is important for Search Engines to tell them, that the page does not exist and should be deleted from the index.
50
 
 
 
 
51
  = Is it possible to add custom CSS to the 404 page? =
52
+
53
  The 404page plugin adds a CSS class `error404` to the `<body>` tag which can be used for extra styling.
54
 
55
+ == Compatibility ==
56
+
57
+ = The 404page plugin was sucessfully tested by the author with the following themes =
58
+ * [Athena](https://wordpress.org/themes/athena/)
59
+ * [Customizr](https://wordpress.org/themes/customizr/) (Read more about [Customizr Compatibility Mode](http://petersplugins.com/docs/404page/#settings_operating_method))
60
+ * [Enfold](https://themeforest.net/item/enfold-responsive-multipurpose-theme/4519990?ref=petersplugins)
61
+ * [evolve](https://wordpress.org/themes/evolve/)
62
+ * [GeneratePress](https://wordpress.org/themes/generatepress/)
63
+ * [Graphene](https://wordpress.org/themes/graphene/)
64
+ * [Hemingway](https://wordpress.org/themes/hemingway/)
65
+ * [Hueman](https://wordpress.org/themes/hueman/)
66
+ * [Responsive](https://wordpress.org/themes/responsive/)
67
+ * [Spacious](https://wordpress.org/themes/spacious/)
68
+ * [Sparkling](https://wordpress.org/themes/sparkling/)
69
+ * [Sydney](https://wordpress.org/themes/sydney/)
70
+ * [Twenty Ten](https://wordpress.org/themes/twentyten/)
71
+ * [Twenty Eleven](https://wordpress.org/themes/twentyeleven/)
72
+ * [Twenty Twelve](https://wordpress.org/themes/twentytwelve/)
73
+ * [Twenty Thirteen](https://wordpress.org/themes/twentythirteen/)
74
+ * [Twenty Fourteen](https://wordpress.org/themes/twentyfourteen/)
75
+ * [Twenty Fifteen](https://wordpress.org/themes/twentyfifteen/)
76
+ * [Twenty Sixteen](https://wordpress.org/themes/twentysixteen/)
77
+ * [Twenty Seventeen](https://wordpress.org/themes/twentyseventeen/)
78
+ * [Vantage](https://wordpress.org/themes/vantage/)
79
+ * [Virtue](https://wordpress.org/themes/virtue/)
80
+ * [Zerif Lite](http://themeisle.com/themes/zerif-lite/)
81
+
82
+ = The 404page plugin was sucessfully tested by the author with the following starter themes =
83
+ * [Bones](http://themble.com/bones/)
84
+ * [JointsWP](http://jointswp.com/)
85
+ * [undersores](http://underscores.me/)
86
+
87
+ = The 404page plugin was sucessfully tested by the author with the following plugins =
88
+ * [bbPress](https://wordpress.org/plugins/bbpress/)
89
+ * [BuddyPress](https://wordpress.org/plugins/buddypress/)
90
+ * [DW Question & Answer](https://www.designwall.com/wordpress/plugins/dw-question-answer/)
91
+ * [hashtagger](https://wordpress.org/plugins/hashtagger/)
92
+ * [Page Builder by SiteOrigin](https://wordpress.org/plugins/siteorigin-panels/)
93
+ * [Polylang](https://wordpress.org/plugins/polylang/)
94
+ * [User Submitted Posts](https://wordpress.org/plugins/user-submitted-posts/)
95
+ * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
96
+ * [WP Super Cache](https://wordpress.org/plugins/wp-super-cache/)(Read more about [WP Super Cache Compatibility](http://petersplugins.com/docs/404page/#wp_super_cache)
97
+ * [WPML WordPress Multilingual Plugin](https://wpml.org/)([officially approved by WPML team](https://wpml.org/plugin/404page/))
98
+
99
+ == For developers ==
100
+
101
+ = Action Hook =
102
+ The plugin adds an action hook 404page_after_404 which you can use to add extra functionality. The exact position the action occurs after an 404 error is detected depends on the Operating Method. Your function must not generate any output. There are no parameters.
103
+
104
+ = Native Support =
105
+ If you are a theme developer you can add native support for the 404page plugin to your theme for full control. [Read more](http://petersplugins.com/docs/404page/#theme_native_support).
106
+
107
  == Screenshots ==
108
 
109
  1. Create your 404 Page as a normal WordPress Page
112
 
113
  == Changelog ==
114
 
115
+ = 2.5 (2017-05-19) =
116
+ * hide 404 page from search results on front end (if WPML is active, all languages are hidden)
117
+ * do not fire a 404 in Compatibility Mode if the [DW Question & Answer plugin by DesignWall](https://www.designwall.com/wordpress/plugins/dw-question-answer/) is active and a question has no answers
118
+
119
  = 2.4 (2017-03-08) =
120
  * ensure that all core files are loaded properly ([See Topic](https://wordpress.org/support/topic/had-to-deactivate-404page-to-make-wordpress-correctly))
121
  * Polylang plugin does no longer require Compatibility Mode ([See Topic](https://wordpress.org/support/topic/still-displaying-the-themes-404-page-with-polylang/))
178
 
179
  == Upgrade Notice ==
180
 
181
+ = 2.5 =
182
+ Hhide 404 page from search results, compatibility with DW Question & Answer plugin
183
+
184
  = 2.4 =
185
  Version 2.4 fixes several issues. See [changelog](https://wordpress.org/plugins/404page/changelog/) for details.
186
 
197
  Version 2.0 is more or less a completely new development and a big step forward. [Read more](http://petersplugins.com/blog/2016/02/23/the-404page-plugin-now-works-with-wpml-and-other-enhancements/)
198
 
199
  = 1.4 =
200
+ Editing of the 404 page is now possible directly from settings page. Portuguese translation added.