$npx -y skills add Lonsdale201/wp-agent-skills --skill elementor-deprecationsAudit Elementor addon code for deprecated Elementor APIs,
| 1 | # Elementor: deprecations (audit & deprecate correctly) |
| 2 | |
| 3 | 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. |
| 4 | |
| 5 | ## The Deprecation class (since 3.1.0) |
| 6 | |
| 7 | Lives at [modules/dev-tools/deprecation.php](deprecation.php), reached via the dev-tools module: |
| 8 | |
| 9 | ```php |
| 10 | $deprecation = \Elementor\Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation; |
| 11 | ``` |
| 12 | |
| 13 | Six methods, each recording **(name, version, replacement)** ([deprecation.php:236,257,278,321,346](deprecation.php)): |
| 14 | |
| 15 | | Method | Deprecates | Signature (key args) | |
| 16 | |---|---|---| |
| 17 | | `deprecated_function` | functions / methods | `($function_name, $version, $replacement = '', $base_version = null)` | |
| 18 | | `deprecated_hook` | a hook (generic) | `($hook, $version, $replacement = '', $base_version = null)` | |
| 19 | | `deprecated_argument` | an argument | `($argument, $version, $replacement = '', $message = '')` | |
| 20 | | `do_deprecated_action` | an action hook (still fires it) | `($hook, $args, $version, $replacement = '', $base_version = null)` | |
| 21 | | `apply_deprecated_filter` | a filter hook (still applies it) | `($hook, $args, $version, $replacement = '', $base_version = null)` | |
| 22 | |
| 23 | (The official docs list four methods; source also has `deprecated_hook`.) |
| 24 | |
| 25 | ## Debugging: WP_DEBUG is NOT enough — the gotcha |
| 26 | |
| 27 | 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](deprecation.php)) only emits the **PHP** `_deprecated_*` log call when **all three** hold: |
| 28 | |
| 29 | 1. `WP_DEBUG` is true, **and** |
| 30 | 2. the deprecation is within `SOFT_VERSIONS_COUNT` (**4**) Elementor majors of the current version (`$diff <= 4`), **and** |
| 31 | 3. `ELEMENTOR_DEBUG` is true (`Utils::is_elementor_debug()`). |
| 32 | |
| 33 | ```php |
| 34 | // deprecation.php:206-220 (paraphrased) |
| 35 | if ( defined( 'WP_DEBUG' ) && WP_DEBUG && $diff <= self::SOFT_VERSIONS_COUNT ) { |
| 36 | $this->soft_deprecated_notices[ $entity ] = [ $version, $replacement ]; // editor console |
| 37 | if ( Utils::is_elementor_debug() ) { |
| 38 | $print_deprecated = true; // → _deprecated_function() / _deprecated_hook() fires |
| 39 | } |
| 40 | } |
| 41 | ``` |
| 42 | |
| 43 | Consequences for an addon dev: |
| 44 | |
| 45 | - **Set `define( 'ELEMENTOR_DEBUG', true );` (plus `WP_DEBUG`)** in `wp-config.php` — otherwise you usually won't see Elementor's deprecation notices in the PHP log, only WP-core ones. |
| 46 | - The browser-console "soft" notices (in the editor) appear with just `WP_DEBUG` + within 4 majors; `HARD_VERSIONS_COUNT` (**8**) is used editor-side to escalate severity ([deprecation.php:11-12,21-26](deprecation.php)). |
| 47 | - **Past the 4-major window the wrapper goes silent** (no PHP notice, no recorded console notice). Don't rely on Elementor warning you forever — migrate while it's still in-window, and audit statically (below). |
| 48 | |
| 49 | ## Audit workflow — find deprecated Elementor APIs in addon code |
| 50 | |
| 51 | 1. **Regenerate the deprecation list for the installed version** (it changes per release) — see `reference.md` for the full recipe. Quick form: |
| 52 | ```bash |
| 53 | grep -rn -A4 -E "deprecated_function|deprecated_hook|deprecated_argument|do_deprecated_action|apply_deprecated_filter" \ |
| 54 | wp-content/plugins/elementor wp-content/plugins/elementor-pro --include=*.php |
| 55 | ``` |
| 56 | 2. **Scan the addon** for the deprecated names: |
| 57 | - Methods you define that match a depr |