Commit inicial, se subio el proyecto
This commit is contained in:
+106
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Compatibility with Aelia Currency Switcher.
|
||||
*
|
||||
* @since 2.7
|
||||
*/
|
||||
if ( class_exists( 'WC_Aelia_CurrencySwitcher' ) ) :
|
||||
/**
|
||||
* Update .htaccess & config files when the Geolocation option is updated
|
||||
*
|
||||
* @since 2.7
|
||||
*
|
||||
* @param array $old_value Previous setting values.
|
||||
* @param array $value Submitted settings values.
|
||||
*/
|
||||
function rocket_after_update_aelia_currencyswitcher_options( $old_value, $value ) {
|
||||
if ( ( ! isset( $old_value['ipgeolocation_enabled'] ) && isset( $value['ipgeolocation_enabled'] ) ) || ( isset( $old_value['ipgeolocation_enabled'], $value['ipgeolocation_enabled'] ) && $old_value['ipgeolocation_enabled'] !== $value['ipgeolocation_enabled'] )
|
||||
) {
|
||||
// Update the WP Rocket rules on the .htaccess file.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Update the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
}
|
||||
add_action( 'update_option_wc_aelia_currency_switcher', 'rocket_after_update_aelia_currencyswitcher_options', 10, 2 );
|
||||
|
||||
/**
|
||||
* Generate a caching file depending on the currency cookie value
|
||||
*/
|
||||
add_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 64 );
|
||||
add_filter( 'rocket_cache_dynamic_cookies', 'rocket_add_aelia_currencyswitcher_dynamic_cookies' );
|
||||
add_filter( 'rocket_cache_mandatory_cookies', 'rocket_add_aelia_currencyswitcher_mandatory_cookie' );
|
||||
endif;
|
||||
|
||||
/**
|
||||
* Add the Aelia Currency Switcher cookies when activating the plugin
|
||||
*
|
||||
* @since 2.7
|
||||
*/
|
||||
function rocket_activate_aelia_currencyswitcher() {
|
||||
add_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 64 );
|
||||
add_filter( 'rocket_cache_dynamic_cookies', 'rocket_add_aelia_currencyswitcher_dynamic_cookies' );
|
||||
add_filter( 'rocket_cache_mandatory_cookies', 'rocket_add_aelia_currencyswitcher_mandatory_cookie' );
|
||||
|
||||
// Update the WP Rocket rules on the .htaccess file.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'activate_woocommerce-aelia-currencyswitcher/woocommerce-aelia-currencyswitcher.php', 'rocket_activate_aelia_currencyswitcher', 11 );
|
||||
|
||||
/**
|
||||
* Remove the Aelia Currency Switcher cookies when deactivating the plugin
|
||||
*
|
||||
* @since 2.7
|
||||
*/
|
||||
function rocket_deactivate_aelia_currencyswitcher() {
|
||||
remove_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 64 );
|
||||
remove_filter( 'rocket_cache_dynamic_cookies', 'rocket_add_aelia_currencyswitcher_dynamic_cookies' );
|
||||
remove_filter( 'rocket_cache_mandatory_cookies', 'rocket_add_aelia_currencyswitcher_mandatory_cookie' );
|
||||
|
||||
// Update the WP Rocket rules on the .htaccess file.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'deactivate_woocommerce-aelia-currencyswitcher/woocommerce-aelia-currencyswitcher.php', 'rocket_deactivate_aelia_currencyswitcher', 11 );
|
||||
|
||||
/**
|
||||
* Add the Aelia Currency Switcher cookies to the dynamic cookies list
|
||||
*
|
||||
* @since 2.7
|
||||
*
|
||||
* @param array $cookies Cookies to use for dynamic caching.
|
||||
* @return array Updated cookies list
|
||||
*/
|
||||
function rocket_add_aelia_currencyswitcher_dynamic_cookies( $cookies ) {
|
||||
$cookies[] = 'aelia_cs_recalculate_cart_totals';
|
||||
$cookies[] = 'aelia_cs_selected_currency';
|
||||
$cookies[] = 'aelia_customer_country';
|
||||
return $cookies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the Aelia Currency Switcher to the list of mandatory cookies before generating caching files
|
||||
*
|
||||
* @since 2.7
|
||||
*
|
||||
* @param array $cookies Mandatory cookies to serve the cache.
|
||||
* @return array Updated cookies list
|
||||
*/
|
||||
function rocket_add_aelia_currencyswitcher_mandatory_cookie( $cookies ) {
|
||||
$acs_options = get_option( 'wc_aelia_currency_switcher' );
|
||||
|
||||
if ( ! empty( $acs_options['ipgeolocation_enabled'] ) ) {
|
||||
$cookies[] = 'aelia_cs_selected_currency';
|
||||
}
|
||||
|
||||
return $cookies;
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Compatibility with Aelia Prices by Country.
|
||||
*
|
||||
* @since 2.8.15
|
||||
*/
|
||||
if ( class_exists( 'Aelia\WC\PricesByCountry\WC_Aelia_Prices_By_Country' ) ) :
|
||||
/**
|
||||
* Generate a caching file depending on the country cookie value
|
||||
*/
|
||||
add_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 66 );
|
||||
add_filter( 'rocket_cache_dynamic_cookies', 'rocket_add_aelia_prices_by_country_dynamic_cookies' );
|
||||
endif;
|
||||
|
||||
/**
|
||||
* Add cookie when we activate the plugin
|
||||
*
|
||||
* @since 2.8.15
|
||||
* @author Remy Perona
|
||||
*/
|
||||
function rocket_activate_aelia_prices_by_country() {
|
||||
add_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 66 );
|
||||
add_filter( 'rocket_cache_dynamic_cookies', 'rocket_add_aelia_prices_by_country_dynamic_cookies' );
|
||||
|
||||
// Update the WP Rocket rules on the .htaccess file.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'activate_woocommerce-prices-by-country/woocommerce-prices-by-country.php', 'rocket_activate_aelia_prices_by_country', 11 );
|
||||
|
||||
/**
|
||||
* Remove cookies when we deactivate the plugin
|
||||
*
|
||||
* @since 2.8.15
|
||||
* @author Remy Perona
|
||||
*/
|
||||
function rocket_deactivate_aelia_prices_by_country() {
|
||||
remove_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 66 );
|
||||
remove_filter( 'rocket_cache_dynamic_cookies', 'rocket_add_aelia_prices_by_country_dynamic_cookies' );
|
||||
|
||||
// Update the WP Rocket rules on the .htaccess file.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'deactivate_woocommerce-prices-by-country/woocommerce-prices-by-country.php', 'rocket_deactivate_aelia_prices_by_country', 11 );
|
||||
|
||||
/**
|
||||
* Add the Aelia Prices by Country cookie to generate caching files depending on its value
|
||||
*
|
||||
* @since 2.8.15
|
||||
* @author Remy Perona
|
||||
*
|
||||
* @param array $cookies Cookies list to use for dynamic caching.
|
||||
* @return array Updated cookies list
|
||||
*/
|
||||
function rocket_add_aelia_prices_by_country_dynamic_cookies( $cookies ) {
|
||||
$cookies[] = 'aelia_customer_country';
|
||||
return $cookies;
|
||||
}
|
||||
Vendored
+69
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Compatibility with Aelia Tax Display by Country.
|
||||
*
|
||||
* @since 2.8.15
|
||||
*/
|
||||
if ( class_exists( 'Aelia\WC\TaxDisplayByCountry\WC_Aelia_Tax_Display_By_Country' ) ) :
|
||||
/**
|
||||
* Generate a caching file depending to the tax display cookie values
|
||||
*/
|
||||
add_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 68 );
|
||||
add_filter( 'rocket_cache_dynamic_cookies', 'rocket_add_aelia_tax_display_by_country_dynamic_cookies' );
|
||||
endif;
|
||||
|
||||
/**
|
||||
* Add cookies when we activate the plugin
|
||||
*
|
||||
* @since 2.8.15
|
||||
* @author Remy Perona
|
||||
*/
|
||||
function rocket_activate_aelia_tax_display_by_country() {
|
||||
add_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 68 );
|
||||
add_filter( 'rocket_cache_dynamic_cookies', 'rocket_add_aelia_tax_display_by_country_dynamic_cookies' );
|
||||
|
||||
// Update the WP Rocket rules on the .htaccess file.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'activate_woocommerce-tax-display-by-country/woocommerce-tax-display-by-country.php', 'rocket_activate_aelia_tax_display_by_country', 11 );
|
||||
|
||||
/**
|
||||
* Remove cookies when we deactivate the plugin
|
||||
*
|
||||
* @since 2.8.15
|
||||
* @author Remy Perona
|
||||
*/
|
||||
function rocket_deactivate_aelia_tax_display_by_country() {
|
||||
remove_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 68 );
|
||||
remove_filter( 'rocket_cache_dynamic_cookies', 'rocket_add_aelia_tax_display_by_country_dynamic_cookies' );
|
||||
|
||||
// Update the WP Rocket rules on the .htaccess file.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'deactivate_woocommerce-tax-display-by-country/woocommerce-tax-display-by-country.php', 'rocket_deactivate_aelia_tax_display_by_country', 11 );
|
||||
|
||||
/**
|
||||
* Add the Aelia Tax Display by Country cookies to generate caching files depending on their values
|
||||
*
|
||||
* @since 2.8.15
|
||||
* @author Remy Perona
|
||||
*
|
||||
* @param array $cookies Cookies list to use for dynamic caching.
|
||||
* @return array Updated cookies list
|
||||
*/
|
||||
function rocket_add_aelia_tax_display_by_country_dynamic_cookies( $cookies ) {
|
||||
$cookies[] = 'aelia_customer_country';
|
||||
$cookies[] = 'aelia_customer_state';
|
||||
$cookies[] = 'aelia_tax_exempt';
|
||||
|
||||
return $cookies;
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( function_exists( 'EDD' ) ) :
|
||||
add_filter( 'rocket_cache_reject_uri', 'rocket_exclude_edd_pages' );
|
||||
add_action( 'update_option_edd_settings', 'rocket_after_update_array_options', 10, 2 );
|
||||
endif;
|
||||
|
||||
/**
|
||||
* Exclude EDD pages from cache
|
||||
*
|
||||
* @param array $urls Array of URLs to exclude from cache.
|
||||
* @return array Updated array of URLs
|
||||
*/
|
||||
function rocket_exclude_edd_pages( $urls ) {
|
||||
$edd_settings = get_option( 'edd_settings' );
|
||||
if ( isset( $edd_settings['purchase_page'] ) ) {
|
||||
$checkout_urls = get_rocket_i18n_translated_post_urls( $edd_settings['purchase_page'], 'page', '(.*)' );
|
||||
$urls = array_merge( $urls, $checkout_urls );
|
||||
}
|
||||
|
||||
return $urls;
|
||||
}
|
||||
|
||||
/**
|
||||
* Exclude EDD pages from cache on EDD activation.
|
||||
*/
|
||||
function rocket_activate_edd() {
|
||||
add_filter( 'rocket_cache_reject_uri', 'rocket_exclude_edd_pages' );
|
||||
|
||||
// Update .htaccess file rules.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'activate_easy-digital-downloads/easy-digital-downloads.php', 'rocket_activate_edd', 11 );
|
||||
|
||||
/**
|
||||
* Remove EDD pages from cache exclusion on EDD deactivation.
|
||||
*/
|
||||
function rocket_deactivate_edd() {
|
||||
remove_filter( 'rocket_cache_reject_uri', 'rocket_exclude_edd_pages' );
|
||||
|
||||
// Update .htaccess file rules.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'deactivate_easy-digital-downloads/easy-digital-downloads.php', 'rocket_deactivate_edd', 11 );
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Compatibility with Easy Digital Downloads Software Licensing addon.
|
||||
*
|
||||
* @since 2.7
|
||||
*/
|
||||
if ( class_exists( 'EDD_Software_Licensing' ) && defined( 'EDD_SL_VERSION' ) ) :
|
||||
// Exclude EDD SL endpoint from cache on WP Rocket activation.
|
||||
add_filter( 'rocket_cache_reject_uri', 'rocket_exclude_edd_sl_endpoint' );
|
||||
endif;
|
||||
|
||||
/**
|
||||
* Exclude EDD SL endpoint from cache when activating the plugin
|
||||
*
|
||||
* @since 2.7
|
||||
*/
|
||||
function rocket_activate_edd_software_licensing() {
|
||||
add_filter( 'rocket_cache_reject_uri', 'rocket_exclude_edd_sl_endpoint' );
|
||||
|
||||
// Update the WP Rocket rules on the .htaccess file.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'activate_edd-software-licensing/edd-software-licenses.php', 'rocket_activate_edd_software_licensing', 11 );
|
||||
|
||||
/**
|
||||
* Remove exclusion of EDD SL endpoint from cache when deactivating the plugin
|
||||
*
|
||||
* @since 2.7
|
||||
*/
|
||||
function rocket_deactivate_edd_software_licensing() {
|
||||
remove_filter( 'rocket_cache_reject_uri', 'rocket_exclude_edd_sl_endpoint' );
|
||||
|
||||
// Update the WP Rocket rules on the .htaccess file.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'deactivate_edd-software-licensing/edd-software-licenses.php', 'rocket_deactivate_edd_software_licensing', 11 );
|
||||
|
||||
/**
|
||||
* Exclude EDD SL endpoint from caching
|
||||
*
|
||||
* @since 2.7
|
||||
*
|
||||
* @param array $uri URLs to exclude from caching.
|
||||
* @return array Updated list of URLs to exclude
|
||||
*/
|
||||
function rocket_exclude_edd_sl_endpoint( $uri ) {
|
||||
$uri[] = '/edd-sl/(.*)';
|
||||
return $uri;
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Exclude pages of Give plugin from cache.
|
||||
*
|
||||
* @since 2.7
|
||||
*/
|
||||
if ( defined( 'GIVE_VERSION' ) && function_exists( 'give_get_settings' ) ) {
|
||||
add_filter( 'rocket_cache_reject_uri', 'rocket_add_give_exclude_pages' );
|
||||
|
||||
if ( is_admin() ) {
|
||||
add_action( 'update_option_give_settings', 'rocket_after_update_single_options', 10, 2 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add give pages to the excluded pages
|
||||
*
|
||||
* @since 2.7
|
||||
*
|
||||
* @param Array $urls Array of excluded pages.
|
||||
* @return Array Updated array of excluded pages
|
||||
*/
|
||||
function rocket_add_give_exclude_pages( $urls ) {
|
||||
$give_options = give_get_settings();
|
||||
$urls = array_merge( $urls, get_rocket_i18n_translated_post_urls( $give_options['success_page'], 'page' ) );
|
||||
$urls = array_merge( $urls, get_rocket_i18n_translated_post_urls( $give_options['history_page'], 'page' ) );
|
||||
$urls = array_merge( $urls, get_rocket_i18n_translated_post_urls( $give_options['failure_page'], 'page' ) );
|
||||
|
||||
return $urls;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add give pages to the excluded pages when activating the plugin
|
||||
*
|
||||
* @since 2.7
|
||||
*/
|
||||
function rocket_activate_give() {
|
||||
add_filter( 'rocket_cache_reject_uri', 'rocket_add_give_exclude_pages' );
|
||||
|
||||
// Update the WP Rocket rules on the .htaccess.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'activate_give/give.php', 'rocket_activate_give', 11 );
|
||||
|
||||
/**
|
||||
* Remove give pages from the excluded pages when activating the plugin
|
||||
*
|
||||
* @since 2.7
|
||||
*/
|
||||
function rocket_remove_give_exclude_pages() {
|
||||
remove_filter( 'rocket_cache_reject_uri', 'rocket_add_give_exclude_pages' );
|
||||
|
||||
// Update the WP Rocket rules on the .htaccess.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'deactivate_give/give.php', 'rocket_remove_give_exclude_pages', 11 );
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( function_exists( 'it_exchange_get_page_type' ) && function_exists( 'it_exchange_get_page_url' ) ) :
|
||||
add_filter( 'rocket_cache_reject_uri', 'rocket_exclude_ithemes_exchange_pages' );
|
||||
add_action( 'update_option_it-storage-exchange_settings_pages', 'rocket_after_update_single_options', 10, 2 );
|
||||
endif;
|
||||
|
||||
|
||||
/**
|
||||
* Exclude iThemes Exchange pages from cache.
|
||||
*
|
||||
* @param array $urls Array of URLs to exclude from cache.
|
||||
* @return array Updated array of URLs to exclude from cache
|
||||
*/
|
||||
function rocket_exclude_ithemes_exchange_pages( $urls ) {
|
||||
$pages = [
|
||||
'purchases',
|
||||
'confirmation',
|
||||
'account',
|
||||
'profile',
|
||||
'downloads',
|
||||
'purchases',
|
||||
'log-in',
|
||||
'log-out',
|
||||
];
|
||||
|
||||
foreach ( $pages as $page ) {
|
||||
if ( it_exchange_get_page_type( $page ) === 'WordPress' ) {
|
||||
$exchange_urls = get_rocket_i18n_translated_post_urls( it_exchange_get_page_wpid( $page ) );
|
||||
} else {
|
||||
$exchange_urls = [ rocket_extract_url_component( it_exchange_get_page_url( $page ), PHP_URL_PATH ) ];
|
||||
}
|
||||
|
||||
$urls = array_merge( $urls, $exchange_urls );
|
||||
}
|
||||
|
||||
return $urls;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Exclude iThemes Exchanges pages from cache on plugin activation.
|
||||
*/
|
||||
function rocket_activate_ithemes_exchange() {
|
||||
add_filter( 'rocket_cache_reject_uri', 'rocket_exclude_ithemes_exchange_pages' );
|
||||
|
||||
// Update .htaccess file rules.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'activate_ithemes-exchange/ithemes-exchange.php', 'rocket_activate_ithemes_exchange', 11 );
|
||||
|
||||
/**
|
||||
* Remove iThemes Exchanges pages from cache exclusion on plugin deactivation.
|
||||
*/
|
||||
function rocket_deactivate_ithemes_exchange() {
|
||||
remove_filter( 'rocket_cache_reject_uri', 'rocket_exclude_ithemes_exchange_pages' );
|
||||
|
||||
// Update .htaccess file rules.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'deactivate_ithemes-exchange/ithemes-exchange.php', 'rocket_deactivate_ithemes_exchange', 11 );
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( defined( 'JIGOSHOP_VERSION' ) && function_exists( 'jigoshop_get_page_id' ) ) :
|
||||
add_filter( 'rocket_cache_reject_uri', 'rocket_exclude_jigoshop_pages' );
|
||||
add_action( 'update_option_jigoshop_options', 'rocket_after_update_array_options', 10, 2 );
|
||||
endif;
|
||||
|
||||
/**
|
||||
* Exclude Jigoshop pages from cache.
|
||||
*
|
||||
* @param array $urls Array of URLs to exclude from cache.
|
||||
* @return array Updated array of URLs to exclude from cache
|
||||
*/
|
||||
function rocket_exclude_jigoshop_pages( $urls ) {
|
||||
if ( jigoshop_get_page_id( 'checkout' ) && jigoshop_get_page_id( 'checkout' ) !== '-1' ) {
|
||||
$checkout_urls = get_rocket_i18n_translated_post_urls( jigoshop_get_page_id( 'checkout' ), 'page', '(.*)' );
|
||||
$urls = array_merge( $urls, $checkout_urls );
|
||||
}
|
||||
|
||||
if ( jigoshop_get_page_id( 'cart' ) && jigoshop_get_page_id( 'cart' ) !== '-1' ) {
|
||||
$cart_urls = get_rocket_i18n_translated_post_urls( jigoshop_get_page_id( 'cart' ) );
|
||||
$urls = array_merge( $urls, $cart_urls );
|
||||
}
|
||||
|
||||
if ( jigoshop_get_page_id( 'myaccount' ) && jigoshop_get_page_id( 'myaccount' ) !== '-1' ) {
|
||||
$cart_urls = get_rocket_i18n_translated_post_urls( jigoshop_get_page_id( 'myaccount' ), 'page', '(.*)' );
|
||||
$urls = array_merge( $urls, $cart_urls );
|
||||
}
|
||||
|
||||
return $urls;
|
||||
}
|
||||
|
||||
/**
|
||||
* Exclude Jigoshop pages from cache on plugin activation.
|
||||
*/
|
||||
function rocket_activate_jigoshop() {
|
||||
add_filter( 'rocket_cache_reject_uri', 'rocket_exclude_jigoshop_pages' );
|
||||
|
||||
// Update .htaccess file rules.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'activate_jigoshop/jigoshop.php', 'rocket_activate_jigoshop', 11 );
|
||||
|
||||
/**
|
||||
* Remove Jigoshop pages from cache exclusion on plugin deactivation.
|
||||
*/
|
||||
function rocket_deactivate_jigoshop() {
|
||||
remove_filter( 'rocket_cache_reject_uri', 'rocket_exclude_jigoshop_pages' );
|
||||
|
||||
// Update .htaccess file rules.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'deactivate_jigoshop/jigoshop.php', 'rocket_deactivate_jigoshop', 11 );
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Compatibility with WooCommerce Currency Converter Widget.
|
||||
*
|
||||
* @since 2.7
|
||||
*/
|
||||
if ( class_exists( 'WC_Currency_Converter' ) ) :
|
||||
// Add cookie to config file when WP Rocket is activated and WooCommerce Currency Converter Widget is already active.
|
||||
add_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 70 );
|
||||
add_filter( 'rocket_cache_dynamic_cookies', 'rocket_add_woocommerce_currency_converter_dynamic_cookies', 11 );
|
||||
add_filter( 'rocket_cache_mandatory_cookies', 'rocket_add_woocommerce_currency_converter_mandatory_cookie', 11 );
|
||||
add_action( 'update_option_woocommerce_default_customer_address', 'rocket_after_update_single_options', 10, 2 );
|
||||
endif;
|
||||
|
||||
/**
|
||||
* Add cookies when we activating the plugin
|
||||
*
|
||||
* @since 2.7
|
||||
*/
|
||||
function rocket_activate_woocommerce_currency_converter() {
|
||||
add_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 70 );
|
||||
add_filter( 'rocket_cache_dynamic_cookies', 'rocket_add_woocommerce_currency_converter_dynamic_cookies' );
|
||||
add_filter( 'rocket_cache_mandatory_cookies', 'rocket_add_woocommerce_currency_converter_mandatory_cookie' );
|
||||
|
||||
// Update the WP Rocket rules on the .htaccess file.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'activate_woocommerce-currency-converter-widget/currency-converter.php', 'rocket_activate_woocommerce_currency_converter', 11 );
|
||||
|
||||
/**
|
||||
* Remove cookies when deactivating the plugin
|
||||
*
|
||||
* @since 2.7
|
||||
*/
|
||||
function rocket_deactivate_woocommerce_currency_converter() {
|
||||
remove_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 70 );
|
||||
remove_filter( 'rocket_cache_dynamic_cookies', 'rocket_add_woocommerce_currency_converter_dynamic_cookies' );
|
||||
remove_filter( 'rocket_cache_mandatory_cookies', 'rocket_add_woocommerce_currency_converter_mandatory_cookie' );
|
||||
|
||||
// Update the WP Rocket rules on the .htaccess file.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'deactivate_woocommerce-currency-converter-widget/currency-converter.php', 'rocket_deactivate_woocommerce_currency_converter', 11 );
|
||||
|
||||
/**
|
||||
* Add the WC Currency Converter Widget cookie to generate caching files depending on its value
|
||||
*
|
||||
* @since 2.7
|
||||
*
|
||||
* @param array $cookies Cookies list to use for dynamic caching.
|
||||
* @return array Updated cookies list
|
||||
*/
|
||||
function rocket_add_woocommerce_currency_converter_dynamic_cookies( $cookies ) {
|
||||
$cookies[] = 'woocommerce_current_currency';
|
||||
return $cookies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the WC Currency Converter Widget cookie to the list of mandatory cookies before generating the caching files
|
||||
*
|
||||
* @since 2.7
|
||||
*
|
||||
* @param array $cookies Mandatory cookies list.
|
||||
* @return array Updated cookies list
|
||||
*/
|
||||
function rocket_add_woocommerce_currency_converter_mandatory_cookie( $cookies ) {
|
||||
$widget_woocommerce_currency_converter = get_option( 'widget_woocommerce_currency_converter' );
|
||||
|
||||
if ( ! empty( $widget_woocommerce_currency_converter ) && 'geolocation_ajax' === get_option( 'woocommerce_default_customer_address' ) ) {
|
||||
$cookies[] = 'woocommerce_current_currency';
|
||||
}
|
||||
|
||||
return $cookies;
|
||||
}
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Check if WCML is active and has minimum requirements.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function rocket_wcml_has_requirements() {
|
||||
return defined( 'ICL_SITEPRESS_VERSION' )
|
||||
&& version_compare( ICL_SITEPRESS_VERSION, '4.4.11', '>=' )
|
||||
&& defined( 'WCML_VERSION' )
|
||||
&& version_compare( WCML_VERSION, '4.12.6', '>=' );
|
||||
}
|
||||
|
||||
if ( rocket_wcml_has_requirements() ) :
|
||||
/**
|
||||
* Use Cookie instead of WCSession
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function rocket_wcml_use_cookie_storage() {
|
||||
return 'cookie';
|
||||
}
|
||||
add_filter( 'wcml_user_store_strategy', 'rocket_wcml_use_cookie_storage', 10, 2 );
|
||||
|
||||
add_filter( 'rocket_cache_dynamic_cookies', 'rocket_wcml_add_dynamic_cookies' );
|
||||
add_filter( 'rocket_cache_mandatory_cookies', 'rocket_wcml_add_mandatory_cookies' );
|
||||
add_action( 'updated_option', 'rocket_wcml_reset_settings', 10, 3 );
|
||||
|
||||
/**
|
||||
* Reset WP Rocket settings on WCML deactivation.
|
||||
*/
|
||||
function rocket_wcml_deactivate() {
|
||||
remove_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 64 );
|
||||
remove_filter( 'rocket_cache_dynamic_cookies', 'rocket_wcml_add_dynamic_cookies' );
|
||||
remove_filter( 'rocket_cache_mandatory_cookies', 'rocket_wcml_add_mandatory_cookies' );
|
||||
flush_rocket_htaccess();
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'deactivate_woocommerce-multilingual/wpml-woocommerce.php', 'rocket_wcml_deactivate', 11 );
|
||||
|
||||
add_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 64 );
|
||||
|
||||
endif;
|
||||
|
||||
/**
|
||||
* Add dynamic cookies for WCML.
|
||||
*
|
||||
* @param array $cookies Cookies.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function rocket_wcml_add_dynamic_cookies( $cookies ) {
|
||||
$cookies[] = 'wcml_client_currency';
|
||||
$cookies[] = 'wcml_client_currency_language';
|
||||
$cookies[] = 'wcml_client_country';
|
||||
|
||||
return $cookies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add mandatory cookies for WCML.
|
||||
*
|
||||
* @param array $cookies Cookies.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function rocket_wcml_add_mandatory_cookies( $cookies ) {
|
||||
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
|
||||
if ( apply_filters( 'wcml_geolocation_is_used', false ) ) {
|
||||
// phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
|
||||
$cookies[] = 'wcml_client_country';
|
||||
}
|
||||
|
||||
return $cookies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset WP Rocket settings when a relevant WCML setting is changed.
|
||||
*
|
||||
* @param string $option Option name.
|
||||
* @param mixed $old_data Old data.
|
||||
* @param mixed $data New data.
|
||||
*/
|
||||
function rocket_wcml_reset_settings( $option, $old_data, $data ) {
|
||||
$keys_to_check = [
|
||||
'enable_multi_currency',
|
||||
'currency_mode',
|
||||
'default_currencies',
|
||||
];
|
||||
|
||||
$check_key = function ( $result, $key ) use ( $old_data, $data ) {
|
||||
$has_value_changed = function ( $key ) use ( $old_data, $data ) {
|
||||
$get_value = function ( $key, $data ) {
|
||||
return isset( $data[ $key ] ) ? $data[ $key ] : null;
|
||||
};
|
||||
|
||||
return $get_value( $key, $old_data ) !== $get_value( $key, $data );
|
||||
};
|
||||
|
||||
return $result || $has_value_changed( $key );
|
||||
};
|
||||
|
||||
if (
|
||||
'_wcml_settings' === $option
|
||||
&& array_reduce( $keys_to_check, $check_key, false )
|
||||
) {
|
||||
flush_rocket_htaccess();
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset WP Rocket settings on WCML activation.
|
||||
*/
|
||||
function rocket_wcml_activate() {
|
||||
if ( rocket_wcml_has_requirements() ) {
|
||||
add_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 64 );
|
||||
add_filter( 'rocket_cache_dynamic_cookies', 'rocket_wcml_add_dynamic_cookies' );
|
||||
add_filter( 'rocket_cache_mandatory_cookies', 'rocket_wcml_add_mandatory_cookies' );
|
||||
flush_rocket_htaccess();
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
}
|
||||
add_action( 'activate_woocommerce-multilingual/wpml-woocommerce.php', 'rocket_wcml_activate', 11 );
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( defined( 'WPSHOP_VERSION' ) && class_exists( 'wpshop_tools' ) && method_exists( 'wpshop_tools', 'get_page_id' ) ) :
|
||||
add_filter( 'rocket_cache_reject_uri', 'rocket_exclude_wpshop_pages' );
|
||||
add_action( 'update_option_wpshop_cart_page_id', 'rocket_after_update_single_options', 10, 2 );
|
||||
add_action( 'update_option_wpshop_checkout_page_id', 'rocket_after_update_single_options', 10, 2 );
|
||||
add_action( 'update_option_wpshop_payment_return_page_id', 'rocket_after_update_single_options', 10, 2 );
|
||||
add_action( 'update_option_wpshop_payment_return_nok_page_id', 'rocket_after_update_single_options', 10, 2 );
|
||||
add_action( 'update_option_wpshop_myaccount_page_id', 'rocket_after_update_single_options', 10, 2 );
|
||||
endif;
|
||||
|
||||
|
||||
/**
|
||||
* Exclude WP Shop pages from cache.
|
||||
*
|
||||
* @param array $urls Array of URLs to exclude from cache.
|
||||
* @return array Updated array of URLs to exclude from cache
|
||||
*/
|
||||
function rocket_exclude_wpshop_pages( $urls ) {
|
||||
$pages = [
|
||||
'wpshop_cart_page_id',
|
||||
'wpshop_checkout_page_id',
|
||||
'wpshop_payment_return_page_id',
|
||||
'wpshop_payment_return_nok_page_id',
|
||||
'wpshop_myaccount_page_id',
|
||||
];
|
||||
|
||||
foreach ( $pages as $page ) {
|
||||
$page_id = wpshop_tools::get_page_id( get_option( $page ) );
|
||||
if ( $page_id ) {
|
||||
$urls = array_merge( $urls, get_rocket_i18n_translated_post_urls( $page_id ) );
|
||||
}
|
||||
}
|
||||
|
||||
return $urls;
|
||||
}
|
||||
|
||||
/**
|
||||
* Exclude WP Shop pages from cache on plugin activation.
|
||||
*/
|
||||
function rocket_activate_wpshop() {
|
||||
add_filter( 'rocket_cache_reject_uri', 'rocket_exclude_wpshop_pages' );
|
||||
|
||||
// Update .htaccess file rules.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'activate_wpshop/wpshop.php', 'rocket_activate_wpshop', 11 );
|
||||
|
||||
/**
|
||||
* Remove WP Shop pages from cache exclusion on plugin deactivation.
|
||||
*/
|
||||
function rocket_deactivate_wpshop() {
|
||||
remove_filter( 'rocket_cache_reject_uri', 'rocket_exclude_wpshop_pages' );
|
||||
|
||||
// Update .htaccess file rules.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'deactivate_wpshop/wpshop.php', 'rocket_deactivate_wpshop', 11 );
|
||||
Reference in New Issue
Block a user