示例#1
0
 /**
  * sets the $lang property for this object.
  * Languages are prefixed with a '_'
  *
  * If we're not currently performing a migration
  * it also checks if the options for the current language are set.
  * If they are not, then we will copy the options from the main language.
  */
 public static function multilingual_options()
 {
     // Set the self::$lang
     if (!in_array(Avada_Multilingual::get_active_language(), array('', 'en', 'all'))) {
         self::$lang = '_' . Avada_Multilingual::get_active_language();
     }
     // Make sure the options are copied if needed
     if (!in_array(self::$lang, array('', 'en', 'all')) && !self::$lang_applied) {
         // Set the $option_name property
         self::$option_name = self::get_option_name();
         // Get the options without using a language (defaults)
         $original_options = get_option(self::$original_option_name, array());
         // Get options with a language
         $options = get_option(self::$original_option_name . self::$lang, array());
         // If we're not currently performing a migration and the options are not set
         // then we must copy the default options to the new language.
         if (!self::$is_updating && !empty($original_options) && empty($options)) {
             update_option(self::$original_option_name . self::$lang, get_option(self::$original_option_name));
         }
         // Modify the option_name to include the language
         self::$option_name = self::$original_option_name . self::$lang;
         // Set $lang_applied to true. Makes sure we don't do the above more than once.
         self::$lang_applied = true;
     }
 }