Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/wp-rocket/inc/deprecated/3.15.php
Keine Baseline-Datei – Diff nur gegen leer.
1
-
1
+
<?php
2
+
3
+
/**
4
+
* Add "Cache options" metabox
5
+
*
6
+
* @since 3.15 deprecated
7
+
* @since 2.5
8
+
*/
9
+
function rocket_cache_options_meta_boxes() {
10
+
11
+
if ( ! rocket_can_display_options() ) {
12
+
return;
13
+
}
14
+
15
+
if ( current_user_can( 'rocket_manage_options' ) ) {
16
+
$cpts = get_post_types(
17
+
[
18
+
'public' => true,
19
+
],
20
+
'objects'
21
+
);
22
+
unset( $cpts['attachment'] );
23
+
24
+
$cpts = apply_filters( 'rocket_metabox_options_post_types', $cpts );
25
+
26
+
foreach ( $cpts as $cpt => $cpt_object ) {
27
+
$label = $cpt_object->labels->singular_name;
28
+
add_meta_box( 'rocket_post_exclude', sprintf( __( 'WP Rocket Options', 'rocket' ), $label ), 'rocket_display_cache_options_meta_boxes', $cpt, 'side', 'core' );
29
+
}
30
+
}
31
+
}
32
+
33
+
/**
34
+
* Displays some checkbox to de/activate some cache options
35
+
*
36
+
* @since 3.15 deprecated
37
+
* @since 2.5
38
+
*/
39
+
function rocket_display_cache_options_meta_boxes() {
40
+
if ( current_user_can( 'rocket_manage_options' ) ) {
41
+
global $post, $pagenow;
42
+
wp_nonce_field( 'rocket_box_option', '_rocketnonce', false, true );
43
+
?>
44
+
45
+
<div class="misc-pub-section">
46
+
<?php
47
+
$reject_current_uri = false;
48
+
if ( 'post-new.php' !== $pagenow ) {
49
+
$rejected_uris = array_flip( get_rocket_option( 'cache_reject_uri', [] ) );
50
+
$path = rocket_clean_exclude_file( get_permalink( $post->ID ) );
51
+
52
+
if ( isset( $rejected_uris[ $path ] ) ) {
53
+
$reject_current_uri = true;
54
+
}
55
+
}
56
+
?>
57
+
<input name="rocket_post_nocache" id="rocket_post_nocache" type="checkbox" title="<?php esc_html_e( 'Never cache this page', 'rocket' ); ?>" <?php checked( $reject_current_uri, true ); ?>><label for="rocket_post_nocache"><?php esc_html_e( 'Never cache this page', 'rocket' ); ?></label>
58
+
</div>
59
+
60
+
<div class="misc-pub-section">
61
+
<p><?php esc_html_e( 'Activate these options on this post:', 'rocket' ); ?></p>
62
+
<?php
63
+
$fields = [];
64
+
65
+
$old_fields = $fields;
66
+
67
+
/**
68
+
* WP Rocket Metabox fields on post edit page.
69
+
*
70
+
* @param string[] $fields Metaboxes fields.
71
+
*/
72
+
$fields = apply_filters( 'rocket_meta_boxes_fields', $fields );
73
+
74
+
if ( ! is_array( $fields ) ) {
75
+
$fields = $old_fields;
76
+
}
77
+
78
+
foreach ( $fields as $field => $label ) {
79
+
$disabled = disabled( ! get_rocket_option( $field ), true, false );
80
+
// translators: %s is the name of the option.
81
+
$title = $disabled ? ' title="' . esc_attr( sprintf( __( 'Activate first the %s option.', 'rocket' ), $label ) ) . '"' : '';
82
+
$class = $disabled ? ' class="rkt-disabled"' : '';
83
+
$checked = ! $disabled ? checked( ! get_post_meta( $post->ID, '_rocket_exclude_' . $field, true ), true, false ) : '';
84
+
?>
85
+
86
+
<input name="rocket_post_exclude_hidden[<?php echo esc_attr( $field ); ?>]" type="hidden" value="on">
87
+
<input name="rocket_post_exclude[<?php echo esc_attr( $field ); ?>]" id="rocket_post_exclude_<?php echo esc_attr( $field ); ?>" type="checkbox"<?php echo $title; ?><?php echo $checked; ?><?php echo $disabled; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Dynamic content is properly escaped in the view. ?>>
88
+
<label for="rocket_post_exclude_<?php echo esc_attr( $field ); ?>"<?php echo $title; ?><?php echo $class; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Dynamic content is properly escaped in the view. ?>><?php echo esc_html( $label ); ?></label><br>
89
+
90
+
<?php
91
+
}
92
+
?>
93
+
94
+
<p class="rkt-note">
95
+
<?php
96
+
// translators: %1$s = opening strong tag, %2$s = closing strong tag.
97
+
printf( esc_html__( '%1$sNote:%2$s None of these options will be applied if this post has been excluded from cache in the global cache settings.', 'rocket' ), '<strong>', '</strong>' );
98
+
?>
99
+
</p>
100
+
</div>
101
+
102
+
<?php
103
+
/**
104
+
* Fires after WP Rocket’s metabox.
105
+
*
106
+
* @since 3.6
107
+
*/
108
+
do_action( 'rocket_after_options_metabox' );
109
+
}
110
+
}
111
+
112
+
/**
113
+
* Manage the cache options from the metabox.
114
+
*
115
+
* @since 3.15 deprecated
116
+
* @since 2.5
117
+
*/
118
+
function rocket_save_metabox_options() {
119
+
if ( current_user_can( 'rocket_manage_options' ) &&
120
+
isset( $_POST['post_ID'], $_POST['rocket_post_exclude_hidden'], $_POST['_rocketnonce'] ) ) {
121
+
122
+
check_admin_referer( 'rocket_box_option', '_rocketnonce' );
123
+
124
+
// No cache field.
125
+
if ( isset( $_POST['post_status'] ) && 'publish' === $_POST['post_status'] ) {
126
+
$new_cache_reject_uri = $cache_reject_uri = get_rocket_option( 'cache_reject_uri', [] ); // phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.Found
127
+
$rejected_uris = array_flip( $cache_reject_uri );
128
+
$path = rocket_clean_exclude_file( get_permalink( (int) $_POST['post_ID'] ) );
129
+
130
+
if ( isset( $_POST['rocket_post_nocache'] ) ) {
131
+
if ( ! isset( $rejected_uris[ $path ] ) ) {
132
+
array_push( $new_cache_reject_uri, $path );
133
+
}
134
+
} else {
135
+
if ( isset( $rejected_uris[ $path ] ) ) {
136
+
unset( $new_cache_reject_uri[ $rejected_uris[ $path ] ] );
137
+
}
138
+
}
139
+
140
+
if ( $new_cache_reject_uri !== $cache_reject_uri ) {
141
+
// Update the "Never cache the following pages" option.
142
+
update_rocket_option( 'cache_reject_uri', $new_cache_reject_uri );
143
+
144
+
// Update config file.
145
+
rocket_generate_config_file();
146
+
}
147
+
}
148
+
149
+
// Options fields.
150
+
$fields = [];
151
+
152
+
$old_fields = $fields;
153
+
154
+
/**
155
+
* Metaboxes fields.
156
+
*
157
+
* @param string[] $fields Metaboxes fields.
158
+
*/
159
+
$fields = apply_filters( 'rocket_meta_boxes_fields', $fields );
160
+
161
+
if ( ! is_array( $old_fields ) ) {
162
+
$fields = $old_fields;
163
+
}
164
+
165
+
$fields = array_keys( $fields );
166
+
167
+
foreach ( $fields as $field ) {
168
+
if ( isset( $_POST['rocket_post_exclude_hidden'][ $field ] ) ) {
169
+
if ( isset( $_POST['rocket_post_exclude'][ $field ] ) ) {
170
+
delete_post_meta( (int) $_POST['post_ID'], '_rocket_exclude_' . $field );
171
+
} else {
172
+
if ( get_rocket_option( $field ) ) {
173
+
update_post_meta( (int) $_POST['post_ID'], '_rocket_exclude_' . $field, true );
174
+
}
175
+
}
176
+
}
177
+
}
178
+
}
179
+
}
180
+