WPFunctions::get()->applyFilters( 'mailpoet_permission_access_plugin_admin', [ 'administrator', 'editor', ] ), self::PERMISSION_MANAGE_SETTINGS => WPFunctions::get()->applyFilters( 'mailpoet_permission_manage_settings', [ 'administrator', ] ), self::PERMISSION_MANAGE_FEATURES => WPFunctions::get()->applyFilters( 'mailpoet_permission_manage_features', [ 'administrator', ] ), self::PERMISSION_MANAGE_EMAILS => WPFunctions::get()->applyFilters( 'mailpoet_permission_manage_emails', [ 'administrator', 'editor', ] ), self::PERMISSION_MANAGE_SUBSCRIBERS => WPFunctions::get()->applyFilters( 'mailpoet_permission_manage_subscribers', [ 'administrator', ] ), self::PERMISSION_MANAGE_FORMS => WPFunctions::get()->applyFilters( 'mailpoet_permission_manage_forms', [ 'administrator', ] ), self::PERMISSION_MANAGE_SEGMENTS => WPFunctions::get()->applyFilters( 'mailpoet_permission_manage_segments', [ 'administrator', ] ), self::PERMISSION_MANAGE_AUTOMATIONS => WPFunctions::get()->applyFilters( 'mailpoet_permission_manage_automations', [ 'administrator', 'editor', ] ), ]; } public function getPermissionLabels() { return [ self::PERMISSION_ACCESS_PLUGIN_ADMIN => __('Admin menu item', 'mailpoet'), self::PERMISSION_MANAGE_SETTINGS => __('Manage settings', 'mailpoet'), self::PERMISSION_MANAGE_FEATURES => __('Manage features', 'mailpoet'), self::PERMISSION_MANAGE_EMAILS => __('Manage emails', 'mailpoet'), self::PERMISSION_MANAGE_SUBSCRIBERS => __('Manage subscribers', 'mailpoet'), self::PERMISSION_MANAGE_FORMS => __('Manage forms', 'mailpoet'), self::PERMISSION_MANAGE_SEGMENTS => __('Manage segments', 'mailpoet'), self::PERMISSION_MANAGE_AUTOMATIONS => __('Manage automations', 'mailpoet'), ]; } public function validatePermission($permission) { if ($permission === self::NO_ACCESS_RESTRICTION) return true; if ($permission === self::ALL_ROLES_ACCESS) { $capabilities = array_keys($this->getDefaultPermissions()); foreach ($capabilities as $capability) { if (WPFunctions::get()->currentUserCan($capability)) { return true; } } return false; } return WPFunctions::get()->currentUserCan($permission); } }