PluginProbe
Elementor Website Builder – more than just a page builder / 3.5.6
Elementor Website Builder – more than just a page builder v3.5.6
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 4.1.0-beta1 4.1.0-dev1 All 452 releases
← All changes | core/role-manager/role-manager.php +43 -122 4.1.0-beta33.5.6 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,31 @@
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 + $sanitized_page_title = esc_html( $this->get_page_title() );
40 +
41 + add_submenu_page(
42 + Settings::PAGE_ID,
43 + $sanitized_page_title,
44 + $sanitized_page_title,
45 + 'manage_options',
46 + self::PAGE_ID,
47 + [ $this, 'display_settings_page' ]
48 + );
51 49 }
52 50
53 51 /**
54 52 * @since 2.0.0
@@ -71,17 +69,8 @@
71 69 'setting_args' => [
72 70 'sanitize_callback' => [ $validation_class, 'checkbox_list' ],
73 71 ],
74 72 ],
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 73 ],
85 74 ],
86 75 ],
87 76 ],
@@ -87,12 +76,8 @@
87 76 ],
88 77 ];
89 78 }
90 79
91 - public function save_advanced_options( $input ) {
92 - return $input;
93 - }
94 -
95 80 /**
96 81 * @since 2.0.0
97 82 * @access public
98 83 */
@@ -101,25 +86,23 @@
101 86 ?>
102 87 <div class="wrap">
103 88 <h1 class="wp-heading-inline"><?php echo esc_html( $this->get_page_title() ); ?></h1>
104 89
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 );
90 + <div id="elementor-role-manager">
91 + <h3><?php echo esc_html__( 'Manage What Your Users Can Edit In Elementor', 'elementor' ); ?></h3>
92 + <form id="elementor-settings-form" method="post" action="options.php">
93 + <?php
94 + settings_fields( static::PAGE_ID );
95 + echo '<div class="elementor-settings-form-page elementor-active">';
96 + foreach ( get_editable_roles() as $role_slug => $role_data ) {
97 + if ( 'administrator' === $role_slug ) {
98 + continue;
117 99 }
118 - submit_button( __( 'Save Changes', 'elementor' ), 'primary', 'submit', true, [ 'data-id' => 'elementor-role-manager-button-save-changes' ] );
119 - ?>
120 - </form>
121 - </div>
100 + $this->display_role_controls( $role_slug, $role_data );
101 + }
102 + submit_button();
103 + ?>
104 + </form>
122 105 </div>
123 106 </div><!-- /.wrap -->
124 107 <?php
125 108 }
@@ -136,16 +119,14 @@
136 119 if ( false === $excluded_options ) {
137 120 $excluded_options = $this->get_role_manager_options();
138 121 }
139 122
140 - $row_classes = 'elementor-role-row ' . esc_attr( $role_slug ) . ' e-editor-one';
141 -
142 123 ?>
143 - <div class="<?php echo esc_attr( $row_classes ); ?>">
124 + <div class="elementor-role-row <?php echo esc_attr( $role_slug ); ?>">
144 125 <div class="elementor-role-label">
145 - <span class="elementor-role-name"><?php echo esc_html( translate_user_role( $role_data['name'] ) ); ?></span>
126 + <span class="elementor-role-name"><?php echo esc_html( $role_data['name'] ); ?></span>
146 127 <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>
128 + <span class="elementor-role-toggle"><span class="dashicons dashicons-arrow-down"></span></span>
148 129 </div>
149 130 <div class="elementor-role-controls hidden">
150 131 <div class="elementor-role-control">
151 132 <label>
@@ -152,9 +133,9 @@
152 133 <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 134 <?php echo esc_html__( 'No access to editor', 'elementor' ); ?>
154 135 </label>
155 136 </div>
156 - <div class="elementor-role-controls-advanced">
137 + <div>
157 138 <?php
158 139 /**
159 140 * Role restrictions controls.
160 141 *
@@ -176,77 +157,28 @@
176 157 </div>
177 158 <?php
178 159 }
179 160
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 161 /**
217 162 * @since 2.0.0
218 163 * @access public
219 164 */
220 165 public function get_go_pro_link_html() {
221 - $promotion = $this->get_go_pro_link_content();
222 -
166 + $pro_link = Utils::get_pro_link( 'https://elementor.com/pro/?utm_source=wp-role-manager&utm_campaign=gopro&utm_medium=wp-dash' );
223 167 ?>
224 168 <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>
169 + <div class="elementor-role-go-pro__desc"><?php echo esc_html__( 'Want to give access only to content?', 'elementor' ); ?></div>
170 + <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 esc_html__( 'Go Pro', 'elementor' ); ?></a></div>
227 171 </div>
228 172 <?php
229 173 }
230 174
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 175 /**
244 176 * @since 2.0.0
245 177 * @access public
246 178 */
247 179 public function get_user_restrictions_array() {
248 - $user = wp_get_current_user();
180 + $user = wp_get_current_user();
249 181 $user_roles = $user->roles;
250 182 $options = $this->get_user_restrictions();
251 183 $restrictions = [];
252 184 if ( empty( $options ) ) {
@@ -302,12 +234,8 @@
302 234
303 235 return true;
304 236 }
305 237
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 238 /**
311 239 * @since 2.0.0
312 240 * @access public
313 241 */
@@ -313,15 +241,8 @@
313 241 */
314 242 public function __construct() {
315 243 parent::__construct();
316 244
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' ] );
245 + add_action( 'admin_menu', [ $this, 'register_admin_menu' ], 100 );
323 246 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 247 }
327 248 }