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


PHP Tags::get_by_slug方法代码示例

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


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

示例1: action_post_update_before

 public function action_post_update_before($post)
 {
     $aliases = self::get_aliases();
     if (Options::get('tagrewriter__plurals') != NULL && Options::get('tagrewriter__plurals') == 1) {
         $pluralize = true;
     } else {
         $pluralize = false;
     }
     $tags = array();
     foreach ($post->tags as $tag) {
         if (isset($aliases[$tag])) {
             $tags[] = $aliases[$tag];
             continue;
         }
         if ($pluralize) {
             if (Tags::get_by_slug($tag . 's') != false) {
                 $tags[] = $tag . 's';
                 continue;
             } elseif (Tags::get_by_slug(rtrim($tag, 's')) != false) {
                 $tags[] = rtrim($tag, 's');
                 continue;
             }
         }
         $tags[] = $tag;
     }
     $post->tags = $tags;
 }
开发者ID:habari-extras,项目名称:tagrewriter,代码行数:27,代码来源:tagrewriter.plugin.php

示例2: post_count

 /**
  * Returns the count of times a tag is used.
  *
  * @param mixed The tag to count usage.
  * @return int The number of times a tag is used.
  **/
 public static function post_count($tag)
 {
     if (is_int($tag)) {
         $tag = Tags::get_by_id($tag);
     } else {
         if (is_string($tag)) {
             $tag = Tags::get_by_slug(Utils::slugify($tag));
         }
     }
     return DB::get_row('SELECT COUNT(tag_id) AS count FROM {tag2post} WHERE tag_id = ?', array($tag->id));
 }
开发者ID:anupom,项目名称:my-blog,代码行数:17,代码来源:tags.php

示例3: delete

 /**
  * function delete
  * Deletes an existing post
  */
 public function delete()
 {
     $allow = true;
     $allow = Plugins::filter('post_delete_allow', $allow, $this);
     if (!$allow) {
         return;
     }
     // invoke plugins
     Plugins::act('post_delete_before', $this);
     // delete all the tags associated with this post
     foreach ($this->get_tags() as $tag_slug => $tag_text) {
         $tag = Tags::get_by_slug($tag_slug);
         Tag::detach_from_post($tag->id, $this->id);
     }
     // Delete all comments associated with this post
     if ($this->comments->count() > 0) {
         $this->comments->delete();
     }
     // Delete all info records associated with this post
     $this->info->delete_all();
     // Delete all post_tokens associated with this post
     $this->delete_tokens();
     $result = parent::deleteRecord(DB::table('posts'), array('slug' => $this->slug));
     EventLog::log(sprintf(_t('Post %1$s (%2$s) deleted.'), $this->id, $this->slug), 'info', 'content', 'habari');
     //scheduled post
     if ($this->status == Post::status('scheduled')) {
         Posts::update_scheduled_posts_cronjob();
     }
     // invoke plugins on the after_post_delete action
     Plugins::act('post_delete_after', $this);
     return $result;
 }
开发者ID:psaintlaurent,项目名称:Habari,代码行数:36,代码来源:post.php

示例4: action_auth_ajax_wp_import_posts


//.........这里部分代码省略.........
         // should we import categories as tags too?
         if ($inputs['category_import']) {
             // then do the same as above for the category taxonomy
             $categories = $wpdb->get_results($taxonomy_query, array(':taxonomy' => 'category', ':object_id' => $post->id));
         }
         // create the new post
         $p = new Post(array('title' => MultiByte::convert_encoding($post->post_title), 'content' => MultiByte::convert_encoding($post->post_content), 'user_id' => $user_map[$post->post_author], 'pubdate' => HabariDateTime::date_create($post->post_date), 'updated' => HabariDateTime::date_create($post->post_modified), 'slug' => MultiByte::convert_encoding($post->post_name)));
         // figure out the post type
         switch ($post->post_type) {
             case 'post':
                 $p->content_type = Post::type('entry');
                 break;
             case 'page':
                 $p->content_type = Post::type('page');
                 break;
             default:
                 // we're not importing other types - continue 2 to break out of the switch and the loop and continue to the next post
                 continue 2;
         }
         // figure out the post status
         switch ($post->post_status) {
             case 'publish':
                 $p->status = Post::status('published');
                 break;
             case 'future':
                 $p->status = Post::status('scheduled');
                 break;
             case 'pending':
                 // means pending-review, not pending as in scheduled
             // means pending-review, not pending as in scheduled
             case 'draft':
                 $p->status = Post::status('draft');
                 break;
             default:
                 // Post::status() returns false if it doesn't recognize the status type
                 $status = Post::status($post->post_status);
                 // store in a temp value because if you try and set ->status to an invalid value the Post class freaks
                 if ($status == false) {
                     // we're not importing statuses we don't recognize - continue 2 to break out of the switch and the loop and continue to the next post
                     continue 2;
                 } else {
                     $p->status = $status;
                 }
                 break;
         }
         // if comments are closed, disable them on the new post
         if ($post->comment_status == 'closed') {
             $p->info->comments_disabled = true;
         }
         // save the old post ID in info
         $p->info->wp_id = $post->id;
         // since we're not using it, save the old GUID too
         $p->info->wp_guid = $post->guid;
         // now that we've got all the pieces in place, save the post
         try {
             $p->insert();
             // now that the post is in the db we can add tags to it
             // first, if we want to import categories as tags, add them to the array
             if ($inputs['category_import']) {
                 $tags = array_merge($tags, $categories);
             }
             // now for the tags!
             foreach ($tags as $tag) {
                 // try to get the tag by slug, which is the key and therefore the most unique
                 $t = Tags::get_by_slug($tag->slug);
                 // if we didn't get back a tag, create a new one
                 if ($t == false) {
                     $t = Tag::create(array('term' => $tag->slug, 'term_display' => $tag->name));
                 }
                 // now that we have a tag (one way or the other), associate this post with it
                 $t->associate('post', $p->id);
             }
         } catch (Exception $e) {
             EventLog::log($e->getMessage(), 'err');
             echo '<p class="error">' . _t('There was an error importing post %s. See the EventLog for the error message.', array($post->post_title));
             echo '<p>' . _t('Rolling back changes&hellip;') . '</p>';
             // rollback all changes before we return so the import hasn't changed anything yet
             DB::rollback();
             // and return so they don't get AJAX to send them on to the next step
             return false;
         }
     }
     // if we've finished without an error, commit the import
     DB::commit();
     if ($max < $num_posts) {
         // if there are more posts to import
         // get the next ajax url
         $ajax_url = URL::get('auth_ajax', array('context' => 'wp_import_posts'));
         // bump the import index by one so we get a new batch next time
         $inputs['import_index']++;
     } else {
         // move on to importing comments
         // get the next ajax url
         $ajax_url = URL::get('auth_ajax', array('context' => 'wp_import_comments'));
         // reset the import index so we start at the first comment
         $inputs['import_index'] = 0;
     }
     // and spit out ajax to send them to the next step - posts!
     echo $this->get_ajax($ajax_url, $inputs);
 }
开发者ID:ringmaster,项目名称:system,代码行数:101,代码来源:wpimport.plugin.php

示例5: theme_mutiple_h1

 public function theme_mutiple_h1($theme)
 {
     $h1 = '';
     if (count($this->handler_vars) === 0) {
         $this->handler_vars = Controller::get_handler()->handler_vars;
     }
     if ($this->request->display_entries_by_date && count($this->handler_vars) > 0) {
         $date_string = '';
         $date_string .= isset($this->handler_vars['year']) ? $this->handler_vars['year'] : '';
         $date_string .= isset($this->handler_vars['month']) ? '‒' . $this->handler_vars['month'] : '';
         $date_string .= isset($this->handler_vars['day']) ? '‒' . $this->handler_vars['day'] : '';
         $h1 = '<h1>' . sprintf(_t('Posts written in %s', 'binadamu'), $date_string) . '</h1>';
     } else {
         if ($this->request->display_entries_by_tag && isset($this->handler_vars['tag'])) {
             $tag = count($this->posts) > 0 ? Tags::get_by_slug($this->handler_vars['tag'])->term_display : $this->handler_vars['tag'];
             $h1 = '<h1>' . sprintf(_t('Posts tagged with %s', 'binadamu'), htmlspecialchars($tag)) . '</h1>';
         } else {
             if ($this->request->display_search && isset($this->handler_vars['criteria'])) {
                 $h1 = '<h1>' . sprintf(_t('Search results for “%s”', 'binadamu'), htmlspecialchars($this->handler_vars['criteria'])) . '</h1>';
             }
         }
     }
     return $h1;
 }
开发者ID:habari-extras,项目名称:binadamu,代码行数:24,代码来源:theme.php


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