';
}
}
if ( ! function_exists( 'rocket_get_home_path' ) ) {
/**
* Get the absolute filesystem path to the root of the WordPress installation.
*
* @since 2.11.7 copy function get_home_path() from WP core.
* @since 2.11.5
* @deprecated 3.0
*
* @author Chris Williams
*
* @return string Full filesystem path to the root of the WordPress installation.
*/
function rocket_get_home_path() {
_deprecated_function( __FUNCTION__, '3.0' );
$home = set_url_scheme( get_option( 'home' ), 'http' );
$siteurl = set_url_scheme( get_option( 'siteurl' ), 'http' );
$home_path = ABSPATH;
if ( ! empty( $home ) && 0 !== strcasecmp( $home, $siteurl ) ) {
$wp_path_rel_to_home = str_ireplace( $home, '', $siteurl ); /* $siteurl - $home */
$pos = strripos( str_replace( '\\', '/', $_SERVER['SCRIPT_FILENAME'] ), trailingslashit( $wp_path_rel_to_home ) );
$home_path = substr( $_SERVER['SCRIPT_FILENAME'], 0, $pos );
$home_path = trailingslashit( $home_path );
}
return str_replace( '\\', '/', $home_path );
}
}
if ( ! function_exists( 'rocket_clean_cache_after_woocommerce_save_product_variation' ) ) {
/**
* Clean product cache on variation update
*
* @since 2.9
* @deprecated 3.1
* @see WP_Rocket\Third_Party\Plugins\Ecommerce\WooCommerce::clean_cache_after_woocommerce_save_product_variation()
* @author Remy Perona
*
* @param int $variation_id ID of the variation.
*/
function rocket_clean_cache_after_woocommerce_save_product_variation( $variation_id ) {
_deprecated_function( __FUNCTION__, '3.1', 'WP_Rocket\Third_Party\Plugins\Ecommerce\WooCommerce::clean_cache_after_woocommerce_save_product_variation()' );
$product_id = wp_get_post_parent_id( $variation_id );
if ( $product_id ) {
rocket_clean_post( $product_id );
}
}
}
if ( ! function_exists( 'rocket_cache_v_query_string' ) ) {
/**
* Automatically cache v query string when WC geolocation with cache compatibility option is active
*
* @since 2.8.6
* @deprecated 3.1
* @see WP_Rocket\Third_Party\Plugins\Ecommerce\WooCommerce::cache_geolocation_query_string()
* @author Rémy Perona
*
* @param array $query_strings list of query strings to cache.
* @return array Updated list of query strings to cache
*/
function rocket_cache_v_query_string( $query_strings ) {
_deprecated_function( __FUNCTION__, '3.1', 'WP_Rocket\Third_Party\Plugins\Ecommerce\WooCommerce::cache_geolocation_query_string()' );
if ( 'geolocation_ajax' === get_option( 'woocommerce_default_customer_address' ) ) {
$query_strings[] = 'v';
}
return $query_strings;
}
}
if ( ! function_exists( 'rocket_exclude_woocommerce_pages' ) ) {
/**
* Exclude WooCommerce cart, checkout and account pages from caching
*
* @since 2.11 Moved to 3rd party
* @since 2.4
* @deprecated 3.1
* @see WP_Rocket\Third_Party\Plugins\Ecommerce\WooCommerce::exclude_pages()
*
* @param array $urls An array of excluded pages.
* @return array Updated array of excluded pages
*/
function rocket_exclude_woocommerce_pages( $urls ) {
_deprecated_function( __FUNCTION__, '3.1', 'WP_Rocket\Third_Party\Plugins\Ecommerce\WooCommerce::exclude_pages()' );
if ( function_exists( 'WC' ) && function_exists( 'wc_get_page_id' ) ) {
if ( wc_get_page_id( 'checkout' ) && wc_get_page_id( 'checkout' ) !== -1 && wc_get_page_id( 'checkout' ) !== (int) get_option( 'page_on_front' ) ) {
$checkout_urls = get_rocket_i18n_translated_post_urls( wc_get_page_id( 'checkout' ), 'page', '(.*)' );
$urls = array_merge( $urls, $checkout_urls );
}
if ( wc_get_page_id( 'cart' ) && wc_get_page_id( 'cart' ) !== -1 && wc_get_page_id( 'cart' ) !== (int) get_option( 'page_on_front' ) ) {
$cart_urls = get_rocket_i18n_translated_post_urls( wc_get_page_id( 'cart' ) );
$urls = array_merge( $urls, $cart_urls );
}
if ( wc_get_page_id( 'myaccount' ) && wc_get_page_id( 'myaccount' ) !== -1 && wc_get_page_id( 'myaccount' ) !== (int) get_option( 'page_on_front' ) ) {
$cart_urls = get_rocket_i18n_translated_post_urls( wc_get_page_id( 'myaccount' ), 'page', '(.*)' );
$urls = array_merge( $urls, $cart_urls );
}
}
return $urls;
}
}
if ( ! function_exists( 'rocket_activate_woocommerce' ) ) {
/**
* Add query string to exclusion when activating the plugin
*
* @since 2.8.6
* @deprecated 3.1
* @see WP_Rocket\Third_Party\Plugins\Ecommerce\WooCommerce::activate_woocommerce()
* @author Rémy Perona
*/
function rocket_activate_woocommerce() {
_deprecated_function( __FUNCTION__, '3.1', 'WP_Rocket\Third_Party\Plugins\Ecommerce\WooCommerce::activate_woocommerce()' );
add_filter( 'rocket_cache_reject_uri', 'rocket_exclude_woocommerce_pages' );
add_filter( 'rocket_cache_query_strings', 'rocket_cache_v_query_string' );
// Update .htaccess file rules.
flush_rocket_htaccess();
// Regenerate the config file.
rocket_generate_config_file();
}
}
if ( ! function_exists( 'rocket_deactivate_woocommerce' ) ) {
/**
* Remove query string from exclusion when deactivating the plugin
*
* @since 2.8.6
* @deprecated 3.1
* @see WP_Rocket\Third_Party\Plugins\Ecommerce\WooCommerce::deactivate_woocommerce()
* @author Rémy Perona
*/
function rocket_deactivate_woocommerce() {
_deprecated_function( __FUNCTION__, '3.1', 'WP_Rocket\Third_Party\Plugins\Ecommerce\WooCommerce::deactivate_woocommerce()' );
remove_filter( 'rocket_cache_reject_uri', 'rocket_exclude_woocommerce_pages' );
remove_filter( 'rocket_cache_query_strings', 'rocket_cache_v_query_string' );
// Update .htaccess file rules.
flush_rocket_htaccess();
// Regenerate the config file.
rocket_generate_config_file();
}
}
if ( ! function_exists( 'rocket_exclude_wc_rest_api' ) ) {
/**
* Exclude WooCommerce REST API URL from cache
*
* @since 2.6.5
* @deprecated 3.1
* @see WP_Rocket\Third_Party\Plugins\Ecommerce\WooCommerce::exclude_wc_rest_api()
*
* @param array $uri URLs to exclude from cache.
* @return array Updated list of URLs to exclude from cache
*/
function rocket_exclude_wc_rest_api( $uri ) {
_deprecated_function( __FUNCTION__, '3.1', 'WP_Rocket\Third_Party\Plugins\Ecommerce\WooCommerce::exclude_wc_rest_api()' );
/**
* By default, don't cache the WooCommerce REST API.
*
* @since 2.6.5
*
* @param bool false will force to cache the WooCommerce REST API
*/
$rocket_cache_reject_wc_rest_api = apply_filters( 'rocket_cache_reject_wc_rest_api', true );
// Exclude WooCommerce REST API.
if ( $rocket_cache_reject_wc_rest_api ) {
$uri[] = rocket_clean_exclude_file( home_url( '/wc-api/v(.*)' ) );
}
return $uri;
}
}
if ( ! function_exists( 'rocket_minify_process' ) ) {
/**
* Launch WP Rocket minification process (HTML, CSS and JavaScript)
*
* @since 2.10 New process for minification without concatenation
* @since 1.3.0 This process is called via the new filter rocket_buffer
* @since 1.1.6 Minify inline CSS and JavaScript
* @since 1.0
* @deprecated 3.1
*
* @param string $buffer HTML content.
* @return string Modified HTML content
*/
function rocket_minify_process( $buffer ) {
_deprecated_function( __FUNCTION__, '3.1' );
$enable_css = get_rocket_option( 'minify_css' );
$enable_js = get_rocket_option( 'minify_js' );
$enable_google_fonts = get_rocket_option( 'minify_google_fonts' );
if ( $enable_css || $enable_js || $enable_google_fonts ) {
list( $buffer, $conditionals ) = rocket_extract_ie_conditionals( $buffer );
}
// Minify JavaScript.
if ( $enable_js && ( ! defined( 'DONOTROCKETOPTIMIZE' ) || ! DONOTROCKETOPTIMIZE ) && ( ! defined( 'DONOTMINIFYJS' ) || ! DONOTMINIFYJS ) && ! is_rocket_post_excluded_option( 'minify_js' ) ) {
$buffer = rocket_minify_files( $buffer, 'js' );
}
// Minify CSS.
if ( $enable_css && ( ! defined( 'DONOTROCKETOPTIMIZE' ) || ! DONOTROCKETOPTIMIZE ) && ( ! defined( 'DONOTMINIFYCSS' ) || ! DONOTMINIFYCSS ) && ! is_rocket_post_excluded_option( 'minify_css' ) ) {
$buffer = rocket_minify_files( $buffer, 'css' );
}
// Concatenate Google Fonts.
if ( $enable_google_fonts ) {
$buffer = rocket_concatenate_google_fonts( $buffer );
}
if ( $enable_css || $enable_js || $enable_google_fonts ) {
$buffer = rocket_inject_ie_conditionals( $buffer, $conditionals );
}
return $buffer;
}
}
if ( ! function_exists( 'rocket_minify_html' ) ) {
/**
* Minifies inline HTML
*
* @since 2.10 Do the HTML minification independently and hook it later to prevent conflicts
* @since 1.1.12
* @deprecated 3.1
*
* @param string $buffer HTML content.
* @return string Updated HTML content
*/
function rocket_minify_html( $buffer ) {
_deprecated_function( __FUNCTION__, '3.1' );
if ( ! get_rocket_option( 'minify_html' ) || is_rocket_post_excluded_option( 'minify_html' ) ) {
return $buffer;
}
$html_options = array(
'cssMinifier' => 'rocket_minify_inline_css',
);
/**
* Filter options of minify inline HTML
*
* @since 1.1.12
*
* @param array $html_options Options of minify inline HTML.
*/
$html_options = apply_filters( 'rocket_minify_html_options', $html_options );
return Minify_HTML::minify( $buffer, $html_options );
}
}
if ( ! function_exists( 'rocket_fix_ssl_minify' ) ) {
/**
* Fix issue with SSL and minification
*
* @since 2.3
* @deprecated 3.1
*
* @param string $url An url to filter to set the scheme to https if needed.
* @return string Updated URL
*/
function rocket_fix_ssl_minify( $url ) {
_deprecated_function( __FUNCTION__, '3.1' );
if ( is_ssl() && false === strpos( $url, 'https://' ) && ! in_array( rocket_extract_url_component( $url, PHP_URL_HOST ), get_rocket_cnames_host( array( 'all', 'css_js', 'css', 'js' ) ), true ) ) {
$url = str_replace( 'http://', 'https://', $url );
}
return $url;
}
}
if ( ! function_exists( 'rocket_minify_i18n_multidomain' ) ) {
/**
* Compatibility with multilingual plugins & multidomain configuration
*
* @since 2.6.13 Regression Fix: Apply CDN on minified CSS and JS files by checking the CNAME host
* @since 2.6.8
* @deprecated 3.1
*
* @param string $url Minified file URL.
* @return string Updated minified file URL
*/
function rocket_minify_i18n_multidomain( $url ) {
_deprecated_function( __FUNCTION__, '3.1' );
if ( ! rocket_has_i18n() ) {
return $url;
}
$url_host = rocket_extract_url_component( $url, PHP_URL_HOST );
$zone = array( 'all', 'css_and_js' );
$current_filter = current_filter();
// Add only CSS zone.
if ( 'rocket_css_url' === $current_filter ) {
$zone[] = 'css';
}
// Add only JS zone.
if ( 'rocket_js_url' === $current_filter ) {
$zone[] = 'js';
}
$cnames = get_rocket_cdn_cnames( $zone );
$cnames = array_map( 'rocket_remove_url_protocol' , $cnames );
if ( $url_host !== $_SERVER['HTTP_HOST'] && in_array( $_SERVER['HTTP_HOST'], get_rocket_i18n_host(), true ) && ! in_array( $url_host, $cnames, true ) ) {
$url = str_replace( $url_host, $_SERVER['HTTP_HOST'], $url );
}
return $url;
}
}
if ( ! function_exists( 'rocket_get_js_enqueued_in_head' ) ) {
/**
* Get all src for JS files already enqueued in head
*
* @since 2.10
* @deprecated 3.1
* @author Remy Perona
*/
function rocket_get_js_enqueued_in_head() {
_deprecated_function( __FUNCTION__, '3.1' );
global $wp_scripts, $rocket_js_enqueued_in_head;
if ( ! (bool) $wp_scripts->done ) {
return;
}
foreach ( $wp_scripts->done as $handle ) {
if ( ! empty( $wp_scripts->registered[ $handle ]->src ) ) {
$rocket_js_enqueued_in_head[] = str_replace( '#', '\#', rocket_clean_exclude_file( $wp_scripts->registered[ $handle ]->src ) );
}
}
}
}
if ( ! function_exists( 'get_rocket_exclude_files' ) ) {
/**
* Get all files to exclude from minification/concatenation.
*
* @since 2.11
* @deprecated 3.1
* @author Remy Perona
*
* @param string $extension Type of files to exclude.
* @return array Array of excluded files.
*/
function get_rocket_exclude_files( $extension ) {
_deprecated_function( __FUNCTION__, '3.1' );
if ( 'css' === $extension ) {
$excluded_files = get_rocket_option( 'exclude_css', array() );
/**
* Filters CSS files to exclude from minification/concatenation.
*
* @since 2.6
*
* @param array $excluded_files List of excluded CSS files.
*/
$excluded_files = apply_filters( 'rocket_exclude_css', $excluded_files );
} elseif ( 'js' === $extension ) {
global $wp_scripts;
$excluded_files = get_rocket_option( 'exclude_js', array() );
if ( get_rocket_option( 'defer_all_js', 0 ) && get_rocket_option( 'defer_all_js_safe', 0 ) ) {
$excluded_files[] = rocket_clean_exclude_file( site_url( $wp_scripts->registered['jquery-core']->src ) );
}
/**
* Filter JS files to exclude from minification/concatenation.
*
* @since 2.6
*
* @param array $js_files List of excluded JS files.
*/
$excluded_files = apply_filters( 'rocket_exclude_js', $excluded_files );
}
return $excluded_files;
}
}
if ( ! function_exists( 'rocket_concatenate_google_fonts' ) ) {
/**
* Concatenates Google Fonts tags (http://fonts.googleapis.com/css?...)
*
* @since 2.3
* @deprecated 3.1
*
* @param string $buffer HTML content.
* @return string Modified HTML content
*/
function rocket_concatenate_google_fonts( $buffer ) {
_deprecated_function( __FUNCTION__, '3.1' );
// Get all Google Fonts CSS files.
$buffer_without_comments = preg_replace( '//Uis', '', $buffer );
preg_match_all( '/