get_role_manager_advanced_options();
return static::$advanced_options;
}
/**
* @since 2.0.0
* @access protected
*/
protected function get_page_title() {
return esc_html__( 'Role Manager', 'elementor' );
}
/**
* @since 2.0.0
* @access public
*/
public function register_admin_menu( Admin_Menu_Manager $admin_menu ) {
$admin_menu->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' ],
],
],
self::ROLE_MANAGER_ADVANCED => [
'field_args' => [
'type' => 'raw_html',
'html' => '',
],
'setting_args' => [
'sanitize_callback' => [ $this, 'save_advanced_options' ],
],
],
],
],
],
],
];
}
public function save_advanced_options( $input ) {
return $input;
}
/**
* @since 2.0.0
* @access public
*/
public function display_settings_page() {
$this->get_tabs();
?>
get_role_manager_options();
}
?>
get_user_advanced_options();
$checked = isset( $advanced_options[ $role_slug ] ) ? $advanced_options[ $role_slug ] : [];
?>
get_user_advanced_options();
$checked = isset( $advanced_options[ $role_slug ] ) ? $advanced_options[ $role_slug ] : [];
?>
get_go_pro_link_content();
?>
esc_html__( 'Want to give access only to content?', 'elementor' ),
'upgrade_url' => esc_url( $upgrade_url ),
'upgrade_text' => esc_html__( 'Upgrade', 'elementor' ),
];
return Filtered_Promotions_Manager::get_filtered_promotion_data( $promotion, 'elementor/role/custom_promotion', 'upgrade_url' );
}
/**
* @since 2.0.0
* @access public
*/
public function get_user_restrictions_array() {
$user = wp_get_current_user();
$user_roles = $user->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();
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, 'add_json_enable_control' ] );
add_action( 'elementor/role/restrictions/controls', [ $this, 'add_custom_html_enable_control' ] );
add_action( 'elementor/role/restrictions/controls', [ $this, 'get_go_pro_link_html' ] );
add_filter( 'elementor/editor/user/restrictions', [ $this, 'get_role_manager_advanced_options' ] );
}
}