Moved hook like in master v3
This commit is contained in:
parent
4ba989a07e
commit
1d0bd12a46
|
@ -196,6 +196,15 @@ abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->update_additional_fields_for_object( $object, $request );
|
$this->update_additional_fields_for_object( $object, $request );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fires after a single object is created or updated via the REST API.
|
||||||
|
*
|
||||||
|
* @param WC_Data $object Inserted object.
|
||||||
|
* @param WP_REST_Request $request Request object.
|
||||||
|
* @param boolean $creating True when creating object, false when updating.
|
||||||
|
*/
|
||||||
|
do_action( "woocommerce_rest_insert_{$this->post_type}_object", $object, $request, true );
|
||||||
} catch ( WC_Data_Exception $e ) {
|
} catch ( WC_Data_Exception $e ) {
|
||||||
$object->delete();
|
$object->delete();
|
||||||
return new WP_Error( $e->getErrorCode(), $e->getMessage(), $e->getErrorData() );
|
return new WP_Error( $e->getErrorCode(), $e->getMessage(), $e->getErrorData() );
|
||||||
|
@ -204,15 +213,6 @@ abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller {
|
||||||
return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
|
return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Fires after a single object is created or updated via the REST API.
|
|
||||||
*
|
|
||||||
* @param WC_Data $object Inserted object.
|
|
||||||
* @param WP_REST_Request $request Request object.
|
|
||||||
* @param boolean $creating True when creating object, false when updating.
|
|
||||||
*/
|
|
||||||
do_action( "woocommerce_rest_insert_{$this->post_type}_object", $object, $request, true );
|
|
||||||
|
|
||||||
$request->set_param( 'context', 'edit' );
|
$request->set_param( 'context', 'edit' );
|
||||||
$response = $this->prepare_object_for_response( $object, $request );
|
$response = $this->prepare_object_for_response( $object, $request );
|
||||||
$response = rest_ensure_response( $response );
|
$response = rest_ensure_response( $response );
|
||||||
|
@ -243,21 +243,21 @@ abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->update_additional_fields_for_object( $object, $request );
|
$this->update_additional_fields_for_object( $object, $request );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fires after a single object is created or updated via the REST API.
|
||||||
|
*
|
||||||
|
* @param WC_Data $object Inserted object.
|
||||||
|
* @param WP_REST_Request $request Request object.
|
||||||
|
* @param boolean $creating True when creating object, false when updating.
|
||||||
|
*/
|
||||||
|
do_action( "woocommerce_rest_insert_{$this->post_type}_object", $object, $request, false );
|
||||||
} catch ( WC_Data_Exception $e ) {
|
} catch ( WC_Data_Exception $e ) {
|
||||||
return new WP_Error( $e->getErrorCode(), $e->getMessage(), $e->getErrorData() );
|
return new WP_Error( $e->getErrorCode(), $e->getMessage(), $e->getErrorData() );
|
||||||
} catch ( WC_REST_Exception $e ) {
|
} catch ( WC_REST_Exception $e ) {
|
||||||
return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
|
return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Fires after a single object is created or updated via the REST API.
|
|
||||||
*
|
|
||||||
* @param WC_Data $object Inserted object.
|
|
||||||
* @param WP_REST_Request $request Request object.
|
|
||||||
* @param boolean $creating True when creating object, false when updating.
|
|
||||||
*/
|
|
||||||
do_action( "woocommerce_rest_insert_{$this->post_type}_object", $object, $request, false );
|
|
||||||
|
|
||||||
$request->set_param( 'context', 'edit' );
|
$request->set_param( 'context', 'edit' );
|
||||||
$response = $this->prepare_object_for_response( $object, $request );
|
$response = $this->prepare_object_for_response( $object, $request );
|
||||||
return rest_ensure_response( $response );
|
return rest_ensure_response( $response );
|
||||||
|
|
Loading…
Reference in New Issue