-
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?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use PLUGIN_FILE.
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
| <strong><?php echo $this->get_promotion_heading(); ?></strong> | ||
| </p> | ||
| <p> | ||
| <?php echo $this->get_promotion_message(); ?> |
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.
echo on get_promotion_heading() and get_promotion_message() could use wp_kses_post()
| $url, | ||
| $class, | ||
| $target ? ' target="' . $target . '"' : '', | ||
| $text |
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.
maybe esc_html( $text ) here?
| 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 <br><br><a href="%s" target="_blank" class="e-btn e-info" style="color:#fff;">%s</a>', $message, $url, $link_text ); |
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.
what do you say about this:
$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';
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() );
}
return sprintf(
'%s <br><br><a href="%s" target="_blank" rel="noopener noreferrer" class="e-btn e-info" style="color:#fff;">%s</a>',
esc_html( $message ),
esc_url( $url ),
esc_html( $link_text )
);| 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.
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
| ); | ||
| } | ||
|
|
||
| public function get_promotion_buttons(): array { |
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.
|
|
||
| wp_send_json_success(); | ||
| } | ||
|
|
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| $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.
Choose a reason for hiding this comment
The 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
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as others




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:
