first commit
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace WPML;
|
||||
|
||||
class DefaultCapabilities {
|
||||
|
||||
public static function get() {
|
||||
return [
|
||||
'wpml_manage_translation_management' => __( 'Manage Translation Management', 'sitepress' ),
|
||||
'wpml_manage_languages' => __( 'Manage Languages', 'sitepress' ),
|
||||
'wpml_manage_theme_and_plugin_localization' => __( 'Manage Theme and Plugin localization', 'sitepress' ),
|
||||
'wpml_manage_support' => __( 'Manage Support', 'sitepress' ),
|
||||
'wpml_manage_woocommerce_multilingual' => __( 'Manage WooCommerce Multilingual', 'sitepress' ),
|
||||
'wpml_operate_woocommerce_multilingual' => __( 'Operate WooCommerce Multilingual. Everything on WCML except the settings tab.', 'sitepress' ),
|
||||
'wpml_manage_media_translation' => __( 'Manage Media translation', 'sitepress' ),
|
||||
'wpml_manage_navigation' => __( 'Manage Navigation', 'sitepress' ),
|
||||
'wpml_manage_sticky_links' => __( 'Manage Sticky Links', 'sitepress' ),
|
||||
'wpml_manage_string_translation' => __( 'Manage String Translation', 'sitepress' ),
|
||||
'wpml_manage_translation_analytics' => __( 'Manage Translation Analytics', 'sitepress' ),
|
||||
'wpml_manage_wp_menus_sync' => __( 'Manage WPML Menus Sync', 'sitepress' ),
|
||||
'wpml_manage_taxonomy_translation' => __( 'Manage Taxonomy Translation', 'sitepress' ),
|
||||
'wpml_manage_troubleshooting' => __( 'Manage Troubleshooting', 'sitepress' ),
|
||||
'wpml_manage_translation_options' => __( 'Translation options', 'sitepress' ),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace WPML;
|
||||
|
||||
use WPML\LIB\WP\Hooks;
|
||||
use WPML\LIB\WP\User;
|
||||
use WPML\LIB\WP\Roles as WPRoles;
|
||||
use function WPML\FP\spreadArgs;
|
||||
|
||||
class Roles implements \IWPML_Backend_Action, \IWPML_AJAX_Action {
|
||||
|
||||
public function add_hooks() {
|
||||
Hooks::onAction( 'set_user_role', 10, 3 )->then( spreadArgs( [ self::class, 'remove_caps' ] ) );
|
||||
}
|
||||
|
||||
public static function remove_caps( $userId, $role, $oldRoles ) {
|
||||
if ( ! WPRoles::hasCap( 'manage_options', $role ) ) {
|
||||
$user = User::get( $userId );
|
||||
|
||||
wpml_collect( DefaultCapabilities::get() )
|
||||
->keys()
|
||||
->map( [ $user, 'remove_cap' ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
class WPML_Manage_Translations_Role {
|
||||
const CAPABILITY = 'manage_translations';
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
class WPML_Translator_Role {
|
||||
const CAPABILITY = 'translate';
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user