| 1 |
<?php |
| 2 |
|
| 3 |
namespace Getwid; |
| 4 |
|
| 5 |
/** |
| 6 |
* Class Post Template Part |
| 7 |
* @package Getwid |
| 8 |
*/ |
| 9 |
class PostTemplatePart { |
| 10 |
|
| 11 |
public $postType = 'getwid_template_part'; |
| 12 |
|
| 13 |
/** |
| 14 |
* PostTemplatePart constructor. |
| 15 |
*/ |
| 16 |
public function __construct() { |
| 17 |
|
| 18 |
add_action( 'init', [ $this, 'register_post_type' ] ); |
| 19 |
} |
| 20 |
|
| 21 |
public function register_post_type(){ |
| 22 |
$labels = array( |
| 23 |
'name' => __( 'Post Templates', 'getwid' ), |
| 24 |
'singular_name' => __( 'Post Template', 'getwid' ), |
| 25 |
'menu_name' => __( 'Getwid Post Templates', 'getwid' ), |
| 26 |
'add_new' => __( 'New Template', 'getwid' ), |
| 27 |
'add_new_item' => __( 'Add New Template', 'getwid' ), |
| 28 |
'edit_item' => __( 'Edit Template', 'getwid' ), |
| 29 |
'new_item' => __( 'New Template', 'getwid' ), |
| 30 |
'view_item' => __( 'View Template', 'getwid' ), |
| 31 |
'search_items' => __( 'Search Templates', 'getwid' ), |
| 32 |
'not_found' => __( 'No templates found', 'getwid' ), |
| 33 |
'not_found_in_trash' => __( 'No templates found in Trash', 'getwid' ), |
| 34 |
); |
| 35 |
|
| 36 |
$args = array( |
| 37 |
'labels' => $labels, |
| 38 |
'has_archive' => false, |
| 39 |
'public' => false, |
| 40 |
'exclude_from_search' => true, |
| 41 |
'show_in_nav_menus' => false, |
| 42 |
'show_in_admin_bar' => false, |
| 43 |
'hierarchical' => false, |
| 44 |
'show_ui' => true, |
| 45 |
'show_in_menu' => false, |
| 46 |
'menu_position' => 100, |
| 47 |
'menu_icon' => 'dashicons-category', |
| 48 |
'supports' => array( |
| 49 |
'title', |
| 50 |
'editor', |
| 51 |
'author', |
| 52 |
'revisions', |
| 53 |
), |
| 54 |
'capabilities' => array( |
| 55 |
'publish_posts' => 'administrator', |
| 56 |
'edit_others_posts' => 'administrator', |
| 57 |
'delete_posts' => 'administrator', |
| 58 |
'delete_others_posts' => 'administrator', |
| 59 |
'read_private_posts' => 'administrator', |
| 60 |
'edit_post' => 'administrator', |
| 61 |
// 'edit_posts' => 'administrator', |
| 62 |
'delete_post' => 'administrator', |
| 63 |
'read_post' => 'administrator', |
| 64 |
'create_posts' => 'administrator', |
| 65 |
), |
| 66 |
'rewrite' => false, |
| 67 |
'show_in_rest' => true, |
| 68 |
// template |
| 69 |
'template' => array( |
| 70 |
array ( |
| 71 |
'getwid/template-post-layout-helper', |
| 72 |
), |
| 73 |
), |
| 74 |
); |
| 75 |
|
| 76 |
register_post_type( $this->postType, $args ); |
| 77 |
} |
| 78 |
|
| 79 |
} |
| 80 |
|