コード例 #1
0
ファイル: h-menu.php プロジェクト: hrsetyono/edje-wp
 public function _add()
 {
     $args = $this->args;
     global $menu;
     end($menu);
     foreach ($args as $title => $value) {
         $position = null;
         $icon = null;
         // get position if specified
         if (isset($value['position'])) {
             $position = $this->get_position($menu, $value['position']);
         }
         if (isset($value['icon'])) {
             $icon = H_Elper::to_icon($value['icon']);
         }
         // add top level menu if slug is specified
         if (isset($value['slug'])) {
             add_menu_page($title, $title, 'manage_options', $value['slug'], null, $icon, $position);
         }
         // if has submenu
         if (isset($value['submenu'])) {
             $parent_slug = isset($value['slug']) ? $value['slug'] : $menu[$position][2];
             $smenu = new H_Submenu($parent_slug, $value['submenu']);
             $smenu->add();
         }
         // If has counter
         if (isset($value['counter'])) {
             $menu[$position][0] .= $this->add_counter($value["counter"]);
         }
     }
 }
コード例 #2
0
ファイル: post-column.php プロジェクト: hrsetyono/edje-wp
 private function format_arg($text, $value)
 {
     $col = array('slug' => '', 'title' => '', 'sortable' => false, 'editable' => false, 'icon' => '', 'content' => '');
     // if contains caret, it's sortable
     if (strpos($text, '^')) {
         $text = trim($text, '^');
         $col['sortable'] = true;
     }
     $col['slug'] = H_Elper::to_param($text);
     // if comments, set the default icon
     if ($col['slug'] === 'comments') {
         $col['icon'] = 'dashicons-admin-comments';
     }
     // if value is array, get [content], if not just put the plain value
     if (is_array($value)) {
         $col['content'] = isset($value['content']) ? $value['content'] : $text;
         // add icon if exist
         if (isset($value['icon'])) {
             $col['icon'] = H_Elper::to_icon($value['icon']);
         }
     } else {
         $col['content'] = $value;
     }
     // if icon exist
     $title = H_Elper::to_title($text);
     if ($col['icon']) {
         $title = "<span class='dashicons {$col['icon']}'></span> <span class='screen-reader-text'>{$title}</span>";
     }
     $col['title'] = $title;
     return $col;
 }