|
1
|
|
|
<?php |
|
2
|
|
|
namespace EventEspresso\core\domain\services\admin; |
|
3
|
|
|
|
|
4
|
|
|
use DomainException; |
|
5
|
|
|
use EventEspresso\core\domain\CaffeinatedInterface; |
|
6
|
|
|
use EventEspresso\core\domain\DomainInterface; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* PluginUpsells |
|
10
|
|
|
* Handles injecting various marketing upsell things throughout the app. |
|
11
|
|
|
* |
|
12
|
|
|
* @package EventEspresso\core\domain\services\admin |
|
13
|
|
|
* @author Darren Ethier |
|
14
|
|
|
* @since $VID:$ |
|
15
|
|
|
*/ |
|
16
|
|
|
class PluginUpsells |
|
17
|
|
|
{ |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @var DomainInterface |
|
21
|
|
|
*/ |
|
22
|
|
|
private $domain; |
|
23
|
|
|
|
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* PluginUpsells constructor. |
|
27
|
|
|
* |
|
28
|
|
|
* @param DomainInterface $domain |
|
29
|
|
|
*/ |
|
30
|
|
|
public function __construct(DomainInterface $domain) |
|
31
|
|
|
{ |
|
32
|
|
|
$this->domain = $domain; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Hook in various upsells for the decaf version of EE. |
|
38
|
|
|
*/ |
|
39
|
|
|
public function decafUpsells() |
|
40
|
|
|
{ |
|
41
|
|
|
if ($this->domain instanceof CaffeinatedInterface && ! $this->domain->isCaffeinated()) { |
|
42
|
|
|
add_action('after_plugin_row', array($this, 'doPremiumUpsell'), 10, 3); |
|
43
|
|
|
} |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Callback for `after_plugin_row` to add upsell info |
|
49
|
|
|
* @param string $plugin_file |
|
50
|
|
|
* @param array $plugin_data |
|
51
|
|
|
* @param string $status |
|
52
|
|
|
* @throws DomainException |
|
53
|
|
|
*/ |
|
54
|
|
|
public function doPremiumUpsell($plugin_file, $plugin_data, $status) |
|
55
|
|
|
{ |
|
56
|
|
|
if ($plugin_file === $this->domain->pluginBasename()) { |
|
57
|
|
|
list($button_text, $button_url, $upsell_text) = $this->getAfterPluginRowDetails(); |
|
58
|
|
|
echo '<tr class="plugin-update-tr ee-upsell-plugin-list-table active"> |
|
59
|
|
|
<td colspan="3" class="plugin-update colspanchange"> |
|
60
|
|
|
<div class="notice inline notice-alt"> |
|
61
|
|
|
<div class="ee-upsell-container"> |
|
62
|
|
|
<div class="ee-upsell-inner-container"> |
|
63
|
|
|
<a href="' . $button_url . '"> |
|
64
|
|
|
' . $button_text . ' |
|
65
|
|
|
</a> |
|
66
|
|
|
</div> |
|
67
|
|
|
<div class="ee-upsell-inner-container"> |
|
68
|
|
|
<p>' . $upsell_text . '</p> |
|
69
|
|
|
</div> |
|
70
|
|
|
<div style="clear:both"></div> |
|
71
|
|
|
</div> |
|
72
|
|
|
</div> |
|
73
|
|
|
</td> |
|
74
|
|
|
</tr>'; |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* Provide the details used for the upsell container. |
|
80
|
|
|
* @return array |
|
81
|
|
|
*/ |
|
82
|
|
|
protected function getAfterPluginRowDetails() |
|
83
|
|
|
{ |
|
84
|
|
|
return array( |
|
85
|
|
|
esc_html__('Upgrade for Support', 'event_espresso'), |
|
86
|
|
|
'https://eventespresso.com/purchase/?slug=ee4-license-personal&utm_source=wp_admin_plugins_screen&utm_medium=link&utm_campaign=plugins_screen_upgrade_link" class="button button-primary', |
|
87
|
|
|
sprintf( |
|
88
|
|
|
esc_html__( |
|
89
|
|
|
'You\'re missing out on %1$sexpert support%2$s and %1$sone-click updates%2$s! Don\'t have an Event Espresso support license key? Support the project and buy one today!', |
|
90
|
|
|
'event_espresso' |
|
91
|
|
|
), |
|
92
|
|
|
'<strong>', |
|
93
|
|
|
'</strong>' |
|
94
|
|
|
) |
|
95
|
|
|
); |
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
|