@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public static function instance() { |
104 | 104 | // check if class object is instantiated |
105 | - if ( ! self::$_instance instanceof EE_System ) { |
|
105 | + if ( ! self::$_instance instanceof EE_System) { |
|
106 | 106 | self::$_instance = new self(); |
107 | 107 | } |
108 | 108 | return self::$_instance; |
@@ -113,12 +113,12 @@ discard block |
||
113 | 113 | * resets the instance and returns it |
114 | 114 | * @return EE_System |
115 | 115 | */ |
116 | - public static function reset(){ |
|
116 | + public static function reset() { |
|
117 | 117 | self::$_instance->_req_type = NULL; |
118 | 118 | //we need to reset the migration manager in order for it to detect DMSs properly |
119 | 119 | EE_Data_Migration_Manager::reset(); |
120 | 120 | //make sure none of the old hooks are left hanging around |
121 | - remove_all_actions( 'AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
121 | + remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
122 | 122 | self::instance()->detect_activations_or_upgrades(); |
123 | 123 | self::instance()->perform_activations_upgrades_and_migrations(); |
124 | 124 | return self::instance(); |
@@ -134,26 +134,26 @@ discard block |
||
134 | 134 | * @access private |
135 | 135 | */ |
136 | 136 | private function __construct() { |
137 | - do_action( 'AHEE__EE_System__construct__begin', $this ); |
|
137 | + do_action('AHEE__EE_System__construct__begin', $this); |
|
138 | 138 | // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc |
139 | - add_action( 'AHEE__EE_Bootstrap__load_espresso_addons', array( $this, 'load_espresso_addons' ) ); |
|
139 | + add_action('AHEE__EE_Bootstrap__load_espresso_addons', array($this, 'load_espresso_addons')); |
|
140 | 140 | // when an ee addon is activated, we want to call the core hook(s) again |
141 | 141 | // because the newly-activated addon didn't get a chance to run at all |
142 | - add_action( 'activate_plugin', array( $this, 'load_espresso_addons' ), 1 ); |
|
142 | + add_action('activate_plugin', array($this, 'load_espresso_addons'), 1); |
|
143 | 143 | // detect whether install or upgrade |
144 | - add_action( 'AHEE__EE_Bootstrap__detect_activations_or_upgrades', array( $this, 'detect_activations_or_upgrades' ), 3 ); |
|
144 | + add_action('AHEE__EE_Bootstrap__detect_activations_or_upgrades', array($this, 'detect_activations_or_upgrades'), 3); |
|
145 | 145 | // load EE_Config, EE_Textdomain, etc |
146 | - add_action( 'AHEE__EE_Bootstrap__load_core_configuration', array( $this, 'load_core_configuration' ), 5 ); |
|
146 | + add_action('AHEE__EE_Bootstrap__load_core_configuration', array($this, 'load_core_configuration'), 5); |
|
147 | 147 | // load EE_Config, EE_Textdomain, etc |
148 | - add_action( 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', array( $this, 'register_shortcodes_modules_and_widgets' ), 7 ); |
|
148 | + add_action('AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', array($this, 'register_shortcodes_modules_and_widgets'), 7); |
|
149 | 149 | // you wanna get going? I wanna get going... let's get going! |
150 | - add_action( 'AHEE__EE_Bootstrap__brew_espresso', array( $this, 'brew_espresso' ), 9 ); |
|
150 | + add_action('AHEE__EE_Bootstrap__brew_espresso', array($this, 'brew_espresso'), 9); |
|
151 | 151 | //other housekeeping |
152 | 152 | //exclude EE critical pages from wp_list_pages |
153 | - add_filter( 'wp_list_pages_excludes', array( $this, 'remove_pages_from_wp_list_pages' ), 10 ); |
|
153 | + add_filter('wp_list_pages_excludes', array($this, 'remove_pages_from_wp_list_pages'), 10); |
|
154 | 154 | // ALL EE Addons should use the following hook point to attach their initial setup too |
155 | 155 | // it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads |
156 | - do_action( 'AHEE__EE_System__construct__complete', $this ); |
|
156 | + do_action('AHEE__EE_System__construct__complete', $this); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | |
@@ -173,13 +173,13 @@ discard block |
||
173 | 173 | public function load_espresso_addons() { |
174 | 174 | // set autoloaders for all of the classes implementing EEI_Plugin_API |
175 | 175 | // which provide helpers for EE plugin authors to more easily register certain components with EE. |
176 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder( EE_LIBRARIES . 'plugin_api' ); |
|
176 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'plugin_api'); |
|
177 | 177 | //load and setup EE_Capabilities |
178 | - EE_Registry::instance()->load_core( 'Capabilities' ); |
|
178 | + EE_Registry::instance()->load_core('Capabilities'); |
|
179 | 179 | //caps need to be initialized on every request so that capability maps are set. |
180 | 180 | //@see https://events.codebasehq.com/projects/event-espresso/tickets/8674 |
181 | 181 | EE_Registry::instance()->CAP->init_caps(); |
182 | - do_action( 'AHEE__EE_System__load_espresso_addons' ); |
|
182 | + do_action('AHEE__EE_System__load_espresso_addons'); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | |
@@ -194,10 +194,10 @@ discard block |
||
194 | 194 | * @access public |
195 | 195 | * @return void |
196 | 196 | */ |
197 | - public function detect_activations_or_upgrades(){ |
|
197 | + public function detect_activations_or_upgrades() { |
|
198 | 198 | //first off: let's make sure to handle core |
199 | 199 | $this->detect_if_activation_or_upgrade(); |
200 | - foreach(EE_Registry::instance()->addons as $addon){ |
|
200 | + foreach (EE_Registry::instance()->addons as $addon) { |
|
201 | 201 | //detect teh request type for that addon |
202 | 202 | $addon->detect_activation_or_upgrade(); |
203 | 203 | } |
@@ -218,44 +218,44 @@ discard block |
||
218 | 218 | do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin'); |
219 | 219 | |
220 | 220 | // load M-Mode class |
221 | - EE_Registry::instance()->load_core( 'Maintenance_Mode' ); |
|
221 | + EE_Registry::instance()->load_core('Maintenance_Mode'); |
|
222 | 222 | // check if db has been updated, or if its a brand-new installation |
223 | 223 | |
224 | 224 | $espresso_db_update = $this->fix_espresso_db_upgrade_option(); |
225 | - $request_type = $this->detect_req_type($espresso_db_update); |
|
225 | + $request_type = $this->detect_req_type($espresso_db_update); |
|
226 | 226 | //EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ ); |
227 | - if( $request_type != EE_System::req_type_normal){ |
|
227 | + if ($request_type != EE_System::req_type_normal) { |
|
228 | 228 | EE_Registry::instance()->load_helper('Activation'); |
229 | 229 | } |
230 | 230 | |
231 | - switch($request_type){ |
|
231 | + switch ($request_type) { |
|
232 | 232 | case EE_System::req_type_new_activation: |
233 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__new_activation' ); |
|
234 | - $this->_handle_core_version_change( $espresso_db_update ); |
|
233 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation'); |
|
234 | + $this->_handle_core_version_change($espresso_db_update); |
|
235 | 235 | break; |
236 | 236 | case EE_System::req_type_reactivation: |
237 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__reactivation' ); |
|
238 | - $this->_handle_core_version_change( $espresso_db_update ); |
|
237 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation'); |
|
238 | + $this->_handle_core_version_change($espresso_db_update); |
|
239 | 239 | break; |
240 | 240 | case EE_System::req_type_upgrade: |
241 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__upgrade' ); |
|
241 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade'); |
|
242 | 242 | //migrations may be required now that we've upgraded |
243 | 243 | EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
244 | - $this->_handle_core_version_change( $espresso_db_update ); |
|
244 | + $this->_handle_core_version_change($espresso_db_update); |
|
245 | 245 | // echo "done upgrade";die; |
246 | 246 | break; |
247 | 247 | case EE_System::req_type_downgrade: |
248 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__downgrade' ); |
|
248 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade'); |
|
249 | 249 | //its possible migrations are no longer required |
250 | 250 | EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
251 | - $this->_handle_core_version_change( $espresso_db_update ); |
|
251 | + $this->_handle_core_version_change($espresso_db_update); |
|
252 | 252 | break; |
253 | 253 | case EE_System::req_type_normal: |
254 | 254 | default: |
255 | 255 | // $this->_maybe_redirect_to_ee_about(); |
256 | 256 | break; |
257 | 257 | } |
258 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__complete' ); |
|
258 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete'); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | /** |
@@ -263,10 +263,10 @@ discard block |
||
263 | 263 | * initializing the database later during the request |
264 | 264 | * @param array $espresso_db_update |
265 | 265 | */ |
266 | - protected function _handle_core_version_change( $espresso_db_update ){ |
|
267 | - $this->update_list_of_installed_versions( $espresso_db_update ); |
|
266 | + protected function _handle_core_version_change($espresso_db_update) { |
|
267 | + $this->update_list_of_installed_versions($espresso_db_update); |
|
268 | 268 | //get ready to verify the DB is ok (provided we aren't in maintenance mode, of course) |
269 | - add_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations', array( $this, 'initialize_db_if_no_migrations_required' )); |
|
269 | + add_action('AHEE__EE_System__perform_activations_upgrades_and_migrations', array($this, 'initialize_db_if_no_migrations_required')); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | |
@@ -281,44 +281,44 @@ discard block |
||
281 | 281 | * @internal param array $espresso_db_update_value the value of the WordPress option. If not supplied, fetches it from the options table |
282 | 282 | * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction |
283 | 283 | */ |
284 | - private function fix_espresso_db_upgrade_option($espresso_db_update = null){ |
|
285 | - do_action( 'FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update ); |
|
286 | - if( ! $espresso_db_update){ |
|
287 | - $espresso_db_update = get_option( 'espresso_db_update' ); |
|
284 | + private function fix_espresso_db_upgrade_option($espresso_db_update = null) { |
|
285 | + do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update); |
|
286 | + if ( ! $espresso_db_update) { |
|
287 | + $espresso_db_update = get_option('espresso_db_update'); |
|
288 | 288 | } |
289 | 289 | // check that option is an array |
290 | - if( ! is_array( $espresso_db_update )) { |
|
290 | + if ( ! is_array($espresso_db_update)) { |
|
291 | 291 | // if option is FALSE, then it never existed |
292 | - if ( $espresso_db_update === FALSE ) { |
|
292 | + if ($espresso_db_update === FALSE) { |
|
293 | 293 | // make $espresso_db_update an array and save option with autoload OFF |
294 | - $espresso_db_update = array(); |
|
295 | - add_option( 'espresso_db_update', $espresso_db_update, '', 'no' ); |
|
294 | + $espresso_db_update = array(); |
|
295 | + add_option('espresso_db_update', $espresso_db_update, '', 'no'); |
|
296 | 296 | } else { |
297 | 297 | // option is NOT FALSE but also is NOT an array, so make it an array and save it |
298 | - $espresso_db_update = array( $espresso_db_update=>array() ); |
|
299 | - update_option( 'espresso_db_update', $espresso_db_update ); |
|
298 | + $espresso_db_update = array($espresso_db_update=>array()); |
|
299 | + update_option('espresso_db_update', $espresso_db_update); |
|
300 | 300 | } |
301 | - }else{ |
|
301 | + } else { |
|
302 | 302 | $corrected_db_update = array(); |
303 | 303 | //if IS an array, but is it an array where KEYS are version numbers, and values are arrays? |
304 | - foreach($espresso_db_update as $should_be_version_string => $should_be_array){ |
|
305 | - if(is_int($should_be_version_string) && ! is_array($should_be_array)){ |
|
304 | + foreach ($espresso_db_update as $should_be_version_string => $should_be_array) { |
|
305 | + if (is_int($should_be_version_string) && ! is_array($should_be_array)) { |
|
306 | 306 | //the key is an int, and the value IS NOT an array |
307 | 307 | //so it must be numerically-indexed, where values are versions installed... |
308 | 308 | //fix it! |
309 | 309 | $version_string = $should_be_array; |
310 | 310 | $corrected_db_update[$version_string] = array('unknown-date'); |
311 | - }else{ |
|
311 | + } else { |
|
312 | 312 | //ok it checks out |
313 | 313 | $corrected_db_update[$should_be_version_string] = $should_be_array; |
314 | 314 | } |
315 | 315 | } |
316 | 316 | $espresso_db_update = $corrected_db_update; |
317 | - update_option( 'espresso_db_update', $espresso_db_update ); |
|
317 | + update_option('espresso_db_update', $espresso_db_update); |
|
318 | 318 | |
319 | 319 | } |
320 | 320 | |
321 | - do_action( 'FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update ); |
|
321 | + do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update); |
|
322 | 322 | return $espresso_db_update; |
323 | 323 | } |
324 | 324 | |
@@ -337,33 +337,33 @@ discard block |
||
337 | 337 | * so we prefer to only do it when necessary |
338 | 338 | * @return void |
339 | 339 | */ |
340 | - public function initialize_db_if_no_migrations_required( $initialize_addons_too = FALSE, $verify_schema = true ){ |
|
340 | + public function initialize_db_if_no_migrations_required($initialize_addons_too = FALSE, $verify_schema = true) { |
|
341 | 341 | $request_type = $this->detect_req_type(); |
342 | 342 | //only initialize system if we're not in maintenance mode. |
343 | - if( EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance ){ |
|
344 | - update_option( 'ee_flush_rewrite_rules', TRUE ); |
|
343 | + if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
344 | + update_option('ee_flush_rewrite_rules', TRUE); |
|
345 | 345 | EEH_Activation::system_initialization(); |
346 | - if( $verify_schema ) { |
|
346 | + if ($verify_schema) { |
|
347 | 347 | EEH_Activation::initialize_db_and_folders(); |
348 | 348 | } |
349 | 349 | EEH_Activation::initialize_db_content(); |
350 | - if( $initialize_addons_too ) { |
|
350 | + if ($initialize_addons_too) { |
|
351 | 351 | $this->initialize_addons(); |
352 | 352 | } |
353 | - }else{ |
|
354 | - EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for( 'Core' ); |
|
353 | + } else { |
|
354 | + EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core'); |
|
355 | 355 | } |
356 | - if ( $request_type == EE_System::req_type_new_activation || $request_type == EE_System::req_type_reactivation || $request_type == EE_System::req_type_upgrade ) { |
|
357 | - add_action( 'AHEE__EE_System__load_CPTs_and_session__start', array( $this, 'redirect_to_about_ee' ), 9 ); |
|
356 | + if ($request_type == EE_System::req_type_new_activation || $request_type == EE_System::req_type_reactivation || $request_type == EE_System::req_type_upgrade) { |
|
357 | + add_action('AHEE__EE_System__load_CPTs_and_session__start', array($this, 'redirect_to_about_ee'), 9); |
|
358 | 358 | } |
359 | 359 | } |
360 | 360 | |
361 | 361 | /** |
362 | 362 | * Initializes the db for all registered addons |
363 | 363 | */ |
364 | - public function initialize_addons(){ |
|
364 | + public function initialize_addons() { |
|
365 | 365 | //foreach registered addon, make sure its db is up-to-date too |
366 | - foreach(EE_Registry::instance()->addons as $addon){ |
|
366 | + foreach (EE_Registry::instance()->addons as $addon) { |
|
367 | 367 | $addon->initialize_db_if_no_migrations_required(); |
368 | 368 | } |
369 | 369 | } |
@@ -375,16 +375,16 @@ discard block |
||
375 | 375 | * @param string $current_version_to_add version to be added to the version history |
376 | 376 | * @return boolean success as to whether or not this option was changed |
377 | 377 | */ |
378 | - public function update_list_of_installed_versions($version_history = NULL,$current_version_to_add = NULL) { |
|
379 | - if( ! $version_history ) { |
|
378 | + public function update_list_of_installed_versions($version_history = NULL, $current_version_to_add = NULL) { |
|
379 | + if ( ! $version_history) { |
|
380 | 380 | $version_history = $this->fix_espresso_db_upgrade_option($version_history); |
381 | 381 | } |
382 | - if( $current_version_to_add == NULL){ |
|
382 | + if ($current_version_to_add == NULL) { |
|
383 | 383 | $current_version_to_add = espresso_version(); |
384 | 384 | } |
385 | - $version_history[ $current_version_to_add ][] = date( 'Y-m-d H:i:s',time() ); |
|
385 | + $version_history[$current_version_to_add][] = date('Y-m-d H:i:s', time()); |
|
386 | 386 | // re-save |
387 | - return update_option( 'espresso_db_update', $version_history ); |
|
387 | + return update_option('espresso_db_update', $version_history); |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | |
@@ -401,10 +401,10 @@ discard block |
||
401 | 401 | * but still know if this is a new install or not |
402 | 402 | * @return int one of the constants on EE_System::req_type_ |
403 | 403 | */ |
404 | - public function detect_req_type( $espresso_db_update = NULL ){ |
|
405 | - if ( $this->_req_type === NULL ){ |
|
406 | - $espresso_db_update = ! empty( $espresso_db_update ) ? $espresso_db_update : $this->fix_espresso_db_upgrade_option(); |
|
407 | - $this->_req_type = $this->detect_req_type_given_activation_history( $espresso_db_update, 'ee_espresso_activation', espresso_version() ); |
|
404 | + public function detect_req_type($espresso_db_update = NULL) { |
|
405 | + if ($this->_req_type === NULL) { |
|
406 | + $espresso_db_update = ! empty($espresso_db_update) ? $espresso_db_update : $this->fix_espresso_db_upgrade_option(); |
|
407 | + $this->_req_type = $this->detect_req_type_given_activation_history($espresso_db_update, 'ee_espresso_activation', espresso_version()); |
|
408 | 408 | } |
409 | 409 | return $this->_req_type; |
410 | 410 | } |
@@ -420,39 +420,39 @@ discard block |
||
420 | 420 | * @param string $version_to_upgrade_to the version that was just upgraded to (for core that will be espresso_version()) |
421 | 421 | * @return int one of the constants on EE_System::req_type_* |
422 | 422 | */ |
423 | - public static function detect_req_type_given_activation_history( $activation_history_for_addon, $activation_indicator_option_name, $version_to_upgrade_to ){ |
|
424 | - $version_is_higher = self::_new_version_is_higher( $activation_history_for_addon, $version_to_upgrade_to ); |
|
425 | - if( $activation_history_for_addon ){ |
|
423 | + public static function detect_req_type_given_activation_history($activation_history_for_addon, $activation_indicator_option_name, $version_to_upgrade_to) { |
|
424 | + $version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to); |
|
425 | + if ($activation_history_for_addon) { |
|
426 | 426 | //it exists, so this isn't a completely new install |
427 | 427 | //check if this version already in that list of previously installed versions |
428 | - if ( ! isset( $activation_history_for_addon[ $version_to_upgrade_to ] )) { |
|
428 | + if ( ! isset($activation_history_for_addon[$version_to_upgrade_to])) { |
|
429 | 429 | //it a version we haven't seen before |
430 | - if( $version_is_higher === 1 ){ |
|
430 | + if ($version_is_higher === 1) { |
|
431 | 431 | $req_type = EE_System::req_type_upgrade; |
432 | - }else{ |
|
432 | + } else { |
|
433 | 433 | $req_type = EE_System::req_type_downgrade; |
434 | 434 | } |
435 | - delete_option( $activation_indicator_option_name ); |
|
435 | + delete_option($activation_indicator_option_name); |
|
436 | 436 | } else { |
437 | 437 | // its not an update. maybe a reactivation? |
438 | - if( get_option( $activation_indicator_option_name, FALSE ) ){ |
|
439 | - if ( $version_is_higher === -1 ){ |
|
438 | + if (get_option($activation_indicator_option_name, FALSE)) { |
|
439 | + if ($version_is_higher === -1) { |
|
440 | 440 | $req_type = EE_System::req_type_downgrade; |
441 | - }elseif( $version_is_higher === 0 ){ |
|
441 | + }elseif ($version_is_higher === 0) { |
|
442 | 442 | //we've seen this version before, but it's an activation. must be a reactivation |
443 | 443 | $req_type = EE_System::req_type_reactivation; |
444 | - }else{//$version_is_higher === 1 |
|
444 | + } else {//$version_is_higher === 1 |
|
445 | 445 | $req_type = EE_System::req_type_upgrade; |
446 | 446 | } |
447 | - delete_option( $activation_indicator_option_name ); |
|
447 | + delete_option($activation_indicator_option_name); |
|
448 | 448 | } else { |
449 | 449 | //we've seen this version before and the activation indicate doesn't show it was just activated |
450 | - if ( $version_is_higher === -1 ){ |
|
450 | + if ($version_is_higher === -1) { |
|
451 | 451 | $req_type = EE_System::req_type_downgrade; |
452 | - }elseif( $version_is_higher === 0 ){ |
|
452 | + }elseif ($version_is_higher === 0) { |
|
453 | 453 | //we've seen this version before and it's not an activation. its normal request |
454 | 454 | $req_type = EE_System::req_type_normal; |
455 | - }else{//$version_is_higher === 1 |
|
455 | + } else {//$version_is_higher === 1 |
|
456 | 456 | $req_type = EE_System::req_type_upgrade; |
457 | 457 | } |
458 | 458 | } |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | } else { |
461 | 461 | //brand new install |
462 | 462 | $req_type = EE_System::req_type_new_activation; |
463 | - delete_option( $activation_indicator_option_name ); |
|
463 | + delete_option($activation_indicator_option_name); |
|
464 | 464 | } |
465 | 465 | return $req_type; |
466 | 466 | } |
@@ -478,30 +478,30 @@ discard block |
||
478 | 478 | * 0 if $version_to_upgrade_to MATCHES (reactivation or normal request); |
479 | 479 | * 1 if $version_to_upgrade_to is HIGHER (upgrade) ; |
480 | 480 | */ |
481 | - protected static function _new_version_is_higher( $activation_history_for_addon, $version_to_upgrade_to ){ |
|
481 | + protected static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to) { |
|
482 | 482 | //find the most recently-activated version |
483 | 483 | $most_recently_active_version_activation = '1970-01-01 00:00:00'; |
484 | 484 | $most_recently_active_version = '0.0.0.dev.000'; |
485 | - if( is_array( $activation_history_for_addon ) ){ |
|
486 | - foreach( $activation_history_for_addon as $version => $times_activated ){ |
|
485 | + if (is_array($activation_history_for_addon)) { |
|
486 | + foreach ($activation_history_for_addon as $version => $times_activated) { |
|
487 | 487 | //check there is a record of when this version was activated. Otherwise, |
488 | 488 | //mark it as unknown |
489 | - if( ! $times_activated ){ |
|
490 | - $times_activated = array( 'unknown-date'); |
|
489 | + if ( ! $times_activated) { |
|
490 | + $times_activated = array('unknown-date'); |
|
491 | 491 | } |
492 | - if( is_string( $times_activated ) ){ |
|
493 | - $times_activated = array( $times_activated ); |
|
492 | + if (is_string($times_activated)) { |
|
493 | + $times_activated = array($times_activated); |
|
494 | 494 | } |
495 | - foreach( $times_activated as $an_activation ){ |
|
496 | - if( $an_activation != 'unknown-date' && |
|
497 | - $an_activation > $most_recently_active_version_activation ){ |
|
495 | + foreach ($times_activated as $an_activation) { |
|
496 | + if ($an_activation != 'unknown-date' && |
|
497 | + $an_activation > $most_recently_active_version_activation) { |
|
498 | 498 | $most_recently_active_version = $version; |
499 | 499 | $most_recently_active_version_activation = $an_activation == 'unknown-date' ? '1970-01-01 00:00:00' : $an_activation; |
500 | 500 | } |
501 | 501 | } |
502 | 502 | } |
503 | 503 | } |
504 | - return version_compare( $version_to_upgrade_to, $most_recently_active_version ); |
|
504 | + return version_compare($version_to_upgrade_to, $most_recently_active_version); |
|
505 | 505 | } |
506 | 506 | |
507 | 507 | |
@@ -511,20 +511,20 @@ discard block |
||
511 | 511 | * @return void |
512 | 512 | */ |
513 | 513 | public function redirect_to_about_ee() { |
514 | - $notices = EE_Error::get_notices( FALSE ); |
|
514 | + $notices = EE_Error::get_notices(FALSE); |
|
515 | 515 | //if current user is an admin and it's not an ajax request |
516 | - if(EE_Registry::instance()->CAP->current_user_can( 'manage_options', 'espresso_about_default' ) && ! ( defined('DOING_AJAX') && DOING_AJAX ) && ! isset( $notices[ 'errors' ] ) ){ |
|
517 | - $query_params = array( 'page' => 'espresso_about' ); |
|
516 | + if (EE_Registry::instance()->CAP->current_user_can('manage_options', 'espresso_about_default') && ! (defined('DOING_AJAX') && DOING_AJAX) && ! isset($notices['errors'])) { |
|
517 | + $query_params = array('page' => 'espresso_about'); |
|
518 | 518 | |
519 | - if ( EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation ) { |
|
519 | + if (EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation) { |
|
520 | 520 | $query_params['new_activation'] = TRUE; |
521 | 521 | } |
522 | 522 | |
523 | - if ( EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation ) { |
|
523 | + if (EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation) { |
|
524 | 524 | $query_params['reactivation'] = TRUE; |
525 | 525 | } |
526 | - $url = add_query_arg( $query_params, admin_url( 'admin.php' ) ); |
|
527 | - wp_safe_redirect( $url ); |
|
526 | + $url = add_query_arg($query_params, admin_url('admin.php')); |
|
527 | + wp_safe_redirect($url); |
|
528 | 528 | exit(); |
529 | 529 | } |
530 | 530 | } |
@@ -538,31 +538,31 @@ discard block |
||
538 | 538 | * |
539 | 539 | * @return void |
540 | 540 | */ |
541 | - public function load_core_configuration(){ |
|
542 | - do_action( 'AHEE__EE_System__load_core_configuration__begin', $this ); |
|
543 | - EE_Registry::instance()->load_core( 'EE_Load_Textdomain' ); |
|
541 | + public function load_core_configuration() { |
|
542 | + do_action('AHEE__EE_System__load_core_configuration__begin', $this); |
|
543 | + EE_Registry::instance()->load_core('EE_Load_Textdomain'); |
|
544 | 544 | //load textdomain |
545 | 545 | EE_Load_Textdomain::load_textdomain(); |
546 | 546 | // load and setup EE_Config and EE_Network_Config |
547 | - EE_Registry::instance()->load_core( 'Config' ); |
|
548 | - EE_Registry::instance()->load_core( 'Network_Config' ); |
|
547 | + EE_Registry::instance()->load_core('Config'); |
|
548 | + EE_Registry::instance()->load_core('Network_Config'); |
|
549 | 549 | // setup autoloaders |
550 | 550 | // enable logging? |
551 | - if ( EE_Registry::instance()->CFG->admin->use_full_logging ) { |
|
552 | - EE_Registry::instance()->load_core( 'Log' ); |
|
551 | + if (EE_Registry::instance()->CFG->admin->use_full_logging) { |
|
552 | + EE_Registry::instance()->load_core('Log'); |
|
553 | 553 | } |
554 | 554 | // check for activation errors |
555 | - $activation_errors = get_option( 'ee_plugin_activation_errors', FALSE ); |
|
556 | - if ( $activation_errors ) { |
|
557 | - EE_Error::add_error( $activation_errors, __FILE__, __FUNCTION__, __LINE__ ); |
|
558 | - update_option( 'ee_plugin_activation_errors', FALSE ); |
|
555 | + $activation_errors = get_option('ee_plugin_activation_errors', FALSE); |
|
556 | + if ($activation_errors) { |
|
557 | + EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__); |
|
558 | + update_option('ee_plugin_activation_errors', FALSE); |
|
559 | 559 | } |
560 | 560 | // get model names |
561 | 561 | $this->_parse_model_names(); |
562 | 562 | |
563 | 563 | //load caf stuff a chance to play during the activation process too. |
564 | 564 | $this->_maybe_brew_regular(); |
565 | - do_action( 'AHEE__EE_System__load_core_configuration__complete', $this ); |
|
565 | + do_action('AHEE__EE_System__load_core_configuration__complete', $this); |
|
566 | 566 | } |
567 | 567 | |
568 | 568 | |
@@ -571,23 +571,23 @@ discard block |
||
571 | 571 | * |
572 | 572 | * @return void |
573 | 573 | */ |
574 | - private function _parse_model_names(){ |
|
574 | + private function _parse_model_names() { |
|
575 | 575 | //get all the files in the EE_MODELS folder that end in .model.php |
576 | - $models = glob( EE_MODELS.'*.model.php'); |
|
576 | + $models = glob(EE_MODELS.'*.model.php'); |
|
577 | 577 | $model_names = array(); |
578 | 578 | $non_abstract_db_models = array(); |
579 | - foreach( $models as $model ){ |
|
579 | + foreach ($models as $model) { |
|
580 | 580 | // get model classname |
581 | - $classname = EEH_File::get_classname_from_filepath_with_standard_filename( $model ); |
|
582 | - $shortname = str_replace( 'EEM_', '', $classname ); |
|
581 | + $classname = EEH_File::get_classname_from_filepath_with_standard_filename($model); |
|
582 | + $shortname = str_replace('EEM_', '', $classname); |
|
583 | 583 | $reflectionClass = new ReflectionClass($classname); |
584 | - if( $reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()){ |
|
584 | + if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) { |
|
585 | 585 | $non_abstract_db_models[$shortname] = $classname; |
586 | 586 | } |
587 | - $model_names[ $shortname ] = $classname; |
|
587 | + $model_names[$shortname] = $classname; |
|
588 | 588 | } |
589 | - EE_Registry::instance()->models = apply_filters( 'FHEE__EE_System__parse_model_names', $model_names ); |
|
590 | - EE_Registry::instance()->non_abstract_db_models = apply_filters( 'FHEE__EE_System__parse_implemented_model_names', $non_abstract_db_models ); |
|
589 | + EE_Registry::instance()->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names); |
|
590 | + EE_Registry::instance()->non_abstract_db_models = apply_filters('FHEE__EE_System__parse_implemented_model_names', $non_abstract_db_models); |
|
591 | 591 | } |
592 | 592 | |
593 | 593 | |
@@ -597,8 +597,8 @@ discard block |
||
597 | 597 | * @return void |
598 | 598 | */ |
599 | 599 | private function _maybe_brew_regular() { |
600 | - if (( ! defined( 'EE_DECAF' ) || EE_DECAF !== TRUE ) && is_readable( EE_CAFF_PATH . 'brewing_regular.php' )) { |
|
601 | - require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
600 | + if (( ! defined('EE_DECAF') || EE_DECAF !== TRUE) && is_readable(EE_CAFF_PATH.'brewing_regular.php')) { |
|
601 | + require_once EE_CAFF_PATH.'brewing_regular.php'; |
|
602 | 602 | } |
603 | 603 | } |
604 | 604 | |
@@ -615,9 +615,9 @@ discard block |
||
615 | 615 | * @return void |
616 | 616 | */ |
617 | 617 | public function register_shortcodes_modules_and_widgets() { |
618 | - do_action( 'AHEE__EE_System__register_shortcodes_modules_and_widgets' ); |
|
618 | + do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets'); |
|
619 | 619 | // check for addons using old hookpoint |
620 | - if ( has_action( 'AHEE__EE_System__register_shortcodes_modules_and_addons' )) { |
|
620 | + if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) { |
|
621 | 621 | $this->_incompatible_addon_error(); |
622 | 622 | } |
623 | 623 | } |
@@ -631,19 +631,19 @@ discard block |
||
631 | 631 | */ |
632 | 632 | private function _incompatible_addon_error() { |
633 | 633 | // get array of classes hooking into here |
634 | - $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook( 'AHEE__EE_System__register_shortcodes_modules_and_addons' ); |
|
635 | - if ( ! empty( $class_names )) { |
|
636 | - $msg = __( 'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', 'event_espresso' ); |
|
634 | + $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook('AHEE__EE_System__register_shortcodes_modules_and_addons'); |
|
635 | + if ( ! empty($class_names)) { |
|
636 | + $msg = __('The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', 'event_espresso'); |
|
637 | 637 | $msg .= '<ul>'; |
638 | - foreach ( $class_names as $class_name ) { |
|
639 | - $msg .= '<li><b>Event Espresso - ' . str_replace( array( 'EE_', 'EEM_', 'EED_', 'EES_', 'EEW_' ), '', $class_name ) . '</b></li>'; |
|
638 | + foreach ($class_names as $class_name) { |
|
639 | + $msg .= '<li><b>Event Espresso - '.str_replace(array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '', $class_name).'</b></li>'; |
|
640 | 640 | } |
641 | 641 | $msg .= '</ul>'; |
642 | - $msg .= __( 'Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', 'event_espresso' ); |
|
642 | + $msg .= __('Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', 'event_espresso'); |
|
643 | 643 | // save list of incompatible addons to wp-options for later use |
644 | - add_option( 'ee_incompatible_addons', $class_names, '', 'no' ); |
|
645 | - if ( is_admin() ) { |
|
646 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
644 | + add_option('ee_incompatible_addons', $class_names, '', 'no'); |
|
645 | + if (is_admin()) { |
|
646 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
647 | 647 | } |
648 | 648 | } |
649 | 649 | } |
@@ -660,25 +660,25 @@ discard block |
||
660 | 660 | * |
661 | 661 | * @return void |
662 | 662 | */ |
663 | - public function brew_espresso(){ |
|
664 | - do_action( 'AHEE__EE_System__brew_espresso__begin', $this ); |
|
663 | + public function brew_espresso() { |
|
664 | + do_action('AHEE__EE_System__brew_espresso__begin', $this); |
|
665 | 665 | // load some final core systems |
666 | - add_action( 'init', array( $this, 'set_hooks_for_core' ), 1 ); |
|
667 | - add_action( 'init', array( $this, 'perform_activations_upgrades_and_migrations' ), 3 ); |
|
668 | - add_action( 'init', array( $this, 'load_CPTs_and_session' ), 5 ); |
|
669 | - add_action( 'init', array( $this, 'load_controllers' ), 7 ); |
|
670 | - add_action( 'init', array( $this, 'core_loaded_and_ready' ), 9 ); |
|
671 | - add_action( 'init', array( $this, 'initialize' ), 10 ); |
|
672 | - add_action( 'init', array( $this, 'initialize_last' ), 100 ); |
|
673 | - add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 25 ); |
|
674 | - add_action( 'admin_bar_menu', array( $this, 'espresso_toolbar_items' ), 100 ); |
|
675 | - |
|
676 | - if ( is_admin() && apply_filters( 'FHEE__EE_System__brew_espresso__load_pue', TRUE ) ) { |
|
666 | + add_action('init', array($this, 'set_hooks_for_core'), 1); |
|
667 | + add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3); |
|
668 | + add_action('init', array($this, 'load_CPTs_and_session'), 5); |
|
669 | + add_action('init', array($this, 'load_controllers'), 7); |
|
670 | + add_action('init', array($this, 'core_loaded_and_ready'), 9); |
|
671 | + add_action('init', array($this, 'initialize'), 10); |
|
672 | + add_action('init', array($this, 'initialize_last'), 100); |
|
673 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 25); |
|
674 | + add_action('admin_bar_menu', array($this, 'espresso_toolbar_items'), 100); |
|
675 | + |
|
676 | + if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', TRUE)) { |
|
677 | 677 | // pew pew pew |
678 | - EE_Registry::instance()->load_core( 'PUE' ); |
|
679 | - do_action( 'AHEE__EE_System__brew_espresso__after_pue_init' ); |
|
678 | + EE_Registry::instance()->load_core('PUE'); |
|
679 | + do_action('AHEE__EE_System__brew_espresso__after_pue_init'); |
|
680 | 680 | } |
681 | - do_action( 'AHEE__EE_System__brew_espresso__complete', $this ); |
|
681 | + do_action('AHEE__EE_System__brew_espresso__complete', $this); |
|
682 | 682 | } |
683 | 683 | |
684 | 684 | |
@@ -692,7 +692,7 @@ discard block |
||
692 | 692 | */ |
693 | 693 | public function set_hooks_for_core() { |
694 | 694 | $this->_deactivate_incompatible_addons(); |
695 | - do_action( 'AHEE__EE_System__set_hooks_for_core' ); |
|
695 | + do_action('AHEE__EE_System__set_hooks_for_core'); |
|
696 | 696 | } |
697 | 697 | |
698 | 698 | |
@@ -701,15 +701,15 @@ discard block |
||
701 | 701 | * Using the information gathered in EE_System::_incompatible_addon_error, |
702 | 702 | * deactivates any addons considered incompatible with the current version of EE |
703 | 703 | */ |
704 | - private function _deactivate_incompatible_addons(){ |
|
705 | - $incompatible_addons = get_option( 'ee_incompatible_addons', array() ); |
|
706 | - if ( ! empty( $incompatible_addons )) { |
|
707 | - $active_plugins = get_option( 'active_plugins', array() ); |
|
708 | - foreach ( $active_plugins as $active_plugin ) { |
|
709 | - foreach ( $incompatible_addons as $incompatible_addon ) { |
|
710 | - if ( strpos( $active_plugin, $incompatible_addon ) !== FALSE ) { |
|
711 | - unset( $_GET['activate'] ); |
|
712 | - espresso_deactivate_plugin( $active_plugin ); |
|
704 | + private function _deactivate_incompatible_addons() { |
|
705 | + $incompatible_addons = get_option('ee_incompatible_addons', array()); |
|
706 | + if ( ! empty($incompatible_addons)) { |
|
707 | + $active_plugins = get_option('active_plugins', array()); |
|
708 | + foreach ($active_plugins as $active_plugin) { |
|
709 | + foreach ($incompatible_addons as $incompatible_addon) { |
|
710 | + if (strpos($active_plugin, $incompatible_addon) !== FALSE) { |
|
711 | + unset($_GET['activate']); |
|
712 | + espresso_deactivate_plugin($active_plugin); |
|
713 | 713 | } |
714 | 714 | } |
715 | 715 | } |
@@ -726,10 +726,10 @@ discard block |
||
726 | 726 | */ |
727 | 727 | public function perform_activations_upgrades_and_migrations() { |
728 | 728 | //first check if we had previously attempted to setup EE's directories but failed |
729 | - if( EEH_Activation::upload_directories_incomplete() ) { |
|
729 | + if (EEH_Activation::upload_directories_incomplete()) { |
|
730 | 730 | EEH_Activation::create_upload_directories(); |
731 | 731 | } |
732 | - do_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations' ); |
|
732 | + do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
733 | 733 | } |
734 | 734 | |
735 | 735 | |
@@ -741,10 +741,10 @@ discard block |
||
741 | 741 | * @return void |
742 | 742 | */ |
743 | 743 | public function load_CPTs_and_session() { |
744 | - do_action( 'AHEE__EE_System__load_CPTs_and_session__start' ); |
|
744 | + do_action('AHEE__EE_System__load_CPTs_and_session__start'); |
|
745 | 745 | // register Custom Post Types |
746 | - EE_Registry::instance()->load_core( 'Register_CPTs' ); |
|
747 | - do_action( 'AHEE__EE_System__load_CPTs_and_session__complete' ); |
|
746 | + EE_Registry::instance()->load_core('Register_CPTs'); |
|
747 | + do_action('AHEE__EE_System__load_CPTs_and_session__complete'); |
|
748 | 748 | } |
749 | 749 | |
750 | 750 | |
@@ -759,16 +759,16 @@ discard block |
||
759 | 759 | * @return void |
760 | 760 | */ |
761 | 761 | public function load_controllers() { |
762 | - do_action( 'AHEE__EE_System__load_controllers__start' ); |
|
762 | + do_action('AHEE__EE_System__load_controllers__start'); |
|
763 | 763 | // let's get it started |
764 | - if ( ! is_admin() && ! EE_Maintenance_Mode::instance()->level() ) { |
|
765 | - do_action( 'AHEE__EE_System__load_controllers__load_front_controllers' ); |
|
766 | - EE_Registry::instance()->load_core( 'Front_Controller' ); |
|
767 | - } else if ( ! EE_FRONT_AJAX ) { |
|
768 | - do_action( 'AHEE__EE_System__load_controllers__load_admin_controllers' ); |
|
769 | - EE_Registry::instance()->load_core( 'Admin' ); |
|
764 | + if ( ! is_admin() && ! EE_Maintenance_Mode::instance()->level()) { |
|
765 | + do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
|
766 | + EE_Registry::instance()->load_core('Front_Controller'); |
|
767 | + } else if ( ! EE_FRONT_AJAX) { |
|
768 | + do_action('AHEE__EE_System__load_controllers__load_admin_controllers'); |
|
769 | + EE_Registry::instance()->load_core('Admin'); |
|
770 | 770 | } |
771 | - do_action( 'AHEE__EE_System__load_controllers__complete' ); |
|
771 | + do_action('AHEE__EE_System__load_controllers__complete'); |
|
772 | 772 | } |
773 | 773 | |
774 | 774 | |
@@ -782,10 +782,10 @@ discard block |
||
782 | 782 | * @return void |
783 | 783 | */ |
784 | 784 | public function core_loaded_and_ready() { |
785 | - do_action( 'AHEE__EE_System__core_loaded_and_ready' ); |
|
786 | - do_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons' ); |
|
785 | + do_action('AHEE__EE_System__core_loaded_and_ready'); |
|
786 | + do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
|
787 | 787 | // add_action( 'wp_loaded', array( $this, 'set_hooks_for_shortcodes_modules_and_addons' ), 1 ); |
788 | - EE_Registry::instance()->load_core( 'Session' ); |
|
788 | + EE_Registry::instance()->load_core('Session'); |
|
789 | 789 | } |
790 | 790 | |
791 | 791 | |
@@ -799,7 +799,7 @@ discard block |
||
799 | 799 | * @return void |
800 | 800 | */ |
801 | 801 | public function initialize() { |
802 | - do_action( 'AHEE__EE_System__initialize' ); |
|
802 | + do_action('AHEE__EE_System__initialize'); |
|
803 | 803 | } |
804 | 804 | |
805 | 805 | |
@@ -813,7 +813,7 @@ discard block |
||
813 | 813 | * @return void |
814 | 814 | */ |
815 | 815 | public function initialize_last() { |
816 | - do_action( 'AHEE__EE_System__initialize_last' ); |
|
816 | + do_action('AHEE__EE_System__initialize_last'); |
|
817 | 817 | } |
818 | 818 | |
819 | 819 | |
@@ -845,21 +845,21 @@ discard block |
||
845 | 845 | */ |
846 | 846 | public static function do_not_cache() { |
847 | 847 | // set no cache constants |
848 | - if ( ! defined( 'DONOTCACHEPAGE' ) ) { |
|
849 | - define( 'DONOTCACHEPAGE', true ); |
|
848 | + if ( ! defined('DONOTCACHEPAGE')) { |
|
849 | + define('DONOTCACHEPAGE', true); |
|
850 | 850 | } |
851 | - if ( ! defined( 'DONOTCACHCEOBJECT' ) ) { |
|
852 | - define( 'DONOTCACHCEOBJECT', true ); |
|
851 | + if ( ! defined('DONOTCACHCEOBJECT')) { |
|
852 | + define('DONOTCACHCEOBJECT', true); |
|
853 | 853 | } |
854 | - if ( ! defined( 'DONOTCACHEDB' ) ) { |
|
855 | - define( 'DONOTCACHEDB', true ); |
|
854 | + if ( ! defined('DONOTCACHEDB')) { |
|
855 | + define('DONOTCACHEDB', true); |
|
856 | 856 | } |
857 | 857 | // add no cache headers |
858 | - add_action( 'send_headers' , array( 'EE_System', 'nocache_headers' ), 10 ); |
|
858 | + add_action('send_headers', array('EE_System', 'nocache_headers'), 10); |
|
859 | 859 | // plus a little extra for nginx |
860 | - add_filter( 'nocache_headers', array( 'EE_System', 'nocache_headers_nginx' ), 10, 1 ); |
|
860 | + add_filter('nocache_headers', array('EE_System', 'nocache_headers_nginx'), 10, 1); |
|
861 | 861 | // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process |
862 | - remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head' ); |
|
862 | + remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
|
863 | 863 | } |
864 | 864 | |
865 | 865 | |
@@ -871,7 +871,7 @@ discard block |
||
871 | 871 | * @param $headers |
872 | 872 | * @return array |
873 | 873 | */ |
874 | - public static function nocache_headers_nginx ( $headers ) { |
|
874 | + public static function nocache_headers_nginx($headers) { |
|
875 | 875 | $headers['X-Accel-Expires'] = 0; |
876 | 876 | return $headers; |
877 | 877 | } |
@@ -897,15 +897,15 @@ discard block |
||
897 | 897 | * @param $admin_bar |
898 | 898 | * @return void |
899 | 899 | */ |
900 | - public function espresso_toolbar_items( $admin_bar ) { |
|
900 | + public function espresso_toolbar_items($admin_bar) { |
|
901 | 901 | |
902 | 902 | // if in full M-Mode, or its an AJAX request, or user is NOT an admin |
903 | - if ( EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance || defined( 'DOING_AJAX' ) || ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_ee', 'ee_admin_bar_menu_top_level' )) { |
|
903 | + if (EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance || defined('DOING_AJAX') || ! EE_Registry::instance()->CAP->current_user_can('ee_read_ee', 'ee_admin_bar_menu_top_level')) { |
|
904 | 904 | return; |
905 | 905 | } |
906 | 906 | |
907 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
908 | - EE_Registry::instance()->load_helper( 'URL' ); |
|
907 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
908 | + EE_Registry::instance()->load_helper('URL'); |
|
909 | 909 | $menu_class = 'espresso_menu_item_class'; |
910 | 910 | //we don't use the constants EVENTS_ADMIN_URL or REG_ADMIN_URL |
911 | 911 | //because they're only defined in each of their respective constructors |
@@ -917,20 +917,20 @@ discard block |
||
917 | 917 | //Top Level |
918 | 918 | $admin_bar->add_menu(array( |
919 | 919 | 'id' => 'espresso-toolbar', |
920 | - 'title' => '<span class="ee-icon ee-icon-ee-cup-thick ee-icon-size-20"></span><span class="ab-label">' . _x('Event Espresso', 'admin bar menu group label', 'event_espresso') . '</span>', |
|
920 | + 'title' => '<span class="ee-icon ee-icon-ee-cup-thick ee-icon-size-20"></span><span class="ab-label">'._x('Event Espresso', 'admin bar menu group label', 'event_espresso').'</span>', |
|
921 | 921 | 'href' => $events_admin_url, |
922 | 922 | 'meta' => array( |
923 | 923 | 'title' => __('Event Espresso', 'event_espresso'), |
924 | - 'class' => $menu_class . 'first' |
|
924 | + 'class' => $menu_class.'first' |
|
925 | 925 | ), |
926 | 926 | )); |
927 | 927 | |
928 | 928 | //Events |
929 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events' ) ) { |
|
929 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events')) { |
|
930 | 930 | $admin_bar->add_menu(array( |
931 | 931 | 'id' => 'espresso-toolbar-events', |
932 | 932 | 'parent' => 'espresso-toolbar', |
933 | - 'title' => __( 'Events', 'event_espresso' ), |
|
933 | + 'title' => __('Events', 'event_espresso'), |
|
934 | 934 | 'href' => $events_admin_url, |
935 | 935 | 'meta' => array( |
936 | 936 | 'title' => __('Events', 'event_espresso'), |
@@ -941,13 +941,13 @@ discard block |
||
941 | 941 | } |
942 | 942 | |
943 | 943 | |
944 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_edit_events', 'ee_admin_bar_menu_espresso-toolbar-events-new' ) ) { |
|
944 | + if (EE_Registry::instance()->CAP->current_user_can('ee_edit_events', 'ee_admin_bar_menu_espresso-toolbar-events-new')) { |
|
945 | 945 | //Events Add New |
946 | 946 | $admin_bar->add_menu(array( |
947 | 947 | 'id' => 'espresso-toolbar-events-new', |
948 | 948 | 'parent' => 'espresso-toolbar-events', |
949 | 949 | 'title' => __('Add New', 'event_espresso'), |
950 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'create_new' ), $events_admin_url ), |
|
950 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'create_new'), $events_admin_url), |
|
951 | 951 | 'meta' => array( |
952 | 952 | 'title' => __('Add New', 'event_espresso'), |
953 | 953 | 'target' => '', |
@@ -956,18 +956,18 @@ discard block |
||
956 | 956 | )); |
957 | 957 | } |
958 | 958 | |
959 | - if ( is_single() && ( get_post_type() == 'espresso_events' ) ) { |
|
959 | + if (is_single() && (get_post_type() == 'espresso_events')) { |
|
960 | 960 | |
961 | 961 | //Current post |
962 | 962 | global $post; |
963 | 963 | |
964 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_edit_event', 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID ) ) { |
|
964 | + if (EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID)) { |
|
965 | 965 | //Events Edit Current Event |
966 | 966 | $admin_bar->add_menu(array( |
967 | 967 | 'id' => 'espresso-toolbar-events-edit', |
968 | 968 | 'parent' => 'espresso-toolbar-events', |
969 | 969 | 'title' => __('Edit Event', 'event_espresso'), |
970 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'edit', 'post'=>$post->ID ), $events_admin_url ), |
|
970 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'edit', 'post'=>$post->ID), $events_admin_url), |
|
971 | 971 | 'meta' => array( |
972 | 972 | 'title' => __('Edit Event', 'event_espresso'), |
973 | 973 | 'target' => '', |
@@ -979,11 +979,11 @@ discard block |
||
979 | 979 | } |
980 | 980 | |
981 | 981 | //Events View |
982 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-view' ) ) { |
|
982 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-view')) { |
|
983 | 983 | $admin_bar->add_menu(array( |
984 | 984 | 'id' => 'espresso-toolbar-events-view', |
985 | 985 | 'parent' => 'espresso-toolbar-events', |
986 | - 'title' => __( 'View', 'event_espresso' ), |
|
986 | + 'title' => __('View', 'event_espresso'), |
|
987 | 987 | 'href' => $events_admin_url, |
988 | 988 | 'meta' => array( |
989 | 989 | 'title' => __('View', 'event_espresso'), |
@@ -993,12 +993,12 @@ discard block |
||
993 | 993 | )); |
994 | 994 | } |
995 | 995 | |
996 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-all' ) ) { |
|
996 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-all')) { |
|
997 | 997 | //Events View All |
998 | 998 | $admin_bar->add_menu(array( |
999 | 999 | 'id' => 'espresso-toolbar-events-all', |
1000 | 1000 | 'parent' => 'espresso-toolbar-events-view', |
1001 | - 'title' => __( 'All', 'event_espresso' ), |
|
1001 | + 'title' => __('All', 'event_espresso'), |
|
1002 | 1002 | 'href' => $events_admin_url, |
1003 | 1003 | 'meta' => array( |
1004 | 1004 | 'title' => __('All', 'event_espresso'), |
@@ -1009,13 +1009,13 @@ discard block |
||
1009 | 1009 | } |
1010 | 1010 | |
1011 | 1011 | |
1012 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-today' ) ) { |
|
1012 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-today')) { |
|
1013 | 1013 | //Events View Today |
1014 | 1014 | $admin_bar->add_menu(array( |
1015 | 1015 | 'id' => 'espresso-toolbar-events-today', |
1016 | 1016 | 'parent' => 'espresso-toolbar-events-view', |
1017 | 1017 | 'title' => __('Today', 'event_espresso'), |
1018 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today' ), $events_admin_url ), |
|
1018 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today'), $events_admin_url), |
|
1019 | 1019 | 'meta' => array( |
1020 | 1020 | 'title' => __('Today', 'event_espresso'), |
1021 | 1021 | 'target' => '', |
@@ -1025,13 +1025,13 @@ discard block |
||
1025 | 1025 | } |
1026 | 1026 | |
1027 | 1027 | |
1028 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-month' ) ) { |
|
1028 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-month')) { |
|
1029 | 1029 | //Events View This Month |
1030 | 1030 | $admin_bar->add_menu(array( |
1031 | 1031 | 'id' => 'espresso-toolbar-events-month', |
1032 | 1032 | 'parent' => 'espresso-toolbar-events-view', |
1033 | - 'title' => __( 'This Month', 'event_espresso'), |
|
1034 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month' ), $events_admin_url ), |
|
1033 | + 'title' => __('This Month', 'event_espresso'), |
|
1034 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month'), $events_admin_url), |
|
1035 | 1035 | 'meta' => array( |
1036 | 1036 | 'title' => __('This Month', 'event_espresso'), |
1037 | 1037 | 'target' => '', |
@@ -1041,11 +1041,11 @@ discard block |
||
1041 | 1041 | } |
1042 | 1042 | |
1043 | 1043 | //Registration Overview |
1044 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations' ) ) { |
|
1044 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations')) { |
|
1045 | 1045 | $admin_bar->add_menu(array( |
1046 | 1046 | 'id' => 'espresso-toolbar-registrations', |
1047 | 1047 | 'parent' => 'espresso-toolbar', |
1048 | - 'title' => __( 'Registrations', 'event_espresso' ), |
|
1048 | + 'title' => __('Registrations', 'event_espresso'), |
|
1049 | 1049 | 'href' => $reg_admin_url, |
1050 | 1050 | 'meta' => array( |
1051 | 1051 | 'title' => __('Registrations', 'event_espresso'), |
@@ -1056,12 +1056,12 @@ discard block |
||
1056 | 1056 | } |
1057 | 1057 | |
1058 | 1058 | //Registration Overview Today |
1059 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today' ) ) { |
|
1059 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today')) { |
|
1060 | 1060 | $admin_bar->add_menu(array( |
1061 | 1061 | 'id' => 'espresso-toolbar-registrations-today', |
1062 | 1062 | 'parent' => 'espresso-toolbar-registrations', |
1063 | - 'title' => __( 'Today', 'event_espresso'), |
|
1064 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today' ), $reg_admin_url ), |
|
1063 | + 'title' => __('Today', 'event_espresso'), |
|
1064 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today'), $reg_admin_url), |
|
1065 | 1065 | 'meta' => array( |
1066 | 1066 | 'title' => __('Today', 'event_espresso'), |
1067 | 1067 | 'target' => '', |
@@ -1071,14 +1071,14 @@ discard block |
||
1071 | 1071 | } |
1072 | 1072 | |
1073 | 1073 | //Registration Overview Today Completed |
1074 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved' ) ) { |
|
1074 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved')) { |
|
1075 | 1075 | $admin_bar->add_menu(array( |
1076 | 1076 | 'id' => 'espresso-toolbar-registrations-today-approved', |
1077 | 1077 | 'parent' => 'espresso-toolbar-registrations-today', |
1078 | - 'title' => __( 'Approved', 'event_espresso' ), |
|
1079 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_approved ), $reg_admin_url ), |
|
1078 | + 'title' => __('Approved', 'event_espresso'), |
|
1079 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_approved), $reg_admin_url), |
|
1080 | 1080 | 'meta' => array( |
1081 | - 'title' => __('Approved', 'event_espresso' ), |
|
1081 | + 'title' => __('Approved', 'event_espresso'), |
|
1082 | 1082 | 'target' => '', |
1083 | 1083 | 'class' => $menu_class |
1084 | 1084 | ), |
@@ -1086,14 +1086,14 @@ discard block |
||
1086 | 1086 | } |
1087 | 1087 | |
1088 | 1088 | //Registration Overview Today Pending\ |
1089 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending' ) ) { |
|
1089 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending')) { |
|
1090 | 1090 | $admin_bar->add_menu(array( |
1091 | 1091 | 'id' => 'espresso-toolbar-registrations-today-pending', |
1092 | 1092 | 'parent' => 'espresso-toolbar-registrations-today', |
1093 | - 'title' => __( 'Pending', 'event_espresso' ), |
|
1094 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', 'reg_status'=>EEM_Registration::status_id_pending_payment ), $reg_admin_url ), |
|
1093 | + 'title' => __('Pending', 'event_espresso'), |
|
1094 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', 'reg_status'=>EEM_Registration::status_id_pending_payment), $reg_admin_url), |
|
1095 | 1095 | 'meta' => array( |
1096 | - 'title' => __('Pending Payment', 'event_espresso' ), |
|
1096 | + 'title' => __('Pending Payment', 'event_espresso'), |
|
1097 | 1097 | 'target' => '', |
1098 | 1098 | 'class' => $menu_class |
1099 | 1099 | ), |
@@ -1101,14 +1101,14 @@ discard block |
||
1101 | 1101 | } |
1102 | 1102 | |
1103 | 1103 | //Registration Overview Today Incomplete |
1104 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved' ) ) { |
|
1104 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved')) { |
|
1105 | 1105 | $admin_bar->add_menu(array( |
1106 | 1106 | 'id' => 'espresso-toolbar-registrations-today-not-approved', |
1107 | 1107 | 'parent' => 'espresso-toolbar-registrations-today', |
1108 | - 'title' => __( 'Not Approved', 'event_espresso' ), |
|
1109 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_not_approved ), $reg_admin_url ), |
|
1108 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1109 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_not_approved), $reg_admin_url), |
|
1110 | 1110 | 'meta' => array( |
1111 | - 'title' => __('Not Approved', 'event_espresso' ), |
|
1111 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1112 | 1112 | 'target' => '', |
1113 | 1113 | 'class' => $menu_class |
1114 | 1114 | ), |
@@ -1116,12 +1116,12 @@ discard block |
||
1116 | 1116 | } |
1117 | 1117 | |
1118 | 1118 | //Registration Overview Today Incomplete |
1119 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled' ) ) { |
|
1119 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled')) { |
|
1120 | 1120 | $admin_bar->add_menu(array( |
1121 | 1121 | 'id' => 'espresso-toolbar-registrations-today-cancelled', |
1122 | 1122 | 'parent' => 'espresso-toolbar-registrations-today', |
1123 | - 'title' => __( 'Cancelled', 'event_espresso'), |
|
1124 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_cancelled ), $reg_admin_url ), |
|
1123 | + 'title' => __('Cancelled', 'event_espresso'), |
|
1124 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_cancelled), $reg_admin_url), |
|
1125 | 1125 | 'meta' => array( |
1126 | 1126 | 'title' => __('Cancelled', 'event_espresso'), |
1127 | 1127 | 'target' => '', |
@@ -1131,12 +1131,12 @@ discard block |
||
1131 | 1131 | } |
1132 | 1132 | |
1133 | 1133 | //Registration Overview This Month |
1134 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month' ) ) { |
|
1134 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month')) { |
|
1135 | 1135 | $admin_bar->add_menu(array( |
1136 | 1136 | 'id' => 'espresso-toolbar-registrations-month', |
1137 | 1137 | 'parent' => 'espresso-toolbar-registrations', |
1138 | - 'title' => __( 'This Month', 'event_espresso' ), |
|
1139 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month' ), $reg_admin_url ), |
|
1138 | + 'title' => __('This Month', 'event_espresso'), |
|
1139 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month'), $reg_admin_url), |
|
1140 | 1140 | 'meta' => array( |
1141 | 1141 | 'title' => __('This Month', 'event_espresso'), |
1142 | 1142 | 'target' => '', |
@@ -1146,12 +1146,12 @@ discard block |
||
1146 | 1146 | } |
1147 | 1147 | |
1148 | 1148 | //Registration Overview This Month Approved |
1149 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved' ) ) { |
|
1149 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved')) { |
|
1150 | 1150 | $admin_bar->add_menu(array( |
1151 | 1151 | 'id' => 'espresso-toolbar-registrations-month-approved', |
1152 | 1152 | 'parent' => 'espresso-toolbar-registrations-month', |
1153 | - 'title' => __( 'Approved', 'event_espresso' ), |
|
1154 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_approved ), $reg_admin_url ), |
|
1153 | + 'title' => __('Approved', 'event_espresso'), |
|
1154 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_approved), $reg_admin_url), |
|
1155 | 1155 | 'meta' => array( |
1156 | 1156 | 'title' => __('Approved', 'event_espresso'), |
1157 | 1157 | 'target' => '', |
@@ -1161,12 +1161,12 @@ discard block |
||
1161 | 1161 | } |
1162 | 1162 | |
1163 | 1163 | //Registration Overview This Month Pending |
1164 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending' ) ) { |
|
1164 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending')) { |
|
1165 | 1165 | $admin_bar->add_menu(array( |
1166 | 1166 | 'id' => 'espresso-toolbar-registrations-month-pending', |
1167 | 1167 | 'parent' => 'espresso-toolbar-registrations-month', |
1168 | - 'title' => __( 'Pending', 'event_espresso'), |
|
1169 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_pending_payment ), $reg_admin_url ), |
|
1168 | + 'title' => __('Pending', 'event_espresso'), |
|
1169 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_pending_payment), $reg_admin_url), |
|
1170 | 1170 | 'meta' => array( |
1171 | 1171 | 'title' => __('Pending', 'event_espresso'), |
1172 | 1172 | 'target' => '', |
@@ -1176,14 +1176,14 @@ discard block |
||
1176 | 1176 | } |
1177 | 1177 | |
1178 | 1178 | //Registration Overview This Month Not Approved |
1179 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved' ) ) { |
|
1179 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved')) { |
|
1180 | 1180 | $admin_bar->add_menu(array( |
1181 | 1181 | 'id' => 'espresso-toolbar-registrations-month-not-approved', |
1182 | 1182 | 'parent' => 'espresso-toolbar-registrations-month', |
1183 | - 'title' => __( 'Not Approved', 'event_espresso'), |
|
1184 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_not_approved ), $reg_admin_url ), |
|
1183 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1184 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_not_approved), $reg_admin_url), |
|
1185 | 1185 | 'meta' => array( |
1186 | - 'title' => __('Not Approved', 'event_espresso' ), |
|
1186 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1187 | 1187 | 'target' => '', |
1188 | 1188 | 'class' => $menu_class |
1189 | 1189 | ), |
@@ -1192,12 +1192,12 @@ discard block |
||
1192 | 1192 | |
1193 | 1193 | |
1194 | 1194 | //Registration Overview This Month Cancelled |
1195 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled' ) ) { |
|
1195 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled')) { |
|
1196 | 1196 | $admin_bar->add_menu(array( |
1197 | 1197 | 'id' => 'espresso-toolbar-registrations-month-cancelled', |
1198 | 1198 | 'parent' => 'espresso-toolbar-registrations-month', |
1199 | 1199 | 'title' => __('Cancelled', 'event_espresso'), |
1200 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_cancelled ), $reg_admin_url ), |
|
1200 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_cancelled), $reg_admin_url), |
|
1201 | 1201 | 'meta' => array( |
1202 | 1202 | 'title' => __('Cancelled', 'event_espresso'), |
1203 | 1203 | 'target' => '', |
@@ -1207,11 +1207,11 @@ discard block |
||
1207 | 1207 | } |
1208 | 1208 | |
1209 | 1209 | //Extensions & Services |
1210 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_ee', 'ee_admin_bar_menu_espresso-toolbar-extensions-and-services' ) ) { |
|
1210 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_ee', 'ee_admin_bar_menu_espresso-toolbar-extensions-and-services')) { |
|
1211 | 1211 | $admin_bar->add_menu(array( |
1212 | 1212 | 'id' => 'espresso-toolbar-extensions-and-services', |
1213 | 1213 | 'parent' => 'espresso-toolbar', |
1214 | - 'title' => __( 'Extensions & Services', 'event_espresso' ), |
|
1214 | + 'title' => __('Extensions & Services', 'event_espresso'), |
|
1215 | 1215 | 'href' => $extensions_admin_url, |
1216 | 1216 | 'meta' => array( |
1217 | 1217 | 'title' => __('Extensions & Services', 'event_espresso'), |
@@ -1233,8 +1233,8 @@ discard block |
||
1233 | 1233 | * @param array $exclude_array any existing pages being excluded are in this array. |
1234 | 1234 | * @return array |
1235 | 1235 | */ |
1236 | - public function remove_pages_from_wp_list_pages( $exclude_array ) { |
|
1237 | - return array_merge( $exclude_array, EE_Registry::instance()->CFG->core->get_critical_pages_array() ); |
|
1236 | + public function remove_pages_from_wp_list_pages($exclude_array) { |
|
1237 | + return array_merge($exclude_array, EE_Registry::instance()->CFG->core->get_critical_pages_array()); |
|
1238 | 1238 | } |
1239 | 1239 | |
1240 | 1240 | |
@@ -1254,11 +1254,11 @@ discard block |
||
1254 | 1254 | */ |
1255 | 1255 | public function wp_enqueue_scripts() { |
1256 | 1256 | // unlike other systems, EE_System_scripts loading is turned ON by default, but prior to the init hook, can be turned off via: add_filter( 'FHEE_load_EE_System_scripts', '__return_false' ); |
1257 | - if ( apply_filters( 'FHEE_load_EE_System_scripts', TRUE ) ) { |
|
1257 | + if (apply_filters('FHEE_load_EE_System_scripts', TRUE)) { |
|
1258 | 1258 | // jquery_validate loading is turned OFF by default, but prior to the wp_enqueue_scripts hook, can be turned back on again via: add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
1259 | - if ( apply_filters( 'FHEE_load_jquery_validate', FALSE ) ) { |
|
1259 | + if (apply_filters('FHEE_load_jquery_validate', FALSE)) { |
|
1260 | 1260 | // register jQuery Validate |
1261 | - wp_register_script( 'jquery-validate', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', array('jquery'), '1.11.1', TRUE ); |
|
1261 | + wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js', array('jquery'), '1.11.1', TRUE); |
|
1262 | 1262 | } |
1263 | 1263 | } |
1264 | 1264 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /** |
5 | 5 | * Event Espresso |
@@ -47,8 +47,8 @@ discard block |
||
47 | 47 | * @param int $parent_term_taxonomy_id optional |
48 | 48 | * @return EE_Term_Taxonomy |
49 | 49 | */ |
50 | - function add_event_category( $category_name, $category_description = NULL, $parent_term_taxonomy_id = NULL ) { |
|
51 | - return $this->get_model()->add_event_category( $this, $category_name, $category_description, $parent_term_taxonomy_id ); |
|
50 | + function add_event_category($category_name, $category_description = NULL, $parent_term_taxonomy_id = NULL) { |
|
51 | + return $this->get_model()->add_event_category($this, $category_name, $category_description, $parent_term_taxonomy_id); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | |
@@ -58,8 +58,8 @@ discard block |
||
58 | 58 | * @param string $category_name |
59 | 59 | * @return bool |
60 | 60 | */ |
61 | - function remove_event_category( $category_name ) { |
|
62 | - return $this->get_model()->remove_event_category( $this, $category_name ); |
|
61 | + function remove_event_category($category_name) { |
|
62 | + return $this->get_model()->remove_event_category($this, $category_name); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | |
@@ -70,14 +70,14 @@ discard block |
||
70 | 70 | * @param EE_Term_Taxonomy $term_taxonomy |
71 | 71 | * @return EE_Base_Class the relation was removed from |
72 | 72 | */ |
73 | - function remove_relation_to_term_taxonomy( $term_taxonomy ) { |
|
74 | - if ( !$term_taxonomy ) { |
|
75 | - EE_Error::add_error( sprintf( __( "No Term_Taxonomy provided which to remove from model object of type %s and id %d", "event_espresso" ), get_class( $this ), $this->ID() ), __FILE__, __FUNCTION__, __LINE__ ); |
|
73 | + function remove_relation_to_term_taxonomy($term_taxonomy) { |
|
74 | + if ( ! $term_taxonomy) { |
|
75 | + EE_Error::add_error(sprintf(__("No Term_Taxonomy provided which to remove from model object of type %s and id %d", "event_espresso"), get_class($this), $this->ID()), __FILE__, __FUNCTION__, __LINE__); |
|
76 | 76 | return NULL; |
77 | 77 | } |
78 | - $term_taxonomy->set_count( $term_taxonomy->count() - 1 ); |
|
78 | + $term_taxonomy->set_count($term_taxonomy->count() - 1); |
|
79 | 79 | $term_taxonomy->save(); |
80 | - return $this->_remove_relation_to( $term_taxonomy, 'Term_Taxonomy' ); |
|
80 | + return $this->_remove_relation_to($term_taxonomy, 'Term_Taxonomy'); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * @return int |
102 | 102 | */ |
103 | 103 | public function parent() { |
104 | - return $this->get( 'parent' ); |
|
104 | + return $this->get('parent'); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * @return string |
112 | 112 | */ |
113 | 113 | public function status() { |
114 | - return $this->get( 'status' ); |
|
114 | + return $this->get('status'); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | /** |
120 | 120 | * @param string $status |
121 | 121 | */ |
122 | - public function set_status( $status ) { |
|
123 | - $this->set( 'status', $status ); |
|
122 | + public function set_status($status) { |
|
123 | + $this->set('status', $status); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | |
@@ -134,12 +134,12 @@ discard block |
||
134 | 134 | * @param string|array $attr Optional. Query string or array of attributes. |
135 | 135 | * @return string HTML image element |
136 | 136 | */ |
137 | - protected function _get_feature_image( $size, $attr ) { |
|
137 | + protected function _get_feature_image($size, $attr) { |
|
138 | 138 | //first let's see if we already have the _feature_image property set AND if it has a cached element on it FOR the given size |
139 | - $attr_key = is_array( $attr ) ? implode( '_', $attr ) : $attr; |
|
140 | - $cache_key = is_array( $size ) ? implode( '_', $size ) . $attr_key : $size . $attr_key; |
|
141 | - $this->_feature_image[ $cache_key ] = isset( $this->_feature_image[ $cache_key ] ) ? $this->_feature_image[ $cache_key ] : $this->get_model()->get_feature_image( $this->ID(), $size, $attr ); |
|
142 | - return $this->_feature_image[ $cache_key ]; |
|
139 | + $attr_key = is_array($attr) ? implode('_', $attr) : $attr; |
|
140 | + $cache_key = is_array($size) ? implode('_', $size).$attr_key : $size.$attr_key; |
|
141 | + $this->_feature_image[$cache_key] = isset($this->_feature_image[$cache_key]) ? $this->_feature_image[$cache_key] : $this->get_model()->get_feature_image($this->ID(), $size, $attr); |
|
142 | + return $this->_feature_image[$cache_key]; |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | |
@@ -150,8 +150,8 @@ discard block |
||
150 | 150 | * @param string|array $attr |
151 | 151 | * @return string of html |
152 | 152 | */ |
153 | - public function feature_image( $size = 'thumbnail', $attr = '' ) { |
|
154 | - return $this->_get_feature_image( $size, $attr ); |
|
153 | + public function feature_image($size = 'thumbnail', $attr = '') { |
|
154 | + return $this->_get_feature_image($size, $attr); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | |
@@ -161,9 +161,9 @@ discard block |
||
161 | 161 | * @param string|array $size can either be a string: 'thumbnail', 'medium', 'large', 'full' OR 2-item array representing width and height in pixels eg. array(32,32). |
162 | 162 | * @return string|boolean the url of the image or false if not found |
163 | 163 | */ |
164 | - public function feature_image_url( $size = 'thumbnail' ) { |
|
165 | - $attachment = wp_get_attachment_image_src( get_post_thumbnail_id( $this->ID() ), $size ); |
|
166 | - return !empty( $attachment ) ? $attachment[ 0 ] : FALSE; |
|
164 | + public function feature_image_url($size = 'thumbnail') { |
|
165 | + $attachment = wp_get_attachment_image_src(get_post_thumbnail_id($this->ID()), $size); |
|
166 | + return ! empty($attachment) ? $attachment[0] : FALSE; |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | |
@@ -185,37 +185,37 @@ discard block |
||
185 | 185 | * This array is INDEXED by RELATED OBJ NAME (so it corresponds with the obj_names sent); |
186 | 186 | * @return void |
187 | 187 | */ |
188 | - public function restore_revision( $revision_id, $related_obj_names = array(), $where_query = array() ) { |
|
188 | + public function restore_revision($revision_id, $related_obj_names = array(), $where_query = array()) { |
|
189 | 189 | //get revision object |
190 | - $revision_obj = $this->get_model()->get_one_by_ID( $revision_id ); |
|
191 | - if ( $revision_obj instanceof EE_CPT_Base ) { |
|
190 | + $revision_obj = $this->get_model()->get_one_by_ID($revision_id); |
|
191 | + if ($revision_obj instanceof EE_CPT_Base) { |
|
192 | 192 | //no related_obj_name so we assume we're saving a revision on this object. |
193 | - if ( empty( $related_obj_names ) ) { |
|
193 | + if (empty($related_obj_names)) { |
|
194 | 194 | $fields = $this->get_model()->get_meta_table_fields(); |
195 | - foreach ( $fields as $field ) { |
|
196 | - $this->set( $field, $revision_obj->get( $field ) ); |
|
195 | + foreach ($fields as $field) { |
|
196 | + $this->set($field, $revision_obj->get($field)); |
|
197 | 197 | } |
198 | 198 | $this->save(); |
199 | 199 | } |
200 | - $related_obj_names = (array)$related_obj_names; |
|
201 | - foreach ( $related_obj_names as $related_name ) { |
|
200 | + $related_obj_names = (array) $related_obj_names; |
|
201 | + foreach ($related_obj_names as $related_name) { |
|
202 | 202 | //related_obj_name so we're saving a revision on an object related to this object |
203 | 203 | //do we have $where_query params for this related object? If we do then we include that. |
204 | - $cols_n_values = isset( $where_query[ $related_name ] ) ? $where_query[ $related_name ] : array(); |
|
205 | - $where_params = !empty( $cols_n_values ) ? array( $cols_n_values ) : array(); |
|
206 | - $related_objs = $this->get_many_related( $related_name, $where_params ); |
|
207 | - $revision_related_objs = $revision_obj->get_many_related( $related_name, $where_params ); |
|
204 | + $cols_n_values = isset($where_query[$related_name]) ? $where_query[$related_name] : array(); |
|
205 | + $where_params = ! empty($cols_n_values) ? array($cols_n_values) : array(); |
|
206 | + $related_objs = $this->get_many_related($related_name, $where_params); |
|
207 | + $revision_related_objs = $revision_obj->get_many_related($related_name, $where_params); |
|
208 | 208 | //load helper |
209 | - EE_Registry::instance()->load_helper( 'Array' ); |
|
209 | + EE_Registry::instance()->load_helper('Array'); |
|
210 | 210 | //remove related objs from this object that are not in revision |
211 | 211 | //array_diff *should* work cause I think objects are indexed by ID? |
212 | - $related_to_remove = EEH_Array::object_array_diff( $related_objs, $revision_related_objs ); |
|
213 | - foreach ( $related_to_remove as $rr ) { |
|
214 | - $this->_remove_relation_to( $rr, $related_name, $cols_n_values ); |
|
212 | + $related_to_remove = EEH_Array::object_array_diff($related_objs, $revision_related_objs); |
|
213 | + foreach ($related_to_remove as $rr) { |
|
214 | + $this->_remove_relation_to($rr, $related_name, $cols_n_values); |
|
215 | 215 | } |
216 | 216 | //add all related objs attached to revision to this object |
217 | - foreach ( $revision_related_objs as $r_obj ) { |
|
218 | - $this->_add_relation_to( $r_obj, $related_name, $cols_n_values ); |
|
217 | + foreach ($revision_related_objs as $r_obj) { |
|
218 | + $this->_add_relation_to($r_obj, $related_name, $cols_n_values); |
|
219 | 219 | } |
220 | 220 | } |
221 | 221 | } |
@@ -231,8 +231,8 @@ discard block |
||
231 | 231 | * <li>If $single is set to false, or left blank, the function returns an array containing all values of the specified key.</li> |
232 | 232 | * <li>If $single is set to true, the function returns the first value of the specified key (not in an array</li></ul> |
233 | 233 | */ |
234 | - public function get_post_meta( $meta_key = NULL, $single = FALSE ) { |
|
235 | - return get_post_meta( $this->ID(), $meta_key, $single ); |
|
234 | + public function get_post_meta($meta_key = NULL, $single = FALSE) { |
|
235 | + return get_post_meta($this->ID(), $meta_key, $single); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | |
@@ -244,11 +244,11 @@ discard block |
||
244 | 244 | * @param mixed $prev_value |
245 | 245 | * @return mixed Returns meta_id if the meta doesn't exist, otherwise returns true on success and false on failure. NOTE: If the meta_value passed to this function is the same as the value that is already in the database, this function returns false. |
246 | 246 | */ |
247 | - public function update_post_meta( $meta_key, $meta_value, $prev_value = NULL ) { |
|
248 | - if ( ! $this->ID() ) { |
|
247 | + public function update_post_meta($meta_key, $meta_value, $prev_value = NULL) { |
|
248 | + if ( ! $this->ID()) { |
|
249 | 249 | $this->save(); |
250 | 250 | } |
251 | - return update_post_meta( $this->ID(), $meta_key, $meta_value, $prev_value ); |
|
251 | + return update_post_meta($this->ID(), $meta_key, $meta_value, $prev_value); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | |
@@ -260,11 +260,11 @@ discard block |
||
260 | 260 | * @param bool $unique . If postmeta for this $meta_key already exists, whether to add an additional item or not |
261 | 261 | * @return boolean Boolean true, except if the $unique argument was set to true and a custom field with the given key already exists, in which case false is returned. |
262 | 262 | */ |
263 | - public function add_post_meta( $meta_key, $meta_value, $unique = FALSE ) { |
|
264 | - if ( $this->ID() ) { |
|
263 | + public function add_post_meta($meta_key, $meta_value, $unique = FALSE) { |
|
264 | + if ($this->ID()) { |
|
265 | 265 | $this->save(); |
266 | 266 | } |
267 | - return add_post_meta( $this->ID(), $meta_key, $meta_value, $unique ); |
|
267 | + return add_post_meta($this->ID(), $meta_key, $meta_value, $unique); |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | |
@@ -276,13 +276,13 @@ discard block |
||
276 | 276 | * @param mixed $meta_value |
277 | 277 | * @return boolean False for failure. True for success. |
278 | 278 | */ |
279 | - public function delete_post_meta( $meta_key, $meta_value = '' ) { |
|
280 | - if ( ! $this->ID() ) { |
|
279 | + public function delete_post_meta($meta_key, $meta_value = '') { |
|
280 | + if ( ! $this->ID()) { |
|
281 | 281 | //there are obviously no postmetas for this if it's not saved |
282 | 282 | //so let's just report this as a success |
283 | 283 | return true; |
284 | 284 | } |
285 | - return delete_post_meta( $this->ID(), $meta_key, $meta_value ); |
|
285 | + return delete_post_meta($this->ID(), $meta_key, $meta_value); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | * @return string |
293 | 293 | */ |
294 | 294 | public function get_permalink() { |
295 | - return get_permalink( $this->ID() ); |
|
295 | + return get_permalink($this->ID()); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | |
@@ -302,8 +302,8 @@ discard block |
||
302 | 302 | * @param array $query_params |
303 | 303 | * @return EE_Term_Taxonomy |
304 | 304 | */ |
305 | - public function term_taxonomies( $query_params = array() ) { |
|
306 | - return $this->get_many_related( 'Term_Taxonomy', $query_params ); |
|
305 | + public function term_taxonomies($query_params = array()) { |
|
306 | + return $this->get_many_related('Term_Taxonomy', $query_params); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * The main purpose of this method is to return the parent for the model object |
99 | 99 | * |
100 | 100 | * @access public |
101 | - * @return int |
|
101 | + * @return boolean |
|
102 | 102 | */ |
103 | 103 | public function parent() { |
104 | 104 | return $this->get( 'parent' ); |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | |
109 | 109 | /** |
110 | 110 | * return the _status property |
111 | - * @return string |
|
111 | + * @return boolean |
|
112 | 112 | */ |
113 | 113 | public function status() { |
114 | 114 | return $this->get( 'status' ); |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * |
131 | 131 | * @link http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail |
132 | 132 | * @access protected |
133 | - * @param string|array $size (optional) Image size. Defaults to 'post-thumbnail' but can also be a 2-item array representing width and height in pixels (i.e. array(32,32) ). |
|
133 | + * @param string $size (optional) Image size. Defaults to 'post-thumbnail' but can also be a 2-item array representing width and height in pixels (i.e. array(32,32) ). |
|
134 | 134 | * @param string|array $attr Optional. Query string or array of attributes. |
135 | 135 | * @return string HTML image element |
136 | 136 | */ |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | |
159 | 159 | /** |
160 | 160 | * This uses the wp "wp_get_attachment_image_src()" function to return the feature image for the current class using the given size params. |
161 | - * @param string|array $size can either be a string: 'thumbnail', 'medium', 'large', 'full' OR 2-item array representing width and height in pixels eg. array(32,32). |
|
161 | + * @param integer[] $size can either be a string: 'thumbnail', 'medium', 'large', 'full' OR 2-item array representing width and height in pixels eg. array(32,32). |
|
162 | 162 | * @return string|boolean the url of the image or false if not found |
163 | 163 | */ |
164 | 164 | public function feature_image_url( $size = 'thumbnail' ) { |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * This is a method for restoring this_obj using details from the given $revision_id |
173 | 173 | * |
174 | 174 | * @param int $revision_id ID of the revision we're getting data from |
175 | - * @param array $related_obj_names if included this will be used to restore for related obj |
|
175 | + * @param string[] $related_obj_names if included this will be used to restore for related obj |
|
176 | 176 | * if not included then we just do restore on the meta. |
177 | 177 | * We will accept an array of related_obj_names for restoration here. |
178 | 178 | * @param array $where_query You can optionally include an array of key=>value pairs |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | * Wrapper for get_post_meta, http://codex.wordpress.org/Function_Reference/get_post_meta |
228 | 228 | * @param string $meta_key |
229 | 229 | * @param boolean $single |
230 | - * @return mixed <ul><li>If only $id is set it will return all meta values in an associative array.</li> |
|
230 | + * @return string|null <ul><li>If only $id is set it will return all meta values in an associative array.</li> |
|
231 | 231 | * <li>If $single is set to false, or left blank, the function returns an array containing all values of the specified key.</li> |
232 | 232 | * <li>If $single is set to true, the function returns the first value of the specified key (not in an array</li></ul> |
233 | 233 | */ |
@@ -255,8 +255,8 @@ discard block |
||
255 | 255 | |
256 | 256 | /** |
257 | 257 | * Wrapper for add_post_meta, http://codex.wordpress.org/Function_Reference/add_post_meta |
258 | - * @param mixed $meta_key |
|
259 | - * @param mixed $meta_value |
|
258 | + * @param string $meta_key |
|
259 | + * @param boolean $meta_value |
|
260 | 260 | * @param bool $unique . If postmeta for this $meta_key already exists, whether to add an additional item or not |
261 | 261 | * @return boolean Boolean true, except if the $unique argument was set to true and a custom field with the given key already exists, in which case false is returned. |
262 | 262 | */ |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | /** |
273 | 273 | * Wrapper for delete_post_meta, http://codex.wordpress.org/Function_Reference/delete_post_meta |
274 | 274 | * |
275 | - * @param mixed $meta_key |
|
275 | + * @param string $meta_key |
|
276 | 276 | * @param mixed $meta_value |
277 | 277 | * @return boolean False for failure. True for success. |
278 | 278 | */ |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | /** |
301 | 301 | * Gets all the term-taxonomies for this CPT |
302 | 302 | * @param array $query_params |
303 | - * @return EE_Term_Taxonomy |
|
303 | + * @return EE_Base_Class[] |
|
304 | 304 | */ |
305 | 305 | public function term_taxonomies( $query_params = array() ) { |
306 | 306 | return $this->get_many_related( 'Term_Taxonomy', $query_params ); |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -42,25 +42,25 @@ discard block |
||
42 | 42 | $this->_shortcodes = array( |
43 | 43 | '[TXN_ID]' => __('The transaction id for the purchase.', 'event_espresso'), |
44 | 44 | '[PAYMENT_URL]' => __('This is a link to make a payment for the event', 'event_espresso'), |
45 | - '[PAYMENT_LINK_IF_NEEDED_*]' => __('This is a special dynamic shortcode that allows one to insert a payment link conditional on there being amount owing on the transaction. Three params are available on this shortcode:', 'event_espresso') . '<ul>' |
|
46 | - . '<li>' . sprintf( __('%class:%s This can be used to indicate css class is given to the containing css element (default is "callout").', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
47 | - . '<li>' . sprintf( __('%scustom_text:%s This should be a sprintf format text string (with %%s for where the hyperlink tags go) that is used for the generated link text (The default is "You can %%smake a payment here »%%s.)', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
48 | - . '<li>' . sprintf( __('%scontainer_tag:%s Use this to indicate what container tag you want surrounding the payment link (default is "p").', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
45 | + '[PAYMENT_LINK_IF_NEEDED_*]' => __('This is a special dynamic shortcode that allows one to insert a payment link conditional on there being amount owing on the transaction. Three params are available on this shortcode:', 'event_espresso').'<ul>' |
|
46 | + . '<li>'.sprintf(__('%class:%s This can be used to indicate css class is given to the containing css element (default is "callout").', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
47 | + . '<li>'.sprintf(__('%scustom_text:%s This should be a sprintf format text string (with %%s for where the hyperlink tags go) that is used for the generated link text (The default is "You can %%smake a payment here »%%s.)', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
48 | + . '<li>'.sprintf(__('%scontainer_tag:%s Use this to indicate what container tag you want surrounding the payment link (default is "p").', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
49 | 49 | . '</ul>', |
50 | - '[PAYMENT_DUE_DATE_*]' => __( 'This is a special dynamic shortcode that allows one to output a payment due date. It will only result in a date shown if there is money owing. Three parameters are available on this shortcode:', 'event_espresso' ) |
|
50 | + '[PAYMENT_DUE_DATE_*]' => __('This is a special dynamic shortcode that allows one to output a payment due date. It will only result in a date shown if there is money owing. Three parameters are available on this shortcode:', 'event_espresso') |
|
51 | 51 | . '<ul>' |
52 | - . '<li>' . sprintf( __( '%sformat:%s This is used to indicate what format the date is in. Default is whatever is set as date formats for your website.', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
53 | - . '<li>' . sprintf( __( '%days_until_due:%s This is the number of days form the transaction creation date that the payment is due. Defaults to 30.', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
54 | - . '<li>' . sprintf( __( '%sprefix_text:%s You can use this to indicate what text will prefix the date string. Defaults to "Payment in full due by:"', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>', |
|
52 | + . '<li>'.sprintf(__('%sformat:%s This is used to indicate what format the date is in. Default is whatever is set as date formats for your website.', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
53 | + . '<li>'.sprintf(__('%days_until_due:%s This is the number of days form the transaction creation date that the payment is due. Defaults to 30.', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
54 | + . '<li>'.sprintf(__('%sprefix_text:%s You can use this to indicate what text will prefix the date string. Defaults to "Payment in full due by:"', 'event_espresso'), '<strong>', '</strong>').'</li>', |
|
55 | 55 | '[INVOICE_LINK]' => __('This is a full html link to the invoice', 'event_espresso'), |
56 | 56 | '[INVOICE_URL]' => __('This is just the url for the invoice', 'event_espresso'), |
57 | 57 | '[INVOICE_LOGO_URL]' => __('This returns the url for the logo uploaded via the invoice settings page.', 'event_espresso'), |
58 | 58 | '[INVOICE_LOGO]' => __('This returns the logo uploaded via the invoice settings page wrapped in img_tags and with a "logo screen" classes. The image size is also set in the img tags automatically to match the uploaded logo.', 'event_espresso'), |
59 | 59 | '[INVOICE_PAYEE_NAME]' => __('This will parse to either: the value of the "Company Name" field in the invoice payment method settings; if that is blank, then the value of the Company Name in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso'), |
60 | - '[INVOICE_PAYEE_ADDRESS]' => __('This will parse to either: the value of the "Company Address" field in the invoice payment method settings; if that is blank, then the value of the Company Address in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso' ), |
|
61 | - '[INVOICE_PAYMENT_INSTRUCTIONS]' => __('This will parse to the value of the "Payment Instructions" field found on the Invoice payment methods settings page', 'event_espresso' ), |
|
62 | - '[INVOICE_PAYEE_EMAIL]' => __('This will parse to either: the value of the "Company Email" field in the invoice payment method settings; if that is blank, then the value of the Company Email in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso' ), |
|
63 | - '[INVOICE_PAYEE_TAX_NUMBER_*]' => __('This will parse to either: the value of the "Company Tax Number" field in the invoice payment method settings; if that is blank, then the value of the Company Tax Number in the "Your Organization Settings", if that is blank then an empty string. Note this is also a special dynamic shortcode. You can use the "prefix" parameter to indicate what text you want to use as a prefix before this tax number. It defaults to "VAT/Tax Number:". To change this prefix you do the following format for this shortcode: <code>[INVOICE_PAYEE_TAX_NUMBER_* prefix="GST:"]</code> and that will ouptut: GST: 12345t56. If you have no tax number in your settings, then no prefix will be output either.', 'event_espresso' ), |
|
60 | + '[INVOICE_PAYEE_ADDRESS]' => __('This will parse to either: the value of the "Company Address" field in the invoice payment method settings; if that is blank, then the value of the Company Address in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso'), |
|
61 | + '[INVOICE_PAYMENT_INSTRUCTIONS]' => __('This will parse to the value of the "Payment Instructions" field found on the Invoice payment methods settings page', 'event_espresso'), |
|
62 | + '[INVOICE_PAYEE_EMAIL]' => __('This will parse to either: the value of the "Company Email" field in the invoice payment method settings; if that is blank, then the value of the Company Email in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso'), |
|
63 | + '[INVOICE_PAYEE_TAX_NUMBER_*]' => __('This will parse to either: the value of the "Company Tax Number" field in the invoice payment method settings; if that is blank, then the value of the Company Tax Number in the "Your Organization Settings", if that is blank then an empty string. Note this is also a special dynamic shortcode. You can use the "prefix" parameter to indicate what text you want to use as a prefix before this tax number. It defaults to "VAT/Tax Number:". To change this prefix you do the following format for this shortcode: <code>[INVOICE_PAYEE_TAX_NUMBER_* prefix="GST:"]</code> and that will ouptut: GST: 12345t56. If you have no tax number in your settings, then no prefix will be output either.', 'event_espresso'), |
|
64 | 64 | '[TOTAL_COST]' => __('The total cost for the transaction', 'event_espresso'), |
65 | 65 | '[TXN_STATUS]' => __('The transaction status for the transaction.', 'event_espresso'), |
66 | 66 | '[TXN_STATUS_ID]' => __('The ID representing the transaction status as saved in the db. This tends to be useful for including with css classes for styling certain statuses differently from others.', 'event_espresso'), |
@@ -71,54 +71,54 @@ discard block |
||
71 | 71 | '[TOTAL_OWING]' => __('The total owing on a transaction with no attributes.', 'event_espresso'), |
72 | 72 | '[TXN_SUBTOTAL]' => __('The subtotal for all txn line items.', 'event_espresso'), |
73 | 73 | '[TXN_TAX_SUBTOTAL]' => __('The subtotal for all tax line items.', 'event_espresso'), |
74 | - '[OWING_STATUS_MESSAGE_*]' => __('A dynamic shortcode for adjusting how total oweing gets shown. The acceptable attributes on the shortcode are:', 'event_espresso') . '<p></ul>' . |
|
75 | - '<li><strong>still_owing</strong>:' . __('If the transaction is not paid in full, then whatever is set for this attribute is shown (otherwise its just the amount oweing). The default is:', 'event_espresso' ) . sprintf( __( '%sPlease make a payment.%s', 'event_espresso'), '<a href="[PAYMENT_URL]" class="noPrint">', '</a>' ) . '</li>' . |
|
76 | - '<li><strong>none_owing</strong>:' . __('If the transaction is paid in full, then you can indicate how this gets displayed. Note, that it defaults to just be the total oweing.', 'event_espresso') . '</li></ul></p>', |
|
74 | + '[OWING_STATUS_MESSAGE_*]' => __('A dynamic shortcode for adjusting how total oweing gets shown. The acceptable attributes on the shortcode are:', 'event_espresso').'<p></ul>'. |
|
75 | + '<li><strong>still_owing</strong>:'.__('If the transaction is not paid in full, then whatever is set for this attribute is shown (otherwise its just the amount oweing). The default is:', 'event_espresso').sprintf(__('%sPlease make a payment.%s', 'event_espresso'), '<a href="[PAYMENT_URL]" class="noPrint">', '</a>').'</li>'. |
|
76 | + '<li><strong>none_owing</strong>:'.__('If the transaction is paid in full, then you can indicate how this gets displayed. Note, that it defaults to just be the total oweing.', 'event_espresso').'</li></ul></p>', |
|
77 | 77 | '[TXN_TOTAL_TICKETS]' => __('The total number of all tickets purchased in a transaction', 'event_espresso'), |
78 | 78 | '[TKT_QTY_PURCHASED]' => __('The total number of all tickets purchased in a transaction. <strong>NOTE: This shortcode is good to use in the "[TICKET_LIST]" field but has been deprecated from all other contexts in favor of the more explicit [TXN_TOTAL_TICKETS] shortcode.</strong>', 'event_espresso'), |
79 | 79 | '[TRANSACTION_ADMIN_URL]' => __('The url to the admin page for this transaction', 'event_espresso'), |
80 | 80 | '[RECEIPT_URL]' => __('This parses to the generated url for retrieving the receipt for the transaction', 'event_espresso'), |
81 | - '[INVOICE_RECEIPT_SWITCHER_URL]' => __( 'This parses to the url that will switch to the receipt if an invoice is displayed, and switch to the invoice if receipt is displayed. If a message type OTHER than invoice or receipt is displayed then this will just return the url for the invoice. If the related message type is not active then will parse to an empty string.', 'event_espresso'), |
|
82 | - '[INVOICE_RECEIPT_SWITCHER_BUTTON]' => sprintf( __( 'The same as %1$s[INVOICE_RECEIPT_SWITCHER_URL]%2$s except this returns the html for a button linked to the invoice or receipt.', 'event_espresso' ), '<code>', '</code>' ) |
|
81 | + '[INVOICE_RECEIPT_SWITCHER_URL]' => __('This parses to the url that will switch to the receipt if an invoice is displayed, and switch to the invoice if receipt is displayed. If a message type OTHER than invoice or receipt is displayed then this will just return the url for the invoice. If the related message type is not active then will parse to an empty string.', 'event_espresso'), |
|
82 | + '[INVOICE_RECEIPT_SWITCHER_BUTTON]' => sprintf(__('The same as %1$s[INVOICE_RECEIPT_SWITCHER_URL]%2$s except this returns the html for a button linked to the invoice or receipt.', 'event_espresso'), '<code>', '</code>') |
|
83 | 83 | ); |
84 | 84 | } |
85 | 85 | |
86 | 86 | |
87 | - protected function _parser( $shortcode ) { |
|
87 | + protected function _parser($shortcode) { |
|
88 | 88 | |
89 | - EE_Registry::instance()->load_helper( 'Template' ); |
|
89 | + EE_Registry::instance()->load_helper('Template'); |
|
90 | 90 | |
91 | 91 | //attempt to get the transaction. Since this is potentially used in more fields, we may have to look in the _extra_data for the transaction. |
92 | 92 | $transaction = $this->_data->txn instanceof EE_Transaction ? $this->_data->txn : null; |
93 | - $transaction = ! $transaction instanceof EE_Transaction && is_array( $this->_extra_data ) && isset( $this->_extra_data['data'] ) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->txn: $transaction; |
|
93 | + $transaction = ! $transaction instanceof EE_Transaction && is_array($this->_extra_data) && isset($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->txn : $transaction; |
|
94 | 94 | |
95 | 95 | //payment |
96 | 96 | $payment = $this->_data->payment instanceof EE_Payment ? $this->_data->payment : null; |
97 | - $payment = ! $payment instanceof EE_Payment && is_array( $this->_extra_data ) && isset( $this->_extra_data['data'] ) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->payment: $payment; |
|
97 | + $payment = ! $payment instanceof EE_Payment && is_array($this->_extra_data) && isset($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->payment : $payment; |
|
98 | 98 | |
99 | 99 | |
100 | - if ( ! $transaction instanceof EE_Transaction ) |
|
100 | + if ( ! $transaction instanceof EE_Transaction) |
|
101 | 101 | return ''; |
102 | 102 | |
103 | - switch ( $shortcode ) { |
|
103 | + switch ($shortcode) { |
|
104 | 104 | case '[TXN_ID]' : |
105 | 105 | return $transaction->ID(); |
106 | 106 | break; |
107 | 107 | |
108 | 108 | case '[PAYMENT_URL]' : |
109 | 109 | $payment_url = $transaction->payment_overview_url(); |
110 | - return empty( $payment_url ) ? __( 'http://dummypaymenturlforpreview.com', 'event_espresso') : $payment_url; |
|
110 | + return empty($payment_url) ? __('http://dummypaymenturlforpreview.com', 'event_espresso') : $payment_url; |
|
111 | 111 | break; |
112 | 112 | |
113 | 113 | case '[INVOICE_LINK]' : |
114 | 114 | $invoice_url = $transaction->invoice_url(); |
115 | - $invoice_url = empty( $invoice_url ) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url; |
|
116 | - return sprintf( __('%sClick here for Invoice%s', 'event_espresso'), '<a href="' . $invoice_url . '">', '</a>' ); |
|
115 | + $invoice_url = empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url; |
|
116 | + return sprintf(__('%sClick here for Invoice%s', 'event_espresso'), '<a href="'.$invoice_url.'">', '</a>'); |
|
117 | 117 | break; /**/ |
118 | 118 | |
119 | 119 | case '[INVOICE_URL]' : |
120 | 120 | $invoice_url = $transaction->invoice_url(); |
121 | - return empty( $invoice_url ) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url; |
|
121 | + return empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url; |
|
122 | 122 | break; |
123 | 123 | |
124 | 124 | case '[INVOICE_LOGO_URL]' : |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | break; |
127 | 127 | |
128 | 128 | case '[INVOICE_LOGO]' : |
129 | - return $this->_get_invoice_logo( TRUE ); |
|
129 | + return $this->_get_invoice_logo(TRUE); |
|
130 | 130 | break; |
131 | 131 | |
132 | 132 | case '[INVOICE_PAYEE_NAME]' : |
@@ -148,18 +148,18 @@ discard block |
||
148 | 148 | |
149 | 149 | case "[TOTAL_COST]" : |
150 | 150 | $total = $transaction->total(); |
151 | - return ! empty($total) ? EEH_Template::format_currency( $total ) : ''; |
|
151 | + return ! empty($total) ? EEH_Template::format_currency($total) : ''; |
|
152 | 152 | break; |
153 | 153 | |
154 | 154 | case "[PAYMENT_STATUS]" : |
155 | 155 | $status = $transaction->pretty_status(); |
156 | - return !empty($status) ? $status : __('Unknown', 'event_espresso'); |
|
156 | + return ! empty($status) ? $status : __('Unknown', 'event_espresso'); |
|
157 | 157 | break; /**/ |
158 | 158 | |
159 | 159 | // note the [payment_status] shortcode is kind of misleading because payment status might be different from txn status so I'm adding this here for clarity. |
160 | 160 | case "[TXN_STATUS]" : |
161 | 161 | $status = $transaction->pretty_status(); |
162 | - return !empty( $status ) ? $status : __('Unknown', 'event_espresso'); |
|
162 | + return ! empty($status) ? $status : __('Unknown', 'event_espresso'); |
|
163 | 163 | break; |
164 | 164 | |
165 | 165 | case "[TXN_STATUS_ID]" : |
@@ -167,21 +167,21 @@ discard block |
||
167 | 167 | break; |
168 | 168 | |
169 | 169 | case "[PAYMENT_GATEWAY]" : |
170 | - return $this->_get_payment_gateway( $transaction ); |
|
170 | + return $this->_get_payment_gateway($transaction); |
|
171 | 171 | break; |
172 | 172 | |
173 | 173 | case "[AMOUNT_PAID]" : |
174 | 174 | $amount = $payment instanceof EE_Payment ? $payment->amount() : 0; |
175 | - return EEH_Template::format_currency( $amount ); |
|
175 | + return EEH_Template::format_currency($amount); |
|
176 | 176 | break; |
177 | 177 | |
178 | 178 | case "[TOTAL_AMOUNT_PAID]" : |
179 | - return EEH_Template::format_currency( $transaction->paid() ); |
|
179 | + return EEH_Template::format_currency($transaction->paid()); |
|
180 | 180 | break; |
181 | 181 | |
182 | 182 | case "[TOTAL_OWING]" : |
183 | 183 | $total_owing = $transaction->remaining(); |
184 | - return EEH_Template::format_currency( $total_owing ); |
|
184 | + return EEH_Template::format_currency($total_owing); |
|
185 | 185 | break; |
186 | 186 | |
187 | 187 | case "[TXN_SUBTOTAL]" : |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | break; |
190 | 190 | |
191 | 191 | case "[TXN_TAX_SUBTOTAL]" : |
192 | - return EEH_Template::format_currency($this->_get_subtotal( TRUE )); |
|
192 | + return EEH_Template::format_currency($this->_get_subtotal(TRUE)); |
|
193 | 193 | break; |
194 | 194 | |
195 | 195 | case "[TKT_QTY_PURCHASED]" : |
@@ -198,9 +198,9 @@ discard block |
||
198 | 198 | break; |
199 | 199 | |
200 | 200 | case "[TRANSACTION_ADMIN_URL]" : |
201 | - require_once EE_CORE . 'admin/EE_Admin_Page.core.php'; |
|
202 | - $query_args = array( 'page' => 'espresso_transactions', 'action' => 'view_transaction', 'TXN_ID' => $transaction->ID() ); |
|
203 | - $url = EE_Admin_Page::add_query_args_and_nonce( $query_args, admin_url('admin.php') ); |
|
201 | + require_once EE_CORE.'admin/EE_Admin_Page.core.php'; |
|
202 | + $query_args = array('page' => 'espresso_transactions', 'action' => 'view_transaction', 'TXN_ID' => $transaction->ID()); |
|
203 | + $url = EE_Admin_Page::add_query_args_and_nonce($query_args, admin_url('admin.php')); |
|
204 | 204 | return $url; |
205 | 205 | break; |
206 | 206 | |
@@ -208,14 +208,14 @@ discard block |
||
208 | 208 | //get primary_registration |
209 | 209 | $reg = $this->_data->primary_reg_obj; |
210 | 210 | |
211 | - if ( ! $reg instanceof EE_Registration ) { |
|
211 | + if ( ! $reg instanceof EE_Registration) { |
|
212 | 212 | return ''; |
213 | 213 | } |
214 | 214 | return $reg->receipt_url(); |
215 | 215 | break; |
216 | 216 | |
217 | 217 | case "[INVOICE_RECEIPT_SWITCHER_URL]" : |
218 | - return $this->_get_invoice_receipt_switcher( FALSE ); |
|
218 | + return $this->_get_invoice_receipt_switcher(FALSE); |
|
219 | 219 | break; |
220 | 220 | |
221 | 221 | case "[INVOICE_RECEIPT_SWITCHER_BUTTON]" : |
@@ -225,20 +225,20 @@ discard block |
||
225 | 225 | |
226 | 226 | } |
227 | 227 | |
228 | - if ( strpos( $shortcode, '[OWING_STATUS_MESSAGE_*' ) !== FALSE ) { |
|
229 | - return $this->_get_custom_total_oweing( $shortcode ); |
|
228 | + if (strpos($shortcode, '[OWING_STATUS_MESSAGE_*') !== FALSE) { |
|
229 | + return $this->_get_custom_total_oweing($shortcode); |
|
230 | 230 | } |
231 | 231 | |
232 | - if ( strpos( $shortcode, '[INVOICE_PAYEE_TAX_NUMBER_*' ) !== FALSE ) { |
|
233 | - return $this->_get_invoice_payee_tax_number( $shortcode ); |
|
232 | + if (strpos($shortcode, '[INVOICE_PAYEE_TAX_NUMBER_*') !== FALSE) { |
|
233 | + return $this->_get_invoice_payee_tax_number($shortcode); |
|
234 | 234 | } |
235 | 235 | |
236 | - if ( strpos( $shortcode, '[PAYMENT_LINK_IF_NEEDED_*' ) !== FALSE ) { |
|
237 | - return $this->_get_payment_link_if_needed( $shortcode ); |
|
236 | + if (strpos($shortcode, '[PAYMENT_LINK_IF_NEEDED_*') !== FALSE) { |
|
237 | + return $this->_get_payment_link_if_needed($shortcode); |
|
238 | 238 | } |
239 | 239 | |
240 | - if ( strpos( $shortcode, '[PAYMENT_DUE_DATE_*' ) !== false ) { |
|
241 | - return $this->_get_payment_due_date( $shortcode, $transaction ); |
|
240 | + if (strpos($shortcode, '[PAYMENT_DUE_DATE_*') !== false) { |
|
241 | + return $this->_get_payment_due_date($shortcode, $transaction); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | return ''; |
@@ -255,22 +255,22 @@ discard block |
||
255 | 255 | * |
256 | 256 | * @return string parsed. |
257 | 257 | */ |
258 | - private function _get_custom_total_oweing( $shortcode ) { |
|
259 | - $valid_shortcodes = array( 'transaction' ); |
|
260 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
258 | + private function _get_custom_total_oweing($shortcode) { |
|
259 | + $valid_shortcodes = array('transaction'); |
|
260 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
261 | 261 | |
262 | 262 | //ensure default is set. |
263 | 263 | $addressee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
264 | 264 | $total_owing = $addressee instanceof EE_Messages_Addressee && $addressee->txn instanceof EE_Transaction ? $addressee->txn->remaining() : 0; |
265 | 265 | |
266 | - if ( $total_owing > 0 ) { |
|
267 | - $owing_content = ! empty( $attrs['still_owing'] ) ? $attrs['still_owing'] : sprintf( __( '%sPlease make a payment.%s', 'event_espresso'), '<a href="[PAYMENT_URL]" class="noPrint">', '</a>' ); |
|
266 | + if ($total_owing > 0) { |
|
267 | + $owing_content = ! empty($attrs['still_owing']) ? $attrs['still_owing'] : sprintf(__('%sPlease make a payment.%s', 'event_espresso'), '<a href="[PAYMENT_URL]" class="noPrint">', '</a>'); |
|
268 | 268 | |
269 | 269 | //we need to re run this string through the parser to catch any shortcodes that are in it. |
270 | 270 | $this->_set_shortcode_helper(); |
271 | - $owing_content = $this->_shortcode_helper->parse_message_template( $owing_content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_context, $this->_GRP_ID ); |
|
271 | + $owing_content = $this->_shortcode_helper->parse_message_template($owing_content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_context, $this->_GRP_ID); |
|
272 | 272 | } else { |
273 | - $owing_content = !empty( $attrs['none_owing']) ? $attrs['none_owing'] : ''; |
|
273 | + $owing_content = ! empty($attrs['none_owing']) ? $attrs['none_owing'] : ''; |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | return $owing_content; |
@@ -278,8 +278,8 @@ discard block |
||
278 | 278 | |
279 | 279 | |
280 | 280 | |
281 | - private function _get_payment_gateway( $transaction ) { |
|
282 | - $pm = $this->_get_payment_method( $transaction ); |
|
281 | + private function _get_payment_gateway($transaction) { |
|
282 | + $pm = $this->_get_payment_method($transaction); |
|
283 | 283 | return $pm instanceof EE_Payment_Method ? $pm->name() : ''; |
284 | 284 | } |
285 | 285 | |
@@ -294,37 +294,37 @@ discard block |
||
294 | 294 | * |
295 | 295 | * @return string url or html |
296 | 296 | */ |
297 | - private function _get_invoice_logo( $img_tags = FALSE ) { |
|
297 | + private function _get_invoice_logo($img_tags = FALSE) { |
|
298 | 298 | //try to get the invoice payment method's logo for this transaction image first |
299 | 299 | $pm = $this->_get_payment_method(); |
300 | - if ( $pm instanceof EE_Payment_Method ){ |
|
301 | - $invoice_logo_url = $pm->get_extra_meta( 'pdf_logo_image', TRUE ); |
|
302 | - }else{ |
|
300 | + if ($pm instanceof EE_Payment_Method) { |
|
301 | + $invoice_logo_url = $pm->get_extra_meta('pdf_logo_image', TRUE); |
|
302 | + } else { |
|
303 | 303 | $invoice_logo_url = NULL; |
304 | 304 | } |
305 | - if( empty( $invoice_logo_url ) ){ |
|
305 | + if (empty($invoice_logo_url)) { |
|
306 | 306 | $invoice_logo_url = EE_Registry::instance()->CFG->organization->logo_url; |
307 | 307 | } |
308 | 308 | |
309 | - if ( empty( $invoice_logo_url ) ) { |
|
309 | + if (empty($invoice_logo_url)) { |
|
310 | 310 | return ''; |
311 | 311 | } |
312 | 312 | |
313 | - if ( ! $img_tags ) { |
|
313 | + if ( ! $img_tags) { |
|
314 | 314 | return $invoice_logo_url; |
315 | 315 | } |
316 | 316 | |
317 | 317 | //image tags have been requested. |
318 | - $image_size = getimagesize( $invoice_logo_url ); |
|
318 | + $image_size = getimagesize($invoice_logo_url); |
|
319 | 319 | |
320 | 320 | //if image is wider than 200px, set the wideth to 200 |
321 | - if ( $image_size[0] > 300 ) { |
|
321 | + if ($image_size[0] > 300) { |
|
322 | 322 | $image_width = 300; |
323 | - }else{ |
|
323 | + } else { |
|
324 | 324 | $image_width = $image_size[0]; |
325 | 325 | } |
326 | 326 | |
327 | - return '<img class="logo screen" src="' . $invoice_logo_url . '" width="' . $image_width . '" alt="logo" />'; |
|
327 | + return '<img class="logo screen" src="'.$invoice_logo_url.'" width="'.$image_width.'" alt="logo" />'; |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | |
@@ -341,26 +341,26 @@ discard block |
||
341 | 341 | private function _get_invoice_payee_name() { |
342 | 342 | $payee_name = NULL; |
343 | 343 | $pm = $this->_get_payment_method(); |
344 | - if( $pm instanceof EE_Payment_Method ){ |
|
345 | - $payee_name = $pm->get_extra_meta( 'pdf_payee_name', TRUE ); |
|
344 | + if ($pm instanceof EE_Payment_Method) { |
|
345 | + $payee_name = $pm->get_extra_meta('pdf_payee_name', TRUE); |
|
346 | 346 | } |
347 | - $payee_name = empty( $payee_name ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'name' ) : $payee_name; |
|
347 | + $payee_name = empty($payee_name) ? EE_Registry::instance()->CFG->organization->get_pretty('name') : $payee_name; |
|
348 | 348 | return $payee_name; |
349 | 349 | } |
350 | 350 | |
351 | 351 | /** |
352 | 352 | * gets the payment method for this transaction. Otherwise gets a default one. |
353 | 353 | */ |
354 | - private function _get_payment_method( $transaction = null ){ |
|
355 | - if( $transaction instanceof EE_Transaction ) { |
|
354 | + private function _get_payment_method($transaction = null) { |
|
355 | + if ($transaction instanceof EE_Transaction) { |
|
356 | 356 | $payment_method = $transaction->payment_method(); |
357 | - if ( empty( $payment_method ) ) { |
|
358 | - return apply_filters( 'FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type('Invoice')); |
|
357 | + if (empty($payment_method)) { |
|
358 | + return apply_filters('FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type('Invoice')); |
|
359 | 359 | } |
360 | 360 | return $payment_method; |
361 | - }else{ |
|
361 | + } else { |
|
362 | 362 | //get the first payment method we can find |
363 | - return apply_filters( 'FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type('Invoice')); |
|
363 | + return apply_filters('FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type('Invoice')); |
|
364 | 364 | } |
365 | 365 | } |
366 | 366 | |
@@ -377,10 +377,10 @@ discard block |
||
377 | 377 | private function _get_invoice_payee_email() { |
378 | 378 | $payee_email = NULL; |
379 | 379 | $pm = $this->_get_payment_method(); |
380 | - if( $pm instanceof EE_Payment_Method ){ |
|
381 | - $payee_email = $pm->get_extra_meta( 'pdf_payee_email', TRUE ); |
|
380 | + if ($pm instanceof EE_Payment_Method) { |
|
381 | + $payee_email = $pm->get_extra_meta('pdf_payee_email', TRUE); |
|
382 | 382 | } |
383 | - $payee_email = empty( $payee_email ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) : $payee_email; |
|
383 | + $payee_email = empty($payee_email) ? EE_Registry::instance()->CFG->organization->get_pretty('email') : $payee_email; |
|
384 | 384 | return $payee_email; |
385 | 385 | } |
386 | 386 | |
@@ -396,24 +396,24 @@ discard block |
||
396 | 396 | * |
397 | 397 | * @return string |
398 | 398 | */ |
399 | - private function _get_invoice_payee_tax_number( $shortcode ) { |
|
399 | + private function _get_invoice_payee_tax_number($shortcode) { |
|
400 | 400 | $payee_tax_number = NULL; |
401 | 401 | $pm = $this->_get_payment_method(); |
402 | - if( $pm instanceof EE_Payment_Method ){ |
|
403 | - $payee_tax_number = $pm->get_extra_meta( 'pdf_payee_tax_number', TRUE ); |
|
402 | + if ($pm instanceof EE_Payment_Method) { |
|
403 | + $payee_tax_number = $pm->get_extra_meta('pdf_payee_tax_number', TRUE); |
|
404 | 404 | } |
405 | - $payee_tax_number = empty( $payee_tax_number ) ? EE_Registry::instance()->CFG->organization->vat : $payee_tax_number; |
|
405 | + $payee_tax_number = empty($payee_tax_number) ? EE_Registry::instance()->CFG->organization->vat : $payee_tax_number; |
|
406 | 406 | |
407 | - if ( empty( $payee_tax_number ) ) { |
|
407 | + if (empty($payee_tax_number)) { |
|
408 | 408 | return ''; |
409 | 409 | } |
410 | 410 | |
411 | 411 | //any attributes? |
412 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
412 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
413 | 413 | |
414 | 414 | //prefix? |
415 | - $prefix = isset( $attrs['prefix'] ) ? $attrs['prefix'] : __( 'VAT/Tax Number: ', 'event_espresso' ); |
|
416 | - return $prefix . $payee_tax_number; |
|
415 | + $prefix = isset($attrs['prefix']) ? $attrs['prefix'] : __('VAT/Tax Number: ', 'event_espresso'); |
|
416 | + return $prefix.$payee_tax_number; |
|
417 | 417 | } |
418 | 418 | |
419 | 419 | |
@@ -430,22 +430,22 @@ discard block |
||
430 | 430 | private function _get_invoice_payee_address() { |
431 | 431 | $payee_address = NULL; |
432 | 432 | $pm = $this->_get_payment_method(); |
433 | - if( $pm instanceof EE_Payment_Method ){ |
|
434 | - $payee_address = $pm->get_extra_meta( 'pdf_payee_address', TRUE ); |
|
433 | + if ($pm instanceof EE_Payment_Method) { |
|
434 | + $payee_address = $pm->get_extra_meta('pdf_payee_address', TRUE); |
|
435 | 435 | } |
436 | - if ( empty( $payee_address ) ) { |
|
436 | + if (empty($payee_address)) { |
|
437 | 437 | $organization = EE_Registry::instance()->CFG->organization; |
438 | - $payee_address = $organization->get_pretty( 'address_1' ) . '<br>'; |
|
439 | - $payee_address .= !empty( $organization->address_2 ) ? $organization->get_pretty( 'address_2' ) . '<br>' : ''; |
|
440 | - $payee_address .= $organization->get_pretty( 'city' ) . '<br>'; |
|
438 | + $payee_address = $organization->get_pretty('address_1').'<br>'; |
|
439 | + $payee_address .= ! empty($organization->address_2) ? $organization->get_pretty('address_2').'<br>' : ''; |
|
440 | + $payee_address .= $organization->get_pretty('city').'<br>'; |
|
441 | 441 | |
442 | 442 | //state |
443 | - $state = EE_Registry::instance()->load_model( 'State' )->get_one_by_ID( $organization->STA_ID ); |
|
444 | - $payee_address .= $state instanceof EE_State ? $state->name() : ''; |
|
443 | + $state = EE_Registry::instance()->load_model('State')->get_one_by_ID($organization->STA_ID); |
|
444 | + $payee_address .= $state instanceof EE_State ? $state->name() : ''; |
|
445 | 445 | |
446 | 446 | //Country |
447 | - $payee_address .= ! empty( $organization->CNT_ISO ) ? ', ' . $organization->CNT_ISO . '<br>' : ''; |
|
448 | - $payee_address .= ! empty( $organization->zip ) ? $organization->zip : ''; |
|
447 | + $payee_address .= ! empty($organization->CNT_ISO) ? ', '.$organization->CNT_ISO.'<br>' : ''; |
|
448 | + $payee_address .= ! empty($organization->zip) ? $organization->zip : ''; |
|
449 | 449 | } |
450 | 450 | return $payee_address; |
451 | 451 | } |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | private function _get_invoice_payment_instructions() { |
464 | 464 | $instructions = NULL; |
465 | 465 | $pm = $this->_get_payment_method(); |
466 | - return ( $pm instanceof EE_Payment_Method ) ? $pm->get_extra_meta( 'pdf_instructions', TRUE) : ''; |
|
466 | + return ($pm instanceof EE_Payment_Method) ? $pm->get_extra_meta('pdf_instructions', TRUE) : ''; |
|
467 | 467 | } |
468 | 468 | |
469 | 469 | |
@@ -477,27 +477,27 @@ discard block |
||
477 | 477 | * |
478 | 478 | * @return string |
479 | 479 | */ |
480 | - protected function _get_invoice_receipt_switcher( $button = TRUE ) { |
|
480 | + protected function _get_invoice_receipt_switcher($button = TRUE) { |
|
481 | 481 | $reg = $this->_data->primary_reg_obj; |
482 | - $message_type = isset( $this->_extra_data['message_type'] ) ? $this->_extra_data['message_type'] : ''; |
|
483 | - if ( ! $reg instanceof EE_Registration || empty( $message_type ) ) { |
|
482 | + $message_type = isset($this->_extra_data['message_type']) ? $this->_extra_data['message_type'] : ''; |
|
483 | + if ( ! $reg instanceof EE_Registration || empty($message_type)) { |
|
484 | 484 | return''; |
485 | 485 | } |
486 | 486 | |
487 | - $switch_to_invoice = ! $message_type instanceof EE_Invoice_message_type ? true : false; |
|
488 | - $switch_to_label = $switch_to_invoice && ! $message_type instanceof EE_Receipt_message_type ? __('View Invoice', 'event_espresso' ) : __( 'Switch to Invoice', 'event_espresso' ); |
|
489 | - $switch_to_label = ! $switch_to_invoice ? __( 'Switch to Receipt', 'event_espresso' ) : $switch_to_label; |
|
487 | + $switch_to_invoice = ! $message_type instanceof EE_Invoice_message_type ? true : false; |
|
488 | + $switch_to_label = $switch_to_invoice && ! $message_type instanceof EE_Receipt_message_type ? __('View Invoice', 'event_espresso') : __('Switch to Invoice', 'event_espresso'); |
|
489 | + $switch_to_label = ! $switch_to_invoice ? __('Switch to Receipt', 'event_espresso') : $switch_to_label; |
|
490 | 490 | $switch_to_url = $switch_to_invoice ? $reg->invoice_url() : $reg->receipt_url(); |
491 | 491 | |
492 | - if ( ! $button ) { |
|
492 | + if ( ! $button) { |
|
493 | 493 | return $switch_to_url; |
494 | 494 | } |
495 | 495 | |
496 | - if ( ! empty( $switch_to_url ) ) { |
|
496 | + if ( ! empty($switch_to_url)) { |
|
497 | 497 | |
498 | 498 | return ' |
499 | -<form method="post" action="' . $switch_to_url . '" > |
|
500 | - <input class="print_button" type="submit" value="' . $switch_to_label . '" /> |
|
499 | +<form method="post" action="' . $switch_to_url.'" > |
|
500 | + <input class="print_button" type="submit" value="' . $switch_to_label.'" /> |
|
501 | 501 | </form> |
502 | 502 | '; |
503 | 503 | } |
@@ -517,11 +517,11 @@ discard block |
||
517 | 517 | * |
518 | 518 | * @return string |
519 | 519 | */ |
520 | - private function _get_receipt_url( EE_Transaction $transaction ) { |
|
520 | + private function _get_receipt_url(EE_Transaction $transaction) { |
|
521 | 521 | //get primary_registration |
522 | 522 | $reg = $this->_data->primary_reg_obj; |
523 | 523 | |
524 | - if ( ! $reg instanceof EE_Registration ) { |
|
524 | + if ( ! $reg instanceof EE_Registration) { |
|
525 | 525 | return ''; |
526 | 526 | } |
527 | 527 | |
@@ -537,10 +537,10 @@ discard block |
||
537 | 537 | * |
538 | 538 | * @return int |
539 | 539 | */ |
540 | - private function _get_subtotal( $tax = FALSE ) { |
|
541 | - $grand_total = isset( $this->_data->grand_total_line_item ) ? $this->_data->grand_total_line_item : NULL; |
|
540 | + private function _get_subtotal($tax = FALSE) { |
|
541 | + $grand_total = isset($this->_data->grand_total_line_item) ? $this->_data->grand_total_line_item : NULL; |
|
542 | 542 | |
543 | - if ( ! $grand_total instanceof EE_Line_Item ) { |
|
543 | + if ( ! $grand_total instanceof EE_Line_Item) { |
|
544 | 544 | return 0; |
545 | 545 | } |
546 | 546 | |
@@ -559,27 +559,27 @@ discard block |
||
559 | 559 | * |
560 | 560 | * @return string parsed. |
561 | 561 | */ |
562 | - private function _get_payment_link_if_needed( $shortcode ) { |
|
563 | - $valid_shortcodes = array( 'transaction' ); |
|
564 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
562 | + private function _get_payment_link_if_needed($shortcode) { |
|
563 | + $valid_shortcodes = array('transaction'); |
|
564 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
565 | 565 | |
566 | 566 | //ensure default is set. |
567 | 567 | $addressee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
568 | 568 | $total_owing = $addressee instanceof EE_Messages_Addressee && $addressee->txn instanceof EE_Transaction ? $addressee->txn->remaining() : 0; |
569 | 569 | |
570 | - if ( $total_owing > 0 ) { |
|
571 | - $class = isset( $attrs['class'] ) ? $attrs['class'] : 'callout'; |
|
572 | - $custom_text = isset( $attrs['custom_text'] ) ? $attrs['custom_text'] : 'You can %smake a payment here »%s.'; |
|
573 | - $container_tag = isset( $attrs['container_tag'] ) ? $attrs['container_tag'] : 'p'; |
|
574 | - $opening_tag = ! empty( $container_tag ) ? '<' . $container_tag : ''; |
|
575 | - $opening_tag .= ! empty( $opening_tag ) && !empty( $class ) ? ' class="' . $class . '"' : $opening_tag; |
|
576 | - $opening_tag .= !empty( $opening_tag ) ? '>' : $opening_tag; |
|
577 | - $closing_tag = ! empty( $container_tag ) ? '</' . $container_tag .'>' : ''; |
|
578 | - $content = $opening_tag . sprintf( $custom_text, '<a href="[PAYMENT_URL]">', '</a>' ) . $closing_tag; |
|
570 | + if ($total_owing > 0) { |
|
571 | + $class = isset($attrs['class']) ? $attrs['class'] : 'callout'; |
|
572 | + $custom_text = isset($attrs['custom_text']) ? $attrs['custom_text'] : 'You can %smake a payment here »%s.'; |
|
573 | + $container_tag = isset($attrs['container_tag']) ? $attrs['container_tag'] : 'p'; |
|
574 | + $opening_tag = ! empty($container_tag) ? '<'.$container_tag : ''; |
|
575 | + $opening_tag .= ! empty($opening_tag) && ! empty($class) ? ' class="'.$class.'"' : $opening_tag; |
|
576 | + $opening_tag .= ! empty($opening_tag) ? '>' : $opening_tag; |
|
577 | + $closing_tag = ! empty($container_tag) ? '</'.$container_tag.'>' : ''; |
|
578 | + $content = $opening_tag.sprintf($custom_text, '<a href="[PAYMENT_URL]">', '</a>').$closing_tag; |
|
579 | 579 | |
580 | 580 | //we need to re run this string through the parser to catch any shortcodes that are in it. |
581 | 581 | $this->_set_shortcode_helper(); |
582 | - $owing_content = $this->_shortcode_helper->parse_message_template( $content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_context, $this->_GRP_ID ); |
|
582 | + $owing_content = $this->_shortcode_helper->parse_message_template($content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_context, $this->_GRP_ID); |
|
583 | 583 | } else { |
584 | 584 | return ''; |
585 | 585 | } |
@@ -599,31 +599,31 @@ discard block |
||
599 | 599 | * @param EE_Transaction $transaction |
600 | 600 | * @return string |
601 | 601 | */ |
602 | - protected function _get_payment_due_date( $shortcode, EE_Transaction $transaction ) { |
|
602 | + protected function _get_payment_due_date($shortcode, EE_Transaction $transaction) { |
|
603 | 603 | //if transaction is paid in full then we can just return an empty string |
604 | - if ( $transaction->remaining() === 0 ) { |
|
604 | + if ($transaction->remaining() === 0) { |
|
605 | 605 | return ''; |
606 | 606 | } |
607 | 607 | |
608 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
609 | - $format = isset( $attrs['format'] ) ? $attrs['format'] : get_option( 'date_format' ); |
|
610 | - $days_until_due = isset( $attrs['days_until_due'] ) ? (int) $attrs['days_until_due'] : 30; |
|
611 | - $prefix_text = isset( $attrs['prefix_text'] ) ? $attrs['prefix_text'] : __( 'Payment in full due by: ', 'event_espresso' ); |
|
612 | - $transaction_created = $transaction->get_DateTime_object( 'TXN_timestamp' ); |
|
608 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
609 | + $format = isset($attrs['format']) ? $attrs['format'] : get_option('date_format'); |
|
610 | + $days_until_due = isset($attrs['days_until_due']) ? (int) $attrs['days_until_due'] : 30; |
|
611 | + $prefix_text = isset($attrs['prefix_text']) ? $attrs['prefix_text'] : __('Payment in full due by: ', 'event_espresso'); |
|
612 | + $transaction_created = $transaction->get_DateTime_object('TXN_timestamp'); |
|
613 | 613 | |
614 | 614 | //setup date due: |
615 | 615 | try { |
616 | - if ( $transaction_created instanceof DateTime ) { |
|
617 | - $date_due = $transaction_created->add( new DateInterval( 'P' . $days_until_due . 'D' ) )->format( $format ); |
|
616 | + if ($transaction_created instanceof DateTime) { |
|
617 | + $date_due = $transaction_created->add(new DateInterval('P'.$days_until_due.'D'))->format($format); |
|
618 | 618 | } else { |
619 | 619 | throw new Exception(); |
620 | 620 | } |
621 | - } catch( Exception $e ) { |
|
621 | + } catch (Exception $e) { |
|
622 | 622 | //format was likely invalid. |
623 | 623 | $date_due = 'Unable to calculate date due, likely the format string is invalid.'; |
624 | 624 | } |
625 | 625 | |
626 | - return $prefix_text . $date_due; |
|
626 | + return $prefix_text.$date_due; |
|
627 | 627 | } |
628 | 628 | |
629 | 629 | } //end EE_Transaction Shortcodes library |
@@ -197,7 +197,7 @@ |
||
197 | 197 | * |
198 | 198 | * @access public |
199 | 199 | * @param $ATT_ID |
200 | - * @return mixed array on success, FALSE on fail |
|
200 | + * @return EE_Base_Class|null array on success, FALSE on fail |
|
201 | 201 | * @deprecated |
202 | 202 | */ |
203 | 203 | public function get_attendee_by_ID( $ATT_ID = FALSE ) { |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2 | -require_once ( EE_MODELS . 'EEM_Base.model.php' ); |
|
2 | +require_once (EE_MODELS.'EEM_Base.model.php'); |
|
3 | 3 | |
4 | 4 | /** |
5 | 5 | * |
@@ -21,60 +21,60 @@ discard block |
||
21 | 21 | * Please instead use the EEM_Attendee::system_question_* constants |
22 | 22 | * @deprecated |
23 | 23 | */ |
24 | - const fname_question_id=1; |
|
24 | + const fname_question_id = 1; |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * @deprecated |
28 | 28 | */ |
29 | - const lname_question_id=2; |
|
29 | + const lname_question_id = 2; |
|
30 | 30 | |
31 | 31 | |
32 | 32 | /** |
33 | 33 | * @deprecated |
34 | 34 | */ |
35 | - const email_question_id=3; |
|
35 | + const email_question_id = 3; |
|
36 | 36 | |
37 | 37 | |
38 | 38 | /** |
39 | 39 | * @deprecated |
40 | 40 | */ |
41 | - const address_question_id=4; |
|
41 | + const address_question_id = 4; |
|
42 | 42 | |
43 | 43 | |
44 | 44 | /** |
45 | 45 | * @deprecated |
46 | 46 | */ |
47 | - const address2_question_id=5; |
|
47 | + const address2_question_id = 5; |
|
48 | 48 | |
49 | 49 | |
50 | 50 | /** |
51 | 51 | * @deprecated |
52 | 52 | */ |
53 | - const city_question_id=6; |
|
53 | + const city_question_id = 6; |
|
54 | 54 | |
55 | 55 | |
56 | 56 | /** |
57 | 57 | * @deprecated |
58 | 58 | */ |
59 | - const state_question_id=7; |
|
59 | + const state_question_id = 7; |
|
60 | 60 | |
61 | 61 | |
62 | 62 | /** |
63 | 63 | * @deprecated |
64 | 64 | */ |
65 | - const country_question_id=8; |
|
65 | + const country_question_id = 8; |
|
66 | 66 | |
67 | 67 | |
68 | 68 | /** |
69 | 69 | * @deprecated |
70 | 70 | */ |
71 | - const zip_question_id=9; |
|
71 | + const zip_question_id = 9; |
|
72 | 72 | |
73 | 73 | |
74 | 74 | /** |
75 | 75 | * @deprecated |
76 | 76 | */ |
77 | - const phone_question_id=10; |
|
77 | + const phone_question_id = 10; |
|
78 | 78 | |
79 | 79 | /** |
80 | 80 | * When looking for questions that correspond to attendee fields, |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | * @access protected |
120 | 120 | * @param null $timezone |
121 | 121 | */ |
122 | - protected function __construct( $timezone = NULL ) { |
|
123 | - $this->singular_item = __('Attendee','event_espresso'); |
|
124 | - $this->plural_item = __('Attendees','event_espresso'); |
|
122 | + protected function __construct($timezone = NULL) { |
|
123 | + $this->singular_item = __('Attendee', 'event_espresso'); |
|
124 | + $this->plural_item = __('Attendees', 'event_espresso'); |
|
125 | 125 | $this->_tables = array( |
126 | 126 | 'Attendee_CPT'=> new EE_Primary_Table('posts', 'ID'), |
127 | 127 | 'Attendee_Meta'=>new EE_Secondary_Table('esp_attendee_meta', 'ATTM_ID', 'ATT_ID') |
@@ -135,34 +135,34 @@ discard block |
||
135 | 135 | 'ATT_created'=>new EE_Datetime_Field('post_date', __("Time Attendee Created", "event_espresso"), false, time()), |
136 | 136 | 'ATT_short_bio'=>new EE_Simple_HTML_Field('post_excerpt', __("Attendee Short Biography", "event_espresso"), true, __("No Biography Provided", "event_espresso")), |
137 | 137 | 'ATT_modified'=>new EE_Datetime_Field('post_modified', __("Time Attendee Last Modified", "event_espresso"), FALSE, time()), |
138 | - 'ATT_author'=>new EE_WP_User_Field('post_author', __("Creator ID of the first Event attended", "event_espresso"), false ), |
|
138 | + 'ATT_author'=>new EE_WP_User_Field('post_author', __("Creator ID of the first Event attended", "event_espresso"), false), |
|
139 | 139 | 'ATT_parent'=>new EE_DB_Only_Int_Field('post_parent', __("Parent Attendee (unused)", "event_espresso"), false, 0), |
140 | - 'post_type'=>new EE_WP_Post_Type_Field('espresso_attendees'),// EE_DB_Only_Text_Field('post_type', __("Post Type of Attendee", "event_espresso"), false,'espresso_attendees'), |
|
140 | + 'post_type'=>new EE_WP_Post_Type_Field('espresso_attendees'), // EE_DB_Only_Text_Field('post_type', __("Post Type of Attendee", "event_espresso"), false,'espresso_attendees'), |
|
141 | 141 | 'status' => new EE_WP_Post_Status_Field('post_status', __('Attendee Status', 'event_espresso'), false, 'publish') |
142 | 142 | ), |
143 | 143 | 'Attendee_Meta'=>array( |
144 | - 'ATTM_ID'=> new EE_DB_Only_Int_Field('ATTM_ID', __('Attendee Meta Row ID','event_espresso'), false), |
|
144 | + 'ATTM_ID'=> new EE_DB_Only_Int_Field('ATTM_ID', __('Attendee Meta Row ID', 'event_espresso'), false), |
|
145 | 145 | 'ATT_ID_fk'=>new EE_DB_Only_Int_Field('ATT_ID', __("Foreign Key to Attendee in Post Table", "event_espresso"), false), |
146 | - 'ATT_fname'=>new EE_Plain_Text_Field('ATT_fname', __('First Name','event_espresso'), true, ''), |
|
147 | - 'ATT_lname'=>new EE_Plain_Text_Field('ATT_lname', __('Last Name','event_espresso'), true, ''), |
|
148 | - 'ATT_address'=>new EE_Plain_Text_Field('ATT_address', __('Address Part 1','event_espresso'), true, ''), |
|
149 | - 'ATT_address2'=>new EE_Plain_Text_Field('ATT_address2', __('Address Part 2','event_espresso'), true, ''), |
|
150 | - 'ATT_city'=>new EE_Plain_Text_Field('ATT_city', __('City','event_espresso'), true, ''), |
|
151 | - 'STA_ID'=>new EE_Foreign_Key_Int_Field('STA_ID', __('State','event_espresso'), true,0,'State'), |
|
152 | - 'CNT_ISO'=>new EE_Foreign_Key_String_Field('CNT_ISO', __('Country','event_espresso'), true,'','Country'), |
|
153 | - 'ATT_zip'=>new EE_Plain_Text_Field('ATT_zip', __('ZIP/Postal Code','event_espresso'), true, ''), |
|
154 | - 'ATT_email'=>new EE_Email_Field('ATT_email', __('Email Address','event_espresso'), true, ''), |
|
155 | - 'ATT_phone'=>new EE_Plain_Text_Field('ATT_phone', __('Phone','event_espresso'), true, '') |
|
146 | + 'ATT_fname'=>new EE_Plain_Text_Field('ATT_fname', __('First Name', 'event_espresso'), true, ''), |
|
147 | + 'ATT_lname'=>new EE_Plain_Text_Field('ATT_lname', __('Last Name', 'event_espresso'), true, ''), |
|
148 | + 'ATT_address'=>new EE_Plain_Text_Field('ATT_address', __('Address Part 1', 'event_espresso'), true, ''), |
|
149 | + 'ATT_address2'=>new EE_Plain_Text_Field('ATT_address2', __('Address Part 2', 'event_espresso'), true, ''), |
|
150 | + 'ATT_city'=>new EE_Plain_Text_Field('ATT_city', __('City', 'event_espresso'), true, ''), |
|
151 | + 'STA_ID'=>new EE_Foreign_Key_Int_Field('STA_ID', __('State', 'event_espresso'), true, 0, 'State'), |
|
152 | + 'CNT_ISO'=>new EE_Foreign_Key_String_Field('CNT_ISO', __('Country', 'event_espresso'), true, '', 'Country'), |
|
153 | + 'ATT_zip'=>new EE_Plain_Text_Field('ATT_zip', __('ZIP/Postal Code', 'event_espresso'), true, ''), |
|
154 | + 'ATT_email'=>new EE_Email_Field('ATT_email', __('Email Address', 'event_espresso'), true, ''), |
|
155 | + 'ATT_phone'=>new EE_Plain_Text_Field('ATT_phone', __('Phone', 'event_espresso'), true, '') |
|
156 | 156 | )); |
157 | 157 | $this->_model_relations = array( |
158 | 158 | 'Registration'=>new EE_Has_Many_Relation(), |
159 | 159 | 'State'=>new EE_Belongs_To_Relation(), |
160 | 160 | 'Country'=>new EE_Belongs_To_Relation(), |
161 | - 'Event'=>new EE_HABTM_Relation('Registration', FALSE ), |
|
161 | + 'Event'=>new EE_HABTM_Relation('Registration', FALSE), |
|
162 | 162 | 'WP_User' => new EE_Belongs_To_Relation(), |
163 | 163 | ); |
164 | 164 | $this->_caps_slug = 'contacts'; |
165 | - parent::__construct( $timezone ); |
|
165 | + parent::__construct($timezone); |
|
166 | 166 | |
167 | 167 | } |
168 | 168 | |
@@ -172,8 +172,8 @@ discard block |
||
172 | 172 | * @param string $system_question_string |
173 | 173 | * @return string|null if not found |
174 | 174 | */ |
175 | - public function get_attendee_field_for_system_question( $system_question_string ) { |
|
176 | - return isset( $this->_system_question_to_attendee_field_name[ $system_question_string ] ) ? $this->_system_question_to_attendee_field_name[ $system_question_string ] : null; |
|
175 | + public function get_attendee_field_for_system_question($system_question_string) { |
|
176 | + return isset($this->_system_question_to_attendee_field_name[$system_question_string]) ? $this->_system_question_to_attendee_field_name[$system_question_string] : null; |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | |
@@ -184,8 +184,8 @@ discard block |
||
184 | 184 | * @param EE_Transaction/int $transaction_id_or_obj EE_Transaction or its ID |
185 | 185 | * @return EE_Attendee[] |
186 | 186 | */ |
187 | - public function get_attendees_for_transaction( $transaction_id_or_obj ){ |
|
188 | - return $this->get_all( array( array( |
|
187 | + public function get_attendees_for_transaction($transaction_id_or_obj) { |
|
188 | + return $this->get_all(array(array( |
|
189 | 189 | 'Registration.Transaction.TXN_ID' => $transaction_id_or_obj instanceof EE_Transaction ? $transaction_id_or_obj->ID() : $transaction_id_or_obj |
190 | 190 | ))); |
191 | 191 | } |
@@ -200,9 +200,9 @@ discard block |
||
200 | 200 | * @return mixed array on success, FALSE on fail |
201 | 201 | * @deprecated |
202 | 202 | */ |
203 | - public function get_attendee_by_ID( $ATT_ID = FALSE ) { |
|
203 | + public function get_attendee_by_ID($ATT_ID = FALSE) { |
|
204 | 204 | // retrieve a particular EE_Attendee |
205 | - return $this->get_one_by_ID( $ATT_ID ); |
|
205 | + return $this->get_one_by_ID($ATT_ID); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | |
@@ -215,14 +215,14 @@ discard block |
||
215 | 215 | * @param array $where_cols_n_values |
216 | 216 | * @return mixed array on success, FALSE on fail |
217 | 217 | */ |
218 | - public function get_attendee( $where_cols_n_values = array() ) { |
|
218 | + public function get_attendee($where_cols_n_values = array()) { |
|
219 | 219 | |
220 | - if ( empty( $where_cols_n_values )) { |
|
220 | + if (empty($where_cols_n_values)) { |
|
221 | 221 | return FALSE; |
222 | 222 | } |
223 | - $attendee = $this->get_all( array($where_cols_n_values )); |
|
224 | - if ( ! empty( $attendee )) { |
|
225 | - return array_shift( $attendee ); |
|
223 | + $attendee = $this->get_all(array($where_cols_n_values)); |
|
224 | + if ( ! empty($attendee)) { |
|
225 | + return array_shift($attendee); |
|
226 | 226 | } else { |
227 | 227 | return FALSE; |
228 | 228 | } |
@@ -238,20 +238,20 @@ discard block |
||
238 | 238 | * @param array $where_cols_n_values |
239 | 239 | * @return bool|mixed |
240 | 240 | */ |
241 | - public function find_existing_attendee( $where_cols_n_values = NULL ) { |
|
241 | + public function find_existing_attendee($where_cols_n_values = NULL) { |
|
242 | 242 | // search by combo of first and last names plus the email address |
243 | - $attendee_data_keys = array( 'ATT_fname' => $this->_ATT_fname, 'ATT_lname' => $this->_ATT_lname, 'ATT_email' => $this->_ATT_email ); |
|
243 | + $attendee_data_keys = array('ATT_fname' => $this->_ATT_fname, 'ATT_lname' => $this->_ATT_lname, 'ATT_email' => $this->_ATT_email); |
|
244 | 244 | // no search params means attendee object already exists. |
245 | - $where_cols_n_values = is_array( $where_cols_n_values ) && ! empty( $where_cols_n_values ) ? $where_cols_n_values : $attendee_data_keys; |
|
245 | + $where_cols_n_values = is_array($where_cols_n_values) && ! empty($where_cols_n_values) ? $where_cols_n_values : $attendee_data_keys; |
|
246 | 246 | $valid_data = TRUE; |
247 | 247 | // check for required values |
248 | - $valid_data = isset( $where_cols_n_values['ATT_fname'] ) && ! empty( $where_cols_n_values['ATT_fname'] ) ? $valid_data : FALSE; |
|
249 | - $valid_data = isset( $where_cols_n_values['ATT_lname'] ) && ! empty( $where_cols_n_values['ATT_lname'] ) ? $valid_data : FALSE; |
|
250 | - $valid_data = isset( $where_cols_n_values['ATT_email'] ) && ! empty( $where_cols_n_values['ATT_email'] ) ? $valid_data : FALSE; |
|
248 | + $valid_data = isset($where_cols_n_values['ATT_fname']) && ! empty($where_cols_n_values['ATT_fname']) ? $valid_data : FALSE; |
|
249 | + $valid_data = isset($where_cols_n_values['ATT_lname']) && ! empty($where_cols_n_values['ATT_lname']) ? $valid_data : FALSE; |
|
250 | + $valid_data = isset($where_cols_n_values['ATT_email']) && ! empty($where_cols_n_values['ATT_email']) ? $valid_data : FALSE; |
|
251 | 251 | |
252 | - if ( $valid_data ) { |
|
253 | - $attendee = $this->get_attendee( $where_cols_n_values ); |
|
254 | - if ( $attendee instanceof EE_Attendee ) { |
|
252 | + if ($valid_data) { |
|
253 | + $attendee = $this->get_attendee($where_cols_n_values); |
|
254 | + if ($attendee instanceof EE_Attendee) { |
|
255 | 255 | return $attendee; |
256 | 256 | } |
257 | 257 | } |
@@ -269,12 +269,12 @@ discard block |
||
269 | 269 | * @param array $ids array of EE_Registration ids |
270 | 270 | * @return EE_Attendee[] |
271 | 271 | */ |
272 | - public function get_array_of_contacts_from_reg_ids( $ids ) { |
|
272 | + public function get_array_of_contacts_from_reg_ids($ids) { |
|
273 | 273 | $ids = (array) $ids; |
274 | 274 | $_where = array( |
275 | - 'Registration.REG_ID' => array( 'in', $ids ) |
|
275 | + 'Registration.REG_ID' => array('in', $ids) |
|
276 | 276 | ); |
277 | - return $this->get_all( array( $_where ) ); |
|
277 | + return $this->get_all(array($_where)); |
|
278 | 278 | } |
279 | 279 | |
280 | 280 |
@@ -257,7 +257,7 @@ |
||
257 | 257 | * @param int $TXN_ID |
258 | 258 | * @param int $ATT_ID |
259 | 259 | * @param int $att_nmbr in case the ATT_ID is the same for multiple registrations (same details used) then the attendee number is required |
260 | - * @return mixed array on success, FALSE on fail |
|
260 | + * @return EE_Base_Class|null array on success, FALSE on fail |
|
261 | 261 | */ |
262 | 262 | public function get_registration_for_transaction_attendee( $TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0 ) { |
263 | 263 | return $this->get_one(array( |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2 | -require_once ( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' ); |
|
3 | -require_once ( EE_CLASSES . 'EE_Registration.class.php' ); |
|
2 | +require_once (EE_MODELS.'EEM_Soft_Delete_Base.model.php'); |
|
3 | +require_once (EE_CLASSES.'EE_Registration.class.php'); |
|
4 | 4 | /** |
5 | 5 | * |
6 | 6 | * Registration Model |
@@ -92,31 +92,31 @@ discard block |
||
92 | 92 | * Note this just sends the timezone info to the date time model field objects. Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option) |
93 | 93 | * @return \EEM_Registration |
94 | 94 | */ |
95 | - protected function __construct( $timezone ) { |
|
96 | - $this->singular_item = __('Registration','event_espresso'); |
|
97 | - $this->plural_item = __('Registrations','event_espresso'); |
|
95 | + protected function __construct($timezone) { |
|
96 | + $this->singular_item = __('Registration', 'event_espresso'); |
|
97 | + $this->plural_item = __('Registrations', 'event_espresso'); |
|
98 | 98 | |
99 | 99 | $this->_tables = array( |
100 | - 'Registration'=>new EE_Primary_Table('esp_registration','REG_ID') |
|
100 | + 'Registration'=>new EE_Primary_Table('esp_registration', 'REG_ID') |
|
101 | 101 | ); |
102 | 102 | $this->_fields = array( |
103 | 103 | 'Registration'=>array( |
104 | - 'REG_ID'=>new EE_Primary_Key_Int_Field('REG_ID', __('Registration ID','event_espresso')), |
|
105 | - 'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID','event_espresso'), false, 0, 'Event'), |
|
106 | - 'ATT_ID'=>new EE_Foreign_Key_Int_Field('ATT_ID', __('Attendee ID','event_espresso'), false, 0, 'Attendee'), |
|
107 | - 'TXN_ID'=>new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID','event_espresso'), false, 0, 'Transaction'), |
|
108 | - 'TKT_ID'=>new EE_Foreign_Key_Int_Field('TKT_ID', __('Ticket ID','event_espresso'), false, 0, 'Ticket'), |
|
109 | - 'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID','event_espresso'), false, EEM_Registration::status_id_incomplete, 'Status'), |
|
110 | - 'REG_date'=>new EE_Datetime_Field('REG_date', __('Time registration occurred','event_espresso'), false, time(), $timezone ), |
|
111 | - 'REG_final_price'=>new EE_Money_Field('REG_final_price', __('Registration\'s share of the transaction total','event_espresso'), false, 0), |
|
112 | - 'REG_paid'=>new EE_Money_Field('REG_paid', __('Amount paid to date towards registration','event_espresso'), false, 0), |
|
113 | - 'REG_session'=>new EE_Plain_Text_Field('REG_session', __('Session ID of registration','event_espresso'), false, ''), |
|
114 | - 'REG_code'=>new EE_Plain_Text_Field('REG_code', __('Unique Code for this registration','event_espresso'), false, ''), |
|
115 | - 'REG_url_link'=>new EE_Plain_Text_Field('REG_url_link', __('String to be used in URL for identifying registration','event_espresso'), false, ''), |
|
116 | - 'REG_count'=>new EE_Integer_Field('REG_count', __('Count of this registration in the group registration ','event_espresso'), true, 1), |
|
117 | - 'REG_group_size'=>new EE_Integer_Field('REG_group_size', __('Number of registrations on this group','event_espresso'), false, 1), |
|
118 | - 'REG_att_is_going'=>new EE_Boolean_Field('REG_att_is_going', __('Flag indicating the registrant plans on attending','event_espresso'), false, false), |
|
119 | - 'REG_deleted' => new EE_Trashed_Flag_Field('REG_deleted', __('Flag indicating if registration has been archived or not.', 'event_espresso'), false, false ) |
|
104 | + 'REG_ID'=>new EE_Primary_Key_Int_Field('REG_ID', __('Registration ID', 'event_espresso')), |
|
105 | + 'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID', 'event_espresso'), false, 0, 'Event'), |
|
106 | + 'ATT_ID'=>new EE_Foreign_Key_Int_Field('ATT_ID', __('Attendee ID', 'event_espresso'), false, 0, 'Attendee'), |
|
107 | + 'TXN_ID'=>new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso'), false, 0, 'Transaction'), |
|
108 | + 'TKT_ID'=>new EE_Foreign_Key_Int_Field('TKT_ID', __('Ticket ID', 'event_espresso'), false, 0, 'Ticket'), |
|
109 | + 'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'), false, EEM_Registration::status_id_incomplete, 'Status'), |
|
110 | + 'REG_date'=>new EE_Datetime_Field('REG_date', __('Time registration occurred', 'event_espresso'), false, time(), $timezone), |
|
111 | + 'REG_final_price'=>new EE_Money_Field('REG_final_price', __('Registration\'s share of the transaction total', 'event_espresso'), false, 0), |
|
112 | + 'REG_paid'=>new EE_Money_Field('REG_paid', __('Amount paid to date towards registration', 'event_espresso'), false, 0), |
|
113 | + 'REG_session'=>new EE_Plain_Text_Field('REG_session', __('Session ID of registration', 'event_espresso'), false, ''), |
|
114 | + 'REG_code'=>new EE_Plain_Text_Field('REG_code', __('Unique Code for this registration', 'event_espresso'), false, ''), |
|
115 | + 'REG_url_link'=>new EE_Plain_Text_Field('REG_url_link', __('String to be used in URL for identifying registration', 'event_espresso'), false, ''), |
|
116 | + 'REG_count'=>new EE_Integer_Field('REG_count', __('Count of this registration in the group registration ', 'event_espresso'), true, 1), |
|
117 | + 'REG_group_size'=>new EE_Integer_Field('REG_group_size', __('Number of registrations on this group', 'event_espresso'), false, 1), |
|
118 | + 'REG_att_is_going'=>new EE_Boolean_Field('REG_att_is_going', __('Flag indicating the registrant plans on attending', 'event_espresso'), false, false), |
|
119 | + 'REG_deleted' => new EE_Trashed_Flag_Field('REG_deleted', __('Flag indicating if registration has been archived or not.', 'event_espresso'), false, false) |
|
120 | 120 | ) |
121 | 121 | ); |
122 | 122 | $this->_model_relations = array( |
@@ -128,11 +128,11 @@ discard block |
||
128 | 128 | 'Answer'=>new EE_Has_Many_Relation(), |
129 | 129 | 'Checkin'=>new EE_Has_Many_Relation(), |
130 | 130 | 'Registration_Payment' => new EE_Has_Many_Relation(), |
131 | - 'Payment'=>new EE_HABTM_Relation( 'Registration_Payment' ), |
|
131 | + 'Payment'=>new EE_HABTM_Relation('Registration_Payment'), |
|
132 | 132 | ); |
133 | 133 | $this->_model_chain_to_wp_user = 'Event'; |
134 | 134 | |
135 | - parent::__construct( $timezone ); |
|
135 | + parent::__construct($timezone); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | |
@@ -165,9 +165,9 @@ discard block |
||
165 | 165 | * @param bool $translated If true will return the values as singular localized strings |
166 | 166 | * @return array |
167 | 167 | */ |
168 | - public static function reg_status_array( $exclude = array(), $translated = FALSE ) { |
|
169 | - EEM_Registration::instance()->_get_registration_status_array( $exclude ); |
|
170 | - return $translated ? EEM_Status::instance()->localized_status( self::$_reg_status, FALSE, 'sentence') : self::$_reg_status; |
|
168 | + public static function reg_status_array($exclude = array(), $translated = FALSE) { |
|
169 | + EEM_Registration::instance()->_get_registration_status_array($exclude); |
|
170 | + return $translated ? EEM_Status::instance()->localized_status(self::$_reg_status, FALSE, 'sentence') : self::$_reg_status; |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | |
@@ -178,19 +178,19 @@ discard block |
||
178 | 178 | * @param array $exclude |
179 | 179 | * @return array |
180 | 180 | */ |
181 | - private function _get_registration_status_array( $exclude = array() ) { |
|
181 | + private function _get_registration_status_array($exclude = array()) { |
|
182 | 182 | //in the very rare circumstance that we are deleting a model's table's data |
183 | 183 | //and the table hasn't actually been created, this could have an error |
184 | 184 | /** @type WPDB $wpdb */ |
185 | 185 | global $wpdb; |
186 | - EE_Registry::instance()->load_helper( 'Activation' ); |
|
187 | - if( EEH_Activation::table_exists( $wpdb->prefix . 'esp_status' ) ){ |
|
188 | - $SQL = 'SELECT STS_ID, STS_code FROM '. $wpdb->prefix . 'esp_status WHERE STS_type = "registration"'; |
|
189 | - $results = $wpdb->get_results( $SQL ); |
|
186 | + EE_Registry::instance()->load_helper('Activation'); |
|
187 | + if (EEH_Activation::table_exists($wpdb->prefix.'esp_status')) { |
|
188 | + $SQL = 'SELECT STS_ID, STS_code FROM '.$wpdb->prefix.'esp_status WHERE STS_type = "registration"'; |
|
189 | + $results = $wpdb->get_results($SQL); |
|
190 | 190 | self::$_reg_status = array(); |
191 | - foreach ( $results as $status ) { |
|
192 | - if ( ! in_array( $status->STS_ID, $exclude )) { |
|
193 | - self::$_reg_status[ $status->STS_ID ] = $status->STS_code; |
|
191 | + foreach ($results as $status) { |
|
192 | + if ( ! in_array($status->STS_ID, $exclude)) { |
|
193 | + self::$_reg_status[$status->STS_ID] = $status->STS_code; |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 | } |
@@ -205,15 +205,15 @@ discard block |
||
205 | 205 | * @param array $where_params Array of query_params as described in the comments for EEM_Base::get_all() |
206 | 206 | * @return wpdb results array |
207 | 207 | */ |
208 | - public function get_reg_months_and_years( $where_params ) { |
|
208 | + public function get_reg_months_and_years($where_params) { |
|
209 | 209 | $query_params[0] = $where_params; |
210 | 210 | $query_params['group_by'] = array('reg_year', 'reg_month'); |
211 | - $query_params['order_by'] = array( 'REG_date' => 'DESC' ); |
|
211 | + $query_params['order_by'] = array('REG_date' => 'DESC'); |
|
212 | 212 | $columns_to_select = array( |
213 | 213 | 'reg_year' => array('YEAR(REG_date)', '%s'), |
214 | 214 | 'reg_month' => array('MONTHNAME(REG_date)', '%s') |
215 | 215 | ); |
216 | - return $this->_get_all_wpdb_results( $query_params, OBJECT, $columns_to_select ); |
|
216 | + return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | |
@@ -225,11 +225,11 @@ discard block |
||
225 | 225 | * @param int $ATT_ID |
226 | 226 | * @return EE_Registration[] |
227 | 227 | */ |
228 | - public function get_all_registrations_for_attendee( $ATT_ID = 0 ) { |
|
229 | - if ( ! $ATT_ID ) { |
|
228 | + public function get_all_registrations_for_attendee($ATT_ID = 0) { |
|
229 | + if ( ! $ATT_ID) { |
|
230 | 230 | return FALSE; |
231 | 231 | } |
232 | - return $this->get_all( array( array( 'ATT_ID' => $ATT_ID ))); |
|
232 | + return $this->get_all(array(array('ATT_ID' => $ATT_ID))); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | |
@@ -240,8 +240,8 @@ discard block |
||
240 | 240 | * @param string $REG_url_link |
241 | 241 | * @return EE_Registration |
242 | 242 | */ |
243 | - public function get_registration_for_reg_url_link($REG_url_link){ |
|
244 | - if(!$REG_url_link){ |
|
243 | + public function get_registration_for_reg_url_link($REG_url_link) { |
|
244 | + if ( ! $REG_url_link) { |
|
245 | 245 | return false; |
246 | 246 | } |
247 | 247 | return $this->get_one(array(array('REG_url_link'=>$REG_url_link))); |
@@ -259,13 +259,13 @@ discard block |
||
259 | 259 | * @param int $att_nmbr in case the ATT_ID is the same for multiple registrations (same details used) then the attendee number is required |
260 | 260 | * @return mixed array on success, FALSE on fail |
261 | 261 | */ |
262 | - public function get_registration_for_transaction_attendee( $TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0 ) { |
|
262 | + public function get_registration_for_transaction_attendee($TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0) { |
|
263 | 263 | return $this->get_one(array( |
264 | 264 | array( |
265 | 265 | 'TXN_ID'=>$TXN_ID, |
266 | 266 | 'ATT_ID'=>$ATT_ID |
267 | 267 | ), |
268 | - 'limit'=>array( min( ( $att_nmbr-1 ), 0 ), 1 ) |
|
268 | + 'limit'=>array(min(($att_nmbr - 1), 0), 1) |
|
269 | 269 | )); |
270 | 270 | } |
271 | 271 | |
@@ -277,19 +277,19 @@ discard block |
||
277 | 277 | * @param $period string which can be passed to php's strtotime function (eg "-1 month") |
278 | 278 | * @return stdClass[] with properties regDate and total |
279 | 279 | */ |
280 | - public function get_registrations_per_day_report( $period = '-1 month' ) { |
|
280 | + public function get_registrations_per_day_report($period = '-1 month') { |
|
281 | 281 | |
282 | - $sql_date = $this->convert_datetime_for_query( 'REG_date', date("Y-m-d H:i:s", strtotime($period) ), 'Y-m-d H:i:s', 'UTC' ); |
|
283 | - $where = array( 'REG_date' => array( '>=', $sql_date ), 'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete ) ); |
|
282 | + $sql_date = $this->convert_datetime_for_query('REG_date', date("Y-m-d H:i:s", strtotime($period)), 'Y-m-d H:i:s', 'UTC'); |
|
283 | + $where = array('REG_date' => array('>=', $sql_date), 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete)); |
|
284 | 284 | |
285 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_registrations', 'reg_per_day_report' ) ) { |
|
285 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_day_report')) { |
|
286 | 286 | $where['Event.EVT_wp_user'] = get_current_user_id(); |
287 | 287 | } |
288 | 288 | |
289 | - $offset = get_option( 'gmt_offset' ); |
|
289 | + $offset = get_option('gmt_offset'); |
|
290 | 290 | $query_interval = $offset < 0 |
291 | - ? 'DATE_SUB(REG_date, INTERVAL ' . $offset*-1 . ' HOUR)' |
|
292 | - : 'DATE_ADD(REG_date, INTERVAL ' . $offset . ' HOUR)'; |
|
291 | + ? 'DATE_SUB(REG_date, INTERVAL '.$offset * -1.' HOUR)' |
|
292 | + : 'DATE_ADD(REG_date, INTERVAL '.$offset.' HOUR)'; |
|
293 | 293 | |
294 | 294 | $results = $this->_get_all_wpdb_results( |
295 | 295 | array( |
@@ -299,8 +299,8 @@ discard block |
||
299 | 299 | ), |
300 | 300 | OBJECT, |
301 | 301 | array( |
302 | - 'regDate'=>array( 'DATE(' . $query_interval . ')','%s'), |
|
303 | - 'total'=>array('count(REG_ID)','%d') |
|
302 | + 'regDate'=>array('DATE('.$query_interval.')', '%s'), |
|
303 | + 'total'=>array('count(REG_ID)', '%d') |
|
304 | 304 | )); |
305 | 305 | return $results; |
306 | 306 | } |
@@ -315,23 +315,23 @@ discard block |
||
315 | 315 | * @param $period string which can be passed to php's strtotime function (eg "-1 month") |
316 | 316 | * @return stdClass[] each with properties event_name, reg_limit, and total |
317 | 317 | */ |
318 | - public function get_registrations_per_event_report( $period = '-1 month' ) { |
|
318 | + public function get_registrations_per_event_report($period = '-1 month') { |
|
319 | 319 | |
320 | - $date_sql = $this->convert_datetime_for_query( 'REG_date', date( "Y-m-d H:i:s", strtotime( $period )), 'Y-m-d H:i:s', 'UTC' ); |
|
321 | - $where = array( 'REG_date' => array( '>=', $date_sql ), 'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete ) ); |
|
320 | + $date_sql = $this->convert_datetime_for_query('REG_date', date("Y-m-d H:i:s", strtotime($period)), 'Y-m-d H:i:s', 'UTC'); |
|
321 | + $where = array('REG_date' => array('>=', $date_sql), 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete)); |
|
322 | 322 | |
323 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_registrations', 'reg_per_event_report' ) ) { |
|
323 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
324 | 324 | $where['Event.EVT_wp_user'] = get_current_user_id(); |
325 | 325 | } |
326 | 326 | $results = $this->_get_all_wpdb_results(array( |
327 | 327 | $where, |
328 | 328 | 'group_by'=>'Event.EVT_name', |
329 | 329 | 'order_by'=>'Event.EVT_name', |
330 | - 'limit'=>array(0,24)), |
|
330 | + 'limit'=>array(0, 24)), |
|
331 | 331 | OBJECT, |
332 | 332 | array( |
333 | - 'event_name'=>array('Event_CPT.post_title','%s'), |
|
334 | - 'total'=>array('COUNT(REG_ID)','%s') |
|
333 | + 'event_name'=>array('Event_CPT.post_title', '%s'), |
|
334 | + 'total'=>array('COUNT(REG_ID)', '%s') |
|
335 | 335 | ) |
336 | 336 | ); |
337 | 337 | |
@@ -345,11 +345,11 @@ discard block |
||
345 | 345 | * @param int $TXN_ID |
346 | 346 | * @return EE_Registration |
347 | 347 | */ |
348 | - public function get_primary_registration_for_transaction_ID( $TXN_ID = 0){ |
|
349 | - if( ! $TXN_ID ){ |
|
348 | + public function get_primary_registration_for_transaction_ID($TXN_ID = 0) { |
|
349 | + if ( ! $TXN_ID) { |
|
350 | 350 | return false; |
351 | 351 | } |
352 | - return $this->get_one(array(array('TXN_ID'=>$TXN_ID,'REG_count'=> EEM_Registration::PRIMARY_REGISTRANT_COUNT))); |
|
352 | + return $this->get_one(array(array('TXN_ID'=>$TXN_ID, 'REG_count'=> EEM_Registration::PRIMARY_REGISTRANT_COUNT))); |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | |
@@ -361,11 +361,11 @@ discard block |
||
361 | 361 | * @param boolean $for_incomplete_payments |
362 | 362 | * @return int |
363 | 363 | */ |
364 | - public function get_event_registration_count ( $EVT_ID, $for_incomplete_payments = FALSE ) { |
|
364 | + public function get_event_registration_count($EVT_ID, $for_incomplete_payments = FALSE) { |
|
365 | 365 | // we only count approved registrations towards registration limits |
366 | - $query_params = array( array( 'EVT_ID' => $EVT_ID, 'STS_ID' => self::status_id_approved ) ); |
|
367 | - if( $for_incomplete_payments ){ |
|
368 | - $query_params[0]['Transaction.STS_ID']=array('!=', EEM_Transaction::complete_status_code); |
|
366 | + $query_params = array(array('EVT_ID' => $EVT_ID, 'STS_ID' => self::status_id_approved)); |
|
367 | + if ($for_incomplete_payments) { |
|
368 | + $query_params[0]['Transaction.STS_ID'] = array('!=', EEM_Transaction::complete_status_code); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | return $this->count($query_params); |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | /** @type WPDB $wpdb */ |
382 | 382 | global $wpdb; |
383 | 383 | return $wpdb->query( |
384 | - 'DELETE r FROM ' . $this->table() . ' r LEFT JOIN ' . EEM_Transaction::instance()->table() . ' t ON r.TXN_ID = t.TXN_ID WHERE t.TXN_ID IS NULL' ); |
|
384 | + 'DELETE r FROM '.$this->table().' r LEFT JOIN '.EEM_Transaction::instance()->table().' t ON r.TXN_ID = t.TXN_ID WHERE t.TXN_ID IS NULL' ); |
|
385 | 385 | } |
386 | 386 | |
387 | 387 |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | * Sum all the deleted items. |
147 | 147 | * @param array $query_params like EEM_Base::get_all |
148 | 148 | * @param string $field_to_sum |
149 | - * @return int |
|
149 | + * @return double |
|
150 | 150 | */ |
151 | 151 | public function sum_deleted($query_params = null, $field_to_sum = null){ |
152 | 152 | $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | * @param boolean $allow_blocking if TRUE, matched objects will only be deleted if there is no related model info |
196 | 196 | * that blocks it (ie, there' sno other data that depends on this data); if false, deletes regardless of other objects |
197 | 197 | * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB |
198 | - * @return boolean success |
|
198 | + * @return integer success |
|
199 | 199 | */ |
200 | 200 | public function delete_permanently($query_params = array(), $allow_blocking = true){ |
201 | 201 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | /** |
279 | 279 | * Updates all the items of this model which match the $query params, regardless of whether |
280 | 280 | * they've been soft-deleted or not |
281 | - * @param array $field_n_values like EEM_Base::update's $fields_n_value |
|
281 | + * @param array $fields_n_values like EEM_Base::update's $fields_n_value |
|
282 | 282 | * @param array $query_params like EEM_base::get_all's $query_params |
283 | 283 | * @param boolean $keep_model_objs_in_sync if TRUE, makes sure we ALSO update model objects |
284 | 284 | * in this model's entity map according to $fields_n_values that match $query_params. This |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2 | -require_once( EE_MODELS . 'EEM_Base.model.php'); |
|
2 | +require_once(EE_MODELS.'EEM_Base.model.php'); |
|
3 | 3 | /** |
4 | 4 | * EEM_Soft_Delete_Base |
5 | 5 | * |
@@ -25,13 +25,13 @@ discard block |
||
25 | 25 | * @subpackage includes/models/ |
26 | 26 | * @author Michael Nelson |
27 | 27 | */ |
28 | -abstract class EEM_Soft_Delete_Base extends EEM_Base{ |
|
28 | +abstract class EEM_Soft_Delete_Base extends EEM_Base { |
|
29 | 29 | |
30 | 30 | /** |
31 | 31 | * @param null $timezone |
32 | 32 | */ |
33 | 33 | protected function __construct($timezone = NULL) { |
34 | - if( ! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions ){ |
|
34 | + if ( ! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions) { |
|
35 | 35 | $this->_default_where_conditions_strategy = new EE_Soft_Delete_Where_Conditions(); |
36 | 36 | } |
37 | 37 | parent::__construct($timezone); |
@@ -42,12 +42,12 @@ discard block |
||
42 | 42 | * @return string |
43 | 43 | * @throws EE_Error |
44 | 44 | */ |
45 | - public function deleted_field_name(){ |
|
45 | + public function deleted_field_name() { |
|
46 | 46 | $field = $this->get_a_field_of_type('EE_Trashed_Flag_Field'); |
47 | - if($field){ |
|
47 | + if ($field) { |
|
48 | 48 | return $field->get_name(); |
49 | - }else{ |
|
50 | - throw new EE_Error(sprintf(__('We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?','event_espresso'),get_class($this),get_class($this))); |
|
49 | + } else { |
|
50 | + throw new EE_Error(sprintf(__('We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?', 'event_espresso'), get_class($this), get_class($this))); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @param array $query_params like EEM_Base::get_all's $query_params |
58 | 58 | * @return EE_Soft_Delete_Base_Class |
59 | 59 | */ |
60 | - public function get_one_deleted($query_params = array()){ |
|
60 | + public function get_one_deleted($query_params = array()) { |
|
61 | 61 | $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
62 | 62 | return parent::get_one($query_params); |
63 | 63 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @param array $query_params like EEM_base::get_all's $query_params |
68 | 68 | * @return EE_Soft_Delete_Base_Class |
69 | 69 | */ |
70 | - public function get_one_deleted_or_undeleted($query_params = array()){ |
|
70 | + public function get_one_deleted_or_undeleted($query_params = array()) { |
|
71 | 71 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
72 | 72 | return parent::get_one($query_params); |
73 | 73 | } |
@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | * @param int|string $id |
78 | 78 | * @return EE_Soft_Delete_Base_Class |
79 | 79 | */ |
80 | - public function get_one_by_ID_but_ignore_deleted($id){ |
|
80 | + public function get_one_by_ID_but_ignore_deleted($id) { |
|
81 | 81 | return $this->get_one( |
82 | 82 | $this->alter_query_params_to_restrict_by_ID( |
83 | 83 | $id, |
84 | - array( 'default_where_conditions' => 'default' ) |
|
84 | + array('default_where_conditions' => 'default') |
|
85 | 85 | ) |
86 | 86 | ); |
87 | 87 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @param bool $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE; |
94 | 94 | * @return int |
95 | 95 | */ |
96 | - public function count_deleted($query_params = null, $field_to_count = null, $distinct = FALSE){ |
|
96 | + public function count_deleted($query_params = null, $field_to_count = null, $distinct = FALSE) { |
|
97 | 97 | $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
98 | 98 | return parent::count($query_params, $field_to_count, $distinct); |
99 | 99 | } |
@@ -103,9 +103,9 @@ discard block |
||
103 | 103 | * @param array $query_params like EEM_Base::get_all's $query_params |
104 | 104 | * @return array like EEM_Base::get_all's $query_params |
105 | 105 | */ |
106 | - protected function _alter_query_params_so_only_trashed_items_included($query_params){ |
|
107 | - $deletedFlagFieldName=$this->deleted_field_name(); |
|
108 | - $query_params[0][$deletedFlagFieldName]=true; |
|
106 | + protected function _alter_query_params_so_only_trashed_items_included($query_params) { |
|
107 | + $deletedFlagFieldName = $this->deleted_field_name(); |
|
108 | + $query_params[0][$deletedFlagFieldName] = true; |
|
109 | 109 | return $query_params; |
110 | 110 | } |
111 | 111 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * @param array $query_params |
115 | 115 | * @return array |
116 | 116 | */ |
117 | - public function alter_query_params_so_deleted_and_undeleted_items_included( $query_params = array() ){ |
|
117 | + public function alter_query_params_so_deleted_and_undeleted_items_included($query_params = array()) { |
|
118 | 118 | return $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
119 | 119 | } |
120 | 120 | |
@@ -123,8 +123,8 @@ discard block |
||
123 | 123 | * @param array $query_params |
124 | 124 | * @return array |
125 | 125 | */ |
126 | - protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params){ |
|
127 | - if( ! isset( $query_params[ 'default_where_conditions' ] ) ) { |
|
126 | + protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params) { |
|
127 | + if ( ! isset($query_params['default_where_conditions'])) { |
|
128 | 128 | $query_params['default_where_conditions'] = 'minimum'; |
129 | 129 | } |
130 | 130 | return $query_params; |
@@ -137,9 +137,9 @@ discard block |
||
137 | 137 | * @param bool $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE; |
138 | 138 | * @return int |
139 | 139 | */ |
140 | - public function count_deleted_and_undeleted($query_params = null, $field_to_count = null, $distinct = FALSE){ |
|
140 | + public function count_deleted_and_undeleted($query_params = null, $field_to_count = null, $distinct = FALSE) { |
|
141 | 141 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
142 | - return parent::count($query_params,$field_to_count, $distinct); |
|
142 | + return parent::count($query_params, $field_to_count, $distinct); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * @param string $field_to_sum |
149 | 149 | * @return int |
150 | 150 | */ |
151 | - public function sum_deleted($query_params = null, $field_to_sum = null){ |
|
151 | + public function sum_deleted($query_params = null, $field_to_sum = null) { |
|
152 | 152 | $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
153 | 153 | return parent::sum($query_params, $field_to_sum); |
154 | 154 | } |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | * @param string $field_to_sum |
160 | 160 | * @reutrn int |
161 | 161 | */ |
162 | - public function sum_deleted_and_undeleted($query_params = null, $field_to_sum = null){ |
|
162 | + public function sum_deleted_and_undeleted($query_params = null, $field_to_sum = null) { |
|
163 | 163 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
164 | 164 | parent::sum($query_params, $field_to_sum); |
165 | 165 | } |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | * @param array $query_params like EEM_Base::get_all |
170 | 170 | * @return EE_Soft_Delete_Base_Class[] |
171 | 171 | */ |
172 | - public function get_all_deleted_and_undeleted($query_params = array()){ |
|
172 | + public function get_all_deleted_and_undeleted($query_params = array()) { |
|
173 | 173 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
174 | 174 | return parent::get_all($query_params); |
175 | 175 | } |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | * @param array $query_params like EEM_Base::get_all |
180 | 180 | * @return EE_Soft_Delete_Base_Class[] |
181 | 181 | */ |
182 | - public function get_all_deleted($query_params = array()){ |
|
182 | + public function get_all_deleted($query_params = array()) { |
|
183 | 183 | $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
184 | 184 | return parent::get_all($query_params); |
185 | 185 | } |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB |
198 | 198 | * @return boolean success |
199 | 199 | */ |
200 | - public function delete_permanently($query_params = array(), $allow_blocking = true){ |
|
200 | + public function delete_permanently($query_params = array(), $allow_blocking = true) { |
|
201 | 201 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
202 | 202 | return parent::delete_permanently($query_params, $allow_blocking); |
203 | 203 | } |
@@ -208,8 +208,8 @@ discard block |
||
208 | 208 | * @param mixed $ID int if primary key is an int, string otherwise |
209 | 209 | * @return boolean success |
210 | 210 | */ |
211 | - public function restore_by_ID($ID=FALSE){ |
|
212 | - return $this->delete_or_restore_by_ID(false,$ID); |
|
211 | + public function restore_by_ID($ID = FALSE) { |
|
212 | + return $this->delete_or_restore_by_ID(false, $ID); |
|
213 | 213 | } |
214 | 214 | /** |
215 | 215 | * For deleting or restoring a particular item. Note that this model is a SOFT-DELETABLE model! However, |
@@ -218,14 +218,14 @@ discard block |
||
218 | 218 | * @param mixed $ID int if primary key is an int, string otherwise |
219 | 219 | * @return boolean |
220 | 220 | */ |
221 | - public function delete_or_restore_by_ID($delete=true,$ID=FALSE){ |
|
222 | - if ( ! $ID ) { |
|
221 | + public function delete_or_restore_by_ID($delete = true, $ID = FALSE) { |
|
222 | + if ( ! $ID) { |
|
223 | 223 | return FALSE; |
224 | 224 | } |
225 | 225 | if ( |
226 | 226 | $this->delete_or_restore( |
227 | 227 | $delete, |
228 | - $this->alter_query_params_to_restrict_by_ID( $ID ) |
|
228 | + $this->alter_query_params_to_restrict_by_ID($ID) |
|
229 | 229 | ) |
230 | 230 | ) { |
231 | 231 | return TRUE; |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | * @param bool $block_deletes |
246 | 246 | * @return boolean |
247 | 247 | */ |
248 | - public function delete($query_params = array(), $block_deletes = false){ |
|
248 | + public function delete($query_params = array(), $block_deletes = false) { |
|
249 | 249 | //no matter what, we WON'T block soft deletes. |
250 | 250 | return $this->delete_or_restore(true, $query_params); |
251 | 251 | } |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | * @param array $query_params like EEM_Base::get_all |
257 | 257 | * @return boolean |
258 | 258 | */ |
259 | - public function restore($query_params = array()){ |
|
259 | + public function restore($query_params = array()) { |
|
260 | 260 | return $this->delete_or_restore(false, $query_params); |
261 | 261 | } |
262 | 262 | /** |
@@ -265,10 +265,10 @@ discard block |
||
265 | 265 | * @param array $query_params like EEM_Base::get_all |
266 | 266 | * @return boolean |
267 | 267 | */ |
268 | - function delete_or_restore($delete=true,$query_params = array()){ |
|
269 | - $deletedFlagFieldName=$this->deleted_field_name(); |
|
268 | + function delete_or_restore($delete = true, $query_params = array()) { |
|
269 | + $deletedFlagFieldName = $this->deleted_field_name(); |
|
270 | 270 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
271 | - if ( $this->update (array($deletedFlagFieldName=>$delete), $query_params )) { |
|
271 | + if ($this->update(array($deletedFlagFieldName=>$delete), $query_params)) { |
|
272 | 272 | return TRUE; |
273 | 273 | } else { |
274 | 274 | return FALSE; |
@@ -286,8 +286,8 @@ discard block |
||
286 | 286 | * be aware that model objects being used could get out-of-sync with the database |
287 | 287 | * @return int number of items updated |
288 | 288 | */ |
289 | - public function update_deleted_and_undeleted($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE ){ |
|
289 | + public function update_deleted_and_undeleted($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE) { |
|
290 | 290 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
291 | - return $this->update($fields_n_values, $query_params, $keep_model_objs_in_sync ); |
|
291 | + return $this->update($fields_n_values, $query_params, $keep_model_objs_in_sync); |
|
292 | 292 | } |
293 | 293 | } |
@@ -7,6 +7,10 @@ discard block |
||
7 | 7 | |
8 | 8 | protected $_post_type; |
9 | 9 | protected $_meta_field; |
10 | + |
|
11 | + /** |
|
12 | + * @param string $post_type |
|
13 | + */ |
|
10 | 14 | function __construct($post_type, $meta_field_to_chk = ''){ |
11 | 15 | $this->_post_type = $post_type; |
12 | 16 | $this->_meta_field = $meta_field_to_chk; |
@@ -27,7 +31,6 @@ discard block |
||
27 | 31 | } |
28 | 32 | /** |
29 | 33 | * Gets the where default where conditions for a custom post type model |
30 | - * @param string $model_relation_path. Eg, from Event to Payment, this should be "Registration.Transaction.Payment" |
|
31 | 34 | * @return array like EEM_Base::get_all's $query_params's index [0] (where conditions) |
32 | 35 | */ |
33 | 36 | protected function _get_default_where_conditions() { |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | /** |
6 | 6 | * |
@@ -15,11 +15,11 @@ discard block |
||
15 | 15 | * @since 4.8.29.rc.010 |
16 | 16 | * |
17 | 17 | */ |
18 | -class EE_CPT_Minimum_Where_Conditions extends EE_Default_Where_Conditions{ |
|
18 | +class EE_CPT_Minimum_Where_Conditions extends EE_Default_Where_Conditions { |
|
19 | 19 | |
20 | 20 | protected $_post_type; |
21 | 21 | protected $_meta_field; |
22 | - function __construct($post_type, $meta_field_to_chk = ''){ |
|
22 | + function __construct($post_type, $meta_field_to_chk = '') { |
|
23 | 23 | $this->_post_type = $post_type; |
24 | 24 | $this->_meta_field = $meta_field_to_chk; |
25 | 25 | } |
@@ -29,10 +29,10 @@ discard block |
||
29 | 29 | * @param string $column column name |
30 | 30 | * @return EE_Model_Field_Base |
31 | 31 | */ |
32 | - protected function _get_field_on_column($column){ |
|
32 | + protected function _get_field_on_column($column) { |
|
33 | 33 | $all_fields = $this->_model->field_settings(true); |
34 | - foreach($all_fields as $field_name => $field_obj){ |
|
35 | - if($column == $field_obj->get_table_column()){ |
|
34 | + foreach ($all_fields as $field_name => $field_obj) { |
|
35 | + if ($column == $field_obj->get_table_column()) { |
|
36 | 36 | return $field_obj; |
37 | 37 | } |
38 | 38 | } |
@@ -5,7 +5,7 @@ |
||
5 | 5 | /** |
6 | 6 | * |
7 | 7 | * Class EE_CPT_Minimum_Where_Conditions |
8 | - * |
|
8 | + * |
|
9 | 9 | * Strategy specifically for adding where conditions specific to CPT models. |
10 | 10 | * But only sets the minimum, so any row of the right type will get used |
11 | 11 | * |
@@ -17,7 +17,6 @@ |
||
17 | 17 | class EE_CPT_Where_Conditions extends EE_CPT_Minimum_Where_Conditions{ |
18 | 18 | /** |
19 | 19 | * Gets the where default where conditions for a custom post type model |
20 | - * @param string $model_relation_path. Eg, from Event to Payment, this should be "Registration.Transaction.Payment" |
|
21 | 20 | * @return array like EEM_Base::get_all's $query_params's index [0] (where conditions) |
22 | 21 | */ |
23 | 22 | protected function _get_default_where_conditions() { |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | /** |
6 | 6 | * |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | * * @since 4.6.0 |
15 | 15 | * |
16 | 16 | */ |
17 | -class EE_CPT_Where_Conditions extends EE_CPT_Minimum_Where_Conditions{ |
|
17 | +class EE_CPT_Where_Conditions extends EE_CPT_Minimum_Where_Conditions { |
|
18 | 18 | /** |
19 | 19 | * Gets the where default where conditions for a custom post type model |
20 | 20 | * @param string $model_relation_path. Eg, from Event to Payment, this should be "Registration.Transaction.Payment" |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | return array_merge( |
26 | 26 | parent::_get_default_where_conditions(), |
27 | 27 | array( |
28 | - $status_field->get_name() => array('NOT IN',array('auto-draft','trash') ) |
|
28 | + $status_field->get_name() => array('NOT IN', array('auto-draft', 'trash')) |
|
29 | 29 | ) |
30 | 30 | ); |
31 | 31 | } |
@@ -5,7 +5,7 @@ |
||
5 | 5 | /** |
6 | 6 | * |
7 | 7 | * Class EE_Default_Where_Conditions |
8 | - * |
|
8 | + * |
|
9 | 9 | * Strategy specifically for adding where conditions specific to CPT models. |
10 | 10 | * |
11 | 11 | * @package Event Espresso |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -define('EE_Event_Category_Taxonomy','espresso_event_category'); |
|
2 | +define('EE_Event_Category_Taxonomy', 'espresso_event_category'); |
|
3 | 3 | /** |
4 | 4 | * |
5 | 5 | * EEM_CPT_Base |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | * @author Mike Nelson |
17 | 17 | * |
18 | 18 | */ |
19 | -abstract class EEM_CPT_Base extends EEM_Soft_Delete_Base{ |
|
19 | +abstract class EEM_CPT_Base extends EEM_Soft_Delete_Base { |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * @var string post_status_publish - the wp post status for published cpts |
@@ -69,55 +69,55 @@ discard block |
||
69 | 69 | * @param string $timezone |
70 | 70 | * @throws \EE_Error |
71 | 71 | */ |
72 | - protected function __construct( $timezone = NULL ){ |
|
72 | + protected function __construct($timezone = NULL) { |
|
73 | 73 | |
74 | 74 | //adds a relationship to Term_Taxonomy for all these models. For this to work |
75 | 75 | //Term_Relationship must have a relation to each model subclassing EE_CPT_Base explicitly |
76 | 76 | //eg, in EEM_Term_Relationship, inside the _model_relations array, there must be an entry |
77 | 77 | //with key equalling the subclassing model's model name (eg 'Event' or 'Venue'), and the value |
78 | 78 | //must also be new EE_HABTM_Relation('Term_Relationship'); |
79 | - $this->_model_relations['Term_Taxonomy'] =new EE_HABTM_Relation('Term_Relationship'); |
|
79 | + $this->_model_relations['Term_Taxonomy'] = new EE_HABTM_Relation('Term_Relationship'); |
|
80 | 80 | $primary_table_name = NULL; |
81 | 81 | //add the common _status field to all CPT primary tables. |
82 | - foreach ( $this->_tables as $alias => $table_obj ) { |
|
83 | - if ( $table_obj instanceof EE_Primary_Table ) { |
|
82 | + foreach ($this->_tables as $alias => $table_obj) { |
|
83 | + if ($table_obj instanceof EE_Primary_Table) { |
|
84 | 84 | $primary_table_name = $alias; |
85 | 85 | } |
86 | 86 | } |
87 | 87 | //set default wp post statuses if child has not already set. |
88 | - if ( ! isset( $this->_fields[$primary_table_name]['status'] )) { |
|
88 | + if ( ! isset($this->_fields[$primary_table_name]['status'])) { |
|
89 | 89 | $this->_fields[$primary_table_name]['status'] = new EE_WP_Post_Status_Field('post_status', __("Event Status", "event_espresso"), false, 'draft'); |
90 | 90 | } |
91 | - if( ! isset( $this->_fields[$primary_table_name]['to_ping'])){ |
|
92 | - $this->_fields[$primary_table_name]['to_ping'] = new EE_DB_Only_Text_Field('to_ping', __( 'To Ping', 'event_espresso' ), FALSE, ''); |
|
91 | + if ( ! isset($this->_fields[$primary_table_name]['to_ping'])) { |
|
92 | + $this->_fields[$primary_table_name]['to_ping'] = new EE_DB_Only_Text_Field('to_ping', __('To Ping', 'event_espresso'), FALSE, ''); |
|
93 | 93 | } |
94 | - if( ! isset( $this->_fields[$primary_table_name]['pinged'])){ |
|
95 | - $this->_fields[$primary_table_name]['pinged'] = new EE_DB_Only_Text_Field('pinged', __( 'Pinged', 'event_espresso' ), FALSE, ''); |
|
94 | + if ( ! isset($this->_fields[$primary_table_name]['pinged'])) { |
|
95 | + $this->_fields[$primary_table_name]['pinged'] = new EE_DB_Only_Text_Field('pinged', __('Pinged', 'event_espresso'), FALSE, ''); |
|
96 | 96 | } |
97 | 97 | |
98 | - if( ! isset( $this->_fields[$primary_table_name]['comment_status'])){ |
|
99 | - $this->_fields[$primary_table_name]['comment_status'] = new EE_Plain_Text_Field('comment_status', __('Comment Status', 'event_espresso' ), FALSE, 'open'); |
|
98 | + if ( ! isset($this->_fields[$primary_table_name]['comment_status'])) { |
|
99 | + $this->_fields[$primary_table_name]['comment_status'] = new EE_Plain_Text_Field('comment_status', __('Comment Status', 'event_espresso'), FALSE, 'open'); |
|
100 | 100 | } |
101 | 101 | |
102 | - if( ! isset( $this->_fields[$primary_table_name]['ping_status'])){ |
|
102 | + if ( ! isset($this->_fields[$primary_table_name]['ping_status'])) { |
|
103 | 103 | $this->_fields[$primary_table_name]['ping_status'] = new EE_Plain_Text_Field('ping_status', __('Ping Status', 'event_espresso'), FALSE, 'open'); |
104 | 104 | } |
105 | 105 | |
106 | - if( ! isset( $this->_fields[$primary_table_name]['post_content_filtered'])){ |
|
107 | - $this->_fields[$primary_table_name]['post_content_filtered'] = new EE_DB_Only_Text_Field('post_content_filtered', __( 'Post Content Filtered', 'event_espresso' ), FALSE, ''); |
|
106 | + if ( ! isset($this->_fields[$primary_table_name]['post_content_filtered'])) { |
|
107 | + $this->_fields[$primary_table_name]['post_content_filtered'] = new EE_DB_Only_Text_Field('post_content_filtered', __('Post Content Filtered', 'event_espresso'), FALSE, ''); |
|
108 | 108 | } |
109 | - if( ! isset( $this->_model_relations[ 'Post_Meta' ] ) ) { |
|
109 | + if ( ! isset($this->_model_relations['Post_Meta'])) { |
|
110 | 110 | //don't block deletes though because we want to maintain the current behaviour |
111 | - $this->_model_relations[ 'Post_Meta' ] = new EE_Has_Many_Relation( false ); |
|
111 | + $this->_model_relations['Post_Meta'] = new EE_Has_Many_Relation(false); |
|
112 | 112 | } |
113 | - if( ! $this->_minimum_where_conditions_strategy instanceof EE_Default_Where_Conditions ){ |
|
113 | + if ( ! $this->_minimum_where_conditions_strategy instanceof EE_Default_Where_Conditions) { |
|
114 | 114 | //nothing was set during child constructor, so set default |
115 | - $this->_minimum_where_conditions_strategy = new EE_CPT_Minimum_Where_Conditions( $this->post_type() ); |
|
115 | + $this->_minimum_where_conditions_strategy = new EE_CPT_Minimum_Where_Conditions($this->post_type()); |
|
116 | 116 | } |
117 | - if( ! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions ) { |
|
117 | + if ( ! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions) { |
|
118 | 118 | //nothing was set during child constructor, so set default |
119 | 119 | //it's ok for child classes to specify this, but generally this is more DRY |
120 | - $this->_default_where_conditions_strategy = new EE_CPT_Where_Conditions( $this->post_type() ); |
|
120 | + $this->_default_where_conditions_strategy = new EE_CPT_Where_Conditions($this->post_type()); |
|
121 | 121 | } |
122 | 122 | parent::__construct($timezone); |
123 | 123 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function public_event_stati() { |
132 | 132 | // @see wp-includes/post.php |
133 | - return get_post_stati( array( 'public' => TRUE )); |
|
133 | + return get_post_stati(array('public' => TRUE)); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * @return string |
142 | 142 | * @throws EE_Error |
143 | 143 | */ |
144 | - public function deleted_field_name(){ |
|
144 | + public function deleted_field_name() { |
|
145 | 145 | throw new EE_Error(sprintf(__("EEM_CPT_Base should nto call deleted_field_name! It should instead use post_status_field_name", "event_espresso"))); |
146 | 146 | } |
147 | 147 | |
@@ -152,12 +152,12 @@ discard block |
||
152 | 152 | * @return string |
153 | 153 | * @throws EE_Error |
154 | 154 | */ |
155 | - public function post_status_field_name(){ |
|
155 | + public function post_status_field_name() { |
|
156 | 156 | $field = $this->get_a_field_of_type('EE_WP_Post_Status_Field'); |
157 | - if($field){ |
|
157 | + if ($field) { |
|
158 | 158 | return $field->get_name(); |
159 | - }else{ |
|
160 | - throw new EE_Error(sprintf(__('We are trying to find the post status flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?','event_espresso'),get_class($this),get_class($this))); |
|
159 | + } else { |
|
160 | + throw new EE_Error(sprintf(__('We are trying to find the post status flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?', 'event_espresso'), get_class($this), get_class($this))); |
|
161 | 161 | } |
162 | 162 | } |
163 | 163 | |
@@ -168,9 +168,9 @@ discard block |
||
168 | 168 | * @param array $query_params like EEM_Base::get_all's $query_params |
169 | 169 | * @return array like EEM_Base::get_all's $query_params |
170 | 170 | */ |
171 | - protected function _alter_query_params_so_only_trashed_items_included($query_params){ |
|
172 | - $post_status_field_name=$this->post_status_field_name(); |
|
173 | - $query_params[0][$post_status_field_name]=self::post_status_trashed; |
|
171 | + protected function _alter_query_params_so_only_trashed_items_included($query_params) { |
|
172 | + $post_status_field_name = $this->post_status_field_name(); |
|
173 | + $query_params[0][$post_status_field_name] = self::post_status_trashed; |
|
174 | 174 | return $query_params; |
175 | 175 | } |
176 | 176 | |
@@ -181,8 +181,8 @@ discard block |
||
181 | 181 | * @param array $query_params |
182 | 182 | * @return array |
183 | 183 | */ |
184 | - protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params){ |
|
185 | - $query_params[ 'default_where_conditions' ] = 'minimum'; |
|
184 | + protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params) { |
|
185 | + $query_params['default_where_conditions'] = 'minimum'; |
|
186 | 186 | return $query_params; |
187 | 187 | } |
188 | 188 | |
@@ -194,11 +194,11 @@ discard block |
||
194 | 194 | * @param array $query_params like EEM_Base::get_all |
195 | 195 | * @return boolean success |
196 | 196 | */ |
197 | - function delete_or_restore($delete=true,$query_params = array()){ |
|
198 | - $post_status_field_name=$this->post_status_field_name(); |
|
197 | + function delete_or_restore($delete = true, $query_params = array()) { |
|
198 | + $post_status_field_name = $this->post_status_field_name(); |
|
199 | 199 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
200 | 200 | $new_status = $delete ? self::post_status_trashed : 'draft'; |
201 | - if ( $this->update (array($post_status_field_name=>$new_status), $query_params )) { |
|
201 | + if ($this->update(array($post_status_field_name=>$new_status), $query_params)) { |
|
202 | 202 | return TRUE; |
203 | 203 | } else { |
204 | 204 | return FALSE; |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | */ |
216 | 216 | public function meta_table() { |
217 | 217 | $meta_table = $this->_get_other_tables(); |
218 | - $meta_table = reset( $meta_table ); |
|
218 | + $meta_table = reset($meta_table); |
|
219 | 219 | return $meta_table instanceof EE_Secondary_Table ? $meta_table->get_table_name() : NULL; |
220 | 220 | } |
221 | 221 | |
@@ -227,16 +227,16 @@ discard block |
||
227 | 227 | * @param bool $all triggers whether we include DB_Only fields or JUST non DB_Only fields. Defaults to false (no db only fields) |
228 | 228 | * @return array |
229 | 229 | */ |
230 | - public function get_meta_table_fields( $all = FALSE ) { |
|
230 | + public function get_meta_table_fields($all = FALSE) { |
|
231 | 231 | $all_fields = $fields_to_return = array(); |
232 | - foreach ( $this->_tables as $alias => $table_obj ) { |
|
233 | - if ( $table_obj instanceof EE_Secondary_Table ) |
|
234 | - $all_fields = array_merge( $this->_get_fields_for_table($alias), $all_fields ); |
|
232 | + foreach ($this->_tables as $alias => $table_obj) { |
|
233 | + if ($table_obj instanceof EE_Secondary_Table) |
|
234 | + $all_fields = array_merge($this->_get_fields_for_table($alias), $all_fields); |
|
235 | 235 | } |
236 | 236 | |
237 | - if ( !$all ) { |
|
238 | - foreach ( $all_fields as $name => $obj ) { |
|
239 | - if ( $obj instanceof EE_DB_Only_Field_Base ) |
|
237 | + if ( ! $all) { |
|
238 | + foreach ($all_fields as $name => $obj) { |
|
239 | + if ($obj instanceof EE_DB_Only_Field_Base) |
|
240 | 240 | continue; |
241 | 241 | $fields_to_return[] = $name; |
242 | 242 | } |
@@ -259,13 +259,13 @@ discard block |
||
259 | 259 | * @param int $parent_term_taxonomy_id |
260 | 260 | * @return EE_Term_Taxonomy |
261 | 261 | */ |
262 | - function add_event_category(EE_CPT_Base $cpt_model_object, $category_name, $category_description ='',$parent_term_taxonomy_id = null){ |
|
262 | + function add_event_category(EE_CPT_Base $cpt_model_object, $category_name, $category_description = '', $parent_term_taxonomy_id = null) { |
|
263 | 263 | //create term |
264 | - require_once( EE_MODELS . 'EEM_Term.model.php'); |
|
264 | + require_once(EE_MODELS.'EEM_Term.model.php'); |
|
265 | 265 | //first, check for a term by the same name or slug |
266 | 266 | $category_slug = sanitize_title($category_name); |
267 | - $term = EEM_Term::instance()->get_one(array(array('OR'=>array('name'=>$category_name,'slug'=>$category_slug)))); |
|
268 | - if( ! $term ){ |
|
267 | + $term = EEM_Term::instance()->get_one(array(array('OR'=>array('name'=>$category_name, 'slug'=>$category_slug)))); |
|
268 | + if ( ! $term) { |
|
269 | 269 | $term = EE_Term::new_instance(array( |
270 | 270 | 'name'=>$category_name, |
271 | 271 | 'slug'=>$category_slug |
@@ -273,10 +273,10 @@ discard block |
||
273 | 273 | $term->save(); |
274 | 274 | } |
275 | 275 | //make sure there's a term-taxonomy entry too |
276 | - require_once( EE_MODELS . 'EEM_Term_Taxonomy.model.php'); |
|
277 | - $term_taxonomy = EEM_Term_Taxonomy::instance()->get_one(array(array('term_id'=>$term->ID(),'taxonomy'=>EE_Event_Category_Taxonomy))); |
|
276 | + require_once(EE_MODELS.'EEM_Term_Taxonomy.model.php'); |
|
277 | + $term_taxonomy = EEM_Term_Taxonomy::instance()->get_one(array(array('term_id'=>$term->ID(), 'taxonomy'=>EE_Event_Category_Taxonomy))); |
|
278 | 278 | /** @var $term_taxonomy EE_Term_Taxonomy */ |
279 | - if( ! $term_taxonomy ){ |
|
279 | + if ( ! $term_taxonomy) { |
|
280 | 280 | $term_taxonomy = EE_Term_Taxonomy::new_instance(array( |
281 | 281 | 'term_id'=>$term->ID(), |
282 | 282 | 'taxonomy'=>EE_Event_Category_Taxonomy, |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | 'parent'=>$parent_term_taxonomy_id |
286 | 286 | )); |
287 | 287 | $term_taxonomy->save(); |
288 | - }else{ |
|
288 | + } else { |
|
289 | 289 | $term_taxonomy->set_count($term_taxonomy->count() + 1); |
290 | 290 | $term_taxonomy->save(); |
291 | 291 | } |
@@ -300,11 +300,11 @@ discard block |
||
300 | 300 | * @param string $category_name name of the event category (term) |
301 | 301 | * @return bool |
302 | 302 | */ |
303 | - function remove_event_category(EE_CPT_Base $cpt_model_object_event, $category_name){ |
|
303 | + function remove_event_category(EE_CPT_Base $cpt_model_object_event, $category_name) { |
|
304 | 304 | //find the term_taxonomy by that name |
305 | - $term_taxonomy = $this->get_first_related($cpt_model_object_event, 'Term_Taxonomy', array(array('Term.name'=>$category_name,'taxonomy'=>EE_Event_Category_Taxonomy))); |
|
305 | + $term_taxonomy = $this->get_first_related($cpt_model_object_event, 'Term_Taxonomy', array(array('Term.name'=>$category_name, 'taxonomy'=>EE_Event_Category_Taxonomy))); |
|
306 | 306 | /** @var $term_taxonomy EE_Term_Taxonomy */ |
307 | - if( $term_taxonomy ){ |
|
307 | + if ($term_taxonomy) { |
|
308 | 308 | $term_taxonomy->set_count($term_taxonomy->count() - 1); |
309 | 309 | $term_taxonomy->save(); |
310 | 310 | } |
@@ -324,8 +324,8 @@ discard block |
||
324 | 324 | * @param string|array $attr Optional. Query string or array of attributes. |
325 | 325 | * @return string HTML image element |
326 | 326 | */ |
327 | - public function get_feature_image( $id, $size = 'thumbnail', $attr = '' ) { |
|
328 | - return get_the_post_thumbnail( $id, $size, $attr ); |
|
327 | + public function get_feature_image($id, $size = 'thumbnail', $attr = '') { |
|
328 | + return get_the_post_thumbnail($id, $size, $attr); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | |
@@ -338,10 +338,10 @@ discard block |
||
338 | 338 | * @global array $wp_post_statuses set in wp core for storing all the post stati |
339 | 339 | * @return array |
340 | 340 | */ |
341 | - public function get_post_statuses(){ |
|
341 | + public function get_post_statuses() { |
|
342 | 342 | global $wp_post_statuses; |
343 | 343 | $statuses = array(); |
344 | - foreach($wp_post_statuses as $post_status => $args_object){ |
|
344 | + foreach ($wp_post_statuses as $post_status => $args_object) { |
|
345 | 345 | $statuses[$post_status] = $args_object->label; |
346 | 346 | } |
347 | 347 | return $statuses; |
@@ -356,9 +356,9 @@ discard block |
||
356 | 356 | public function get_status_array() { |
357 | 357 | $statuses = $this->get_post_statuses(); |
358 | 358 | //first the global filter |
359 | - $statuses = apply_filters( 'FHEE_EEM_CPT_Base__get_status_array', $statuses ); |
|
359 | + $statuses = apply_filters('FHEE_EEM_CPT_Base__get_status_array', $statuses); |
|
360 | 360 | //now the class specific filter |
361 | - $statuses = apply_filters( 'FHEE_EEM_' . get_class($this) . '__get_status_array', $statuses ); |
|
361 | + $statuses = apply_filters('FHEE_EEM_'.get_class($this).'__get_status_array', $statuses); |
|
362 | 362 | return $statuses; |
363 | 363 | } |
364 | 364 | |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | */ |
371 | 371 | public function get_custom_post_statuses() { |
372 | 372 | $new_stati = array(); |
373 | - foreach ( $this->_custom_stati as $status => $props ) { |
|
373 | + foreach ($this->_custom_stati as $status => $props) { |
|
374 | 374 | $new_stati[$status] = $props['label']; |
375 | 375 | } |
376 | 376 | return $new_stati; |
@@ -386,24 +386,24 @@ discard block |
||
386 | 386 | * @param WP_Post|array $post |
387 | 387 | * @return EE_CPT_Base |
388 | 388 | */ |
389 | - public function instantiate_class_from_post_object_orig($post){ |
|
390 | - $post = (array)$post; |
|
389 | + public function instantiate_class_from_post_object_orig($post) { |
|
390 | + $post = (array) $post; |
|
391 | 391 | $has_all_necessary_fields_for_table = true; |
392 | 392 | //check if the post has fields on the meta table already |
393 | - foreach($this->_get_other_tables() as $table_obj){ |
|
393 | + foreach ($this->_get_other_tables() as $table_obj) { |
|
394 | 394 | $fields_for_that_table = $this->_get_fields_for_table($table_obj->get_table_alias()); |
395 | - foreach($fields_for_that_table as $field_obj){ |
|
396 | - if( ! isset($post[$field_obj->get_table_column()]) |
|
397 | - && ! isset($post[$field_obj->get_qualified_column()])){ |
|
395 | + foreach ($fields_for_that_table as $field_obj) { |
|
396 | + if ( ! isset($post[$field_obj->get_table_column()]) |
|
397 | + && ! isset($post[$field_obj->get_qualified_column()])) { |
|
398 | 398 | $has_all_necessary_fields_for_table = false; |
399 | 399 | } |
400 | 400 | } |
401 | 401 | } |
402 | 402 | //if we don't have all the fields we need, then just fetch the proper model from the DB |
403 | - if( ! $has_all_necessary_fields_for_table){ |
|
403 | + if ( ! $has_all_necessary_fields_for_table) { |
|
404 | 404 | |
405 | 405 | return $this->get_one_by_ID($post['ID']); |
406 | - }else{ |
|
406 | + } else { |
|
407 | 407 | return $this->instantiate_class_from_array_or_object($post); |
408 | 408 | } |
409 | 409 | } |
@@ -414,30 +414,30 @@ discard block |
||
414 | 414 | * @param null $post |
415 | 415 | * @return EE_Base_Class|EE_Soft_Delete_Base_Class |
416 | 416 | */ |
417 | - public function instantiate_class_from_post_object( $post = NULL ){ |
|
418 | - if ( empty( $post )) { |
|
417 | + public function instantiate_class_from_post_object($post = NULL) { |
|
418 | + if (empty($post)) { |
|
419 | 419 | global $post; |
420 | 420 | } |
421 | - $post = (array)$post; |
|
421 | + $post = (array) $post; |
|
422 | 422 | $tables_needing_to_be_queried = array(); |
423 | 423 | //check if the post has fields on the meta table already |
424 | - foreach($this->get_tables() as $table_obj){ |
|
424 | + foreach ($this->get_tables() as $table_obj) { |
|
425 | 425 | $fields_for_that_table = $this->_get_fields_for_table($table_obj->get_table_alias()); |
426 | - foreach($fields_for_that_table as $field_obj){ |
|
427 | - if( ! isset($post[$field_obj->get_table_column()]) |
|
428 | - && ! isset($post[$field_obj->get_qualified_column()])){ |
|
426 | + foreach ($fields_for_that_table as $field_obj) { |
|
427 | + if ( ! isset($post[$field_obj->get_table_column()]) |
|
428 | + && ! isset($post[$field_obj->get_qualified_column()])) { |
|
429 | 429 | $tables_needing_to_be_queried[$table_obj->get_table_alias()] = $table_obj; |
430 | 430 | } |
431 | 431 | } |
432 | 432 | } |
433 | 433 | //if we don't have all the fields we need, then just fetch the proper model from the DB |
434 | - if( $tables_needing_to_be_queried){ |
|
435 | - if(count($tables_needing_to_be_queried) == 1 && reset($tables_needing_to_be_queried) instanceof EE_Secondary_Table){ |
|
434 | + if ($tables_needing_to_be_queried) { |
|
435 | + if (count($tables_needing_to_be_queried) == 1 && reset($tables_needing_to_be_queried) instanceof EE_Secondary_Table) { |
|
436 | 436 | //so we're only missing data from a secondary table. Well that's not too hard to query for |
437 | 437 | $table_to_query = reset($tables_needing_to_be_queried); |
438 | - $missing_data = $this->_do_wpdb_query( 'get_row', array( 'SELECT * FROM ' . $table_to_query->get_table_name() . ' WHERE ' . $table_to_query->get_fk_on_table() . ' = ' . $post['ID'], ARRAY_A )); |
|
439 | - if ( ! empty( $missing_data )) { |
|
440 | - $post = array_merge( $post, $missing_data ); |
|
438 | + $missing_data = $this->_do_wpdb_query('get_row', array('SELECT * FROM '.$table_to_query->get_table_name().' WHERE '.$table_to_query->get_fk_on_table().' = '.$post['ID'], ARRAY_A)); |
|
439 | + if ( ! empty($missing_data)) { |
|
440 | + $post = array_merge($post, $missing_data); |
|
441 | 441 | } |
442 | 442 | } else { |
443 | 443 | return $this->get_one_by_ID($post['ID']); |
@@ -454,15 +454,15 @@ discard block |
||
454 | 454 | * @throws EE_Error |
455 | 455 | * @return string |
456 | 456 | */ |
457 | - public function post_type(){ |
|
457 | + public function post_type() { |
|
458 | 458 | $post_type_field = NULL; |
459 | - foreach($this->field_settings(true) as $field_obj){ |
|
460 | - if($field_obj instanceof EE_WP_Post_Type_Field){ |
|
461 | - $post_type_field = $field_obj;break; |
|
459 | + foreach ($this->field_settings(true) as $field_obj) { |
|
460 | + if ($field_obj instanceof EE_WP_Post_Type_Field) { |
|
461 | + $post_type_field = $field_obj; break; |
|
462 | 462 | } |
463 | 463 | } |
464 | - if($post_type_field == NULL){ |
|
465 | - throw new EE_Error(sprintf(__("CPT Model %s should have a field of type EE_WP_Post_Type, but doesnt", "event_espresso"),get_class($this))); |
|
464 | + if ($post_type_field == NULL) { |
|
465 | + throw new EE_Error(sprintf(__("CPT Model %s should have a field of type EE_WP_Post_Type, but doesnt", "event_espresso"), get_class($this))); |
|
466 | 466 | } |
467 | 467 | return $post_type_field->get_default_value(); |
468 | 468 | } |