$row) { $key = (string) $key; if (!is_array($row)) { $row = array('label' => (string) $row); } $query = isset($row['query']) && is_array($row['query']) ? $row['query'] : array(); if (empty($query) && $default_arg !== '') { $query = array($default_arg => $key); } $out[$key] = array( 'id' => $key, 'label' => isset($row['label']) ? (string) $row['label'] : $key, 'query' => $query, 'align' => (isset($row['align']) && 'right' === $row['align']) ? 'right' : '', 'badge_class' => isset($row['badge_class']) ? (string) $row['badge_class'] : 'aieo-tab-count', 'icon' => isset($row['icon']) ? (string) $row['icon'] : '', ); } return $out; } public static function tab_strip($page_id, array $tabs, $active = '', array $opts = array()) { $arg = isset($opts['arg']) ? (string) $opts['arg'] : ''; $tabs = self::normalise_tabs($tabs, $arg); if (empty($tabs)) { return ''; } $keys = array_keys($tabs); $counts = isset($opts['counts']) && is_array($opts['counts']) ? $opts['counts'] : array(); if ($active === '' || !isset($tabs[$active])) { $active = self::active_from_request($tabs); } self::declare_tabs($page_id, $tabs); $base = isset($opts['base']) && $opts['base'] !== '' ? (string) $opts['base'] : add_query_arg( array('page' => AIEO_DMM::MENU_SLUG, 'dmm_tab' => $page_id), admin_url('admin.php') ); if (class_exists('AIEO_Chrome') && AIEO_Chrome::on() && function_exists('rooster_admin_tabs')) { $rows = array(); foreach ($tabs as $key => $tab) { $n = isset($counts[$key]) ? (int) $counts[$key] : 0; $rows[] = array( 'id' => $key, 'label' => $tab['label'], 'url' => add_query_arg($tab['query'], $base), 'icon' => $tab['icon'], 'count' => $n > 0 ? $n : null, 'end' => 'right' === $tab['align'], 'entry' => ($key === $active && false === strpos($key, '__')) ? 'rooster-one/tab/' . $page_id . '/' . $key : '', ); } echo rooster_admin_tabs($rows, $active); return $active; } $el = (isset($opts['wrapper']) && 'div' === $opts['wrapper']) ? 'div' : 'h2'; $margin = isset($opts['margin']) ? (string) $opts['margin'] : '16px'; self::print_tab_css(); printf('<%s class="nav-tab-wrapper" style="margin-bottom:%s;">', $el, esc_attr($margin)); foreach ($tabs as $key => $tab) { $url = add_query_arg($tab['query'], $base); $n = isset($counts[$key]) ? (int) $counts[$key] : 0; $badge = ''; if ($n > 0) { $badge = ' ' . (int) $n . ''; } printf( '%s%s', esc_url($url), ($key === $active ? ' nav-tab-active' : ''), ('right' === $tab['align'] ? ' style="float:right;margin-right:0;"' : ''), esc_html($tab['label']), $badge ); } if ($active !== '' && isset($tabs[$active]) && false === strpos($active, '__') && function_exists('rooster_admin_pin_button')) { echo rooster_admin_pin_button('rooster-one/tab/' . $page_id . '/' . $active); } printf('%s>', $el); return $active; } public static function card(array $c) { if (!class_exists('AIEO_Table')) { require_once AIEO_DIR . 'includes/dmm/reports/class-aieo-table.php'; } self::$last_anchor = (string) ($c['anchor'] ?? ''); return AIEO_Table::card_shell($c); } public static function title_badge($text, $tone = 'mono') { $text = (string) $text; if ('' === $text || !class_exists('\Rooster\Admin\Ui')) { return ''; } return \Rooster\Admin\Ui::badge($text, (string) $tone, array('sm' => true)); } private static $last_anchor = ''; public static function current_anchor() { return self::$last_anchor; } public static function notice($html, $tone = 'info', array $opts = array()) { $title = (string) ($opts['title'] ?? ''); $detail = (string) ($opts['detail'] ?? ''); $id = (string) ($opts['id'] ?? ''); if (class_exists('\Rooster\Admin\Library') && wp_style_is(\Rooster\Admin\Library::HANDLE, 'enqueued')) { return \Rooster\Admin\Ui::notice((string) $html, (string) $tone, array_filter(array('inline' => true, 'title' => $title, 'detail' => $detail, 'id' => $id))); } $class = array('success' => 'notice-success', 'warning' => 'notice-warning', 'destructive' => 'notice-error', 'info' => 'notice-info', 'mono' => 'notice-info', 'primary' => 'notice-info'); return '
' . esc_html($title) . '
' : '') . ('' !== (string) $html ? '' . $html . '
' : '') . $detail . '' . esc_html($note) . '
'; } if (is_callable($render)) { call_user_func($render); } echo '