Last active
August 18, 2017 01:25
-
-
Save gschoppe/99c5d381f50d73e389c5978327da78a4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment