WC_Report_Downloads::get_items()
Get downloads matching criteria.
Метод класса: WC_Report_Downloads{}
Хуки из метода
Возвращает
null
. Ничего (null).
Использование
$WC_Report_Downloads = new WC_Report_Downloads(); $WC_Report_Downloads->get_items( $current_page, $per_page );
- $current_page(int) (обязательный)
- Current viewed page.
- $per_page(int) (обязательный)
- How many results to show per page.
Код WC_Report_Downloads::get_items() WC Report Downloads::get items WC 9.4.2
public function get_items( $current_page, $per_page ) { global $wpdb; $this->max_items = 0; $this->items = array(); $filters = $this->get_filter_vars(); // Get downloads from database. $table = $wpdb->prefix . WC_Customer_Download_Log_Data_Store::get_table_name(); $query_from = " FROM {$table} as downloads "; if ( ! is_null( $filters->product_id ) || ! is_null( $filters->download_id ) || ! is_null( $filters->order_id ) ) { $query_from .= " LEFT JOIN {$wpdb->prefix}woocommerce_downloadable_product_permissions as permissions on downloads.permission_id = permissions.permission_id "; } $query_from .= ' WHERE 1=1 '; if ( ! is_null( $filters->product_id ) ) { $query_from .= $wpdb->prepare( ' AND product_id = %d ', $filters->product_id ); } if ( ! is_null( $filters->download_id ) ) { $query_from .= $wpdb->prepare( ' AND download_id = %s ', $filters->download_id ); } if ( ! is_null( $filters->order_id ) ) { $query_from .= $wpdb->prepare( ' AND order_id = %d ', $filters->order_id ); } if ( ! is_null( $filters->permission_id ) ) { $query_from .= $wpdb->prepare( ' AND downloads.permission_id = %d ', $filters->permission_id ); } if ( ! is_null( $filters->user_id ) ) { $query_from .= $wpdb->prepare( ' AND downloads.user_id = %d ', $filters->user_id ); } if ( ! is_null( $filters->user_ip_address ) ) { $query_from .= $wpdb->prepare( ' AND user_ip_address = %s ', $filters->user_ip_address ); } $query_from = apply_filters( 'woocommerce_report_downloads_query_from', $query_from ); $query_order = $wpdb->prepare( 'ORDER BY timestamp DESC LIMIT %d, %d;', ( $current_page - 1 ) * $per_page, $per_page ); $this->items = $wpdb->get_results( "SELECT * {$query_from} {$query_order}" ); // WPCS: cache ok, db call ok, unprepared SQL ok. $this->max_items = $wpdb->get_var( "SELECT COUNT( DISTINCT download_log_id ) {$query_from};" ); // WPCS: cache ok, db call ok, unprepared SQL ok. }