PluginProbe
Timetics – Appointment Booking Calendar & Scheduling / 1.0.38
Timetics – Appointment Booking Calendar & Scheduling v1.0.38
1.0.61 1.0.60 1.0.59 1.0.58 1.0.57 1.0.56 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.2 1.0.20 1.0.21 1.0.22 1.0.23 1.0.24 All 62 releases
← All changes | base/role.php +14 -13 trunk1.0.38 View file →
@@ -5,10 +5,8 @@
5 5 * @package Timetics
6 6 */
7 7 namespace Timetics\Base;
8 8
9 -defined( 'ABSPATH' ) || exit;
10 -
11 9 use Timetics\Utils\Singleton;
12 10
13 11 /**
14 12 * Class Role
@@ -35,24 +33,13 @@
35 33 public function register_role() {
36 34 $roles = $this->get_roles();
37 35
38 36 foreach ( $roles as $role ) {
39 - // add_role() is a no-op if the role already exists, so on upgrade an
40 - // existing timetics-staff role keeps whatever caps it had before —
41 - // prune anything no longer in the definition below.
42 - $existing = get_role( $role['name'] );
43 -
44 37 add_role(
45 38 $role['name'],
46 39 $role['display_name'],
47 40 $role['capabilities']
48 41 );
49 -
50 - if ( $existing ) {
51 - foreach ( array_diff( array_keys( $existing->capabilities ), array_keys( $role['capabilities'] ) ) as $stale_cap ) {
52 - $existing->remove_cap( $stale_cap );
53 - }
54 - }
55 42 }
56 43 }
57 44
58 45 /**
@@ -66,9 +53,17 @@
66 53 'name' => 'timetics-staff',
67 54 'display_name' => esc_html__( 'Staff', 'timetics' ),
68 55 'capabilities' => [
69 56 'read' => true,
57 + 'delete_posts' => true,
58 + 'delete_published_posts' => true,
59 + 'edit_posts' => true,
60 + 'publish_posts' => true,
70 61 'upload_files' => true,
62 + 'edit_pages' => true,
63 + 'edit_published_pages' => true,
64 + 'publish_pages' => true,
65 + 'delete_published_pages' => false,
71 66 'read_booking' => true,
72 67 'read_meeting' => true,
73 68 'edit_profile' => true,
74 69 'manage_timetics' => true,
@@ -152,7 +147,13 @@
152 147 $users = get_users( ['role' => 'timetics-staff'] );
153 148
154 149 foreach ( $users as $user ) {
155 150 $user->add_role('timetics-customer');
151 + }
152 +
153 + foreach ( $users as $user ) {
154 + if ( ! user_can( $user, 'delete_published_pages' ) ) {
155 + $user->add_cap( 'delete_published_pages', true );
156 + }
156 157 }
157 158 }
158 159 }