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rc.2 3.1.0 6.2.1 3.1.1 6.2.2 3.1.2 6.2.3 3.2.0 6.3.0 3.2.1 6.3.0-beta.1 3.2.2 6.3.0-rc.1 3.2.3 6.3.0-rc.2 3.2.4 6.3.1 3.2.5 6.3.2 3.2.6 6.4.0 3.3.0 6.4.0-beta.1 3.3.1 6.4.0-rc.1 3.3.2 6.4.1 3.3.2-rc.1 6.4.2 3.3.3 6.5.0 3.3.4 6.5.0-beta.1 3.3.5 6.5.0-rc.1 3.3.6 6.5.0-rc.2 3.4.0 6.5.1 3.4.0-beta.1 6.5.2 3.4.0-rc.2 6.6.0 3.4.1 6.6.0-beta.1 3.4.2 6.6.0-rc.1 3.4.3 6.6.0-rc.2 3.4.4 6.6.1 3.4.5 6.6.2 3.4.6 6.7.0 3.4.7 6.7.0-beta.1 3.4.8 6.7.0-beta.2 3.5.0 6.7.0-rc.1 3.5.0-beta.1 6.7.1 3.5.0-rc.1 6.8.0 3.5.0-rc.2 6.8.0-beta.1 3.5.1 6.8.0-beta.2 3.5.10 6.8.0-rc.1 3.5.2 6.8.1 3.5.3 6.8.2 3.5.4 6.8.3 3.5.5 6.9.0 3.5.6 6.9.0-beta.1 3.5.7 6.9.0-beta.2 3.5.8 6.9.0-rc.1 3.5.9 6.9.1 3.6.0 6.9.2 3.6.0-beta.1 6.9.3 3.6.0-rc.1 6.9.4 3.6.0-rc.2 6.9.5 3.6.0-rc.3 7.0.0 3.6.1 7.0.0-beta.1 3.6.2 7.0.0-beta.2 3.6.3 7.0.0-beta.3 3.6.4 7.0.0-rc.1 3.6.5 7.0.0-rc.2 3.6.6 7.0.1 3.6.7 7.0.2 3.7.0 7.1.0 3.7.0-beta.1 7.1.0-beta.1 3.7.0-rc.1 7.1.0-beta.2 3.7.0-rc.2 7.1.0-rc.1 3.7.1 7.1.0-rc.2 3.7.2 7.1.1
woocommerce / includes / rest-api / Controllers / Version3 / class-wc-rest-layout-templates-controller.php
woocommerce / includes / rest-api / Controllers / Version3 Last commit date
class-wc-rest-controller.php 1 year ago class-wc-rest-coupons-controller.php 4 years ago class-wc-rest-crud-controller.php 7 months ago class-wc-rest-customer-downloads-controller.php 5 years ago class-wc-rest-customers-controller.php 3 years ago class-wc-rest-data-continents-controller.php 4 months ago class-wc-rest-data-controller.php 5 years ago class-wc-rest-data-countries-controller.php 4 months ago class-wc-rest-data-currencies-controller.php 4 months ago class-wc-rest-layout-templates-controller.php 2 years ago class-wc-rest-network-orders-controller.php 5 years ago class-wc-rest-order-notes-controller.php 5 years ago class-wc-rest-order-refunds-controller.php 2 months ago class-wc-rest-orders-controller.php 2 months ago class-wc-rest-payment-gateways-controller.php 1 year ago class-wc-rest-paypal-buttons-controller.php 5 months ago class-wc-rest-paypal-standard-controller.php 3 months ago class-wc-rest-paypal-webhooks-controller.php 3 months ago class-wc-rest-posts-controller.php 2 years ago class-wc-rest-product-attribute-terms-controller.php 5 years ago class-wc-rest-product-attributes-controller.php 2 years ago class-wc-rest-product-brands-controller.php 1 year ago class-wc-rest-product-categories-controller.php 3 months ago class-wc-rest-product-custom-fields-controller.php 1 year ago class-wc-rest-product-reviews-controller.php 1 year ago class-wc-rest-product-shipping-classes-controller.php 1 year ago class-wc-rest-product-tags-controller.php 5 years ago class-wc-rest-product-variations-controller.php 1 month ago class-wc-rest-products-catalog-controller.php 7 months ago class-wc-rest-products-controller.php 2 months ago class-wc-rest-refunds-controller.php 2 years ago class-wc-rest-report-coupons-totals-controller.php 5 years ago class-wc-rest-report-customers-totals-controller.php 5 years ago class-wc-rest-report-orders-totals-controller.php 2 years ago class-wc-rest-report-products-totals-controller.php 5 years ago class-wc-rest-report-reviews-totals-controller.php 5 years ago class-wc-rest-report-sales-controller.php 5 years ago class-wc-rest-report-top-sellers-controller.php 5 years ago class-wc-rest-reports-controller.php 5 years ago class-wc-rest-setting-options-controller.php 4 months ago class-wc-rest-settings-controller.php 5 years ago class-wc-rest-shipping-methods-controller.php 5 years ago class-wc-rest-shipping-zone-locations-controller.php 5 years ago class-wc-rest-shipping-zone-methods-controller.php 5 years ago class-wc-rest-shipping-zones-controller-base.php 5 years ago class-wc-rest-shipping-zones-controller.php 5 years ago class-wc-rest-system-status-controller.php 5 years ago class-wc-rest-system-status-tools-controller.php 5 years ago class-wc-rest-tax-classes-controller.php 5 years ago class-wc-rest-taxes-controller.php 5 years ago class-wc-rest-terms-controller.php 1 month ago class-wc-rest-variations-controller.php 9 months ago class-wc-rest-webhooks-controller.php 5 years ago
class-wc-rest-layout-templates-controller.php
147 lines
1 <?php
2 /**
3 * REST API Layout Templates controller
4 *
5 * Handles requests to /layout-templates.
6 *
7 * @package WooCommerce\RestApi
8 * @since 8.6.0
9 */
10
11 defined( 'ABSPATH' ) || exit;
12
13 use Automattic\WooCommerce\LayoutTemplates\LayoutTemplateRegistry;
14
15 /**
16 * REST API Layout Templates controller class.
17 */
18 class WC_REST_Layout_Templates_Controller extends WC_REST_Controller {
19
20 /**
21 * Endpoint namespace.
22 *
23 * @var string
24 */
25 protected $namespace = 'wc/v3';
26
27 /**
28 * Route base.
29 *
30 * @var string
31 */
32 protected $rest_base = 'layout-templates';
33
34 /**
35 * Register the routes for template layouts.
36 */
37 public function register_routes() {
38 register_rest_route(
39 $this->namespace,
40 '/' . $this->rest_base,
41 array(
42 'methods' => WP_REST_Server::READABLE,
43 'callback' => array( $this, 'get_items' ),
44 'permission_callback' => array( $this, 'get_items_permissions_check' ),
45 'args' => array(
46 'area' => array(
47 'description' => __( 'Area to get templates for.', 'woocommerce' ),
48 'type' => 'string',
49 'default' => '',
50 ),
51 ),
52 )
53 );
54
55 register_rest_route(
56 $this->namespace,
57 '/' . $this->rest_base . '/(?P<id>\w[\w\s\-]*)',
58 array(
59 'args' => array(
60 'id' => array(
61 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
62 'type' => 'string',
63 ),
64 ),
65 array(
66 'methods' => WP_REST_Server::READABLE,
67 'callback' => array( $this, 'get_item' ),
68 'permission_callback' => array( $this, 'get_item_permissions_check' ),
69 'args' => array(),
70 ),
71 )
72 );
73 }
74
75 /**
76 * Check if a given request has access to read template layouts.
77 *
78 * @param WP_REST_Request $request The request.
79 */
80 public function get_items_permissions_check( $request ): bool {
81 return true;
82 }
83
84 /**
85 * Check if a given request has access to read a template layout.
86 *
87 * @param WP_REST_Request $request The request.
88 */
89 public function get_item_permissions_check( $request ): bool {
90 return true;
91 }
92
93 /**
94 * Handle request for template layouts.
95 *
96 * @param WP_REST_Request $request The request.
97 */
98 public function get_items( $request ) {
99 $layout_templates = $this->get_layout_templates(
100 array(
101 'area' => $request['area'],
102 )
103 );
104
105 $response = rest_ensure_response( $layout_templates );
106
107 return $response;
108 }
109
110 /**
111 * Handle request for a single template layout.
112 *
113 * @param WP_REST_Request $request The request.
114 */
115 public function get_item( $request ) {
116 $layout_templates = $this->get_layout_templates(
117 array(
118 'id' => $request['id'],
119 )
120 );
121
122 if ( count( $layout_templates ) !== 1 ) {
123 return new WP_Error( 'woocommerce_rest_layout_template_invalid_id', __( 'Invalid layout template ID.', 'woocommerce' ), array( 'status' => 404 ) );
124 }
125
126 $response = rest_ensure_response( current( $layout_templates ) );
127
128 return $response;
129 }
130
131 /**
132 * Get layout templates.
133 *
134 * @param array $query_params Query params.
135 */
136 private function get_layout_templates( array $query_params ): array {
137 $layout_template_registry = wc_get_container()->get( LayoutTemplateRegistry::class );
138
139 return array_map(
140 function( $layout_template ) {
141 return $layout_template->to_json();
142 },
143 $layout_template_registry->instantiate_layout_templates( $query_params )
144 );
145 }
146 }
147