Skip to content

Commit

Permalink
Fixes PHP Deprecated: str_replace(): Passing null to parameter 2 (P…
Browse files Browse the repository at this point in the history
…HP 8.1)
  • Loading branch information
seb86 committed Dec 13, 2023
1 parent b561205 commit 4ebeafd
Showing 1 changed file with 7 additions and 2 deletions.
Expand Up @@ -250,8 +250,13 @@ public function get_items( $request ) {
$max_pages = ceil( $total_terms / $per_page );
$response->header( 'X-WP-TotalPages', (int) $max_pages );

$base = str_replace( '(?P<attribute_id>[\d]+)', $request['attribute_id'], $this->rest_base );
$base = add_query_arg( $request->get_query_params(), rest_url( '/' . $this->namespace . '/' . $base ) );
$base = '/' . $this->namespace . '/' . $this->rest_base;

if ( ! empty( $request['attribute_id'] ) ) {
$base = str_replace( '(?P<attribute_id>[\d]+)', $request['attribute_id'], $base );
}

$base = add_query_arg( $request->get_query_params(), rest_url( $base ) );

if ( $page > 1 ) {
$prev_page = $page - 1;
Expand Down

0 comments on commit 4ebeafd

Please sign in to comment.