Version Description
Download this release
Release Info
Developer | petersplugins |
Plugin | 404page – your smart custom 404 error page |
Version | 9 |
Comparing to | |
See all releases |
Code changes from version 8 to 9
- 404page.php +1 -1
- inc/class-404page-block-editor.php +116 -0
- inc/class-404page-classic-editor.php +89 -0
- inc/class-404page.php +58 -38
- loader.php +3 -1
- readme.txt +11 -4
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:
|
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: 9
|
13 |
* Author: Peter Raschendorfer
|
14 |
* Author URI: https://petersplugins.com
|
15 |
* Text Domain: 404page
|
inc/class-404page-block-editor.php
ADDED
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* The 404page block editor plugin class
|
5 |
+
*
|
6 |
+
* @since 9
|
7 |
+
*/
|
8 |
+
|
9 |
+
if ( ! defined( 'WPINC' ) ) {
|
10 |
+
die;
|
11 |
+
}
|
12 |
+
|
13 |
+
/**
|
14 |
+
* The block editor plugin class
|
15 |
+
*/
|
16 |
+
if ( !class_exists( 'PP_404Page_BlockEditor' ) ) {
|
17 |
+
|
18 |
+
class PP_404Page_BlockEditor {
|
19 |
+
|
20 |
+
/**
|
21 |
+
* reference to core class
|
22 |
+
*
|
23 |
+
* @since 9
|
24 |
+
* @var object
|
25 |
+
* @access private
|
26 |
+
*/
|
27 |
+
private $_core;
|
28 |
+
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Initialize the class
|
32 |
+
*
|
33 |
+
* @since 9
|
34 |
+
* @access public
|
35 |
+
*/
|
36 |
+
public function __construct( $_core ) {
|
37 |
+
|
38 |
+
$this->_core = $_core;
|
39 |
+
|
40 |
+
$this->init();
|
41 |
+
|
42 |
+
}
|
43 |
+
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Do Init
|
47 |
+
*
|
48 |
+
* @since 9
|
49 |
+
* @access private
|
50 |
+
*/
|
51 |
+
private function init() {
|
52 |
+
|
53 |
+
add_action( 'admin_head', array( $this, 'admin_style' ) );
|
54 |
+
|
55 |
+
}
|
56 |
+
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Add Block Editor Style to Header if currently edited page is a custom 404 error page
|
60 |
+
*
|
61 |
+
* @since 9
|
62 |
+
* @access public
|
63 |
+
*/
|
64 |
+
public function admin_style() {
|
65 |
+
|
66 |
+
if ( $this->is_gutenberg_editing() ) {
|
67 |
+
|
68 |
+
?>
|
69 |
+
<style type="text/css">
|
70 |
+
.edit-post-layout__content:before { content: "<?php _e( 'You are currently editing your custom 404 error page', '404page'); ?>"; background-color: #333; color: #FFF; padding: 8px; font-size: 16px; display: block };
|
71 |
+
</style>
|
72 |
+
<?php
|
73 |
+
|
74 |
+
}
|
75 |
+
|
76 |
+
}
|
77 |
+
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Is the 404 page edited in gutenberg editor?
|
81 |
+
*
|
82 |
+
* @since 9
|
83 |
+
* @access private
|
84 |
+
*/
|
85 |
+
private function is_gutenberg_editing() {
|
86 |
+
|
87 |
+
// Is the current screen the page edit screen and is a custom 404 error page defined?
|
88 |
+
if ( get_current_screen()->id == 'page' && $this->_core->get_id() > 0 ) {
|
89 |
+
|
90 |
+
// Is the block editor active for pages and is the classic editor not loaded?
|
91 |
+
if ( function_exists( 'use_block_editor_for_post_type' ) && use_block_editor_for_post_type( 'page' ) && ! isset( $_GET['classic-editor'] ) ) {
|
92 |
+
|
93 |
+
global $post;
|
94 |
+
|
95 |
+
$all404pages = $this->_core->get_all_page_ids();
|
96 |
+
|
97 |
+
// Is the currently edited page a custom 404 error page?
|
98 |
+
if ( in_array( $post->ID, $all404pages ) ) {
|
99 |
+
|
100 |
+
return true;
|
101 |
+
|
102 |
+
}
|
103 |
+
|
104 |
+
}
|
105 |
+
|
106 |
+
}
|
107 |
+
|
108 |
+
return false;
|
109 |
+
|
110 |
+
}
|
111 |
+
|
112 |
+
}
|
113 |
+
|
114 |
+
}
|
115 |
+
|
116 |
+
?>
|
inc/class-404page-classic-editor.php
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* The 404page classic editor plugin class
|
5 |
+
*
|
6 |
+
* @since 9
|
7 |
+
*/
|
8 |
+
|
9 |
+
if ( ! defined( 'WPINC' ) ) {
|
10 |
+
die;
|
11 |
+
}
|
12 |
+
|
13 |
+
/**
|
14 |
+
* The classic editor plugin class
|
15 |
+
*/
|
16 |
+
if ( !class_exists( 'PP_404Page_ClassicEditor' ) ) {
|
17 |
+
|
18 |
+
class PP_404Page_ClassicEditor {
|
19 |
+
|
20 |
+
/**
|
21 |
+
* reference to core class
|
22 |
+
*
|
23 |
+
* @since 9
|
24 |
+
* @var object
|
25 |
+
* @access private
|
26 |
+
*/
|
27 |
+
private $_core;
|
28 |
+
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Initialize the class
|
32 |
+
*
|
33 |
+
* @since 9
|
34 |
+
* @access public
|
35 |
+
*/
|
36 |
+
public function __construct( $_core ) {
|
37 |
+
|
38 |
+
$this->_core = $_core;
|
39 |
+
|
40 |
+
$this->init();
|
41 |
+
|
42 |
+
}
|
43 |
+
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Do Init
|
47 |
+
*
|
48 |
+
* @since 9
|
49 |
+
* @access private
|
50 |
+
*/
|
51 |
+
private function init() {
|
52 |
+
|
53 |
+
add_action( 'admin_head', array( $this, 'admin_style' ) );
|
54 |
+
|
55 |
+
}
|
56 |
+
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Add Classic Editor Style to Header if currently edited page is a custom 404 error page
|
60 |
+
*
|
61 |
+
* @since 9
|
62 |
+
* @access public
|
63 |
+
*/
|
64 |
+
public function admin_style() {
|
65 |
+
|
66 |
+
// we just ignore whether Gutenberg is used or not, because this classes do not exist if Gutenberg is active
|
67 |
+
if ( get_current_screen()->id == 'page' && $this->_core->get_id() > 0 ) {
|
68 |
+
|
69 |
+
global $post;
|
70 |
+
|
71 |
+
$all404pages = $this->_core->get_all_page_ids();
|
72 |
+
if ( in_array( $post->ID, $all404pages ) ) {
|
73 |
+
|
74 |
+
?>
|
75 |
+
<style type="text/css">
|
76 |
+
#post-body-content:before { content: "<?php _e( 'You are currently editing your custom 404 error page', '404page'); ?>"; background-color: #333; color: #FFF; padding: 8px; font-size: 16px; display: block; margin-bottom: 10px };
|
77 |
+
</style>
|
78 |
+
<?php
|
79 |
+
|
80 |
+
}
|
81 |
+
}
|
82 |
+
|
83 |
+
}
|
84 |
+
|
85 |
+
}
|
86 |
+
|
87 |
+
}
|
88 |
+
|
89 |
+
?>
|
inc/class-404page.php
CHANGED
@@ -82,6 +82,28 @@ if ( !class_exists( 'PP_404Page' ) ) {
|
|
82 |
private $admin_handle;
|
83 |
|
84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
/**
|
86 |
* Init the Class
|
87 |
*
|
@@ -211,6 +233,9 @@ if ( !class_exists( 'PP_404Page' ) ) {
|
|
211 |
add_action( 'admin_notices', array( $this, 'admin_notices' ) );
|
212 |
add_action( 'wp_ajax_pp_404page_dismiss_admin_notice', array( $this, 'dismiss_admin_notice' ) );
|
213 |
|
|
|
|
|
|
|
214 |
}
|
215 |
|
216 |
|
@@ -223,7 +248,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
|
|
223 |
// as of v 2.2 always call set_mode
|
224 |
// as of v 2.4 we do not need to add an init action hook
|
225 |
|
226 |
-
if ( !is_admin() && $this->
|
227 |
|
228 |
// as of v 3.0 we once check if there's a 404 page set and not in all functions separately
|
229 |
$this->set_mode();
|
@@ -241,7 +266,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
|
|
241 |
if ( $this->settings->get_fire_error() ) {
|
242 |
|
243 |
add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', function () {
|
244 |
-
return array( $this->
|
245 |
} );
|
246 |
|
247 |
}
|
@@ -256,7 +281,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
|
|
256 |
add_action( 'admin_enqueue_scripts', array( $this, 'admin_css' ) );
|
257 |
|
258 |
// Remove 404 page from post list if activated
|
259 |
-
if ( $this->settings->get_hide() and $this->
|
260 |
add_action( 'pre_get_posts' ,array ( $this, 'exclude_404page' ) );
|
261 |
}
|
262 |
|
@@ -504,7 +529,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
|
|
504 |
* Standard Mode
|
505 |
*/
|
506 |
function do_404_header_standard_mode() {
|
507 |
-
if ( is_page() && get_the_ID() == $this->
|
508 |
status_header( 404 );
|
509 |
nocache_headers();
|
510 |
$this->maybe_force_404();
|
@@ -718,7 +743,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
|
|
718 |
*/
|
719 |
function admin_style() {
|
720 |
|
721 |
-
if ( $this->
|
722 |
|
723 |
echo '<style type="text/css">';
|
724 |
|
@@ -732,24 +757,6 @@ if ( !class_exists( 'PP_404Page' ) ) {
|
|
732 |
|
733 |
}
|
734 |
|
735 |
-
// the currently edited page is a 404 error page
|
736 |
-
// @since 5
|
737 |
-
if ( get_current_screen()->id == 'page' && $this->settings->get_id() > 0 ) {
|
738 |
-
|
739 |
-
global $post;
|
740 |
-
|
741 |
-
$all404pages = $this->get_all_page_ids();
|
742 |
-
if ( in_array( $post->ID, $all404pages ) ) {
|
743 |
-
|
744 |
-
?>
|
745 |
-
<style type="text/css">
|
746 |
-
h1.wp-heading-inline:before { content: "404"; background-color: #333; color: #FFF; display: inline-block; padding: 0 5px; margin-right: 10px; }';
|
747 |
-
</style>
|
748 |
-
<?php
|
749 |
-
|
750 |
-
}
|
751 |
-
}
|
752 |
-
|
753 |
}
|
754 |
|
755 |
|
@@ -758,16 +765,16 @@ if ( !class_exists( 'PP_404Page' ) ) {
|
|
758 |
*/
|
759 |
function admin_404page() {
|
760 |
|
761 |
-
if ( $this->
|
762 |
|
763 |
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>';
|
764 |
}
|
765 |
|
766 |
-
wp_dropdown_pages( array( 'name' => '404page_page_id', 'id' => 'select404page', 'echo' => 1, 'show_option_none' => __( '— NONE (WP default 404 page) —', '404page'), 'option_none_value' => '0', 'selected' => $this->
|
767 |
|
768 |
-
echo '<div id="404page_edit_link" style="display: none">' . get_edit_post_link( $this->
|
769 |
echo '<div id="404page_test_link" style="display: none">' . get_site_url() . '/404page-test-' . md5( rand() ) . '</div>';
|
770 |
-
echo '<div id="404page_current_value" style="display: none">' . $this->
|
771 |
echo '<p class="submit"><input type="button" name="edit_404_page" id="edit_404_page" class="button secondary" value="' . __( 'Edit Page', '404page' ) . '" /> <input type="button" name="test_404_page" id="test_404_page" class="button secondary" value="' . __( 'Test 404 error', '404page' ) . '" /></p>';
|
772 |
|
773 |
}
|
@@ -1242,10 +1249,10 @@ if ( !class_exists( 'PP_404Page' ) ) {
|
|
1242 |
|
1243 |
// @since 8
|
1244 |
// show update notice
|
1245 |
-
if ( current_user_can( 'manage_options' ) && get_user_meta( get_current_user_id(), 'pp-404page-update-notice-
|
1246 |
?>
|
1247 |
-
<div class="notice is-dismissible pp-404page-admin-notice" id="pp-404page-update-notice-
|
1248 |
-
<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( '
|
1249 |
</div>
|
1250 |
<?php
|
1251 |
}
|
@@ -1293,12 +1300,24 @@ if ( !class_exists( 'PP_404Page' ) ) {
|
|
1293 |
}
|
1294 |
|
1295 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1296 |
/**
|
1297 |
* get the id of the 404 page in the current language if WPML or Polylang is active
|
1298 |
*/
|
1299 |
private function get_page_id() {
|
1300 |
|
1301 |
-
$pageid = $this->
|
1302 |
|
1303 |
if ( $pageid > 0 ) {
|
1304 |
|
@@ -1328,14 +1347,15 @@ if ( !class_exists( 'PP_404Page' ) ) {
|
|
1328 |
* if WPML is active this function returns an array of all page ids in all available languages
|
1329 |
* otherwise it returns the page id as array
|
1330 |
* introduced in v 2.4
|
|
|
1331 |
*/
|
1332 |
-
|
1333 |
|
1334 |
if ( defined( 'ICL_SITEPRESS_VERSION' ) ) {
|
1335 |
|
1336 |
// WPML is active
|
1337 |
// get an array for all translations
|
1338 |
-
$pageid = $this->
|
1339 |
$pages = array( $pageid );
|
1340 |
|
1341 |
if ( $pageid > 0 ) {
|
@@ -1453,7 +1473,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
|
|
1453 |
// check if there's a custom 404 page set
|
1454 |
function pp_404_is_active() {
|
1455 |
|
1456 |
-
return ( $this->
|
1457 |
|
1458 |
}
|
1459 |
|
@@ -1469,7 +1489,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
|
|
1469 |
|
1470 |
$title = '';
|
1471 |
|
1472 |
-
if ( $this->
|
1473 |
|
1474 |
$title = get_the_title( $this->get_page_id() );
|
1475 |
|
@@ -1491,7 +1511,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
|
|
1491 |
|
1492 |
$content = '';
|
1493 |
|
1494 |
-
if ( $this->
|
1495 |
|
1496 |
$content = apply_filters( 'the_content', get_post_field( 'post_content', $this->get_page_id() ) );
|
1497 |
|
@@ -1513,9 +1533,9 @@ if ( !class_exists( 'PP_404Page' ) ) {
|
|
1513 |
* get path for asset file
|
1514 |
*
|
1515 |
* @since 7
|
1516 |
-
* @access
|
1517 |
*/
|
1518 |
-
|
1519 |
|
1520 |
return plugins_url( 'assets/' . $dir . '/' . $file, $this->get_plugin_file() );
|
1521 |
|
82 |
private $admin_handle;
|
83 |
|
84 |
|
85 |
+
/**
|
86 |
+
* Block Editor Class
|
87 |
+
*
|
88 |
+
* @see class-404page-block-editor.php
|
89 |
+
* @since 9
|
90 |
+
* @var object
|
91 |
+
* @access private
|
92 |
+
*/
|
93 |
+
private $blockeditor;
|
94 |
+
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Classic Editor Class
|
98 |
+
*
|
99 |
+
* @see class-404page-classic-editor.php
|
100 |
+
* @since 9
|
101 |
+
* @var object
|
102 |
+
* @access private
|
103 |
+
*/
|
104 |
+
private $classiceditor;
|
105 |
+
|
106 |
+
|
107 |
/**
|
108 |
* Init the Class
|
109 |
*
|
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 |
|
248 |
// as of v 2.2 always call set_mode
|
249 |
// as of v 2.4 we do not need to add an init action hook
|
250 |
|
251 |
+
if ( !is_admin() && $this->get_id() > 0 ) {
|
252 |
|
253 |
// as of v 3.0 we once check if there's a 404 page set and not in all functions separately
|
254 |
$this->set_mode();
|
266 |
if ( $this->settings->get_fire_error() ) {
|
267 |
|
268 |
add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', function () {
|
269 |
+
return array( $this->get_id() );
|
270 |
} );
|
271 |
|
272 |
}
|
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 |
}
|
287 |
|
529 |
* Standard Mode
|
530 |
*/
|
531 |
function do_404_header_standard_mode() {
|
532 |
+
if ( is_page() && get_the_ID() == $this->get_id() && !is_404() ) {
|
533 |
status_header( 404 );
|
534 |
nocache_headers();
|
535 |
$this->maybe_force_404();
|
743 |
*/
|
744 |
function admin_style() {
|
745 |
|
746 |
+
if ( $this->get_id() > 0 ) {
|
747 |
|
748 |
echo '<style type="text/css">';
|
749 |
|
757 |
|
758 |
}
|
759 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
760 |
}
|
761 |
|
762 |
|
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' => __( '— NONE (WP default 404 page) —', '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' ) . '" /> <input type="button" name="test_404_page" id="test_404_page" class="button secondary" value="' . __( 'Test 404 error', '404page' ) . '" /></p>';
|
779 |
|
780 |
}
|
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 |
}
|
1300 |
}
|
1301 |
|
1302 |
|
1303 |
+
/**
|
1304 |
+
* get id of the 404 page
|
1305 |
+
*
|
1306 |
+
* @since 9
|
1307 |
+
* @access public
|
1308 |
+
*/
|
1309 |
+
public function get_id() {
|
1310 |
+
|
1311 |
+
return $this->settings->get_id();
|
1312 |
+
|
1313 |
+
}
|
1314 |
+
|
1315 |
/**
|
1316 |
* get the id of the 404 page in the current language if WPML or Polylang is active
|
1317 |
*/
|
1318 |
private function get_page_id() {
|
1319 |
|
1320 |
+
$pageid = $this->get_id();
|
1321 |
|
1322 |
if ( $pageid > 0 ) {
|
1323 |
|
1347 |
* if WPML is active this function returns an array of all page ids in all available languages
|
1348 |
* otherwise it returns the page id as array
|
1349 |
* introduced in v 2.4
|
1350 |
+
* public since v9 to access it from other classes
|
1351 |
*/
|
1352 |
+
public function get_all_page_ids() {
|
1353 |
|
1354 |
if ( defined( 'ICL_SITEPRESS_VERSION' ) ) {
|
1355 |
|
1356 |
// WPML is active
|
1357 |
// get an array for all translations
|
1358 |
+
$pageid = $this->get_id();
|
1359 |
$pages = array( $pageid );
|
1360 |
|
1361 |
if ( $pageid > 0 ) {
|
1473 |
// check if there's a custom 404 page set
|
1474 |
function pp_404_is_active() {
|
1475 |
|
1476 |
+
return ( $this->get_id() > 0 );
|
1477 |
|
1478 |
}
|
1479 |
|
1489 |
|
1490 |
$title = '';
|
1491 |
|
1492 |
+
if ( $this->get_id() > 0 && $this->settings->get_native() ) {
|
1493 |
|
1494 |
$title = get_the_title( $this->get_page_id() );
|
1495 |
|
1511 |
|
1512 |
$content = '';
|
1513 |
|
1514 |
+
if ( $this->get_id() > 0 && $this->settings->get_native() ) {
|
1515 |
|
1516 |
$content = apply_filters( 'the_content', get_post_field( 'post_content', $this->get_page_id() ) );
|
1517 |
|
1533 |
* get path for asset file
|
1534 |
*
|
1535 |
* @since 7
|
1536 |
+
* @access public
|
1537 |
*/
|
1538 |
+
public function get_asset_file( $dir, $file ) {
|
1539 |
|
1540 |
return plugins_url( 'assets/' . $dir . '/' . $file, $this->get_plugin_file() );
|
1541 |
|
loader.php
CHANGED
@@ -18,6 +18,8 @@ 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 |
|
22 |
|
23 |
/**
|
@@ -29,7 +31,7 @@ function pp_404page() {
|
|
29 |
'file' => dirname( __FILE__ ) . '/404page.php',
|
30 |
'slug' => pathinfo( dirname( __FILE__ ) . '/404page.php', PATHINFO_FILENAME ),
|
31 |
'name' => '404page - your smart custom 404 error page',
|
32 |
-
'version' => '
|
33 |
) );
|
34 |
|
35 |
}
|
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 |
'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 |
}
|
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:
|
8 |
Requires PHP: 5.4
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
@@ -129,9 +129,10 @@ If you are a theme developer you can add native support for the 404page plugin t
|
|
129 |
== Screenshots ==
|
130 |
|
131 |
1. The default 404 error page of the currently used themme (WP Bootstrap Starter used for this example)
|
132 |
-
2.
|
133 |
-
3.
|
134 |
-
4.
|
|
|
135 |
|
136 |
== Frequently Asked Questions ==
|
137 |
|
@@ -152,6 +153,9 @@ Please use the [Support Forum](https://wordpress.org/support/plugin/404page).
|
|
152 |
|
153 |
== Changelog ==
|
154 |
|
|
|
|
|
|
|
155 |
= 8 (2019-01-11) =
|
156 |
* fixed compatibility issue with latest WPML version
|
157 |
* code improvement
|
@@ -261,6 +265,9 @@ Please use the [Support Forum](https://wordpress.org/support/plugin/404page).
|
|
261 |
|
262 |
== Upgrade Notice ==
|
263 |
|
|
|
|
|
|
|
264 |
= 8 =
|
265 |
fixed compatibility issue with latest WPML version
|
266 |
|
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
|
129 |
== Screenshots ==
|
130 |
|
131 |
1. The default 404 error page of the currently used themme (WP Bootstrap Starter used for this example)
|
132 |
+
2. Editing the custom 404 error page using the Classic Editor
|
133 |
+
3. Editing the custom 404 error page using the Block Editor (Gutenberg)
|
134 |
+
4. Select the created page as 404 error page
|
135 |
+
5. The custom 404 error page in action
|
136 |
|
137 |
== Frequently Asked Questions ==
|
138 |
|
153 |
|
154 |
== Changelog ==
|
155 |
|
156 |
+
= 8 (2019-01-24) =
|
157 |
+
* Gutenberg note added
|
158 |
+
|
159 |
= 8 (2019-01-11) =
|
160 |
* fixed compatibility issue with latest WPML version
|
161 |
* code improvement
|
265 |
|
266 |
== Upgrade Notice ==
|
267 |
|
268 |
+
= 8 =
|
269 |
+
Gutenberg note added
|
270 |
+
|
271 |
= 8 =
|
272 |
fixed compatibility issue with latest WPML version
|
273 |
|