-
Notifications
You must be signed in to change notification settings - Fork 33
PCI Engagement Boost: Allow Pages and CPTs #3532
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
67d32af
Add utils/post/rest-route endpoint
acicovic 7f7a36c
Add utils/post/rest-route endpoint integration tests
acicovic fdd78b9
EndpointUtilsPostTest.php: Clean up after some tests
acicovic 36edd69
Engagement Boost: Add support for custom post types
acicovic 749fa9a
Fix linting errors
acicovic 98c8bf4
Engagement Boost: Hide for post types that don't support the REST API
acicovic 634b91f
Fix deprecated string interpolation syntax
acicovic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| <?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-escape-html', 'wp-i18n', 'wp-notices', 'wp-primitives', 'wp-url'), 'version' => 'cb305c11a90df2b8d9ae'); | ||
| <?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-escape-html', 'wp-i18n', 'wp-notices', 'wp-primitives', 'wp-url'), 'version' => '86966deca1032417599c'); |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| <?php | ||
| /** | ||
| * Utils API Endpoint: Post | ||
| * | ||
| * @package Parsely | ||
| * @since 3.20.5 | ||
| */ | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Parsely\REST_API\Utils; | ||
|
|
||
| use Parsely\REST_API\Base_Endpoint; | ||
| use Parsely\REST_API\Use_Post_ID_Parameter_Trait; | ||
| use WP_REST_Request; | ||
| use WP_REST_Response; | ||
|
|
||
| /** | ||
| * The Utils API Post endpoint. | ||
| * | ||
| * Provides an endpoint for utility functions related to Posts. | ||
| * | ||
| * @since 3.20.5 | ||
| */ | ||
| class Endpoint_Post extends Base_Endpoint { | ||
| use Use_Post_ID_Parameter_Trait; | ||
|
|
||
| /** | ||
| * Returns the endpoint's name. | ||
| * | ||
| * @since 3.20.5 | ||
| * | ||
| * @return string The endpoint's name. | ||
| */ | ||
| public static function get_endpoint_name(): string { | ||
| return 'post'; | ||
| } | ||
|
|
||
| /** | ||
| * Registers the routes for the endpoint. | ||
| * | ||
| * @since 3.20.5 | ||
| */ | ||
| public function register_routes(): void { | ||
| /** | ||
| * GET /utils/post/{post_id}/rest-route | ||
| * Returns the REST route of a Post. | ||
| */ | ||
| $this->register_rest_route_with_post_id( | ||
| '/rest-route', | ||
| array( 'GET' ), | ||
| array( $this, 'get_rest_route' ) | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * API Endpoint: GET /utils/post/{post_id}/rest-route | ||
| * | ||
| * Returns the REST route of a post. | ||
| * | ||
| * @since 3.20.5 | ||
| * | ||
| * @param WP_REST_Request $request The request object. | ||
| * @return WP_REST_Response The response object. | ||
| */ | ||
| public function get_rest_route( WP_REST_Request $request ) { | ||
| $post_id = $request->get_param( 'post_id' ); | ||
| $post_rest_route = rest_get_route_for_post( $post_id ); | ||
|
|
||
| return new WP_REST_Response( array( 'data' => $post_rest_route ), 200 ); | ||
| } | ||
acicovic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| <?php | ||
| /** | ||
| * API Utils Controller | ||
| * | ||
| * @package Parsely | ||
| * @since 3.20.5 | ||
| */ | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Parsely\REST_API\Utils; | ||
|
|
||
| use Parsely\REST_API\REST_API_Controller; | ||
| use Parsely\REST_API\Utils\Endpoint_Post; | ||
|
|
||
| /** | ||
| * The Utils API Controller. | ||
| * | ||
| * Used to define the namespace, version, and endpoints for the Utils API. | ||
| * | ||
| * @since 3.20.5 | ||
| */ | ||
| class Utils_Controller extends REST_API_Controller { | ||
| /** | ||
| * Gets the prefix for this API route. | ||
| * | ||
| * @since 3.20.5 | ||
| * | ||
| * @return string The namespace. | ||
| */ | ||
| public static function get_route_prefix(): string { | ||
| return 'utils'; | ||
| } | ||
|
|
||
| /** | ||
| * Initializes the Utils API endpoints. | ||
| * | ||
| * @since 3.20.5 | ||
| */ | ||
| public function init(): void { | ||
| $endpoints = array( | ||
| new Endpoint_Post( $this ), | ||
| ); | ||
|
|
||
| $this->register_endpoints( $endpoints ); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.