Add utility function to get clean URL
Enough with this annoyance!
This commit is contained in:
parent
ca3ef92068
commit
3acb67a8f5
@ -1569,4 +1569,32 @@ if ( ! function_exists( 'fictioneer_minify_html' ) ) {
|
||||
}
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// GET CLEAN CURRENT URL
|
||||
// =============================================================================
|
||||
|
||||
if ( ! function_exists( 'fictioneer_get_clean_url' ) ) {
|
||||
/**
|
||||
* Returns URL without query arguments or page number
|
||||
*
|
||||
* @since 5.4.0
|
||||
*
|
||||
* @return string The clean URL.
|
||||
*/
|
||||
|
||||
function fictioneer_get_clean_url() {
|
||||
global $wp;
|
||||
|
||||
// Setup
|
||||
$url = home_url( $wp->request );
|
||||
|
||||
// Remove page (if any)
|
||||
$url = preg_replace( '/\/page\/\d+\/$/', '', $url );
|
||||
$url = preg_replace( '/\/page\/\d+$/', '', $url );
|
||||
|
||||
// Return cleaned URL
|
||||
return $url;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -213,10 +213,7 @@ add_action( 'fictioneer_header', 'fictioneer_header_background', 10 );
|
||||
|
||||
function fictioneer_sort_order_filter_interface( $args ) {
|
||||
// Setup
|
||||
$base_uri = strtok( $_SERVER['REQUEST_URI'], '?' );
|
||||
$current_url = home_url( $base_uri );
|
||||
$current_url = preg_replace( '/\/page\/\d+\/$/', '', $current_url );
|
||||
$current_url = preg_replace( '/\/page\/\d+$/', '', $current_url );
|
||||
$current_url = fictioneer_get_clean_url();
|
||||
$post_type = null;
|
||||
|
||||
// Archive?
|
||||
|
Loading…
x
Reference in New Issue
Block a user