Automattic\WooCommerce\Admin\Notes
DataStore::get_notes_where_clauses() public WC 1.0
Return where clauses for getting notes by status and type. For use in both the count and listing queries.
@param array $args Array of args to pass.
{} Это метод класса: DataStore{}
Хуки из метода
Возвращает
Строку
. Where clauses for the query.
Использование
$DataStore = new DataStore(); $DataStore->get_notes_where_clauses( $args );
- $args **
- -
По умолчанию: array()
Код DataStore::get_notes_where_clauses() DataStore::get notes where clauses WC 5.2.2
public function get_notes_where_clauses( $args = array() ) {
$allowed_types = Note::get_allowed_types();
$where_type_array = array();
if ( isset( $args['type'] ) ) {
foreach ( $args['type'] as $args_type ) {
$args_type = trim( $args_type );
if ( in_array( $args_type, $allowed_types, true ) ) {
$where_type_array[] = "'" . esc_sql( $args_type ) . "'";
}
}
}
$allowed_statuses = Note::get_allowed_statuses();
$where_status_array = array();
if ( isset( $args['status'] ) ) {
foreach ( $args['status'] as $args_status ) {
$args_status = trim( $args_status );
if ( in_array( $args_status, $allowed_statuses, true ) ) {
$where_status_array[] = "'" . esc_sql( $args_status ) . "'";
}
}
}
$escaped_is_deleted = '';
if ( isset( $args['is_deleted'] ) ) {
$escaped_is_deleted = esc_sql( $args['is_deleted'] );
}
$where_name_array = [];
if ( isset( $args['name'] ) ) {
foreach ( $args['name'] as $args_name ) {
$args_name = trim( $args_name );
$where_name_array[] = sprintf( "'%s'", esc_sql( $args_name ) );
}
}
$escaped_where_types = implode( ',', $where_type_array );
$escaped_where_status = implode( ',', $where_status_array );
$escaped_where_names = implode( ',', $where_name_array );
$where_clauses = '';
if ( ! empty( $escaped_where_types ) ) {
$where_clauses .= " AND type IN ($escaped_where_types)";
}
if ( ! empty( $escaped_where_status ) ) {
$where_clauses .= " AND status IN ($escaped_where_status)";
}
if ( ! empty( $escaped_where_names ) ) {
$where_clauses .= " AND name IN ($escaped_where_names)";
}
$where_clauses .= $escaped_is_deleted ? ' AND is_deleted = 1' : ' AND is_deleted = 0';
/**
* Filter the notes WHERE clause before retrieving the data.
*
* Allows modification of the notes select criterial.
*
* @param string $where_clauses The generated WHERE clause.
* @param array $args The original arguments for the request.
*/
return apply_filters( 'woocommerce_note_where_clauses', $where_clauses, $args );
}