| @@ -1,9 +1,7 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | namespace Elementor; |
| 3 | 3 | |
| 4 | -use Elementor\Plugin; | |
| 5 | - | |
| 6 | 4 | if ( ! defined( 'ABSPATH' ) ) { |
| 7 | 5 | exit; // Exit if accessed directly. |
| 8 | 6 | } |
| 9 | 7 | |
| @@ -71,25 +69,8 @@ | ||
| 71 | 69 | return admin_url( 'admin.php?page=' . static::PAGE_ID ); |
| 72 | 70 | } |
| 73 | 71 | |
| 74 | 72 | /** |
| 75 | - * Get settings tab URL. | |
| 76 | - * | |
| 77 | - * Retrieve the URL of a specific tab in the settings page. | |
| 78 | - * | |
| 79 | - * @since 3.23.0 | |
| 80 | - * @access public | |
| 81 | - * @static | |
| 82 | - * | |
| 83 | - * @param string $tab_id The ID of the settings tab. | |
| 84 | - * | |
| 85 | - * @return string Settings tab URL. | |
| 86 | - */ | |
| 87 | - final public static function get_settings_tab_url( $tab_id ): string { | |
| 88 | - return admin_url( "admin.php?page=elementor-settings#tab-$tab_id" ); | |
| 89 | - } | |
| 90 | - | |
| 91 | - /** | |
| 92 | 73 | * Settings page constructor. |
| 93 | 74 | * |
| 94 | 75 | * Initializing Elementor settings page. |
| 95 | 76 | * |
| @@ -96,10 +77,9 @@ | ||
| 96 | 77 | * @since 1.5.0 |
| 97 | 78 | * @access public |
| 98 | 79 | */ |
| 99 | 80 | public function __construct() { |
| 100 | - // PHPCS - The user data is not used. | |
| 101 | - if ( ! empty( $_POST['option_page'] ) && static::PAGE_ID === $_POST['option_page'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 81 | + if ( ! empty( $_POST['option_page'] ) && static::PAGE_ID === $_POST['option_page'] ) { | |
| 102 | 82 | add_action( 'admin_init', [ $this, 'register_settings_fields' ] ); |
| 103 | 83 | } |
| 104 | 84 | } |
| 105 | 85 | |
| @@ -272,16 +252,12 @@ | ||
| 272 | 252 | } |
| 273 | 253 | |
| 274 | 254 | $field['field_args']['class'] = implode( ' ', $field_classes ); |
| 275 | 255 | |
| 276 | - if ( ! isset( $field['render'] ) ) { | |
| 277 | - $field['render'] = [ $controls_class_name, 'render' ]; | |
| 278 | - } | |
| 279 | - | |
| 280 | 256 | add_settings_field( |
| 281 | 257 | $full_field_id, |
| 282 | 258 | isset( $field['label'] ) ? $field['label'] : '', |
| 283 | - $field['render'], | |
| 259 | + [ $controls_class_name, 'render' ], | |
| 284 | 260 | static::PAGE_ID, |
| 285 | 261 | $full_section_id, |
| 286 | 262 | $field['field_args'] |
| 287 | 263 | ); |
| @@ -311,13 +287,13 @@ | ||
| 311 | 287 | |
| 312 | 288 | $tabs = $this->get_tabs(); |
| 313 | 289 | ?> |
| 314 | 290 | <div class="wrap"> |
| 315 | - <h1 class="wp-heading-inline"><?php echo esc_html( $this->get_page_title() ); ?></h1> | |
| 291 | + <h1><?php echo $this->get_page_title(); ?></h1> | |
| 316 | 292 | <div id="elementor-settings-tabs-wrapper" class="nav-tab-wrapper"> |
| 317 | 293 | <?php |
| 318 | 294 | foreach ( $tabs as $tab_id => $tab ) { |
| 319 | - if ( ! $this->should_render_tab( $tab ) ) { | |
| 295 | + if ( empty( $tab['sections'] ) ) { | |
| 320 | 296 | continue; |
| 321 | 297 | } |
| 322 | 298 | |
| 323 | 299 | $active_class = ''; |
| @@ -325,13 +301,9 @@ | ||
| 325 | 301 | if ( 'general' === $tab_id ) { |
| 326 | 302 | $active_class = ' nav-tab-active'; |
| 327 | 303 | } |
| 328 | 304 | |
| 329 | - $sanitized_tab_id = esc_attr( $tab_id ); | |
| 330 | - $sanitized_tab_label = esc_html( $tab['label'] ); | |
| 331 | - | |
| 332 | - // PHPCS - Escaped the relevant strings above. | |
| 333 | - echo "<a id='elementor-settings-tab-{$sanitized_tab_id}' class='nav-tab{$active_class}' href='#tab-{$sanitized_tab_id}'>{$sanitized_tab_label}</a>"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 305 | + echo "<a id='elementor-settings-tab-{$tab_id}' class='nav-tab{$active_class}' href='#tab-{$tab_id}'>{$tab['label']}</a>"; | |
| 334 | 306 | } |
| 335 | 307 | ?> |
| 336 | 308 | </div> |
| 337 | 309 | <form id="elementor-settings-form" method="post" action="options.php"> |
| @@ -338,9 +310,9 @@ | ||
| 338 | 310 | <?php |
| 339 | 311 | settings_fields( static::PAGE_ID ); |
| 340 | 312 | |
| 341 | 313 | foreach ( $tabs as $tab_id => $tab ) { |
| 342 | - if ( ! $this->should_render_tab( $tab ) ) { | |
| 314 | + if ( empty( $tab['sections'] ) ) { | |
| 343 | 315 | continue; |
| 344 | 316 | } |
| 345 | 317 | |
| 346 | 318 | $active_class = ''; |
| @@ -348,22 +320,15 @@ | ||
| 348 | 320 | if ( 'general' === $tab_id ) { |
| 349 | 321 | $active_class = ' elementor-active'; |
| 350 | 322 | } |
| 351 | 323 | |
| 352 | - $sanitized_tab_id = esc_attr( $tab_id ); | |
| 324 | + echo "<div id='tab-{$tab_id}' class='elementor-settings-form-page{$active_class}'>"; | |
| 353 | 325 | |
| 354 | - // PHPCS - $active_class is a non-dynamic string and $sanitized_tab_id is escaped above. | |
| 355 | - echo "<div id='tab-{$sanitized_tab_id}' class='elementor-settings-form-page{$active_class}'>"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 356 | - | |
| 357 | 326 | foreach ( $tab['sections'] as $section_id => $section ) { |
| 358 | - if ( ! $this->should_render_section( $section ) ) { | |
| 359 | - continue; | |
| 360 | - } | |
| 361 | - | |
| 362 | 327 | $full_section_id = 'elementor_' . $section_id . '_section'; |
| 363 | 328 | |
| 364 | 329 | if ( ! empty( $section['label'] ) ) { |
| 365 | - echo '<h2>' . esc_html( $section['label'] ) . '</h2>'; | |
| 330 | + echo "<h2>{$section['label']}</h2>"; | |
| 366 | 331 | } |
| 367 | 332 | |
| 368 | 333 | if ( ! empty( $section['callback'] ) ) { |
| 369 | 334 | $section['callback'](); |
| @@ -378,9 +343,9 @@ | ||
| 378 | 343 | |
| 379 | 344 | echo '</div>'; |
| 380 | 345 | } |
| 381 | 346 | |
| 382 | - submit_button( __( 'Save Changes', 'elementor' ), 'primary', 'submit', true, [ 'data-id' => 'elementor-settings-button-save-changes' ] ); | |
| 347 | + submit_button(); | |
| 383 | 348 | ?> |
| 384 | 349 | </form> |
| 385 | 350 | </div><!-- /.wrap --> |
| 386 | 351 | <?php |
| @@ -385,27 +350,8 @@ | ||
| 385 | 350 | </div><!-- /.wrap --> |
| 386 | 351 | <?php |
| 387 | 352 | } |
| 388 | 353 | |
| 389 | - public function get_usage_fields() { | |
| 390 | - return [ | |
| 391 | - 'allow_tracking' => [ | |
| 392 | - 'label' => esc_html__( 'Data Sharing', 'elementor' ), | |
| 393 | - 'field_args' => [ | |
| 394 | - 'type' => 'checkbox', | |
| 395 | - 'value' => 'yes', | |
| 396 | - 'default' => '', | |
| 397 | - 'sub_desc' => sprintf( | |
| 398 | - '%1$s <a href="https://go.elementor.com/usage-data-tracking/" target="_blank">%2$s</a>', | |
| 399 | - esc_html__( 'Become a super contributor by helping us understand how you use our service to enhance your experience and improve our product.', 'elementor' ), | |
| 400 | - esc_html__( 'Learn more', 'elementor' ) | |
| 401 | - ), | |
| 402 | - ], | |
| 403 | - 'setting_args' => [ __NAMESPACE__ . '\Tracker', 'check_for_settings_optin' ], | |
| 404 | - ], | |
| 405 | - ]; | |
| 406 | - } | |
| 407 | - | |
| 408 | 354 | /** |
| 409 | 355 | * Ensure tabs. |
| 410 | 356 | * |
| 411 | 357 | * Make sure the settings page has tabs before inserting any new sections or |
| @@ -432,32 +378,6 @@ | ||
| 432 | 378 | * @param Settings_Page $this The settings page. |
| 433 | 379 | */ |
| 434 | 380 | do_action( "elementor/admin/after_create_settings/{$page_id}", $this ); |
| 435 | 381 | } |
| 436 | - } | |
| 437 | - | |
| 438 | - /** | |
| 439 | - * Should it render the settings tab | |
| 440 | - * | |
| 441 | - * @param array $tab | |
| 442 | - * | |
| 443 | - * @return bool | |
| 444 | - */ | |
| 445 | - private function should_render_tab( $tab ) { | |
| 446 | - // BC - When 'show_if' prop is not exists, it actually should render the tab. | |
| 447 | - return ! empty( $tab['sections'] ) && ( ! isset( $tab['show_if'] ) || $tab['show_if'] ); | |
| 448 | - } | |
| 449 | - | |
| 450 | - /** | |
| 451 | - * Should it render the settings section | |
| 452 | - * | |
| 453 | - * @param array $section | |
| 454 | - * | |
| 455 | - * Since 3.19.0 | |
| 456 | - * | |
| 457 | - * @return bool | |
| 458 | - */ | |
| 459 | - private function should_render_section( $section ) { | |
| 460 | - // BC - When 'show_if' prop is not exists, it actually should render the section. | |
| 461 | - return ! isset( $section['show_if'] ) || $section['show_if']; | |
| 462 | 382 | } |
| 463 | 383 | } |