Changeset 10110
- Timestamp:
- 09/14/2015 03:39:38 PM (9 years ago)
- Location:
- trunk/src
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-activity/bp-activity-loader.php
r10077 r10110 30 30 buddypress()->plugin_dir, 31 31 array( 32 'adminbar_myaccount_order' => 10 32 'adminbar_myaccount_order' => 10, 33 'search_query_arg' => 'activity_search', 33 34 ) 34 35 ); -
trunk/src/bp-activity/bp-activity-template.php
r10077 r10110 642 642 : false; 643 643 644 $search_terms_default = false; 645 $search_query_arg = bp_core_get_component_search_query_arg( 'activity' ); 646 if ( ! empty( $_REQUEST[ $search_query_arg ] ) ) { 647 $search_terms_default = stripslashes( $_REQUEST[ $search_query_arg ] ); 648 } 649 644 650 /** Parse Args ************************************************************/ 645 651 … … 677 683 678 684 // Searching 679 'search_terms' => false, // specify terms to search on685 'search_terms' => $search_terms_default, 680 686 'update_meta_cache' => true, 681 687 ), 'has_activities' ); -
trunk/src/bp-blogs/bp-blogs-loader.php
r10100 r10110 27 27 buddypress()->plugin_dir, 28 28 array( 29 'adminbar_myaccount_order' => 30 29 'adminbar_myaccount_order' => 30, 30 'search_query_arg' => 'sites_search', 30 31 ) 31 32 ); -
trunk/src/bp-blogs/bp-blogs-template.php
r10100 r10110 385 385 * @type array $include_blog_ids Array of blog IDs to limit results to. 386 386 * @type string $sort 'ASC' or 'DESC'. Default: 'DESC'. 387 * @type string $search_terms Limit results by a search term. Default: the 388 * value of $_REQUEST['s'], if present.387 * @type string $search_terms Limit results by a search term. Default: the value of `$_REQUEST['s']` or 388 * `$_REQUEST['sites_search']`, if present. 389 389 * @type int $user_id The ID of the user whose blogs should be retrieved. 390 390 * When viewing a user profile page, 'user_id' defaults to the … … 396 396 global $blogs_template; 397 397 398 // Check for and use search terms 399 $search_terms = ! empty( $_REQUEST['s'] ) 400 ? $_REQUEST['s'] 401 : false; 398 // Check for and use search terms. 399 $search_terms_default = false; 400 $search_query_arg = bp_core_get_component_search_query_arg( 'blogs' ); 401 if ( ! empty( $_REQUEST[ $search_query_arg ] ) ) { 402 $search_terms_default = stripslashes( $_REQUEST[ $search_query_arg ] ); 403 } elseif ( ! empty( $_REQUEST['s'] ) ) { 404 $search_terms_default = stripslashes( $_REQUEST['s'] ); 405 } 402 406 403 407 // Parse arguments … … 410 414 'user_id' => bp_displayed_user_id(), // Pass a user_id to limit to only blogs this user is a member of 411 415 'include_blog_ids' => false, 412 'search_terms' => $search_terms , // Pass search terms to filter on the blog title or description.416 'search_terms' => $search_terms_default, 413 417 'update_meta_cache' => true 414 418 ), 'has_blogs' ); … … 1450 1454 */ 1451 1455 function bp_directory_blogs_search_form() { 1452 $default_search_value = bp_get_search_default_text(); 1453 $search_value = !empty( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : $default_search_value; 1456 1457 $query_arg = bp_core_get_component_search_query_arg( 'blogs' ); 1458 1459 if ( ! empty( $_REQUEST[ $query_arg ] ) ) { 1460 $search_value = stripslashes( $_REQUEST[ $query_arg ] ); 1461 } else { 1462 $search_value = bp_get_search_default_text( 'blogs' ); 1463 } 1454 1464 1455 1465 $search_form_html = '<form action="" method="get" id="search-blogs-form"> 1456 <label><input type="text" name=" s" id="blogs_search" placeholder="'. esc_attr( $search_value ) .'" /></label>1466 <label><input type="text" name="' . esc_attr( $query_arg ) . '" id="blogs_search" placeholder="'. esc_attr( $search_value ) .'" /></label> 1457 1467 <input type="submit" id="blogs_search_submit" name="blogs_search_submit" value="' . __( 'Search', 'buddypress' ) . '" /> 1458 1468 </form>'; -
trunk/src/bp-core/bp-core-catchuri.php
r10108 r10110 322 322 } 323 323 324 // Set the current action 325 $bp->current_action = isset( $bp_uri[$uri_offset + 1] ) ? $bp_uri[$uri_offset + 1] : ''; 324 // Determine the current action. 325 $current_action = isset( $bp_uri[ $uri_offset + 1 ] ) ? $bp_uri[ $uri_offset + 1 ] : ''; 326 327 /* 328 * If a BuddyPress directory is set to the WP front page, URLs like example.com/members/?s=foo 329 * shouldn't interfere with blog searches. 330 */ 331 if ( empty( $current_action) && ! empty( $_GET['s'] ) && 'page' == get_option( 'show_on_front' ) && ! empty( $match->id ) ) { 332 $page_on_front = (int) get_option( 'page_on_front' ); 333 if ( (int) $match->id === $page_on_front ) { 334 $bp->current_component = ''; 335 return false; 336 } 337 } 338 339 $bp->current_action = $current_action; 326 340 327 341 // Slice the rest of the $bp_uri array and reset offset -
trunk/src/bp-core/bp-core-component.php
r10108 r10110 127 127 public $global_tables = array(); 128 128 129 /** 130 * Query argument for component search URLs. 131 * 132 * @since 2.4.0 133 * @var string 134 */ 135 public $search_query_arg = 's'; 136 129 137 /** Methods ***************************************************************/ 130 138 … … 135 143 * @since 1.9.0 Added $params as a parameter. 136 144 * @since 2.3.0 Added $params['features'] as a configurable value. 145 * @since 2.4.0 Added $params['search_query_arg'] as a configurable value. 137 146 * 138 147 * @param string $id Unique ID. Letters, numbers, and underscores only. … … 142 151 * @param array $params { 143 152 * Additional parameters used by the component. 144 * @type int $adminbar_myaccount_order Set the position for our menu under the WP Toolbar's "My Account menu". 145 * @type array $features An array of feature names. This is used to load additional files from your 146 * component directory and for feature active checks. eg. array( 'awesome' ) 147 * would look for a file called "bp-{$this->id}-awesome.php" and you could use 148 * bp_is_active( $this->id, 'awesome' ) to determine if the feature is active. 153 * @type int $adminbar_myaccount_order Set the position for our menu under the WP Toolbar's "My Account menu". 154 * @type array $features An array of feature names. This is used to load additional files from your 155 * component directory and for feature active checks. eg. array( 'awesome' ) 156 * would look for a file called "bp-{$this->id}-awesome.php" and you could use 157 * bp_is_active( $this->id, 'awesome' ) to determine if the feature is active. 158 * @type string $search_query_arg String to be used as the query argument in component search URLs. 149 159 * } 150 160 */ … … 170 180 if ( ! empty( $params['features'] ) ) { 171 181 $this->features = array_map( 'sanitize_title', (array) $params['features'] ); 182 } 183 184 if ( ! empty( $params['search_query_arg'] ) ) { 185 $this->search_query_arg = sanitize_title( $params['search_query_arg'] ); 172 186 } 173 187 -
trunk/src/bp-core/bp-core-functions.php
r10108 r10110 852 852 function bp_core_add_illegal_names() { 853 853 update_site_option( 'illegal_names', get_site_option( 'illegal_names' ), array() ); 854 } 855 856 /** 857 * Get the 'search' query argument for a given component. 858 * 859 * @since 2.4.0 860 * 861 * @param string $component Component name. 862 * @return string|bool Query argument on success. False on failure. 863 */ 864 function bp_core_get_component_search_query_arg( $component ) { 865 $query_arg = false; 866 if ( isset( buddypress()->{$component}->search_query_arg ) ) { 867 $query_arg = sanitize_title( buddypress()->{$component}->search_query_arg ); 868 } 869 870 /** 871 * Filters the query arg for a component search string. 872 * 873 * @since 2.4.0 874 * 875 * @param string $query_arg Query argument. 876 * @param string $component Component name. 877 */ 878 return apply_filters( 'bp_core_get_component_search_query_arg', $query_arg, $component ); 854 879 } 855 880 -
trunk/src/bp-groups/bp-groups-loader.php
r9936 r10110 91 91 buddypress()->plugin_dir, 92 92 array( 93 'adminbar_myaccount_order' => 70 93 'adminbar_myaccount_order' => 70, 94 'search_query_arg' => 'groups_search', 94 95 ) 95 96 ); -
trunk/src/bp-groups/bp-groups-template.php
r10075 r10110 487 487 * to groups of which the specified user 488 488 * is a member. Default: null. 489 * @type string $search_terms If provided, only groups whose names or descriptions 490 * match the search terms will be returned. Default: false. 489 * @type string $search_terms If provided, only groups whose names or descriptions match the search terms 490 * will be returned. Default: value of `$_REQUEST['groups_search']` or 491 * `$_REQUEST['s']`, if present. Otherwise false. 491 492 * @type array $meta_query An array of meta_query conditions. 492 493 * See {@link WP_Meta_Query::queries} for description. … … 534 535 535 536 // Default search string (too soon to escape here) 536 if ( ! empty( $_REQUEST['group-filter-box'] ) ) { 537 $search_query_arg = bp_core_get_component_search_query_arg( 'groups' ); 538 if ( ! empty( $_REQUEST[ $search_query_arg ] ) ) { 539 $search_terms = stripslashes( $_REQUEST[ $search_query_arg ] ); 540 } elseif ( ! empty( $_REQUEST['group-filter-box'] ) ) { 537 541 $search_terms = $_REQUEST['group-filter-box']; 538 542 } elseif ( !empty( $_REQUEST['s'] ) ) { … … 4979 4983 function bp_directory_groups_search_form() { 4980 4984 4981 $default_search_value = bp_get_search_default_text( 'groups' ); 4982 $search_value = !empty( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : $default_search_value; 4985 $query_arg = bp_core_get_component_search_query_arg( 'groups' ); 4986 4987 if ( ! empty( $_REQUEST[ $query_arg ] ) ) { 4988 $search_value = stripslashes( $_REQUEST[ $query_arg ] ); 4989 } else { 4990 $search_value = bp_get_search_default_text( 'groups' ); 4991 } 4983 4992 4984 4993 $search_form_html = '<form action="" method="get" id="search-groups-form"> 4985 <label><input type="text" name=" s" id="groups_search" placeholder="'. esc_attr( $search_value ) .'" /></label>4994 <label><input type="text" name="' . esc_attr( $query_arg ) . '" id="groups_search" placeholder="'. esc_attr( $search_value ) .'" /></label> 4986 4995 <input type="submit" id="groups_search_submit" name="groups_search_submit" value="'. __( 'Search', 'buddypress' ) .'" /> 4987 4996 </form>'; -
trunk/src/bp-members/bp-members-loader.php
r9936 r10110 35 35 buddypress()->plugin_dir, 36 36 array( 37 'adminbar_myaccount_order' => 20 37 'adminbar_myaccount_order' => 20, 38 'search_query_arg' => 'members_s', 38 39 ) 39 40 ); -
trunk/src/bp-members/bp-members-template.php
r9977 r10110 532 532 * @type string|array $member_type__not_in Array or comma-separated list of member types to exclude 533 533 * from results. 534 * @type string $search_terms Limit results by a search term. Default: null. 534 * @type string $search_terms Limit results by a search term. Default: value of 535 * `$_REQUEST['members_search']` or `$_REQUEST['s']`, if present. 536 * Otherwise false. 535 537 * @type string $meta_key Limit results by the presence of a usermeta key. 536 538 * Default: false. … … 563 565 } 564 566 567 $search_terms_default = null; 568 $search_query_arg = bp_core_get_component_search_query_arg( 'members' ); 569 if ( ! empty( $_REQUEST[ $search_query_arg ] ) ) { 570 $search_terms_default = stripslashes( $_REQUEST[ $search_query_arg ] ); 571 } 572 565 573 // type: active ( default ) | random | newest | popular | online | alphabetical 566 574 $r = bp_parse_args( $args, array( … … 579 587 'member_type__in' => '', 580 588 'member_type__not_in' => '', 581 'search_terms' => null, // Pass search_terms to filter users by their profile data589 'search_terms' => $search_terms_default, 582 590 583 591 'meta_key' => false, // Only return users with this usermeta … … 1335 1343 function bp_directory_members_search_form() { 1336 1344 1337 $default_search_value = bp_get_search_default_text( 'members' ); 1338 $search_value = !empty( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : $default_search_value; 1345 $query_arg = bp_core_get_component_search_query_arg( 'members' ); 1346 1347 if ( ! empty( $_REQUEST[ $query_arg ] ) ) { 1348 $search_value = stripslashes( $_REQUEST[ $query_arg ] ); 1349 } else { 1350 $search_value = bp_get_search_default_text( 'members' ); 1351 } 1339 1352 1340 1353 $search_form_html = '<form action="" method="get" id="search-members-form"> 1341 <label><input type="text" name=" s" id="members_search" placeholder="'. esc_attr( $search_value ) .'" /></label>1354 <label><input type="text" name="' . esc_attr( $query_arg ) . '" id="members_search" placeholder="'. esc_attr( $search_value ) .'" /></label> 1342 1355 <input type="submit" id="members_search_submit" name="members_search_submit" value="' . __( 'Search', 'buddypress' ) . '" /> 1343 1356 </form>';
Note: See TracChangeset
for help on using the changeset viewer.