From 7b1b750825f9df703ba42cd2279adf4481476afb Mon Sep 17 00:00:00 2001 From: Rami Yushuvaev Date: Tue, 20 Jan 2026 13:39:07 +0200 Subject: [PATCH 01/12] Update promotions for Elementor One --- src/php/class-plugin.php | 4 +- src/php/promotions/class-promotions.php | 19 +++ src/php/promotions/elementor-pro.php | 130 ---------------- src/php/promotions/elementor.php | 187 ++++++++++++++++++++++++ 4 files changed, 208 insertions(+), 132 deletions(-) create mode 100644 src/php/promotions/class-promotions.php delete mode 100644 src/php/promotions/elementor-pro.php create mode 100644 src/php/promotions/elementor.php diff --git a/src/php/class-plugin.php b/src/php/class-plugin.php index faa3ddc3..f7800e3b 100644 --- a/src/php/class-plugin.php +++ b/src/php/class-plugin.php @@ -160,9 +160,9 @@ public function load_plugin() { // Importers. new Plugins_Import_Manager(); new Files_Import_Manager(); - + // Initialize promotions. - new Promotions\Elementor_Pro(); + new Promotions(); } /** diff --git a/src/php/promotions/class-promotions.php b/src/php/promotions/class-promotions.php new file mode 100644 index 00000000..86ef88b4 --- /dev/null +++ b/src/php/promotions/class-promotions.php @@ -0,0 +1,19 @@ +is_custom_code_screen() ) { - return; - } - ?> -
-

- -

-

- -

-

- - - - - - -

-
- 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_notice', - [ - 'type' => \Elementor\Controls_Manager::NOTICE, - 'notice_type' => 'info', - 'dismissible' => true, - '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; - } -} diff --git a/src/php/promotions/elementor.php b/src/php/promotions/elementor.php new file mode 100644 index 00000000..62692159 --- /dev/null +++ b/src/php/promotions/elementor.php @@ -0,0 +1,187 @@ +is_custom_code_screen() ) { + return; + } + ?> + +
+
+ <?php esc_attr_e( 'Code Snippets Logo', 'code-snippets' ); ?> +
+
+

+ +

+

+ +

+

+ + + + + + +

+
+
+ id, + [ + // Elementor Core + 'elementor_custom_code', + 'elementor_page_elementor_custom_code', + // Elementor Pro + 'edit-elementor_snippet', + 'elementor_snippet', + // New Elementor One + 'elementor_page_e-custom-code', + ], + true + ); + + return $is_custom_code_page; + } + + /** + * Promotion on the Custom CSS section, inside the Elementor Editor. + * + * @return void + */ + public function promotion_in_custom_css_section() { + // Elementor Core + add_action( 'elementor/element/common/section_custom_css_pro/after_section_start', [ $this, 'add_promotion_to_custom_css_section_in_elementor_core' ], 10, 2 ); + // Elementor Pro + add_action( 'elementor/element/common/section_custom_css/after_section_start', [ $this, 'add_promotion_to_custom_css_section_in_elementor_pro' ], 10, 2 ); + } + + /** + * Register promotion section in the Custom CSS section. + * + * @param \Elementor\Widget_Base|\Elementor\Element_Base $element The Elementor element. + */ + public function add_promotion_to_custom_css_section_in_elementor_core( $element ) { + $element->add_control( + 'code_snippets_promotion_notice_elementor_core', + [ + 'type' => \Elementor\Controls_Manager::NOTICE, + 'notice_type' => 'info', + 'dismissible' => true, + 'heading' => esc_html__( 'Manage your custom styles', 'code-snippets' ), + 'content' => $this->get_promotion_content(), + ] + ); + } + + /** + * Register promotion section in the Custom CSS section. + * + * @param \Elementor\Widget_Base|\Elementor\Element_Base $element The Elementor element. + */ + public function add_promotion_to_custom_css_section_in_elementor_pro( $element ) { + $element->add_control( + 'code_snippets_promotion_notice_elementor_pro', + [ + 'type' => \Elementor\Controls_Manager::NOTICE, + 'notice_type' => 'info', + 'dismissible' => true, + '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_code_snippets_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_code_snippets_pro(): bool { + return defined( 'CODE_SNIPPETS_PRO' ) && CODE_SNIPPETS_PRO; + } +} From bd06a910cab1bc037c912517805da2c3e2cfec8e Mon Sep 17 00:00:00 2001 From: Rami Yushuvaev Date: Fri, 23 Jan 2026 16:10:28 +0200 Subject: [PATCH 02/12] Update --- src/php/promotions/class-promotions.php | 4 ---- src/php/promotions/elementor.php | 15 +++++++++------ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/php/promotions/class-promotions.php b/src/php/promotions/class-promotions.php index 86ef88b4..79570cfb 100644 --- a/src/php/promotions/class-promotions.php +++ b/src/php/promotions/class-promotions.php @@ -1,10 +1,6 @@ is_custom_code_screen() ) { return; } + + if ( get_setting( 'general', 'hide_upgrade_menu' ) ) { + return; + } ?> -
-
- <?php esc_attr_e( 'Code Snippets Logo', 'code-snippets' ); ?> -
-
-

- -

-

- -

-

- - - - - - -

-
-
- id, - [ - // Elementor Core - 'elementor_custom_code', - 'elementor_page_elementor_custom_code', - // Elementor Pro - 'edit-elementor_snippet', - 'elementor_snippet', - // New Elementor One - 'elementor_page_e-custom-code', - ], - true - ); - - return $is_custom_code_page; - } - - /** - * Promotion on the Custom CSS section, inside the Elementor Editor. - * - * @return void - */ - public function promotion_in_custom_css_section() { - // Elementor Core - add_action( 'elementor/element/common/section_custom_css_pro/after_section_start', [ $this, 'add_promotion_to_custom_css_section_in_elementor_core' ], 10, 2 ); - // Elementor Pro - add_action( 'elementor/element/common/section_custom_css/after_section_start', [ $this, 'add_promotion_to_custom_css_section_in_elementor_pro' ], 10, 2 ); + public function get_plugin_slug(): string { + return 'elementor'; } - /** - * Register promotion section in the Custom CSS section. - * - * @param \Elementor\Widget_Base|\Elementor\Element_Base $element The Elementor element. - */ - public function add_promotion_to_custom_css_section_in_elementor_core( $element ) { - $element->add_control( - 'code_snippets_promotion_notice_elementor_core', - [ - 'type' => \Elementor\Controls_Manager::NOTICE, - 'notice_type' => 'info', - 'dismissible' => true, - 'heading' => esc_html__( 'Manage your custom styles', 'code-snippets' ), - 'content' => $this->get_promotion_content(), - ] - ); + public function get_plugin_admin_screens(): array { + return [ + // Elementor Core + 'elementor_custom_code', + 'elementor_page_elementor_custom_code', + // Elementor Pro + 'edit-elementor_snippet', + 'elementor_snippet', + // New Elementor One + 'elementor_page_e-custom-code', + ]; } - /** - * Register promotion section in the Custom CSS section. - * - * @param \Elementor\Widget_Base|\Elementor\Element_Base $element The Elementor element. - */ - public function add_promotion_to_custom_css_section_in_elementor_pro( $element ) { - $element->add_control( - 'code_snippets_promotion_notice_elementor_pro', - [ - 'type' => \Elementor\Controls_Manager::NOTICE, - 'notice_type' => 'info', - 'dismissible' => true, - '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_code_snippets_pro() ) { - $link_text = esc_html__( 'Manage CSS snippets', 'code-snippets' ); - $url = add_query_arg( 'type', 'css', code_snippets()->get_menu_url() ); - } 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 ); + public function get_promotion_heading(): string { + return esc_html__( 'Looking for a better way to manage your custom code?', 'code-snippets' ); } - /** - * Check if pro version is installed and active. - * - * @return bool - */ - private function is_code_snippets_pro(): bool { - return code_snippets()->licensing->is_licensed(); + public function get_promotion_message(): string { + return esc_html__( 'Code Snippets Pro provides a powerful and user-friendly alternative to Elementor Custom Code, with cloud sync, advanced features, and an intuitive interface.', 'code-snippets' ); } } diff --git a/src/php/promotions/header-footer-code-manager.php b/src/php/promotions/header-footer-code-manager.php new file mode 100644 index 00000000..cbf4ed8c --- /dev/null +++ b/src/php/promotions/header-footer-code-manager.php @@ -0,0 +1,29 @@ +id, + $this->get_plugin_admin_screens() ?? [], + true + ); + + return $is_custom_code_page; + } + + public function display_promotion() { + if ( ! $this->is_plugin_admin_screen() ) { + return; + } + + if ( get_setting( 'general', 'hide_promotion_' . $this->get_plugin_slug() ) ) { + return; + } + ?> + +
+
+ <?php esc_attr_e( 'Code Snippets Logo', 'code-snippets' ); ?> +
+
+

+ get_promotion_heading(); ?> +

+

+ get_promotion_message(); ?> +

+

+ + + + + + +

+
+
+ plugin_promotions = [ + // Notices in admin screens. + 'elementor' => Promotions\Elementor::class, + 'insert-headers-and-footers' => Promotions\Insert_Headers_And_Footers::class, + 'header-footer-code-manager' => Promotions\Header_Footer_Code_Manager::class, + 'insert-php-code-snippet' => Promotions\Insert_PHP_Code_Snippet::class, + + // Other Promotions. + 'elementor-editor' => Promotions\Elementor_Editor::class, + ]; + } + + public function __construct() { + if ( empty( $this->plugin_promotions ) ) { + $this->init_plugin_promotions(); + } + + foreach ( $this->plugin_promotions as $plugin_slug => $promotion_class ) { + new $promotion_class(); + } + } +} From 57f0f86be08df35a0580096a5b96a17b031b6a5e Mon Sep 17 00:00:00 2001 From: Rami Yushuvaev Date: Fri, 23 Jan 2026 23:47:27 +0200 Subject: [PATCH 04/12] Add missing dismiss capability --- src/php/promotions/promotion-base.php | 70 +++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 4 deletions(-) diff --git a/src/php/promotions/promotion-base.php b/src/php/promotions/promotion-base.php index 930274f4..8a50b760 100644 --- a/src/php/promotions/promotion-base.php +++ b/src/php/promotions/promotion-base.php @@ -3,10 +3,12 @@ namespace Code_Snippets\Promotions; use function Code_Snippets\code_snippets; -use function Code_Snippets\Settings\get_setting; abstract class Promotion_Base { + const AJAX_ACTION = 'code_snippets_dismiss_promotion'; + const USER_META_KEY = 'code_snippets_dismissed_promotions'; + abstract public function get_plugin_slug(): string; abstract public function get_plugin_admin_screens(): array; @@ -35,12 +37,26 @@ public function is_plugin_admin_screen(): bool { return $is_custom_code_page; } + public function is_promotion_dismissed(): bool { + $user_id = get_current_user_id(); + if ( ! $user_id ) { + return false; + } + + $dismissed_promotions = get_user_meta( $user_id, self::USER_META_KEY, true ); + if ( ! is_array( $dismissed_promotions ) ) { + $dismissed_promotions = []; + } + + return in_array( $this->get_plugin_slug(), $dismissed_promotions, true ); + } + public function display_promotion() { if ( ! $this->is_plugin_admin_screen() ) { return; } - if ( get_setting( 'general', 'hide_promotion_' . $this->get_plugin_slug() ) ) { + if ( $this->is_promotion_dismissed() ) { return; } ?> @@ -62,7 +78,10 @@ public function display_promotion() { margin-block-end: 0.5em; } -
+
+ Date: Sat, 24 Jan 2026 20:36:12 +0200 Subject: [PATCH 05/12] Move promotion buttons to a separate method --- src/php/promotions/elementor.php | 18 +++++++++++ .../promotions/header-footer-code-manager.php | 21 +++++++++++-- .../promotions/insert-headers-and-footers.php | 18 +++++++++++ .../promotions/insert-php-code-snippet.php | 18 +++++++++++ src/php/promotions/promotion-base.php | 31 +++++++++++++------ 5 files changed, 93 insertions(+), 13 deletions(-) diff --git a/src/php/promotions/elementor.php b/src/php/promotions/elementor.php index 12eb7951..354436f5 100644 --- a/src/php/promotions/elementor.php +++ b/src/php/promotions/elementor.php @@ -1,6 +1,8 @@ code_snippets()->get_menu_url(), + 'text' => esc_html__( 'Manage your snippets', 'code-snippets' ), + 'class' => 'button button-primary', + ], + [ + 'url' => 'https://codesnippets.pro/pricing/?utm_source=' . $this->get_plugin_slug() . '&utm_medium=promotion&utm_campaign=custom-code', + 'text' => esc_html__( 'Learn More', 'code-snippets' ), + 'class' => 'button button-secondary', + 'target' => '_blank', + ], + ]; + } } diff --git a/src/php/promotions/header-footer-code-manager.php b/src/php/promotions/header-footer-code-manager.php index cbf4ed8c..1933cec9 100644 --- a/src/php/promotions/header-footer-code-manager.php +++ b/src/php/promotions/header-footer-code-manager.php @@ -1,9 +1,8 @@ code_snippets()->get_menu_url(), + 'text' => esc_html__( 'Manage your snippets', 'code-snippets' ), + 'class' => 'button button-primary', + ], + [ + 'url' => 'https://codesnippets.pro/pricing/?utm_source=' . $this->get_plugin_slug() . '&utm_medium=promotion&utm_campaign=custom-code', + 'text' => esc_html__( 'Learn More', 'code-snippets' ), + 'class' => 'button button-secondary', + 'target' => '_blank', + ], + ]; + } } \ No newline at end of file diff --git a/src/php/promotions/insert-headers-and-footers.php b/src/php/promotions/insert-headers-and-footers.php index c28bc853..80be66ea 100644 --- a/src/php/promotions/insert-headers-and-footers.php +++ b/src/php/promotions/insert-headers-and-footers.php @@ -1,6 +1,8 @@ code_snippets()->get_menu_url(), + 'text' => esc_html__( 'Manage your snippets', 'code-snippets' ), + 'class' => 'button button-primary', + ], + [ + 'url' => 'https://codesnippets.pro/pricing/?utm_source=' . $this->get_plugin_slug() . '&utm_medium=promotion&utm_campaign=custom-code', + 'text' => esc_html__( 'Learn More', 'code-snippets' ), + 'class' => 'button button-secondary', + 'target' => '_blank', + ], + ]; + } } \ No newline at end of file diff --git a/src/php/promotions/insert-php-code-snippet.php b/src/php/promotions/insert-php-code-snippet.php index 943fad15..d7715858 100644 --- a/src/php/promotions/insert-php-code-snippet.php +++ b/src/php/promotions/insert-php-code-snippet.php @@ -1,6 +1,8 @@ code_snippets()->get_menu_url(), + 'text' => esc_html__( 'Manage your snippets', 'code-snippets' ), + 'class' => 'button button-primary', + ], + [ + 'url' => 'https://codesnippets.pro/pricing/?utm_source=' . $this->get_plugin_slug() . '&utm_medium=promotion&utm_campaign=custom-code', + 'text' => esc_html__( 'Learn More', 'code-snippets' ), + 'class' => 'button button-secondary', + 'target' => '_blank', + ], + ]; + } } \ No newline at end of file diff --git a/src/php/promotions/promotion-base.php b/src/php/promotions/promotion-base.php index 8a50b760..fe6da652 100644 --- a/src/php/promotions/promotion-base.php +++ b/src/php/promotions/promotion-base.php @@ -2,8 +2,6 @@ namespace Code_Snippets\Promotions; -use function Code_Snippets\code_snippets; - abstract class Promotion_Base { const AJAX_ACTION = 'code_snippets_dismiss_promotion'; @@ -17,6 +15,8 @@ abstract public function get_promotion_heading(): string; abstract public function get_promotion_message(): string; + abstract public function get_promotion_buttons(): array; + public function is_plugin_admin_screen(): bool { if ( ! is_admin() ) { return false; @@ -74,8 +74,7 @@ public function display_promotion() { padding: 10px; } .code-snippets-promotion-content p { - margin-block-start: 0; - margin-block-end: 0.5em; + margin-block: 0 .5em; }
get_promotion_message(); ?>

- - - - - - + get_promotion_buttons(); + + foreach ( $buttons as $button ) { + $url = isset( $button['url'] ) ? esc_url( $button['url'] ) : ''; + $text = isset( $button['text'] ) ? $button['text'] : ''; + $class = isset( $button['class'] ) ? esc_attr( $button['class'] ) : 'button'; + $target = isset( $button['target'] ) ? esc_attr( $button['target'] ) : ''; + + printf( + '%s ', + $url, + $class, + $target ? ' target="' . $target . '"' : '', + $text + ); + } + ?>

From c1701e9ea642cfe77b37e472a769279a4df686b1 Mon Sep 17 00:00:00 2001 From: Rami Yushuvaev Date: Sat, 24 Jan 2026 20:41:33 +0200 Subject: [PATCH 06/12] move to folders --- src/php/promotions/{ => admin-notices}/elementor.php | 0 .../promotions/{ => admin-notices}/header-footer-code-manager.php | 0 .../promotions/{ => admin-notices}/insert-headers-and-footers.php | 0 .../promotions/{ => admin-notices}/insert-php-code-snippet.php | 0 src/php/promotions/{ => other-promotions}/elementor-editor.php | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename src/php/promotions/{ => admin-notices}/elementor.php (100%) rename src/php/promotions/{ => admin-notices}/header-footer-code-manager.php (100%) rename src/php/promotions/{ => admin-notices}/insert-headers-and-footers.php (100%) rename src/php/promotions/{ => admin-notices}/insert-php-code-snippet.php (100%) rename src/php/promotions/{ => other-promotions}/elementor-editor.php (100%) diff --git a/src/php/promotions/elementor.php b/src/php/promotions/admin-notices/elementor.php similarity index 100% rename from src/php/promotions/elementor.php rename to src/php/promotions/admin-notices/elementor.php diff --git a/src/php/promotions/header-footer-code-manager.php b/src/php/promotions/admin-notices/header-footer-code-manager.php similarity index 100% rename from src/php/promotions/header-footer-code-manager.php rename to src/php/promotions/admin-notices/header-footer-code-manager.php diff --git a/src/php/promotions/insert-headers-and-footers.php b/src/php/promotions/admin-notices/insert-headers-and-footers.php similarity index 100% rename from src/php/promotions/insert-headers-and-footers.php rename to src/php/promotions/admin-notices/insert-headers-and-footers.php diff --git a/src/php/promotions/insert-php-code-snippet.php b/src/php/promotions/admin-notices/insert-php-code-snippet.php similarity index 100% rename from src/php/promotions/insert-php-code-snippet.php rename to src/php/promotions/admin-notices/insert-php-code-snippet.php diff --git a/src/php/promotions/elementor-editor.php b/src/php/promotions/other-promotions/elementor-editor.php similarity index 100% rename from src/php/promotions/elementor-editor.php rename to src/php/promotions/other-promotions/elementor-editor.php From 2bde5dd9a1ad49715a6e024106933962a13d84ec Mon Sep 17 00:00:00 2001 From: Rami Yushuvaev Date: Sun, 25 Jan 2026 11:34:08 +0200 Subject: [PATCH 07/12] Conditional manage/migrate cta buttons --- .../header-footer-code-manager.php | 36 ++++++++++++++----- .../admin-notices/insert-php-code-snippet.php | 36 ++++++++++++++----- 2 files changed, 54 insertions(+), 18 deletions(-) diff --git a/src/php/promotions/admin-notices/header-footer-code-manager.php b/src/php/promotions/admin-notices/header-footer-code-manager.php index 1933cec9..e6e12a3a 100644 --- a/src/php/promotions/admin-notices/header-footer-code-manager.php +++ b/src/php/promotions/admin-notices/header-footer-code-manager.php @@ -2,6 +2,7 @@ namespace Code_Snippets\Promotions; use function Code_Snippets\code_snippets; +use Code_Snippets\Header_Footer_Code_Manager_Importer; class Header_Footer_Code_Manager extends Promotion_Base { @@ -27,18 +28,35 @@ public function get_promotion_message(): string { } public function get_promotion_buttons(): array { - return [ - [ + $buttons = []; + + if ( $this->has_snippets() ) { + $buttons[] = [ + 'url' => add_query_arg( 'tab', 'plugins', code_snippets()->get_menu_url( 'import' ) ), + 'text' => esc_html__( 'Migrate to Code Snippets', 'code-snippets' ), + 'class' => 'button button-primary', + ]; + } else { + $buttons[] = [ 'url' => code_snippets()->get_menu_url(), 'text' => esc_html__( 'Manage your snippets', 'code-snippets' ), 'class' => 'button button-primary', - ], - [ - 'url' => 'https://codesnippets.pro/pricing/?utm_source=' . $this->get_plugin_slug() . '&utm_medium=promotion&utm_campaign=custom-code', - 'text' => esc_html__( 'Learn More', 'code-snippets' ), - 'class' => 'button button-secondary', - 'target' => '_blank', - ], + ]; + } + + $buttons[] = [ + 'url' => 'https://codesnippets.pro/pricing/?utm_source=' . $this->get_plugin_slug() . '&utm_medium=promotion&utm_campaign=custom-code', + 'text' => esc_html__( 'Learn More', 'code-snippets' ), + 'class' => 'button button-secondary', + 'target' => '_blank', ]; + + return $buttons; + } + + protected function has_snippets(): bool { + $importer = new Header_Footer_Code_Manager_Importer(); + $data = $importer->get_data(); + return ! empty( $data ); } } \ No newline at end of file diff --git a/src/php/promotions/admin-notices/insert-php-code-snippet.php b/src/php/promotions/admin-notices/insert-php-code-snippet.php index d7715858..a56b8a7d 100644 --- a/src/php/promotions/admin-notices/insert-php-code-snippet.php +++ b/src/php/promotions/admin-notices/insert-php-code-snippet.php @@ -2,6 +2,7 @@ namespace Code_Snippets\Promotions; use function Code_Snippets\code_snippets; +use Code_Snippets\Insert_PHP_Code_Snippet_Importer; class Insert_PHP_Code_Snippet extends Promotion_Base { @@ -27,18 +28,35 @@ public function get_promotion_message(): string { } public function get_promotion_buttons(): array { - return [ - [ + $buttons = []; + + if ( $this->has_snippets() ) { + $buttons[] = [ + 'url' => add_query_arg( 'tab', 'plugins', code_snippets()->get_menu_url( 'import' ) ), + 'text' => esc_html__( 'Migrate to Code Snippets', 'code-snippets' ), + 'class' => 'button button-primary', + ]; + } else { + $buttons[] = [ 'url' => code_snippets()->get_menu_url(), 'text' => esc_html__( 'Manage your snippets', 'code-snippets' ), 'class' => 'button button-primary', - ], - [ - 'url' => 'https://codesnippets.pro/pricing/?utm_source=' . $this->get_plugin_slug() . '&utm_medium=promotion&utm_campaign=custom-code', - 'text' => esc_html__( 'Learn More', 'code-snippets' ), - 'class' => 'button button-secondary', - 'target' => '_blank', - ], + ]; + } + + $buttons[] = [ + 'url' => 'https://codesnippets.pro/pricing/?utm_source=' . $this->get_plugin_slug() . '&utm_medium=promotion&utm_campaign=custom-code', + 'text' => esc_html__( 'Learn More', 'code-snippets' ), + 'class' => 'button button-secondary', + 'target' => '_blank', ]; + + return $buttons; + } + + protected function has_snippets(): bool { + $importer = new Insert_PHP_Code_Snippet_Importer(); + $data = $importer->get_data(); + return ! empty( $data ); } } \ No newline at end of file From 3b1e157a8627fd86f9674f30049278ac9d8037a9 Mon Sep 17 00:00:00 2001 From: Rami Yushuvaev Date: Sun, 25 Jan 2026 12:08:02 +0200 Subject: [PATCH 08/12] Update --- src/php/promotions/admin-notices/elementor.php | 9 ++++++++- .../admin-notices/header-footer-code-manager.php | 9 ++++++++- .../admin-notices/insert-headers-and-footers.php | 9 ++++++++- .../promotions/admin-notices/insert-php-code-snippet.php | 9 ++++++++- src/php/promotions/other-promotions/elementor-editor.php | 5 ++++- src/php/promotions/promotion-base.php | 2 ++ 6 files changed, 38 insertions(+), 5 deletions(-) diff --git a/src/php/promotions/admin-notices/elementor.php b/src/php/promotions/admin-notices/elementor.php index 354436f5..69187743 100644 --- a/src/php/promotions/admin-notices/elementor.php +++ b/src/php/promotions/admin-notices/elementor.php @@ -5,6 +5,10 @@ class Elementor extends Promotion_Base { + public function get_plugin_name(): string { + return esc_html__( 'Elementor Custom Code', 'code-snippets' ); + } + public function get_plugin_slug(): string { return 'elementor'; } @@ -27,7 +31,10 @@ public function get_promotion_heading(): string { } public function get_promotion_message(): string { - return esc_html__( 'Code Snippets Pro provides a powerful and user-friendly alternative to Elementor Custom Code, with cloud sync, advanced features, and an intuitive interface.', 'code-snippets' ); + return sprintf( + esc_html__( 'Code Snippets provides a powerful and user-friendly alternative to "%s", with cloud sync, advanced features, and an intuitive interface.', 'code-snippets' ), + $this->get_plugin_name() + ); } public function get_promotion_buttons(): array { diff --git a/src/php/promotions/admin-notices/header-footer-code-manager.php b/src/php/promotions/admin-notices/header-footer-code-manager.php index e6e12a3a..fe7f3bed 100644 --- a/src/php/promotions/admin-notices/header-footer-code-manager.php +++ b/src/php/promotions/admin-notices/header-footer-code-manager.php @@ -6,6 +6,10 @@ class Header_Footer_Code_Manager extends Promotion_Base { + public function get_plugin_name(): string { + return esc_html__( 'Header Footer Code Manager', 'code-snippets' ); + } + public function get_plugin_slug(): string { return 'header-footer-code-manager'; } @@ -24,7 +28,10 @@ public function get_promotion_heading(): string { } public function get_promotion_message(): string { - return esc_html__( 'Code Snippets Pro provides a powerful and user-friendly alternative to Header Footer Code Manager, with cloud sync, advanced features, and an intuitive interface.', 'code-snippets' ); + return sprintf( + esc_html__( 'Code Snippets provides a powerful and user-friendly alternative to "%s", with cloud sync, advanced features, and an intuitive interface.', 'code-snippets' ), + $this->get_plugin_name() + ); } public function get_promotion_buttons(): array { diff --git a/src/php/promotions/admin-notices/insert-headers-and-footers.php b/src/php/promotions/admin-notices/insert-headers-and-footers.php index 80be66ea..460beabc 100644 --- a/src/php/promotions/admin-notices/insert-headers-and-footers.php +++ b/src/php/promotions/admin-notices/insert-headers-and-footers.php @@ -5,6 +5,10 @@ class Insert_Headers_And_Footers extends Promotion_Base { + public function get_plugin_name(): string { + return esc_html__( 'Insert Headers and Footers', 'code-snippets' ); + } + public function get_plugin_slug(): string { return 'insert-headers-and-footers'; } @@ -20,7 +24,10 @@ public function get_promotion_heading(): string { } public function get_promotion_message(): string { - return esc_html__( 'Code Snippets Pro provides a powerful and user-friendly alternative to Header Footer Code Manager, with cloud sync, advanced features, and an intuitive interface.', 'code-snippets' ); + return sprintf( + esc_html__( 'Code Snippets provides a powerful and user-friendly alternative to "%s", with cloud sync, advanced features, and an intuitive interface.', 'code-snippets' ), + $this->get_plugin_name() + ); } public function get_promotion_buttons(): array { diff --git a/src/php/promotions/admin-notices/insert-php-code-snippet.php b/src/php/promotions/admin-notices/insert-php-code-snippet.php index a56b8a7d..b8e6b8b3 100644 --- a/src/php/promotions/admin-notices/insert-php-code-snippet.php +++ b/src/php/promotions/admin-notices/insert-php-code-snippet.php @@ -6,6 +6,10 @@ class Insert_PHP_Code_Snippet extends Promotion_Base { + public function get_plugin_name(): string { + return esc_html__( 'Insert PHP Code Snippet', 'code-snippets' ); + } + public function get_plugin_slug(): string { return 'insert-php-code-snippet'; } @@ -24,7 +28,10 @@ public function get_promotion_heading(): string { } public function get_promotion_message(): string { - return esc_html__( 'Code Snippets Pro provides a powerful and user-friendly alternative to Header Footer Code Manager, with cloud sync, advanced features, and an intuitive interface.', 'code-snippets' ); + return sprintf( + esc_html__( 'Code Snippets provides a powerful and user-friendly alternative to "%s", with cloud sync, advanced features, and an intuitive interface.', 'code-snippets' ), + $this->get_plugin_name() + ); } public function get_promotion_buttons(): array { diff --git a/src/php/promotions/other-promotions/elementor-editor.php b/src/php/promotions/other-promotions/elementor-editor.php index bced57f9..c42e3fa9 100644 --- a/src/php/promotions/other-promotions/elementor-editor.php +++ b/src/php/promotions/other-promotions/elementor-editor.php @@ -61,7 +61,10 @@ public function add_promotion_to_custom_css_section_in_elementor_pro( $element ) * @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' ); + $message = sprintf( + esc_html__( 'Code Snippets provides a powerful and user-friendly alternative to "%s", with cloud sync, advanced features, and an intuitive interface.', 'code-snippets' ), + esc_html__( 'Elementor Custom Code', 'code-snippets' ) + ); if ( $this->is_code_snippets_pro() ) { $link_text = esc_html__( 'Manage CSS snippets', 'code-snippets' ); diff --git a/src/php/promotions/promotion-base.php b/src/php/promotions/promotion-base.php index fe6da652..f78bd8ac 100644 --- a/src/php/promotions/promotion-base.php +++ b/src/php/promotions/promotion-base.php @@ -7,6 +7,8 @@ abstract class Promotion_Base { const AJAX_ACTION = 'code_snippets_dismiss_promotion'; const USER_META_KEY = 'code_snippets_dismissed_promotions'; + abstract public function get_plugin_name(): string; + abstract public function get_plugin_slug(): string; abstract public function get_plugin_admin_screens(): array; From 8305f28ed2428ef7f160bfc65a629ce80f98f908 Mon Sep 17 00:00:00 2001 From: Rami Yushuvaev Date: Sun, 25 Jan 2026 16:36:31 +0200 Subject: [PATCH 09/12] Add promotions to additional plugins --- .../admin-notices/head-footer-code.php | 48 +++++++++++++++++++ ...footers.php => wp-headers-and-footers.php} | 4 +- src/php/promotions/promotion-manager.php | 3 +- 3 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 src/php/promotions/admin-notices/head-footer-code.php rename src/php/promotions/admin-notices/{insert-headers-and-footers.php => wp-headers-and-footers.php} (93%) diff --git a/src/php/promotions/admin-notices/head-footer-code.php b/src/php/promotions/admin-notices/head-footer-code.php new file mode 100644 index 00000000..6d91b4ed --- /dev/null +++ b/src/php/promotions/admin-notices/head-footer-code.php @@ -0,0 +1,48 @@ +get_plugin_name() + ); + } + + public function get_promotion_buttons(): array { + return [ + [ + 'url' => code_snippets()->get_menu_url(), + 'text' => esc_html__( 'Manage your snippets', 'code-snippets' ), + 'class' => 'button button-primary', + ], + [ + 'url' => 'https://codesnippets.pro/pricing/?utm_source=' . $this->get_plugin_slug() . '&utm_medium=promotion&utm_campaign=custom-code', + 'text' => esc_html__( 'Learn More', 'code-snippets' ), + 'class' => 'button button-secondary', + 'target' => '_blank', + ], + ]; + } +} \ No newline at end of file diff --git a/src/php/promotions/admin-notices/insert-headers-and-footers.php b/src/php/promotions/admin-notices/wp-headers-and-footers.php similarity index 93% rename from src/php/promotions/admin-notices/insert-headers-and-footers.php rename to src/php/promotions/admin-notices/wp-headers-and-footers.php index 460beabc..2c2d50ee 100644 --- a/src/php/promotions/admin-notices/insert-headers-and-footers.php +++ b/src/php/promotions/admin-notices/wp-headers-and-footers.php @@ -3,14 +3,14 @@ use function Code_Snippets\code_snippets; -class Insert_Headers_And_Footers extends Promotion_Base { +class WP_Headers_And_Footers extends Promotion_Base { public function get_plugin_name(): string { return esc_html__( 'Insert Headers and Footers', 'code-snippets' ); } public function get_plugin_slug(): string { - return 'insert-headers-and-footers'; + return 'wp-headers-and-footers'; } public function get_plugin_admin_screens(): array { diff --git a/src/php/promotions/promotion-manager.php b/src/php/promotions/promotion-manager.php index cfae54f9..f63f9a36 100644 --- a/src/php/promotions/promotion-manager.php +++ b/src/php/promotions/promotion-manager.php @@ -9,9 +9,10 @@ private function init_plugin_promotions() { $this->plugin_promotions = [ // Notices in admin screens. 'elementor' => Promotions\Elementor::class, - 'insert-headers-and-footers' => Promotions\Insert_Headers_And_Footers::class, + 'head-footer-code' => Promotions\Header_Footer_Code::class, 'header-footer-code-manager' => Promotions\Header_Footer_Code_Manager::class, 'insert-php-code-snippet' => Promotions\Insert_PHP_Code_Snippet::class, + 'wp-headers-and-footers' => Promotions\WP_Headers_And_Footers::class, // Other Promotions. 'elementor-editor' => Promotions\Elementor_Editor::class, From bce4130507c4b1cf84a54f6efb35445327378586 Mon Sep 17 00:00:00 2001 From: Rami Yushuvaev Date: Sun, 25 Jan 2026 20:06:29 +0200 Subject: [PATCH 10/12] Add promotions to additional plugins --- .../promotions/admin-notices/insert-php.php | 54 +++++++++++++++++++ src/php/promotions/promotion-manager.php | 1 + 2 files changed, 55 insertions(+) create mode 100644 src/php/promotions/admin-notices/insert-php.php diff --git a/src/php/promotions/admin-notices/insert-php.php b/src/php/promotions/admin-notices/insert-php.php new file mode 100644 index 00000000..0a8efdb6 --- /dev/null +++ b/src/php/promotions/admin-notices/insert-php.php @@ -0,0 +1,54 @@ +get_plugin_name() + ); + } + + public function get_promotion_buttons(): array { + return [ + [ + 'url' => code_snippets()->get_menu_url(), + 'text' => esc_html__( 'Manage your snippets', 'code-snippets' ), + 'class' => 'button button-primary', + ], + [ + 'url' => 'https://codesnippets.pro/pricing/?utm_source=' . $this->get_plugin_slug() . '&utm_medium=promotion&utm_campaign=custom-code', + 'text' => esc_html__( 'Learn More', 'code-snippets' ), + 'class' => 'button button-secondary', + 'target' => '_blank', + ], + ]; + } +} \ No newline at end of file diff --git a/src/php/promotions/promotion-manager.php b/src/php/promotions/promotion-manager.php index f63f9a36..2e8ea5af 100644 --- a/src/php/promotions/promotion-manager.php +++ b/src/php/promotions/promotion-manager.php @@ -12,6 +12,7 @@ private function init_plugin_promotions() { 'head-footer-code' => Promotions\Header_Footer_Code::class, 'header-footer-code-manager' => Promotions\Header_Footer_Code_Manager::class, 'insert-php-code-snippet' => Promotions\Insert_PHP_Code_Snippet::class, + 'insert-php' => Promotions\Insert_PHP::class, 'wp-headers-and-footers' => Promotions\WP_Headers_And_Footers::class, // Other Promotions. From 41fff237d7bf9c5e2cbf93a82098952f46e17b0d Mon Sep 17 00:00:00 2001 From: Rami Yushuvaev Date: Sun, 25 Jan 2026 20:44:01 +0200 Subject: [PATCH 11/12] Add promotions to additional plugins --- .../admin-notices/insert-html-snippet.php | 51 +++++++++++++++++++ src/php/promotions/promotion-manager.php | 1 + 2 files changed, 52 insertions(+) create mode 100644 src/php/promotions/admin-notices/insert-html-snippet.php diff --git a/src/php/promotions/admin-notices/insert-html-snippet.php b/src/php/promotions/admin-notices/insert-html-snippet.php new file mode 100644 index 00000000..dcb7bb93 --- /dev/null +++ b/src/php/promotions/admin-notices/insert-html-snippet.php @@ -0,0 +1,51 @@ +get_plugin_name() + ); + } + + public function get_promotion_buttons(): array { + return [ + [ + 'url' => code_snippets()->get_menu_url(), + 'text' => esc_html__( 'Manage your snippets', 'code-snippets' ), + 'class' => 'button button-primary', + ], + [ + 'url' => 'https://codesnippets.pro/pricing/?utm_source=' . $this->get_plugin_slug() . '&utm_medium=promotion&utm_campaign=custom-code', + 'text' => esc_html__( 'Learn More', 'code-snippets' ), + 'class' => 'button button-secondary', + 'target' => '_blank', + ], + ]; + } +} \ No newline at end of file diff --git a/src/php/promotions/promotion-manager.php b/src/php/promotions/promotion-manager.php index 2e8ea5af..1e1d1f1e 100644 --- a/src/php/promotions/promotion-manager.php +++ b/src/php/promotions/promotion-manager.php @@ -11,6 +11,7 @@ private function init_plugin_promotions() { 'elementor' => Promotions\Elementor::class, 'head-footer-code' => Promotions\Header_Footer_Code::class, 'header-footer-code-manager' => Promotions\Header_Footer_Code_Manager::class, + 'insert-html-snippet' => Promotions\Insert_HTML_Snippet::class, 'insert-php-code-snippet' => Promotions\Insert_PHP_Code_Snippet::class, 'insert-php' => Promotions\Insert_PHP::class, 'wp-headers-and-footers' => Promotions\WP_Headers_And_Footers::class, From b18ce5e3b158e28eb413522e13c4434d330188f6 Mon Sep 17 00:00:00 2001 From: Rami Yushuvaev Date: Sun, 25 Jan 2026 20:53:27 +0200 Subject: [PATCH 12/12] Update --- src/php/promotions/admin-notices/head-footer-code.php | 2 +- src/php/promotions/admin-notices/header-footer-code-manager.php | 2 +- src/php/promotions/admin-notices/insert-html-snippet.php | 2 +- src/php/promotions/admin-notices/insert-php-code-snippet.php | 2 +- src/php/promotions/admin-notices/insert-php.php | 2 +- src/php/promotions/admin-notices/wp-headers-and-footers.php | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/php/promotions/admin-notices/head-footer-code.php b/src/php/promotions/admin-notices/head-footer-code.php index 6d91b4ed..0d383500 100644 --- a/src/php/promotions/admin-notices/head-footer-code.php +++ b/src/php/promotions/admin-notices/head-footer-code.php @@ -45,4 +45,4 @@ public function get_promotion_buttons(): array { ], ]; } -} \ No newline at end of file +} diff --git a/src/php/promotions/admin-notices/header-footer-code-manager.php b/src/php/promotions/admin-notices/header-footer-code-manager.php index fe7f3bed..691e212c 100644 --- a/src/php/promotions/admin-notices/header-footer-code-manager.php +++ b/src/php/promotions/admin-notices/header-footer-code-manager.php @@ -66,4 +66,4 @@ protected function has_snippets(): bool { $data = $importer->get_data(); return ! empty( $data ); } -} \ No newline at end of file +} diff --git a/src/php/promotions/admin-notices/insert-html-snippet.php b/src/php/promotions/admin-notices/insert-html-snippet.php index dcb7bb93..3a02bf92 100644 --- a/src/php/promotions/admin-notices/insert-html-snippet.php +++ b/src/php/promotions/admin-notices/insert-html-snippet.php @@ -48,4 +48,4 @@ public function get_promotion_buttons(): array { ], ]; } -} \ No newline at end of file +} diff --git a/src/php/promotions/admin-notices/insert-php-code-snippet.php b/src/php/promotions/admin-notices/insert-php-code-snippet.php index b8e6b8b3..f07056a3 100644 --- a/src/php/promotions/admin-notices/insert-php-code-snippet.php +++ b/src/php/promotions/admin-notices/insert-php-code-snippet.php @@ -66,4 +66,4 @@ protected function has_snippets(): bool { $data = $importer->get_data(); return ! empty( $data ); } -} \ No newline at end of file +} diff --git a/src/php/promotions/admin-notices/insert-php.php b/src/php/promotions/admin-notices/insert-php.php index 0a8efdb6..555065b2 100644 --- a/src/php/promotions/admin-notices/insert-php.php +++ b/src/php/promotions/admin-notices/insert-php.php @@ -51,4 +51,4 @@ public function get_promotion_buttons(): array { ], ]; } -} \ No newline at end of file +} diff --git a/src/php/promotions/admin-notices/wp-headers-and-footers.php b/src/php/promotions/admin-notices/wp-headers-and-footers.php index 2c2d50ee..9b526d56 100644 --- a/src/php/promotions/admin-notices/wp-headers-and-footers.php +++ b/src/php/promotions/admin-notices/wp-headers-and-footers.php @@ -45,4 +45,4 @@ public function get_promotion_buttons(): array { ], ]; } -} \ No newline at end of file +}