當前位置: 首頁>>代碼示例>>PHP>>正文


PHP WPSEO_Options::get_option_instance方法代碼示例

本文整理匯總了PHP中WPSEO_Options::get_option_instance方法的典型用法代碼示例。如果您正苦於以下問題:PHP WPSEO_Options::get_option_instance方法的具體用法?PHP WPSEO_Options::get_option_instance怎麽用?PHP WPSEO_Options::get_option_instance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在WPSEO_Options的用法示例。


在下文中一共展示了WPSEO_Options::get_option_instance方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: get_custom_field_names

 /**
  * Retrieve all custom field names set in SEO ->
  *
  * @return array
  */
 private function get_custom_field_names()
 {
     $custom_field_names = array();
     $post = $this->get_post();
     $options = get_option(WPSEO_Options::get_option_instance('wpseo_titles')->option_name, array());
     if (is_object($post)) {
         $target_option = 'page-analyse-extra-' . $post->post_type;
         if (array_key_exists($target_option, $options)) {
             $custom_field_names = explode(',', $options[$target_option]);
         }
     }
     return $custom_field_names;
 }
開發者ID:mazykin46,項目名稱:portfolio,代碼行數:18,代碼來源:class-custom-fields-plugin.php

示例2: filter_page_analysis

 /**
  * Filter for adding custom fields to page analysis
  *
  * Based on the configured custom fields for page analysis. this filter will get the needed values from post_meta
  * and add them to the $page_content. Page analysis will be able to scan the content of these customs fields by
  * doing this. - If value doesn't exists as a post-meta value, there will be nothing included.
  *
  * @param string $page_content The content of the current post text.
  * @param object $post         The total object of the post content.
  *
  * @return string $page_content
  */
 public function filter_page_analysis($page_content, $post)
 {
     $options = get_option(WPSEO_Options::get_option_instance('wpseo_titles')->option_name, array());
     $target_option = 'page-analyse-extra-' . $post->post_type;
     if (array_key_exists($target_option, $options)) {
         $custom_fields = explode(',', $options[$target_option]);
         if (is_array($custom_fields)) {
             foreach ($custom_fields as $custom_field) {
                 $custom_field_data = get_post_meta($post->ID, $custom_field, true);
                 if (!empty($custom_field_data)) {
                     $page_content .= ' ' . $custom_field_data;
                 }
             }
         }
     }
     return $page_content;
 }
開發者ID:Infernosaint,項目名稱:WPSetupTest2,代碼行數:29,代碼來源:class-premium.php

示例3: unzip_file

 $unzipped = unzip_file($file['file'], $p_path);
 if (!is_wp_error($unzipped)) {
     $filename = $p_path . 'settings.ini';
     if (@is_file($filename) && is_readable($filename)) {
         $options = parse_ini_file($filename, true);
         if (is_array($options) && $options !== array()) {
             $old_wpseo_version = null;
             if (isset($options['wpseo']['version']) && $options['wpseo']['version'] !== '') {
                 $old_wpseo_version = $options['wpseo']['version'];
             }
             foreach ($options as $name => $optgroup) {
                 if ($name === 'wpseo_taxonomy_meta') {
                     $optgroup = json_decode(urldecode($optgroup['wpseo_taxonomy_meta']), true);
                 }
                 // Make sure that the imported options are cleaned/converted on import
                 $option_instance = WPSEO_Options::get_option_instance($name);
                 if (is_object($option_instance) && method_exists($option_instance, 'import')) {
                     $optgroup = $option_instance->import($optgroup, $old_wpseo_version, $options);
                 } elseif (WP_DEBUG === true || defined('WPSEO_DEBUG') && WPSEO_DEBUG === true) {
                     $content .= '<p><strong>' . sprintf(__('Setting "%s" is no longer used and has been discarded.', 'wordpress-seo'), $name) . '</strong></p>';
                 }
             }
             $content .= '<p><strong>' . __('Settings successfully imported.', 'wordpress-seo') . '</strong></p>';
         } else {
             $content .= '<p><strong>' . __('Settings could not be imported:', 'wordpress-seo') . ' ' . __('No settings found in file.', 'wordpress-seo') . '</strong></p>';
         }
         unset($options, $name, $optgroup);
     } else {
         $content .= '<p><strong>' . __('Settings could not be imported:', 'wordpress-seo') . ' ' . __('Unzipping failed - file settings.ini not found.', 'wordpress-seo') . '</strong></p>';
     }
     @unlink($filename);
開發者ID:rinodung,項目名稱:myfreetheme,代碼行數:31,代碼來源:import.php

示例4: parse_option_group

 /**
  * Parse the option group and import it
  *
  * @param string $name
  * @param array  $opt_group
  * @param array  $options
  */
 private function parse_option_group($name, $opt_group, $options)
 {
     if ($name === 'wpseo_taxonomy_meta') {
         $opt_group = json_decode(urldecode($opt_group['wpseo_taxonomy_meta']), true);
     }
     // Make sure that the imported options are cleaned/converted on import
     $option_instance = WPSEO_Options::get_option_instance($name);
     if (is_object($option_instance) && method_exists($option_instance, 'import')) {
         $option_instance->import($opt_group, $this->old_wpseo_version, $options);
     } elseif (WP_DEBUG === true || defined('WPSEO_DEBUG') && WPSEO_DEBUG === true) {
         $this->msg = sprintf(__('Setting "%s" is no longer used and has been discarded.', 'wordpress-seo'), $name);
     }
 }
開發者ID:HealthStaffTraining,項目名稱:healthstafftraining,代碼行數:20,代碼來源:class-import.php

示例5: import_seo_settings

 public function import_seo_settings($file)
 {
     if (!empty($file)) {
         $upload_dir = wp_upload_dir();
         if (!defined('DIRECTORY_SEPARATOR')) {
             define('DIRECTORY_SEPARATOR', '/');
         }
         $p_path = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . 'wpseo-import' . DIRECTORY_SEPARATOR;
         if (!isset($GLOBALS['wp_filesystem']) || !is_object($GLOBALS['wp_filesystem'])) {
             WP_Filesystem();
         }
         $unzipped = unzip_file($file, $p_path);
         if (!is_wp_error($unzipped)) {
             $filename = $p_path . 'settings.ini';
             if (@is_file($filename) && is_readable($filename)) {
                 $options = parse_ini_file($filename, true);
                 if (is_array($options) && $options !== array()) {
                     $old_wpseo_version = null;
                     if (isset($options['wpseo']['version']) && $options['wpseo']['version'] !== '') {
                         $old_wpseo_version = $options['wpseo']['version'];
                     }
                     foreach ($options as $name => $optgroup) {
                         if ($name === 'wpseo_taxonomy_meta') {
                             $optgroup = json_decode(urldecode($optgroup['wpseo_taxonomy_meta']), true);
                         }
                         // Make sure that the imported options are cleaned/converted on import
                         $option_instance = WPSEO_Options::get_option_instance($name);
                         if (is_object($option_instance) && method_exists($option_instance, 'import')) {
                             $optgroup = $option_instance->import($optgroup, $old_wpseo_version, $options);
                         }
                     }
                     return true;
                 } else {
                     throw new Exception(__('Settings could not be imported:', 'wordpress-seo'));
                 }
                 unset($options, $name, $optgroup);
             } else {
                 throw new Exception(__('Settings could not be imported:', 'wordpress-seo'));
             }
             @unlink($filename);
             @unlink($p_path);
         } else {
             throw new Exception(__('Settings could not be imported:', 'wordpress-seo') . ' ' . sprintf(__('Unzipping failed with error "%s".', 'wordpress-seo'), $unzipped->get_error_message()));
         }
         unset($zip, $unzipped);
         @unlink($file);
     } else {
         throw new Exception(__('Settings could not be imported:', 'wordpress-seo') . ' ' . __('Upload failed.', 'wordpress-seo'));
     }
     return false;
 }
開發者ID:HasClass0,項目名稱:mainwp-child,代碼行數:51,代碼來源:MainWPWordpressSEO.class.php


注:本文中的WPSEO_Options::get_option_instance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。