1024, 'm' => 1048576, 'g' => 1073741824, ]; $memory_last_char = substr( $memory, -1 ); if ( array_key_exists( strtolower( $memory_last_char ), $memory_shorthands ) ) { $memory = (int) str_replace( $memory_last_char, '', $memory ) * $memory_shorthands[ strtolower( $memory_last_char ) ]; } if ( 268435456 > $memory ) { wp_raise_memory_limit(); } $time_limit = ini_get( 'max_execution_time' ); if ( 300 > $time_limit && 0 != $time_limit ) { @set_time_limit( 0 ); } } $this->available_languages = Fusion_Multilingual::get_available_languages(); $this->active_language = Fusion_Multilingual::get_active_language(); $this->default_language = Fusion_Multilingual::get_default_language(); // If English is used then make this first in array order. Also set starting language so that it is migrated first. if ( in_array( 'en', $this->available_languages ) ) { $en_array = [ 'en' ]; $en_key = array_search( 'en', $this->available_languages ); $available_languages_no_en = $this->available_languages; unset( $available_languages_no_en[ $en_key ] ); $this->available_languages = array_merge( $en_array, $available_languages_no_en ); $this->starting_language = 'en'; } else { // If not English then make default language first in array order. Also set it to be starting language for migration. $default_array = [ $this->default_language ]; $default_key = array_search( $this->default_language, $this->available_languages ); $available_languages_no_default = $this->available_languages; unset( $available_languages_no_default[ $default_key ] ); $this->available_languages = array_merge( $default_array, $available_languages_no_default ); $this->starting_language = $this->default_language; } if ( $_GET && isset( $_GET['avada_update'] ) ) { // Only continue if the URL is ?avada_update=1. if ( '1' != $_GET['avada_update'] ) { return; } // Only continue if we're updating to version 4.0.0. if ( ! isset( $_GET['ver'] ) || ( $this->version != $_GET['ver'] ) ) { return; } // Get the current step. if ( ! isset( $_GET['step'] ) ) { $this->step = 0; } else { $this->step = intval( $_GET['step'] ); } if ( isset( $_GET['proceed'] ) && '0' == $_GET['proceed'] ) { $this->proceed = false; } $_get_lang = ( isset( $_GET['lang'] ) ) ? sanitize_text_field( wp_unslash( $_GET['lang'] ) ) : ''; if ( isset( $_GET['lang'] ) && ! in_array( $_get_lang, [ '', 'en', 'all', null ] ) ) { Fusion_Multilingual::set_active_language( $_get_lang ); } $this->options = get_option( Avada::get_option_name(), [] ); $this->fields = Avada_Options::get_option_fields(); add_action( 'admin_init', [ $this, 'migrate_page' ] ); } } /** * The migration page. * * @access public */ public function migrate_page() { ob_start(); $this->setup_wizard_template(); if ( isset( $this->steps[ $this->step ] ) && isset( $this->steps[ $this->step ]['callback'] ) ) { call_user_func( $this->steps[ $this->step ]['callback'] ); } // Make sure we have not finished. if ( $this->step >= count( $this->steps ) - 1 ) { if ( empty( $this->available_languages ) || count( $this->available_languages ) == array_search( $this->active_language, $this->available_languages ) + 1 ) { $this->finished(); } } exit; } /** * Output the content for the current step. */ public function setup_wizard_template() { $current_step = intval( $this->step ); ?> > <?php esc_html_e( 'Avada Global Options Migration', 'Avada' ); ?>
available_languages ) ) { /* translators: Version number. */ printf( esc_html__( 'We have an amazing new update in store for you! Avada %s includes our completely new Global Options Panel and the brand new Avada Builder. To enjoy the full experience, two primary conversion steps need to be performed. First your Global Options database entries need to be converted (sequentially for each language, if you have a multi-lingual site). In a second step your shortcodes will be converted for the new builder. Thank you for choosing Avada!', 'Avada' ), esc_attr( $version ) ); } else { /* translators: Version number. */ printf( esc_html__( 'We have an amazing new update in store for you! Avada %s includes our completely new Global Options Panel and the brand new Avada Builder. To enjoy the full experience, two primary conversion steps need to be performed. First your Global Options database entries need to be converted. In a second step your shortcodes will be converted for the new builder. Thank you for choosing Avada!', 'Avada' ), esc_attr( $version ) ); } ?>

available_languages ) ) : ?> ' . esc_attr( $this->active_language ) . '' ); ?> = count( $this->steps ) ) : ?>

= ( count( $this->steps ) * 0.75 ) ) : ?>

= ( count( $this->steps ) * 0.4 ) ) : ?>

available_languages ) && 1 < count( $this->available_languages ) ) : ?> active_language, $this->available_languages ) + 1; ?>

available_languages ) ); ?>

steps ) && isset( $this->steps[ $this->step ] ) ) : ?>

step + 1 ), count( $this->steps ) ); ?>

    steps as $key => $step ) : ?>
available_languages ) || count( $this->available_languages ) == array_search( $this->active_language, $this->available_languages ) + 1 ) : ?>

step ) >= count( $this->steps ) ) : ?> available_languages ) || count( $this->available_languages ) == array_search( $this->active_language, $this->available_languages ) + 1 ) : ?>
redirect_script(); // phpcs:ignore WordPress.Security.EscapeOutput ?>
available_languages; $current_step = intval( $this->step ); $next_step = $current_step + 1; // Add 500ms delay for refreshes. $delay = 500; if ( ( $current_step + 1 ) <= count( $this->steps ) && $this->proceed ) { // Redirect to next step. $lang = ( isset( $_GET['lang'] ) ) ? sanitize_text_field( wp_unslash( $_GET['lang'] ) ) : ''; return ''; } else { // Check if this is a multilingual site. if ( ! empty( $languages ) ) { // Get the next language code. $next_lang = $this->get_next_language(); if ( 'finished' === $next_lang ) { return; } return ''; } } } /** * Gets the next language in multilingual sites. * * @access public * @return string */ public function get_next_language() { // Get all languages. $languages = $this->available_languages; // Get the current language key. if ( $_GET && isset( $_GET['lang'] ) ) { $current_lang_code = ( isset( $_GET['lang'] ) ) ? sanitize_text_field( wp_unslash( $_GET['lang'] ) ) : ''; $current_lang_key = (int) array_search( $current_lang_code, $languages ); if ( false === $current_lang_key ) { $current_lang_key = null; } } else { $current_lang_key = null; } // If no language is currently defined, then proceed to 0. if ( null === $current_lang_key ) { $next_lang_key = 0; } else { // Proceed to next language. $next_lang_key = $current_lang_key + 1; } // Check if this key exists in the array. // If not, then proceed to the next one. if ( ! isset( $languages[ $next_lang_key ] ) ) { $next_lang_key++; } // If the next language is "en" skip it. if ( isset( $languages[ $next_lang_key ] ) && 'en' == $languages[ $next_lang_key ] ) { $next_lang_key++; } // Check if we're finished. // If yes, then return "finished". if ( $next_lang_key >= count( $languages ) ) { return 'finished'; } // Return the code of the next language. return esc_attr( $languages[ $next_lang_key ] ); } /** * Debug helper. * Creates an `avada-migration-debug.log` file in wp-content. * * @static * @access public * @param array $data The setting data. */ public static function generate_debug_log( $data = [] ) { $debug_log = ''; $debug_content = ''; $debug_file_path = WP_CONTENT_DIR . '/avada-migration-debug.log'; if ( defined( 'AVADA_MIGRATION_DEBUG_LOG' ) && AVADA_MIGRATION_DEBUG_LOG ) { if ( ! empty( $data ) ) { $final_data = []; foreach ( $data as $item ) { $final_data[] = ( is_array( $item ) ) ? wp_json_encode( $item ) : $item; } $debug_log .= 'Old Setting: ' . $final_data[0] . "\r\n"; $debug_log .= 'New Setting: ' . $final_data[1] . "\r\n"; $debug_log .= 'Old Value: ' . $final_data[2] . "\r\n"; $debug_log .= 'New Value: ' . $final_data[3] . "\r\n"; $debug_log .= "\r\n"; } // Write debug file contents. if ( file_exists( $debug_file_path ) ) { $debug_content = fusion_file_get_contents( $debug_file_path ); } $debug_content .= $debug_log; file_put_contents( $debug_file_path, $debug_content ); // phpcs:ignore WordPress.WP.AlternativeFunctions } } }