当前位置: 首页>>代码示例>>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;未经允许,请勿转载。