max_num_pages;
if ( ! $pages ) {
$pages = 1;
}
}
if ( $is_ajax ) {
$html = '';
if ( 1 !== $pages ) {
$pagination_unique_classes .= ' ajax-pagination-' . $class_name;
$html .= '
';
}
return $html;
} else {
if ( 1 !== $pages ) {
echo '';
}
}
}
/**
* Get current page url
*/
public static function get_current_page_url() {
$protocol = ( ! empty( $_SERVER['HTTPS'] ) && 'off' !== $_SERVER['HTTPS'] ) || ( ! empty( $_SERVER['SERVER_PORT'] ) && 443 === $_SERVER['SERVER_PORT'] ) ? 'https://' : 'http://';
if ( isset( $_SERVER['HTTP_HOST'] ) && isset( $_SERVER['REQUEST_URI'] ) ) {
$url = esc_url( wp_unslash( $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ) );
return $url;
}
return null;
}
/**
* Get page number from url
*
* @param string $url page url.
*/
public static function get_page_number_from_url( $url ) {
$pattern = '/\/page\/(\d+)\//';
if ( preg_match( $pattern, $url, $matches ) ) {
return isset( $matches[1] ) ? (int) $matches[1] : null;
}
return null;
}
}
new WO_APG_Init();