| @@ -16,17 +16,8 @@ | ||
| 16 | 16 | * @since 1.0.0 |
| 17 | 17 | */ |
| 18 | 18 | class Elements_Manager { |
| 19 | 19 | |
| 20 | - const CATEGORY_ATOMIC_ELEMENTS = 'v4-elements'; | |
| 21 | - const CATEGORY_ATOMIC_FORM = 'atomic-form'; | |
| 22 | - const CATEGORY_FAVORITES = 'favorites'; | |
| 23 | - const CATEGORY_ANGIE_WIDGETS = 'angie-widgets'; | |
| 24 | - const CATEGORY_CUSTOM_WIDGETS = 'custom-widgets'; | |
| 25 | - const CATEGORY_BASIC = 'basic'; | |
| 26 | - const CATEGORY_PRO_ELEMENTS = 'pro-elements'; | |
| 27 | - const CATEGORY_WORDPRESS = 'wordpress'; | |
| 28 | - | |
| 29 | 20 | /** |
| 30 | 21 | * Element types. |
| 31 | 22 | * |
| 32 | 23 | * Holds the list of all the element types. |
| @@ -292,9 +283,9 @@ | ||
| 292 | 283 | * @access private |
| 293 | 284 | */ |
| 294 | 285 | private function init_categories() { |
| 295 | 286 | $this->categories = [ |
| 296 | - self::CATEGORY_ATOMIC_ELEMENTS => [ | |
| 287 | + 'v4-elements' => [ | |
| 297 | 288 | 'title' => esc_html__( 'Atomic Elements', 'elementor' ), |
| 298 | 289 | 'hideIfEmpty' => true, |
| 299 | 290 | ], |
| 300 | 291 | 'layout' => [ |
| @@ -304,9 +295,9 @@ | ||
| 304 | 295 | 'basic' => [ |
| 305 | 296 | 'title' => esc_html__( 'Basic', 'elementor' ), |
| 306 | 297 | 'icon' => 'eicon-font', |
| 307 | 298 | ], |
| 308 | - self::CATEGORY_PRO_ELEMENTS => [ | |
| 299 | + 'pro-elements' => [ | |
| 309 | 300 | 'title' => esc_html__( 'Pro', 'elementor' ), |
| 310 | 301 | 'promotion' => [ |
| 311 | 302 | 'url' => esc_url( 'https://go.elementor.com/go-pro-section-pro-widget-panel/' ), |
| 312 | 303 | ], |
| @@ -338,34 +329,11 @@ | ||
| 338 | 329 | ], |
| 339 | 330 | ], |
| 340 | 331 | ]; |
| 341 | 332 | |
| 342 | - if ( Plugin::$instance->experiments->is_feature_active( 'e_atomic_elements' ) ) { | |
| 343 | - $atomic_form_category = [ | |
| 344 | - 'title' => esc_html__( 'Atomic Form', 'elementor' ), | |
| 345 | - ]; | |
| 346 | - | |
| 347 | - if ( Utils::has_pro() && Plugin::$instance->experiments->is_feature_active( 'e_pro_atomic_form' ) ) { | |
| 348 | - $atomic_form_category['hideIfEmpty'] = true; | |
| 349 | - } elseif ( ! Utils::has_pro() ) { | |
| 350 | - $atomic_form_category['hideIfEmpty'] = false; | |
| 351 | - $atomic_form_category['promotion'] = [ | |
| 352 | - 'url' => esc_url( 'https://go.elementor.com/go-pro-atomic-form-section/' ), | |
| 353 | - ]; | |
| 354 | - } else { | |
| 355 | - $atomic_form_category['hideIfEmpty'] = true; | |
| 356 | - } | |
| 357 | - | |
| 358 | - $this->categories = array_merge( | |
| 359 | - [ self::CATEGORY_ATOMIC_ELEMENTS => $this->categories[ self::CATEGORY_ATOMIC_ELEMENTS ] ], | |
| 360 | - [ self::CATEGORY_ATOMIC_FORM => $atomic_form_category ], | |
| 361 | - array_diff_key( $this->categories, [ self::CATEGORY_ATOMIC_ELEMENTS => true ] ) | |
| 362 | - ); | |
| 363 | - } | |
| 364 | - | |
| 365 | 333 | // Not using the `add_category` because it doesn't allow 3rd party to inject a category on top the others. |
| 366 | 334 | $this->categories = array_merge_recursive( [ |
| 367 | - self::CATEGORY_FAVORITES => [ | |
| 335 | + 'favorites' => [ | |
| 368 | 336 | 'title' => esc_html__( 'Favorites', 'elementor' ), |
| 369 | 337 | 'icon' => 'eicon-heart', |
| 370 | 338 | 'sort' => 'a-z', |
| 371 | 339 | 'hideIfEmpty' => false, |
| @@ -386,24 +354,8 @@ | ||
| 386 | 354 | * @param Elements_Manager $this Elements manager instance. |
| 387 | 355 | */ |
| 388 | 356 | do_action( 'elementor/elements/categories_registered', $this ); |
| 389 | 357 | |
| 390 | - $after_candidates = Plugin::$instance->experiments->is_feature_active( 'e_atomic_elements' ) | |
| 391 | - ? [ self::CATEGORY_ATOMIC_FORM, self::CATEGORY_ATOMIC_ELEMENTS ] | |
| 392 | - : [ self::CATEGORY_BASIC ]; | |
| 393 | - | |
| 394 | - $this->promote_category_after( self::CATEGORY_ANGIE_WIDGETS, $after_candidates ); | |
| 395 | - $this->promote_category_after( self::CATEGORY_CUSTOM_WIDGETS, $after_candidates ); | |
| 396 | - | |
| 397 | - if ( ! Utils::has_pro() && Plugin::$instance->experiments->is_feature_active( 'e_atomic_elements' ) ) { | |
| 398 | - $this->promote_category_after( self::CATEGORY_PRO_ELEMENTS, [ | |
| 399 | - self::CATEGORY_CUSTOM_WIDGETS, | |
| 400 | - self::CATEGORY_ANGIE_WIDGETS, | |
| 401 | - self::CATEGORY_ATOMIC_FORM, | |
| 402 | - self::CATEGORY_ATOMIC_ELEMENTS, | |
| 403 | - ] ); | |
| 404 | - } | |
| 405 | - | |
| 406 | 358 | $this->categories['wordpress'] = [ |
| 407 | 359 | 'title' => esc_html__( 'WordPress', 'elementor' ), |
| 408 | 360 | 'icon' => 'eicon-wordpress', |
| 409 | 361 | 'active' => false, |
| @@ -425,37 +377,8 @@ | ||
| 425 | 377 | public function register_frontend_handlers() { |
| 426 | 378 | foreach ( $this->get_element_types() as $element ) { |
| 427 | 379 | $element->register_frontend_handlers(); |
| 428 | 380 | } |
| 429 | - } | |
| 430 | - | |
| 431 | - private function promote_category_after( string $category_name, array $after_candidates ): void { | |
| 432 | - if ( ! isset( $this->categories[ $category_name ] ) ) { | |
| 433 | - return; | |
| 434 | - } | |
| 435 | - | |
| 436 | - $after = null; | |
| 437 | - | |
| 438 | - foreach ( $after_candidates as $candidate ) { | |
| 439 | - if ( isset( $this->categories[ $candidate ] ) ) { | |
| 440 | - $after = $candidate; | |
| 441 | - break; | |
| 442 | - } | |
| 443 | - } | |
| 444 | - | |
| 445 | - if ( ! $after ) { | |
| 446 | - return; | |
| 447 | - } | |
| 448 | - | |
| 449 | - $category = $this->categories[ $category_name ]; | |
| 450 | - unset( $this->categories[ $category_name ] ); | |
| 451 | - | |
| 452 | - $position = array_search( $after, array_keys( $this->categories ), true ) + 1; | |
| 453 | - $this->categories = array_merge( | |
| 454 | - array_slice( $this->categories, 0, $position, true ), | |
| 455 | - [ $category_name => $category ], | |
| 456 | - array_slice( $this->categories, $position, null, true ) | |
| 457 | - ); | |
| 458 | 381 | } |
| 459 | 382 | |
| 460 | 383 | /** |
| 461 | 384 | * Require files. |