urrent_blog_id();
foreach ( $blog_ids as $blog_id ) {
switch_to_blog( $blog_id );
$this->do_2_2_settings_update();
}
switch_to_blog( $original_blog_id );
}
}
/**
* Helper for 2.2 autoptimize_extra_settings upgrade to avoid duplicate code
*/
private function do_2_2_settings_update()
{
$nogooglefont = autoptimizeOptionWrapper::get_option( 'autoptimize_css_nogooglefont', '' );
$ao_extrasetting = autoptimizeOptionWrapper::get_option( 'autoptimize_extra_settings', '' );
if ( ( $nogooglefont ) && ( empty( $ao_extrasetting ) ) ) {
autoptimizeOptionWrapper::update_option( 'autoptimize_extra_settings', autoptimizeConfig::get_ao_extra_default_options() );
}
delete_option( 'autoptimize_css_nogooglefont' );
}
/**
* 2.4.2 introduced too many cronned ao_cachecheckers, make this right
*/
private function upgrade_from_2_4_2() {
// below code by Thomas Sjolshagen (http://eighty20results.com/)
// as found on https://www.paidmembershipspro.com/deleting-oldextra-cron-events/.
$jobs = _get_cron_array();
// Remove all ao_cachechecker cron jobs (for now).
foreach ( $jobs as $when => $job ) {
$name = key( $job );
if ( false !== strpos( $name, 'ao_cachechecker' ) ) {
unset( $jobs[ $when ] );
}
}
// Save the data.
_set_cron_array( $jobs );
}
/**
* Migrate imgopt options from autoptimize_extra_settings to autoptimize_imgopt_settings
*/
private function upgrade_from_2_4() {
$extra_settings = autoptimizeOptionWrapper::get_option( 'autoptimize_extra_settings', '' );
$imgopt_settings = autoptimizeOptionWrapper::get_option( 'autoptimize_imgopt_settings', '' );
if ( empty( $imgopt_settings ) && ! empty( $extra_settings ) ) {
$imgopt_settings = autoptimizeConfig::get_ao_imgopt_default_options();
if ( array_key_exists( 'autoptimize_extra_checkbox_field_5', $extra_settings ) ) {
$imgopt_settings['autoptimize_imgopt_checkbox_field_1'] = $extra_settings['autoptimize_extra_checkbox_field_5'];
}
if ( array_key_exists( 'autoptimize_extra_select_field_6', $extra_settings ) ) {
$imgopt_settings['autoptimize_imgopt_select_field_2'] = $extra_settings['autoptimize_extra_select_field_6'];
}
autoptimizeOptionWrapper::update_option( 'autoptimize_imgopt_settings', $imgopt_settings );
}
}
/**
* Remove CCSS request limit option + update jquery exclusion to include WordPress 5.6 jquery.min.js.
*/
private function upgrade_from_2_7() {
delete_option( 'autoptimize_ccss_rlimit' );
$js_exclusions = get_option( 'autoptimize_js_exclude', '' );
if ( strpos( $js_exclusions, 'js/jquery/jquery.js' ) !== false && strpos( $js_exclusions, 'js/jquery/jquery.min.js' ) === false ) {
$js_exclusions .= ', js/jquery/jquery.min.js';
autoptimizeOptionWrapper::update_option( 'autoptimize_js_exclude', $js_exclusions );
}
}
/**
* Set an option to indicate the AO installation predates the compatibility logic, this way we
* can avoid adding compatibility code that is likely not needed and maybe not wanted as it
* can introduce performance regressions.
*/
private function upgrade_from_2_9_before_compatibility() {
autoptimizeOptionWrapper::update_option( 'autoptimize_installed_before_compatibility', true );
}
/**
* If the 404 handler is active, delete the current PHP-file so it can be re-created to fix the double underscore bug.
*/
private function upgrade_from_3_1() {
if ( autoptimizeCache::do_fallback() && version_compare( autoptimizeOptionWrapper::get_option( 'autoptimize_version', 'none' ), '3.1.2', 'lt' ) ) {
$_fallback_php = trailingslashit( WP_CONTENT_DIR ) . 'autoptimize_404_handler.php';
@unlink( $_fallback_php ); // @codingStandardsIgnoreLine
}
}
}