() { $upgrade_url = 'https://go.elementor.com/go-pro-role-manager/'; $promotion = [ 'description' => esc_html__( 'Want to give access only to content?', 'elementor' ), 'upgrade_url' => esc_url( $upgrade_url ), 'upgrade_text' => esc_html__( 'Upgrade', 'elementor' ), ]; $new_promotion = apply_filters( 'elementor/role/custom_promotion', $promotion ); if ( ! empty( $new_promotion ) && count( $new_promotion ) <= count( $promotion ) ) { $promotion = $new_promotion; $promotion = $this->replace_url( $promotion, $upgrade_url ); } return $promotion; } /** * @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(); 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, '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' ] ); } }