| @@ -2,17 +2,19 @@ | ||
| 2 | 2 | /** |
| 3 | 3 | * Roles and Capabilities for Charitable |
| 4 | 4 | * |
| 5 | 5 | * @package Charitable/Classes/Charitable_Roles |
| 6 | - * @author Eric Daams | |
| 7 | - * @copyright Copyright (c) 2019, Studio 164a | |
| 6 | + * @author David Bisset | |
| 7 | + * @copyright Copyright (c) 2023, WP Charitable LLC | |
| 8 | 8 | * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 9 | 9 | * @since 1.0.0 |
| 10 | - * @version 1.5.9 | |
| 10 | + * @version 1.6.51 | |
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | // Exit if accessed directly. |
| 14 | -if ( ! defined( 'ABSPATH' ) ) { exit; } | |
| 14 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 15 | + exit; | |
| 16 | +} | |
| 15 | 17 | |
| 16 | 18 | if ( ! class_exists( 'Charitable_Roles' ) ) : |
| 17 | 19 | |
| 18 | 20 | /** |
| @@ -17,9 +19,9 @@ | ||
| 17 | 19 | |
| 18 | 20 | /** |
| 19 | 21 | * Charitable_Roles class. |
| 20 | 22 | * |
| 21 | - * @since 1.0.0 | |
| 23 | + * @since 1.0.0 | |
| 22 | 24 | */ |
| 23 | 25 | class Charitable_Roles { |
| 24 | 26 | |
| 25 | 27 | /** |
| @@ -24,56 +26,64 @@ | ||
| 24 | 26 | |
| 25 | 27 | /** |
| 26 | 28 | * Sets up roles for Charitable. This is called by the install script. |
| 27 | 29 | * |
| 28 | - * @since 1.0.0 | |
| 30 | + * @since 1.0.0 | |
| 29 | 31 | * |
| 30 | - * @return void | |
| 32 | + * @return void | |
| 31 | 33 | */ |
| 32 | 34 | public function add_roles() { |
| 33 | - add_role( 'campaign_manager', __( 'Campaign Manager', 'charitable' ), array( | |
| 34 | - 'read' => true, | |
| 35 | - 'delete_posts' => true, | |
| 36 | - 'edit_posts' => true, | |
| 37 | - 'delete_published_posts' => true, | |
| 38 | - 'publish_posts' => true, | |
| 39 | - 'upload_files' => true, | |
| 40 | - 'edit_published_posts' => true, | |
| 41 | - 'read_private_pages' => true, | |
| 42 | - 'edit_private_pages' => true, | |
| 43 | - 'delete_private_pages' => true, | |
| 44 | - 'read_private_posts' => true, | |
| 45 | - 'edit_private_posts' => true, | |
| 46 | - 'delete_private_posts' => true, | |
| 47 | - 'delete_others_posts' => true, | |
| 48 | - 'delete_published_pages' => true, | |
| 49 | - 'delete_others_pages' => true, | |
| 50 | - 'delete_pages' => true, | |
| 51 | - 'publish_pages' => true, | |
| 52 | - 'edit_published_pages' => true, | |
| 53 | - 'edit_others_pages' => true, | |
| 54 | - 'edit_pages' => true, | |
| 55 | - 'edit_others_posts' => true, | |
| 56 | - 'manage_links' => true, | |
| 57 | - 'manage_categories' => true, | |
| 58 | - 'moderate_comments' => true, | |
| 59 | - 'import' => true, | |
| 60 | - 'export' => true, | |
| 61 | - 'unfiltered_html' => true, | |
| 62 | - ) ); | |
| 35 | + add_role( | |
| 36 | + 'campaign_manager', | |
| 37 | + __( 'Campaign Manager', 'charitable' ), | |
| 38 | + array( | |
| 39 | + 'read' => true, | |
| 40 | + 'delete_posts' => true, | |
| 41 | + 'edit_posts' => true, | |
| 42 | + 'delete_published_posts' => true, | |
| 43 | + 'publish_posts' => true, | |
| 44 | + 'upload_files' => true, | |
| 45 | + 'edit_published_posts' => true, | |
| 46 | + 'read_private_pages' => true, | |
| 47 | + 'edit_private_pages' => true, | |
| 48 | + 'delete_private_pages' => true, | |
| 49 | + 'read_private_posts' => true, | |
| 50 | + 'edit_private_posts' => true, | |
| 51 | + 'delete_private_posts' => true, | |
| 52 | + 'delete_others_posts' => true, | |
| 53 | + 'delete_published_pages' => true, | |
| 54 | + 'delete_others_pages' => true, | |
| 55 | + 'delete_pages' => true, | |
| 56 | + 'publish_pages' => true, | |
| 57 | + 'edit_published_pages' => true, | |
| 58 | + 'edit_others_pages' => true, | |
| 59 | + 'edit_pages' => true, | |
| 60 | + 'edit_others_posts' => true, | |
| 61 | + 'manage_links' => true, | |
| 62 | + 'manage_categories' => true, | |
| 63 | + 'moderate_comments' => true, | |
| 64 | + 'import' => true, | |
| 65 | + 'export' => true, | |
| 66 | + 'unfiltered_html' => false, | |
| 67 | + ) | |
| 68 | + ); | |
| 63 | 69 | |
| 64 | - add_role( 'donor', __( 'Donor', 'charitable' ), array( | |
| 65 | - 'read' => true, | |
| 66 | - ) ); | |
| 70 | + add_role( | |
| 71 | + 'donor', | |
| 72 | + __( 'Donor', 'charitable' ), | |
| 73 | + array( | |
| 74 | + 'read' => true, | |
| 75 | + ) | |
| 76 | + ); | |
| 67 | 77 | } |
| 68 | 78 | |
| 69 | 79 | /** |
| 70 | 80 | * Sets up capabilities for Charitable. This is called by the install script. |
| 71 | 81 | * |
| 72 | - * @global WP_Roles | |
| 73 | - * @since 1.0.0 | |
| 82 | + * @since 1.0.0 | |
| 74 | 83 | * |
| 75 | - * @return void | |
| 84 | + * @global WP_Roles | |
| 85 | + * @return void | |
| 76 | 86 | */ |
| 77 | 87 | public function add_caps() { |
| 78 | 88 | global $wp_roles; |
| 79 | 89 | |
| @@ -83,9 +93,8 @@ | ||
| 83 | 93 | } |
| 84 | 94 | } |
| 85 | 95 | |
| 86 | 96 | if ( is_object( $wp_roles ) ) { |
| 87 | - | |
| 88 | 97 | $wp_roles->add_cap( 'campaign_manager', 'view_charitable_sensitive_data' ); |
| 89 | 98 | $wp_roles->add_cap( 'campaign_manager', 'export_charitable_reports' ); |
| 90 | 99 | |
| 91 | 100 | $wp_roles->add_cap( 'administrator', 'view_charitable_sensitive_data' ); |
| @@ -102,12 +111,12 @@ | ||
| 102 | 111 | |
| 103 | 112 | /** |
| 104 | 113 | * Removes roles. This is called upon deactivation. |
| 105 | 114 | * |
| 106 | - * @global WP_Roles | |
| 107 | - * @since 1.0.0 | |
| 115 | + * @since 1.0.0 | |
| 108 | 116 | * |
| 109 | - * @return void | |
| 117 | + * @global WP_Roles | |
| 118 | + * @return void | |
| 110 | 119 | */ |
| 111 | 120 | public function remove_caps() { |
| 112 | 121 | global $wp_roles; |
| 113 | 122 | |
| @@ -117,9 +126,8 @@ | ||
| 117 | 126 | } |
| 118 | 127 | } |
| 119 | 128 | |
| 120 | 129 | if ( is_object( $wp_roles ) ) { |
| 121 | - | |
| 122 | 130 | $wp_roles->remove_cap( 'campaign_manager', 'view_charitable_sensitive_data' ); |
| 123 | 131 | $wp_roles->remove_cap( 'campaign_manager', 'export_charitable_reports' ); |
| 124 | 132 | |
| 125 | 133 | $wp_roles->remove_cap( 'administrator', 'view_charitable_sensitive_data' ); |
| @@ -139,11 +147,11 @@ | ||
| 139 | 147 | |
| 140 | 148 | /** |
| 141 | 149 | * Returns the caps for the post types that Charitable adds. |
| 142 | 150 | * |
| 143 | - * @since 1.0.0 | |
| 151 | + * @since 1.0.0 | |
| 144 | 152 | * |
| 145 | - * @return array | |
| 153 | + * @return array | |
| 146 | 154 | */ |
| 147 | 155 | private function get_core_caps() { |
| 148 | 156 | return array( |
| 149 | 157 | /* Campaign post type */ |
| @@ -180,8 +188,11 @@ | ||
| 180 | 188 | 'manage_campaign_terms', |
| 181 | 189 | 'edit_campaign_terms', |
| 182 | 190 | 'delete_campaign_terms', |
| 183 | 191 | 'assign_campaign_terms', |
| 192 | + | |
| 193 | + /* Builder */ | |
| 194 | + 'view_campaign_single', | |
| 184 | 195 | ); |
| 185 | 196 | } |
| 186 | 197 | } |
| 187 | 198 | |