コード例 #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;
 }
コード例 #3
0
ファイル: post-type.php プロジェクト: hrsetyono/edje-wp
 private function create_labels($raw_name)
 {
     $name = H_Elper::to_title($raw_name);
     $plural = Inflector::pluralize($name);
     $singular = $name;
     $labels = array('name' => $plural, 'singular_name' => $singular, 'all_items' => 'All ' . $plural, 'add_new_item' => 'Add New ' . $singular, 'edit_item' => 'Edit ' . $singular, 'new_item' => 'New ' . $singular, 'view_item' => 'View ' . $singular, 'search_items' => 'Search ' . $plural, 'not_found' => 'No ' . strtolower($plural) . ' found', 'not_found_in_trash' => 'No ' . strtolower($plural) . ' found in Trash', 'parent_item_colon' => 'Parent ' . $singular . ':');
     return $labels;
 }
コード例 #4
0
ファイル: taxonomy.php プロジェクト: hrsetyono/edje-wp
 private function create_labels($label, $name)
 {
     $plural = Inflector::pluralize($label);
     $singular = $label;
     $title = H_Elper::to_title($name);
     $title_plural = Inflector::pluralize($title);
     $labels = array('name' => $title_plural, 'singular_name' => $title, 'menu_name' => $plural, 'all_items' => 'All ' . $plural, 'edit_item' => 'Edit ' . $singular, 'view_item' => 'View ' . $singular, 'update_item' => 'Update ' . $singular, 'add_new_item' => 'Add New ' . $singular, 'parent_item' => 'Parent ' . $singular, 'search_items' => 'Search ' . $plural, 'popular_items' => NULL, 'add_or_remove_items' => 'Add or remove ' . strtolower($plural), 'choose_from_most_used' => 'Choose from the most used ' . strtolower($plural), 'not_found' => 'No ' . strtolower($plural) . ' found');
     return $labels;
 }
コード例 #5
0
ファイル: h-metatags.php プロジェクト: hrsetyono/edje-wp
 function custom_meta_tags()
 {
     global $post;
     $content = get_bloginfo('description');
     // if not front page, use excerpt from content
     if (!is_front_page() && $post) {
         $excerpt = $post->post_excerpt ? $post->post_excerpt : H_Elper::trim_content($post->post_content);
         $content = $excerpt ? $excerpt : $content;
     }
     echo "<meta name='description' content='{$content}'>";
 }
コード例 #6
0
ファイル: post-action.php プロジェクト: hrsetyono/edje-wp
 private function _parse_for_actions($actions, $post)
 {
     $args = array();
     $new_actions = $this->actions;
     foreach ($new_actions as $key => $value) {
         $slug = is_int($key) ? $value : $key;
         $title = H_Elper::to_title($slug);
         switch ($slug) {
             case 'view':
             case 'edit':
             case 'trash':
                 $content = $actions[$slug];
                 break;
             case 'quickedit':
             case 'quick_edit':
                 $content = $actions['inline hide-if-no-js'];
                 break;
             default:
                 // if a function AND return null
                 if (is_callable($value) && is_null($value(null))) {
                     $redirect_uri = $this->_get_redirect_uri();
                     $action_name = "h_action_{$slug}";
                     $href = admin_url("?action={$action_name}&post={$post->ID}&redirect_uri={$redirect_uri}");
                     $content = "<a href='{$href}'>{$title}</a>";
                 } else {
                     $href = $value($post->ID);
                     $content = "<a href='{$href}'>{$title}</a>";
                 }
         }
         $args[$slug] = array('title' => $title, 'content' => $content);
     }
     return $args;
 }