PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.5
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.5
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 13.7.2 13.8.3 All 506 releases
jetpack / jetpack_vendor / automattic / jetpack-import / src / endpoints / class-page.php

class-page.php in Jetpack – WP Security, Backup, Speed, & Growth 16.3-a.5, at jetpack_vendor/automattic/jetpack-import/src/endpoints/class-page.php

52 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Pages REST route
4 *
5 * @package automattic/jetpack-import
6 */
7
8 namespace Automattic\Jetpack\Import\Endpoints;
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
18 /**
19 * Class Page
20 */
21 class Page extends Post {
22
23 /**
24 * Constructor.
25 */
26 public function __construct() {
27 parent::__construct( 'page' );
28 }
29
30 /**
31 * Creates a single page.
32 *
33 * @param WP_REST_Request $request Full details about the request.
34 * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.
35 */
36 public function create_item( $request ) {
37 // Set the WP_IMPORTING constant to prevent sync notifications
38 $this->set_importing();
39
40 if ( ! empty( $request['parent'] ) ) {
41 $pages = \get_pages( $this->get_import_db_query( $request['parent'] ) );
42
43 // Overwrite the page parent page ID.
44 $request['parent'] = is_array( $pages ) && count( $pages ) ? $pages[0]->ID : 0;
45 }
46
47 $response = parent::create_item( $request );
48
49 return $this->add_import_id_metadata( $request, $response );
50 }
51 }
52