admin-notices
1 year ago
features
1 year ago
plugin-capabilities
1 year ago
redirects
1 year ago
roles
1 year ago
admin-load.php
1 year ago
admin.php
1 year ago
backup-handler.php
1 year ago
backup.php
1 year ago
cap-helper.php
1 year ago
dashboard.php
1 year ago
extractor-capabilities.php
1 year ago
filters-admin.php
1 year ago
filters-woocommerce.php
1 year ago
filters-wp_rest_workarounds.php
1 year ago
filters.php
1 year ago
functions-admin.php
1 year ago
functions.php
1 year ago
handler.php
1 year ago
inflect-cme.php
1 year ago
manager.php
1 year ago
network.php
1 year ago
plugin-capabilities.php
1 year ago
pp-handler.php
1 year ago
pp-ui.php
1 year ago
publishpress-roles.php
1 year ago
settings-handler.php
1 year ago
settings-ui.php
1 year ago
settings.php
1 year ago
test-user-ui.php
1 year ago
test-user.php
1 year ago
plugin-capabilities.php
337 lines
| 1 | <?php |
| 2 | |
| 3 | namespace PublishPress\Capabilities; |
| 4 | |
| 5 | class Plugin_Capabilities |
| 6 | { |
| 7 | private static $instance = null; |
| 8 | |
| 9 | public static function instance() |
| 10 | { |
| 11 | if (is_null(self::$instance)) { |
| 12 | self::$instance = new Plugin_Capabilities(); |
| 13 | } |
| 14 | |
| 15 | return self::$instance; |
| 16 | } |
| 17 | |
| 18 | public function __construct() |
| 19 | { |
| 20 | //PublishPress Capabilities |
| 21 | add_filter('cme_plugin_capabilities', [$this, 'cme_publishpress_capabilities_capabilities']); |
| 22 | //PublishPress Authors |
| 23 | add_filter('cme_plugin_capabilities', [$this, 'cme_multiple_authors_capabilities']); |
| 24 | //PublishPress Permissions |
| 25 | add_filter('cme_plugin_capabilities', [$this, 'cme_presspermit_capabilities']); |
| 26 | //Gravity Forms |
| 27 | add_filter('cme_plugin_capabilities', [$this, 'cme_gravityforms_capabilities']); |
| 28 | //WPML |
| 29 | add_filter('cme_plugin_capabilities', [$this, 'cme_wpml_capabilities']); |
| 30 | //WS Form |
| 31 | add_filter('cme_plugin_capabilities', [$this, 'cme_wsform_capabilities']); |
| 32 | //TaxoPress |
| 33 | add_filter('cme_plugin_capabilities', [$this, 'cme_taxopress_capabilities']); |
| 34 | //WooCommerce` |
| 35 | add_filter('cme_plugin_capabilities', [$this, 'cme_woocommerce_capabilities']); |
| 36 | //Echo Knowledge Base |
| 37 | add_filter('cme_plugin_capabilities', [$this, 'cme_echo_knowledge_base_capabilities']); |
| 38 | // Yoast SEO |
| 39 | add_filter('cme_plugin_capabilities', [$this, 'cme_yoast_seo_capabilities']); |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * PublishPress Capabilities |
| 44 | * |
| 45 | * @param array $plugin_caps |
| 46 | * |
| 47 | * @return array |
| 48 | */ |
| 49 | public function cme_publishpress_capabilities_capabilities($plugin_caps) |
| 50 | { |
| 51 | |
| 52 | $plugin_caps['PublishPress Capabilities'] = apply_filters('cme_publishpress_capabilities_capabilities', []); |
| 53 | |
| 54 | return $plugin_caps; |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * PublishPress Authors |
| 59 | * |
| 60 | * @param array $plugin_caps |
| 61 | * |
| 62 | * @return array |
| 63 | */ |
| 64 | public function cme_multiple_authors_capabilities($plugin_caps) |
| 65 | { |
| 66 | |
| 67 | if (defined('PUBLISHPRESS_MULTIPLE_AUTHORS_VERSION')) { |
| 68 | if ($_caps = apply_filters('cme_multiple_authors_capabilities', [])) { |
| 69 | $plugin_caps['PublishPress Authors'] = $_caps; |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | return $plugin_caps; |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * PublishPress Permissions |
| 78 | * |
| 79 | * @param array $plugin_caps |
| 80 | * |
| 81 | * @return array |
| 82 | */ |
| 83 | public function cme_presspermit_capabilities($plugin_caps) |
| 84 | { |
| 85 | |
| 86 | if (defined('PRESSPERMIT_VERSION')) { |
| 87 | $plugin_caps['PublishPress Permissions'] = apply_filters( |
| 88 | 'cme_presspermit_capabilities', |
| 89 | [ |
| 90 | 'edit_own_attachments', |
| 91 | 'list_others_unattached_files', |
| 92 | 'pp_administer_content', |
| 93 | 'pp_assign_roles', |
| 94 | 'pp_associate_any_page', |
| 95 | 'pp_create_groups', |
| 96 | 'pp_create_network_groups', |
| 97 | 'pp_define_moderation', |
| 98 | 'pp_define_post_status', |
| 99 | 'pp_define_privacy', |
| 100 | 'pp_delete_groups', |
| 101 | 'pp_edit_groups', |
| 102 | 'pp_exempt_edit_circle', |
| 103 | 'pp_exempt_read_circle', |
| 104 | 'pp_force_quick_edit', |
| 105 | 'pp_list_all_files', |
| 106 | 'pp_manage_capabilities', |
| 107 | 'pp_manage_members', |
| 108 | 'pp_manage_network_members', |
| 109 | 'pp_manage_settings', |
| 110 | 'pp_moderate_any', |
| 111 | 'pp_set_associate_exceptions', |
| 112 | 'pp_set_edit_exceptions', |
| 113 | 'pp_set_read_exceptions', |
| 114 | 'pp_set_revise_exceptions', |
| 115 | 'pp_set_term_assign_exceptions', |
| 116 | 'pp_set_term_associate_exceptions', |
| 117 | 'pp_set_term_manage_exceptions', |
| 118 | 'pp_unfiltered', |
| 119 | 'set_posts_status', |
| 120 | ] |
| 121 | ); |
| 122 | } |
| 123 | |
| 124 | return $plugin_caps; |
| 125 | } |
| 126 | |
| 127 | /** |
| 128 | * Gravity Forms |
| 129 | * |
| 130 | * @param array $plugin_caps |
| 131 | * |
| 132 | * @return array |
| 133 | */ |
| 134 | public function cme_gravityforms_capabilities($plugin_caps) |
| 135 | { |
| 136 | if (defined('GF_PLUGIN_DIR_PATH')) { |
| 137 | $plugin_caps['Gravity Forms'] = apply_filters( |
| 138 | 'cme_gravityforms_capabilities', |
| 139 | [ |
| 140 | 'gravityforms_create_form', |
| 141 | 'gravityforms_delete_forms', |
| 142 | 'gravityforms_edit_forms', |
| 143 | 'gravityforms_preview_forms', |
| 144 | 'gravityforms_view_entries', |
| 145 | 'gravityforms_edit_entries', |
| 146 | 'gravityforms_delete_entries', |
| 147 | 'gravityforms_view_entry_notes', |
| 148 | 'gravityforms_edit_entry_notes', |
| 149 | 'gravityforms_export_entries', |
| 150 | 'gravityforms_view_settings', |
| 151 | 'gravityforms_edit_settings', |
| 152 | 'gravityforms_view_updates', |
| 153 | 'gravityforms_view_addons', |
| 154 | 'gravityforms_system_status', |
| 155 | 'gravityforms_uninstall', |
| 156 | 'gravityforms_logging', |
| 157 | 'gravityforms_api_settings', |
| 158 | ] |
| 159 | ); |
| 160 | } |
| 161 | |
| 162 | return $plugin_caps; |
| 163 | } |
| 164 | |
| 165 | /** |
| 166 | * WPML |
| 167 | * |
| 168 | * @param array $plugin_caps |
| 169 | * |
| 170 | * @return array |
| 171 | */ |
| 172 | public function cme_wpml_capabilities($plugin_caps) |
| 173 | { |
| 174 | |
| 175 | if (defined('WPML_PLUGIN_FILE')) { |
| 176 | $plugin_caps['WPML'] = apply_filters( |
| 177 | 'cme_wpml_capabilities', |
| 178 | [ |
| 179 | 'wpml_manage_translation_management', |
| 180 | 'wpml_manage_languages', |
| 181 | 'wpml_manage_translation_options', |
| 182 | 'wpml_manage_troubleshooting', |
| 183 | 'wpml_manage_taxonomy_translation', |
| 184 | 'wpml_manage_wp_menus_sync', |
| 185 | 'wpml_manage_translation_analytics', |
| 186 | 'wpml_manage_string_translation', |
| 187 | 'wpml_manage_sticky_links', |
| 188 | 'wpml_manage_navigation', |
| 189 | 'wpml_manage_theme_and_plugin_localization', |
| 190 | 'wpml_manage_media_translation', |
| 191 | 'wpml_manage_support', |
| 192 | 'wpml_manage_woocommerce_multilingual', |
| 193 | 'wpml_operate_woocommerce_multilingual', |
| 194 | ] |
| 195 | ); |
| 196 | } |
| 197 | |
| 198 | return $plugin_caps; |
| 199 | } |
| 200 | |
| 201 | /** |
| 202 | * WS Form |
| 203 | * |
| 204 | * @param array $plugin_caps |
| 205 | * |
| 206 | * @return array |
| 207 | */ |
| 208 | public function cme_wsform_capabilities($plugin_caps) |
| 209 | { |
| 210 | if (defined('WS_FORM_VERSION')) { |
| 211 | $plugin_caps['WS Form'] = apply_filters( |
| 212 | 'cme_wsform_capabilities', |
| 213 | [ |
| 214 | 'create_form', |
| 215 | 'delete_form', |
| 216 | 'edit_form', |
| 217 | 'export_form', |
| 218 | 'import_form', |
| 219 | 'publish_form', |
| 220 | 'read_form', |
| 221 | 'delete_submission', |
| 222 | 'edit_submission', |
| 223 | 'export_submission', |
| 224 | 'read_submission', |
| 225 | 'create_form_style', |
| 226 | 'delete_form_style', |
| 227 | 'edit_form_style', |
| 228 | 'export_form_style', |
| 229 | 'import_form_style', |
| 230 | 'publish_form_style', |
| 231 | 'read_form_style', |
| 232 | 'manage_options_wsform', |
| 233 | ] |
| 234 | ); |
| 235 | } |
| 236 | |
| 237 | return $plugin_caps; |
| 238 | } |
| 239 | |
| 240 | /** |
| 241 | * TaxoPress |
| 242 | * |
| 243 | * @param array $plugin_caps |
| 244 | * |
| 245 | * @return array |
| 246 | */ |
| 247 | public function cme_taxopress_capabilities($plugin_caps) |
| 248 | { |
| 249 | |
| 250 | if (defined('STAGS_VERSION')) { |
| 251 | $plugin_caps['TaxoPress'] = apply_filters( |
| 252 | 'cme_taxopress_capabilities', |
| 253 | [ |
| 254 | 'simple_tags', |
| 255 | 'admin_simple_tags' |
| 256 | ] |
| 257 | ); |
| 258 | } |
| 259 | |
| 260 | return $plugin_caps; |
| 261 | } |
| 262 | |
| 263 | /** |
| 264 | * Echo Knowledge Base |
| 265 | * |
| 266 | * @param array $plugin_caps |
| 267 | * |
| 268 | * @return array |
| 269 | */ |
| 270 | public function cme_echo_knowledge_base_capabilities($plugin_caps) |
| 271 | { |
| 272 | |
| 273 | if (defined('EPKB_PLUGIN_NAME')) { |
| 274 | $plugin_caps['Echo Knowledge Base'] = apply_filters( |
| 275 | 'cme_echo_knowledge_base_capabilities', |
| 276 | [ |
| 277 | 'admin_eckb_access_manager_page', |
| 278 | 'admin_eckb_access_crud_users', |
| 279 | 'admin_eckb_access_frontend_editor_write', |
| 280 | 'admin_eckb_access_search_analytics_read', |
| 281 | 'admin_eckb_access_order_articles_write', |
| 282 | 'admin_eckb_access_need_help_read', |
| 283 | 'admin_eckb_access_addons_news_read' |
| 284 | ] |
| 285 | ); |
| 286 | } |
| 287 | |
| 288 | return $plugin_caps; |
| 289 | } |
| 290 | |
| 291 | /** |
| 292 | * Yoast SEO |
| 293 | * |
| 294 | * @param array $plugin_caps |
| 295 | * |
| 296 | * @return array |
| 297 | */ |
| 298 | public function cme_yoast_seo_capabilities($plugin_caps) { |
| 299 | if (defined('WPSEO_FILE')) { |
| 300 | $plugin_caps['Yoast SEO'] = apply_filters('cme_yoast_seo_capabilities', |
| 301 | [ |
| 302 | 'view_site_health_checks', |
| 303 | 'wpseo_bulk_edit', |
| 304 | 'wpseo_edit_advanced_metadata', |
| 305 | 'wpseo_manage_options' |
| 306 | |
| 307 | ] |
| 308 | ); |
| 309 | } |
| 310 | |
| 311 | return $plugin_caps; |
| 312 | } |
| 313 | |
| 314 | /** |
| 315 | * WooCommerce |
| 316 | * |
| 317 | * @param array $plugin_caps |
| 318 | * |
| 319 | * @return array |
| 320 | */ |
| 321 | public function cme_woocommerce_capabilities($plugin_caps) |
| 322 | { |
| 323 | |
| 324 | if (defined('WC_PLUGIN_FILE') && class_exists('WC_Install')) { |
| 325 | $woocommerce_caps = array_merge(...array_values(\WC_Install::get_core_capabilities())); |
| 326 | sort($woocommerce_caps); |
| 327 | // https://github.com/woocommerce/woocommerce/blob/f513ce7c253b0b05511e1eb592b9345aaf084f9a/plugins/woocommerce/includes/class-wc-install.php#L1788C3-L1814C4 |
| 328 | $plugin_caps['WooCommerce'] = apply_filters( |
| 329 | 'cme_woocommerce_capabilities', |
| 330 | $woocommerce_caps |
| 331 | ); |
| 332 | } |
| 333 | |
| 334 | return $plugin_caps; |
| 335 | } |
| 336 | } |
| 337 |