Automattic\WooCommerce\Admin\Notes
DataStore::get_notes()
Return an ordered list of notes.
Method of the class: DataStore{}
No Hooks.
Return
Array
. An array of objects containing a note id.
Usage
$DataStore = new DataStore(); $DataStore->get_notes( $args, $context );
- $args(array)
- Query arguments.
Default: array() - $context(string)
- 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.
Default: self::WC_ADMIN_NOTE_OPER_GLOBAL
DataStore::get_notes() DataStore::get notes code WC 8.7.0
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 }