@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
| 2 | - exit('No direct script access allowed'); |
|
| 2 | + exit('No direct script access allowed'); |
|
| 3 | 3 | } |
| 4 | 4 | /** |
| 5 | 5 | * Event Espresso |
@@ -23,670 +23,670 @@ discard block |
||
| 23 | 23 | class EE_Attendee extends EE_CPT_Base implements EEI_Contact, EEI_Address, EEI_Admin_Links, EEI_Attendee |
| 24 | 24 | { |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Sets some dynamic defaults |
|
| 28 | - * |
|
| 29 | - * @param array $fieldValues |
|
| 30 | - * @param bool $bydb |
|
| 31 | - * @param string $timezone |
|
| 32 | - * @param array $date_formats |
|
| 33 | - */ |
|
| 34 | - protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array()) |
|
| 35 | - { |
|
| 36 | - if (! isset($fieldValues['ATT_full_name'])) { |
|
| 37 | - $fname = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : ''; |
|
| 38 | - $lname = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : ''; |
|
| 39 | - $fieldValues['ATT_full_name'] = $fname . $lname; |
|
| 40 | - } |
|
| 41 | - if (! isset($fieldValues['ATT_slug'])) { |
|
| 42 | - // $fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20)); |
|
| 43 | - $fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']); |
|
| 44 | - } |
|
| 45 | - if (! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) { |
|
| 46 | - $fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50); |
|
| 47 | - } |
|
| 48 | - parent::__construct($fieldValues, $bydb, $timezone, $date_formats); |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * @param array $props_n_values incoming values |
|
| 54 | - * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
| 55 | - * used.) |
|
| 56 | - * @param array $date_formats incoming date_formats in an array where the first value is the |
|
| 57 | - * date_format and the second value is the time format |
|
| 58 | - * @return EE_Attendee |
|
| 59 | - */ |
|
| 60 | - public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
| 61 | - { |
|
| 62 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
| 63 | - return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * @param array $props_n_values incoming values from the database |
|
| 69 | - * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
| 70 | - * the website will be used. |
|
| 71 | - * @return EE_Attendee |
|
| 72 | - */ |
|
| 73 | - public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
| 74 | - { |
|
| 75 | - return new self($props_n_values, true, $timezone); |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * Set Attendee First Name |
|
| 81 | - * |
|
| 82 | - * @access public |
|
| 83 | - * @param string $fname |
|
| 84 | - */ |
|
| 85 | - public function set_fname($fname = '') |
|
| 86 | - { |
|
| 87 | - $this->set('ATT_fname', $fname); |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * Set Attendee Last Name |
|
| 93 | - * |
|
| 94 | - * @access public |
|
| 95 | - * @param string $lname |
|
| 96 | - */ |
|
| 97 | - public function set_lname($lname = '') |
|
| 98 | - { |
|
| 99 | - $this->set('ATT_lname', $lname); |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * Set Attendee Address |
|
| 105 | - * |
|
| 106 | - * @access public |
|
| 107 | - * @param string $address |
|
| 108 | - */ |
|
| 109 | - public function set_address($address = '') |
|
| 110 | - { |
|
| 111 | - $this->set('ATT_address', $address); |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * Set Attendee Address2 |
|
| 117 | - * |
|
| 118 | - * @access public |
|
| 119 | - * @param string $address2 |
|
| 120 | - */ |
|
| 121 | - public function set_address2($address2 = '') |
|
| 122 | - { |
|
| 123 | - $this->set('ATT_address2', $address2); |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - |
|
| 127 | - /** |
|
| 128 | - * Set Attendee City |
|
| 129 | - * |
|
| 130 | - * @access public |
|
| 131 | - * @param string $city |
|
| 132 | - */ |
|
| 133 | - public function set_city($city = '') |
|
| 134 | - { |
|
| 135 | - $this->set('ATT_city', $city); |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - |
|
| 139 | - /** |
|
| 140 | - * Set Attendee State ID |
|
| 141 | - * |
|
| 142 | - * @access public |
|
| 143 | - * @param int $STA_ID |
|
| 144 | - */ |
|
| 145 | - public function set_state($STA_ID = 0) |
|
| 146 | - { |
|
| 147 | - $this->set('STA_ID', $STA_ID); |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - |
|
| 151 | - /** |
|
| 152 | - * Set Attendee Country ISO Code |
|
| 153 | - * |
|
| 154 | - * @access public |
|
| 155 | - * @param string $CNT_ISO |
|
| 156 | - */ |
|
| 157 | - public function set_country($CNT_ISO = '') |
|
| 158 | - { |
|
| 159 | - $this->set('CNT_ISO', $CNT_ISO); |
|
| 160 | - } |
|
| 161 | - |
|
| 162 | - |
|
| 163 | - /** |
|
| 164 | - * Set Attendee Zip/Postal Code |
|
| 165 | - * |
|
| 166 | - * @access public |
|
| 167 | - * @param string $zip |
|
| 168 | - */ |
|
| 169 | - public function set_zip($zip = '') |
|
| 170 | - { |
|
| 171 | - $this->set('ATT_zip', $zip); |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - |
|
| 175 | - /** |
|
| 176 | - * Set Attendee Email Address |
|
| 177 | - * |
|
| 178 | - * @access public |
|
| 179 | - * @param string $email |
|
| 180 | - */ |
|
| 181 | - public function set_email($email = '') |
|
| 182 | - { |
|
| 183 | - $this->set('ATT_email', $email); |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - |
|
| 187 | - /** |
|
| 188 | - * Set Attendee Phone |
|
| 189 | - * |
|
| 190 | - * @access public |
|
| 191 | - * @param string $phone |
|
| 192 | - */ |
|
| 193 | - public function set_phone($phone = '') |
|
| 194 | - { |
|
| 195 | - $this->set('ATT_phone', $phone); |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - |
|
| 199 | - /** |
|
| 200 | - * set deleted |
|
| 201 | - * |
|
| 202 | - * @access public |
|
| 203 | - * @param bool $ATT_deleted |
|
| 204 | - */ |
|
| 205 | - public function set_deleted($ATT_deleted = false) |
|
| 206 | - { |
|
| 207 | - $this->set('ATT_deleted', $ATT_deleted); |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - |
|
| 211 | - /** |
|
| 212 | - * Returns the value for the post_author id saved with the cpt |
|
| 213 | - * |
|
| 214 | - * @since 4.5.0 |
|
| 215 | - * @return int |
|
| 216 | - */ |
|
| 217 | - public function wp_user() |
|
| 218 | - { |
|
| 219 | - return $this->get('ATT_author'); |
|
| 220 | - } |
|
| 221 | - |
|
| 222 | - |
|
| 223 | - /** |
|
| 224 | - * get Attendee First Name |
|
| 225 | - * |
|
| 226 | - * @access public |
|
| 227 | - * @return string |
|
| 228 | - */ |
|
| 229 | - public function fname() |
|
| 230 | - { |
|
| 231 | - return $this->get('ATT_fname'); |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - |
|
| 235 | - /** |
|
| 236 | - * echoes out the attendee's first name |
|
| 237 | - * |
|
| 238 | - * @return void |
|
| 239 | - */ |
|
| 240 | - public function e_full_name() |
|
| 241 | - { |
|
| 242 | - echo $this->full_name(); |
|
| 243 | - } |
|
| 244 | - |
|
| 245 | - |
|
| 246 | - /** |
|
| 247 | - * Returns the first and last name concatenated together with a space. |
|
| 248 | - * |
|
| 249 | - * @param bool $apply_html_entities |
|
| 250 | - * @return string |
|
| 251 | - */ |
|
| 252 | - public function full_name($apply_html_entities = false) |
|
| 253 | - { |
|
| 254 | - $full_name = array( |
|
| 255 | - $this->fname(), |
|
| 256 | - $this->lname(), |
|
| 257 | - ); |
|
| 258 | - $full_name = array_filter($full_name); |
|
| 259 | - $full_name = implode(' ', $full_name); |
|
| 260 | - return $apply_html_entities ? htmlentities($full_name, ENT_QUOTES, 'UTF-8') : $full_name; |
|
| 261 | - } |
|
| 262 | - |
|
| 263 | - |
|
| 264 | - /** |
|
| 265 | - * This returns the value of the `ATT_full_name` field which is usually equivalent to calling `full_name()` unless |
|
| 266 | - * the post_title field has been directly modified in the db for the post (espresso_attendees post type) for this |
|
| 267 | - * attendee. |
|
| 268 | - * |
|
| 269 | - * @param bool $apply_html_entities |
|
| 270 | - * @return string |
|
| 271 | - */ |
|
| 272 | - public function ATT_full_name($apply_html_entities = false) |
|
| 273 | - { |
|
| 274 | - return $apply_html_entities |
|
| 275 | - ? htmlentities($this->get('ATT_full_name'), ENT_QUOTES, 'UTF-8') |
|
| 276 | - : $this->get('ATT_full_name'); |
|
| 277 | - } |
|
| 278 | - |
|
| 279 | - |
|
| 280 | - /** |
|
| 281 | - * get Attendee Last Name |
|
| 282 | - * |
|
| 283 | - * @access public |
|
| 284 | - * @return string |
|
| 285 | - */ |
|
| 286 | - public function lname() |
|
| 287 | - { |
|
| 288 | - return $this->get('ATT_lname'); |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - |
|
| 292 | - /** |
|
| 293 | - * Gets the attendee's full address as an array so client code can decide hwo to display it |
|
| 294 | - * |
|
| 295 | - * @return array numerically indexed, with each part of the address that is known. |
|
| 296 | - * Eg, if the user only responded to state and country, |
|
| 297 | - * it would be array(0=>'Alabama',1=>'USA') |
|
| 298 | - * @return array |
|
| 299 | - */ |
|
| 300 | - public function full_address_as_array() |
|
| 301 | - { |
|
| 302 | - $full_address_array = array(); |
|
| 303 | - $initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',); |
|
| 304 | - foreach ($initial_address_fields as $address_field_name) { |
|
| 305 | - $address_fields_value = $this->get($address_field_name); |
|
| 306 | - if (! empty($address_fields_value)) { |
|
| 307 | - $full_address_array[] = $address_fields_value; |
|
| 308 | - } |
|
| 309 | - } |
|
| 310 | - //now handle state and country |
|
| 311 | - $state_obj = $this->state_obj(); |
|
| 312 | - if (! empty($state_obj)) { |
|
| 313 | - $full_address_array[] = $state_obj->name(); |
|
| 314 | - } |
|
| 315 | - $country_obj = $this->country_obj(); |
|
| 316 | - if (! empty($country_obj)) { |
|
| 317 | - $full_address_array[] = $country_obj->name(); |
|
| 318 | - } |
|
| 319 | - //lastly get the xip |
|
| 320 | - $zip_value = $this->zip(); |
|
| 321 | - if (! empty($zip_value)) { |
|
| 322 | - $full_address_array[] = $zip_value; |
|
| 323 | - } |
|
| 324 | - return $full_address_array; |
|
| 325 | - } |
|
| 326 | - |
|
| 327 | - |
|
| 328 | - /** |
|
| 329 | - * get Attendee Address |
|
| 330 | - * |
|
| 331 | - * @return string |
|
| 332 | - */ |
|
| 333 | - public function address() |
|
| 334 | - { |
|
| 335 | - return $this->get('ATT_address'); |
|
| 336 | - } |
|
| 337 | - |
|
| 338 | - |
|
| 339 | - /** |
|
| 340 | - * get Attendee Address2 |
|
| 341 | - * |
|
| 342 | - * @return string |
|
| 343 | - */ |
|
| 344 | - public function address2() |
|
| 345 | - { |
|
| 346 | - return $this->get('ATT_address2'); |
|
| 347 | - } |
|
| 348 | - |
|
| 349 | - |
|
| 350 | - /** |
|
| 351 | - * get Attendee City |
|
| 352 | - * |
|
| 353 | - * @return string |
|
| 354 | - */ |
|
| 355 | - public function city() |
|
| 356 | - { |
|
| 357 | - return $this->get('ATT_city'); |
|
| 358 | - } |
|
| 359 | - |
|
| 360 | - |
|
| 361 | - /** |
|
| 362 | - * get Attendee State ID |
|
| 363 | - * |
|
| 364 | - * @return string |
|
| 365 | - */ |
|
| 366 | - public function state_ID() |
|
| 367 | - { |
|
| 368 | - return $this->get('STA_ID'); |
|
| 369 | - } |
|
| 370 | - |
|
| 371 | - |
|
| 372 | - /** |
|
| 373 | - * @return string |
|
| 374 | - */ |
|
| 375 | - public function state_abbrev() |
|
| 376 | - { |
|
| 377 | - return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : ''; |
|
| 378 | - } |
|
| 379 | - |
|
| 380 | - |
|
| 381 | - /** |
|
| 382 | - * Gets the state set to this attendee |
|
| 383 | - * |
|
| 384 | - * @return EE_State |
|
| 385 | - */ |
|
| 386 | - public function state_obj() |
|
| 387 | - { |
|
| 388 | - return $this->get_first_related('State'); |
|
| 389 | - } |
|
| 390 | - |
|
| 391 | - |
|
| 392 | - /** |
|
| 393 | - * Returns the state's name, otherwise 'Unknown' |
|
| 394 | - * |
|
| 395 | - * @return string |
|
| 396 | - */ |
|
| 397 | - public function state_name() |
|
| 398 | - { |
|
| 399 | - if ($this->state_obj()) { |
|
| 400 | - return $this->state_obj()->name(); |
|
| 401 | - } else { |
|
| 402 | - return ''; |
|
| 403 | - } |
|
| 404 | - } |
|
| 405 | - |
|
| 406 | - |
|
| 407 | - /** |
|
| 408 | - * either displays the state abbreviation or the state name, as determined |
|
| 409 | - * by the "FHEE__EEI_Address__state__use_abbreviation" filter. |
|
| 410 | - * defaults to abbreviation |
|
| 411 | - * |
|
| 412 | - * @return string |
|
| 413 | - */ |
|
| 414 | - public function state() |
|
| 415 | - { |
|
| 416 | - if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) { |
|
| 417 | - return $this->state_abbrev(); |
|
| 418 | - } else { |
|
| 419 | - return $this->state_name(); |
|
| 420 | - } |
|
| 421 | - } |
|
| 422 | - |
|
| 423 | - |
|
| 424 | - /** |
|
| 425 | - * get Attendee Country ISO Code |
|
| 426 | - * |
|
| 427 | - * @return string |
|
| 428 | - */ |
|
| 429 | - public function country_ID() |
|
| 430 | - { |
|
| 431 | - return $this->get('CNT_ISO'); |
|
| 432 | - } |
|
| 433 | - |
|
| 434 | - |
|
| 435 | - /** |
|
| 436 | - * Gets country set for this attendee |
|
| 437 | - * |
|
| 438 | - * @return EE_Country |
|
| 439 | - */ |
|
| 440 | - public function country_obj() |
|
| 441 | - { |
|
| 442 | - return $this->get_first_related('Country'); |
|
| 443 | - } |
|
| 444 | - |
|
| 445 | - |
|
| 446 | - /** |
|
| 447 | - * Returns the country's name if known, otherwise 'Unknown' |
|
| 448 | - * |
|
| 449 | - * @return string |
|
| 450 | - */ |
|
| 451 | - public function country_name() |
|
| 452 | - { |
|
| 453 | - if ($this->country_obj()) { |
|
| 454 | - return $this->country_obj()->name(); |
|
| 455 | - } else { |
|
| 456 | - return ''; |
|
| 457 | - } |
|
| 458 | - } |
|
| 459 | - |
|
| 460 | - |
|
| 461 | - /** |
|
| 462 | - * either displays the country ISO2 code or the country name, as determined |
|
| 463 | - * by the "FHEE__EEI_Address__country__use_abbreviation" filter. |
|
| 464 | - * defaults to abbreviation |
|
| 465 | - * |
|
| 466 | - * @return string |
|
| 467 | - */ |
|
| 468 | - public function country() |
|
| 469 | - { |
|
| 470 | - if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) { |
|
| 471 | - return $this->country_ID(); |
|
| 472 | - } else { |
|
| 473 | - return $this->country_name(); |
|
| 474 | - } |
|
| 475 | - } |
|
| 476 | - |
|
| 477 | - |
|
| 478 | - /** |
|
| 479 | - * get Attendee Zip/Postal Code |
|
| 480 | - * |
|
| 481 | - * @return string |
|
| 482 | - */ |
|
| 483 | - public function zip() |
|
| 484 | - { |
|
| 485 | - return $this->get('ATT_zip'); |
|
| 486 | - } |
|
| 487 | - |
|
| 488 | - |
|
| 489 | - /** |
|
| 490 | - * get Attendee Email Address |
|
| 491 | - * |
|
| 492 | - * @return string |
|
| 493 | - */ |
|
| 494 | - public function email() |
|
| 495 | - { |
|
| 496 | - return $this->get('ATT_email'); |
|
| 497 | - } |
|
| 498 | - |
|
| 499 | - |
|
| 500 | - /** |
|
| 501 | - * get Attendee Phone # |
|
| 502 | - * |
|
| 503 | - * @return string |
|
| 504 | - */ |
|
| 505 | - public function phone() |
|
| 506 | - { |
|
| 507 | - return $this->get('ATT_phone'); |
|
| 508 | - } |
|
| 509 | - |
|
| 510 | - |
|
| 511 | - /** |
|
| 512 | - * get deleted |
|
| 513 | - * |
|
| 514 | - * @return bool |
|
| 515 | - */ |
|
| 516 | - public function deleted() |
|
| 517 | - { |
|
| 518 | - return $this->get('ATT_deleted'); |
|
| 519 | - } |
|
| 520 | - |
|
| 521 | - |
|
| 522 | - /** |
|
| 523 | - * Gets registrations of this attendee |
|
| 524 | - * |
|
| 525 | - * @param array $query_params |
|
| 526 | - * @return EE_Registration[] |
|
| 527 | - */ |
|
| 528 | - public function get_registrations($query_params = array()) |
|
| 529 | - { |
|
| 530 | - return $this->get_many_related('Registration', $query_params); |
|
| 531 | - } |
|
| 532 | - |
|
| 533 | - |
|
| 534 | - /** |
|
| 535 | - * Gets the most recent registration of this attendee |
|
| 536 | - * |
|
| 537 | - * @return EE_Registration |
|
| 538 | - */ |
|
| 539 | - public function get_most_recent_registration() |
|
| 540 | - { |
|
| 541 | - return $this->get_first_related('Registration', |
|
| 542 | - array('order_by' => array('REG_date' => 'DESC'))); //null, 'REG_date', 'DESC', '=', 'OBJECT_K'); |
|
| 543 | - } |
|
| 544 | - |
|
| 545 | - |
|
| 546 | - /** |
|
| 547 | - * Gets the most recent registration for this attend at this event |
|
| 548 | - * |
|
| 549 | - * @param int $event_id |
|
| 550 | - * @return EE_Registration |
|
| 551 | - */ |
|
| 552 | - public function get_most_recent_registration_for_event($event_id) |
|
| 553 | - { |
|
| 554 | - return $this->get_first_related('Registration', |
|
| 555 | - array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC')));//, '=', 'OBJECT_K' ); |
|
| 556 | - } |
|
| 557 | - |
|
| 558 | - |
|
| 559 | - /** |
|
| 560 | - * returns any events attached to this attendee ($_Event property); |
|
| 561 | - * |
|
| 562 | - * @return array |
|
| 563 | - */ |
|
| 564 | - public function events() |
|
| 565 | - { |
|
| 566 | - return $this->get_many_related('Event'); |
|
| 567 | - } |
|
| 568 | - |
|
| 569 | - |
|
| 570 | - /** |
|
| 571 | - * Gets the billing info array where keys match espresso_reg_page_billing_inputs(), |
|
| 572 | - * and keys are their cleaned values. @see EE_Attendee::save_and_clean_billing_info_for_payment_method() which was |
|
| 573 | - * used to save the billing info |
|
| 574 | - * |
|
| 575 | - * @param EE_Payment_Method $payment_method the _gateway_name property on the gateway class |
|
| 576 | - * @return EE_Form_Section_Proper|null |
|
| 577 | - */ |
|
| 578 | - public function billing_info_for_payment_method($payment_method) |
|
| 579 | - { |
|
| 580 | - $pm_type = $payment_method->type_obj(); |
|
| 581 | - if (! $pm_type instanceof EE_PMT_Base) { |
|
| 582 | - return null; |
|
| 583 | - } |
|
| 584 | - $billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true); |
|
| 585 | - if (! $billing_info) { |
|
| 586 | - return null; |
|
| 587 | - } |
|
| 588 | - $billing_form = $pm_type->billing_form(); |
|
| 589 | - if ($billing_form instanceof EE_Form_Section_Proper) { |
|
| 590 | - $billing_form->receive_form_submission(array($billing_form->name() => $billing_info), false); |
|
| 591 | - } |
|
| 592 | - return $billing_form; |
|
| 593 | - } |
|
| 594 | - |
|
| 595 | - |
|
| 596 | - /** |
|
| 597 | - * Gets the postmeta key that holds this attendee's billing info for the |
|
| 598 | - * specified payment method |
|
| 599 | - * |
|
| 600 | - * @param EE_Payment_Method $payment_method |
|
| 601 | - * @return string |
|
| 602 | - */ |
|
| 603 | - public function get_billing_info_postmeta_name($payment_method) |
|
| 604 | - { |
|
| 605 | - if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
|
| 606 | - return 'billing_info_' . $payment_method->type_obj()->system_name(); |
|
| 607 | - } else { |
|
| 608 | - return null; |
|
| 609 | - } |
|
| 610 | - } |
|
| 611 | - |
|
| 612 | - |
|
| 613 | - /** |
|
| 614 | - * Saves the billing info to the attendee. @see EE_Attendee::billing_info_for_payment_method() which is used to |
|
| 615 | - * retrieve it |
|
| 616 | - * |
|
| 617 | - * @param EE_Billing_Attendee_Info_Form $billing_form |
|
| 618 | - * @param EE_Payment_Method $payment_method |
|
| 619 | - * @return boolean |
|
| 620 | - */ |
|
| 621 | - public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method) |
|
| 622 | - { |
|
| 623 | - if (! $billing_form instanceof EE_Billing_Attendee_Info_Form) { |
|
| 624 | - EE_Error::add_error(__('Cannot save billing info because there is none.', 'event_espresso')); |
|
| 625 | - return false; |
|
| 626 | - } |
|
| 627 | - $billing_form->clean_sensitive_data(); |
|
| 628 | - return update_post_meta($this->ID(), $this->get_billing_info_postmeta_name($payment_method), |
|
| 629 | - $billing_form->input_values(true)); |
|
| 630 | - } |
|
| 631 | - |
|
| 632 | - |
|
| 633 | - /** |
|
| 634 | - * Return the link to the admin details for the object. |
|
| 635 | - * |
|
| 636 | - * @return string |
|
| 637 | - */ |
|
| 638 | - public function get_admin_details_link() |
|
| 639 | - { |
|
| 640 | - return $this->get_admin_edit_link(); |
|
| 641 | - } |
|
| 642 | - |
|
| 643 | - |
|
| 644 | - /** |
|
| 645 | - * Returns the link to the editor for the object. Sometimes this is the same as the details. |
|
| 646 | - * |
|
| 647 | - * @return string |
|
| 648 | - */ |
|
| 649 | - public function get_admin_edit_link() |
|
| 650 | - { |
|
| 651 | - EE_Registry::instance()->load_helper('URL'); |
|
| 652 | - return EEH_URL::add_query_args_and_nonce( |
|
| 653 | - array( |
|
| 654 | - 'page' => 'espresso_registrations', |
|
| 655 | - 'action' => 'edit_attendee', |
|
| 656 | - 'post' => $this->ID(), |
|
| 657 | - ), |
|
| 658 | - admin_url('admin.php') |
|
| 659 | - ); |
|
| 660 | - } |
|
| 661 | - |
|
| 662 | - |
|
| 663 | - /** |
|
| 664 | - * Returns the link to a settings page for the object. |
|
| 665 | - * |
|
| 666 | - * @return string |
|
| 667 | - */ |
|
| 668 | - public function get_admin_settings_link() |
|
| 669 | - { |
|
| 670 | - return $this->get_admin_edit_link(); |
|
| 671 | - } |
|
| 672 | - |
|
| 673 | - |
|
| 674 | - /** |
|
| 675 | - * Returns the link to the "overview" for the object (typically the "list table" view). |
|
| 676 | - * |
|
| 677 | - * @return string |
|
| 678 | - */ |
|
| 679 | - public function get_admin_overview_link() |
|
| 680 | - { |
|
| 681 | - EE_Registry::instance()->load_helper('URL'); |
|
| 682 | - return EEH_URL::add_query_args_and_nonce( |
|
| 683 | - array( |
|
| 684 | - 'page' => 'espresso_registrations', |
|
| 685 | - 'action' => 'contact_list', |
|
| 686 | - ), |
|
| 687 | - admin_url('admin.php') |
|
| 688 | - ); |
|
| 689 | - } |
|
| 26 | + /** |
|
| 27 | + * Sets some dynamic defaults |
|
| 28 | + * |
|
| 29 | + * @param array $fieldValues |
|
| 30 | + * @param bool $bydb |
|
| 31 | + * @param string $timezone |
|
| 32 | + * @param array $date_formats |
|
| 33 | + */ |
|
| 34 | + protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array()) |
|
| 35 | + { |
|
| 36 | + if (! isset($fieldValues['ATT_full_name'])) { |
|
| 37 | + $fname = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : ''; |
|
| 38 | + $lname = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : ''; |
|
| 39 | + $fieldValues['ATT_full_name'] = $fname . $lname; |
|
| 40 | + } |
|
| 41 | + if (! isset($fieldValues['ATT_slug'])) { |
|
| 42 | + // $fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20)); |
|
| 43 | + $fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']); |
|
| 44 | + } |
|
| 45 | + if (! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) { |
|
| 46 | + $fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50); |
|
| 47 | + } |
|
| 48 | + parent::__construct($fieldValues, $bydb, $timezone, $date_formats); |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * @param array $props_n_values incoming values |
|
| 54 | + * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
| 55 | + * used.) |
|
| 56 | + * @param array $date_formats incoming date_formats in an array where the first value is the |
|
| 57 | + * date_format and the second value is the time format |
|
| 58 | + * @return EE_Attendee |
|
| 59 | + */ |
|
| 60 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
| 61 | + { |
|
| 62 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
| 63 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * @param array $props_n_values incoming values from the database |
|
| 69 | + * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
| 70 | + * the website will be used. |
|
| 71 | + * @return EE_Attendee |
|
| 72 | + */ |
|
| 73 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
| 74 | + { |
|
| 75 | + return new self($props_n_values, true, $timezone); |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * Set Attendee First Name |
|
| 81 | + * |
|
| 82 | + * @access public |
|
| 83 | + * @param string $fname |
|
| 84 | + */ |
|
| 85 | + public function set_fname($fname = '') |
|
| 86 | + { |
|
| 87 | + $this->set('ATT_fname', $fname); |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * Set Attendee Last Name |
|
| 93 | + * |
|
| 94 | + * @access public |
|
| 95 | + * @param string $lname |
|
| 96 | + */ |
|
| 97 | + public function set_lname($lname = '') |
|
| 98 | + { |
|
| 99 | + $this->set('ATT_lname', $lname); |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * Set Attendee Address |
|
| 105 | + * |
|
| 106 | + * @access public |
|
| 107 | + * @param string $address |
|
| 108 | + */ |
|
| 109 | + public function set_address($address = '') |
|
| 110 | + { |
|
| 111 | + $this->set('ATT_address', $address); |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * Set Attendee Address2 |
|
| 117 | + * |
|
| 118 | + * @access public |
|
| 119 | + * @param string $address2 |
|
| 120 | + */ |
|
| 121 | + public function set_address2($address2 = '') |
|
| 122 | + { |
|
| 123 | + $this->set('ATT_address2', $address2); |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + |
|
| 127 | + /** |
|
| 128 | + * Set Attendee City |
|
| 129 | + * |
|
| 130 | + * @access public |
|
| 131 | + * @param string $city |
|
| 132 | + */ |
|
| 133 | + public function set_city($city = '') |
|
| 134 | + { |
|
| 135 | + $this->set('ATT_city', $city); |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + |
|
| 139 | + /** |
|
| 140 | + * Set Attendee State ID |
|
| 141 | + * |
|
| 142 | + * @access public |
|
| 143 | + * @param int $STA_ID |
|
| 144 | + */ |
|
| 145 | + public function set_state($STA_ID = 0) |
|
| 146 | + { |
|
| 147 | + $this->set('STA_ID', $STA_ID); |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + |
|
| 151 | + /** |
|
| 152 | + * Set Attendee Country ISO Code |
|
| 153 | + * |
|
| 154 | + * @access public |
|
| 155 | + * @param string $CNT_ISO |
|
| 156 | + */ |
|
| 157 | + public function set_country($CNT_ISO = '') |
|
| 158 | + { |
|
| 159 | + $this->set('CNT_ISO', $CNT_ISO); |
|
| 160 | + } |
|
| 161 | + |
|
| 162 | + |
|
| 163 | + /** |
|
| 164 | + * Set Attendee Zip/Postal Code |
|
| 165 | + * |
|
| 166 | + * @access public |
|
| 167 | + * @param string $zip |
|
| 168 | + */ |
|
| 169 | + public function set_zip($zip = '') |
|
| 170 | + { |
|
| 171 | + $this->set('ATT_zip', $zip); |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + |
|
| 175 | + /** |
|
| 176 | + * Set Attendee Email Address |
|
| 177 | + * |
|
| 178 | + * @access public |
|
| 179 | + * @param string $email |
|
| 180 | + */ |
|
| 181 | + public function set_email($email = '') |
|
| 182 | + { |
|
| 183 | + $this->set('ATT_email', $email); |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + |
|
| 187 | + /** |
|
| 188 | + * Set Attendee Phone |
|
| 189 | + * |
|
| 190 | + * @access public |
|
| 191 | + * @param string $phone |
|
| 192 | + */ |
|
| 193 | + public function set_phone($phone = '') |
|
| 194 | + { |
|
| 195 | + $this->set('ATT_phone', $phone); |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + |
|
| 199 | + /** |
|
| 200 | + * set deleted |
|
| 201 | + * |
|
| 202 | + * @access public |
|
| 203 | + * @param bool $ATT_deleted |
|
| 204 | + */ |
|
| 205 | + public function set_deleted($ATT_deleted = false) |
|
| 206 | + { |
|
| 207 | + $this->set('ATT_deleted', $ATT_deleted); |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + |
|
| 211 | + /** |
|
| 212 | + * Returns the value for the post_author id saved with the cpt |
|
| 213 | + * |
|
| 214 | + * @since 4.5.0 |
|
| 215 | + * @return int |
|
| 216 | + */ |
|
| 217 | + public function wp_user() |
|
| 218 | + { |
|
| 219 | + return $this->get('ATT_author'); |
|
| 220 | + } |
|
| 221 | + |
|
| 222 | + |
|
| 223 | + /** |
|
| 224 | + * get Attendee First Name |
|
| 225 | + * |
|
| 226 | + * @access public |
|
| 227 | + * @return string |
|
| 228 | + */ |
|
| 229 | + public function fname() |
|
| 230 | + { |
|
| 231 | + return $this->get('ATT_fname'); |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + |
|
| 235 | + /** |
|
| 236 | + * echoes out the attendee's first name |
|
| 237 | + * |
|
| 238 | + * @return void |
|
| 239 | + */ |
|
| 240 | + public function e_full_name() |
|
| 241 | + { |
|
| 242 | + echo $this->full_name(); |
|
| 243 | + } |
|
| 244 | + |
|
| 245 | + |
|
| 246 | + /** |
|
| 247 | + * Returns the first and last name concatenated together with a space. |
|
| 248 | + * |
|
| 249 | + * @param bool $apply_html_entities |
|
| 250 | + * @return string |
|
| 251 | + */ |
|
| 252 | + public function full_name($apply_html_entities = false) |
|
| 253 | + { |
|
| 254 | + $full_name = array( |
|
| 255 | + $this->fname(), |
|
| 256 | + $this->lname(), |
|
| 257 | + ); |
|
| 258 | + $full_name = array_filter($full_name); |
|
| 259 | + $full_name = implode(' ', $full_name); |
|
| 260 | + return $apply_html_entities ? htmlentities($full_name, ENT_QUOTES, 'UTF-8') : $full_name; |
|
| 261 | + } |
|
| 262 | + |
|
| 263 | + |
|
| 264 | + /** |
|
| 265 | + * This returns the value of the `ATT_full_name` field which is usually equivalent to calling `full_name()` unless |
|
| 266 | + * the post_title field has been directly modified in the db for the post (espresso_attendees post type) for this |
|
| 267 | + * attendee. |
|
| 268 | + * |
|
| 269 | + * @param bool $apply_html_entities |
|
| 270 | + * @return string |
|
| 271 | + */ |
|
| 272 | + public function ATT_full_name($apply_html_entities = false) |
|
| 273 | + { |
|
| 274 | + return $apply_html_entities |
|
| 275 | + ? htmlentities($this->get('ATT_full_name'), ENT_QUOTES, 'UTF-8') |
|
| 276 | + : $this->get('ATT_full_name'); |
|
| 277 | + } |
|
| 278 | + |
|
| 279 | + |
|
| 280 | + /** |
|
| 281 | + * get Attendee Last Name |
|
| 282 | + * |
|
| 283 | + * @access public |
|
| 284 | + * @return string |
|
| 285 | + */ |
|
| 286 | + public function lname() |
|
| 287 | + { |
|
| 288 | + return $this->get('ATT_lname'); |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + |
|
| 292 | + /** |
|
| 293 | + * Gets the attendee's full address as an array so client code can decide hwo to display it |
|
| 294 | + * |
|
| 295 | + * @return array numerically indexed, with each part of the address that is known. |
|
| 296 | + * Eg, if the user only responded to state and country, |
|
| 297 | + * it would be array(0=>'Alabama',1=>'USA') |
|
| 298 | + * @return array |
|
| 299 | + */ |
|
| 300 | + public function full_address_as_array() |
|
| 301 | + { |
|
| 302 | + $full_address_array = array(); |
|
| 303 | + $initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',); |
|
| 304 | + foreach ($initial_address_fields as $address_field_name) { |
|
| 305 | + $address_fields_value = $this->get($address_field_name); |
|
| 306 | + if (! empty($address_fields_value)) { |
|
| 307 | + $full_address_array[] = $address_fields_value; |
|
| 308 | + } |
|
| 309 | + } |
|
| 310 | + //now handle state and country |
|
| 311 | + $state_obj = $this->state_obj(); |
|
| 312 | + if (! empty($state_obj)) { |
|
| 313 | + $full_address_array[] = $state_obj->name(); |
|
| 314 | + } |
|
| 315 | + $country_obj = $this->country_obj(); |
|
| 316 | + if (! empty($country_obj)) { |
|
| 317 | + $full_address_array[] = $country_obj->name(); |
|
| 318 | + } |
|
| 319 | + //lastly get the xip |
|
| 320 | + $zip_value = $this->zip(); |
|
| 321 | + if (! empty($zip_value)) { |
|
| 322 | + $full_address_array[] = $zip_value; |
|
| 323 | + } |
|
| 324 | + return $full_address_array; |
|
| 325 | + } |
|
| 326 | + |
|
| 327 | + |
|
| 328 | + /** |
|
| 329 | + * get Attendee Address |
|
| 330 | + * |
|
| 331 | + * @return string |
|
| 332 | + */ |
|
| 333 | + public function address() |
|
| 334 | + { |
|
| 335 | + return $this->get('ATT_address'); |
|
| 336 | + } |
|
| 337 | + |
|
| 338 | + |
|
| 339 | + /** |
|
| 340 | + * get Attendee Address2 |
|
| 341 | + * |
|
| 342 | + * @return string |
|
| 343 | + */ |
|
| 344 | + public function address2() |
|
| 345 | + { |
|
| 346 | + return $this->get('ATT_address2'); |
|
| 347 | + } |
|
| 348 | + |
|
| 349 | + |
|
| 350 | + /** |
|
| 351 | + * get Attendee City |
|
| 352 | + * |
|
| 353 | + * @return string |
|
| 354 | + */ |
|
| 355 | + public function city() |
|
| 356 | + { |
|
| 357 | + return $this->get('ATT_city'); |
|
| 358 | + } |
|
| 359 | + |
|
| 360 | + |
|
| 361 | + /** |
|
| 362 | + * get Attendee State ID |
|
| 363 | + * |
|
| 364 | + * @return string |
|
| 365 | + */ |
|
| 366 | + public function state_ID() |
|
| 367 | + { |
|
| 368 | + return $this->get('STA_ID'); |
|
| 369 | + } |
|
| 370 | + |
|
| 371 | + |
|
| 372 | + /** |
|
| 373 | + * @return string |
|
| 374 | + */ |
|
| 375 | + public function state_abbrev() |
|
| 376 | + { |
|
| 377 | + return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : ''; |
|
| 378 | + } |
|
| 379 | + |
|
| 380 | + |
|
| 381 | + /** |
|
| 382 | + * Gets the state set to this attendee |
|
| 383 | + * |
|
| 384 | + * @return EE_State |
|
| 385 | + */ |
|
| 386 | + public function state_obj() |
|
| 387 | + { |
|
| 388 | + return $this->get_first_related('State'); |
|
| 389 | + } |
|
| 390 | + |
|
| 391 | + |
|
| 392 | + /** |
|
| 393 | + * Returns the state's name, otherwise 'Unknown' |
|
| 394 | + * |
|
| 395 | + * @return string |
|
| 396 | + */ |
|
| 397 | + public function state_name() |
|
| 398 | + { |
|
| 399 | + if ($this->state_obj()) { |
|
| 400 | + return $this->state_obj()->name(); |
|
| 401 | + } else { |
|
| 402 | + return ''; |
|
| 403 | + } |
|
| 404 | + } |
|
| 405 | + |
|
| 406 | + |
|
| 407 | + /** |
|
| 408 | + * either displays the state abbreviation or the state name, as determined |
|
| 409 | + * by the "FHEE__EEI_Address__state__use_abbreviation" filter. |
|
| 410 | + * defaults to abbreviation |
|
| 411 | + * |
|
| 412 | + * @return string |
|
| 413 | + */ |
|
| 414 | + public function state() |
|
| 415 | + { |
|
| 416 | + if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) { |
|
| 417 | + return $this->state_abbrev(); |
|
| 418 | + } else { |
|
| 419 | + return $this->state_name(); |
|
| 420 | + } |
|
| 421 | + } |
|
| 422 | + |
|
| 423 | + |
|
| 424 | + /** |
|
| 425 | + * get Attendee Country ISO Code |
|
| 426 | + * |
|
| 427 | + * @return string |
|
| 428 | + */ |
|
| 429 | + public function country_ID() |
|
| 430 | + { |
|
| 431 | + return $this->get('CNT_ISO'); |
|
| 432 | + } |
|
| 433 | + |
|
| 434 | + |
|
| 435 | + /** |
|
| 436 | + * Gets country set for this attendee |
|
| 437 | + * |
|
| 438 | + * @return EE_Country |
|
| 439 | + */ |
|
| 440 | + public function country_obj() |
|
| 441 | + { |
|
| 442 | + return $this->get_first_related('Country'); |
|
| 443 | + } |
|
| 444 | + |
|
| 445 | + |
|
| 446 | + /** |
|
| 447 | + * Returns the country's name if known, otherwise 'Unknown' |
|
| 448 | + * |
|
| 449 | + * @return string |
|
| 450 | + */ |
|
| 451 | + public function country_name() |
|
| 452 | + { |
|
| 453 | + if ($this->country_obj()) { |
|
| 454 | + return $this->country_obj()->name(); |
|
| 455 | + } else { |
|
| 456 | + return ''; |
|
| 457 | + } |
|
| 458 | + } |
|
| 459 | + |
|
| 460 | + |
|
| 461 | + /** |
|
| 462 | + * either displays the country ISO2 code or the country name, as determined |
|
| 463 | + * by the "FHEE__EEI_Address__country__use_abbreviation" filter. |
|
| 464 | + * defaults to abbreviation |
|
| 465 | + * |
|
| 466 | + * @return string |
|
| 467 | + */ |
|
| 468 | + public function country() |
|
| 469 | + { |
|
| 470 | + if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) { |
|
| 471 | + return $this->country_ID(); |
|
| 472 | + } else { |
|
| 473 | + return $this->country_name(); |
|
| 474 | + } |
|
| 475 | + } |
|
| 476 | + |
|
| 477 | + |
|
| 478 | + /** |
|
| 479 | + * get Attendee Zip/Postal Code |
|
| 480 | + * |
|
| 481 | + * @return string |
|
| 482 | + */ |
|
| 483 | + public function zip() |
|
| 484 | + { |
|
| 485 | + return $this->get('ATT_zip'); |
|
| 486 | + } |
|
| 487 | + |
|
| 488 | + |
|
| 489 | + /** |
|
| 490 | + * get Attendee Email Address |
|
| 491 | + * |
|
| 492 | + * @return string |
|
| 493 | + */ |
|
| 494 | + public function email() |
|
| 495 | + { |
|
| 496 | + return $this->get('ATT_email'); |
|
| 497 | + } |
|
| 498 | + |
|
| 499 | + |
|
| 500 | + /** |
|
| 501 | + * get Attendee Phone # |
|
| 502 | + * |
|
| 503 | + * @return string |
|
| 504 | + */ |
|
| 505 | + public function phone() |
|
| 506 | + { |
|
| 507 | + return $this->get('ATT_phone'); |
|
| 508 | + } |
|
| 509 | + |
|
| 510 | + |
|
| 511 | + /** |
|
| 512 | + * get deleted |
|
| 513 | + * |
|
| 514 | + * @return bool |
|
| 515 | + */ |
|
| 516 | + public function deleted() |
|
| 517 | + { |
|
| 518 | + return $this->get('ATT_deleted'); |
|
| 519 | + } |
|
| 520 | + |
|
| 521 | + |
|
| 522 | + /** |
|
| 523 | + * Gets registrations of this attendee |
|
| 524 | + * |
|
| 525 | + * @param array $query_params |
|
| 526 | + * @return EE_Registration[] |
|
| 527 | + */ |
|
| 528 | + public function get_registrations($query_params = array()) |
|
| 529 | + { |
|
| 530 | + return $this->get_many_related('Registration', $query_params); |
|
| 531 | + } |
|
| 532 | + |
|
| 533 | + |
|
| 534 | + /** |
|
| 535 | + * Gets the most recent registration of this attendee |
|
| 536 | + * |
|
| 537 | + * @return EE_Registration |
|
| 538 | + */ |
|
| 539 | + public function get_most_recent_registration() |
|
| 540 | + { |
|
| 541 | + return $this->get_first_related('Registration', |
|
| 542 | + array('order_by' => array('REG_date' => 'DESC'))); //null, 'REG_date', 'DESC', '=', 'OBJECT_K'); |
|
| 543 | + } |
|
| 544 | + |
|
| 545 | + |
|
| 546 | + /** |
|
| 547 | + * Gets the most recent registration for this attend at this event |
|
| 548 | + * |
|
| 549 | + * @param int $event_id |
|
| 550 | + * @return EE_Registration |
|
| 551 | + */ |
|
| 552 | + public function get_most_recent_registration_for_event($event_id) |
|
| 553 | + { |
|
| 554 | + return $this->get_first_related('Registration', |
|
| 555 | + array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC')));//, '=', 'OBJECT_K' ); |
|
| 556 | + } |
|
| 557 | + |
|
| 558 | + |
|
| 559 | + /** |
|
| 560 | + * returns any events attached to this attendee ($_Event property); |
|
| 561 | + * |
|
| 562 | + * @return array |
|
| 563 | + */ |
|
| 564 | + public function events() |
|
| 565 | + { |
|
| 566 | + return $this->get_many_related('Event'); |
|
| 567 | + } |
|
| 568 | + |
|
| 569 | + |
|
| 570 | + /** |
|
| 571 | + * Gets the billing info array where keys match espresso_reg_page_billing_inputs(), |
|
| 572 | + * and keys are their cleaned values. @see EE_Attendee::save_and_clean_billing_info_for_payment_method() which was |
|
| 573 | + * used to save the billing info |
|
| 574 | + * |
|
| 575 | + * @param EE_Payment_Method $payment_method the _gateway_name property on the gateway class |
|
| 576 | + * @return EE_Form_Section_Proper|null |
|
| 577 | + */ |
|
| 578 | + public function billing_info_for_payment_method($payment_method) |
|
| 579 | + { |
|
| 580 | + $pm_type = $payment_method->type_obj(); |
|
| 581 | + if (! $pm_type instanceof EE_PMT_Base) { |
|
| 582 | + return null; |
|
| 583 | + } |
|
| 584 | + $billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true); |
|
| 585 | + if (! $billing_info) { |
|
| 586 | + return null; |
|
| 587 | + } |
|
| 588 | + $billing_form = $pm_type->billing_form(); |
|
| 589 | + if ($billing_form instanceof EE_Form_Section_Proper) { |
|
| 590 | + $billing_form->receive_form_submission(array($billing_form->name() => $billing_info), false); |
|
| 591 | + } |
|
| 592 | + return $billing_form; |
|
| 593 | + } |
|
| 594 | + |
|
| 595 | + |
|
| 596 | + /** |
|
| 597 | + * Gets the postmeta key that holds this attendee's billing info for the |
|
| 598 | + * specified payment method |
|
| 599 | + * |
|
| 600 | + * @param EE_Payment_Method $payment_method |
|
| 601 | + * @return string |
|
| 602 | + */ |
|
| 603 | + public function get_billing_info_postmeta_name($payment_method) |
|
| 604 | + { |
|
| 605 | + if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
|
| 606 | + return 'billing_info_' . $payment_method->type_obj()->system_name(); |
|
| 607 | + } else { |
|
| 608 | + return null; |
|
| 609 | + } |
|
| 610 | + } |
|
| 611 | + |
|
| 612 | + |
|
| 613 | + /** |
|
| 614 | + * Saves the billing info to the attendee. @see EE_Attendee::billing_info_for_payment_method() which is used to |
|
| 615 | + * retrieve it |
|
| 616 | + * |
|
| 617 | + * @param EE_Billing_Attendee_Info_Form $billing_form |
|
| 618 | + * @param EE_Payment_Method $payment_method |
|
| 619 | + * @return boolean |
|
| 620 | + */ |
|
| 621 | + public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method) |
|
| 622 | + { |
|
| 623 | + if (! $billing_form instanceof EE_Billing_Attendee_Info_Form) { |
|
| 624 | + EE_Error::add_error(__('Cannot save billing info because there is none.', 'event_espresso')); |
|
| 625 | + return false; |
|
| 626 | + } |
|
| 627 | + $billing_form->clean_sensitive_data(); |
|
| 628 | + return update_post_meta($this->ID(), $this->get_billing_info_postmeta_name($payment_method), |
|
| 629 | + $billing_form->input_values(true)); |
|
| 630 | + } |
|
| 631 | + |
|
| 632 | + |
|
| 633 | + /** |
|
| 634 | + * Return the link to the admin details for the object. |
|
| 635 | + * |
|
| 636 | + * @return string |
|
| 637 | + */ |
|
| 638 | + public function get_admin_details_link() |
|
| 639 | + { |
|
| 640 | + return $this->get_admin_edit_link(); |
|
| 641 | + } |
|
| 642 | + |
|
| 643 | + |
|
| 644 | + /** |
|
| 645 | + * Returns the link to the editor for the object. Sometimes this is the same as the details. |
|
| 646 | + * |
|
| 647 | + * @return string |
|
| 648 | + */ |
|
| 649 | + public function get_admin_edit_link() |
|
| 650 | + { |
|
| 651 | + EE_Registry::instance()->load_helper('URL'); |
|
| 652 | + return EEH_URL::add_query_args_and_nonce( |
|
| 653 | + array( |
|
| 654 | + 'page' => 'espresso_registrations', |
|
| 655 | + 'action' => 'edit_attendee', |
|
| 656 | + 'post' => $this->ID(), |
|
| 657 | + ), |
|
| 658 | + admin_url('admin.php') |
|
| 659 | + ); |
|
| 660 | + } |
|
| 661 | + |
|
| 662 | + |
|
| 663 | + /** |
|
| 664 | + * Returns the link to a settings page for the object. |
|
| 665 | + * |
|
| 666 | + * @return string |
|
| 667 | + */ |
|
| 668 | + public function get_admin_settings_link() |
|
| 669 | + { |
|
| 670 | + return $this->get_admin_edit_link(); |
|
| 671 | + } |
|
| 672 | + |
|
| 673 | + |
|
| 674 | + /** |
|
| 675 | + * Returns the link to the "overview" for the object (typically the "list table" view). |
|
| 676 | + * |
|
| 677 | + * @return string |
|
| 678 | + */ |
|
| 679 | + public function get_admin_overview_link() |
|
| 680 | + { |
|
| 681 | + EE_Registry::instance()->load_helper('URL'); |
|
| 682 | + return EEH_URL::add_query_args_and_nonce( |
|
| 683 | + array( |
|
| 684 | + 'page' => 'espresso_registrations', |
|
| 685 | + 'action' => 'contact_list', |
|
| 686 | + ), |
|
| 687 | + admin_url('admin.php') |
|
| 688 | + ); |
|
| 689 | + } |
|
| 690 | 690 | |
| 691 | 691 | |
| 692 | 692 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
| 2 | - exit('No direct script access allowed'); |
|
| 2 | + exit('No direct script access allowed'); |
|
| 3 | 3 | } |
| 4 | 4 | |
| 5 | 5 | /** |
@@ -13,93 +13,93 @@ discard block |
||
| 13 | 13 | class EE_WP_User extends EE_Base_Class implements EEI_Admin_Links |
| 14 | 14 | { |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * @var WP_User |
|
| 18 | - */ |
|
| 19 | - protected $_wp_user_obj; |
|
| 16 | + /** |
|
| 17 | + * @var WP_User |
|
| 18 | + */ |
|
| 19 | + protected $_wp_user_obj; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @param array $props_n_values |
|
| 23 | - * @return EE_WP_User|mixed |
|
| 24 | - */ |
|
| 25 | - public static function new_instance($props_n_values = array()) |
|
| 26 | - { |
|
| 27 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
| 28 | - return $has_object ? $has_object : new self($props_n_values); |
|
| 29 | - } |
|
| 21 | + /** |
|
| 22 | + * @param array $props_n_values |
|
| 23 | + * @return EE_WP_User|mixed |
|
| 24 | + */ |
|
| 25 | + public static function new_instance($props_n_values = array()) |
|
| 26 | + { |
|
| 27 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
| 28 | + return $has_object ? $has_object : new self($props_n_values); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * @param array $props_n_values |
|
| 34 | - * @return EE_WP_User |
|
| 35 | - */ |
|
| 36 | - public static function new_instance_from_db($props_n_values = array()) |
|
| 37 | - { |
|
| 38 | - return new self($props_n_values, true); |
|
| 39 | - } |
|
| 32 | + /** |
|
| 33 | + * @param array $props_n_values |
|
| 34 | + * @return EE_WP_User |
|
| 35 | + */ |
|
| 36 | + public static function new_instance_from_db($props_n_values = array()) |
|
| 37 | + { |
|
| 38 | + return new self($props_n_values, true); |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * Return a normal WP_User object (caches the object for future calls) |
|
| 43 | - * |
|
| 44 | - * @return WP_User |
|
| 45 | - */ |
|
| 46 | - public function wp_user_obj() |
|
| 47 | - { |
|
| 48 | - if (! $this->_wp_user_obj) { |
|
| 49 | - $this->_wp_user_obj = get_user_by('ID', $this->ID()); |
|
| 50 | - } |
|
| 51 | - return $this->_wp_user_obj; |
|
| 52 | - } |
|
| 41 | + /** |
|
| 42 | + * Return a normal WP_User object (caches the object for future calls) |
|
| 43 | + * |
|
| 44 | + * @return WP_User |
|
| 45 | + */ |
|
| 46 | + public function wp_user_obj() |
|
| 47 | + { |
|
| 48 | + if (! $this->_wp_user_obj) { |
|
| 49 | + $this->_wp_user_obj = get_user_by('ID', $this->ID()); |
|
| 50 | + } |
|
| 51 | + return $this->_wp_user_obj; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Return the link to the admin details for the object. |
|
| 56 | - * |
|
| 57 | - * @return string |
|
| 58 | - */ |
|
| 59 | - public function get_admin_details_link() |
|
| 60 | - { |
|
| 61 | - return $this->get_admin_edit_link(); |
|
| 62 | - } |
|
| 54 | + /** |
|
| 55 | + * Return the link to the admin details for the object. |
|
| 56 | + * |
|
| 57 | + * @return string |
|
| 58 | + */ |
|
| 59 | + public function get_admin_details_link() |
|
| 60 | + { |
|
| 61 | + return $this->get_admin_edit_link(); |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * Returns the link to the editor for the object. Sometimes this is the same as the details. |
|
| 66 | - * |
|
| 67 | - * @return string |
|
| 68 | - */ |
|
| 69 | - public function get_admin_edit_link() |
|
| 70 | - { |
|
| 71 | - return esc_url( |
|
| 72 | - add_query_arg( |
|
| 73 | - 'wp_http_referer', |
|
| 74 | - urlencode( |
|
| 75 | - wp_unslash( |
|
| 76 | - $_SERVER['REQUEST_URI'] |
|
| 77 | - ) |
|
| 78 | - ), |
|
| 79 | - get_edit_user_link($this->ID()) |
|
| 80 | - ) |
|
| 81 | - ); |
|
| 82 | - } |
|
| 64 | + /** |
|
| 65 | + * Returns the link to the editor for the object. Sometimes this is the same as the details. |
|
| 66 | + * |
|
| 67 | + * @return string |
|
| 68 | + */ |
|
| 69 | + public function get_admin_edit_link() |
|
| 70 | + { |
|
| 71 | + return esc_url( |
|
| 72 | + add_query_arg( |
|
| 73 | + 'wp_http_referer', |
|
| 74 | + urlencode( |
|
| 75 | + wp_unslash( |
|
| 76 | + $_SERVER['REQUEST_URI'] |
|
| 77 | + ) |
|
| 78 | + ), |
|
| 79 | + get_edit_user_link($this->ID()) |
|
| 80 | + ) |
|
| 81 | + ); |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * Returns the link to a settings page for the object. |
|
| 86 | - * |
|
| 87 | - * @return string |
|
| 88 | - */ |
|
| 89 | - public function get_admin_settings_link() |
|
| 90 | - { |
|
| 91 | - return $this->get_admin_edit_link(); |
|
| 92 | - } |
|
| 84 | + /** |
|
| 85 | + * Returns the link to a settings page for the object. |
|
| 86 | + * |
|
| 87 | + * @return string |
|
| 88 | + */ |
|
| 89 | + public function get_admin_settings_link() |
|
| 90 | + { |
|
| 91 | + return $this->get_admin_edit_link(); |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * Returns the link to the "overview" for the object (typically the "list table" view). |
|
| 96 | - * |
|
| 97 | - * @return string |
|
| 98 | - */ |
|
| 99 | - public function get_admin_overview_link() |
|
| 100 | - { |
|
| 101 | - return admin_url('users.php'); |
|
| 102 | - } |
|
| 94 | + /** |
|
| 95 | + * Returns the link to the "overview" for the object (typically the "list table" view). |
|
| 96 | + * |
|
| 97 | + * @return string |
|
| 98 | + */ |
|
| 99 | + public function get_admin_overview_link() |
|
| 100 | + { |
|
| 101 | + return admin_url('users.php'); |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | 104 | |
| 105 | 105 | } |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 2 | 2 | exit('No direct script access allowed'); |
| 3 | 3 | } |
| 4 | 4 | |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | public function wp_user_obj() |
| 47 | 47 | { |
| 48 | - if (! $this->_wp_user_obj) { |
|
| 48 | + if ( ! $this->_wp_user_obj) { |
|
| 49 | 49 | $this->_wp_user_obj = get_user_by('ID', $this->ID()); |
| 50 | 50 | } |
| 51 | 51 | return $this->_wp_user_obj; |
@@ -38,217 +38,217 @@ |
||
| 38 | 38 | * @since 4.0 |
| 39 | 39 | */ |
| 40 | 40 | if (function_exists('espresso_version')) { |
| 41 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
| 42 | - /** |
|
| 43 | - * espresso_duplicate_plugin_error |
|
| 44 | - * displays if more than one version of EE is activated at the same time |
|
| 45 | - */ |
|
| 46 | - function espresso_duplicate_plugin_error() |
|
| 47 | - { |
|
| 48 | - ?> |
|
| 41 | + if (! function_exists('espresso_duplicate_plugin_error')) { |
|
| 42 | + /** |
|
| 43 | + * espresso_duplicate_plugin_error |
|
| 44 | + * displays if more than one version of EE is activated at the same time |
|
| 45 | + */ |
|
| 46 | + function espresso_duplicate_plugin_error() |
|
| 47 | + { |
|
| 48 | + ?> |
|
| 49 | 49 | <div class="error"> |
| 50 | 50 | <p> |
| 51 | 51 | <?php |
| 52 | - echo esc_html__( |
|
| 53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
| 54 | - 'event_espresso' |
|
| 55 | - ); ?> |
|
| 52 | + echo esc_html__( |
|
| 53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
| 54 | + 'event_espresso' |
|
| 55 | + ); ?> |
|
| 56 | 56 | </p> |
| 57 | 57 | </div> |
| 58 | 58 | <?php |
| 59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 60 | - } |
|
| 61 | - } |
|
| 62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
| 59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
| 63 | 63 | |
| 64 | 64 | } else { |
| 65 | - define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
| 66 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
| 67 | - /** |
|
| 68 | - * espresso_minimum_php_version_error |
|
| 69 | - * |
|
| 70 | - * @return void |
|
| 71 | - */ |
|
| 72 | - function espresso_minimum_php_version_error() |
|
| 73 | - { |
|
| 74 | - ?> |
|
| 65 | + define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
| 66 | + if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
| 67 | + /** |
|
| 68 | + * espresso_minimum_php_version_error |
|
| 69 | + * |
|
| 70 | + * @return void |
|
| 71 | + */ |
|
| 72 | + function espresso_minimum_php_version_error() |
|
| 73 | + { |
|
| 74 | + ?> |
|
| 75 | 75 | <div class="error"> |
| 76 | 76 | <p> |
| 77 | 77 | <?php |
| 78 | - printf( |
|
| 79 | - esc_html__( |
|
| 80 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
| 81 | - 'event_espresso' |
|
| 82 | - ), |
|
| 83 | - EE_MIN_PHP_VER_REQUIRED, |
|
| 84 | - PHP_VERSION, |
|
| 85 | - '<br/>', |
|
| 86 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
| 87 | - ); |
|
| 88 | - ?> |
|
| 78 | + printf( |
|
| 79 | + esc_html__( |
|
| 80 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
| 81 | + 'event_espresso' |
|
| 82 | + ), |
|
| 83 | + EE_MIN_PHP_VER_REQUIRED, |
|
| 84 | + PHP_VERSION, |
|
| 85 | + '<br/>', |
|
| 86 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
| 87 | + ); |
|
| 88 | + ?> |
|
| 89 | 89 | </p> |
| 90 | 90 | </div> |
| 91 | 91 | <?php |
| 92 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 93 | - } |
|
| 92 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
| 96 | - } else { |
|
| 97 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
| 98 | - /** |
|
| 99 | - * espresso_version |
|
| 100 | - * Returns the plugin version |
|
| 101 | - * |
|
| 102 | - * @return string |
|
| 103 | - */ |
|
| 104 | - function espresso_version() |
|
| 105 | - { |
|
| 106 | - return apply_filters('FHEE__espresso__espresso_version', '4.9.53.rc.004'); |
|
| 107 | - } |
|
| 95 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
| 96 | + } else { |
|
| 97 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
| 98 | + /** |
|
| 99 | + * espresso_version |
|
| 100 | + * Returns the plugin version |
|
| 101 | + * |
|
| 102 | + * @return string |
|
| 103 | + */ |
|
| 104 | + function espresso_version() |
|
| 105 | + { |
|
| 106 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.53.rc.004'); |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - /** |
|
| 110 | - * espresso_plugin_activation |
|
| 111 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
| 112 | - */ |
|
| 113 | - function espresso_plugin_activation() |
|
| 114 | - { |
|
| 115 | - update_option('ee_espresso_activation', true); |
|
| 116 | - } |
|
| 109 | + /** |
|
| 110 | + * espresso_plugin_activation |
|
| 111 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
| 112 | + */ |
|
| 113 | + function espresso_plugin_activation() |
|
| 114 | + { |
|
| 115 | + update_option('ee_espresso_activation', true); |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
| 119 | - /** |
|
| 120 | - * espresso_load_error_handling |
|
| 121 | - * this function loads EE's class for handling exceptions and errors |
|
| 122 | - */ |
|
| 123 | - function espresso_load_error_handling() |
|
| 124 | - { |
|
| 125 | - static $error_handling_loaded = false; |
|
| 126 | - if ($error_handling_loaded) { |
|
| 127 | - return; |
|
| 128 | - } |
|
| 129 | - // load debugging tools |
|
| 130 | - if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
| 131 | - require_once EE_HELPERS . 'EEH_Debug_Tools.helper.php'; |
|
| 132 | - \EEH_Debug_Tools::instance(); |
|
| 133 | - } |
|
| 134 | - // load error handling |
|
| 135 | - if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
| 136 | - require_once EE_CORE . 'EE_Error.core.php'; |
|
| 137 | - } else { |
|
| 138 | - wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
| 139 | - } |
|
| 140 | - $error_handling_loaded = true; |
|
| 141 | - } |
|
| 118 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
| 119 | + /** |
|
| 120 | + * espresso_load_error_handling |
|
| 121 | + * this function loads EE's class for handling exceptions and errors |
|
| 122 | + */ |
|
| 123 | + function espresso_load_error_handling() |
|
| 124 | + { |
|
| 125 | + static $error_handling_loaded = false; |
|
| 126 | + if ($error_handling_loaded) { |
|
| 127 | + return; |
|
| 128 | + } |
|
| 129 | + // load debugging tools |
|
| 130 | + if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
| 131 | + require_once EE_HELPERS . 'EEH_Debug_Tools.helper.php'; |
|
| 132 | + \EEH_Debug_Tools::instance(); |
|
| 133 | + } |
|
| 134 | + // load error handling |
|
| 135 | + if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
| 136 | + require_once EE_CORE . 'EE_Error.core.php'; |
|
| 137 | + } else { |
|
| 138 | + wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
| 139 | + } |
|
| 140 | + $error_handling_loaded = true; |
|
| 141 | + } |
|
| 142 | 142 | |
| 143 | - /** |
|
| 144 | - * espresso_load_required |
|
| 145 | - * given a class name and path, this function will load that file or throw an exception |
|
| 146 | - * |
|
| 147 | - * @param string $classname |
|
| 148 | - * @param string $full_path_to_file |
|
| 149 | - * @throws EE_Error |
|
| 150 | - */ |
|
| 151 | - function espresso_load_required($classname, $full_path_to_file) |
|
| 152 | - { |
|
| 153 | - if (is_readable($full_path_to_file)) { |
|
| 154 | - require_once $full_path_to_file; |
|
| 155 | - } else { |
|
| 156 | - throw new \EE_Error ( |
|
| 157 | - sprintf( |
|
| 158 | - esc_html__( |
|
| 159 | - 'The %s class file could not be located or is not readable due to file permissions.', |
|
| 160 | - 'event_espresso' |
|
| 161 | - ), |
|
| 162 | - $classname |
|
| 163 | - ) |
|
| 164 | - ); |
|
| 165 | - } |
|
| 166 | - } |
|
| 143 | + /** |
|
| 144 | + * espresso_load_required |
|
| 145 | + * given a class name and path, this function will load that file or throw an exception |
|
| 146 | + * |
|
| 147 | + * @param string $classname |
|
| 148 | + * @param string $full_path_to_file |
|
| 149 | + * @throws EE_Error |
|
| 150 | + */ |
|
| 151 | + function espresso_load_required($classname, $full_path_to_file) |
|
| 152 | + { |
|
| 153 | + if (is_readable($full_path_to_file)) { |
|
| 154 | + require_once $full_path_to_file; |
|
| 155 | + } else { |
|
| 156 | + throw new \EE_Error ( |
|
| 157 | + sprintf( |
|
| 158 | + esc_html__( |
|
| 159 | + 'The %s class file could not be located or is not readable due to file permissions.', |
|
| 160 | + 'event_espresso' |
|
| 161 | + ), |
|
| 162 | + $classname |
|
| 163 | + ) |
|
| 164 | + ); |
|
| 165 | + } |
|
| 166 | + } |
|
| 167 | 167 | |
| 168 | - /** |
|
| 169 | - * @since 4.9.27 |
|
| 170 | - * @throws \EE_Error |
|
| 171 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 172 | - * @throws \EventEspresso\core\exceptions\InvalidEntityException |
|
| 173 | - * @throws \EventEspresso\core\exceptions\InvalidIdentifierException |
|
| 174 | - * @throws \EventEspresso\core\exceptions\InvalidClassException |
|
| 175 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 176 | - * @throws \EventEspresso\core\services\container\exceptions\ServiceExistsException |
|
| 177 | - * @throws \EventEspresso\core\services\container\exceptions\ServiceNotFoundException |
|
| 178 | - * @throws \OutOfBoundsException |
|
| 179 | - */ |
|
| 180 | - function bootstrap_espresso() |
|
| 181 | - { |
|
| 182 | - require_once __DIR__ . '/core/espresso_definitions.php'; |
|
| 183 | - try { |
|
| 184 | - espresso_load_error_handling(); |
|
| 185 | - espresso_load_required( |
|
| 186 | - 'EEH_Base', |
|
| 187 | - EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php' |
|
| 188 | - ); |
|
| 189 | - espresso_load_required( |
|
| 190 | - 'EEH_File', |
|
| 191 | - EE_CORE . 'interfaces' . DS . 'EEHI_File.interface.php' |
|
| 192 | - ); |
|
| 193 | - espresso_load_required( |
|
| 194 | - 'EEH_File', |
|
| 195 | - EE_CORE . 'helpers' . DS . 'EEH_File.helper.php' |
|
| 196 | - ); |
|
| 197 | - espresso_load_required( |
|
| 198 | - 'EEH_Array', |
|
| 199 | - EE_CORE . 'helpers' . DS . 'EEH_Array.helper.php' |
|
| 200 | - ); |
|
| 201 | - // instantiate and configure PSR4 autoloader |
|
| 202 | - espresso_load_required( |
|
| 203 | - 'Psr4Autoloader', |
|
| 204 | - EE_CORE . 'Psr4Autoloader.php' |
|
| 205 | - ); |
|
| 206 | - espresso_load_required( |
|
| 207 | - 'EE_Psr4AutoloaderInit', |
|
| 208 | - EE_CORE . 'EE_Psr4AutoloaderInit.core.php' |
|
| 209 | - ); |
|
| 210 | - $AutoloaderInit = new EE_Psr4AutoloaderInit(); |
|
| 211 | - $AutoloaderInit->initializeAutoloader(); |
|
| 212 | - espresso_load_required( |
|
| 213 | - 'EE_Request', |
|
| 214 | - EE_CORE . 'request_stack' . DS . 'EE_Request.core.php' |
|
| 215 | - ); |
|
| 216 | - espresso_load_required( |
|
| 217 | - 'EE_Response', |
|
| 218 | - EE_CORE . 'request_stack' . DS . 'EE_Response.core.php' |
|
| 219 | - ); |
|
| 220 | - espresso_load_required( |
|
| 221 | - 'EE_Bootstrap', |
|
| 222 | - EE_CORE . 'EE_Bootstrap.core.php' |
|
| 223 | - ); |
|
| 224 | - // bootstrap EE and the request stack |
|
| 225 | - new EE_Bootstrap( |
|
| 226 | - new EE_Request($_GET, $_POST, $_COOKIE), |
|
| 227 | - new EE_Response() |
|
| 228 | - ); |
|
| 229 | - } catch (Exception $e) { |
|
| 230 | - require_once EE_CORE . 'exceptions' . DS . 'ExceptionStackTraceDisplay.php'; |
|
| 231 | - new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e); |
|
| 232 | - } |
|
| 233 | - } |
|
| 234 | - bootstrap_espresso(); |
|
| 235 | - } |
|
| 168 | + /** |
|
| 169 | + * @since 4.9.27 |
|
| 170 | + * @throws \EE_Error |
|
| 171 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 172 | + * @throws \EventEspresso\core\exceptions\InvalidEntityException |
|
| 173 | + * @throws \EventEspresso\core\exceptions\InvalidIdentifierException |
|
| 174 | + * @throws \EventEspresso\core\exceptions\InvalidClassException |
|
| 175 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 176 | + * @throws \EventEspresso\core\services\container\exceptions\ServiceExistsException |
|
| 177 | + * @throws \EventEspresso\core\services\container\exceptions\ServiceNotFoundException |
|
| 178 | + * @throws \OutOfBoundsException |
|
| 179 | + */ |
|
| 180 | + function bootstrap_espresso() |
|
| 181 | + { |
|
| 182 | + require_once __DIR__ . '/core/espresso_definitions.php'; |
|
| 183 | + try { |
|
| 184 | + espresso_load_error_handling(); |
|
| 185 | + espresso_load_required( |
|
| 186 | + 'EEH_Base', |
|
| 187 | + EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php' |
|
| 188 | + ); |
|
| 189 | + espresso_load_required( |
|
| 190 | + 'EEH_File', |
|
| 191 | + EE_CORE . 'interfaces' . DS . 'EEHI_File.interface.php' |
|
| 192 | + ); |
|
| 193 | + espresso_load_required( |
|
| 194 | + 'EEH_File', |
|
| 195 | + EE_CORE . 'helpers' . DS . 'EEH_File.helper.php' |
|
| 196 | + ); |
|
| 197 | + espresso_load_required( |
|
| 198 | + 'EEH_Array', |
|
| 199 | + EE_CORE . 'helpers' . DS . 'EEH_Array.helper.php' |
|
| 200 | + ); |
|
| 201 | + // instantiate and configure PSR4 autoloader |
|
| 202 | + espresso_load_required( |
|
| 203 | + 'Psr4Autoloader', |
|
| 204 | + EE_CORE . 'Psr4Autoloader.php' |
|
| 205 | + ); |
|
| 206 | + espresso_load_required( |
|
| 207 | + 'EE_Psr4AutoloaderInit', |
|
| 208 | + EE_CORE . 'EE_Psr4AutoloaderInit.core.php' |
|
| 209 | + ); |
|
| 210 | + $AutoloaderInit = new EE_Psr4AutoloaderInit(); |
|
| 211 | + $AutoloaderInit->initializeAutoloader(); |
|
| 212 | + espresso_load_required( |
|
| 213 | + 'EE_Request', |
|
| 214 | + EE_CORE . 'request_stack' . DS . 'EE_Request.core.php' |
|
| 215 | + ); |
|
| 216 | + espresso_load_required( |
|
| 217 | + 'EE_Response', |
|
| 218 | + EE_CORE . 'request_stack' . DS . 'EE_Response.core.php' |
|
| 219 | + ); |
|
| 220 | + espresso_load_required( |
|
| 221 | + 'EE_Bootstrap', |
|
| 222 | + EE_CORE . 'EE_Bootstrap.core.php' |
|
| 223 | + ); |
|
| 224 | + // bootstrap EE and the request stack |
|
| 225 | + new EE_Bootstrap( |
|
| 226 | + new EE_Request($_GET, $_POST, $_COOKIE), |
|
| 227 | + new EE_Response() |
|
| 228 | + ); |
|
| 229 | + } catch (Exception $e) { |
|
| 230 | + require_once EE_CORE . 'exceptions' . DS . 'ExceptionStackTraceDisplay.php'; |
|
| 231 | + new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e); |
|
| 232 | + } |
|
| 233 | + } |
|
| 234 | + bootstrap_espresso(); |
|
| 235 | + } |
|
| 236 | 236 | } |
| 237 | 237 | if (! function_exists('espresso_deactivate_plugin')) { |
| 238 | - /** |
|
| 239 | - * deactivate_plugin |
|
| 240 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
| 241 | - * |
|
| 242 | - * @access public |
|
| 243 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
| 244 | - * @return void |
|
| 245 | - */ |
|
| 246 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
| 247 | - { |
|
| 248 | - if (! function_exists('deactivate_plugins')) { |
|
| 249 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
| 250 | - } |
|
| 251 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
| 252 | - deactivate_plugins($plugin_basename); |
|
| 253 | - } |
|
| 238 | + /** |
|
| 239 | + * deactivate_plugin |
|
| 240 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
| 241 | + * |
|
| 242 | + * @access public |
|
| 243 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
| 244 | + * @return void |
|
| 245 | + */ |
|
| 246 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
| 247 | + { |
|
| 248 | + if (! function_exists('deactivate_plugins')) { |
|
| 249 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
| 250 | + } |
|
| 251 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
| 252 | + deactivate_plugins($plugin_basename); |
|
| 253 | + } |
|
| 254 | 254 | } |