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

Version Description

workaround for WordPress bug

Download this release

Release Info

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

Code changes from version 9 to 10

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: 9
13
* Author: Peter Raschendorfer
14
* Author URI: https://petersplugins.com
15
* Text Domain: 404page
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: 10
13
* Author: Peter Raschendorfer
14
* Author URI: https://petersplugins.com
15
* Text Domain: 404page
assets/css/404page-ui.css CHANGED
@@ -7,11 +7,6 @@
7
width: auto;
8
}
9
10
- #pp-404page-settings .form-table th {
11
- padding: 0;
12
- font-weight: normal;
13
- }
14
-
15
#pp-404page-settings .form-table td {
16
padding: 0;
17
margin-bottom: 20px;
@@ -23,60 +18,9 @@
23
margin-bottom: 20px;
24
}
25
26
- #pp-settings-advanced .form-table th {
27
- display: none;
28
- }
29
-
30
- #pp-404page-settings input[type="checkbox"] {
31
- display: none;
32
- }
33
-
34
- #pp-404page-settings input[type="checkbox"] + label.check {
35
- cursor: pointer;
36
- text-indent: -9999px;
37
- width: 80px;
38
- height: 40px;
39
- background: grey;
40
- display: block;
41
- border-radius: 40px;
42
- position: relative;
43
- float: left;
44
- margin-right: 40px;
45
- }
46
-
47
- .rtl #pp-404page-settings input[type="checkbox"] + label.check {
48
- float: right;
49
- margin-left: 40px;
50
- margin-right: 0;
51
- }
52
-
53
- #pp-404page-settings input[type="checkbox"]:disabled + label.check {
54
- background-color: #DDD;
55
- }
56
-
57
- #pp-404page-settings input[type="checkbox"] + label.check:after {
58
- content: '';
59
- position: absolute;
60
- top: 5px;
61
- width: 30px;
62
- height: 30px;
63
- background: #fff;
64
- border-radius: 30px;
65
- transition: 0.3s;
66
- }
67
-
68
- body:not(.rtl) #pp-404page-settings input[type="checkbox"] + label.check:after, .rtl #pp-404page-settings input[type="checkbox"]:enabled:checked + label.check:after {
69
- left: 5px;
70
- transform: none;
71
- }
72
-
73
- #pp-404page-settings input[type="checkbox"]:enabled:checked + label.check {
74
- background: #104060;
75
- }
76
-
77
- body:not(.rtl) #pp-404page-settings input[type="checkbox"]:enabled:checked + label.check:after, .rtl #pp-404page-settings input[type="checkbox"] + label.check:after {
78
- left: calc(100% - 5px);
79
- transform: translateX(-100%);
80
}
81
82
#pp-404page-settings select {
7
width: auto;
8
}
9
10
#pp-404page-settings .form-table td {
11
padding: 0;
12
margin-bottom: 20px;
18
margin-bottom: 20px;
19
}
20
21
+ #pp-404page-settings .form-table th {
22
+ padding: 0;
23
+ font-weight: normal;
24
}
25
26
#pp-404page-settings select {
assets/css/pp-admin-page-v2.css ADDED
@@ -0,0 +1,120 @@
1
+ .pp-admin-page-wrapper h1 {
2
+ margin-bottom: 32px;
3
+ }
4
+
5
+ .pp-admin-page-wrapper h1>span {
6
+ display: block;
7
+ line-height: 48px;
8
+ padding-left: 60px;
9
+ background-image: url(../img/pluginicon.png);
10
+ background-repeat: no-repeat;
11
+ background-color: #4B6F87;
12
+ color: #fff;
13
+ }
14
+
15
+ .rtl .pp-admin-page-wrapper h1>span {
16
+ padding-left: 0;
17
+ padding-right: 60px;
18
+ background-position: right top;
19
+ }
20
+
21
+ .pp-admin-page-wrapper h1 nav {
22
+ text-align: right;
23
+ line-height: 1;
24
+ border-right: 1px solid #4B6F87;
25
+ }
26
+
27
+ .rtl .pp-admin-page-wrapper h1 nav {
28
+ text-align: left;
29
+ }
30
+
31
+ .pp-admin-page-wrapper h1 nav a {
32
+ display: inline-block;
33
+ padding: 6px;
34
+ color: #4B6F87;
35
+ background-color: #fff;
36
+ text-decoration: none;
37
+ font-size: 12px;
38
+ height: 20px;
39
+ line-height: 20px;
40
+ border-left: 1px solid #4B6F87;
41
+ border-bottom: 1px solid #4B6F87;
42
+ }
43
+
44
+ .pp-admin-page-wrapper h1 nav a span.text {
45
+ white-space: nowrap;
46
+ padding-left: 4px;
47
+ display: none;
48
+ }
49
+
50
+ @media only screen and (min-width: 1200px) {
51
+ .pp-admin-page-wrapper h1 nav a span.text {
52
+ display: inline;
53
+ }
54
+ }
55
+
56
+ .pp-admin-page-wrapper h1 nav a:hover, .pp-admin-page-wrapper h1 nav a:focus {
57
+ background-color: #4B6F87;
58
+ color: #fff;
59
+ }
60
+
61
+ .pp-admin-page-hide-th th {
62
+ display: none;
63
+ }
64
+
65
+ .pp-admin-page-wrapper .toggle {
66
+ height: 40px;
67
+ line-height: 40px;
68
+ }
69
+
70
+ .pp-admin-page-wrapper .toggle input[type="checkbox"] {
71
+ display: none;
72
+ }
73
+
74
+ .pp-admin-page-wrapper .toggle input[type="checkbox"] + label {
75
+ cursor: pointer;
76
+ text-indent: -9999px;
77
+ width: 80px;
78
+ height: 40px;
79
+ background: grey;
80
+ display: block;
81
+ border-radius: 40px;
82
+ position: relative;
83
+ float: left;
84
+ margin-right: 40px;
85
+ }
86
+
87
+ .rtl .pp-admin-page-wrapper .toggle input[type="checkbox"] + label {
88
+ float: right;
89
+ margin-left: 40px;
90
+ margin-right: 0;
91
+ }
92
+
93
+ .pp-admin-page-wrapper .toggle input[type="checkbox"]:disabled + label {
94
+ background-color: #DDD;
95
+ }
96
+
97
+ .pp-admin-page-wrapper .toggle input[type="checkbox"] + label:after {
98
+ content: '';
99
+ position: absolute;
100
+ top: 5px;
101
+ width: 30px;
102
+ height: 30px;
103
+ background: #fff;
104
+ border-radius: 30px;
105
+ transition: 0.3s;
106
+ }
107
+
108
+ body:not(.rtl) .pp-admin-page-wrapper .toggle input[type="checkbox"] + label:after, .rtl .pp-admin-page-wrapper .toggle input[type="checkbox"]:checked + label:after {
109
+ left: 5px;
110
+ transform: none;
111
+ }
112
+
113
+ .pp-admin-page-wrapper .toggle input[type="checkbox"]:enabled:checked + label {
114
+ background: #104060;
115
+ }
116
+
117
+ body:not(.rtl) .pp-admin-page-wrapper .toggle input[type="checkbox"]:checked + label:after, .rtl .pp-admin-page-wrapper .toggle input[type="checkbox"] + label:after {
118
+ left: calc(100% - 5px);
119
+ transform: translateX(-100%);
120
+ }
assets/css/pp-admin-page.css DELETED
@@ -1,55 +0,0 @@
1
- .pp-admin-page-wrapper h1>span {
2
- display: block;
3
- line-height: 48px;
4
- padding-left: 60px;
5
- background-image: url(../img/pluginicon.png);
6
- background-repeat: no-repeat;
7
- background-color: #4B6F87;
8
- color: #fff;
9
- }
10
-
11
- .rtl .pp-admin-page-wrapper h1>span {
12
- padding-left: 0;
13
- padding-right: 60px;
14
- background-position: right top;
15
- }
16
-
17
- .pp-admin-page-wrapper h1 nav {
18
- text-align: right;
19
- line-height: 1;
20
- border-right: 1px solid #4B6F87;
21
- }
22
-
23
- .rtl .pp-admin-page-wrapper h1 nav {
24
- text-align: left;
25
- }
26
-
27
- .pp-admin-page-wrapper h1 nav a {
28
- display: inline-block;
29
- padding: 6px;
30
- color: #4B6F87;
31
- background-color: #fff;
32
- text-decoration: none;
33
- font-size: 12px;
34
- height: 20px;
35
- line-height: 20px;
36
- border-left: 1px solid #4B6F87;
37
- border-bottom: 1px solid #4B6F87;
38
- }
39
-
40
- .pp-admin-page-wrapper h1 nav a span.text {
41
- white-space: nowrap;
42
- padding-left: 4px;
43
- display: none;
44
- }
45
-
46
- @media only screen and (min-width: 1200px) {
47
- .pp-admin-page-wrapper h1 nav a span.text {
48
- display: inline;
49
- }
50
- }
51
-
52
- .pp-admin-page-wrapper h1 nav a:hover, .pp-admin-page-wrapper h1 nav a:focus {
53
- background-color: #4B6F87;
54
- color: #fff;
55
- }
inc/admin/404page-admin-page.php CHANGED
@@ -1,25 +1,25 @@
1
<div class="wrap pp-admin-page-wrapper" id="pp-404page-settings">
2
<h1>
3
- <span><?php echo $this->get_plugin_name(); ?></span>
4
<nav>
5
<?php $this->show_nav_icons( array(
6
array(
7
- 'link' => 'https://wordpress.org/support/plugin/' . $this->get_plugin_slug() . '/reviews/',
8
'title' => __( 'Please rate Plugin', '404page' ),
9
'icon' => 'dashicons-star-filled'
10
),
11
array(
12
- 'link' => 'https://wordpress.org/plugins/' . $this->get_plugin_slug(),
13
'title' => __( 'WordPress.org Plugin Page', '404page' ),
14
'icon' => 'dashicons-wordpress'
15
),
16
array(
17
- 'link' => 'https://petersplugins.com/docs/' . $this->get_plugin_slug(),
18
'title' => __( 'Plugin Doc', '404page' ),
19
'icon' => 'dashicons-book-alt'
20
),
21
array(
22
- 'link' => 'https://wordpress.org/support/plugin/' . $this->get_plugin_slug(),
23
'title' => __( 'Support', '404page' ),
24
'icon' => 'dashicons-editor-help'
25
),
1
<div class="wrap pp-admin-page-wrapper" id="pp-404page-settings">
2
<h1>
3
+ <span><?php echo $this->_core->get_plugin_name(); ?></span>
4
<nav>
5
<?php $this->show_nav_icons( array(
6
array(
7
+ 'link' => 'https://wordpress.org/support/plugin/' . $this->_core->get_plugin_slug() . '/reviews/',
8
'title' => __( 'Please rate Plugin', '404page' ),
9
'icon' => 'dashicons-star-filled'
10
),
11
array(
12
+ 'link' => 'https://wordpress.org/plugins/' . $this->_core->get_plugin_slug(),
13
'title' => __( 'WordPress.org Plugin Page', '404page' ),
14
'icon' => 'dashicons-wordpress'
15
),
16
array(
17
+ 'link' => 'https://petersplugins.com/docs/' . $this->_core->get_plugin_slug(),
18
'title' => __( 'Plugin Doc', '404page' ),
19
'icon' => 'dashicons-book-alt'
20
),
21
array(
22
+ 'link' => 'https://wordpress.org/support/plugin/' . $this->_core->get_plugin_slug(),
23
'title' => __( 'Support', '404page' ),
24
'icon' => 'dashicons-editor-help'
25
),
inc/class-404page-admin.php ADDED
@@ -0,0 +1,480 @@
1
+ <?php
2
+
3
+ /**
4
+ * The 404page admin plugin class
5
+ *
6
+ * @since 10
7
+ */
8
+
9
+ if ( ! defined( 'WPINC' ) ) {
10
+ die;
11
+ }
12
+
13
+ /**
14
+ * The admin plugin class
15
+ */
16
+ if ( !class_exists( 'PP_404Page_Admin' ) ) {
17
+
18
+ class PP_404Page_Admin {
19
+
20
+ /**
21
+ * reference to core class
22
+ *
23
+ * @since 10
24
+ * @var object
25
+ * @access private
26
+ */
27
+ private $_core;
28
+
29
+
30
+ /**
31
+ * reference to settings class
32
+ *
33
+ * @since 10
34
+ * @var object
35
+ * @access private
36
+ */
37
+ private $_settings;
38
+
39
+
40
+ /**
41
+ * admin handle
42
+ *
43
+ * @since 10
44
+ * @var object
45
+ * @access private
46
+ */
47
+ private $admin_handle;
48
+
49
+
50
+ /**
51
+ * Initialize the class
52
+ *
53
+ * @since 10
54
+ * @access public
55
+ */
56
+ public function __construct( $_core, $_settings ) {
57
+
58
+ $this->_core = $_core;
59
+ $this->_settings = $_settings;
60
+
61
+ $this->init();
62
+
63
+ }
64
+
65
+
66
+ /**
67
+ * Do Init
68
+ *
69
+ * @since 10
70
+ * @access private
71
+ */
72
+ private function init() {
73
+
74
+ add_action( 'admin_init', array( $this, 'admin_init' ) );
75
+ add_action( 'admin_menu', array( $this, 'admin_menu' ) );
76
+ add_action( 'admin_head', array( $this, 'admin_style' ) );
77
+ add_filter( 'plugin_action_links_' . plugin_basename( $this->_core->get_plugin_file() ), array( $this, 'add_settings_links' ) );
78
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_js' ) );
79
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_css' ) );
80
+ add_action( 'admin_notices', array( $this, 'admin_notices' ) );
81
+ add_action( 'wp_ajax_pp_404page_dismiss_admin_notice', array( $this, 'dismiss_admin_notice' ) );
82
+
83
+ }
84
+
85
+
86
+ /**
87
+ * init admin
88
+ * moved to PP_404Page_Admin in v 10
89
+ */
90
+ function admin_init() {
91
+
92
+ $this->_settings->set_method();
93
+
94
+
95
+ add_settings_section( '404page-settings', null, null, '404page_settings_section' );
96
+ add_settings_section( '404page-settings', null, null, '404page_settings_section_advanced' );
97
+ register_setting( '404page_settings', '404page_page_id' );
98
+ register_setting( '404page_settings', '404page_hide' );
99
+ register_setting( '404page_settings', '404page_method', array( $this, 'handle_method' ) );
100
+ register_setting( '404page_settings', '404page_fire_error' );
101
+ register_setting( '404page_settings', '404page_force_error' );
102
+ register_setting( '404page_settings', '404page_no_url_guessing' );
103
+ register_setting( '404page_settings', '404page_http410_if_trashed' );
104
+ add_settings_field( '404page_settings_404page', __( 'Page to be displayed as 404 page', '404page' ) . '&nbsp;<a class="dashicons dashicons-editor-help" href="https://petersplugins.com/docs/' . $this->_core->get_plugin_slug() . '/#settings_select_page"></a>' , array( $this, 'admin_404page' ), '404page_settings_section', '404page-settings', array( 'label_for' => '404page_page_id' ) );
105
+ add_settings_field( '404page_settings_hide', '' , array( $this, 'admin_hide' ), '404page_settings_section_advanced', '404page-settings', array( 'label_for' => '404page_hide' ) );
106
+ add_settings_field( '404page_settings_fire', '' , array( $this, 'admin_fire404' ), '404page_settings_section_advanced', '404page-settings', array( 'label_for' => '404page_fire_error' ) );
107
+ add_settings_field( '404page_settings_force', '' , array( $this, 'admin_force404' ), '404page_settings_section_advanced', '404page-settings', array( 'label_for' => '404page_force_error' ) );
108
+ add_settings_field( '404page_settings_noguess', '' , array( $this, 'admin_noguess' ), '404page_settings_section_advanced', '404page-settings', array( 'label_for' => '404page_no_url_guessing' ) );
109
+ add_settings_field( '404page_settings_http410', '' , array( $this, 'admin_http410' ), '404page_settings_section_advanced', '404page-settings', array( 'label_for' => '404page_http410_if_trashed' ) );
110
+ add_settings_field( '404page_settings_method', '', array( $this, 'admin_method' ), '404page_settings_section_advanced', '404page-settings', array( 'label_for' => '404page_method' ) );
111
+ }
112
+
113
+
114
+ /**
115
+ * handle the method setting
116
+ * moved to PP_404Page_Admin in v 10
117
+ */
118
+ function handle_method( $method ) {
119
+
120
+ if ( null === $method ) {
121
+
122
+ $method = 'STD';
123
+
124
+ }
125
+
126
+ return $method;
127
+
128
+ }
129
+
130
+
131
+ /**
132
+ * handle the settings field hide
133
+ * moved to PP_404Page_Admin in v 10
134
+ */
135
+ function admin_hide() {
136
+
137
+ echo '<p class="toggle"><input type="checkbox" id="404page_hide" name="404page_hide" value="1"' . checked( true, $this->_settings->get_hide(), false ) . '/>';
138
+ echo '<label for="404page_hide" class="check"></label>' . __( 'Hide the selected page from the Pages list', '404page' ) . '&nbsp;<a class="dashicons dashicons-editor-help" href="https://petersplugins.com/docs/' . $this->_core->get_plugin_slug() . '/#settings_hide_page"></a><br />';
139
+ echo '<span class="dashicons dashicons-info"></span>&nbsp;' . __( 'For Administrators the page is always visible.', '404page' ) . '</p><div class="clear"></div>';
140
+
141
+ }
142
+
143
+
144
+ /**
145
+ * handle the settings field fire 404 error
146
+ * moved to PP_404Page_Admin in v 10
147
+ */
148
+ function admin_fire404() {
149
+
150
+ echo '<p class="toggle"><input type="checkbox" id="404page_fire_error" name="404page_fire_error" value="1"' . checked( true, $this->_settings->get_fire_error(), false ) . '/>';
151
+ echo '<label for="404page_fire_error" class="check"></label>' . __( 'Send an 404 error if the page is accessed directly by its URL', '404page' ) . '&nbsp;<a class="dashicons dashicons-editor-help" href="https://petersplugins.com/docs/' . $this->_core->get_plugin_slug() . '/#settings_fire_404"></a><br />';
152
+ echo '<span class="dashicons dashicons-info"></span>&nbsp;' . __( 'Uncheck this if you want the selected page to be accessible.', '404page' );
153
+
154
+ if ( function_exists( 'wpsupercache_activate' ) ) {
155
+
156
+ echo '<br /><span class="dashicons dashicons-warning"></span>&nbsp;<strong>' . __( 'WP Super Cache Plugin detected', '404page' ) . '</strong>. ' . __ ( 'If the page you selected as 404 error page is in cache, always a HTTP code 200 is sent. To avoid this and send a HTTP code 404 you have to exlcude this page from caching', '404page' ) . ' (<a href="' . admin_url( 'options-general.php?page=wpsupercache&tab=settings#rejecturi' ) . '">' . __( 'Click here', '404page' ) . '</a>).<br />(<a href="https://petersplugins.com/docs/' . $this->_core->get_plugin_slug() . '/#wp_super_cache">' . __( 'Read more', '404page' ) . '</a>)';
157
+
158
+ }
159
+
160
+ echo '</p><div class="clear"></div>';
161
+
162
+ }
163
+
164
+
165
+ /**
166
+ * handle the settings field to force an 404 error
167
+ * moved to PP_404Page_Admin in v 10
168
+ */
169
+ function admin_force404() {
170
+
171
+ echo '<p class="toggle"><input type="checkbox" id="404page_force_error" name="404page_force_error" value="1"' . checked( true, $this->_settings->get_force_error(), false ) . '/>';
172
+ echo '<label for="404page_force_error" class="check warning"></label>' . __( 'Force 404 error after loading page', '404page' ) . '&nbsp;<a class="dashicons dashicons-editor-help" href="https://petersplugins.com/docs/' . $this->_core->get_plugin_slug() . '/#settings_force_404"></a>&nbsp;<a class="dashicons dashicons-video-alt3" href="https://youtu.be/09OOCbFLfnI" data-lity></a><br />';
173
+ echo '<span class="dashicons dashicons-warning"></span>&nbsp;' . __( 'Generally this is not needed. It is not recommended to activate this option, unless it is necessary. Please note that this may cause problems with your theme.', '404page' ) . '</p><div class="clear"></div>';
174
+
175
+ }
176
+
177
+
178
+ /**
179
+ * handle the settings field to stop URL guessing
180
+ * moved to PP_404Page_Admin in v 10
181
+ */
182
+ function admin_noguess() {
183
+
184
+ echo '<p class="toggle"><input type="checkbox" id="404page_no_url_guessing" name="404page_no_url_guessing" value="1"' . checked( true, $this->_settings->get_no_url_guessing(), false ) . '/>';
185
+ echo '<label for="404page_no_url_guessing" class="check warning"></label>' . __( 'Disable URL autocorrection guessing', '404page' ) . '&nbsp;<a class="dashicons dashicons-editor-help" href="https://petersplugins.com/docs/' . $this->_core->get_plugin_slug() . '/#settings_stop_guessing"></a>&nbsp;<a class="dashicons dashicons-video-alt3" href="https://youtu.be/H0EdtFcAGl4" data-lity></a><br />';
186
+ echo '<span class="dashicons dashicons-warning"></span>&nbsp;' . __( 'This stops WordPress from URL autocorrection guessing. Only activate, if you are sure about the consequences.', '404page' ) . '</p><div class="clear"></div>';
187
+
188
+ }
189
+
190
+
191
+ /**
192
+ * handle the settings field to send an http 410 error in case the object is trashed
193
+ * @since 3.2
194
+ * moved to PP_404Page_Admin in v 10
195
+ */
196
+ function admin_http410() {
197
+
198
+ echo '<p class="toggle"><input type="checkbox" id="404page_http410_if_trashed" name="404page_http410_if_trashed" value="1"' . checked( true, $this->_settings->get_http410_if_trashed(), false ) . '/>';
199
+ echo '<label for="404page_http410_if_trashed" class="check"></label>' . __( 'Send an HTTP 410 error instead of HTTP 404 in case the requested object is in trash', '404page' ) . '&nbsp;<a class="dashicons dashicons-editor-help" href="https://petersplugins.com/docs/' . $this->_core->get_plugin_slug() . '/#settings_maybe_send_http410"></a>&nbsp;<a class="dashicons dashicons-video-alt3" href="https://youtu.be/O5xPM0BMZxM" data-lity></a><br />';
200
+ echo '<span class="dashicons dashicons-info"></span>&nbsp;' . __( 'Check this if you want to inform search engines that the resource requested is no longer available and will not be available again so it can be removed from the search index immediately.', '404page' );
201
+
202
+ }
203
+
204
+
205
+ /**
206
+ * handle the settings field method
207
+ * moved to PP_404Page_Admin in v 10
208
+ */
209
+ function admin_method() {
210
+
211
+ if ( $this->_settings->get_native() || defined( 'CUSTOMIZR_VER' ) || defined( 'ICL_SITEPRESS_VERSION' ) ) {
212
+
213
+ $dis = ' disabled="disabled"';
214
+
215
+ } else {
216
+
217
+ $dis = '';
218
+ }
219
+
220
+ echo '<p class="toggle"><input type="checkbox" id="404page_method" name="404page_method" value="CMP"' . checked( 'CMP', $this->_settings->get_method(), false ) . $dis . '/>';
221
+ echo '<label for="404page_method" class="check"></label>' . __( 'Activate Compatibility Mode', '404page' ) . '&nbsp;<a class="dashicons dashicons-editor-help" href="https://petersplugins.com/docs/' . $this->_core->get_plugin_slug() . '/#settings_operating_method"></a>&nbsp;<a class="dashicons dashicons-video-alt3" href="https://youtu.be/wqSepDyQeqY" data-lity></a><br />';
222
+ echo '<span class="dashicons dashicons-info"></span>&nbsp;';
223
+
224
+ if ( $this->_settings->get_native() ) {
225
+
226
+ _e( 'This setting is not available because the Theme you are using natively supports the 404page plugin.', '404page' );
227
+ echo ' (<a href="https://petersplugins.com/docs/' . $this->_core->get_plugin_slug() . '/#native_mode">' . __( 'Read more', '404page' ) . '</a>)';
228
+
229
+ } elseif ( defined( 'CUSTOMIZR_VER' ) ) {
230
+
231
+ _e( 'This setting is not availbe because the 404page Plugin works in Customizr Compatibility Mode.', '404page' );
232
+ echo ' (<a href="https://petersplugins.com/docs/' . $this->_core->get_plugin_slug() . '/#special_modes">' . __( 'Read more', '404page' ) . '</a>)';
233
+
234
+ } elseif ( defined( 'ICL_SITEPRESS_VERSION' ) ) {
235
+
236
+ _e( 'This setting is not availbe because the 404page Plugin works in WPML Mode.', '404page' );
237
+ echo ' (<a href="https://petersplugins.com/docs/' . $this->_core->get_plugin_slug() . '/#special_modes">' . __( 'Read more', '404page' ) . '</a>)';
238
+
239
+ } else {
240
+
241
+ _e( 'If you are using a theme or plugin that modifies the WordPress Template System, the 404page plugin may not work properly. Compatibility Mode maybe can fix the problem. Activate Compatibility Mode only if you have any problems.', '404page' );
242
+
243
+ }
244
+
245
+ echo '</p><div class="clear"></div>';
246
+
247
+ }
248
+
249
+
250
+ /**
251
+ * create the menu entry
252
+ * moved to PP_404Page_Admin in v 10
253
+ */
254
+ function admin_menu() {
255
+ $this->admin_handle = add_theme_page ( __( '404 Error Page', "404page" ), __( '404 Error Page', '404page' ), 'manage_options', '404pagesettings', array( $this, 'show_admin' ) );
256
+ }
257
+
258
+
259
+ /**
260
+ * add admin css to header
261
+ * moved to PP_404Page_Admin in v 10
262
+ */
263
+ function admin_style() {
264
+
265
+ if ( $this->_core->get_id() > 0 ) {
266
+
267
+ echo '<style type="text/css">';
268
+
269
+ foreach ( $this->_core->get_all_page_ids() as $pid ) {
270
+
271
+ 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; }';
272
+
273
+ }
274
+
275
+ echo '</style>';
276
+
277
+ }
278
+
279
+ }
280
+
281
+
282
+ /**
283
+ * handle the settings field page id
284
+ * moved to PP_404Page_Admin in v 10
285
+ */
286
+ function admin_404page() {
287
+
288
+ if ( $this->_core->get_id() < 0 ) {
289
+
290
+ echo '<div class="error form-invalid" style="line-height: 3em">' . __( 'The page you have selected as 404 page does not exist anymore. Please choose another page.', '404page' ) . '</div>';
291
+ }
292
+
293
+ wp_dropdown_pages( array( 'name' => '404page_page_id', 'id' => 'select404page', 'echo' => 1, 'show_option_none' => __( '&mdash; NONE (WP default 404 page) &mdash;', '404page'), 'option_none_value' => '0', 'selected' => $this->_core->get_id() ) );
294
+
295
+ echo '<div id="404page_edit_link" style="display: none">' . get_edit_post_link( $this->_core->get_id() ) . '</div>';
296
+ echo '<div id="404page_test_link" style="display: none">' . get_site_url() . '/404page-test-' . md5( rand() ) . '</div>';
297
+ echo '<div id="404page_current_value" style="display: none">' . $this->_core->get_id() . '</div>';
298
+ echo '<p class="submit"><input type="button" name="edit_404_page" id="edit_404_page" class="button secondary" value="' . __( 'Edit Page', '404page' ) . '" />&nbsp;<input type="button" name="test_404_page" id="test_404_page" class="button secondary" value="' . __( 'Test 404 error', '404page' ) . '" /></p>';
299
+
300
+ }
301
+
302
+
303
+ /**
304
+ * add admin css file
305
+ * moved to PP_404Page_Admin in v 10
306
+ */
307
+ function admin_css() {
308
+
309
+ if ( get_current_screen()->id == $this->admin_handle ) {
310
+
311
+ wp_enqueue_style( '404pagelity', $this->_core->get_asset_file( 'css', 'lity.min.css' ) );
312
+ wp_enqueue_style( 'pp-admin-page', $this->_core->get_asset_file( 'css', 'pp-admin-page-v2.css' ) );
313
+ wp_enqueue_style( '404pagecss', $this->_core->get_asset_file( 'css', '404page-ui.css' ) );
314
+
315
+ }
316
+
317
+ }
318
+
319
+
320
+ /**
321
+ * add admin js files
322
+ * moved to PP_404Page_Admin in v 10
323
+ */
324
+ function admin_js() {
325
+
326
+ wp_enqueue_script( '404pagejs', $this->_core->get_asset_file( 'js', '404page.js' ), 'jquery', $this->_core->get_plugin_version(), true );
327
+
328
+ if ( get_current_screen()->id == $this->admin_handle ) {
329
+
330
+ wp_enqueue_script( '404page-ui', $this->_core->get_asset_file( 'js', '404page-ui.js' ), 'jquery', $this->_core->get_plugin_version(), true );
331
+ wp_enqueue_script( '404page-lity', $this->_core->get_asset_file( 'js', 'lity.min.js' ), 'jquery', $this->_core->get_plugin_version(), true );
332
+
333
+ }
334
+
335
+ }
336
+
337
+
338
+ /**
339
+ * show admin page
340
+ * moved to PP_404Page_Admin in v 10
341
+ */
342
+ function show_admin() {
343
+
344
+ if ( !current_user_can( 'manage_options' ) ) {
345
+
346
+ wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
347
+
348
+ }
349
+
350
+ require_once( plugin_dir_path( $this->_core->get_plugin_file() ) . '/inc/admin/404page-admin-page.php' );
351
+
352
+ }
353
+
354
+
355
+ /**
356
+ * show the nav icons
357
+ * @since 6
358
+ * moved to PP_404Page_Admin in v 10
359
+ */
360
+ function show_nav_icons( $icons ) {
361
+
362
+ foreach ( $icons as $icon ) {
363
+
364
+ echo '<a href="' . $icon['link'] . '" title="' . $icon['title'] . '"><span class="dashicons ' . $icon['icon'] . '"></span><span class="text">' . $icon['title'] . '</span></a>';
365
+
366
+ }
367
+
368
+ }
369
+
370
+
371
+ /**
372
+ * show admin notices
373
+ * moved to PP_404Page_Admin in v 10
374
+ */
375
+ function admin_notices() {
376
+
377
+ // @since 8
378
+ // show update notice
379
+
380
+ /**
381
+ * no notice in version 10
382
+ *
383
+ *
384
+ * if ( current_user_can( 'manage_options' ) && get_user_meta( get_current_user_id(), 'pp-404page-update-notice-v9', true ) != 'dismissed' ) {
385
+ * ?>
386
+ * <div class="notice is-dismissible pp-404page-admin-notice" id="pp-404page-update-notice-v9">
387
+ * <p><img src="<?php echo $this->_core->get_asset_file( 'img', '/pluginicon.png' ); ?>" style="width: 48px; height: 48px; float: left; margin-right: 20px" /><strong><?php _e( 'What\'s new in Version 9?', '404page' ); ?></strong><br /><?php _e( 'Display a note in Block Editor Gutenberg if the currently edited page is the custom 404 error page.', '404page' ); ?><br />[<a href="https://wordpress.org/plugins/404page/#developers"><?php _e( 'Changelog', '404page' ); ?></a>]<div class="clear"></div></p>
388
+ * </div>
389
+ * <?php
390
+ * }
391
+ *
392
+ */
393
+
394
+ // invite to follow me
395
+ if ( current_user_can( 'manage_options' ) && get_user_meta( get_current_user_id(), 'pp-404page-admin-notice-1', true ) != 'dismissed' ) {
396
+ ?>
397
+ <div class="notice is-dismissible pp-404page-admin-notice" id="pp-404page-admin-notice-1">
398
+ <p><img src="<?php echo $this->_core->get_asset_file( 'img', '/pluginicon.png' ); ?>" style="width: 48px; height: 48px; float: left; margin-right: 20px" /><strong><?php _e( 'Do you like the 404page plugin?', '404page' ); ?></strong><br /><?php _e( 'Follow me:', '404page' ); ?> <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><div class="clear"></div></p>
399
+ </div>
400
+ <?php
401
+ }
402
+
403
+ // ask for rating
404
+ // in 30 days at the earliest
405
+ if ( ! get_option( 'pp-404page-admin-notice-2-start' ) ) {
406
+ update_option( 'pp-404page-admin-notice-2-start', time() + 30 * 24 * 60 * 60 );
407
+ }
408
+ if ( get_option( 'pp-404page-admin-notice-2-start' ) <= time() ) {
409
+ if ( current_user_can( 'manage_options' ) && get_user_meta( get_current_user_id(), 'pp-404page-admin-notice-2', true ) != 'dismissed' ) {
410
+ ?>
411
+ <div class="notice is-dismissible pp-404page-admin-notice" id="pp-404page-admin-notice-2">
412
+ <p><img src="<?php echo $this->_core->get_asset_file( 'img', 'pluginicon.png' ); ?>" style="width: 48px; height: 48px; float: left; margin-right: 20px" /><?php _e( 'If you like the 404page plugin please support my work with giving it a good rating so that other users know it is helpful for you. Thanks.', '404page' ); ?><br /><a href="https://wordpress.org/support/plugin/<?php echo $this->_core->get_plugin_slug(); ?>/reviews/#new-post" title="<?php _e( 'Please rate plugin', '404page' ); ?>"><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span></a><div class="clear"></div></p>
413
+ </div>
414
+ <?php
415
+ }
416
+ }
417
+
418
+ }
419
+
420
+
421
+ /**
422
+ * dismiss an admin notice
423
+ * moved to PP_404Page_Admin in v 10
424
+ */
425
+ function dismiss_admin_notice() {
426
+
427
+ if ( isset( $_POST['pp_404page_dismiss_admin_notice'] ) ) {
428
+
429
+ update_user_meta( get_current_user_id(), $_POST['pp_404page_dismiss_admin_notice'], 'dismissed' );
430
+
431
+ }
432
+
433
+ wp_die();
434
+
435
+ }
436
+
437
+
438
+ /**
439
+ * add links to plugins table
440
+ * moved to PP_404Page_Admin in v 10
441
+ */
442
+ function add_settings_links( $links ) {
443
+
444
+ return array_merge( $links, array( '<a href="' . admin_url( 'themes.php?page=404pagesettings' ) . '" title="' . __( 'Settings', '404page' ) . '">' . __( 'Settings', '404page' ) . '</a>', '<a href="https://wordpress.org/support/plugin/' . $this->_core->get_plugin_slug() . '/reviews/" title="' . __( 'Please rate plugin', '404page' ) . '">' . __( 'Please rate plugin', '404page' ) . '</a>' ) );
445
+
446
+ }
447
+
448
+
449
+ /**
450
+ * show the videos
451
+ *
452
+ * @since 7
453
+ * @access private
454
+ *
455
+ * moved to PP_404Page_Admin in v 10
456
+ */
457
+ private function show_videos() {
458
+
459
+ $videos = array(
460
+ array( 'id' => 'HygoFMwdIuY', 'title' => 'A brief introduction', 'img' => '404page-brief-intro' ),
461
+ array( 'id' => '9rL9LbYiSJk', 'title' => 'A quick Overview over the Advanced Settings', 'img' => '404page-advanced-settings-quick-overview' ),
462
+ array( 'id' => '09OOCbFLfnI', 'title' => 'The Advanced Setting "Force 404 error after loading page" explained', 'img' => '404page_advanced_force_404' ),
463
+ array( 'id' => 'H0EdtFcAGl4', 'title' => 'The Advanced Setting "Disable URL Autocorrecton Guessing" explained', 'img' => '404page_advanced_url_guessing' ),
464
+ array( 'id' => 'O5xPM0BMZxM', 'title' => 'Send HTTP Status Code 410 for trashed objects', 'img' => '404page_advanced_410_trashed_objects' ),
465
+ array( 'id' => 'wqSepDyQeqY', 'title' => 'Compatibility Mode explained', 'img' => '404page_advanced_compatibility_mode' )
466
+ );
467
+
468
+ foreach( $videos as $video ) {
469
+
470
+ echo '<a href="https://youtu.be/' . $video['id'] . '" title="' . $video['title'] . '" data-lity><div><img src="' . $this->_core->get_asset_file( 'img/videos', $video['img'] . '.png' ) . '" title="' . $video['title'] . '" alt="' . $video['title'] . '"></div></a>';
471
+
472
+ }
473
+
474
+ }
475
+
476
+ }
477
+
478
+ }
479
+
480
+ ?>
inc/class-404page.php CHANGED
@@ -79,7 +79,17 @@ if ( !class_exists( 'PP_404Page' ) ) {
79
private $settings;
80
private $template;
81
private $postid;
82
- private $admin_handle;
83
84
85
/**
@@ -230,12 +240,6 @@ if ( !class_exists( 'PP_404Page' ) ) {
230
add_action( 'init', array( $this, 'add_text_domain' ) );
231
add_action( 'init', array( $this, 'init' ) );
232
233
- add_action( 'admin_notices', array( $this, 'admin_notices' ) );
234
- add_action( 'wp_ajax_pp_404page_dismiss_admin_notice', array( $this, 'dismiss_admin_notice' ) );
235
-
236
- $this->blockeditor = new PP_404Page_BlockEditor( $this );
237
- $this->classiceditor = new PP_404Page_ClassicEditor( $this );
238
-
239
}
240
241
@@ -271,16 +275,19 @@ if ( !class_exists( 'PP_404Page' ) ) {
271
272
}
273
274
- } else {
275
276
- add_action( 'admin_init', array( $this, 'admin_init' ) );
277
- add_action( 'admin_menu', array( $this, 'admin_menu' ) );
278
- add_action( 'admin_head', array( $this, 'admin_style' ) );
279
- add_filter( 'plugin_action_links_' . plugin_basename( $this->get_plugin_file() ), array( $this, 'add_settings_links' ) );
280
- add_action( 'admin_enqueue_scripts', array( $this, 'admin_js' ) );
281
- add_action( 'admin_enqueue_scripts', array( $this, 'admin_css' ) );
282
283
// Remove 404 page from post list if activated
284
if ( $this->settings->get_hide() and $this->get_id() > 0 ) {
285
add_action( 'pre_get_posts' ,array ( $this, 'exclude_404page' ) );
286
}
@@ -409,6 +416,8 @@ if ( !class_exists( 'PP_404Page' ) ) {
409
* Compatibility Mode
410
*/
411
function show404_compatiblity_mode( $posts ) {
412
413
// remove the filter so we handle only the first query - no custom queries
414
remove_filter( 'the_posts', array( $this, 'show404_compatiblity_mode' ), 999 );
@@ -430,7 +439,11 @@ if ( !class_exists( 'PP_404Page' ) ) {
430
$pageid = $this->get_page_id();
431
if ( ! $this->settings->get_native() ) {
432
433
- if ( empty( $posts ) && is_main_query() && !is_robots() && !is_home() && !is_feed() && !is_search() && !is_archive() && ( !defined('DOING_AJAX') || !DOING_AJAX ) ) {
434
435
// as of v2.1 we do not alter the posts argument here because this does not work with SiteOrigin's Page Builder Plugin, template_include filter introduced
436
$this->postid = $pageid;
@@ -442,7 +455,6 @@ if ( !class_exists( 'PP_404Page' ) ) {
442
remove_action( 'pre_get_posts', array ( $this, 'exclude_404page' ) );
443
remove_filter( 'get_pages', array ( $this, 'remove_404page_from_array' ), 10, 2 );
444
445
- global $wp_query;
446
$wp_query = null;
447
$wp_query = new WP_Query();
448
@@ -711,204 +723,6 @@ if ( !class_exists( 'PP_404Page' ) ) {
711
}
712
713
714
- /**
715
- * init admin
716
- */
717
- function admin_init() {
718
-
719
- $this->settings->set_method();
720
-
721
-
722
- add_settings_section( '404page-settings', null, null, '404page_settings_section' );
723
- add_settings_section( '404page-settings', null, null, '404page_settings_section_advanced' );
724
- register_setting( '404page_settings', '404page_page_id' );
725
- register_setting( '404page_settings', '404page_hide' );
726
- register_setting( '404page_settings', '404page_method', array( $this, 'handle_method' ) );
727
- register_setting( '404page_settings', '404page_fire_error' );
728
- register_setting( '404page_settings', '404page_force_error' );
729
- register_setting( '404page_settings', '404page_no_url_guessing' );
730
- register_setting( '404page_settings', '404page_http410_if_trashed' );
731
- add_settings_field( '404page_settings_404page', __( 'Page to be displayed as 404 page', '404page' ) . '&nbsp;<a class="dashicons dashicons-editor-help" href="https://petersplugins.com/docs/' . $this->get_plugin_slug() . '/#settings_select_page"></a>' , array( $this, 'admin_404page' ), '404page_settings_section', '404page-settings', array( 'label_for' => '404page_page_id' ) );
732
- add_settings_field( '404page_settings_hide', '' , array( $this, 'admin_hide' ), '404page_settings_section_advanced', '404page-settings', array( 'label_for' => '404page_hide' ) );
733
- add_settings_field( '404page_settings_fire', '' , array( $this, 'admin_fire404' ), '404page_settings_section_advanced', '404page-settings', array( 'label_for' => '404page_fire_error' ) );
734
- add_settings_field( '404page_settings_force', '' , array( $this, 'admin_force404' ), '404page_settings_section_advanced', '404page-settings', array( 'label_for' => '404page_force_error' ) );
735
- add_settings_field( '404page_settings_noguess', '' , array( $this, 'admin_noguess' ), '404page_settings_section_advanced', '404page-settings', array( 'label_for' => '404page_no_url_guessing' ) );
736
- add_settings_field( '404page_settings_http410', '' , array( $this, 'admin_http410' ), '404page_settings_section_advanced', '404page-settings', array( 'label_for' => '404page_http410_if_trashed' ) );
737
- add_settings_field( '404page_settings_method', '', array( $this, 'admin_method' ), '404page_settings_section_advanced', '404page-settings', array( 'label_for' => '404page_method' ) );
738
- }
739
-
740
-
741
- /**
742
- * add admin css to header
743
- */
744
- function admin_style() {
745
-
746
- if ( $this->get_id() > 0 ) {
747
-
748
- echo '<style type="text/css">';
749
-
750
- foreach ( $this->get_all_page_ids() as $pid ) {
751
-
752
- 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; }';
753
-
754
- }
755
-
756
- echo '</style>';
757
-
758
- }
759
-
760
- }
761
-
762
-
763
- /**
764
- * handle the settings field page id
765
- */
766
- function admin_404page() {
767
-
768
- if ( $this->get_id() < 0 ) {
769
-
770
- echo '<div class="error form-invalid" style="line-height: 3em">' . __( 'The page you have selected as 404 page does not exist anymore. Please choose another page.', '404page' ) . '</div>';
771
- }
772
-
773
- wp_dropdown_pages( array( 'name' => '404page_page_id', 'id' => 'select404page', 'echo' => 1, 'show_option_none' => __( '&mdash; NONE (WP default 404 page) &mdash;', '404page'), 'option_none_value' => '0', 'selected' => $this->get_id() ) );
774
-
775
- echo '<div id="404page_edit_link" style="display: none">' . get_edit_post_link( $this->get_id() ) . '</div>';
776
- echo '<div id="404page_test_link" style="display: none">' . get_site_url() . '/404page-test-' . md5( rand() ) . '</div>';
777
- echo '<div id="404page_current_value" style="display: none">' . $this->get_id() . '</div>';
778
- echo '<p class="submit"><input type="button" name="edit_404_page" id="edit_404_page" class="button secondary" value="' . __( 'Edit Page', '404page' ) . '" />&nbsp;<input type="button" name="test_404_page" id="test_404_page" class="button secondary" value="' . __( 'Test 404 error', '404page' ) . '" /></p>';
779
-
780
- }
781
-
782
-
783
- /**
784
- * handle the settings field hide
785
- */
786
- function admin_hide() {
787
-
788
- echo '<p><input type="checkbox" id="404page_hide" name="404page_hide" value="1"' . checked( true, $this->settings->get_hide(), false ) . '/>';
789
- echo '<label for="404page_hide" class="check"></label>' . __( 'Hide the selected page from the Pages list', '404page' ) . '&nbsp;<a class="dashicons dashicons-editor-help" href="https://petersplugins.com/docs/' . $this->get_plugin_slug() . '/#settings_hide_page"></a><br />';
790
- echo '<span class="dashicons dashicons-info"></span>&nbsp;' . __( 'For Administrators the page is always visible.', '404page' ) . '</p><div class="clear"></div>';
791
-
792
- }
793
-
794
-
795
- /**
796
- * handle the settings field fire 404 error
797
- */
798
- function admin_fire404() {
799
-
800
- echo '<p><input type="checkbox" id="404page_fire_error" name="404page_fire_error" value="1"' . checked( true, $this->settings->get_fire_error(), false ) . '/>';
801
- echo '<label for="404page_fire_error" class="check"></label>' . __( 'Send an 404 error if the page is accessed directly by its URL', '404page' ) . '&nbsp;<a class="dashicons dashicons-editor-help" href="https://petersplugins.com/docs/' . $this->get_plugin_slug() . '/#settings_fire_404"></a><br />';
802
- echo '<span class="dashicons dashicons-info"></span>&nbsp;' . __( 'Uncheck this if you want the selected page to be accessible.', '404page' );
803
-
804
- if ( function_exists( 'wpsupercache_activate' ) ) {
805
-
806
- echo '<br /><span class="dashicons dashicons-warning"></span>&nbsp;<strong>' . __( 'WP Super Cache Plugin detected', '404page' ) . '</strong>. ' . __ ( 'If the page you selected as 404 error page is in cache, always a HTTP code 200 is sent. To avoid this and send a HTTP code 404 you have to exlcude this page from caching', '404page' ) . ' (<a href="' . admin_url( 'options-general.php?page=wpsupercache&tab=settings#rejecturi' ) . '">' . __( 'Click here', '404page' ) . '</a>).<br />(<a href="https://petersplugins.com/docs/' . $this->get_plugin_slug() . '/#wp_super_cache">' . __( 'Read more', '404page' ) . '</a>)';
807
-
808
- }
809
-
810
- echo '</p><div class="clear"></div>';
811
-
812
- }
813
-
814
-
815
- /**
816
- * handle the settings field to force an 404 error
817
- */
818
- function admin_force404() {
819
-
820
- echo '<p><input type="checkbox" id="404page_force_error" name="404page_force_error" value="1"' . checked( true, $this->settings->get_force_error(), false ) . '/>';
821
- echo '<label for="404page_force_error" class="check warning"></label>' . __( 'Force 404 error after loading page', '404page' ) . '&nbsp;<a class="dashicons dashicons-editor-help" href="https://petersplugins.com/docs/' . $this->get_plugin_slug() . '/#settings_force_404"></a>&nbsp;<a class="dashicons dashicons-video-alt3" href="https://youtu.be/09OOCbFLfnI" data-lity></a><br />';
822
- echo '<span class="dashicons dashicons-warning"></span>&nbsp;' . __( 'Generally this is not needed. It is not recommended to activate this option, unless it is necessary. Please note that this may cause problems with your theme.', '404page' ) . '</p><div class="clear"></div>';
823
-
824
- }
825
-
826
-
827
- /**
828
- * handle the settings field to stop URL guessing
829
- */
830
- function admin_noguess() {
831
-
832
- echo '<p><input type="checkbox" id="404page_no_url_guessing" name="404page_no_url_guessing" value="1"' . checked( true, $this->settings->get_no_url_guessing(), false ) . '/>';
833
- echo '<label for="404page_no_url_guessing" class="check warning"></label>' . __( 'Disable URL autocorrection guessing', '404page' ) . '&nbsp;<a class="dashicons dashicons-editor-help" href="https://petersplugins.com/docs/' . $this->get_plugin_slug() . '/#settings_stop_guessing"></a>&nbsp;<a class="dashicons dashicons-video-alt3" href="https://youtu.be/H0EdtFcAGl4" data-lity></a><br />';
834
- echo '<span class="dashicons dashicons-warning"></span>&nbsp;' . __( 'This stops WordPress from URL autocorrection guessing. Only activate, if you are sure about the consequences.', '404page' ) . '</p><div class="clear"></div>';
835
-
836
- }
837
-
838
-
839
- /**
840
- * handle the settings field to send an http 410 error in case the object is trashed
841
- * @since 3.2
842
- */
843
- function admin_http410() {
844
-
845
- echo '<p><input type="checkbox" id="404page_http410_if_trashed" name="404page_http410_if_trashed" value="1"' . checked( true, $this->settings->get_http410_if_trashed(), false ) . '/>';
846
- echo '<label for="404page_http410_if_trashed" class="check"></label>' . __( 'Send an HTTP 410 error instead of HTTP 404 in case the requested object is in trash', '404page' ) . '&nbsp;<a class="dashicons dashicons-editor-help" href="https://petersplugins.com/docs/' . $this->get_plugin_slug() . '/#settings_maybe_send_http410"></a>&nbsp;<a class="dashicons dashicons-video-alt3" href="https://youtu.be/O5xPM0BMZxM" data-lity></a><br />';
847
- echo '<span class="dashicons dashicons-info"></span>&nbsp;' . __( 'Check this if you want to inform search engines that the resource requested is no longer available and will not be available again so it can be removed from the search index immediately.', '404page' );
848
-
849
- }
850
-
851
-
852
- /**
853
- * handle the settings field method
854
- */
855
- function admin_method() {
856
-
857
- if ( $this->settings->get_native() || defined( 'CUSTOMIZR_VER' ) || defined( 'ICL_SITEPRESS_VERSION' ) ) {
858
-
859
- $dis = ' disabled="disabled"';
860
-
861
- } else {
862
-
863
- $dis = '';
864
- }
865
-
866
- echo '<p><input type="checkbox" id="404page_method" name="404page_method" value="CMP"' . checked( 'CMP', $this->settings->get_method(), false ) . $dis . '/>';
867
- echo '<label for="404page_method" class="check"></label>' . __( 'Activate Compatibility Mode', '404page' ) . '&nbsp;<a class="dashicons dashicons-editor-help" href="https://petersplugins.com/docs/' . $this->get_plugin_slug() . '/#settings_operating_method"></a>&nbsp;<a class="dashicons dashicons-video-alt3" href="https://youtu.be/wqSepDyQeqY" data-lity></a><br />';
868
- echo '<span class="dashicons dashicons-info"></span>&nbsp;';
869
-
870
- if ( $this->settings->get_native() ) {
871
-
872
- _e( 'This setting is not available because the Theme you are using natively supports the 404page plugin.', '404page' );
873
- echo ' (<a href="https://petersplugins.com/docs/' . $this->get_plugin_slug() . '/#native_mode">' . __( 'Read more', '404page' ) . '</a>)';
874
-
875
- } elseif ( defined( 'CUSTOMIZR_VER' ) ) {
876
-
877
- _e( 'This setting is not availbe because the 404page Plugin works in Customizr Compatibility Mode.', '404page' );
878
- echo ' (<a href="https://petersplugins.com/docs/' . $this->get_plugin_slug() . '/#special_modes">' . __( 'Read more', '404page' ) . '</a>)';
879
-
880
- } elseif ( defined( 'ICL_SITEPRESS_VERSION' ) ) {
881
-
882
- _e( 'This setting is not availbe because the 404page Plugin works in WPML Mode.', '404page' );
883
- echo ' (<a href="https://petersplugins.com/docs/' . $this->get_plugin_slug() . '/#special_modes">' . __( 'Read more', '404page' ) . '</a>)';
884
-
885
- } else {
886
-
887
- _e( 'If you are using a theme or plugin that modifies the WordPress Template System, the 404page plugin may not work properly. Compatibility Mode maybe can fix the problem. Activate Compatibility Mode only if you have any problems.', '404page' );
888
-
889
- }
890
-
891
- echo '</p><div class="clear"></div>';
892
-
893
- }
894
-
895
-
896
- /**
897
- * handle the method setting
898
- */
899
- function handle_method( $method ) {
900
-
901
- if ( null === $method ) {
902
-
903
- $method = 'STD';
904
-
905
- }
906
-
907
- return $method;
908
-
909
- }
910
-
911
-
912
/**
913
* hide the 404 page from the list of pages
914
*/
@@ -1168,138 +982,8 @@ if ( !class_exists( 'PP_404Page' ) ) {
1168
return false;
1169
1170
}
1171
-
1172
-
1173
- /**
1174
- * create the menu entry
1175
- */
1176
- function admin_menu() {
1177
- $this->admin_handle = add_theme_page ( __( '404 Error Page', "404page" ), __( '404 Error Page', '404page' ), 'manage_options', '404pagesettings', array( $this, 'show_admin' ) );
1178
- }
1179
-
1180
-
1181
- /**
1182
- * add admin css file
1183
- */
1184
- function admin_css() {
1185
-
1186
- if ( get_current_screen()->id == $this->admin_handle ) {
1187
-
1188
- wp_enqueue_style( '404pagelity', $this->get_asset_file( 'css', 'lity.min.css' ) );
1189
- wp_enqueue_style( 'pp-admin-page', $this->get_asset_file( 'css', 'pp-admin-page.css' ) );
1190
- wp_enqueue_style( '404pagecss', $this->get_asset_file( 'css', '404page-ui.css' ) );
1191
-
1192
- }
1193
-
1194
- }
1195
-
1196
-
1197
- /**
1198
- * add admin js files
1199
- */
1200
- function admin_js() {
1201
-
1202
- wp_enqueue_script( '404pagejs', $this->get_asset_file( 'js', '404page.js' ), 'jquery', $this->get_plugin_version(), true );
1203
-
1204
- if ( get_current_screen()->id == $this->admin_handle ) {
1205
-
1206
- wp_enqueue_script( '404page-ui', $this->get_asset_file( 'js', '404page-ui.js' ), 'jquery', $this->get_plugin_version(), true );
1207
- wp_enqueue_script( '404page-lity', $this->get_asset_file( 'js', 'lity.min.js' ), 'jquery', $this->get_plugin_version(), true );
1208
-
1209
- }
1210
-
1211
- }
1212
-
1213
-
1214
- /**
1215
- * show admin page
1216
- */
1217
- function show_admin() {
1218
-
1219
- if ( !current_user_can( 'manage_options' ) ) {
1220
-
1221
- wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
1222
-
1223
- }
1224
-
1225
- require_once( plugin_dir_path( $this->get_plugin_file() ) . '/inc/admin/404page-admin-page.php' );
1226
-
1227
- }
1228
-
1229
-
1230
- /**
1231
- * show the nav icons
1232
- * @since 6
1233
- */
1234
- function show_nav_icons( $icons ) {
1235
1236
- foreach ( $icons as $icon ) {
1237
-
1238
- echo '<a href="' . $icon['link'] . '" title="' . $icon['title'] . '"><span class="dashicons ' . $icon['icon'] . '"></span><span class="text">' . $icon['title'] . '</span></a>';
1239
-
1240
- }
1241
-
1242
- }
1243
-
1244
-
1245
- /**
1246
- * show admin notices
1247
- */
1248
- function admin_notices() {
1249
-
1250
- // @since 8
1251
- // show update notice
1252
- if ( current_user_can( 'manage_options' ) && get_user_meta( get_current_user_id(), 'pp-404page-update-notice-v9', true ) != 'dismissed' ) {
1253
- ?>
1254
- <div class="notice is-dismissible pp-404page-admin-notice" id="pp-404page-update-notice-v9">
1255
- <p><img src="<?php echo $this->get_asset_file( 'img', '/pluginicon.png' ); ?>" style="width: 48px; height: 48px; float: left; margin-right: 20px" /><strong><?php _e( 'What\'s new in Version 9?', '404page' ); ?></strong><br /><?php _e( 'Display a note in Block Editor Gutenberg if the currently edited page is the custom 404 error page.', '404page' ); ?><br />[<a href="https://wordpress.org/plugins/404page/#developers"><?php _e( 'Changelog', '404page' ); ?></a>]<div class="clear"></div></p>
1256
- </div>
1257
- <?php
1258
- }
1259
-
1260
- // invite to follow me
1261
- if ( current_user_can( 'manage_options' ) && get_user_meta( get_current_user_id(), 'pp-404page-admin-notice-1', true ) != 'dismissed' ) {
1262
- ?>
1263
- <div class="notice is-dismissible pp-404page-admin-notice" id="pp-404page-admin-notice-1">
1264
- <p><img src="<?php echo $this->get_asset_file( 'img', '/pluginicon.png' ); ?>" style="width: 48px; height: 48px; float: left; margin-right: 20px" /><strong><?php _e( 'Do you like the 404page plugin?', '404page' ); ?></strong><br /><?php _e( 'Follow me:', '404page' ); ?> <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><div class="clear"></div></p>
1265
- </div>
1266
- <?php
1267
- }
1268
-
1269
- // ask for rating
1270
- // in 30 days at the earliest
1271
- if ( ! get_option( 'pp-404page-admin-notice-2-start' ) ) {
1272
- update_option( 'pp-404page-admin-notice-2-start', time() + 30 * 24 * 60 * 60 );
1273
- }
1274
- if ( get_option( 'pp-404page-admin-notice-2-start' ) <= time() ) {
1275
- if ( current_user_can( 'manage_options' ) && get_user_meta( get_current_user_id(), 'pp-404page-admin-notice-2', true ) != 'dismissed' ) {
1276
- ?>
1277
- <div class="notice is-dismissible pp-404page-admin-notice" id="pp-404page-admin-notice-2">
1278
- <p><img src="<?php echo $this->get_asset_file( 'img', 'pluginicon.png' ); ?>" style="width: 48px; height: 48px; float: left; margin-right: 20px" /><?php _e( 'If you like the 404page plugin please support my work with giving it a good rating so that other users know it is helpful for you. Thanks.', '404page' ); ?><br /><a href="https://wordpress.org/support/plugin/<?php echo $this->plugin_slug; ?>/reviews/#new-post" title="<?php _e( 'Please rate plugin', '404page' ); ?>"><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span></a><div class="clear"></div></p>
1279
- </div>
1280
- <?php
1281
- }
1282
- }
1283
-
1284
- }
1285
-
1286
-
1287
- /**
1288
- * dismiss an admin notice
1289
- */
1290
- function dismiss_admin_notice() {
1291
-
1292
- if ( isset( $_POST['pp_404page_dismiss_admin_notice'] ) ) {
1293
-
1294
- update_user_meta( get_current_user_id(), $_POST['pp_404page_dismiss_admin_notice'], 'dismissed' );
1295
-
1296
- }
1297
-
1298
- wp_die();
1299
-
1300
- }
1301
-
1302
-
1303
/**
1304
* get id of the 404 page
1305
*
@@ -1312,6 +996,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
1312
1313
}
1314
1315
/**
1316
* get the id of the 404 page in the current language if WPML or Polylang is active
1317
*/
@@ -1342,6 +1027,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
1342
1343
}
1344
1345
/**
1346
* get 404 pages in all available languages
1347
* if WPML is active this function returns an array of all page ids in all available languages
@@ -1403,16 +1089,6 @@ if ( !class_exists( 'PP_404Page' ) ) {
1403
}
1404
1405
1406
- /**
1407
- * add links to plugins table
1408
- */
1409
- function add_settings_links( $links ) {
1410
-
1411
- return array_merge( $links, array( '<a href="' . admin_url( 'themes.php?page=404pagesettings' ) . '" title="' . __( 'Settings', '404page' ) . '">' . __( 'Settings', '404page' ) . '</a>', '<a href="https://wordpress.org/support/plugin/' . $this->plugin_slug . '/reviews/" title="' . __( 'Please rate plugin', '404page' ) . '">' . __( 'Please rate plugin', '404page' ) . '</a>' ) );
1412
-
1413
- }
1414
-
1415
-
1416
/**
1417
* uninstall plugin
1418
*/
@@ -1542,31 +1218,6 @@ if ( !class_exists( 'PP_404Page' ) ) {
1542
}
1543
1544
1545
- /**
1546
- * show the videos
1547
- *
1548
- * @since 7
1549
- * @access private
1550
- */
1551
- private function show_videos() {
1552
-
1553
- $videos = array(
1554
- array( 'id' => 'HygoFMwdIuY', 'title' => 'A brief introduction', 'img' => '404page-brief-intro' ),
1555
- array( 'id' => '9rL9LbYiSJk', 'title' => 'A quick Overview over the Advanced Settings', 'img' => '404page-advanced-settings-quick-overview' ),
1556
- array( 'id' => '09OOCbFLfnI', 'title' => 'The Advanced Setting "Force 404 error after loading page" explained', 'img' => '404page_advanced_force_404' ),
1557
- array( 'id' => 'H0EdtFcAGl4', 'title' => 'The Advanced Setting "Disable URL Autocorrecton Guessing" explained', 'img' => '404page_advanced_url_guessing' ),
1558
- array( 'id' => 'O5xPM0BMZxM', 'title' => 'Send HTTP Status Code 410 for trashed objects', 'img' => '404page_advanced_410_trashed_objects' ),
1559
- array( 'id' => 'wqSepDyQeqY', 'title' => 'Compatibility Mode explained', 'img' => '404page_advanced_compatibility_mode' )
1560
- );
1561
-
1562
- foreach( $videos as $video ) {
1563
-
1564
- echo '<a href="https://youtu.be/' . $video['id'] . '" title="' . $video['title'] . '" data-lity><div><img src="' . $this->get_asset_file( 'img/videos', $video['img'] . '.png' ) . '" title="' . $video['title'] . '" alt="' . $video['title'] . '"></div></a>';
1565
-
1566
- }
1567
-
1568
- }
1569
-
1570
}
1571
1572
}
79
private $settings;
80
private $template;
81
private $postid;
82
+
83
+
84
+ /**
85
+ * Admin Class
86
+ *
87
+ * @see class-404page-admin.php
88
+ * @since 10
89
+ * @var object
90
+ * @access private
91
+ */
92
+ private $admin;
93
94
95
/**
240
add_action( 'init', array( $this, 'add_text_domain' ) );
241
add_action( 'init', array( $this, 'init' ) );
242
243
}
244
245
275
276
}
277
278
+ }
279
+
280
+ if ( is_admin() ) {
281
+
282
+ // load classes only if in admin
283
+ // @since 10
284
285
+ $this->admin = new PP_404Page_Admin( $this, $this->settings );
286
+ $this->blockeditor = new PP_404Page_BlockEditor( $this );
287
+ $this->classiceditor = new PP_404Page_ClassicEditor( $this );
288
289
// Remove 404 page from post list if activated
290
+ // not moved to PP_404Page_Admin because we also need exclude_404page() in frontend
291
if ( $this->settings->get_hide() and $this->get_id() > 0 ) {
292
add_action( 'pre_get_posts' ,array ( $this, 'exclude_404page' ) );
293
}
416
* Compatibility Mode
417
*/
418
function show404_compatiblity_mode( $posts ) {
419
+
420
+ global $wp_query;
421
422
// remove the filter so we handle only the first query - no custom queries
423
remove_filter( 'the_posts', array( $this, 'show404_compatiblity_mode' ), 999 );
439
$pageid = $this->get_page_id();
440
if ( ! $this->settings->get_native() ) {
441
442
+ // as of v 10 we also check if $wp_query->query[error] == 404
443
+ // this is necessary to bypass a WordPress bug
444
+ // if permalink setting is something like e.g. /blog/%postname%/ the $posts is not empty
445
+ // bug reported https://core.trac.wordpress.org/ticket/46000
446
+ if ( ( empty( $posts && is_main_query() && !is_robots() && !is_home() && !is_feed() && !is_search() && !is_archive() ) || ( isset( $wp_query->query['error'] ) && $wp_query->query['error'] == 404 ) ) && ( !defined('DOING_AJAX') || !DOING_AJAX ) ) {
447
448
// as of v2.1 we do not alter the posts argument here because this does not work with SiteOrigin's Page Builder Plugin, template_include filter introduced
449
$this->postid = $pageid;
455
remove_action( 'pre_get_posts', array ( $this, 'exclude_404page' ) );
456
remove_filter( 'get_pages', array ( $this, 'remove_404page_from_array' ), 10, 2 );
457
458
$wp_query = null;
459
$wp_query = new WP_Query();
460
723
}
724
725
726
/**
727
* hide the 404 page from the list of pages
728
*/
982
return false;
983
984
}
985
+
986
987
/**
988
* get id of the 404 page
989
*
996
997
}
998
999
+
1000
/**
1001
* get the id of the 404 page in the current language if WPML or Polylang is active
1002
*/
1027
1028
}
1029
1030
+
1031
/**
1032
* get 404 pages in all available languages
1033
* if WPML is active this function returns an array of all page ids in all available languages
1089
}
1090
1091
1092
/**
1093
* uninstall plugin
1094
*/
1218
}
1219
1220
1221
}
1222
1223
}
loader.php CHANGED
@@ -18,8 +18,17 @@ if ( ! defined( 'WPINC' ) ) {
18
*/
19
require_once( plugin_dir_path( __FILE__ ) . '/inc/class-404page.php' );
20
require_once( plugin_dir_path( __FILE__ ) . '/inc/class-404page-settings.php' );
21
- require_once( plugin_dir_path( __FILE__ ) . '/inc/class-404page-block-editor.php' );
22
- require_once( plugin_dir_path( __FILE__ ) . '/inc/class-404page-classic-editor.php' );
23
24
25
/**
@@ -31,7 +40,7 @@ function pp_404page() {
31
'file' => dirname( __FILE__ ) . '/404page.php',
32
'slug' => pathinfo( dirname( __FILE__ ) . '/404page.php', PATHINFO_FILENAME ),
33
'name' => '404page - your smart custom 404 error page',
34
- 'version' => '9'
35
) );
36
37
}
18
*/
19
require_once( plugin_dir_path( __FILE__ ) . '/inc/class-404page.php' );
20
require_once( plugin_dir_path( __FILE__ ) . '/inc/class-404page-settings.php' );
21
+
22
+ if ( is_admin() ) {
23
+
24
+ // load files only if in admin
25
+ // @since 10
26
+
27
+ require_once( plugin_dir_path( __FILE__ ) . '/inc/class-404page-admin.php' );
28
+ require_once( plugin_dir_path( __FILE__ ) . '/inc/class-404page-block-editor.php' );
29
+ require_once( plugin_dir_path( __FILE__ ) . '/inc/class-404page-classic-editor.php' );
30
+
31
+ }
32
33
34
/**
40
'file' => dirname( __FILE__ ) . '/404page.php',
41
'slug' => pathinfo( dirname( __FILE__ ) . '/404page.php', PATHINFO_FILENAME ),
42
'name' => '404page - your smart custom 404 error page',
43
+ 'version' => '10'
44
) );
45
46
}
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: 4.0
6
Tested up to: 5.0
7
- Stable tag: 9
8
Requires PHP: 5.4
9
License: GPLv2 or later
10
License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -13,7 +13,7 @@ Create your custom 404 error page the easy way! No coding. Works with most Theme
13
14
== Description ==
15
16
- <strong>With 80,000+ active installations the [404page](https://petersplugins.com/free-wordpress-plugins/404page/) plugin is the most used plugin to create a customized 404 error page in WordPress.</strong>
17
18
Bringing visitors to your website takes time and effort. Every visitor is important. The default 404 error page of most themes do not provide any information on what to find on your site. A first tme visitor, who does not know you, is left in a dead end and leaves your website. Set up a helpful custom 404 error page to keep him on your site.
19
@@ -153,7 +153,12 @@ Please use the [Support Forum](https://wordpress.org/support/plugin/404page).
153
154
== Changelog ==
155
156
- = 8 (2019-01-24) =
157
* Gutenberg note added
158
159
= 8 (2019-01-11) =
@@ -265,7 +270,10 @@ Please use the [Support Forum](https://wordpress.org/support/plugin/404page).
265
266
== Upgrade Notice ==
267
268
- = 8 =
269
Gutenberg note added
270
271
= 8 =
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: 4.0
6
Tested up to: 5.0
7
+ Stable tag: 10
8
Requires PHP: 5.4
9
License: GPLv2 or later
10
License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
14
== Description ==
15
16
+ <strong>With 90,000+ active installations the [404page](https://petersplugins.com/free-wordpress-plugins/404page/) plugin is the most used plugin to create a customized 404 error page in WordPress.</strong>
17
18
Bringing visitors to your website takes time and effort. Every visitor is important. The default 404 error page of most themes do not provide any information on what to find on your site. A first tme visitor, who does not know you, is left in a dead end and leaves your website. Set up a helpful custom 404 error page to keep him on your site.
19
153
154
== Changelog ==
155
156
+ = 10 (2019-02-14) =
157
+ * workaround for WordPress Permalink bug [#46000](https://core.trac.wordpress.org/ticket/46000)
158
+ * code improvement
159
+ * performance tuning
160
+
161
+ = 9 (2019-01-24) =
162
* Gutenberg note added
163
164
= 8 (2019-01-11) =
270
271
== Upgrade Notice ==
272
273
+ = 10 =
274
+ workaround for WordPress bug
275
+
276
+ = 9 =
277
Gutenberg note added
278
279
= 8 =