Automattic\WooCommerce\Admin\Notes

DataStore::args_to_where_clauses()protectedWC 1.0

Return where clauses for notes queries without applying woocommerce_note_where_clauses filter. INTERNAL: This method is not intended to be used by external code, and may change without notice.

{} Это метод класса: DataStore{}

Хуков нет.

Возвращает

Строку. Where clauses.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->args_to_where_clauses( $args );
$args(массив)
Array of arguments for query conditionals.
По умолчанию: array()

Код DataStore::args_to_where_clauses() WC 6.6.1

protected function args_to_where_clauses( $args = array() ) {
	$allowed_types    = Note::get_allowed_types();
	$where_type_array = $this->get_escaped_arguments_array_by_key( $args, 'type', $allowed_types );

	$allowed_statuses   = Note::get_allowed_statuses();
	$where_status_array = $this->get_escaped_arguments_array_by_key( $args, 'status', $allowed_statuses );

	$escaped_is_deleted = '';
	if ( isset( $args['is_deleted'] ) ) {
		$escaped_is_deleted = esc_sql( $args['is_deleted'] );
	}

	$where_name_array          = $this->get_escaped_arguments_array_by_key( $args, 'name' );
	$where_excluded_name_array = $this->get_escaped_arguments_array_by_key( $args, 'excluded_name' );
	$where_source_array        = $this->get_escaped_arguments_array_by_key( $args, 'source' );

	$escaped_where_types          = implode( ',', $where_type_array );
	$escaped_where_status         = implode( ',', $where_status_array );
	$escaped_where_names          = implode( ',', $where_name_array );
	$escaped_where_excluded_names = implode( ',', $where_excluded_name_array );
	$escaped_where_source         = implode( ',', $where_source_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)";
	}

	if ( ! empty( $escaped_where_excluded_names ) ) {
		$where_clauses .= " AND name NOT IN ($escaped_where_excluded_names)";
	}

	if ( ! empty( $escaped_where_source ) ) {
		$where_clauses .= " AND source IN ($escaped_where_source)";
	}

	$where_clauses .= $escaped_is_deleted ? ' AND is_deleted = 1' : ' AND is_deleted = 0';

	return $where_clauses;
}