| @@ -1,9 +1,7 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | namespace Elementor; |
| 3 | 3 | |
| 4 | -use Elementor\Includes\Elements\Container; | |
| 5 | - | |
| 6 | 4 | if ( ! defined( 'ABSPATH' ) ) { |
| 7 | 5 | exit; // Exit if accessed directly. |
| 8 | 6 | } |
| 9 | 7 | |
| @@ -16,15 +14,8 @@ | ||
| 16 | 14 | * @since 1.0.0 |
| 17 | 15 | */ |
| 18 | 16 | class Elements_Manager { |
| 19 | 17 | |
| 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 | - | |
| 27 | 18 | /** |
| 28 | 19 | * Element types. |
| 29 | 20 | * |
| 30 | 21 | * Holds the list of all the element types. |
| @@ -41,9 +32,9 @@ | ||
| 41 | 32 | * Holds the list of all the element categories. |
| 42 | 33 | * |
| 43 | 34 | * @access private |
| 44 | 35 | * |
| 45 | - * @var $categories | |
| 36 | + * @var | |
| 46 | 37 | */ |
| 47 | 38 | private $categories; |
| 48 | 39 | |
| 49 | 40 | /** |
| @@ -73,11 +64,15 @@ | ||
| 73 | 64 | * |
| 74 | 65 | * @return Element_Base|null Element instance if element created, or null |
| 75 | 66 | * otherwise. |
| 76 | 67 | */ |
| 77 | - public function create_element_instance( array $element_data, array $element_args = [], ?Element_Base $element_type = null ) { | |
| 68 | + public function create_element_instance( array $element_data, array $element_args = [], Element_Base $element_type = null ) { | |
| 78 | 69 | if ( null === $element_type ) { |
| 79 | - $element_type = $this->get_element( $element_data['elType'], isset( $element_data['widgetType'] ) ? $element_data['widgetType'] : null ); | |
| 70 | + if ( 'widget' === $element_data['elType'] ) { | |
| 71 | + $element_type = Plugin::$instance->widgets_manager->get_widget_types( $element_data['widgetType'] ); | |
| 72 | + } else { | |
| 73 | + $element_type = $this->get_element_types( $element_data['elType'] ); | |
| 74 | + } | |
| 80 | 75 | } |
| 81 | 76 | |
| 82 | 77 | if ( ! $element_type ) { |
| 83 | 78 | return null; |
| @@ -95,20 +90,8 @@ | ||
| 95 | 90 | |
| 96 | 91 | return $element; |
| 97 | 92 | } |
| 98 | 93 | |
| 99 | - public function get_element( string $el_type, ?string $widget_type = null ) { | |
| 100 | - $element = null; | |
| 101 | - | |
| 102 | - if ( 'widget' === $el_type ) { | |
| 103 | - $element = Plugin::$instance->widgets_manager->get_widget_types( $widget_type ); | |
| 104 | - } else { | |
| 105 | - $element = $this->get_element_types( $el_type ); | |
| 106 | - } | |
| 107 | - | |
| 108 | - return $element; | |
| 109 | - } | |
| 110 | - | |
| 111 | 94 | /** |
| 112 | 95 | * Get element categories. |
| 113 | 96 | * |
| 114 | 97 | * Retrieve the list of categories the element belongs to. |
| @@ -264,14 +247,8 @@ | ||
| 264 | 247 | |
| 265 | 248 | $this->register_element_type( new $class_name() ); |
| 266 | 249 | } |
| 267 | 250 | |
| 268 | - $experiments_manager = Plugin::$instance->experiments; | |
| 269 | - | |
| 270 | - if ( $experiments_manager->is_feature_active( 'container' ) ) { | |
| 271 | - $this->register_element_type( new Container() ); | |
| 272 | - } | |
| 273 | - | |
| 274 | 251 | /** |
| 275 | 252 | * After elements registered. |
| 276 | 253 | * |
| 277 | 254 | * Fires after Elementor elements are registered. |
| @@ -277,9 +254,9 @@ | ||
| 277 | 254 | * Fires after Elementor elements are registered. |
| 278 | 255 | * |
| 279 | 256 | * @since 1.0.0 |
| 280 | 257 | */ |
| 281 | - do_action( 'elementor/elements/elements_registered', $this ); | |
| 258 | + do_action( 'elementor/elements/elements_registered' ); | |
| 282 | 259 | } |
| 283 | 260 | |
| 284 | 261 | /** |
| 285 | 262 | * Init categories. |
| @@ -290,16 +267,8 @@ | ||
| 290 | 267 | * @access private |
| 291 | 268 | */ |
| 292 | 269 | private function init_categories() { |
| 293 | 270 | $this->categories = [ |
| 294 | - self::CATEGORY_ATOMIC_ELEMENTS => [ | |
| 295 | - 'title' => esc_html__( 'Atomic Elements', 'elementor' ), | |
| 296 | - 'hideIfEmpty' => true, | |
| 297 | - ], | |
| 298 | - 'layout' => [ | |
| 299 | - 'title' => esc_html__( 'Layout', 'elementor' ), | |
| 300 | - 'hideIfEmpty' => true, | |
| 301 | - ], | |
| 302 | 271 | 'basic' => [ |
| 303 | 272 | 'title' => esc_html__( 'Basic', 'elementor' ), |
| 304 | 273 | 'icon' => 'eicon-font', |
| 305 | 274 | ], |
| @@ -304,73 +273,23 @@ | ||
| 304 | 273 | 'icon' => 'eicon-font', |
| 305 | 274 | ], |
| 306 | 275 | 'pro-elements' => [ |
| 307 | 276 | 'title' => esc_html__( 'Pro', 'elementor' ), |
| 308 | - 'promotion' => [ | |
| 309 | - 'url' => esc_url( 'https://go.elementor.com/go-pro-section-pro-widget-panel/' ), | |
| 310 | - ], | |
| 311 | 277 | ], |
| 312 | - 'helloplus' => [ | |
| 313 | - 'title' => esc_html__( 'Hello+', 'elementor' ), | |
| 314 | - 'hideIfEmpty' => true, | |
| 315 | - ], | |
| 316 | 278 | 'general' => [ |
| 317 | 279 | 'title' => esc_html__( 'General', 'elementor' ), |
| 318 | 280 | 'icon' => 'eicon-font', |
| 319 | 281 | ], |
| 320 | - 'link-in-bio' => [ | |
| 321 | - 'title' => esc_html__( 'Link In Bio', 'elementor' ), | |
| 322 | - 'hideIfEmpty' => true, | |
| 323 | - ], | |
| 324 | 282 | 'theme-elements' => [ |
| 325 | 283 | 'title' => esc_html__( 'Site', 'elementor' ), |
| 326 | 284 | 'active' => false, |
| 327 | - 'promotion' => [ | |
| 328 | - 'url' => esc_url( 'https://go.elementor.com/go-pro-section-site-widget-panel/' ), | |
| 329 | - ], | |
| 330 | 285 | ], |
| 331 | 286 | 'woocommerce-elements' => [ |
| 332 | 287 | 'title' => esc_html__( 'WooCommerce', 'elementor' ), |
| 333 | 288 | 'active' => false, |
| 334 | - 'promotion' => [ | |
| 335 | - 'url' => esc_url( 'https://go.elementor.com/go-pro-section-woocommerce-widget-panel/' ), | |
| 336 | - ], | |
| 337 | 289 | ], |
| 338 | 290 | ]; |
| 339 | 291 | |
| 340 | - if ( Plugin::$instance->experiments->is_feature_active( 'e_atomic_elements' ) ) { | |
| 341 | - $atomic_form_category = [ | |
| 342 | - 'title' => esc_html__( 'Atomic Form', 'elementor' ), | |
| 343 | - ]; | |
| 344 | - | |
| 345 | - if ( Utils::has_pro() && Plugin::$instance->experiments->is_feature_active( 'e_pro_atomic_form' ) ) { | |
| 346 | - $atomic_form_category['hideIfEmpty'] = true; | |
| 347 | - } elseif ( ! Utils::has_pro() ) { | |
| 348 | - $atomic_form_category['hideIfEmpty'] = false; | |
| 349 | - $atomic_form_category['promotion'] = [ | |
| 350 | - 'url' => esc_url( 'https://go.elementor.com/go-pro-atomic-form-section/' ), | |
| 351 | - ]; | |
| 352 | - } else { | |
| 353 | - $atomic_form_category['hideIfEmpty'] = true; | |
| 354 | - } | |
| 355 | - | |
| 356 | - $this->categories = array_merge( | |
| 357 | - [ self::CATEGORY_ATOMIC_ELEMENTS => $this->categories[ self::CATEGORY_ATOMIC_ELEMENTS ] ], | |
| 358 | - [ self::CATEGORY_ATOMIC_FORM => $atomic_form_category ], | |
| 359 | - array_diff_key( $this->categories, [ self::CATEGORY_ATOMIC_ELEMENTS => true ] ) | |
| 360 | - ); | |
| 361 | - } | |
| 362 | - | |
| 363 | - // Not using the `add_category` because it doesn't allow 3rd party to inject a category on top the others. | |
| 364 | - $this->categories = array_merge_recursive( [ | |
| 365 | - self::CATEGORY_FAVORITES => [ | |
| 366 | - 'title' => esc_html__( 'Favorites', 'elementor' ), | |
| 367 | - 'icon' => 'eicon-heart', | |
| 368 | - 'sort' => 'a-z', | |
| 369 | - 'hideIfEmpty' => false, | |
| 370 | - ], | |
| 371 | - ], $this->categories ); | |
| 372 | - | |
| 373 | 292 | /** |
| 374 | 293 | * When categories are registered. |
| 375 | 294 | * |
| 376 | 295 | * Fires after basic categories are registered, before WordPress |
| @@ -384,67 +303,18 @@ | ||
| 384 | 303 | * @param Elements_Manager $this Elements manager instance. |
| 385 | 304 | */ |
| 386 | 305 | do_action( 'elementor/elements/categories_registered', $this ); |
| 387 | 306 | |
| 388 | - $after_candidates = Plugin::$instance->experiments->is_feature_active( 'e_atomic_elements' ) | |
| 389 | - ? [ self::CATEGORY_ATOMIC_FORM, self::CATEGORY_ATOMIC_ELEMENTS ] | |
| 390 | - : [ self::CATEGORY_BASIC ]; | |
| 307 | + $this->categories['pojo'] = [ | |
| 308 | + 'title' => esc_html__( 'Pojo Themes', 'elementor' ), | |
| 309 | + 'icon' => 'eicon-pojome', | |
| 310 | + ]; | |
| 391 | 311 | |
| 392 | - $this->promote_category_after( self::CATEGORY_ANGIE_WIDGETS, $after_candidates ); | |
| 393 | - $this->promote_category_after( self::CATEGORY_CUSTOM_WIDGETS, $after_candidates ); | |
| 394 | - | |
| 395 | 312 | $this->categories['wordpress'] = [ |
| 396 | 313 | 'title' => esc_html__( 'WordPress', 'elementor' ), |
| 397 | 314 | 'icon' => 'eicon-wordpress', |
| 398 | 315 | 'active' => false, |
| 399 | 316 | ]; |
| 400 | - } | |
| 401 | - | |
| 402 | - public function enqueue_elements_styles() { | |
| 403 | - foreach ( $this->get_element_types() as $element ) { | |
| 404 | - $element->enqueue_styles(); | |
| 405 | - } | |
| 406 | - } | |
| 407 | - | |
| 408 | - public function enqueue_elements_scripts() { | |
| 409 | - foreach ( $this->get_element_types() as $element ) { | |
| 410 | - $element->enqueue_scripts(); | |
| 411 | - } | |
| 412 | - } | |
| 413 | - | |
| 414 | - public function register_frontend_handlers() { | |
| 415 | - foreach ( $this->get_element_types() as $element ) { | |
| 416 | - $element->register_frontend_handlers(); | |
| 417 | - } | |
| 418 | - } | |
| 419 | - | |
| 420 | - private function promote_category_after( string $category_name, array $after_candidates ): void { | |
| 421 | - if ( ! isset( $this->categories[ $category_name ] ) ) { | |
| 422 | - return; | |
| 423 | - } | |
| 424 | - | |
| 425 | - $after = null; | |
| 426 | - | |
| 427 | - foreach ( $after_candidates as $candidate ) { | |
| 428 | - if ( isset( $this->categories[ $candidate ] ) ) { | |
| 429 | - $after = $candidate; | |
| 430 | - break; | |
| 431 | - } | |
| 432 | - } | |
| 433 | - | |
| 434 | - if ( ! $after ) { | |
| 435 | - return; | |
| 436 | - } | |
| 437 | - | |
| 438 | - $category = $this->categories[ $category_name ]; | |
| 439 | - unset( $this->categories[ $category_name ] ); | |
| 440 | - | |
| 441 | - $position = array_search( $after, array_keys( $this->categories ), true ) + 1; | |
| 442 | - $this->categories = array_merge( | |
| 443 | - array_slice( $this->categories, 0, $position, true ), | |
| 444 | - [ $category_name => $category ], | |
| 445 | - array_slice( $this->categories, $position, null, true ) | |
| 446 | - ); | |
| 447 | 317 | } |
| 448 | 318 | |
| 449 | 319 | /** |
| 450 | 320 | * Require files. |