|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace BulkWP\BulkDelete\Core\Addon; |
|
4
|
|
|
|
|
5
|
|
|
defined( 'ABSPATH' ) || exit; // Exit if accessed directly. |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Upsell Data about an add-on. |
|
9
|
|
|
* |
|
10
|
|
|
* This is a `Record` class that only contains data about a particular add-on. |
|
11
|
|
|
* `Info` suffix is generally considered bad, but this is an exception since the suffix makes sense here. |
|
12
|
|
|
* |
|
13
|
|
|
* @since 6.0.0 |
|
14
|
|
|
*/ |
|
15
|
|
|
class AddonUpsellInfo extends AddonInfo { |
|
16
|
|
|
protected $description; |
|
17
|
|
|
protected $slug; |
|
18
|
|
|
protected $url; |
|
19
|
|
|
protected $buy_url; |
|
20
|
|
|
protected $upsell_title; |
|
21
|
|
|
protected $upsell_message; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Construct AddonUpsellInfo from an array. |
|
25
|
|
|
* |
|
26
|
|
|
* @param array $details Details about the add-on. |
|
27
|
|
|
*/ |
|
28
|
|
|
public function __construct( $details = array() ) { |
|
29
|
|
|
if ( ! is_array( $details ) ) { |
|
|
|
|
|
|
30
|
|
|
return; |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
parent::__construct( $details ); |
|
34
|
|
|
|
|
35
|
|
|
$keys = array( |
|
36
|
|
|
'description', |
|
37
|
|
|
'slug', |
|
38
|
|
|
'url', |
|
39
|
|
|
'buy_url', |
|
40
|
|
|
'upsell_title', |
|
41
|
|
|
'upsell_message', |
|
42
|
|
|
); |
|
43
|
|
|
|
|
44
|
|
|
foreach ( $keys as $key ) { |
|
45
|
|
|
if ( array_key_exists( $key, $details ) ) { |
|
46
|
|
|
$this->{$key} = $details[ $key ]; |
|
47
|
|
|
} |
|
48
|
|
|
} |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
public function get_description() { |
|
52
|
|
|
return $this->description; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function get_slug() { |
|
56
|
|
|
return $this->slug; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
public function get_url() { |
|
60
|
|
|
return $this->url; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Get the url where users can buy the add-on. |
|
65
|
|
|
* |
|
66
|
|
|
* This url might include GA campaign parameters. |
|
67
|
|
|
* Addon url is used if buy url is not explicitly set. |
|
68
|
|
|
* |
|
69
|
|
|
* @return string Url from where the add-on could be bought or just url if it not set. |
|
70
|
|
|
*/ |
|
71
|
|
|
public function get_buy_url() { |
|
72
|
|
|
if ( empty( $this->buy_url ) ) { |
|
73
|
|
|
return $this->url; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
return $this->buy_url; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* Get upsell title for the addon. |
|
81
|
|
|
* |
|
82
|
|
|
* Name is used if title is not explicitly set. |
|
83
|
|
|
* |
|
84
|
|
|
* @return string Upsell title for addon or Name if it not set. |
|
85
|
|
|
*/ |
|
86
|
|
|
public function get_upsell_title() { |
|
87
|
|
|
if ( empty( $this->upsell_title ) ) { |
|
88
|
|
|
return $this->name; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
return $this->upsell_title; |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* Get upsell message for the addon. |
|
96
|
|
|
* |
|
97
|
|
|
* Description is used if title is not explicitly set. |
|
98
|
|
|
* |
|
99
|
|
|
* @return string Upsell description for addon or Description if it not set. |
|
100
|
|
|
*/ |
|
101
|
|
|
public function get_upsell_message() { |
|
102
|
|
|
if ( empty( $this->upsell_message ) ) { |
|
103
|
|
|
return $this->description; |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
return $this->upsell_message; |
|
107
|
|
|
} |
|
108
|
|
|
} |
|
109
|
|
|
|