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

Version Description

corrected wrong image path, added video links

Download this release

Release Info

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

Code changes from version 6 to 7

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: 6
13
  * Author: Peter Raschendorfer
14
  * Author URI: https://petersplugins.com
15
  * Text Domain: 404page
@@ -25,16 +25,9 @@ if ( ! defined( 'WPINC' ) ) {
25
 
26
 
27
  /**
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' => '6'
36
- )
37
- );
38
 
39
 
40
  /**
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: 7
13
  * Author: Peter Raschendorfer
14
  * Author URI: https://petersplugins.com
15
  * Text Domain: 404page
25
 
26
 
27
  /**
28
+ * Loader
29
  */
30
+ require_once( plugin_dir_path( __FILE__ ) . '/loader.php' );
 
 
 
 
 
 
 
31
 
32
 
33
  /**
assets/css/404page-ui.css CHANGED
@@ -89,4 +89,50 @@ body:not(.rtl) #pp-404page-settings input[type="checkbox"]:enabled:checked + lab
89
 
90
  #pp-404page-settings .dashicons-warning, #pp-404page-settings input[type="checkbox"] + label.check.warning:before {
91
  color: #d54e21;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  }
89
 
90
  #pp-404page-settings .dashicons-warning, #pp-404page-settings input[type="checkbox"] + label.check.warning:before {
91
  color: #d54e21;
92
+ }
93
+
94
+ #pp-404page-videos:after {
95
+ content: '';
96
+ display: block;
97
+ width: 0;
98
+ height: 0;
99
+ padding: 0;
100
+ margin: 0;
101
+ clear: both;
102
+ }
103
+
104
+ #pp-404page-videos a {
105
+ display: block;
106
+ margin: 0 12px 12px 0;
107
+ width: 300px;
108
+ float: left;
109
+ }
110
+
111
+ #pp-404page-videos a div {
112
+ position: relative;
113
+ }
114
+
115
+ #pp-404page-videos a img {
116
+ width: 100%;
117
+ height: auto;
118
+ }
119
+
120
+ #pp-404page-videos a div:after {
121
+ content: '\f236';
122
+ font-family: dashicons;
123
+ font-size: 60px;
124
+ display: block;
125
+ position: absolute;
126
+ left: 50%;
127
+ top: 50%;
128
+ -webkit-transform: translate(-50%, -50%);
129
+ transform: translate(-50%, -50%);
130
+ z-index: 99;
131
+ color: #FF0000;
132
+ opacity: 0.3;
133
+ transition: opacity 0.3s ease-in-out;
134
+ }
135
+
136
+ #pp-404page-videos a:hover div:after, #pp-404page-videos a:focus div:after {
137
+ opacity: 0.8;
138
  }
assets/img/videos/404page-advanced-settings-quick-overview.png ADDED
Binary file
assets/img/videos/404page-brief-intro.png ADDED
Binary file
assets/img/videos/404page_advanced_force_404.png ADDED
Binary file
assets/img/videos/404page_advanced_url_guessing.png ADDED
Binary file
assets/img/videos/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden
inc/class-404page-settings.php ADDED
@@ -0,0 +1,299 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * The 404page settings plugin class
5
+ *
6
+ * @since 7
7
+ *
8
+ * taken from 404page core class and outsourced to a seperate class in version 7
9
+ */
10
+
11
+ if ( ! defined( 'WPINC' ) ) {
12
+ die;
13
+ }
14
+
15
+ /**
16
+ * The settings plugin class
17
+ */
18
+ if ( !class_exists( 'PP_404Page_Settings' ) ) {
19
+
20
+ class PP_404Page_Settings {
21
+
22
+ /**
23
+ * Array of settings
24
+ *
25
+ * @since 7
26
+ * @access protected
27
+ */
28
+ protected $settings;
29
+
30
+ /**
31
+ * Initialize the settings class
32
+ *
33
+ * @since 7
34
+ */
35
+ public function __construct() {
36
+
37
+ $this->settings = array();
38
+
39
+ $this->settings['404page_page_id'] = $this->get_option_404page_id();
40
+ $this->settings['404page_hide'] = $this->get_option_404page_hide();
41
+ $this->settings['404page_fire_error'] = $this->get_option_404page_fire_error();
42
+ $this->settings['404page_force_error'] = $this->get_option_404page_force_error();
43
+ $this->settings['404page_no_url_guessing'] = $this->get_option_404page_no_url_guessing();
44
+ $this->settings['404page_http410_if_trashed'] = $this->get_option_404page_http410_if_trashed();
45
+ $this->settings['404page_native'] = false;
46
+ $this->settings['404page_method'] = 'STD';
47
+
48
+ }
49
+
50
+
51
+ /**
52
+ * get setting - id of the 404 page
53
+ *
54
+ * @since 7
55
+ * @access public
56
+ */
57
+ public function get_id() {
58
+
59
+ return $this->settings['404page_page_id'];
60
+
61
+ }
62
+
63
+
64
+ /**
65
+ * get setting - hide 404 page from page list
66
+ *
67
+ * @since 7
68
+ * @access public
69
+ */
70
+ public function get_hide() {
71
+
72
+ return $this->settings['404page_hide'];
73
+
74
+ }
75
+
76
+
77
+ /**
78
+ * get setting - fire 404 error
79
+ *
80
+ * @since 7
81
+ * @access public
82
+ */
83
+ public function get_fire_error() {
84
+
85
+ return $this->settings['404page_fire_error'];
86
+
87
+ }
88
+
89
+
90
+ /**
91
+ * get setting - force 404 error
92
+ *
93
+ * @since 7
94
+ * @access public
95
+ */
96
+ public function get_force_error() {
97
+
98
+ return $this->settings['404page_force_error'];
99
+
100
+ }
101
+
102
+
103
+ /**
104
+ * get setting - no url guessing
105
+ *
106
+ * @since 7
107
+ * @access public
108
+ */
109
+ public function get_no_url_guessing() {
110
+
111
+ return $this->settings['404page_no_url_guessing'];
112
+
113
+ }
114
+
115
+
116
+ /**
117
+ * get setting - http 410 if trashed
118
+ *
119
+ * @since 7
120
+ * @access public
121
+ */
122
+ public function get_http410_if_trashed() {
123
+
124
+ return $this->settings['404page_http410_if_trashed'];
125
+
126
+ }
127
+
128
+
129
+ /**
130
+ * get setting - native support
131
+ *
132
+ * @since 7
133
+ * @access public
134
+ */
135
+ public function get_native() {
136
+
137
+ return $this->settings['404page_native'];
138
+
139
+ }
140
+
141
+
142
+ /**
143
+ * get setting - method
144
+ *
145
+ * @since 7
146
+ * @access public
147
+ */
148
+ public function get_method() {
149
+
150
+ return $this->settings['404page_method'];
151
+
152
+ }
153
+
154
+
155
+ /**
156
+ * set setting - native support
157
+ *
158
+ * @since 7
159
+ * @access public
160
+ */
161
+ public function set_native( $active ) {
162
+
163
+ $this->settings['404page_native'] = ( $active === true );
164
+
165
+ }
166
+
167
+
168
+ /**
169
+ * set the method
170
+ *
171
+ * @since 7
172
+ * @access public
173
+ */
174
+ public function set_method() {
175
+
176
+ if ( defined( 'ICL_SITEPRESS_VERSION' ) ) {
177
+
178
+ // WPML is active
179
+ $this->settings['404page_method'] = 'CMP';
180
+
181
+ } else {
182
+
183
+ $this->settings['404page_method'] = get_option( '404page_method', 'STD' );
184
+
185
+ }
186
+
187
+ }
188
+
189
+
190
+ /**
191
+ * get the id of the 404 page option
192
+ * returns 0 if none is defined, returns -1 if the defined page id does not exist
193
+ *
194
+ * @since 7
195
+ * @access private
196
+ */
197
+ private function get_option_404page_id() {
198
+
199
+ $pageid = get_option( '404page_page_id', 0 );
200
+
201
+ if ( $pageid != 0 ) {
202
+
203
+ $page = get_post( $pageid );
204
+
205
+ if ( !$page || $page->post_status != 'publish' ) {
206
+
207
+ $pageid = -1;
208
+
209
+ }
210
+
211
+ }
212
+
213
+ return $pageid;
214
+
215
+ }
216
+
217
+
218
+ /**
219
+ * do we have to hide the selected 404 page from the page list?
220
+ *
221
+ * @since 7
222
+ * @access private
223
+ */
224
+ private function get_option_404page_hide() {
225
+
226
+ return (bool)get_option( '404page_hide', false );
227
+
228
+ }
229
+
230
+
231
+ /**
232
+ * do we have to fire an 404 error if the selected page is accessed directly?
233
+ *
234
+ * @since 7
235
+ * @access private
236
+ */
237
+ private function get_option_404page_fire_error() {
238
+
239
+ return (bool)get_option( '404page_fire_error', true );
240
+
241
+ }
242
+
243
+
244
+ /**
245
+ * do we have to force the 404 error after loading the page?
246
+ *
247
+ * @since 7
248
+ * @access private
249
+ */
250
+ private function get_option_404page_force_error() {
251
+
252
+ return (bool)get_option( '404page_force_error', false );
253
+
254
+ }
255
+
256
+
257
+ /**
258
+ * do we have to disable the URL guessing?
259
+ *
260
+ * @since 7
261
+ * @access private
262
+ */
263
+ private function get_option_404page_no_url_guessing() {
264
+
265
+ return (bool)get_option( '404page_no_url_guessing', false );
266
+
267
+ }
268
+
269
+
270
+ /**
271
+ * do we have to send an http 410 error in case the object is in trash?
272
+ *
273
+ * @since 7
274
+ * @access private
275
+ */
276
+ private function get_option_404page_http410_if_trashed() {
277
+
278
+ return (bool)get_option( '404page_http410_if_trashed', false );
279
+
280
+ }
281
+
282
+
283
+ /**
284
+ * get all option names
285
+ *
286
+ * @since 7
287
+ * @access public
288
+ */
289
+ public function get_option_names() {
290
+
291
+ return array_keys( $this->settings );
292
+
293
+ }
294
+
295
+ }
296
+
297
+ }
298
+
299
+ ?>
inc/class-404page.php CHANGED
@@ -55,16 +55,13 @@ if ( !class_exists( 'PP_404Page' ) ) {
55
  * get all settings
56
  * except 404page_method
57
  * the 404page_method setting is set in function set_mode() because it may be too early here and not everything is loaded properly
 
 
58
  */
59
  private function get_settings() {
60
- $this->settings = array();
61
- $this->settings['404page_page_id'] = $this->get_404page_id();
62
- $this->settings['404page_hide'] = $this->get_404page_hide();
63
- $this->settings['404page_fire_error'] = $this->get_404page_fire_error();
64
- $this->settings['404page_force_error'] = $this->get_404page_force_error();
65
- $this->settings['404page_no_url_guessing'] = $this->get_404page_no_url_guessing();
66
- $this->settings['404page_http410_if_trashed'] = $this->get_404page_http410_if_trashed();
67
- $this->settings['404page_native'] = false;
68
  }
69
 
70
 
@@ -96,7 +93,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
96
  // as of v 2.2 always call set_mode
97
  // as of v 2.4 we do not need to add an init action hook
98
 
99
- if ( !is_admin() && $this->settings['404page_page_id'] > 0 ) {
100
 
101
  // as of v 3.0 we once check if there's a 404 page set and not in all functions separately
102
  $this->set_mode();
@@ -104,17 +101,17 @@ if ( !class_exists( 'PP_404Page' ) ) {
104
  add_filter( 'get_pages', array ( $this, 'remove_404page_from_array' ), 10, 2 );
105
 
106
  // Stop URL guessing if activated
107
- if ( $this->settings['404page_no_url_guessing'] ) {
108
  add_filter( 'redirect_canonical' ,array ( $this, 'no_url_guessing' ) );
109
  }
110
 
111
  // Remove 404 error page from YOAST sitemap
112
  // only if "Send an 404 error if the page is accessed directly by its URL" is active
113
  // @since 6
114
- if ( $this->settings['404page_fire_error'] ) {
115
 
116
  add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', function () {
117
- return array( $this->settings['404page_page_id'] );
118
  } );
119
 
120
  }
@@ -129,7 +126,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
129
  add_action( 'admin_enqueue_scripts', array( $this, 'admin_css' ) );
130
 
131
  // Remove 404 page from post list if activated
132
- if ( $this->settings['404page_hide'] and $this->settings['404page_page_id'] > 0 ) {
133
  add_action( 'pre_get_posts' ,array ( $this, 'exclude_404page' ) );
134
  }
135
 
@@ -153,7 +150,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
153
  */
154
  function set_mode() {
155
 
156
- $this->settings['404page_method'] = $this->get_404page_method();
157
 
158
  if ( defined( 'CUSTOMIZR_VER' ) ) {
159
 
@@ -168,13 +165,13 @@ if ( !class_exists( 'PP_404Page' ) ) {
168
 
169
  // send http 410 instead of http 404 if requested resource is in trash
170
  // @since 3.2
171
- if ( $this->settings['404page_http410_if_trashed'] ) {
172
 
173
  add_action( 'template_redirect', array( $this, 'maybe_send_410' ) );
174
 
175
  }
176
 
177
- } elseif ( $this->settings['404page_method'] != 'STD' ) {
178
 
179
  // Compatibility Mode
180
  // 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
@@ -188,7 +185,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
188
  // Standard Mode
189
  add_filter( '404_template', array( $this, 'show404_standard_mode' ), 999 );
190
 
191
- if ( $this->settings['404page_fire_error'] ) {
192
 
193
  add_action( 'template_redirect', array( $this, 'do_404_header_standard_mode' ) );
194
 
@@ -196,7 +193,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
196
 
197
  // send http 410 instead of http 404 if requested resource is in trash
198
  // @since 3.2
199
- if ( $this->settings['404page_http410_if_trashed'] ) {
200
 
201
  add_action( 'template_redirect', array( $this, 'maybe_send_410' ) );
202
 
@@ -233,7 +230,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
233
  }
234
  // that's it
235
 
236
- if ( ! $this->settings['404page_native'] ) {
237
 
238
  $wp_query = null;
239
  $wp_query = new WP_Query();
@@ -276,7 +273,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
276
  // that's it
277
 
278
  $pageid = $this->get_page_id();
279
- if ( ! $this->settings['404page_native'] ) {
280
  if ( empty( $posts ) && is_main_query() && !is_robots() && !is_home() && !is_feed() && !is_search() && !is_archive() && ( !defined('DOING_AJAX') || !DOING_AJAX ) ) {
281
 
282
  // 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
@@ -309,7 +306,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
309
  } elseif ( 1 == count( $posts ) && 'page' == $posts[0]->post_type ) {
310
 
311
  // Do a 404 if the 404 page is opened directly
312
- if ( $this->settings['404page_fire_error'] ) {
313
  $curpageid = $posts[0]->ID;
314
 
315
  if ( defined( 'ICL_SITEPRESS_VERSION' ) ) {
@@ -373,7 +370,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
373
  * Standard Mode
374
  */
375
  function do_404_header_standard_mode() {
376
- if ( is_page() && get_the_ID() == $this->settings['404page_page_id'] && !is_404() ) {
377
  status_header( 404 );
378
  nocache_headers();
379
  $this->maybe_force_404();
@@ -393,7 +390,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
393
  // send http 410 instead of http 404 if requested resource is in trash
394
  // @since 3.2
395
 
396
- if ( $this->settings['404page_http410_if_trashed'] && $this->is_url_in_trash( rawurldecode ( ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ) ) ) {
397
 
398
  status_header( 410 );
399
 
@@ -421,14 +418,14 @@ if ( !class_exists( 'PP_404Page' ) ) {
421
  // debug class
422
  // @since 3.1
423
  $debug_class = 'pp404-';
424
- if ( $this->settings['404page_native'] ) {
425
  $debug_class .= 'native';
426
  } elseif ( defined( 'CUSTOMIZR_VER' ) ) {
427
  $debug_class .= 'customizr';
428
  } elseif ( defined( 'ICL_SITEPRESS_VERSION' ) ) {
429
  $debug_class .= 'wpml';
430
- } elseif ( $this->settings['404page_method'] != 'STD' ) {
431
- $debug_class .= 'wpml';
432
  } else {
433
  $debug_class .= 'std';
434
  }
@@ -459,7 +456,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
459
  * Customizr Compatibility Mode
460
  */
461
  function show404title_customizr_mode( $title ) {
462
- if ( ! $this->settings['404page_native'] ) {
463
  return '<h1 class="entry-title">' . get_the_title( $this->get_page_id() ) . '</h1>';
464
  } else {
465
  return $title;
@@ -472,7 +469,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
472
  * Customizr Compatibility Mode
473
  */
474
  function show404_customizr_mode( $content ) {
475
- if ( ! $this->settings['404page_native'] ) {
476
  return '<div class="entry-content">' . apply_filters( 'the_content', get_post_field( 'post_content', $this->get_page_id() ) ) . '</div>';
477
  } else {
478
  return $content;
@@ -486,7 +483,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
486
  * Customizr Compatibility Mode
487
  */
488
  function show404articleselectors_customizr_mode( $selectors ) {
489
- if ( ! $this->settings['404page_native'] ) {
490
  return 'id="post-' . $this->get_page_id() . '" ' . 'class="' . join( ' ', get_post_class( 'row-fluid', $this->get_page_id() ) ) . '"';
491
  } else {
492
  return $selectors;
@@ -498,7 +495,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
498
  * do we have to force a 404 in wp_head?
499
  */
500
  function maybe_force_404() {
501
- if ( $this->settings['404page_force_error'] ) {
502
  add_action( 'wp_head', array( $this, 'force_404_start' ), 9.9 );
503
  add_action( 'wp_head', array( $this, 'force_404_end' ), 99 );
504
  }
@@ -560,7 +557,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
560
  */
561
  function admin_init() {
562
 
563
- $this->settings['404page_method'] = $this->get_404page_method();
564
 
565
 
566
  add_settings_section( '404page-settings', null, null, '404page_settings_section' );
@@ -587,7 +584,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
587
  */
588
  function admin_style() {
589
 
590
- if ( $this->settings['404page_page_id'] > 0 ) {
591
 
592
  echo '<style type="text/css">';
593
 
@@ -603,7 +600,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
603
 
604
  // the currently edited page is a 404 error page
605
  // @since 5
606
- if ( get_current_screen()->id == 'page' && $this->settings['404page_page_id'] > 0 ) {
607
 
608
  global $post;
609
 
@@ -627,16 +624,16 @@ if ( !class_exists( 'PP_404Page' ) ) {
627
  */
628
  function admin_404page() {
629
 
630
- if ( $this->settings['404page_page_id'] < 0 ) {
631
 
632
  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>';
633
  }
634
 
635
- 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->settings['404page_page_id'] ) );
636
 
637
- echo '<div id="404page_edit_link" style="display: none">' . get_edit_post_link( $this->settings['404page_page_id'] ) . '</div>';
638
  echo '<div id="404page_test_link" style="display: none">' . get_site_url() . '/404page-test-' . md5( rand() ) . '</div>';
639
- echo '<div id="404page_current_value" style="display: none">' . $this->settings['404page_page_id'] . '</div>';
640
  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>';
641
 
642
  }
@@ -647,7 +644,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
647
  */
648
  function admin_hide() {
649
 
650
- echo '<p><input type="checkbox" id="404page_hide" name="404page_hide" value="1"' . checked( true, $this->settings['404page_hide'], false ) . '/>';
651
  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="' . $this->dc_url . '/#settings_hide_page"></a><br />';
652
  echo '<span class="dashicons dashicons-info"></span>&nbsp;' . __( 'For Administrators the page is always visible.', '404page' ) . '</p><div class="clear"></div>';
653
 
@@ -659,7 +656,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
659
  */
660
  function admin_fire404() {
661
 
662
- echo '<p><input type="checkbox" id="404page_fire_error" name="404page_fire_error" value="1"' . checked( true, $this->settings['404page_fire_error'], false ) . '/>';
663
  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="' . $this->dc_url . '/#settings_fire_404"></a><br />';
664
  echo '<span class="dashicons dashicons-info"></span>&nbsp;' . __( 'Uncheck this if you want the selected page to be accessible.', '404page' );
665
 
@@ -679,8 +676,8 @@ if ( !class_exists( 'PP_404Page' ) ) {
679
  */
680
  function admin_force404() {
681
 
682
- echo '<p><input type="checkbox" id="404page_force_error" name="404page_force_error" value="1"' . checked( true, $this->settings['404page_force_error'], false ) . '/>';
683
- 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="' . $this->dc_url . '/#settings_force_404"></a><br />';
684
  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>';
685
 
686
  }
@@ -691,8 +688,8 @@ if ( !class_exists( 'PP_404Page' ) ) {
691
  */
692
  function admin_noguess() {
693
 
694
- echo '<p><input type="checkbox" id="404page_no_url_guessing" name="404page_no_url_guessing" value="1"' . checked( true, $this->settings['404page_no_url_guessing'], false ) . '/>';
695
- echo '<label for="404page_no_url_guessing" class="check warning"></label>' . __( 'Disable URL autocorrection guessing', '404page' ) . '&nbsp;<a class="dashicons dashicons-editor-help" href="' . $this->dc_url . '/#settings_stop_guessing"></a><br />';
696
  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>';
697
 
698
  }
@@ -704,7 +701,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
704
  */
705
  function admin_http410() {
706
 
707
- echo '<p><input type="checkbox" id="404page_http410_if_trashed" name="404page_http410_if_trashed" value="1"' . checked( true, $this->settings['404page_http410_if_trashed'], false ) . '/>';
708
  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="' . $this->dc_url . '/#settings_maybe_send_http410"></a><br />';
709
  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' );
710
 
@@ -716,7 +713,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
716
  */
717
  function admin_method() {
718
 
719
- if ( $this->settings['404page_native'] || defined( 'CUSTOMIZR_VER' ) || defined( 'ICL_SITEPRESS_VERSION' ) ) {
720
 
721
  $dis = ' disabled="disabled"';
722
 
@@ -725,11 +722,11 @@ if ( !class_exists( 'PP_404Page' ) ) {
725
  $dis = '';
726
  }
727
 
728
- echo '<p><input type="checkbox" id="404page_method" name="404page_method" value="CMP"' . checked( 'CMP', $this->settings['404page_method'], false ) . $dis . '/>';
729
  echo '<label for="404page_method" class="check"></label>' . __( 'Activate Compatibility Mode', '404page' ) . '&nbsp;<a class="dashicons dashicons-editor-help" href="' . $this->dc_url . '/#settings_operating_method"></a><br />';
730
  echo '<span class="dashicons dashicons-info"></span>&nbsp;';
731
 
732
- if ( $this->settings['404page_native'] ) {
733
 
734
  _e( 'This setting is not available because the Theme you are using natively supports the 404page plugin.', '404page' );
735
  echo ' (<a href="' . $this->dc_url . '/#native_mode">' . __( 'Read more', '404page' ) . '</a>)';
@@ -1047,8 +1044,8 @@ if ( !class_exists( 'PP_404Page' ) ) {
1047
 
1048
  if ( get_current_screen()->id == $this->admin_handle ) {
1049
 
1050
- wp_enqueue_style( 'pp-admin-page', plugins_url( 'assets/css/pp-admin-page.css', $this->_file ) );
1051
- wp_enqueue_style( '404pagecss', plugins_url( 'assets/css/404page-ui.css', $this->_file ) );
1052
 
1053
  }
1054
 
@@ -1060,11 +1057,11 @@ if ( !class_exists( 'PP_404Page' ) ) {
1060
  */
1061
  function admin_js() {
1062
 
1063
- wp_enqueue_script( '404pagejs', plugins_url( 'assets/js/404page.js', $this->_file ), 'jquery', $this->version, true );
1064
 
1065
  if ( get_current_screen()->id == $this->admin_handle ) {
1066
 
1067
- wp_enqueue_script( '404page-ui', plugins_url( 'assets/js/404page-ui.js', $this->_file ), 'jquery', $this->version, true );
1068
 
1069
  }
1070
 
@@ -1136,6 +1133,10 @@ if ( !class_exists( 'PP_404Page' ) ) {
1136
  <?php do_settings_sections( '404page_settings_section_advanced' ); ?>
1137
  </div>
1138
  <?php submit_button(); ?>
 
 
 
 
1139
  </form>
1140
  </div>
1141
  <?php
@@ -1166,7 +1167,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
1166
  if ( current_user_can( 'manage_options' ) && get_user_meta( get_current_user_id(), 'pp-404page-admin-notice-1', true ) != 'dismissed' ) {
1167
  ?>
1168
  <div class="notice is-dismissible pp-404page-admin-notice" id="pp-404page-admin-notice-1">
1169
- <p><img src="<?php echo plugins_url( 'assets/pluginicon.png', $this->_file ); ?>" 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>
1170
  </div>
1171
  <?php
1172
  }
@@ -1180,7 +1181,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
1180
  if ( current_user_can( 'manage_options' ) && get_user_meta( get_current_user_id(), 'pp-404page-admin-notice-2', true ) != 'dismissed' ) {
1181
  ?>
1182
  <div class="notice is-dismissible pp-404page-admin-notice" id="pp-404page-admin-notice-2">
1183
- <p><img src="<?php echo plugins_url( 'assets/pluginicon.png', $this->_file ); ?>" 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>
1184
  </div>
1185
  <?php
1186
  }
@@ -1203,109 +1204,14 @@ if ( !class_exists( 'PP_404Page' ) ) {
1203
  wp_die();
1204
 
1205
  }
1206
-
1207
-
1208
- /**
1209
- * get the id of the 404 page
1210
- * returns 0 if none is defined, returns -1 if the defined page id does not exist
1211
- */
1212
- private function get_404page_id() {
1213
-
1214
- $pageid = get_option( '404page_page_id', 0 );
1215
-
1216
- if ( $pageid != 0 ) {
1217
-
1218
- $page = get_post( $pageid );
1219
-
1220
- if ( !$page || $page->post_status != 'publish' ) {
1221
-
1222
- $pageid = -1;
1223
-
1224
- }
1225
-
1226
- }
1227
-
1228
- return $pageid;
1229
-
1230
- }
1231
-
1232
-
1233
- /**
1234
- * get the selected method
1235
- */
1236
- private function get_404page_method() {
1237
-
1238
- if ( defined( 'ICL_SITEPRESS_VERSION' ) ) {
1239
-
1240
- // WPML is active
1241
- return 'CMP';
1242
-
1243
- } else {
1244
-
1245
- return get_option( '404page_method', 'STD' );
1246
-
1247
- }
1248
-
1249
- }
1250
-
1251
-
1252
- /**
1253
- * do we have to hide the selected 404 page from the page list?
1254
- */
1255
- private function get_404page_hide() {
1256
-
1257
- return (bool)get_option( '404page_hide', false );
1258
-
1259
- }
1260
-
1261
-
1262
- /**
1263
- * do we have to fire an 404 error if the selected page is accessed directly?
1264
- */
1265
- private function get_404page_fire_error() {
1266
-
1267
- return (bool)get_option( '404page_fire_error', true );
1268
-
1269
- }
1270
-
1271
-
1272
- /**
1273
- * do we have to force the 404 error after loading the page?
1274
- */
1275
- private function get_404page_force_error() {
1276
-
1277
- return (bool)get_option( '404page_force_error', false );
1278
-
1279
- }
1280
-
1281
-
1282
- /**
1283
- * do we have to disable the URL guessing?
1284
- */
1285
- private function get_404page_no_url_guessing() {
1286
-
1287
- return (bool)get_option( '404page_no_url_guessing', false );
1288
-
1289
- }
1290
-
1291
-
1292
- /**
1293
- * do we have to send an http 410 error in case the object is in trash?
1294
- * @since 3.2
1295
- */
1296
- private function get_404page_http410_if_trashed() {
1297
-
1298
- return (bool)get_option( '404page_http410_if_trashed', false );
1299
-
1300
- }
1301
-
1302
 
1303
  /**
1304
  * get the id of the 404 page in the current language if WPML or Polylang is active
1305
  */
1306
  private function get_page_id() {
1307
 
1308
- $pageid = $this->settings['404page_page_id'];
1309
 
1310
  if ( $pageid > 0 ) {
1311
 
@@ -1342,7 +1248,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
1342
 
1343
  // WPML is active
1344
  // get an array for all translations
1345
- $pageid = $this->settings['404page_page_id'];
1346
  $pages = array( $pageid );
1347
 
1348
  if ( $pageid > 0 ) {
@@ -1427,7 +1333,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
1427
  $activeblog = $wpdb->blogid;
1428
  $blogids = $wpdb->get_col( esc_sql( 'SELECT blog_id FROM ' . $wpdb->blogs ) );
1429
 
1430
- foreach ($blogids as $blogid) {
1431
 
1432
  switch_to_blog( $blogid );
1433
  $this->uninstall_single();
@@ -1444,9 +1350,9 @@ if ( !class_exists( 'PP_404Page' ) ) {
1444
  */
1445
  function uninstall_single() {
1446
 
1447
- foreach ( $this->settings as $key => $value) {
1448
 
1449
- delete_option( $key );
1450
 
1451
  }
1452
 
@@ -1460,14 +1366,14 @@ if ( !class_exists( 'PP_404Page' ) ) {
1460
  // check if there's a custom 404 page set
1461
  function pp_404_is_active() {
1462
 
1463
- return ( $this->settings['404page_page_id'] > 0 );
1464
 
1465
  }
1466
 
1467
  // activate the native theme support
1468
  function pp_404_set_native_support() {
1469
 
1470
- $this->settings['404page_native'] = true;
1471
 
1472
  }
1473
 
@@ -1476,7 +1382,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
1476
 
1477
  $title = '';
1478
 
1479
- if ( $this->settings['404page_page_id'] > 0 && $this->settings['404page_native'] ) {
1480
 
1481
  $title = get_the_title( $this->get_page_id() );
1482
 
@@ -1498,7 +1404,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
1498
 
1499
  $content = '';
1500
 
1501
- if ( $this->settings['404page_page_id'] > 0 && $this->settings['404page_native'] ) {
1502
 
1503
  $content = apply_filters( 'the_content', get_post_field( 'post_content', $this->get_page_id() ) );
1504
 
@@ -1515,6 +1421,43 @@ if ( !class_exists( 'PP_404Page' ) ) {
1515
 
1516
  }
1517
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1518
  }
1519
 
1520
  }
55
  * get all settings
56
  * except 404page_method
57
  * the 404page_method setting is set in function set_mode() because it may be too early here and not everything is loaded properly
58
+ *
59
+ * since v 7 we have a settings class
60
  */
61
  private function get_settings() {
62
+
63
+ $this->settings = new PP_404Page_Settings();
64
+
 
 
 
 
 
65
  }
66
 
67
 
93
  // as of v 2.2 always call set_mode
94
  // as of v 2.4 we do not need to add an init action hook
95
 
96
+ if ( !is_admin() && $this->settings->get_id() > 0 ) {
97
 
98
  // as of v 3.0 we once check if there's a 404 page set and not in all functions separately
99
  $this->set_mode();
101
  add_filter( 'get_pages', array ( $this, 'remove_404page_from_array' ), 10, 2 );
102
 
103
  // Stop URL guessing if activated
104
+ if ( $this->settings->get_no_url_guessing() ) {
105
  add_filter( 'redirect_canonical' ,array ( $this, 'no_url_guessing' ) );
106
  }
107
 
108
  // Remove 404 error page from YOAST sitemap
109
  // only if "Send an 404 error if the page is accessed directly by its URL" is active
110
  // @since 6
111
+ if ( $this->settings->get_fire_error() ) {
112
 
113
  add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', function () {
114
+ return array( $this->settings->get_id() );
115
  } );
116
 
117
  }
126
  add_action( 'admin_enqueue_scripts', array( $this, 'admin_css' ) );
127
 
128
  // Remove 404 page from post list if activated
129
+ if ( $this->settings->get_hide() and $this->settings->get_id() > 0 ) {
130
  add_action( 'pre_get_posts' ,array ( $this, 'exclude_404page' ) );
131
  }
132
 
150
  */
151
  function set_mode() {
152
 
153
+ $this->settings->set_method();
154
 
155
  if ( defined( 'CUSTOMIZR_VER' ) ) {
156
 
165
 
166
  // send http 410 instead of http 404 if requested resource is in trash
167
  // @since 3.2
168
+ if ( $this->settings->get_http410_if_trashed() ) {
169
 
170
  add_action( 'template_redirect', array( $this, 'maybe_send_410' ) );
171
 
172
  }
173
 
174
+ } elseif ( $this->settings->get_method() != 'STD' ) {
175
 
176
  // Compatibility Mode
177
  // 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
185
  // Standard Mode
186
  add_filter( '404_template', array( $this, 'show404_standard_mode' ), 999 );
187
 
188
+ if ( $this->settings->get_fire_error() ) {
189
 
190
  add_action( 'template_redirect', array( $this, 'do_404_header_standard_mode' ) );
191
 
193
 
194
  // send http 410 instead of http 404 if requested resource is in trash
195
  // @since 3.2
196
+ if ( $this->settings->get_http410_if_trashed() ) {
197
 
198
  add_action( 'template_redirect', array( $this, 'maybe_send_410' ) );
199
 
230
  }
231
  // that's it
232
 
233
+ if ( ! $this->settings->get_native() ) {
234
 
235
  $wp_query = null;
236
  $wp_query = new WP_Query();
273
  // that's it
274
 
275
  $pageid = $this->get_page_id();
276
+ if ( ! $this->settings->get_native() ) {
277
  if ( empty( $posts ) && is_main_query() && !is_robots() && !is_home() && !is_feed() && !is_search() && !is_archive() && ( !defined('DOING_AJAX') || !DOING_AJAX ) ) {
278
 
279
  // 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
306
  } elseif ( 1 == count( $posts ) && 'page' == $posts[0]->post_type ) {
307
 
308
  // Do a 404 if the 404 page is opened directly
309
+ if ( $this->settings->get_fire_error() ) {
310
  $curpageid = $posts[0]->ID;
311
 
312
  if ( defined( 'ICL_SITEPRESS_VERSION' ) ) {
370
  * Standard Mode
371
  */
372
  function do_404_header_standard_mode() {
373
+ if ( is_page() && get_the_ID() == $this->settings->get_id() && !is_404() ) {
374
  status_header( 404 );
375
  nocache_headers();
376
  $this->maybe_force_404();
390
  // send http 410 instead of http 404 if requested resource is in trash
391
  // @since 3.2
392
 
393
+ if ( $this->settings->get_http410_if_trashed() && $this->is_url_in_trash( rawurldecode ( ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ) ) ) {
394
 
395
  status_header( 410 );
396
 
418
  // debug class
419
  // @since 3.1
420
  $debug_class = 'pp404-';
421
+ if ( $this->settings->get_native() ) {
422
  $debug_class .= 'native';
423
  } elseif ( defined( 'CUSTOMIZR_VER' ) ) {
424
  $debug_class .= 'customizr';
425
  } elseif ( defined( 'ICL_SITEPRESS_VERSION' ) ) {
426
  $debug_class .= 'wpml';
427
+ } elseif ( $this->settings->get_method() != 'STD' ) {
428
+ $debug_class .= 'cmp';
429
  } else {
430
  $debug_class .= 'std';
431
  }
456
  * Customizr Compatibility Mode
457
  */
458
  function show404title_customizr_mode( $title ) {
459
+ if ( ! $this->settings->get_native() ) {
460
  return '<h1 class="entry-title">' . get_the_title( $this->get_page_id() ) . '</h1>';
461
  } else {
462
  return $title;
469
  * Customizr Compatibility Mode
470
  */
471
  function show404_customizr_mode( $content ) {
472
+ if ( ! $this->settings->get_native() ) {
473
  return '<div class="entry-content">' . apply_filters( 'the_content', get_post_field( 'post_content', $this->get_page_id() ) ) . '</div>';
474
  } else {
475
  return $content;
483
  * Customizr Compatibility Mode
484
  */
485
  function show404articleselectors_customizr_mode( $selectors ) {
486
+ if ( ! $this->settings->get_native() ) {
487
  return 'id="post-' . $this->get_page_id() . '" ' . 'class="' . join( ' ', get_post_class( 'row-fluid', $this->get_page_id() ) ) . '"';
488
  } else {
489
  return $selectors;
495
  * do we have to force a 404 in wp_head?
496
  */
497
  function maybe_force_404() {
498
+ if ( $this->settings->get_force_error() ) {
499
  add_action( 'wp_head', array( $this, 'force_404_start' ), 9.9 );
500
  add_action( 'wp_head', array( $this, 'force_404_end' ), 99 );
501
  }
557
  */
558
  function admin_init() {
559
 
560
+ $this->settings->set_method();
561
 
562
 
563
  add_settings_section( '404page-settings', null, null, '404page_settings_section' );
584
  */
585
  function admin_style() {
586
 
587
+ if ( $this->settings->get_id() > 0 ) {
588
 
589
  echo '<style type="text/css">';
590
 
600
 
601
  // the currently edited page is a 404 error page
602
  // @since 5
603
+ if ( get_current_screen()->id == 'page' && $this->settings->get_id() > 0 ) {
604
 
605
  global $post;
606
 
624
  */
625
  function admin_404page() {
626
 
627
+ if ( $this->settings->get_id() < 0 ) {
628
 
629
  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>';
630
  }
631
 
632
+ 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->settings->get_id() ) );
633
 
634
+ echo '<div id="404page_edit_link" style="display: none">' . get_edit_post_link( $this->settings->get_id() ) . '</div>';
635
  echo '<div id="404page_test_link" style="display: none">' . get_site_url() . '/404page-test-' . md5( rand() ) . '</div>';
636
+ echo '<div id="404page_current_value" style="display: none">' . $this->settings->get_id() . '</div>';
637
  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>';
638
 
639
  }
644
  */
645
  function admin_hide() {
646
 
647
+ echo '<p><input type="checkbox" id="404page_hide" name="404page_hide" value="1"' . checked( true, $this->settings->get_hide(), false ) . '/>';
648
  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="' . $this->dc_url . '/#settings_hide_page"></a><br />';
649
  echo '<span class="dashicons dashicons-info"></span>&nbsp;' . __( 'For Administrators the page is always visible.', '404page' ) . '</p><div class="clear"></div>';
650
 
656
  */
657
  function admin_fire404() {
658
 
659
+ echo '<p><input type="checkbox" id="404page_fire_error" name="404page_fire_error" value="1"' . checked( true, $this->settings->get_fire_error(), false ) . '/>';
660
  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="' . $this->dc_url . '/#settings_fire_404"></a><br />';
661
  echo '<span class="dashicons dashicons-info"></span>&nbsp;' . __( 'Uncheck this if you want the selected page to be accessible.', '404page' );
662
 
676
  */
677
  function admin_force404() {
678
 
679
+ echo '<p><input type="checkbox" id="404page_force_error" name="404page_force_error" value="1"' . checked( true, $this->settings->get_force_error(), false ) . '/>';
680
+ 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="' . $this->dc_url . '/#settings_force_404"></a>&nbsp;<a class="dashicons dashicons-video-alt3" href="https://youtu.be/09OOCbFLfnI"></a><br />';
681
  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>';
682
 
683
  }
688
  */
689
  function admin_noguess() {
690
 
691
+ 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 ) . '/>';
692
+ echo '<label for="404page_no_url_guessing" class="check warning"></label>' . __( 'Disable URL autocorrection guessing', '404page' ) . '&nbsp;<a class="dashicons dashicons-editor-help" href="' . $this->dc_url . '/#settings_stop_guessing"></a>&nbsp;<a class="dashicons dashicons-video-alt3" href="https://youtu.be/H0EdtFcAGl4"></a><br />';
693
  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>';
694
 
695
  }
701
  */
702
  function admin_http410() {
703
 
704
+ 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 ) . '/>';
705
  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="' . $this->dc_url . '/#settings_maybe_send_http410"></a><br />';
706
  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' );
707
 
713
  */
714
  function admin_method() {
715
 
716
+ if ( $this->settings->get_native() || defined( 'CUSTOMIZR_VER' ) || defined( 'ICL_SITEPRESS_VERSION' ) ) {
717
 
718
  $dis = ' disabled="disabled"';
719
 
722
  $dis = '';
723
  }
724
 
725
+ echo '<p><input type="checkbox" id="404page_method" name="404page_method" value="CMP"' . checked( 'CMP', $this->settings->get_method(), false ) . $dis . '/>';
726
  echo '<label for="404page_method" class="check"></label>' . __( 'Activate Compatibility Mode', '404page' ) . '&nbsp;<a class="dashicons dashicons-editor-help" href="' . $this->dc_url . '/#settings_operating_method"></a><br />';
727
  echo '<span class="dashicons dashicons-info"></span>&nbsp;';
728
 
729
+ if ( $this->settings->get_native() ) {
730
 
731
  _e( 'This setting is not available because the Theme you are using natively supports the 404page plugin.', '404page' );
732
  echo ' (<a href="' . $this->dc_url . '/#native_mode">' . __( 'Read more', '404page' ) . '</a>)';
1044
 
1045
  if ( get_current_screen()->id == $this->admin_handle ) {
1046
 
1047
+ wp_enqueue_style( 'pp-admin-page', $this->get_asset_file( 'css', 'pp-admin-page.css' ) );
1048
+ wp_enqueue_style( '404pagecss', $this->get_asset_file( 'css', '404page-ui.css' ) );
1049
 
1050
  }
1051
 
1057
  */
1058
  function admin_js() {
1059
 
1060
+ wp_enqueue_script( '404pagejs', $this->get_asset_file( 'js', '404page.js' ), 'jquery', $this->version, true );
1061
 
1062
  if ( get_current_screen()->id == $this->admin_handle ) {
1063
 
1064
+ wp_enqueue_script( '404page-ui', $this->get_asset_file( 'js', '404page-ui.js' ), 'jquery', $this->version, true );
1065
 
1066
  }
1067
 
1133
  <?php do_settings_sections( '404page_settings_section_advanced' ); ?>
1134
  </div>
1135
  <?php submit_button(); ?>
1136
+ <div id="pp-404page-videos">
1137
+ <h3><?php _e( 'Helpful YouTube Videos', '404page' ); ?></h3>
1138
+ <?php $this->show_videos(); ?>
1139
+ </div>
1140
  </form>
1141
  </div>
1142
  <?php
1167
  if ( current_user_can( 'manage_options' ) && get_user_meta( get_current_user_id(), 'pp-404page-admin-notice-1', true ) != 'dismissed' ) {
1168
  ?>
1169
  <div class="notice is-dismissible pp-404page-admin-notice" id="pp-404page-admin-notice-1">
1170
+ <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>
1171
  </div>
1172
  <?php
1173
  }
1181
  if ( current_user_can( 'manage_options' ) && get_user_meta( get_current_user_id(), 'pp-404page-admin-notice-2', true ) != 'dismissed' ) {
1182
  ?>
1183
  <div class="notice is-dismissible pp-404page-admin-notice" id="pp-404page-admin-notice-2">
1184
+ <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>
1185
  </div>
1186
  <?php
1187
  }
1204
  wp_die();
1205
 
1206
  }
1207
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1208
 
1209
  /**
1210
  * get the id of the 404 page in the current language if WPML or Polylang is active
1211
  */
1212
  private function get_page_id() {
1213
 
1214
+ $pageid = $this->settings->get_id();
1215
 
1216
  if ( $pageid > 0 ) {
1217
 
1248
 
1249
  // WPML is active
1250
  // get an array for all translations
1251
+ $pageid = $this->settings->get_id();
1252
  $pages = array( $pageid );
1253
 
1254
  if ( $pageid > 0 ) {
1333
  $activeblog = $wpdb->blogid;
1334
  $blogids = $wpdb->get_col( esc_sql( 'SELECT blog_id FROM ' . $wpdb->blogs ) );
1335
 
1336
+ foreach ( $blogids as $blogid ) {
1337
 
1338
  switch_to_blog( $blogid );
1339
  $this->uninstall_single();
1350
  */
1351
  function uninstall_single() {
1352
 
1353
+ foreach ( $this->settings->get_option_names() as $option ) {
1354
 
1355
+ delete_option( $option );
1356
 
1357
  }
1358
 
1366
  // check if there's a custom 404 page set
1367
  function pp_404_is_active() {
1368
 
1369
+ return ( $this->settings->get_id() > 0 );
1370
 
1371
  }
1372
 
1373
  // activate the native theme support
1374
  function pp_404_set_native_support() {
1375
 
1376
+ $this->settings->set_native( true );
1377
 
1378
  }
1379
 
1382
 
1383
  $title = '';
1384
 
1385
+ if ( $this->settings->get_id() > 0 && $this->settings->get_native() ) {
1386
 
1387
  $title = get_the_title( $this->get_page_id() );
1388
 
1404
 
1405
  $content = '';
1406
 
1407
+ if ( $this->settings->get_id() > 0 && $this->settings->get_native() ) {
1408
 
1409
  $content = apply_filters( 'the_content', get_post_field( 'post_content', $this->get_page_id() ) );
1410
 
1421
 
1422
  }
1423
 
1424
+
1425
+ /**
1426
+ * get path for asset file
1427
+ *
1428
+ * @since 7
1429
+ * @access private
1430
+ */
1431
+ private function get_asset_file( $dir, $file ) {
1432
+
1433
+ return plugins_url( 'assets/' . $dir . '/' . $file, $this->_file );
1434
+
1435
+ }
1436
+
1437
+
1438
+ /**
1439
+ * show the videos
1440
+ *
1441
+ * @since 7
1442
+ * @access private
1443
+ */
1444
+ private function show_videos() {
1445
+
1446
+ $videos = array(
1447
+ array( 'id' => 'HygoFMwdIuY', 'title' => 'A brief introduction', 'img' => '404page-brief-intro' ),
1448
+ array( 'id' => '9rL9LbYiSJk', 'title' => 'A quick Overview over the Advanced Settings', 'img' => '404page-advanced-settings-quick-overview' ),
1449
+ array( 'id' => '09OOCbFLfnI', 'title' => 'The Advanced Setting "Force 404 error after loading page" explained', 'img' => '404page_advanced_force_404' ),
1450
+ array( 'id' => 'H0EdtFcAGl4', 'title' => 'The Advanced Setting "Disable URL Autocorrecton Guessing" explained', 'img' => '404page_advanced_url_guessing' )
1451
+ );
1452
+
1453
+ foreach( $videos as $video ) {
1454
+
1455
+ echo '<a href="https://youtu.be/' . $video['id'] . '" title="' . $video['title'] . '"><div><img src="' . $this->get_asset_file( 'img/videos', $video['img'] . '.png' ) . '" title="' . $video['title'] . '" alt="' . $video['title'] . '"></div></a>';
1456
+
1457
+ }
1458
+
1459
+ }
1460
+
1461
  }
1462
 
1463
  }
loader.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * The 404page Plugin Loader
5
+ *
6
+ * @since 7
7
+ *
8
+ **/
9
+
10
+ // If this file is called directly, abort
11
+ if ( ! defined( 'WPINC' ) ) {
12
+ die;
13
+ }
14
+
15
+
16
+ /**
17
+ * Load files
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
+ /**
23
+ * Run plugin
24
+ */
25
+ $pp_404page = new PP_404Page( array(
26
+ 'file' => dirname( __FILE__ ) . '/404page.php',
27
+ 'slug' => pathinfo( dirname( __FILE__ ) . '/404page.php', PATHINFO_FILENAME ),
28
+ 'name' => '404page - your smart custom 404 error page',
29
+ 'version' => '7'
30
+ )
31
+ );
32
+
33
+ ?>
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === 404page - your smart custom 404 error page ===
2
- Contributors: petersplugins
3
  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: 6
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 @@ Custom 404 the easy way! Set any page as custom 404 error page. No coding needed
13
 
14
  == Description ==
15
 
16
- <strong>With 70,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
  It allows you to easily create your own 404 error page without any effort and it works with almost every theme.
19
 
@@ -47,6 +47,8 @@ The only requirement for this plugin is that you change the Permalink Structure
47
 
48
  [The Advanced Setting "Force 404 error after loading page" explained](https://youtu.be/09OOCbFLfnI)
49
 
 
 
50
  == Plugin Privacy Information ==
51
 
52
  * This plugin does not set cookies
@@ -147,6 +149,11 @@ Please use the [Support Forum](https://wordpress.org/support/plugin/404page).
147
 
148
  == Changelog ==
149
 
 
 
 
 
 
150
  = 6 (2018-06-18) =
151
  * exclude 404 page from XML sitemap generated by Yoast SEO
152
  * further UI-improvements
@@ -246,6 +253,9 @@ Please use the [Support Forum](https://wordpress.org/support/plugin/404page).
246
 
247
  == Upgrade Notice ==
248
 
 
 
 
249
  = 6 =
250
  exclude 404 page from XML sitemap generated by Yoast SEO
251
 
1
  === 404page - your smart custom 404 error page ===
2
+ Contributors: petersplugins
3
  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: 5.0
7
+ Stable tag: 7
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 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
  It allows you to easily create your own 404 error page without any effort and it works with almost every theme.
19
 
47
 
48
  [The Advanced Setting "Force 404 error after loading page" explained](https://youtu.be/09OOCbFLfnI)
49
 
50
+ [The Advanced Setting "Disable URL Autocorrecton Guessing" explained](https://youtu.be/H0EdtFcAGl4)
51
+
52
  == Plugin Privacy Information ==
53
 
54
  * This plugin does not set cookies
149
 
150
  == Changelog ==
151
 
152
+ = 7 (2018-07-16) =
153
+ * corrected wrong image path
154
+ * added video links to admin page
155
+ * code improvements
156
+
157
  = 6 (2018-06-18) =
158
  * exclude 404 page from XML sitemap generated by Yoast SEO
159
  * further UI-improvements
253
 
254
  == Upgrade Notice ==
255
 
256
+ = 7 =
257
+ corrected wrong image path, added video links
258
+
259
  = 6 =
260
  exclude 404 page from XML sitemap generated by Yoast SEO
261
 
uninstall.php CHANGED
@@ -18,10 +18,14 @@ if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) || ! WP_UNINSTALL_PLUGIN || dirname( WP_
18
 
19
 
20
  /**
21
- * Load core plugin class and run uninstall
 
 
 
 
 
 
22
  */
23
- require_once( plugin_dir_path( __FILE__ ) . '/inc/class-404page.php' );
24
- $pp_404page = new PP_404Page( __FILE__ );
25
  $pp_404page->uninstall();
26
 
27
  ?>
18
 
19
 
20
  /**
21
+ * Loader
22
+ */
23
+ require_once( plugin_dir_path( __FILE__ ) . '/loader.php' );
24
+
25
+
26
+ /**
27
+ * Run Uninstaller
28
  */
 
 
29
  $pp_404page->uninstall();
30
 
31
  ?>