php populate_cpt_labels.php
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php populate_cpt_labels.php相关的知识,希望对你有一定的参考价值。
<?php
add_action( 'init', function() {
$post_types = array(
'industry_solution' => array(
'args' => array(
'label' => 'Industry Solutions',
'labels' => populate_cpt_labels('Industry Solution', 'Industry Solutions'),
'public' => true,
'has_archive' => false,
'menu_position' => 22,
'menu_icon' => 'dashicons-tag',
'supports' => array('title', 'thumbnail','editor'),
'rewrite' => array('slug' => 'industry')
)
),
'team_member' => array(
'args' => array(
'label' => 'Team Member',
'labels' => populate_cpt_labels('Team Member', 'Team Members'),
'public' => false,
'show_ui' => true,
'menu_position' => 23,
'menu_icon' => 'dashicons-tag',
'supports' => array('title', 'thumbnail','editor')
)
),
'logo' => array(
'args' => array(
'label' => 'Logo',
'labels' => populate_cpt_labels('Logo', 'Logos'),
'public' => false,
'show_ui' => true,
'menu_position' => 24,
'menu_icon' => 'dashicons-tag',
'supports' => array('title', 'thumbnail')
)
),
);
foreach ( $post_types as $post_key => $post_data ) {
$args = array();
if ( ! empty( $post_data['args'] ) ) {
$args = $post_data['args'];
}
register_post_type( $post_key, $args );
}
});
<?php
function populate_cpt_labels( $singular, $plural, $overrides = array(), $text_domain = "" ) {
return shortcode_atts( array(
'name' => _x( $plural, 'Post Type General Name', $text_domain ),
'singular_name' => _x( $singular, 'Post Type Singular Name', $text_domain ),
'menu_name' => __( $plural, $text_domain ),
'name_admin_bar' => __( $singular, $text_domain ),
'archives' => __( $singular . ' Archives', $text_domain ),
'attributes' => __( $singular . ' Attributes', $text_domain ),
'parent_item_colon' => __( 'Parent ' . $singular . ':', $text_domain ),
'all_items' => __( 'All ' . $plural, $text_domain ),
'add_new_item' => __( 'Add New ' . $singular, $text_domain ),
'add_new' => __( 'Add New', $text_domain ),
'new_item' => __( 'New ' . $singular, $text_domain ),
'edit_item' => __( 'Edit ' . $singular, $text_domain ),
'update_item' => __( 'Update ' . $singular, $text_domain ),
'view_item' => __( 'View ' . $singular, $text_domain ),
'view_items' => __( 'View ' . $plural, $text_domain ),
'search_items' => __( 'Search ' . $plural, $text_domain ),
'not_found' => __( 'Not found', $text_domain ),
'not_found_in_trash' => __( 'Not found in Trash', $text_domain ),
'featured_image' => __( 'Featured Image', $text_domain ),
'set_featured_image' => __( 'Set featured image', $text_domain ),
'remove_featured_image' => __( 'Remove featured image', $text_domain ),
'use_featured_image' => __( 'Use as featured image', $text_domain ),
'insert_into_item' => __( 'Insert into ' . $singular, $text_domain ),
'uploaded_to_this_item' => __( 'Uploaded to this ' . $singular, $text_domain ),
'items_list' => __( $plural . ' list', $text_domain ),
'items_list_navigation' => __( $plural . ' list navigation', $text_domain ),
'filter_items_list' => __( 'Filter ' . $singular . ' list', $text_domain ),
) , $overrides );
}
以上是关于php populate_cpt_labels.php的主要内容,如果未能解决你的问题,请参考以下文章
IntelliJ IDEA 11编辑php是,支持php文件名为.php5和.php4,如何设置能让其也支持.php呢?