register( static::PAGE_ID, new Role_Manager_Menu_Item( $this ) );
}
/**
* @since 2.0.0
* @access protected
*/
protected function create_tabs() {
$validation_class = 'Elementor\Settings_Validations';
return [
'general' => [
'label' => esc_html__( 'General', 'elementor' ),
'sections' => [
'tools' => [
'fields' => [
'exclude_user_roles' => [
'label' => esc_html__( 'Exclude Roles', 'elementor' ),
'field_args' => [
'type' => 'checkbox_list_roles',
'exclude' => [ 'super_admin', 'administrator' ],
],
'setting_args' => [
'sanitize_callback' => [ $validation_class, 'checkbox_list' ],
],
],
],
],
],
],
];
}
/**
* @since 2.0.0
* @access public
*/
public function display_settings_page() {
$this->get_tabs();
?>
get_role_manager_options();
}
?>
roles;
$options = $this->get_user_restrictions();
$restrictions = [];
if ( empty( $options ) ) {
return $restrictions;
}
foreach ( $user_roles as $role ) {
if ( ! isset( $options[ $role ] ) ) {
continue;
}
$restrictions = array_merge( $restrictions, $options[ $role ] );
}
return array_unique( $restrictions );
}
/**
* @since 2.0.0
* @access private
*/
private function get_user_restrictions() {
static $restrictions = false;
if ( ! $restrictions ) {
$restrictions = [];
/**
* Editor user restrictions.
*
* Filters the user restrictions in the editor.
*
* @since 2.0.0
*
* @param array $restrictions User restrictions.
*/
$restrictions = apply_filters( 'elementor/editor/user/restrictions', $restrictions );
}
return $restrictions;
}
/**
* @since 2.0.0
* @access public
*
* @param $capability
*
* @return bool
*/
public function user_can( $capability ) {
$options = $this->get_user_restrictions_array();
if ( in_array( $capability, $options, true ) ) {
return false;
}
return true;
}
/**
* @since 2.0.0
* @access public
*/
public function __construct() {
parent::__construct();
if ( ! Plugin::$instance->experiments->is_feature_active( 'admin_menu_rearrangement' ) ) {
add_action( 'elementor/admin/menu/register', function ( Admin_Menu_Manager $admin_menu ) {
$this->register_admin_menu( $admin_menu );
}, Settings::ADMIN_MENU_PRIORITY + 10 );
}
add_action( 'elementor/role/restrictions/controls', [ $this, 'get_go_pro_link_html' ] );
}
}