Skip to:
Content

bbPress.org

Changeset 4359


Ignore:
Timestamp:
11/08/2012 07:37:50 AM (13 years ago)
Author:
johnjamesjacoby
Message:

Suggest:

  • Add hidden and private status's to forum suggestions.
  • Sanity checks on suggestion results and improve readability.
  • Refixes #1901.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/admin/admin.php

    r4358 r4359  
    12521252     */
    12531253    public function suggest_forum() {
    1254         foreach ( get_posts( array( 's' => like_escape( $_REQUEST['q'] ), 'post_type' => bbp_get_forum_post_type() ) ) as $post ) {
    1255             echo sprintf( __( '%s - %s', 'bbpress' ), bbp_get_forum_id( $post->ID ), bbp_get_forum_title( $post->ID ) ) . "\n";
     1254
     1255        // Try to get some forums
     1256        $forums = get_posts( array(
     1257            's'           => like_escape( $_REQUEST['q'] ),
     1258            'post_type'   => bbp_get_forum_post_type(),
     1259            'post_status' => array(
     1260                bbp_get_public_status_id(),
     1261                bbp_get_hidden_status_id(),
     1262                bbp_get_private_status_id()
     1263            )
     1264        ) );
     1265
     1266        // If we found some forums, loop through and display them
     1267        if ( ! empty( $forums ) ) {
     1268            foreach ( (array) $forums as $post ) {
     1269                echo sprintf( __( '%s - %s', 'bbpress' ), bbp_get_forum_id( $post->ID ), bbp_get_forum_title( $post->ID ) ) . "\n";
     1270            }
    12561271        }
    12571272        die();
     
    12691284     */
    12701285    public function suggest_topic() {
    1271         foreach ( get_posts( array( 's' => like_escape( $_REQUEST['q'] ), 'post_type' => bbp_get_topic_post_type() ) ) as $post ) {
    1272             echo sprintf( __( '%s - %s', 'bbpress' ), bbp_get_topic_id( $post->ID ), bbp_get_topic_title( $post->ID ) ) . "\n";
     1286
     1287        // TRy to get some topics
     1288        $topics = get_posts( array(
     1289            's'         => like_escape( $_REQUEST['q'] ),
     1290            'post_type' => bbp_get_topic_post_type()
     1291        ) );
     1292
     1293        // If we found some topics, loop through and display them
     1294        if ( ! empty( $topics ) ) {
     1295            foreach ( (array) $topics as $post ) {
     1296                echo sprintf( __( '%s - %s', 'bbpress' ), bbp_get_topic_id( $post->ID ), bbp_get_topic_title( $post->ID ) ) . "\n";
     1297            }
    12731298        }
    12741299        die();
Note: See TracChangeset for help on using the changeset viewer.