Completed
Branch EDTR/hover-focus-fix (1150b3)
by
unknown
34:00 queued 25:33
created

espresso.php ➔ espresso_plugin_deactivation()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
nc 3
nop 0
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
1
<?php defined('ABSPATH') || exit('No direct script access allowed');
2
/*
3
  Plugin Name:Event Espresso
4
  Plugin URI: http://eventespresso.com/pricing/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=wordpress_plugins_page&utm_content=support_link
5
  Description: Manage events, sell tickets, and receive payments from your WordPress website. Reduce event administration time, cut-out ticketing fees, and own your customer data. | <a href="https://eventespresso.com/add-ons/?utm_source=plugin_activation_screen&utm_medium=link&utm_campaign=plugin_description">Extensions</a> | <a href="https://eventespresso.com/pricing/?utm_source=plugin_activation_screen&utm_medium=link&utm_campaign=plugin_description">Sales</a> | <a href="admin.php?page=espresso_support">Support</a>
6
  Version: 4.10.5.rc.000
7
  Author: Event Espresso
8
  Author URI: http://eventespresso.com/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=wordpress_plugins_page&utm_content=support_link
9
  License: GPLv3
10
  Text Domain: event_espresso
11
  GitHub Plugin URI: https://github.com/eventespresso/event-espresso-core
12
  Copyright (c) 2008-2019 Event Espresso  All Rights Reserved.
13
14
    This program is free software: you can redistribute it and/or modify
15
    it under the terms of the GNU General Public License as published by
16
    the Free Software Foundation, either version 3 of the License, or
17
    (at your option) any later version.
18
19
    This program is distributed in the hope that it will be useful,
20
    but WITHOUT ANY WARRANTY; without even the implied warranty of
21
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
    GNU General Public License for more details.
23
24
    You should have received a copy of the GNU General Public License
25
    along with this program.  If not, see <https://www.gnu.org/licenses/>.
26
 */
27
/**
28
 * Event Espresso
29
 * Event Registration and Management Plugin for WordPress
30
 *
31
 * @package         Event Espresso
32
 * @author          Seth Shoultes
33
 * @copyright   (c) 2008-2018 Event Espresso  All Rights Reserved.
34
 * @license         {@link http://eventespresso.com/support/terms-conditions/}
35
 * @see             Plugin Licensing
36
 * @link            {@link http://www.eventespresso.com}
37
 * @since           4.0
38
 */
39
if (function_exists('espresso_version')) {
40
    if (! function_exists('espresso_duplicate_plugin_error')) {
41
        /**
42
         *    espresso_duplicate_plugin_error
43
         *    displays if more than one version of EE is activated at the same time
44
         */
45
        function espresso_duplicate_plugin_error()
46
        {
47
            ?>
48
            <div class="error">
49
                <p>
50
                    <?php
51
                    echo esc_html__(
52
                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
53
                        'event_espresso'
54
                    ); ?>
55
                </p>
56
            </div>
57
            <?php
58
            espresso_deactivate_plugin(plugin_basename(__FILE__));
59
        }
60
    }
61
    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
62
} else {
63
    define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
64
    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
65
        /**
66
         * espresso_minimum_php_version_error
67
         *
68
         * @return void
69
         */
70
        function espresso_minimum_php_version_error()
71
        {
72
            ?>
73
            <div class="error">
74
                <p>
75
                    <?php
76
                    printf(
77
                        esc_html__(
78
                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
79
                            'event_espresso'
80
                        ),
81
                        EE_MIN_PHP_VER_REQUIRED,
82
                        PHP_VERSION,
83
                        '<br/>',
84
                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
85
                    );
86
                    ?>
87
                </p>
88
            </div>
89
            <?php
90
            espresso_deactivate_plugin(plugin_basename(__FILE__));
91
        }
92
93
        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
94
    } else {
95
        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
96
        /**
97
         * espresso_version
98
         * Returns the plugin version
99
         *
100
         * @return string
101
         */
102
        function espresso_version()
103
        {
104
            return apply_filters('FHEE__espresso__espresso_version', '4.10.5.rc.000');
105
        }
106
107
        /**
108
         * espresso_plugin_activation
109
         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
110
         */
111
        function espresso_plugin_activation()
112
        {
113
            update_option('ee_espresso_activation', true);
114
115
            // Run WP GraphQL activation callback
116
            if (PHP_VERSION_ID < 70000) {
117
                return;
118
            }
119
            if (! class_exists('WPGraphQL')) {
120
                require_once EE_THIRD_PARTY . 'wp-graphql/wp-graphql.php';
121
            }
122
            graphql_init()->activate();
123
        }
124
125
        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
126
127
        /**
128
         * espresso_plugin_deactivation
129
         */
130
        function espresso_plugin_deactivation()
131
        {
132
            // Run WP GraphQL deactivation callback
133
            if (PHP_VERSION_ID < 70000) {
134
                return;
135
            }
136
            if (! class_exists('WPGraphQL')) {
137
                require_once EE_THIRD_PARTY . 'wp-graphql/wp-graphql.php';
138
            }
139
            graphql_init()->deactivate();
140
        }
141
        register_deactivation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation');
142
143
        require_once __DIR__ . '/core/bootstrap_espresso.php';
144
        bootstrap_espresso();
145
    }
146
}
147
if (! function_exists('espresso_deactivate_plugin')) {
148
    /**
149
     *    deactivate_plugin
150
     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
151
     *
152
     * @access public
153
     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
154
     * @return    void
155
     */
156
    function espresso_deactivate_plugin($plugin_basename = '')
157
    {
158
        if (! function_exists('deactivate_plugins')) {
159
            require_once ABSPATH . 'wp-admin/includes/plugin.php';
160
        }
161
        unset($_GET['activate'], $_REQUEST['activate']);
162
        deactivate_plugins($plugin_basename);
163
    }
164
}
165