'; // Re-open tags that WP's settings_errors() will close at end of notice box. $container = apply_filters( 'rocket_container', [] ); $invalid_exclusions_beacon = $container->get( 'beacon' )->get_suggest( 'invalid_exclusions' ); $error_message .= sprintf( '%3$s', $invalid_exclusions_beacon['url'], $invalid_exclusions_beacon['id'], __( 'More info', 'rocket' ) ); $errors = []; $rocket_settings_errors[] = [ 'setting' => 'general', 'code' => 'invalid_patterns', 'message' => __( 'WP Rocket: ', 'rocket' ) . $error_message, 'type' => 'error', ]; } // Clear WP Rocket database optimize cron if the setting has been modified. if ( ( isset( $newvalue['schedule_automatic_cleanup'], $oldvalue['schedule_automatic_cleanup'] ) && $newvalue['schedule_automatic_cleanup'] !== $oldvalue['schedule_automatic_cleanup'] ) || ( ( isset( $newvalue['automatic_cleanup_frequency'], $oldvalue['automatic_cleanup_frequency'] ) && $newvalue['automatic_cleanup_frequency'] !== $oldvalue['automatic_cleanup_frequency'] ) ) ) { if ( wp_next_scheduled( 'rocket_database_optimization_time_event' ) ) { wp_clear_scheduled_hook( 'rocket_database_optimization_time_event' ); } } // Regenerate the minify key if JS files have been modified. // phpcs:ignore Universal.Operators.StrictComparisons.LooseNotEqual if ( ( isset( $newvalue['minify_js'], $oldvalue['minify_js'] ) && $newvalue['minify_js'] != $oldvalue['minify_js'] ) || ( isset( $newvalue['exclude_js'], $oldvalue['exclude_js'] ) && $newvalue['exclude_js'] !== $oldvalue['exclude_js'] ) || ( isset( $oldvalue['cdn'] ) && ! isset( $newvalue['cdn'] ) || ! isset( $oldvalue['cdn'] ) && isset( $newvalue['cdn'] ) ) ) { $newvalue['minify_js_key'] = create_rocket_uniqid(); } // Checked the SSL option if the whole website is on SSL. if ( rocket_is_ssl_website() ) { $newvalue['cache_ssl'] = 1; } if ( 'local' === wp_get_environment_type() ) { $newvalue['optimize_css_delivery'] = 0; $newvalue['remove_unused_css'] = 0; $newvalue['async_css'] = 0; } if ( ! rocket_get_constant( 'WP_ROCKET_ADVANCED_CACHE' ) ) { rocket_generate_advanced_cache_file(); } $keys = get_transient( WP_ROCKET_SLUG ); if ( $keys ) { delete_transient( WP_ROCKET_SLUG ); $newvalue = array_merge( $newvalue, $keys ); } if ( ! $rocket_settings_errors ) { return $newvalue; } $transient_errors = get_transient( 'settings_errors' ); if ( ! $transient_errors || ! is_array( $transient_errors ) ) { $transient_errors = []; } $settings_errors = array_merge( $transient_errors, $rocket_settings_errors ); foreach ( $settings_errors as $error ) { add_settings_error( $error['setting'], $error['code'], $error['message'], $error['type'] ); } return $newvalue; } add_filter( 'pre_update_option_' . rocket_get_constant( 'WP_ROCKET_SLUG' ), 'rocket_pre_main_option', 10, 2 ); /** * Auto-activate the SSL cache if the website URL is updated with https protocol * * @since 2.7 * * @param array $old_value An array of previous options values. * @param array $value An array of submitted options values. */ function rocket_update_ssl_option_after_save_home_url( $old_value, $value ) { if ( $old_value === $value || get_rocket_option( 'cache_ssl' ) ) { return; } $scheme = rocket_extract_url_component( $value, PHP_URL_SCHEME ); update_rocket_option( 'cache_ssl', 'https' === $scheme ? 1 : 0 ); } add_action( 'update_option_home', 'rocket_update_ssl_option_after_save_home_url', 10, 2 );