• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP get_post_types函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中get_post_types函数的典型用法代码示例。如果您正苦于以下问题:PHP get_post_types函数的具体用法?PHP get_post_types怎么用?PHP get_post_types使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_post_types函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: WP_Posts_List_Table

	function WP_Posts_List_Table() {
		global $post_type_object, $post_type, $wpdb;

		if ( !isset( $_REQUEST['post_type'] ) )
			$post_type = 'post';
		elseif ( in_array( $_REQUEST['post_type'], get_post_types( array( 'show_ui' => true ) ) ) )
			$post_type = $_REQUEST['post_type'];
		else
			wp_die( __( 'Invalid post type' ) );
		$_REQUEST['post_type'] = $post_type;

		$post_type_object = get_post_type_object( $post_type );

		if ( !current_user_can( $post_type_object->cap->edit_others_posts ) ) {
			$this->user_posts_count = $wpdb->get_var( $wpdb->prepare( "
				SELECT COUNT( 1 ) FROM $wpdb->posts
				WHERE post_type = %s AND post_status NOT IN ( 'trash', 'auto-draft' )
				AND post_author = %d
			", $post_type, get_current_user_id() ) );

			if ( $this->user_posts_count && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['all_posts'] ) && empty( $_REQUEST['author'] ) && empty( $_REQUEST['show_sticky'] ) )
				$_GET['author'] = get_current_user_id();
		}

		if ( 'post' == $post_type && $sticky_posts = get_option( 'sticky_posts' ) ) {
			$sticky_posts = implode( ', ', array_map( 'absint', (array) $sticky_posts ) );
			$this->sticky_posts_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( 1 ) FROM $wpdb->posts WHERE post_type = %s AND post_status != 'trash' AND ID IN ($sticky_posts)", $post_type ) );
		}

		parent::WP_List_Table( array(
			'plural' => 'posts',
		) );
	}
开发者ID:realfluid,项目名称:umbaugh,代码行数:33,代码来源:class-wp-posts-list-table.php


示例2: action_init

 function action_init()
 {
     //syncing must wait until after init so
     //post types that support comments
     $filt_post_types = array();
     $all_post_types = get_post_types();
     foreach ($all_post_types as $post_type) {
         if (post_type_supports($post_type, 'comments')) {
             $filt_post_types[] = $post_type;
         }
     }
     Jetpack_Sync::sync_posts(__FILE__, array('post_types' => $filt_post_types, 'post_stati' => array('publish')));
     Jetpack_Sync::sync_comments(__FILE__, array('post_types' => $filt_post_types, 'post_stati' => array('publish'), 'comment_stati' => array('approve', 'approved', '1', 'hold', 'unapproved', 'unapprove', '0', 'spam', 'trash')));
     if (defined('DOING_AJAX') && DOING_AJAX) {
         return;
     }
     if (!has_filter('show_admin_bar', '__return_true') && !is_user_logged_in()) {
         return;
     }
     if (!self::current_browser_is_supported()) {
         return;
     }
     add_action('admin_bar_menu', array(&$this, 'admin_bar_menu'), 120);
     add_action('wp_head', array(&$this, 'styles_and_scripts'), 120);
     add_action('admin_head', array(&$this, 'styles_and_scripts'));
 }
开发者ID:lcw07r,项目名称:productcampamsterdam.org,代码行数:26,代码来源:notes.php


示例3: remove_person_meta_box

/**
 * Remove the Person metabox from all post types.
 */
function remove_person_meta_box()
{
    $post_types = get_post_types('', 'names');
    foreach ($post_types as $post_type) {
        remove_meta_box('tagsdiv-person', '' . $post_type . '', 'side');
    }
}
开发者ID:amprog,项目名称:cap-byline,代码行数:10,代码来源:cap-byline.php


示例4: cuttz_add_landing_sections_meta_box

/**
 * Register a new meta box to the post or page edit screen, so that the user can add landing section
 * on a per-post or per-page basis.
 */
function cuttz_add_landing_sections_meta_box()
{
    if (!current_theme_supports('cuttz-landing-sections')) {
        return;
    }
    global $post;
    if (get_option('show_on_front') == 'page') {
        $posts_page_id = get_option('page_for_posts');
        if ($posts_page_id == $post->ID) {
            add_action('edit_form_after_title', 'cuttz_landing_section_posts_notice');
            return;
        }
    }
    if (in_array('woocommerce/woocommerce.php', get_option('active_plugins'))) {
        if ($post->ID == wc_get_page_id('shop')) {
            add_action('edit_form_after_title', 'cuttz_landing_section_shop_notice');
            return;
        }
    }
    $context = 'normal';
    $priority = 'high';
    foreach ((array) get_post_types(array('public' => true)) as $type) {
        if (post_type_supports($type, 'cuttz-landing-sections')) {
            add_meta_box('landing-sections', __('Cuttz Landing Sections', 'cuttz-framework'), 'cuttz_landing_sections_box', $type, $context, $priority);
        }
    }
}
开发者ID:garywp,项目名称:cuttz-framework,代码行数:31,代码来源:landing-sections-mgt.php


示例5: enlightenment_templates

function enlightenment_templates()
{
    $templates = array('error404' => array('name' => __('404', 'enlightenment'), 'conditional' => 'is_404', 'type' => 'special'), 'search' => array('name' => __('Search', 'enlightenment'), 'conditional' => 'is_search', 'type' => 'archive'), 'blog' => array('name' => __('Blog', 'enlightenment'), 'conditional' => 'is_home', 'type' => 'post_type_archive'), 'post' => array('name' => __('Post', 'enlightenment'), 'conditional' => 'is_single', 'type' => 'post_type'), 'page' => array('name' => __('Page', 'enlightenment'), 'conditional' => 'is_page', 'type' => 'post_type'), 'author' => array('name' => __('Author', 'enlightenment'), 'conditional' => 'is_author', 'type' => 'archive'), 'date' => array('name' => __('Date', 'enlightenment'), 'conditional' => 'is_date', 'type' => 'archive'), 'category' => array('name' => __('Category', 'enlightenment'), 'conditional' => 'is_category', 'type' => 'archive'), 'post_tag' => array('name' => __('Tag', 'enlightenment'), 'conditional' => 'is_tag', 'type' => 'archive'), 'comments' => array('name' => __('Comments', 'enlightenment'), 'conditional' => 'is_singular', 'hooks' => array_keys(enlightenment_comments_hooks()), 'type' => 'special'));
    $post_types = get_post_types(array('has_archive' => true), 'objects');
    foreach ($post_types as $name => $post_type) {
        $templates[$name . '-archive'] = array('name' => sprintf(__('%1$s Archive', 'enlightenment'), $post_type->labels->name), 'conditional' => array('is_post_type_archive', $name), 'type' => 'post_type_archive');
    }
    $post_types = get_post_types(array('publicly_queryable' => true), 'objects');
    foreach ($post_types as $name => $post_type) {
        $templates[$name] = array('name' => $post_type->labels->singular_name, 'conditional' => array('is_singular', $name), 'type' => 'post_type');
    }
    $taxonomies = get_taxonomies(array('public' => true), 'objects');
    unset($taxonomies['post_format']);
    unset($taxonomies['category']);
    unset($taxonomies['post_tag']);
    foreach ($taxonomies as $name => $taxonomy) {
        $templates[$name] = array('name' => $taxonomy->labels->singular_name, 'conditional' => array('is_tax', $name), 'type' => 'taxonomy');
    }
    $default_hooks = array_keys(enlightenment_template_hooks());
    foreach ($templates as $name => $template) {
        if (!isset($template['hooks']) || empty($template['hooks'])) {
            $templates[$name]['hooks'] = $default_hooks;
        }
    }
    return apply_filters('enlightenment_templates', $templates);
}
开发者ID:thano,项目名称:cfpi-theme-2016,代码行数:26,代码来源:template-editor.php


示例6: folio_remove_vc_custom_teaser

 function folio_remove_vc_custom_teaser()
 {
     $post_types = get_post_types('', 'names');
     foreach ($post_types as $post_type) {
         remove_meta_box('vc_teaser', $post_type, 'side');
     }
 }
开发者ID:javalidigital,项目名称:multipla,代码行数:7,代码来源:vc-xtend.php


示例7: hocwp_meta_box_side_image

function hocwp_meta_box_side_image($args = array())
{
    global $pagenow;
    if ('post-new.php' == $pagenow || 'post.php' == $pagenow) {
        $id = hocwp_get_value_by_key($args, 'id', 'secondary_image_box');
        $title = hocwp_get_value_by_key($args, 'title', __('Secondary Image', 'hocwp-theme'));
        $post_types = hocwp_get_value_by_key($args, 'post_type');
        if ('all' == $post_types) {
            $post_types = array();
            $types = get_post_types(array('public' => true), 'objects');
            hocwp_exclude_special_post_types($types);
            foreach ($types as $key => $object_type) {
                $post_types[] = $key;
            }
        }
        $post_types = hocwp_sanitize_array($post_types);
        $field_id = hocwp_get_value_by_key($args, 'field_id', 'secondary_image');
        $post_types = apply_filters('hocwp_post_type_user_large_thumbnail', $post_types);
        if (!hocwp_array_has_value($post_types)) {
            return;
        }
        $meta = new HOCWP_Meta('post');
        $meta->set_post_types($post_types);
        $meta->set_id($id);
        $meta->set_title($title);
        $meta->set_context('side');
        $meta->set_priority('low');
        $field_args = array('id' => $field_id, 'field_callback' => 'hocwp_field_media_upload_simple');
        $field_name = hocwp_get_value_by_key($args, 'field_name', $field_id);
        $field_args['name'] = $field_name;
        $meta->add_field($field_args);
        $meta->init();
    }
}
开发者ID:skylarkcob,项目名称:hocwp-projects,代码行数:34,代码来源:meta.php


示例8: search_terms

 public static function search_terms($request = null)
 {
     $response = (object) array('status' => false, 'message' => __('Your request has failed', 'fakerpress'), 'results' => array(), 'more' => true);
     if (!Admin::$is_ajax && is_null($request) || !is_user_logged_in()) {
         return Admin::$is_ajax ? exit(json_encode($response)) : $response;
     }
     $request = (object) wp_parse_args($request, array('search' => isset($_POST['search']) ? $_POST['search'] : '', 'post_type' => isset($_POST['post_type']) ? $_POST['post_type'] : null, 'page' => absint(isset($_POST['page']) ? $_POST['page'] : 0), 'page_limit' => absint(isset($_POST['page_limit']) ? $_POST['page_limit'] : 10)));
     if (is_null($request->post_type) || empty($request->post_type)) {
         $request->post_type = get_post_types(array('public' => true));
     }
     $response->status = true;
     $response->message = __('Request successful', 'fakerpress');
     preg_match('/@(\\w+)/i', $request->search, $response->regex);
     if (!empty($response->regex)) {
         $request->search = array_filter(array_map('trim', explode('|', str_replace($response->regex[0], '|', $request->search))));
         $request->search = reset($request->search);
         $taxonomies = $response->regex[1];
     } else {
         $taxonomies = get_object_taxonomies($request->post_type);
     }
     $response->taxonomies = get_object_taxonomies($request->post_type, 'objects');
     $response->results = get_terms((array) $taxonomies, array('hide_empty' => false, 'search' => $request->search, 'number' => $request->page_limit, 'offset' => $request->page_limit * ($request->page - 1)));
     if (empty($response->results) || count($response->results) < $request->page_limit) {
         $response->more = false;
     }
     return Admin::$is_ajax ? exit(json_encode($response)) : $response;
 }
开发者ID:samuelleal,项目名称:jardimdigital,代码行数:27,代码来源:class-fp-ajax.php


示例9: TOPluginMenu

function TOPluginMenu()
{
    include TOPATH . '/include/interface.php';
    include TOPATH . '/include/terms_walker.php';
    include TOPATH . '/include/options.php';
    add_options_page('Taxonomy Terms Order', '<img class="menu_pto" src="' . TOURL . '/images/menu-icon.gif" alt="" />' . __('Taxonomy Terms Order', 'to'), 'manage_options', 'to-options', 'to_plugin_options');
    $options = get_option('tto_options');
    if (!isset($options['level'])) {
        $options['level'] = 8;
    }
    //put a menu within all custom types if apply
    $post_types = get_post_types();
    foreach ($post_types as $post_type) {
        //check if there are any taxonomy for this post type
        $post_type_taxonomies = get_object_taxonomies($post_type);
        foreach ($post_type_taxonomies as $key => $taxonomy_name) {
            $taxonomy_info = get_taxonomy($taxonomy_name);
            if ($taxonomy_info->hierarchical !== TRUE) {
                unset($post_type_taxonomies[$key]);
            }
        }
        if (count($post_type_taxonomies) == 0) {
            continue;
        }
        if ($post_type == 'post') {
            add_submenu_page('edit.php', __('Taxonomy Order', 'to'), __('Taxonomy Order', 'to'), 'level_' . $options['level'], 'to-interface-' . $post_type, 'TOPluginInterface');
        } else {
            add_submenu_page('edit.php?post_type=' . $post_type, __('Taxonomy Order', 'to'), __('Taxonomy Order', 'to'), 'level_' . $options['level'], 'to-interface-' . $post_type, 'TOPluginInterface');
        }
    }
}
开发者ID:brunolimasinprors,项目名称:fundacaoecarta,代码行数:31,代码来源:taxonomy-terms-order.php


示例10: stats_load

function stats_load()
{
    global $wp_roles;
    Jetpack::enable_module_configurable(__FILE__);
    Jetpack::module_configuration_load(__FILE__, 'stats_configuration_load');
    Jetpack::module_configuration_head(__FILE__, 'stats_configuration_head');
    Jetpack::module_configuration_screen(__FILE__, 'stats_configuration_screen');
    // Tell HQ about changed posts
    $post_stati = get_post_stati(array('public' => true));
    // All public post stati
    $post_stati[] = 'private';
    // Content from private stati will be redacted
    Jetpack_Sync::sync_posts(__FILE__, array('post_types' => get_post_types(array('public' => true)), 'post_stati' => $post_stati));
    // Generate the tracking code after wp() has queried for posts.
    add_action('template_redirect', 'stats_template_redirect', 1);
    add_action('wp_head', 'stats_admin_bar_head', 100);
    add_action('wp_head', 'stats_hide_smile_css');
    add_action('jetpack_admin_menu', 'stats_admin_menu');
    // Map stats caps
    add_filter('map_meta_cap', 'stats_map_meta_caps', 10, 4);
    if (isset($_GET['oldwidget'])) {
        // Old one.
        add_action('wp_dashboard_setup', 'stats_register_dashboard_widget');
    } else {
        add_action('admin_init', 'stats_merged_widget_admin_init');
    }
    add_filter('jetpack_xmlrpc_methods', 'stats_xmlrpc_methods');
    add_filter('pre_option_db_version', 'stats_ignore_db_version');
}
开发者ID:jordankoschei,项目名称:jordankoschei-dot-com,代码行数:29,代码来源:stats.php


示例11: get_page_ancestors

 function get_page_ancestors()
 {
     $ancestors = get_option("scoper_page_ancestors");
     if (is_array($ancestors)) {
         return $ancestors;
     }
     $ancestors = array();
     global $wpdb;
     if (awp_ver('3.0')) {
         $post_types = get_post_types(array('hierarchical' => true, 'public' => true));
         $where = "WHERE post_type IN ('" . implode("','", $post_types) . "') AND post_status != 'auto-draft'";
     } else {
         $where = "WHERE post_type != 'revision' AND post_type != 'post' AND post_status != 'auto-draft'";
     }
     if ($pages = scoper_get_results("SELECT ID, post_parent FROM {$wpdb->posts} {$where}")) {
         $parents = array();
         foreach ($pages as $page) {
             if ($page->post_parent) {
                 $parents[$page->ID] = $page->post_parent;
             }
         }
         foreach ($pages as $page) {
             $ancestors[$page->ID] = ScoperAncestry::_walk_ancestors($page->ID, array(), $parents);
             if (empty($ancestors[$page->ID])) {
                 unset($ancestors[$page->ID]);
             }
         }
         update_option("scoper_page_ancestors", $ancestors);
     }
     return $ancestors;
 }
开发者ID:Netsoro,项目名称:gdnlteamgroup,代码行数:31,代码来源:ancestry_lib_rs.php


示例12: sharing_add_meta_box

function sharing_add_meta_box()
{
    $post_types = get_post_types(array('public' => true));
    foreach ($post_types as $post_type) {
        add_meta_box('sharing_meta', __('Sharing', 'jetpack'), 'sharing_meta_box_content', $post_type, 'advanced', 'high');
    }
}
开发者ID:JeffreyBue,项目名称:jb,代码行数:7,代码来源:sharedaddy.php


示例13: column

 public function column()
 {
     global $wp_version;
     $is_wp_v3_1 = version_compare($wp_version, '3.0.999', '>');
     add_filter('manage_media_columns', array($this, 'add'));
     add_action('manage_media_custom_column', array($this, 'value'), 10, 2);
     add_filter('manage_link-manager_columns', array($this, 'add'));
     add_action('manage_link_custom_column', array($this, 'value'), 10, 2);
     add_action('manage_edit-link-categories_columns', array($this, 'add'));
     add_filter('manage_link_categories_custom_column', array($this, 'returnvalue'), 10, 3);
     foreach (get_taxonomies() as $taxonomy) {
         add_action("manage_edit-{$taxonomy}_columns", array($this, 'add'));
         add_filter("manage_{$taxonomy}_custom_column", array($this, 'returnvalue'), 10, 3);
         if ($is_wp_v3_1) {
             add_filter("manage_edit-{$taxonomy}_sortable_columns", array($this, 'add'));
         }
     }
     foreach (get_post_types() as $post_type) {
         add_action("manage_edit-{$post_type}_columns", array($this, 'add'));
         add_filter("manage_{$post_type}_posts_custom_column", array($this, 'value'), 10, 3);
         if ($is_wp_v3_1) {
             add_filter("manage_edit-{$post_type}_sortable_columns", array($this, 'add'));
         }
     }
     add_action('manage_users_columns', array($this, 'add'));
     add_filter('manage_users_custom_column', array($this, 'returnvalue'), 10, 3);
     if ($is_wp_v3_1) {
         add_filter("manage_users_sortable_columns", array($this, 'add'));
     }
     add_action('manage_edit-comments_columns', array($this, 'add'));
     add_action('manage_comments_custom_column', array($this, 'value'), 10, 2);
     if ($is_wp_v3_1) {
         add_filter("manage_edit-comments_sortable_columns", array($this, 'add'));
     }
 }
开发者ID:RA2WP,项目名称:RA2WP,代码行数:35,代码来源:class.attachaway_column.php


示例14: wpv_post_types_checkboxes

function wpv_post_types_checkboxes($view_settings)
{
    $post_types = get_post_types(array('public' => true), 'objects');
    // remove any post types that don't exist any more.
    foreach ($view_settings['post_type'] as $type) {
        if (!isset($post_types[$type])) {
            unset($view_settings['post_type'][$type]);
        }
    }
    ?>
        <ul style="padding-left:30px;">
            <?php 
    foreach ($post_types as $p) {
        ?>
                <?php 
        $checked = @in_array($p->name, $view_settings['post_type']) ? ' checked="checked"' : '';
        ?>
                <li><label><input type="checkbox" name="_wpv_settings[post_type][]" value="<?php 
        echo $p->name;
        ?>
" <?php 
        echo $checked;
        ?>
 onclick="wpv_filter_vmenu_items();" />&nbsp;<?php 
        echo $p->labels->name;
        ?>
</label></li>
            <?php 
    }
    ?>
        </ul>
    <?php 
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:33,代码来源:wpv-filter-post-types.php


示例15: add_meta_boxes

 /**
  * Add custom meta boxes to the nav menu editor
  */
 public static function add_meta_boxes()
 {
     static::$post_types = get_post_types(['has_archive' => true], 'object');
     if (!empty(static::$post_types)) {
         add_meta_box('add-archives', __('Archives', 'boilerplate'), [get_called_class(), 'archives_meta_box'], 'nav-menus', 'side', 'default');
     }
 }
开发者ID:locomotivemtl,项目名称:wordpress-boilerplate,代码行数:10,代码来源:nav-menus.php


示例16: super_sticky_set_post_types

function super_sticky_set_post_types()
{
    $post_types = get_post_types(array('_builtin' => false, 'public' => true), 'names');
    if (!empty($post_types)) {
        $checked_post_types = super_sticky_post_types();
        foreach ($post_types as $post_type) {
            ?>
			<div><input type="checkbox" id="<?php 
            echo esc_attr('post_type_' . $post_type);
            ?>
" name="sticky_custom_post_types[]" value="<?php 
            echo esc_attr($post_type);
            ?>
" <?php 
            checked(in_array($post_type, $checked_post_types));
            ?>
 /> <label for="<?php 
            echo esc_attr('post_type_' . $post_type);
            ?>
"><?php 
            echo esc_html($post_type);
            ?>
</label></div><?php 
        }
    } else {
        echo '<p>' . __('No public custom post types found.') . '</p>';
    }
}
开发者ID:SloppierKitty7,项目名称:wp-theme-gus,代码行数:28,代码来源:sticky-custom-post-types.php


示例17: add_meta_boxes

 public static function add_meta_boxes()
 {
     $post_types = get_post_types(array('public' => true));
     foreach ($post_types as $post_type) {
         add_meta_box('sbg_box', __('Sidebar', 'Avada'), array('sidebar_generator', 'edit_form'), $post_type, 'side');
     }
 }
开发者ID:universal-youth,项目名称:www.universal-youth.com,代码行数:7,代码来源:multiple_sidebars.php


示例18: enqueue

 /**
  * Enqueue Function.
  * If this field requires any scripts, or css define this function and register/enqueue the scripts/css
  * @return void
  */
 public function enqueue()
 {
     $post_types = get_post_types(array('_builtin' => false));
     /** @var array $options */
     $options = get_option('wpglobus_option');
     $options_post_types = empty($options['post_type']) ? array() : $options['post_type'];
     $disabled_post_types = array();
     /**
      * Add CPT from woocommerce
      */
     $disabled_post_types[] = 'product';
     $disabled_post_types[] = 'product_variation';
     $disabled_post_types[] = 'shop_order';
     $disabled_post_types[] = 'shop_order_refund';
     $disabled_post_types[] = 'shop_coupon';
     $disabled_post_types[] = 'shop_webhook';
     $enabled_post_types = array();
     foreach ($post_types as $post_type) {
         if (!in_array($post_type, $disabled_post_types, true)) {
             $enabled_post_types[] = $post_type;
         }
     }
     wp_enqueue_script('wpglobus-redux-field-post_types', plugins_url('/field_post_types' . WPGlobus::SCRIPT_SUFFIX() . '.js', __FILE__), array('jquery'), WPGlobus::SCRIPT_VER(), true);
     wp_localize_script('wpglobus-redux-field-post_types', 'wpglobus_post_types', array('post_type' => $enabled_post_types, 'options' => $options_post_types));
 }
开发者ID:rodica-andronache,项目名称:WPGlobus,代码行数:30,代码来源:field_post_types.php


示例19: theme_register_meta_boxes

function theme_register_meta_boxes()
{
    if (!class_exists('RW_Meta_Box')) {
        return;
    }
    $meta_boxes = array();
    $post_types = get_post_types();
    /**********************************************************************************/
    /* Intializes Each Above Meta Boxes */
    /**********************************************************************************/
    // $meta_boxes[] = array(
    //   'id' => 'custom_page_elements',
    //   'title' => 'Custom Page Elements',
    //   'pages' => array( 'page' ),
    //   'fields' => array(
    //     array(
    //       'name' => 'Logo',
    //       'id' => 'custom_logo',
    //       'type' => 'image_advanced',
    //       'desc' => 'Custom Logo'
    //       )
    //     )
    // );
    /**********************************************************************************/
    /* Registers Each Above Meta Boxes */
    /**********************************************************************************/
    foreach ($meta_boxes as $meta_box) {
        new RW_Meta_Box($meta_box);
    }
}
开发者ID:stephs829,项目名称:foundation-gulp-WP,代码行数:30,代码来源:meta_boxes.php


示例20: seventeen_right_now_content_table_end

/**
 * Add Custom Post Types and Taxonomies to "At a Glance" Dashboard Widget
 *
 * Ref Link: http://wpsnipp.com/index.php/functions-php/include-custom-post-types-in-right-now-admin-dashboard-widget/
 * http://wordpress.org/support/topic/dashboard-at-a-glance-custom-post-types
 * http://halfelf.org/2012/my-custom-posttypes-live-in-mu/
 */
function seventeen_right_now_content_table_end()
{
    $args = array('public' => true, '_builtin' => false);
    $output = 'object';
    $operator = 'and';
    $post_types = get_post_types($args, $output, $operator);
    foreach ($post_types as $post_type) {
        $num_posts = wp_count_posts($post_type->name);
        $num = number_format_i18n($num_posts->publish);
        $text = _n($post_type->labels->name, $post_type->labels->name, intval($num_posts->publish));
        if (current_user_can('edit_posts')) {
            $cpt_name = $post_type->name;
        }
        echo '<li class="post-count ' . $post_type->name . '-count"><tr><a href="edit.php?post_type=' . $cpt_name . '"><td class="first b b-' . $post_type->name . '"></td>' . $num . '&nbsp;<td class="t ' . $post_type->name . '">' . $text . '</td></a></tr></li>';
    }
    $taxonomies = get_taxonomies($args, $output, $operator);
    foreach ($taxonomies as $taxonomy) {
        $num_terms = wp_count_terms($taxonomy->name);
        $num = number_format_i18n($num_terms);
        $text = _n($taxonomy->labels->name, $taxonomy->labels->name, intval($num_terms));
        if (current_user_can('manage_categories')) {
            $cpt_tax = $taxonomy->name;
        }
        echo '<li class="taxonomy-count ' . $taxonomy->name . '-count"><tr><a href="edit-tags.php?taxonomy=' . $cpt_tax . '"><td class="first b b-' . $taxonomy->name . '"></td>' . $num . '&nbsp;<td class="t ' . $taxonomy->name . '">' . $text . '</td></a></tr></li>';
    }
}
开发者ID:psflannery,项目名称:seventeen,代码行数:33,代码来源:admin.php



注:本文中的get_post_types函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_post_value函数代码示例发布时间:2022-05-15
下一篇:
PHP get_post_type_object函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap