← All changes
|
jetpack_vendor/automattic/jetpack-import/src/endpoints/class-custom-css.php
+16
-14
12.0.3
→
16.3-beta
View file →
| @@ -6,8 +6,16 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | namespace Automattic\Jetpack\Import\Endpoints; |
| 9 | 9 | |
| 10 | +use WP_Error; | |
| 11 | +use WP_REST_Request; | |
| 12 | +use WP_REST_Response; | |
| 13 | + | |
| 14 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 15 | + exit( 0 ); | |
| 16 | +} | |
| 17 | + | |
| 10 | 18 | require_once ABSPATH . 'wp-includes/theme.php'; |
| 11 | 19 | |
| 12 | 20 | /** |
| 13 | 21 | * Class Custom_CSS |
| @@ -14,11 +22,16 @@ | ||
| 14 | 22 | */ |
| 15 | 23 | class Custom_CSS extends \WP_REST_Posts_Controller { |
| 16 | 24 | |
| 17 | 25 | /** |
| 26 | + * Base class | |
| 27 | + */ | |
| 28 | + use Import; | |
| 29 | + | |
| 30 | + /** | |
| 18 | 31 | * The Import ID add a new item to the schema. |
| 19 | 32 | */ |
| 20 | - use Import; | |
| 33 | + use Import_ID; | |
| 21 | 34 | |
| 22 | 35 | /** |
| 23 | 36 | * Whether the controller supports batching. |
| 24 | 37 | * |
| @@ -35,21 +48,8 @@ | ||
| 35 | 48 | $this->rest_base = 'custom-css'; |
| 36 | 49 | } |
| 37 | 50 | |
| 38 | 51 | /** |
| 39 | - * Registers the routes for the objects of the controller. | |
| 40 | - * | |
| 41 | - * @see WP_REST_Posts_Controller::register_rest_route() | |
| 42 | - */ | |
| 43 | - public function register_routes() { | |
| 44 | - register_rest_route( | |
| 45 | - self::$rest_namespace, | |
| 46 | - '/' . $this->rest_base, | |
| 47 | - $this->get_route_options() | |
| 48 | - ); | |
| 49 | - } | |
| 50 | - | |
| 51 | - /** | |
| 52 | 52 | * Update the custom CSS post. |
| 53 | 53 | * |
| 54 | 54 | * @param WP_REST_Request $request Full details about the request. |
| 55 | 55 | * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. |
| @@ -54,8 +54,10 @@ | ||
| 54 | 54 | * @param WP_REST_Request $request Full details about the request. |
| 55 | 55 | * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. |
| 56 | 56 | */ |
| 57 | 57 | public function create_item( $request ) { |
| 58 | + // Set the WP_IMPORTING constant to prevent sync notifications | |
| 59 | + $this->set_importing(); | |
| 58 | 60 | $args = array( |
| 59 | 61 | 'stylesheet' => $request['title'], |
| 60 | 62 | ); |
| 61 | 63 | |