[CWA-744] feat: Update promotions for Elementor One & add promotions to additional plugins#329
[CWA-744] feat: Update promotions for Elementor One & add promotions to additional plugins#329rami-elementor wants to merge 13 commits intocore-betafrom
Conversation
|
Amazing work @rami-elementor ! |
src/php/promotions/elementor.php
Outdated
| <div class="notice notice-info is-dismissible code-snippets-promotion"> | ||
| <div class="code-snippets-promotion-icon"> | ||
| <img | ||
| src="<?php echo esc_url( plugins_url( 'assets/icon.svg', CODE_SNIPPETS_FILE ) ); ?>" |
There was a problem hiding this comment.
Changing to PLUGIN_FILE causes a critical error:
There has been a critical error on this website. Please check your site admin email inbox for instructions. If you continue to have problems, please try the [support forums](https://wordpress.org/support/forums/).
imantsk
left a comment
There was a problem hiding this comment.
Overall very nice and scalable structure 👍
spotted a few improvement opportunities.
also if you have a chance please run phpcbf over the the files in this PR to consolidate all indentation and formatting
| 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', | ||
| ], | ||
| ]; | ||
| } |
There was a problem hiding this comment.
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
| ); | ||
| } | ||
|
|
||
| public function get_promotion_buttons(): array { |
There was a problem hiding this comment.
|
|
||
| wp_send_json_success(); | ||
| } | ||
|
|
There was a problem hiding this comment.
we could add this here:
protected function build_default_buttons( bool $show_migrate = false ): array {
$primary = [
'url' => code_snippets()->get_menu_url(),
'text' => esc_html__( 'Manage your snippets', 'code-snippets' ),
'class' => 'button button-primary',
];
if ( $show_migrate ) {
$primary['url'] = add_query_arg( 'tab', 'plugins', code_snippets()->get_menu_url( 'import' ) );
$primary['text'] = esc_html__( 'Migrate to Code Snippets', 'code-snippets' );
}
return [
$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',
'rel' => 'noopener noreferrer',
],
];
}| 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', | ||
| ], | ||
| ]; |
There was a problem hiding this comment.
this can easily become:
return $this->build_default_buttons();ref: https://github.com/codesnippetspro/code-snippets/pull/329/changes#r2743330836
| 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', | ||
| ], | ||
| ]; | ||
| } |
There was a problem hiding this comment.
| $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; |
There was a problem hiding this comment.
this can become:
return $this->build_default_buttons( $this->has_snippets() );ref: https://github.com/codesnippetspro/code-snippets/pull/329/changes#r2743330836
| 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', | ||
| ], | ||
| ]; |




Elementor released a new design in WordPress admin, with updated slugs. Promotions for CS should be displayed in the new Custom Code screens.
Promotion in empty archive:

Promotion in archive with custom code:

Promotion in new custom code:
