Skip to content

Fix duplicate Elementor promotion control registration #550

Description

@code-snippets-bot

Problem

Code Snippets 3.10.2 can register the same Elementor promotion control twice while loading the Elementor editor. Elementor then reports:

Function Elementor\Controls_Manager::add_control_to_stack was called incorrectly. Cannot redeclare control with same name "code_snippets_promotion_notice_elementor_pro".

The notice occurs with Code Snippets active even when all individual snippets are disabled, and disappears when Code Snippets is deactivated.

Root cause

Plugin::load_plugin() instantiates Promotion_Manager twice on admin requests:

if ( is_admin() ) {
    $this->admin = new Bootstrap_Admin();
    new Promotion_Manager();
}

// ...

if ( is_admin() ) {
    new Promotion_Manager();
}

Each Promotion_Manager creates an Elementor_Editor, which registers another elementor/init callback. Both instances then attach callbacks that add the same code_snippets_promotion_notice_elementor_pro control.

The duplicate initialization is present in the 3.10.2 release and remains present on core and core-beta.

Expected behavior

  • Promotion_Manager is initialized once per request.
  • The Elementor Core and Elementor Pro promotion controls are each registered once.
  • Opening the Elementor editor does not produce a duplicate-control notice.

Acceptance criteria

  • Remove the duplicate Promotion_Manager initialization.
  • Verify Elementor and Elementor Pro editor loading with Code Snippets active.
  • Add regression coverage that prevents the promotion integration from being initialized twice.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions