Automattic\WooCommerce\Admin\API
DataDownloadIPs::get_items
Return the download IPs matching the passed parameters.
Метод класса: DataDownloadIPs{}
Хуков нет.
Возвращает
WP_Error|WP_REST_Response.
Использование
$DataDownloadIPs = new DataDownloadIPs(); $DataDownloadIPs->get_items( $request );
- $request(WP_REST_Request) (обязательный)
- Request data.
Список изменений
| С версии 3.5.0 | Введена. |
Код DataDownloadIPs::get_items() DataDownloadIPs::get items WC 10.9.4
public function get_items( $request ) {
global $wpdb;
if ( isset( $request['match'] ) ) {
$downloads = $wpdb->get_results(
$wpdb->prepare(
"SELECT DISTINCT( user_ip_address ) FROM {$wpdb->prefix}wc_download_log
WHERE user_ip_address LIKE %s
LIMIT 10",
$request['match'] . '%'
)
);
} else {
return new \WP_Error( 'woocommerce_rest_data_download_ips_invalid_request', __( 'Invalid request. Please pass the match parameter.', 'woocommerce' ), array( 'status' => 400 ) );
}
$data = array();
if ( ! empty( $downloads ) ) {
foreach ( $downloads as $download ) {
$response = $this->prepare_item_for_response( $download, $request );
$data[] = $this->prepare_response_for_collection( $response );
}
}
return rest_ensure_response( $data );
}