PluginProbe
EmailKit – Email Customizer for WooCommerce & WP / 1.4.5
EmailKit – Email Customizer for WooCommerce & WP v1.4.5
1.6.9 1.6.8 1.6.7 trunk 1.0.0 1.2.0 1.4.0 1.4.5 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6
emailkit / includes / Admin / CPT.php

CPT.php in EmailKit – Email Customizer for WooCommerce & WP 1.4.5, at includes/Admin/CPT.php

113 lines 4.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace EmailKit\Admin;
4
5 defined( 'ABSPATH' ) || exit;
6
7 class CPT
8 {
9
10 public function __construct()
11 {
12 add_action('init', [$this, 'postType']);
13 add_action('init',[$this,'add_role']);
14 add_action('admin_menu', [$this,'remove_add_new_submenu']);
15 }
16
17 public function add_role(){
18 $roles = array(get_role(('administrator')));
19
20 foreach($roles as $role) {
21
22 if($role) {
23 $role->add_cap( 'edit_emailkit' );
24 $role->add_cap( 'edit_others_emailkit' );
25 $role->add_cap( 'publish_emailkit' );
26 $role->add_cap( 'read_emailkit' );
27 $role->add_cap( 'read_private_emailkit' );
28 $role->add_cap( 'delete_emailkit' );
29 $role->add_cap( 'edit_published_emailkit' );
30 $role->add_cap( 'delete_published_' );
31 }
32 }
33 }
34
35 /**
36 * Emailkit Template CPT
37 */
38 function postType()
39 {
40 $labels = array(
41
42 'name' => esc_html_x('EmailKit', 'Post type general name', 'emailkit'),
43 'singular_name' => esc_html_x('EmailKit', 'Post type singular name', 'emailkit'),
44 'menu_name' => esc_html_x('EmailKit', 'Admin Menu text', 'emailkit'),
45 'name_admin_bar' => esc_html_x('EmailKit', 'Add New on Toolbar', 'emailkit'),
46 'add_new' => esc_html__('Add New Email', 'emailkit'),
47 'add_new_item' => esc_html__('Add New Email Template', 'emailkit'),
48 'new_item' => esc_html__('New Email', 'emailkit'),
49 'edit_item' => esc_html__('Edit Email Template', 'emailkit'),
50 'view_item' => esc_html__('View Email', 'emailkit'),
51 'all_items' => esc_html__('All Emails', 'emailkit'),
52 'search_items' => esc_html__('Search Emails', 'emailkit'),
53 'parent_item_colon' => esc_html__('Parent Emails:', 'emailkit'),
54 'not_found' => esc_html__('No email found.', 'emailkit'),
55 'not_found_in_trash' => esc_html__('No email found in Trash.', 'emailkit'),
56 'archives' => esc_html_x('Email archives', '', 'emailkit'),
57 'insert_into_item' => esc_html_x('Insert into email', '', 'emailkit'),
58 'uploaded_to_this_item' => esc_html_x('Uploaded to this email', '', 'emailkit'),
59 'filter_items_list' => esc_html_x('Filter emails list', '', 'emailkit'),
60 'items_list_navigation' => esc_html_x('Emails list navigation', '', 'emailkit'),
61 'items_list' => esc_html_x('Emails list', '', 'emailkit'),
62
63 );
64
65 $rewrite = [
66 'slug' => 'emailkit-template',
67 'with_front' => true,
68 'pages' => false,
69 'feeds' => false,
70 ];
71
72 $args = array(
73
74 'label' => esc_html__('Email Template', 'emailkit'),
75 'description' => esc_html__('Post Type Description', 'emailkit'),
76 'labels' => $labels,
77 'supports' => array('title'),
78 'hierarchical' => false,
79 'public' => true,
80 'show_ui' => true,
81 'show_in_menu' => true,
82 'menu_icon' => 'dashicons-email',
83 'menu_position' => 25,
84 'show_in_admin_bar' => true,
85 'show_in_nav_menus' => true,
86 'can_export' => true,
87 'has_archive' => true,
88 'exclude_from_search' => false,
89 'publicly_queryable' => false,
90 'rewrite' =>$rewrite,
91 'capability_type' => 'page',
92 'capabilities' => array(
93 'publish_posts' => 'publish_emailkit',
94 'edit_posts' => 'edit_emailkit',
95 'delete_posts' => 'delete_emailkit',
96 'read_private_posts' => 'read_private_emailkit',
97 'edit_post' => 'edit_emailkit',
98 'delete_post' => 'delete_emailkit',
99 'read_post' => 'read_emailkit',
100 ),
101 // '_edit_link' => 'post.php?post=%d&builder=emailkit'
102
103 );
104
105 register_post_type('emailkit', $args);
106 }
107
108 function remove_add_new_submenu() {
109 global $submenu;
110 unset($submenu['edit.php?post_type=emailkit'][10]);
111 }
112 }
113