WordPress 7.1.3
This commit is contained in:
@@ -439,6 +439,9 @@ class DB {
|
||||
return '';
|
||||
}
|
||||
|
||||
$host = Helper::get_home_url();
|
||||
$url = str_replace( $host, '', $url );
|
||||
|
||||
$url = urldecode( preg_replace( '/#.*$/', '', $url ) );
|
||||
|
||||
$url = self::remove_hash( $url );
|
||||
@@ -446,22 +449,18 @@ class DB {
|
||||
// Parse the URL to get the path component.
|
||||
$parsed_url = wp_parse_url( $url );
|
||||
if ( isset( $parsed_url['path'] ) ) {
|
||||
return $parsed_url['path'];
|
||||
$page = $parsed_url['path'];
|
||||
} else {
|
||||
// Remove ASCII domain. idn_to_ascii() needs ext-intl, which isn't
|
||||
// guaranteed to be installed on every host — fall back to the
|
||||
// unconverted host rather than fatal-erroring when it's missing.
|
||||
$host_ascii = function_exists( 'idn_to_ascii' ) ? idn_to_ascii( $host ) : $host;
|
||||
$url = str_replace( $host_ascii, '', $url );
|
||||
|
||||
$page = preg_replace( '#^https?://(www\.)?#i', '', $url );
|
||||
}
|
||||
|
||||
// Fallback: try to extract path by removing domain.
|
||||
$host = Helper::get_home_url();
|
||||
$url = str_replace( $host, '', $url );
|
||||
|
||||
// Remove ASCII domain. idn_to_ascii() needs ext-intl, which isn't
|
||||
// guaranteed to be installed on every host — fall back to the
|
||||
// unconverted host rather than fatal-erroring when it's missing.
|
||||
$host_ascii = function_exists( 'idn_to_ascii' ) ? idn_to_ascii( $host ) : $host;
|
||||
$url = str_replace( $host_ascii, '', $url );
|
||||
|
||||
$url = preg_replace( '#^https?://(www\.)?#i', '', $url );
|
||||
|
||||
return apply_filters( 'rank_math/analytics/get_page', $url );
|
||||
return apply_filters( 'rank_math/analytics/get_page', $page );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -61,8 +61,9 @@ class Objects extends Summary {
|
||||
'noData' => $request->get_param( 'noData' ),
|
||||
];
|
||||
$field_name = 'seo_score';
|
||||
$per_page = $request->get_param( 'per_page' ) ? sanitize_text_field( $request->get_param( 'per_page' ) ) : 25;
|
||||
$offset = ( sanitize_text_field( $request->get_param( 'page' ) ) - 1 ) * $per_page;
|
||||
$per_page = absint( $request->get_param( 'per_page' ) );
|
||||
$per_page = $per_page ? min( $per_page, 100 ) : 25;
|
||||
$offset = ( max( 1, absint( $request->get_param( 'page' ) ) ) - 1 ) * $per_page;
|
||||
|
||||
// Construct SQL condition based on filter parameters.
|
||||
$conditions = [];
|
||||
|
||||
@@ -48,6 +48,20 @@ class Rest extends WP_REST_Controller {
|
||||
],
|
||||
'postsRowsByObjects' => [
|
||||
'callback' => [ Stats::get(), 'get_posts_rows_by_objects' ],
|
||||
'args' => [
|
||||
'page' => [
|
||||
'description' => esc_html__( 'Page number.', 'seo-by-rank-math' ),
|
||||
'type' => 'integer',
|
||||
'required' => false,
|
||||
'sanitize_callback' => 'absint',
|
||||
],
|
||||
'per_page' => [
|
||||
'description' => esc_html__( 'Results per page.', 'seo-by-rank-math' ),
|
||||
'type' => 'integer',
|
||||
'required' => false,
|
||||
'sanitize_callback' => 'absint',
|
||||
],
|
||||
],
|
||||
],
|
||||
'post/(?P<id>\d+)' => [
|
||||
'callback' => [ $this, 'get_post' ],
|
||||
|
||||
Reference in New Issue
Block a user