当前位置: 首页>>代码示例>>PHP>>正文


PHP WPSEO_Meta::meta_fields方法代码示例

本文整理汇总了PHP中WPSEO_Meta::meta_fields方法的典型用法代码示例。如果您正苦于以下问题:PHP WPSEO_Meta::meta_fields方法的具体用法?PHP WPSEO_Meta::meta_fields怎么用?PHP WPSEO_Meta::meta_fields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WPSEO_Meta的用法示例。


在下文中一共展示了WPSEO_Meta::meta_fields方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: init

 /**
  * Register our actions and filters
  *
  * @static
  * @return void
  */
 public static function init()
 {
     $options = WPSEO_Options::get_all();
     foreach (array('opengraph' => 'opengraph', 'twitter' => 'twitter', 'googleplus' => 'google-plus') as $option => $network) {
         if (true === $options[$option]) {
             foreach (array('title' => 'text', 'description' => 'textarea', 'image' => 'upload') as $box => $type) {
                 self::$meta_fields['social'][$network . '-' . $box] = array('type' => $type, 'title' => '', 'default_value' => '', 'description' => '');
             }
         }
     }
     /**
      * Allow add-on plugins to register their meta fields for management by this class
      * add_filter() calls must be made before plugins_loaded prio 14
      */
     $extra_fields = apply_filters('add_extra_wpseo_meta_fields', array());
     if (is_array($extra_fields)) {
         self::$meta_fields = self::array_merge_recursive_distinct($extra_fields, self::$meta_fields);
     }
     $register = function_exists('register_meta');
     foreach (self::$meta_fields as $subset => $field_group) {
         foreach ($field_group as $key => $field_def) {
             if ($field_def['type'] !== 'snippetpreview') {
                 /* register_meta() is undocumented and not used by WP internally, wrapped in
                    function_exists as a precaution in case they remove it. */
                 if ($register === true) {
                     register_meta('post', self::$meta_prefix . $key, array(__CLASS__, 'sanitize_post_meta'));
                 } else {
                     add_filter('sanitize_post_meta_' . self::$meta_prefix . $key, array(__CLASS__, 'sanitize_post_meta'), 10, 2);
                 }
                 // Set the $fields_index property for efficiency
                 self::$fields_index[self::$meta_prefix . $key] = array('subset' => $subset, 'key' => $key);
                 // Set the $defaults property for efficiency
                 if (isset($field_def['default_value'])) {
                     self::$defaults[self::$meta_prefix . $key] = $field_def['default_value'];
                 } else {
                     // meta will always be a string, so let's make the meta meta default also a string
                     self::$defaults[self::$meta_prefix . $key] = '';
                 }
             }
         }
     }
     add_filter('update_post_metadata', array(__CLASS__, 'remove_meta_if_default'), 10, 5);
     add_filter('add_post_metadata', array(__CLASS__, 'dont_save_meta_if_default'), 10, 4);
 }
开发者ID:johnreytepacia,项目名称:etarticles,代码行数:50,代码来源:class-wpseo-meta.php


注:本文中的WPSEO_Meta::meta_fields方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。