Skip to content

fix: improve Governing_Data remote api contract#55

Merged
justlevine merged 3 commits intodevelopfrom
refactor/rest
Nov 12, 2025
Merged

fix: improve Governing_Data remote api contract#55
justlevine merged 3 commits intodevelopfrom
refactor/rest

Conversation

@justlevine
Copy link
Collaborator

Description

Technical Details

Fixes the REST contracts used by Governing_Data, including sanitizing and validating values.

Checklist

Screenshots

To-do

Fixes/Covers issue

Fixes #

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors and improves the Governing_Data REST API client by relocating the class, enhancing error handling, adding input sanitization, and switching to safer HTTP methods.

Key Changes:

  • Moved Governing_Data from inc/classes/rest/ to inc/Modules/Rest/ with namespace change from Onesearch\Inc\REST to Onesearch\REST\Modules
  • Enhanced methods to return WP_Error on failures instead of silently falling back to empty arrays
  • Added input sanitization using WordPress functions (sanitize_text_field, esc_url_raw)
  • Replaced wp_remote_get with wp_safe_remote_get for improved security

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
inc/classes/rest/class-governing-data.php Deleted old location of Governing_Data class
inc/Modules/Rest/Governing_Data.php New location with improved error handling, sanitization, and WP_Error returns
inc/Modules/Rest/Abstract_REST_Controller.php New base controller with shared NAMESPACE constant
inc/Modules/Rest/Rest.php Updated to remove Governing_Data::instance() call and namespace changes
inc/classes/rest/class-basic-options.php Updated import to use new Governing_Data namespace
inc/classes/algolia/class-algolia.php Added WP_Error handling for get_algolia_credentials and updated import
inc/classes/algolia/class-algolia-search.php Refactored constructor logic into register_hooks, added WP_Error checks, updated import
inc/classes/algolia/class-algolia-index-by-post.php Updated to use Abstract_REST_Controller::NAMESPACE constant
inc/Utils.php Added explicit string cast to normalize_url return value
inc/Modules/Core/Assets.php Updated to use Abstract_REST_Controller::NAMESPACE constant
inc/Main.php Updated class reference from Inc\REST to Modules\Rest\Rest

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

justlevine and others added 2 commits November 12, 2025 02:15
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@justlevine justlevine merged commit f137808 into develop Nov 12, 2025
7 of 9 checks passed
@justlevine justlevine deleted the refactor/rest branch November 12, 2025 00:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant