| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* EDD Extension |
| 5 |
* |
| 6 |
* @package NotificationX\Extensions |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace NotificationX\Extensions\EDD; |
| 10 |
|
| 11 |
/** |
| 12 |
* EDD Extension |
| 13 |
*/ |
| 14 |
class EDDInline extends EDD { |
| 15 |
protected static $instance = null; |
| 16 |
|
| 17 |
public $priority = 10; |
| 18 |
public $id = 'edd_inline'; |
| 19 |
public $img = NOTIFICATIONX_ADMIN_URL . 'images/extensions/sources/edd.png'; |
| 20 |
public $doc_link = 'https://notificationx.com/docs/notificationx-easy-digital-downloads/'; |
| 21 |
public $types = 'inline'; |
| 22 |
public $module = 'modules_edd'; |
| 23 |
public $module_priority = 5; |
| 24 |
public $class = 'Easy_Digital_Downloads'; |
| 25 |
public $is_pro = true; |
| 26 |
|
| 27 |
/** |
| 28 |
* Initially Invoked when initialized. |
| 29 |
*/ |
| 30 |
public function __construct() { |
| 31 |
add_filter( 'nx_show_on_exclude', array( $this, 'show_on_exclude' ), 10, 4 ); |
| 32 |
parent::__construct(); |
| 33 |
} |
| 34 |
|
| 35 |
public function init_extension() |
| 36 |
{ |
| 37 |
$this->themes = [ |
| 38 |
'conv-theme-seven' => array( |
| 39 |
'is_pro' => true, |
| 40 |
'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/pro/woo-inline.jpg', |
| 41 |
'image_shape' => 'rounded', |
| 42 |
'inline_location' => ['edd_single'], |
| 43 |
'template' => [ |
| 44 |
'first_param' => 'tag_sales_count', |
| 45 |
'custom_first_param' => __( 'Someone', 'notificationx' ), |
| 46 |
'second_param' => __( 'people purchased', 'notificationx' ), |
| 47 |
'third_param' => 'tag_custom', |
| 48 |
'custom_third_param' => ' ', |
| 49 |
'fourth_param' => 'tag_7days', |
| 50 |
'custom_fourth_param' => __( 'in last {{day:7}}', 'notificationx' ), |
| 51 |
], |
| 52 |
), |
| 53 |
]; |
| 54 |
$this->templates = [ |
| 55 |
'woo_template_sales_count' => [ |
| 56 |
'first_param' => [ |
| 57 |
'tag_sales_count' => __( 'Sales Count', 'notificationx' ), |
| 58 |
], |
| 59 |
'third_param' => [ |
| 60 |
'tag_product_title' => __( 'Product Title', 'notificationx' ), |
| 61 |
], |
| 62 |
'fourth_param' => [ |
| 63 |
'tag_1day' => __( 'In last 1 day', 'notificationx' ), |
| 64 |
'tag_7days' => __( 'In last 7 days', 'notificationx' ), |
| 65 |
'tag_30days' => __( 'In last 30 days', 'notificationx' ), |
| 66 |
], |
| 67 |
'_themes' => [ |
| 68 |
"{$this->id}_conv-theme-seven", |
| 69 |
], |
| 70 |
], |
| 71 |
]; |
| 72 |
} |
| 73 |
|
| 74 |
/** |
| 75 |
* @todo Something |
| 76 |
* |
| 77 |
* @param [type] $exclude |
| 78 |
* @param [type] $settings |
| 79 |
* @return void |
| 80 |
*/ |
| 81 |
public function show_on_exclude( $exclude, $settings ) { |
| 82 |
if ( 'inline' === $settings['type'] && $settings['source'] === $this->id ) { |
| 83 |
$edd_location = $settings['inline_location']; |
| 84 |
$hooks = [ 'edd_archive', 'edd_single' ]; |
| 85 |
$diff = array_diff( $hooks, $edd_location ); |
| 86 |
if ( count( $diff ) <= count( $hooks ) ) { |
| 87 |
return true; |
| 88 |
} |
| 89 |
} |
| 90 |
return $exclude; |
| 91 |
} |
| 92 |
/** |
| 93 |
* Get the instance of called class. |
| 94 |
* |
| 95 |
* @return ReviewX |
| 96 |
*/ |
| 97 |
public static function get_instance($args = null){ |
| 98 |
if ( is_null( static::$instance ) ) { |
| 99 |
$class = __CLASS__; |
| 100 |
if(strpos($class, "NotificationX\\") === 0){ |
| 101 |
$pro_class = str_replace("NotificationX\\", "NotificationXPro\\", $class); |
| 102 |
if(class_exists($pro_class)){ |
| 103 |
$class = $pro_class; |
| 104 |
} |
| 105 |
} |
| 106 |
|
| 107 |
if(!empty($args)){ |
| 108 |
static::$instance = new $class($args); |
| 109 |
} |
| 110 |
else{ |
| 111 |
static::$instance = new $class; |
| 112 |
} |
| 113 |
} |
| 114 |
return static::$instance; |
| 115 |
} |
| 116 |
|
| 117 |
|
| 118 |
} |
| 119 |
|