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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 / class-wc-api.php
woocommerce / includes Last commit date
abstracts 9 years ago admin 9 years ago api 9 years ago cli 9 years ago data-stores 9 years ago emails 9 years ago gateways 9 years ago interfaces 9 years ago legacy 9 years ago libraries 9 years ago log-handlers 9 years ago payment-tokens 9 years ago shipping 9 years ago shortcodes 9 years ago theme-support 9 years ago vendor 9 years ago walkers 9 years ago widgets 9 years ago class-wc-ajax.php 9 years ago class-wc-api.php 9 years ago class-wc-auth.php 9 years ago class-wc-autoloader.php 9 years ago class-wc-background-emailer.php 9 years ago class-wc-background-updater.php 9 years ago class-wc-breadcrumb.php 9 years ago class-wc-cache-helper.php 9 years ago class-wc-cart.php 9 years ago class-wc-checkout.php 9 years ago class-wc-cli.php 9 years ago class-wc-comments.php 9 years ago class-wc-countries.php 9 years ago class-wc-coupon.php 9 years ago class-wc-customer-download.php 9 years ago class-wc-customer.php 9 years ago class-wc-data-exception.php 9 years ago class-wc-data-store.php 9 years ago class-wc-datetime.php 9 years ago class-wc-deprecated-action-hooks.php 9 years ago class-wc-deprecated-filter-hooks.php 9 years ago class-wc-download-handler.php 9 years ago class-wc-emails.php 9 years ago class-wc-embed.php 9 years ago class-wc-form-handler.php 9 years ago class-wc-frontend-scripts.php 9 years ago class-wc-geo-ip.php 9 years ago class-wc-geolocation.php 9 years ago class-wc-https.php 9 years ago class-wc-install.php 9 years ago class-wc-integrations.php 9 years ago class-wc-legacy-api.php 9 years ago class-wc-log-levels.php 9 years ago class-wc-logger.php 9 years ago class-wc-order-factory.php 9 years ago class-wc-order-item-coupon.php 9 years ago class-wc-order-item-fee.php 9 years ago class-wc-order-item-meta.php 9 years ago class-wc-order-item-product.php 9 years ago class-wc-order-item-shipping.php 9 years ago class-wc-order-item-tax.php 9 years ago class-wc-order-item.php 9 years ago class-wc-order-refund.php 9 years ago class-wc-order.php 9 years ago class-wc-payment-gateways.php 9 years ago class-wc-payment-tokens.php 9 years ago class-wc-post-data.php 9 years ago class-wc-post-types.php 9 years ago class-wc-product-attribute.php 9 years ago class-wc-product-download.php 9 years ago class-wc-product-external.php 9 years ago class-wc-product-factory.php 9 years ago class-wc-product-grouped.php 9 years ago class-wc-product-simple.php 9 years ago class-wc-product-variable.php 9 years ago class-wc-product-variation.php 9 years ago class-wc-query.php 9 years ago class-wc-register-wp-admin-settings.php 9 years ago class-wc-session-handler.php 9 years ago class-wc-shipping-rate.php 9 years ago class-wc-shipping-zone.php 9 years ago class-wc-shipping-zones.php 9 years ago class-wc-shipping.php 9 years ago class-wc-shortcodes.php 9 years ago class-wc-structured-data.php 9 years ago class-wc-tax.php 9 years ago class-wc-template-loader.php 9 years ago class-wc-tracker.php 9 years ago class-wc-validation.php 9 years ago class-wc-webhook.php 9 years ago wc-account-functions.php 9 years ago wc-attribute-functions.php 9 years ago wc-cart-functions.php 9 years ago wc-conditional-functions.php 9 years ago wc-core-functions.php 9 years ago wc-coupon-functions.php 9 years ago wc-deprecated-functions.php 9 years ago wc-formatting-functions.php 9 years ago wc-notice-functions.php 9 years ago wc-order-functions.php 9 years ago wc-order-item-functions.php 9 years ago wc-page-functions.php 9 years ago wc-product-functions.php 9 years ago wc-rest-functions.php 9 years ago wc-stock-functions.php 9 years ago wc-template-functions.php 9 years ago wc-template-hooks.php 9 years ago wc-term-functions.php 9 years ago wc-update-functions.php 9 years ago wc-user-functions.php 9 years ago wc-webhook-functions.php 9 years ago wc-widget-functions.php 9 years ago
class-wc-api.php
293 lines
1 <?php
2 /**
3 * WooCommerce API
4 *
5 * Handles WC-API endpoint requests.
6 *
7 * @author WooThemes
8 * @category API
9 * @package WooCommerce/API
10 * @since 2.0
11 */
12
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 class WC_API extends WC_Legacy_API {
18
19 /**
20 * Setup class.
21 * @since 2.0
22 */
23 public function __construct() {
24 parent::__construct();
25
26 // Add query vars.
27 add_filter( 'query_vars', array( $this, 'add_query_vars' ), 0 );
28
29 // Register API endpoints.
30 add_action( 'init', array( $this, 'add_endpoint' ), 0 );
31
32 // Handle wc-api endpoint requests.
33 add_action( 'parse_request', array( $this, 'handle_api_requests' ), 0 );
34
35 // Ensure payment gateways are initialized in time for API requests.
36 add_action( 'woocommerce_api_request', array( 'WC_Payment_Gateways', 'instance' ), 0 );
37
38 // WP REST API.
39 $this->rest_api_init();
40 }
41
42 /**
43 * Add new query vars.
44 *
45 * @since 2.0
46 * @param array $vars
47 * @return string[]
48 */
49 public function add_query_vars( $vars ) {
50 $vars = parent::add_query_vars( $vars );
51 $vars[] = 'wc-api';
52 return $vars;
53 }
54
55 /**
56 * WC API for payment gateway IPNs, etc.
57 * @since 2.0
58 */
59 public static function add_endpoint() {
60 parent::add_endpoint();
61 add_rewrite_endpoint( 'wc-api', EP_ALL );
62 }
63
64 /**
65 * API request - Trigger any API requests.
66 *
67 * @since 2.0
68 * @version 2.4
69 */
70 public function handle_api_requests() {
71 global $wp;
72
73 if ( ! empty( $_GET['wc-api'] ) ) {
74 $wp->query_vars['wc-api'] = $_GET['wc-api'];
75 }
76
77 // wc-api endpoint requests.
78 if ( ! empty( $wp->query_vars['wc-api'] ) ) {
79
80 // Buffer, we won't want any output here.
81 ob_start();
82
83 // No cache headers.
84 nocache_headers();
85
86 // Clean the API request.
87 $api_request = strtolower( wc_clean( $wp->query_vars['wc-api'] ) );
88
89 // Trigger generic action before request hook.
90 do_action( 'woocommerce_api_request', $api_request );
91
92 // Is there actually something hooked into this API request? If not trigger 400 - Bad request.
93 status_header( has_action( 'woocommerce_api_' . $api_request ) ? 200 : 400 );
94
95 // Trigger an action which plugins can hook into to fulfill the request.
96 do_action( 'woocommerce_api_' . $api_request );
97
98 // Done, clear buffer and exit.
99 ob_end_clean();
100 die( '-1' );
101 }
102 }
103
104 /**
105 * Init WP REST API.
106 * @since 2.6.0
107 */
108 private function rest_api_init() {
109 // REST API was included starting WordPress 4.4.
110 if ( ! class_exists( 'WP_REST_Server' ) ) {
111 return;
112 }
113
114 $this->rest_api_includes();
115
116 // Init REST API routes.
117 add_action( 'rest_api_init', array( $this, 'register_rest_routes' ), 10 );
118 }
119
120 /**
121 * Include REST API classes.
122 *
123 * @since 2.6.0
124 */
125 private function rest_api_includes() {
126 // Exception handler.
127 include_once( dirname( __FILE__ ) . '/api/class-wc-rest-exception.php' );
128
129 // Authentication.
130 include_once( dirname( __FILE__ ) . '/api/class-wc-rest-authentication.php' );
131
132 // WP-API classes and functions.
133 include_once( dirname( __FILE__ ) . '/vendor/wp-rest-functions.php' );
134 if ( ! class_exists( 'WP_REST_Controller' ) ) {
135 include_once( dirname( __FILE__ ) . '/vendor/abstract-wp-rest-controller.php' );
136 }
137
138 // Abstract controllers.
139 include_once( dirname( __FILE__ ) . '/abstracts/abstract-wc-rest-controller.php' );
140 include_once( dirname( __FILE__ ) . '/abstracts/abstract-wc-rest-posts-controller.php' );
141 include_once( dirname( __FILE__ ) . '/abstracts/abstract-wc-rest-crud-controller.php' );
142 include_once( dirname( __FILE__ ) . '/abstracts/abstract-wc-rest-terms-controller.php' );
143 include_once( dirname( __FILE__ ) . '/abstracts/abstract-wc-rest-shipping-zones-controller.php' );
144 include_once( dirname( __FILE__ ) . '/abstracts/abstract-wc-settings-api.php' );
145
146 // REST API v1 controllers.
147 include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-coupons-controller.php' );
148 include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-customer-downloads-controller.php' );
149 include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-customers-controller.php' );
150 include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-orders-controller.php' );
151 include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-order-notes-controller.php' );
152 include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-order-refunds-controller.php' );
153 include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-product-attribute-terms-controller.php' );
154 include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-product-attributes-controller.php' );
155 include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-product-categories-controller.php' );
156 include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-product-reviews-controller.php' );
157 include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-product-shipping-classes-controller.php' );
158 include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-product-tags-controller.php' );
159 include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-products-controller.php' );
160 include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-report-sales-controller.php' );
161 include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-report-top-sellers-controller.php' );
162 include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-reports-controller.php' );
163 include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-tax-classes-controller.php' );
164 include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-taxes-controller.php' );
165 include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-webhook-deliveries.php' );
166 include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-webhooks-controller.php' );
167
168 // Legacy v2 code.
169 include_once( dirname( __FILE__ ) . '/api/legacy/class-wc-rest-legacy-coupons-controller.php' );
170 include_once( dirname( __FILE__ ) . '/api/legacy/class-wc-rest-legacy-orders-controller.php' );
171 include_once( dirname( __FILE__ ) . '/api/legacy/class-wc-rest-legacy-products-controller.php' );
172
173 // REST API v2 controllers.
174 include_once( dirname( __FILE__ ) . '/api/class-wc-rest-coupons-controller.php' );
175 include_once( dirname( __FILE__ ) . '/api/class-wc-rest-customer-downloads-controller.php' );
176 include_once( dirname( __FILE__ ) . '/api/class-wc-rest-customers-controller.php' );
177 include_once( dirname( __FILE__ ) . '/api/class-wc-rest-orders-controller.php' );
178 include_once( dirname( __FILE__ ) . '/api/class-wc-rest-order-notes-controller.php' );
179 include_once( dirname( __FILE__ ) . '/api/class-wc-rest-order-refunds-controller.php' );
180 include_once( dirname( __FILE__ ) . '/api/class-wc-rest-product-attribute-terms-controller.php' );
181 include_once( dirname( __FILE__ ) . '/api/class-wc-rest-product-attributes-controller.php' );
182 include_once( dirname( __FILE__ ) . '/api/class-wc-rest-product-categories-controller.php' );
183 include_once( dirname( __FILE__ ) . '/api/class-wc-rest-product-reviews-controller.php' );
184 include_once( dirname( __FILE__ ) . '/api/class-wc-rest-product-shipping-classes-controller.php' );
185 include_once( dirname( __FILE__ ) . '/api/class-wc-rest-product-tags-controller.php' );
186 include_once( dirname( __FILE__ ) . '/api/class-wc-rest-products-controller.php' );
187 include_once( dirname( __FILE__ ) . '/api/class-wc-rest-product-variations-controller.php' );
188 include_once( dirname( __FILE__ ) . '/api/class-wc-rest-report-sales-controller.php' );
189 include_once( dirname( __FILE__ ) . '/api/class-wc-rest-report-top-sellers-controller.php' );
190 include_once( dirname( __FILE__ ) . '/api/class-wc-rest-reports-controller.php' );
191 include_once( dirname( __FILE__ ) . '/api/class-wc-rest-settings-controller.php' );
192 include_once( dirname( __FILE__ ) . '/api/class-wc-rest-setting-options-controller.php' );
193 include_once( dirname( __FILE__ ) . '/api/class-wc-rest-shipping-zones-controller.php' );
194 include_once( dirname( __FILE__ ) . '/api/class-wc-rest-shipping-zone-locations-controller.php' );
195 include_once( dirname( __FILE__ ) . '/api/class-wc-rest-shipping-zone-methods-controller.php' );
196 include_once( dirname( __FILE__ ) . '/api/class-wc-rest-tax-classes-controller.php' );
197 include_once( dirname( __FILE__ ) . '/api/class-wc-rest-taxes-controller.php' );
198 include_once( dirname( __FILE__ ) . '/api/class-wc-rest-webhook-deliveries.php' );
199 include_once( dirname( __FILE__ ) . '/api/class-wc-rest-webhooks-controller.php' );
200 include_once( dirname( __FILE__ ) . '/api/class-wc-rest-system-status-controller.php' );
201 include_once( dirname( __FILE__ ) . '/api/class-wc-rest-system-status-tools-controller.php' );
202 include_once( dirname( __FILE__ ) . '/api/class-wc-rest-shipping-methods-controller.php' );
203 include_once( dirname( __FILE__ ) . '/api/class-wc-rest-payment-gateways-controller.php' );
204 }
205
206 /**
207 * Register REST API routes.
208 * @since 2.6.0
209 */
210 public function register_rest_routes() {
211 // Register settings to the REST API.
212 $this->register_wp_admin_settings();
213
214 $controllers = array(
215 // v1 controllers.
216 'WC_REST_Coupons_V1_Controller',
217 'WC_REST_Customer_Downloads_V1_Controller',
218 'WC_REST_Customers_V1_Controller',
219 'WC_REST_Order_Notes_V1_Controller',
220 'WC_REST_Order_Refunds_V1_Controller',
221 'WC_REST_Orders_V1_Controller',
222 'WC_REST_Product_Attribute_Terms_V1_Controller',
223 'WC_REST_Product_Attributes_V1_Controller',
224 'WC_REST_Product_Categories_V1_Controller',
225 'WC_REST_Product_Reviews_V1_Controller',
226 'WC_REST_Product_Shipping_Classes_V1_Controller',
227 'WC_REST_Product_Tags_V1_Controller',
228 'WC_REST_Products_V1_Controller',
229 'WC_REST_Report_Sales_V1_Controller',
230 'WC_REST_Report_Top_Sellers_V1_Controller',
231 'WC_REST_Reports_V1_Controller',
232 'WC_REST_Tax_Classes_V1_Controller',
233 'WC_REST_Taxes_V1_Controller',
234 'WC_REST_Webhook_Deliveries_V1_Controller',
235 'WC_REST_Webhooks_V1_Controller',
236
237 // v2 controllers.
238 'WC_REST_Coupons_Controller',
239 'WC_REST_Customer_Downloads_Controller',
240 'WC_REST_Customers_Controller',
241 'WC_REST_Order_Notes_Controller',
242 'WC_REST_Order_Refunds_Controller',
243 'WC_REST_Orders_Controller',
244 'WC_REST_Product_Attribute_Terms_Controller',
245 'WC_REST_Product_Attributes_Controller',
246 'WC_REST_Product_Categories_Controller',
247 'WC_REST_Product_Reviews_Controller',
248 'WC_REST_Product_Shipping_Classes_Controller',
249 'WC_REST_Product_Tags_Controller',
250 'WC_REST_Products_Controller',
251 'WC_REST_Product_Variations_Controller',
252 'WC_REST_Report_Sales_Controller',
253 'WC_REST_Report_Top_Sellers_Controller',
254 'WC_REST_Reports_Controller',
255 'WC_REST_Settings_Controller',
256 'WC_REST_Setting_Options_Controller',
257 'WC_REST_Shipping_Zones_Controller',
258 'WC_REST_Shipping_Zone_Locations_Controller',
259 'WC_REST_Shipping_Zone_Methods_Controller',
260 'WC_REST_Tax_Classes_Controller',
261 'WC_REST_Taxes_Controller',
262 'WC_REST_Webhook_Deliveries_Controller',
263 'WC_REST_Webhooks_Controller',
264 'WC_REST_System_Status_Controller',
265 'WC_REST_System_Status_Tools_Controller',
266 'WC_REST_Shipping_Methods_Controller',
267 'WC_REST_Payment_Gateways_Controller',
268 );
269
270 foreach ( $controllers as $controller ) {
271 $this->$controller = new $controller();
272 $this->$controller->register_routes();
273 }
274 }
275
276 /**
277 * Register WC settings from WP-API to the REST API.
278 * @since 3.0.0
279 */
280 public function register_wp_admin_settings() {
281 $pages = WC_Admin_Settings::get_settings_pages();
282 foreach ( $pages as $page ) {
283 new WC_Register_WP_Admin_Settings( $page, 'page' );
284 }
285
286 $emails = WC_Emails::instance();
287 foreach ( $emails->get_emails() as $email ) {
288 new WC_Register_WP_Admin_Settings( $email, 'email' );
289 }
290 }
291
292 }
293