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

Fixes #4868 Apply CDN to used CSS on output instead of on saving #4893

Merged
merged 9 commits into from
Apr 28, 2022
35 changes: 0 additions & 35 deletions inc/Engine/Optimization/RUCSS/Admin/Subscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ public static function get_subscribed_events() : array {
'rocket_input_sanitize' => [ 'sanitize_options', 14, 2 ],
'update_option_' . $slug => [
[ 'clean_used_css_and_cache', 9, 2 ],
[ 'clean_used_css_with_cdn', 9, 2 ],
[ 'maybe_set_processing_transient', 50, 2 ],
],
'switch_theme' => 'truncate_used_css',
Expand Down Expand Up @@ -326,40 +325,6 @@ public function clean_used_css_and_cache( $old_value, $value ) {
$this->set_notice_transient();
}

/**
* Truncate UsedCSS DB Table when CDN option is changed.
*
* @since 3.11
*
* @param array $old_value An array of submitted values for the settings.
* @param array $value An array of previous values for the settings.
*
* @return void
*/
public function clean_used_css_with_cdn( $old_value, $value ) {
if ( ! isset( $value['cdn'], $old_value['cdn'] ) ) {
return;
}

if ( empty( $value['remove_unused_css'] ) ) {
return;
}

if (
$value['cdn'] === $old_value['cdn']
&&
$value['cdn_cnames'] === $old_value['cdn_cnames']
&&
$value['cdn_zone'] === $old_value['cdn_zone']
) {
return;
}

$this->delete_used_css_rows();

$this->set_notice_transient();
}

/**
* Truncate used_css table when clicking on the dashboard button.
*
Expand Down
20 changes: 10 additions & 10 deletions inc/Engine/Optimization/RUCSS/Controller/UsedCSS.php
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,16 @@ private function hide_scripts( string $html ): string {
* @return string
*/
private function get_used_css_markup( UsedCSS_Row $used_css ): string {
$css = str_replace( '\\', '\\\\', $used_css->css );// Guard the backslashes before passing the content to preg_replace.
/**
* Filters Used CSS content before saving into DB.
*
* @since 3.9.0.2
*
* @param string $usedcss Used CSS.
*/
$css = apply_filters( 'rocket_usedcss_content', $used_css->css );

$css = str_replace( '\\', '\\\\', $css );// Guard the backslashes before passing the content to preg_replace.
$used_css_contents = $this->handle_charsets( $css, false );
return sprintf(
'<style id="wpr-usedcss">%s</style>',
Expand Down Expand Up @@ -576,15 +585,6 @@ public function check_job_status( int $id ) {

$css = $this->apply_font_display_swap( $job_details['contents']['shakedCSS'] );

/**
* Filters Used CSS content before saving into DB.
*
* @since 3.9.0.2
*
* @param string $usedcss Used CSS.
*/
$css = apply_filters( 'rocket_usedcss_content', $css );

$this->used_css_query->make_status_completed( $id, $css );

do_action( 'rocket_rucss_complete_job_status', $row_details->url, $job_details );
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.