| @@ -1569,8 +1569,12 @@ | ||
| 1569 | 1569 | * @param array $args Section arguments. |
| 1570 | 1570 | */ |
| 1571 | 1571 | do_action( "elementor/element/{$stack_name}/{$section_id}/before_section_start", $this, $args ); |
| 1572 | 1572 | |
| 1573 | + if ( $this->should_manually_trigger_common_action( $stack_name ) ) { | |
| 1574 | + do_action( "elementor/element/common/{$section_id}/before_section_start", $this, $args ); | |
| 1575 | + } | |
| 1576 | + | |
| 1573 | 1577 | $args['type'] = Controls_Manager::SECTION; |
| 1574 | 1578 | |
| 1575 | 1579 | $this->add_control( $section_id, $args ); |
| 1576 | 1580 | |
| @@ -1609,8 +1613,12 @@ | ||
| 1609 | 1613 | * @param Controls_Stack $this The control. |
| 1610 | 1614 | * @param array $args Section arguments. |
| 1611 | 1615 | */ |
| 1612 | 1616 | do_action( "elementor/element/{$stack_name}/{$section_id}/after_section_start", $this, $args ); |
| 1617 | + | |
| 1618 | + if ( $this->should_manually_trigger_common_action( $stack_name ) ) { | |
| 1619 | + do_action( "elementor/element/common/{$section_id}/after_section_start", $this, $args ); | |
| 1620 | + } | |
| 1613 | 1621 | } |
| 1614 | 1622 | |
| 1615 | 1623 | /** |
| 1616 | 1624 | * End controls section. |
| @@ -1659,8 +1667,12 @@ | ||
| 1659 | 1667 | * @param array $args Section arguments. |
| 1660 | 1668 | */ |
| 1661 | 1669 | do_action( "elementor/element/{$stack_name}/{$section_id}/before_section_end", $this, $args ); |
| 1662 | 1670 | |
| 1671 | + if ( $this->should_manually_trigger_common_action( $stack_name ) ) { | |
| 1672 | + do_action( "elementor/element/common/{$section_id}/before_section_end", $this, $args ); | |
| 1673 | + } | |
| 1674 | + | |
| 1663 | 1675 | $this->current_section = null; |
| 1664 | 1676 | |
| 1665 | 1677 | /** |
| 1666 | 1678 | * After section end. |
| @@ -1687,8 +1699,37 @@ | ||
| 1687 | 1699 | * @param Controls_Stack $this The control. |
| 1688 | 1700 | * @param array $args Section arguments. |
| 1689 | 1701 | */ |
| 1690 | 1702 | do_action( "elementor/element/{$stack_name}/{$section_id}/after_section_end", $this, $args ); |
| 1703 | + | |
| 1704 | + if ( $this->should_manually_trigger_common_action( $stack_name ) ) { | |
| 1705 | + do_action( "elementor/element/common/{$section_id}/after_section_end", $this, $args ); | |
| 1706 | + } | |
| 1707 | + } | |
| 1708 | + | |
| 1709 | + /** | |
| 1710 | + * Should manually trigger common action. | |
| 1711 | + * | |
| 1712 | + * With the Optimized Markup experiment, the Advanced Tab has been split to maintain backward compatibility: | |
| 1713 | + * - 'common' refers to the existing Advanced Tab. | |
| 1714 | + * - 'common-optimized' refers to the new Advanced Tab for optimized widgets. | |
| 1715 | + * | |
| 1716 | + * Third-party developers may have used hooks like 'elementor/element/common/_section_background/before_section_end' | |
| 1717 | + * to add controls to the Advanced Tab. However, this hook will now only work on widgets that are not optimized. | |
| 1718 | + * | |
| 1719 | + * This method checks whether the 'elementor/element/common/...' hooks should be manually executed | |
| 1720 | + * to prevent third parties from needing to add equivalent hooks for 'elementor/element/common-optimized/...'. | |
| 1721 | + * | |
| 1722 | + * @todo Remove this method and the manual execution of 'common' hooks when the feature is merged. | |
| 1723 | + * | |
| 1724 | + * @access private | |
| 1725 | + * | |
| 1726 | + * @param string $stack_name Stack name. | |
| 1727 | + * | |
| 1728 | + * @return bool | |
| 1729 | + */ | |
| 1730 | + private function should_manually_trigger_common_action( $stack_name ): bool { | |
| 1731 | + return 'common-optimized' === $stack_name && Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' ); | |
| 1691 | 1732 | } |
| 1692 | 1733 | |
| 1693 | 1734 | /** |
| 1694 | 1735 | * Start controls tabs. |