WC_REST_Setting_Options_V2_Controller::batch_items
Bulk create, update and delete items.
Метод класса: WC_REST_Setting_Options_V2_Controller{}
Хуков нет.
Возвращает
Массив. Of WP_Error or WP_REST_Response.
Использование
$WC_REST_Setting_Options_V2_Controller = new WC_REST_Setting_Options_V2_Controller(); $WC_REST_Setting_Options_V2_Controller->batch_items( $request );
- $request(WP_REST_Request) (обязательный)
- Full details about the request.
Список изменений
| С версии 3.0.0 | Введена. |
Код WC_REST_Setting_Options_V2_Controller::batch_items() WC REST Setting Options V2 Controller::batch items WC 10.4.3
public function batch_items( $request ) {
// Get the request params.
$items = array_filter( $request->get_params() );
/*
* Since our batch settings update is group-specific and matches based on the route,
* we inject the URL parameters (containing group) into the batch items
*/
if ( ! empty( $items['update'] ) ) {
$to_update = array();
foreach ( $items['update'] as $item ) {
$to_update[] = array_merge( $request->get_url_params(), $item );
}
$request = new WP_REST_Request( $request->get_method() );
$request->set_body_params( array( 'update' => $to_update ) );
}
return parent::batch_items( $request );
}