@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('ABSPATH')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /* |
5 | 5 | Plugin Name: Event Espresso |
@@ -40,243 +40,243 @@ discard block |
||
40 | 40 | * @since 4.0 |
41 | 41 | */ |
42 | 42 | if (function_exists('espresso_version')) { |
43 | - /** |
|
44 | - * espresso_duplicate_plugin_error |
|
45 | - * displays if more than one version of EE is activated at the same time |
|
46 | - */ |
|
47 | - function espresso_duplicate_plugin_error() |
|
48 | - { |
|
49 | - ?> |
|
43 | + /** |
|
44 | + * espresso_duplicate_plugin_error |
|
45 | + * displays if more than one version of EE is activated at the same time |
|
46 | + */ |
|
47 | + function espresso_duplicate_plugin_error() |
|
48 | + { |
|
49 | + ?> |
|
50 | 50 | <div class="error"> |
51 | 51 | <p> |
52 | 52 | <?php echo esc_html__( |
53 | - '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.', |
|
54 | - 'event_espresso' |
|
55 | - ); ?> |
|
53 | + '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.', |
|
54 | + 'event_espresso' |
|
55 | + ); ?> |
|
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | - } |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | + } |
|
61 | 61 | |
62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
63 | 63 | } else { |
64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
65 | - if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | - /** |
|
67 | - * espresso_minimum_php_version_error |
|
68 | - * |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - function espresso_minimum_php_version_error() |
|
72 | - { |
|
73 | - ?> |
|
64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
65 | + if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | + /** |
|
67 | + * espresso_minimum_php_version_error |
|
68 | + * |
|
69 | + * @return void |
|
70 | + */ |
|
71 | + function espresso_minimum_php_version_error() |
|
72 | + { |
|
73 | + ?> |
|
74 | 74 | <div class="error"> |
75 | 75 | <p> |
76 | 76 | <?php |
77 | - printf( |
|
78 | - esc_html__( |
|
79 | - '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.', |
|
80 | - 'event_espresso' |
|
81 | - ), |
|
82 | - EE_MIN_PHP_VER_REQUIRED, |
|
83 | - PHP_VERSION, |
|
84 | - '<br/>', |
|
85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | - ); |
|
87 | - ?> |
|
77 | + printf( |
|
78 | + esc_html__( |
|
79 | + '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.', |
|
80 | + 'event_espresso' |
|
81 | + ), |
|
82 | + EE_MIN_PHP_VER_REQUIRED, |
|
83 | + PHP_VERSION, |
|
84 | + '<br/>', |
|
85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | + ); |
|
87 | + ?> |
|
88 | 88 | </p> |
89 | 89 | </div> |
90 | 90 | <?php |
91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | - } |
|
91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | + } |
|
93 | 93 | |
94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | - } else { |
|
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.9.44.rc.018'); |
|
105 | - } |
|
94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | + } else { |
|
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.9.44.rc.018'); |
|
105 | + } |
|
106 | 106 | |
107 | - // define versions |
|
108 | - define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
109 | - define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
110 | - define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
111 | - define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
112 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
113 | - //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
|
114 | - if ( ! defined('DS')) { |
|
115 | - define('DS', '/'); |
|
116 | - } |
|
117 | - if ( ! defined('PS')) { |
|
118 | - define('PS', PATH_SEPARATOR); |
|
119 | - } |
|
120 | - if ( ! defined('SP')) { |
|
121 | - define('SP', ' '); |
|
122 | - } |
|
123 | - if ( ! defined('EENL')) { |
|
124 | - define('EENL', "\n"); |
|
125 | - } |
|
126 | - define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
127 | - // define the plugin directory and URL |
|
128 | - define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
129 | - define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
130 | - define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
131 | - // main root folder paths |
|
132 | - define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS); |
|
133 | - define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS); |
|
134 | - define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS); |
|
135 | - define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS); |
|
136 | - define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS); |
|
137 | - define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS); |
|
138 | - define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS); |
|
139 | - define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS); |
|
140 | - // core system paths |
|
141 | - define('EE_ADMIN', EE_CORE . 'admin' . DS); |
|
142 | - define('EE_CPTS', EE_CORE . 'CPTs' . DS); |
|
143 | - define('EE_CLASSES', EE_CORE . 'db_classes' . DS); |
|
144 | - define('EE_INTERFACES', EE_CORE . 'interfaces' . DS); |
|
145 | - define('EE_BUSINESS', EE_CORE . 'business' . DS); |
|
146 | - define('EE_MODELS', EE_CORE . 'db_models' . DS); |
|
147 | - define('EE_HELPERS', EE_CORE . 'helpers' . DS); |
|
148 | - define('EE_LIBRARIES', EE_CORE . 'libraries' . DS); |
|
149 | - define('EE_TEMPLATES', EE_CORE . 'templates' . DS); |
|
150 | - define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS); |
|
151 | - define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS); |
|
152 | - define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS); |
|
153 | - // gateways |
|
154 | - define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS); |
|
155 | - define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS); |
|
156 | - // asset URL paths |
|
157 | - define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS); |
|
158 | - define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS); |
|
159 | - define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS); |
|
160 | - define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS); |
|
161 | - define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/'); |
|
162 | - define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/'); |
|
163 | - // define upload paths |
|
164 | - $uploads = wp_upload_dir(); |
|
165 | - // define the uploads directory and URL |
|
166 | - define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS); |
|
167 | - define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS); |
|
168 | - // define the templates directory and URL |
|
169 | - define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS); |
|
170 | - define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS); |
|
171 | - // define the gateway directory and URL |
|
172 | - define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
173 | - define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
174 | - // languages folder/path |
|
175 | - define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS); |
|
176 | - define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); |
|
177 | - //check for dompdf fonts in uploads |
|
178 | - if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { |
|
179 | - define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); |
|
180 | - } |
|
181 | - //ajax constants |
|
182 | - define( |
|
183 | - 'EE_FRONT_AJAX', |
|
184 | - isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false |
|
185 | - ); |
|
186 | - define( |
|
187 | - 'EE_ADMIN_AJAX', |
|
188 | - isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false |
|
189 | - ); |
|
190 | - //just a handy constant occasionally needed for finding values representing infinity in the DB |
|
191 | - //you're better to use this than its straight value (currently -1) in case you ever |
|
192 | - //want to change its default value! or find when -1 means infinity |
|
193 | - define('EE_INF_IN_DB', -1); |
|
194 | - define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
195 | - define('EE_DEBUG', false); |
|
196 | - // for older WP versions |
|
197 | - if ( ! defined('MONTH_IN_SECONDS')) { |
|
198 | - define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30); |
|
199 | - } |
|
200 | - /** |
|
201 | - * espresso_plugin_activation |
|
202 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
203 | - */ |
|
204 | - function espresso_plugin_activation() |
|
205 | - { |
|
206 | - update_option('ee_espresso_activation', true); |
|
207 | - } |
|
107 | + // define versions |
|
108 | + define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
109 | + define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
110 | + define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
111 | + define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
112 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
113 | + //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
|
114 | + if ( ! defined('DS')) { |
|
115 | + define('DS', '/'); |
|
116 | + } |
|
117 | + if ( ! defined('PS')) { |
|
118 | + define('PS', PATH_SEPARATOR); |
|
119 | + } |
|
120 | + if ( ! defined('SP')) { |
|
121 | + define('SP', ' '); |
|
122 | + } |
|
123 | + if ( ! defined('EENL')) { |
|
124 | + define('EENL', "\n"); |
|
125 | + } |
|
126 | + define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
127 | + // define the plugin directory and URL |
|
128 | + define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
129 | + define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
130 | + define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
131 | + // main root folder paths |
|
132 | + define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS); |
|
133 | + define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS); |
|
134 | + define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS); |
|
135 | + define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS); |
|
136 | + define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS); |
|
137 | + define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS); |
|
138 | + define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS); |
|
139 | + define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS); |
|
140 | + // core system paths |
|
141 | + define('EE_ADMIN', EE_CORE . 'admin' . DS); |
|
142 | + define('EE_CPTS', EE_CORE . 'CPTs' . DS); |
|
143 | + define('EE_CLASSES', EE_CORE . 'db_classes' . DS); |
|
144 | + define('EE_INTERFACES', EE_CORE . 'interfaces' . DS); |
|
145 | + define('EE_BUSINESS', EE_CORE . 'business' . DS); |
|
146 | + define('EE_MODELS', EE_CORE . 'db_models' . DS); |
|
147 | + define('EE_HELPERS', EE_CORE . 'helpers' . DS); |
|
148 | + define('EE_LIBRARIES', EE_CORE . 'libraries' . DS); |
|
149 | + define('EE_TEMPLATES', EE_CORE . 'templates' . DS); |
|
150 | + define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS); |
|
151 | + define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS); |
|
152 | + define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS); |
|
153 | + // gateways |
|
154 | + define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS); |
|
155 | + define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS); |
|
156 | + // asset URL paths |
|
157 | + define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS); |
|
158 | + define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS); |
|
159 | + define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS); |
|
160 | + define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS); |
|
161 | + define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/'); |
|
162 | + define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/'); |
|
163 | + // define upload paths |
|
164 | + $uploads = wp_upload_dir(); |
|
165 | + // define the uploads directory and URL |
|
166 | + define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS); |
|
167 | + define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS); |
|
168 | + // define the templates directory and URL |
|
169 | + define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS); |
|
170 | + define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS); |
|
171 | + // define the gateway directory and URL |
|
172 | + define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
173 | + define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
174 | + // languages folder/path |
|
175 | + define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS); |
|
176 | + define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); |
|
177 | + //check for dompdf fonts in uploads |
|
178 | + if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { |
|
179 | + define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); |
|
180 | + } |
|
181 | + //ajax constants |
|
182 | + define( |
|
183 | + 'EE_FRONT_AJAX', |
|
184 | + isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false |
|
185 | + ); |
|
186 | + define( |
|
187 | + 'EE_ADMIN_AJAX', |
|
188 | + isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false |
|
189 | + ); |
|
190 | + //just a handy constant occasionally needed for finding values representing infinity in the DB |
|
191 | + //you're better to use this than its straight value (currently -1) in case you ever |
|
192 | + //want to change its default value! or find when -1 means infinity |
|
193 | + define('EE_INF_IN_DB', -1); |
|
194 | + define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
195 | + define('EE_DEBUG', false); |
|
196 | + // for older WP versions |
|
197 | + if ( ! defined('MONTH_IN_SECONDS')) { |
|
198 | + define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30); |
|
199 | + } |
|
200 | + /** |
|
201 | + * espresso_plugin_activation |
|
202 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
203 | + */ |
|
204 | + function espresso_plugin_activation() |
|
205 | + { |
|
206 | + update_option('ee_espresso_activation', true); |
|
207 | + } |
|
208 | 208 | |
209 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
210 | - /** |
|
211 | - * espresso_load_error_handling |
|
212 | - * this function loads EE's class for handling exceptions and errors |
|
213 | - */ |
|
214 | - function espresso_load_error_handling() |
|
215 | - { |
|
216 | - // load debugging tools |
|
217 | - if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
218 | - require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php'); |
|
219 | - EEH_Debug_Tools::instance(); |
|
220 | - } |
|
221 | - // load error handling |
|
222 | - if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
223 | - require_once(EE_CORE . 'EE_Error.core.php'); |
|
224 | - } else { |
|
225 | - wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
226 | - } |
|
227 | - } |
|
209 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
210 | + /** |
|
211 | + * espresso_load_error_handling |
|
212 | + * this function loads EE's class for handling exceptions and errors |
|
213 | + */ |
|
214 | + function espresso_load_error_handling() |
|
215 | + { |
|
216 | + // load debugging tools |
|
217 | + if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
218 | + require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php'); |
|
219 | + EEH_Debug_Tools::instance(); |
|
220 | + } |
|
221 | + // load error handling |
|
222 | + if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
223 | + require_once(EE_CORE . 'EE_Error.core.php'); |
|
224 | + } else { |
|
225 | + wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
226 | + } |
|
227 | + } |
|
228 | 228 | |
229 | - /** |
|
230 | - * espresso_load_required |
|
231 | - * given a class name and path, this function will load that file or throw an exception |
|
232 | - * |
|
233 | - * @param string $classname |
|
234 | - * @param string $full_path_to_file |
|
235 | - * @throws EE_Error |
|
236 | - */ |
|
237 | - function espresso_load_required($classname, $full_path_to_file) |
|
238 | - { |
|
239 | - static $error_handling_loaded = false; |
|
240 | - if ( ! $error_handling_loaded) { |
|
241 | - espresso_load_error_handling(); |
|
242 | - $error_handling_loaded = true; |
|
243 | - } |
|
244 | - if (is_readable($full_path_to_file)) { |
|
245 | - require_once($full_path_to_file); |
|
246 | - } else { |
|
247 | - throw new EE_Error ( |
|
248 | - sprintf( |
|
249 | - esc_html__( |
|
250 | - 'The %s class file could not be located or is not readable due to file permissions.', |
|
251 | - 'event_espresso' |
|
252 | - ), |
|
253 | - $classname |
|
254 | - ) |
|
255 | - ); |
|
256 | - } |
|
257 | - } |
|
229 | + /** |
|
230 | + * espresso_load_required |
|
231 | + * given a class name and path, this function will load that file or throw an exception |
|
232 | + * |
|
233 | + * @param string $classname |
|
234 | + * @param string $full_path_to_file |
|
235 | + * @throws EE_Error |
|
236 | + */ |
|
237 | + function espresso_load_required($classname, $full_path_to_file) |
|
238 | + { |
|
239 | + static $error_handling_loaded = false; |
|
240 | + if ( ! $error_handling_loaded) { |
|
241 | + espresso_load_error_handling(); |
|
242 | + $error_handling_loaded = true; |
|
243 | + } |
|
244 | + if (is_readable($full_path_to_file)) { |
|
245 | + require_once($full_path_to_file); |
|
246 | + } else { |
|
247 | + throw new EE_Error ( |
|
248 | + sprintf( |
|
249 | + esc_html__( |
|
250 | + 'The %s class file could not be located or is not readable due to file permissions.', |
|
251 | + 'event_espresso' |
|
252 | + ), |
|
253 | + $classname |
|
254 | + ) |
|
255 | + ); |
|
256 | + } |
|
257 | + } |
|
258 | 258 | |
259 | - espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); |
|
260 | - espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); |
|
261 | - espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); |
|
262 | - new EE_Bootstrap(); |
|
263 | - } |
|
259 | + espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); |
|
260 | + espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); |
|
261 | + espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); |
|
262 | + new EE_Bootstrap(); |
|
263 | + } |
|
264 | 264 | } |
265 | 265 | if ( ! function_exists('espresso_deactivate_plugin')) { |
266 | - /** |
|
267 | - * deactivate_plugin |
|
268 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
269 | - * |
|
270 | - * @access public |
|
271 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
272 | - * @return void |
|
273 | - */ |
|
274 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
275 | - { |
|
276 | - if ( ! function_exists('deactivate_plugins')) { |
|
277 | - require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
278 | - } |
|
279 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
280 | - deactivate_plugins($plugin_basename); |
|
281 | - } |
|
266 | + /** |
|
267 | + * deactivate_plugin |
|
268 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
269 | + * |
|
270 | + * @access public |
|
271 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
272 | + * @return void |
|
273 | + */ |
|
274 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
275 | + { |
|
276 | + if ( ! function_exists('deactivate_plugins')) { |
|
277 | + require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
278 | + } |
|
279 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
280 | + deactivate_plugins($plugin_basename); |
|
281 | + } |
|
282 | 282 | } |
283 | 283 | \ No newline at end of file |
@@ -14,362 +14,362 @@ |
||
14 | 14 | class EE_Maintenance_Mode |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * constants available to client code for interpreting the values of EE_Maintenance_Mode::level(). |
|
19 | - * level_0_not_in_maintenance means the site is NOT in maintenance mode (so everything's normal) |
|
20 | - */ |
|
21 | - const level_0_not_in_maintenance = 0; |
|
22 | - |
|
23 | - /** |
|
24 | - * level_1_frontend_only_maintenance means that the site's frontend EE code should be completely disabled |
|
25 | - * but the admin backend should be running as normal. Maybe an admin can view the frontend though |
|
26 | - */ |
|
27 | - const level_1_frontend_only_maintenance = 1; |
|
28 | - |
|
29 | - /** |
|
30 | - * level_2_complete_maintenance means the frontend AND EE backend code are disabled. The only system running |
|
31 | - * is the maintenance mode stuff, which will require users to update all addons, and then finish running all |
|
32 | - * migration scripts before taking the site out of maintenance mode |
|
33 | - */ |
|
34 | - const level_2_complete_maintenance = 2; |
|
35 | - |
|
36 | - /** |
|
37 | - * the name of the option which stores the current level of maintenance mode |
|
38 | - */ |
|
39 | - const option_name_maintenance_mode = 'ee_maintenance_mode'; |
|
40 | - |
|
41 | - |
|
42 | - /** |
|
43 | - * @var EE_Maintenance_Mode $_instance |
|
44 | - */ |
|
45 | - private static $_instance; |
|
46 | - |
|
47 | - /** |
|
48 | - * @var EE_Registry $EE |
|
49 | - */ |
|
50 | - protected $EE; |
|
51 | - |
|
52 | - |
|
53 | - |
|
54 | - /** |
|
55 | - * @singleton method used to instantiate class object |
|
56 | - * @return EE_Maintenance_Mode |
|
57 | - */ |
|
58 | - public static function instance() |
|
59 | - { |
|
60 | - // check if class object is instantiated |
|
61 | - if (! self::$_instance instanceof EE_Maintenance_Mode) { |
|
62 | - self::$_instance = new self(); |
|
63 | - } |
|
64 | - return self::$_instance; |
|
65 | - } |
|
66 | - |
|
67 | - |
|
68 | - |
|
69 | - /** |
|
70 | - * Resets maintenance mode (mostly just re-checks whether or not we should be in maintenance mode) |
|
71 | - * |
|
72 | - * @return EE_Maintenance_Mode |
|
73 | - */ |
|
74 | - public static function reset() |
|
75 | - { |
|
76 | - self::instance()->set_maintenance_mode_if_db_old(); |
|
77 | - return self::instance(); |
|
78 | - } |
|
79 | - |
|
80 | - |
|
81 | - |
|
82 | - /** |
|
83 | - *private constructor to prevent direct creation |
|
84 | - */ |
|
85 | - private function __construct() |
|
86 | - { |
|
87 | - // if M-Mode level 2 is engaged, we still need basic assets loaded |
|
88 | - add_action('wp_enqueue_scripts', array($this, 'load_assets_required_for_m_mode')); |
|
89 | - // shut 'er down down for maintenance ? |
|
90 | - add_filter('the_content', array($this, 'the_content'), 2); |
|
91 | - // add powered by EE msg |
|
92 | - add_action('shutdown', array($this, 'display_maintenance_mode_notice'), 10); |
|
93 | - } |
|
94 | - |
|
95 | - |
|
96 | - |
|
97 | - /** |
|
98 | - * retrieves the maintenance mode option value from the db |
|
99 | - * |
|
100 | - * @return int |
|
101 | - */ |
|
102 | - public function real_level() |
|
103 | - { |
|
104 | - return get_option(self::option_name_maintenance_mode, EE_Maintenance_Mode::level_0_not_in_maintenance); |
|
105 | - } |
|
106 | - |
|
107 | - |
|
108 | - |
|
109 | - /** |
|
110 | - * Returns whether or not the models reportedly are able to run queries or not |
|
111 | - * (ie, if the system thinks their tables are present and up-to-date). |
|
112 | - * |
|
113 | - * @return boolean |
|
114 | - */ |
|
115 | - public function models_can_query() |
|
116 | - { |
|
117 | - return $this->real_level() !== EE_Maintenance_Mode::level_2_complete_maintenance; |
|
118 | - } |
|
119 | - |
|
120 | - |
|
121 | - |
|
122 | - /** |
|
123 | - * Determines whether or not we're in maintenance mode and what level. However, while the site |
|
124 | - * is in level 1 maintenance, and an admin visits the frontend, this function makes it appear |
|
125 | - * to them as if teh site isn't in maintenance mode. |
|
126 | - * EE_Maintenance_Mode::level_0_not_in_maintenance => not in maintenance mode (in normal mode) |
|
127 | - * EE_Maintenance_Mode::level_1_frontend_only_maintenance=> frontend-only maintenance mode |
|
128 | - * EE_Maintenance_Mode::level_2_complete_maintenance => frontend and backend maintenance mode |
|
129 | - * |
|
130 | - * @return int |
|
131 | - */ |
|
132 | - public function level() |
|
133 | - { |
|
134 | - $maintenance_mode_level = $this->real_level(); |
|
135 | - // if this is an admin request, we'll be honest... except if it's ajax, because that might be from the frontend |
|
136 | - if ( |
|
137 | - $maintenance_mode_level === EE_Maintenance_Mode::level_1_frontend_only_maintenance// we're in level 1 |
|
138 | - && ((defined('DOING_AJAX') && DOING_AJAX) || ! is_admin()) // on non-ajax frontend requests |
|
139 | - && current_user_can('administrator') // when the user is an admin |
|
140 | - ) { |
|
141 | - $maintenance_mode_level = EE_Maintenance_Mode::level_0_not_in_maintenance; |
|
142 | - } |
|
143 | - return $maintenance_mode_level; |
|
144 | - } |
|
145 | - |
|
146 | - |
|
147 | - |
|
148 | - /** |
|
149 | - * Determines if we need to put EE in maintenance mode because the database needs updating |
|
150 | - * |
|
151 | - * @return boolean true if DB is old and maintenance mode was triggered; false otherwise |
|
152 | - */ |
|
153 | - public function set_maintenance_mode_if_db_old() |
|
154 | - { |
|
155 | - EE_Registry::instance()->load_core('Data_Migration_Manager'); |
|
156 | - if (EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()) { |
|
157 | - update_option(self::option_name_maintenance_mode, self::level_2_complete_maintenance); |
|
158 | - return true; |
|
159 | - } |
|
160 | - if ($this->level() === self::level_2_complete_maintenance) { |
|
161 | - //we also want to handle the opposite: if the site is mm2, but there aren't any migrations to run |
|
162 | - //then we shouldn't be in mm2. (Maybe an addon got deactivated?) |
|
163 | - update_option(self::option_name_maintenance_mode, self::level_0_not_in_maintenance); |
|
164 | - return false; |
|
165 | - } |
|
166 | - return false; |
|
167 | - } |
|
168 | - |
|
169 | - |
|
170 | - |
|
171 | - /** |
|
172 | - * Updates the maintenance level on the site |
|
173 | - * |
|
174 | - * @param int $level |
|
175 | - * @return void |
|
176 | - */ |
|
177 | - public function set_maintenance_level($level) |
|
178 | - { |
|
179 | - do_action('AHEE__EE_Maintenance_Mode__set_maintenance_level', $level); |
|
180 | - update_option(self::option_name_maintenance_mode, (int)$level); |
|
181 | - } |
|
182 | - |
|
183 | - |
|
184 | - |
|
185 | - /** |
|
186 | - * returns TRUE if M-Mode is engaged and the current request is not for the admin |
|
187 | - * |
|
188 | - * @return string |
|
189 | - */ |
|
190 | - public static function disable_frontend_for_maintenance() |
|
191 | - { |
|
192 | - return (! is_admin() && EE_Maintenance_Mode::instance()->level()); |
|
193 | - } |
|
194 | - |
|
195 | - |
|
196 | - |
|
197 | - /** |
|
198 | - * @return void |
|
199 | - */ |
|
200 | - public function load_assets_required_for_m_mode() |
|
201 | - { |
|
202 | - if ( |
|
203 | - $this->real_level() === EE_Maintenance_Mode::level_2_complete_maintenance |
|
204 | - && ! wp_script_is('espresso_core') |
|
205 | - ) { |
|
206 | - wp_register_style( |
|
207 | - 'espresso_default', |
|
208 | - EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
209 | - array('dashicons'), |
|
210 | - EVENT_ESPRESSO_VERSION |
|
211 | - ); |
|
212 | - wp_enqueue_style('espresso_default'); |
|
213 | - wp_register_script( |
|
214 | - 'espresso_core', |
|
215 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
216 | - array('jquery'), |
|
217 | - EVENT_ESPRESSO_VERSION, |
|
218 | - true |
|
219 | - ); |
|
220 | - wp_enqueue_script('espresso_core'); |
|
221 | - } |
|
222 | - } |
|
223 | - |
|
224 | - |
|
225 | - |
|
226 | - /** |
|
227 | - * replacement EE CPT template that displays message notifying site visitors |
|
228 | - * that EE has been temporarily placed into maintenance mode |
|
229 | - * does NOT get called on non-EE-CPT requests |
|
230 | - * |
|
231 | - * @return string |
|
232 | - */ |
|
233 | - public static function template_include() |
|
234 | - { |
|
235 | - // shut 'er down down for maintenance ? then don't use any of our templates for our endpoints |
|
236 | - return get_template_directory() . '/index.php'; |
|
237 | - } |
|
238 | - |
|
239 | - |
|
240 | - |
|
241 | - /** |
|
242 | - * displays message notifying site visitors that EE has been temporarily |
|
243 | - * placed into maintenance mode when post_type != EE CPT |
|
244 | - * |
|
245 | - * @param string $the_content |
|
246 | - * @return string |
|
247 | - */ |
|
248 | - public function the_content($the_content) |
|
249 | - { |
|
250 | - // check if M-mode is engaged and for EE shortcode |
|
251 | - if ($this->level() && strpos($the_content, '[ESPRESSO_') !== false) { |
|
252 | - // this can eventually be moved to a template, or edited via admin. But for now... |
|
253 | - $the_content = sprintf( |
|
254 | - esc_html__( |
|
255 | - '%sMaintenance Mode%sEvent Registration has been temporarily closed while system maintenance is being performed. We\'re sorry for any inconveniences this may have caused. Please try back again later.%s', |
|
256 | - 'event_espresso' |
|
257 | - ), |
|
258 | - '<h3>', |
|
259 | - '</h3><p>', |
|
260 | - '</p>' |
|
261 | - ); |
|
262 | - } |
|
263 | - return $the_content; |
|
264 | - } |
|
17 | + /** |
|
18 | + * constants available to client code for interpreting the values of EE_Maintenance_Mode::level(). |
|
19 | + * level_0_not_in_maintenance means the site is NOT in maintenance mode (so everything's normal) |
|
20 | + */ |
|
21 | + const level_0_not_in_maintenance = 0; |
|
22 | + |
|
23 | + /** |
|
24 | + * level_1_frontend_only_maintenance means that the site's frontend EE code should be completely disabled |
|
25 | + * but the admin backend should be running as normal. Maybe an admin can view the frontend though |
|
26 | + */ |
|
27 | + const level_1_frontend_only_maintenance = 1; |
|
28 | + |
|
29 | + /** |
|
30 | + * level_2_complete_maintenance means the frontend AND EE backend code are disabled. The only system running |
|
31 | + * is the maintenance mode stuff, which will require users to update all addons, and then finish running all |
|
32 | + * migration scripts before taking the site out of maintenance mode |
|
33 | + */ |
|
34 | + const level_2_complete_maintenance = 2; |
|
35 | + |
|
36 | + /** |
|
37 | + * the name of the option which stores the current level of maintenance mode |
|
38 | + */ |
|
39 | + const option_name_maintenance_mode = 'ee_maintenance_mode'; |
|
40 | + |
|
41 | + |
|
42 | + /** |
|
43 | + * @var EE_Maintenance_Mode $_instance |
|
44 | + */ |
|
45 | + private static $_instance; |
|
46 | + |
|
47 | + /** |
|
48 | + * @var EE_Registry $EE |
|
49 | + */ |
|
50 | + protected $EE; |
|
51 | + |
|
52 | + |
|
53 | + |
|
54 | + /** |
|
55 | + * @singleton method used to instantiate class object |
|
56 | + * @return EE_Maintenance_Mode |
|
57 | + */ |
|
58 | + public static function instance() |
|
59 | + { |
|
60 | + // check if class object is instantiated |
|
61 | + if (! self::$_instance instanceof EE_Maintenance_Mode) { |
|
62 | + self::$_instance = new self(); |
|
63 | + } |
|
64 | + return self::$_instance; |
|
65 | + } |
|
66 | + |
|
67 | + |
|
68 | + |
|
69 | + /** |
|
70 | + * Resets maintenance mode (mostly just re-checks whether or not we should be in maintenance mode) |
|
71 | + * |
|
72 | + * @return EE_Maintenance_Mode |
|
73 | + */ |
|
74 | + public static function reset() |
|
75 | + { |
|
76 | + self::instance()->set_maintenance_mode_if_db_old(); |
|
77 | + return self::instance(); |
|
78 | + } |
|
79 | + |
|
80 | + |
|
81 | + |
|
82 | + /** |
|
83 | + *private constructor to prevent direct creation |
|
84 | + */ |
|
85 | + private function __construct() |
|
86 | + { |
|
87 | + // if M-Mode level 2 is engaged, we still need basic assets loaded |
|
88 | + add_action('wp_enqueue_scripts', array($this, 'load_assets_required_for_m_mode')); |
|
89 | + // shut 'er down down for maintenance ? |
|
90 | + add_filter('the_content', array($this, 'the_content'), 2); |
|
91 | + // add powered by EE msg |
|
92 | + add_action('shutdown', array($this, 'display_maintenance_mode_notice'), 10); |
|
93 | + } |
|
94 | + |
|
95 | + |
|
96 | + |
|
97 | + /** |
|
98 | + * retrieves the maintenance mode option value from the db |
|
99 | + * |
|
100 | + * @return int |
|
101 | + */ |
|
102 | + public function real_level() |
|
103 | + { |
|
104 | + return get_option(self::option_name_maintenance_mode, EE_Maintenance_Mode::level_0_not_in_maintenance); |
|
105 | + } |
|
106 | + |
|
107 | + |
|
108 | + |
|
109 | + /** |
|
110 | + * Returns whether or not the models reportedly are able to run queries or not |
|
111 | + * (ie, if the system thinks their tables are present and up-to-date). |
|
112 | + * |
|
113 | + * @return boolean |
|
114 | + */ |
|
115 | + public function models_can_query() |
|
116 | + { |
|
117 | + return $this->real_level() !== EE_Maintenance_Mode::level_2_complete_maintenance; |
|
118 | + } |
|
119 | + |
|
120 | + |
|
121 | + |
|
122 | + /** |
|
123 | + * Determines whether or not we're in maintenance mode and what level. However, while the site |
|
124 | + * is in level 1 maintenance, and an admin visits the frontend, this function makes it appear |
|
125 | + * to them as if teh site isn't in maintenance mode. |
|
126 | + * EE_Maintenance_Mode::level_0_not_in_maintenance => not in maintenance mode (in normal mode) |
|
127 | + * EE_Maintenance_Mode::level_1_frontend_only_maintenance=> frontend-only maintenance mode |
|
128 | + * EE_Maintenance_Mode::level_2_complete_maintenance => frontend and backend maintenance mode |
|
129 | + * |
|
130 | + * @return int |
|
131 | + */ |
|
132 | + public function level() |
|
133 | + { |
|
134 | + $maintenance_mode_level = $this->real_level(); |
|
135 | + // if this is an admin request, we'll be honest... except if it's ajax, because that might be from the frontend |
|
136 | + if ( |
|
137 | + $maintenance_mode_level === EE_Maintenance_Mode::level_1_frontend_only_maintenance// we're in level 1 |
|
138 | + && ((defined('DOING_AJAX') && DOING_AJAX) || ! is_admin()) // on non-ajax frontend requests |
|
139 | + && current_user_can('administrator') // when the user is an admin |
|
140 | + ) { |
|
141 | + $maintenance_mode_level = EE_Maintenance_Mode::level_0_not_in_maintenance; |
|
142 | + } |
|
143 | + return $maintenance_mode_level; |
|
144 | + } |
|
145 | + |
|
146 | + |
|
147 | + |
|
148 | + /** |
|
149 | + * Determines if we need to put EE in maintenance mode because the database needs updating |
|
150 | + * |
|
151 | + * @return boolean true if DB is old and maintenance mode was triggered; false otherwise |
|
152 | + */ |
|
153 | + public function set_maintenance_mode_if_db_old() |
|
154 | + { |
|
155 | + EE_Registry::instance()->load_core('Data_Migration_Manager'); |
|
156 | + if (EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()) { |
|
157 | + update_option(self::option_name_maintenance_mode, self::level_2_complete_maintenance); |
|
158 | + return true; |
|
159 | + } |
|
160 | + if ($this->level() === self::level_2_complete_maintenance) { |
|
161 | + //we also want to handle the opposite: if the site is mm2, but there aren't any migrations to run |
|
162 | + //then we shouldn't be in mm2. (Maybe an addon got deactivated?) |
|
163 | + update_option(self::option_name_maintenance_mode, self::level_0_not_in_maintenance); |
|
164 | + return false; |
|
165 | + } |
|
166 | + return false; |
|
167 | + } |
|
168 | + |
|
169 | + |
|
170 | + |
|
171 | + /** |
|
172 | + * Updates the maintenance level on the site |
|
173 | + * |
|
174 | + * @param int $level |
|
175 | + * @return void |
|
176 | + */ |
|
177 | + public function set_maintenance_level($level) |
|
178 | + { |
|
179 | + do_action('AHEE__EE_Maintenance_Mode__set_maintenance_level', $level); |
|
180 | + update_option(self::option_name_maintenance_mode, (int)$level); |
|
181 | + } |
|
182 | + |
|
183 | + |
|
184 | + |
|
185 | + /** |
|
186 | + * returns TRUE if M-Mode is engaged and the current request is not for the admin |
|
187 | + * |
|
188 | + * @return string |
|
189 | + */ |
|
190 | + public static function disable_frontend_for_maintenance() |
|
191 | + { |
|
192 | + return (! is_admin() && EE_Maintenance_Mode::instance()->level()); |
|
193 | + } |
|
194 | + |
|
195 | + |
|
196 | + |
|
197 | + /** |
|
198 | + * @return void |
|
199 | + */ |
|
200 | + public function load_assets_required_for_m_mode() |
|
201 | + { |
|
202 | + if ( |
|
203 | + $this->real_level() === EE_Maintenance_Mode::level_2_complete_maintenance |
|
204 | + && ! wp_script_is('espresso_core') |
|
205 | + ) { |
|
206 | + wp_register_style( |
|
207 | + 'espresso_default', |
|
208 | + EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
209 | + array('dashicons'), |
|
210 | + EVENT_ESPRESSO_VERSION |
|
211 | + ); |
|
212 | + wp_enqueue_style('espresso_default'); |
|
213 | + wp_register_script( |
|
214 | + 'espresso_core', |
|
215 | + EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
216 | + array('jquery'), |
|
217 | + EVENT_ESPRESSO_VERSION, |
|
218 | + true |
|
219 | + ); |
|
220 | + wp_enqueue_script('espresso_core'); |
|
221 | + } |
|
222 | + } |
|
223 | + |
|
224 | + |
|
225 | + |
|
226 | + /** |
|
227 | + * replacement EE CPT template that displays message notifying site visitors |
|
228 | + * that EE has been temporarily placed into maintenance mode |
|
229 | + * does NOT get called on non-EE-CPT requests |
|
230 | + * |
|
231 | + * @return string |
|
232 | + */ |
|
233 | + public static function template_include() |
|
234 | + { |
|
235 | + // shut 'er down down for maintenance ? then don't use any of our templates for our endpoints |
|
236 | + return get_template_directory() . '/index.php'; |
|
237 | + } |
|
238 | + |
|
239 | + |
|
240 | + |
|
241 | + /** |
|
242 | + * displays message notifying site visitors that EE has been temporarily |
|
243 | + * placed into maintenance mode when post_type != EE CPT |
|
244 | + * |
|
245 | + * @param string $the_content |
|
246 | + * @return string |
|
247 | + */ |
|
248 | + public function the_content($the_content) |
|
249 | + { |
|
250 | + // check if M-mode is engaged and for EE shortcode |
|
251 | + if ($this->level() && strpos($the_content, '[ESPRESSO_') !== false) { |
|
252 | + // this can eventually be moved to a template, or edited via admin. But for now... |
|
253 | + $the_content = sprintf( |
|
254 | + esc_html__( |
|
255 | + '%sMaintenance Mode%sEvent Registration has been temporarily closed while system maintenance is being performed. We\'re sorry for any inconveniences this may have caused. Please try back again later.%s', |
|
256 | + 'event_espresso' |
|
257 | + ), |
|
258 | + '<h3>', |
|
259 | + '</h3><p>', |
|
260 | + '</p>' |
|
261 | + ); |
|
262 | + } |
|
263 | + return $the_content; |
|
264 | + } |
|
265 | 265 | |
266 | 266 | |
267 | 267 | |
268 | - /** |
|
269 | - * displays message on frontend of site notifying admin that EE has been temporarily placed into maintenance mode |
|
270 | - */ |
|
271 | - public function display_maintenance_mode_notice() |
|
272 | - { |
|
273 | - // check if M-mode is engaged and for EE shortcode |
|
274 | - if ( |
|
275 | - ! (defined('DOING_AJAX') && DOING_AJAX) |
|
276 | - && $this->real_level() |
|
277 | - && ! is_admin() |
|
278 | - && current_user_can('administrator') |
|
279 | - && EE_Registry::instance()->REQ->is_espresso_page() |
|
280 | - ) { |
|
281 | - printf( |
|
282 | - esc_html__( |
|
283 | - '%sclose%sEvent Registration is currently disabled because Event Espresso has been placed into Maintenance Mode. To change Maintenance Mode settings, click here %sEE Maintenance Mode Admin Page%s', |
|
284 | - 'event_espresso' |
|
285 | - ), |
|
286 | - '<div id="ee-m-mode-admin-notice-dv" class="ee-really-important-notice-dv"><a class="close-espresso-notice" title="', |
|
287 | - '"><span class="dashicons dashicons-no"></span></a><p>', |
|
288 | - ' » <a href="' . add_query_arg( |
|
289 | - array('page' => 'espresso_maintenance_settings'), admin_url('admin.php') |
|
290 | - ) . '">', |
|
291 | - '</a></p></div>' |
|
292 | - ); |
|
293 | - } |
|
294 | - } |
|
295 | - // espresso-notices important-notice ee-attention |
|
268 | + /** |
|
269 | + * displays message on frontend of site notifying admin that EE has been temporarily placed into maintenance mode |
|
270 | + */ |
|
271 | + public function display_maintenance_mode_notice() |
|
272 | + { |
|
273 | + // check if M-mode is engaged and for EE shortcode |
|
274 | + if ( |
|
275 | + ! (defined('DOING_AJAX') && DOING_AJAX) |
|
276 | + && $this->real_level() |
|
277 | + && ! is_admin() |
|
278 | + && current_user_can('administrator') |
|
279 | + && EE_Registry::instance()->REQ->is_espresso_page() |
|
280 | + ) { |
|
281 | + printf( |
|
282 | + esc_html__( |
|
283 | + '%sclose%sEvent Registration is currently disabled because Event Espresso has been placed into Maintenance Mode. To change Maintenance Mode settings, click here %sEE Maintenance Mode Admin Page%s', |
|
284 | + 'event_espresso' |
|
285 | + ), |
|
286 | + '<div id="ee-m-mode-admin-notice-dv" class="ee-really-important-notice-dv"><a class="close-espresso-notice" title="', |
|
287 | + '"><span class="dashicons dashicons-no"></span></a><p>', |
|
288 | + ' » <a href="' . add_query_arg( |
|
289 | + array('page' => 'espresso_maintenance_settings'), admin_url('admin.php') |
|
290 | + ) . '">', |
|
291 | + '</a></p></div>' |
|
292 | + ); |
|
293 | + } |
|
294 | + } |
|
295 | + // espresso-notices important-notice ee-attention |
|
296 | 296 | |
297 | 297 | |
298 | 298 | |
299 | - /** |
|
300 | - * override magic methods |
|
301 | - */ |
|
302 | - final public function __destruct() |
|
303 | - { |
|
304 | - } |
|
299 | + /** |
|
300 | + * override magic methods |
|
301 | + */ |
|
302 | + final public function __destruct() |
|
303 | + { |
|
304 | + } |
|
305 | 305 | |
306 | 306 | |
307 | 307 | |
308 | - final public function __call($a, $b) |
|
309 | - { |
|
310 | - } |
|
308 | + final public function __call($a, $b) |
|
309 | + { |
|
310 | + } |
|
311 | 311 | |
312 | 312 | |
313 | 313 | |
314 | - final public function __get($a) |
|
315 | - { |
|
316 | - } |
|
314 | + final public function __get($a) |
|
315 | + { |
|
316 | + } |
|
317 | 317 | |
318 | 318 | |
319 | 319 | |
320 | - final public function __set($a, $b) |
|
321 | - { |
|
322 | - } |
|
320 | + final public function __set($a, $b) |
|
321 | + { |
|
322 | + } |
|
323 | 323 | |
324 | 324 | |
325 | 325 | |
326 | - final public function __isset($a) |
|
327 | - { |
|
328 | - } |
|
326 | + final public function __isset($a) |
|
327 | + { |
|
328 | + } |
|
329 | 329 | |
330 | 330 | |
331 | 331 | |
332 | - final public function __unset($a) |
|
333 | - { |
|
334 | - } |
|
332 | + final public function __unset($a) |
|
333 | + { |
|
334 | + } |
|
335 | 335 | |
336 | 336 | |
337 | 337 | |
338 | - final public function __sleep() |
|
339 | - { |
|
340 | - return array(); |
|
341 | - } |
|
338 | + final public function __sleep() |
|
339 | + { |
|
340 | + return array(); |
|
341 | + } |
|
342 | 342 | |
343 | 343 | |
344 | 344 | |
345 | - final public function __wakeup() |
|
346 | - { |
|
347 | - } |
|
345 | + final public function __wakeup() |
|
346 | + { |
|
347 | + } |
|
348 | 348 | |
349 | 349 | |
350 | 350 | |
351 | - final public function __invoke() |
|
352 | - { |
|
353 | - } |
|
351 | + final public function __invoke() |
|
352 | + { |
|
353 | + } |
|
354 | 354 | |
355 | 355 | |
356 | 356 | |
357 | - final public static function __set_state($a = null) |
|
358 | - { |
|
359 | - return EE_Maintenance_Mode::instance(); |
|
360 | - } |
|
357 | + final public static function __set_state($a = null) |
|
358 | + { |
|
359 | + return EE_Maintenance_Mode::instance(); |
|
360 | + } |
|
361 | 361 | |
362 | 362 | |
363 | 363 | |
364 | - final public function __clone() |
|
365 | - { |
|
366 | - } |
|
364 | + final public function __clone() |
|
365 | + { |
|
366 | + } |
|
367 | 367 | |
368 | 368 | |
369 | 369 | |
370 | - final public static function __callStatic($a, $b) |
|
371 | - { |
|
372 | - } |
|
370 | + final public static function __callStatic($a, $b) |
|
371 | + { |
|
372 | + } |
|
373 | 373 | |
374 | 374 | } |
375 | 375 | // End of file EE_Maintenance_Mode.core.php |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | public static function instance() |
59 | 59 | { |
60 | 60 | // check if class object is instantiated |
61 | - if (! self::$_instance instanceof EE_Maintenance_Mode) { |
|
61 | + if ( ! self::$_instance instanceof EE_Maintenance_Mode) { |
|
62 | 62 | self::$_instance = new self(); |
63 | 63 | } |
64 | 64 | return self::$_instance; |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | public function set_maintenance_level($level) |
178 | 178 | { |
179 | 179 | do_action('AHEE__EE_Maintenance_Mode__set_maintenance_level', $level); |
180 | - update_option(self::option_name_maintenance_mode, (int)$level); |
|
180 | + update_option(self::option_name_maintenance_mode, (int) $level); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | */ |
190 | 190 | public static function disable_frontend_for_maintenance() |
191 | 191 | { |
192 | - return (! is_admin() && EE_Maintenance_Mode::instance()->level()); |
|
192 | + return ( ! is_admin() && EE_Maintenance_Mode::instance()->level()); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | |
@@ -205,14 +205,14 @@ discard block |
||
205 | 205 | ) { |
206 | 206 | wp_register_style( |
207 | 207 | 'espresso_default', |
208 | - EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
208 | + EE_GLOBAL_ASSETS_URL.'css/espresso_default.css', |
|
209 | 209 | array('dashicons'), |
210 | 210 | EVENT_ESPRESSO_VERSION |
211 | 211 | ); |
212 | 212 | wp_enqueue_style('espresso_default'); |
213 | 213 | wp_register_script( |
214 | 214 | 'espresso_core', |
215 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
215 | + EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', |
|
216 | 216 | array('jquery'), |
217 | 217 | EVENT_ESPRESSO_VERSION, |
218 | 218 | true |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | public static function template_include() |
234 | 234 | { |
235 | 235 | // shut 'er down down for maintenance ? then don't use any of our templates for our endpoints |
236 | - return get_template_directory() . '/index.php'; |
|
236 | + return get_template_directory().'/index.php'; |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | |
@@ -285,9 +285,9 @@ discard block |
||
285 | 285 | ), |
286 | 286 | '<div id="ee-m-mode-admin-notice-dv" class="ee-really-important-notice-dv"><a class="close-espresso-notice" title="', |
287 | 287 | '"><span class="dashicons dashicons-no"></span></a><p>', |
288 | - ' » <a href="' . add_query_arg( |
|
288 | + ' » <a href="'.add_query_arg( |
|
289 | 289 | array('page' => 'espresso_maintenance_settings'), admin_url('admin.php') |
290 | - ) . '">', |
|
290 | + ).'">', |
|
291 | 291 | '</a></p></div>' |
292 | 292 | ); |
293 | 293 | } |
@@ -77,26 +77,26 @@ |
||
77 | 77 | class LoaderFactory |
78 | 78 | { |
79 | 79 | |
80 | - /** |
|
81 | - * @var LoaderInterface $loader ; |
|
82 | - */ |
|
83 | - private static $loader; |
|
80 | + /** |
|
81 | + * @var LoaderInterface $loader ; |
|
82 | + */ |
|
83 | + private static $loader; |
|
84 | 84 | |
85 | 85 | |
86 | 86 | |
87 | - /** |
|
88 | - * @return LoaderInterface |
|
89 | - * @throws InvalidArgumentException |
|
90 | - * @throws InvalidInterfaceException |
|
91 | - * @throws InvalidDataTypeException |
|
92 | - */ |
|
93 | - public static function getLoader() |
|
94 | - { |
|
95 | - if (! LoaderFactory::$loader instanceof LoaderInterface) { |
|
96 | - LoaderFactory::$loader = new Loader(); |
|
97 | - } |
|
98 | - return LoaderFactory::$loader; |
|
99 | - } |
|
87 | + /** |
|
88 | + * @return LoaderInterface |
|
89 | + * @throws InvalidArgumentException |
|
90 | + * @throws InvalidInterfaceException |
|
91 | + * @throws InvalidDataTypeException |
|
92 | + */ |
|
93 | + public static function getLoader() |
|
94 | + { |
|
95 | + if (! LoaderFactory::$loader instanceof LoaderInterface) { |
|
96 | + LoaderFactory::$loader = new Loader(); |
|
97 | + } |
|
98 | + return LoaderFactory::$loader; |
|
99 | + } |
|
100 | 100 | |
101 | 101 | |
102 | 102 | } |