Changeset 13520 for trunk/src/bp-core/bp-core-functions.php
- Timestamp:
- 07/17/2023 09:01:08 AM (3 years ago)
- File:
-
- 1 edited
-
trunk/src/bp-core/bp-core-functions.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-functions.php
r13514 r13520 2534 2534 } 2535 2535 2536 // Set default search URL. 2537 $url = bp_get_root_url(); 2538 2536 2539 if ( empty( $_POST['search-terms'] ) ) { 2537 bp_core_redirect( bp_get_root_url());2540 bp_core_redirect( $url ); 2538 2541 return; 2539 2542 } 2540 2543 2541 $search_terms = stripslashes( $_POST['search-terms'] ); 2542 $search_which = !empty( $_POST['search-which'] ) ? $_POST['search-which'] : ''; 2543 $query_string = '/?s='; 2544 $search_terms = sanitize_text_field( wp_unslash( $_POST['search-terms'] ) ); 2545 $encoded_search_terms = urlencode( $search_terms ); 2546 $search_which = ''; 2547 2548 if ( ! empty( $_POST['search-which'] ) ) { 2549 $search_which = sanitize_key( wp_unslash( $_POST['search-which'] ) ); 2550 } 2544 2551 2545 2552 if ( empty( $slug ) ) { 2546 2553 switch ( $search_which ) { 2547 2554 case 'posts': 2548 $slug = ''; 2549 $var = '/?s='; 2555 $url = home_url(); 2550 2556 2551 2557 // If posts aren't displayed on the front page, find the post page's slug. 2552 if ( 'page' == get_option( 'show_on_front' ) ) {2558 if ( 'page' === get_option( 'show_on_front' ) ) { 2553 2559 $page = get_post( get_option( 'page_for_posts' ) ); 2554 2560 2555 if ( ! is_wp_error( $page ) && !empty( $page->post_name ) ) {2561 if ( ! is_wp_error( $page ) && ! empty( $page->post_name ) ) { 2556 2562 $slug = $page->post_name; 2557 $ var = '?s=';2563 $url = get_post_permalink( $page ); 2558 2564 } 2559 2565 } 2566 2567 $url = add_query_arg( 's', $encoded_search_terms, $url ); 2560 2568 break; 2561 2569 2562 2570 case 'activity': 2563 $slug = bp_is_active( 'activity' ) ? bp_get_activity_root_slug() : ''; 2571 if ( bp_is_active( 'activity' ) ) { 2572 $slug = bp_get_activity_root_slug(); 2573 $url = add_query_arg( 'activity_search', $encoded_search_terms, bp_get_activity_directory_permalink() ); 2574 } 2564 2575 break; 2565 2576 2566 2577 case 'blogs': 2567 $slug = bp_is_active( 'blogs' ) ? bp_get_blogs_root_slug() : ''; 2578 if ( bp_is_active( 'blogs' ) ) { 2579 $slug = bp_get_blogs_root_slug(); 2580 $url = add_query_arg( 'sites_search', $encoded_search_terms, bp_get_blogs_directory_url() ); 2581 } 2568 2582 break; 2569 2583 2570 2584 case 'groups': 2571 $slug = bp_is_active( 'groups' ) ? bp_get_groups_root_slug() : ''; 2585 if ( bp_is_active( 'groups' ) ) { 2586 $slug = bp_get_groups_root_slug(); 2587 $url = add_query_arg( 'groups_search', $encoded_search_terms, bp_get_groups_directory_url() ); 2588 } 2572 2589 break; 2573 2590 … … 2575 2592 default: 2576 2593 $slug = bp_get_members_root_slug(); 2594 $url = add_query_arg( 'members_search', $encoded_search_terms, bp_get_members_directory_permalink() ); 2577 2595 break; 2578 2596 } 2579 2597 2580 if ( empty( $slug ) && 'posts' != $search_which ) {2598 if ( empty( $slug ) && 'posts' !== $search_which ) { 2581 2599 bp_core_redirect( bp_get_root_url() ); 2582 2600 return; … … 2589 2607 * @since 1.0.0 2590 2608 * 2591 * @param string $ valueURL for use with site searching.2609 * @param string $url URL for use with site searching. 2592 2610 * @param array $search_terms Array of search terms. 2593 2611 */ 2594 bp_core_redirect( apply_filters( 'bp_core_search_site', home_url( $slug . $query_string . urlencode( $search_terms ) ), $search_terms ) );2612 bp_core_redirect( apply_filters( 'bp_core_search_site', $url, $search_terms ) ); 2595 2613 } 2596 2614
Note: See TracChangeset
for help on using the changeset viewer.