| @@ -1,9 +1,9 @@ | ||
| 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; | |
| 4 | +use Elementor\Core\Admin\Menu\Admin_Menu_Manager; | |
| 5 | +use Elementor\Core\Utils\Promotions\Validate_Promotion; | |
| 6 | 6 | use Elementor\Plugin; |
| 7 | 7 | use Elementor\Settings; |
| 8 | 8 | use Elementor\Settings_Page; |
| 9 | 9 | |
| @@ -51,8 +51,28 @@ | ||
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
| 54 | 54 | * @since 2.0.0 |
| 55 | + * @access public | |
| 56 | + */ | |
| 57 | + public function register_admin_menu( Admin_Menu_Manager $admin_menu ) { | |
| 58 | + $admin_menu->register( static::PAGE_ID, new Role_Manager_Menu_Item( $this ) ); | |
| 59 | + } | |
| 60 | + | |
| 61 | + /** | |
| 62 | + * @param $promotion | |
| 63 | + * @param string $upgrade_url | |
| 64 | + * @return mixed | |
| 65 | + */ | |
| 66 | + private function replace_url( $promotion, string $upgrade_url ) { | |
| 67 | + if ( ! Validate_Promotion::domain_is_on_elementor_dot_com( $promotion['upgrade_url'] ) ) { | |
| 68 | + $promotion['upgrade_url'] = $upgrade_url; | |
| 69 | + } | |
| 70 | + return $promotion; | |
| 71 | + } | |
| 72 | + | |
| 73 | + /** | |
| 74 | + * @since 2.0.0 | |
| 55 | 75 | * @access protected |
| 56 | 76 | */ |
| 57 | 77 | protected function create_tabs() { |
| 58 | 78 | $validation_class = 'Elementor\Settings_Validations'; |
| @@ -101,25 +121,23 @@ | ||
| 101 | 121 | ?> |
| 102 | 122 | <div class="wrap"> |
| 103 | 123 | <h1 class="wp-heading-inline"><?php echo esc_html( $this->get_page_title() ); ?></h1> |
| 104 | 124 | |
| 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 ); | |
| 125 | + <div id="elementor-role-manager"> | |
| 126 | + <h3><?php echo esc_html__( 'Manage What Your Users Can Edit In Elementor', 'elementor' ); ?></h3> | |
| 127 | + <form id="elementor-settings-form" method="post" action="options.php"> | |
| 128 | + <?php | |
| 129 | + settings_fields( static::PAGE_ID ); | |
| 130 | + echo '<div class="elementor-settings-form-page elementor-active">'; | |
| 131 | + foreach ( get_editable_roles() as $role_slug => $role_data ) { | |
| 132 | + if ( 'administrator' === $role_slug ) { | |
| 133 | + continue; | |
| 117 | 134 | } |
| 118 | - submit_button( __( 'Save Changes', 'elementor' ), 'primary', 'submit', true, [ 'data-id' => 'elementor-role-manager-button-save-changes' ] ); | |
| 119 | - ?> | |
| 120 | - </form> | |
| 121 | - </div> | |
| 135 | + $this->display_role_controls( $role_slug, $role_data ); | |
| 136 | + } | |
| 137 | + submit_button(); | |
| 138 | + ?> | |
| 139 | + </form> | |
| 122 | 140 | </div> |
| 123 | 141 | </div><!-- /.wrap --> |
| 124 | 142 | <?php |
| 125 | 143 | } |
| @@ -136,16 +154,14 @@ | ||
| 136 | 154 | if ( false === $excluded_options ) { |
| 137 | 155 | $excluded_options = $this->get_role_manager_options(); |
| 138 | 156 | } |
| 139 | 157 | |
| 140 | - $row_classes = 'elementor-role-row ' . esc_attr( $role_slug ) . ' e-editor-one'; | |
| 141 | - | |
| 142 | 158 | ?> |
| 143 | - <div class="<?php echo esc_attr( $row_classes ); ?>"> | |
| 159 | + <div class="elementor-role-row <?php echo esc_attr( $role_slug ); ?>"> | |
| 144 | 160 | <div class="elementor-role-label"> |
| 145 | 161 | <span class="elementor-role-name"><?php echo esc_html( translate_user_role( $role_data['name'] ) ); ?></span> |
| 146 | 162 | <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> | |
| 163 | + <span class="elementor-role-toggle"><span class="dashicons dashicons-arrow-down"></span></span> | |
| 148 | 164 | </div> |
| 149 | 165 | <div class="elementor-role-controls hidden"> |
| 150 | 166 | <div class="elementor-role-control"> |
| 151 | 167 | <label> |
| @@ -186,9 +202,9 @@ | ||
| 186 | 202 | $checked = isset( $advanced_options[ $role_slug ] ) ? $advanced_options[ $role_slug ] : []; |
| 187 | 203 | ?> |
| 188 | 204 | <div class="elementor-role-control"> |
| 189 | 205 | <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 ); ?>> | |
| 206 | + <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 ); ?>> | |
| 191 | 207 | <?php echo esc_html__( 'Enable the option to upload JSON files', 'elementor' ); ?> |
| 192 | 208 | </label> |
| 193 | 209 | <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 | 210 | </div> |
| @@ -204,9 +220,9 @@ | ||
| 204 | 220 | $checked = isset( $advanced_options[ $role_slug ] ) ? $advanced_options[ $role_slug ] : []; |
| 205 | 221 | ?> |
| 206 | 222 | <div class="elementor-role-control"> |
| 207 | 223 | <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 ); ?>> | |
| 224 | + <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 ); ?>> | |
| 209 | 225 | <?php echo esc_html__( 'Enable the option to use the HTML widget', 'elementor' ); ?> |
| 210 | 226 | </label> |
| 211 | 227 | <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 | 228 | </div> |
| @@ -236,9 +252,16 @@ | ||
| 236 | 252 | 'upgrade_url' => esc_url( $upgrade_url ), |
| 237 | 253 | 'upgrade_text' => esc_html__( 'Upgrade', 'elementor' ), |
| 238 | 254 | ]; |
| 239 | 255 | |
| 240 | - return Filtered_Promotions_Manager::get_filtered_promotion_data( $promotion, 'elementor/role/custom_promotion', 'upgrade_url' ); | |
| 256 | + $new_promotion = apply_filters( 'elementor/role/custom_promotion', $promotion ); | |
| 257 | + | |
| 258 | + if ( ! empty( $new_promotion ) && count( $new_promotion ) <= count( $promotion ) ) { | |
| 259 | + $promotion = $new_promotion; | |
| 260 | + $promotion = $this->replace_url( $promotion, $upgrade_url ); | |
| 261 | + } | |
| 262 | + | |
| 263 | + return $promotion; | |
| 241 | 264 | } |
| 242 | 265 | |
| 243 | 266 | /** |
| 244 | 267 | * @since 2.0.0 |
| @@ -302,12 +325,8 @@ | ||
| 302 | 325 | |
| 303 | 326 | return true; |
| 304 | 327 | } |
| 305 | 328 | |
| 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 | 329 | /** |
| 311 | 330 | * @since 2.0.0 |
| 312 | 331 | * @access public |
| 313 | 332 | */ |
| @@ -313,11 +332,13 @@ | ||
| 313 | 332 | */ |
| 314 | 333 | public function __construct() { |
| 315 | 334 | parent::__construct(); |
| 316 | 335 | |
| 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 | - } ); | |
| 336 | + if ( ! Plugin::$instance->experiments->is_feature_active( 'admin_menu_rearrangement' ) ) { | |
| 337 | + add_action( 'elementor/admin/menu/register', function ( Admin_Menu_Manager $admin_menu ) { | |
| 338 | + $this->register_admin_menu( $admin_menu ); | |
| 339 | + }, Settings::ADMIN_MENU_PRIORITY + 10 ); | |
| 340 | + } | |
| 320 | 341 | |
| 321 | 342 | add_action( 'elementor/role/restrictions/controls', [ $this, 'add_json_enable_control' ] ); |
| 322 | 343 | add_action( 'elementor/role/restrictions/controls', [ $this, 'add_custom_html_enable_control' ] ); |
| 323 | 344 | add_action( 'elementor/role/restrictions/controls', [ $this, 'get_go_pro_link_html' ] ); |