Carbon_Pagination_Utilities   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 25
ccs 10
cts 10
cp 1
rs 10
wmc 4
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A get_current_url() 0 15 4
1
<?php
2
/**
3
 * The Carbon Pagination utilities class.
4
 * Contains various helper functionality.
5
 */
6
class Carbon_Pagination_Utilities {
7
8
	/**
9
	 * Get the current URL, in WordPress style.
10
	 *
11
	 * @static
12
	 * @return string $url The current page URL.
13
	 */
14 7
	public static function get_current_url() {
15 7
		global $wp;
16 7
		$query_vars = array();
17 7
		$permalink_structure = get_option( 'permalink_structure' );
18
19
		// preserve all query vars that are in the GET as well
20
		// if the default permalink structure is used, all query vars should be added
21 7
		foreach ( $wp->query_vars as $qv_key => $qv_value ) {
22 4
			if ( isset( $_GET[ $qv_key ] ) || ! $permalink_structure ) {
23 4
				$query_vars[ $qv_key ] = $qv_value;
24 4
			}
25 7
		}
26
27 7
		return add_query_arg( $query_vars, home_url( '/' . $wp->request ) );
28
	}
29
30
}