Completed
Branch EDTR/master (903b91)
by
unknown
26:04 queued 17:28
created

PluginUpsells::getAfterPluginRowDetails()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 15
rs 9.7666
c 0
b 0
f 0
1
<?php
2
3
namespace EventEspresso\core\domain\services\admin;
4
5
use DomainException;
6
use EventEspresso\core\domain\CaffeinatedInterface;
7
use EventEspresso\core\domain\DomainInterface;
8
9
/**
10
 * PluginUpsells
11
 * Handles injecting various marketing upsell things throughout the app.
12
 *
13
 * @package EventEspresso\core\domain\services\admin
14
 * @author  Darren Ethier
15
 * @since   4.9.59.p
16
 */
17
class PluginUpsells
18
{
19
20
    /**
21
     * @var DomainInterface
22
     */
23
    private $domain;
24
25
26
    /**
27
     * PluginUpsells constructor.
28
     *
29
     * @param DomainInterface $domain
30
     */
31
    public function __construct(DomainInterface $domain)
32
    {
33
        $this->domain = $domain;
34
    }
35
36
37
    /**
38
     * Hook in various upsells for the decaf version of EE.
39
     */
40
    public function decafUpsells()
41
    {
42
        if ($this->domain instanceof CaffeinatedInterface && ! $this->domain->isCaffeinated()) {
43
            add_action('after_plugin_row', array($this, 'doPremiumUpsell'), 10);
44
        }
45
    }
46
47
48
    /**
49
     * Callback for `after_plugin_row` to add upsell info
50
     *
51
     * @param string $plugin_file
52
     * @throws DomainException
53
     */
54
    public function doPremiumUpsell($plugin_file)
55
    {
56
        if ($plugin_file === $this->domain->pluginBasename()) {
57
            echo '
58
    <tr class="ee-upsell-plugin-list-table active">
59
        <th scope="row" class="check-column"></th>
60
        <td class="column-primary">
61
            <div class="ee-upsell-col" style="padding:10px 0;">
62
                <a href="https://eventespresso.com/purchase/?slug=ee4-license-personal&utm_source=wp_admin_plugins_screen&utm_medium=link&utm_campaign=plugins_screen_upgrade_link"">
63
                    <button class="button button-secondary" style="background:#008dcb; border:1px solid #008dcb; color:#fff; ">'
64
                     . esc_html__('Upgrade for Support', 'event_espresso')
65
                     . '</button>
66
                </a>
67
            </div>                 
68
        </td>
69
        <td class="column-description"> 
70
            <div class="ee-upsell-col plugin-description" style="font-size: .85rem; line-height: 1.2rem; padding:5px 0;">'
71
                 . sprintf(
72
                     esc_html__(
73
                         'You\'re missing out on %1$sexpert support%2$s and %1$sone-click updates%2$s!%3$sDon\'t have an Event Espresso support license key? Support the project and buy one today!',
74
                         'event_espresso'
75
                     ),
76
                     '<strong>',
77
                     '</strong>',
78
                     '<br />'
79
                 ) .
80
            '</div>
81
        </td>
82
    </tr>
83
';
84
        }
85
    }
86
}
87