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

Version Description

show an indicator if the currently edited page is a 404 error page

Download this release

Release Info

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

Code changes from version 4 to 5

Files changed (4) hide show
  1. 404page.php +9 -2
  2. assets/pluginicon.png +0 -0
  3. inc/class-404page.php +72 -14
  4. readme.txt +24 -9
404page.php CHANGED
@@ -9,7 +9,7 @@
9
* Plugin Name: 404page - your smart custom 404 error page
10
* Plugin URI: https://petersplugins.com/free-wordpress-plugins/404page/
11
* Description: Custom 404 the easy way! Set any page as custom 404 error page. No coding needed. Works with (almost) every Theme.
12
- * Version: 4
13
* Author: Peter Raschendorfer
14
* Author URI: https://petersplugins.com
15
* Text Domain: 404page
@@ -28,12 +28,19 @@ if ( ! defined( 'WPINC' ) ) {
28
* Load core plugin class and run the plugin
29
*/
30
require_once( plugin_dir_path( __FILE__ ) . '/inc/class-404page.php' );
31
- $pp_404page = new PP_404Page( __FILE__ );
32
33
34
/**
35
* Theme functions
36
*/
37
38
// this function can be used by a theme to check if there's an active custom 404 page
39
function pp_404_is_active() {
9
* Plugin Name: 404page - your smart custom 404 error page
10
* Plugin URI: https://petersplugins.com/free-wordpress-plugins/404page/
11
* Description: Custom 404 the easy way! Set any page as custom 404 error page. No coding needed. Works with (almost) every Theme.
12
+ * Version: 5
13
* Author: Peter Raschendorfer
14
* Author URI: https://petersplugins.com
15
* Text Domain: 404page
28
* Load core plugin class and run the plugin
29
*/
30
require_once( plugin_dir_path( __FILE__ ) . '/inc/class-404page.php' );
31
+ $pp_404page = new PP_404Page( array(
32
+ 'file' => __FILE__,
33
+ 'slug' => pathinfo( __FILE__, PATHINFO_FILENAME ),
34
+ 'name' => '404page - your smart custom 404 error page',
35
+ 'version' => '5'
36
+ )
37
+ );
38
39
40
/**
41
* Theme functions
42
*/
43
+
44
45
// this function can be used by a theme to check if there's an active custom 404 page
46
function pp_404_is_active() {
assets/pluginicon.png CHANGED
Binary file
inc/class-404page.php CHANGED
@@ -36,15 +36,16 @@ if ( !class_exists( 'PP_404Page' ) ) {
36
private $postid;
37
private $admin_handle;
38
39
-
40
/**
41
* here we go
42
*/
43
- public function __construct( $file ) {
44
- $this->_file = $file;
45
- $this->plugin_name = '404page';
46
- $this->plugin_slug = '404page';
47
- $this->version = '4';
48
$this->get_settings();
49
$this->load();
50
}
@@ -222,9 +223,12 @@ if ( !class_exists( 'PP_404Page' ) ) {
222
// that's it
223
224
if ( ! $this->settings['404page_native'] ) {
225
$wp_query = null;
226
$wp_query = new WP_Query();
227
$wp_query->query( 'page_id=' . $this->get_page_id() );
228
$wp_query->the_post();
229
$template = get_page_template();
230
rewind_posts();
@@ -273,7 +277,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
273
274
remove_action( 'pre_get_posts', array ( $this, 'exclude_404page' ) );
275
remove_filter( 'get_pages', array ( $this, 'remove_404page_from_array' ), 10, 2 );
276
-
277
global $wp_query;
278
$wp_query = null;
279
$wp_query = new WP_Query();
@@ -572,19 +576,70 @@ if ( !class_exists( 'PP_404Page' ) ) {
572
*/
573
function admin_style() {
574
575
- echo '<style type="text/css">#pp-plugin-info-404page { background-image: url(' . plugins_url( 'assets/pluginicon.png', $this->_file ) .'); }';
576
577
if ( $this->settings['404page_page_id'] > 0 ) {
578
579
foreach ( $this->get_all_page_ids() as $pid ) {
580
581
- echo ' #the-list #post-' . $pid . ' .column-title .row-title:before { content: "404"; background-color: #333; color: #FFF; display: inline-block; padding: 0 5px; margin-right: 10px; }';
582
583
}
584
585
}
586
587
- echo '</style>';
588
589
}
590
@@ -1048,8 +1103,11 @@ if ( !class_exists( 'PP_404Page' ) ) {
1048
1049
}
1050
?>
1051
- <div class="wrap" id="pp-404page-settings">
1052
- <h1 id="pp-plugin-info-404page"><?php echo $this->plugin_name; ?> <?php _e( 'Settings', '404page' ); ?><span><a class="dashicons dashicons-wordpress" href="<?php echo $this->wp_url; ?>/" title="<?php _e( 'wordpress.org plugin directory', '404page' ); ?>"></a> <a class="dashicons dashicons-admin-home" href="https://petersplugins.com/" title="<?php _e( 'Author homepage', '404page' );?>"></a> <a class="dashicons dashicons-googleplus" href="https://plus.google.com/+petersplugins" title="<?php _e( 'Authors Google+ Page', '404page' ); ?>"></a> <a class="dashicons dashicons-facebook-alt" href="https://www.facebook.com/petersplugins" title="<?php _e( 'Authors facebook Page', '404page' ); ?>"></a> <a class="dashicons dashicons-book-alt" href="<?php echo $this->dc_url; ?>" title="<?php _e( 'Plugin Doc', '404page' ); ?>"></a> <a class="dashicons dashicons-editor-help" href="https://wordpress.org/support/plugin/<?php echo $this->plugin_slug; ?>/" title="<?php _e( 'Support', '404page'); ?>"></a> <a class="dashicons dashicons-admin-comments" href="https://petersplugins.com/contact/" title="<?php _e( 'Contact Author', '404page' ); ?>"></a></span></h1>
1053
<?php settings_errors(); ?>
1054
<form method="post" action="options.php">
1055
<?php settings_fields( '404page_settings' ); ?>
@@ -1123,13 +1181,13 @@ if ( !class_exists( 'PP_404Page' ) ) {
1123
1124
if ( $pageid != 0 ) {
1125
1126
- $page = get_post( $pageid );
1127
1128
if ( !$page || $page->post_status != 'publish' ) {
1129
1130
$pageid = -1;
1131
1132
- }
1133
1134
}
1135
36
private $postid;
37
private $admin_handle;
38
39
/**
40
* here we go
41
*/
42
+ public function __construct( $settings ) {
43
+
44
+ $this->_file = $settings['file'];
45
+ $this->plugin_slug = $settings['slug'];
46
+ $this->plugin_name = $settings['name'];
47
+ $this->version = $settings['version'];
48
+
49
$this->get_settings();
50
$this->load();
51
}
223
// that's it
224
225
if ( ! $this->settings['404page_native'] ) {
226
+
227
$wp_query = null;
228
$wp_query = new WP_Query();
229
$wp_query->query( 'page_id=' . $this->get_page_id() );
230
+
231
+
232
$wp_query->the_post();
233
$template = get_page_template();
234
rewind_posts();
277
278
remove_action( 'pre_get_posts', array ( $this, 'exclude_404page' ) );
279
remove_filter( 'get_pages', array ( $this, 'remove_404page_from_array' ), 10, 2 );
280
+
281
global $wp_query;
282
$wp_query = null;
283
$wp_query = new WP_Query();
576
*/
577
function admin_style() {
578
579
+ if ( get_current_screen()->id == $this->admin_handle ) {
580
+
581
+ ?>
582
+ <style type="text/css">
583
+ #pp-404page-settings h1 span {
584
+ display: block;
585
+ line-height: 48px;
586
+ padding-left: 60px;
587
+ background-image: url(<?php echo plugins_url( 'assets/pluginicon.png', $this->_file ); ?>);
588
+ background-repeat: no-repeat;
589
+ background-color: #4B6F87;
590
+ color: #fff;
591
+ }
592
+ #pp-404page-settings h1 nav {
593
+ background-color: #fff;
594
+ text-align: right;
595
+ line-height: 1;
596
+ }
597
+ #pp-404page-settings h1 nav a {
598
+ display: inline-block;
599
+ padding: 6px;
600
+ color: #4B6F87;
601
+ }
602
+ #pp-404page-settings h1 nav a:hover, #pp-404page-settings h1 nav a:focus {
603
+ color: #104060;
604
+ }
605
+
606
+ </style>
607
+
608
+ <?php
609
+
610
+ }
611
612
if ( $this->settings['404page_page_id'] > 0 ) {
613
614
+ echo '<style type="text/css">';
615
+
616
foreach ( $this->get_all_page_ids() as $pid ) {
617
618
+ echo '#the-list #post-' . $pid . ' .column-title .row-title:before { content: "404"; background-color: #333; color: #FFF; display: inline-block; padding: 0 5px; margin-right: 10px; }';
619
620
}
621
622
+ echo '</style>';
623
+
624
}
625
626
+ // the currently edited page is a 404 error page
627
+ // @since 5
628
+ if ( get_current_screen()->id == 'page' && $this->settings['404page_page_id'] > 0 ) {
629
+
630
+ global $post;
631
+
632
+ $all404pages = $this->get_all_page_ids();
633
+ if ( in_array( $post->ID, $all404pages ) ) {
634
+
635
+ ?>
636
+ <style type="text/css">
637
+ h1.wp-heading-inline:before { content: "404"; background-color: #333; color: #FFF; display: inline-block; padding: 0 5px; margin-right: 10px; }';
638
+ </style>
639
+ <?php
640
+
641
+ }
642
+ }
643
644
}
645
1103
1104
}
1105
?>
1106
+ <div class="wrap 404page" id="pp-404page-settings">
1107
+ <h1>
1108
+ <span><?php echo $this->plugin_name; ?></span>
1109
+ <nav><a class="dashicons dashicons-star-filled" href="https://wordpress.org/support/plugin/<?php echo $this->plugin_slug; ?>/reviews/" title="<?php _e( 'Please rate plugin', '404page' ); ?>"></a><a class="dashicons dashicons-wordpress" href="<?php echo $this->wp_url; ?>/" title="<?php _e( 'wordpress.org plugin directory', '404page' ); ?>"></a><a class="dashicons dashicons-admin-home" href="https://petersplugins.com/" title="<?php _e( 'Author homepage', '404page' );?>"></a><a class="dashicons dashicons-googleplus" href="https://plus.google.com/+petersplugins" title="<?php _e( 'Authors Google+ Page', '404page' ); ?>"></a><a class="dashicons dashicons-facebook-alt" href="https://www.facebook.com/petersplugins/" title="<?php _e( 'Authors facebook Page', '404page' ); ?>"></a><a class="dashicons dashicons-book-alt" href="<?php echo $this->dc_url; ?>" title="<?php _e( 'Plugin Doc', '404page' ); ?>"></a><a class="dashicons dashicons-editor-help" href="https://wordpress.org/support/plugin/<?php echo $this->plugin_slug; ?>/" title="<?php _e( 'Support', '404page'); ?>"></a><a class="dashicons dashicons-admin-comments" href="https://petersplugins.com/contact/" title="<?php _e( 'Contact Author', '404page' ); ?>"></a></span>
1110
+ </h1>
1111
<?php settings_errors(); ?>
1112
<form method="post" action="options.php">
1113
<?php settings_fields( '404page_settings' ); ?>
1181
1182
if ( $pageid != 0 ) {
1183
1184
+ $page = get_post( $pageid );
1185
1186
if ( !$page || $page->post_status != 'publish' ) {
1187
1188
$pageid = -1;
1189
1190
+ }
1191
1192
}
1193
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://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.9
7
- Stable tag: 4
8
Requires PHP: 5.4
9
License: GPLv2 or later
10
License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -39,12 +39,17 @@ Video: [A quick Overview over the Advanced Settings](https://youtu.be/9rL9LbYiSJ
39
40
[Support Forum](https://wordpress.org/support/plugin/404page)
41
42
== Compatibility ==
43
44
= The 404page plugin was sucessfully tested by the author with the following themes =
45
* [Athena](https://wordpress.org/themes/athena/)
46
* [Customizr](https://wordpress.org/themes/customizr/) (Read more about [Customizr Compatibility Mode](http://petersplugins.com/docs/404page/#settings_operating_method))
47
- * [Enfold](https://themeforest.net/item/enfold-responsive-multipurpose-theme/4519990?ref=petersplugins)
48
* [evolve](https://wordpress.org/themes/evolve/)
49
* [GeneratePress](https://wordpress.org/themes/generatepress/)
50
* [Graphene](https://wordpress.org/themes/graphene/)
@@ -65,6 +70,7 @@ Video: [A quick Overview over the Advanced Settings](https://youtu.be/9rL9LbYiSJ
65
* [Vantage](https://wordpress.org/themes/vantage/)
66
* [Virtue](https://wordpress.org/themes/virtue/)
67
* [Zerif Lite](http://themeisle.com/themes/zerif-lite/)
68
69
= The 404page plugin was sucessfully tested by the author with the following starter themes =
70
* [Bones](http://themble.com/bones/)
@@ -80,8 +86,8 @@ Video: [A quick Overview over the Advanced Settings](https://youtu.be/9rL9LbYiSJ
80
* [Polylang](https://wordpress.org/plugins/polylang/)
81
* [User Submitted Posts](https://wordpress.org/plugins/user-submitted-posts/)
82
* [WooCommerce](https://wordpress.org/plugins/woocommerce/)
83
- * [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)
84
- * [WPML WordPress Multilingual Plugin](https://wpml.org/)([officially approved by WPML team](https://wpml.org/plugin/404page/))
85
86
== For developers ==
87
@@ -98,12 +104,14 @@ If you are a theme developer you can add native support for the 404page plugin t
98
* **[smart User Slug Hider](https://wordpress.org/plugins/smart-user-slug-hider/)** - Hide usernames in author pages URLs to enhance security
99
* [See all](https://profiles.wordpress.org/petersplugins/#content-plugins)
100
101
== Screenshots ==
102
103
- 1. Create your costom 404 Error Page as a normal WordPress Page
104
- 2. Set the created Page as 404 Error Page
105
- 3. Advanced Settings
106
- 4. Advanced Settings with WPML plugin installed (Compatibility Mode is not available, because the 404page plugin automatically switches to WMPL mode)
107
108
== Frequently Asked Questions ==
109
@@ -121,7 +129,11 @@ The 404page plugin adds a CSS class `error404` to the `<body>` tag which can be
121
122
== Changelog ==
123
124
- = 4 ( 2018-03-05) =
125
* bugfix for bbPress ([See Topic](https://wordpress.org/support/topic/not-fully-bbpress-compatible/)
126
127
= 3.3 (2017-11-16) =
@@ -212,6 +224,9 @@ The 404page plugin adds a CSS class `error404` to the `<body>` tag which can be
212
213
== Upgrade Notice ==
214
215
= 4 =
216
bugfix for bbPress
217
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.9
7
+ Stable tag: 5
8
Requires PHP: 5.4
9
License: GPLv2 or later
10
License URI: http://www.gnu.org/licenses/gpl-2.0.html
39
40
[Support Forum](https://wordpress.org/support/plugin/404page)
41
42
+ == GDPR Info ==
43
+
44
+ This plugin is fully GDPR compliant. It does not set cookies. It does not collect or store any data. It does not send any data to external servers.
45
+
46
+ [Peters' Plugins GDPR Compliance Information Page](https://petersplugins.com/gdpr-compliance-information/)
47
+
48
== Compatibility ==
49
50
= The 404page plugin was sucessfully tested by the author with the following themes =
51
* [Athena](https://wordpress.org/themes/athena/)
52
* [Customizr](https://wordpress.org/themes/customizr/) (Read more about [Customizr Compatibility Mode](http://petersplugins.com/docs/404page/#settings_operating_method))
53
* [evolve](https://wordpress.org/themes/evolve/)
54
* [GeneratePress](https://wordpress.org/themes/generatepress/)
55
* [Graphene](https://wordpress.org/themes/graphene/)
70
* [Vantage](https://wordpress.org/themes/vantage/)
71
* [Virtue](https://wordpress.org/themes/virtue/)
72
* [Zerif Lite](http://themeisle.com/themes/zerif-lite/)
73
+ **Note**: The [Enfold](https://themeforest.net/item/enfold-responsive-multipurpose-theme/4519990?ref=petersplugins) Theme is no longer supported because the Theme now has its own custom 404 error page feature.
74
75
= The 404page plugin was sucessfully tested by the author with the following starter themes =
76
* [Bones](http://themble.com/bones/)
86
* [Polylang](https://wordpress.org/plugins/polylang/)
87
* [User Submitted Posts](https://wordpress.org/plugins/user-submitted-posts/)
88
* [WooCommerce](https://wordpress.org/plugins/woocommerce/)
89
+ * [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))
90
+ * [WPML WordPress Multilingual Plugin](https://wpml.org/) ([officially approved by WPML team](https://wpml.org/plugin/404page/))
91
92
== For developers ==
93
104
* **[smart User Slug Hider](https://wordpress.org/plugins/smart-user-slug-hider/)** - Hide usernames in author pages URLs to enhance security
105
* [See all](https://profiles.wordpress.org/petersplugins/#content-plugins)
106
107
+ == Stay up to date ==
108
+
109
+ [Follow me on Google+](https://plus.google.com/+petersplugins)
110
+ [Follow me on Facebook](https://www.facebook.com/petersplugins/)
111
+
112
== Screenshots ==
113
114
+ 1. How to easily create your custom 404 error page
115
116
== Frequently Asked Questions ==
117
129
130
== Changelog ==
131
132
+ = 5 (2018-03-05) =
133
+ * show an indicator if the currently edited page is a 404 error page
134
+ * minor code- & UI-improvements
135
+
136
+ = 4 (2018-03-05) =
137
* bugfix for bbPress ([See Topic](https://wordpress.org/support/topic/not-fully-bbpress-compatible/)
138
139
= 3.3 (2017-11-16) =
224
225
== Upgrade Notice ==
226
227
+ = 5 =
228
+ show an indicator if the currently edited page is a 404 error page
229
+
230
= 4 =
231
bugfix for bbPress
232