| 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 |
"html"=> __(' |
| 50 |
<span>Highlight your sales, low stock updates with inline growth alert to boost sales</span> |
| 51 |
<video id="pro_alert_video_popup" type="text/html" allowfullscreen width="450" height="235" autoplay loop muted> |
| 52 |
<source src="https://notificationx.com/wp-content/uploads/2024/01/Introducing-Growth-Alert-Instant-Sales-Booster-With-NotificationX.mp4" type="video/mp4"> |
| 53 |
</video> |
| 54 |
', 'notificationx') |
| 55 |
]; |
| 56 |
} |
| 57 |
|
| 58 |
/** |
| 59 |
* Hooked to nx_before_metabox_load action. |
| 60 |
* |
| 61 |
* @return void |
| 62 |
*/ |
| 63 |
public function init_fields() { |
| 64 |
parent::init_fields(); |
| 65 |
add_filter( 'nx_show_on_exclude', array( $this, 'show_on_exclude' ), 10, 4 ); |
| 66 |
|
| 67 |
} |
| 68 |
|
| 69 |
/** |
| 70 |
* Making sure inline notice don't show as normal notice |
| 71 |
* if pro is disabled. |
| 72 |
* |
| 73 |
* @param bool $exclude |
| 74 |
* @param array $settings |
| 75 |
* @return bool |
| 76 |
*/ |
| 77 |
public function show_on_exclude( $exclude, $settings ) { |
| 78 |
if ( ! empty( $settings['inline_location'] ) && $this->id === $settings['type'] ) { |
| 79 |
return true; |
| 80 |
} |
| 81 |
return $exclude; |
| 82 |
} |
| 83 |
|
| 84 |
public function is_stock_theme( $theme ) { |
| 85 |
$themes = [ 'woocommerce_sales_inline_stock-theme-one', 'woocommerce_sales_inline_stock-theme-two' ]; |
| 86 |
if ( in_array( $theme, $themes, true ) ) { |
| 87 |
return true; |
| 88 |
} |
| 89 |
return false; |
| 90 |
} |
| 91 |
|
| 92 |
public function nx_can_entry( $result, $entry, $settings ) { |
| 93 |
if ( $this->is_stock_theme( $settings['themes'] ) ) { |
| 94 |
return false; |
| 95 |
} |
| 96 |
return $result; |
| 97 |
} |
| 98 |
|
| 99 |
} |
| 100 |
|