$value ) { if ( in_array( $attribute, $skip, true ) ) { continue; } if ( empty( $value ) ) { throw Reports_Exceptions\Invalid_Parameter::from( $attribute, __METHOD__, $item_id ); } } } /** * Retrieves all registered items with a given sorting scheme. * * @since 3.0 * * @param string $sort Optional. How to sort the list of registered items before retrieval. * Accepts 'priority' or 'ID' (alphabetized by item ID), or empty (none). * Default empty. * @return array An array of all registered items, sorted if `$sort` is not empty. */ public function get_items_sorted( $sort = '' ) { // If sorting, handle it before retrieval from the ArrayObject. switch( $sort ) { case 'ID': parent::ksort(); break; case 'priority': parent::uasort( array( $this, 'priority_sort' ) ); break; default: break; } return parent::get_items(); } /** * Sorting helper to sort items by priority. * * @since 3.0 * * @param array $a Item A. * @param array $b Item B * @return int Zero (0) if `$a` equals `$b`. Minus one (-1) if `$a` is less than `$b`, otherwise one (1). */ public function priority_sort( $a, $b ) { if ( $a['priority'] == $b['priority'] ) { return 0; } return ( $a['priority'] < $b['priority'] ) ? -1 : 1; } }