Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/wp-rocket/inc/deprecated/3.2.php
Keine Baseline-Datei – Diff nur gegen leer.
1
-
1
+
<?php
2
+
3
+
defined( 'ABSPATH' ) || exit;
4
+
5
+
/**
6
+
* Add a message about Imagify on the "Upload New Media" screen and WP Rocket options page.
7
+
*
8
+
* @since 2.7
9
+
* @deprecated 3.2
10
+
*/
11
+
function rocket_imagify_notice() {
12
+
_deprecated_function( __FUNCTION__, '3.2' );
13
+
$current_screen = get_current_screen();
14
+
15
+
// Add the notice only on the "WP Rocket" settings, "Media Library" & "Upload New Media" screens.
16
+
if ( 'admin_notices' === current_filter() && ( isset( $current_screen ) && 'settings_page_wprocket' !== $current_screen->base ) ) {
17
+
return;
18
+
}
19
+
20
+
$boxes = get_user_meta( $GLOBALS['current_user']->ID, 'rocket_boxes', true );
21
+
22
+
if ( defined( 'IMAGIFY_VERSION' ) || in_array( __FUNCTION__, (array) $boxes, true ) || 1 === get_option( 'wp_rocket_dismiss_imagify_notice' ) || ! current_user_can( 'manage_options' ) ) {
23
+
return;
24
+
}
25
+
26
+
$imagify_plugin = 'imagify/imagify.php';
27
+
$is_imagify_installed = rocket_is_plugin_installed( $imagify_plugin );
28
+
29
+
$action_url = $is_imagify_installed ?
30
+
rocket_get_plugin_activation_link( $imagify_plugin )
31
+
:
32
+
wp_nonce_url( add_query_arg(
33
+
array(
34
+
'action' => 'install-plugin',
35
+
'plugin' => 'imagify',
36
+
),
37
+
admin_url( 'update.php' )
38
+
), 'install-plugin_imagify' );
39
+
40
+
$details_url = add_query_arg(
41
+
array(
42
+
'tab' => 'plugin-information',
43
+
'plugin' => 'imagify',
44
+
'TB_iframe' => true,
45
+
'width' => 722,
46
+
'height' => 949,
47
+
),
48
+
admin_url( 'plugin-install.php' )
49
+
);
50
+
51
+
$classes = $is_imagify_installed ? '' : ' install-now';
52
+
$cta_txt = $is_imagify_installed ? esc_html__( 'Activate Imagify', 'rocket' ) : esc_html__( 'Install Imagify for Free', 'rocket' );
53
+
54
+
$dismiss_url = wp_nonce_url(
55
+
admin_url( 'admin-post.php?action=rocket_ignore&box=' . __FUNCTION__ ),
56
+
'rocket_ignore_' . __FUNCTION__
57
+
);
58
+
?>
59
+
60
+
<div id="plugin-filter" class="updated plugin-card plugin-card-imagify rkt-imagify-notice">
61
+
<a href="<?php echo $dismiss_url; ?>" class="rkt-cross"><span class="dashicons dashicons-no"></span></a>
62
+
63
+
<p class="rkt-imagify-logo">
64
+
<img src="<?php echo WP_ROCKET_ASSETS_IMG_URL; ?>logo-imagify.png" srcset="<?php echo WP_ROCKET_ASSETS_IMG_URL; ?>logo-imagify.svg 2x" alt="Imagify" width="150" height="18">
65
+
</p>
66
+
<p class="rkt-imagify-msg">
67
+
<?php _e( 'Speed up your website and boost your SEO by reducing image file sizes without losing quality with Imagify.', 'rocket' ); ?>
68
+
</p>
69
+
<p class="rkt-imagify-cta">
70
+
<a data-slug="imagify" href="<?php echo $action_url; ?>" class="button button-primary<?php echo $classes; ?>"><?php echo $cta_txt; ?></a>
71
+
<?php if ( ! $is_imagify_installed ) : ?>
72
+
<br><a data-slug="imagify" data-name="Imagify Image Optimizer" class="thickbox open-plugin-details-modal" href="<?php echo $details_url; ?>"><?php _e( 'More details', 'rocket' ); ?></a>
73
+
<?php endif; ?>
74
+
</p>
75
+
</div>
76
+
77
+
<?php
78
+
}
79
+
80
+
if ( ! function_exists( 'run_rocket_preload_cache' ) ) :
81
+
/**
82
+
* Launches the preload
83
+
*
84
+
* @since 2.8
85
+
* @author Remy Perona
86
+
* @deprecated 3.2
87
+
*
88
+
* @param string $spider The spider name.
89
+
* @param bool $do_sitemap_preload Do the sitemap preload.
90
+
*
91
+
* @return void
92
+
*/
93
+
function run_rocket_preload_cache( $spider, $do_sitemap_preload = true ) {
94
+
_deprecated_function( __FUNCTION__, '3.2' );
95
+
96
+
// Preload cache.
97
+
run_rocket_bot( $spider );
98
+
99
+
if ( $do_sitemap_preload & get_rocket_option( 'sitemap_preload', false ) ) {
100
+
$rocket_background_process = $GLOBALS['rocket_sitemap_background_process'];
101
+
102
+
if ( method_exists( $rocket_background_process, 'cancel_process' ) ) {
103
+
$rocket_background_process->cancel_process();
104
+
}
105
+
106
+
delete_transient( 'rocket_sitemap_preload_running' );
107
+
delete_transient( 'rocket_sitemap_preload_complete' );
108
+
run_rocket_sitemap_preload();
109
+
}
110
+
}
111
+
endif;
112
+
113
+
if ( ! function_exists( 'do_rocket_bot_cache_json' ) ) :
114
+
/**
115
+
* Run WP Rocket Bot when a post is added, updated or deleted
116
+
*
117
+
* @since 1.3.2
118
+
* @deprecated 3.2
119
+
*/
120
+
function do_rocket_bot_cache_json() {
121
+
_deprecated_function( __FUNCTION__, '3.2' );
122
+
return false;
123
+
}
124
+
endif;
125
+
126
+
if ( ! function_exists( 'rocket_process_sitemap' ) ) {
127
+
/**
128
+
* Processes the sitemaps recursively
129
+
*
130
+
* @since 2.8
131
+
* @author Remy Perona
132
+
*
133
+
* @param string $sitemap_url URL of the sitemap.
134
+
* @param array $urls An array of URLs.
135
+
* @return array Empty array or array containing URLs
136
+
*/
137
+
function rocket_process_sitemap( $sitemap_url, $urls = array() ) {
138
+
_deprecated_function( __FUNCTION__, '3.2' );
139
+
$tmp_urls = array();
140
+
141
+
/**
142
+
* Filters the arguments for the sitemap preload request
143
+
*
144
+
* @since 2.10.8
145
+
* @author Remy Perona
146
+
*
147
+
* @param array $args Arguments for the request.
148
+
*/
149
+
$args = apply_filters( 'rocket_preload_sitemap_request_args', array(
150
+
'user-agent' => 'WP Rocket/Sitemaps',
151
+
'sslverify' => apply_filters( 'https_local_ssl_verify', true ),
152
+
) );
153
+
154
+
$sitemap = wp_remote_get( esc_url( $sitemap_url ), $args );
155
+
156
+
if ( is_wp_error( $sitemap ) ) {
157
+
return array();
158
+
}
159
+
160
+
$xml_data = wp_remote_retrieve_body( $sitemap );
161
+
162
+
if ( empty( $xml_data ) ) {
163
+
return array();
164
+
}
165
+
166
+
libxml_use_internal_errors( true );
167
+
168
+
$xml = simplexml_load_string( $xml_data );
169
+
170
+
if ( false === $xml ) {
171
+
libxml_clear_errors();
172
+
return array();
173
+
}
174
+
175
+
$url_count = count( $xml->url );
176
+
177
+
if ( $url_count > 0 ) {
178
+
for ( $i = 0; $i < $url_count; $i++ ) {
179
+
$page_url = (string) $xml->url[ $i ]->loc;
180
+
$tmp_urls[] = $page_url;
181
+
}
182
+
} else {
183
+
// Sub sitemap?
184
+
$sitemap_children = count( $xml->sitemap );
185
+
if ( $sitemap_children > 0 ) {
186
+
for ( $i = 0; $i < $sitemap_children; $i++ ) {
187
+
$sub_sitemap_url = (string) $xml->sitemap[ $i ]->loc;
188
+
$urls = rocket_process_sitemap( $sub_sitemap_url, $urls );
189
+
}
190
+
}
191
+
}
192
+
193
+
$urls = array_merge( $urls, $tmp_urls );
194
+
return $urls;
195
+
}
196
+
}
197
+
198
+
if ( ! function_exists( 'rocket_sitemap_preload_complete' ) ) {
199
+
/**
200
+
* This notice is displayed after the sitemap preload is complete
201
+
*
202
+
* @since 2.11
203
+
* @deprecated 3.2
204
+
* @author Remy Perona
205
+
*/
206
+
function rocket_sitemap_preload_complete() {
207
+
_deprecated_function( __FUNCTION__, '3.2' );
208
+
$screen = get_current_screen();
209
+
210
+
/** This filter is documented in inc/admin-bar.php */
211
+
if ( ! current_user_can( apply_filters( 'rocket_capacity', 'manage_options' ) ) ) {
212
+
return;
213
+
}
214
+
215
+
if ( 'settings_page_wprocket' !== $screen->id ) {
216
+
return;
217
+
}
218
+
219
+
$result = get_transient( 'rocket_sitemap_preload_complete' );
220
+
if ( false === $result ) {
221
+
return;
222
+
}
223
+
224
+
delete_transient( 'rocket_sitemap_preload_complete' );
225
+
226
+
rocket_notice_html( array(
227
+
// translators: %d is the number of pages preloaded.
228
+
'message' => sprintf( __( 'Sitemap preload: %d pages have been cached.', 'rocket' ), $result ),
229
+
) );
230
+
}
231
+
}
232
+
233
+
if ( ! function_exists( 'rocket_sitemap_preload_running' ) ) {
234
+
/**
235
+
* This notice is displayed when the sitemap preload is running
236
+
*
237
+
* @since 2.11
238
+
* @deprecated 3.2
239
+
* @author Remy Perona
240
+
*/
241
+
function rocket_sitemap_preload_running() {
242
+
_deprecated_function( __FUNCTION__, '3.2' );
243
+
$screen = get_current_screen();
244
+
245
+
// This filter is documented in inc/admin-bar.php.
246
+
if ( ! current_user_can( apply_filters( 'rocket_capacity', 'manage_options' ) ) ) {
247
+
return;
248
+
}
249
+
250
+
if ( 'settings_page_wprocket' !== $screen->id ) {
251
+
return;
252
+
}
253
+
254
+
$running = get_transient( 'rocket_sitemap_preload_running' );
255
+
if ( false === $running ) {
256
+
return;
257
+
}
258
+
259
+
rocket_notice_html( array(
260
+
// translators: %d = Number of pages preloaded.
261
+
'message' => sprintf( __( 'Sitemap preload: %d uncached pages have now been preloaded. (refresh to see progress)', 'rocket' ), $running ),
262
+
) );
263
+
}
264
+
}
265
+
266
+
if ( ! function_exists( 'run_rocket_bot_after_clean_post' ) ) {
267
+
/**
268
+
* Actions to be done after the purge cache files of a post
269
+
* By Default, this hook call the WP Rocket Bot (cache json)
270
+
*
271
+
* @deprecated 3.2
272
+
* @since 1.3.0
273
+
*
274
+
* @param object $post The post object.
275
+
* @param array $purge_urls An array of URLs to clean.
276
+
* @param string $lang The language to clean.
277
+
*/
278
+
function run_rocket_bot_after_clean_post( $post, $purge_urls, $lang ) {
279
+
_deprecated_function( __FUNCTION__, '3.2' );
280
+
// Run robot only if post is published.
281
+
if ( 'publish' !== $post->post_status ) {
282
+
return false;
283
+
}
284
+
285
+
// Add Homepage URL to $purge_urls for bot crawl.
286
+
array_push( $purge_urls, get_rocket_i18n_home_url( $lang ) );
287
+
288
+
// Add default WordPress feeds (posts & comments).
289
+
array_push( $purge_urls, get_feed_link() );
290
+
array_push( $purge_urls, get_feed_link( 'comments_' ) );
291
+
292
+
// Get the author page.
293
+
$purge_author = array( get_author_posts_url( $post->post_author ) );
294
+
295
+
// Get all dates archive page.
296
+
$purge_dates = get_rocket_post_dates_urls( $post->ID );
297
+
298
+
// Remove dates archives page and author page to preload cache.
299
+
$purge_urls = array_diff( $purge_urls, $purge_dates, $purge_author );
300
+
301
+
// Create json file and run WP Rocket Bot.
302
+
$json_encode_urls = '["' . implode( '","', array_filter( $purge_urls ) ) . '"]';
303
+
if ( rocket_put_content( WP_ROCKET_PATH . 'cache.json', $json_encode_urls ) ) {
304
+
global $do_rocket_bot_cache_json;
305
+
$do_rocket_bot_cache_json = true;
306
+
}
307
+
}
308
+
}
309
+
310
+
if ( ! function_exists( 'run_rocket_bot_after_clean_term' ) ) {
311
+
/**
312
+
* Actions to be done after the purge cache files of a term
313
+
* By Default, this hook call the WP Rocket Bot (cache json)
314
+
*
315
+
* @deprecated 3.2
316
+
* @since 2.6.8
317
+
*
318
+
* @param object $post The post object.
319
+
* @param array $purge_urls An array of URLs to clean.
320
+
* @param string $lang The language to clean.
321
+
*/
322
+
function run_rocket_bot_after_clean_term( $post, $purge_urls, $lang ) {
323
+
_deprecated_function( __FUNCTION__, '3.2' );
324
+
// Add Homepage URL to $purge_urls for bot crawl.
325
+
array_push( $purge_urls, get_rocket_i18n_home_url( $lang ) );
326
+
327
+
// Create json file and run WP Rocket Bot.
328
+
$json_encode_urls = '["' . implode( '","', array_filter( $purge_urls ) ) . '"]';
329
+
if ( rocket_put_content( WP_ROCKET_PATH . 'cache.json', $json_encode_urls ) ) {
330
+
global $do_rocket_bot_cache_json;
331
+
$do_rocket_bot_cache_json = true;
332
+
}
333
+
}
334
+
}
335
+
336
+
if ( ! function_exists( 'rocket_clean_directory_for_default_language_on_wpml' ) ) {
337
+
/**
338
+
* Conflict with WPML: Clear the homepage when the "Use directory for default language" option is activated.
339
+
*
340
+
* @since 2.6.8
341
+
* @deprecated 3.2.4
342
+
*/
343
+
function rocket_clean_directory_for_default_language_on_wpml() {
344
+
_deprecated_function( __FUNCTION__, '3.2.4' );
345
+
$option = get_option( 'icl_sitepress_settings' );
346
+
347
+
if ( 1 === $option['language_negotiation_type'] && $option['urls']['directory_for_default_language'] ) {
348
+
rocket_clean_files( home_url() );
349
+
}
350
+
}
351
+
}
352
+
353
+
if ( ! function_exists( 'rocket_fetch_and_cache_busting' ) ) {
354
+
/**
355
+
* Fetch and save the cache busting file content
356
+
*
357
+
* @since 2.10
358
+
* @deprecated 3.2.5
359
+
* @author Remy Perona
360
+
*
361
+
* @param string $src Original URL of the asset.
362
+
* @param array $cache_busting_paths Paths used to generated the cache busting file.
363
+
* @param string $abspath_src Absolute path to the asset.
364
+
* @param string $current_filter Current filter value.
365
+
* @return bool true if successful, false otherwise
366
+
*/
367
+
function rocket_fetch_and_cache_busting( $src, $cache_busting_paths, $abspath_src, $current_filter ) {
368
+
_deprecated_function( __FUNCTION__, '3.2.5' );
369
+
if ( wp_is_stream( $src ) ) {
370
+
$response = wp_remote_get( $src );
371
+
$content = wp_remote_retrieve_body( $response );
372
+
} else {
373
+
$content = rocket_direct_filesystem()->get_contents( $src );
374
+
}
375
+
376
+
if ( ! $content ) {
377
+
return false;
378
+
}
379
+
380
+
if ( 'style_loader_src' === $current_filter ) {
381
+
/**
382
+
* Filters the Document Root path to use during CSS minification to rewrite paths
383
+
*
384
+
* @since 2.7
385
+
*
386
+
* @param string The Document Root path.
387
+
*/
388
+
$document_root = apply_filters( 'rocket_min_documentRoot', wp_normalize_path( dirname( $_SERVER['SCRIPT_FILENAME'] ) ) );
389
+
390
+
// Rewrite import/url in CSS content to add the absolute path to the file.
391
+
$content = Minify_CSS_UriRewriter::rewrite( $content, dirname( $abspath_src ), $document_root );
392
+
}
393
+
394
+
if ( ! rocket_direct_filesystem()->is_dir( $cache_busting_paths['bustingpath'] ) ) {
395
+
rocket_mkdir_p( $cache_busting_paths['bustingpath'] );
396
+
}
397
+
398
+
rocket_mkdir_p( dirname( $cache_busting_paths['filepath'] ) );
399
+
400
+
return rocket_put_content( $cache_busting_paths['filepath'], $content );
401
+
}
402
+
}
403
+