Skip to:
Content

BuddyPress.org

Ticket #2776: bpcore-2.patch

File bpcore-2.patch, 6.6 KB (added by DJPaul, 15 years ago)

bp_core_action_search_site 2

  • bp-core/bp-core-templatetags.php

     
    456456
    457457        $search_value = __( 'Search anything...', 'buddypress' );
    458458        if ( !empty( $_GET['s'] ) )
    459                 $search_value = $_GET['s'];
     459                $search_value = stripslashes( $_GET['s'] );
    460460
    461461        ?>
    462462        <form action="" method="get" id="search-members-form">
  • bp-blogs/bp-blogs-templatetags.php

     
    502502}
    503503
    504504function bp_directory_blogs_search_form() {
    505         global $bp; ?>
     505        global $bp;
     506
     507        $search_value = __( 'Search anything...', 'buddypress' );
     508        if ( !empty( $_GET['s'] ) )
     509                $search_value = stripslashes( $_GET['s'] );
     510
     511        ?>
    506512        <form action="" method="get" id="search-blogs-form">
    507                 <label><input type="text" name="s" id="blogs_search" value="<?php if ( isset( $_GET['s'] ) ) { echo $_GET['s']; } else { _e( 'Search anything...', 'buddypress' ); } ?>"  onfocus="if (this.value == '<?php _e( 'Search anything...', 'buddypress' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'Search anything...', 'buddypress' ) ?>';}" /></label>
     513                <label><input type="text" name="s" id="blogs_search" value="<?php echo esc_attr( $search_value ) ?>"  onfocus="if (this.value == '<?php _e( 'Search anything...', 'buddypress' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'Search anything...', 'buddypress' ) ?>';}" /></label>
    508514                <input type="submit" id="blogs_search_submit" name="blogs_search_submit" value="<?php _e( 'Search', 'buddypress' ) ?>" />
    509515        </form>
    510516<?php
  • bp-forums/bp-forums-templatetags.php

     
    10301030
    10311031        $search_value = __( 'Search anything...', 'buddypress' );
    10321032        if ( !empty( $_REQUEST['fs'] ) )
    1033                 $search_value = $_REQUEST['fs'];
     1033                $search_value = stripslashes( $_REQUEST['fs'] );
    10341034
    10351035?>
    10361036        <form action="" method="get" id="search-forums-form">
    1037                 <label><input type="text" name="s" id="forums_search" value="<?php echo esc_attr($search_value) ?>"  onfocus="if (this.value == '<?php _e( 'Search anything...', 'buddypress' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'Search anything...', 'buddypress' ) ?>';}" /></label>
     1037                <label><input type="text" name="s" id="forums_search" value="<?php echo esc_attr( $search_value ) ?>"  onfocus="if (this.value == '<?php _e( 'Search anything...', 'buddypress' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'Search anything...', 'buddypress' ) ?>';}" /></label>
    10381038                <input type="submit" id="forums_search_submit" name="forums_search_submit" value="<?php _e( 'Search', 'buddypress' ) ?>" />
    10391039        </form>
    10401040<?php
  • bp-core.php

     
    16781678 *
    16791679 * @package BuddyPress Core
    16801680 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    1681  * @param $slug The slug to redirect to for searching.
     1681 * @param string $slug The slug to redirect to for searching.
    16821682 */
    1683 function bp_core_action_search_site( $slug = false ) {
     1683function bp_core_action_search_site( $slug = '' ) {
    16841684        global $bp;
    16851685
    1686         if ( $bp->current_component == BP_SEARCH_SLUG ) {
    1687                 $search_terms = $_POST['search-terms'];
    1688                 $search_which = $_POST['search-which'];
     1686        if ( BP_SEARCH_SLUG != $bp->current_component )
     1687                return;
    16891688
    1690                 if ( !$slug || empty( $slug ) ) {
    1691                         switch ( $search_which ) {
    1692                                 case 'members': default:
    1693                                         $slug = $bp->members->slug;
    1694                                         $var = '/?s=';
    1695                                         break;
    1696                                 case 'groups':
    1697                                         $slug = BP_GROUPS_SLUG;
    1698                                         $var = '/?s=';
    1699                                         break;
    1700                                 case 'forums':
    1701                                         $slug = BP_FORUMS_SLUG;
    1702                                         $var = '/?fs=';
    1703                                         break;
    1704                                 case 'blogs':
    1705                                         $slug = BP_BLOGS_SLUG;
    1706                                         $var = '/?s=';
    1707                                         break;
    1708                         }
     1689        if ( empty( $_POST['search-terms'] ) ) {
     1690                bp_core_redirect( $bp->root_domain );
     1691                return;
     1692        }
     1693
     1694        $search_terms = stripslashes( $_POST['search-terms'] );
     1695        $search_which = !empty( $_POST['search-which'] ) ? $_POST['search-which'] : '';
     1696        $query_string = '/?s=';
     1697
     1698        if ( empty( $slug ) ) {
     1699                switch ( $search_which ) {
     1700                        case 'blogs':
     1701                                $slug = bp_is_active( 'blogs' )  ? $bp->blogs->slug  : '';
     1702                                break;
     1703                        case 'forums':
     1704                                $slug = bp_is_active( 'forums' ) ? $bp->forums->slug : '';
     1705                                $query_string = '/?fs=';
     1706                                break;
     1707                        case 'groups':
     1708                                $slug = bp_is_active( 'groups' ) ? $bp->groups->slug : '';
     1709                                break;
     1710                        case 'members':
     1711                        default:
     1712                                $slug = $bp->members->slug;
     1713                                break;
    17091714                }
    17101715
    1711                 $search_url = apply_filters( 'bp_core_search_site', site_url( $slug . $var . urlencode($search_terms) ), $search_terms );
     1716                if ( empty( $slug ) ) {
     1717                        bp_core_redirect( $bp->root_domain );
     1718                        return;
     1719                }
     1720        }
    17121721
    1713                 bp_core_redirect( $search_url );
    1714         }
     1722        bp_core_redirect( apply_filters( 'bp_core_search_site', site_url( $slug . $query_string . urlencode( $search_terms ) ), $search_terms ) );
    17151723}
    17161724add_action( 'init', 'bp_core_action_search_site', 5 );
    17171725
  • bp-groups/bp-groups-templatetags.php

     
    18351835        global $bp;
    18361836
    18371837        $search_value = __( 'Search anything...', 'buddypress' );
    1838         if ( isset( $_REQUEST['s'] ) && !empty( $_REQUEST['s'] ) )
    1839                 $search_value = $_REQUEST['s'];
     1838        if ( !empty( $_REQUEST['s'] ) )
     1839                $search_value = stripslashes( $_REQUEST['s'] );
    18401840
    18411841?>
    18421842        <form action="" method="get" id="search-groups-form">
    1843                 <label><input type="text" name="s" id="groups_search" value="<?php echo esc_attr($search_value) ?>"  onfocus="if (this.value == '<?php _e( 'Search anything...', 'buddypress' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'Search anything...', 'buddypress' ) ?>';}" /></label>
     1843                <label><input type="text" name="s" id="groups_search" value="<?php echo esc_attr( $search_value ) ?>"  onfocus="if (this.value == '<?php _e( 'Search anything...', 'buddypress' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'Search anything...', 'buddypress' ) ?>';}" /></label>
    18441844                <input type="submit" id="groups_search_submit" name="groups_search_submit" value="<?php _e( 'Search', 'buddypress' ) ?>" />
    18451845        </form>
    18461846<?php