Version Description
now uses my own Plugin Foundation
Download this release
Release Info
Developer | petersplugins |
Plugin | ![]() |
Version | 11.0.0 |
Comparing to | |
See all releases |
Code changes from version 10.5 to 11.0.0
- 404page.php +2 -38
- assets/css/404page-ui.css +6 -39
- assets/css/pp-admin-page-v2.css +0 -120
- assets/img/pluginicon.png +0 -0
- assets/js/404page.js +5 -19
- functions.php +62 -0
- inc/admin/404page-admin-page.php +9 -69
- inc/class-404page-admin.php +236 -255
- inc/class-404page-block-editor.php +5 -30
- inc/class-404page-classic-editor.php +5 -30
- inc/class-404page-deprecated.php +78 -0
- inc/class-404page-settings.php +19 -245
- inc/class-404page.php +100 -229
- inc/ppf/assets/css/pp-admin-page.css +263 -0
- inc/ppf/assets/js/jquery.cookie.js +117 -0
- inc/ppf/assets/js/pp-admin-page.js +29 -0
- inc/ppf/loader.php +19 -0
- inc/ppf/ppf-admin.php +606 -0
- inc/ppf/ppf-class.php +155 -0
- inc/ppf/ppf-plugin.php +533 -0
- inc/ppf/ppf-settings.php +206 -0
- inc/ppf/ppf-subclass.php +95 -0
- loader.php +13 -17
- readme.txt +13 -8
404page.php
CHANGED
@@ -7,9 +7,9 @@
|
|
7 |
*
|
8 |
* @wordpress-plugin
|
9 |
* Plugin Name: 404page - your smart custom 404 error page
|
10 |
-
* Plugin URI: https://petersplugins.com/
|
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
|
@@ -29,40 +29,4 @@ if ( ! defined( 'WPINC' ) ) {
|
|
29 |
*/
|
30 |
require_once( plugin_dir_path( __FILE__ ) . '/loader.php' );
|
31 |
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Theme functions
|
35 |
-
*/
|
36 |
-
|
37 |
-
|
38 |
-
// this function can be used by a theme to check if there's an active custom 404 page
|
39 |
-
function pp_404_is_active() {
|
40 |
-
return pp_404page()->pp_404_is_active();
|
41 |
-
}
|
42 |
-
|
43 |
-
// this function can be used by a theme to activate native support
|
44 |
-
function pp_404_set_native_support() {
|
45 |
-
pp_404page()->pp_404_set_native_support();
|
46 |
-
}
|
47 |
-
|
48 |
-
// this function can be used by a theme to get the title of the custom 404 page in native support
|
49 |
-
function pp_404_get_the_title() {
|
50 |
-
return pp_404page()->pp_404_get_the_title();
|
51 |
-
}
|
52 |
-
|
53 |
-
// this function can be used by a theme to print out the title of the custom 404 page in native support
|
54 |
-
function pp_404_the_title() {
|
55 |
-
pp_404page()->pp_404_the_title();
|
56 |
-
}
|
57 |
-
|
58 |
-
// this function can be used by a theme to get the content of the custom 404 page in native support
|
59 |
-
function pp_404_get_the_content() {
|
60 |
-
return pp_404page()->pp_404_get_the_content();
|
61 |
-
}
|
62 |
-
|
63 |
-
// this function can be used by a theme to print out the content of the custom 404 page in native support
|
64 |
-
function pp_404_the_content() {
|
65 |
-
return pp_404page()->pp_404_the_content();
|
66 |
-
}
|
67 |
-
|
68 |
?>
|
7 |
*
|
8 |
* @wordpress-plugin
|
9 |
* Plugin Name: 404page - your smart custom 404 error page
|
10 |
+
* Plugin URI: https://petersplugins.com/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: 11.0.0
|
13 |
* Author: Peter Raschendorfer
|
14 |
* Author URI: https://petersplugins.com
|
15 |
* Text Domain: 404page
|
29 |
*/
|
30 |
require_once( plugin_dir_path( __FILE__ ) . '/loader.php' );
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
?>
|
assets/css/404page-ui.css
CHANGED
@@ -2,40 +2,7 @@
|
|
2 |
width: 100%;
|
3 |
}
|
4 |
|
5 |
-
|
6 |
-
display: block;
|
7 |
-
width: auto;
|
8 |
-
}
|
9 |
-
|
10 |
-
#pp-404page-settings .form-table td {
|
11 |
-
padding: 0;
|
12 |
-
margin-bottom: 20px;
|
13 |
-
}
|
14 |
-
|
15 |
-
#pp-404page-settings .form-table td p {
|
16 |
-
padding: 0;
|
17 |
-
line-height: 1.2;
|
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 {
|
27 |
-
border: 1px solid #104060;
|
28 |
-
border-radius:5px;
|
29 |
-
height: 40px;
|
30 |
-
line-height: 40px;
|
31 |
-
margin: 5px 0;
|
32 |
-
}
|
33 |
-
|
34 |
-
#pp-404page-settings .dashicons-warning, #pp-404page-settings input[type="checkbox"] + label.check.warning:before {
|
35 |
-
color: #d54e21;
|
36 |
-
}
|
37 |
-
|
38 |
-
#pp-404page-videos:after {
|
39 |
content: '';
|
40 |
display: block;
|
41 |
width: 0;
|
@@ -45,7 +12,7 @@
|
|
45 |
clear: both;
|
46 |
}
|
47 |
|
48 |
-
|
49 |
display: block;
|
50 |
margin: 0 12px 12px 0;
|
51 |
width: 300px;
|
@@ -53,16 +20,16 @@
|
|
53 |
line-height: 1;
|
54 |
}
|
55 |
|
56 |
-
|
57 |
position: relative;
|
58 |
}
|
59 |
|
60 |
-
|
61 |
width: 100%;
|
62 |
height: auto;
|
63 |
}
|
64 |
|
65 |
-
|
66 |
content: '\f236';
|
67 |
font-family: dashicons;
|
68 |
font-size: 60px;
|
@@ -78,7 +45,7 @@
|
|
78 |
transition: opacity 0.3s ease-in-out;
|
79 |
}
|
80 |
|
81 |
-
|
82 |
opacity: 0.8;
|
83 |
}
|
84 |
|
2 |
width: 100%;
|
3 |
}
|
4 |
|
5 |
+
.pp-404page-videos:after {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
content: '';
|
7 |
display: block;
|
8 |
width: 0;
|
12 |
clear: both;
|
13 |
}
|
14 |
|
15 |
+
.pp-404page-videos a {
|
16 |
display: block;
|
17 |
margin: 0 12px 12px 0;
|
18 |
width: 300px;
|
20 |
line-height: 1;
|
21 |
}
|
22 |
|
23 |
+
.pp-404page-videos a div {
|
24 |
position: relative;
|
25 |
}
|
26 |
|
27 |
+
.pp-404page-videos a img {
|
28 |
width: 100%;
|
29 |
height: auto;
|
30 |
}
|
31 |
|
32 |
+
.pp-404page-videos a div:after {
|
33 |
content: '\f236';
|
34 |
font-family: dashicons;
|
35 |
font-size: 60px;
|
45 |
transition: opacity 0.3s ease-in-out;
|
46 |
}
|
47 |
|
48 |
+
.pp-404page-videos a:hover div:after, .pp-404page-videos a:focus div:after {
|
49 |
opacity: 0.8;
|
50 |
}
|
51 |
|
assets/css/pp-admin-page-v2.css
DELETED
@@ -1,120 +0,0 @@
|
|
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/img/pluginicon.png
CHANGED
Binary file
|
assets/js/404page.js
CHANGED
@@ -1,19 +1,5 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
data = {
|
8 |
-
action: 'pp_404page_dismiss_admin_notice',
|
9 |
-
pp_404page_dismiss_admin_notice: $( this ).parent().attr( 'id' ),
|
10 |
-
securekey : pp_404page_security.securekey
|
11 |
-
};
|
12 |
-
|
13 |
-
$.post( ajaxurl, data );
|
14 |
-
|
15 |
-
return false;
|
16 |
-
|
17 |
-
});
|
18 |
-
|
19 |
-
});
|
1 |
+
/**
|
2 |
+
* As of version 11.0.0 this file is no longer needed
|
3 |
+
*
|
4 |
+
* It is only included in the setup to override the file when upgrading from an earlier version
|
5 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
functions.php
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* The 404page Plugin Functions
|
5 |
+
*
|
6 |
+
* @since 11.0.0
|
7 |
+
*
|
8 |
+
**/
|
9 |
+
|
10 |
+
// If this file is called directly, abort
|
11 |
+
if ( ! defined( 'WPINC' ) ) {
|
12 |
+
die;
|
13 |
+
}
|
14 |
+
|
15 |
+
|
16 |
+
// this function can be used by a theme to check if there's an active custom 404 page
|
17 |
+
function pp_404_is_active() {
|
18 |
+
|
19 |
+
return pp_404page()->pp_404_is_active();
|
20 |
+
|
21 |
+
}
|
22 |
+
|
23 |
+
|
24 |
+
// this function can be used by a theme to activate native support
|
25 |
+
function pp_404_set_native_support() {
|
26 |
+
|
27 |
+
pp_404page()->pp_404_set_native_support();
|
28 |
+
|
29 |
+
}
|
30 |
+
|
31 |
+
|
32 |
+
// this function can be used by a theme to get the title of the custom 404 page in native support
|
33 |
+
function pp_404_get_the_title() {
|
34 |
+
|
35 |
+
return pp_404page()->pp_404_get_the_title();
|
36 |
+
|
37 |
+
}
|
38 |
+
|
39 |
+
|
40 |
+
// this function can be used by a theme to print out the title of the custom 404 page in native support
|
41 |
+
function pp_404_the_title() {
|
42 |
+
|
43 |
+
pp_404page()->pp_404_the_title();
|
44 |
+
|
45 |
+
}
|
46 |
+
|
47 |
+
|
48 |
+
// this function can be used by a theme to get the content of the custom 404 page in native support
|
49 |
+
function pp_404_get_the_content() {
|
50 |
+
|
51 |
+
return pp_404page()->pp_404_get_the_content();
|
52 |
+
|
53 |
+
}
|
54 |
+
|
55 |
+
// this function can be used by a theme to print out the content of the custom 404 page in native support
|
56 |
+
function pp_404_the_content() {
|
57 |
+
|
58 |
+
return pp_404page()->pp_404_the_content();
|
59 |
+
|
60 |
+
}
|
61 |
+
|
62 |
+
?>
|
inc/admin/404page-admin-page.php
CHANGED
@@ -1,69 +1,9 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
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 |
-
),
|
26 |
-
array(
|
27 |
-
'link' => 'https://petersplugins.com/',
|
28 |
-
'title' => __( 'Authors Website', '404page' ),
|
29 |
-
'icon' => 'dashicons-admin-home'
|
30 |
-
),
|
31 |
-
array(
|
32 |
-
'link' => 'https://www.facebook.com/petersplugins/',
|
33 |
-
'title' => __( 'Authors Facebook Page', '404page' ),
|
34 |
-
'icon' => 'dashicons-facebook-alt'
|
35 |
-
)
|
36 |
-
|
37 |
-
) ); ?>
|
38 |
-
</nav>
|
39 |
-
</h1>
|
40 |
-
<?php settings_errors(); ?>
|
41 |
-
|
42 |
-
<div class="postbox">
|
43 |
-
<div class="inside">
|
44 |
-
|
45 |
-
<form method="POST" action="options.php">
|
46 |
-
|
47 |
-
<h2><?php esc_html_e( 'General', '404page' ); ?></h2>
|
48 |
-
<?php settings_fields( '404page_settings' ); ?>
|
49 |
-
<?php do_settings_sections( '404page_settings_section' ); ?>
|
50 |
-
<div id="pp-settings-advanced">
|
51 |
-
<h2><?php esc_html_e( 'Advanced', '404page' ); ?></h2>
|
52 |
-
<?php do_settings_sections( '404page_settings_section_advanced' ); ?>
|
53 |
-
</div>
|
54 |
-
<?php submit_button(); ?>
|
55 |
-
|
56 |
-
</form>
|
57 |
-
|
58 |
-
</div>
|
59 |
-
</div>
|
60 |
-
|
61 |
-
<div class="postbox">
|
62 |
-
<div class="inside">
|
63 |
-
<div id="pp-404page-videos">
|
64 |
-
<h2><?php esc_html_e( 'Watch the Explainer Videos', '404page' ); ?></h2>
|
65 |
-
<?php $this->show_videos(); ?>
|
66 |
-
</div>
|
67 |
-
</div>
|
68 |
-
</div>
|
69 |
-
</div>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* As of version 11.0.0 this file is no longer needed
|
5 |
+
*
|
6 |
+
* It is only included in the setup to override the file when upgrading from an earlier version
|
7 |
+
*/
|
8 |
+
|
9 |
+
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inc/class-404page-admin.php
CHANGED
@@ -15,115 +15,168 @@ if ( ! defined( 'WPINC' ) ) {
|
|
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 |
-
*
|
52 |
*
|
53 |
* @since 10
|
54 |
* @access public
|
55 |
*/
|
56 |
-
public function
|
57 |
-
|
58 |
-
|
59 |
-
$this->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
|
61 |
-
$this
|
|
|
62 |
|
|
|
|
|
63 |
}
|
64 |
|
65 |
|
66 |
/**
|
67 |
-
|
68 |
-
*
|
69 |
-
* @since 10
|
70 |
-
* @access private
|
71 |
*/
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
}
|
84 |
|
85 |
|
86 |
/**
|
87 |
-
*
|
88 |
-
*
|
|
|
|
|
|
|
|
|
|
|
89 |
*/
|
90 |
-
function
|
91 |
-
|
92 |
-
$
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
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', esc_html__( 'Page to be displayed as 404 page', '404page' ) . ' <a class="dashicons dashicons-editor-help" href="' . esc_url( '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
|
116 |
* moved to PP_404Page_Admin in v 10
|
117 |
*/
|
118 |
-
function
|
119 |
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
|
|
|
124 |
}
|
125 |
|
126 |
-
|
|
|
|
|
|
|
|
|
|
|
127 |
|
128 |
}
|
129 |
|
@@ -134,9 +187,13 @@ if ( !class_exists( 'PP_404Page_Admin' ) ) {
|
|
134 |
*/
|
135 |
function admin_hide() {
|
136 |
|
137 |
-
|
138 |
-
|
139 |
-
|
|
|
|
|
|
|
|
|
140 |
|
141 |
}
|
142 |
|
@@ -147,17 +204,13 @@ if ( !class_exists( 'PP_404Page_Admin' ) ) {
|
|
147 |
*/
|
148 |
function admin_fire404() {
|
149 |
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
}
|
159 |
-
|
160 |
-
echo '</p><div class="clear"></div>';
|
161 |
|
162 |
}
|
163 |
|
@@ -168,9 +221,13 @@ if ( !class_exists( 'PP_404Page_Admin' ) ) {
|
|
168 |
*/
|
169 |
function admin_force404() {
|
170 |
|
171 |
-
|
172 |
-
|
173 |
-
|
|
|
|
|
|
|
|
|
174 |
|
175 |
}
|
176 |
|
@@ -181,9 +238,13 @@ if ( !class_exists( 'PP_404Page_Admin' ) ) {
|
|
181 |
*/
|
182 |
function admin_noguess() {
|
183 |
|
184 |
-
|
185 |
-
|
186 |
-
|
|
|
|
|
|
|
|
|
187 |
|
188 |
}
|
189 |
|
@@ -195,9 +256,13 @@ if ( !class_exists( 'PP_404Page_Admin' ) ) {
|
|
195 |
*/
|
196 |
function admin_http410() {
|
197 |
|
198 |
-
|
199 |
-
|
200 |
-
|
|
|
|
|
|
|
|
|
201 |
|
202 |
}
|
203 |
|
@@ -208,7 +273,9 @@ if ( !class_exists( 'PP_404Page_Admin' ) ) {
|
|
208 |
*/
|
209 |
function admin_method() {
|
210 |
|
211 |
-
|
|
|
|
|
212 |
|
213 |
$dis = ' disabled="disabled"';
|
214 |
|
@@ -217,24 +284,24 @@ if ( !class_exists( 'PP_404Page_Admin' ) ) {
|
|
217 |
$dis = '';
|
218 |
}
|
219 |
|
220 |
-
echo '<p class="toggle"><input type="checkbox" id="404page_method" name="404page_method" value="CMP"' . checked( 'CMP', $this->
|
221 |
-
echo '<label for="404page_method" class="check"></label
|
222 |
echo '<span class="dashicons dashicons-info"></span> ';
|
223 |
|
224 |
-
if ( $this->
|
225 |
|
226 |
esc_html_e( 'This setting is not available because the Theme you are using natively supports the 404page plugin.', '404page' );
|
227 |
-
echo ' (<a href="' . esc_url( 'https://petersplugins.com
|
228 |
|
229 |
} elseif ( defined( 'CUSTOMIZR_VER' ) ) {
|
230 |
|
231 |
esc_html_e( 'This setting is not availbe because the 404page Plugin works in Customizr Compatibility Mode.', '404page' );
|
232 |
-
echo ' (<a href="' . esc_url( 'https://petersplugins.com
|
233 |
|
234 |
} elseif ( defined( 'ICL_SITEPRESS_VERSION' ) ) {
|
235 |
|
236 |
esc_html_e( 'This setting is not availbe because the 404page Plugin works in WPML Mode.', '404page' );
|
237 |
-
echo ' (<a href="' . esc_url( 'https://petersplugins.com
|
238 |
|
239 |
} else {
|
240 |
|
@@ -242,7 +309,7 @@ if ( !class_exists( 'PP_404Page_Admin' ) ) {
|
|
242 |
|
243 |
}
|
244 |
|
245 |
-
echo '</p
|
246 |
|
247 |
}
|
248 |
|
@@ -251,8 +318,9 @@ if ( !class_exists( 'PP_404Page_Admin' ) ) {
|
|
251 |
* create the menu entry
|
252 |
* moved to PP_404Page_Admin in v 10
|
253 |
*/
|
254 |
-
function
|
255 |
-
$
|
|
|
256 |
}
|
257 |
|
258 |
|
@@ -260,13 +328,13 @@ if ( !class_exists( 'PP_404Page_Admin' ) ) {
|
|
260 |
* add admin css to header
|
261 |
* moved to PP_404Page_Admin in v 10
|
262 |
*/
|
263 |
-
function
|
264 |
|
265 |
-
if ( $this->
|
266 |
|
267 |
echo '<style type="text/css">';
|
268 |
|
269 |
-
foreach ( $this->
|
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 |
|
@@ -279,38 +347,16 @@ if ( !class_exists( 'PP_404Page_Admin' ) ) {
|
|
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">' . esc_html__( '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' => esc_html__( '— NONE (WP default 404 page) —', '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="' . esc_html__( 'Edit Page', '404page' ) . '" /> <input type="button" name="test_404_page" id="test_404_page" class="button secondary" value="' . esc_html__( '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->
|
310 |
|
311 |
-
wp_enqueue_style( '404pagelity', $this->
|
312 |
-
wp_enqueue_style( '
|
313 |
-
wp_enqueue_style( '404pagecss', $this->_core->get_asset_file( 'css', '404page-ui.css' ) );
|
314 |
|
315 |
}
|
316 |
|
@@ -322,16 +368,11 @@ if ( !class_exists( 'PP_404Page_Admin' ) ) {
|
|
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 |
-
// since 10.4
|
329 |
-
wp_localize_script( '404pagejs', 'pp_404page_security', array( 'securekey' => $this->get_nonce() ) );
|
330 |
|
331 |
-
if ( get_current_screen()->id == $this->
|
332 |
|
333 |
-
wp_enqueue_script( '404page-ui', $this->
|
334 |
-
wp_enqueue_script( '404page-lity', $this->
|
335 |
|
336 |
}
|
337 |
|
@@ -344,106 +385,42 @@ if ( !class_exists( 'PP_404Page_Admin' ) ) {
|
|
344 |
*/
|
345 |
function show_admin() {
|
346 |
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
// @since 8
|
381 |
-
// show update notice
|
382 |
-
|
383 |
-
/**
|
384 |
-
* no notice in version 10
|
385 |
-
*
|
386 |
-
*
|
387 |
-
* if ( current_user_can( 'manage_options' ) && get_user_meta( get_current_user_id(), 'pp-404page-update-notice-v9', true ) != 'dismissed' ) {
|
388 |
-
* ?>
|
389 |
-
* <div class="notice is-dismissible pp-404page-admin-notice" id="pp-404page-update-notice-v9">
|
390 |
-
* <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 esc_html_e( 'What\'s new in Version 9?', '404page' ); ?></strong><br /><?php esc_html_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 esc_html_e( 'Changelog', '404page' ); ?></a>]<div class="clear"></div></p>
|
391 |
-
* </div>
|
392 |
-
* <?php
|
393 |
-
* }
|
394 |
-
*
|
395 |
-
*/
|
396 |
-
|
397 |
-
// invite to follow me
|
398 |
-
if ( current_user_can( 'manage_options' ) && get_user_meta( get_current_user_id(), 'pp-404page-admin-notice-1', true ) != 'dismissed' ) {
|
399 |
-
?>
|
400 |
-
<div class="notice is-dismissible pp-404page-admin-notice" id="pp-404page-admin-notice-1">
|
401 |
-
<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 esc_html_e( 'Do you like the 404page plugin?', '404page' ); ?></strong><br /><?php esc_html_e( 'Follow me:', '404page' ); ?> <a class="dashicons dashicons-facebook-alt" href="https://www.facebook.com/petersplugins" title="<?php esc_html_e( 'Authors facebook Page', '404page' ); ?>"></a><div class="clear"></div></p>
|
402 |
-
</div>
|
403 |
-
<?php
|
404 |
-
}
|
405 |
-
|
406 |
-
// ask for rating
|
407 |
-
// in 30 days at the earliest
|
408 |
-
if ( ! get_option( 'pp-404page-admin-notice-2-start' ) ) {
|
409 |
-
update_option( 'pp-404page-admin-notice-2-start', time() + 30 * 24 * 60 * 60 );
|
410 |
-
}
|
411 |
-
if ( get_option( 'pp-404page-admin-notice-2-start' ) <= time() ) {
|
412 |
-
if ( current_user_can( 'manage_options' ) && get_user_meta( get_current_user_id(), 'pp-404page-admin-notice-2', true ) != 'dismissed' ) {
|
413 |
-
?>
|
414 |
-
<div class="notice is-dismissible pp-404page-admin-notice" id="pp-404page-admin-notice-2">
|
415 |
-
<p><img src="<?php echo $this->_core->get_asset_file( 'img', 'pluginicon.png' ); ?>" style="width: 48px; height: 48px; float: left; margin-right: 20px" /><?php esc_html_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="<?php echo esc_url( 'https://wordpress.org/support/plugin/' . $this->_core->get_plugin_slug() . '/reviews/#new-post' ); ?>" title="<?php esc_html_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>
|
416 |
-
</div>
|
417 |
-
<?php
|
418 |
-
}
|
419 |
-
}
|
420 |
-
|
421 |
-
}
|
422 |
-
|
423 |
-
|
424 |
-
/**
|
425 |
-
* dismiss an admin notice
|
426 |
-
* moved to PP_404Page_Admin in v 10
|
427 |
-
*/
|
428 |
-
function dismiss_admin_notice() {
|
429 |
-
|
430 |
-
// since 10.4 check nonce
|
431 |
-
if ( $this->check_nonce() ) {
|
432 |
-
|
433 |
-
if ( isset( $_POST['pp_404page_dismiss_admin_notice'] ) ) {
|
434 |
-
|
435 |
-
// since 10.4 check value
|
436 |
-
if (strpos( $_POST['pp_404page_dismiss_admin_notice'], 'pp-404page-admin-notice-') === 0 ) {
|
437 |
|
438 |
-
|
439 |
-
|
440 |
-
}
|
441 |
-
|
442 |
-
}
|
443 |
-
|
444 |
-
}
|
445 |
|
446 |
-
|
447 |
|
448 |
}
|
449 |
|
@@ -454,20 +431,22 @@ if ( !class_exists( 'PP_404Page_Admin' ) ) {
|
|
454 |
*/
|
455 |
function add_settings_links( $links ) {
|
456 |
|
457 |
-
return array_merge( $links, array( '<a href="' . admin_url( 'themes.php?page=404pagesettings' ) . '" title="' . esc_html__( 'Settings', '404page' ) . '">' . esc_html__( 'Settings', '404page' ) . '</a>', '<a href="' . esc_url( 'https://wordpress.org/support/plugin/' . $this->
|
458 |
|
459 |
}
|
460 |
|
461 |
|
462 |
/**
|
463 |
-
*
|
|
|
464 |
*
|
465 |
-
* @since
|
466 |
* @access private
|
467 |
-
*
|
468 |
-
* moved to PP_404Page_Admin in v 10
|
469 |
*/
|
470 |
-
private function
|
|
|
|
|
471 |
|
472 |
$videos = array(
|
473 |
array( 'id' => 'HygoFMwdIuY', 'title' => 'A brief introduction', 'img' => '404page-brief-intro' ),
|
@@ -480,9 +459,11 @@ if ( !class_exists( 'PP_404Page_Admin' ) ) {
|
|
480 |
|
481 |
foreach( $videos as $video ) {
|
482 |
|
483 |
-
|
484 |
|
485 |
}
|
|
|
|
|
486 |
|
487 |
}
|
488 |
|
15 |
*/
|
16 |
if ( !class_exists( 'PP_404Page_Admin' ) ) {
|
17 |
|
18 |
+
class PP_404Page_Admin extends PPF01_Admin {
|
19 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
/**
|
22 |
+
* Do Init
|
23 |
*
|
24 |
* @since 10
|
25 |
* @access public
|
26 |
*/
|
27 |
+
public function init() {
|
28 |
+
|
29 |
+
// @since 11.0.0
|
30 |
+
$this->init_rating_notice( array(
|
31 |
+
'title' => esc_html( 'Are you happy with the 404page plugin?', '404page' ),
|
32 |
+
'subtitle' => esc_html( 'You\'ve been using this plugin for a while now. Would be great to get some feedback!', '404page' ),
|
33 |
+
'button_yes' => esc_html( 'Yes, I\'m happy with it', '404page' ),
|
34 |
+
'button_no' => esc_html( 'Not really', '404page' ),
|
35 |
+
'button_later' => esc_html( 'Ask me later', '404page' ),
|
36 |
+
'button_close' => esc_html( 'Never show again', '404page' ),
|
37 |
+
'like' => esc_html( 'I\'m really glad you like it. I do not ask for a donation. All I\'m asking you for is to give it a good rating. Thank you very much. If you like, you can follow me on facebook.', '404page' ),
|
38 |
+
'button_rate' => esc_html( 'Yes, I\'d like to rate it', '404page' ),
|
39 |
+
'button_fb' => esc_html( 'Open Facebook page', '404page' ),
|
40 |
+
'dislike' => esc_html( 'I\'m really sorry you don\'t like it. Would you please do me a favor and drop me line, why you are not happy with it? Maybe I can do better...', '404page' ),
|
41 |
+
'button_contact' => esc_html( 'Yes sure', '404page' )
|
42 |
+
),
|
43 |
+
array(
|
44 |
+
'rate' => 'https://wordpress.org/support/plugin/' . $this->core()->get_plugin_slug() . '/reviews/',
|
45 |
+
'contact' => 'https://petersplugins.com/contact/',
|
46 |
+
'facebook' => 'https://www.facebook.com/petersplugins/'
|
47 |
+
));
|
48 |
+
|
49 |
+
$this->add_actions( array(
|
50 |
+
'admin_init',
|
51 |
+
'admin_menu',
|
52 |
+
'admin_head'
|
53 |
+
) );
|
54 |
|
55 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'admin_js' ) );
|
56 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'admin_css' ) );
|
57 |
|
58 |
+
add_filter( 'plugin_action_links_' . plugin_basename( $this->core()->get_plugin_file() ), array( $this, 'add_settings_links' ) );
|
59 |
+
|
60 |
}
|
61 |
|
62 |
|
63 |
/**
|
64 |
+
* init admin
|
65 |
+
* moved to PP_404Page_Admin in v 10
|
|
|
|
|
66 |
*/
|
67 |
+
function action_admin_init() {
|
68 |
+
|
69 |
+
$this->settings()->set_method();
|
70 |
+
|
71 |
+
// @since 11.0.0
|
72 |
+
$this->add_setting_sections(
|
73 |
+
|
74 |
+
array(
|
75 |
+
|
76 |
+
array(
|
77 |
+
|
78 |
+
'section' => 'general',
|
79 |
+
'title' => esc_html__( 'General', '404page' ),
|
80 |
+
'fields' => array(
|
81 |
+
array(
|
82 |
+
'key' => 'page_id',
|
83 |
+
'callback' => 'admin_404page'
|
84 |
+
)
|
85 |
+
)
|
86 |
+
|
87 |
+
),
|
88 |
+
|
89 |
+
array(
|
90 |
+
|
91 |
+
'section' => 'advanced',
|
92 |
+
'title' => esc_html__( 'Advanced', '404page' ),
|
93 |
+
'fields' => array(
|
94 |
+
array(
|
95 |
+
'key' => 'hide',
|
96 |
+
'callback' => 'admin_hide'
|
97 |
+
),
|
98 |
+
array(
|
99 |
+
'key' => 'fire_error',
|
100 |
+
'callback' => 'admin_fire404'
|
101 |
+
),
|
102 |
+
array(
|
103 |
+
'key' => 'force_error',
|
104 |
+
'callback' => 'admin_force404'
|
105 |
+
),
|
106 |
+
array(
|
107 |
+
'key' => 'no_url_guessing',
|
108 |
+
'callback' => 'admin_noguess'
|
109 |
+
),
|
110 |
+
array(
|
111 |
+
'key' => 'http410_if_trashed',
|
112 |
+
'callback' => 'admin_http410'
|
113 |
+
),
|
114 |
+
array(
|
115 |
+
'key' => 'method',
|
116 |
+
'callback' => 'admin_method'
|
117 |
+
)
|
118 |
+
|
119 |
+
)
|
120 |
+
|
121 |
+
),
|
122 |
+
|
123 |
+
array(
|
124 |
+
|
125 |
+
'section' => 'videos',
|
126 |
+
'title' => esc_html__( 'Explainer Videos', '404page' ),
|
127 |
+
'html' => $this->add_videos(),
|
128 |
+
'nosubmit' => true
|
129 |
+
|
130 |
+
)
|
131 |
+
|
132 |
+
)
|
133 |
+
|
134 |
+
);
|
135 |
+
|
136 |
}
|
137 |
|
138 |
|
139 |
/**
|
140 |
+
* sanitize settings
|
141 |
+
* was handle_method() in previous versions
|
142 |
+
* as of version 11.0.0 the method is part of the settings array
|
143 |
+
*
|
144 |
+
* @since 11.0.0
|
145 |
+
* @param array $settings array of settings to save
|
146 |
+
* @access public
|
147 |
*/
|
148 |
+
public function sanitize_settings( $settings ) {
|
149 |
+
|
150 |
+
if ( ! array_key_exists( 'method', $settings ) || ( $settings['method'] != 'STD' && $settings['method'] != 'CMP' ) ) {
|
151 |
+
|
152 |
+
$settings['method'] = 'STD';
|
153 |
+
|
154 |
+
}
|
155 |
+
|
156 |
+
return $settings;
|
157 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
}
|
159 |
|
160 |
|
161 |
/**
|
162 |
+
* handle the settings field page id
|
163 |
* moved to PP_404Page_Admin in v 10
|
164 |
*/
|
165 |
+
function admin_404page() {
|
166 |
|
167 |
+
echo esc_html__( 'Page to be displayed as 404 page', '404page' ) . ' <a class="dashicons dashicons-editor-help" href="' . esc_url( 'https://petersplugins.com/' . $this->core()->get_plugin_slug() . '/manual/#settings_select_page' ) . '"></a>';
|
168 |
+
|
169 |
+
if ( $this->settings()->get( 'page_id' ) < 0 ) {
|
170 |
|
171 |
+
echo '<div class="error form-invalid" style="line-height: 3em">' . esc_html__( 'The page you have selected as 404 page does not exist anymore. Please choose another page.', '404page' ) . '</div>';
|
172 |
}
|
173 |
|
174 |
+
wp_dropdown_pages( array( 'name' => $this->settings()->get_option_name() . '[page_id]', 'id' => 'select404page', 'echo' => 1, 'show_option_none' => esc_html__( '— NONE (WP default 404 page) —', '404page'), 'option_none_value' => '0', 'selected' => $this->settings()->get( 'page_id' ) ) );
|
175 |
+
|
176 |
+
echo '<div id="404page_edit_link" style="display: none">' . get_edit_post_link( $this->settings()->get( 'page_id' ) ) . '</div>';
|
177 |
+
echo '<div id="404page_test_link" style="display: none">' . get_site_url() . '/404page-test-' . md5( rand() ) . '</div>';
|
178 |
+
echo '<div id="404page_current_value" style="display: none">' . $this->settings()->get( 'page_id' ) . '</div>';
|
179 |
+
echo '<p class="submit"><input type="button" name="edit_404_page" id="edit_404_page" class="button secondary" value="' . esc_html__( 'Edit Page', '404page' ) . '" /> <input type="button" name="test_404_page" id="test_404_page" class="button secondary" value="' . esc_html__( 'Test 404 error', '404page' ) . '" /></p>';
|
180 |
|
181 |
}
|
182 |
|
187 |
*/
|
188 |
function admin_hide() {
|
189 |
|
190 |
+
$this->print_slider_check(
|
191 |
+
'hide',
|
192 |
+
esc_html__( 'Hide the selected page from the Pages list', '404page' ),
|
193 |
+
'settings_hide_page',
|
194 |
+
false,
|
195 |
+
'<span class="dashicons dashicons-info"></span> ' . esc_html__( 'For Administrators the page is always visible.', '404page' )
|
196 |
+
);
|
197 |
|
198 |
}
|
199 |
|
204 |
*/
|
205 |
function admin_fire404() {
|
206 |
|
207 |
+
$this->print_slider_check(
|
208 |
+
'fire_error',
|
209 |
+
esc_html__( 'Send an 404 error if the page is accessed directly by its URL', '404page' ),
|
210 |
+
'settings_fire_404',
|
211 |
+
false,
|
212 |
+
'<span class="dashicons dashicons-info"></span> ' . esc_html__( 'Uncheck this if you want the selected page to be accessible.', '404page' ) . ( function_exists( 'wpsupercache_activate' ) ? '<br /><span class="dashicons dashicons-warning"></span> <strong>' . esc_html__( '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' ) . '">' . esc_html__( 'Click here', '404page' ) . '</a>).<br />(<a href="' . esc_url( 'https://petersplugins.com/' . $this->core()->get_plugin_slug() . '/manual/#wp_super_cache' ) . '">' . esc_html__( 'Read more', '404page' ) . '</a>)' : '' )
|
213 |
+
);
|
|
|
|
|
|
|
|
|
214 |
|
215 |
}
|
216 |
|
221 |
*/
|
222 |
function admin_force404() {
|
223 |
|
224 |
+
$this->print_slider_check(
|
225 |
+
'force_error',
|
226 |
+
esc_html__( 'Force 404 error after loading page', '404page' ),
|
227 |
+
'settings_force_404',
|
228 |
+
'09OOCbFLfnI',
|
229 |
+
'<span class="dashicons dashicons-warning"></span> ' . esc_html__( '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' )
|
230 |
+
);
|
231 |
|
232 |
}
|
233 |
|
238 |
*/
|
239 |
function admin_noguess() {
|
240 |
|
241 |
+
$this->print_slider_check(
|
242 |
+
'no_url_guessing',
|
243 |
+
esc_html__( 'Disable URL autocorrection guessing', '404page' ),
|
244 |
+
'settings_stop_guessing',
|
245 |
+
'H0EdtFcAGl4',
|
246 |
+
'<span class="dashicons dashicons-warning"></span> ' . esc_html__( 'This stops WordPress from URL autocorrection guessing. Only activate, if you are sure about the consequences.', '404page' )
|
247 |
+
);
|
248 |
|
249 |
}
|
250 |
|
256 |
*/
|
257 |
function admin_http410() {
|
258 |
|
259 |
+
$this->print_slider_check(
|
260 |
+
'http410_if_trashed',
|
261 |
+
esc_html__( 'Send an HTTP 410 error instead of HTTP 404 in case the requested object is in trash', '404page' ),
|
262 |
+
'settings_maybe_send_http410',
|
263 |
+
'O5xPM0BMZxM',
|
264 |
+
'<span class="dashicons dashicons-info"></span> ' . esc_html__( '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' )
|
265 |
+
);
|
266 |
|
267 |
}
|
268 |
|
273 |
*/
|
274 |
function admin_method() {
|
275 |
|
276 |
+
// unfortunately we can't use print_slider_check() here
|
277 |
+
|
278 |
+
if ( $this->core()->is_native() || defined( 'CUSTOMIZR_VER' ) || defined( 'ICL_SITEPRESS_VERSION' ) ) {
|
279 |
|
280 |
$dis = ' disabled="disabled"';
|
281 |
|
284 |
$dis = '';
|
285 |
}
|
286 |
|
287 |
+
echo '<p class="toggle"><span class="slider"><input type="checkbox" id="404page_method" name="404page_method" value="CMP"' . checked( 'CMP', $this->settings()->get( 'method' ), false ) . $dis . '/>';
|
288 |
+
echo '<label for="404page_method" class="check"></label></span><span class="caption">' . esc_html__( 'Activate Compatibility Mode', '404page' ) . ' <a class="dashicons dashicons-editor-help" href="' . esc_url( 'https://petersplugins.com/' . $this->core()->get_plugin_slug() . '/manual/#settings_operating_method' ) . '"></a> <a class="dashicons dashicons-video-alt3" href="https://youtu.be/wqSepDyQeqY" data-lity></a><br />';
|
289 |
echo '<span class="dashicons dashicons-info"></span> ';
|
290 |
|
291 |
+
if ( $this->core()->is_native() ) {
|
292 |
|
293 |
esc_html_e( 'This setting is not available because the Theme you are using natively supports the 404page plugin.', '404page' );
|
294 |
+
echo ' (<a href="' . esc_url( 'https://petersplugins.com/' . $this->core()->get_plugin_slug() . '/manual/#native_mode' ) . '">' . esc_html__( 'Read more', '404page' ) . '</a>)';
|
295 |
|
296 |
} elseif ( defined( 'CUSTOMIZR_VER' ) ) {
|
297 |
|
298 |
esc_html_e( 'This setting is not availbe because the 404page Plugin works in Customizr Compatibility Mode.', '404page' );
|
299 |
+
echo ' (<a href="' . esc_url( 'https://petersplugins.com/' . $this->core()->get_plugin_slug() . '/manual/#special_modes' ) .'">' . esc_html__( 'Read more', '404page' ) . '</a>)';
|
300 |
|
301 |
} elseif ( defined( 'ICL_SITEPRESS_VERSION' ) ) {
|
302 |
|
303 |
esc_html_e( 'This setting is not availbe because the 404page Plugin works in WPML Mode.', '404page' );
|
304 |
+
echo ' (<a href="' . esc_url( 'https://petersplugins.com/' . $this->core()->get_plugin_slug() . '/manual/#special_modes' ) . '">' . esc_html__( 'Read more', '404page' ) . '</a>)';
|
305 |
|
306 |
} else {
|
307 |
|
309 |
|
310 |
}
|
311 |
|
312 |
+
echo '</span></p>';
|
313 |
|
314 |
}
|
315 |
|
318 |
* create the menu entry
|
319 |
* moved to PP_404Page_Admin in v 10
|
320 |
*/
|
321 |
+
function action_admin_menu() {
|
322 |
+
$screen_id = add_theme_page ( esc_html__( '404 Error Page', "404page" ), esc_html__( '404 Error Page', '404page' ), 'manage_options', '404pagesettings', array( $this, 'show_admin' ) );
|
323 |
+
$this->set_screen_id( $screen_id );
|
324 |
}
|
325 |
|
326 |
|
328 |
* add admin css to header
|
329 |
* moved to PP_404Page_Admin in v 10
|
330 |
*/
|
331 |
+
function action_admin_head() {
|
332 |
|
333 |
+
if ( $this->settings()->get( 'page_id' ) > 0 ) {
|
334 |
|
335 |
echo '<style type="text/css">';
|
336 |
|
337 |
+
foreach ( $this->core()->get_all_page_ids() as $pid ) {
|
338 |
|
339 |
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; }';
|
340 |
|
347 |
}
|
348 |
|
349 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
350 |
/**
|
351 |
* add admin css file
|
352 |
* moved to PP_404Page_Admin in v 10
|
353 |
*/
|
354 |
function admin_css() {
|
355 |
|
356 |
+
if ( get_current_screen()->id == $this->get_screen_id() ) {
|
357 |
|
358 |
+
wp_enqueue_style( '404pagelity', $this->core()->get_asset_url( 'css', 'lity.min.css' ) );
|
359 |
+
wp_enqueue_style( '404pagecss', $this->core()->get_asset_url( 'css', '404page-ui.css' ) );
|
|
|
360 |
|
361 |
}
|
362 |
|
368 |
* moved to PP_404Page_Admin in v 10
|
369 |
*/
|
370 |
function admin_js() {
|
|
|
|
|
|
|
|
|
|
|
371 |
|
372 |
+
if ( get_current_screen()->id == $this->get_screen_id() ) {
|
373 |
|
374 |
+
wp_enqueue_script( '404page-ui', $this->core()->get_asset_url( 'js', '404page-ui.js' ), 'jquery', $this->core()->get_plugin_version(), true );
|
375 |
+
wp_enqueue_script( '404page-lity', $this->core()->get_asset_url( 'js', 'lity.min.js' ), 'jquery', $this->core()->get_plugin_version(), true );
|
376 |
|
377 |
}
|
378 |
|
385 |
*/
|
386 |
function show_admin() {
|
387 |
|
388 |
+
$this->add_toolbar_icons( array(
|
389 |
+
array(
|
390 |
+
'link' => 'https://wordpress.org/support/plugin/' . $this->core()->get_plugin_slug() . '/reviews/',
|
391 |
+
'title' => __( 'Please rate Plugin', '404page' ),
|
392 |
+
'icon' => 'dashicons-star-filled',
|
393 |
+
'highlight' => true
|
394 |
+
),
|
395 |
+
array(
|
396 |
+
'link' => 'https://wordpress.org/plugins/' . $this->core()->get_plugin_slug(),
|
397 |
+
'title' => __( 'WordPress.org Plugin Page', '404page' ),
|
398 |
+
'icon' => 'dashicons-wordpress'
|
399 |
+
),
|
400 |
+
array(
|
401 |
+
'link' => 'https://petersplugins.com/' . $this->core()->get_plugin_slug() . '/manual/',
|
402 |
+
'title' => __( 'Plugin Doc', '404page' ),
|
403 |
+
'icon' => 'dashicons-book-alt'
|
404 |
+
),
|
405 |
+
array(
|
406 |
+
'link' => 'https://wordpress.org/support/plugin/' . $this->core()->get_plugin_slug(),
|
407 |
+
'title' => __( 'Support', '404page' ),
|
408 |
+
'icon' => 'dashicons-editor-help'
|
409 |
+
),
|
410 |
+
array(
|
411 |
+
'link' => 'https://petersplugins.com/',
|
412 |
+
'title' => __( 'Authors Website', '404page' ),
|
413 |
+
'icon' => 'dashicons-admin-home'
|
414 |
+
),
|
415 |
+
array(
|
416 |
+
'link' => 'https://www.facebook.com/petersplugins/',
|
417 |
+
'title' => __( 'Authors Facebook Page', '404page' ),
|
418 |
+
'icon' => 'dashicons-facebook-alt'
|
419 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
420 |
|
421 |
+
) );
|
|
|
|
|
|
|
|
|
|
|
|
|
422 |
|
423 |
+
$this->show( 'manage_options' );
|
424 |
|
425 |
}
|
426 |
|
431 |
*/
|
432 |
function add_settings_links( $links ) {
|
433 |
|
434 |
+
return array_merge( $links, array( '<a href="' . admin_url( 'themes.php?page=404pagesettings' ) . '" title="' . esc_html__( 'Settings', '404page' ) . '">' . esc_html__( 'Settings', '404page' ) . '</a>', '<a href="' . esc_url( 'https://wordpress.org/support/plugin/' . $this->core()->get_plugin_slug() . '/reviews/' ) . '" title="' . esc_html__( 'Please rate plugin', '404page' ) . '">' . esc_html__( 'Please rate plugin', '404page' ) . '</a>' ) );
|
435 |
|
436 |
}
|
437 |
|
438 |
|
439 |
/**
|
440 |
+
* create the HTML code for the videos
|
441 |
+
* was show_videos() in previous versions and printed out the HTML
|
442 |
*
|
443 |
+
* @since 11.0.0
|
444 |
* @access private
|
445 |
+
* @return string HTML code
|
|
|
446 |
*/
|
447 |
+
private function add_videos() {
|
448 |
+
|
449 |
+
$html = '<div class="pp-404page-videos">';
|
450 |
|
451 |
$videos = array(
|
452 |
array( 'id' => 'HygoFMwdIuY', 'title' => 'A brief introduction', 'img' => '404page-brief-intro' ),
|
459 |
|
460 |
foreach( $videos as $video ) {
|
461 |
|
462 |
+
$html .= '<a href="' . esc_url( 'https://youtu.be/' . $video['id'] ) . '" title="' . $video['title'] . '" data-lity><div><img src="' . $this->core()->get_asset_url( 'img/videos', $video['img'] . '.png' ) . '" title="' . $video['title'] . '" alt="' . $video['title'] . '"></div></a>';
|
463 |
|
464 |
}
|
465 |
+
|
466 |
+
return $html . '</div>';
|
467 |
|
468 |
}
|
469 |
|
inc/class-404page-block-editor.php
CHANGED
@@ -15,40 +15,15 @@ if ( ! defined( 'WPINC' ) ) {
|
|
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
|
50 |
*/
|
51 |
-
|
52 |
|
53 |
add_action( 'admin_head', array( $this, 'admin_style' ) );
|
54 |
|
@@ -85,14 +60,14 @@ if ( !class_exists( 'PP_404Page_BlockEditor' ) ) {
|
|
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->
|
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->
|
96 |
|
97 |
// Is the currently edited page a custom 404 error page?
|
98 |
if ( in_array( $post->ID, $all404pages ) ) {
|
15 |
*/
|
16 |
if ( !class_exists( 'PP_404Page_BlockEditor' ) ) {
|
17 |
|
18 |
+
class PP_404Page_BlockEditor extends PPF01_SubClass {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
/**
|
21 |
* Do Init
|
22 |
*
|
23 |
* @since 9
|
24 |
+
* @access public
|
25 |
*/
|
26 |
+
public function init() {
|
27 |
|
28 |
add_action( 'admin_head', array( $this, 'admin_style' ) );
|
29 |
|
60 |
private function is_gutenberg_editing() {
|
61 |
|
62 |
// Is the current screen the page edit screen and is a custom 404 error page defined?
|
63 |
+
if ( get_current_screen()->id == 'page' && $this->settings()->get( 'page_id' ) > 0 ) {
|
64 |
|
65 |
// Is the block editor active for pages and is the classic editor not loaded?
|
66 |
if ( function_exists( 'use_block_editor_for_post_type' ) && use_block_editor_for_post_type( 'page' ) && ! isset( $_GET['classic-editor'] ) ) {
|
67 |
|
68 |
global $post;
|
69 |
|
70 |
+
$all404pages = $this->core()->get_all_page_ids();
|
71 |
|
72 |
// Is the currently edited page a custom 404 error page?
|
73 |
if ( in_array( $post->ID, $all404pages ) ) {
|
inc/class-404page-classic-editor.php
CHANGED
@@ -15,40 +15,15 @@ if ( ! defined( 'WPINC' ) ) {
|
|
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
|
50 |
*/
|
51 |
-
|
52 |
|
53 |
add_action( 'admin_head', array( $this, 'admin_style' ) );
|
54 |
|
@@ -64,11 +39,11 @@ if ( !class_exists( 'PP_404Page_ClassicEditor' ) ) {
|
|
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->
|
68 |
|
69 |
global $post;
|
70 |
|
71 |
-
$all404pages = $this->
|
72 |
if ( in_array( $post->ID, $all404pages ) ) {
|
73 |
|
74 |
?>
|
15 |
*/
|
16 |
if ( !class_exists( 'PP_404Page_ClassicEditor' ) ) {
|
17 |
|
18 |
+
class PP_404Page_ClassicEditor extends PPF01_SubClass {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
/**
|
21 |
* Do Init
|
22 |
*
|
23 |
* @since 9
|
24 |
+
* @access public
|
25 |
*/
|
26 |
+
public function init() {
|
27 |
|
28 |
add_action( 'admin_head', array( $this, 'admin_style' ) );
|
29 |
|
39 |
public function admin_style() {
|
40 |
|
41 |
// we just ignore whether Gutenberg is used or not, because this classes do not exist if Gutenberg is active
|
42 |
+
if ( get_current_screen()->id == 'page' && $this->settings()->get( 'page_id' ) > 0 ) {
|
43 |
|
44 |
global $post;
|
45 |
|
46 |
+
$all404pages = $this->core()->get_all_page_ids();
|
47 |
if ( in_array( $post->ID, $all404pages ) ) {
|
48 |
|
49 |
?>
|
inc/class-404page-deprecated.php
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* The 404page deprecated class
|
5 |
+
*
|
6 |
+
* to ensure backward compatibility
|
7 |
+
*
|
8 |
+
* @since 11.0.0
|
9 |
+
*/
|
10 |
+
|
11 |
+
if ( ! defined( 'WPINC' ) ) {
|
12 |
+
die;
|
13 |
+
}
|
14 |
+
|
15 |
+
/**
|
16 |
+
* The deprecated plugin class
|
17 |
+
*/
|
18 |
+
if ( !class_exists( 'PP_404Page_Deprecated' ) ) {
|
19 |
+
|
20 |
+
class PP_404Page_Deprecated extends PPF01_SubClass {
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Do Init
|
24 |
+
*
|
25 |
+
* @since 11.0.0
|
26 |
+
* @access public
|
27 |
+
*/
|
28 |
+
public function init() {
|
29 |
+
|
30 |
+
|
31 |
+
// since 11.0.0 all settings are stored in a single serialized value
|
32 |
+
// collet all the individual settings from older versions and create the serialized value
|
33 |
+
// plus the user meta data are deleted
|
34 |
+
|
35 |
+
$newkey = str_replace( '-', '_', $this->core()->get_plugin_slug() ) . '_settings';
|
36 |
+
|
37 |
+
if ( false === get_option( $newkey ) ) {
|
38 |
+
|
39 |
+
if ( false !== get_option( '404page_page_id' ) ) {
|
40 |
+
|
41 |
+
$oldkeys = array(
|
42 |
+
'404page_page_id',
|
43 |
+
'404page_hide',
|
44 |
+
'404page_fire_error',
|
45 |
+
'404page_force_error',
|
46 |
+
'404page_no_url_guessing',
|
47 |
+
'404page_http410_if_trashed',
|
48 |
+
'404page_method'
|
49 |
+
);
|
50 |
+
|
51 |
+
$newvals = array();
|
52 |
+
|
53 |
+
foreach ( $oldkeys as $key ) {
|
54 |
+
|
55 |
+
$newvals[ str_replace( '404page_', '', $key ) ] = get_option( $key );
|
56 |
+
delete_option( $key );
|
57 |
+
|
58 |
+
}
|
59 |
+
|
60 |
+
update_option( $newkey, $newvals );
|
61 |
+
|
62 |
+
|
63 |
+
// delete user meta for old admin notices for all users
|
64 |
+
foreach ( array( 'pp-404page-admin-notice-1', 'pp-404page-admin-notice-2', 'pp-404page-update-notice-v8', 'pp-404page-update-notice-v9' ) as $key ) {
|
65 |
+
delete_metadata( 'user', false, $key, false, true );
|
66 |
+
}
|
67 |
+
|
68 |
+
}
|
69 |
+
|
70 |
+
}
|
71 |
+
|
72 |
+
}
|
73 |
+
|
74 |
+
}
|
75 |
+
|
76 |
+
}
|
77 |
+
|
78 |
+
?>
|
inc/class-404page-settings.php
CHANGED
@@ -17,150 +17,29 @@ if ( ! defined( 'WPINC' ) ) {
|
|
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 |
-
|
79 |
*
|
80 |
-
* @since
|
81 |
-
* @access
|
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 |
-
|
149 |
|
150 |
-
|
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->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
|
165 |
}
|
166 |
|
@@ -184,113 +63,8 @@ if ( !class_exists( 'PP_404Page_Settings' ) ) {
|
|
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 |
|
17 |
*/
|
18 |
if ( !class_exists( 'PP_404Page_Settings' ) ) {
|
19 |
|
20 |
+
class PP_404Page_Settings extends PPF01_Settings {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
/**
|
23 |
+
* sanitize settings
|
24 |
*
|
25 |
+
* @since 11.0.0
|
26 |
+
* @access private
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
*/
|
28 |
+
private function sanitize_settings() {
|
29 |
|
30 |
+
// Set page ID to -1 if the page does not exist or is not published
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
+
if ( $this->get( 'page_id' ) != 0 ) {
|
33 |
+
|
34 |
+
$page = get_post( $this->get( 'page_id' ) );
|
35 |
+
|
36 |
+
if ( !$page || $page->post_status != 'publish' ) {
|
37 |
+
|
38 |
+
$this->set( 'page_id', -1 );
|
39 |
+
|
40 |
+
}
|
41 |
+
|
42 |
+
}
|
43 |
|
44 |
}
|
45 |
|
63 |
|
64 |
}
|
65 |
|
66 |
+
}
|
67 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
|
69 |
}
|
70 |
|
inc/class-404page.php
CHANGED
@@ -23,60 +23,18 @@ if ( ! defined( 'PP_404' ) ) {
|
|
23 |
if ( !class_exists( 'PP_404Page' ) ) {
|
24 |
|
25 |
|
26 |
-
class PP_404Page {
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Instance
|
30 |
-
*
|
31 |
-
* @since 8
|
32 |
-
* @var singleton
|
33 |
-
* @access protected
|
34 |
-
*/
|
35 |
-
protected static $_instance = null;
|
36 |
-
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Plugin Main File Path and Name
|
40 |
-
*
|
41 |
-
* @since 8
|
42 |
-
* @var string
|
43 |
-
* @access private
|
44 |
-
* was $_file before
|
45 |
-
*/
|
46 |
-
|
47 |
-
|
48 |
-
/**
|
49 |
-
* Plugin Name
|
50 |
-
*
|
51 |
-
* @since 1
|
52 |
-
* @var string
|
53 |
-
* @access private
|
54 |
-
*/
|
55 |
-
private $plugin_name;
|
56 |
|
57 |
|
58 |
/**
|
59 |
-
*
|
60 |
*
|
61 |
-
* @since
|
62 |
-
* @var
|
63 |
* @access private
|
64 |
*/
|
65 |
-
private $
|
66 |
-
|
67 |
|
68 |
-
/**
|
69 |
-
* Plugin Version
|
70 |
-
*
|
71 |
-
* @since 8
|
72 |
-
* @var int
|
73 |
-
* @access private
|
74 |
-
* was $version before
|
75 |
-
*/
|
76 |
-
private $plugin_version;
|
77 |
-
|
78 |
-
|
79 |
-
private $settings;
|
80 |
private $template;
|
81 |
private $postid;
|
82 |
|
@@ -115,144 +73,69 @@ if ( !class_exists( 'PP_404Page' ) ) {
|
|
115 |
|
116 |
|
117 |
/**
|
118 |
-
*
|
119 |
-
*
|
120 |
-
* @since 1
|
121 |
-
* @see getInstance
|
122 |
-
*/
|
123 |
-
protected function __construct( $settings ) {
|
124 |
-
|
125 |
-
$this->plugin_file = $settings['file'];
|
126 |
-
$this->plugin_slug = $settings['slug'];
|
127 |
-
$this->plugin_name = $settings['name'];
|
128 |
-
$this->plugin_version = $settings['version'];
|
129 |
-
|
130 |
-
$this->get_settings();
|
131 |
-
$this->load();
|
132 |
-
}
|
133 |
-
|
134 |
-
|
135 |
-
/**
|
136 |
-
* Prevent Cloning
|
137 |
*
|
138 |
-
* @
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
/**
|
144 |
-
* Get the Instance
|
145 |
-
*
|
146 |
-
* @since 8
|
147 |
-
* @param array $settings {
|
148 |
-
* @type string $file Plugin Main File Path and Name
|
149 |
-
* @type string $slug Plugin Slug
|
150 |
-
* @type string $name Plugin Name
|
151 |
-
* @type int $version Plugin Verion
|
152 |
-
* }
|
153 |
-
* @return singleton
|
154 |
-
*/
|
155 |
-
public static function getInstance( $settings ) {
|
156 |
-
|
157 |
-
if ( null === self::$_instance ) {
|
158 |
-
|
159 |
-
self::$_instance = new self( $settings );
|
160 |
-
|
161 |
-
}
|
162 |
-
|
163 |
-
return self::$_instance;
|
164 |
-
|
165 |
-
}
|
166 |
-
|
167 |
-
|
168 |
-
/**
|
169 |
-
* get plugin file
|
170 |
-
*
|
171 |
-
* @since 8
|
172 |
-
* @access public
|
173 |
-
*/
|
174 |
-
public function get_plugin_file() {
|
175 |
-
|
176 |
-
return $this->plugin_file;
|
177 |
-
|
178 |
-
}
|
179 |
-
|
180 |
-
|
181 |
-
/**
|
182 |
-
* get plugin slug
|
183 |
-
*
|
184 |
-
* @since 8
|
185 |
-
* @access public
|
186 |
-
*/
|
187 |
-
public function get_plugin_slug() {
|
188 |
-
|
189 |
-
return $this->plugin_slug;
|
190 |
-
|
191 |
-
}
|
192 |
-
|
193 |
-
|
194 |
-
/**
|
195 |
-
* get plugin name
|
196 |
-
*
|
197 |
-
* @since 8
|
198 |
-
* @access public
|
199 |
-
*/
|
200 |
-
public function get_plugin_name() {
|
201 |
-
|
202 |
-
return $this->plugin_name;
|
203 |
-
|
204 |
-
}
|
205 |
-
|
206 |
-
|
207 |
-
/**
|
208 |
-
* get plugin version
|
209 |
-
*
|
210 |
-
* @since 8
|
211 |
-
* @access public
|
212 |
*/
|
213 |
-
|
214 |
-
|
215 |
-
return $this->plugin_version;
|
216 |
-
|
217 |
-
}
|
218 |
|
219 |
|
220 |
/**
|
221 |
-
*
|
222 |
-
* except 404page_method
|
223 |
-
* the 404page_method setting is set in function set_mode() because it may be too early here and not everything is loaded properly
|
224 |
*
|
225 |
-
* since
|
226 |
-
|
227 |
-
private function get_settings() {
|
228 |
-
|
229 |
-
$this->settings = new PP_404Page_Settings();
|
230 |
-
|
231 |
-
}
|
232 |
-
|
233 |
-
|
234 |
-
/**
|
235 |
-
* Load
|
236 |
-
* runs the init() function on firing of init action to ensure everything is loaded properly
|
237 |
*/
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
244 |
|
245 |
|
246 |
/**
|
247 |
* do plugin init
|
248 |
* this runs after init action has fired to ensure everything is loaded properly
|
|
|
249 |
*/
|
250 |
-
function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
251 |
|
252 |
// as of v 2.2 always call set_mode
|
253 |
// as of v 2.4 we do not need to add an init action hook
|
254 |
|
255 |
-
if ( !is_admin() && $this->
|
256 |
|
257 |
// as of v 3.0 we once check if there's a 404 page set and not in all functions separately
|
258 |
$this->set_mode();
|
@@ -260,36 +143,37 @@ if ( !class_exists( 'PP_404Page' ) ) {
|
|
260 |
add_filter( 'get_pages', array ( $this, 'remove_404page_from_array' ), 10, 2 );
|
261 |
|
262 |
// Stop URL guessing if activated
|
263 |
-
if ( $this->settings
|
264 |
add_filter( 'redirect_canonical' ,array ( $this, 'no_url_guessing' ) );
|
265 |
}
|
266 |
|
267 |
// Remove 404 error page from YOAST sitemap
|
268 |
// only if "Send an 404 error if the page is accessed directly by its URL" is active
|
269 |
// @since 6
|
270 |
-
if ( $this->settings
|
271 |
|
272 |
add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', function () {
|
273 |
-
return array( $this->
|
274 |
} );
|
275 |
|
276 |
}
|
277 |
|
278 |
}
|
279 |
|
|
|
280 |
if ( class_exists( 'PP_404Page_Admin' ) ) {
|
281 |
|
282 |
// load classes only if in admin
|
283 |
// @since 10
|
284 |
// using class_exists( 'PP_404Page_Admin' ) instead of is_admin() as of v 10.3 for compatibilty with iThemes Sync
|
285 |
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
|
290 |
// Remove 404 page from post list if activated
|
291 |
// not moved to PP_404Page_Admin because we also need exclude_404page() in frontend
|
292 |
-
if ( $this->settings
|
293 |
add_action( 'pre_get_posts' ,array ( $this, 'exclude_404page' ) );
|
294 |
}
|
295 |
|
@@ -298,22 +182,12 @@ if ( !class_exists( 'PP_404Page' ) ) {
|
|
298 |
}
|
299 |
|
300 |
|
301 |
-
/**
|
302 |
-
* add text domain
|
303 |
-
*/
|
304 |
-
function add_text_domain() {
|
305 |
-
|
306 |
-
load_plugin_textdomain( '404page' );
|
307 |
-
|
308 |
-
}
|
309 |
-
|
310 |
-
|
311 |
/**
|
312 |
* init filters
|
313 |
*/
|
314 |
function set_mode() {
|
315 |
|
316 |
-
$this->settings
|
317 |
|
318 |
if ( defined( 'CUSTOMIZR_VER' ) ) {
|
319 |
|
@@ -328,13 +202,13 @@ if ( !class_exists( 'PP_404Page' ) ) {
|
|
328 |
|
329 |
// send http 410 instead of http 404 if requested resource is in trash
|
330 |
// @since 3.2
|
331 |
-
if ( $this->settings
|
332 |
|
333 |
add_action( 'template_redirect', array( $this, 'maybe_send_410' ) );
|
334 |
|
335 |
}
|
336 |
|
337 |
-
} elseif ( $this->settings
|
338 |
|
339 |
// Compatibility Mode
|
340 |
// 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
|
@@ -348,7 +222,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
|
|
348 |
// Standard Mode
|
349 |
add_filter( '404_template', array( $this, 'show404_standard_mode' ), 999 );
|
350 |
|
351 |
-
if ( $this->settings
|
352 |
|
353 |
add_action( 'template_redirect', array( $this, 'do_404_header_standard_mode' ) );
|
354 |
|
@@ -356,7 +230,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
|
|
356 |
|
357 |
// send http 410 instead of http 404 if requested resource is in trash
|
358 |
// @since 3.2
|
359 |
-
if ( $this->settings
|
360 |
|
361 |
add_action( 'template_redirect', array( $this, 'maybe_send_410' ) );
|
362 |
|
@@ -393,7 +267,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
|
|
393 |
}
|
394 |
// that's it
|
395 |
|
396 |
-
if ( ! $this->
|
397 |
|
398 |
$wp_query = null;
|
399 |
$wp_query = new WP_Query();
|
@@ -438,7 +312,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
|
|
438 |
// that's it
|
439 |
|
440 |
$pageid = $this->get_page_id();
|
441 |
-
if ( ! $this->
|
442 |
|
443 |
// as of v 10 we also check if $wp_query->query[error] == 404
|
444 |
// this is necessary to bypass a WordPress bug
|
@@ -478,7 +352,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
|
|
478 |
} elseif ( 1 == count( $posts ) && 'page' == $posts[0]->post_type ) {
|
479 |
|
480 |
// Do a 404 if the 404 page is opened directly
|
481 |
-
if ( $this->settings
|
482 |
$curpageid = $posts[0]->ID;
|
483 |
|
484 |
if ( defined( 'ICL_SITEPRESS_VERSION' ) ) {
|
@@ -542,7 +416,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
|
|
542 |
* Standard Mode
|
543 |
*/
|
544 |
function do_404_header_standard_mode() {
|
545 |
-
if ( is_page() && get_the_ID() == $this->
|
546 |
status_header( 404 );
|
547 |
nocache_headers();
|
548 |
$this->maybe_force_404();
|
@@ -562,7 +436,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
|
|
562 |
// send http 410 instead of http 404 if requested resource is in trash
|
563 |
// @since 3.2
|
564 |
|
565 |
-
if ( $this->settings
|
566 |
|
567 |
status_header( 410 );
|
568 |
|
@@ -590,13 +464,13 @@ if ( !class_exists( 'PP_404Page' ) ) {
|
|
590 |
// debug class
|
591 |
// @since 3.1
|
592 |
$debug_class = 'pp404-';
|
593 |
-
if ( $this->
|
594 |
$debug_class .= 'native';
|
595 |
} elseif ( defined( 'CUSTOMIZR_VER' ) ) {
|
596 |
$debug_class .= 'customizr';
|
597 |
} elseif ( defined( 'ICL_SITEPRESS_VERSION' ) ) {
|
598 |
$debug_class .= 'wpml';
|
599 |
-
} elseif ( $this->settings
|
600 |
$debug_class .= 'cmp';
|
601 |
} else {
|
602 |
$debug_class .= 'std';
|
@@ -628,7 +502,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
|
|
628 |
* Customizr Compatibility Mode
|
629 |
*/
|
630 |
function show404title_customizr_mode( $title ) {
|
631 |
-
if ( ! $this->
|
632 |
return '<h1 class="entry-title">' . get_the_title( $this->get_page_id() ) . '</h1>';
|
633 |
} else {
|
634 |
return $title;
|
@@ -641,7 +515,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
|
|
641 |
* Customizr Compatibility Mode
|
642 |
*/
|
643 |
function show404_customizr_mode( $content ) {
|
644 |
-
if ( ! $this->
|
645 |
return '<div class="entry-content">' . apply_filters( 'the_content', get_post_field( 'post_content', $this->get_page_id() ) ) . '</div>';
|
646 |
} else {
|
647 |
return $content;
|
@@ -655,7 +529,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
|
|
655 |
* Customizr Compatibility Mode
|
656 |
*/
|
657 |
function show404articleselectors_customizr_mode( $selectors ) {
|
658 |
-
if ( ! $this->
|
659 |
return 'id="post-' . $this->get_page_id() . '" class="' . join( ' ', get_post_class( 'row-fluid', $this->get_page_id() ) ) . '"';
|
660 |
} else {
|
661 |
return $selectors;
|
@@ -667,7 +541,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
|
|
667 |
* do we have to force a 404 in wp_head?
|
668 |
*/
|
669 |
function maybe_force_404() {
|
670 |
-
if ( $this->settings
|
671 |
add_action( 'wp_head', array( $this, 'force_404_start' ), 9.9 );
|
672 |
add_action( 'wp_head', array( $this, 'force_404_end' ), 99 );
|
673 |
}
|
@@ -983,19 +857,6 @@ if ( !class_exists( 'PP_404Page' ) ) {
|
|
983 |
return false;
|
984 |
|
985 |
}
|
986 |
-
|
987 |
-
|
988 |
-
/**
|
989 |
-
* get id of the 404 page
|
990 |
-
*
|
991 |
-
* @since 9
|
992 |
-
* @access public
|
993 |
-
*/
|
994 |
-
public function get_id() {
|
995 |
-
|
996 |
-
return $this->settings->get_id();
|
997 |
-
|
998 |
-
}
|
999 |
|
1000 |
|
1001 |
/**
|
@@ -1003,7 +864,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
|
|
1003 |
*/
|
1004 |
private function get_page_id() {
|
1005 |
|
1006 |
-
$pageid = $this->
|
1007 |
|
1008 |
if ( $pageid > 0 ) {
|
1009 |
|
@@ -1042,7 +903,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
|
|
1042 |
|
1043 |
// WPML is active
|
1044 |
// get an array for all translations
|
1045 |
-
$pageid = $this->
|
1046 |
$pages = array( $pageid );
|
1047 |
|
1048 |
if ( $pageid > 0 ) {
|
@@ -1134,11 +995,8 @@ if ( !class_exists( 'PP_404Page' ) ) {
|
|
1134 |
*/
|
1135 |
function uninstall_single() {
|
1136 |
|
1137 |
-
|
1138 |
-
|
1139 |
-
delete_option( $option );
|
1140 |
-
|
1141 |
-
}
|
1142 |
|
1143 |
}
|
1144 |
|
@@ -1150,14 +1008,14 @@ if ( !class_exists( 'PP_404Page' ) ) {
|
|
1150 |
// check if there's a custom 404 page set
|
1151 |
function pp_404_is_active() {
|
1152 |
|
1153 |
-
return ( $this->
|
1154 |
|
1155 |
}
|
1156 |
|
1157 |
// activate the native theme support
|
1158 |
function pp_404_set_native_support() {
|
1159 |
|
1160 |
-
$this->
|
1161 |
|
1162 |
}
|
1163 |
|
@@ -1166,7 +1024,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
|
|
1166 |
|
1167 |
$title = '';
|
1168 |
|
1169 |
-
if ( $this->
|
1170 |
|
1171 |
$title = get_the_title( $this->get_page_id() );
|
1172 |
|
@@ -1188,7 +1046,7 @@ if ( !class_exists( 'PP_404Page' ) ) {
|
|
1188 |
|
1189 |
$content = '';
|
1190 |
|
1191 |
-
if ( $this->
|
1192 |
|
1193 |
$content = apply_filters( 'the_content', get_post_field( 'post_content', $this->get_page_id() ) );
|
1194 |
|
@@ -1207,14 +1065,27 @@ if ( !class_exists( 'PP_404Page' ) ) {
|
|
1207 |
|
1208 |
|
1209 |
/**
|
1210 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1211 |
*
|
1212 |
-
* @since
|
1213 |
* @access public
|
1214 |
*/
|
1215 |
-
public function
|
1216 |
|
1217 |
-
return
|
1218 |
|
1219 |
}
|
1220 |
|
23 |
if ( !class_exists( 'PP_404Page' ) ) {
|
24 |
|
25 |
|
26 |
+
class PP_404Page extends PPF01_Plugin {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
|
29 |
/**
|
30 |
+
* Native Mode
|
31 |
*
|
32 |
+
* @since 11.0.0 - was part of previous settings class
|
33 |
+
* @var bool
|
34 |
* @access private
|
35 |
*/
|
36 |
+
private $native;
|
|
|
37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
private $template;
|
39 |
private $postid;
|
40 |
|
73 |
|
74 |
|
75 |
/**
|
76 |
+
* Deprecated Class
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
*
|
78 |
+
* @see class-404page-deprecated.php
|
79 |
+
* @since 11.0.0
|
80 |
+
* @var object
|
81 |
+
* @access private
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
*/
|
83 |
+
private $deprecated;
|
|
|
|
|
|
|
|
|
84 |
|
85 |
|
86 |
/**
|
87 |
+
* Init the Class
|
|
|
|
|
88 |
*
|
89 |
+
* @since 11.0.0
|
90 |
+
* was part of __construct before
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
*/
|
92 |
+
public function plugin_init() {
|
93 |
+
|
94 |
+
// settings defaults
|
95 |
+
// @since 11.0.0
|
96 |
+
$defaults = array(
|
97 |
+
'page_id' => 0,
|
98 |
+
'hide' => false,
|
99 |
+
'fire_error' => true,
|
100 |
+
'force_error' => false,
|
101 |
+
'no_url_guessing' => false,
|
102 |
+
'http410_if_trashed' => false,
|
103 |
+
'method' => 'STD'
|
104 |
+
);
|
105 |
+
|
106 |
+
// since 11.0.0 we use add_settings_class() to load the settings
|
107 |
+
$this->add_settings_class( 'PP_404Page_Settings', 'class-404page-settings', $this, $defaults );
|
108 |
+
|
109 |
+
// @since 11.0.0
|
110 |
+
$this->add_action( 'init' );
|
111 |
+
}
|
112 |
|
113 |
|
114 |
/**
|
115 |
* do plugin init
|
116 |
* this runs after init action has fired to ensure everything is loaded properly
|
117 |
+
* was init() before 11.0.0
|
118 |
*/
|
119 |
+
function action_init() {
|
120 |
+
|
121 |
+
// moved from add_text_domain() in v 11.0.0
|
122 |
+
|