Ejemplo n.º 1
0
 public static function get_instance()
 {
     if (null == self::$instance) {
         self::$instance = new Avada_Options();
     }
     return self::$instance;
 }
Ejemplo n.º 2
0
 public function __construct()
 {
     Avada::$is_updating = true;
     /* Raise the memory limit and max_execution_time time */
     @ini_set('memory_limit', '256M');
     @set_time_limit(0);
     $this->available_languages = Avada_Multilingual::get_available_languages();
     $this->active_language = Avada_Multilingual::get_active_language();
     $this->default_language = Avada_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 = 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 = 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;
         }
         if (isset($_GET['lang']) && !in_array($_GET['lang'], array('', 'en', 'all', null))) {
             Avada_Multilingual::set_active_language($_GET['lang']);
         }
         $this->options = get_option(Avada::get_option_name(), array());
         $this->fields = Avada_Options::get_option_fields();
         add_action('admin_init', array($this, 'migrate_page'));
     }
 }
Ejemplo n.º 3
0
 /**
  * The class constructor
  */
 private function __construct()
 {
     $this->set_is_updating();
     // Multilingual handling
     self::multilingual_options();
     // Make sure that $option_name is set.
     // This is run AFTER the multilingual option as a fallback.
     if (empty(self::$option_name)) {
         self::$option_name = self::get_option_name();
     }
     // Instantiate secondary classes
     $this->settings = Avada_Settings::get_instance();
     $this->options = Avada_Options::get_instance();
     $this->init = new Avada_Init();
     $this->social_sharing = new Avada_Social_Sharing();
     $this->template = new Avada_Template();
     $this->blog = new Avada_Blog();
     $this->images = new Avada_Images();
     $this->head = new Avada_Head();
     $this->dynamic_css = new Avada_Dynamic_CSS();
     $this->layout = new Avada_Layout();
     $this->google_map = new Avada_GoogleMap();
     add_action('wp', array($this, 'set_page_id'));
 }
Ejemplo n.º 4
0
 /**
  * Gets the default value of a single setting
  */
 public function get_default($setting = null, $subset = false)
 {
     if (is_null($setting) || empty($setting)) {
         return '';
     }
     $all_fields = Avada_Options::get_option_fields();
     if (!is_array($all_fields) || !isset($all_fields[$setting]) || !isset($all_fields[$setting]['default'])) {
         return '';
     }
     $default = $all_fields[$setting]['default'];
     if (!$subset || !is_array($default)) {
         return $default;
     }
     if (!isset($default[$subset])) {
         return '';
     }
     return $default[$subset];
 }
Ejemplo n.º 5
0
/**
 * Compatibility tweak:
 * We were previously using SMOF.
 * Some plugins use $smof_data to get the Avada options
 * so we'll be re-creating it here for the sake of those plugins.
 */
function avada_smof_compatibility()
{
    $options = get_option(Avada::get_option_name(), array());
    $fields = Avada_Options::get_option_fields();
    foreach ($fields as $field_id => $field_args) {
        if (!isset($options[$field_id])) {
            if (isset($field_args['default'])) {
                $options[$field_id] = $field_args['default'];
            }
        }
        if (isset($options[$field_id]) && is_array($options[$field_id])) {
            if (isset($field_args['default']) && is_array($field_args['default'])) {
                foreach ($field_args['default'] as $key => $value) {
                    if (!isset($options[$field_id][$key])) {
                        if ('top' == $key && !isset($options[$field_id]['top'])) {
                            if (isset($options[$field_id]['margin-top'])) {
                                $options[$field_id]['top'] = $options[$field_id]['margin-top'];
                            } elseif (isset($options[$field_id]['padding-top'])) {
                                $options[$field_id]['top'] = $options[$field_id]['padding-top'];
                            } elseif (isset($options[$field_id]['top'])) {
                                $options[$field_id]['top'] = $field_args['default']['top'];
                            } else {
                                $options[$field_id]['top'] = Avada()->settings->get($field_id, 'top');
                            }
                        } elseif ('bottom' == $key) {
                            if (isset($options[$field_id]['margin-bottom'])) {
                                $options[$field_id]['bottom'] = $options[$field_id]['margin-bottom'];
                            } elseif (isset($options[$field_id]['padding-bottom'])) {
                                $options[$field_id]['bottom'] = $options[$field_id]['padding-bottom'];
                            } elseif (isset($options[$field_id]['bottom'])) {
                                $options[$field_id]['bottom'] = $field_args['default']['bottom'];
                            } else {
                                $options[$field_id]['bottom'] = Avada()->settings->get($field_id, 'bottom');
                            }
                        } else {
                            if (!isset($options[$field_id][$key])) {
                                $options[$field_id][$key] = $field_args['default'][$key];
                            }
                        }
                    }
                }
            }
            if ('color-alpha' == $field_args['type']) {
                if (isset($options[$field_id]) && !empty($options[$field_id])) {
                    if (is_array($options[$field_id])) {
                        if (isset($options[$field_id]['rgba']) && !empty($options[$field_id]['rgba'])) {
                            $options[$field_id] = $options[$field_id]['rgba'];
                        } elseif (isset($options[$field_id]['color']) && !empty($options[$field_id]['rgba'])) {
                            $options[$field_id] = $options[$field_id]['color'];
                        }
                    }
                } else {
                    if (isset($field_args['default'])) {
                        if (is_array($field_args['default'])) {
                            if (isset($field_args['default']['rgba']) && !empty($field_args['default']['rgba'])) {
                                $options[$field_id] = $field_args['default']['rgba'];
                            } elseif (isset($field_args['default']['color']) && !empty($field_args['default']['color'])) {
                                $options[$field_id] = $field_args['default']['color'];
                            }
                        } else {
                            $options[$field_id] = $field_args['default'];
                        }
                    }
                }
                if (!empty($options[$field_id])) {
                    $options[$field_id] = Avada_Sanitize::color($options[$field_id]);
                }
            }
        }
    }
    return $options;
}
 /**
  * Various other options that don't fit anywhere else
  */
 public function other_options()
 {
     $options = get_option(Avada::get_option_name(), array());
     /**
      * convert the "round" option to "50%"
      */
     $round_options = array('content_box_icon_circle_radius', 'content_box_icon_circle_radius', 'social_links_boxed_radius', 'header_social_links_boxed_radius', 'footer_social_links_boxed_radius', 'sharing_social_links_boxed_radius', 'imageframe_border_radius', 'person_border_radius', 'flip_boxes_border_radius');
     foreach ($round_options as $round_option) {
         if (isset($options[$round_option])) {
             $initial_value = isset($options[$round_option]) ? $options[$round_option] : 'UNDEFINED';
             if ('round' == strtolower(trim($options[$round_option]))) {
                 $options[$round_option] = '50%';
             }
             Avada_Migrate::generate_debug_log(array($round_option, $round_option, $initial_value, $options[$round_option]));
         }
     }
     $dimensions_fields = array('slider_nav_box_dimensions' => array('width' => 'slider_nav_box_width', 'height' => 'slider_nav_box_height'), 'tfes_dimensions' => array('width' => 'tfes_slider_width', 'height' => 'tfes_slider_height'), 'gmap_dimensions' => array('width' => 'gmap_width', 'height' => 'gmap_height'), 'lightbox_video_dimensions' => array('width' => 'lightbox_video_width', 'height' => 'lightbox_video_height'));
     $this->fields = Avada_Options::get_option_fields();
     foreach ($dimensions_fields as $dimensions_field => $args) {
         $initial_value_width = 'UNDEFINED';
         $initial_value_height = 'UNDEFINED';
         $width = isset($this->fields[$dimensions_field]['default']['width']) ? $this->fields[$dimensions_field]['default']['width'] : '';
         if (isset($options[$args['width']])) {
             $width = $options[$args['width']];
             $initial_value_width = $width;
         }
         $height = isset($this->fields[$dimensions_field]['default']['height']) ? $this->fields[$dimensions_field]['default']['height'] : '';
         if (isset($options[$args['height']])) {
             $height = $options[$args['height']];
             $initial_value_height = $height;
         }
         $options[$dimensions_field] = array('width' => Avada_Sanitize::size($width), 'height' => Avada_Sanitize::size($height));
         Avada_Migrate::generate_debug_log(array($args['width'], $dimensions_field . '[width]', $initial_value_width, $options[$dimensions_field]['width']));
         Avada_Migrate::generate_debug_log(array($args['height'], $dimensions_field . '[height]', $initial_value_height, $options[$dimensions_field]['height']));
     }
     $capitalization_check_fields = array('excerpt_base', 'sidenav_behavior');
     foreach ($capitalization_check_fields as $capitalization_check_field) {
         if (isset($options[$capitalization_check_field])) {
             $initial_value = $options[$capitalization_check_field];
             $options[$capitalization_check_field] = ucfirst($options[$capitalization_check_field]);
             Avada_Migrate::generate_debug_log(array($capitalization_check_field, $capitalization_check_field, $initial_value, $options[$capitalization_check_field]));
         }
     }
     // SMOF default value is "show"
     if (isset($options['faq_filters']) && 'show' == $options['faq_filters']) {
         $options['faq_filters'] = 'yes';
     }
     if (isset($options['load_more_posts_button_bg_color'])) {
         $options['blog_load_more_posts_button_bg_color'] = $options['load_more_posts_button_bg_color'];
         $options['portfolio_load_more_posts_button_bg_color'] = $options['load_more_posts_button_bg_color'];
     }
     if (isset($options['pagination_box_padding']) && !is_array($options['pagination_box_padding'])) {
         $options['pagination_box_padding'] = trim($options['pagination_box_padding']);
         if (strpos($options['pagination_box_padding'], ' ')) {
             $values = explode(' ', $options['pagination_box_padding']);
             $options['pagination_box_padding'] = array('height' => $values[0], 'width' => $values[1]);
         } else {
             $value = $options['pagination_box_padding'];
             $options['pagination_box_padding'] = array('width' => $value, 'height' => $value);
         }
     }
     // Update the options with our modifications.
     update_option(Avada::get_option_name(), $options);
 }