PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3
Jetpack – WP Security, Backup, Speed, & Growth v16.3
16.3 16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 All 508 releases
← All changes | jetpack_vendor/automattic/jetpack-import/src/endpoints/class-menu-item.php +17 -14 12.0.3 → 16.3 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 /**
11 19 * Class Menu_Item
12 20 */
13 21 class Menu_Item extends \WP_REST_Menu_Items_Controller {
@@ -12,11 +20,16 @@
12 20 */
13 21 class Menu_Item extends \WP_REST_Menu_Items_Controller {
14 22
15 23 /**
24 + * Base class
25 + */
26 + use Import;
27 +
28 + /**
16 29 * The Import ID add a new item to the schema.
17 30 */
18 - use Import;
31 + use Import_ID;
19 32
20 33 /**
21 34 * Whether the controller supports batching. Default true.
22 35 *
@@ -34,21 +47,8 @@
34 47 $this->import_id_meta_type = 'post';
35 48 }
36 49
37 50 /**
38 - * Registers the routes for the objects of the controller.
39 - *
40 - * @see WP_REST_Terms_Controller::register_rest_route()
41 - */
42 - public function register_routes() {
43 - register_rest_route(
44 - self::$rest_namespace,
45 - '/menu-items',
46 - $this->get_route_options()
47 - );
48 - }
49 -
50 - /**
51 51 * Adds the schema from additional fields to a schema array.
52 52 *
53 53 * The type of object is inferred from the passed schema.
54 54 *
@@ -70,8 +70,11 @@
70 70 * @param WP_REST_Request $request Full details about the request.
71 71 * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.
72 72 */
73 73 public function create_item( $request ) {
74 + // Set the WP_IMPORTING constant to prevent sync notifications
75 + $this->set_importing();
76 +
74 77 if ( ! empty( $request['menus'] ) ) {
75 78 $menu_id = \term_exists( $request['menus'], 'nav_menu' );
76 79
77 80 if ( $menu_id ) {