Skip to content

Conversation

@NishilHoogar
Copy link
Collaborator

@NishilHoogar NishilHoogar commented Oct 24, 2025

Added includes/class-wpfa-rest.php to encapsulate all REST API logic in a modular structure.

Summary by Sourcery

Add a new REST API component to serve event and speaker data and integrate it into the plugin initialization

New Features:

  • Expose GET /wpfa/v1/speakers and GET /wpfa/v1/events endpoints with transient caching
  • Support creating speakers via POST /wpfa/v1/speakers with permission checks and cache invalidation

Enhancements:

  • Modularize REST API logic into a dedicated WPFA_REST class

Chores:

  • Load and initialize the WPFA_REST class in the plugin loader

Added includes/class-wpfa-rest.php to encapsulate all REST API logic in a modular structure.
@sourcery-ai
Copy link

sourcery-ai bot commented Oct 24, 2025

🧙 Sourcery has finished reviewing your pull request!


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@mariobehling mariobehling requested a review from Copilot October 26, 2025 18:13
Copy link

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 introduces REST API endpoints to the WPFA Event plugin, enabling programmatic access to speakers and events data. The implementation follows WordPress REST API standards with proper authentication, caching, and modular code structure.

Key changes:

  • Created a new WPFA_REST class to handle REST API routes for speakers (GET/POST) and events (GET)
  • Integrated transient caching (1 hour TTL) for improved performance on read operations
  • Updated the plugin loader to initialize the REST API component

Reviewed Changes

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

File Description
includes/class-wpfa-rest.php New REST API handler providing endpoints for speakers and events with caching and permission controls
includes/class-wpfa-loader.php Updated to load and initialize the new WPFA_REST class

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

Comment on lines +190 to +215
private function get_speaker_schema() {
return [
'name' => [
'required' => true,
'type' => 'string',
'sanitize_callback' => 'sanitize_text_field',
],
'bio' => [
'required' => false,
'type' => 'string',
],
'organization' => [
'required' => false,
'type' => 'string',
],
'role' => [
'required' => false,
'type' => 'string',
],
'photo_url' => [
'required' => false,
'type' => 'string',
'format' => 'uri',
],
];
}
Copy link

Copilot AI Oct 26, 2025

Choose a reason for hiding this comment

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

The schema defines sanitize_callback for 'name' but not for other fields. The 'bio', 'organization', and 'role' fields should also have sanitize callbacks to ensure consistent input sanitization. Add 'sanitize_callback' => 'sanitize_text_field' for 'organization' and 'role', and 'sanitize_callback' => 'sanitize_textarea_field' for 'bio'.

Copilot uses AI. Check for mistakes.
Comment on lines +210 to +212
'required' => false,
'type' => 'string',
'format' => 'uri',
Copy link

Copilot AI Oct 26, 2025

Choose a reason for hiding this comment

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

The 'photo_url' field in the schema lacks a sanitize_callback. Add 'sanitize_callback' => 'esc_url_raw' to ensure URLs are properly sanitized, matching the sanitization used in create_speaker() at line 128.

Suggested change
'required' => false,
'type' => 'string',
'format' => 'uri',
'required' => false,
'type' => 'string',
'format' => 'uri',
'sanitize_callback' => 'esc_url_raw',

Copilot uses AI. Check for mistakes.
Comment on lines 76 to 82
$query = new WP_Query(
[
'post_type' => 'wpfa_speaker',
'posts_per_page' => -1,
'post_status' => 'publish',
]
);
Copy link

Copilot AI Oct 26, 2025

Choose a reason for hiding this comment

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

Using 'posts_per_page' => -1 retrieves all speakers without pagination, which could cause performance issues with a large number of speakers. Consider implementing pagination parameters in the REST endpoint or setting a reasonable upper limit to prevent memory exhaustion.

Copilot uses AI. Check for mistakes.
Comment on lines 149 to 155
$query = new WP_Query(
[
'post_type' => 'wpfa_event',
'posts_per_page' => -1,
'post_status' => 'publish',
]
);
Copy link

Copilot AI Oct 26, 2025

Choose a reason for hiding this comment

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

Using 'posts_per_page' => -1 retrieves all events without pagination, which could cause performance issues with a large number of events. Consider implementing pagination parameters in the REST endpoint or setting a reasonable upper limit to prevent memory exhaustion.

Copilot uses AI. Check for mistakes.
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