PluginProbe
EmailKit – Email Customizer for WooCommerce & WP / 1.2.0
EmailKit – Email Customizer for WooCommerce & WP v1.2.0
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.2.0, at includes/Admin/CPT.php

108 lines 4.5 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 $args = array(
66
67 'label' => esc_html__('Email Template', 'emailkit'),
68 'description' => esc_html__('Post Type Description', 'emailkit'),
69 'labels' => $labels,
70 'supports' => array('title'),
71 'hierarchical' => false,
72 'public' => true,
73 'show_ui' => true,
74 'show_in_menu' => true,
75 'menu_icon' => 'dashicons-email',
76 'menu_position' => 25,
77 'show_in_admin_bar' => true,
78 'show_in_nav_menus' => true,
79 'can_export' => true,
80 'has_archive' => true,
81 'exclude_from_search' => false,
82 'publicly_queryable' => false,
83 'rewrite' => false,
84 'capability_type' => 'page',
85 'capabilities' => array(
86 'publish_posts' => 'publish_emailkit',
87 'edit_posts' => 'edit_emailkit',
88 'delete_posts' => 'delete_emailkit',
89 'read_private_posts' => 'read_private_emailkit',
90 'edit_post' => 'edit_emailkit',
91 'delete_post' => 'delete_emailkit',
92 'read_post' => 'read_emailkit',
93 ),
94 // '_edit_link' => 'post.php?post=%d&builder=emailkit'
95
96 );
97
98 register_post_type('emailkit', $args);
99
100 flush_rewrite_rules();
101 }
102
103 function remove_add_new_submenu() {
104 global $submenu;
105 unset($submenu['edit.php?post_type=emailkit'][10]);
106 }
107 }
108