@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | * @param EE_Line_Item $line_item |
| 74 | 74 | * @param array $options |
| 75 | 75 | * @param EE_Line_Item $parent_line_item |
| 76 | - * @return mixed |
|
| 76 | + * @return string |
|
| 77 | 77 | * @throws EE_Error |
| 78 | 78 | */ |
| 79 | 79 | public function display_line_item( |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | * _event_row - basically a Heading row displayed once above each event's ticket rows |
| 217 | 217 | * |
| 218 | 218 | * @param EE_Line_Item $line_item |
| 219 | - * @return mixed |
|
| 219 | + * @return string |
|
| 220 | 220 | */ |
| 221 | 221 | private function _event_row(EE_Line_Item $line_item) |
| 222 | 222 | { |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | * |
| 243 | 243 | * @param EE_Line_Item $line_item |
| 244 | 244 | * @param array $options |
| 245 | - * @return mixed |
|
| 245 | + * @return string |
|
| 246 | 246 | * @throws EE_Error |
| 247 | 247 | */ |
| 248 | 248 | private function _ticket_row(EE_Line_Item $line_item, $options = array()) |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | * |
| 300 | 300 | * @param EE_Line_Item $line_item |
| 301 | 301 | * @param array $options |
| 302 | - * @return mixed |
|
| 302 | + * @return string |
|
| 303 | 303 | * @throws EE_Error |
| 304 | 304 | */ |
| 305 | 305 | private function _item_row(EE_Line_Item $line_item, $options = array()) |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | * |
| 423 | 423 | * @param EE_Line_Item $line_item |
| 424 | 424 | * @param array $options |
| 425 | - * @return mixed |
|
| 425 | + * @return string |
|
| 426 | 426 | * @throws EE_Error |
| 427 | 427 | */ |
| 428 | 428 | private function _tax_row(EE_Line_Item $line_item, $options = array()) |
@@ -466,7 +466,7 @@ discard block |
||
| 466 | 466 | * |
| 467 | 467 | * @param EE_Line_Item $line_item |
| 468 | 468 | * @param string $text |
| 469 | - * @return mixed |
|
| 469 | + * @return string |
|
| 470 | 470 | * @throws EE_Error |
| 471 | 471 | */ |
| 472 | 472 | private function _total_tax_row(EE_Line_Item $line_item, $text = '') |
@@ -505,7 +505,7 @@ discard block |
||
| 505 | 505 | * @param EE_Line_Item $line_item |
| 506 | 506 | * @param string $text |
| 507 | 507 | * @param array $options |
| 508 | - * @return mixed |
|
| 508 | + * @return string |
|
| 509 | 509 | * @throws EE_Error |
| 510 | 510 | */ |
| 511 | 511 | private function _sub_total_row(EE_Line_Item $line_item, $text = '', $options = array()) |
@@ -541,7 +541,7 @@ discard block |
||
| 541 | 541 | * |
| 542 | 542 | * @param EE_Line_Item $line_item |
| 543 | 543 | * @param string $text |
| 544 | - * @return mixed |
|
| 544 | + * @return string |
|
| 545 | 545 | * @throws EE_Error |
| 546 | 546 | */ |
| 547 | 547 | private function _total_row(EE_Line_Item $line_item, $text = '') |
@@ -568,7 +568,7 @@ discard block |
||
| 568 | 568 | * |
| 569 | 569 | * @param EE_Line_Item $line_item |
| 570 | 570 | * @param array $options |
| 571 | - * @return mixed |
|
| 571 | + * @return string |
|
| 572 | 572 | * @throws EE_Error |
| 573 | 573 | */ |
| 574 | 574 | private function _payments_and_amount_owing_rows(EE_Line_Item $line_item, $options = array()) |
@@ -12,636 +12,636 @@ |
||
| 12 | 12 | class EE_SPCO_Line_Item_Display_Strategy implements EEI_Line_Item_Display |
| 13 | 13 | { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * array of events |
|
| 17 | - * |
|
| 18 | - * @type EE_Line_Item[] $_events |
|
| 19 | - */ |
|
| 20 | - private $_events = array(); |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * whether to display the taxes row or not |
|
| 24 | - * |
|
| 25 | - * @type bool $_show_taxes |
|
| 26 | - */ |
|
| 27 | - private $_show_taxes = false; |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * html for any tax rows |
|
| 31 | - * |
|
| 32 | - * @type string $_show_taxes |
|
| 33 | - */ |
|
| 34 | - private $_taxes_html = ''; |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * total amount including tax we can bill for at this time |
|
| 38 | - * |
|
| 39 | - * @type float $_grand_total |
|
| 40 | - */ |
|
| 41 | - private $_grand_total = 0.00; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * total number of items being billed for |
|
| 45 | - * |
|
| 46 | - * @type int $_total_items |
|
| 47 | - */ |
|
| 48 | - private $_total_items = 0; |
|
| 49 | - |
|
| 50 | - |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * @return float |
|
| 54 | - */ |
|
| 55 | - public function grand_total() |
|
| 56 | - { |
|
| 57 | - return $this->_grand_total; |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * @return int |
|
| 64 | - */ |
|
| 65 | - public function total_items() |
|
| 66 | - { |
|
| 67 | - return $this->_total_items; |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * @param EE_Line_Item $line_item |
|
| 74 | - * @param array $options |
|
| 75 | - * @param EE_Line_Item $parent_line_item |
|
| 76 | - * @return mixed |
|
| 77 | - * @throws EE_Error |
|
| 78 | - */ |
|
| 79 | - public function display_line_item( |
|
| 80 | - EE_Line_Item $line_item, |
|
| 81 | - $options = array(), |
|
| 82 | - EE_Line_Item $parent_line_item = null |
|
| 83 | - ) { |
|
| 84 | - $html = ''; |
|
| 85 | - // set some default options and merge with incoming |
|
| 86 | - $default_options = array( |
|
| 87 | - 'show_desc' => true, // true false |
|
| 88 | - 'odd' => false, |
|
| 89 | - ); |
|
| 90 | - $options = array_merge($default_options, (array) $options); |
|
| 91 | - switch ($line_item->type()) { |
|
| 92 | - case EEM_Line_Item::type_line_item: |
|
| 93 | - $this->_show_taxes = $line_item->is_taxable() ? true : $this->_show_taxes; |
|
| 94 | - if ($line_item->OBJ_type() === 'Ticket') { |
|
| 95 | - // item row |
|
| 96 | - $html .= $this->_ticket_row($line_item, $options); |
|
| 97 | - } else { |
|
| 98 | - // item row |
|
| 99 | - $html .= $this->_item_row($line_item, $options); |
|
| 100 | - } |
|
| 101 | - if (apply_filters( |
|
| 102 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy__display_line_item__display_sub_line_items', |
|
| 103 | - true |
|
| 104 | - ) |
|
| 105 | - ) { |
|
| 106 | - // got any kids? |
|
| 107 | - foreach ($line_item->children() as $child_line_item) { |
|
| 108 | - $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
| 109 | - } |
|
| 110 | - } |
|
| 111 | - break; |
|
| 112 | - case EEM_Line_Item::type_sub_line_item: |
|
| 113 | - $html .= $this->_sub_item_row($line_item, $options, $parent_line_item); |
|
| 114 | - break; |
|
| 115 | - case EEM_Line_Item::type_sub_total: |
|
| 116 | - static $sub_total = 0; |
|
| 117 | - $event_sub_total = 0; |
|
| 118 | - $text = esc_html__('Sub-Total', 'event_espresso'); |
|
| 119 | - if ($line_item->OBJ_type() === 'Event') { |
|
| 120 | - $options['event_id'] = $event_id = $line_item->OBJ_ID(); |
|
| 121 | - if (! isset($this->_events[ $options['event_id'] ])) { |
|
| 122 | - $event = EEM_Event::instance()->get_one_by_ID($options['event_id']); |
|
| 123 | - // if event has default reg status of Not Approved, then don't display info on it |
|
| 124 | - if ($event instanceof EE_Event |
|
| 125 | - && $event->default_registration_status() === EEM_Registration::status_id_not_approved |
|
| 126 | - ) { |
|
| 127 | - $display_event = false; |
|
| 128 | - // unless there are registrations for it that are returning to pay |
|
| 129 | - if (isset($options['registrations']) && is_array($options['registrations'])) { |
|
| 130 | - foreach ($options['registrations'] as $registration) { |
|
| 131 | - if (! $registration instanceof EE_Registration) { |
|
| 132 | - continue; |
|
| 133 | - } |
|
| 134 | - $display_event = $registration->event_ID() === $options['event_id'] |
|
| 135 | - && $registration->status_ID() !== EEM_Registration::status_id_not_approved |
|
| 136 | - ? true |
|
| 137 | - : $display_event; |
|
| 138 | - } |
|
| 139 | - } |
|
| 140 | - if (! $display_event) { |
|
| 141 | - return ''; |
|
| 142 | - } |
|
| 143 | - } |
|
| 144 | - $this->_events[ $options['event_id'] ] = 0; |
|
| 145 | - $html .= $this->_event_row($line_item); |
|
| 146 | - $text = esc_html__('Event Sub-Total', 'event_espresso'); |
|
| 147 | - } |
|
| 148 | - } |
|
| 149 | - $child_line_items = $line_item->children(); |
|
| 150 | - // loop thru children |
|
| 151 | - foreach ($child_line_items as $child_line_item) { |
|
| 152 | - // recursively feed children back into this method |
|
| 153 | - $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
| 154 | - } |
|
| 155 | - $event_sub_total += isset($options['event_id']) ? $this->_events[ $options['event_id'] ] : 0; |
|
| 156 | - $sub_total += $event_sub_total; |
|
| 157 | - if (( |
|
| 158 | - // event subtotals |
|
| 159 | - $line_item->code() !== 'pre-tax-subtotal' && count($child_line_items) > 1 |
|
| 160 | - ) |
|
| 161 | - || ( |
|
| 162 | - // pre-tax subtotals |
|
| 163 | - $line_item->code() === 'pre-tax-subtotal' && count($this->_events) > 1 |
|
| 164 | - ) |
|
| 165 | - ) { |
|
| 166 | - $options['sub_total'] = $line_item->OBJ_type() === 'Event' ? $event_sub_total : $sub_total; |
|
| 167 | - $html .= $this->_sub_total_row($line_item, $text, $options); |
|
| 168 | - } |
|
| 169 | - break; |
|
| 170 | - case EEM_Line_Item::type_tax: |
|
| 171 | - if ($this->_show_taxes) { |
|
| 172 | - $this->_taxes_html .= $this->_tax_row($line_item, $options); |
|
| 173 | - } |
|
| 174 | - break; |
|
| 175 | - case EEM_Line_Item::type_tax_sub_total: |
|
| 176 | - if ($this->_show_taxes) { |
|
| 177 | - $child_line_items = $line_item->children(); |
|
| 178 | - // loop thru children |
|
| 179 | - foreach ($child_line_items as $child_line_item) { |
|
| 180 | - // recursively feed children back into this method |
|
| 181 | - $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
| 182 | - } |
|
| 183 | - if (count($child_line_items) > 1) { |
|
| 184 | - $this->_taxes_html .= $this->_total_tax_row($line_item, esc_html__('Tax Total', 'event_espresso')); |
|
| 185 | - } |
|
| 186 | - } |
|
| 187 | - break; |
|
| 188 | - case EEM_Line_Item::type_total: |
|
| 189 | - // get all child line items |
|
| 190 | - $children = $line_item->children(); |
|
| 191 | - // loop thru all non-tax child line items |
|
| 192 | - foreach ($children as $child_line_item) { |
|
| 193 | - if ($child_line_item->type() !== EEM_Line_Item::type_tax_sub_total) { |
|
| 194 | - // recursively feed children back into this method |
|
| 195 | - $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
| 196 | - } |
|
| 197 | - } |
|
| 198 | - // now loop thru tax child line items |
|
| 199 | - foreach ($children as $child_line_item) { |
|
| 200 | - if ($child_line_item->type() === EEM_Line_Item::type_tax_sub_total) { |
|
| 201 | - // recursively feed children back into this method |
|
| 202 | - $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
| 203 | - } |
|
| 204 | - } |
|
| 205 | - $html .= $this->_taxes_html; |
|
| 206 | - $html .= $this->_total_row($line_item, esc_html__('Total', 'event_espresso')); |
|
| 207 | - $html .= $this->_payments_and_amount_owing_rows($line_item, $options); |
|
| 208 | - break; |
|
| 209 | - } |
|
| 210 | - return $html; |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - |
|
| 214 | - |
|
| 215 | - /** |
|
| 216 | - * _event_row - basically a Heading row displayed once above each event's ticket rows |
|
| 217 | - * |
|
| 218 | - * @param EE_Line_Item $line_item |
|
| 219 | - * @return mixed |
|
| 220 | - */ |
|
| 221 | - private function _event_row(EE_Line_Item $line_item) |
|
| 222 | - { |
|
| 223 | - // start of row |
|
| 224 | - $html = EEH_HTML::tr('', 'event-cart-total-row', 'total_tr odd'); |
|
| 225 | - // event name td |
|
| 226 | - $html .= EEH_HTML::td( |
|
| 227 | - EEH_HTML::strong($line_item->name()), |
|
| 228 | - '', |
|
| 229 | - 'event-header', |
|
| 230 | - '', |
|
| 231 | - ' colspan="4"' |
|
| 232 | - ); |
|
| 233 | - // end of row |
|
| 234 | - $html .= EEH_HTML::trx(); |
|
| 235 | - return $html; |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - |
|
| 239 | - |
|
| 240 | - /** |
|
| 241 | - * _ticket_row |
|
| 242 | - * |
|
| 243 | - * @param EE_Line_Item $line_item |
|
| 244 | - * @param array $options |
|
| 245 | - * @return mixed |
|
| 246 | - * @throws EE_Error |
|
| 247 | - */ |
|
| 248 | - private function _ticket_row(EE_Line_Item $line_item, $options = array()) |
|
| 249 | - { |
|
| 250 | - // start of row |
|
| 251 | - $row_class = $options['odd'] ? 'item odd' : 'item'; |
|
| 252 | - $html = EEH_HTML::tr('', '', $row_class); |
|
| 253 | - // name && desc |
|
| 254 | - $name_and_desc = apply_filters( |
|
| 255 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', |
|
| 256 | - $line_item->name(), |
|
| 257 | - $line_item |
|
| 258 | - ); |
|
| 259 | - $name_and_desc .= apply_filters( |
|
| 260 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
|
| 261 | - ( |
|
| 262 | - $options['show_desc'] |
|
| 263 | - ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' |
|
| 264 | - : '' |
|
| 265 | - ), |
|
| 266 | - $line_item, |
|
| 267 | - $options |
|
| 268 | - ); |
|
| 269 | - $name_and_desc .= $line_item->is_taxable() ? ' * ' : ''; |
|
| 270 | - // name td |
|
| 271 | - $html .= EEH_HTML::td( /*__FUNCTION__ .*/ |
|
| 272 | - $name_and_desc, |
|
| 273 | - '', |
|
| 274 | - 'item_l' |
|
| 275 | - ); |
|
| 276 | - // price td |
|
| 277 | - $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
| 278 | - // quantity td |
|
| 279 | - $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght'); |
|
| 280 | - $this->_total_items += $line_item->quantity(); |
|
| 281 | - // determine total for line item |
|
| 282 | - $total = $line_item->total(); |
|
| 283 | - $this->_events[ $options['event_id'] ] += $total; |
|
| 284 | - // total td |
|
| 285 | - $html .= EEH_HTML::td( |
|
| 286 | - EEH_Template::format_currency($total, false, false), |
|
| 287 | - '', |
|
| 288 | - 'item_r jst-rght' |
|
| 289 | - ); |
|
| 290 | - // end of row |
|
| 291 | - $html .= EEH_HTML::trx(); |
|
| 292 | - return $html; |
|
| 293 | - } |
|
| 294 | - |
|
| 295 | - |
|
| 296 | - |
|
| 297 | - /** |
|
| 298 | - * _item_row |
|
| 299 | - * |
|
| 300 | - * @param EE_Line_Item $line_item |
|
| 301 | - * @param array $options |
|
| 302 | - * @return mixed |
|
| 303 | - * @throws EE_Error |
|
| 304 | - */ |
|
| 305 | - private function _item_row(EE_Line_Item $line_item, $options = array()) |
|
| 306 | - { |
|
| 307 | - // start of row |
|
| 308 | - $row_class = $options['odd'] ? 'item odd' : 'item'; |
|
| 309 | - $html = EEH_HTML::tr('', '', $row_class); |
|
| 310 | - $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() . ': ' : ''; |
|
| 311 | - // name && desc |
|
| 312 | - $name_and_desc = apply_filters( |
|
| 313 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', |
|
| 314 | - $obj_name . $line_item->name(), |
|
| 315 | - $line_item |
|
| 316 | - ); |
|
| 317 | - $name_and_desc .= apply_filters( |
|
| 318 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
|
| 319 | - ( |
|
| 320 | - $options['show_desc'] |
|
| 321 | - ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' |
|
| 322 | - : '' |
|
| 323 | - ), |
|
| 324 | - $line_item, |
|
| 325 | - $options |
|
| 326 | - ); |
|
| 327 | - $name_and_desc .= $line_item->is_taxable() ? ' * ' : ''; |
|
| 328 | - // name td |
|
| 329 | - $html .= EEH_HTML::td($name_and_desc, '', 'item_l'); |
|
| 330 | - // price td |
|
| 331 | - if ($line_item->is_percent()) { |
|
| 332 | - $html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c jst-rght'); |
|
| 333 | - } else { |
|
| 334 | - $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
| 335 | - } |
|
| 336 | - // quantity td |
|
| 337 | - $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght'); |
|
| 338 | - // $total = $line_item->total() * $line_item->quantity(); |
|
| 339 | - $total = $line_item->total(); |
|
| 340 | - if (isset($options['event_id'], $this->_events[ $options['event_id'] ])) { |
|
| 341 | - $this->_events[ $options['event_id'] ] += $total; |
|
| 342 | - } |
|
| 343 | - // total td |
|
| 344 | - $html .= EEH_HTML::td( |
|
| 345 | - EEH_Template::format_currency($total, false, false), |
|
| 346 | - '', |
|
| 347 | - 'item_r jst-rght' |
|
| 348 | - ); |
|
| 349 | - // end of row |
|
| 350 | - $html .= EEH_HTML::trx(); |
|
| 351 | - return $html; |
|
| 352 | - } |
|
| 353 | - |
|
| 354 | - |
|
| 355 | - |
|
| 356 | - /** |
|
| 357 | - * _sub_item_row |
|
| 358 | - * |
|
| 359 | - * @param EE_Line_Item $line_item |
|
| 360 | - * @param array $options |
|
| 361 | - * @param EE_Line_Item $parent_line_item |
|
| 362 | - * @return mixed |
|
| 363 | - * @throws EE_Error |
|
| 364 | - */ |
|
| 365 | - private function _sub_item_row(EE_Line_Item $line_item, $options = array(), EE_Line_Item $parent_line_item = null) |
|
| 366 | - { |
|
| 367 | - if ($parent_line_item instanceof EE_Line_Item |
|
| 368 | - && $line_item->children() === array() |
|
| 369 | - && $line_item->name() === $parent_line_item->name() |
|
| 370 | - && apply_filters( |
|
| 371 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy___sub_item_row__hide_main_sub_line_item', |
|
| 372 | - true |
|
| 373 | - ) |
|
| 374 | - ) { |
|
| 375 | - return ''; |
|
| 376 | - } |
|
| 377 | - // start of row |
|
| 378 | - $html = EEH_HTML::tr('', '', 'item sub-item-row'); |
|
| 379 | - // name && desc |
|
| 380 | - $name_and_desc = EEH_HTML::span('', '', 'sub-item-row-bullet dashicons dashicons-arrow-right') |
|
| 381 | - . $line_item->name(); |
|
| 382 | - $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: ' |
|
| 383 | - . $line_item->desc() |
|
| 384 | - . '</span>' : ''; |
|
| 385 | - // name td |
|
| 386 | - $html .= EEH_HTML::td($name_and_desc, '', 'item_l sub-item'); |
|
| 387 | - $qty = $parent_line_item instanceof EE_Line_Item ? $parent_line_item->quantity() : 1; |
|
| 388 | - // discount/surcharge td |
|
| 389 | - if ($line_item->is_percent()) { |
|
| 390 | - $html .= EEH_HTML::td( |
|
| 391 | - EEH_Template::format_currency( |
|
| 392 | - $line_item->total() / $qty, |
|
| 393 | - false, |
|
| 394 | - false |
|
| 395 | - ), |
|
| 396 | - '', |
|
| 397 | - 'item_c jst-rght' |
|
| 398 | - ); |
|
| 399 | - } else { |
|
| 400 | - $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
| 401 | - } |
|
| 402 | - // no quantity td |
|
| 403 | - $html .= EEH_HTML::td(); |
|
| 404 | - // no total td |
|
| 405 | - $html .= EEH_HTML::td(); |
|
| 406 | - // end of row |
|
| 407 | - $html .= EEH_HTML::trx(); |
|
| 408 | - $html = apply_filters( |
|
| 409 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy___sub_item_row__html', |
|
| 410 | - $html, |
|
| 411 | - $line_item, |
|
| 412 | - $options, |
|
| 413 | - $parent_line_item |
|
| 414 | - ); |
|
| 415 | - return $html; |
|
| 416 | - } |
|
| 417 | - |
|
| 418 | - |
|
| 419 | - |
|
| 420 | - /** |
|
| 421 | - * _tax_row |
|
| 422 | - * |
|
| 423 | - * @param EE_Line_Item $line_item |
|
| 424 | - * @param array $options |
|
| 425 | - * @return mixed |
|
| 426 | - * @throws EE_Error |
|
| 427 | - */ |
|
| 428 | - private function _tax_row(EE_Line_Item $line_item, $options = array()) |
|
| 429 | - { |
|
| 430 | - // start of row |
|
| 431 | - $html = EEH_HTML::tr('', 'item sub-item tax-total'); |
|
| 432 | - // name && desc |
|
| 433 | - $name_and_desc = $line_item->name(); |
|
| 434 | - $name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">' |
|
| 435 | - . esc_html__(' * taxable items', 'event_espresso') . '</span>'; |
|
| 436 | - $name_and_desc .= $options['show_desc'] ? '<br/>' . $line_item->desc() : ''; |
|
| 437 | - // name td |
|
| 438 | - $html .= EEH_HTML::td( /*__FUNCTION__ .*/ |
|
| 439 | - $name_and_desc, |
|
| 440 | - '', |
|
| 441 | - 'item_l sub-item' |
|
| 442 | - ); |
|
| 443 | - // percent td |
|
| 444 | - $html .= EEH_HTML::td($line_item->percent() . '%', '', ' jst-rght', ''); |
|
| 445 | - // empty td (price) |
|
| 446 | - $html .= EEH_HTML::td(EEH_HTML::nbsp()); |
|
| 447 | - // total td |
|
| 448 | - $html .= EEH_HTML::td( |
|
| 449 | - EEH_Template::format_currency( |
|
| 450 | - $line_item->total(), |
|
| 451 | - false, |
|
| 452 | - false |
|
| 453 | - ), |
|
| 454 | - '', |
|
| 455 | - 'item_r jst-rght' |
|
| 456 | - ); |
|
| 457 | - // end of row |
|
| 458 | - $html .= EEH_HTML::trx(); |
|
| 459 | - return $html; |
|
| 460 | - } |
|
| 461 | - |
|
| 462 | - |
|
| 463 | - |
|
| 464 | - /** |
|
| 465 | - * _total_row |
|
| 466 | - * |
|
| 467 | - * @param EE_Line_Item $line_item |
|
| 468 | - * @param string $text |
|
| 469 | - * @return mixed |
|
| 470 | - * @throws EE_Error |
|
| 471 | - */ |
|
| 472 | - private function _total_tax_row(EE_Line_Item $line_item, $text = '') |
|
| 473 | - { |
|
| 474 | - $html = ''; |
|
| 475 | - if ($line_item->total()) { |
|
| 476 | - // start of row |
|
| 477 | - $html = EEH_HTML::tr('', '', 'total_tr odd'); |
|
| 478 | - // total td |
|
| 479 | - $html .= EEH_HTML::td( |
|
| 480 | - $text, |
|
| 481 | - '', |
|
| 482 | - 'total_currency total jst-rght', |
|
| 483 | - '', |
|
| 484 | - ' colspan="2"' |
|
| 485 | - ); |
|
| 486 | - // empty td (price) |
|
| 487 | - $html .= EEH_HTML::td(EEH_HTML::nbsp()); |
|
| 488 | - // total td |
|
| 489 | - $html .= EEH_HTML::td( |
|
| 490 | - EEH_Template::format_currency($line_item->total(), false, false), |
|
| 491 | - '', |
|
| 492 | - 'total jst-rght' |
|
| 493 | - ); |
|
| 494 | - // end of row |
|
| 495 | - $html .= EEH_HTML::trx(); |
|
| 496 | - } |
|
| 497 | - return $html; |
|
| 498 | - } |
|
| 499 | - |
|
| 500 | - |
|
| 501 | - |
|
| 502 | - /** |
|
| 503 | - * _total_row |
|
| 504 | - * |
|
| 505 | - * @param EE_Line_Item $line_item |
|
| 506 | - * @param string $text |
|
| 507 | - * @param array $options |
|
| 508 | - * @return mixed |
|
| 509 | - * @throws EE_Error |
|
| 510 | - */ |
|
| 511 | - private function _sub_total_row(EE_Line_Item $line_item, $text = '', $options = array()) |
|
| 512 | - { |
|
| 513 | - $html = ''; |
|
| 514 | - if ($line_item->total()) { |
|
| 515 | - // start of row |
|
| 516 | - $html = EEH_HTML::tr('', '', 'total_tr odd'); |
|
| 517 | - // total td |
|
| 518 | - $html .= EEH_HTML::td( |
|
| 519 | - $text, |
|
| 520 | - '', |
|
| 521 | - 'total_currency total jst-rght', |
|
| 522 | - '', |
|
| 523 | - ' colspan="3"' |
|
| 524 | - ); |
|
| 525 | - // total td |
|
| 526 | - $html .= EEH_HTML::td( |
|
| 527 | - EEH_Template::format_currency($options['sub_total'], false, false), |
|
| 528 | - '', |
|
| 529 | - 'total jst-rght' |
|
| 530 | - ); |
|
| 531 | - // end of row |
|
| 532 | - $html .= EEH_HTML::trx(); |
|
| 533 | - } |
|
| 534 | - return $html; |
|
| 535 | - } |
|
| 536 | - |
|
| 537 | - |
|
| 538 | - |
|
| 539 | - /** |
|
| 540 | - * _total_row |
|
| 541 | - * |
|
| 542 | - * @param EE_Line_Item $line_item |
|
| 543 | - * @param string $text |
|
| 544 | - * @return mixed |
|
| 545 | - * @throws EE_Error |
|
| 546 | - */ |
|
| 547 | - private function _total_row(EE_Line_Item $line_item, $text = '') |
|
| 548 | - { |
|
| 549 | - // start of row |
|
| 550 | - $html = EEH_HTML::tr('', '', 'spco-grand-total total_tr odd'); |
|
| 551 | - // total td |
|
| 552 | - $html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="3"'); |
|
| 553 | - // total td |
|
| 554 | - $html .= EEH_HTML::td( |
|
| 555 | - EEH_Template::format_currency($line_item->total(), false, false), |
|
| 556 | - '', |
|
| 557 | - 'total jst-rght' |
|
| 558 | - ); |
|
| 559 | - // end of row |
|
| 560 | - $html .= EEH_HTML::trx(); |
|
| 561 | - return $html; |
|
| 562 | - } |
|
| 563 | - |
|
| 564 | - |
|
| 565 | - |
|
| 566 | - /** |
|
| 567 | - * _payments_and_amount_owing_rows |
|
| 568 | - * |
|
| 569 | - * @param EE_Line_Item $line_item |
|
| 570 | - * @param array $options |
|
| 571 | - * @return mixed |
|
| 572 | - * @throws EE_Error |
|
| 573 | - */ |
|
| 574 | - private function _payments_and_amount_owing_rows(EE_Line_Item $line_item, $options = array()) |
|
| 575 | - { |
|
| 576 | - $html = ''; |
|
| 577 | - $owing = $line_item->total(); |
|
| 578 | - $transaction = EEM_Transaction::instance()->get_one_by_ID($line_item->TXN_ID()); |
|
| 579 | - if ($transaction instanceof EE_Transaction) { |
|
| 580 | - $registration_payments = array(); |
|
| 581 | - $registrations = ! empty($options['registrations']) |
|
| 582 | - ? $options['registrations'] |
|
| 583 | - : $transaction->registrations(); |
|
| 584 | - foreach ($registrations as $registration) { |
|
| 585 | - if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) { |
|
| 586 | - $registration_payments += $registration->registration_payments(); |
|
| 587 | - } |
|
| 588 | - } |
|
| 589 | - if (! empty($registration_payments)) { |
|
| 590 | - foreach ($registration_payments as $registration_payment) { |
|
| 591 | - if ($registration_payment instanceof EE_Registration_Payment) { |
|
| 592 | - $owing -= $registration_payment->amount(); |
|
| 593 | - $payment = $registration_payment->payment(); |
|
| 594 | - $payment_desc = ''; |
|
| 595 | - if ($payment instanceof EE_Payment) { |
|
| 596 | - $payment_desc = sprintf( |
|
| 597 | - esc_html__('Payment%1$s Received: %2$s', 'event_espresso'), |
|
| 598 | - $payment->txn_id_chq_nmbr() !== '' |
|
| 599 | - ? ' <span class="small-text">(#' . $payment->txn_id_chq_nmbr() . ')</span> ' |
|
| 600 | - : '', |
|
| 601 | - $payment->timestamp() |
|
| 602 | - ); |
|
| 603 | - } |
|
| 604 | - // start of row |
|
| 605 | - $html .= EEH_HTML::tr('', '', 'total_tr odd'); |
|
| 606 | - // payment desc |
|
| 607 | - $html .= EEH_HTML::td($payment_desc, '', '', '', ' colspan="3"'); |
|
| 608 | - // total td |
|
| 609 | - $html .= EEH_HTML::td( |
|
| 610 | - EEH_Template::format_currency( |
|
| 611 | - $registration_payment->amount(), |
|
| 612 | - false, |
|
| 613 | - false |
|
| 614 | - ), |
|
| 615 | - '', |
|
| 616 | - 'total jst-rght' |
|
| 617 | - ); |
|
| 618 | - // end of row |
|
| 619 | - $html .= EEH_HTML::trx(); |
|
| 620 | - } |
|
| 621 | - } |
|
| 622 | - if ($line_item->total()) { |
|
| 623 | - // start of row |
|
| 624 | - $html .= EEH_HTML::tr('', '', 'total_tr odd'); |
|
| 625 | - // total td |
|
| 626 | - $html .= EEH_HTML::td( |
|
| 627 | - esc_html__('Amount Owing', 'event_espresso'), |
|
| 628 | - '', |
|
| 629 | - 'total_currency total jst-rght', |
|
| 630 | - '', |
|
| 631 | - ' colspan="3"' |
|
| 632 | - ); |
|
| 633 | - // total td |
|
| 634 | - $html .= EEH_HTML::td( |
|
| 635 | - EEH_Template::format_currency($owing, false, false), |
|
| 636 | - '', |
|
| 637 | - 'total jst-rght' |
|
| 638 | - ); |
|
| 639 | - // end of row |
|
| 640 | - $html .= EEH_HTML::trx(); |
|
| 641 | - } |
|
| 642 | - } |
|
| 643 | - } |
|
| 644 | - $this->_grand_total = $owing; |
|
| 645 | - return $html; |
|
| 646 | - } |
|
| 15 | + /** |
|
| 16 | + * array of events |
|
| 17 | + * |
|
| 18 | + * @type EE_Line_Item[] $_events |
|
| 19 | + */ |
|
| 20 | + private $_events = array(); |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * whether to display the taxes row or not |
|
| 24 | + * |
|
| 25 | + * @type bool $_show_taxes |
|
| 26 | + */ |
|
| 27 | + private $_show_taxes = false; |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * html for any tax rows |
|
| 31 | + * |
|
| 32 | + * @type string $_show_taxes |
|
| 33 | + */ |
|
| 34 | + private $_taxes_html = ''; |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * total amount including tax we can bill for at this time |
|
| 38 | + * |
|
| 39 | + * @type float $_grand_total |
|
| 40 | + */ |
|
| 41 | + private $_grand_total = 0.00; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * total number of items being billed for |
|
| 45 | + * |
|
| 46 | + * @type int $_total_items |
|
| 47 | + */ |
|
| 48 | + private $_total_items = 0; |
|
| 49 | + |
|
| 50 | + |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * @return float |
|
| 54 | + */ |
|
| 55 | + public function grand_total() |
|
| 56 | + { |
|
| 57 | + return $this->_grand_total; |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * @return int |
|
| 64 | + */ |
|
| 65 | + public function total_items() |
|
| 66 | + { |
|
| 67 | + return $this->_total_items; |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * @param EE_Line_Item $line_item |
|
| 74 | + * @param array $options |
|
| 75 | + * @param EE_Line_Item $parent_line_item |
|
| 76 | + * @return mixed |
|
| 77 | + * @throws EE_Error |
|
| 78 | + */ |
|
| 79 | + public function display_line_item( |
|
| 80 | + EE_Line_Item $line_item, |
|
| 81 | + $options = array(), |
|
| 82 | + EE_Line_Item $parent_line_item = null |
|
| 83 | + ) { |
|
| 84 | + $html = ''; |
|
| 85 | + // set some default options and merge with incoming |
|
| 86 | + $default_options = array( |
|
| 87 | + 'show_desc' => true, // true false |
|
| 88 | + 'odd' => false, |
|
| 89 | + ); |
|
| 90 | + $options = array_merge($default_options, (array) $options); |
|
| 91 | + switch ($line_item->type()) { |
|
| 92 | + case EEM_Line_Item::type_line_item: |
|
| 93 | + $this->_show_taxes = $line_item->is_taxable() ? true : $this->_show_taxes; |
|
| 94 | + if ($line_item->OBJ_type() === 'Ticket') { |
|
| 95 | + // item row |
|
| 96 | + $html .= $this->_ticket_row($line_item, $options); |
|
| 97 | + } else { |
|
| 98 | + // item row |
|
| 99 | + $html .= $this->_item_row($line_item, $options); |
|
| 100 | + } |
|
| 101 | + if (apply_filters( |
|
| 102 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy__display_line_item__display_sub_line_items', |
|
| 103 | + true |
|
| 104 | + ) |
|
| 105 | + ) { |
|
| 106 | + // got any kids? |
|
| 107 | + foreach ($line_item->children() as $child_line_item) { |
|
| 108 | + $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
| 109 | + } |
|
| 110 | + } |
|
| 111 | + break; |
|
| 112 | + case EEM_Line_Item::type_sub_line_item: |
|
| 113 | + $html .= $this->_sub_item_row($line_item, $options, $parent_line_item); |
|
| 114 | + break; |
|
| 115 | + case EEM_Line_Item::type_sub_total: |
|
| 116 | + static $sub_total = 0; |
|
| 117 | + $event_sub_total = 0; |
|
| 118 | + $text = esc_html__('Sub-Total', 'event_espresso'); |
|
| 119 | + if ($line_item->OBJ_type() === 'Event') { |
|
| 120 | + $options['event_id'] = $event_id = $line_item->OBJ_ID(); |
|
| 121 | + if (! isset($this->_events[ $options['event_id'] ])) { |
|
| 122 | + $event = EEM_Event::instance()->get_one_by_ID($options['event_id']); |
|
| 123 | + // if event has default reg status of Not Approved, then don't display info on it |
|
| 124 | + if ($event instanceof EE_Event |
|
| 125 | + && $event->default_registration_status() === EEM_Registration::status_id_not_approved |
|
| 126 | + ) { |
|
| 127 | + $display_event = false; |
|
| 128 | + // unless there are registrations for it that are returning to pay |
|
| 129 | + if (isset($options['registrations']) && is_array($options['registrations'])) { |
|
| 130 | + foreach ($options['registrations'] as $registration) { |
|
| 131 | + if (! $registration instanceof EE_Registration) { |
|
| 132 | + continue; |
|
| 133 | + } |
|
| 134 | + $display_event = $registration->event_ID() === $options['event_id'] |
|
| 135 | + && $registration->status_ID() !== EEM_Registration::status_id_not_approved |
|
| 136 | + ? true |
|
| 137 | + : $display_event; |
|
| 138 | + } |
|
| 139 | + } |
|
| 140 | + if (! $display_event) { |
|
| 141 | + return ''; |
|
| 142 | + } |
|
| 143 | + } |
|
| 144 | + $this->_events[ $options['event_id'] ] = 0; |
|
| 145 | + $html .= $this->_event_row($line_item); |
|
| 146 | + $text = esc_html__('Event Sub-Total', 'event_espresso'); |
|
| 147 | + } |
|
| 148 | + } |
|
| 149 | + $child_line_items = $line_item->children(); |
|
| 150 | + // loop thru children |
|
| 151 | + foreach ($child_line_items as $child_line_item) { |
|
| 152 | + // recursively feed children back into this method |
|
| 153 | + $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
| 154 | + } |
|
| 155 | + $event_sub_total += isset($options['event_id']) ? $this->_events[ $options['event_id'] ] : 0; |
|
| 156 | + $sub_total += $event_sub_total; |
|
| 157 | + if (( |
|
| 158 | + // event subtotals |
|
| 159 | + $line_item->code() !== 'pre-tax-subtotal' && count($child_line_items) > 1 |
|
| 160 | + ) |
|
| 161 | + || ( |
|
| 162 | + // pre-tax subtotals |
|
| 163 | + $line_item->code() === 'pre-tax-subtotal' && count($this->_events) > 1 |
|
| 164 | + ) |
|
| 165 | + ) { |
|
| 166 | + $options['sub_total'] = $line_item->OBJ_type() === 'Event' ? $event_sub_total : $sub_total; |
|
| 167 | + $html .= $this->_sub_total_row($line_item, $text, $options); |
|
| 168 | + } |
|
| 169 | + break; |
|
| 170 | + case EEM_Line_Item::type_tax: |
|
| 171 | + if ($this->_show_taxes) { |
|
| 172 | + $this->_taxes_html .= $this->_tax_row($line_item, $options); |
|
| 173 | + } |
|
| 174 | + break; |
|
| 175 | + case EEM_Line_Item::type_tax_sub_total: |
|
| 176 | + if ($this->_show_taxes) { |
|
| 177 | + $child_line_items = $line_item->children(); |
|
| 178 | + // loop thru children |
|
| 179 | + foreach ($child_line_items as $child_line_item) { |
|
| 180 | + // recursively feed children back into this method |
|
| 181 | + $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
| 182 | + } |
|
| 183 | + if (count($child_line_items) > 1) { |
|
| 184 | + $this->_taxes_html .= $this->_total_tax_row($line_item, esc_html__('Tax Total', 'event_espresso')); |
|
| 185 | + } |
|
| 186 | + } |
|
| 187 | + break; |
|
| 188 | + case EEM_Line_Item::type_total: |
|
| 189 | + // get all child line items |
|
| 190 | + $children = $line_item->children(); |
|
| 191 | + // loop thru all non-tax child line items |
|
| 192 | + foreach ($children as $child_line_item) { |
|
| 193 | + if ($child_line_item->type() !== EEM_Line_Item::type_tax_sub_total) { |
|
| 194 | + // recursively feed children back into this method |
|
| 195 | + $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
| 196 | + } |
|
| 197 | + } |
|
| 198 | + // now loop thru tax child line items |
|
| 199 | + foreach ($children as $child_line_item) { |
|
| 200 | + if ($child_line_item->type() === EEM_Line_Item::type_tax_sub_total) { |
|
| 201 | + // recursively feed children back into this method |
|
| 202 | + $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
| 203 | + } |
|
| 204 | + } |
|
| 205 | + $html .= $this->_taxes_html; |
|
| 206 | + $html .= $this->_total_row($line_item, esc_html__('Total', 'event_espresso')); |
|
| 207 | + $html .= $this->_payments_and_amount_owing_rows($line_item, $options); |
|
| 208 | + break; |
|
| 209 | + } |
|
| 210 | + return $html; |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + |
|
| 214 | + |
|
| 215 | + /** |
|
| 216 | + * _event_row - basically a Heading row displayed once above each event's ticket rows |
|
| 217 | + * |
|
| 218 | + * @param EE_Line_Item $line_item |
|
| 219 | + * @return mixed |
|
| 220 | + */ |
|
| 221 | + private function _event_row(EE_Line_Item $line_item) |
|
| 222 | + { |
|
| 223 | + // start of row |
|
| 224 | + $html = EEH_HTML::tr('', 'event-cart-total-row', 'total_tr odd'); |
|
| 225 | + // event name td |
|
| 226 | + $html .= EEH_HTML::td( |
|
| 227 | + EEH_HTML::strong($line_item->name()), |
|
| 228 | + '', |
|
| 229 | + 'event-header', |
|
| 230 | + '', |
|
| 231 | + ' colspan="4"' |
|
| 232 | + ); |
|
| 233 | + // end of row |
|
| 234 | + $html .= EEH_HTML::trx(); |
|
| 235 | + return $html; |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + |
|
| 239 | + |
|
| 240 | + /** |
|
| 241 | + * _ticket_row |
|
| 242 | + * |
|
| 243 | + * @param EE_Line_Item $line_item |
|
| 244 | + * @param array $options |
|
| 245 | + * @return mixed |
|
| 246 | + * @throws EE_Error |
|
| 247 | + */ |
|
| 248 | + private function _ticket_row(EE_Line_Item $line_item, $options = array()) |
|
| 249 | + { |
|
| 250 | + // start of row |
|
| 251 | + $row_class = $options['odd'] ? 'item odd' : 'item'; |
|
| 252 | + $html = EEH_HTML::tr('', '', $row_class); |
|
| 253 | + // name && desc |
|
| 254 | + $name_and_desc = apply_filters( |
|
| 255 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', |
|
| 256 | + $line_item->name(), |
|
| 257 | + $line_item |
|
| 258 | + ); |
|
| 259 | + $name_and_desc .= apply_filters( |
|
| 260 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
|
| 261 | + ( |
|
| 262 | + $options['show_desc'] |
|
| 263 | + ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' |
|
| 264 | + : '' |
|
| 265 | + ), |
|
| 266 | + $line_item, |
|
| 267 | + $options |
|
| 268 | + ); |
|
| 269 | + $name_and_desc .= $line_item->is_taxable() ? ' * ' : ''; |
|
| 270 | + // name td |
|
| 271 | + $html .= EEH_HTML::td( /*__FUNCTION__ .*/ |
|
| 272 | + $name_and_desc, |
|
| 273 | + '', |
|
| 274 | + 'item_l' |
|
| 275 | + ); |
|
| 276 | + // price td |
|
| 277 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
| 278 | + // quantity td |
|
| 279 | + $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght'); |
|
| 280 | + $this->_total_items += $line_item->quantity(); |
|
| 281 | + // determine total for line item |
|
| 282 | + $total = $line_item->total(); |
|
| 283 | + $this->_events[ $options['event_id'] ] += $total; |
|
| 284 | + // total td |
|
| 285 | + $html .= EEH_HTML::td( |
|
| 286 | + EEH_Template::format_currency($total, false, false), |
|
| 287 | + '', |
|
| 288 | + 'item_r jst-rght' |
|
| 289 | + ); |
|
| 290 | + // end of row |
|
| 291 | + $html .= EEH_HTML::trx(); |
|
| 292 | + return $html; |
|
| 293 | + } |
|
| 294 | + |
|
| 295 | + |
|
| 296 | + |
|
| 297 | + /** |
|
| 298 | + * _item_row |
|
| 299 | + * |
|
| 300 | + * @param EE_Line_Item $line_item |
|
| 301 | + * @param array $options |
|
| 302 | + * @return mixed |
|
| 303 | + * @throws EE_Error |
|
| 304 | + */ |
|
| 305 | + private function _item_row(EE_Line_Item $line_item, $options = array()) |
|
| 306 | + { |
|
| 307 | + // start of row |
|
| 308 | + $row_class = $options['odd'] ? 'item odd' : 'item'; |
|
| 309 | + $html = EEH_HTML::tr('', '', $row_class); |
|
| 310 | + $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() . ': ' : ''; |
|
| 311 | + // name && desc |
|
| 312 | + $name_and_desc = apply_filters( |
|
| 313 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', |
|
| 314 | + $obj_name . $line_item->name(), |
|
| 315 | + $line_item |
|
| 316 | + ); |
|
| 317 | + $name_and_desc .= apply_filters( |
|
| 318 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
|
| 319 | + ( |
|
| 320 | + $options['show_desc'] |
|
| 321 | + ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' |
|
| 322 | + : '' |
|
| 323 | + ), |
|
| 324 | + $line_item, |
|
| 325 | + $options |
|
| 326 | + ); |
|
| 327 | + $name_and_desc .= $line_item->is_taxable() ? ' * ' : ''; |
|
| 328 | + // name td |
|
| 329 | + $html .= EEH_HTML::td($name_and_desc, '', 'item_l'); |
|
| 330 | + // price td |
|
| 331 | + if ($line_item->is_percent()) { |
|
| 332 | + $html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c jst-rght'); |
|
| 333 | + } else { |
|
| 334 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
| 335 | + } |
|
| 336 | + // quantity td |
|
| 337 | + $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght'); |
|
| 338 | + // $total = $line_item->total() * $line_item->quantity(); |
|
| 339 | + $total = $line_item->total(); |
|
| 340 | + if (isset($options['event_id'], $this->_events[ $options['event_id'] ])) { |
|
| 341 | + $this->_events[ $options['event_id'] ] += $total; |
|
| 342 | + } |
|
| 343 | + // total td |
|
| 344 | + $html .= EEH_HTML::td( |
|
| 345 | + EEH_Template::format_currency($total, false, false), |
|
| 346 | + '', |
|
| 347 | + 'item_r jst-rght' |
|
| 348 | + ); |
|
| 349 | + // end of row |
|
| 350 | + $html .= EEH_HTML::trx(); |
|
| 351 | + return $html; |
|
| 352 | + } |
|
| 353 | + |
|
| 354 | + |
|
| 355 | + |
|
| 356 | + /** |
|
| 357 | + * _sub_item_row |
|
| 358 | + * |
|
| 359 | + * @param EE_Line_Item $line_item |
|
| 360 | + * @param array $options |
|
| 361 | + * @param EE_Line_Item $parent_line_item |
|
| 362 | + * @return mixed |
|
| 363 | + * @throws EE_Error |
|
| 364 | + */ |
|
| 365 | + private function _sub_item_row(EE_Line_Item $line_item, $options = array(), EE_Line_Item $parent_line_item = null) |
|
| 366 | + { |
|
| 367 | + if ($parent_line_item instanceof EE_Line_Item |
|
| 368 | + && $line_item->children() === array() |
|
| 369 | + && $line_item->name() === $parent_line_item->name() |
|
| 370 | + && apply_filters( |
|
| 371 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy___sub_item_row__hide_main_sub_line_item', |
|
| 372 | + true |
|
| 373 | + ) |
|
| 374 | + ) { |
|
| 375 | + return ''; |
|
| 376 | + } |
|
| 377 | + // start of row |
|
| 378 | + $html = EEH_HTML::tr('', '', 'item sub-item-row'); |
|
| 379 | + // name && desc |
|
| 380 | + $name_and_desc = EEH_HTML::span('', '', 'sub-item-row-bullet dashicons dashicons-arrow-right') |
|
| 381 | + . $line_item->name(); |
|
| 382 | + $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: ' |
|
| 383 | + . $line_item->desc() |
|
| 384 | + . '</span>' : ''; |
|
| 385 | + // name td |
|
| 386 | + $html .= EEH_HTML::td($name_and_desc, '', 'item_l sub-item'); |
|
| 387 | + $qty = $parent_line_item instanceof EE_Line_Item ? $parent_line_item->quantity() : 1; |
|
| 388 | + // discount/surcharge td |
|
| 389 | + if ($line_item->is_percent()) { |
|
| 390 | + $html .= EEH_HTML::td( |
|
| 391 | + EEH_Template::format_currency( |
|
| 392 | + $line_item->total() / $qty, |
|
| 393 | + false, |
|
| 394 | + false |
|
| 395 | + ), |
|
| 396 | + '', |
|
| 397 | + 'item_c jst-rght' |
|
| 398 | + ); |
|
| 399 | + } else { |
|
| 400 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
| 401 | + } |
|
| 402 | + // no quantity td |
|
| 403 | + $html .= EEH_HTML::td(); |
|
| 404 | + // no total td |
|
| 405 | + $html .= EEH_HTML::td(); |
|
| 406 | + // end of row |
|
| 407 | + $html .= EEH_HTML::trx(); |
|
| 408 | + $html = apply_filters( |
|
| 409 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy___sub_item_row__html', |
|
| 410 | + $html, |
|
| 411 | + $line_item, |
|
| 412 | + $options, |
|
| 413 | + $parent_line_item |
|
| 414 | + ); |
|
| 415 | + return $html; |
|
| 416 | + } |
|
| 417 | + |
|
| 418 | + |
|
| 419 | + |
|
| 420 | + /** |
|
| 421 | + * _tax_row |
|
| 422 | + * |
|
| 423 | + * @param EE_Line_Item $line_item |
|
| 424 | + * @param array $options |
|
| 425 | + * @return mixed |
|
| 426 | + * @throws EE_Error |
|
| 427 | + */ |
|
| 428 | + private function _tax_row(EE_Line_Item $line_item, $options = array()) |
|
| 429 | + { |
|
| 430 | + // start of row |
|
| 431 | + $html = EEH_HTML::tr('', 'item sub-item tax-total'); |
|
| 432 | + // name && desc |
|
| 433 | + $name_and_desc = $line_item->name(); |
|
| 434 | + $name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">' |
|
| 435 | + . esc_html__(' * taxable items', 'event_espresso') . '</span>'; |
|
| 436 | + $name_and_desc .= $options['show_desc'] ? '<br/>' . $line_item->desc() : ''; |
|
| 437 | + // name td |
|
| 438 | + $html .= EEH_HTML::td( /*__FUNCTION__ .*/ |
|
| 439 | + $name_and_desc, |
|
| 440 | + '', |
|
| 441 | + 'item_l sub-item' |
|
| 442 | + ); |
|
| 443 | + // percent td |
|
| 444 | + $html .= EEH_HTML::td($line_item->percent() . '%', '', ' jst-rght', ''); |
|
| 445 | + // empty td (price) |
|
| 446 | + $html .= EEH_HTML::td(EEH_HTML::nbsp()); |
|
| 447 | + // total td |
|
| 448 | + $html .= EEH_HTML::td( |
|
| 449 | + EEH_Template::format_currency( |
|
| 450 | + $line_item->total(), |
|
| 451 | + false, |
|
| 452 | + false |
|
| 453 | + ), |
|
| 454 | + '', |
|
| 455 | + 'item_r jst-rght' |
|
| 456 | + ); |
|
| 457 | + // end of row |
|
| 458 | + $html .= EEH_HTML::trx(); |
|
| 459 | + return $html; |
|
| 460 | + } |
|
| 461 | + |
|
| 462 | + |
|
| 463 | + |
|
| 464 | + /** |
|
| 465 | + * _total_row |
|
| 466 | + * |
|
| 467 | + * @param EE_Line_Item $line_item |
|
| 468 | + * @param string $text |
|
| 469 | + * @return mixed |
|
| 470 | + * @throws EE_Error |
|
| 471 | + */ |
|
| 472 | + private function _total_tax_row(EE_Line_Item $line_item, $text = '') |
|
| 473 | + { |
|
| 474 | + $html = ''; |
|
| 475 | + if ($line_item->total()) { |
|
| 476 | + // start of row |
|
| 477 | + $html = EEH_HTML::tr('', '', 'total_tr odd'); |
|
| 478 | + // total td |
|
| 479 | + $html .= EEH_HTML::td( |
|
| 480 | + $text, |
|
| 481 | + '', |
|
| 482 | + 'total_currency total jst-rght', |
|
| 483 | + '', |
|
| 484 | + ' colspan="2"' |
|
| 485 | + ); |
|
| 486 | + // empty td (price) |
|
| 487 | + $html .= EEH_HTML::td(EEH_HTML::nbsp()); |
|
| 488 | + // total td |
|
| 489 | + $html .= EEH_HTML::td( |
|
| 490 | + EEH_Template::format_currency($line_item->total(), false, false), |
|
| 491 | + '', |
|
| 492 | + 'total jst-rght' |
|
| 493 | + ); |
|
| 494 | + // end of row |
|
| 495 | + $html .= EEH_HTML::trx(); |
|
| 496 | + } |
|
| 497 | + return $html; |
|
| 498 | + } |
|
| 499 | + |
|
| 500 | + |
|
| 501 | + |
|
| 502 | + /** |
|
| 503 | + * _total_row |
|
| 504 | + * |
|
| 505 | + * @param EE_Line_Item $line_item |
|
| 506 | + * @param string $text |
|
| 507 | + * @param array $options |
|
| 508 | + * @return mixed |
|
| 509 | + * @throws EE_Error |
|
| 510 | + */ |
|
| 511 | + private function _sub_total_row(EE_Line_Item $line_item, $text = '', $options = array()) |
|
| 512 | + { |
|
| 513 | + $html = ''; |
|
| 514 | + if ($line_item->total()) { |
|
| 515 | + // start of row |
|
| 516 | + $html = EEH_HTML::tr('', '', 'total_tr odd'); |
|
| 517 | + // total td |
|
| 518 | + $html .= EEH_HTML::td( |
|
| 519 | + $text, |
|
| 520 | + '', |
|
| 521 | + 'total_currency total jst-rght', |
|
| 522 | + '', |
|
| 523 | + ' colspan="3"' |
|
| 524 | + ); |
|
| 525 | + // total td |
|
| 526 | + $html .= EEH_HTML::td( |
|
| 527 | + EEH_Template::format_currency($options['sub_total'], false, false), |
|
| 528 | + '', |
|
| 529 | + 'total jst-rght' |
|
| 530 | + ); |
|
| 531 | + // end of row |
|
| 532 | + $html .= EEH_HTML::trx(); |
|
| 533 | + } |
|
| 534 | + return $html; |
|
| 535 | + } |
|
| 536 | + |
|
| 537 | + |
|
| 538 | + |
|
| 539 | + /** |
|
| 540 | + * _total_row |
|
| 541 | + * |
|
| 542 | + * @param EE_Line_Item $line_item |
|
| 543 | + * @param string $text |
|
| 544 | + * @return mixed |
|
| 545 | + * @throws EE_Error |
|
| 546 | + */ |
|
| 547 | + private function _total_row(EE_Line_Item $line_item, $text = '') |
|
| 548 | + { |
|
| 549 | + // start of row |
|
| 550 | + $html = EEH_HTML::tr('', '', 'spco-grand-total total_tr odd'); |
|
| 551 | + // total td |
|
| 552 | + $html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="3"'); |
|
| 553 | + // total td |
|
| 554 | + $html .= EEH_HTML::td( |
|
| 555 | + EEH_Template::format_currency($line_item->total(), false, false), |
|
| 556 | + '', |
|
| 557 | + 'total jst-rght' |
|
| 558 | + ); |
|
| 559 | + // end of row |
|
| 560 | + $html .= EEH_HTML::trx(); |
|
| 561 | + return $html; |
|
| 562 | + } |
|
| 563 | + |
|
| 564 | + |
|
| 565 | + |
|
| 566 | + /** |
|
| 567 | + * _payments_and_amount_owing_rows |
|
| 568 | + * |
|
| 569 | + * @param EE_Line_Item $line_item |
|
| 570 | + * @param array $options |
|
| 571 | + * @return mixed |
|
| 572 | + * @throws EE_Error |
|
| 573 | + */ |
|
| 574 | + private function _payments_and_amount_owing_rows(EE_Line_Item $line_item, $options = array()) |
|
| 575 | + { |
|
| 576 | + $html = ''; |
|
| 577 | + $owing = $line_item->total(); |
|
| 578 | + $transaction = EEM_Transaction::instance()->get_one_by_ID($line_item->TXN_ID()); |
|
| 579 | + if ($transaction instanceof EE_Transaction) { |
|
| 580 | + $registration_payments = array(); |
|
| 581 | + $registrations = ! empty($options['registrations']) |
|
| 582 | + ? $options['registrations'] |
|
| 583 | + : $transaction->registrations(); |
|
| 584 | + foreach ($registrations as $registration) { |
|
| 585 | + if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) { |
|
| 586 | + $registration_payments += $registration->registration_payments(); |
|
| 587 | + } |
|
| 588 | + } |
|
| 589 | + if (! empty($registration_payments)) { |
|
| 590 | + foreach ($registration_payments as $registration_payment) { |
|
| 591 | + if ($registration_payment instanceof EE_Registration_Payment) { |
|
| 592 | + $owing -= $registration_payment->amount(); |
|
| 593 | + $payment = $registration_payment->payment(); |
|
| 594 | + $payment_desc = ''; |
|
| 595 | + if ($payment instanceof EE_Payment) { |
|
| 596 | + $payment_desc = sprintf( |
|
| 597 | + esc_html__('Payment%1$s Received: %2$s', 'event_espresso'), |
|
| 598 | + $payment->txn_id_chq_nmbr() !== '' |
|
| 599 | + ? ' <span class="small-text">(#' . $payment->txn_id_chq_nmbr() . ')</span> ' |
|
| 600 | + : '', |
|
| 601 | + $payment->timestamp() |
|
| 602 | + ); |
|
| 603 | + } |
|
| 604 | + // start of row |
|
| 605 | + $html .= EEH_HTML::tr('', '', 'total_tr odd'); |
|
| 606 | + // payment desc |
|
| 607 | + $html .= EEH_HTML::td($payment_desc, '', '', '', ' colspan="3"'); |
|
| 608 | + // total td |
|
| 609 | + $html .= EEH_HTML::td( |
|
| 610 | + EEH_Template::format_currency( |
|
| 611 | + $registration_payment->amount(), |
|
| 612 | + false, |
|
| 613 | + false |
|
| 614 | + ), |
|
| 615 | + '', |
|
| 616 | + 'total jst-rght' |
|
| 617 | + ); |
|
| 618 | + // end of row |
|
| 619 | + $html .= EEH_HTML::trx(); |
|
| 620 | + } |
|
| 621 | + } |
|
| 622 | + if ($line_item->total()) { |
|
| 623 | + // start of row |
|
| 624 | + $html .= EEH_HTML::tr('', '', 'total_tr odd'); |
|
| 625 | + // total td |
|
| 626 | + $html .= EEH_HTML::td( |
|
| 627 | + esc_html__('Amount Owing', 'event_espresso'), |
|
| 628 | + '', |
|
| 629 | + 'total_currency total jst-rght', |
|
| 630 | + '', |
|
| 631 | + ' colspan="3"' |
|
| 632 | + ); |
|
| 633 | + // total td |
|
| 634 | + $html .= EEH_HTML::td( |
|
| 635 | + EEH_Template::format_currency($owing, false, false), |
|
| 636 | + '', |
|
| 637 | + 'total jst-rght' |
|
| 638 | + ); |
|
| 639 | + // end of row |
|
| 640 | + $html .= EEH_HTML::trx(); |
|
| 641 | + } |
|
| 642 | + } |
|
| 643 | + } |
|
| 644 | + $this->_grand_total = $owing; |
|
| 645 | + return $html; |
|
| 646 | + } |
|
| 647 | 647 | } |
@@ -38,103 +38,103 @@ |
||
| 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 | } else { |
| 64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
| 65 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
| 66 | - /** |
|
| 67 | - * espresso_minimum_php_version_error |
|
| 68 | - * |
|
| 69 | - * @return void |
|
| 70 | - */ |
|
| 71 | - function espresso_minimum_php_version_error() |
|
| 72 | - { |
|
| 73 | - ?> |
|
| 64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
| 65 | + if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
| 66 | + /** |
|
| 67 | + * espresso_minimum_php_version_error |
|
| 68 | + * |
|
| 69 | + * @return void |
|
| 70 | + */ |
|
| 71 | + function espresso_minimum_php_version_error() |
|
| 72 | + { |
|
| 73 | + ?> |
|
| 74 | 74 | <div class="error"> |
| 75 | 75 | <p> |
| 76 | 76 | <?php |
| 77 | - printf( |
|
| 78 | - esc_html__( |
|
| 79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
| 80 | - 'event_espresso' |
|
| 81 | - ), |
|
| 82 | - EE_MIN_PHP_VER_REQUIRED, |
|
| 83 | - PHP_VERSION, |
|
| 84 | - '<br/>', |
|
| 85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
| 86 | - ); |
|
| 87 | - ?> |
|
| 77 | + printf( |
|
| 78 | + esc_html__( |
|
| 79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
| 80 | + 'event_espresso' |
|
| 81 | + ), |
|
| 82 | + EE_MIN_PHP_VER_REQUIRED, |
|
| 83 | + PHP_VERSION, |
|
| 84 | + '<br/>', |
|
| 85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
| 86 | + ); |
|
| 87 | + ?> |
|
| 88 | 88 | </p> |
| 89 | 89 | </div> |
| 90 | 90 | <?php |
| 91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 92 | - } |
|
| 91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
| 95 | - } else { |
|
| 96 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
| 97 | - /** |
|
| 98 | - * espresso_version |
|
| 99 | - * Returns the plugin version |
|
| 100 | - * |
|
| 101 | - * @return string |
|
| 102 | - */ |
|
| 103 | - function espresso_version() |
|
| 104 | - { |
|
| 105 | - return apply_filters('FHEE__espresso__espresso_version', '4.9.68.rc.015'); |
|
| 106 | - } |
|
| 94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
| 95 | + } else { |
|
| 96 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
| 97 | + /** |
|
| 98 | + * espresso_version |
|
| 99 | + * Returns the plugin version |
|
| 100 | + * |
|
| 101 | + * @return string |
|
| 102 | + */ |
|
| 103 | + function espresso_version() |
|
| 104 | + { |
|
| 105 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.68.rc.015'); |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - /** |
|
| 109 | - * espresso_plugin_activation |
|
| 110 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
| 111 | - */ |
|
| 112 | - function espresso_plugin_activation() |
|
| 113 | - { |
|
| 114 | - update_option('ee_espresso_activation', true); |
|
| 115 | - } |
|
| 108 | + /** |
|
| 109 | + * espresso_plugin_activation |
|
| 110 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
| 111 | + */ |
|
| 112 | + function espresso_plugin_activation() |
|
| 113 | + { |
|
| 114 | + update_option('ee_espresso_activation', true); |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
| 117 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
| 118 | 118 | |
| 119 | - require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
| 120 | - bootstrap_espresso(); |
|
| 121 | - } |
|
| 119 | + require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
| 120 | + bootstrap_espresso(); |
|
| 121 | + } |
|
| 122 | 122 | } |
| 123 | 123 | if (! function_exists('espresso_deactivate_plugin')) { |
| 124 | - /** |
|
| 125 | - * deactivate_plugin |
|
| 126 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
| 127 | - * |
|
| 128 | - * @access public |
|
| 129 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
| 130 | - * @return void |
|
| 131 | - */ |
|
| 132 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
| 133 | - { |
|
| 134 | - if (! function_exists('deactivate_plugins')) { |
|
| 135 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
| 136 | - } |
|
| 137 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
| 138 | - deactivate_plugins($plugin_basename); |
|
| 139 | - } |
|
| 124 | + /** |
|
| 125 | + * deactivate_plugin |
|
| 126 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
| 127 | + * |
|
| 128 | + * @access public |
|
| 129 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
| 130 | + * @return void |
|
| 131 | + */ |
|
| 132 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
| 133 | + { |
|
| 134 | + if (! function_exists('deactivate_plugins')) { |
|
| 135 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
| 136 | + } |
|
| 137 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
| 138 | + deactivate_plugins($plugin_basename); |
|
| 139 | + } |
|
| 140 | 140 | } |