From ff70a74f6d5fa8c0c88ce0007fae808589597087 Mon Sep 17 00:00:00 2001 From: Rami Yushuvaev Date: Tue, 25 Nov 2025 15:14:48 +0000 Subject: [PATCH 1/3] Add promotions --- src/php/class-plugin.php | 3 + src/php/promotions/elementor-pro.php | 153 +++++++++++++++++++++++++++ 2 files changed, 156 insertions(+) create mode 100644 src/php/promotions/elementor-pro.php diff --git a/src/php/class-plugin.php b/src/php/class-plugin.php index c05613e2..4e83f674 100644 --- a/src/php/class-plugin.php +++ b/src/php/class-plugin.php @@ -156,6 +156,9 @@ public function load_plugin() { $upgrade = new Upgrade( $this->version, $this->db ); add_action( 'plugins_loaded', array( $upgrade, 'run' ), 0 ); $this->licensing = new Licensing(); + + // Initialize promotions. + new Promotions\Elementor_Pro(); } /** diff --git a/src/php/promotions/elementor-pro.php b/src/php/promotions/elementor-pro.php new file mode 100644 index 00000000..043bf2d3 --- /dev/null +++ b/src/php/promotions/elementor-pro.php @@ -0,0 +1,153 @@ +is_custom_code_screen() ) { + return; + } + + ?> +
+

+ +

+

+ Code Snippets Pro' + ); + ?> +

+

+ + + + + + +

+
+ id, + [ + 'edit-elementor_snippet', + 'elementor_snippet', + ], + true + ); + } + + /** + * Promotion on the Custom CSS section, inside the Elementor Editor. + * + * @return void + */ + public function promotion_in_custom_css_section() { + add_action( 'elementor/element/common/section_custom_css/before_section_end', [ $this, 'add_promotion_to_custom_css_section' ], 10, 2 ); + } + + /** + * Register promotion section after the Custom CSS section. + * + * @param \Elementor\Widget_Base|\Elementor\Element_Base $element The Elementor element. + */ + public function add_promotion_to_custom_css_section( $element ) { + + $element->add_control( + 'code_snippets_promotion_alert', + [ + 'type' => \Elementor\Controls_Manager::ALERT, + 'alert_type' => 'warning', + 'content' => esc_html__( 'Set locations and angle for each breakpoint to ensure the gradient adapts to different screen sizes.', 'code-snippets' ), + 'render_type' => 'ui', + ] + ); + + $element->add_control( + 'code_snippets_promotion_notice', + [ + 'type' => \Elementor\Controls_Manager::NOTICE, + 'notice_type' => 'info', + 'dismissible' => true, + 'heading' => esc_html__( '💡 Looking for a better way to manage custom code?', 'code-snippets' ), + 'content' => sprintf( + /* translators: %s: Code Snippets plugin name */ + esc_html__( '%s provides a powerful and user-friendly alternative to Elementor Custom Code, with cloud sync, advanced features, and an intuitive interface.', 'code-snippets' ), + 'Code Snippets Pro' + ), + ] + ); + + $element->add_control( + 'code_snippets_promotion_raw_html', + [ + 'type' => \Elementor\Controls_Manager::RAW_HTML, + 'raw' => sprintf( + '
+

+ %s +

+

+ %s +

+ + %s + +
', + esc_html__( '💡 Looking for a better way to manage custom code?', 'code-snippets' ), + sprintf( + /* translators: %s: Code Snippets plugin name */ + esc_html__( '%s provides a powerful and user-friendly alternative to Elementor Custom Code, with cloud sync, advanced features, and an intuitive interface.', 'code-snippets' ), + 'Code Snippets Pro' + ), + esc_url( 'https://example.com/promo' ), // <-- Change to your promo URL. + esc_html__( 'Learn More', 'code-snippets' ) + ), + 'content_classes' => 'your-promo-class', + ] + ); + } +} From 3a756d7252cf30e368c58c36efacc7eb46494123 Mon Sep 17 00:00:00 2001 From: Rami Yushuvaev Date: Tue, 9 Dec 2025 13:41:46 +0000 Subject: [PATCH 2/3] Add promotions --- src/php/promotions/elementor-pro.php | 42 +--------------------------- 1 file changed, 1 insertion(+), 41 deletions(-) diff --git a/src/php/promotions/elementor-pro.php b/src/php/promotions/elementor-pro.php index 043bf2d3..22270066 100644 --- a/src/php/promotions/elementor-pro.php +++ b/src/php/promotions/elementor-pro.php @@ -95,24 +95,13 @@ public function promotion_in_custom_css_section() { * @param \Elementor\Widget_Base|\Elementor\Element_Base $element The Elementor element. */ public function add_promotion_to_custom_css_section( $element ) { - - $element->add_control( - 'code_snippets_promotion_alert', - [ - 'type' => \Elementor\Controls_Manager::ALERT, - 'alert_type' => 'warning', - 'content' => esc_html__( 'Set locations and angle for each breakpoint to ensure the gradient adapts to different screen sizes.', 'code-snippets' ), - 'render_type' => 'ui', - ] - ); - $element->add_control( 'code_snippets_promotion_notice', [ 'type' => \Elementor\Controls_Manager::NOTICE, 'notice_type' => 'info', 'dismissible' => true, - 'heading' => esc_html__( '💡 Looking for a better way to manage custom code?', 'code-snippets' ), + 'heading' => esc_html__( 'Manage your custom code', 'code-snippets' ), 'content' => sprintf( /* translators: %s: Code Snippets plugin name */ esc_html__( '%s provides a powerful and user-friendly alternative to Elementor Custom Code, with cloud sync, advanced features, and an intuitive interface.', 'code-snippets' ), @@ -120,34 +109,5 @@ public function add_promotion_to_custom_css_section( $element ) { ), ] ); - - $element->add_control( - 'code_snippets_promotion_raw_html', - [ - 'type' => \Elementor\Controls_Manager::RAW_HTML, - 'raw' => sprintf( - '
-

- %s -

-

- %s -

- - %s - -
', - esc_html__( '💡 Looking for a better way to manage custom code?', 'code-snippets' ), - sprintf( - /* translators: %s: Code Snippets plugin name */ - esc_html__( '%s provides a powerful and user-friendly alternative to Elementor Custom Code, with cloud sync, advanced features, and an intuitive interface.', 'code-snippets' ), - 'Code Snippets Pro' - ), - esc_url( 'https://example.com/promo' ), // <-- Change to your promo URL. - esc_html__( 'Learn More', 'code-snippets' ) - ), - 'content_classes' => 'your-promo-class', - ] - ); } } From 75d971696d33257ca276f8f50c70a80f641f4f77 Mon Sep 17 00:00:00 2001 From: Rami Yushuvaev Date: Tue, 9 Dec 2025 14:05:58 +0000 Subject: [PATCH 3/3] Update promotions --- src/php/promotions/elementor-pro.php | 57 ++++++++++++++++++---------- 1 file changed, 37 insertions(+), 20 deletions(-) diff --git a/src/php/promotions/elementor-pro.php b/src/php/promotions/elementor-pro.php index 22270066..8a01396b 100644 --- a/src/php/promotions/elementor-pro.php +++ b/src/php/promotions/elementor-pro.php @@ -27,27 +27,20 @@ public function promotion_in_custom_code_screen() { if ( ! $this->is_custom_code_screen() ) { return; } - ?> -
+

- +

- Code Snippets Pro' - ); - ?> +

- - + + - - + +

@@ -101,13 +94,37 @@ public function add_promotion_to_custom_css_section( $element ) { 'type' => \Elementor\Controls_Manager::NOTICE, 'notice_type' => 'info', 'dismissible' => true, - 'heading' => esc_html__( 'Manage your custom code', 'code-snippets' ), - 'content' => sprintf( - /* translators: %s: Code Snippets plugin name */ - esc_html__( '%s provides a powerful and user-friendly alternative to Elementor Custom Code, with cloud sync, advanced features, and an intuitive interface.', 'code-snippets' ), - 'Code Snippets Pro' - ), + 'heading' => esc_html__( 'Manage your custom styles', 'code-snippets' ), + 'content' => $this->get_promotion_content(), ] ); } + + /** + * Get the promotion content with appropriate link. + * + * @return string + */ + private function get_promotion_content(): string { + $message = esc_html__( 'Code Snippets Pro provides a powerful and user-friendly alternative to Elementor Custom Code, with cloud sync, conditional logic, and advanced features.', 'code-snippets' ); + + if ( $this->is_pro() ) { + $link_text = esc_html__( 'Manage CSS snippets', 'code-snippets' ); + $url = admin_url( 'admin.php?page=snippets&type=css' ); + } else { + $link_text = esc_html__( 'Learn More', 'code-snippets' ); + $url = 'https://codesnippets.pro/pricing/?utm_source=elementor&utm_medium=banner&utm_campaign=elementor-addon-custom-code'; + } + + return sprintf( '%s

%s', $message, $url, $link_text ); + } + + /** + * Check if pro version is installed and active. + * + * @return bool + */ + private function is_pro(): bool { + return defined( 'CODE_SNIPPETS_PRO' ) && CODE_SNIPPETS_PRO; + } }