Automattic\WooCommerce\Admin\API\Reports
DataStore::get_filtered_ids()
Returns filtered comma separated ids, based on query arguments from the user.
Method of the class: DataStore{}
Hooks from the method
Return
String
.
Usage
// protected - for code of main (parent) or child class $result = $this->get_filtered_ids( $query_args, $field, $separator );
- $query_args(array) (required)
- Parameters supplied by the user.
- $field(string) (required)
- Query field to filter.
- $separator(string)
- Field separator.
Default: ','
DataStore::get_filtered_ids() DataStore::get filtered ids code WC 9.6.1
protected function get_filtered_ids( $query_args, $field, $separator = ',' ) { global $wpdb; $ids_str = ''; $ids = isset( $query_args[ $field ] ) && is_array( $query_args[ $field ] ) ? $query_args[ $field ] : array(); /** * Filter the IDs before retrieving report data. * * Allows filtering of the objects included or excluded from reports. * * @param array $ids List of object Ids. * @param array $query_args The original arguments for the request. * @param string $field The object type. * @param string $context The data store context. */ $ids = apply_filters( 'woocommerce_analytics_' . $field, $ids, $query_args, $field, $this->context ); if ( ! empty( $ids ) ) { $placeholders = implode( $separator, array_fill( 0, count( $ids ), '%d' ) ); /* phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared */ $ids_str = $wpdb->prepare( "{$placeholders}", $ids ); /* phpcs:enable */ } return $ids_str; }