Exemplo n.º 1
0
 public function options($options_name, &$opts = array(), $def_opts = array())
 {
     $opts = SucomUtil::rename_keys($opts, $this->renamed_keys);
     // custom value changes for regular options
     if ($options_name == constant($this->p->cf['uca'] . '_OPTIONS_NAME')) {
         if ($opts['options_version'] <= 270) {
             foreach ($opts as $key => $val) {
                 if (strpos($key, 'inc_') === 0) {
                     $new_key = '';
                     switch ($key) {
                         case preg_match('/^inc_(description|twitter:)/', $key) ? true : false:
                             $new_key = preg_replace('/^inc_/', 'add_meta_name_', $key);
                             break;
                         default:
                             $new_key = preg_replace('/^inc_/', 'add_meta_property_', $key);
                             break;
                     }
                     if (!empty($new_key)) {
                         $opts[$new_key] = $val;
                     }
                     unset($opts[$key]);
                 }
             }
         }
         if ($opts['options_version'] <= 260) {
             if ($opts['og_img_width'] == 1200 && $opts['og_img_height'] == 630 && !empty($opts['og_img_crop'])) {
                 $this->p->notice->inf('Open Graph Image Dimentions have been updated from ' . $opts['og_img_width'] . 'x' . $opts['og_img_height'] . ', ' . ($opts['og_img_crop'] ? '' : 'un') . 'cropped to ' . $def_opts['og_img_width'] . 'x' . $def_opts['og_img_height'] . ', ' . ($def_opts['og_img_crop'] ? '' : 'un') . 'cropped.', true);
                 $opts['og_img_width'] = $def_opts['og_img_width'];
                 $opts['og_img_height'] = $def_opts['og_img_height'];
                 $opts['og_img_crop'] = $def_opts['og_img_crop'];
             }
         }
         if ($opts['options_version'] <= 247) {
             if (!empty($opts['twitter_shorten'])) {
                 $opts['twitter_shortener'] = 'googl';
                 unset($opts['twitter_shorten']);
             }
         }
         if ($opts['options_version'] <= 28) {
             // upgrade the old og_img_size name into width / height / crop values
             if (array_key_exists('og_img_size', $opts)) {
                 if (!empty($opts['og_img_size']) && $opts['og_img_size'] !== 'medium') {
                     $size_info = $this->p->media->get_size_info($opts['og_img_size']);
                     if ($size_info['width'] > 0 && $size_info['height'] > 0) {
                         $opts['og_img_width'] = $size_info['width'];
                         $opts['og_img_height'] = $size_info['height'];
                         $opts['og_img_crop'] = $size_info['crop'];
                     }
                 }
                 unset($opts['og_img_size']);
             }
         }
     }
     $opts = $this->sanitize($opts, $def_opts);
     // cleanup excess options and sanitize
     return $opts;
 }
Exemplo n.º 2
0
 public function options($options_name, &$opts = array(), $def_opts = array())
 {
     // retrieve the first numeric string
     $opts_version = empty($opts['options_version']) ? 0 : preg_replace('/^[^0-9]*([0-9]*).*$/', '$1', $opts['options_version']);
     if ($options_name === constant('WPSSO_OPTIONS_NAME')) {
         $opts = SucomUtil::rename_keys($opts, $this->renamed_keys);
         if (version_compare($opts_version, 260, '<=')) {
             if ($opts['og_img_width'] == 1200 && $opts['og_img_height'] == 630 && !empty($opts['og_img_crop'])) {
                 $this->p->notice->inf('Open Graph Image Dimentions have been updated from ' . $opts['og_img_width'] . 'x' . $opts['og_img_height'] . ', ' . ($opts['og_img_crop'] ? '' : 'un') . 'cropped to ' . $def_opts['og_img_width'] . 'x' . $def_opts['og_img_height'] . ', ' . ($def_opts['og_img_crop'] ? '' : 'un') . 'cropped.', true);
                 $opts['og_img_width'] = $def_opts['og_img_width'];
                 $opts['og_img_height'] = $def_opts['og_img_height'];
                 $opts['og_img_crop'] = $def_opts['og_img_crop'];
             }
         }
         if (version_compare($opts_version, 270, '<=')) {
             foreach ($opts as $key => $val) {
                 if (strpos($key, 'inc_') === 0) {
                     $new_key = '';
                     switch ($key) {
                         case preg_match('/^inc_(description|twitter:)/', $key) ? true : false:
                             $new_key = preg_replace('/^inc_/', 'add_meta_name_', $key);
                             break;
                         default:
                             $new_key = preg_replace('/^inc_/', 'add_meta_property_', $key);
                             break;
                     }
                     if (!empty($new_key)) {
                         $opts[$new_key] = $val;
                     }
                     unset($opts[$key]);
                 }
             }
         }
         if (version_compare($opts_version, 296, '<=')) {
             if (empty($opts['plugin_min_shorten']) || $opts['plugin_min_shorten'] < 22) {
                 $opts['plugin_min_shorten'] = 22;
             }
         }
         if (version_compare($opts_version, 373, '<=')) {
             if (!empty($opts['plugin_head_attr_filter_name']) && $opts['plugin_head_attr_filter_name'] === 'language_attributes') {
                 $opts['plugin_head_attr_filter_name'] = 'head_attributes';
             }
         }
     } elseif ($options_name === constant('WPSSO_SITE_OPTIONS_NAME')) {
         $opts = SucomUtil::rename_keys($opts, $this->renamed_site_keys);
     }
     if (version_compare($opts_version, 342, '<=')) {
         if (isset($opts['plugin_file_cache_hrs'])) {
             $opts['plugin_file_cache_exp'] = $opts['plugin_file_cache_hrs'] * 3600;
             unset($opts['plugin_file_cache_hrs']);
         }
     }
     return $this->sanitize($opts, $def_opts);
     // cleanup options and sanitize
 }
Exemplo n.º 3
0
 public function options($options_name, &$opts = array(), $def_opts = array())
 {
     $opts = SucomUtil::rename_keys($opts, $this->renamed_keys);
     // custom value changes for regular options
     if ($options_name == constant($this->p->cf['uca'] . '_OPTIONS_NAME')) {
         if (version_compare($opts['options_version'], 260, '<=')) {
             if ($opts['og_img_width'] == 1200 && $opts['og_img_height'] == 630 && !empty($opts['og_img_crop'])) {
                 $this->p->notice->inf('Open Graph Image Dimentions have been updated from ' . $opts['og_img_width'] . 'x' . $opts['og_img_height'] . ', ' . ($opts['og_img_crop'] ? '' : 'un') . 'cropped to ' . $def_opts['og_img_width'] . 'x' . $def_opts['og_img_height'] . ', ' . ($def_opts['og_img_crop'] ? '' : 'un') . 'cropped.', true);
                 $opts['og_img_width'] = $def_opts['og_img_width'];
                 $opts['og_img_height'] = $def_opts['og_img_height'];
                 $opts['og_img_crop'] = $def_opts['og_img_crop'];
             }
         }
         if (version_compare($opts['options_version'], 270, '<=')) {
             foreach ($opts as $key => $val) {
                 if (strpos($key, 'inc_') === 0) {
                     $new_key = '';
                     switch ($key) {
                         case preg_match('/^inc_(description|twitter:)/', $key) ? true : false:
                             $new_key = preg_replace('/^inc_/', 'add_meta_name_', $key);
                             break;
                         default:
                             $new_key = preg_replace('/^inc_/', 'add_meta_property_', $key);
                             break;
                     }
                     if (!empty($new_key)) {
                         $opts[$new_key] = $val;
                     }
                     unset($opts[$key]);
                 }
             }
         }
         if (version_compare($opts['options_version'], 296, '<=')) {
             if ($opts['plugin_min_shorten'] < 22) {
                 $opts['plugin_min_shorten'] = 22;
             }
         }
     }
     $opts = $this->sanitize($opts, $def_opts);
     // cleanup excess options and sanitize
     return $opts;
 }