• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wp_create_tag函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wp_create_term函数代码示例发布时间:2022-05-23
下一篇:
PHP wp_create_post_autosave函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap