3.7.php
8.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
<?php
defined( 'ABSPATH' ) || exit;
/**
* Require deprecated classes.
*/
if ( ! class_exists( 'Minify_HTML' ) ) {
require_once __DIR__ . '/vendors/classes/class-minify-html.php';
}
if ( ! class_exists( 'WP_Rocket\Subscriber\Optimization\Minify_HTML_Subscriber' ) ) {
require_once __DIR__ . '/subscriber/admin/Optimization/class-minify-html-subscriber.php';
}
class_alias( '\WP_Rocket\Engine\Heartbeat\HeartbeatSubscriber', '\WP_Rocket\Subscriber\Heartbeat_Subscriber' );
/**
* Conflict with WP Serveur hosting: don't apply inline JS on all pages.
*
* @since 3.7 deprecated
* @since 2.6.11
*
* @param array $html_options WP Rocket options array.
*
* @return array Updated WP Rocket options array.
*/
function rocket_deactivate_inline_js_on_wp_serveur( $html_options ) {
_deprecated_function( __FUNCTION__ . '()', '3.7' );
if ( isset( $html_options['jsMinifier'] ) ) {
unset( $html_options['jsMinifier'] );
}
return $html_options;
}
/**
* Conflict with AppBanners: don't minify inline script when HTML minification is activated
*
* @since 3.7 deprecated
* @since 2.2.4
*
* @param array $html_options An array of WP Rocket options.
*
* @return array Array without the inline js minify option
*/
function rocket_deactivate_js_minifier_with_appbanner( $html_options ) {
_deprecated_function( __FUNCTION__ . '()', '3.7' );
if ( isset( $html_options['jsMinifier'] ) && class_exists( 'AppBanners' ) ) {
unset( $html_options['jsMinifier'] );
}
return $html_options;
}
/**
* Deactivate WP Rocket HTML Minification if Autoptimize HTML minification is enabled
*
* @since 3.7 deprecated
* @since 2.9.5
*
* @param string $old_value Previous autoptimize option value.
* @param string $value New autoptimize option value.
*
* @author Remy Perona
*
*/
function rocket_maybe_deactivate_minify_html( $old_value, $value ) {
_deprecated_function( __FUNCTION__ . '()', '3.7' );
if ( $value !== $old_value && 'on' === $value ) {
update_rocket_option( 'minify_html', 0 );
}
}
/**
* Disable WP Rocket HTML minification field if Autoptimize HTML minification is enabled
*
* @since 3.7 deprecated
* @since 2.9.5
* @return bool|null True if it is active
* @author Remy Perona
*
*/
function rocket_maybe_disable_minify_html() {
_deprecated_function( __FUNCTION__ . '()', '3.7' );
if ( is_plugin_active( 'autoptimize/autoptimize.php' ) && 'on' === get_option( 'autoptimize_html' ) ) {
return true;
}
}
/**
* Conflict with Revolution Slider: don't minify inline script when HTML minification is activated
*
* @since 3.7 deprecated
* @since 2.6.8
*
* @param array $html_options WP Rocket options array.
*
* @return array Updated WP Rocket options
*/
function rocket_deactivate_js_minifier_with_revslider( $html_options ) {
_deprecated_function( __FUNCTION__ . '()', '3.7' );
if ( isset( $html_options['jsMinifier'] ) && class_exists( 'RevSliderFront' ) ) {
unset( $html_options['jsMinifier'] );
}
return $html_options;
}
/**
* Disable the emoji functionality to reduce then number of external HTTP requests.
*
* @since 3.7 Deprecated.
* @since 2.7
*
* @deprecated
*/
function rocket_disable_emoji() {
_deprecated_function( __FUNCTION__ . '()', '3.7' );
if ( rocket_bypass() ) {
return;
}
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
add_filter( 'emoji_svg_url', '__return_false' );
}
/**
* Remove the tinymce emoji plugin.
*
* @since 3.7 Deprecated.
* @since 2.7
*
* @param array $plugins Plugins loaded for TinyMCE.
*
* @return array
*
* @deprecated
*/
function rocket_disable_emoji_tinymce( $plugins ) {
_deprecated_function( __FUNCTION__ . '()', '3.7' );
if ( is_array( $plugins ) ) {
return array_diff( $plugins, [ 'wpemoji' ] );
}
return [];
}
/**
* Disable embeds on init.
*
* - Removes the needed query vars.
* - Disables oEmbed discovery.
* - Completely removes the related JavaScript.
*
* @since 3.7 Deprecated.
* @since 2.10
*
* @deprecated
*/
function rocket_disable_embeds_init() {
_deprecated_function( __FUNCTION__ . '()', '3.7' );
if ( rocket_bypass() ) {
return;
}
global $wp;
// Remove the embed query var.
$wp->public_query_vars = array_diff(
$wp->public_query_vars,
[
'embed',
]
);
// Remove the oembed/1.0/embed REST route.
add_filter( 'rest_endpoints', 'rocket_disable_embeds_remove_embed_endpoint' );
// Disable handling of internal embeds in oembed/1.0/proxy REST route.
add_filter( 'oembed_response_data', 'rocket_disable_embeds_filter_oembed_response_data' );
// Turn off oEmbed auto discovery.
add_filter( 'embed_oembed_discover', '__return_false' );
// Don't filter oEmbed results.
remove_filter( 'oembed_dataparse', 'wp_filter_oembed_result', 10 );
// Remove oEmbed discovery links.
remove_action( 'wp_head', 'wp_oembed_add_discovery_links' );
// Remove oEmbed-specific JavaScript from the front-end and back-end.
remove_action( 'wp_head', 'wp_oembed_add_host_js' );
add_filter( 'tiny_mce_plugins', 'rocket_disable_embeds_tiny_mce_plugin' );
// Remove all embeds rewrite rules.
add_filter( 'rewrite_rules_array', 'rocket_disable_embeds_rewrites' );
// Remove filter of the oEmbed result before any HTTP requests are made.
remove_filter( 'pre_oembed_result', 'wp_filter_pre_oembed_result', 10 );
// Load block editor JavaScript.
add_action( 'enqueue_block_editor_assets', 'rocket_disable_embeds_enqueue_block_editor_assets' );
// Remove wp-embed dependency of wp-edit-post script handle.
add_action( 'wp_default_scripts', 'rocket_disable_embeds_remove_script_dependencies' );
}
/**
* Removes the 'wpembed' TinyMCE plugin.
*
* @since 3.7 Deprecated.
* @since 2.10
*
* @param array $plugins List of TinyMCE plugins.
*
* @return array The modified list.
*
* @deprecated
*/
function rocket_disable_embeds_tiny_mce_plugin( $plugins ) {
_deprecated_function( __FUNCTION__ . '()', '3.7' );
return array_diff( $plugins, [ 'wpembed' ] );
}
/**
* Remove all rewrite rules related to embeds.
*
* @since 3.7 Deprecated.
* @since 2.10
*
* @param array $rules WordPress rewrite rules.
*
* @return array Rewrite rules without embeds rules.
*
* @deprecated
*/
function rocket_disable_embeds_rewrites( $rules ) {
_deprecated_function( __FUNCTION__ . '()', '3.7' );
if ( empty( $rules ) ) {
return $rules;
}
foreach ( $rules as $rule => $rewrite ) {
if ( false !== strpos( $rewrite, 'embed=true' ) ) {
unset( $rules[ $rule ] );
}
}
return $rules;
}
/**
* Removes the oembed/1.0/embed REST route.
*
* @since 3.6 Deprecated.
* @since 3.3.3
*
* @param array $endpoints Registered REST API endpoints.
*
* @return array Filtered REST API endpoints.
*
* @deprecated
*/
function rocket_disable_embeds_remove_embed_endpoint( $endpoints ) {
_deprecated_function( __FUNCTION__ . '()', '3.7' );
unset( $endpoints['/oembed/1.0/embed'] );
return $endpoints;
}
/**
* Disables sending internal oEmbed response data in proxy endpoint.
*
* @since 3.7 Deprecated.
* @since 3.3.3
*
* @param array $data The response data.
*
* @return array|false Response data or false if in a REST API context.
*
* @deprecated
*/
function rocket_disable_embeds_filter_oembed_response_data( $data ) {
_deprecated_function( __FUNCTION__ . '()', '3.7' );
if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) {
return false;
}
return $data;
}
/**
* Enqueues JavaScript for the block editor.
*
* This is used to unregister the `core-embed/wordpress` block type.
*
* @since 3.7 Deprecated.
* @since 3.3.3
*
* @deprecated
*/
function rocket_disable_embeds_enqueue_block_editor_assets() {
_deprecated_function( __FUNCTION__ . '()', '3.7' );
wp_enqueue_script(
'rocket-disable-embeds',
WP_ROCKET_ASSETS_JS_URL . 'editor/editor.js',
[
'wp-edit-post',
'wp-editor',
'wp-dom',
],
WP_ROCKET_VERSION,
true
);
}
/**
* Removes wp-embed dependency of core packages.
*
* @since 3.7 deprecated
* @since 3.3.3
*
* @param \WP_Scripts $scripts WP_Scripts instance, passed by reference.
*
* @deprecated
*/
function rocket_disable_embeds_remove_script_dependencies( $scripts ) {
_deprecated_function( __FUNCTION__ . '()', '3.7' );
if ( ! empty( $scripts->registered['wp-edit-post'] ) ) {
$scripts->registered['wp-edit-post']->deps = array_diff(
$scripts->registered['wp-edit-post']->deps,
[ 'wp-embed' ]
);
}
}