Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.10.1 #4426

Merged
merged 31 commits into from
Oct 14, 2021
Merged

3.10.1 #4426

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c1edff0
Translate /languages/rocket.pot in fa_IR
transifex-integration[bot] Sep 15, 2021
3adb20e
Translate /languages/rocket.pot in pl_PL
transifex-integration[bot] Sep 21, 2021
d240e9e
Translate /languages/rocket.pot in pl_PL
transifex-integration[bot] Sep 21, 2021
0a11af7
Merge branch 'develop' into transifex
Tabrisrp Sep 29, 2021
67f5fad
remove extra capitalization
Tabrisrp Sep 29, 2021
24f3739
update with strings changes in 3.10
Tabrisrp Sep 29, 2021
8609818
Translate /languages/rocket.pot in pt_PT
transifex-integration[bot] Sep 30, 2021
3f52dd0
Translate /languages/rocket.pot in pt_PT
transifex-integration[bot] Sep 30, 2021
1d1baf1
Translate /languages/rocket.pot in pt_PT
transifex-integration[bot] Sep 30, 2021
c11a30a
Translate /languages/rocket.pot in fr_FR
transifex-integration[bot] Oct 1, 2021
c6c47e0
Translate /languages/rocket.pot in de_DE
transifex-integration[bot] Oct 1, 2021
7be70a3
Exclude inline javascript for urls_polylangREPLACETOID (PR #4329)
nicomollet Oct 1, 2021
aa6d48e
Exclude www.paypal.com/sdk/js from load JavaScript deferred (PR #4332)
DahmaniAdame Oct 1, 2021
d5eda82
Exclude inline JS from combine JS to avoid cache dir size issue (PR #…
alfonso100 Oct 1, 2021
f2d571f
Remove extra space in remove unused CSS field description (PR #4401)
Presskopp Oct 1, 2021
8779576
Translate /languages/rocket.pot in tr_TR
transifex-integration[bot] Oct 2, 2021
a32ee0e
Translate /languages/rocket.pot in fa_IR
transifex-integration[bot] Oct 2, 2021
30355ef
Translate /languages/rocket.pot in fr_FR
transifex-integration[bot] Oct 4, 2021
2cf17ab
Closes #4320 combine CSS divi 4.10 compatibility (PR #4377)
mostafa-hisham Oct 5, 2021
2d23ddb
Fixes #4366 Add new path of minified files for Uncode 2.5.0 (PR #4370)
benitolopez Oct 5, 2021
61b63a5
Exclude CallRail's script from JS Minification (PR #4405)
vmanthos Oct 6, 2021
31617ea
Fixes #4391 stop background processes before rollback and update (PR …
mostafa-hisham Oct 8, 2021
03ce80e
Add "Beta" to RUCSS UI Button (PR #4412)
iCaspar Oct 8, 2021
b7038dd
Fixes #4260 Update WooCommerce URL and ID for Beacon and Helpscout (P…
Tabrisrp Oct 8, 2021
5ad8bf6
Fixes #4374 prevent PHP fatal error by adding guard clauses if preg_r…
Tabrisrp Oct 8, 2021
f782c7a
Fixes #4397 Guard against preg_replace() errors when moving meta char…
Tabrisrp Oct 13, 2021
f51e591
Closes #4378 Reduce requests to Wistia (PR #4409)
Tabrisrp Oct 13, 2021
4f08f62
update version to 3.10.1
Tabrisrp Oct 13, 2021
4822180
update translations
Tabrisrp Oct 13, 2021
1cfc88a
Merge branch 'transifex' into develop
Tabrisrp Oct 13, 2021
fec6fa1
Fixes #4420 Exclude documentcloud.adobe.com/view-sdk/main.js from JS …
alfonso100 Oct 14, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions inc/3rd-party/themes/uncode.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
function rocket_exclude_js_uncode( $excluded_js ) {
$excluded_js[] = rocket_clean_exclude_file( get_template_directory_uri() . '/library/js/init.js' );
$excluded_js[] = rocket_clean_exclude_file( get_template_directory_uri() . '/library/js/min/init.min.js' );
$excluded_js[] = rocket_clean_exclude_file( get_template_directory_uri() . '/library/js/init.min.js' );
$excluded_js[] = rocket_clean_exclude_file( get_template_directory_uri() . '/library/js/ai-uncode.js' );
$excluded_js[] = rocket_clean_exclude_file( get_template_directory_uri() . '/library/js/min/ai-uncode.min.js' );
$excluded_js[] = rocket_clean_exclude_file( get_template_directory_uri() . '/library/js/ai-uncode.min.js' );

return $excluded_js;
}
Expand Down Expand Up @@ -56,6 +58,7 @@ function rocket_exclude_inline_js_uncode( $inline_js ) {
function rocket_exclude_defer_js_uncode( $exclude_defer_js ) {
$exclude_defer_js[] = rocket_clean_exclude_file( get_template_directory_uri() . '/library/js/init.js' );
$exclude_defer_js[] = rocket_clean_exclude_file( get_template_directory_uri() . '/library/js/min/init.min.js' );
$exclude_defer_js[] = rocket_clean_exclude_file( get_template_directory_uri() . '/library/js/init.min.js' );
return $exclude_defer_js;
}
add_filter( 'rocket_exclude_defer_js', 'rocket_exclude_defer_js_uncode' );
Expand Down
4 changes: 2 additions & 2 deletions inc/Engine/Admin/Beacon/Beacon.php
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,8 @@ public function get_suggest( $doc_id ) {
],
'ecommerce' => [
'en' => [
'id' => '555c619ce4b027e1978e1767',
'url' => 'https://docs.wp-rocket.me/article/75-is-wp-rocket-compatible-with-e-commerce-plugins/?utm_source=wp_plugin&utm_medium=wp_rocket',
'id' => '548f492de4b034fd4862493e',
'url' => 'https://docs.wp-rocket.me/article/27-using-wp-rocket-on-your-ecommerce-site/?utm_source=wp_plugin&utm_medium=wp_rocket',
],
'fr' => [
'id' => '568f8291c69791436155caea',
Expand Down
6 changes: 3 additions & 3 deletions inc/Engine/Admin/Settings/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -701,9 +701,9 @@ private function assets_section() {
'sanitize_callback' => 'sanitize_checkbox',
'options' => [
'remove_unused_css' => [
'label' => __( 'Remove Unused CSS', 'rocket' ),
'label' => __( 'Remove Unused CSS (Beta)', 'rocket' ),
// translators: %1$s = opening <a> tag, %2$s = closing </a> tag.
'description' => sprintf( __( 'Removes unused CSS per page and helps to reduce page size and HTTP requests. Recommended for best performance. Test thoroughly! %1$sMore info%2$s', 'rocket' ), '<a href="' . esc_url( $rucss_beacon['url'] ) . '" data-beacon-article="' . esc_attr( $rucss_beacon['id'] ) . '" target="_blank">', '</a>' ),
'description' => sprintf( __( 'Removes unused CSS per page and helps to reduce page size and HTTP requests. Recommended for best performance. Test thoroughly! %1$sMore info%2$s', 'rocket' ), '<a href="' . esc_url( $rucss_beacon['url'] ) . '" data-beacon-article="' . esc_attr( $rucss_beacon['id'] ) . '" target="_blank">', '</a>' ),
'warning' => [
'title' => __( 'We’re still working on it!', 'rocket' ),
'description' => __( 'This is a beta feature. We’re providing you early access but some changes might be added later on. If you notice any errors on your website, simply deactivate the feature.', 'rocket' ),
Expand All @@ -729,7 +729,7 @@ private function assets_section() {
],
],
'async_css' => [
'label' => __( 'Load CSS Asynchronously', 'rocket' ),
'label' => __( 'Load CSS asynchronously', 'rocket' ),
'description' => is_plugin_active( 'wp-criticalcss/wp-criticalcss.php' ) ?
// translators: %1$s = plugin name.
sprintf( _x( 'Load CSS asynchronously is currently handled by the %1$s plugin. If you want to use WP Rocket’s load CSS asynchronously option, disable the %1$s plugin.', 'WP Critical CSS compatibility', 'rocket' ), 'WP Critical CSS' ) :
Expand Down
21 changes: 17 additions & 4 deletions inc/Engine/CriticalPath/CriticalCSSSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ public static function get_subscribed_events() {
'switch_theme' => 'maybe_regenerate_cpcss',
'rocket_excluded_inline_js_content' => 'exclude_inline_js',
'before_delete_post' => 'delete_cpcss',
'admin_post_rocket_rollback' => [ 'stop_critical_css_generation', 9 ],
'wp_rocket_upgrade' => [ 'stop_critical_css_generation', 9 ],
];
// phpcs:enable WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned
}
Expand Down Expand Up @@ -300,10 +302,7 @@ public function stop_process_on_deactivation( $old_value, $value ) {
&&
0 === (int) $value['async_css']
) {
$this->critical_css->stop_generation();

delete_transient( 'rocket_critical_css_generation_process_running' );
delete_transient( 'rocket_critical_css_generation_process_complete' );
$this->stop_critical_css_generation();
}
}

Expand Down Expand Up @@ -729,4 +728,18 @@ private function should_async_css() {

return ! is_rocket_post_excluded_option( 'async_css' );
}

/**
* Stops the critical CSS generation.
*
* @since 3.10
*
* @return void
*/
public function stop_critical_css_generation() {

$this->critical_css->stop_generation();
delete_transient( 'rocket_critical_css_generation_process_running' );
delete_transient( 'rocket_critical_css_generation_process_complete' );
}
}
1 change: 1 addition & 0 deletions inc/Engine/Optimization/DeferJS/DeferJS.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ public function get_excluded() : array {
'/wp-includes/js/dist/vendor/wp-polyfill(.min)?.js',
'/wp-includes/js/dist/url(.min)?.js',
'/wp-includes/js/dist/hooks(.min)?.js',
'www.paypal.com/sdk/js',
];

$exclude_defer_js = array_unique( array_merge( $exclude_defer_js, $this->options->get( 'exclude_defer_js', [] ) ) );
Expand Down
45 changes: 36 additions & 9 deletions inc/Engine/Optimization/DelayJS/HTML.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,16 +216,43 @@ public function replace_scripts( $matches ): string {
*/
public function move_meta_charset_to_head( $html ): string {
$meta_pattern = "#<meta[^h]*(http-equiv[^=]*=[^\'\"]*[\'\" ]Content-Type[\'\"][ ]*[^>]*|)(charset[^=]*=[ ]*[\'\" ]*[^\'\"> ][^\'\">]+[^\'\"> ][\'\" ]*|charset[^=]*=*[^\'\"> ][^\'\">]+[^\'\"> ])([^>]*|)>(?=.*</head>)#Usmi";
if ( preg_match( $meta_pattern, $html, $matches ) ) {
$html = preg_replace( "$meta_pattern", '', $html );
if ( preg_match( '/<head\b/i', $html ) ) {
$html = preg_replace( '/(<head\b[^>]*?>)/i', "\${1}${matches[0]}", $html );
} elseif ( preg_match( '/<html\b/i', $html ) ) {
$html = preg_replace( '/(<html\b[^>]*?>)/i', "\${1}${matches[0]}", $html );
} else {
$html = preg_replace( '/(<\w+)/', "${matches[0]}\${1}", $html, 1 );

if ( ! preg_match( $meta_pattern, $html, $matches ) ) {
return $html;
}

$replaced_html = preg_replace( "$meta_pattern", '', $html );

if ( empty( $replaced_html ) ) {
return $html;
}

if ( preg_match( '/<head\b/i', $replaced_html ) ) {
$replaced_html = preg_replace( '/(<head\b[^>]*?>)/i', "\${1}${matches[0]}", $replaced_html, 1 );

if ( empty( $replaced_html ) ) {
return $html;
}

return $replaced_html;
}
return $html;

if ( preg_match( '/<html\b/i', $replaced_html ) ) {
$replaced_html = preg_replace( '/(<html\b[^>]*?>)/i', "\${1}${matches[0]}", $replaced_html, 1 );

if ( empty( $replaced_html ) ) {
return $html;
}

return $replaced_html;
}

$replaced_html = preg_replace( '/(<\w+)/', "${matches[0]}\${1}", $replaced_html, 1 );

if ( empty( $replaced_html ) ) {
return $html;
}

return $replaced_html;
}
}
16 changes: 13 additions & 3 deletions inc/Engine/Optimization/DelayJS/Subscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,23 @@ public function add_delay_js_script( $html ): string {

$lazyload_script = $this->filesystem->get_contents( rocket_get_constant( 'WP_ROCKET_PATH' ) . 'assets/js/lazyload-scripts.min.js' );

$replaced_html = $html;

if ( false !== $lazyload_script ) {
$html = preg_replace( $pattern, "$0<script>{$lazyload_script}</script>", $html, 1 );
$replaced_html = preg_replace( $pattern, "$0<script>{$lazyload_script}</script>", $replaced_html, 1 );

if ( empty( $replaced_html ) ) {
return $html;
}
}

$html = preg_replace( $pattern, '$0<script>' . $this->html->get_ie_fallback() . '</script>', $html, 1 );
$replaced_html = preg_replace( $pattern, '$0<script>' . $this->html->get_ie_fallback() . '</script>', $replaced_html, 1 );

if ( empty( $replaced_html ) ) {
return $html;
}

return $this->html->move_meta_charset_to_head( $html );
return $this->html->move_meta_charset_to_head( $replaced_html );
}

/**
Expand Down
2 changes: 2 additions & 0 deletions inc/Engine/Optimization/Minify/JS/AbstractJSOptimization.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ protected function get_excluded_external_file_path() {
'cdna.hubpeople.com/js/widget_standalone_two_modes.js',
's3.tradingview.com',
'www.vbt.io/ext/vbtforms.js',
'cdn.callrail.com',
'documentcloud.adobe.com/view-sdk/main.js',
];

$excluded_external = array_merge( $defaults, $this->options->get( 'exclude_js', [] ) );
Expand Down
2 changes: 2 additions & 0 deletions inc/Engine/Optimization/Minify/JS/Combine.php
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,8 @@ protected function get_excluded_inline_content() {
'WoocommerceWidget/woocommerceWidget.js',
'var ht_ctc_chat_var',
'spuvar',
'var wpilFrontend',
'urls_polylangREPLACETOID',
];

$excluded_inline = array_merge( $defaults, $this->options->get( 'exclude_inline_js', [] ) );
Expand Down
11 changes: 11 additions & 0 deletions inc/Engine/Optimization/RUCSS/Warmup/ResourceFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,4 +334,15 @@ private function decompress( string $data ): string {

return $decompressed;
}

/**
* Cancel resource fetcher process
*
* @since 3.10
*
* @return void
*/
public function cancel_resource_fetcher_process() {
$this->process->cancel_process();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,22 @@ private function prepare_js_content( string $contents ) : string {
* @return string
*/
private function get_resource_contents( array $resource ) : string {
$file_content = $resource['external'] ? $this->local_cache->get_content( $resource['url'] ) : $this->get_file_content( $resource['path'] );

$resource_path = ! empty( $resource['path'] ) ? $resource['path'] : '';

$file_content = ! empty( $resource['external'] ) ? $this->local_cache->get_content( $resource['url'] ) : $this->get_file_content( $resource_path );

// Minify the content if it's there.
if ( $file_content ) {
$file_content = 'js' === $resource['type'] ? $this->prepare_js_content( $file_content ) : $this->prepare_css_content( $resource['path'], $file_content );
$file_content = 'js' === $resource['type'] ? $this->prepare_js_content( $file_content ) : $this->prepare_css_content( $resource_path, $file_content );
}

if ( ! $file_content ) {
Logger::error(
'No file content.',
[
'RUCSS warmup process',
'path' => $resource['path'],
'path' => $resource_path,
]
);

Expand Down
20 changes: 16 additions & 4 deletions inc/Engine/Optimization/RUCSS/Warmup/Subscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,18 @@ public function __construct( Options_Data $options, ResourceFetcher $resource_fe
*/
public static function get_subscribed_events() : array {
return [
'rocket_buffer' => [ 'collect_resources', 11 ],
'rest_api_init' => 'register_routes',
'switch_theme' => 'restart_warmup_on_theme_change',
'init' => [
'rocket_buffer' => [ 'collect_resources', 11 ],
'rest_api_init' => 'register_routes',
'switch_theme' => 'restart_warmup_on_theme_change',
'init' => [
[ 'update_warmup_status_while_has_items', 10 ],
[ 'activate_optimization_on_warmup_completion', 11 ],
[ 'auto_stop_warmup_after_1hour', 12 ],
],
// The following priority should be less than 10.
'update_option_' . rocket_get_constant( 'WP_ROCKET_SLUG' ) => [ 'start_scanner', 9, 2 ],
'admin_post_rocket_rollback' => [ 'cancel_resource_fetching', 9 ],
'wp_rocket_upgrade' => [ 'cancel_resource_fetching', 9 ],
];
}

Expand Down Expand Up @@ -203,4 +205,14 @@ public function register_routes() {
$this->restwp->register_status_route();
}

/**
* Cancel resource fetching
*
* @since 3.10
*
* @return void
*/
public function cancel_resource_fetching() {
$this->resource_fetcher->cancel_resource_fetcher_process();
}
}
13 changes: 13 additions & 0 deletions inc/Engine/Preload/PreloadSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ public static function get_subscribed_events() {
'rocket_after_preload_after_purge_cache' => [
[ 'maybe_preload_mobile_homepage', 10, 3 ],
],
'admin_post_rocket_rollback' => [ 'stop_homepage_preload', 9 ],
'wp_rocket_upgrade' => [ 'stop_homepage_preload', 9 ],
];
}

Expand Down Expand Up @@ -385,4 +387,15 @@ public function do_admin_post_stop_preload() {
wp_safe_redirect( wp_get_referer() );
die();
}

/**
* Stops homepage preload.
*
* @since 3.10
*
* @return void
*/
public function stop_homepage_preload() {
$this->homepage_preloader->cancel_preload();
}
}
13 changes: 13 additions & 0 deletions inc/Engine/Preload/SitemapPreloadSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public static function get_subscribed_events() {
'pagely_cache_purge_after' => [ 'preload', 12 ],
'update_option_' . WP_ROCKET_SLUG => [ 'maybe_cancel_preload', 10, 2 ],
'admin_notices' => [ 'simplexml_notice' ],
'admin_post_rocket_rollback' => [ 'stop_sitemap_preload', 9 ],
'wp_rocket_upgrade' => [ 'stop_sitemap_preload', 9 ],
];
}

Expand Down Expand Up @@ -129,4 +131,15 @@ public function simplexml_notice() {
]
);
}

/**
* Stops sitemap preload.
*
* @since 3.10
*
* @return void
*/
public function stop_sitemap_preload() {
$this->sitemap_preload->cancel_preload();
}
}
28 changes: 27 additions & 1 deletion inc/ThirdParty/Themes/Divi.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,13 @@ public static function get_subscribed_events() {
if ( ! self::is_divi() ) {
return $events;
}

$events['rocket_exclude_js'] = 'exclude_js';
$events['rocket_maybe_disable_youtube_lazyload_helper'] = 'add_divi_to_description';

$events['wp_enqueue_scripts'] = 'disable_divi_jquery_body';

$events['rocket_exclude_css'] = 'exclude_css_from_combine';

return $events;
}

Expand Down Expand Up @@ -172,4 +174,28 @@ public function disable_divi_jquery_body() {
}

}

/**
* Excludes Divi's CSS files from CSS combination
*
* @since 3.10.1
*
* @param array $exclude_css An array of CSS to be excluded.
*
* @return array the updated array of paths
*/
public function exclude_css_from_combine( $exclude_css ) {

if ( ! (bool) $this->options->get( 'minify_concatenate_css', 0 ) ) {
return $exclude_css;
}

$wp_content = wp_parse_url( content_url( '/' ), PHP_URL_PATH );

if ( $wp_content ) {
$exclude_css[] = $wp_content . 'et-cache/(.*).css';
}

return $exclude_css;
}
}
Binary file modified languages/rocket-de_DE.mo
Binary file not shown.