Automattic\WooCommerce\Admin\Notes

DataStore::get_notes()publicWC 1.0

Return an ordered list of notes.

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

Хуков нет.

Возвращает

Массив. An array of objects containing a note id.

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

$DataStore = new DataStore();
$DataStore->get_notes( $args, $context );
$args(массив)
Query arguments.
По умолчанию: array()
$context(строка)
Optional argument that the woocommerce_note_where_clauses filter can use to determine whether to apply extra conditions. Extensions should define their own contexts and use them to avoid adding to notes where clauses when not needed.
По умолчанию: self::WC_ADMIN_NOTE_OPER_GLOBAL

Код DataStore::get_notes() WC 6.6.1

public function get_notes( $args = array(), $context = self::WC_ADMIN_NOTE_OPER_GLOBAL ) {
	global $wpdb;

	$defaults = array(
		'per_page' => get_option( 'posts_per_page' ),
		'page'     => 1,
		'order'    => 'DESC',
		'orderby'  => 'date_created',
	);
	$args     = wp_parse_args( $args, $defaults );

	$offset        = $args['per_page'] * ( $args['page'] - 1 );
	$where_clauses = $this->get_notes_where_clauses( $args, $context );

	// sanitize order and orderby.
	$order_by  = '`' . str_replace( '`', '', $args['orderby'] ) . '`';
	$order_dir = 'asc' === strtolower( $args['order'] ) ? 'ASC' : 'DESC';

	$query = $wpdb->prepare(
		// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
		"SELECT * FROM {$wpdb->prefix}wc_admin_notes WHERE 1=1{$where_clauses} ORDER BY {$order_by} {$order_dir} LIMIT %d, %d",
		$offset,
		$args['per_page']
	);

	return $wpdb->get_results( $query ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
}