Skip to content
Open
6 changes: 3 additions & 3 deletions src/php/class-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ public function load_plugin() {
// Importers.
new Plugins_Import_Manager();
new Files_Import_Manager();
// Initialize promotions.
new Promotions\Elementor_Pro();

// Promotions.
new Promotion_Manager();
}

/**
Expand Down
55 changes: 55 additions & 0 deletions src/php/promotions/admin-notices/elementor.php
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',
],
];
}
}
48 changes: 48 additions & 0 deletions src/php/promotions/admin-notices/head-footer-code.php
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 {
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',
],
];
}
}
69 changes: 69 additions & 0 deletions src/php/promotions/admin-notices/header-footer-code-manager.php
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() ) {
$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 );
}
}
51 changes: 51 additions & 0 deletions src/php/promotions/admin-notices/insert-html-snippet.php
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',
],
];
}
}
69 changes: 69 additions & 0 deletions src/php/promotions/admin-notices/insert-php-code-snippet.php
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;
}

protected function has_snippets(): bool {
$importer = new Insert_PHP_Code_Snippet_Importer();
$data = $importer->get_data();
return ! empty( $data );
}
}
54 changes: 54 additions & 0 deletions src/php/promotions/admin-notices/insert-php.php
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',
],
];
}
}
Loading