PluginProbe
Code Snippets / 3.10.1
Code Snippets v3.10.1
3.10.2 3.10.1 3.10.0 3.10.0-beta.2 3.10.0-beta.1 4.0.0-beta.1 3.9.6 trunk 2.10.0 2.10.1 2.12.0 2.12.1 2.13.0 2.13.1 2.13.2 2.13.3 2.14.0 2.14.1 2.14.2 2.14.3 2.14.4 2.14.5 2.14.6 3.0.0 3.0.1 All 64 releases
code-snippets / php / Integration / Promotions / Other / Elementor_Editor.php

Elementor_Editor.php in Code Snippets 3.10.1, at php/Integration/Promotions/Other/Elementor_Editor.php

88 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Code_Snippets\Integration\Promotions\Other;
4
5 use Elementor\Controls_Manager;
6 use Elementor\Element_Base;
7 use Elementor\Widget_Base;
8 use function Code_Snippets\code_snippets;
9
10 /**
11 * Handle adding promotions to the Elementor editor.
12 */
13 class Elementor_Editor {
14
15 /**
16 * Class constructor.
17 */
18 public function __construct() {
19 add_action( 'elementor/init', [ $this, 'promotion_in_custom_css_section' ] );
20 }
21
22 /**
23 * Promotion on the Custom CSS section, inside the Elementor Editor.
24 */
25 public function promotion_in_custom_css_section() {
26 // Elementor Core.
27 add_action(
28 'elementor/element/common/section_custom_css/after_section_start',
29 function ( $element ) {
30 $this->add_promotion_control( $element, 'core' );
31 }
32 );
33
34 // Elementor Pro.
35 add_action(
36 'elementor/element/common/section_custom_css_pro/after_section_start',
37 function ( $element ) {
38 $this->add_promotion_control( $element, 'pro' );
39 }
40 );
41 }
42
43 /**
44 * Register promotion section in the Custom CSS section.
45 *
46 * @param Widget_Base|Element_Base $element The Elementor element.
47 * @param string $suffix Identifier to append.
48 */
49 public function add_promotion_control( $element, string $suffix ) {
50 $element->add_control(
51 "code_snippets_promotion_notice_elementor_$suffix",
52 [
53 'type' => Controls_Manager::NOTICE,
54 'notice_type' => 'info',
55 'dismissible' => true,
56 'heading' => esc_html__( 'Manage your custom styles', 'code-snippets' ),
57 'content' => $this->get_promotion_content(),
58 ]
59 );
60 }
61
62 /**
63 * Get the promotion content with appropriate link.
64 *
65 * @return string
66 */
67 private function get_promotion_content(): string {
68 // translators: %s: plugin name.
69 $message = __( 'Code Snippets provides a powerful and user-friendly alternative to "%s", with cloud sync, advanced features, and an intuitive interface.', 'code-snippets' );
70 $message = sprintf( $message, __( 'Elementor Custom Code', 'code-snippets' ) );
71
72 if ( code_snippets()->licensing->is_licensed() ) {
73 $link_text = __( 'Manage CSS snippets', 'code-snippets' );
74 $link_url = add_query_arg( 'type', 'css', code_snippets()->get_menu_url() );
75 } else {
76 $link_text = __( 'Learn more', 'code-snippets' );
77 $link_url = 'https://codesnippets.pro/pricing/?utm_source=elementor&utm_medium=banner&utm_campaign=elementor-addon-custom-code';
78 }
79
80 return sprintf(
81 '%s <br><br><a href="%s" target="_blank" rel="noopener noreferrer" class="e-btn e-info" style="color: #fff;">%s</a>',
82 esc_html( $message ),
83 esc_url( $link_url ),
84 esc_html( $link_text )
85 );
86 }
87 }
88