*/ public static function screens() { global $submenu; static $cache = null; if ( null !== $cache && did_action( 'admin_menu' ) ) { return $cache; } $screens = array( 'overview' => array( 'label' => __( 'Overview', 'dealroot' ), 'page' => Admin::PAGE, 'capability' => Admin::capability(), 'order' => 10, ), 'live' => array( 'label' => __( 'Live', 'dealroot' ), 'page' => Live_Page::PAGE, 'capability' => Admin::capability(), 'order' => 16, 'live' => Live::count(), ), 'leads' => array( 'label' => __( 'Leads', 'dealroot' ), 'page' => Admin::LEADS_PAGE, 'capability' => Admin::capability(), 'order' => 12, 'count' => Leads::status_counts()['new'], ), 'ask' => array( 'label' => __( 'Ask', 'dealroot' ), 'page' => Ask_Page::PAGE, 'capability' => Admin::capability(), 'order' => 27, ), 'reports' => array( 'label' => __( 'Reports', 'dealroot' ), 'page' => Reports_Page::PAGE, 'capability' => Admin::capability(), 'order' => 14, ), 'forms' => array( 'label' => __( 'Forms', 'dealroot' ), 'page' => Forms_Page::PAGE, 'capability' => 'manage_options', 'order' => 30, ), 'settings' => array( 'label' => __( 'Settings', 'dealroot' ), 'page' => Admin::SETTINGS_PAGE, 'capability' => 'manage_options', 'order' => 90, ), ); /** * Filters the screens shown in the bar of the Dealroot screens. * * @param array $screens Key => label, page (menu slug), capability, order and an optional count. */ $screens = (array) apply_filters( 'dealroot_admin_screens', $screens ); // A screen that was taken out of the menu, e.g. for a white label, leaves the bar too. $menu = wp_list_pluck( (array) ( $submenu[ Admin::PAGE ] ?? array() ), 2 ); $screens = array_filter( $screens, static function ( $screen ) use ( $menu ) { return ! empty( $screen['label'] ) && ! empty( $screen['page'] ) && ( ! $menu || in_array( $screen['page'], $menu, true ) ) && current_user_can( $screen['capability'] ?? 'manage_options' ); } ); uasort( $screens, static function ( $a, $b ) { return ( $a['order'] ?? 50 ) <=> ( $b['order'] ?? 50 ); } ); if ( did_action( 'admin_menu' ) ) { $cache = $screens; } return $screens; } /** * Address of a screen. * * @param string $page Menu slug. * @param array $args Further query arguments. * @return string */ public static function url( $page, array $args = array() ) { return add_query_arg( array_merge( array( 'page' => $page ), $args ), admin_url( 'admin.php' ) ); } /** * Opens a screen: the wrapper, the bar and the head with title, description and actions. * * @param string $current Key of the screen in the bar. * @param string $title Title. * @param array $args { * Optional. * * @type string $description One or two sentences below the title. * @type string $actions Buttons next to the title, as HTML. * @type array $back Link above the title: url and label. * @type string $media HTML before the title, such as the initials of a person. * @type string $class Further classes of the wrapper. * } */ public static function open( $current, $title, array $args = array() ) { $args = wp_parse_args( $args, array( 'description' => '', 'actions' => '', 'back' => array(), 'media' => '', 'class' => '', ) ); ?>