Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/30/2010 10:13:05 PM (16 years ago)
Author:
boonebgorges
Message:

Replaces generic 'Search anything' default directory search text with component-specific text. Fixes #1915. Fixes ->forums->slug so that it is properly set in the bp_pages way

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-templatetags.php

    r3622 r3627  
    455455        global $bp;
    456456
    457         $search_value = __( 'Search anything...', 'buddypress' );
    458         if ( !empty( $_GET['s'] ) )
    459                 $search_value = stripslashes( $_GET['s'] );
     457        $default_search_value = bp_get_search_default_text();
     458        $search_value = !empty( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : $default_search_value;
    460459
    461460        ?>
    462461        <form action="" method="get" id="search-members-form">
    463                 <label><input type="text" name="s" id="members_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>
     462                <label><input type="text" name="s" id="members_search" value="<?php echo esc_attr( $search_value ) ?>"  onfocus="if (this.value == '<?php echo $default_search_value ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php echo $default_search_value ?>';}" /></label>
    464463                <input type="submit" id="members_search_submit" name="members_search_submit" value="<?php _e( 'Search', 'buddypress' ) ?>" />
    465464        </form>
     
    10491048}
    10501049
     1050/**
     1051 * Get the default text for the search box for a given component.
     1052 *
     1053 * @global object $bp BuddyPress global settings
     1054 * @return string
     1055 * @since 1.3
     1056 */
     1057function bp_search_default_text() {
     1058        echo bp_get_search_default_text();
     1059}
     1060        function bp_get_search_default_text( $component = false ) {
     1061                global $bp;
     1062               
     1063                if ( empty( $component ) )
     1064                        $component = $bp->current_component;
     1065               
     1066                $default_text = __( 'Search anything...', 'buddypress' );
     1067               
     1068                if ( !empty( $bp->default_search_strings[$component] ) ) {
     1069                        // Most of the time, $component will be the actual component name
     1070                        $default_text = $bp->default_search_strings[$component];
     1071                } else {
     1072                        // When the request comes through AJAX, we need to get the component name
     1073                        // out of $bp->pages
     1074                        if ( !empty( $bp->pages->{$component}->slug ) ) {
     1075                                $key = $bp->pages->{$component}->slug;
     1076                                if ( !empty( $bp->default_search_strings[$key] ) )
     1077                                        $default_text = $bp->default_search_strings[$key];
     1078                        }
     1079                }
     1080               
     1081                return apply_filters( 'bp_search_default_text', $default_text, $component );
     1082        }
     1083
    10511084function bp_search_form() {
    10521085        $form = '
Note: See TracChangeset for help on using the changeset viewer.