business-hours.php
7 months ago
class-wpcom-rest-api-v2-endpoint-admin-bar.php
2 months ago
class-wpcom-rest-api-v2-endpoint-admin-color.php
7 months ago
class-wpcom-rest-api-v2-endpoint-admin-menu.php
1 month ago
class-wpcom-rest-api-v2-endpoint-agent-guidelines-ai.php
1 week ago
class-wpcom-rest-api-v2-endpoint-ai.php
1 week ago
class-wpcom-rest-api-v2-endpoint-app-media.php
7 months ago
class-wpcom-rest-api-v2-endpoint-application-password-extras.php
3 months ago
class-wpcom-rest-api-v2-endpoint-block-editor-assets.php
2 weeks ago
class-wpcom-rest-api-v2-endpoint-blog-stats.php
7 months ago
class-wpcom-rest-api-v2-endpoint-email-preview.php
2 months ago
class-wpcom-rest-api-v2-endpoint-external-media.php
7 months ago
class-wpcom-rest-api-v2-endpoint-following.php
7 months ago
class-wpcom-rest-api-v2-endpoint-goodreads.php
7 months ago
class-wpcom-rest-api-v2-endpoint-google-docs.php
7 months ago
class-wpcom-rest-api-v2-endpoint-guidelines-banner-dismissed.php
1 week ago
class-wpcom-rest-api-v2-endpoint-instagram-gallery.php
2 months ago
class-wpcom-rest-api-v2-endpoint-mailchimp.php
7 months ago
class-wpcom-rest-api-v2-endpoint-mcp-settings.php
2 days ago
class-wpcom-rest-api-v2-endpoint-newsletter-categories-list.php
7 months ago
class-wpcom-rest-api-v2-endpoint-newsletter-categories-subscriptions-count.php
7 months ago
class-wpcom-rest-api-v2-endpoint-newsletter-email-sent-status.php
3 months ago
class-wpcom-rest-api-v2-endpoint-podcast-player.php
2 months ago
class-wpcom-rest-api-v2-endpoint-profile.php
7 months ago
class-wpcom-rest-api-v2-endpoint-related-posts.php
7 months ago
class-wpcom-rest-api-v2-endpoint-resolve-redirect.php
7 months ago
class-wpcom-rest-api-v2-endpoint-search.php
1 week ago
class-wpcom-rest-api-v2-endpoint-send-email-preview.php
1 month ago
class-wpcom-rest-api-v2-endpoint-subscribers-list.php
2 weeks ago
class-wpcom-rest-api-v2-endpoint-template-loader.php
7 months ago
class-wpcom-rest-api-v2-endpoint-top-posts.php
2 months ago
class-wpcom-rest-api-v2-endpoint-transient.php
7 months ago
class-wpcom-rest-api-v3-endpoint-blogging-prompts.php
7 months ago
class-wpcom-rest-api-v3-endpoint-jitm.php
7 months ago
gutenberg-available-extensions.php
7 months ago
hello.php
7 months ago
memberships.php
2 weeks ago
publicize-connection-test-results.php
7 months ago
service-api-keys.php
1 month ago
sites-posts-featured-media-url.php
7 months ago
subscribers.php
7 months ago
gutenberg-available-extensions.php
92 lines
| 1 | <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName |
| 2 | /** |
| 3 | * Interact with the list of available block editor extensions (blocks, plugins) |
| 4 | * made available by the Jetpack plugin. |
| 5 | * |
| 6 | * @package automattic/jetpack |
| 7 | */ |
| 8 | |
| 9 | if ( ! defined( 'ABSPATH' ) ) { |
| 10 | exit( 0 ); |
| 11 | } |
| 12 | |
| 13 | /** |
| 14 | * Gutenberg: List Available Gutenberg Extensions (Blocks and Plugins) |
| 15 | * |
| 16 | * [ |
| 17 | * { # Availability Object. See schema for more detail. |
| 18 | * available: (boolean) Whether the extension is available |
| 19 | * unavailable_reason: (string) Reason for the extension not being available |
| 20 | * }, |
| 21 | * ... |
| 22 | * ] |
| 23 | * |
| 24 | * @since 6.9 |
| 25 | */ |
| 26 | class WPCOM_REST_API_V2_Endpoint_Gutenberg_Available_Extensions extends WP_REST_Controller { |
| 27 | /** |
| 28 | * Constructor. |
| 29 | */ |
| 30 | public function __construct() { |
| 31 | $this->namespace = 'wpcom/v2'; |
| 32 | $this->rest_base = 'gutenberg'; |
| 33 | $this->wpcom_is_site_specific_endpoint = true; |
| 34 | |
| 35 | add_action( 'rest_api_init', array( $this, 'register_routes' ) ); |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Register the endpoint route. |
| 40 | */ |
| 41 | public function register_routes() { |
| 42 | register_rest_route( |
| 43 | $this->namespace, |
| 44 | $this->rest_base . '/available-extensions', |
| 45 | array( |
| 46 | array( |
| 47 | 'methods' => WP_REST_Server::READABLE, |
| 48 | 'callback' => array( 'Jetpack_Gutenberg', 'get_availability' ), |
| 49 | 'permission_callback' => array( $this, 'get_items_permission_check' ), |
| 50 | ), |
| 51 | 'schema' => array( $this, 'get_item_schema' ), |
| 52 | ) |
| 53 | ); |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Return the available Gutenberg extensions schema |
| 58 | * |
| 59 | * @return array Available Gutenberg extensions schema |
| 60 | */ |
| 61 | public function get_public_item_schema() { |
| 62 | $schema = array( |
| 63 | '$schema' => 'http://json-schema.org/draft-04/schema#', |
| 64 | 'title' => 'gutenberg-available-extensions', |
| 65 | 'type' => 'object', |
| 66 | 'properties' => array( |
| 67 | 'available' => array( |
| 68 | 'description' => __( 'Whether the extension is available', 'jetpack' ), |
| 69 | 'type' => 'boolean', |
| 70 | ), |
| 71 | 'unavailable_reason' => array( |
| 72 | 'description' => __( 'Reason for the extension not being available', 'jetpack' ), |
| 73 | 'type' => 'string', |
| 74 | ), |
| 75 | ), |
| 76 | ); |
| 77 | |
| 78 | return $this->add_additional_fields_schema( $schema ); |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * Ensure the user has proper permissions |
| 83 | * |
| 84 | * @return boolean |
| 85 | */ |
| 86 | public function get_items_permission_check() { |
| 87 | return current_user_can( 'edit_posts' ); |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | wpcom_rest_api_v2_load_plugin( 'WPCOM_REST_API_V2_Endpoint_Gutenberg_Available_Extensions' ); |
| 92 |