Skip to content

Commit

Permalink
Merge branch 'develop' into enhancement/6007-rankmath
Browse files Browse the repository at this point in the history
  • Loading branch information
Tabrisrp committed Jul 11, 2023
2 parents a60fc33 + 4c697c3 commit 6fa6afa
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 9 deletions.
2 changes: 1 addition & 1 deletion inc/Engine/Optimization/DelayJS/Admin/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public function maybe_disable_combine_js( $value, $old_value ): array {
public static function get_delay_js_default_exclusions(): array {

$exclusions = [
'\/jquery(-migrate)?-?([0-9.]+)?(.min|.slim|.slim.min)?.js(\?(.*))?$',
'\/jquery(-migrate)?-?([0-9.]+)?(.min|.slim|.slim.min)?.js(\?(.*))?( |\'|"|>)',
'js-(before|after)',
];

Expand Down
38 changes: 38 additions & 0 deletions inc/ThirdParty/Plugins/Ecommerce/WooCommerceSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ public static function get_subscribed_events() {

$events['wp_head'] = 'show_empty_product_gallery_with_delayJS';
$events['rocket_delay_js_exclusions'] = 'show_notempty_product_gallery_with_delayJS';

$events['wp_ajax_woocommerce_product_ordering'] = [ 'disallow_rocket_clean_post', 9 ];
$events['woocommerce_after_product_ordering'] = [ 'allow_rocket_clean_post' ];
}

if ( class_exists( 'WC_API' ) ) {
Expand Down Expand Up @@ -592,4 +595,39 @@ public function show_notempty_product_gallery_with_delayJS( $exclusions = [] ):

return array_merge( $exclusions, $exclusions_gallery );
}

/**
* Disable post cache clearing during product sorting.
*
* @return void
*/
public function disallow_rocket_clean_post() : void {
$this->event_manager->remove_callback( 'clean_post_cache', 'rocket_clean_post' );
}

/**
* Re-enable post cache clearing after product sorting.
*
* @param integer $product_id ID of sorted product.
* @return void
*/
public function allow_rocket_clean_post( int $product_id ) : void {
$urls = [];
$category_list = wc_get_product_category_list( $product_id );

if ( preg_match_all( '/<a\s+(?:[^>]*?\s+)?href=(["\'])(?<urls>.*?)\1/i', $category_list, $matches ) ) {
$urls = $matches['urls'];
}

$shop_page = get_permalink( wc_get_page_id( 'shop' ) );

if ( empty( $shop_page ) ) {
$shop_page = home_url( 'shop' );
}

$urls[] = $shop_page;

rocket_clean_files( $urls );
$this->event_manager->add_callback( 'clean_post_cache', 'rocket_clean_post' );
}
}
2 changes: 1 addition & 1 deletion inc/ThirdParty/Plugins/Optimization/Ezoic.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function add_conflict_explanations( $plugins_explanations ) {
$plugins_explanations['ezoic'] = sprintf(
// translators: %1$s = opening <a> tag, %2$s = closing </a> tag.
__( 'This plugin blocks WP Rocket\'s caching and optimizations. Deactivate it and use %1$sEzoic\'s nameserver integration%2$s instead.', 'rocket' ),
'<a href="https://support.ezoic.com/support/solutions/articles/48000453926-name-server-integration" target="_blank" rel="noopener noreferrer">',
'<a href="https://support.ezoic.com/kb/article/how-can-i-integrate-my-site-with-ezoic" target="_blank" rel="noopener noreferrer">',
'</a>'
);

Expand Down
2 changes: 1 addition & 1 deletion inc/ThirdParty/Themes/MinimalistBlogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static function get_subscribed_events() {
* @return array
*/
public function exclude_jquery_from_delay_js( array $exclusions = [] ) {
$exclusions[] = '\/jquery(-migrate)?-?([0-9.]+)?(.min|.slim|.slim.min)?.js(\?(.*))?$';
$exclusions[] = '\/jquery(-migrate)?-?([0-9.]+)?(.min|.slim|.slim.min)?.js(\?(.*))?( |\'|"|>)';
return $exclusions;
}
}
1 change: 1 addition & 0 deletions inc/admin/ui/notices.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ function rocket_plugins_to_deactivate() {
'add-expires-headers' => 'add-expires-headers/add-expires-headers.php',
'page-optimize' => 'page-optimize/page-optimize.php',
'psn-pagespeed-ninja' => 'psn-pagespeed-ninja/pagespeedninja.php',
'wp-optimize' => 'wp-optimize/wp-optimize.php',
'wp-asset-clean-up' => 'wp-asset-clean-up/wpacu.php',
'wp-asset-clean-up-pro' => 'wp-asset-clean-up-pro/wpacu.php',
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
'excluded' => []
],
'expected' => [
'\/jquery(-migrate)?-?([0-9.]+)?(.min|.slim|.slim.min)?.js(\?(.*))?$'
]
'\/jquery(-migrate)?-?([0-9.]+)?(.min|.slim|.slim.min)?.js(\?(.*))?( |\'|"|>)',
],
],
'testThemeShouldReturnExpected' => [
'config' => [
Expand All @@ -17,7 +17,7 @@
'excluded' => []
],
'expected' => [
'\/jquery(-migrate)?-?([0-9.]+)?(.min|.slim|.slim.min)?.js(\?(.*))?$'
]
]
'\/jquery(-migrate)?-?([0-9.]+)?(.min|.slim|.slim.min)?.js(\?(.*))?( |\'|"|>)',
],
],
];
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Test_Explanations extends TestCase {
public function testShouldReturnExpected() {
$plugins_explanations = [];
$expected = [
'ezoic' => 'This plugin blocks WP Rocket\'s caching and optimizations. Deactivate it and use <a href="https://support.ezoic.com/support/solutions/articles/48000453926-name-server-integration" target="_blank" rel="noopener noreferrer">Ezoic\'s nameserver integration</a> instead.',
'ezoic' => 'This plugin blocks WP Rocket\'s caching and optimizations. Deactivate it and use <a href="https://support.ezoic.com/kb/article/how-can-i-integrate-my-site-with-ezoic" target="_blank" rel="noopener noreferrer">Ezoic\'s nameserver integration</a> instead.',
];

$this->assertSame(
Expand Down

0 comments on commit 6fa6afa

Please sign in to comment.