| @@ -1,0 +1,101 @@ | ||
| 1 | +<?php | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * Extension Abstract | |
| 5 | + * | |
| 6 | + * @package NotificationX\Extensions | |
| 7 | + */ | |
| 8 | + | |
| 9 | +namespace NotificationX\Types; | |
| 10 | + | |
| 11 | +use NotificationX\Extensions\GlobalFields; | |
| 12 | +use NotificationX\GetInstance; | |
| 13 | + | |
| 14 | +/** | |
| 15 | + * Extension Abstract for all Extension. | |
| 16 | + * @method static Inline get_instance($args = null) | |
| 17 | + */ | |
| 18 | +class Inline extends Types { | |
| 19 | + /** | |
| 20 | + * Instance of Admin | |
| 21 | + * | |
| 22 | + * @var Admin | |
| 23 | + */ | |
| 24 | + use GetInstance; | |
| 25 | + public $priority = 50; | |
| 26 | + public $is_pro = true; | |
| 27 | + public $module = ['modules_woocommerce']; | |
| 28 | + public $id = 'inline'; | |
| 29 | + public $default_source = 'woo_inline'; | |
| 30 | + public $link_type = '-1'; | |
| 31 | + | |
| 32 | + /** | |
| 33 | + * Initially Invoked when initialized. | |
| 34 | + */ | |
| 35 | + public function __construct() { | |
| 36 | + // nx_comment_colored_themes | |
| 37 | + parent::__construct(); | |
| 38 | + | |
| 39 | + } | |
| 40 | + | |
| 41 | + public function init() | |
| 42 | + { | |
| 43 | + parent::init(); | |
| 44 | + $this->title = __('Growth Alert 🚀', 'notificationx'); | |
| 45 | + $this->dashboard_title = __('Growth Alert', 'notificationx'); | |
| 46 | + $this->popup = [ | |
| 47 | + "denyButtonText" => __("<a href='https://notificationx.com/growth-alert/' target='_blank'>More Info</a>", "notificationx"), | |
| 48 | + "confirmButtonText" => __("<a href='https://notificationx.com/#pricing' target='_blank'>Upgrade to PRO</a>", "notificationx"), | |
| 49 | + // phpcs:disable PluginCheck.CodeAnalysis.Offloading.OffloadedContent -- False positive for this context: these are HTML email bodies and remote documentation/tutorial links in admin help text, not offloaded plugin assets. Audited 2026-07-16. | |
| 50 | + "html"=> __(' | |
| 51 | + <span>Highlight your sales, low stock updates with inline growth alert to boost sales</span> | |
| 52 | + <video id="pro_alert_video_popup" type="text/html" allowfullscreen width="450" height="235" autoplay loop muted> | |
| 53 | + <source src="https://notificationx.com/wp-content/uploads/2024/01/Introducing-Growth-Alert-Instant-Sales-Booster-With-NotificationX.mp4" type="video/mp4"> | |
| 54 | + </video> | |
| 55 | + ', 'notificationx') | |
| 56 | + // phpcs:enable PluginCheck.CodeAnalysis.Offloading.OffloadedContent | |
| 57 | + ]; | |
| 58 | + } | |
| 59 | + | |
| 60 | + /** | |
| 61 | + * Hooked to nx_before_metabox_load action. | |
| 62 | + * | |
| 63 | + * @return void | |
| 64 | + */ | |
| 65 | + public function init_fields() { | |
| 66 | + parent::init_fields(); | |
| 67 | + add_filter( 'nx_show_on_exclude', array( $this, 'show_on_exclude' ), 10, 4 ); | |
| 68 | + | |
| 69 | + } | |
| 70 | + | |
| 71 | + /** | |
| 72 | + * Making sure inline notice don't show as normal notice | |
| 73 | + * if pro is disabled. | |
| 74 | + * | |
| 75 | + * @param bool $exclude | |
| 76 | + * @param array $settings | |
| 77 | + * @return bool | |
| 78 | + */ | |
| 79 | + public function show_on_exclude( $exclude, $settings ) { | |
| 80 | + if ( ! empty( $settings['inline_location'] ) && $this->id === $settings['type'] ) { | |
| 81 | + return true; | |
| 82 | + } | |
| 83 | + return $exclude; | |
| 84 | + } | |
| 85 | + | |
| 86 | + public function is_stock_theme( $theme ) { | |
| 87 | + $themes = [ 'woocommerce_sales_inline_stock-theme-one', 'woocommerce_sales_inline_stock-theme-two' ]; | |
| 88 | + if ( in_array( $theme, $themes, true ) ) { | |
| 89 | + return true; | |
| 90 | + } | |
| 91 | + return false; | |
| 92 | + } | |
| 93 | + | |
| 94 | + public function nx_can_entry( $result, $entry, $settings ) { | |
| 95 | + if ( $this->is_stock_theme( $settings['themes'] ) ) { | |
| 96 | + return false; | |
| 97 | + } | |
| 98 | + return $result; | |
| 99 | + } | |
| 100 | + | |
| 101 | +} | |