Changeset 4502 for sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-performance-optimizations.php
- Timestamp:
- 12/08/2016 11:09:32 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-performance-optimizations.php
r4330 r4502 28 28 add_action( 'wp_ajax_wp-link-ajax', array( $this, 'disable_wp_link_ajax' ), -1 ); 29 29 add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ) ); 30 31 // Redirect search results. 32 add_action( 'bbp_template_redirect', array( $this, 'redirect_search_results_to_google_search' ) ); 33 } 34 35 /** 36 * Redirects search results to Google Custom Search. 37 */ 38 public function redirect_search_results_to_google_search() { 39 $is_wp_search = is_search(); 40 $is_bbp_search = bbp_is_search_results(); 41 42 if ( ! $is_wp_search && ! $is_bbp_search ) { 43 return; 44 } 45 46 $search_terms = $search_url = ''; 47 48 if ( $is_bbp_search ) { 49 $search_terms = bbp_get_search_terms(); 50 } elseif ( $is_wp_search ) { 51 $search_terms = get_search_query( false ); 52 } 53 54 if ( $search_terms ) { 55 $search_url = sprintf( 'https://wordpress.org/search/%s/?forums=1', urlencode( $search_terms ) ); 56 $search_url = esc_url_raw( $search_url ); 57 } 58 59 if ( ! $search_url ) { 60 wp_safe_redirect( home_url( '/' ) ); 61 exit; 62 } 63 64 wp_safe_redirect( $search_url ); 65 exit; 30 66 } 31 67
Note: See TracChangeset
for help on using the changeset viewer.