Automattic\WooCommerce\Internal\ProductDownloads
DownloadableFileAttachments::handle_rest_request_before_callbacks
Respond with "not found" when a single downloadable product file is requested from the REST API media endpoint.
Метод класса: DownloadableFileAttachments{}
Хуков нет.
Возвращает
mixed.
Использование
$DownloadableFileAttachments = new DownloadableFileAttachments(); $DownloadableFileAttachments->handle_rest_request_before_callbacks( $response, $handler, $request );
- $response(разное) (обязательный)
- Response to replace the requested version with, or null.
- $handler(массив|разное) (обязательный)
- Route handler used for the request.
- $request(обязательный)
- .
Код DownloadableFileAttachments::handle_rest_request_before_callbacks() DownloadableFileAttachments::handle rest request before callbacks WC 11.3.0
public function handle_rest_request_before_callbacks( $response, $handler, $request ) {
$callback = is_array( $handler ) ? ( $handler['callback'] ?? null ) : null;
if (
is_wp_error( $response )
|| ! is_array( $callback )
|| ! ( $callback[0] ?? null ) instanceof WP_REST_Attachments_Controller
|| 'get_item' !== ( $callback[1] ?? null )
|| ! $this->is_hidden_attachment( absint( $request['id'] ?? 0 ) )
) {
return $response;
}
return new WP_Error( 'rest_post_invalid_id', __( 'Invalid post ID.', 'woocommerce' ), array( 'status' => 404 ) );
}