Completed
Push — update/search/migrate-to-wpes-... ( 9c956e...11a260 )
by Alex
08:29
created

Jetpack_Search_Helpers::get_widgets_from_option()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 5
nc 2
nop 0
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
class Jetpack_Search_Helpers {
4
	static function get_search_url() {
5
		$query_args = $_GET;
6
7
		// Handle the case where a permastruct is being used, such as /search/{$query}
8
		if ( ! isset( $query_args['s'] ) ) {
9
			$query_args['s'] = get_search_query();
10
		}
11
12
		if ( isset( $query_args['paged'] ) ) {
13
			unset( $query_args['paged'] );
14
		}
15
16
		$query = http_build_query( $query_args );
17
		return home_url( "?{$query}" );
18
	}
19
20
	static function add_query_arg( $key, $value = false ) {
21
		if ( is_array( $key ) ) {
22
			return add_query_arg( $key, self::get_search_url() );
23
		}
24
25
		return add_query_arg( $key, $value, self::get_search_url() );
26
	}
27
28
	static function remove_query_arg( $key ) {
29
		return remove_query_arg( $key, self::get_search_url() );
30
	}
31
}
32