-
Notifications
You must be signed in to change notification settings - Fork 108
[CWA-744] feat: Update promotions for Elementor One & add promotions to additional plugins #329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: core-beta
Are you sure you want to change the base?
Changes from all commits
7b1b750
bd06a91
3c20066
57f0f86
3674e8c
c1701e9
2bde5dd
3b1e157
8305f28
bce4130
41fff23
b18ce5e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| <?php | ||
| namespace Code_Snippets\Promotions; | ||
|
|
||
| use function Code_Snippets\code_snippets; | ||
|
|
||
| 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'; | ||
| } | ||
|
|
||
| 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', | ||
| ]; | ||
| } | ||
|
|
||
| public function get_promotion_heading(): string { | ||
| return esc_html__( 'Looking for a better way to manage your custom code?', 'code-snippets' ); | ||
| } | ||
|
|
||
| public function get_promotion_message(): string { | ||
| 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 { | ||
| 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', | ||
| ], | ||
| ]; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| <?php | ||
| namespace Code_Snippets\Promotions; | ||
|
|
||
| use function Code_Snippets\code_snippets; | ||
|
|
||
| class Header_Footer_Code extends Promotion_Base { | ||
|
|
||
| public function get_plugin_name(): string { | ||
| return esc_html__( 'Head & Footer Code', 'code-snippets' ); | ||
| } | ||
|
|
||
| public function get_plugin_slug(): string { | ||
| return 'head-footer-code'; | ||
| } | ||
|
|
||
| public function get_plugin_admin_screens(): array { | ||
| return [ | ||
| 'tools_page_head-footer-code' | ||
| ]; | ||
| } | ||
|
|
||
| public function get_promotion_heading(): string { | ||
| return esc_html__( 'Looking for a better way to manage your custom code?', 'code-snippets' ); | ||
| } | ||
|
|
||
| public function get_promotion_message(): string { | ||
| 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 { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| 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', | ||
| ], | ||
| ]; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| <?php | ||
| 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 { | ||
|
|
||
| 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'; | ||
| } | ||
|
|
||
| public function get_plugin_admin_screens(): array { | ||
| return [ | ||
| 'toplevel_page_hfcm-list', | ||
| 'hfcm_page_hfcm-tools', | ||
| 'hfcm_page_hfcm-create', | ||
| 'admin_page_hfcm-update', | ||
| ]; | ||
| } | ||
|
|
||
| public function get_promotion_heading(): string { | ||
| return esc_html__( 'Looking for a better way to manage your custom code?', 'code-snippets' ); | ||
| } | ||
|
|
||
| public function get_promotion_message(): string { | ||
| 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 { | ||
| $buttons = []; | ||
|
|
||
| if ( $this->has_snippets() ) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as https://github.com/codesnippetspro/code-snippets/pull/329/changes#r2743314696
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| $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', | ||
| ]; | ||
| } | ||
|
|
||
| $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 ); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| <?php | ||
| namespace Code_Snippets\Promotions; | ||
|
|
||
| use function Code_Snippets\code_snippets; | ||
|
|
||
| class Insert_HTML_Snippet extends Promotion_Base { | ||
|
|
||
| public function get_plugin_name(): string { | ||
| return esc_html__( 'Insert HTML Snippet', 'code-snippets' ); | ||
| } | ||
|
|
||
| public function get_plugin_slug(): string { | ||
| return 'insert-html-snippet'; | ||
| } | ||
|
|
||
| public function get_plugin_admin_screens(): array { | ||
| return [ | ||
| 'toplevel_page_insert-html-snippet-manage', | ||
| 'insert-html-snippet_page_insert-html-snippet-settings', | ||
| 'insert-html-snippet_page_insert-html-snippet-about', | ||
| 'insert-html-snippet_page_insert-html-snippet-suggest-features', | ||
| ]; | ||
| } | ||
|
|
||
| public function get_promotion_heading(): string { | ||
| return esc_html__( 'Looking for a better way to manage your custom code?', 'code-snippets' ); | ||
| } | ||
|
|
||
| public function get_promotion_message(): string { | ||
| 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 { | ||
| 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', | ||
| ], | ||
| ]; | ||
|
Comment on lines
+37
to
+49
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as others |
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| <?php | ||
| 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 { | ||
|
|
||
| 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'; | ||
| } | ||
|
|
||
| public function get_plugin_admin_screens(): array { | ||
| return [ | ||
| 'toplevel_page_insert-php-code-snippet-manage', | ||
| 'insert-php-code-snippet_page_insert-php-code-snippet-settings', | ||
| 'insert-php-code-snippet_page_insert-php-code-snippet-about', | ||
| 'insert-php-code-snippet_page_insert-php-code-snippet-suggest-features', | ||
| ]; | ||
| } | ||
|
|
||
| public function get_promotion_heading(): string { | ||
| return esc_html__( 'Looking for a better way to manage your custom code?', 'code-snippets' ); | ||
| } | ||
|
|
||
| public function get_promotion_message(): string { | ||
| 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 { | ||
| $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', | ||
| ]; | ||
| } | ||
|
|
||
| $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; | ||
|
Comment on lines
+38
to
+61
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this can become: return $this->build_default_buttons( $this->has_snippets() );ref: https://github.com/codesnippetspro/code-snippets/pull/329/changes#r2743330836 |
||
| } | ||
|
|
||
| protected function has_snippets(): bool { | ||
| $importer = new Insert_PHP_Code_Snippet_Importer(); | ||
| $data = $importer->get_data(); | ||
| return ! empty( $data ); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| <?php | ||
| namespace Code_Snippets\Promotions; | ||
|
|
||
| use function Code_Snippets\code_snippets; | ||
|
|
||
| class Insert_PHP extends Promotion_Base { | ||
|
|
||
| public function get_plugin_name(): string { | ||
| return esc_html__( 'Woody Code Snippets', 'code-snippets' ); | ||
| } | ||
|
|
||
| public function get_plugin_slug(): string { | ||
| return 'insert-php'; | ||
| } | ||
|
|
||
| public function get_plugin_admin_screens(): array { | ||
| return [ | ||
| 'wbcr-snippets', | ||
| 'edit-wbcr-snippets', | ||
| 'edit-wbcr-snippet-tags', | ||
| 'wbcr-snippets_page_winp-new-item', | ||
| 'wbcr-snippets_page_winp-settings', | ||
| 'wbcr-snippets_page_snippet-library', | ||
| 'wbcr-snippets_page_ti-about-insert_php', | ||
| ]; | ||
| } | ||
|
|
||
| public function get_promotion_heading(): string { | ||
| return esc_html__( 'Looking for a better way to manage your custom code?', 'code-snippets' ); | ||
| } | ||
|
|
||
| public function get_promotion_message(): string { | ||
| 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 { | ||
| 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', | ||
| ], | ||
| ]; | ||
| } | ||
|
Comment on lines
+39
to
+53
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i see this button building repeats on each promotion class.
this makes me think that it could be standardised and go directly in the base class