Skip to:
Content

bbPress.org

Changeset 4997


Ignore:
Timestamp:
06/24/2013 03:57:07 AM (8 years ago)
Author:
johnjamesjacoby
Message:

Make search results page use pretty permalinks if they are enabled:

  • Change search form method from "get" to "post"
  • Move 'bbp_search_request_redirect' action to 'bbp_post_request' to avoid recursion.
  • Tweak bbp_search_request_redirect() to check for pretty permalinks, and remove now superfluous recursion checks.
  • See #2337.
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/core/actions.php

    r4944 r4997  
    284284
    285285// Theme-side POST requests
    286 add_action( 'bbp_post_request', 'bbp_do_ajax',                1  );
    287 add_action( 'bbp_post_request', 'bbp_edit_topic_tag_handler', 1  );
    288 add_action( 'bbp_post_request', 'bbp_edit_user_handler',      1  );
    289 add_action( 'bbp_post_request', 'bbp_edit_forum_handler',     1  );
    290 add_action( 'bbp_post_request', 'bbp_edit_reply_handler',     1  );
    291 add_action( 'bbp_post_request', 'bbp_edit_topic_handler',     1  );
    292 add_action( 'bbp_post_request', 'bbp_merge_topic_handler',    1  );
    293 add_action( 'bbp_post_request', 'bbp_split_topic_handler',    1  );
    294 add_action( 'bbp_post_request', 'bbp_move_reply_handler',     1  );
    295 add_action( 'bbp_post_request', 'bbp_new_forum_handler',      10 );
    296 add_action( 'bbp_post_request', 'bbp_new_reply_handler',      10 );
    297 add_action( 'bbp_post_request', 'bbp_new_topic_handler',      10 );
     286add_action( 'bbp_post_request', 'bbp_do_ajax',                 1  );
     287add_action( 'bbp_post_request', 'bbp_edit_topic_tag_handler',  1  );
     288add_action( 'bbp_post_request', 'bbp_edit_user_handler',       1  );
     289add_action( 'bbp_post_request', 'bbp_edit_forum_handler',      1  );
     290add_action( 'bbp_post_request', 'bbp_edit_reply_handler',      1  );
     291add_action( 'bbp_post_request', 'bbp_edit_topic_handler',      1  );
     292add_action( 'bbp_post_request', 'bbp_merge_topic_handler',     1  );
     293add_action( 'bbp_post_request', 'bbp_split_topic_handler',     1  );
     294add_action( 'bbp_post_request', 'bbp_move_reply_handler',      1  );
     295add_action( 'bbp_post_request', 'bbp_new_forum_handler',       10 );
     296add_action( 'bbp_post_request', 'bbp_new_reply_handler',       10 );
     297add_action( 'bbp_post_request', 'bbp_new_topic_handler',       10 );
     298add_action( 'bbp_post_request', 'bbp_search_results_redirect', 10 );
    298299
    299300// Theme-side GET requests
  • trunk/includes/search/functions.php

    r4928 r4997  
    5050    // Get search terms
    5151    $search_terms = bbp_get_search_terms();
    52     $retval = !empty( $search_terms ) ? array( 's' => $search_terms ) : array();
     52    $retval       = !empty( $search_terms ) ? array( 's' => $search_terms ) : array();
    5353
    5454    return apply_filters( 'bbp_get_search_query_args', $retval );
     
    6161 * @return If a redirect is not needed
    6262 */
    63 function bbp_search_template_redirect() {
    64 
    65     // Bail if already on search results page
    66     if ( bbp_is_search_results() )
     63function bbp_search_results_redirect() {
     64    global $wp_rewrite;
     65   
     66    // Bail if not using pretty permalinks
     67    if ( ! $wp_rewrite->using_permalinks() ) {
    6768        return;
    68 
    69     // Bail if search terms are empty
    70     if ( false === bbp_get_search_terms() )
    71         return;
     69    }
    7270
    7371    // Get the redirect URL
    7472    $redirect_to = bbp_get_search_results_url();
    75 
    76     // Bail if no redirect URL or may cause infinite loop
    77     if ( empty( $redirect_to ) || ( bbp_get_search_url() === $redirect_to ) )
     73    if ( empty( $redirect_to ) ) {
    7874        return;
     75    }
    7976
    8077    // Redirect and bail
  • trunk/templates/default/bbpress/form-search.php

    r4768 r4997  
    1010?>
    1111
    12 <form role="search" method="get" id="bbp-search-form" action="<?php bbp_search_url(); ?>">
     12<form role="search" method="post" id="bbp-search-form" action="<?php bbp_search_url(); ?>">
    1313    <div>
    1414        <label class="screen-reader-text hidden" for="bbp_search"><?php _e( 'Search for:', 'bbpress' ); ?></label>
Note: See TracChangeset for help on using the changeset viewer.