add wp-rocket
This commit is contained in:
80
wp-content/plugins/wp-rocket/inc/3rd-party/hosting/flywheel.php
vendored
Normal file
80
wp-content/plugins/wp-rocket/inc/3rd-party/hosting/flywheel.php
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Changes the text on the Varnish one-click block.
|
||||
*
|
||||
* @since 3.0
|
||||
* @author Remy Perona
|
||||
*
|
||||
* @param array $settings Field settings data.
|
||||
*
|
||||
* @return array modified field settings data.
|
||||
*/
|
||||
function rocket_flywheel_varnish_field( $settings ) {
|
||||
$settings['varnish_auto_purge']['title'] = sprintf(
|
||||
// Translators: %s = Hosting name.
|
||||
__( 'Your site is hosted on %s, we have enabled Varnish auto-purge for compatibility.', 'rocket' ),
|
||||
'Flywheel'
|
||||
);
|
||||
|
||||
return $settings;
|
||||
}
|
||||
add_filter( 'rocket_varnish_field_settings', 'rocket_flywheel_varnish_field' );
|
||||
|
||||
add_filter( 'rocket_display_input_varnish_auto_purge', '__return_false' );
|
||||
|
||||
/**
|
||||
* Allow to purge Varnish on Flywheel websites
|
||||
*
|
||||
* @since 2.6.8
|
||||
*/
|
||||
add_filter( 'do_rocket_varnish_http_purge', '__return_true' );
|
||||
add_filter( 'do_rocket_generate_caching_files', '__return_false' );
|
||||
|
||||
// Prevent mandatory cookies on hosting with server cache.
|
||||
add_filter( 'rocket_cache_mandatory_cookies', '__return_empty_array', PHP_INT_MAX );
|
||||
|
||||
/**
|
||||
* Set up the right Varnish IP for Flywheel
|
||||
*
|
||||
* @since 2.6.8
|
||||
* @param array $varnish_ip Varnish IP.
|
||||
*/
|
||||
function rocket_varnish_ip_on_flywheel( $varnish_ip ) {
|
||||
$varnish_ip[] = '127.0.0.1';
|
||||
|
||||
return $varnish_ip;
|
||||
}
|
||||
add_filter( 'rocket_varnish_ip', 'rocket_varnish_ip_on_flywheel' );
|
||||
|
||||
/**
|
||||
* Remove WP Rocket functions on WP core action hooks to prevent triggering a double cache clear.
|
||||
*
|
||||
* @since 3.3.1
|
||||
* @author Remy Perona
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function rocket_flywheel_remove_partial_purge_hooks() {
|
||||
// WP core action hooks rocket_clean_post() gets hooked into.
|
||||
$clean_post_hooks = [
|
||||
// Disables the refreshing of partial cache when content is edited.
|
||||
'wp_trash_post',
|
||||
'delete_post',
|
||||
'clean_post_cache',
|
||||
'wp_update_comment_count',
|
||||
];
|
||||
|
||||
// Remove rocket_clean_post() from core action hooks.
|
||||
array_map(
|
||||
function( $hook ) {
|
||||
remove_action( $hook, 'rocket_clean_post' );
|
||||
},
|
||||
$clean_post_hooks
|
||||
);
|
||||
|
||||
remove_filter( 'rocket_clean_files', 'rocket_clean_files_users' );
|
||||
}
|
||||
add_action( 'wp_rocket_loaded', 'rocket_flywheel_remove_partial_purge_hooks' );
|
130
wp-content/plugins/wp-rocket/inc/3rd-party/hosting/godaddy.php
vendored
Normal file
130
wp-content/plugins/wp-rocket/inc/3rd-party/hosting/godaddy.php
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Changes the text on the Varnish one-click block.
|
||||
*
|
||||
* @since 3.0
|
||||
* @author Remy Perona
|
||||
*
|
||||
* @param array $settings Field settings data.
|
||||
*
|
||||
* @return array modified field settings data.
|
||||
*/
|
||||
function rocket_godaddy_varnish_field( $settings ) {
|
||||
$settings['varnish_auto_purge']['title'] = sprintf(
|
||||
// Translators: %s = Hosting name.
|
||||
__( 'Your site is hosted on %s, we have enabled Varnish auto-purge for compatibility.', 'rocket' ),
|
||||
'GoDaddy'
|
||||
);
|
||||
|
||||
return $settings;
|
||||
}
|
||||
add_filter( 'rocket_varnish_field_settings', 'rocket_godaddy_varnish_field' );
|
||||
|
||||
add_filter( 'rocket_display_input_varnish_auto_purge', '__return_false' );
|
||||
|
||||
add_filter( 'set_rocket_wp_cache_define', '__return_true' );
|
||||
// Prevent mandatory cookies on hosting with server cache.
|
||||
add_filter( 'rocket_cache_mandatory_cookies', '__return_empty_array', PHP_INT_MAX );
|
||||
add_filter( 'rocket_htaccess_mod_rewrite', '__return_false' );
|
||||
|
||||
/**
|
||||
* Remove expiration on HTML to prevent issue with Varnish cache.
|
||||
*
|
||||
* @since 2.9.5
|
||||
* @author Remy Perona
|
||||
*
|
||||
* @param string $rules htaccess rules.
|
||||
* @return string Updated htaccess rules.
|
||||
*/
|
||||
function rocket_remove_html_expire_goddady( $rules ) {
|
||||
$rules = preg_replace( '@\s*#\s*Your document html@', '', $rules );
|
||||
$rules = preg_replace( '@\s*ExpiresByType text/html\s*"access plus \d+ (seconds|minutes|hour|week|month|year)"@', '', $rules );
|
||||
|
||||
return $rules;
|
||||
}
|
||||
add_filter( 'rocket_htaccess_mod_expires', 'rocket_remove_html_expire_goddady', 5 );
|
||||
|
||||
/**
|
||||
* Call the Varnish server to purge the cache with GoDaddy.
|
||||
*
|
||||
* @since 2.9.5
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function rocket_clean_domain_godaddy() {
|
||||
rocket_godaddy_request( 'BAN' );
|
||||
}
|
||||
add_action( 'before_rocket_clean_domain', 'rocket_clean_domain_godaddy' );
|
||||
|
||||
/**
|
||||
* Call the Varnish server to purge a specific URL with GoDaddy.
|
||||
*
|
||||
* @since 2.9.5
|
||||
*
|
||||
* @param string $url URL to purge.
|
||||
* @return void
|
||||
*/
|
||||
function rocket_clean_file_godaddy( $url ) {
|
||||
rocket_godaddy_request( 'PURGE', home_url( $url ) );
|
||||
}
|
||||
add_action( 'before_rocket_clean_file', 'rocket_clean_file_godaddy' );
|
||||
|
||||
/**
|
||||
* Call the Varnish server to purge the home with GoDaddy.
|
||||
*
|
||||
* @since 2.9.5
|
||||
*
|
||||
* @param string $root root URL.
|
||||
* @param string $lang language code.
|
||||
* @return void
|
||||
*/
|
||||
function rocket_clean_home_godaddy( $root, $lang ) {
|
||||
$home_url = trailingslashit( get_rocket_i18n_home_url( $lang ) );
|
||||
$home_pagination_url = $home_url . trailingslashit( $GLOBALS['wp_rewrite']->pagination_base );
|
||||
|
||||
rocket_godaddy_request( 'PURGE', $home_url );
|
||||
rocket_godaddy_request( 'PURGE', $home_pagination_url );
|
||||
}
|
||||
add_action( 'before_rocket_clean_home', 'rocket_clean_home_godaddy', 10, 2 );
|
||||
|
||||
/**
|
||||
* Perform the call to the Varnish server to purge
|
||||
*
|
||||
* @since 2.9.5
|
||||
* @source WPaaS\Cache
|
||||
*
|
||||
* @param string $method can be BAN or PURGE.
|
||||
* @param string $url URL to purge.
|
||||
* @return void
|
||||
*/
|
||||
function rocket_godaddy_request( $method, $url = null ) {
|
||||
if ( ! method_exists( 'WPass\Plugin', 'vip' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( empty( $url ) ) {
|
||||
$url = home_url();
|
||||
}
|
||||
|
||||
$host = rocket_extract_url_component( $url, PHP_URL_HOST );
|
||||
$url = set_url_scheme( str_replace( $host, WPaas\Plugin::vip(), $url ), 'http' );
|
||||
|
||||
wp_cache_flush();
|
||||
|
||||
// This forces the APC cache to flush across the server.
|
||||
update_option( 'gd_system_last_cache_flush', time() );
|
||||
|
||||
wp_remote_request(
|
||||
esc_url_raw( $url ),
|
||||
[
|
||||
'method' => $method,
|
||||
'blocking' => false,
|
||||
'headers' => [
|
||||
'Host' => $host,
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
166
wp-content/plugins/wp-rocket/inc/3rd-party/hosting/kinsta.php
vendored
Normal file
166
wp-content/plugins/wp-rocket/inc/3rd-party/hosting/kinsta.php
vendored
Normal file
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
add_filter( 'do_rocket_generate_caching_files', '__return_false', PHP_INT_MAX );
|
||||
add_filter( 'rocket_display_varnish_options_tab', '__return_false' );
|
||||
// Prevent mandatory cookies on hosting with server cache.
|
||||
add_filter( 'rocket_cache_mandatory_cookies', '__return_empty_array', PHP_INT_MAX );
|
||||
|
||||
global $kinsta_cache;
|
||||
|
||||
if ( isset( $kinsta_cache ) && class_exists( '\\Kinsta\\CDN_Enabler' ) ) {
|
||||
/**
|
||||
* Clear Kinsta cache when clearing WP Rocket cache
|
||||
*
|
||||
* @since 3.0
|
||||
* @author Remy Perona
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function rocket_clean_kinsta_cache() {
|
||||
global $kinsta_cache;
|
||||
|
||||
if ( ! empty( $kinsta_cache->kinsta_cache_purge ) ) {
|
||||
$kinsta_cache->kinsta_cache_purge->purge_complete_caches();
|
||||
}
|
||||
}
|
||||
add_action( 'after_rocket_clean_domain', 'rocket_clean_kinsta_cache' );
|
||||
|
||||
/**
|
||||
* Partially clear Kinsta cache when partially clearing WP Rocket cache
|
||||
*
|
||||
* @since 3.0
|
||||
* @author Remy Perona
|
||||
*
|
||||
* @param object $post Post object.
|
||||
* @return void
|
||||
*/
|
||||
function rocket_clean_kinsta_post_cache( $post ) {
|
||||
global $kinsta_cache;
|
||||
$kinsta_cache->kinsta_cache_purge->initiate_purge( $post->ID, 'post' );
|
||||
}
|
||||
add_action( 'after_rocket_clean_post', 'rocket_clean_kinsta_post_cache' );
|
||||
|
||||
/**
|
||||
* Clears Kinsta cache for the homepage URL when using "Purge this URL" from the admin bar on the front end
|
||||
*
|
||||
* @since 3.0.4
|
||||
* @author Remy Perona
|
||||
*
|
||||
* @param string $root WP Rocket root cache path.
|
||||
* @param string $lang Current language.
|
||||
* @return void
|
||||
*/
|
||||
function rocket_clean_kinsta_cache_home( $root = '', $lang = '' ) {
|
||||
$url = get_rocket_i18n_home_url( $lang );
|
||||
$url = trailingslashit( $url ) . 'kinsta-clear-cache/';
|
||||
|
||||
wp_remote_get(
|
||||
$url,
|
||||
[
|
||||
'blocking' => false,
|
||||
'timeout' => 0.01,
|
||||
]
|
||||
);
|
||||
}
|
||||
add_action( 'after_rocket_clean_home', 'rocket_clean_kinsta_cache_home', 10, 2 );
|
||||
|
||||
/**
|
||||
* Clears Kinsta cache for a specific URL when using "Purge this URL" from the admin bar on the front end
|
||||
*
|
||||
* @since 3.0.4
|
||||
* @author Remy Perona
|
||||
*
|
||||
* @param string $url URL to purge.
|
||||
* @return void
|
||||
*/
|
||||
function rocket_clean_kinsta_cache_url( $url ) {
|
||||
$url = trailingslashit( $url ) . 'kinsta-clear-cache/';
|
||||
|
||||
wp_remote_get(
|
||||
$url,
|
||||
[
|
||||
'blocking' => false,
|
||||
'timeout' => 0.01,
|
||||
]
|
||||
);
|
||||
}
|
||||
add_action( 'after_rocket_clean_file', 'rocket_clean_kinsta_cache_url' );
|
||||
|
||||
/**
|
||||
* Remove WP Rocket functions on WP core action hooks to prevent triggering a double cache clear.
|
||||
*
|
||||
* @since 3.0
|
||||
* @author Remy Perona
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function rocket_remove_partial_purge_hooks() {
|
||||
// WP core action hooks rocket_clean_post() gets hooked into.
|
||||
$clean_post_hooks = [
|
||||
// Disables the refreshing of partial cache when content is edited.
|
||||
'wp_trash_post',
|
||||
'delete_post',
|
||||
'clean_post_cache',
|
||||
'wp_update_comment_count',
|
||||
];
|
||||
|
||||
// Remove rocket_clean_post() from core action hooks.
|
||||
array_map(
|
||||
function( $hook ) {
|
||||
remove_action( $hook, 'rocket_clean_post' );
|
||||
},
|
||||
$clean_post_hooks
|
||||
);
|
||||
|
||||
remove_filter( 'rocket_clean_files', 'rocket_clean_files_users' );
|
||||
}
|
||||
add_action( 'wp_rocket_loaded', 'rocket_remove_partial_purge_hooks' );
|
||||
|
||||
if ( \Kinsta\CDN_Enabler::cdn_is_enabled() ) {
|
||||
/**
|
||||
* Add Kinsta CDN to WP Rocket CDN hosts list if enabled
|
||||
*
|
||||
* @since 3.0
|
||||
* @author Remy Perona
|
||||
*
|
||||
* @param Array $hosts Array of CDN hosts.
|
||||
* @return Array Updated array of CDN hosts
|
||||
*/
|
||||
function rocket_add_kinsta_cdn_cname( $hosts ) {
|
||||
if ( ! isset( $_SERVER['KINSTA_CDN_DOMAIN'] ) ) {
|
||||
return $hosts;
|
||||
}
|
||||
|
||||
$hosts[] = sanitize_text_field( wp_unslash( $_SERVER['KINSTA_CDN_DOMAIN'] ) );
|
||||
|
||||
return $hosts;
|
||||
}
|
||||
add_filter( 'rocket_cdn_cnames', 'rocket_add_kinsta_cdn_cname', 1 );
|
||||
}
|
||||
} else {
|
||||
add_action(
|
||||
'admin_notices',
|
||||
function() {
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$screen = get_current_screen();
|
||||
|
||||
if ( 'settings_page_wprocket' !== $screen->id ) {
|
||||
return;
|
||||
}
|
||||
|
||||
rocket_notice_html(
|
||||
[
|
||||
'status' => 'error',
|
||||
'dismissible' => '',
|
||||
// translators: %1$s = opening link tag, %2$s = closing link tag.
|
||||
'message' => sprintf( __( 'Your installation seems to be missing core Kinsta files managing Cache clearing and CDN, which will prevent your Kinsta installation and WP Rocket from working correctly. Please get in touch with Kinsta support through your %1$sMyKinsta%2$s account to resolve this issue.', 'rocket' ), '<a href="https://my.kinsta.com/login/" target="_blank">', '</a>' ),
|
||||
]
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
24
wp-content/plugins/wp-rocket/inc/3rd-party/hosting/nginx.php
vendored
Normal file
24
wp-content/plugins/wp-rocket/inc/3rd-party/hosting/nginx.php
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Compatibility with an usual NGINX configuration which include:
|
||||
* try_files $uri $uri/ /index.php?q=$uri&$args
|
||||
*
|
||||
* @since 2.3.9
|
||||
*
|
||||
* @param array $query_strings Array of query strings to cache.
|
||||
*
|
||||
* @return array Updated array of query strings.
|
||||
*/
|
||||
function rocket_better_nginx_compatibility( $query_strings ) {
|
||||
global $is_nginx;
|
||||
|
||||
if ( $is_nginx ) {
|
||||
$query_strings[] = 'q';
|
||||
}
|
||||
|
||||
return $query_strings;
|
||||
}
|
||||
add_filter( 'rocket_cache_query_strings', 'rocket_better_nginx_compatibility' );
|
31
wp-content/plugins/wp-rocket/inc/3rd-party/hosting/pagely.php
vendored
Normal file
31
wp-content/plugins/wp-rocket/inc/3rd-party/hosting/pagely.php
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Clear WP Rocket cache after purged the Varnish cache via Pagely hosting.
|
||||
*
|
||||
* @since 2.5.7
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function rocket_clear_cache_after_pagely() {
|
||||
// Clear all caching files.
|
||||
rocket_clean_domain();
|
||||
}
|
||||
add_action( 'pagely_cache_purge_after', 'rocket_clear_cache_after_pagely' );
|
||||
|
||||
/**
|
||||
* Call the cache server to purge the cache with Pagely hosting.
|
||||
*
|
||||
* @since 2.5.7
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function rocket_clean_pagely() {
|
||||
if ( class_exists( 'PagelyCachePurge' ) ) {
|
||||
$purger = new PagelyCachePurge();
|
||||
$purger->purgeAll();
|
||||
}
|
||||
}
|
||||
add_action( 'after_rocket_clean_domain', 'rocket_clean_pagely' );
|
61
wp-content/plugins/wp-rocket/inc/3rd-party/hosting/pressidium.php
vendored
Normal file
61
wp-content/plugins/wp-rocket/inc/3rd-party/hosting/pressidium.php
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( defined( 'WP_NINUKIS_WP_NAME' ) ) {
|
||||
/**
|
||||
* Changes the text on the Varnish one-click block.
|
||||
*
|
||||
* @since 3.0
|
||||
* @author Remy Perona
|
||||
*
|
||||
* @param array $settings Field settings data.
|
||||
*
|
||||
* @return array modified field settings data.
|
||||
*/
|
||||
function rocket_pressidium_varnish_field( $settings ) {
|
||||
// Translators: %s = Hosting name.
|
||||
$settings['varnish_auto_purge']['title'] = sprintf( __( 'Your site is hosted on %s, we have enabled Varnish auto-purge for compatibility.', 'rocket' ), 'Pressidium' );
|
||||
|
||||
return $settings;
|
||||
}
|
||||
add_filter( 'rocket_varnish_field_settings', 'rocket_pressidium_varnish_field' );
|
||||
|
||||
add_filter( 'rocket_display_input_varnish_auto_purge', '__return_false' );
|
||||
// Prevent mandatory cookies on hosting with server cache.
|
||||
add_filter( 'rocket_cache_mandatory_cookies', '__return_empty_array', PHP_INT_MAX );
|
||||
|
||||
/**
|
||||
* Clear WP Rocket cache after purged the Varnish cache via Pressidium Hosting
|
||||
*
|
||||
* @since 2.5.11
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function rocket_clear_cache_after_pressidium() {
|
||||
if ( isset( $_POST['purge-all'] ) && current_user_can( 'manage_options' ) && check_admin_referer( WP_NINUKIS_WP_NAME . '-caching' ) ) {
|
||||
// Clear all caching files.
|
||||
rocket_clean_domain();
|
||||
|
||||
// Preload cache.
|
||||
run_rocket_bot();
|
||||
run_rocket_sitemap_preload();
|
||||
}
|
||||
}
|
||||
add_action( 'admin_init', 'rocket_clear_cache_after_pressidium' );
|
||||
}
|
||||
|
||||
if ( class_exists( 'Ninukis_Plugin' ) ) {
|
||||
/**
|
||||
* Call the cache server to purge the cache with Pressidium hosting.
|
||||
*
|
||||
* @since 2.6
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function rocket_clean_pressidium() {
|
||||
$plugin = Ninukis_Plugin::get_instance();
|
||||
$plugin->purgeAllCaches();
|
||||
}
|
||||
add_action( 'after_rocket_clean_domain', 'rocket_clean_pressidium' );
|
||||
}
|
98
wp-content/plugins/wp-rocket/inc/3rd-party/hosting/presslabs.php
vendored
Normal file
98
wp-content/plugins/wp-rocket/inc/3rd-party/hosting/presslabs.php
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
require_once WP_CONTENT_DIR . '/advanced-cache.php';
|
||||
|
||||
add_action( 'pl_pre_cache_refresh', 'rocket_clean_files', 0 );
|
||||
add_filter( 'rocket_display_varnish_options_tab', '__return_false' );
|
||||
add_filter( 'do_rocket_generate_caching_files', '__return_false', PHP_INT_MAX );
|
||||
add_filter( 'rocket_cache_mandatory_cookies', '__return_empty_array', PHP_INT_MAX );
|
||||
add_action( 'after_rocket_clean_home', 'rocket_pl_clean_home', 10, 2 );
|
||||
add_action( 'after_rocket_clean_file', 'rocket_pl_clean_post', 2 );
|
||||
add_action( 'pl_pre_url_button_cache_refresh', 'rocket_clean_files' );
|
||||
add_action( 'wp_rocket_loaded', 'rocket_remove_partial_purge_hooks' );
|
||||
|
||||
/**
|
||||
* We clear the cache only on the post, homepage and listings when creating/updating/deleting posts.
|
||||
*
|
||||
* @since 3.3
|
||||
*
|
||||
* @param object $post The Post object itself for which the action occured.
|
||||
* @param array $permalink A list of permalinks to be flushed from cache.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function rocket_pl_clean_post( $post = false, $permalink = false ) {
|
||||
if ( ! $post || ! $permalink ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$cache_handler = new \Presslabs\Cache\CacheHandler();
|
||||
|
||||
$cache_handler->invalidate_url( $permalink[0], true );
|
||||
$cache_handler->invalidate_url( home_url( '/' ), true );
|
||||
$cache_handler->purge_cache( 'listing' );
|
||||
}
|
||||
|
||||
/**
|
||||
* We clear the cache for the homepage URL when using "Purge this URL" from the admin bar on the front end.
|
||||
*
|
||||
* @since 3.3
|
||||
*
|
||||
* @param string $root WP Rocket root cache path.
|
||||
* @param string $lang Current language.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function rocket_pl_clean_home( $root = false, $lang = false ) {
|
||||
if ( ! $post || ! $permalink ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$cache_handler = new \Presslabs\Cache\CacheHandler();
|
||||
$cache_handler->invalidate_url( home_url( '/' ), true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove WP Rocket functions on WP core action hooks to prevent triggering a double cache clear.
|
||||
*
|
||||
* @since 3.3
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function rocket_remove_partial_purge_hooks() {
|
||||
// WP core action hooks rocket_clean_post() gets hooked into.
|
||||
$clean_post_hooks = [
|
||||
// Disables the refreshing of partial cache when content is edited.
|
||||
'wp_trash_post',
|
||||
'delete_post',
|
||||
'clean_post_cache',
|
||||
'wp_update_comment_count',
|
||||
];
|
||||
// Remove rocket_clean_post() from core action hooks.
|
||||
array_map(
|
||||
function( $hook ) {
|
||||
remove_action( $hook, 'rocket_clean_post' );
|
||||
},
|
||||
$clean_post_hooks
|
||||
);
|
||||
remove_filter( 'rocket_clean_files', 'rocket_clean_files_users' );
|
||||
}
|
||||
|
||||
if ( ! defined( 'DISABLE_CDN_OFFLOAD' ) && defined( 'PL_CDN_HOST' ) ) {
|
||||
/**
|
||||
* If we have CDN enabled we'll add our HOST to the list.
|
||||
*
|
||||
* @since 3.3
|
||||
*
|
||||
* @param array $hosts Array of CDN hosts.
|
||||
*
|
||||
* @return array Updated array of CDN hosts
|
||||
*/
|
||||
function rocket_add_pl_cdn( $hosts ) {
|
||||
$hosts[] = constant( 'PL_CDN_HOST' );
|
||||
return $hosts;
|
||||
}
|
||||
add_filter( 'rocket_cdn_cnames', 'rocket_add_pl_cdn', 1 );
|
||||
}
|
87
wp-content/plugins/wp-rocket/inc/3rd-party/hosting/siteground.php
vendored
Normal file
87
wp-content/plugins/wp-rocket/inc/3rd-party/hosting/siteground.php
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Returns the current version of the SG Optimizer plugin.
|
||||
*
|
||||
* @since 3.2.3.1
|
||||
* @author Remy Perona
|
||||
*
|
||||
* @return string version number.
|
||||
*/
|
||||
function rocket_get_sg_optimizer_version() {
|
||||
static $version;
|
||||
|
||||
if ( isset( $version ) ) {
|
||||
return $version;
|
||||
}
|
||||
|
||||
$sg_optimizer = get_file_data( WP_PLUGIN_DIR . '/sg-cachepress/sg-cachepress.php', [ 'Version' => 'Version' ] );
|
||||
$version = $sg_optimizer['Version'];
|
||||
|
||||
return $version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if SG Optimizer Supercache is active.
|
||||
*
|
||||
* @since 3.2.3.1
|
||||
* @author Remy Perona
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function rocket_is_supercacher_active() {
|
||||
if ( ! version_compare( rocket_get_sg_optimizer_version(), '5.0' ) < 0 ) {
|
||||
global $sg_cachepress_environment;
|
||||
|
||||
return isset( $sg_cachepress_environment ) && $sg_cachepress_environment instanceof SG_CachePress_Environment && $sg_cachepress_environment->cache_is_enabled();
|
||||
}
|
||||
|
||||
return (bool) get_option( 'siteground_optimizer_enable_cache', 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Call the cache server to purge the cache with SuperCacher (SiteGround).
|
||||
*
|
||||
* @since 2.3
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function rocket_clean_supercacher() {
|
||||
if ( ! rocket_is_supercacher_active() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! version_compare( rocket_get_sg_optimizer_version(), '5.0' ) < 0 ) {
|
||||
SiteGround_Optimizer\Supercacher\Supercacher::purge_cache();
|
||||
} elseif ( isset( $sg_cachepress_supercacher ) && $sg_cachepress_supercacher instanceof SG_CachePress_Supercacher ) {
|
||||
$sg_cachepress_supercacher->purge_cache();
|
||||
}
|
||||
}
|
||||
|
||||
if ( rocket_is_supercacher_active() ) {
|
||||
add_action( 'admin_post_sg-cachepress-purge', 'rocket_clean_domain', 0 );
|
||||
add_action( 'after_rocket_clean_domain', 'rocket_clean_supercacher' );
|
||||
add_filter( 'rocket_display_varnish_options_tab', '__return_false' );
|
||||
// Prevent mandatory cookies on hosting with server cache.
|
||||
add_filter( 'rocket_cache_mandatory_cookies', '__return_empty_array', PHP_INT_MAX );
|
||||
|
||||
/**
|
||||
* Force WP Rocket caching on SG Optimizer versions before 4.0.5.
|
||||
*
|
||||
* @since 3.0.4
|
||||
* @author Arun Basil Lal
|
||||
*
|
||||
* @link https://github.com/wp-media/wp-rocket/issues/925
|
||||
*/
|
||||
if ( version_compare( rocket_get_sg_optimizer_version(), '4.0.5' ) < 0 ) {
|
||||
add_filter( 'do_rocket_generate_caching_files', '__return_true', 11 );
|
||||
}
|
||||
|
||||
if ( version_compare( rocket_get_sg_optimizer_version(), '5.0' ) < 0 ) {
|
||||
add_action( 'wp_ajax_sg-cachepress-purge', 'rocket_clean_domain', 0 );
|
||||
} else {
|
||||
add_action( 'wp_ajax_admin_bar_purge_cache', 'rocket_clean_domain', 0 );
|
||||
}
|
||||
}
|
35
wp-content/plugins/wp-rocket/inc/3rd-party/hosting/wp-serveur.php
vendored
Normal file
35
wp-content/plugins/wp-rocket/inc/3rd-party/hosting/wp-serveur.php
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Allow to purge Varnish on WP Serveur websites.
|
||||
*
|
||||
* @since 2.6.11
|
||||
*/
|
||||
add_filter( 'do_rocket_varnish_http_purge', '__return_true' );
|
||||
// Prevent mandatory cookies on hosting with server cache.
|
||||
add_filter( 'rocket_cache_mandatory_cookies', '__return_empty_array', PHP_INT_MAX );
|
||||
|
||||
/**
|
||||
* Changes the text on the Varnish one-click block.
|
||||
*
|
||||
* @since 3.0
|
||||
* @author Remy Perona
|
||||
*
|
||||
* @param array $settings Field settings data.
|
||||
*
|
||||
* @return array modified field settings data.
|
||||
*/
|
||||
function rocket_wpserveur_varnish_field( $settings ) {
|
||||
$settings['varnish_auto_purge']['title'] = sprintf(
|
||||
// Translators: %s = Hosting name.
|
||||
__( 'Your site is hosted on %s, we have enabled Varnish auto-purge for compatibility.', 'rocket' ),
|
||||
'WP Serveur'
|
||||
);
|
||||
|
||||
return $settings;
|
||||
}
|
||||
add_filter( 'rocket_varnish_field_settings', 'rocket_wpserveur_varnish_field' );
|
||||
|
||||
add_filter( 'rocket_display_input_varnish_auto_purge', '__return_false' );
|
Reference in New Issue
Block a user