| 1 |
<?php |
| 2 |
|
| 3 |
namespace Code_Snippets\Integration\Promotions\Notices; |
| 4 |
|
| 5 |
use Code_Snippets\REST_API\Import\Plugins\Insert_PHP_Code_Snippet_Plugin_Importer; |
| 6 |
|
| 7 |
/** |
| 8 |
* Promotion class for Insert PHP Code Snippet plugin. |
| 9 |
* |
| 10 |
* @link https://wordpress.org/plugins/insert-php-code-snippet/ |
| 11 |
*/ |
| 12 |
class Insert_PHP_Code_Snippet extends Promotion_Base { |
| 13 |
|
| 14 |
/** |
| 15 |
* Get the name of the plugin being promoted. |
| 16 |
* |
| 17 |
* @return string The plugin name. |
| 18 |
*/ |
| 19 |
public function get_plugin_name(): string { |
| 20 |
return __( 'Insert PHP Code Snippet', 'code-snippets' ); |
| 21 |
} |
| 22 |
|
| 23 |
/** |
| 24 |
* Get the slug of the plugin being promoted. |
| 25 |
* |
| 26 |
* @return string The plugin slug. |
| 27 |
*/ |
| 28 |
public function get_plugin_slug(): string { |
| 29 |
return 'insert-php-code-snippet'; |
| 30 |
} |
| 31 |
|
| 32 |
/** |
| 33 |
* Get the admin screens where the promotion should be displayed. |
| 34 |
* |
| 35 |
* @return array An array of admin screen IDs. |
| 36 |
*/ |
| 37 |
public function get_plugin_admin_screens(): array { |
| 38 |
return [ |
| 39 |
'toplevel_page_insert-php-code-snippet-manage', |
| 40 |
'insert-php-code-snippet_page_insert-php-code-snippet-settings', |
| 41 |
'insert-php-code-snippet_page_insert-php-code-snippet-about', |
| 42 |
'insert-php-code-snippet_page_insert-php-code-snippet-suggest-features', |
| 43 |
]; |
| 44 |
} |
| 45 |
|
| 46 |
/** |
| 47 |
* Get the heading text for the promotion notice. |
| 48 |
* |
| 49 |
* @return string The promotion heading. |
| 50 |
*/ |
| 51 |
public function get_promotion_heading(): string { |
| 52 |
return __( 'Looking for a better way to manage your custom code?', 'code-snippets' ); |
| 53 |
} |
| 54 |
|
| 55 |
/** |
| 56 |
* Check if the user should see the migration button. |
| 57 |
* |
| 58 |
* @return bool Whether the user should see the migration button. |
| 59 |
*/ |
| 60 |
public function show_migration_button(): bool { |
| 61 |
$importer = new Insert_PHP_Code_Snippet_Plugin_Importer(); |
| 62 |
$data = $importer->get_data(); |
| 63 |
return ! empty( $data ); |
| 64 |
} |
| 65 |
} |
| 66 |
|