generated from pascalmartineau/wp-skeleton
feat: Initial plugins and theme
All checks were successful
WordPress deployment / deploy (push) Successful in 9s
All checks were successful
WordPress deployment / deploy (push) Successful in 9s
This commit is contained in:
88
wp-content/themes/ccat/includes/cpt/contributor.php
Normal file
88
wp-content/themes/ccat/includes/cpt/contributor.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
// Register 'contributor' post type
|
||||
add_action( 'init', 'ccat_contributor_register_post_type' );
|
||||
function ccat_contributor_register_post_type() {
|
||||
register_post_type(
|
||||
'contributor',
|
||||
array(
|
||||
'labels' => array(
|
||||
'name' => __( "Contributors", 'ccat' ),
|
||||
'menu_name' => __( "Contributors", 'ccat' ),
|
||||
'singular_name' => __( "Contributor", 'ccat' ),
|
||||
'add_new' => __( "Add New", 'ccat' ),
|
||||
'add_new_item' => __( "Add New Contributor", 'ccat' ),
|
||||
'new_item' => __( "New Contributor", 'ccat' ),
|
||||
'edit_item' => __( "Edit Contributor", 'ccat' ),
|
||||
'view_item' => __( "View Contributor", 'ccat' ),
|
||||
'view_items' => __( "View Contributors", 'ccat' ),
|
||||
'search_items' => __( "Search Contributors", 'ccat' ),
|
||||
'not_found' => __( "No Contributors found", 'ccat' ),
|
||||
'not_found_in_trash' => __( "No Contributors found in trash", 'ccat' ),
|
||||
'parent_item_colon' => __( "Parent Contributor:", 'ccat' ),
|
||||
'all_items' => __( "All Contributors", 'ccat' ),
|
||||
'archives' => __( "Contributor Archives", 'ccat' ),
|
||||
'attributes' => __( "Contributor Attributes", 'ccat' ),
|
||||
'insert_into_item' => __( "Insert into Contributor", 'ccat' ),
|
||||
'uploaded_to_this_item' => __( "Uploaded to this Contributor", 'ccat' ),
|
||||
'featured_image' => __( "Featured Image", 'ccat' ),
|
||||
'set_featured_image' => __( "Set featured image", 'ccat' ),
|
||||
'remove_featured_image' => __( "Remove featured image", 'ccat' ),
|
||||
'use_featured_image' => __( "Use as featured image", 'ccat' ),
|
||||
'filter_items_list' => __( "Filter Contributors list", 'ccat' ),
|
||||
'items_list_navigation' => __( "Contributors list navigation", 'ccat' ),
|
||||
'items_list' => __( "Contributors list", 'ccat' ),
|
||||
'item_published' => __( "Contributor published.", 'ccat' ),
|
||||
'item_published_privately' => __( "Contributor published privately.", 'ccat' ),
|
||||
'item_reverted_to_draft' => __( "Contributor reverted to draft.", 'ccat' ),
|
||||
'item_scheduled' => __( "Contributor scheduled.", 'ccat' ),
|
||||
'item_updated' => __( "Contributor updated.", 'ccat' ),
|
||||
),
|
||||
'public' => true,
|
||||
'hierarchical' => true,
|
||||
'show_ui' => true,
|
||||
'show_in_nav_menus' => false,
|
||||
'supports' => array( 'title', 'thumbnail', 'author', 'excerpt', 'revisions' ),
|
||||
'has_archive' => false,
|
||||
'rewrite' => array(
|
||||
'slug' => 'contributeur',
|
||||
'with_front' => false,
|
||||
),
|
||||
'query_var' => true,
|
||||
'menu_icon' => 'dashicons-art',
|
||||
'show_in_rest' => true,
|
||||
'rest_base' => 'contributor',
|
||||
'rest_controller_class' => 'WP_REST_Posts_Controller',
|
||||
'show_in_graphql' => true,
|
||||
'graphql_single_name' => "Contributor",
|
||||
'graphql_plural_name' => "Contributors",
|
||||
'graphql_interfaces' => array( 'Node' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Custom 'contributor' post updated messages
|
||||
add_filter( 'post_updated_messages', 'ccat_contributor_post_updated_messages' );
|
||||
function ccat_contributor_post_updated_messages( $messages ) {
|
||||
global $post;
|
||||
$permalink = get_permalink( $post );
|
||||
$preview_post_link_html = sprintf( ' <a target="_blank" href="%1$s">%2$s</a>', esc_url( get_preview_post_link( $post ) ), __( "Preview Contributor", 'ccat' ) );
|
||||
$scheduled_post_link_html = sprintf( ' <a target="_blank" href="%1$s">%2$s</a>', esc_url( $permalink ), __( "Preview Contributor", 'ccat' ) );
|
||||
$scheduled_date = date_i18n( __( "M j, Y @ H:i", 'ccat' ), strtotime( $post->post_date ) );
|
||||
$view_post_link_html = sprintf( ' <a href="%1$s">%2$s</a>', esc_url( $permalink ), __( "View Contributor", 'ccat' ) );
|
||||
$messages['contributor'] = array(
|
||||
0 => '',
|
||||
1 => __( "Contributor updated.", 'ccat' ) . $view_post_link_html,
|
||||
2 => __( "Custom field updated.", 'ccat' ),
|
||||
3 => __( "Custom field deleted.", 'ccat' ),
|
||||
4 => __( "Contributor updated.", 'ccat' ),
|
||||
5 => isset( $_GET['revision'] ) ? sprintf( __( "Contributor restored to revision from %s", 'ccat' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
|
||||
6 => __( "Contributor published.", 'ccat' ) . $view_post_link_html,
|
||||
7 => __( "Contributor saved.", 'ccat' ),
|
||||
8 => __( "Contributor submitted.", 'ccat' ) . $preview_post_link_html,
|
||||
9 => sprintf( __( 'Contributor scheduled for: %s.' ), '<strong>' . $scheduled_date . '</strong>' ) . $scheduled_post_link_html,
|
||||
10 => __( 'Contributor draft updated.' ) . $preview_post_link_html,
|
||||
);
|
||||
|
||||
return $messages;
|
||||
}
|
||||
Reference in New Issue
Block a user