Elementor deprecations

From Lonsdale201/wp-agent-skills · View interactive version

Elementor deprecations is an AI agent skill from the GitHub repository Lonsdale201/wp-agent-skills. Audit Elementor addon code for deprecated Elementor APIs, and deprecate your own code correctly. Elementor 3.1+ centralizes this in the Deprecation class (modules/dev-tools/deprecation.php) — deprecated_function, deprecated_hook, deprecated_argument, do_deprecated_action, apply_deprecated_filter — a

How to use this skill

Skill file

Elementor: deprecations (audit & deprecate correctly)

For developers maintaining an Elementor addon — recognise when your code calls a deprecated Elementor API (so you can migrate before it's removed), and deprecate your own APIs the way Elementor does. This is a static reference + audit skill, not a runtime watcher (use a hook + logging for that). The key strength: Elementor's deprecation data is source-extractable, so every claim here can be regenerated against the exact version installed — see reference.md for the recipe and the snapshot.

The Deprecation class (since 3.1.0)

Lives at modules/dev-tools/deprecation.php, reached via the dev-tools module:

$deprecation = \Elementor\Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation;

Six methods, each recording (name, version, replacement) (deprecation.php:236,257,278,321,346):

| Method | Deprecates | Signature (key args) |

|---|---|---|

| deprecated_function | functions / methods | ($function_name, $version, $replacement = '', $base_version = null) |

| deprecated_hook | a hook (generic) | ($hook, $version, $replacement = '', $base_version = null) |

| deprecated_argument | an argument | ($argument, $version, $replacement = '', $message = '') |

| do_deprecated_action | an action hook (still fires it) | ($hook, $args, $version, $replacement = '', $base_version = null) |

| apply_deprecated_filter | a filter hook (still applies it) | ($hook, $args, $version, $replacement = '', $base_version = null) |

(The official docs list four methods; source also has deprecated_hook.)

Debugging: WP_DEBUG is NOT enough — the gotcha

The docs say "soft deprecated code logs PHP notices, hard logs errors when WP_DEBUG is on." Source is more conservative. check_deprecation() (deprecation.php:193-221) only emits the PHP _deprecated_* log call when all three hold:

  1. WP_DEBUG is true, and
  2. the deprecation is within SOFT_VERSIONS_COUNT (4) Elementor majors of the current version ($diff <= 4), and
  3. ELEMENTOR_DEBUG is true (Utils::is_elementor_debug()).
// deprecation.php:206-220 (paraphrased)
if ( defined( 'WP_DEBUG' ) && WP_DEBUG && $diff <= self::SOFT_VERSIONS_COUNT ) {
    $this->soft_deprecated_notices[ $entity ] = [ $version, $replacement ]; // editor console
    if ( Utils::is_elementor_debug() ) {
        $print_deprecated = true; // → _deprecated_function() / _deprecated_hook() fires
    }
}

Consequences for an addon dev:

Audit workflow — find deprecated Elementor APIs in addon code

  1. Regenerate the deprecation list for the installed version (it changes per release) — see reference.md for the full recipe. Quick form:

```bash

grep -rn -A4 -E "deprecated_function|deprecated_hook|deprecated_argument|do_deprecated_action|apply_deprecated_filter" \

wp-content/plugins/elementor wp-content/plugins/elementor-pro --include=*.php

```

  1. Scan the addon for the deprecated names:
  1. Report each finding as file:line — <deprecated> (since <version>) → use <replacement>.
  2. Migrate to the replacement; keep get_name() / public identifiers stable.

The high-frequency ones for addon devs (verified, snapshot)

Widget/Element method renames — define the no-underscore form:

| Deprecated method | Since | Replacement |

|---|---|---|

| _register_controls() | 3.1.0 | register_controls() |

| _register_skins() | 3.1.0 | register_skins() |

| _print_content() | 3.1.0 | print_content() |

| _add_render_attributes() | 3.1.0 | add_render_attributes() |

| _content_template() | 2.9.0 | content_template() |

| _get_initial_config() | 2.9.0 | get_initial_config() |

| _init() | 2.9.0 | init() |

Registration hook renames (3.5.0) — hook the new action:

| Deprecated hook | Since | Replacement |

|---|---|---|

| elementor/widgets/widgets_registered | 3.5.0 | elementor/widgets/register |

| elementor/dynamic_tags/register_tags | 3.5.0 | elementor/dynamic_tags/register |

| elementor/finder/categories/init | 3.5.0 | elementor/finder/register |

| elementor/controls/controls_registered | 3.5.0 | elementor/controls/register |

Plus the manager methods register_tag($class)/unregister_tag($name) → register(instance)/unregister($name) (3.5.0), and the breakpoints filter elementor/core/responsive/get_stylesheet_templates → elementor/core/breakpoints/get_stylesheet_template (3.2.0). Full snapshot in reference.md.

Deprecating your OWN code (mirror Elementor)

When you rename/retire an API in your addon, route it through the same class so your consumers get consistent notices:

// A function/method you renamed:
\Elementor\Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation
    ->deprecated_function( __METHOD__, '2.5.0', __CLASS__ . '::new_method()' );

// An action hook you renamed — still fire it for back-compat:
$deprecation = \Elementor\Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation;
$deprecation->do_deprecated_action( 'myplugin/old_hook', [ $arg ], '2.5.0', 'myplugin/new_hook' );
do_action( 'myplugin/new_hook', $arg );

// A filter you renamed:
$value = $deprecation->apply_deprecated_filter( 'myplugin/old_filter', [ $value ], '2.5.0', 'myplugin/new_filter' );
$value = apply_filters( 'myplugin/new_filter', $value );

Version-guard the access so a missing dev-tools module never fatals:

$modules = \Elementor\Plugin::$instance->modules_manager;
$dev = $modules ? $modules->get_modules( 'dev-tools' ) : null;
if ( $dev && isset( $dev->deprecation ) ) {
    $dev->deprecation->deprecated_function( __METHOD__, '2.5.0', __CLASS__ . '::new_method()' );
}

Critical rules

Common mistakes

// WRONG — new widget still using the deprecated method name
class My_Widget extends \Elementor\Widget_Base {
    protected function _register_controls() { /* ... */ }   // deprecated 3.1.0 → logs notice
}
// RIGHT
class My_Widget extends \Elementor\Widget_Base {
    protected function register_controls() { /* ... */ }
}

// WRONG — hooking the deprecated registration action
add_action( 'elementor/widgets/widgets_registered', 'myplugin_register_widgets' );  // 3.5.0
// RIGHT
add_action( 'elementor/widgets/register', 'myplugin_register_widgets' );

// WRONG — "I enabled WP_DEBUG but see no Elementor deprecation notices, so my code is clean"
// Elementor's _deprecated_* needs ELEMENTOR_DEBUG too, and only within 4 majors. Absence ≠ clean.
// RIGHT — define( 'ELEMENTOR_DEBUG', true ); AND audit statically with the grep recipe.

Cross-references

What this skill does NOT cover

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.