business-hours.php
4 years ago
class-wpcom-rest-api-v2-endpoint-admin-color.php
2 years ago
class-wpcom-rest-api-v2-endpoint-admin-menu.php
1 year ago
class-wpcom-rest-api-v2-endpoint-ai.php
2 years ago
class-wpcom-rest-api-v2-endpoint-app-media.php
2 years ago
class-wpcom-rest-api-v2-endpoint-blog-stats.php
2 years ago
class-wpcom-rest-api-v2-endpoint-email-preview.php
2 years ago
class-wpcom-rest-api-v2-endpoint-external-media.php
1 year ago
class-wpcom-rest-api-v2-endpoint-following.php
2 years ago
class-wpcom-rest-api-v2-endpoint-goodreads.php
2 years ago
class-wpcom-rest-api-v2-endpoint-google-docs.php
4 years ago
class-wpcom-rest-api-v2-endpoint-instagram-gallery.php
3 years ago
class-wpcom-rest-api-v2-endpoint-mailchimp.php
2 years ago
class-wpcom-rest-api-v2-endpoint-newsletter-categories-list.php
2 years ago
class-wpcom-rest-api-v2-endpoint-newsletter-categories-subscriptions-count.php
2 years ago
class-wpcom-rest-api-v2-endpoint-podcast-player.php
2 years ago
class-wpcom-rest-api-v2-endpoint-profile.php
2 years ago
class-wpcom-rest-api-v2-endpoint-publicize-share-post.php
1 year ago
class-wpcom-rest-api-v2-endpoint-publicize-share-status.php
1 year ago
class-wpcom-rest-api-v2-endpoint-related-posts.php
2 years ago
class-wpcom-rest-api-v2-endpoint-resolve-redirect.php
2 years ago
class-wpcom-rest-api-v2-endpoint-search.php
4 years ago
class-wpcom-rest-api-v2-endpoint-send-email-preview.php
2 years ago
class-wpcom-rest-api-v2-endpoint-template-loader.php
3 years ago
class-wpcom-rest-api-v2-endpoint-top-posts.php
2 years ago
class-wpcom-rest-api-v2-endpoint-transient.php
5 years ago
class-wpcom-rest-api-v3-endpoint-blogging-prompts.php
1 year ago
gutenberg-available-extensions.php
2 years ago
hello.php
4 years ago
memberships.php
1 year ago
publicize-connection-test-results.php
3 years ago
publicize-connections.php
2 years ago
publicize-services.php
3 years ago
service-api-keys.php
2 years ago
sites-posts-featured-media-url.php
2 years ago
subscribers.php
3 years ago
trait-wpcom-rest-api-proxy-request-trait.php
1 year ago
gutenberg-available-extensions.php
88 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 | /** |
| 10 | * Gutenberg: List Available Gutenberg Extensions (Blocks and Plugins) |
| 11 | * |
| 12 | * [ |
| 13 | * { # Availability Object. See schema for more detail. |
| 14 | * available: (boolean) Whether the extension is available |
| 15 | * unavailable_reason: (string) Reason for the extension not being available |
| 16 | * }, |
| 17 | * ... |
| 18 | * ] |
| 19 | * |
| 20 | * @since 6.9 |
| 21 | */ |
| 22 | class WPCOM_REST_API_V2_Endpoint_Gutenberg_Available_Extensions extends WP_REST_Controller { |
| 23 | /** |
| 24 | * Constructor. |
| 25 | */ |
| 26 | public function __construct() { |
| 27 | $this->namespace = 'wpcom/v2'; |
| 28 | $this->rest_base = 'gutenberg'; |
| 29 | $this->wpcom_is_site_specific_endpoint = true; |
| 30 | |
| 31 | add_action( 'rest_api_init', array( $this, 'register_routes' ) ); |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Register the endpoint route. |
| 36 | */ |
| 37 | public function register_routes() { |
| 38 | register_rest_route( |
| 39 | $this->namespace, |
| 40 | $this->rest_base . '/available-extensions', |
| 41 | array( |
| 42 | array( |
| 43 | 'methods' => WP_REST_Server::READABLE, |
| 44 | 'callback' => array( 'Jetpack_Gutenberg', 'get_availability' ), |
| 45 | 'permission_callback' => array( $this, 'get_items_permission_check' ), |
| 46 | ), |
| 47 | 'schema' => array( $this, 'get_item_schema' ), |
| 48 | ) |
| 49 | ); |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Return the available Gutenberg extensions schema |
| 54 | * |
| 55 | * @return array Available Gutenberg extensions schema |
| 56 | */ |
| 57 | public function get_public_item_schema() { |
| 58 | $schema = array( |
| 59 | '$schema' => 'http://json-schema.org/draft-04/schema#', |
| 60 | 'title' => 'gutenberg-available-extensions', |
| 61 | 'type' => 'object', |
| 62 | 'properties' => array( |
| 63 | 'available' => array( |
| 64 | 'description' => __( 'Whether the extension is available', 'jetpack' ), |
| 65 | 'type' => 'boolean', |
| 66 | ), |
| 67 | 'unavailable_reason' => array( |
| 68 | 'description' => __( 'Reason for the extension not being available', 'jetpack' ), |
| 69 | 'type' => 'string', |
| 70 | ), |
| 71 | ), |
| 72 | ); |
| 73 | |
| 74 | return $this->add_additional_fields_schema( $schema ); |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Ensure the user has proper permissions |
| 79 | * |
| 80 | * @return boolean |
| 81 | */ |
| 82 | public function get_items_permission_check() { |
| 83 | return current_user_can( 'edit_posts' ); |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | wpcom_rest_api_v2_load_plugin( 'WPCOM_REST_API_V2_Endpoint_Gutenberg_Available_Extensions' ); |
| 88 |