| @@ 154-156 (lines=3) @@ | ||
| 151 | $id = (int) $request['id']; |
|
| 152 | $post = get_post( $id ); |
|
| 153 | ||
| 154 | if ( empty( $id ) || empty( $post->ID ) || ! in_array( $post->post_type, $this->get_post_types() ) ) { |
|
| 155 | return new WP_Error( "woocommerce_rest_invalid_{$this->post_type}_id", __( 'Invalid ID.', 'woocommerce' ), array( 'status' => 404 ) ); |
|
| 156 | } |
|
| 157 | ||
| 158 | $data = $this->prepare_item_for_response( $post, $request ); |
|
| 159 | $response = rest_ensure_response( $data ); |
|
| @@ 258-260 (lines=3) @@ | ||
| 255 | $id = (int) $request['id']; |
|
| 256 | $post = get_post( $id ); |
|
| 257 | ||
| 258 | if ( empty( $id ) || empty( $post->ID ) || ! in_array( $post->post_type, $this->get_post_types() ) ) { |
|
| 259 | return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'ID is invalid.', 'woocommerce' ), array( 'status' => 400 ) ); |
|
| 260 | } |
|
| 261 | ||
| 262 | $post = $this->prepare_item_for_database( $request ); |
|
| 263 | if ( is_wp_error( $post ) ) { |
|
| @@ 417-419 (lines=3) @@ | ||
| 414 | $force = (bool) $request['force']; |
|
| 415 | $post = get_post( $id ); |
|
| 416 | ||
| 417 | if ( empty( $id ) || empty( $post->ID ) || ! in_array( $post->post_type, $this->get_post_types() ) ) { |
|
| 418 | return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid post id.', 'woocommerce' ), array( 'status' => 404 ) ); |
|
| 419 | } |
|
| 420 | ||
| 421 | $supports_trash = EMPTY_TRASH_DAYS > 0; |
|
| 422 | ||
| @@ 163-165 (lines=3) @@ | ||
| 160 | public function get_items( $request ) { |
|
| 161 | $order = get_post( (int) $request['order_id'] ); |
|
| 162 | ||
| 163 | if ( empty( $order->post_type ) || $this->post_type !== $order->post_type ) { |
|
| 164 | return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid order ID.', 'woocommerce' ), array( 'status' => 404 ) ); |
|
| 165 | } |
|
| 166 | ||
| 167 | $args = array( |
|
| 168 | 'post_id' => $order->ID, |
|
| @@ 202-204 (lines=3) @@ | ||
| 199 | ||
| 200 | $order = get_post( (int) $request['order_id'] ); |
|
| 201 | ||
| 202 | if ( empty( $order->post_type ) || $this->post_type !== $order->post_type ) { |
|
| 203 | return new WP_Error( 'woocommerce_rest_order_invalid_id', __( 'Invalid order ID.', 'woocommerce' ), array( 'status' => 404 ) ); |
|
| 204 | } |
|
| 205 | ||
| 206 | $order = wc_get_order( $order ); |
|
| 207 | ||
| @@ 246-248 (lines=3) @@ | ||
| 243 | $id = (int) $request['id']; |
|
| 244 | $order = get_post( (int) $request['order_id'] ); |
|
| 245 | ||
| 246 | if ( empty( $order->post_type ) || $this->post_type !== $order->post_type ) { |
|
| 247 | return new WP_Error( 'woocommerce_rest_order_invalid_id', __( 'Invalid order ID.', 'woocommerce' ), array( 'status' => 404 ) ); |
|
| 248 | } |
|
| 249 | ||
| 250 | $note = get_comment( $id ); |
|
| 251 | ||
| @@ 279-281 (lines=3) @@ | ||
| 276 | ||
| 277 | $order = get_post( (int) $request['order_id'] ); |
|
| 278 | ||
| 279 | if ( empty( $order->post_type ) || $this->post_type !== $order->post_type ) { |
|
| 280 | return new WP_Error( 'woocommerce_rest_order_invalid_id', __( 'Invalid order ID.', 'woocommerce' ), array( 'status' => 404 ) ); |
|
| 281 | } |
|
| 282 | ||
| 283 | $note = get_comment( $id ); |
|
| 284 | ||
| @@ 1734-1736 (lines=3) @@ | ||
| 1731 | $force = (bool) $request['force']; |
|
| 1732 | $post = get_post( $id ); |
|
| 1733 | ||
| 1734 | if ( empty( $id ) || empty( $post->ID ) || ! in_array( $post->post_type, $this->get_post_types() ) ) { |
|
| 1735 | return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid post ID.', 'woocommerce' ), array( 'status' => 404 ) ); |
|
| 1736 | } |
|
| 1737 | ||
| 1738 | $supports_trash = EMPTY_TRASH_DAYS > 0; |
|
| 1739 | ||
| @@ 105-107 (lines=3) @@ | ||
| 102 | public function get_items( $request ) { |
|
| 103 | $webhook = new WC_Webhook( (int) $request['webhook_id'] ); |
|
| 104 | ||
| 105 | if ( empty( $webhook->post_data->post_type ) || 'shop_webhook' !== $webhook->post_data->post_type ) { |
|
| 106 | return new WP_Error( 'woocommerce_rest_webhook_invalid_id', __( 'Invalid webhook ID.', 'woocommerce' ), array( 'status' => 404 ) ); |
|
| 107 | } |
|
| 108 | ||
| 109 | $logs = $webhook->get_delivery_logs(); |
|
| 110 | ||
| @@ 131-133 (lines=3) @@ | ||
| 128 | $id = (int) $request['id']; |
|
| 129 | $webhook = new WC_Webhook( (int) $request['webhook_id'] ); |
|
| 130 | ||
| 131 | if ( empty( $webhook->post_data->post_type ) || 'shop_webhook' !== $webhook->post_data->post_type ) { |
|
| 132 | return new WP_Error( 'woocommerce_rest_webhook_invalid_id', __( 'Invalid webhook ID.', 'woocommerce' ), array( 'status' => 404 ) ); |
|
| 133 | } |
|
| 134 | ||
| 135 | $log = $webhook->get_delivery_log( $id ); |
|
| 136 | ||
| @@ 216-218 (lines=3) @@ | ||
| 213 | $id = (int) $request['id']; |
|
| 214 | $post = get_post( $id ); |
|
| 215 | ||
| 216 | if ( empty( $id ) || empty( $post->ID ) || $this->post_type !== $post->post_type ) { |
|
| 217 | return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'ID is invalid.', 'woocommerce' ), array( 'status' => 400 ) ); |
|
| 218 | } |
|
| 219 | ||
| 220 | $webhook = new WC_Webhook( $id ); |
|
| 221 | ||
| @@ 304-306 (lines=3) @@ | ||
| 301 | ||
| 302 | $post = get_post( $id ); |
|
| 303 | ||
| 304 | if ( empty( $id ) || empty( $post->ID ) || $this->post_type !== $post->post_type ) { |
|
| 305 | return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid post ID.', 'woocommerce' ), array( 'status' => 404 ) ); |
|
| 306 | } |
|
| 307 | ||
| 308 | $request->set_param( 'context', 'edit' ); |
|
| 309 | $response = $this->prepare_item_for_response( $post, $request ); |
|
| @@ 755-757 (lines=3) @@ | ||
| 752 | try { |
|
| 753 | $post_id = (int) $request['id']; |
|
| 754 | ||
| 755 | if ( empty( $post_id ) || $this->post_type !== get_post_type( $post_id ) ) { |
|
| 756 | return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'ID is invalid.', 'woocommerce' ), array( 'status' => 400 ) ); |
|
| 757 | } |
|
| 758 | ||
| 759 | $order_id = $this->update_order( $request ); |
|
| 760 | if ( is_wp_error( $order_id ) ) { |
|