@@ -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,239 +40,239 @@ 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.25.rc.003'); |
|
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.25.rc.003'); |
|
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 | - /** |
|
197 | - * espresso_plugin_activation |
|
198 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
199 | - */ |
|
200 | - function espresso_plugin_activation() |
|
201 | - { |
|
202 | - update_option('ee_espresso_activation', true); |
|
203 | - } |
|
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 | + /** |
|
197 | + * espresso_plugin_activation |
|
198 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
199 | + */ |
|
200 | + function espresso_plugin_activation() |
|
201 | + { |
|
202 | + update_option('ee_espresso_activation', true); |
|
203 | + } |
|
204 | 204 | |
205 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
206 | - /** |
|
207 | - * espresso_load_error_handling |
|
208 | - * this function loads EE's class for handling exceptions and errors |
|
209 | - */ |
|
210 | - function espresso_load_error_handling() |
|
211 | - { |
|
212 | - // load debugging tools |
|
213 | - if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
214 | - require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php'); |
|
215 | - EEH_Debug_Tools::instance(); |
|
216 | - } |
|
217 | - // load error handling |
|
218 | - if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
219 | - require_once(EE_CORE . 'EE_Error.core.php'); |
|
220 | - } else { |
|
221 | - wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
222 | - } |
|
223 | - } |
|
205 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
206 | + /** |
|
207 | + * espresso_load_error_handling |
|
208 | + * this function loads EE's class for handling exceptions and errors |
|
209 | + */ |
|
210 | + function espresso_load_error_handling() |
|
211 | + { |
|
212 | + // load debugging tools |
|
213 | + if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
214 | + require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php'); |
|
215 | + EEH_Debug_Tools::instance(); |
|
216 | + } |
|
217 | + // load error handling |
|
218 | + if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
219 | + require_once(EE_CORE . 'EE_Error.core.php'); |
|
220 | + } else { |
|
221 | + wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
222 | + } |
|
223 | + } |
|
224 | 224 | |
225 | - /** |
|
226 | - * espresso_load_required |
|
227 | - * given a class name and path, this function will load that file or throw an exception |
|
228 | - * |
|
229 | - * @param string $classname |
|
230 | - * @param string $full_path_to_file |
|
231 | - * @throws EE_Error |
|
232 | - */ |
|
233 | - function espresso_load_required($classname, $full_path_to_file) |
|
234 | - { |
|
235 | - static $error_handling_loaded = false; |
|
236 | - if ( ! $error_handling_loaded) { |
|
237 | - espresso_load_error_handling(); |
|
238 | - $error_handling_loaded = true; |
|
239 | - } |
|
240 | - if (is_readable($full_path_to_file)) { |
|
241 | - require_once($full_path_to_file); |
|
242 | - } else { |
|
243 | - throw new EE_Error ( |
|
244 | - sprintf( |
|
245 | - esc_html__( |
|
246 | - 'The %s class file could not be located or is not readable due to file permissions.', |
|
247 | - 'event_espresso' |
|
248 | - ), |
|
249 | - $classname |
|
250 | - ) |
|
251 | - ); |
|
252 | - } |
|
253 | - } |
|
225 | + /** |
|
226 | + * espresso_load_required |
|
227 | + * given a class name and path, this function will load that file or throw an exception |
|
228 | + * |
|
229 | + * @param string $classname |
|
230 | + * @param string $full_path_to_file |
|
231 | + * @throws EE_Error |
|
232 | + */ |
|
233 | + function espresso_load_required($classname, $full_path_to_file) |
|
234 | + { |
|
235 | + static $error_handling_loaded = false; |
|
236 | + if ( ! $error_handling_loaded) { |
|
237 | + espresso_load_error_handling(); |
|
238 | + $error_handling_loaded = true; |
|
239 | + } |
|
240 | + if (is_readable($full_path_to_file)) { |
|
241 | + require_once($full_path_to_file); |
|
242 | + } else { |
|
243 | + throw new EE_Error ( |
|
244 | + sprintf( |
|
245 | + esc_html__( |
|
246 | + 'The %s class file could not be located or is not readable due to file permissions.', |
|
247 | + 'event_espresso' |
|
248 | + ), |
|
249 | + $classname |
|
250 | + ) |
|
251 | + ); |
|
252 | + } |
|
253 | + } |
|
254 | 254 | |
255 | - espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); |
|
256 | - espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); |
|
257 | - espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); |
|
258 | - new EE_Bootstrap(); |
|
259 | - } |
|
255 | + espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); |
|
256 | + espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); |
|
257 | + espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); |
|
258 | + new EE_Bootstrap(); |
|
259 | + } |
|
260 | 260 | } |
261 | 261 | if ( ! function_exists('espresso_deactivate_plugin')) { |
262 | - /** |
|
263 | - * deactivate_plugin |
|
264 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
265 | - * |
|
266 | - * @access public |
|
267 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
268 | - * @return void |
|
269 | - */ |
|
270 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
271 | - { |
|
272 | - if ( ! function_exists('deactivate_plugins')) { |
|
273 | - require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
274 | - } |
|
275 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
276 | - deactivate_plugins($plugin_basename); |
|
277 | - } |
|
262 | + /** |
|
263 | + * deactivate_plugin |
|
264 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
265 | + * |
|
266 | + * @access public |
|
267 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
268 | + * @return void |
|
269 | + */ |
|
270 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
271 | + { |
|
272 | + if ( ! function_exists('deactivate_plugins')) { |
|
273 | + require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
274 | + } |
|
275 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
276 | + deactivate_plugins($plugin_basename); |
|
277 | + } |
|
278 | 278 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | protected static $_incompatible_addons = array( |
49 | 49 | 'Multi_Event_Registration' => '2.0.11.rc.002', |
50 | 50 | 'Promotions' => '1.0.0.rc.084', |
51 | - ); |
|
51 | + ); |
|
52 | 52 | |
53 | 53 | |
54 | 54 | |
@@ -219,655 +219,655 @@ discard block |
||
219 | 219 | */ |
220 | 220 | public static function register( $addon_name = '', $setup_args = array() ) { |
221 | 221 | // required fields MUST be present, so let's make sure they are. |
222 | - \EE_Register_Addon::_verify_parameters($addon_name, $setup_args); |
|
223 | - // get class name for addon |
|
222 | + \EE_Register_Addon::_verify_parameters($addon_name, $setup_args); |
|
223 | + // get class name for addon |
|
224 | 224 | $class_name = \EE_Register_Addon::_parse_class_name($addon_name, $setup_args); |
225 | 225 | //setup $_settings array from incoming values. |
226 | - $addon_settings = \EE_Register_Addon::_get_addon_settings($class_name, $setup_args); |
|
227 | - // setup PUE |
|
228 | - \EE_Register_Addon::_parse_pue_options($addon_name, $class_name, $setup_args); |
|
229 | - // does this addon work with this version of core or WordPress ? |
|
230 | - if ( ! \EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings) ) { |
|
231 | - return; |
|
226 | + $addon_settings = \EE_Register_Addon::_get_addon_settings($class_name, $setup_args); |
|
227 | + // setup PUE |
|
228 | + \EE_Register_Addon::_parse_pue_options($addon_name, $class_name, $setup_args); |
|
229 | + // does this addon work with this version of core or WordPress ? |
|
230 | + if ( ! \EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings) ) { |
|
231 | + return; |
|
232 | 232 | } |
233 | 233 | // register namespaces |
234 | - \EE_Register_Addon::_setup_namespaces($addon_settings); |
|
235 | - // check if this is an activation request |
|
236 | - if ( \EE_Register_Addon::_addon_activation($addon_name, $addon_settings)) { |
|
237 | - // dont bother setting up the rest of the addon atm |
|
238 | - return; |
|
239 | - } |
|
234 | + \EE_Register_Addon::_setup_namespaces($addon_settings); |
|
235 | + // check if this is an activation request |
|
236 | + if ( \EE_Register_Addon::_addon_activation($addon_name, $addon_settings)) { |
|
237 | + // dont bother setting up the rest of the addon atm |
|
238 | + return; |
|
239 | + } |
|
240 | 240 | // we need cars |
241 | - \EE_Register_Addon::_setup_autoloaders($addon_name); |
|
242 | - // register new models and extensions |
|
243 | - \EE_Register_Addon::_register_models_and_extensions($addon_name); |
|
244 | - // setup DMS |
|
245 | - \EE_Register_Addon::_register_data_migration_scripts($addon_name); |
|
246 | - // if config_class is present let's register config. |
|
247 | - \EE_Register_Addon::_register_config($addon_name); |
|
248 | - // register admin pages |
|
249 | - \EE_Register_Addon::_register_admin_pages($addon_name); |
|
250 | - // add to list of modules to be registered |
|
251 | - \EE_Register_Addon::_register_modules($addon_name); |
|
252 | - // add to list of shortcodes to be registered |
|
253 | - \EE_Register_Addon::_register_shortcodes($addon_name); |
|
254 | - // add to list of widgets to be registered |
|
255 | - \EE_Register_Addon::_register_widgets($addon_name); |
|
256 | - // register capability related stuff. |
|
257 | - \EE_Register_Addon::_register_capabilities($addon_name); |
|
258 | - // any message type to register? |
|
259 | - \EE_Register_Addon::_register_message_types($addon_name); |
|
241 | + \EE_Register_Addon::_setup_autoloaders($addon_name); |
|
242 | + // register new models and extensions |
|
243 | + \EE_Register_Addon::_register_models_and_extensions($addon_name); |
|
244 | + // setup DMS |
|
245 | + \EE_Register_Addon::_register_data_migration_scripts($addon_name); |
|
246 | + // if config_class is present let's register config. |
|
247 | + \EE_Register_Addon::_register_config($addon_name); |
|
248 | + // register admin pages |
|
249 | + \EE_Register_Addon::_register_admin_pages($addon_name); |
|
250 | + // add to list of modules to be registered |
|
251 | + \EE_Register_Addon::_register_modules($addon_name); |
|
252 | + // add to list of shortcodes to be registered |
|
253 | + \EE_Register_Addon::_register_shortcodes($addon_name); |
|
254 | + // add to list of widgets to be registered |
|
255 | + \EE_Register_Addon::_register_widgets($addon_name); |
|
256 | + // register capability related stuff. |
|
257 | + \EE_Register_Addon::_register_capabilities($addon_name); |
|
258 | + // any message type to register? |
|
259 | + \EE_Register_Addon::_register_message_types($addon_name); |
|
260 | 260 | // any custom post type/ custom capabilities or default terms to register |
261 | - \EE_Register_Addon::_register_custom_post_types($addon_name); |
|
262 | - // and any payment methods |
|
263 | - \EE_Register_Addon::_register_payment_methods($addon_name); |
|
261 | + \EE_Register_Addon::_register_custom_post_types($addon_name); |
|
262 | + // and any payment methods |
|
263 | + \EE_Register_Addon::_register_payment_methods($addon_name); |
|
264 | 264 | // load and instantiate main addon class |
265 | 265 | \EE_Register_Addon::_load_and_init_addon_class($addon_name); |
266 | 266 | } |
267 | 267 | |
268 | 268 | |
269 | 269 | |
270 | - /** |
|
271 | - * @param string $addon_name |
|
272 | - * @param array $setup_args |
|
273 | - * @return void |
|
274 | - * @throws \EE_Error |
|
275 | - */ |
|
276 | - private static function _verify_parameters($addon_name, array $setup_args) |
|
277 | - { |
|
278 | - // required fields MUST be present, so let's make sure they are. |
|
279 | - if (empty($addon_name) || ! is_array($setup_args)) { |
|
280 | - throw new EE_Error( |
|
281 | - __( |
|
282 | - 'In order to register an EE_Addon with EE_Register_Addon::register(), you must include the "addon_name" (the name of the addon), and an array of arguments.', |
|
283 | - 'event_espresso' |
|
284 | - ) |
|
285 | - ); |
|
286 | - } |
|
287 | - if ( ! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) { |
|
288 | - throw new EE_Error( |
|
289 | - sprintf( |
|
290 | - __( |
|
291 | - 'When registering an addon, you didn\'t provide the "main_file_path", which is the full path to the main file loaded directly by Wordpress. You only provided %s', |
|
292 | - 'event_espresso' |
|
293 | - ), |
|
294 | - implode(',', array_keys($setup_args)) |
|
295 | - ) |
|
296 | - ); |
|
297 | - } |
|
298 | - // check that addon has not already been registered with that name |
|
299 | - if (isset(self::$_settings[$addon_name]) && ! did_action('activate_plugin')) { |
|
300 | - throw new EE_Error( |
|
301 | - sprintf( |
|
302 | - __( |
|
303 | - 'An EE_Addon with the name "%s" has already been registered and each EE_Addon requires a unique name.', |
|
304 | - 'event_espresso' |
|
305 | - ), |
|
306 | - $addon_name |
|
307 | - ) |
|
308 | - ); |
|
309 | - } |
|
270 | + /** |
|
271 | + * @param string $addon_name |
|
272 | + * @param array $setup_args |
|
273 | + * @return void |
|
274 | + * @throws \EE_Error |
|
275 | + */ |
|
276 | + private static function _verify_parameters($addon_name, array $setup_args) |
|
277 | + { |
|
278 | + // required fields MUST be present, so let's make sure they are. |
|
279 | + if (empty($addon_name) || ! is_array($setup_args)) { |
|
280 | + throw new EE_Error( |
|
281 | + __( |
|
282 | + 'In order to register an EE_Addon with EE_Register_Addon::register(), you must include the "addon_name" (the name of the addon), and an array of arguments.', |
|
283 | + 'event_espresso' |
|
284 | + ) |
|
285 | + ); |
|
286 | + } |
|
287 | + if ( ! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) { |
|
288 | + throw new EE_Error( |
|
289 | + sprintf( |
|
290 | + __( |
|
291 | + 'When registering an addon, you didn\'t provide the "main_file_path", which is the full path to the main file loaded directly by Wordpress. You only provided %s', |
|
292 | + 'event_espresso' |
|
293 | + ), |
|
294 | + implode(',', array_keys($setup_args)) |
|
295 | + ) |
|
296 | + ); |
|
297 | + } |
|
298 | + // check that addon has not already been registered with that name |
|
299 | + if (isset(self::$_settings[$addon_name]) && ! did_action('activate_plugin')) { |
|
300 | + throw new EE_Error( |
|
301 | + sprintf( |
|
302 | + __( |
|
303 | + 'An EE_Addon with the name "%s" has already been registered and each EE_Addon requires a unique name.', |
|
304 | + 'event_espresso' |
|
305 | + ), |
|
306 | + $addon_name |
|
307 | + ) |
|
308 | + ); |
|
309 | + } |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | |
313 | 313 | |
314 | - /** |
|
315 | - * @param string $addon_name |
|
316 | - * @param array $setup_args |
|
317 | - * @return string |
|
318 | - */ |
|
319 | - private static function _parse_class_name($addon_name, array $setup_args) |
|
320 | - { |
|
321 | - if (empty($setup_args['class_name'])) { |
|
322 | - // generate one by first separating name with spaces |
|
323 | - $class_name = str_replace(array('-', '_'), ' ', trim($addon_name)); |
|
324 | - //capitalize, then replace spaces with underscores |
|
325 | - $class_name = str_replace(' ', '_', ucwords($class_name)); |
|
326 | - } else { |
|
327 | - $class_name = $setup_args['class_name']; |
|
328 | - } |
|
329 | - return strpos($class_name, 'EE_') === 0 ? $class_name : 'EE_' . $class_name; |
|
330 | - } |
|
331 | - |
|
332 | - |
|
333 | - |
|
334 | - /** |
|
335 | - * @param string $class_name |
|
336 | - * @param array $setup_args |
|
337 | - * @return array |
|
338 | - */ |
|
339 | - private static function _get_addon_settings($class_name, array $setup_args) |
|
340 | - { |
|
341 | - //setup $_settings array from incoming values. |
|
342 | - $addon_settings = array( |
|
343 | - // generated from the addon name, changes something like "calendar" to "EE_Calendar" |
|
344 | - 'class_name' => $class_name, |
|
345 | - // the addon slug for use in URLs, etc |
|
346 | - 'plugin_slug' => isset($setup_args['plugin_slug']) |
|
347 | - ? (string)$setup_args['plugin_slug'] |
|
348 | - : '', |
|
349 | - // page slug to be used when generating the "Settings" link on the WP plugin page |
|
350 | - 'plugin_action_slug' => isset($setup_args['plugin_action_slug']) |
|
351 | - ? (string)$setup_args['plugin_action_slug'] |
|
352 | - : '', |
|
353 | - // the "software" version for the addon |
|
354 | - 'version' => isset($setup_args['version']) |
|
355 | - ? (string)$setup_args['version'] |
|
356 | - : '', |
|
357 | - // the minimum version of EE Core that the addon will work with |
|
358 | - 'min_core_version' => isset($setup_args['min_core_version']) |
|
359 | - ? (string)$setup_args['min_core_version'] |
|
360 | - : '', |
|
361 | - // the minimum version of WordPress that the addon will work with |
|
362 | - 'min_wp_version' => isset($setup_args['min_wp_version']) |
|
363 | - ? (string)$setup_args['min_wp_version'] |
|
364 | - : EE_MIN_WP_VER_REQUIRED, |
|
365 | - // full server path to main file (file loaded directly by WP) |
|
366 | - 'main_file_path' => isset($setup_args['main_file_path']) |
|
367 | - ? (string)$setup_args['main_file_path'] |
|
368 | - : '', |
|
369 | - // path to folder containing files for integrating with the EE core admin and/or setting up EE admin pages |
|
370 | - 'admin_path' => isset($setup_args['admin_path']) |
|
371 | - ? (string)$setup_args['admin_path'] : '', |
|
372 | - // a method to be called when the EE Admin is first invoked, can be used for hooking into any admin page |
|
373 | - 'admin_callback' => isset($setup_args['admin_callback']) |
|
374 | - ? (string)$setup_args['admin_callback'] |
|
375 | - : '', |
|
376 | - // the section name for this addon's configuration settings section (defaults to "addons") |
|
377 | - 'config_section' => isset($setup_args['config_section']) |
|
378 | - ? (string)$setup_args['config_section'] |
|
379 | - : 'addons', |
|
380 | - // the class name for this addon's configuration settings object |
|
381 | - 'config_class' => isset($setup_args['config_class']) |
|
382 | - ? (string)$setup_args['config_class'] : '', |
|
383 | - //the name given to the config for this addons' configuration settings object (optional) |
|
384 | - 'config_name' => isset($setup_args['config_name']) |
|
385 | - ? (string)$setup_args['config_name'] : '', |
|
386 | - // an array of "class names" => "full server paths" for any classes that might be invoked by the addon |
|
387 | - 'autoloader_paths' => isset($setup_args['autoloader_paths']) |
|
388 | - ? (array)$setup_args['autoloader_paths'] |
|
389 | - : array(), |
|
390 | - // an array of "full server paths" for any folders containing classes that might be invoked by the addon |
|
391 | - 'autoloader_folders' => isset($setup_args['autoloader_folders']) |
|
392 | - ? (array)$setup_args['autoloader_folders'] |
|
393 | - : array(), |
|
394 | - // array of full server paths to any EE_DMS data migration scripts used by the addon |
|
395 | - 'dms_paths' => isset($setup_args['dms_paths']) |
|
396 | - ? (array)$setup_args['dms_paths'] |
|
397 | - : array(), |
|
398 | - // array of full server paths to any EED_Modules used by the addon |
|
399 | - 'module_paths' => isset($setup_args['module_paths']) |
|
400 | - ? (array)$setup_args['module_paths'] |
|
401 | - : array(), |
|
402 | - // array of full server paths to any EES_Shortcodes used by the addon |
|
403 | - 'shortcode_paths' => isset($setup_args['shortcode_paths']) |
|
404 | - ? (array)$setup_args['shortcode_paths'] |
|
405 | - : array(), |
|
406 | - // array of full server paths to any WP_Widgets used by the addon |
|
407 | - 'widget_paths' => isset($setup_args['widget_paths']) |
|
408 | - ? (array)$setup_args['widget_paths'] |
|
409 | - : array(), |
|
410 | - // array of PUE options used by the addon |
|
411 | - 'pue_options' => isset($setup_args['pue_options']) |
|
412 | - ? (array)$setup_args['pue_options'] |
|
413 | - : array(), |
|
414 | - 'message_types' => isset($setup_args['message_types']) |
|
415 | - ? (array)$setup_args['message_types'] |
|
416 | - : array(), |
|
417 | - 'capabilities' => isset($setup_args['capabilities']) |
|
418 | - ? (array)$setup_args['capabilities'] |
|
419 | - : array(), |
|
420 | - 'capability_maps' => isset($setup_args['capability_maps']) |
|
421 | - ? (array)$setup_args['capability_maps'] |
|
422 | - : array(), |
|
423 | - 'model_paths' => isset($setup_args['model_paths']) |
|
424 | - ? (array)$setup_args['model_paths'] |
|
425 | - : array(), |
|
426 | - 'class_paths' => isset($setup_args['class_paths']) |
|
427 | - ? (array)$setup_args['class_paths'] |
|
428 | - : array(), |
|
429 | - 'model_extension_paths' => isset($setup_args['model_extension_paths']) |
|
430 | - ? (array)$setup_args['model_extension_paths'] |
|
431 | - : array(), |
|
432 | - 'class_extension_paths' => isset($setup_args['class_extension_paths']) |
|
433 | - ? (array)$setup_args['class_extension_paths'] |
|
434 | - : array(), |
|
435 | - 'custom_post_types' => isset($setup_args['custom_post_types']) |
|
436 | - ? (array)$setup_args['custom_post_types'] |
|
437 | - : array(), |
|
438 | - 'custom_taxonomies' => isset($setup_args['custom_taxonomies']) |
|
439 | - ? (array)$setup_args['custom_taxonomies'] |
|
440 | - : array(), |
|
441 | - 'payment_method_paths' => isset($setup_args['payment_method_paths']) |
|
442 | - ? (array)$setup_args['payment_method_paths'] |
|
443 | - : array(), |
|
444 | - 'default_terms' => isset($setup_args['default_terms']) |
|
445 | - ? (array)$setup_args['default_terms'] |
|
446 | - : array(), |
|
447 | - // if not empty, inserts a new table row after this plugin's row on the WP Plugins page |
|
448 | - // that can be used for adding upgrading/marketing info |
|
449 | - 'plugins_page_row' => isset($setup_args['plugins_page_row']) |
|
450 | - ? $setup_args['plugins_page_row'] |
|
451 | - : '', |
|
452 | - 'namespace' => isset( |
|
453 | - $setup_args['namespace'], |
|
454 | - $setup_args['namespace']['FQNS'], |
|
455 | - $setup_args['namespace']['DIR'] |
|
456 | - ) |
|
457 | - ? (array)$setup_args['namespace'] |
|
458 | - : array(), |
|
459 | - ); |
|
460 | - // if plugin_action_slug is NOT set, but an admin page path IS set, |
|
461 | - // then let's just use the plugin_slug since that will be used for linking to the admin page |
|
462 | - $addon_settings['plugin_action_slug'] = empty($addon_settings['plugin_action_slug']) |
|
463 | - && ! empty($addon_settings['admin_path']) |
|
464 | - ? $addon_settings['plugin_slug'] |
|
465 | - : $addon_settings['plugin_action_slug']; |
|
466 | - // full server path to main file (file loaded directly by WP) |
|
467 | - $addon_settings['plugin_basename'] = plugin_basename($addon_settings['main_file_path']); |
|
468 | - return $addon_settings; |
|
314 | + /** |
|
315 | + * @param string $addon_name |
|
316 | + * @param array $setup_args |
|
317 | + * @return string |
|
318 | + */ |
|
319 | + private static function _parse_class_name($addon_name, array $setup_args) |
|
320 | + { |
|
321 | + if (empty($setup_args['class_name'])) { |
|
322 | + // generate one by first separating name with spaces |
|
323 | + $class_name = str_replace(array('-', '_'), ' ', trim($addon_name)); |
|
324 | + //capitalize, then replace spaces with underscores |
|
325 | + $class_name = str_replace(' ', '_', ucwords($class_name)); |
|
326 | + } else { |
|
327 | + $class_name = $setup_args['class_name']; |
|
328 | + } |
|
329 | + return strpos($class_name, 'EE_') === 0 ? $class_name : 'EE_' . $class_name; |
|
469 | 330 | } |
470 | 331 | |
471 | 332 | |
472 | 333 | |
473 | - /** |
|
474 | - * @param string $addon_name |
|
475 | - * @param array $addon_settings |
|
476 | - * @return boolean |
|
477 | - */ |
|
334 | + /** |
|
335 | + * @param string $class_name |
|
336 | + * @param array $setup_args |
|
337 | + * @return array |
|
338 | + */ |
|
339 | + private static function _get_addon_settings($class_name, array $setup_args) |
|
340 | + { |
|
341 | + //setup $_settings array from incoming values. |
|
342 | + $addon_settings = array( |
|
343 | + // generated from the addon name, changes something like "calendar" to "EE_Calendar" |
|
344 | + 'class_name' => $class_name, |
|
345 | + // the addon slug for use in URLs, etc |
|
346 | + 'plugin_slug' => isset($setup_args['plugin_slug']) |
|
347 | + ? (string)$setup_args['plugin_slug'] |
|
348 | + : '', |
|
349 | + // page slug to be used when generating the "Settings" link on the WP plugin page |
|
350 | + 'plugin_action_slug' => isset($setup_args['plugin_action_slug']) |
|
351 | + ? (string)$setup_args['plugin_action_slug'] |
|
352 | + : '', |
|
353 | + // the "software" version for the addon |
|
354 | + 'version' => isset($setup_args['version']) |
|
355 | + ? (string)$setup_args['version'] |
|
356 | + : '', |
|
357 | + // the minimum version of EE Core that the addon will work with |
|
358 | + 'min_core_version' => isset($setup_args['min_core_version']) |
|
359 | + ? (string)$setup_args['min_core_version'] |
|
360 | + : '', |
|
361 | + // the minimum version of WordPress that the addon will work with |
|
362 | + 'min_wp_version' => isset($setup_args['min_wp_version']) |
|
363 | + ? (string)$setup_args['min_wp_version'] |
|
364 | + : EE_MIN_WP_VER_REQUIRED, |
|
365 | + // full server path to main file (file loaded directly by WP) |
|
366 | + 'main_file_path' => isset($setup_args['main_file_path']) |
|
367 | + ? (string)$setup_args['main_file_path'] |
|
368 | + : '', |
|
369 | + // path to folder containing files for integrating with the EE core admin and/or setting up EE admin pages |
|
370 | + 'admin_path' => isset($setup_args['admin_path']) |
|
371 | + ? (string)$setup_args['admin_path'] : '', |
|
372 | + // a method to be called when the EE Admin is first invoked, can be used for hooking into any admin page |
|
373 | + 'admin_callback' => isset($setup_args['admin_callback']) |
|
374 | + ? (string)$setup_args['admin_callback'] |
|
375 | + : '', |
|
376 | + // the section name for this addon's configuration settings section (defaults to "addons") |
|
377 | + 'config_section' => isset($setup_args['config_section']) |
|
378 | + ? (string)$setup_args['config_section'] |
|
379 | + : 'addons', |
|
380 | + // the class name for this addon's configuration settings object |
|
381 | + 'config_class' => isset($setup_args['config_class']) |
|
382 | + ? (string)$setup_args['config_class'] : '', |
|
383 | + //the name given to the config for this addons' configuration settings object (optional) |
|
384 | + 'config_name' => isset($setup_args['config_name']) |
|
385 | + ? (string)$setup_args['config_name'] : '', |
|
386 | + // an array of "class names" => "full server paths" for any classes that might be invoked by the addon |
|
387 | + 'autoloader_paths' => isset($setup_args['autoloader_paths']) |
|
388 | + ? (array)$setup_args['autoloader_paths'] |
|
389 | + : array(), |
|
390 | + // an array of "full server paths" for any folders containing classes that might be invoked by the addon |
|
391 | + 'autoloader_folders' => isset($setup_args['autoloader_folders']) |
|
392 | + ? (array)$setup_args['autoloader_folders'] |
|
393 | + : array(), |
|
394 | + // array of full server paths to any EE_DMS data migration scripts used by the addon |
|
395 | + 'dms_paths' => isset($setup_args['dms_paths']) |
|
396 | + ? (array)$setup_args['dms_paths'] |
|
397 | + : array(), |
|
398 | + // array of full server paths to any EED_Modules used by the addon |
|
399 | + 'module_paths' => isset($setup_args['module_paths']) |
|
400 | + ? (array)$setup_args['module_paths'] |
|
401 | + : array(), |
|
402 | + // array of full server paths to any EES_Shortcodes used by the addon |
|
403 | + 'shortcode_paths' => isset($setup_args['shortcode_paths']) |
|
404 | + ? (array)$setup_args['shortcode_paths'] |
|
405 | + : array(), |
|
406 | + // array of full server paths to any WP_Widgets used by the addon |
|
407 | + 'widget_paths' => isset($setup_args['widget_paths']) |
|
408 | + ? (array)$setup_args['widget_paths'] |
|
409 | + : array(), |
|
410 | + // array of PUE options used by the addon |
|
411 | + 'pue_options' => isset($setup_args['pue_options']) |
|
412 | + ? (array)$setup_args['pue_options'] |
|
413 | + : array(), |
|
414 | + 'message_types' => isset($setup_args['message_types']) |
|
415 | + ? (array)$setup_args['message_types'] |
|
416 | + : array(), |
|
417 | + 'capabilities' => isset($setup_args['capabilities']) |
|
418 | + ? (array)$setup_args['capabilities'] |
|
419 | + : array(), |
|
420 | + 'capability_maps' => isset($setup_args['capability_maps']) |
|
421 | + ? (array)$setup_args['capability_maps'] |
|
422 | + : array(), |
|
423 | + 'model_paths' => isset($setup_args['model_paths']) |
|
424 | + ? (array)$setup_args['model_paths'] |
|
425 | + : array(), |
|
426 | + 'class_paths' => isset($setup_args['class_paths']) |
|
427 | + ? (array)$setup_args['class_paths'] |
|
428 | + : array(), |
|
429 | + 'model_extension_paths' => isset($setup_args['model_extension_paths']) |
|
430 | + ? (array)$setup_args['model_extension_paths'] |
|
431 | + : array(), |
|
432 | + 'class_extension_paths' => isset($setup_args['class_extension_paths']) |
|
433 | + ? (array)$setup_args['class_extension_paths'] |
|
434 | + : array(), |
|
435 | + 'custom_post_types' => isset($setup_args['custom_post_types']) |
|
436 | + ? (array)$setup_args['custom_post_types'] |
|
437 | + : array(), |
|
438 | + 'custom_taxonomies' => isset($setup_args['custom_taxonomies']) |
|
439 | + ? (array)$setup_args['custom_taxonomies'] |
|
440 | + : array(), |
|
441 | + 'payment_method_paths' => isset($setup_args['payment_method_paths']) |
|
442 | + ? (array)$setup_args['payment_method_paths'] |
|
443 | + : array(), |
|
444 | + 'default_terms' => isset($setup_args['default_terms']) |
|
445 | + ? (array)$setup_args['default_terms'] |
|
446 | + : array(), |
|
447 | + // if not empty, inserts a new table row after this plugin's row on the WP Plugins page |
|
448 | + // that can be used for adding upgrading/marketing info |
|
449 | + 'plugins_page_row' => isset($setup_args['plugins_page_row']) |
|
450 | + ? $setup_args['plugins_page_row'] |
|
451 | + : '', |
|
452 | + 'namespace' => isset( |
|
453 | + $setup_args['namespace'], |
|
454 | + $setup_args['namespace']['FQNS'], |
|
455 | + $setup_args['namespace']['DIR'] |
|
456 | + ) |
|
457 | + ? (array)$setup_args['namespace'] |
|
458 | + : array(), |
|
459 | + ); |
|
460 | + // if plugin_action_slug is NOT set, but an admin page path IS set, |
|
461 | + // then let's just use the plugin_slug since that will be used for linking to the admin page |
|
462 | + $addon_settings['plugin_action_slug'] = empty($addon_settings['plugin_action_slug']) |
|
463 | + && ! empty($addon_settings['admin_path']) |
|
464 | + ? $addon_settings['plugin_slug'] |
|
465 | + : $addon_settings['plugin_action_slug']; |
|
466 | + // full server path to main file (file loaded directly by WP) |
|
467 | + $addon_settings['plugin_basename'] = plugin_basename($addon_settings['main_file_path']); |
|
468 | + return $addon_settings; |
|
469 | + } |
|
470 | + |
|
471 | + |
|
472 | + |
|
473 | + /** |
|
474 | + * @param string $addon_name |
|
475 | + * @param array $addon_settings |
|
476 | + * @return boolean |
|
477 | + */ |
|
478 | 478 | private static function _addon_is_compatible( $addon_name, array $addon_settings ) { |
479 | - global $wp_version; |
|
480 | - $incompatibility_message = ''; |
|
481 | - //check whether this addon version is compatible with EE core |
|
482 | - if ( |
|
483 | - isset(EE_Register_Addon::$_incompatible_addons[$addon_name]) |
|
484 | - && ! self::_meets_min_core_version_requirement( |
|
485 | - EE_Register_Addon::$_incompatible_addons[$addon_name], |
|
486 | - $addon_settings['version'] |
|
487 | - ) |
|
488 | - ) { |
|
489 | - $incompatibility_message = sprintf( |
|
490 | - __( |
|
491 | - '%4$sIMPORTANT!%5$sThe Event Espresso "%1$s" addon is not compatible with this version of Event Espresso.%2$sPlease upgrade your "%1$s" addon to version %3$s or newer to resolve this issue.' |
|
492 | - ), |
|
493 | - $addon_name, |
|
494 | - '<br />', |
|
495 | - EE_Register_Addon::$_incompatible_addons[$addon_name], |
|
496 | - '<span style="font-weight: bold; color: #D54E21;">', |
|
497 | - '</span><br />' |
|
498 | - ); |
|
499 | - } else if ( |
|
500 | - ! self::_meets_min_core_version_requirement($addon_settings['min_core_version'], espresso_version()) |
|
501 | - ) { |
|
502 | - $incompatibility_message = sprintf( |
|
503 | - __( |
|
504 | - '%5$sIMPORTANT!%6$sThe Event Espresso "%1$s" addon requires Event Espresso Core version "%2$s" or higher in order to run.%4$sYour version of Event Espresso Core is currently at "%3$s". Please upgrade Event Espresso Core first and then re-activate "%1$s".', |
|
505 | - 'event_espresso' |
|
506 | - ), |
|
507 | - $addon_name, |
|
508 | - self::_effective_version($addon_settings['min_core_version']), |
|
509 | - self::_effective_version(espresso_version()), |
|
510 | - '<br />', |
|
511 | - '<span style="font-weight: bold; color: #D54E21;">', |
|
512 | - '</span><br />' |
|
513 | - ); |
|
514 | - } else if (version_compare($wp_version, $addon_settings['min_wp_version'], '<')) { |
|
515 | - $incompatibility_message = sprintf( |
|
516 | - __( |
|
517 | - '%4$sIMPORTANT!%5$sThe Event Espresso "%1$s" addon requires WordPress version "%2$s" or greater.%3$sPlease update your version of WordPress to use the "%1$s" addon and to keep your site secure.', |
|
518 | - 'event_espresso' |
|
519 | - ), |
|
520 | - $addon_name, |
|
521 | - $addon_settings['min_wp_version'], |
|
522 | - '<br />', |
|
523 | - '<span style="font-weight: bold; color: #D54E21;">', |
|
524 | - '</span><br />' |
|
525 | - ); |
|
526 | - } |
|
527 | - if ( ! empty($incompatibility_message)) { |
|
528 | - // remove 'activate' from the REQUEST |
|
529 | - // so WP doesn't erroneously tell the user the plugin activated fine when it didn't |
|
530 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
531 | - if (current_user_can('activate_plugins')) { |
|
532 | - // show an error message indicating the plugin didn't activate properly |
|
533 | - EE_Error::add_error($incompatibility_message, __FILE__, __FUNCTION__, __LINE__); |
|
534 | - } |
|
535 | - // BAIL FROM THE ADDON REGISTRATION PROCESS |
|
536 | - return false; |
|
537 | - } |
|
538 | - // addon IS compatible |
|
539 | - return true; |
|
479 | + global $wp_version; |
|
480 | + $incompatibility_message = ''; |
|
481 | + //check whether this addon version is compatible with EE core |
|
482 | + if ( |
|
483 | + isset(EE_Register_Addon::$_incompatible_addons[$addon_name]) |
|
484 | + && ! self::_meets_min_core_version_requirement( |
|
485 | + EE_Register_Addon::$_incompatible_addons[$addon_name], |
|
486 | + $addon_settings['version'] |
|
487 | + ) |
|
488 | + ) { |
|
489 | + $incompatibility_message = sprintf( |
|
490 | + __( |
|
491 | + '%4$sIMPORTANT!%5$sThe Event Espresso "%1$s" addon is not compatible with this version of Event Espresso.%2$sPlease upgrade your "%1$s" addon to version %3$s or newer to resolve this issue.' |
|
492 | + ), |
|
493 | + $addon_name, |
|
494 | + '<br />', |
|
495 | + EE_Register_Addon::$_incompatible_addons[$addon_name], |
|
496 | + '<span style="font-weight: bold; color: #D54E21;">', |
|
497 | + '</span><br />' |
|
498 | + ); |
|
499 | + } else if ( |
|
500 | + ! self::_meets_min_core_version_requirement($addon_settings['min_core_version'], espresso_version()) |
|
501 | + ) { |
|
502 | + $incompatibility_message = sprintf( |
|
503 | + __( |
|
504 | + '%5$sIMPORTANT!%6$sThe Event Espresso "%1$s" addon requires Event Espresso Core version "%2$s" or higher in order to run.%4$sYour version of Event Espresso Core is currently at "%3$s". Please upgrade Event Espresso Core first and then re-activate "%1$s".', |
|
505 | + 'event_espresso' |
|
506 | + ), |
|
507 | + $addon_name, |
|
508 | + self::_effective_version($addon_settings['min_core_version']), |
|
509 | + self::_effective_version(espresso_version()), |
|
510 | + '<br />', |
|
511 | + '<span style="font-weight: bold; color: #D54E21;">', |
|
512 | + '</span><br />' |
|
513 | + ); |
|
514 | + } else if (version_compare($wp_version, $addon_settings['min_wp_version'], '<')) { |
|
515 | + $incompatibility_message = sprintf( |
|
516 | + __( |
|
517 | + '%4$sIMPORTANT!%5$sThe Event Espresso "%1$s" addon requires WordPress version "%2$s" or greater.%3$sPlease update your version of WordPress to use the "%1$s" addon and to keep your site secure.', |
|
518 | + 'event_espresso' |
|
519 | + ), |
|
520 | + $addon_name, |
|
521 | + $addon_settings['min_wp_version'], |
|
522 | + '<br />', |
|
523 | + '<span style="font-weight: bold; color: #D54E21;">', |
|
524 | + '</span><br />' |
|
525 | + ); |
|
526 | + } |
|
527 | + if ( ! empty($incompatibility_message)) { |
|
528 | + // remove 'activate' from the REQUEST |
|
529 | + // so WP doesn't erroneously tell the user the plugin activated fine when it didn't |
|
530 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
531 | + if (current_user_can('activate_plugins')) { |
|
532 | + // show an error message indicating the plugin didn't activate properly |
|
533 | + EE_Error::add_error($incompatibility_message, __FILE__, __FUNCTION__, __LINE__); |
|
534 | + } |
|
535 | + // BAIL FROM THE ADDON REGISTRATION PROCESS |
|
536 | + return false; |
|
537 | + } |
|
538 | + // addon IS compatible |
|
539 | + return true; |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | |
543 | 543 | |
544 | - /** |
|
545 | - * if plugin update engine is being used for auto-updates, |
|
546 | - * then let's set that up now before going any further so that ALL addons can be updated |
|
547 | - * (not needed if PUE is not being used) |
|
548 | - * |
|
549 | - * @param string $addon_name |
|
550 | - * @param string $class_name |
|
551 | - * @param array $setup_args |
|
552 | - * @return void |
|
553 | - */ |
|
544 | + /** |
|
545 | + * if plugin update engine is being used for auto-updates, |
|
546 | + * then let's set that up now before going any further so that ALL addons can be updated |
|
547 | + * (not needed if PUE is not being used) |
|
548 | + * |
|
549 | + * @param string $addon_name |
|
550 | + * @param string $class_name |
|
551 | + * @param array $setup_args |
|
552 | + * @return void |
|
553 | + */ |
|
554 | 554 | private static function _parse_pue_options( $addon_name, $class_name, array $setup_args ) { |
555 | - // |
|
556 | - if ( ! empty($setup_args['pue_options'])) { |
|
557 | - self::$_settings[$addon_name]['pue_options'] = array( |
|
558 | - 'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug']) |
|
559 | - ? (string)$setup_args['pue_options']['pue_plugin_slug'] |
|
560 | - : 'espresso_' . strtolower($class_name), |
|
561 | - 'plugin_basename' => isset($setup_args['pue_options']['plugin_basename']) |
|
562 | - ? (string)$setup_args['pue_options']['plugin_basename'] |
|
563 | - : plugin_basename($setup_args['main_file_path']), |
|
564 | - 'checkPeriod' => isset($setup_args['pue_options']['checkPeriod']) |
|
565 | - ? (string)$setup_args['pue_options']['checkPeriod'] |
|
566 | - : '24', |
|
567 | - 'use_wp_update' => isset($setup_args['pue_options']['use_wp_update']) |
|
568 | - ? (string)$setup_args['pue_options']['use_wp_update'] |
|
569 | - : false, |
|
570 | - ); |
|
571 | - add_action( |
|
572 | - 'AHEE__EE_System__brew_espresso__after_pue_init', |
|
573 | - array('EE_Register_Addon', 'load_pue_update') |
|
574 | - ); |
|
575 | - } |
|
555 | + // |
|
556 | + if ( ! empty($setup_args['pue_options'])) { |
|
557 | + self::$_settings[$addon_name]['pue_options'] = array( |
|
558 | + 'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug']) |
|
559 | + ? (string)$setup_args['pue_options']['pue_plugin_slug'] |
|
560 | + : 'espresso_' . strtolower($class_name), |
|
561 | + 'plugin_basename' => isset($setup_args['pue_options']['plugin_basename']) |
|
562 | + ? (string)$setup_args['pue_options']['plugin_basename'] |
|
563 | + : plugin_basename($setup_args['main_file_path']), |
|
564 | + 'checkPeriod' => isset($setup_args['pue_options']['checkPeriod']) |
|
565 | + ? (string)$setup_args['pue_options']['checkPeriod'] |
|
566 | + : '24', |
|
567 | + 'use_wp_update' => isset($setup_args['pue_options']['use_wp_update']) |
|
568 | + ? (string)$setup_args['pue_options']['use_wp_update'] |
|
569 | + : false, |
|
570 | + ); |
|
571 | + add_action( |
|
572 | + 'AHEE__EE_System__brew_espresso__after_pue_init', |
|
573 | + array('EE_Register_Addon', 'load_pue_update') |
|
574 | + ); |
|
575 | + } |
|
576 | + } |
|
577 | + |
|
578 | + |
|
579 | + |
|
580 | + /** |
|
581 | + * register namespaces right away before any other files or classes get loaded, but AFTER the version checks |
|
582 | + * |
|
583 | + * @param array $addon_settings |
|
584 | + * @return void |
|
585 | + */ |
|
586 | + private static function _setup_namespaces(array $addon_settings) |
|
587 | + { |
|
588 | + // |
|
589 | + if ( |
|
590 | + isset( |
|
591 | + $addon_settings['namespace'], |
|
592 | + $addon_settings['namespace']['FQNS'], |
|
593 | + $addon_settings['namespace']['DIR'] |
|
594 | + ) |
|
595 | + ) { |
|
596 | + EE_Psr4AutoloaderInit::psr4_loader()->addNamespace( |
|
597 | + $addon_settings['namespace']['FQNS'], |
|
598 | + $addon_settings['namespace']['DIR'] |
|
599 | + ); |
|
600 | + } |
|
576 | 601 | } |
577 | 602 | |
578 | 603 | |
579 | 604 | |
580 | - /** |
|
581 | - * register namespaces right away before any other files or classes get loaded, but AFTER the version checks |
|
582 | - * |
|
583 | - * @param array $addon_settings |
|
584 | - * @return void |
|
585 | - */ |
|
586 | - private static function _setup_namespaces(array $addon_settings) |
|
587 | - { |
|
588 | - // |
|
589 | - if ( |
|
590 | - isset( |
|
591 | - $addon_settings['namespace'], |
|
592 | - $addon_settings['namespace']['FQNS'], |
|
593 | - $addon_settings['namespace']['DIR'] |
|
594 | - ) |
|
595 | - ) { |
|
596 | - EE_Psr4AutoloaderInit::psr4_loader()->addNamespace( |
|
597 | - $addon_settings['namespace']['FQNS'], |
|
598 | - $addon_settings['namespace']['DIR'] |
|
599 | - ); |
|
600 | - } |
|
601 | - } |
|
602 | - |
|
603 | - |
|
604 | - |
|
605 | - /** |
|
606 | - * @param string $addon_name |
|
607 | - * @param array $addon_settings |
|
608 | - * @return bool |
|
609 | - */ |
|
605 | + /** |
|
606 | + * @param string $addon_name |
|
607 | + * @param array $addon_settings |
|
608 | + * @return bool |
|
609 | + */ |
|
610 | 610 | private static function _addon_activation( $addon_name, array $addon_settings ) { |
611 | - // this is an activation request |
|
612 | - if (did_action('activate_plugin')) { |
|
613 | - //to find if THIS is the addon that was activated, |
|
614 | - //just check if we have already registered it or not |
|
615 | - //(as the newly-activated addon wasn't around the first time addons were registered) |
|
616 | - if ( ! isset(self::$_settings[$addon_name])) { |
|
617 | - self::$_settings[$addon_name] = $addon_settings; |
|
618 | - $addon = self::_load_and_init_addon_class($addon_name); |
|
619 | - $addon->set_activation_indicator_option(); |
|
620 | - // dont bother setting up the rest of the addon. |
|
621 | - // we know it was just activated and the request will end soon |
|
622 | - } |
|
623 | - return true; |
|
624 | - } else { |
|
625 | - // make sure this was called in the right place! |
|
626 | - if ( |
|
627 | - ! did_action('AHEE__EE_System__load_espresso_addons') |
|
628 | - || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin') |
|
629 | - ) { |
|
630 | - EE_Error::doing_it_wrong( |
|
631 | - __METHOD__, |
|
632 | - sprintf( |
|
633 | - __( |
|
634 | - 'An attempt to register an EE_Addon named "%s" has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__load_espresso_addons" hook to register addons.', |
|
635 | - 'event_espresso' |
|
636 | - ), |
|
637 | - $addon_name |
|
638 | - ), |
|
639 | - '4.3.0' |
|
640 | - ); |
|
641 | - } |
|
642 | - self::$_settings[$addon_name] = $addon_settings; |
|
643 | - } |
|
644 | - return false; |
|
645 | - } |
|
646 | - |
|
647 | - |
|
648 | - |
|
649 | - /** |
|
650 | - * @param string $addon_name |
|
651 | - * @return void |
|
652 | - * @throws \EE_Error |
|
653 | - */ |
|
654 | - private static function _setup_autoloaders($addon_name) |
|
655 | - { |
|
656 | - if ( ! empty(self::$_settings[$addon_name]['autoloader_paths'])) { |
|
657 | - // setup autoloader for single file |
|
658 | - EEH_Autoloader::instance()->register_autoloader(self::$_settings[$addon_name]['autoloader_paths']); |
|
659 | - } |
|
660 | - // setup autoloaders for folders |
|
661 | - if ( ! empty(self::$_settings[$addon_name]['autoloader_folders'])) { |
|
662 | - foreach ((array)self::$_settings[$addon_name]['autoloader_folders'] as $autoloader_folder) { |
|
663 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder); |
|
664 | - } |
|
665 | - } |
|
666 | - } |
|
667 | - |
|
668 | - |
|
669 | - |
|
670 | - /** |
|
671 | - * register new models and extensions |
|
672 | - * |
|
673 | - * @param string $addon_name |
|
674 | - * @return void |
|
675 | - * @throws \EE_Error |
|
676 | - */ |
|
611 | + // this is an activation request |
|
612 | + if (did_action('activate_plugin')) { |
|
613 | + //to find if THIS is the addon that was activated, |
|
614 | + //just check if we have already registered it or not |
|
615 | + //(as the newly-activated addon wasn't around the first time addons were registered) |
|
616 | + if ( ! isset(self::$_settings[$addon_name])) { |
|
617 | + self::$_settings[$addon_name] = $addon_settings; |
|
618 | + $addon = self::_load_and_init_addon_class($addon_name); |
|
619 | + $addon->set_activation_indicator_option(); |
|
620 | + // dont bother setting up the rest of the addon. |
|
621 | + // we know it was just activated and the request will end soon |
|
622 | + } |
|
623 | + return true; |
|
624 | + } else { |
|
625 | + // make sure this was called in the right place! |
|
626 | + if ( |
|
627 | + ! did_action('AHEE__EE_System__load_espresso_addons') |
|
628 | + || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin') |
|
629 | + ) { |
|
630 | + EE_Error::doing_it_wrong( |
|
631 | + __METHOD__, |
|
632 | + sprintf( |
|
633 | + __( |
|
634 | + 'An attempt to register an EE_Addon named "%s" has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__load_espresso_addons" hook to register addons.', |
|
635 | + 'event_espresso' |
|
636 | + ), |
|
637 | + $addon_name |
|
638 | + ), |
|
639 | + '4.3.0' |
|
640 | + ); |
|
641 | + } |
|
642 | + self::$_settings[$addon_name] = $addon_settings; |
|
643 | + } |
|
644 | + return false; |
|
645 | + } |
|
646 | + |
|
647 | + |
|
648 | + |
|
649 | + /** |
|
650 | + * @param string $addon_name |
|
651 | + * @return void |
|
652 | + * @throws \EE_Error |
|
653 | + */ |
|
654 | + private static function _setup_autoloaders($addon_name) |
|
655 | + { |
|
656 | + if ( ! empty(self::$_settings[$addon_name]['autoloader_paths'])) { |
|
657 | + // setup autoloader for single file |
|
658 | + EEH_Autoloader::instance()->register_autoloader(self::$_settings[$addon_name]['autoloader_paths']); |
|
659 | + } |
|
660 | + // setup autoloaders for folders |
|
661 | + if ( ! empty(self::$_settings[$addon_name]['autoloader_folders'])) { |
|
662 | + foreach ((array)self::$_settings[$addon_name]['autoloader_folders'] as $autoloader_folder) { |
|
663 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder); |
|
664 | + } |
|
665 | + } |
|
666 | + } |
|
667 | + |
|
668 | + |
|
669 | + |
|
670 | + /** |
|
671 | + * register new models and extensions |
|
672 | + * |
|
673 | + * @param string $addon_name |
|
674 | + * @return void |
|
675 | + * @throws \EE_Error |
|
676 | + */ |
|
677 | 677 | private static function _register_models_and_extensions( $addon_name ) { |
678 | - // register new models |
|
679 | - if ( |
|
680 | - ! empty(self::$_settings[$addon_name]['model_paths']) |
|
681 | - || ! empty(self::$_settings[$addon_name]['class_paths']) |
|
682 | - ) { |
|
683 | - EE_Register_Model::register( |
|
684 | - $addon_name, |
|
685 | - array( |
|
686 | - 'model_paths' => self::$_settings[$addon_name]['model_paths'], |
|
687 | - 'class_paths' => self::$_settings[$addon_name]['class_paths'], |
|
688 | - ) |
|
689 | - ); |
|
690 | - } |
|
691 | - // register model extensions |
|
692 | - if ( |
|
693 | - ! empty(self::$_settings[$addon_name]['model_extension_paths']) |
|
694 | - || ! empty(self::$_settings[$addon_name]['class_extension_paths']) |
|
695 | - ) { |
|
696 | - EE_Register_Model_Extensions::register( |
|
697 | - $addon_name, |
|
698 | - array( |
|
699 | - 'model_extension_paths' => self::$_settings[$addon_name]['model_extension_paths'], |
|
700 | - 'class_extension_paths' => self::$_settings[$addon_name]['class_extension_paths'], |
|
701 | - ) |
|
702 | - ); |
|
703 | - } |
|
704 | - } |
|
705 | - |
|
706 | - |
|
707 | - |
|
708 | - /** |
|
709 | - * @param string $addon_name |
|
710 | - * @return void |
|
711 | - * @throws \EE_Error |
|
712 | - */ |
|
678 | + // register new models |
|
679 | + if ( |
|
680 | + ! empty(self::$_settings[$addon_name]['model_paths']) |
|
681 | + || ! empty(self::$_settings[$addon_name]['class_paths']) |
|
682 | + ) { |
|
683 | + EE_Register_Model::register( |
|
684 | + $addon_name, |
|
685 | + array( |
|
686 | + 'model_paths' => self::$_settings[$addon_name]['model_paths'], |
|
687 | + 'class_paths' => self::$_settings[$addon_name]['class_paths'], |
|
688 | + ) |
|
689 | + ); |
|
690 | + } |
|
691 | + // register model extensions |
|
692 | + if ( |
|
693 | + ! empty(self::$_settings[$addon_name]['model_extension_paths']) |
|
694 | + || ! empty(self::$_settings[$addon_name]['class_extension_paths']) |
|
695 | + ) { |
|
696 | + EE_Register_Model_Extensions::register( |
|
697 | + $addon_name, |
|
698 | + array( |
|
699 | + 'model_extension_paths' => self::$_settings[$addon_name]['model_extension_paths'], |
|
700 | + 'class_extension_paths' => self::$_settings[$addon_name]['class_extension_paths'], |
|
701 | + ) |
|
702 | + ); |
|
703 | + } |
|
704 | + } |
|
705 | + |
|
706 | + |
|
707 | + |
|
708 | + /** |
|
709 | + * @param string $addon_name |
|
710 | + * @return void |
|
711 | + * @throws \EE_Error |
|
712 | + */ |
|
713 | 713 | private static function _register_data_migration_scripts( $addon_name ) { |
714 | - // setup DMS |
|
715 | - if ( ! empty(self::$_settings[$addon_name]['dms_paths'])) { |
|
716 | - EE_Register_Data_Migration_Scripts::register( |
|
717 | - $addon_name, |
|
718 | - array('dms_paths' => self::$_settings[$addon_name]['dms_paths']) |
|
719 | - ); |
|
720 | - } |
|
721 | - } |
|
722 | - |
|
723 | - |
|
724 | - /** |
|
725 | - * @param string $addon_name |
|
726 | - * @return void |
|
727 | - * @throws \EE_Error |
|
728 | - */ |
|
714 | + // setup DMS |
|
715 | + if ( ! empty(self::$_settings[$addon_name]['dms_paths'])) { |
|
716 | + EE_Register_Data_Migration_Scripts::register( |
|
717 | + $addon_name, |
|
718 | + array('dms_paths' => self::$_settings[$addon_name]['dms_paths']) |
|
719 | + ); |
|
720 | + } |
|
721 | + } |
|
722 | + |
|
723 | + |
|
724 | + /** |
|
725 | + * @param string $addon_name |
|
726 | + * @return void |
|
727 | + * @throws \EE_Error |
|
728 | + */ |
|
729 | 729 | private static function _register_config( $addon_name ) { |
730 | - // if config_class is present let's register config. |
|
731 | - if ( ! empty(self::$_settings[$addon_name]['config_class'])) { |
|
732 | - EE_Register_Config::register( |
|
733 | - self::$_settings[$addon_name]['config_class'], |
|
734 | - array( |
|
735 | - 'config_section' => self::$_settings[$addon_name]['config_section'], |
|
736 | - 'config_name' => self::$_settings[$addon_name]['config_name'], |
|
737 | - ) |
|
738 | - ); |
|
739 | - } |
|
740 | - } |
|
741 | - |
|
742 | - |
|
743 | - /** |
|
744 | - * @param string $addon_name |
|
745 | - * @return void |
|
746 | - * @throws \EE_Error |
|
747 | - */ |
|
730 | + // if config_class is present let's register config. |
|
731 | + if ( ! empty(self::$_settings[$addon_name]['config_class'])) { |
|
732 | + EE_Register_Config::register( |
|
733 | + self::$_settings[$addon_name]['config_class'], |
|
734 | + array( |
|
735 | + 'config_section' => self::$_settings[$addon_name]['config_section'], |
|
736 | + 'config_name' => self::$_settings[$addon_name]['config_name'], |
|
737 | + ) |
|
738 | + ); |
|
739 | + } |
|
740 | + } |
|
741 | + |
|
742 | + |
|
743 | + /** |
|
744 | + * @param string $addon_name |
|
745 | + * @return void |
|
746 | + * @throws \EE_Error |
|
747 | + */ |
|
748 | 748 | private static function _register_admin_pages( $addon_name ) { |
749 | - if ( ! empty(self::$_settings[$addon_name]['admin_path'])) { |
|
750 | - EE_Register_Admin_Page::register( |
|
751 | - $addon_name, |
|
752 | - array('page_path' => self::$_settings[$addon_name]['admin_path']) |
|
753 | - ); |
|
754 | - } |
|
755 | - } |
|
756 | - |
|
757 | - |
|
758 | - /** |
|
759 | - * @param string $addon_name |
|
760 | - * @return void |
|
761 | - * @throws \EE_Error |
|
762 | - */ |
|
749 | + if ( ! empty(self::$_settings[$addon_name]['admin_path'])) { |
|
750 | + EE_Register_Admin_Page::register( |
|
751 | + $addon_name, |
|
752 | + array('page_path' => self::$_settings[$addon_name]['admin_path']) |
|
753 | + ); |
|
754 | + } |
|
755 | + } |
|
756 | + |
|
757 | + |
|
758 | + /** |
|
759 | + * @param string $addon_name |
|
760 | + * @return void |
|
761 | + * @throws \EE_Error |
|
762 | + */ |
|
763 | 763 | private static function _register_modules( $addon_name ) { |
764 | - if ( ! empty(self::$_settings[$addon_name]['module_paths'])) { |
|
765 | - EE_Register_Module::register( |
|
766 | - $addon_name, |
|
767 | - array('module_paths' => self::$_settings[$addon_name]['module_paths']) |
|
768 | - ); |
|
769 | - } |
|
770 | - } |
|
771 | - |
|
772 | - |
|
773 | - /** |
|
774 | - * @param string $addon_name |
|
775 | - * @return void |
|
776 | - * @throws \EE_Error |
|
777 | - */ |
|
764 | + if ( ! empty(self::$_settings[$addon_name]['module_paths'])) { |
|
765 | + EE_Register_Module::register( |
|
766 | + $addon_name, |
|
767 | + array('module_paths' => self::$_settings[$addon_name]['module_paths']) |
|
768 | + ); |
|
769 | + } |
|
770 | + } |
|
771 | + |
|
772 | + |
|
773 | + /** |
|
774 | + * @param string $addon_name |
|
775 | + * @return void |
|
776 | + * @throws \EE_Error |
|
777 | + */ |
|
778 | 778 | private static function _register_shortcodes( $addon_name ) { |
779 | - if ( ! empty(self::$_settings[$addon_name]['shortcode_paths'])) { |
|
780 | - EE_Register_Shortcode::register( |
|
781 | - $addon_name, |
|
782 | - array('shortcode_paths' => self::$_settings[$addon_name]['shortcode_paths']) |
|
783 | - ); |
|
784 | - } |
|
785 | - } |
|
786 | - |
|
787 | - |
|
788 | - /** |
|
789 | - * @param string $addon_name |
|
790 | - * @return void |
|
791 | - * @throws \EE_Error |
|
792 | - */ |
|
779 | + if ( ! empty(self::$_settings[$addon_name]['shortcode_paths'])) { |
|
780 | + EE_Register_Shortcode::register( |
|
781 | + $addon_name, |
|
782 | + array('shortcode_paths' => self::$_settings[$addon_name]['shortcode_paths']) |
|
783 | + ); |
|
784 | + } |
|
785 | + } |
|
786 | + |
|
787 | + |
|
788 | + /** |
|
789 | + * @param string $addon_name |
|
790 | + * @return void |
|
791 | + * @throws \EE_Error |
|
792 | + */ |
|
793 | 793 | private static function _register_widgets( $addon_name ) { |
794 | - if ( ! empty(self::$_settings[$addon_name]['widget_paths'])) { |
|
795 | - EE_Register_Widget::register( |
|
796 | - $addon_name, |
|
797 | - array('widget_paths' => self::$_settings[$addon_name]['widget_paths']) |
|
798 | - ); |
|
799 | - } |
|
800 | - } |
|
801 | - |
|
802 | - |
|
803 | - /** |
|
804 | - * @param string $addon_name |
|
805 | - * @return void |
|
806 | - * @throws \EE_Error |
|
807 | - */ |
|
794 | + if ( ! empty(self::$_settings[$addon_name]['widget_paths'])) { |
|
795 | + EE_Register_Widget::register( |
|
796 | + $addon_name, |
|
797 | + array('widget_paths' => self::$_settings[$addon_name]['widget_paths']) |
|
798 | + ); |
|
799 | + } |
|
800 | + } |
|
801 | + |
|
802 | + |
|
803 | + /** |
|
804 | + * @param string $addon_name |
|
805 | + * @return void |
|
806 | + * @throws \EE_Error |
|
807 | + */ |
|
808 | 808 | private static function _register_capabilities( $addon_name ) { |
809 | - if ( ! empty(self::$_settings[$addon_name]['capabilities'])) { |
|
810 | - EE_Register_Capabilities::register( |
|
811 | - $addon_name, |
|
812 | - array( |
|
813 | - 'capabilities' => self::$_settings[$addon_name]['capabilities'], |
|
814 | - 'capability_maps' => self::$_settings[$addon_name]['capability_maps'], |
|
815 | - ) |
|
816 | - ); |
|
817 | - } |
|
818 | - } |
|
819 | - |
|
820 | - |
|
821 | - /** |
|
822 | - * @param string $addon_name |
|
823 | - * @return void |
|
824 | - * @throws \EE_Error |
|
825 | - */ |
|
809 | + if ( ! empty(self::$_settings[$addon_name]['capabilities'])) { |
|
810 | + EE_Register_Capabilities::register( |
|
811 | + $addon_name, |
|
812 | + array( |
|
813 | + 'capabilities' => self::$_settings[$addon_name]['capabilities'], |
|
814 | + 'capability_maps' => self::$_settings[$addon_name]['capability_maps'], |
|
815 | + ) |
|
816 | + ); |
|
817 | + } |
|
818 | + } |
|
819 | + |
|
820 | + |
|
821 | + /** |
|
822 | + * @param string $addon_name |
|
823 | + * @return void |
|
824 | + * @throws \EE_Error |
|
825 | + */ |
|
826 | 826 | private static function _register_message_types( $addon_name ) { |
827 | - if ( ! empty(self::$_settings[$addon_name]['message_types'])) { |
|
828 | - add_action( |
|
829 | - 'EE_Brewing_Regular___messages_caf', |
|
830 | - array('EE_Register_Addon', 'register_message_types') |
|
831 | - ); |
|
832 | - } |
|
833 | - } |
|
834 | - |
|
835 | - |
|
836 | - /** |
|
837 | - * @param string $addon_name |
|
838 | - * @return void |
|
839 | - * @throws \EE_Error |
|
840 | - */ |
|
827 | + if ( ! empty(self::$_settings[$addon_name]['message_types'])) { |
|
828 | + add_action( |
|
829 | + 'EE_Brewing_Regular___messages_caf', |
|
830 | + array('EE_Register_Addon', 'register_message_types') |
|
831 | + ); |
|
832 | + } |
|
833 | + } |
|
834 | + |
|
835 | + |
|
836 | + /** |
|
837 | + * @param string $addon_name |
|
838 | + * @return void |
|
839 | + * @throws \EE_Error |
|
840 | + */ |
|
841 | 841 | private static function _register_custom_post_types( $addon_name ) { |
842 | - if ( |
|
843 | - ! empty(self::$_settings[$addon_name]['custom_post_types']) |
|
844 | - || ! empty(self::$_settings[$addon_name]['custom_taxonomies']) |
|
845 | - ) { |
|
846 | - EE_Register_CPT::register( |
|
847 | - $addon_name, |
|
848 | - array( |
|
849 | - 'cpts' => self::$_settings[$addon_name]['custom_post_types'], |
|
850 | - 'cts' => self::$_settings[$addon_name]['custom_taxonomies'], |
|
851 | - 'default_terms' => self::$_settings[$addon_name]['default_terms'], |
|
852 | - ) |
|
853 | - ); |
|
854 | - } |
|
855 | - } |
|
856 | - |
|
857 | - |
|
858 | - /** |
|
859 | - * @param string $addon_name |
|
860 | - * @return void |
|
861 | - * @throws \EE_Error |
|
862 | - */ |
|
842 | + if ( |
|
843 | + ! empty(self::$_settings[$addon_name]['custom_post_types']) |
|
844 | + || ! empty(self::$_settings[$addon_name]['custom_taxonomies']) |
|
845 | + ) { |
|
846 | + EE_Register_CPT::register( |
|
847 | + $addon_name, |
|
848 | + array( |
|
849 | + 'cpts' => self::$_settings[$addon_name]['custom_post_types'], |
|
850 | + 'cts' => self::$_settings[$addon_name]['custom_taxonomies'], |
|
851 | + 'default_terms' => self::$_settings[$addon_name]['default_terms'], |
|
852 | + ) |
|
853 | + ); |
|
854 | + } |
|
855 | + } |
|
856 | + |
|
857 | + |
|
858 | + /** |
|
859 | + * @param string $addon_name |
|
860 | + * @return void |
|
861 | + * @throws \EE_Error |
|
862 | + */ |
|
863 | 863 | private static function _register_payment_methods( $addon_name ) { |
864 | - if ( ! empty(self::$_settings[$addon_name]['payment_method_paths'])) { |
|
865 | - EE_Register_Payment_Method::register( |
|
866 | - $addon_name, |
|
867 | - array('payment_method_paths' => self::$_settings[$addon_name]['payment_method_paths']) |
|
868 | - ); |
|
869 | - } |
|
870 | - } |
|
864 | + if ( ! empty(self::$_settings[$addon_name]['payment_method_paths'])) { |
|
865 | + EE_Register_Payment_Method::register( |
|
866 | + $addon_name, |
|
867 | + array('payment_method_paths' => self::$_settings[$addon_name]['payment_method_paths']) |
|
868 | + ); |
|
869 | + } |
|
870 | + } |
|
871 | 871 | |
872 | 872 | |
873 | 873 | |
@@ -896,14 +896,14 @@ discard block |
||
896 | 896 | //unfortunately this can't be hooked in upon construction, because we don't have |
897 | 897 | //the plugin mainfile's path upon construction. |
898 | 898 | register_deactivation_hook( $addon->get_main_plugin_file(), array( $addon, 'deactivation' ) ); |
899 | - // call any additional admin_callback functions during load_admin_controller hook |
|
900 | - if ( ! empty(self::$_settings[$addon_name]['admin_callback'])) { |
|
901 | - add_action( |
|
902 | - 'AHEE__EE_System__load_controllers__load_admin_controllers', |
|
903 | - array($addon, self::$_settings[$addon_name]['admin_callback']) |
|
904 | - ); |
|
905 | - } |
|
906 | - return $addon; |
|
899 | + // call any additional admin_callback functions during load_admin_controller hook |
|
900 | + if ( ! empty(self::$_settings[$addon_name]['admin_callback'])) { |
|
901 | + add_action( |
|
902 | + 'AHEE__EE_System__load_controllers__load_admin_controllers', |
|
903 | + array($addon, self::$_settings[$addon_name]['admin_callback']) |
|
904 | + ); |
|
905 | + } |
|
906 | + return $addon; |
|
907 | 907 | } |
908 | 908 | |
909 | 909 | |
@@ -999,15 +999,15 @@ discard block |
||
999 | 999 | EE_Register_Widget::deregister( $addon_name ); |
1000 | 1000 | } |
1001 | 1001 | if ( ! empty( self::$_settings[ $addon_name ]['model_paths'] ) |
1002 | - || |
|
1003 | - ! empty( self::$_settings[ $addon_name ]['class_paths'] ) |
|
1002 | + || |
|
1003 | + ! empty( self::$_settings[ $addon_name ]['class_paths'] ) |
|
1004 | 1004 | ) { |
1005 | 1005 | // add to list of shortcodes to be registered |
1006 | 1006 | EE_Register_Model::deregister( $addon_name ); |
1007 | 1007 | } |
1008 | 1008 | if ( ! empty( self::$_settings[ $addon_name ]['model_extension_paths'] ) |
1009 | - || |
|
1010 | - ! empty( self::$_settings[ $addon_name ]['class_extension_paths'] ) |
|
1009 | + || |
|
1010 | + ! empty( self::$_settings[ $addon_name ]['class_extension_paths'] ) |
|
1011 | 1011 | ) { |
1012 | 1012 | // add to list of shortcodes to be registered |
1013 | 1013 | EE_Register_Model_Extensions::deregister( $addon_name ); |