Skip to content

Commit

Permalink
Fix deprecation warning for htmlspecialchars (#670)
Browse files Browse the repository at this point in the history
Co-authored-by: Nícholas André <[email protected]>
  • Loading branch information
johnwatkins0 and nicholasio authored Jan 19, 2024
1 parent 297cc47 commit f18be49
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/cyan-badgers-smile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@headstartwp/headstartwp": patch
---

Ensure htmlspecialchars receives an empty string instead of null to fix deprecation warnings.
6 changes: 3 additions & 3 deletions wp/headless-wp/includes/classes/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function modify_rest_params( $args, $request ) {
return $args;
}

$author = htmlspecialchars( filter_input( INPUT_GET, 'author' ) );
$author = htmlspecialchars( filter_input( INPUT_GET, 'author' ) ?? '' );

if ( ! empty( $author ) && ! is_numeric( $author ) ) {
unset( $args['author__in'] );
Expand All @@ -108,10 +108,10 @@ public function modify_rest_params( $args, $request ) {
$taxonomies = wp_list_filter( get_object_taxonomies( $args['post_type'], 'objects' ), [ 'show_in_rest' => true ] );

foreach ( $taxonomies as $taxonomy ) {
$term = htmlspecialchars( filter_input( INPUT_GET, $taxonomy->name ) );
$term = htmlspecialchars( filter_input( INPUT_GET, $taxonomy->name ) ?? '' );

if ( ! $term ) {
$term = htmlspecialchars( filter_input( INPUT_GET, $taxonomy->rest_base ) );
$term = htmlspecialchars( filter_input( INPUT_GET, $taxonomy->rest_base ) ?? '' );
}

if ( ! empty( $term ) && ! is_numeric( $term ) ) {
Expand Down

1 comment on commit f18be49

@vercel
Copy link

@vercel vercel bot commented on f18be49 Jan 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.