← All changes
|
php/Integration/Promotions/Other/Elementor_Editor.php
+18
-0
3.10.1
→
4.0.0-beta.3
View file →
| @@ -22,8 +22,12 @@ | ||
| 22 | 22 | /** |
| 23 | 23 | * Promotion on the Custom CSS section, inside the Elementor Editor. |
| 24 | 24 | */ |
| 25 | 25 | public function promotion_in_custom_css_section() { |
| 26 | + if ( ! $this->supports_notice_control() ) { | |
| 27 | + return; | |
| 28 | + } | |
| 29 | + | |
| 26 | 30 | // Elementor Core. |
| 27 | 31 | add_action( |
| 28 | 32 | 'elementor/element/common/section_custom_css/after_section_start', |
| 29 | 33 | function ( $element ) { |
| @@ -37,8 +41,22 @@ | ||
| 37 | 41 | function ( $element ) { |
| 38 | 42 | $this->add_promotion_control( $element, 'pro' ); |
| 39 | 43 | } |
| 40 | 44 | ); |
| 45 | + } | |
| 46 | + | |
| 47 | + /** | |
| 48 | + * Check whether this version of Elementor offers the notice control type. | |
| 49 | + * | |
| 50 | + * The type arrived in Elementor 3.19. On anything older the constant does | |
| 51 | + * not exist, and reading it while the editor builds its controls raises an | |
| 52 | + * Error that leaves the editor unusable, so the promotion is skipped | |
| 53 | + * rather than degraded. | |
| 54 | + * | |
| 55 | + * @return bool | |
| 56 | + */ | |
| 57 | + protected function supports_notice_control(): bool { | |
| 58 | + return defined( Controls_Manager::class . '::NOTICE' ); | |
| 41 | 59 | } |
| 42 | 60 | |
| 43 | 61 | /** |
| 44 | 62 | * Register promotion section in the Custom CSS section. |