Completed
Branch BUG-10626-dst-unit-test (8d5d80)
by
unknown
14:30
created

espresso.php ➔ bootstrap_espresso()   B

Complexity

Conditions 2
Paths 15

Size

Total Lines 26
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 20
nc 15
nop 0
dl 0
loc 26
rs 8.8571
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 your events from your WordPress dashboard. Reduce your admin, reduce your costs make your life easier! | <a href="admin.php?page=espresso_support&action=contact_support">Support</a>
6
  Version:			4.9.35.rc.017
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: 		    GPLv2
10
  Text Domain: 		event_espresso
11
  GitHub Plugin URI: https://github.com/eventespresso/event-espresso-core
12
  Copyright 		(c) 2008-2017 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 2 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, write to the Free Software
26
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27
 */
28
/**
29
 * Event Espresso
30
 * Event Registration and Management Plugin for WordPress
31
 *
32
 * @package          Event Espresso
33
 * @author           Seth Shoultes
34
 * @copyright    (c) 2008-2017 Event Espresso  All Rights Reserved.
35
 * @license          {@link http://eventespresso.com/support/terms-conditions/}
36
 * @see              Plugin Licensing
37
 * @link             {@link http://www.eventespresso.com}
38
 * @since            4.0
39
 */
40
if (function_exists('espresso_version')) {
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 echo esc_html__(
51
                        '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.',
52
                        'event_espresso'
53
                ); ?>
54
            </p>
55
        </div>
56
        <?php
57
        espresso_deactivate_plugin(plugin_basename(__FILE__));
58
    }
59
60
    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
61
} else {
62
    define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
63
    if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
64
        /**
65
         * espresso_minimum_php_version_error
66
         *
67
         * @return void
68
         */
69
        function espresso_minimum_php_version_error()
70
        {
71
            ?>
72
            <div class="error">
73
                <p>
74
                    <?php
75
                    printf(
76
                            esc_html__(
77
                                    '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.',
78
                                    'event_espresso'
79
                            ),
80
                            EE_MIN_PHP_VER_REQUIRED,
81
                            PHP_VERSION,
82
                            '<br/>',
83
                            '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
84
                    );
85
                    ?>
86
                </p>
87
            </div>
88
            <?php
89
            espresso_deactivate_plugin(plugin_basename(__FILE__));
90
        }
91
92
        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
93
94
    } else {
95
96
        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
98
        /**
99
         * espresso_version
100
         * Returns the plugin version
101
         *
102
         * @return string
103
         */
104
        function espresso_version()
105
        {
106
            return apply_filters('FHEE__espresso__espresso_version', '4.9.35.rc.017');
107
        }
108
109
        /**
110
         * espresso_plugin_activation
111
         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
112
         */
113
        function espresso_plugin_activation()
114
        {
115
            update_option('ee_espresso_activation', true);
116
        }
117
        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118
119
        /**
120
         *    espresso_load_error_handling
121
         *    this function loads EE's class for handling exceptions and errors
122
         */
123
        function espresso_load_error_handling()
124
        {
125
            static $error_handling_loaded = false;
126
            if ($error_handling_loaded) {
127
                return;
128
            }
129
            // load debugging tools
130
            if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
131
                require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
132
                \EEH_Debug_Tools::instance();
133
            }
134
            // load error handling
135
            if (is_readable(EE_CORE . 'EE_Error.core.php')) {
136
                require_once(EE_CORE . 'EE_Error.core.php');
137
            } else {
138
                wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
139
            }
140
            $error_handling_loaded = true;
141
        }
142
143
        /**
144
         *    espresso_load_required
145
         *    given a class name and path, this function will load that file or throw an exception
146
         *
147
         * @param    string $classname
148
         * @param    string $full_path_to_file
149
         * @throws    EE_Error
150
         */
151
        function espresso_load_required($classname, $full_path_to_file)
152
        {
153
            if (is_readable($full_path_to_file)) {
154
                require_once($full_path_to_file);
155
            } else {
156
                throw new \EE_Error (
157
                    sprintf(
158
                        esc_html__(
159
                            'The %s class file could not be located or is not readable due to file permissions.',
160
                            'event_espresso'
161
                        ),
162
                        $classname
163
                    )
164
                );
165
            }
166
        }
167
168
        /**
169
         * @since 4.9.27
170
         * @throws \EE_Error
171
         * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
172
         * @throws \EventEspresso\core\exceptions\InvalidEntityException
173
         * @throws \EventEspresso\core\exceptions\InvalidIdentifierException
174
         * @throws \EventEspresso\core\exceptions\InvalidClassException
175
         * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
176
         * @throws \EventEspresso\core\services\container\exceptions\ServiceExistsException
177
         * @throws \EventEspresso\core\services\container\exceptions\ServiceNotFoundException
178
         * @throws \OutOfBoundsException
179
         */
180
        function bootstrap_espresso()
181
        {
182
            try {
183
                require_once(plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE) . 'core/espresso_definitions.php');
184
                espresso_load_error_handling();
185
                espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php');
186
                espresso_load_required('EEH_File', EE_CORE . 'interfaces' . DS . 'EEHI_File.interface.php');
187
                espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php');
188
                espresso_load_required('EEH_Array', EE_CORE . 'helpers' . DS . 'EEH_Array.helper.php');
189
                // instantiate and configure PSR4 autoloader
190
                espresso_load_required('Psr4Autoloader', EE_CORE . 'Psr4Autoloader.php');
191
                espresso_load_required('EE_Psr4AutoloaderInit', EE_CORE . 'EE_Psr4AutoloaderInit.core.php');
192
                $AutoloaderInit = new \EE_Psr4AutoloaderInit();
193
                $AutoloaderInit->initializeAutoloader();
194
                espresso_load_required('EE_Request', EE_CORE . 'request_stack' . DS . 'EE_Request.core.php');
195
                espresso_load_required('EE_Response', EE_CORE . 'request_stack' . DS . 'EE_Response.core.php');
196
                espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
197
                // bootstrap EE and the request stack
198
                new EE_Bootstrap(
199
                    new EE_Request($_GET, $_POST, $_COOKIE),
200
                    new EE_Response()
201
                );
202
            } catch (Exception $e) {
203
                new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e);
204
            }
205
        }
206
207
        bootstrap_espresso();
208
209
    }
210
}
211
212
if ( ! function_exists('espresso_deactivate_plugin')) {
213
    /**
214
     *    deactivate_plugin
215
     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
216
     *
217
     * @access public
218
     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
219
     * @return    void
220
     */
221
    function espresso_deactivate_plugin($plugin_basename = '')
222
    {
223
        if ( ! function_exists('deactivate_plugins')) {
224
            require_once(ABSPATH . 'wp-admin/includes/plugin.php');
225
        }
226
        unset($_GET['activate'], $_REQUEST['activate']);
227
        deactivate_plugins($plugin_basename);
228
    }
229
}