コード例 #1
0
ファイル: types.php プロジェクト: justintadlock/message-board
/**
 * Removes a topic from the list of sticky topics.
 *
 * @since  1.0.0
 * @access public
 * @param  int    $topic_id
 * @return bool
 */
function mb_remove_sticky_topic($topic_id)
{
    $topic_id = mb_get_topic_id($topic_id);
    if (mb_is_topic_sticky($topic_id)) {
        $stickies = mb_get_sticky_topics();
        $key = array_search($topic_id, $stickies);
        if (isset($stickies[$key])) {
            unset($stickies[$key]);
            return update_option('mb_sticky_topics', array_unique($stickies));
        }
    }
    return false;
}
コード例 #2
0
ファイル: query.php プロジェクト: justintadlock/message-board
/**
 * Adds sticky posts to the posts array.  Meant to be used as a filter on `the_posts`.
 *
 * @since  1.0.0
 * @access public
 * @param  array  $posts
 * @param  object $query
 * @return array
 */
function mb_posts_sticky_filter($posts, $query)
{
    remove_filter('the_posts', 'mb_posts_sticky_filter');
    $forum_id = mb_is_single_forum() ? get_queried_object_id() : 0;
    return mb_add_stickies($posts, mb_get_sticky_topics(), $forum_id);
}
コード例 #3
0
 /**
  * Add custom views (status list).
  *
  * @since  1.0.0
  * @access public
  * @param  array  $views
  * @return array
  */
 public function views($views)
 {
     $post_type = mb_get_topic_post_type();
     $super = mb_get_super_topics();
     $sticky = mb_get_sticky_topics();
     $super_count = count($super);
     $sticky_count = count($sticky);
     if (0 < $super_count) {
         $super_text = sprintf(_n('Super <span class="count">(%s)</span>', 'Super <span class="count">(%s)</span>', $super_count, 'message-board'), number_format_i18n($super_count));
         $views['super'] = sprintf('<a href="%s">%s</a>', add_query_arg(array('post_type' => $post_type, 'topic_type' => 'super'), admin_url('edit.php')), $super_text);
     }
     if (0 < $sticky_count) {
         $sticky_text = sprintf(_n('Sticky <span class="count">(%s)</span>', 'Sticky <span class="count">(%s)</span>', $sticky_count, 'message-board'), number_format_i18n($sticky_count));
         $views['sticky'] = sprintf('<a href="%s">%s</a>', add_query_arg(array('post_type' => $post_type, 'topic_type' => 'sticky'), admin_url('edit.php')), $sticky_text);
     }
     return $views;
 }