Skip to:
Content

BuddyPress.org

Ticket #6844: 6844.2.diff

File 6844.2.diff, 8.1 KB (added by boonebgorges, 8 years ago)
  • src/bp-core/bp-core-functions.php

    diff --git a/src/bp-core/bp-core-functions.php b/src/bp-core/bp-core-functions.php
    index 21f6198..d3bcbde 100644
    a b function bp_core_add_illegal_names() { 
    850850 * Get the 'search' query argument for a given component.
    851851 *
    852852 * @since 2.4.0
     853 * @since 2.7.0 The `$component` parameter was made optional, with the current component
     854 *              as the fallback value.
    853855 *
    854  * @param string $component Component name.
     856 * @param string $component Optional. Component name. Defaults to current component.
    855857 * @return string|bool Query argument on success. False on failure.
    856858 */
    857 function bp_core_get_component_search_query_arg( $component ) {
     859function bp_core_get_component_search_query_arg( $component = null ) {
     860        if ( ! $component ) {
     861                $component = bp_current_component();
     862        }
     863
    858864        $query_arg = false;
    859865        if ( isset( buddypress()->{$component}->search_query_arg ) ) {
    860866                $query_arg = sanitize_title( buddypress()->{$component}->search_query_arg );
  • src/bp-core/bp-core-template.php

    diff --git a/src/bp-core/bp-core-template.php b/src/bp-core/bp-core-template.php
    index 22bffd1..1916874 100644
    a b function bp_search_form_type_select() { 
    585585}
    586586
    587587/**
     588 * Output the 'name' attribute for search form input element.
     589 *
     590 * @since 2.7.0
     591 *
     592 * @param string $component See bp_get_search_input_name().
     593 */
     594function bp_search_input_name( $component = '' ) {
     595        echo esc_attr( bp_get_search_input_name( $component ) );
     596}
     597
     598/**
     599 * Get the 'name' attribute for the search form input element.
     600 *
     601 * @since 2.7.0
     602 *
     603 * @param string $component Component name. Defaults to current component.
     604 * @return string Text for the 'name' attribute.
     605 */
     606function bp_get_search_input_name( $component = '' ) {
     607        if ( ! $component ) {
     608                $component = bp_current_component();
     609        }
     610
     611        $bp = buddypress();
     612
     613        $name = '';
     614        if ( isset( $bp->{$component}->id ) ) {
     615                $name = $bp->{$component}->id . '_search';
     616        }
     617
     618        return $name;
     619}
     620
     621/**
     622 * Output the placeholder text for the search box for a given component.
     623 *
     624 * @since 2.7.0
     625 *
     626 * @param string $component See bp_get_search_placeholder().
     627 */
     628function bp_search_placeholder( $component = '' ) {
     629        echo esc_attr( bp_get_search_placeholder( $component ) );
     630}
     631
     632/**
     633 * Get the placeholder text for the search box for a given component.
     634 *
     635 * @since 2.7.0
     636 *
     637 * @param string $component Component name. Defaults to current component.
     638 * @return string Placeholder text for the search field.
     639 */
     640function bp_get_search_placeholder( $component = '' ) {
     641        $query_arg = bp_core_get_component_search_query_arg( $component );
     642
     643        if ( $query_arg && ! empty( $_REQUEST[ $query_arg ] ) ) {
     644                $placeholder = wp_unslash( $_REQUEST[ $query_arg ] );
     645        } else {
     646                $placeholder = bp_get_search_default_text( $component );
     647        }
     648
     649        return $placeholder;
     650}
     651
     652/**
    588653 * Output the default text for the search box for a given component.
    589654 *
    590655 * @since 1.5.0
  • src/bp-templates/bp-legacy/buddypress/blogs/index.php

    diff --git a/src/bp-templates/bp-legacy/buddypress/blogs/index.php b/src/bp-templates/bp-legacy/buddypress/blogs/index.php
    index c8460d9..9bd2ccf 100644
    a b do_action( 'bp_before_directory_blogs_page' ); ?> 
    3333         */
    3434        do_action( 'bp_before_directory_blogs_content' ); ?>
    3535
    36         <div id="blog-dir-search" class="dir-search" role="search">
    37                 <?php bp_directory_blogs_search_form(); ?>
    38         </div><!-- #blog-dir-search -->
     36        <?php /* Backward compatibility for inline search form. Use template part instead. */ ?>
     37        <?php if ( has_filter( 'bp_directory_blogs_search_form' ) ) : ?>
     38
     39                <div id="blog-dir-search" class="dir-search" role="search">
     40                        <?php bp_directory_blogs_search_form(); ?>
     41                </div><!-- #blog-dir-search -->
     42
     43        <?php else : ?>
     44
     45                <?php bp_get_template_part( 'common/search/dir-search-form' ); ?>
     46
     47        <?php endif; ?>
    3948
    4049        <?php
    4150
  • new file src/bp-templates/bp-legacy/buddypress/common/search/dir-search-form.php

    diff --git a/src/bp-templates/bp-legacy/buddypress/common/search/dir-search-form.php b/src/bp-templates/bp-legacy/buddypress/common/search/dir-search-form.php
    new file mode 100644
    index 0000000..3861e90
    - +  
     1<?php
     2/**
     3 * Output the search form markup.
     4 *
     5 * @since 2.7.0
     6 */
     7?>
     8
     9<div id="<?php echo esc_attr( bp_current_component() ); ?>-dir-search" class="dir-search" role="search">
     10        <form action="" method="get" id="search-<?php  echo esc_attr( bp_current_component() ); ?>-form">
     11                <label for="<?php bp_search_input_name(); ?>" class="bp-screen-reader-text" aria-hidden="true"><?php bp_search_placeholder(); ?></label>
     12                <input type="text" name="<?php echo esc_attr( bp_core_get_component_search_query_arg() ); ?>" id="<?php bp_search_input_name(); ?>" placeholder="<?php bp_search_placeholder(); ?>" />
     13
     14                <input type="submit" id="<?php echo esc_attr( bp_get_search_input_name() ); ?>_submit" name="<?php bp_search_input_name(); ?>_submit" value="<?php echo esc_html( 'Search', 'buddypress' ); ?>" />
     15        </form>
     16</div><!-- #<?php echo esc_attr( bp_current_component() ); ?>-dir-search -->
  • src/bp-templates/bp-legacy/buddypress/forums/index.php

    diff --git a/src/bp-templates/bp-legacy/buddypress/forums/index.php b/src/bp-templates/bp-legacy/buddypress/forums/index.php
    index 3508f30..45fc302 100644
    a b  
    2929                 */
    3030                do_action( 'bp_before_directory_forums_content' ); ?>
    3131
    32                 <div id="forums-dir-search" class="dir-search" role="search">
     32                <?php /* Backward compatibility for inline search form. Use template part instead. */ ?>
     33                <?php if ( has_filter( 'bp_directory_forums_search_form' ) ) : ?>
    3334
    34                         <?php bp_directory_forums_search_form(); ?>
     35                        <div id="forums-dir-search" class="dir-search" role="search">
     36                                <?php bp_directory_forums_search_form(); ?>
     37                        </div>
     38
     39                <?php else: ?>
     40
     41                        <?php bp_get_template_part( 'common/search/dir-search-form' ); ?>
     42
     43                <?php endif; ?>
    3544
    36                 </div>
    3745        </form>
    3846
    3947        <?php
  • src/bp-templates/bp-legacy/buddypress/groups/index.php

    diff --git a/src/bp-templates/bp-legacy/buddypress/groups/index.php b/src/bp-templates/bp-legacy/buddypress/groups/index.php
    index 1379734..f893b05 100644
    a b do_action( 'bp_before_directory_groups_page' ); ?> 
    3333         */
    3434        do_action( 'bp_before_directory_groups_content' ); ?>
    3535
    36         <div id="group-dir-search" class="dir-search" role="search">
    37                 <?php bp_directory_groups_search_form(); ?>
    38         </div><!-- #group-dir-search -->
     36        <?php /* Backward compatibility for inline search form. Use template part instead. */ ?>
     37        <?php if ( has_filter( 'bp_directory_groups_search_form' ) ) : ?>
     38
     39                <div id="group-dir-search" class="dir-search" role="search">
     40                        <?php bp_directory_groups_search_form(); ?>
     41                </div><!-- #group-dir-search -->
     42
     43        <?php else: ?>
     44
     45                <?php bp_get_template_part( 'common/search/dir-search-form' ); ?>
     46
     47        <?php endif; ?>
    3948
    4049        <form action="" method="post" id="groups-directory-form" class="dir-form">
    4150
  • src/bp-templates/bp-legacy/buddypress/members/index.php

    diff --git a/src/bp-templates/bp-legacy/buddypress/members/index.php b/src/bp-templates/bp-legacy/buddypress/members/index.php
    index 3c1a560..ba3c6ab 100644
    a b do_action( 'bp_before_directory_members_page' ); ?> 
    3333         */
    3434        do_action( 'bp_before_directory_members_content' ); ?>
    3535
    36         <div id="members-dir-search" class="dir-search" role="search">
    37                 <?php bp_directory_members_search_form(); ?>
    38         </div><!-- #members-dir-search -->
     36        <?php /* Backward compatibility for inline search form. Use template part instead. */ ?>
     37        <?php if ( has_filter( 'bp_directory_members_search_form' ) ) : ?>
    3938
    40         <?php
     39                <div id="members-dir-search" class="dir-search" role="search">
     40                        <?php bp_directory_members_search_form(); ?>
     41                </div><!-- #members-dir-search -->
     42
     43        <?php else: ?>
     44
     45                <?php bp_get_template_part( 'common/search/dir-search-form' ); ?>
    4146
     47        <?php endif; ?>
     48
     49        <?php
    4250        /**
    4351         * Fires before the display of the members list tabs.
    4452         *