Carbon_Pagination_Utilities::get_current_url()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 8
c 1
b 0
f 0
nc 3
nop 0
dl 0
loc 15
ccs 10
cts 10
cp 1
crap 4
rs 9.2
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
}