PluginProbe
Elementor Website Builder – more than just a page builder / 3.0.2
Elementor Website Builder – more than just a page builder v3.0.2
4.3.1 4.3.0 4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 All 454 releases
← All changes | core/role-manager/role-manager.php +45 -126 4.3.1 → 3.0.2 View file →
@@ -1,12 +1,10 @@
1 1 <?php
2 2 namespace Elementor\Core\RoleManager;
3 3
4 -use Elementor\Core\Utils\Promotions\Filtered_Promotions_Manager;
5 -use Elementor\Modules\EditorOne\Classes\Menu_Data_Provider;
6 -use Elementor\Plugin;
4 +use Elementor\Settings_Page;
7 5 use Elementor\Settings;
8 -use Elementor\Settings_Page;
6 +use Elementor\Utils;
9 7
10 8 if ( ! defined( 'ABSPATH' ) ) {
11 9 exit; // Exit if accessed directly.
12 10 }
@@ -16,12 +14,8 @@
16 14 const PAGE_ID = 'elementor-role-manager';
17 15
18 16 const ROLE_MANAGER_OPTION_NAME = 'exclude_user_roles';
19 17
20 - const ROLE_MANAGER_ADVANCED = 'role-manager';
21 -
22 - private static $advanced_options = [];
23 -
24 18 /**
25 19 * @since 2.0.0
26 20 * @access public
27 21 */
@@ -28,27 +22,29 @@
28 22 public function get_role_manager_options() {
29 23 return get_option( 'elementor_' . self::ROLE_MANAGER_OPTION_NAME, [] );
30 24 }
31 25
32 - public function get_role_manager_advanced_options() {
33 - return get_option( 'elementor_' . self::ROLE_MANAGER_ADVANCED, [] );
26 + /**
27 + * @since 2.0.0
28 + * @access protected
29 + */
30 + protected function get_page_title() {
31 + return __( 'Role Manager', 'elementor' );
34 32 }
35 33
36 - public function get_user_advanced_options() {
37 - if ( ! empty( static::$advanced_options ) ) {
38 - return static::$advanced_options;
39 - }
40 -
41 - static::$advanced_options = $this->get_role_manager_advanced_options();
42 - return static::$advanced_options;
43 - }
44 -
45 34 /**
46 35 * @since 2.0.0
47 - * @access protected
36 + * @access public
48 37 */
49 - protected function get_page_title() {
50 - return esc_html__( 'Role Manager', 'elementor' );
38 + public function register_admin_menu() {
39 + add_submenu_page(
40 + Settings::PAGE_ID,
41 + $this->get_page_title(),
42 + $this->get_page_title(),
43 + 'manage_options',
44 + self::PAGE_ID,
45 + [ $this, 'display_settings_page' ]
46 + );
51 47 }
52 48
53 49 /**
54 50 * @since 2.0.0
@@ -57,14 +53,14 @@
57 53 protected function create_tabs() {
58 54 $validation_class = 'Elementor\Settings_Validations';
59 55 return [
60 56 'general' => [
61 - 'label' => esc_html__( 'General', 'elementor' ),
57 + 'label' => __( 'General', 'elementor' ),
62 58 'sections' => [
63 59 'tools' => [
64 60 'fields' => [
65 61 'exclude_user_roles' => [
66 - 'label' => esc_html__( 'Exclude Roles', 'elementor' ),
62 + 'label' => __( 'Exclude Roles', 'elementor' ),
67 63 'field_args' => [
68 64 'type' => 'checkbox_list_roles',
69 65 'exclude' => [ 'super_admin', 'administrator' ],
70 66 ],
@@ -71,17 +67,8 @@
71 67 'setting_args' => [
72 68 'sanitize_callback' => [ $validation_class, 'checkbox_list' ],
73 69 ],
74 70 ],
75 - self::ROLE_MANAGER_ADVANCED => [
76 - 'field_args' => [
77 - 'type' => 'raw_html',
78 - 'html' => '',
79 - ],
80 - 'setting_args' => [
81 - 'sanitize_callback' => [ $this, 'save_advanced_options' ],
82 - ],
83 - ],
84 71 ],
85 72 ],
86 73 ],
87 74 ],
@@ -87,12 +74,8 @@
87 74 ],
88 75 ];
89 76 }
90 77
91 - public function save_advanced_options( $input ) {
92 - return $input;
93 - }
94 -
95 78 /**
96 79 * @since 2.0.0
97 80 * @access public
98 81 */
@@ -99,27 +82,25 @@
99 82 public function display_settings_page() {
100 83 $this->get_tabs();
101 84 ?>
102 85 <div class="wrap">
103 - <h1 class="wp-heading-inline"><?php echo esc_html( $this->get_page_title() ); ?></h1>
86 + <h1><?php echo esc_html( $this->get_page_title() ); ?></h1>
104 87
105 - <div>
106 - <div id="elementor-role-manager">
107 - <h3><?php echo esc_html__( 'Manage What Your Users Can Edit In Elementor', 'elementor' ); ?></h3>
108 - <form id="elementor-settings-form" method="post" action="options.php">
109 - <?php
110 - settings_fields( static::PAGE_ID );
111 - echo '<div class="elementor-settings-form-page elementor-active">';
112 - foreach ( get_editable_roles() as $role_slug => $role_data ) {
113 - if ( 'administrator' === $role_slug ) {
114 - continue;
115 - }
116 - $this->display_role_controls( $role_slug, $role_data );
88 + <div id="elementor-role-manager">
89 + <h3><?php echo __( 'Manage What Your Users Can Edit In Elementor', 'elementor' ); ?></h3>
90 + <form id="elementor-settings-form" method="post" action="options.php">
91 + <?php
92 + settings_fields( static::PAGE_ID );
93 + echo '<div class="elementor-settings-form-page elementor-active">';
94 + foreach ( get_editable_roles() as $role_slug => $role_data ) {
95 + if ( 'administrator' === $role_slug ) {
96 + continue;
117 97 }
118 - submit_button( __( 'Save Changes', 'elementor' ), 'primary', 'submit', true, [ 'data-id' => 'elementor-role-manager-button-save-changes' ] );
119 - ?>
120 - </form>
121 - </div>
98 + $this->display_role_controls( $role_slug, $role_data );
99 + }
100 + submit_button();
101 + ?>
102 + </form>
122 103 </div>
123 104 </div><!-- /.wrap -->
124 105 <?php
125 106 }
@@ -136,25 +117,23 @@
136 117 if ( false === $excluded_options ) {
137 118 $excluded_options = $this->get_role_manager_options();
138 119 }
139 120
140 - $row_classes = 'elementor-role-row ' . esc_attr( $role_slug ) . ' e-editor-one';
141 -
142 121 ?>
143 - <div class="<?php echo esc_attr( $row_classes ); ?>">
122 + <div class="elementor-role-row <?php echo esc_attr( $role_slug ); ?>">
144 123 <div class="elementor-role-label">
145 - <span class="elementor-role-name"><?php echo esc_html( translate_user_role( $role_data['name'] ) ); ?></span>
124 + <span class="elementor-role-name"><?php echo esc_html( $role_data['name'] ); ?></span>
146 125 <span data-excluded-label="<?php esc_attr_e( 'Role Excluded', 'elementor' ); ?>" class="elementor-role-excluded-indicator"></span>
147 - <span class="elementor-role-toggle" data-id="<?php echo esc_attr( $role_slug ); ?>-toggle"><span class="dashicons dashicons-arrow-down"></span></span>
126 + <span class="elementor-role-toggle"><span class="dashicons dashicons-arrow-down"></span></span>
148 127 </div>
149 128 <div class="elementor-role-controls hidden">
150 129 <div class="elementor-role-control">
151 130 <label>
152 131 <input type="checkbox" name="elementor_exclude_user_roles[]" value="<?php echo esc_attr( $role_slug ); ?>"<?php checked( in_array( $role_slug, $excluded_options, true ), true ); ?>>
153 - <?php echo esc_html__( 'No access to editor', 'elementor' ); ?>
132 + <?php echo __( 'No access to editor', 'elementor' ); ?>
154 133 </label>
155 134 </div>
156 - <div class="elementor-role-controls-advanced">
135 + <div>
157 136 <?php
158 137 /**
159 138 * Role restrictions controls.
160 139 *
@@ -176,77 +155,28 @@
176 155 </div>
177 156 <?php
178 157 }
179 158
180 - public function add_json_enable_control( $role_slug ) {
181 - $value = 'json-upload';
182 - $id = self::ROLE_MANAGER_ADVANCED . '_' . $role_slug . '_' . $value;
183 - $name = 'elementor_' . self::ROLE_MANAGER_ADVANCED . '[' . $role_slug . '][]';
184 -
185 - $advanced_options = $this->get_user_advanced_options();
186 - $checked = isset( $advanced_options[ $role_slug ] ) ? $advanced_options[ $role_slug ] : [];
187 - ?>
188 - <div class="elementor-role-control">
189 - <label for="<?php echo esc_attr( $id ); ?>">
190 - <input type="checkbox" name="<?php echo esc_attr( $name ); ?>" id="<?php echo esc_attr( $id ); ?>" value="<?php echo esc_attr( $value ); ?>" <?php checked( in_array( $value, $checked, true ), true ); ?>>
191 - <?php echo esc_html__( 'Enable the option to upload JSON files', 'elementor' ); ?>
192 - </label>
193 - <p class="elementor-role-control-warning"><strong><?php echo esc_html__( 'Heads up', 'elementor' ); ?>:</strong> <?php echo esc_html__( 'Giving broad access to upload JSON files can pose a security risk to your website because such files may contain malicious scripts, etc.', 'elementor' ); ?></p>
194 - </div>
195 - <?php
196 - }
197 -
198 - public function add_custom_html_enable_control( $role_slug ) {
199 - $value = 'custom-html';
200 - $id = self::ROLE_MANAGER_ADVANCED . '_' . $role_slug . '_' . $value;
201 - $name = 'elementor_' . self::ROLE_MANAGER_ADVANCED . '[' . $role_slug . '][]';
202 -
203 - $advanced_options = $this->get_user_advanced_options();
204 - $checked = isset( $advanced_options[ $role_slug ] ) ? $advanced_options[ $role_slug ] : [];
205 - ?>
206 - <div class="elementor-role-control">
207 - <label for="<?php echo esc_attr( $id ); ?>">
208 - <input type="checkbox" name="<?php echo esc_attr( $name ); ?>" id="<?php echo esc_attr( $id ); ?>" value="<?php echo esc_attr( $value ); ?>" <?php checked( in_array( $value, $checked, true ), true ); ?>>
209 - <?php echo esc_html__( 'Enable the option to use the HTML widget', 'elementor' ); ?>
210 - </label>
211 - <p class="elementor-role-control-warning"><strong><?php echo esc_html__( 'Heads up', 'elementor' ); ?>:</strong> <?php echo esc_html__( 'Giving broad access to edit the HTML widget can pose a security risk to your website because it enables users to run malicious scripts, etc.', 'elementor' ); ?></p>
212 - </div>
213 - <?php
214 - }
215 -
216 159 /**
217 160 * @since 2.0.0
218 161 * @access public
219 162 */
220 163 public function get_go_pro_link_html() {
221 - $promotion = $this->get_go_pro_link_content();
222 -
164 + $pro_link = Utils::get_pro_link( 'https://elementor.com/pro/?utm_source=wp-role-manager&utm_campaign=gopro&utm_medium=wp-dash' );
223 165 ?>
224 166 <div class="elementor-role-go-pro">
225 - <div class="elementor-role-go-pro__desc"><?php echo esc_html( $promotion['description'] ); ?></div>
226 - <div class="elementor-role-go-pro__link"><a class="elementor-button go-pro" target="_blank" href="<?php echo esc_url( $promotion['upgrade_url'] ); ?>"><?php echo esc_html( $promotion['upgrade_text'] ); ?></a></div>
167 + <div class="elementor-role-go-pro__desc"><?php echo __( 'Want to give access only to content?', 'elementor' ); ?></div>
168 + <div class="elementor-role-go-pro__link"><a class="elementor-button elementor-button-default elementor-button-go-pro" target="_blank" href="<?php echo esc_url( $pro_link ); ?>"><?php echo __( 'Go Pro', 'elementor' ); ?></a></div>
227 169 </div>
228 170 <?php
229 171 }
230 172
231 - public function get_go_pro_link_content() {
232 - $upgrade_url = 'https://go.elementor.com/go-pro-role-manager/';
233 -
234 - $promotion = [
235 - 'description' => esc_html__( 'Want to give access only to content?', 'elementor' ),
236 - 'upgrade_url' => esc_url( $upgrade_url ),
237 - 'upgrade_text' => esc_html__( 'Upgrade', 'elementor' ),
238 - ];
239 -
240 - return Filtered_Promotions_Manager::get_filtered_promotion_data( $promotion, 'elementor/role/custom_promotion', 'upgrade_url' );
241 - }
242 -
243 173 /**
244 174 * @since 2.0.0
245 175 * @access public
246 176 */
247 177 public function get_user_restrictions_array() {
248 - $user = wp_get_current_user();
178 + $user = wp_get_current_user();
249 179 $user_roles = $user->roles;
250 180 $options = $this->get_user_restrictions();
251 181 $restrictions = [];
252 182 if ( empty( $options ) ) {
@@ -302,12 +232,8 @@
302 232
303 233 return true;
304 234 }
305 235
306 - private function register_editor_one_menu( Menu_Data_Provider $menu_data_provider ) {
307 - $menu_data_provider->register_menu( new Editor_One_Role_Manager_Menu() );
308 - }
309 -
310 236 /**
311 237 * @since 2.0.0
312 238 * @access public
313 239 */
@@ -313,15 +239,8 @@
313 239 */
314 240 public function __construct() {
315 241 parent::__construct();
316 242
317 - add_action( 'elementor/editor-one/menu/register', function ( Menu_Data_Provider $menu_data_provider ) {
318 - $this->register_editor_one_menu( $menu_data_provider );
319 - } );
320 -
321 - add_action( 'elementor/role/restrictions/controls', [ $this, 'add_json_enable_control' ] );
322 - add_action( 'elementor/role/restrictions/controls', [ $this, 'add_custom_html_enable_control' ] );
243 + add_action( 'admin_menu', [ $this, 'register_admin_menu' ], 100 );
323 244 add_action( 'elementor/role/restrictions/controls', [ $this, 'get_go_pro_link_html' ] );
324 -
325 - add_filter( 'elementor/editor/user/restrictions', [ $this, 'get_role_manager_advanced_options' ] );
326 245 }
327 246 }