Skip to:
Content

bbPress.org

Changeset 3926


Ignore:
Timestamp:
05/30/2012 10:55:38 PM (14 years ago)
Author:
johnjamesjacoby
Message:

bbp_has_topics():

  • Smarter defaults for topic-search and stickies, and both params together.
  • Rearrange default arguments to improve readability.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-includes/bbp-topic-template.php

    r3899 r3926  
    8282    // What are the default allowed statuses (based on user caps)
    8383    if ( !bbp_is_query_name( 'bbp_widget' ) && bbp_get_view_all() )
    84         $default_status = join( ',', array( bbp_get_public_status_id(), bbp_get_closed_status_id(), bbp_get_spam_status_id(), bbp_get_trash_status_id() ) );
     84        $default_post_status = join( ',', array( bbp_get_public_status_id(), bbp_get_closed_status_id(), bbp_get_spam_status_id(), bbp_get_trash_status_id() ) );
    8585    else
    86         $default_status = join( ',', array( bbp_get_public_status_id(), bbp_get_closed_status_id() ) );
    87 
    88     // Default arguments
     86        $default_post_status = join( ',', array( bbp_get_public_status_id(), bbp_get_closed_status_id() ) );
     87
     88    $default_topic_search    = !empty( $_REQUEST['ts'] ) ? $_REQUEST['ts'] : false;
     89    $default_show_stickies   = (bool) ( bbp_is_single_forum() || bbp_is_topic_archive() ) && ( false === $default_topic_search );
     90    $default_post_parent     = bbp_is_single_forum() ? bbp_get_forum_id() : 'any';
     91
     92    // Default argument array
    8993    $default = array(
    90         'post_type'      => bbp_get_topic_post_type(),                          // Narrow query down to bbPress topics
    91         'post_parent'    => bbp_is_single_forum() ? bbp_get_forum_id() : 'any', // Forum ID
    92         'meta_key'       => '_bbp_last_active_time',                            // Make sure topic has some last activity time
    93         'orderby'        => 'meta_value',                                       // 'meta_value', 'author', 'date', 'title', 'modified', 'parent', rand',
    94         'order'          => 'DESC',                                             // 'ASC', 'DESC'
    95         'posts_per_page' => bbp_get_topics_per_page(),                          // Topics per page
    96         'paged'          => bbp_get_paged(),                                    // Page Number
    97         's'              => !empty( $_REQUEST['ts'] ) ? $_REQUEST['ts'] : '',   // Topic Search
    98         'show_stickies'  => bbp_is_single_forum() || bbp_is_topic_archive(),    // Ignore sticky topics?
    99         'max_num_pages'  => false,                                              // Maximum number of pages to show
    100         'post_status'    => $default_status,                                    // Post Status
     94        'post_type'      => bbp_get_topic_post_type(), // Narrow query down to bbPress topics
     95        'post_parent'    => $default_post_parent,      // Forum ID
     96        'post_status'    => $default_post_status,      // Post Status
     97        'meta_key'       => '_bbp_last_active_time',   // Make sure topic has some last activity time
     98        'orderby'        => 'meta_value',              // 'meta_value', 'author', 'date', 'title', 'modified', 'parent', rand',
     99        'order'          => 'DESC',                    // 'ASC', 'DESC'
     100        'posts_per_page' => bbp_get_topics_per_page(), // Topics per page
     101        'paged'          => bbp_get_paged(),           // Page Number
     102        's'              => $default_topic_search,     // Topic Search
     103        'show_stickies'  => $default_show_stickies,    // Ignore sticky topics?
     104        'max_num_pages'  => false,                     // Maximum number of pages to show
    101105    );
    102106
Note: See TracChangeset for help on using the changeset viewer.