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


PHP wp_create_tag函数代码示例

本文整理汇总了PHP中wp_create_tag函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_create_tag函数的具体用法?PHP wp_create_tag怎么用?PHP wp_create_tag使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: validate_settings

 /**
  * Validate settings
  *
  * Make sure that all user supplied content is in an expected format before
  * saving to the database. This function will also delete the transient set in
  * Featured_Content::get_featured_content().
  *
  * @uses Featured_Content::delete_transient()
  *
  * @param array $input
  * @return array $output
  */
 public static function validate_settings($input)
 {
     $output = array();
     if (empty($input['tag-name'])) {
         $output['tag-id'] = 0;
     } else {
         $term = get_term_by('name', $input['tag-name'], 'post_tag');
         if ($term) {
             $output['tag-id'] = $term->term_id;
         } else {
             $new_tag = wp_create_tag($input['tag-name']);
             if (!is_wp_error($new_tag) && isset($new_tag['term_id'])) {
                 $output['tag-id'] = $new_tag['term_id'];
             }
         }
         $output['tag-name'] = $input['tag-name'];
     }
     $output['hide-tag'] = isset($input['hide-tag']) && $input['hide-tag'] ? 1 : 0;
     $output['show-all'] = isset($input['show-all']) && $input['show-all'] ? 1 : 0;
     self::delete_transient();
     return $output;
 }
开发者ID:martincarson,项目名称:jetpack,代码行数:34,代码来源:featured-content.php

示例2: validate_settings

 /**
  * Validate Settings.
  *
  * Make sure that all user supplied content is in an
  * expected format before saving to the database. This
  * function will also delete the transient set in
  * Featured_Content::get_featured_content().
  *
  * @uses Featured_Content::self::sanitize_quantity()
  * @uses Featured_Content::self::delete_transient()
  */
 function validate_settings($input)
 {
     $output = array();
     if (isset($input['tag-id'])) {
         $output['tag-id'] = absint($input['tag-id']);
     }
     if (isset($input['tag-name'])) {
         $new_tag = wp_create_tag($input['tag-name']);
         if (!is_wp_error($new_tag) && isset($new_tag['term_id'])) {
             $tag = get_term($new_tag['term_id'], 'post_tag');
         }
         if (isset($tag->term_id)) {
             $output['tag-id'] = $tag->term_id;
         }
     }
     if (isset($input['quantity'])) {
         $output['quantity'] = self::sanitize_quantity($input['quantity']);
     }
     $output['hide-tag'] = isset($input['hide-tag']) ? 1 : 0;
     self::delete_transient();
     return $output;
 }
开发者ID:kevinreilly,项目名称:mendelements.com,代码行数:33,代码来源:featured-content.php

示例3: validate_settings

 /**
  * Validate featured content settings.
  *
  * Make sure that all user supplied content is in an expected
  * format before saving to the database. This function will also
  * delete the transient set in Featured_Content::get_featured_content().
  *
  * @static
  * @access public
  * @since 1.0
  *
  * @param array $input Array of settings input.
  * @return array Validated settings output.
  */
 public static function validate_settings($input)
 {
     $output = array();
     if (empty($input['tag-name'])) {
         $output['tag-id'] = 0;
     } else {
         $term = get_term_by('name', $input['tag-name'], 'post_tag');
         if ($term) {
             $output['tag-id'] = $term->term_id;
         } else {
             $new_tag = wp_create_tag($input['tag-name']);
             if (!is_wp_error($new_tag) && isset($new_tag['term_id'])) {
                 $output['tag-id'] = $new_tag['term_id'];
             }
         }
         $output['tag-name'] = $input['tag-name'];
     }
     if (isset($input['quantity'])) {
         $output['quantity'] = self::sanitize_quantity($input['quantity']);
     }
     $output['hide-tag'] = isset($input['hide-tag']) && $input['hide-tag'] ? 1 : 0;
     // Delete the featured post ids transient.
     self::delete_transient();
     return $output;
 }
开发者ID:quyip8818,项目名称:wps,代码行数:39,代码来源:featured-content.php

示例4: test_terms

 function test_terms()
 {
     $this->make_user_by_role('editor');
     $tag1 = wp_create_tag('tag1');
     $this->assertInternalType('array', $tag1);
     $tag2 = wp_create_tag('tag2');
     $this->assertInternalType('array', $tag2);
     $tag3 = wp_create_tag('tag3');
     $this->assertInternalType('array', $tag3);
     $post = array('post_title' => 'Test', 'terms' => array('post_tag' => array($tag2['term_id'], $tag3['term_id'])));
     $result = $this->myxmlrpcserver->wp_newPost(array(1, 'editor', 'editor', $post));
     $this->assertNotInstanceOf('IXR_Error', $result);
     $post_tags = wp_get_object_terms($result, 'post_tag', array('fields' => 'ids'));
     $this->assertNotContains($tag1['term_id'], $post_tags);
     $this->assertContains($tag2['term_id'], $post_tags);
     $this->assertContains($tag3['term_id'], $post_tags);
 }
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:17,代码来源:newPost.php


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