@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | <ul class="wp-people-group" id="ee-people-group-owners"> |
| 4 | 4 | <li class="wp-person" id="ee-person-sshoultes"> |
| 5 | 5 | <a href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 6 | - <?php echo esp_gravatar_image( '[email protected]', 'Seth Shoultes' ); ?> |
|
| 6 | + <?php echo esp_gravatar_image('[email protected]', 'Seth Shoultes'); ?> |
|
| 7 | 7 | </a> |
| 8 | 8 | <a class="web" href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 9 | 9 | Seth Shoultes |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | </li> |
| 13 | 13 | <li class="wp-person" id="ee-person-gkoyle"> |
| 14 | 14 | <a href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 15 | - <?php echo esp_gravatar_image( '[email protected]', 'Garth Koyle' ); ?> |
|
| 15 | + <?php echo esp_gravatar_image('[email protected]', 'Garth Koyle'); ?> |
|
| 16 | 16 | </a> |
| 17 | 17 | <a class="web" href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 18 | 18 | Garth Koyle |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | <ul class="wp-people-group" id="ee-people-group-core-developers"> |
| 25 | 25 | <li class="wp-person" id="ee-person-bchristensen"> |
| 26 | 26 | <a href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 27 | - <?php echo esp_gravatar_image( '[email protected]', 'Brent Christensen' ); ?> |
|
| 27 | + <?php echo esp_gravatar_image('[email protected]', 'Brent Christensen'); ?> |
|
| 28 | 28 | </a> |
| 29 | 29 | <a class="web" href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 30 | 30 | Brent Christensen |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | </li> |
| 34 | 34 | <li class="wp-person" id="ee-person-dethier"> |
| 35 | 35 | <a href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 36 | - <?php echo esp_gravatar_image( '[email protected]', 'Darren Ethier' ); ?> |
|
| 36 | + <?php echo esp_gravatar_image('[email protected]', 'Darren Ethier'); ?> |
|
| 37 | 37 | </a> |
| 38 | 38 | <a class="web" href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 39 | 39 | Darren Ethier |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | </li> |
| 43 | 43 | <li class="wp-person" id="ee-person-mnelson"> |
| 44 | 44 | <a href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 45 | - <?php echo esp_gravatar_image( '[email protected]', 'Michael Nelson' ); ?> |
|
| 45 | + <?php echo esp_gravatar_image('[email protected]', 'Michael Nelson'); ?> |
|
| 46 | 46 | </a> |
| 47 | 47 | <a class="web" href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 48 | 48 | Michael Nelson |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | </li> |
| 52 | 52 | <li class="wp-person" id="ee-person-nkolivoshka"> |
| 53 | 53 | <a href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 54 | - <?php echo esp_gravatar_image( '[email protected]', 'Nazar Kolivoshka' ); ?> |
|
| 54 | + <?php echo esp_gravatar_image('[email protected]', 'Nazar Kolivoshka'); ?> |
|
| 55 | 55 | </a> |
| 56 | 56 | <a class="web" href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 57 | 57 | Nazar Kolivoshka |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | <ul class="wp-people-group" id="ee-people-group-support-staff"> |
| 64 | 64 | <li class="wp-person" id="ee-person-jfeck"> |
| 65 | 65 | <a href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 66 | - <?php echo esp_gravatar_image( '[email protected]', 'Josh Feck' ); ?> |
|
| 66 | + <?php echo esp_gravatar_image('[email protected]', 'Josh Feck'); ?> |
|
| 67 | 67 | </a> |
| 68 | 68 | <a class="web" href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 69 | 69 | Josh Feck |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | </li> |
| 72 | 72 | <li class="wp-person" id="ee-person-twarwick"> |
| 73 | 73 | <a href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 74 | - <?php echo esp_gravatar_image( '[email protected]', 'Tony Warwick' ); ?> |
|
| 74 | + <?php echo esp_gravatar_image('[email protected]', 'Tony Warwick'); ?> |
|
| 75 | 75 | </a> |
| 76 | 76 | <a class="web" href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 77 | 77 | Tony Warwick |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | </li> |
| 80 | 80 | <li class="wp-person" id="ee-person-lcaum"> |
| 81 | 81 | <a href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 82 | - <?php echo esp_gravatar_image( '[email protected]', 'Lorenzo Caum' ); ?> |
|
| 82 | + <?php echo esp_gravatar_image('[email protected]', 'Lorenzo Caum'); ?> |
|
| 83 | 83 | </a> |
| 84 | 84 | <a class="web" href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 85 | 85 | Lorenzo Caum |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | </ul> |
| 90 | 90 | <h3 class="wp-people-group"><?php _e('Contributor Recognition', 'event_espresso'); ?></h3> |
| 91 | 91 | <p class="description"> |
| 92 | - <?php printf( __('For every major release we want to recognize the people who contributed to the release via a GitHub pull request. Want to see your name listed here? %sWhen you submit a pull request that gets included in a major release%s, we\'ll add your name here linked to your GitHub profile.', 'event_espresso'), '<a href="https://github.com/eventespresso/event-espresso-core" title="Contribute to Event Espresso by making a pull request via GitHub">', '</a>' ); ?> |
|
| 92 | + <?php printf(__('For every major release we want to recognize the people who contributed to the release via a GitHub pull request. Want to see your name listed here? %sWhen you submit a pull request that gets included in a major release%s, we\'ll add your name here linked to your GitHub profile.', 'event_espresso'), '<a href="https://github.com/eventespresso/event-espresso-core" title="Contribute to Event Espresso by making a pull request via GitHub">', '</a>'); ?> |
|
| 93 | 93 | </p> |
| 94 | 94 | <p class="wp-credits-list"> |
| 95 | 95 | <ul> |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | </p> |
| 104 | 104 | <h3 class="wp-people-group"><?php _e('External Libraries', 'event_espresso'); ?></h3> |
| 105 | 105 | <p class="description"> |
| 106 | - <?php printf( __('Along with the libraries %sincluded with WordPress%s, Event Espresso utilizes the following third party libraries:', 'event_espresso'), '<a href="credits.php">', '</a>' ); ?> |
|
| 106 | + <?php printf(__('Along with the libraries %sincluded with WordPress%s, Event Espresso utilizes the following third party libraries:', 'event_espresso'), '<a href="credits.php">', '</a>'); ?> |
|
| 107 | 107 | </p> |
| 108 | 108 | <p class="wp-credits-list"> |
| 109 | 109 | <a href="http://josscrowcroft.github.io/accounting.js/"><?php _e('accounting.js', 'event_espresso'); ?></a>, |
@@ -119,10 +119,10 @@ discard block |
||
| 119 | 119 | |
| 120 | 120 | <?php |
| 121 | 121 | function esp_gravatar_profile($email) { |
| 122 | - echo 'http://www.gravatar.com/' . md5($email); |
|
| 122 | + echo 'http://www.gravatar.com/'.md5($email); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | function esp_gravatar_image($email, $name) { |
| 126 | - echo '<img src="http://0.gravatar.com/avatar/' . md5($email) . '?s=60" class="gravatar" alt="' . $name . '"/>'; |
|
| 126 | + echo '<img src="http://0.gravatar.com/avatar/'.md5($email).'?s=60" class="gravatar" alt="'.$name.'"/>'; |
|
| 127 | 127 | } |
| 128 | 128 | ?> |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | use EventEspresso\core\interfaces\ResettableInterface; |
| 3 | 3 | |
| 4 | 4 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
| 5 | - exit('No direct script access allowed'); |
|
| 5 | + exit('No direct script access allowed'); |
|
| 6 | 6 | } |
| 7 | 7 | do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
| 8 | 8 | |
@@ -23,421 +23,421 @@ discard block |
||
| 23 | 23 | class EE_Cart implements ResettableInterface |
| 24 | 24 | { |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * instance of the EE_Cart object |
|
| 28 | - * |
|
| 29 | - * @access private |
|
| 30 | - * @var EE_Cart $_instance |
|
| 31 | - */ |
|
| 32 | - private static $_instance; |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * instance of the EE_Session object |
|
| 36 | - * |
|
| 37 | - * @access protected |
|
| 38 | - * @var EE_Session $_session |
|
| 39 | - */ |
|
| 40 | - protected $_session; |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * The total Line item which comprises all the children line-item subtotals, |
|
| 44 | - * which in turn each have their line items. |
|
| 45 | - * Typically, the line item structure will look like: |
|
| 46 | - * grand total |
|
| 47 | - * -tickets-sub-total |
|
| 48 | - * --ticket1 |
|
| 49 | - * --ticket2 |
|
| 50 | - * --... |
|
| 51 | - * -taxes-sub-total |
|
| 52 | - * --tax1 |
|
| 53 | - * --tax2 |
|
| 54 | - * |
|
| 55 | - * @var EE_Line_Item |
|
| 56 | - */ |
|
| 57 | - private $_grand_total; |
|
| 58 | - |
|
| 59 | - |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * @singleton method used to instantiate class object |
|
| 63 | - * @access public |
|
| 64 | - * @param EE_Line_Item $grand_total |
|
| 65 | - * @param EE_Session $session |
|
| 66 | - * @return \EE_Cart |
|
| 67 | - * @throws \EE_Error |
|
| 68 | - */ |
|
| 69 | - public static function instance(EE_Line_Item $grand_total = null, EE_Session $session = null) |
|
| 70 | - { |
|
| 71 | - if ($grand_total instanceof EE_Line_Item && $grand_total->is_total()) { |
|
| 72 | - self::$_instance = new self($grand_total, $session); |
|
| 73 | - } |
|
| 74 | - // or maybe retrieve an existing one ? |
|
| 75 | - if ( ! self::$_instance instanceof EE_Cart) { |
|
| 76 | - // try getting the cart out of the session |
|
| 77 | - $saved_cart = $session instanceof EE_Session ? $session->cart() : null; |
|
| 78 | - self::$_instance = $saved_cart instanceof EE_Cart ? $saved_cart : new self($grand_total, $session); |
|
| 79 | - unset($saved_cart); |
|
| 80 | - } |
|
| 81 | - // verify that cart is ok and grand total line item exists |
|
| 82 | - if ( ! self::$_instance instanceof EE_Cart || ! self::$_instance->_grand_total instanceof EE_Line_Item) { |
|
| 83 | - self::$_instance = new self($grand_total, $session); |
|
| 84 | - } |
|
| 85 | - self::$_instance->get_grand_total(); |
|
| 86 | - // once everything is all said and done, save the cart to the EE_Session |
|
| 87 | - add_action('shutdown', array(self::$_instance, 'save_cart'), 90); |
|
| 88 | - return self::$_instance; |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * private constructor to prevent direct creation |
|
| 95 | - * |
|
| 96 | - * @Constructor |
|
| 97 | - * @access private |
|
| 98 | - * @param EE_Line_Item $grand_total |
|
| 99 | - * @param EE_Session $session |
|
| 100 | - */ |
|
| 101 | - private function __construct(EE_Line_Item $grand_total = null, EE_Session $session = null) |
|
| 102 | - { |
|
| 103 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 104 | - $this->set_session($session); |
|
| 105 | - if ($grand_total instanceof EE_Line_Item && $grand_total->is_total()) { |
|
| 106 | - $this->set_grand_total_line_item($grand_total); |
|
| 107 | - } |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * Resets the cart completely (whereas empty_cart |
|
| 114 | - * |
|
| 115 | - * @param EE_Line_Item $grand_total |
|
| 116 | - * @param EE_Session $session |
|
| 117 | - * @return EE_Cart |
|
| 118 | - * @throws \EE_Error |
|
| 119 | - */ |
|
| 120 | - public static function reset(EE_Line_Item $grand_total = null, EE_Session $session = null) |
|
| 121 | - { |
|
| 122 | - remove_action('shutdown', array(self::$_instance, 'save_cart'), 90); |
|
| 123 | - if ($session instanceof EE_Session) { |
|
| 124 | - $session->reset_cart(); |
|
| 125 | - } |
|
| 126 | - self::$_instance = null; |
|
| 127 | - return self::instance($grand_total, $session); |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * @return \EE_Session |
|
| 134 | - */ |
|
| 135 | - public function session() |
|
| 136 | - { |
|
| 137 | - if ( ! $this->_session instanceof EE_Session) { |
|
| 138 | - $this->set_session(); |
|
| 139 | - } |
|
| 140 | - return $this->_session; |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - |
|
| 144 | - |
|
| 145 | - /** |
|
| 146 | - * @param EE_Session $session |
|
| 147 | - */ |
|
| 148 | - public function set_session(EE_Session $session = null) |
|
| 149 | - { |
|
| 150 | - $this->_session = $session instanceof EE_Session ? $session : EE_Registry::instance()->load_core('Session'); |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - |
|
| 154 | - |
|
| 155 | - /** |
|
| 156 | - * Sets the cart to match the line item. Especially handy for loading an old cart where you |
|
| 157 | - * know the grand total line item on it |
|
| 158 | - * |
|
| 159 | - * @param EE_Line_Item $line_item |
|
| 160 | - */ |
|
| 161 | - public function set_grand_total_line_item(EE_Line_Item $line_item) |
|
| 162 | - { |
|
| 163 | - $this->_grand_total = $line_item; |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - |
|
| 167 | - |
|
| 168 | - /** |
|
| 169 | - * get_cart_from_reg_url_link |
|
| 170 | - * |
|
| 171 | - * @access public |
|
| 172 | - * @param EE_Transaction $transaction |
|
| 173 | - * @param EE_Session $session |
|
| 174 | - * @return \EE_Cart |
|
| 175 | - * @throws \EE_Error |
|
| 176 | - */ |
|
| 177 | - public static function get_cart_from_txn(EE_Transaction $transaction, EE_Session $session = null) |
|
| 178 | - { |
|
| 179 | - $grand_total = $transaction->total_line_item(); |
|
| 180 | - $grand_total->get_items(); |
|
| 181 | - $grand_total->tax_descendants(); |
|
| 182 | - return EE_Cart::instance($grand_total, $session); |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - |
|
| 186 | - |
|
| 187 | - /** |
|
| 188 | - * Creates the total line item, and ensures it has its 'tickets' and 'taxes' sub-items |
|
| 189 | - * |
|
| 190 | - * @return EE_Line_Item |
|
| 191 | - * @throws \EE_Error |
|
| 192 | - */ |
|
| 193 | - private function _create_grand_total() |
|
| 194 | - { |
|
| 195 | - $this->_grand_total = EEH_Line_Item::create_total_line_item(); |
|
| 196 | - return $this->_grand_total; |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - |
|
| 200 | - |
|
| 201 | - /** |
|
| 202 | - * Gets all the line items of object type Ticket |
|
| 203 | - * |
|
| 204 | - * @access public |
|
| 205 | - * @return \EE_Line_Item[] |
|
| 206 | - */ |
|
| 207 | - public function get_tickets() |
|
| 208 | - { |
|
| 209 | - if ($this->_grand_total === null ) { |
|
| 210 | - return array(); |
|
| 211 | - } |
|
| 212 | - return EEH_Line_Item::get_ticket_line_items($this->_grand_total); |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - |
|
| 216 | - |
|
| 217 | - /** |
|
| 218 | - * returns the total quantity of tickets in the cart |
|
| 219 | - * |
|
| 220 | - * @access public |
|
| 221 | - * @return int |
|
| 222 | - * @throws \EE_Error |
|
| 223 | - */ |
|
| 224 | - public function all_ticket_quantity_count() |
|
| 225 | - { |
|
| 226 | - $tickets = $this->get_tickets(); |
|
| 227 | - if (empty($tickets)) { |
|
| 228 | - return 0; |
|
| 229 | - } |
|
| 230 | - $count = 0; |
|
| 231 | - foreach ($tickets as $ticket) { |
|
| 232 | - $count += $ticket->get('LIN_quantity'); |
|
| 233 | - } |
|
| 234 | - return $count; |
|
| 235 | - } |
|
| 236 | - |
|
| 237 | - |
|
| 238 | - |
|
| 239 | - /** |
|
| 240 | - * Gets all the tax line items |
|
| 241 | - * |
|
| 242 | - * @return \EE_Line_Item[] |
|
| 243 | - * @throws \EE_Error |
|
| 244 | - */ |
|
| 245 | - public function get_taxes() |
|
| 246 | - { |
|
| 247 | - return EEH_Line_Item::get_taxes_subtotal($this->_grand_total)->children(); |
|
| 248 | - } |
|
| 249 | - |
|
| 250 | - |
|
| 251 | - |
|
| 252 | - /** |
|
| 253 | - * Gets the total line item (which is a parent of all other line items) on this cart |
|
| 254 | - * |
|
| 255 | - * @return EE_Line_Item |
|
| 256 | - * @throws \EE_Error |
|
| 257 | - */ |
|
| 258 | - public function get_grand_total() |
|
| 259 | - { |
|
| 260 | - return $this->_grand_total instanceof EE_Line_Item ? $this->_grand_total : $this->_create_grand_total(); |
|
| 261 | - } |
|
| 262 | - |
|
| 263 | - |
|
| 264 | - |
|
| 265 | - /** |
|
| 266 | - * @process items for adding to cart |
|
| 267 | - * @access public |
|
| 268 | - * @param EE_Ticket $ticket |
|
| 269 | - * @param int $qty |
|
| 270 | - * @return TRUE on success, FALSE on fail |
|
| 271 | - * @throws \EE_Error |
|
| 272 | - */ |
|
| 273 | - public function add_ticket_to_cart(EE_Ticket $ticket, $qty = 1) |
|
| 274 | - { |
|
| 275 | - EEH_Line_Item::add_ticket_purchase($this->get_grand_total(), $ticket, $qty); |
|
| 276 | - return $this->save_cart() ? true : false; |
|
| 277 | - } |
|
| 278 | - |
|
| 279 | - |
|
| 280 | - |
|
| 281 | - /** |
|
| 282 | - * get_cart_total_before_tax |
|
| 283 | - * |
|
| 284 | - * @access public |
|
| 285 | - * @return float |
|
| 286 | - * @throws \EE_Error |
|
| 287 | - */ |
|
| 288 | - public function get_cart_total_before_tax() |
|
| 289 | - { |
|
| 290 | - return $this->get_grand_total()->recalculate_pre_tax_total(); |
|
| 291 | - } |
|
| 292 | - |
|
| 293 | - |
|
| 294 | - |
|
| 295 | - /** |
|
| 296 | - * gets the total amount of tax paid for items in this cart |
|
| 297 | - * |
|
| 298 | - * @access public |
|
| 299 | - * @return float |
|
| 300 | - * @throws \EE_Error |
|
| 301 | - */ |
|
| 302 | - public function get_applied_taxes() |
|
| 303 | - { |
|
| 304 | - return EEH_Line_Item::ensure_taxes_applied($this->_grand_total); |
|
| 305 | - } |
|
| 306 | - |
|
| 307 | - |
|
| 308 | - |
|
| 309 | - /** |
|
| 310 | - * Gets the total amount to be paid for the items in the cart, including taxes and other modifiers |
|
| 311 | - * |
|
| 312 | - * @access public |
|
| 313 | - * @return float |
|
| 314 | - * @throws \EE_Error |
|
| 315 | - */ |
|
| 316 | - public function get_cart_grand_total() |
|
| 317 | - { |
|
| 318 | - EEH_Line_Item::ensure_taxes_applied($this->_grand_total); |
|
| 319 | - return $this->get_grand_total()->total(); |
|
| 320 | - } |
|
| 321 | - |
|
| 322 | - |
|
| 323 | - |
|
| 324 | - /** |
|
| 325 | - * Gets the total amount to be paid for the items in the cart, including taxes and other modifiers |
|
| 326 | - * |
|
| 327 | - * @access public |
|
| 328 | - * @return float |
|
| 329 | - * @throws \EE_Error |
|
| 330 | - */ |
|
| 331 | - public function recalculate_all_cart_totals() |
|
| 332 | - { |
|
| 333 | - $pre_tax_total = $this->get_cart_total_before_tax(); |
|
| 334 | - $taxes_total = EEH_Line_Item::ensure_taxes_applied($this->_grand_total); |
|
| 335 | - $this->_grand_total->set_total($pre_tax_total + $taxes_total); |
|
| 336 | - $this->_grand_total->save_this_and_descendants_to_txn(); |
|
| 337 | - return $this->get_grand_total()->total(); |
|
| 338 | - } |
|
| 339 | - |
|
| 340 | - |
|
| 341 | - |
|
| 342 | - /** |
|
| 343 | - * deletes an item from the cart |
|
| 344 | - * |
|
| 345 | - * @access public |
|
| 346 | - * @param array|bool|string $line_item_codes |
|
| 347 | - * @return int on success, FALSE on fail |
|
| 348 | - * @throws \EE_Error |
|
| 349 | - */ |
|
| 350 | - public function delete_items($line_item_codes = false) |
|
| 351 | - { |
|
| 352 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 353 | - return EEH_Line_Item::delete_items($this->get_grand_total(), $line_item_codes); |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - |
|
| 357 | - |
|
| 358 | - /** |
|
| 359 | - * @remove ALL items from cart and zero ALL totals |
|
| 360 | - * @access public |
|
| 361 | - * @return bool |
|
| 362 | - * @throws \EE_Error |
|
| 363 | - */ |
|
| 364 | - public function empty_cart() |
|
| 365 | - { |
|
| 366 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 367 | - $this->_grand_total = $this->_create_grand_total(); |
|
| 368 | - return $this->save_cart(true); |
|
| 369 | - } |
|
| 370 | - |
|
| 371 | - |
|
| 372 | - |
|
| 373 | - /** |
|
| 374 | - * @remove ALL items from cart and delete total as well |
|
| 375 | - * @access public |
|
| 376 | - * @return bool |
|
| 377 | - * @throws \EE_Error |
|
| 378 | - */ |
|
| 379 | - public function delete_cart() |
|
| 380 | - { |
|
| 381 | - if ($this->_grand_total instanceof EE_Line_Item) { |
|
| 382 | - $deleted = EEH_Line_Item::delete_all_child_items($this->_grand_total); |
|
| 383 | - if ($deleted) { |
|
| 384 | - $deleted += $this->_grand_total->delete(); |
|
| 385 | - $this->_grand_total = null; |
|
| 386 | - return true; |
|
| 387 | - } |
|
| 388 | - } |
|
| 389 | - return false; |
|
| 390 | - } |
|
| 391 | - |
|
| 392 | - |
|
| 393 | - |
|
| 394 | - /** |
|
| 395 | - * @save cart to session |
|
| 396 | - * @access public |
|
| 397 | - * @param bool $apply_taxes |
|
| 398 | - * @return TRUE on success, FALSE on fail |
|
| 399 | - * @throws \EE_Error |
|
| 400 | - */ |
|
| 401 | - public function save_cart($apply_taxes = true) |
|
| 402 | - { |
|
| 403 | - if ($apply_taxes && $this->_grand_total instanceof EE_Line_Item) { |
|
| 404 | - EEH_Line_Item::ensure_taxes_applied($this->_grand_total); |
|
| 405 | - //make sure we don't cache the transaction because it can get stale |
|
| 406 | - if ($this->_grand_total->get_one_from_cache('Transaction') instanceof EE_Transaction |
|
| 407 | - && $this->_grand_total->get_one_from_cache('Transaction')->ID() |
|
| 408 | - ) { |
|
| 409 | - $this->_grand_total->clear_cache('Transaction', null, true); |
|
| 410 | - } |
|
| 411 | - } |
|
| 412 | - if ($this->session() instanceof EE_Session) { |
|
| 413 | - return $this->session()->set_cart($this); |
|
| 414 | - } else { |
|
| 415 | - return false; |
|
| 416 | - } |
|
| 417 | - } |
|
| 418 | - |
|
| 419 | - |
|
| 420 | - |
|
| 421 | - public function __wakeup() |
|
| 422 | - { |
|
| 423 | - if ( ! $this->_grand_total instanceof EE_Line_Item && absint($this->_grand_total) !== 0) { |
|
| 424 | - // $this->_grand_total is actually just an ID, so use it to get the object from the db |
|
| 425 | - $this->_grand_total = EEM_Line_Item::instance()->get_one_by_ID($this->_grand_total); |
|
| 426 | - } |
|
| 427 | - } |
|
| 428 | - |
|
| 429 | - |
|
| 430 | - |
|
| 431 | - /** |
|
| 432 | - * @return array |
|
| 433 | - */ |
|
| 434 | - public function __sleep() |
|
| 435 | - { |
|
| 436 | - if ($this->_grand_total instanceof EE_Line_Item && $this->_grand_total->ID()) { |
|
| 437 | - $this->_grand_total = $this->_grand_total->ID(); |
|
| 438 | - } |
|
| 439 | - return array('_grand_total'); |
|
| 440 | - } |
|
| 26 | + /** |
|
| 27 | + * instance of the EE_Cart object |
|
| 28 | + * |
|
| 29 | + * @access private |
|
| 30 | + * @var EE_Cart $_instance |
|
| 31 | + */ |
|
| 32 | + private static $_instance; |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * instance of the EE_Session object |
|
| 36 | + * |
|
| 37 | + * @access protected |
|
| 38 | + * @var EE_Session $_session |
|
| 39 | + */ |
|
| 40 | + protected $_session; |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * The total Line item which comprises all the children line-item subtotals, |
|
| 44 | + * which in turn each have their line items. |
|
| 45 | + * Typically, the line item structure will look like: |
|
| 46 | + * grand total |
|
| 47 | + * -tickets-sub-total |
|
| 48 | + * --ticket1 |
|
| 49 | + * --ticket2 |
|
| 50 | + * --... |
|
| 51 | + * -taxes-sub-total |
|
| 52 | + * --tax1 |
|
| 53 | + * --tax2 |
|
| 54 | + * |
|
| 55 | + * @var EE_Line_Item |
|
| 56 | + */ |
|
| 57 | + private $_grand_total; |
|
| 58 | + |
|
| 59 | + |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * @singleton method used to instantiate class object |
|
| 63 | + * @access public |
|
| 64 | + * @param EE_Line_Item $grand_total |
|
| 65 | + * @param EE_Session $session |
|
| 66 | + * @return \EE_Cart |
|
| 67 | + * @throws \EE_Error |
|
| 68 | + */ |
|
| 69 | + public static function instance(EE_Line_Item $grand_total = null, EE_Session $session = null) |
|
| 70 | + { |
|
| 71 | + if ($grand_total instanceof EE_Line_Item && $grand_total->is_total()) { |
|
| 72 | + self::$_instance = new self($grand_total, $session); |
|
| 73 | + } |
|
| 74 | + // or maybe retrieve an existing one ? |
|
| 75 | + if ( ! self::$_instance instanceof EE_Cart) { |
|
| 76 | + // try getting the cart out of the session |
|
| 77 | + $saved_cart = $session instanceof EE_Session ? $session->cart() : null; |
|
| 78 | + self::$_instance = $saved_cart instanceof EE_Cart ? $saved_cart : new self($grand_total, $session); |
|
| 79 | + unset($saved_cart); |
|
| 80 | + } |
|
| 81 | + // verify that cart is ok and grand total line item exists |
|
| 82 | + if ( ! self::$_instance instanceof EE_Cart || ! self::$_instance->_grand_total instanceof EE_Line_Item) { |
|
| 83 | + self::$_instance = new self($grand_total, $session); |
|
| 84 | + } |
|
| 85 | + self::$_instance->get_grand_total(); |
|
| 86 | + // once everything is all said and done, save the cart to the EE_Session |
|
| 87 | + add_action('shutdown', array(self::$_instance, 'save_cart'), 90); |
|
| 88 | + return self::$_instance; |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * private constructor to prevent direct creation |
|
| 95 | + * |
|
| 96 | + * @Constructor |
|
| 97 | + * @access private |
|
| 98 | + * @param EE_Line_Item $grand_total |
|
| 99 | + * @param EE_Session $session |
|
| 100 | + */ |
|
| 101 | + private function __construct(EE_Line_Item $grand_total = null, EE_Session $session = null) |
|
| 102 | + { |
|
| 103 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 104 | + $this->set_session($session); |
|
| 105 | + if ($grand_total instanceof EE_Line_Item && $grand_total->is_total()) { |
|
| 106 | + $this->set_grand_total_line_item($grand_total); |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * Resets the cart completely (whereas empty_cart |
|
| 114 | + * |
|
| 115 | + * @param EE_Line_Item $grand_total |
|
| 116 | + * @param EE_Session $session |
|
| 117 | + * @return EE_Cart |
|
| 118 | + * @throws \EE_Error |
|
| 119 | + */ |
|
| 120 | + public static function reset(EE_Line_Item $grand_total = null, EE_Session $session = null) |
|
| 121 | + { |
|
| 122 | + remove_action('shutdown', array(self::$_instance, 'save_cart'), 90); |
|
| 123 | + if ($session instanceof EE_Session) { |
|
| 124 | + $session->reset_cart(); |
|
| 125 | + } |
|
| 126 | + self::$_instance = null; |
|
| 127 | + return self::instance($grand_total, $session); |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * @return \EE_Session |
|
| 134 | + */ |
|
| 135 | + public function session() |
|
| 136 | + { |
|
| 137 | + if ( ! $this->_session instanceof EE_Session) { |
|
| 138 | + $this->set_session(); |
|
| 139 | + } |
|
| 140 | + return $this->_session; |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + |
|
| 144 | + |
|
| 145 | + /** |
|
| 146 | + * @param EE_Session $session |
|
| 147 | + */ |
|
| 148 | + public function set_session(EE_Session $session = null) |
|
| 149 | + { |
|
| 150 | + $this->_session = $session instanceof EE_Session ? $session : EE_Registry::instance()->load_core('Session'); |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + |
|
| 154 | + |
|
| 155 | + /** |
|
| 156 | + * Sets the cart to match the line item. Especially handy for loading an old cart where you |
|
| 157 | + * know the grand total line item on it |
|
| 158 | + * |
|
| 159 | + * @param EE_Line_Item $line_item |
|
| 160 | + */ |
|
| 161 | + public function set_grand_total_line_item(EE_Line_Item $line_item) |
|
| 162 | + { |
|
| 163 | + $this->_grand_total = $line_item; |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + |
|
| 167 | + |
|
| 168 | + /** |
|
| 169 | + * get_cart_from_reg_url_link |
|
| 170 | + * |
|
| 171 | + * @access public |
|
| 172 | + * @param EE_Transaction $transaction |
|
| 173 | + * @param EE_Session $session |
|
| 174 | + * @return \EE_Cart |
|
| 175 | + * @throws \EE_Error |
|
| 176 | + */ |
|
| 177 | + public static function get_cart_from_txn(EE_Transaction $transaction, EE_Session $session = null) |
|
| 178 | + { |
|
| 179 | + $grand_total = $transaction->total_line_item(); |
|
| 180 | + $grand_total->get_items(); |
|
| 181 | + $grand_total->tax_descendants(); |
|
| 182 | + return EE_Cart::instance($grand_total, $session); |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + |
|
| 186 | + |
|
| 187 | + /** |
|
| 188 | + * Creates the total line item, and ensures it has its 'tickets' and 'taxes' sub-items |
|
| 189 | + * |
|
| 190 | + * @return EE_Line_Item |
|
| 191 | + * @throws \EE_Error |
|
| 192 | + */ |
|
| 193 | + private function _create_grand_total() |
|
| 194 | + { |
|
| 195 | + $this->_grand_total = EEH_Line_Item::create_total_line_item(); |
|
| 196 | + return $this->_grand_total; |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + |
|
| 200 | + |
|
| 201 | + /** |
|
| 202 | + * Gets all the line items of object type Ticket |
|
| 203 | + * |
|
| 204 | + * @access public |
|
| 205 | + * @return \EE_Line_Item[] |
|
| 206 | + */ |
|
| 207 | + public function get_tickets() |
|
| 208 | + { |
|
| 209 | + if ($this->_grand_total === null ) { |
|
| 210 | + return array(); |
|
| 211 | + } |
|
| 212 | + return EEH_Line_Item::get_ticket_line_items($this->_grand_total); |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + |
|
| 216 | + |
|
| 217 | + /** |
|
| 218 | + * returns the total quantity of tickets in the cart |
|
| 219 | + * |
|
| 220 | + * @access public |
|
| 221 | + * @return int |
|
| 222 | + * @throws \EE_Error |
|
| 223 | + */ |
|
| 224 | + public function all_ticket_quantity_count() |
|
| 225 | + { |
|
| 226 | + $tickets = $this->get_tickets(); |
|
| 227 | + if (empty($tickets)) { |
|
| 228 | + return 0; |
|
| 229 | + } |
|
| 230 | + $count = 0; |
|
| 231 | + foreach ($tickets as $ticket) { |
|
| 232 | + $count += $ticket->get('LIN_quantity'); |
|
| 233 | + } |
|
| 234 | + return $count; |
|
| 235 | + } |
|
| 236 | + |
|
| 237 | + |
|
| 238 | + |
|
| 239 | + /** |
|
| 240 | + * Gets all the tax line items |
|
| 241 | + * |
|
| 242 | + * @return \EE_Line_Item[] |
|
| 243 | + * @throws \EE_Error |
|
| 244 | + */ |
|
| 245 | + public function get_taxes() |
|
| 246 | + { |
|
| 247 | + return EEH_Line_Item::get_taxes_subtotal($this->_grand_total)->children(); |
|
| 248 | + } |
|
| 249 | + |
|
| 250 | + |
|
| 251 | + |
|
| 252 | + /** |
|
| 253 | + * Gets the total line item (which is a parent of all other line items) on this cart |
|
| 254 | + * |
|
| 255 | + * @return EE_Line_Item |
|
| 256 | + * @throws \EE_Error |
|
| 257 | + */ |
|
| 258 | + public function get_grand_total() |
|
| 259 | + { |
|
| 260 | + return $this->_grand_total instanceof EE_Line_Item ? $this->_grand_total : $this->_create_grand_total(); |
|
| 261 | + } |
|
| 262 | + |
|
| 263 | + |
|
| 264 | + |
|
| 265 | + /** |
|
| 266 | + * @process items for adding to cart |
|
| 267 | + * @access public |
|
| 268 | + * @param EE_Ticket $ticket |
|
| 269 | + * @param int $qty |
|
| 270 | + * @return TRUE on success, FALSE on fail |
|
| 271 | + * @throws \EE_Error |
|
| 272 | + */ |
|
| 273 | + public function add_ticket_to_cart(EE_Ticket $ticket, $qty = 1) |
|
| 274 | + { |
|
| 275 | + EEH_Line_Item::add_ticket_purchase($this->get_grand_total(), $ticket, $qty); |
|
| 276 | + return $this->save_cart() ? true : false; |
|
| 277 | + } |
|
| 278 | + |
|
| 279 | + |
|
| 280 | + |
|
| 281 | + /** |
|
| 282 | + * get_cart_total_before_tax |
|
| 283 | + * |
|
| 284 | + * @access public |
|
| 285 | + * @return float |
|
| 286 | + * @throws \EE_Error |
|
| 287 | + */ |
|
| 288 | + public function get_cart_total_before_tax() |
|
| 289 | + { |
|
| 290 | + return $this->get_grand_total()->recalculate_pre_tax_total(); |
|
| 291 | + } |
|
| 292 | + |
|
| 293 | + |
|
| 294 | + |
|
| 295 | + /** |
|
| 296 | + * gets the total amount of tax paid for items in this cart |
|
| 297 | + * |
|
| 298 | + * @access public |
|
| 299 | + * @return float |
|
| 300 | + * @throws \EE_Error |
|
| 301 | + */ |
|
| 302 | + public function get_applied_taxes() |
|
| 303 | + { |
|
| 304 | + return EEH_Line_Item::ensure_taxes_applied($this->_grand_total); |
|
| 305 | + } |
|
| 306 | + |
|
| 307 | + |
|
| 308 | + |
|
| 309 | + /** |
|
| 310 | + * Gets the total amount to be paid for the items in the cart, including taxes and other modifiers |
|
| 311 | + * |
|
| 312 | + * @access public |
|
| 313 | + * @return float |
|
| 314 | + * @throws \EE_Error |
|
| 315 | + */ |
|
| 316 | + public function get_cart_grand_total() |
|
| 317 | + { |
|
| 318 | + EEH_Line_Item::ensure_taxes_applied($this->_grand_total); |
|
| 319 | + return $this->get_grand_total()->total(); |
|
| 320 | + } |
|
| 321 | + |
|
| 322 | + |
|
| 323 | + |
|
| 324 | + /** |
|
| 325 | + * Gets the total amount to be paid for the items in the cart, including taxes and other modifiers |
|
| 326 | + * |
|
| 327 | + * @access public |
|
| 328 | + * @return float |
|
| 329 | + * @throws \EE_Error |
|
| 330 | + */ |
|
| 331 | + public function recalculate_all_cart_totals() |
|
| 332 | + { |
|
| 333 | + $pre_tax_total = $this->get_cart_total_before_tax(); |
|
| 334 | + $taxes_total = EEH_Line_Item::ensure_taxes_applied($this->_grand_total); |
|
| 335 | + $this->_grand_total->set_total($pre_tax_total + $taxes_total); |
|
| 336 | + $this->_grand_total->save_this_and_descendants_to_txn(); |
|
| 337 | + return $this->get_grand_total()->total(); |
|
| 338 | + } |
|
| 339 | + |
|
| 340 | + |
|
| 341 | + |
|
| 342 | + /** |
|
| 343 | + * deletes an item from the cart |
|
| 344 | + * |
|
| 345 | + * @access public |
|
| 346 | + * @param array|bool|string $line_item_codes |
|
| 347 | + * @return int on success, FALSE on fail |
|
| 348 | + * @throws \EE_Error |
|
| 349 | + */ |
|
| 350 | + public function delete_items($line_item_codes = false) |
|
| 351 | + { |
|
| 352 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 353 | + return EEH_Line_Item::delete_items($this->get_grand_total(), $line_item_codes); |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + |
|
| 357 | + |
|
| 358 | + /** |
|
| 359 | + * @remove ALL items from cart and zero ALL totals |
|
| 360 | + * @access public |
|
| 361 | + * @return bool |
|
| 362 | + * @throws \EE_Error |
|
| 363 | + */ |
|
| 364 | + public function empty_cart() |
|
| 365 | + { |
|
| 366 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 367 | + $this->_grand_total = $this->_create_grand_total(); |
|
| 368 | + return $this->save_cart(true); |
|
| 369 | + } |
|
| 370 | + |
|
| 371 | + |
|
| 372 | + |
|
| 373 | + /** |
|
| 374 | + * @remove ALL items from cart and delete total as well |
|
| 375 | + * @access public |
|
| 376 | + * @return bool |
|
| 377 | + * @throws \EE_Error |
|
| 378 | + */ |
|
| 379 | + public function delete_cart() |
|
| 380 | + { |
|
| 381 | + if ($this->_grand_total instanceof EE_Line_Item) { |
|
| 382 | + $deleted = EEH_Line_Item::delete_all_child_items($this->_grand_total); |
|
| 383 | + if ($deleted) { |
|
| 384 | + $deleted += $this->_grand_total->delete(); |
|
| 385 | + $this->_grand_total = null; |
|
| 386 | + return true; |
|
| 387 | + } |
|
| 388 | + } |
|
| 389 | + return false; |
|
| 390 | + } |
|
| 391 | + |
|
| 392 | + |
|
| 393 | + |
|
| 394 | + /** |
|
| 395 | + * @save cart to session |
|
| 396 | + * @access public |
|
| 397 | + * @param bool $apply_taxes |
|
| 398 | + * @return TRUE on success, FALSE on fail |
|
| 399 | + * @throws \EE_Error |
|
| 400 | + */ |
|
| 401 | + public function save_cart($apply_taxes = true) |
|
| 402 | + { |
|
| 403 | + if ($apply_taxes && $this->_grand_total instanceof EE_Line_Item) { |
|
| 404 | + EEH_Line_Item::ensure_taxes_applied($this->_grand_total); |
|
| 405 | + //make sure we don't cache the transaction because it can get stale |
|
| 406 | + if ($this->_grand_total->get_one_from_cache('Transaction') instanceof EE_Transaction |
|
| 407 | + && $this->_grand_total->get_one_from_cache('Transaction')->ID() |
|
| 408 | + ) { |
|
| 409 | + $this->_grand_total->clear_cache('Transaction', null, true); |
|
| 410 | + } |
|
| 411 | + } |
|
| 412 | + if ($this->session() instanceof EE_Session) { |
|
| 413 | + return $this->session()->set_cart($this); |
|
| 414 | + } else { |
|
| 415 | + return false; |
|
| 416 | + } |
|
| 417 | + } |
|
| 418 | + |
|
| 419 | + |
|
| 420 | + |
|
| 421 | + public function __wakeup() |
|
| 422 | + { |
|
| 423 | + if ( ! $this->_grand_total instanceof EE_Line_Item && absint($this->_grand_total) !== 0) { |
|
| 424 | + // $this->_grand_total is actually just an ID, so use it to get the object from the db |
|
| 425 | + $this->_grand_total = EEM_Line_Item::instance()->get_one_by_ID($this->_grand_total); |
|
| 426 | + } |
|
| 427 | + } |
|
| 428 | + |
|
| 429 | + |
|
| 430 | + |
|
| 431 | + /** |
|
| 432 | + * @return array |
|
| 433 | + */ |
|
| 434 | + public function __sleep() |
|
| 435 | + { |
|
| 436 | + if ($this->_grand_total instanceof EE_Line_Item && $this->_grand_total->ID()) { |
|
| 437 | + $this->_grand_total = $this->_grand_total->ID(); |
|
| 438 | + } |
|
| 439 | + return array('_grand_total'); |
|
| 440 | + } |
|
| 441 | 441 | |
| 442 | 442 | |
| 443 | 443 | } |
@@ -23,14 +23,14 @@ |
||
| 23 | 23 | class CartFactory |
| 24 | 24 | { |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * @return EE_Cart |
|
| 28 | - * @throws InvalidArgumentException |
|
| 29 | - * @throws InvalidInterfaceException |
|
| 30 | - * @throws InvalidDataTypeException |
|
| 31 | - */ |
|
| 32 | - public static function getCart() |
|
| 33 | - { |
|
| 34 | - return LoaderFactory::getLoader()->getShared('EE_Cart'); |
|
| 35 | - } |
|
| 26 | + /** |
|
| 27 | + * @return EE_Cart |
|
| 28 | + * @throws InvalidArgumentException |
|
| 29 | + * @throws InvalidInterfaceException |
|
| 30 | + * @throws InvalidDataTypeException |
|
| 31 | + */ |
|
| 32 | + public static function getCart() |
|
| 33 | + { |
|
| 34 | + return LoaderFactory::getLoader()->getShared('EE_Cart'); |
|
| 35 | + } |
|
| 36 | 36 | } |
@@ -25,17 +25,17 @@ |
||
| 25 | 25 | class ModelFactory |
| 26 | 26 | { |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * @param string $model_name |
|
| 30 | - * @return bool|EEM_Base |
|
| 31 | - * @throws EE_Error |
|
| 32 | - * @throws InvalidDataTypeException |
|
| 33 | - * @throws InvalidInterfaceException |
|
| 34 | - * @throws InvalidArgumentException |
|
| 35 | - * @throws ReflectionException |
|
| 36 | - */ |
|
| 37 | - public static function getModel($model_name) |
|
| 38 | - { |
|
| 39 | - return EE_Registry::instance()->load_model($model_name); |
|
| 40 | - } |
|
| 28 | + /** |
|
| 29 | + * @param string $model_name |
|
| 30 | + * @return bool|EEM_Base |
|
| 31 | + * @throws EE_Error |
|
| 32 | + * @throws InvalidDataTypeException |
|
| 33 | + * @throws InvalidInterfaceException |
|
| 34 | + * @throws InvalidArgumentException |
|
| 35 | + * @throws ReflectionException |
|
| 36 | + */ |
|
| 37 | + public static function getModel($model_name) |
|
| 38 | + { |
|
| 39 | + return EE_Registry::instance()->load_model($model_name); |
|
| 40 | + } |
|
| 41 | 41 | } |
@@ -66,24 +66,24 @@ discard block |
||
| 66 | 66 | public function ticketDatetimeAvailability(EE_Ticket $ticket, $get_original_ticket_spaces = false) |
| 67 | 67 | { |
| 68 | 68 | // if the $_available_spaces array has not been set up yet... |
| 69 | - if (! isset($this->available_spaces['tickets'][ $ticket->ID() ])) { |
|
| 69 | + if ( ! isset($this->available_spaces['tickets'][$ticket->ID()])) { |
|
| 70 | 70 | $this->setInitialTicketDatetimeAvailability($ticket); |
| 71 | 71 | } |
| 72 | 72 | $available_spaces = $ticket->qty() - $ticket->sold(); |
| 73 | - if (isset($this->available_spaces['tickets'][ $ticket->ID() ])) { |
|
| 73 | + if (isset($this->available_spaces['tickets'][$ticket->ID()])) { |
|
| 74 | 74 | // loop thru tickets, which will ALSO include individual ticket records AND a total |
| 75 | - foreach ($this->available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces) { |
|
| 75 | + foreach ($this->available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) { |
|
| 76 | 76 | // if we want the original datetime availability BEFORE we started subtracting tickets ? |
| 77 | 77 | if ($get_original_ticket_spaces) { |
| 78 | 78 | // then grab the available spaces from the "tickets" array |
| 79 | 79 | // and compare with the above to get the lowest number |
| 80 | 80 | $available_spaces = min( |
| 81 | 81 | $available_spaces, |
| 82 | - $this->available_spaces['tickets'][ $ticket->ID() ][ $DTD_ID ] |
|
| 82 | + $this->available_spaces['tickets'][$ticket->ID()][$DTD_ID] |
|
| 83 | 83 | ); |
| 84 | 84 | } else { |
| 85 | 85 | // we want the updated ticket availability as stored in the "datetimes" array |
| 86 | - $available_spaces = min($available_spaces, $this->available_spaces['datetimes'][ $DTD_ID ]); |
|
| 86 | + $available_spaces = min($available_spaces, $this->available_spaces['datetimes'][$DTD_ID]); |
|
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | 89 | } |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | 'order_by' => array('DTT_EVT_start' => 'ASC'), |
| 115 | 115 | ) |
| 116 | 116 | ); |
| 117 | - if (! empty($datetimes)) { |
|
| 117 | + if ( ! empty($datetimes)) { |
|
| 118 | 118 | // now loop thru all of the datetimes |
| 119 | 119 | foreach ($datetimes as $datetime) { |
| 120 | 120 | if ($datetime instanceof EE_Datetime) { |
@@ -122,17 +122,17 @@ discard block |
||
| 122 | 122 | $spaces_remaining = $datetime->spaces_remaining(); |
| 123 | 123 | // save the total available spaces ( the lesser of the ticket qty minus the number of tickets sold |
| 124 | 124 | // or the datetime spaces remaining) to this ticket using the datetime ID as the key |
| 125 | - $this->available_spaces['tickets'][ $ticket->ID() ][ $datetime->ID() ] = min( |
|
| 125 | + $this->available_spaces['tickets'][$ticket->ID()][$datetime->ID()] = min( |
|
| 126 | 126 | $ticket->qty() - $ticket->sold(), |
| 127 | 127 | $spaces_remaining |
| 128 | 128 | ); |
| 129 | 129 | // if the remaining spaces for this datetime is already set, |
| 130 | 130 | // then compare that against the datetime spaces remaining, and take the lowest number, |
| 131 | 131 | // else just take the datetime spaces remaining, and assign to the datetimes array |
| 132 | - $this->available_spaces['datetimes'][ $datetime->ID() ] = isset( |
|
| 133 | - $this->available_spaces['datetimes'][ $datetime->ID() ] |
|
| 132 | + $this->available_spaces['datetimes'][$datetime->ID()] = isset( |
|
| 133 | + $this->available_spaces['datetimes'][$datetime->ID()] |
|
| 134 | 134 | ) |
| 135 | - ? min($this->available_spaces['datetimes'][ $datetime->ID() ], $spaces_remaining) |
|
| 135 | + ? min($this->available_spaces['datetimes'][$datetime->ID()], $spaces_remaining) |
|
| 136 | 136 | : $spaces_remaining; |
| 137 | 137 | } |
| 138 | 138 | } |
@@ -148,11 +148,11 @@ discard block |
||
| 148 | 148 | */ |
| 149 | 149 | public function recalculateTicketDatetimeAvailability(EE_Ticket $ticket, $qty = 0) |
| 150 | 150 | { |
| 151 | - if (isset($this->available_spaces['tickets'][ $ticket->ID() ])) { |
|
| 151 | + if (isset($this->available_spaces['tickets'][$ticket->ID()])) { |
|
| 152 | 152 | // loop thru tickets, which will ALSO include individual ticket records AND a total |
| 153 | - foreach ($this->available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces) { |
|
| 153 | + foreach ($this->available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) { |
|
| 154 | 154 | // subtract the qty of selected tickets from each datetime's available spaces this ticket has access to, |
| 155 | - $this->available_spaces['datetimes'][ $DTD_ID ] -= $qty; |
|
| 155 | + $this->available_spaces['datetimes'][$DTD_ID] -= $qty; |
|
| 156 | 156 | } |
| 157 | 157 | } |
| 158 | 158 | } |
@@ -26,215 +26,215 @@ |
||
| 26 | 26 | class TicketDatetimeAvailabilityTracker |
| 27 | 27 | { |
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * array of datetimes and the spaces available for them |
|
| 31 | - * |
|
| 32 | - * @var array[][] |
|
| 33 | - */ |
|
| 34 | - private $available_spaces = array(); |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * @var EEM_Datetime $datetime_model |
|
| 38 | - */ |
|
| 39 | - private $datetime_model; |
|
| 40 | - |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * TicketDatetimeAvailabilityTracker constructor. |
|
| 44 | - * |
|
| 45 | - * @param EEM_Datetime $datetime_model |
|
| 46 | - */ |
|
| 47 | - public function __construct(EEM_Datetime $datetime_model) |
|
| 48 | - { |
|
| 49 | - $this->datetime_model = $datetime_model; |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * ticketDatetimeAvailability |
|
| 55 | - * creates an array of tickets plus all of the datetimes available to each ticket |
|
| 56 | - * and tracks the spaces remaining for each of those datetimes |
|
| 57 | - * |
|
| 58 | - * @param EE_Ticket $ticket - selected ticket |
|
| 59 | - * @param bool $get_original_ticket_spaces |
|
| 60 | - * @return int |
|
| 61 | - * @throws EE_Error |
|
| 62 | - * @throws InvalidArgumentException |
|
| 63 | - * @throws InvalidDataTypeException |
|
| 64 | - * @throws InvalidInterfaceException |
|
| 65 | - */ |
|
| 66 | - public function ticketDatetimeAvailability(EE_Ticket $ticket, $get_original_ticket_spaces = false) |
|
| 67 | - { |
|
| 68 | - // if the $_available_spaces array has not been set up yet... |
|
| 69 | - if (! isset($this->available_spaces['tickets'][ $ticket->ID() ])) { |
|
| 70 | - $this->setInitialTicketDatetimeAvailability($ticket); |
|
| 71 | - } |
|
| 72 | - $available_spaces = $ticket->qty() - $ticket->sold(); |
|
| 73 | - if (isset($this->available_spaces['tickets'][ $ticket->ID() ])) { |
|
| 74 | - // loop thru tickets, which will ALSO include individual ticket records AND a total |
|
| 75 | - foreach ($this->available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces) { |
|
| 76 | - // if we want the original datetime availability BEFORE we started subtracting tickets ? |
|
| 77 | - if ($get_original_ticket_spaces) { |
|
| 78 | - // then grab the available spaces from the "tickets" array |
|
| 79 | - // and compare with the above to get the lowest number |
|
| 80 | - $available_spaces = min( |
|
| 81 | - $available_spaces, |
|
| 82 | - $this->available_spaces['tickets'][ $ticket->ID() ][ $DTD_ID ] |
|
| 83 | - ); |
|
| 84 | - } else { |
|
| 85 | - // we want the updated ticket availability as stored in the "datetimes" array |
|
| 86 | - $available_spaces = min($available_spaces, $this->available_spaces['datetimes'][ $DTD_ID ]); |
|
| 87 | - } |
|
| 88 | - } |
|
| 89 | - } |
|
| 90 | - return $available_spaces; |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - |
|
| 94 | - /** |
|
| 95 | - * @param EE_Ticket $ticket |
|
| 96 | - * @return void |
|
| 97 | - * @throws InvalidArgumentException |
|
| 98 | - * @throws InvalidInterfaceException |
|
| 99 | - * @throws InvalidDataTypeException |
|
| 100 | - * @throws EE_Error |
|
| 101 | - */ |
|
| 102 | - private function setInitialTicketDatetimeAvailability(EE_Ticket $ticket) |
|
| 103 | - { |
|
| 104 | - // first, get all of the datetimes that are available to this ticket |
|
| 105 | - $datetimes = $ticket->get_many_related( |
|
| 106 | - 'Datetime', |
|
| 107 | - array( |
|
| 108 | - array( |
|
| 109 | - 'DTT_EVT_end' => array( |
|
| 110 | - '>=', |
|
| 111 | - $this->datetime_model->current_time_for_query('DTT_EVT_end'), |
|
| 112 | - ), |
|
| 113 | - ), |
|
| 114 | - 'order_by' => array('DTT_EVT_start' => 'ASC'), |
|
| 115 | - ) |
|
| 116 | - ); |
|
| 117 | - if (! empty($datetimes)) { |
|
| 118 | - // now loop thru all of the datetimes |
|
| 119 | - foreach ($datetimes as $datetime) { |
|
| 120 | - if ($datetime instanceof EE_Datetime) { |
|
| 121 | - // the number of spaces available for the datetime without considering individual ticket quantities |
|
| 122 | - $spaces_remaining = $datetime->spaces_remaining(); |
|
| 123 | - // save the total available spaces ( the lesser of the ticket qty minus the number of tickets sold |
|
| 124 | - // or the datetime spaces remaining) to this ticket using the datetime ID as the key |
|
| 125 | - $this->available_spaces['tickets'][ $ticket->ID() ][ $datetime->ID() ] = min( |
|
| 126 | - $ticket->qty() - $ticket->sold(), |
|
| 127 | - $spaces_remaining |
|
| 128 | - ); |
|
| 129 | - // if the remaining spaces for this datetime is already set, |
|
| 130 | - // then compare that against the datetime spaces remaining, and take the lowest number, |
|
| 131 | - // else just take the datetime spaces remaining, and assign to the datetimes array |
|
| 132 | - $this->available_spaces['datetimes'][ $datetime->ID() ] = isset( |
|
| 133 | - $this->available_spaces['datetimes'][ $datetime->ID() ] |
|
| 134 | - ) |
|
| 135 | - ? min($this->available_spaces['datetimes'][ $datetime->ID() ], $spaces_remaining) |
|
| 136 | - : $spaces_remaining; |
|
| 137 | - } |
|
| 138 | - } |
|
| 139 | - } |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - |
|
| 143 | - /** |
|
| 144 | - * @param EE_Ticket $ticket |
|
| 145 | - * @param int $qty |
|
| 146 | - * @return void |
|
| 147 | - * @throws EE_Error |
|
| 148 | - */ |
|
| 149 | - public function recalculateTicketDatetimeAvailability(EE_Ticket $ticket, $qty = 0) |
|
| 150 | - { |
|
| 151 | - if (isset($this->available_spaces['tickets'][ $ticket->ID() ])) { |
|
| 152 | - // loop thru tickets, which will ALSO include individual ticket records AND a total |
|
| 153 | - foreach ($this->available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces) { |
|
| 154 | - // subtract the qty of selected tickets from each datetime's available spaces this ticket has access to, |
|
| 155 | - $this->available_spaces['datetimes'][ $DTD_ID ] -= $qty; |
|
| 156 | - } |
|
| 157 | - } |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - |
|
| 161 | - /** |
|
| 162 | - * @param EE_Ticket $ticket |
|
| 163 | - * @param $qty |
|
| 164 | - * @param int $total_ticket_count |
|
| 165 | - * @throws EE_Error |
|
| 166 | - * @throws InvalidArgumentException |
|
| 167 | - * @throws InvalidDataTypeException |
|
| 168 | - * @throws InvalidInterfaceException |
|
| 169 | - */ |
|
| 170 | - public function processAvailabilityError(EE_Ticket $ticket, $qty, $total_ticket_count = 1) |
|
| 171 | - { |
|
| 172 | - // tickets can not be purchased but let's find the exact number left |
|
| 173 | - // for the last ticket selected PRIOR to subtracting tickets |
|
| 174 | - $available_spaces = $this->ticketDatetimeAvailability($ticket, true); |
|
| 175 | - // greedy greedy greedy eh? |
|
| 176 | - if ($available_spaces > 0) { |
|
| 177 | - if ( |
|
| 178 | - apply_filters( |
|
| 179 | - 'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_display_availability_error', |
|
| 180 | - true, |
|
| 181 | - $ticket, |
|
| 182 | - $qty, |
|
| 183 | - $available_spaces |
|
| 184 | - ) |
|
| 185 | - ) { |
|
| 186 | - $this->availabilityError( |
|
| 187 | - $available_spaces, |
|
| 188 | - $total_ticket_count |
|
| 189 | - ); |
|
| 190 | - } |
|
| 191 | - } else { |
|
| 192 | - EE_Error::add_error( |
|
| 193 | - esc_html__( |
|
| 194 | - 'We\'re sorry, but there are no available spaces left for this event at this particular date and time.', |
|
| 195 | - 'event_espresso' |
|
| 196 | - ), |
|
| 197 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 198 | - ); |
|
| 199 | - } |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - |
|
| 203 | - /** |
|
| 204 | - * @param int $available_spaces |
|
| 205 | - * @param int $total_ticket_count |
|
| 206 | - */ |
|
| 207 | - private function availabilityError($available_spaces = 1, $total_ticket_count = 1) |
|
| 208 | - { |
|
| 209 | - // add error messaging - we're using the _n function that will generate |
|
| 210 | - // the appropriate singular or plural message based on the number of $available_spaces |
|
| 211 | - if ($total_ticket_count) { |
|
| 212 | - $msg = sprintf( |
|
| 213 | - esc_html( |
|
| 214 | - _n( |
|
| 215 | - 'We\'re sorry, but there is only %1$s available space left for this event at this particular date and time. Please select a different number (or different combination) of tickets by cancelling the current selection and choosing again, or proceed to registration.', |
|
| 216 | - 'We\'re sorry, but there are only %1$s available spaces left for this event at this particular date and time. Please select a different number (or different combination) of tickets by cancelling the current selection and choosing again, or proceed to registration.', |
|
| 217 | - $available_spaces, |
|
| 218 | - 'event_espresso' |
|
| 219 | - ) |
|
| 220 | - ), |
|
| 221 | - $available_spaces, |
|
| 222 | - '<br />' |
|
| 223 | - ); |
|
| 224 | - } else { |
|
| 225 | - $msg = sprintf( |
|
| 226 | - esc_html( |
|
| 227 | - _n( |
|
| 228 | - 'We\'re sorry, but there is only %1$s available space left for this event at this particular date and time. Please select a different number (or different combination) of tickets.', |
|
| 229 | - 'We\'re sorry, but there are only %1$s available spaces left for this event at this particular date and time. Please select a different number (or different combination) of tickets.', |
|
| 230 | - $available_spaces, |
|
| 231 | - 'event_espresso' |
|
| 232 | - ) |
|
| 233 | - ), |
|
| 234 | - $available_spaces, |
|
| 235 | - '<br />' |
|
| 236 | - ); |
|
| 237 | - } |
|
| 238 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 239 | - } |
|
| 29 | + /** |
|
| 30 | + * array of datetimes and the spaces available for them |
|
| 31 | + * |
|
| 32 | + * @var array[][] |
|
| 33 | + */ |
|
| 34 | + private $available_spaces = array(); |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * @var EEM_Datetime $datetime_model |
|
| 38 | + */ |
|
| 39 | + private $datetime_model; |
|
| 40 | + |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * TicketDatetimeAvailabilityTracker constructor. |
|
| 44 | + * |
|
| 45 | + * @param EEM_Datetime $datetime_model |
|
| 46 | + */ |
|
| 47 | + public function __construct(EEM_Datetime $datetime_model) |
|
| 48 | + { |
|
| 49 | + $this->datetime_model = $datetime_model; |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * ticketDatetimeAvailability |
|
| 55 | + * creates an array of tickets plus all of the datetimes available to each ticket |
|
| 56 | + * and tracks the spaces remaining for each of those datetimes |
|
| 57 | + * |
|
| 58 | + * @param EE_Ticket $ticket - selected ticket |
|
| 59 | + * @param bool $get_original_ticket_spaces |
|
| 60 | + * @return int |
|
| 61 | + * @throws EE_Error |
|
| 62 | + * @throws InvalidArgumentException |
|
| 63 | + * @throws InvalidDataTypeException |
|
| 64 | + * @throws InvalidInterfaceException |
|
| 65 | + */ |
|
| 66 | + public function ticketDatetimeAvailability(EE_Ticket $ticket, $get_original_ticket_spaces = false) |
|
| 67 | + { |
|
| 68 | + // if the $_available_spaces array has not been set up yet... |
|
| 69 | + if (! isset($this->available_spaces['tickets'][ $ticket->ID() ])) { |
|
| 70 | + $this->setInitialTicketDatetimeAvailability($ticket); |
|
| 71 | + } |
|
| 72 | + $available_spaces = $ticket->qty() - $ticket->sold(); |
|
| 73 | + if (isset($this->available_spaces['tickets'][ $ticket->ID() ])) { |
|
| 74 | + // loop thru tickets, which will ALSO include individual ticket records AND a total |
|
| 75 | + foreach ($this->available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces) { |
|
| 76 | + // if we want the original datetime availability BEFORE we started subtracting tickets ? |
|
| 77 | + if ($get_original_ticket_spaces) { |
|
| 78 | + // then grab the available spaces from the "tickets" array |
|
| 79 | + // and compare with the above to get the lowest number |
|
| 80 | + $available_spaces = min( |
|
| 81 | + $available_spaces, |
|
| 82 | + $this->available_spaces['tickets'][ $ticket->ID() ][ $DTD_ID ] |
|
| 83 | + ); |
|
| 84 | + } else { |
|
| 85 | + // we want the updated ticket availability as stored in the "datetimes" array |
|
| 86 | + $available_spaces = min($available_spaces, $this->available_spaces['datetimes'][ $DTD_ID ]); |
|
| 87 | + } |
|
| 88 | + } |
|
| 89 | + } |
|
| 90 | + return $available_spaces; |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + |
|
| 94 | + /** |
|
| 95 | + * @param EE_Ticket $ticket |
|
| 96 | + * @return void |
|
| 97 | + * @throws InvalidArgumentException |
|
| 98 | + * @throws InvalidInterfaceException |
|
| 99 | + * @throws InvalidDataTypeException |
|
| 100 | + * @throws EE_Error |
|
| 101 | + */ |
|
| 102 | + private function setInitialTicketDatetimeAvailability(EE_Ticket $ticket) |
|
| 103 | + { |
|
| 104 | + // first, get all of the datetimes that are available to this ticket |
|
| 105 | + $datetimes = $ticket->get_many_related( |
|
| 106 | + 'Datetime', |
|
| 107 | + array( |
|
| 108 | + array( |
|
| 109 | + 'DTT_EVT_end' => array( |
|
| 110 | + '>=', |
|
| 111 | + $this->datetime_model->current_time_for_query('DTT_EVT_end'), |
|
| 112 | + ), |
|
| 113 | + ), |
|
| 114 | + 'order_by' => array('DTT_EVT_start' => 'ASC'), |
|
| 115 | + ) |
|
| 116 | + ); |
|
| 117 | + if (! empty($datetimes)) { |
|
| 118 | + // now loop thru all of the datetimes |
|
| 119 | + foreach ($datetimes as $datetime) { |
|
| 120 | + if ($datetime instanceof EE_Datetime) { |
|
| 121 | + // the number of spaces available for the datetime without considering individual ticket quantities |
|
| 122 | + $spaces_remaining = $datetime->spaces_remaining(); |
|
| 123 | + // save the total available spaces ( the lesser of the ticket qty minus the number of tickets sold |
|
| 124 | + // or the datetime spaces remaining) to this ticket using the datetime ID as the key |
|
| 125 | + $this->available_spaces['tickets'][ $ticket->ID() ][ $datetime->ID() ] = min( |
|
| 126 | + $ticket->qty() - $ticket->sold(), |
|
| 127 | + $spaces_remaining |
|
| 128 | + ); |
|
| 129 | + // if the remaining spaces for this datetime is already set, |
|
| 130 | + // then compare that against the datetime spaces remaining, and take the lowest number, |
|
| 131 | + // else just take the datetime spaces remaining, and assign to the datetimes array |
|
| 132 | + $this->available_spaces['datetimes'][ $datetime->ID() ] = isset( |
|
| 133 | + $this->available_spaces['datetimes'][ $datetime->ID() ] |
|
| 134 | + ) |
|
| 135 | + ? min($this->available_spaces['datetimes'][ $datetime->ID() ], $spaces_remaining) |
|
| 136 | + : $spaces_remaining; |
|
| 137 | + } |
|
| 138 | + } |
|
| 139 | + } |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + |
|
| 143 | + /** |
|
| 144 | + * @param EE_Ticket $ticket |
|
| 145 | + * @param int $qty |
|
| 146 | + * @return void |
|
| 147 | + * @throws EE_Error |
|
| 148 | + */ |
|
| 149 | + public function recalculateTicketDatetimeAvailability(EE_Ticket $ticket, $qty = 0) |
|
| 150 | + { |
|
| 151 | + if (isset($this->available_spaces['tickets'][ $ticket->ID() ])) { |
|
| 152 | + // loop thru tickets, which will ALSO include individual ticket records AND a total |
|
| 153 | + foreach ($this->available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces) { |
|
| 154 | + // subtract the qty of selected tickets from each datetime's available spaces this ticket has access to, |
|
| 155 | + $this->available_spaces['datetimes'][ $DTD_ID ] -= $qty; |
|
| 156 | + } |
|
| 157 | + } |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + |
|
| 161 | + /** |
|
| 162 | + * @param EE_Ticket $ticket |
|
| 163 | + * @param $qty |
|
| 164 | + * @param int $total_ticket_count |
|
| 165 | + * @throws EE_Error |
|
| 166 | + * @throws InvalidArgumentException |
|
| 167 | + * @throws InvalidDataTypeException |
|
| 168 | + * @throws InvalidInterfaceException |
|
| 169 | + */ |
|
| 170 | + public function processAvailabilityError(EE_Ticket $ticket, $qty, $total_ticket_count = 1) |
|
| 171 | + { |
|
| 172 | + // tickets can not be purchased but let's find the exact number left |
|
| 173 | + // for the last ticket selected PRIOR to subtracting tickets |
|
| 174 | + $available_spaces = $this->ticketDatetimeAvailability($ticket, true); |
|
| 175 | + // greedy greedy greedy eh? |
|
| 176 | + if ($available_spaces > 0) { |
|
| 177 | + if ( |
|
| 178 | + apply_filters( |
|
| 179 | + 'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_display_availability_error', |
|
| 180 | + true, |
|
| 181 | + $ticket, |
|
| 182 | + $qty, |
|
| 183 | + $available_spaces |
|
| 184 | + ) |
|
| 185 | + ) { |
|
| 186 | + $this->availabilityError( |
|
| 187 | + $available_spaces, |
|
| 188 | + $total_ticket_count |
|
| 189 | + ); |
|
| 190 | + } |
|
| 191 | + } else { |
|
| 192 | + EE_Error::add_error( |
|
| 193 | + esc_html__( |
|
| 194 | + 'We\'re sorry, but there are no available spaces left for this event at this particular date and time.', |
|
| 195 | + 'event_espresso' |
|
| 196 | + ), |
|
| 197 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 198 | + ); |
|
| 199 | + } |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + |
|
| 203 | + /** |
|
| 204 | + * @param int $available_spaces |
|
| 205 | + * @param int $total_ticket_count |
|
| 206 | + */ |
|
| 207 | + private function availabilityError($available_spaces = 1, $total_ticket_count = 1) |
|
| 208 | + { |
|
| 209 | + // add error messaging - we're using the _n function that will generate |
|
| 210 | + // the appropriate singular or plural message based on the number of $available_spaces |
|
| 211 | + if ($total_ticket_count) { |
|
| 212 | + $msg = sprintf( |
|
| 213 | + esc_html( |
|
| 214 | + _n( |
|
| 215 | + 'We\'re sorry, but there is only %1$s available space left for this event at this particular date and time. Please select a different number (or different combination) of tickets by cancelling the current selection and choosing again, or proceed to registration.', |
|
| 216 | + 'We\'re sorry, but there are only %1$s available spaces left for this event at this particular date and time. Please select a different number (or different combination) of tickets by cancelling the current selection and choosing again, or proceed to registration.', |
|
| 217 | + $available_spaces, |
|
| 218 | + 'event_espresso' |
|
| 219 | + ) |
|
| 220 | + ), |
|
| 221 | + $available_spaces, |
|
| 222 | + '<br />' |
|
| 223 | + ); |
|
| 224 | + } else { |
|
| 225 | + $msg = sprintf( |
|
| 226 | + esc_html( |
|
| 227 | + _n( |
|
| 228 | + 'We\'re sorry, but there is only %1$s available space left for this event at this particular date and time. Please select a different number (or different combination) of tickets.', |
|
| 229 | + 'We\'re sorry, but there are only %1$s available spaces left for this event at this particular date and time. Please select a different number (or different combination) of tickets.', |
|
| 230 | + $available_spaces, |
|
| 231 | + 'event_espresso' |
|
| 232 | + ) |
|
| 233 | + ), |
|
| 234 | + $available_spaces, |
|
| 235 | + '<br />' |
|
| 236 | + ); |
|
| 237 | + } |
|
| 238 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 239 | + } |
|
| 240 | 240 | } |
@@ -20,470 +20,470 @@ |
||
| 20 | 20 | class EED_Ticket_Selector extends EED_Module |
| 21 | 21 | { |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * @var DisplayTicketSelector $ticket_selector |
|
| 25 | - */ |
|
| 26 | - private static $ticket_selector; |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * @var TicketSelectorIframeEmbedButton $iframe_embed_button |
|
| 30 | - */ |
|
| 31 | - private static $iframe_embed_button; |
|
| 32 | - |
|
| 33 | - |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * @return EED_Module|EED_Ticket_Selector |
|
| 37 | - */ |
|
| 38 | - public static function instance() |
|
| 39 | - { |
|
| 40 | - return parent::get_instance(__CLASS__); |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * @return void |
|
| 47 | - */ |
|
| 48 | - protected function set_config() |
|
| 49 | - { |
|
| 50 | - $this->set_config_section('template_settings'); |
|
| 51 | - $this->set_config_class('EE_Ticket_Selector_Config'); |
|
| 52 | - $this->set_config_name('EED_Ticket_Selector'); |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
| 59 | - * |
|
| 60 | - * @return void |
|
| 61 | - */ |
|
| 62 | - public static function set_hooks() |
|
| 63 | - { |
|
| 64 | - // routing |
|
| 65 | - EE_Config::register_route( |
|
| 66 | - 'iframe', |
|
| 67 | - 'EED_Ticket_Selector', |
|
| 68 | - 'ticket_selector_iframe', |
|
| 69 | - 'ticket_selector' |
|
| 70 | - ); |
|
| 71 | - EE_Config::register_route( |
|
| 72 | - 'process_ticket_selections', |
|
| 73 | - 'EED_Ticket_Selector', |
|
| 74 | - 'process_ticket_selections' |
|
| 75 | - ); |
|
| 76 | - EE_Config::register_route( |
|
| 77 | - 'cancel_ticket_selections', |
|
| 78 | - 'EED_Ticket_Selector', |
|
| 79 | - 'cancel_ticket_selections' |
|
| 80 | - ); |
|
| 81 | - add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2); |
|
| 82 | - add_action('AHEE_event_details_header_bottom', array('EED_Ticket_Selector', 'display_ticket_selector'), 10, 1); |
|
| 83 | - add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'translate_js_strings'), 0); |
|
| 84 | - add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets'), 10); |
|
| 85 | - EED_Ticket_Selector::loadIframeAssets(); |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
| 92 | - * |
|
| 93 | - * @return void |
|
| 94 | - */ |
|
| 95 | - public static function set_hooks_admin() |
|
| 96 | - { |
|
| 97 | - // hook into the end of the \EE_Admin_Page::_load_page_dependencies() |
|
| 98 | - // to load assets for "espresso_events" page on the "edit" route (action) |
|
| 99 | - add_action( |
|
| 100 | - 'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__edit', |
|
| 101 | - array('EED_Ticket_Selector', 'ticket_selector_iframe_embed_button'), |
|
| 102 | - 10 |
|
| 103 | - ); |
|
| 104 | - /** |
|
| 105 | - * Make sure assets for the ticket selector are loaded on the espresso registrations route so admin side |
|
| 106 | - * registrations work. |
|
| 107 | - */ |
|
| 108 | - add_action( |
|
| 109 | - 'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_registrations__new_registration', |
|
| 110 | - array('EED_Ticket_Selector', 'set_definitions'), |
|
| 111 | - 10 |
|
| 112 | - ); |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - |
|
| 116 | - |
|
| 117 | - /** |
|
| 118 | - * set_definitions |
|
| 119 | - * |
|
| 120 | - * @return void |
|
| 121 | - * @throws InvalidArgumentException |
|
| 122 | - * @throws InvalidDataTypeException |
|
| 123 | - * @throws InvalidInterfaceException |
|
| 124 | - */ |
|
| 125 | - public static function set_definitions() |
|
| 126 | - { |
|
| 127 | - // don't do this twice |
|
| 128 | - if (defined('TICKET_SELECTOR_ASSETS_URL')) { |
|
| 129 | - return; |
|
| 130 | - } |
|
| 131 | - define('TICKET_SELECTOR_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS); |
|
| 132 | - define( |
|
| 133 | - 'TICKET_SELECTOR_TEMPLATES_PATH', |
|
| 134 | - str_replace('\\', DS, plugin_dir_path(__FILE__)) . 'templates' . DS |
|
| 135 | - ); |
|
| 136 | - //if config is not set, initialize |
|
| 137 | - if ( |
|
| 138 | - ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config |
|
| 139 | - ) { |
|
| 140 | - EED_Ticket_Selector::instance()->set_config(); |
|
| 141 | - EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = EED_Ticket_Selector::instance()->config(); |
|
| 142 | - } |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - |
|
| 146 | - |
|
| 147 | - /** |
|
| 148 | - * @return DisplayTicketSelector |
|
| 149 | - */ |
|
| 150 | - public static function ticketSelector() |
|
| 151 | - { |
|
| 152 | - if (! EED_Ticket_Selector::$ticket_selector instanceof DisplayTicketSelector) { |
|
| 153 | - EED_Ticket_Selector::$ticket_selector = new DisplayTicketSelector(EED_Events_Archive::is_iframe()); |
|
| 154 | - } |
|
| 155 | - return EED_Ticket_Selector::$ticket_selector; |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - |
|
| 159 | - /** |
|
| 160 | - * gets the ball rolling |
|
| 161 | - * |
|
| 162 | - * @param WP $WP |
|
| 163 | - * @return void |
|
| 164 | - */ |
|
| 165 | - public function run($WP) |
|
| 166 | - { |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - |
|
| 170 | - |
|
| 171 | - /** |
|
| 172 | - * @return TicketSelectorIframeEmbedButton |
|
| 173 | - */ |
|
| 174 | - public static function getIframeEmbedButton() |
|
| 175 | - { |
|
| 176 | - if (! self::$iframe_embed_button instanceof TicketSelectorIframeEmbedButton) { |
|
| 177 | - self::$iframe_embed_button = new TicketSelectorIframeEmbedButton(); |
|
| 178 | - } |
|
| 179 | - return self::$iframe_embed_button; |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - |
|
| 183 | - |
|
| 184 | - /** |
|
| 185 | - * ticket_selector_iframe_embed_button |
|
| 186 | - * |
|
| 187 | - * @return void |
|
| 188 | - * @throws EE_Error |
|
| 189 | - */ |
|
| 190 | - public static function ticket_selector_iframe_embed_button() |
|
| 191 | - { |
|
| 192 | - $iframe_embed_button = EED_Ticket_Selector::getIframeEmbedButton(); |
|
| 193 | - $iframe_embed_button->addEventEditorIframeEmbedButton(); |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - |
|
| 197 | - |
|
| 198 | - /** |
|
| 199 | - * ticket_selector_iframe |
|
| 200 | - * |
|
| 201 | - * @return void |
|
| 202 | - * @throws DomainException |
|
| 203 | - * @throws EE_Error |
|
| 204 | - */ |
|
| 205 | - public function ticket_selector_iframe() |
|
| 206 | - { |
|
| 207 | - $ticket_selector_iframe = new TicketSelectorIframe(); |
|
| 208 | - $ticket_selector_iframe->display(); |
|
| 209 | - } |
|
| 210 | - |
|
| 211 | - |
|
| 212 | - |
|
| 213 | - /** |
|
| 214 | - * creates buttons for selecting number of attendees for an event |
|
| 215 | - * |
|
| 216 | - * @param WP_Post|int $event |
|
| 217 | - * @param bool $view_details |
|
| 218 | - * @return string |
|
| 219 | - * @throws EE_Error |
|
| 220 | - */ |
|
| 221 | - public static function display_ticket_selector($event = null, $view_details = false) |
|
| 222 | - { |
|
| 223 | - return EED_Ticket_Selector::ticketSelector()->display($event, $view_details); |
|
| 224 | - } |
|
| 225 | - |
|
| 226 | - |
|
| 227 | - /** |
|
| 228 | - * @return array or FALSE |
|
| 229 | - * @throws \ReflectionException |
|
| 230 | - * @throws \EE_Error |
|
| 231 | - * @throws InvalidArgumentException |
|
| 232 | - * @throws InvalidInterfaceException |
|
| 233 | - * @throws InvalidDataTypeException |
|
| 234 | - */ |
|
| 235 | - public function process_ticket_selections() |
|
| 236 | - { |
|
| 237 | - /** @var EventEspresso\modules\ticket_selector\ProcessTicketSelector $form */ |
|
| 238 | - $form = LoaderFactory::getLoader()->getShared('EventEspresso\modules\ticket_selector\ProcessTicketSelector'); |
|
| 239 | - return $form->processTicketSelections(); |
|
| 240 | - } |
|
| 241 | - |
|
| 242 | - |
|
| 243 | - /** |
|
| 244 | - * @return string |
|
| 245 | - * @throws InvalidArgumentException |
|
| 246 | - * @throws InvalidInterfaceException |
|
| 247 | - * @throws InvalidDataTypeException |
|
| 248 | - * @throws EE_Error |
|
| 249 | - */ |
|
| 250 | - public static function cancel_ticket_selections() |
|
| 251 | - { |
|
| 252 | - /** @var EventEspresso\modules\ticket_selector\ProcessTicketSelector $form */ |
|
| 253 | - $form = LoaderFactory::getLoader()->getShared('EventEspresso\modules\ticket_selector\ProcessTicketSelector'); |
|
| 254 | - return $form->cancelTicketSelections(); |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - |
|
| 258 | - |
|
| 259 | - /** |
|
| 260 | - * @return void |
|
| 261 | - */ |
|
| 262 | - public static function translate_js_strings() |
|
| 263 | - { |
|
| 264 | - EE_Registry::$i18n_js_strings['please_select_date_filter_notice'] = esc_html__( |
|
| 265 | - 'please select a datetime', |
|
| 266 | - 'event_espresso' |
|
| 267 | - ); |
|
| 268 | - } |
|
| 269 | - |
|
| 270 | - |
|
| 271 | - |
|
| 272 | - /** |
|
| 273 | - * @return void |
|
| 274 | - */ |
|
| 275 | - public static function load_tckt_slctr_assets() |
|
| 276 | - { |
|
| 277 | - if (apply_filters('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', false)) { |
|
| 278 | - // add some style |
|
| 279 | - wp_register_style( |
|
| 280 | - 'ticket_selector', |
|
| 281 | - TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css', |
|
| 282 | - array(), |
|
| 283 | - EVENT_ESPRESSO_VERSION |
|
| 284 | - ); |
|
| 285 | - wp_enqueue_style('ticket_selector'); |
|
| 286 | - // make it dance |
|
| 287 | - wp_register_script( |
|
| 288 | - 'ticket_selector', |
|
| 289 | - TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js', |
|
| 290 | - array('espresso_core'), |
|
| 291 | - EVENT_ESPRESSO_VERSION, |
|
| 292 | - true |
|
| 293 | - ); |
|
| 294 | - wp_enqueue_script('ticket_selector'); |
|
| 295 | - require_once EE_LIBRARIES |
|
| 296 | - . 'form_sections/strategies/display/EE_Checkbox_Dropdown_Selector_Display_Strategy.strategy.php'; |
|
| 297 | - \EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts(); |
|
| 298 | - } |
|
| 299 | - } |
|
| 300 | - |
|
| 301 | - |
|
| 302 | - |
|
| 303 | - /** |
|
| 304 | - * @return void |
|
| 305 | - */ |
|
| 306 | - public static function loadIframeAssets() |
|
| 307 | - { |
|
| 308 | - // for event lists |
|
| 309 | - add_filter( |
|
| 310 | - 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css', |
|
| 311 | - array('EED_Ticket_Selector', 'iframeCss') |
|
| 312 | - ); |
|
| 313 | - add_filter( |
|
| 314 | - 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js', |
|
| 315 | - array('EED_Ticket_Selector', 'iframeJs') |
|
| 316 | - ); |
|
| 317 | - // for ticket selectors |
|
| 318 | - add_filter( |
|
| 319 | - 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css', |
|
| 320 | - array('EED_Ticket_Selector', 'iframeCss') |
|
| 321 | - ); |
|
| 322 | - add_filter( |
|
| 323 | - 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
|
| 324 | - array('EED_Ticket_Selector', 'iframeJs') |
|
| 325 | - ); |
|
| 326 | - } |
|
| 327 | - |
|
| 328 | - |
|
| 329 | - |
|
| 330 | - /** |
|
| 331 | - * Informs the rest of the forms system what CSS and JS is needed to display the input |
|
| 332 | - * |
|
| 333 | - * @param array $iframe_css |
|
| 334 | - * @return array |
|
| 335 | - */ |
|
| 336 | - public static function iframeCss(array $iframe_css) |
|
| 337 | - { |
|
| 338 | - $iframe_css['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css'; |
|
| 339 | - return $iframe_css; |
|
| 340 | - } |
|
| 341 | - |
|
| 342 | - |
|
| 343 | - |
|
| 344 | - /** |
|
| 345 | - * Informs the rest of the forms system what CSS and JS is needed to display the input |
|
| 346 | - * |
|
| 347 | - * @param array $iframe_js |
|
| 348 | - * @return array |
|
| 349 | - */ |
|
| 350 | - public static function iframeJs(array $iframe_js) |
|
| 351 | - { |
|
| 352 | - $iframe_js['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js'; |
|
| 353 | - return $iframe_js; |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - |
|
| 357 | - /****************************** DEPRECATED ******************************/ |
|
| 358 | - |
|
| 359 | - |
|
| 360 | - |
|
| 361 | - /** |
|
| 362 | - * @deprecated |
|
| 363 | - * @return string |
|
| 364 | - * @throws EE_Error |
|
| 365 | - */ |
|
| 366 | - public static function display_view_details_btn() |
|
| 367 | - { |
|
| 368 | - // todo add doing_it_wrong() notice during next major version |
|
| 369 | - return EED_Ticket_Selector::ticketSelector()->displayViewDetailsButton(); |
|
| 370 | - } |
|
| 371 | - |
|
| 372 | - |
|
| 373 | - |
|
| 374 | - /** |
|
| 375 | - * @deprecated |
|
| 376 | - * @return string |
|
| 377 | - * @throws EE_Error |
|
| 378 | - */ |
|
| 379 | - public static function display_ticket_selector_submit() |
|
| 380 | - { |
|
| 381 | - // todo add doing_it_wrong() notice during next major version |
|
| 382 | - return EED_Ticket_Selector::ticketSelector()->displaySubmitButton(); |
|
| 383 | - } |
|
| 384 | - |
|
| 385 | - |
|
| 386 | - |
|
| 387 | - /** |
|
| 388 | - * @deprecated |
|
| 389 | - * @param string $permalink_string |
|
| 390 | - * @param int $id |
|
| 391 | - * @param string $new_title |
|
| 392 | - * @param string $new_slug |
|
| 393 | - * @return string |
|
| 394 | - * @throws InvalidArgumentException |
|
| 395 | - * @throws InvalidDataTypeException |
|
| 396 | - * @throws InvalidInterfaceException |
|
| 397 | - */ |
|
| 398 | - public static function iframe_code_button($permalink_string, $id, $new_title = '', $new_slug = '') |
|
| 399 | - { |
|
| 400 | - // todo add doing_it_wrong() notice during next major version |
|
| 401 | - if ( |
|
| 402 | - EE_Registry::instance()->REQ->get('page') === 'espresso_events' |
|
| 403 | - && EE_Registry::instance()->REQ->get('action') === 'edit' |
|
| 404 | - ) { |
|
| 405 | - $iframe_embed_button = EED_Ticket_Selector::getIframeEmbedButton(); |
|
| 406 | - $iframe_embed_button->addEventEditorIframeEmbedButton(); |
|
| 407 | - } |
|
| 408 | - return ''; |
|
| 409 | - } |
|
| 410 | - |
|
| 411 | - |
|
| 412 | - |
|
| 413 | - /** |
|
| 414 | - * @deprecated |
|
| 415 | - * @param int $ID |
|
| 416 | - * @param string $external_url |
|
| 417 | - * @return string |
|
| 418 | - */ |
|
| 419 | - public static function ticket_selector_form_open($ID = 0, $external_url = '') |
|
| 420 | - { |
|
| 421 | - // todo add doing_it_wrong() notice during next major version |
|
| 422 | - return EED_Ticket_Selector::ticketSelector()->formOpen($ID, $external_url); |
|
| 423 | - } |
|
| 424 | - |
|
| 425 | - |
|
| 426 | - |
|
| 427 | - /** |
|
| 428 | - * @deprecated |
|
| 429 | - * @return string |
|
| 430 | - */ |
|
| 431 | - public static function ticket_selector_form_close() |
|
| 432 | - { |
|
| 433 | - // todo add doing_it_wrong() notice during next major version |
|
| 434 | - return EED_Ticket_Selector::ticketSelector()->formClose(); |
|
| 435 | - } |
|
| 436 | - |
|
| 437 | - |
|
| 438 | - |
|
| 439 | - /** |
|
| 440 | - * @deprecated |
|
| 441 | - * @return string |
|
| 442 | - */ |
|
| 443 | - public static function no_tkt_slctr_end_dv() |
|
| 444 | - { |
|
| 445 | - // todo add doing_it_wrong() notice during next major version |
|
| 446 | - return EED_Ticket_Selector::ticketSelector()->ticketSelectorEndDiv(); |
|
| 447 | - } |
|
| 448 | - |
|
| 449 | - |
|
| 450 | - |
|
| 451 | - /** |
|
| 452 | - * @deprecated 4.9.13 |
|
| 453 | - * @return string |
|
| 454 | - */ |
|
| 455 | - public static function tkt_slctr_end_dv() |
|
| 456 | - { |
|
| 457 | - return EED_Ticket_Selector::ticketSelector()->clearTicketSelector(); |
|
| 458 | - } |
|
| 459 | - |
|
| 460 | - |
|
| 461 | - |
|
| 462 | - /** |
|
| 463 | - * @deprecated |
|
| 464 | - * @return string |
|
| 465 | - */ |
|
| 466 | - public static function clear_tkt_slctr() |
|
| 467 | - { |
|
| 468 | - return EED_Ticket_Selector::ticketSelector()->clearTicketSelector(); |
|
| 469 | - } |
|
| 470 | - |
|
| 471 | - |
|
| 472 | - |
|
| 473 | - /** |
|
| 474 | - * @deprecated |
|
| 475 | - */ |
|
| 476 | - public static function load_tckt_slctr_assets_admin() |
|
| 477 | - { |
|
| 478 | - // todo add doing_it_wrong() notice during next major version |
|
| 479 | - if ( |
|
| 480 | - EE_Registry::instance()->REQ->get('page') === 'espresso_events' |
|
| 481 | - && EE_Registry::instance()->REQ->get('action') === 'edit' |
|
| 482 | - ) { |
|
| 483 | - $iframe_embed_button = EED_Ticket_Selector::getIframeEmbedButton(); |
|
| 484 | - $iframe_embed_button->embedButtonAssets(); |
|
| 485 | - } |
|
| 486 | - } |
|
| 23 | + /** |
|
| 24 | + * @var DisplayTicketSelector $ticket_selector |
|
| 25 | + */ |
|
| 26 | + private static $ticket_selector; |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * @var TicketSelectorIframeEmbedButton $iframe_embed_button |
|
| 30 | + */ |
|
| 31 | + private static $iframe_embed_button; |
|
| 32 | + |
|
| 33 | + |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * @return EED_Module|EED_Ticket_Selector |
|
| 37 | + */ |
|
| 38 | + public static function instance() |
|
| 39 | + { |
|
| 40 | + return parent::get_instance(__CLASS__); |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * @return void |
|
| 47 | + */ |
|
| 48 | + protected function set_config() |
|
| 49 | + { |
|
| 50 | + $this->set_config_section('template_settings'); |
|
| 51 | + $this->set_config_class('EE_Ticket_Selector_Config'); |
|
| 52 | + $this->set_config_name('EED_Ticket_Selector'); |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
| 59 | + * |
|
| 60 | + * @return void |
|
| 61 | + */ |
|
| 62 | + public static function set_hooks() |
|
| 63 | + { |
|
| 64 | + // routing |
|
| 65 | + EE_Config::register_route( |
|
| 66 | + 'iframe', |
|
| 67 | + 'EED_Ticket_Selector', |
|
| 68 | + 'ticket_selector_iframe', |
|
| 69 | + 'ticket_selector' |
|
| 70 | + ); |
|
| 71 | + EE_Config::register_route( |
|
| 72 | + 'process_ticket_selections', |
|
| 73 | + 'EED_Ticket_Selector', |
|
| 74 | + 'process_ticket_selections' |
|
| 75 | + ); |
|
| 76 | + EE_Config::register_route( |
|
| 77 | + 'cancel_ticket_selections', |
|
| 78 | + 'EED_Ticket_Selector', |
|
| 79 | + 'cancel_ticket_selections' |
|
| 80 | + ); |
|
| 81 | + add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2); |
|
| 82 | + add_action('AHEE_event_details_header_bottom', array('EED_Ticket_Selector', 'display_ticket_selector'), 10, 1); |
|
| 83 | + add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'translate_js_strings'), 0); |
|
| 84 | + add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets'), 10); |
|
| 85 | + EED_Ticket_Selector::loadIframeAssets(); |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + |
|
| 89 | + |
|
| 90 | + /** |
|
| 91 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
| 92 | + * |
|
| 93 | + * @return void |
|
| 94 | + */ |
|
| 95 | + public static function set_hooks_admin() |
|
| 96 | + { |
|
| 97 | + // hook into the end of the \EE_Admin_Page::_load_page_dependencies() |
|
| 98 | + // to load assets for "espresso_events" page on the "edit" route (action) |
|
| 99 | + add_action( |
|
| 100 | + 'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__edit', |
|
| 101 | + array('EED_Ticket_Selector', 'ticket_selector_iframe_embed_button'), |
|
| 102 | + 10 |
|
| 103 | + ); |
|
| 104 | + /** |
|
| 105 | + * Make sure assets for the ticket selector are loaded on the espresso registrations route so admin side |
|
| 106 | + * registrations work. |
|
| 107 | + */ |
|
| 108 | + add_action( |
|
| 109 | + 'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_registrations__new_registration', |
|
| 110 | + array('EED_Ticket_Selector', 'set_definitions'), |
|
| 111 | + 10 |
|
| 112 | + ); |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * set_definitions |
|
| 119 | + * |
|
| 120 | + * @return void |
|
| 121 | + * @throws InvalidArgumentException |
|
| 122 | + * @throws InvalidDataTypeException |
|
| 123 | + * @throws InvalidInterfaceException |
|
| 124 | + */ |
|
| 125 | + public static function set_definitions() |
|
| 126 | + { |
|
| 127 | + // don't do this twice |
|
| 128 | + if (defined('TICKET_SELECTOR_ASSETS_URL')) { |
|
| 129 | + return; |
|
| 130 | + } |
|
| 131 | + define('TICKET_SELECTOR_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS); |
|
| 132 | + define( |
|
| 133 | + 'TICKET_SELECTOR_TEMPLATES_PATH', |
|
| 134 | + str_replace('\\', DS, plugin_dir_path(__FILE__)) . 'templates' . DS |
|
| 135 | + ); |
|
| 136 | + //if config is not set, initialize |
|
| 137 | + if ( |
|
| 138 | + ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config |
|
| 139 | + ) { |
|
| 140 | + EED_Ticket_Selector::instance()->set_config(); |
|
| 141 | + EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = EED_Ticket_Selector::instance()->config(); |
|
| 142 | + } |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + |
|
| 146 | + |
|
| 147 | + /** |
|
| 148 | + * @return DisplayTicketSelector |
|
| 149 | + */ |
|
| 150 | + public static function ticketSelector() |
|
| 151 | + { |
|
| 152 | + if (! EED_Ticket_Selector::$ticket_selector instanceof DisplayTicketSelector) { |
|
| 153 | + EED_Ticket_Selector::$ticket_selector = new DisplayTicketSelector(EED_Events_Archive::is_iframe()); |
|
| 154 | + } |
|
| 155 | + return EED_Ticket_Selector::$ticket_selector; |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + |
|
| 159 | + /** |
|
| 160 | + * gets the ball rolling |
|
| 161 | + * |
|
| 162 | + * @param WP $WP |
|
| 163 | + * @return void |
|
| 164 | + */ |
|
| 165 | + public function run($WP) |
|
| 166 | + { |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + |
|
| 170 | + |
|
| 171 | + /** |
|
| 172 | + * @return TicketSelectorIframeEmbedButton |
|
| 173 | + */ |
|
| 174 | + public static function getIframeEmbedButton() |
|
| 175 | + { |
|
| 176 | + if (! self::$iframe_embed_button instanceof TicketSelectorIframeEmbedButton) { |
|
| 177 | + self::$iframe_embed_button = new TicketSelectorIframeEmbedButton(); |
|
| 178 | + } |
|
| 179 | + return self::$iframe_embed_button; |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + |
|
| 183 | + |
|
| 184 | + /** |
|
| 185 | + * ticket_selector_iframe_embed_button |
|
| 186 | + * |
|
| 187 | + * @return void |
|
| 188 | + * @throws EE_Error |
|
| 189 | + */ |
|
| 190 | + public static function ticket_selector_iframe_embed_button() |
|
| 191 | + { |
|
| 192 | + $iframe_embed_button = EED_Ticket_Selector::getIframeEmbedButton(); |
|
| 193 | + $iframe_embed_button->addEventEditorIframeEmbedButton(); |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + |
|
| 197 | + |
|
| 198 | + /** |
|
| 199 | + * ticket_selector_iframe |
|
| 200 | + * |
|
| 201 | + * @return void |
|
| 202 | + * @throws DomainException |
|
| 203 | + * @throws EE_Error |
|
| 204 | + */ |
|
| 205 | + public function ticket_selector_iframe() |
|
| 206 | + { |
|
| 207 | + $ticket_selector_iframe = new TicketSelectorIframe(); |
|
| 208 | + $ticket_selector_iframe->display(); |
|
| 209 | + } |
|
| 210 | + |
|
| 211 | + |
|
| 212 | + |
|
| 213 | + /** |
|
| 214 | + * creates buttons for selecting number of attendees for an event |
|
| 215 | + * |
|
| 216 | + * @param WP_Post|int $event |
|
| 217 | + * @param bool $view_details |
|
| 218 | + * @return string |
|
| 219 | + * @throws EE_Error |
|
| 220 | + */ |
|
| 221 | + public static function display_ticket_selector($event = null, $view_details = false) |
|
| 222 | + { |
|
| 223 | + return EED_Ticket_Selector::ticketSelector()->display($event, $view_details); |
|
| 224 | + } |
|
| 225 | + |
|
| 226 | + |
|
| 227 | + /** |
|
| 228 | + * @return array or FALSE |
|
| 229 | + * @throws \ReflectionException |
|
| 230 | + * @throws \EE_Error |
|
| 231 | + * @throws InvalidArgumentException |
|
| 232 | + * @throws InvalidInterfaceException |
|
| 233 | + * @throws InvalidDataTypeException |
|
| 234 | + */ |
|
| 235 | + public function process_ticket_selections() |
|
| 236 | + { |
|
| 237 | + /** @var EventEspresso\modules\ticket_selector\ProcessTicketSelector $form */ |
|
| 238 | + $form = LoaderFactory::getLoader()->getShared('EventEspresso\modules\ticket_selector\ProcessTicketSelector'); |
|
| 239 | + return $form->processTicketSelections(); |
|
| 240 | + } |
|
| 241 | + |
|
| 242 | + |
|
| 243 | + /** |
|
| 244 | + * @return string |
|
| 245 | + * @throws InvalidArgumentException |
|
| 246 | + * @throws InvalidInterfaceException |
|
| 247 | + * @throws InvalidDataTypeException |
|
| 248 | + * @throws EE_Error |
|
| 249 | + */ |
|
| 250 | + public static function cancel_ticket_selections() |
|
| 251 | + { |
|
| 252 | + /** @var EventEspresso\modules\ticket_selector\ProcessTicketSelector $form */ |
|
| 253 | + $form = LoaderFactory::getLoader()->getShared('EventEspresso\modules\ticket_selector\ProcessTicketSelector'); |
|
| 254 | + return $form->cancelTicketSelections(); |
|
| 255 | + } |
|
| 256 | + |
|
| 257 | + |
|
| 258 | + |
|
| 259 | + /** |
|
| 260 | + * @return void |
|
| 261 | + */ |
|
| 262 | + public static function translate_js_strings() |
|
| 263 | + { |
|
| 264 | + EE_Registry::$i18n_js_strings['please_select_date_filter_notice'] = esc_html__( |
|
| 265 | + 'please select a datetime', |
|
| 266 | + 'event_espresso' |
|
| 267 | + ); |
|
| 268 | + } |
|
| 269 | + |
|
| 270 | + |
|
| 271 | + |
|
| 272 | + /** |
|
| 273 | + * @return void |
|
| 274 | + */ |
|
| 275 | + public static function load_tckt_slctr_assets() |
|
| 276 | + { |
|
| 277 | + if (apply_filters('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', false)) { |
|
| 278 | + // add some style |
|
| 279 | + wp_register_style( |
|
| 280 | + 'ticket_selector', |
|
| 281 | + TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css', |
|
| 282 | + array(), |
|
| 283 | + EVENT_ESPRESSO_VERSION |
|
| 284 | + ); |
|
| 285 | + wp_enqueue_style('ticket_selector'); |
|
| 286 | + // make it dance |
|
| 287 | + wp_register_script( |
|
| 288 | + 'ticket_selector', |
|
| 289 | + TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js', |
|
| 290 | + array('espresso_core'), |
|
| 291 | + EVENT_ESPRESSO_VERSION, |
|
| 292 | + true |
|
| 293 | + ); |
|
| 294 | + wp_enqueue_script('ticket_selector'); |
|
| 295 | + require_once EE_LIBRARIES |
|
| 296 | + . 'form_sections/strategies/display/EE_Checkbox_Dropdown_Selector_Display_Strategy.strategy.php'; |
|
| 297 | + \EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts(); |
|
| 298 | + } |
|
| 299 | + } |
|
| 300 | + |
|
| 301 | + |
|
| 302 | + |
|
| 303 | + /** |
|
| 304 | + * @return void |
|
| 305 | + */ |
|
| 306 | + public static function loadIframeAssets() |
|
| 307 | + { |
|
| 308 | + // for event lists |
|
| 309 | + add_filter( |
|
| 310 | + 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css', |
|
| 311 | + array('EED_Ticket_Selector', 'iframeCss') |
|
| 312 | + ); |
|
| 313 | + add_filter( |
|
| 314 | + 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js', |
|
| 315 | + array('EED_Ticket_Selector', 'iframeJs') |
|
| 316 | + ); |
|
| 317 | + // for ticket selectors |
|
| 318 | + add_filter( |
|
| 319 | + 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css', |
|
| 320 | + array('EED_Ticket_Selector', 'iframeCss') |
|
| 321 | + ); |
|
| 322 | + add_filter( |
|
| 323 | + 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
|
| 324 | + array('EED_Ticket_Selector', 'iframeJs') |
|
| 325 | + ); |
|
| 326 | + } |
|
| 327 | + |
|
| 328 | + |
|
| 329 | + |
|
| 330 | + /** |
|
| 331 | + * Informs the rest of the forms system what CSS and JS is needed to display the input |
|
| 332 | + * |
|
| 333 | + * @param array $iframe_css |
|
| 334 | + * @return array |
|
| 335 | + */ |
|
| 336 | + public static function iframeCss(array $iframe_css) |
|
| 337 | + { |
|
| 338 | + $iframe_css['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css'; |
|
| 339 | + return $iframe_css; |
|
| 340 | + } |
|
| 341 | + |
|
| 342 | + |
|
| 343 | + |
|
| 344 | + /** |
|
| 345 | + * Informs the rest of the forms system what CSS and JS is needed to display the input |
|
| 346 | + * |
|
| 347 | + * @param array $iframe_js |
|
| 348 | + * @return array |
|
| 349 | + */ |
|
| 350 | + public static function iframeJs(array $iframe_js) |
|
| 351 | + { |
|
| 352 | + $iframe_js['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js'; |
|
| 353 | + return $iframe_js; |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + |
|
| 357 | + /****************************** DEPRECATED ******************************/ |
|
| 358 | + |
|
| 359 | + |
|
| 360 | + |
|
| 361 | + /** |
|
| 362 | + * @deprecated |
|
| 363 | + * @return string |
|
| 364 | + * @throws EE_Error |
|
| 365 | + */ |
|
| 366 | + public static function display_view_details_btn() |
|
| 367 | + { |
|
| 368 | + // todo add doing_it_wrong() notice during next major version |
|
| 369 | + return EED_Ticket_Selector::ticketSelector()->displayViewDetailsButton(); |
|
| 370 | + } |
|
| 371 | + |
|
| 372 | + |
|
| 373 | + |
|
| 374 | + /** |
|
| 375 | + * @deprecated |
|
| 376 | + * @return string |
|
| 377 | + * @throws EE_Error |
|
| 378 | + */ |
|
| 379 | + public static function display_ticket_selector_submit() |
|
| 380 | + { |
|
| 381 | + // todo add doing_it_wrong() notice during next major version |
|
| 382 | + return EED_Ticket_Selector::ticketSelector()->displaySubmitButton(); |
|
| 383 | + } |
|
| 384 | + |
|
| 385 | + |
|
| 386 | + |
|
| 387 | + /** |
|
| 388 | + * @deprecated |
|
| 389 | + * @param string $permalink_string |
|
| 390 | + * @param int $id |
|
| 391 | + * @param string $new_title |
|
| 392 | + * @param string $new_slug |
|
| 393 | + * @return string |
|
| 394 | + * @throws InvalidArgumentException |
|
| 395 | + * @throws InvalidDataTypeException |
|
| 396 | + * @throws InvalidInterfaceException |
|
| 397 | + */ |
|
| 398 | + public static function iframe_code_button($permalink_string, $id, $new_title = '', $new_slug = '') |
|
| 399 | + { |
|
| 400 | + // todo add doing_it_wrong() notice during next major version |
|
| 401 | + if ( |
|
| 402 | + EE_Registry::instance()->REQ->get('page') === 'espresso_events' |
|
| 403 | + && EE_Registry::instance()->REQ->get('action') === 'edit' |
|
| 404 | + ) { |
|
| 405 | + $iframe_embed_button = EED_Ticket_Selector::getIframeEmbedButton(); |
|
| 406 | + $iframe_embed_button->addEventEditorIframeEmbedButton(); |
|
| 407 | + } |
|
| 408 | + return ''; |
|
| 409 | + } |
|
| 410 | + |
|
| 411 | + |
|
| 412 | + |
|
| 413 | + /** |
|
| 414 | + * @deprecated |
|
| 415 | + * @param int $ID |
|
| 416 | + * @param string $external_url |
|
| 417 | + * @return string |
|
| 418 | + */ |
|
| 419 | + public static function ticket_selector_form_open($ID = 0, $external_url = '') |
|
| 420 | + { |
|
| 421 | + // todo add doing_it_wrong() notice during next major version |
|
| 422 | + return EED_Ticket_Selector::ticketSelector()->formOpen($ID, $external_url); |
|
| 423 | + } |
|
| 424 | + |
|
| 425 | + |
|
| 426 | + |
|
| 427 | + /** |
|
| 428 | + * @deprecated |
|
| 429 | + * @return string |
|
| 430 | + */ |
|
| 431 | + public static function ticket_selector_form_close() |
|
| 432 | + { |
|
| 433 | + // todo add doing_it_wrong() notice during next major version |
|
| 434 | + return EED_Ticket_Selector::ticketSelector()->formClose(); |
|
| 435 | + } |
|
| 436 | + |
|
| 437 | + |
|
| 438 | + |
|
| 439 | + /** |
|
| 440 | + * @deprecated |
|
| 441 | + * @return string |
|
| 442 | + */ |
|
| 443 | + public static function no_tkt_slctr_end_dv() |
|
| 444 | + { |
|
| 445 | + // todo add doing_it_wrong() notice during next major version |
|
| 446 | + return EED_Ticket_Selector::ticketSelector()->ticketSelectorEndDiv(); |
|
| 447 | + } |
|
| 448 | + |
|
| 449 | + |
|
| 450 | + |
|
| 451 | + /** |
|
| 452 | + * @deprecated 4.9.13 |
|
| 453 | + * @return string |
|
| 454 | + */ |
|
| 455 | + public static function tkt_slctr_end_dv() |
|
| 456 | + { |
|
| 457 | + return EED_Ticket_Selector::ticketSelector()->clearTicketSelector(); |
|
| 458 | + } |
|
| 459 | + |
|
| 460 | + |
|
| 461 | + |
|
| 462 | + /** |
|
| 463 | + * @deprecated |
|
| 464 | + * @return string |
|
| 465 | + */ |
|
| 466 | + public static function clear_tkt_slctr() |
|
| 467 | + { |
|
| 468 | + return EED_Ticket_Selector::ticketSelector()->clearTicketSelector(); |
|
| 469 | + } |
|
| 470 | + |
|
| 471 | + |
|
| 472 | + |
|
| 473 | + /** |
|
| 474 | + * @deprecated |
|
| 475 | + */ |
|
| 476 | + public static function load_tckt_slctr_assets_admin() |
|
| 477 | + { |
|
| 478 | + // todo add doing_it_wrong() notice during next major version |
|
| 479 | + if ( |
|
| 480 | + EE_Registry::instance()->REQ->get('page') === 'espresso_events' |
|
| 481 | + && EE_Registry::instance()->REQ->get('action') === 'edit' |
|
| 482 | + ) { |
|
| 483 | + $iframe_embed_button = EED_Ticket_Selector::getIframeEmbedButton(); |
|
| 484 | + $iframe_embed_button->embedButtonAssets(); |
|
| 485 | + } |
|
| 486 | + } |
|
| 487 | 487 | |
| 488 | 488 | |
| 489 | 489 | } |
@@ -241,7 +241,7 @@ |
||
| 241 | 241 | |
| 242 | 242 | |
| 243 | 243 | /** |
| 244 | - * @return string |
|
| 244 | + * @return boolean |
|
| 245 | 245 | * @throws InvalidArgumentException |
| 246 | 246 | * @throws InvalidInterfaceException |
| 247 | 247 | * @throws InvalidDataTypeException |
@@ -14,94 +14,94 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class LicenseService |
| 16 | 16 | { |
| 17 | - /** |
|
| 18 | - * @var Config |
|
| 19 | - */ |
|
| 20 | - private $config; |
|
| 17 | + /** |
|
| 18 | + * @var Config |
|
| 19 | + */ |
|
| 20 | + private $config; |
|
| 21 | 21 | |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * @var Stats |
|
| 25 | - */ |
|
| 26 | - private $stats_collection; |
|
| 23 | + /** |
|
| 24 | + * @var Stats |
|
| 25 | + */ |
|
| 26 | + private $stats_collection; |
|
| 27 | 27 | |
| 28 | - public function __construct(Stats $stats_collection, Config $config) |
|
| 29 | - { |
|
| 30 | - $this->config = $config; |
|
| 31 | - $this->stats_collection = $stats_collection; |
|
| 32 | - $this->loadPueClient(); |
|
| 33 | - } |
|
| 28 | + public function __construct(Stats $stats_collection, Config $config) |
|
| 29 | + { |
|
| 30 | + $this->config = $config; |
|
| 31 | + $this->stats_collection = $stats_collection; |
|
| 32 | + $this->loadPueClient(); |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - private function loadPueClient() |
|
| 36 | - { |
|
| 37 | - // PUE Auto Upgrades stuff |
|
| 38 | - if (is_readable(EE_THIRD_PARTY . 'pue/pue-client.php')) { //include the file |
|
| 39 | - require_once(EE_THIRD_PARTY . 'pue/pue-client.php'); |
|
| 35 | + private function loadPueClient() |
|
| 36 | + { |
|
| 37 | + // PUE Auto Upgrades stuff |
|
| 38 | + if (is_readable(EE_THIRD_PARTY . 'pue/pue-client.php')) { //include the file |
|
| 39 | + require_once(EE_THIRD_PARTY . 'pue/pue-client.php'); |
|
| 40 | 40 | |
| 41 | - //$options needs to be an array with the included keys as listed. |
|
| 42 | - $options = array( |
|
| 43 | - // 'optionName' => '', //(optional) - used as the reference for saving update information in the |
|
| 44 | - // clients options table. Will be automatically set if left blank. |
|
| 45 | - 'apikey' => $this->config->siteLicenseKey(), |
|
| 46 | - //(required), you will need to obtain the apikey that the client gets from your site and |
|
| 47 | - // then saves in their sites options table (see 'getting an api-key' below) |
|
| 48 | - 'lang_domain' => $this->config->i18nDomain(), |
|
| 49 | - //(optional) - put here whatever reference you are using for the localization of your plugin (if it's |
|
| 50 | - // localized). That way strings in this file will be included in the translation for your plugin. |
|
| 51 | - 'checkPeriod' => $this->config->checkPeriod(), |
|
| 52 | - //(optional) - use this parameter to indicate how often you want the client's install to ping your |
|
| 53 | - // server for update checks. The integer indicates hours. If you don't include this parameter it will |
|
| 54 | - // default to 12 hours. |
|
| 55 | - 'option_key' => $this->config->optionKey(), |
|
| 56 | - //this is what is used to reference the api_key in your plugin options. PUE uses this to trigger |
|
| 57 | - // updating your information message whenever this option_key is modified. |
|
| 58 | - 'options_page_slug' => $this->config->optionsPageSlug(), |
|
| 59 | - 'plugin_basename' => EE_PLUGIN_BASENAME, |
|
| 60 | - 'use_wp_update' => true, |
|
| 61 | - //if TRUE then you want FREE versions of the plugin to be updated from WP |
|
| 62 | - 'extra_stats' => $this->stats_collection->statsCallback(), |
|
| 63 | - 'turn_on_notices_saved' => true, |
|
| 64 | - ); |
|
| 65 | - //initiate the class and start the plugin update engine! |
|
| 66 | - new PluginUpdateEngineChecker( |
|
| 67 | - $this->config->hostServerUrl(), |
|
| 68 | - $this->config->pluginSlug(), |
|
| 69 | - $options |
|
| 70 | - ); |
|
| 71 | - } |
|
| 72 | - } |
|
| 41 | + //$options needs to be an array with the included keys as listed. |
|
| 42 | + $options = array( |
|
| 43 | + // 'optionName' => '', //(optional) - used as the reference for saving update information in the |
|
| 44 | + // clients options table. Will be automatically set if left blank. |
|
| 45 | + 'apikey' => $this->config->siteLicenseKey(), |
|
| 46 | + //(required), you will need to obtain the apikey that the client gets from your site and |
|
| 47 | + // then saves in their sites options table (see 'getting an api-key' below) |
|
| 48 | + 'lang_domain' => $this->config->i18nDomain(), |
|
| 49 | + //(optional) - put here whatever reference you are using for the localization of your plugin (if it's |
|
| 50 | + // localized). That way strings in this file will be included in the translation for your plugin. |
|
| 51 | + 'checkPeriod' => $this->config->checkPeriod(), |
|
| 52 | + //(optional) - use this parameter to indicate how often you want the client's install to ping your |
|
| 53 | + // server for update checks. The integer indicates hours. If you don't include this parameter it will |
|
| 54 | + // default to 12 hours. |
|
| 55 | + 'option_key' => $this->config->optionKey(), |
|
| 56 | + //this is what is used to reference the api_key in your plugin options. PUE uses this to trigger |
|
| 57 | + // updating your information message whenever this option_key is modified. |
|
| 58 | + 'options_page_slug' => $this->config->optionsPageSlug(), |
|
| 59 | + 'plugin_basename' => EE_PLUGIN_BASENAME, |
|
| 60 | + 'use_wp_update' => true, |
|
| 61 | + //if TRUE then you want FREE versions of the plugin to be updated from WP |
|
| 62 | + 'extra_stats' => $this->stats_collection->statsCallback(), |
|
| 63 | + 'turn_on_notices_saved' => true, |
|
| 64 | + ); |
|
| 65 | + //initiate the class and start the plugin update engine! |
|
| 66 | + new PluginUpdateEngineChecker( |
|
| 67 | + $this->config->hostServerUrl(), |
|
| 68 | + $this->config->pluginSlug(), |
|
| 69 | + $options |
|
| 70 | + ); |
|
| 71 | + } |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * This is a handy helper method for retrieving whether there is an update available for the given plugin. |
|
| 77 | - * |
|
| 78 | - * @param string $basename Use the equivalent result from plugin_basename() for this param as WP uses that to |
|
| 79 | - * identify plugins. Defaults to core update |
|
| 80 | - * @return boolean True if update available, false if not. |
|
| 81 | - */ |
|
| 82 | - public static function isUpdateAvailable($basename = '') |
|
| 83 | - { |
|
| 84 | - $basename = ! empty($basename) ? $basename : EE_PLUGIN_BASENAME; |
|
| 75 | + /** |
|
| 76 | + * This is a handy helper method for retrieving whether there is an update available for the given plugin. |
|
| 77 | + * |
|
| 78 | + * @param string $basename Use the equivalent result from plugin_basename() for this param as WP uses that to |
|
| 79 | + * identify plugins. Defaults to core update |
|
| 80 | + * @return boolean True if update available, false if not. |
|
| 81 | + */ |
|
| 82 | + public static function isUpdateAvailable($basename = '') |
|
| 83 | + { |
|
| 84 | + $basename = ! empty($basename) ? $basename : EE_PLUGIN_BASENAME; |
|
| 85 | 85 | |
| 86 | - $update = false; |
|
| 86 | + $update = false; |
|
| 87 | 87 | |
| 88 | - // should take "event-espresso-core/espresso.php" and change to "/event-espresso-core" |
|
| 89 | - $folder = DS . dirname($basename); |
|
| 88 | + // should take "event-espresso-core/espresso.php" and change to "/event-espresso-core" |
|
| 89 | + $folder = DS . dirname($basename); |
|
| 90 | 90 | |
| 91 | - $plugins = get_plugins($folder); |
|
| 92 | - $current = get_site_transient('update_plugins'); |
|
| 91 | + $plugins = get_plugins($folder); |
|
| 92 | + $current = get_site_transient('update_plugins'); |
|
| 93 | 93 | |
| 94 | - foreach ((array)$plugins as $plugin_file => $plugin_data) { |
|
| 95 | - if (isset($current->response['plugin_file'])) { |
|
| 96 | - $update = true; |
|
| 97 | - } |
|
| 98 | - } |
|
| 94 | + foreach ((array)$plugins as $plugin_file => $plugin_data) { |
|
| 95 | + if (isset($current->response['plugin_file'])) { |
|
| 96 | + $update = true; |
|
| 97 | + } |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - //it's possible that there is an update but an invalid site-license-key is in use |
|
| 101 | - if (get_site_option('pue_json_error_' . $basename)) { |
|
| 102 | - $update = true; |
|
| 103 | - } |
|
| 100 | + //it's possible that there is an update but an invalid site-license-key is in use |
|
| 101 | + if (get_site_option('pue_json_error_' . $basename)) { |
|
| 102 | + $update = true; |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - return $update; |
|
| 106 | - } |
|
| 105 | + return $update; |
|
| 106 | + } |
|
| 107 | 107 | } |
| 108 | 108 | \ No newline at end of file |
@@ -35,8 +35,8 @@ discard block |
||
| 35 | 35 | private function loadPueClient() |
| 36 | 36 | { |
| 37 | 37 | // PUE Auto Upgrades stuff |
| 38 | - if (is_readable(EE_THIRD_PARTY . 'pue/pue-client.php')) { //include the file |
|
| 39 | - require_once(EE_THIRD_PARTY . 'pue/pue-client.php'); |
|
| 38 | + if (is_readable(EE_THIRD_PARTY.'pue/pue-client.php')) { //include the file |
|
| 39 | + require_once(EE_THIRD_PARTY.'pue/pue-client.php'); |
|
| 40 | 40 | |
| 41 | 41 | //$options needs to be an array with the included keys as listed. |
| 42 | 42 | $options = array( |
@@ -86,19 +86,19 @@ discard block |
||
| 86 | 86 | $update = false; |
| 87 | 87 | |
| 88 | 88 | // should take "event-espresso-core/espresso.php" and change to "/event-espresso-core" |
| 89 | - $folder = DS . dirname($basename); |
|
| 89 | + $folder = DS.dirname($basename); |
|
| 90 | 90 | |
| 91 | 91 | $plugins = get_plugins($folder); |
| 92 | 92 | $current = get_site_transient('update_plugins'); |
| 93 | 93 | |
| 94 | - foreach ((array)$plugins as $plugin_file => $plugin_data) { |
|
| 94 | + foreach ((array) $plugins as $plugin_file => $plugin_data) { |
|
| 95 | 95 | if (isset($current->response['plugin_file'])) { |
| 96 | 96 | $update = true; |
| 97 | 97 | } |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | //it's possible that there is an update but an invalid site-license-key is in use |
| 101 | - if (get_site_option('pue_json_error_' . $basename)) { |
|
| 101 | + if (get_site_option('pue_json_error_'.$basename)) { |
|
| 102 | 102 | $update = true; |
| 103 | 103 | } |
| 104 | 104 | |
@@ -16,284 +16,284 @@ |
||
| 16 | 16 | class StatsGatherer |
| 17 | 17 | { |
| 18 | 18 | |
| 19 | - const COUNT_ALL_EVENTS = 'event'; |
|
| 20 | - const COUNT_ACTIVE_EVENTS = 'active_event'; |
|
| 21 | - const COUNT_DATETIMES = 'datetime'; |
|
| 22 | - const COUNT_TICKETS = 'ticket'; |
|
| 23 | - const COUNT_DATETIMES_SOLD = 'datetime_sold'; |
|
| 24 | - const COUNT_TICKETS_FREE = 'free_ticket'; |
|
| 25 | - const COUNT_TICKETS_PAID = 'paid_ticket'; |
|
| 26 | - const COUNT_TICKETS_SOLD = 'ticket_sold'; |
|
| 27 | - const COUNT_REGISTRATIONS_APPROVED = 'registrations_approved'; |
|
| 28 | - const COUNT_REGISTRATIONS_NOT_APPROVED = 'registrations_not_approved'; |
|
| 29 | - const COUNT_REGISTRATIONS_PENDING = 'registrations_pending'; |
|
| 30 | - const COUNT_REGISTRATIONS_INCOMPLETE = 'registrations_incomplete'; |
|
| 31 | - const COUNT_REGISTRATIONS_ALL = 'registrations_all'; |
|
| 32 | - const COUNT_REGISTRATIONS_CANCELLED = 'registrations_cancelled'; |
|
| 33 | - const COUNT_REGISTRATIONS_DECLINED = 'registrations_declined'; |
|
| 34 | - const SUM_TRANSACTIONS_COMPLETE_TOTAL = 'transactions_complete_total_sum'; |
|
| 35 | - const SUM_TRANSACTIONS_ALL_PAID = 'transactions_all_paid'; |
|
| 36 | - const INFO_SITE_CURRENCY = 'site_currency'; |
|
| 19 | + const COUNT_ALL_EVENTS = 'event'; |
|
| 20 | + const COUNT_ACTIVE_EVENTS = 'active_event'; |
|
| 21 | + const COUNT_DATETIMES = 'datetime'; |
|
| 22 | + const COUNT_TICKETS = 'ticket'; |
|
| 23 | + const COUNT_DATETIMES_SOLD = 'datetime_sold'; |
|
| 24 | + const COUNT_TICKETS_FREE = 'free_ticket'; |
|
| 25 | + const COUNT_TICKETS_PAID = 'paid_ticket'; |
|
| 26 | + const COUNT_TICKETS_SOLD = 'ticket_sold'; |
|
| 27 | + const COUNT_REGISTRATIONS_APPROVED = 'registrations_approved'; |
|
| 28 | + const COUNT_REGISTRATIONS_NOT_APPROVED = 'registrations_not_approved'; |
|
| 29 | + const COUNT_REGISTRATIONS_PENDING = 'registrations_pending'; |
|
| 30 | + const COUNT_REGISTRATIONS_INCOMPLETE = 'registrations_incomplete'; |
|
| 31 | + const COUNT_REGISTRATIONS_ALL = 'registrations_all'; |
|
| 32 | + const COUNT_REGISTRATIONS_CANCELLED = 'registrations_cancelled'; |
|
| 33 | + const COUNT_REGISTRATIONS_DECLINED = 'registrations_declined'; |
|
| 34 | + const SUM_TRANSACTIONS_COMPLETE_TOTAL = 'transactions_complete_total_sum'; |
|
| 35 | + const SUM_TRANSACTIONS_ALL_PAID = 'transactions_all_paid'; |
|
| 36 | + const INFO_SITE_CURRENCY = 'site_currency'; |
|
| 37 | 37 | |
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @var EEM_Payment_Method |
|
| 41 | - */ |
|
| 42 | - private $payment_method_model; |
|
| 39 | + /** |
|
| 40 | + * @var EEM_Payment_Method |
|
| 41 | + */ |
|
| 42 | + private $payment_method_model; |
|
| 43 | 43 | |
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * @var EEM_Event |
|
| 47 | - */ |
|
| 48 | - private $event_model; |
|
| 45 | + /** |
|
| 46 | + * @var EEM_Event |
|
| 47 | + */ |
|
| 48 | + private $event_model; |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * @var EEM_Datetime |
|
| 52 | - */ |
|
| 53 | - private $datetime_model; |
|
| 50 | + /** |
|
| 51 | + * @var EEM_Datetime |
|
| 52 | + */ |
|
| 53 | + private $datetime_model; |
|
| 54 | 54 | |
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * @var EEM_Ticket |
|
| 58 | - */ |
|
| 59 | - private $ticket_model; |
|
| 56 | + /** |
|
| 57 | + * @var EEM_Ticket |
|
| 58 | + */ |
|
| 59 | + private $ticket_model; |
|
| 60 | 60 | |
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * @var EEM_Registration |
|
| 64 | - */ |
|
| 65 | - private $registration_model; |
|
| 62 | + /** |
|
| 63 | + * @var EEM_Registration |
|
| 64 | + */ |
|
| 65 | + private $registration_model; |
|
| 66 | 66 | |
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * @var EEM_Transaction |
|
| 70 | - */ |
|
| 71 | - private $transaction_model; |
|
| 68 | + /** |
|
| 69 | + * @var EEM_Transaction |
|
| 70 | + */ |
|
| 71 | + private $transaction_model; |
|
| 72 | 72 | |
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * @var EE_Config |
|
| 76 | - */ |
|
| 77 | - private $config; |
|
| 74 | + /** |
|
| 75 | + * @var EE_Config |
|
| 76 | + */ |
|
| 77 | + private $config; |
|
| 78 | 78 | |
| 79 | 79 | |
| 80 | - /** |
|
| 81 | - * StatsGatherer constructor. |
|
| 82 | - * |
|
| 83 | - * @param EEM_Payment_Method $payment_method_model |
|
| 84 | - * @param EEM_Event $event_model |
|
| 85 | - * @param EEM_Datetime $datetime_model |
|
| 86 | - * @param EEM_Ticket $ticket_model |
|
| 87 | - * @param EEM_Registration $registration_model |
|
| 88 | - * @param EEM_Transaction $transaction_model |
|
| 89 | - * @param EE_Config $config |
|
| 90 | - */ |
|
| 91 | - public function __construct( |
|
| 92 | - EEM_Payment_Method $payment_method_model, |
|
| 93 | - EEM_Event $event_model, |
|
| 94 | - EEM_Datetime $datetime_model, |
|
| 95 | - EEM_Ticket $ticket_model, |
|
| 96 | - EEM_Registration $registration_model, |
|
| 97 | - EEM_Transaction $transaction_model, |
|
| 98 | - EE_Config $config |
|
| 99 | - ) { |
|
| 100 | - $this->payment_method_model = $payment_method_model; |
|
| 101 | - $this->event_model = $event_model; |
|
| 102 | - $this->datetime_model = $datetime_model; |
|
| 103 | - $this->ticket_model = $ticket_model; |
|
| 104 | - $this->registration_model = $registration_model; |
|
| 105 | - $this->transaction_model = $transaction_model; |
|
| 106 | - $this->config = $config; |
|
| 107 | - } |
|
| 80 | + /** |
|
| 81 | + * StatsGatherer constructor. |
|
| 82 | + * |
|
| 83 | + * @param EEM_Payment_Method $payment_method_model |
|
| 84 | + * @param EEM_Event $event_model |
|
| 85 | + * @param EEM_Datetime $datetime_model |
|
| 86 | + * @param EEM_Ticket $ticket_model |
|
| 87 | + * @param EEM_Registration $registration_model |
|
| 88 | + * @param EEM_Transaction $transaction_model |
|
| 89 | + * @param EE_Config $config |
|
| 90 | + */ |
|
| 91 | + public function __construct( |
|
| 92 | + EEM_Payment_Method $payment_method_model, |
|
| 93 | + EEM_Event $event_model, |
|
| 94 | + EEM_Datetime $datetime_model, |
|
| 95 | + EEM_Ticket $ticket_model, |
|
| 96 | + EEM_Registration $registration_model, |
|
| 97 | + EEM_Transaction $transaction_model, |
|
| 98 | + EE_Config $config |
|
| 99 | + ) { |
|
| 100 | + $this->payment_method_model = $payment_method_model; |
|
| 101 | + $this->event_model = $event_model; |
|
| 102 | + $this->datetime_model = $datetime_model; |
|
| 103 | + $this->ticket_model = $ticket_model; |
|
| 104 | + $this->registration_model = $registration_model; |
|
| 105 | + $this->transaction_model = $transaction_model; |
|
| 106 | + $this->config = $config; |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | 109 | |
| 110 | - /** |
|
| 111 | - * Return the stats array for PUE UXIP stats. |
|
| 112 | - * @return array |
|
| 113 | - */ |
|
| 114 | - public function stats() |
|
| 115 | - { |
|
| 116 | - $stats = $this->paymentMethodStats(); |
|
| 117 | - //a-ok so let's setup our stats. |
|
| 118 | - $stats = array_merge($stats, array( |
|
| 119 | - 'is_multisite' => is_multisite() && is_main_site(), |
|
| 120 | - 'active_theme' => $this->getActiveThemeStat(), |
|
| 121 | - 'ee4_all_events_count' => $this->getCountFor(self::COUNT_ALL_EVENTS), |
|
| 122 | - 'ee4_active_events_count' => $this->getCountFor(self::COUNT_ACTIVE_EVENTS), |
|
| 123 | - 'all_dtts_count' => $this->getCountFor(self::COUNT_DATETIMES), |
|
| 124 | - 'dtt_sold' => $this->getCountFor(self::COUNT_DATETIMES_SOLD), |
|
| 125 | - 'all_tkt_count' => $this->getCountFor(self::COUNT_TICKETS), |
|
| 126 | - 'free_tkt_count' => $this->getCountFor(self::COUNT_TICKETS_FREE), |
|
| 127 | - 'paid_tkt_count' => $this->getCountFor(self::COUNT_TICKETS_PAID), |
|
| 128 | - 'tkt_sold' => $this->getCountFor(self::COUNT_TICKETS_SOLD), |
|
| 129 | - 'approve_registration_count' => $this->getCountFor(self::COUNT_REGISTRATIONS_APPROVED), |
|
| 130 | - 'pending_registration_count' => $this->getCountFor(self::COUNT_REGISTRATIONS_PENDING), |
|
| 131 | - 'not_approved_registration_count' => $this->getCountFor(self::COUNT_REGISTRATIONS_NOT_APPROVED), |
|
| 132 | - 'incomplete_registration_count' => $this->getCountFor(self::COUNT_REGISTRATIONS_INCOMPLETE), |
|
| 133 | - 'cancelled_registration_count' => $this->getCountFor(self::COUNT_REGISTRATIONS_CANCELLED), |
|
| 134 | - 'declined_registration_count' => $this->getCountFor(self::COUNT_REGISTRATIONS_DECLINED), |
|
| 135 | - 'all_registration_count' => $this->getCountFor(self::COUNT_REGISTRATIONS_ALL), |
|
| 136 | - 'completed_transaction_total_sum' => $this->getCountFor(self::SUM_TRANSACTIONS_COMPLETE_TOTAL), |
|
| 137 | - 'all_transaction_paid_sum' => $this->getCountFor(self::SUM_TRANSACTIONS_ALL_PAID), |
|
| 138 | - self::INFO_SITE_CURRENCY => $this->config->currency instanceof EE_Currency_Config |
|
| 139 | - ? $this->config->currency->code |
|
| 140 | - : 'unknown', |
|
| 141 | - 'phpversion' => implode('.', array(PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION)) |
|
| 142 | - )); |
|
| 143 | - //remove any values that equal null. This ensures any stats that weren't retrieved successfully are excluded. |
|
| 144 | - return array_filter($stats, function ($value) { |
|
| 145 | - return $value !== null; |
|
| 146 | - }); |
|
| 147 | - } |
|
| 110 | + /** |
|
| 111 | + * Return the stats array for PUE UXIP stats. |
|
| 112 | + * @return array |
|
| 113 | + */ |
|
| 114 | + public function stats() |
|
| 115 | + { |
|
| 116 | + $stats = $this->paymentMethodStats(); |
|
| 117 | + //a-ok so let's setup our stats. |
|
| 118 | + $stats = array_merge($stats, array( |
|
| 119 | + 'is_multisite' => is_multisite() && is_main_site(), |
|
| 120 | + 'active_theme' => $this->getActiveThemeStat(), |
|
| 121 | + 'ee4_all_events_count' => $this->getCountFor(self::COUNT_ALL_EVENTS), |
|
| 122 | + 'ee4_active_events_count' => $this->getCountFor(self::COUNT_ACTIVE_EVENTS), |
|
| 123 | + 'all_dtts_count' => $this->getCountFor(self::COUNT_DATETIMES), |
|
| 124 | + 'dtt_sold' => $this->getCountFor(self::COUNT_DATETIMES_SOLD), |
|
| 125 | + 'all_tkt_count' => $this->getCountFor(self::COUNT_TICKETS), |
|
| 126 | + 'free_tkt_count' => $this->getCountFor(self::COUNT_TICKETS_FREE), |
|
| 127 | + 'paid_tkt_count' => $this->getCountFor(self::COUNT_TICKETS_PAID), |
|
| 128 | + 'tkt_sold' => $this->getCountFor(self::COUNT_TICKETS_SOLD), |
|
| 129 | + 'approve_registration_count' => $this->getCountFor(self::COUNT_REGISTRATIONS_APPROVED), |
|
| 130 | + 'pending_registration_count' => $this->getCountFor(self::COUNT_REGISTRATIONS_PENDING), |
|
| 131 | + 'not_approved_registration_count' => $this->getCountFor(self::COUNT_REGISTRATIONS_NOT_APPROVED), |
|
| 132 | + 'incomplete_registration_count' => $this->getCountFor(self::COUNT_REGISTRATIONS_INCOMPLETE), |
|
| 133 | + 'cancelled_registration_count' => $this->getCountFor(self::COUNT_REGISTRATIONS_CANCELLED), |
|
| 134 | + 'declined_registration_count' => $this->getCountFor(self::COUNT_REGISTRATIONS_DECLINED), |
|
| 135 | + 'all_registration_count' => $this->getCountFor(self::COUNT_REGISTRATIONS_ALL), |
|
| 136 | + 'completed_transaction_total_sum' => $this->getCountFor(self::SUM_TRANSACTIONS_COMPLETE_TOTAL), |
|
| 137 | + 'all_transaction_paid_sum' => $this->getCountFor(self::SUM_TRANSACTIONS_ALL_PAID), |
|
| 138 | + self::INFO_SITE_CURRENCY => $this->config->currency instanceof EE_Currency_Config |
|
| 139 | + ? $this->config->currency->code |
|
| 140 | + : 'unknown', |
|
| 141 | + 'phpversion' => implode('.', array(PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION)) |
|
| 142 | + )); |
|
| 143 | + //remove any values that equal null. This ensures any stats that weren't retrieved successfully are excluded. |
|
| 144 | + return array_filter($stats, function ($value) { |
|
| 145 | + return $value !== null; |
|
| 146 | + }); |
|
| 147 | + } |
|
| 148 | 148 | |
| 149 | - /** |
|
| 150 | - * @param string $which enum (@see constants prefixed with COUNT) |
|
| 151 | - * @return int|null |
|
| 152 | - */ |
|
| 153 | - private function getCountFor($which) |
|
| 154 | - { |
|
| 155 | - try { |
|
| 156 | - switch ($which) { |
|
| 157 | - case self::COUNT_ALL_EVENTS: |
|
| 158 | - $count = $this->event_model->count(); |
|
| 159 | - break; |
|
| 160 | - case self::COUNT_TICKETS: |
|
| 161 | - $count = $this->ticket_model->count(); |
|
| 162 | - break; |
|
| 163 | - case self::COUNT_DATETIMES: |
|
| 164 | - $count = $this->datetime_model->count(); |
|
| 165 | - break; |
|
| 166 | - case self::COUNT_ACTIVE_EVENTS: |
|
| 167 | - $count = $this->event_model->get_active_events(array(), true); |
|
| 168 | - break; |
|
| 169 | - case self::COUNT_DATETIMES_SOLD: |
|
| 170 | - $count = $this->datetime_model->sum(array(), 'DTT_sold'); |
|
| 171 | - break; |
|
| 172 | - case self::COUNT_TICKETS_FREE: |
|
| 173 | - $count = $this->ticket_model->count(array(array( |
|
| 174 | - 'TKT_price' => 0 |
|
| 175 | - ))); |
|
| 176 | - break; |
|
| 177 | - case self::COUNT_TICKETS_PAID: |
|
| 178 | - $count = $this->ticket_model->count(array(array( |
|
| 179 | - 'TKT_price' => array('>', 0) |
|
| 180 | - ))); |
|
| 181 | - break; |
|
| 182 | - case self::COUNT_TICKETS_SOLD: |
|
| 183 | - $count = $this->ticket_model->sum(array(), 'TKT_sold'); |
|
| 184 | - break; |
|
| 185 | - case self::COUNT_REGISTRATIONS_ALL: |
|
| 186 | - $count = $this->registration_model->count(); |
|
| 187 | - break; |
|
| 188 | - case self::COUNT_REGISTRATIONS_CANCELLED: |
|
| 189 | - $count = $this->registration_model->count( |
|
| 190 | - array( |
|
| 191 | - array( |
|
| 192 | - 'STS_ID' => EEM_Registration::status_id_cancelled |
|
| 193 | - ) |
|
| 194 | - ) |
|
| 195 | - ); |
|
| 196 | - break; |
|
| 197 | - case self::COUNT_REGISTRATIONS_INCOMPLETE: |
|
| 198 | - $count = $this->registration_model->count( |
|
| 199 | - array( |
|
| 200 | - array( |
|
| 201 | - 'STS_ID' => EEM_Registration::status_id_incomplete |
|
| 202 | - ) |
|
| 203 | - ) |
|
| 204 | - ); |
|
| 205 | - break; |
|
| 206 | - case self::COUNT_REGISTRATIONS_NOT_APPROVED: |
|
| 207 | - $count = $this->registration_model->count( |
|
| 208 | - array( |
|
| 209 | - array( |
|
| 210 | - 'STS_ID' => EEM_Registration::status_id_not_approved |
|
| 211 | - ) |
|
| 212 | - ) |
|
| 213 | - ); |
|
| 214 | - break; |
|
| 215 | - case self::COUNT_REGISTRATIONS_DECLINED: |
|
| 216 | - $count = $this->registration_model->count( |
|
| 217 | - array( |
|
| 218 | - array( |
|
| 219 | - 'STS_ID' => EEM_Registration::status_id_declined |
|
| 220 | - ) |
|
| 221 | - ) |
|
| 222 | - ); |
|
| 223 | - break; |
|
| 224 | - case self::COUNT_REGISTRATIONS_PENDING: |
|
| 225 | - $count = $this->registration_model->count( |
|
| 226 | - array( |
|
| 227 | - array( |
|
| 228 | - 'STS_ID' => EEM_Registration::status_id_pending_payment |
|
| 229 | - ) |
|
| 230 | - ) |
|
| 231 | - ); |
|
| 232 | - break; |
|
| 233 | - case self::COUNT_REGISTRATIONS_APPROVED: |
|
| 234 | - $count = $this->registration_model->count( |
|
| 235 | - array( |
|
| 236 | - array( |
|
| 237 | - 'STS_ID' => EEM_Registration::status_id_approved |
|
| 238 | - ) |
|
| 239 | - ) |
|
| 240 | - ); |
|
| 241 | - break; |
|
| 242 | - case self::SUM_TRANSACTIONS_COMPLETE_TOTAL: |
|
| 243 | - $count = $this->transaction_model->sum( |
|
| 244 | - array( |
|
| 245 | - array( |
|
| 246 | - 'STS_ID' => EEM_Transaction::complete_status_code |
|
| 247 | - ) |
|
| 248 | - ), |
|
| 249 | - 'TXN_total' |
|
| 250 | - ); |
|
| 251 | - break; |
|
| 252 | - case self::SUM_TRANSACTIONS_ALL_PAID: |
|
| 253 | - $count = $this->transaction_model->sum( |
|
| 254 | - array(), |
|
| 255 | - 'TXN_paid' |
|
| 256 | - ); |
|
| 257 | - break; |
|
| 258 | - default: |
|
| 259 | - $count = null; |
|
| 260 | - break; |
|
| 261 | - } |
|
| 262 | - } catch (Exception $e) { |
|
| 263 | - $count = null; |
|
| 264 | - } |
|
| 265 | - return $count; |
|
| 266 | - } |
|
| 149 | + /** |
|
| 150 | + * @param string $which enum (@see constants prefixed with COUNT) |
|
| 151 | + * @return int|null |
|
| 152 | + */ |
|
| 153 | + private function getCountFor($which) |
|
| 154 | + { |
|
| 155 | + try { |
|
| 156 | + switch ($which) { |
|
| 157 | + case self::COUNT_ALL_EVENTS: |
|
| 158 | + $count = $this->event_model->count(); |
|
| 159 | + break; |
|
| 160 | + case self::COUNT_TICKETS: |
|
| 161 | + $count = $this->ticket_model->count(); |
|
| 162 | + break; |
|
| 163 | + case self::COUNT_DATETIMES: |
|
| 164 | + $count = $this->datetime_model->count(); |
|
| 165 | + break; |
|
| 166 | + case self::COUNT_ACTIVE_EVENTS: |
|
| 167 | + $count = $this->event_model->get_active_events(array(), true); |
|
| 168 | + break; |
|
| 169 | + case self::COUNT_DATETIMES_SOLD: |
|
| 170 | + $count = $this->datetime_model->sum(array(), 'DTT_sold'); |
|
| 171 | + break; |
|
| 172 | + case self::COUNT_TICKETS_FREE: |
|
| 173 | + $count = $this->ticket_model->count(array(array( |
|
| 174 | + 'TKT_price' => 0 |
|
| 175 | + ))); |
|
| 176 | + break; |
|
| 177 | + case self::COUNT_TICKETS_PAID: |
|
| 178 | + $count = $this->ticket_model->count(array(array( |
|
| 179 | + 'TKT_price' => array('>', 0) |
|
| 180 | + ))); |
|
| 181 | + break; |
|
| 182 | + case self::COUNT_TICKETS_SOLD: |
|
| 183 | + $count = $this->ticket_model->sum(array(), 'TKT_sold'); |
|
| 184 | + break; |
|
| 185 | + case self::COUNT_REGISTRATIONS_ALL: |
|
| 186 | + $count = $this->registration_model->count(); |
|
| 187 | + break; |
|
| 188 | + case self::COUNT_REGISTRATIONS_CANCELLED: |
|
| 189 | + $count = $this->registration_model->count( |
|
| 190 | + array( |
|
| 191 | + array( |
|
| 192 | + 'STS_ID' => EEM_Registration::status_id_cancelled |
|
| 193 | + ) |
|
| 194 | + ) |
|
| 195 | + ); |
|
| 196 | + break; |
|
| 197 | + case self::COUNT_REGISTRATIONS_INCOMPLETE: |
|
| 198 | + $count = $this->registration_model->count( |
|
| 199 | + array( |
|
| 200 | + array( |
|
| 201 | + 'STS_ID' => EEM_Registration::status_id_incomplete |
|
| 202 | + ) |
|
| 203 | + ) |
|
| 204 | + ); |
|
| 205 | + break; |
|
| 206 | + case self::COUNT_REGISTRATIONS_NOT_APPROVED: |
|
| 207 | + $count = $this->registration_model->count( |
|
| 208 | + array( |
|
| 209 | + array( |
|
| 210 | + 'STS_ID' => EEM_Registration::status_id_not_approved |
|
| 211 | + ) |
|
| 212 | + ) |
|
| 213 | + ); |
|
| 214 | + break; |
|
| 215 | + case self::COUNT_REGISTRATIONS_DECLINED: |
|
| 216 | + $count = $this->registration_model->count( |
|
| 217 | + array( |
|
| 218 | + array( |
|
| 219 | + 'STS_ID' => EEM_Registration::status_id_declined |
|
| 220 | + ) |
|
| 221 | + ) |
|
| 222 | + ); |
|
| 223 | + break; |
|
| 224 | + case self::COUNT_REGISTRATIONS_PENDING: |
|
| 225 | + $count = $this->registration_model->count( |
|
| 226 | + array( |
|
| 227 | + array( |
|
| 228 | + 'STS_ID' => EEM_Registration::status_id_pending_payment |
|
| 229 | + ) |
|
| 230 | + ) |
|
| 231 | + ); |
|
| 232 | + break; |
|
| 233 | + case self::COUNT_REGISTRATIONS_APPROVED: |
|
| 234 | + $count = $this->registration_model->count( |
|
| 235 | + array( |
|
| 236 | + array( |
|
| 237 | + 'STS_ID' => EEM_Registration::status_id_approved |
|
| 238 | + ) |
|
| 239 | + ) |
|
| 240 | + ); |
|
| 241 | + break; |
|
| 242 | + case self::SUM_TRANSACTIONS_COMPLETE_TOTAL: |
|
| 243 | + $count = $this->transaction_model->sum( |
|
| 244 | + array( |
|
| 245 | + array( |
|
| 246 | + 'STS_ID' => EEM_Transaction::complete_status_code |
|
| 247 | + ) |
|
| 248 | + ), |
|
| 249 | + 'TXN_total' |
|
| 250 | + ); |
|
| 251 | + break; |
|
| 252 | + case self::SUM_TRANSACTIONS_ALL_PAID: |
|
| 253 | + $count = $this->transaction_model->sum( |
|
| 254 | + array(), |
|
| 255 | + 'TXN_paid' |
|
| 256 | + ); |
|
| 257 | + break; |
|
| 258 | + default: |
|
| 259 | + $count = null; |
|
| 260 | + break; |
|
| 261 | + } |
|
| 262 | + } catch (Exception $e) { |
|
| 263 | + $count = null; |
|
| 264 | + } |
|
| 265 | + return $count; |
|
| 266 | + } |
|
| 267 | 267 | |
| 268 | - /** |
|
| 269 | - * Return the active theme. |
|
| 270 | - * @return false|string |
|
| 271 | - */ |
|
| 272 | - private function getActiveThemeStat() |
|
| 273 | - { |
|
| 274 | - $theme = wp_get_theme(); |
|
| 275 | - return $theme->get('Name'); |
|
| 276 | - } |
|
| 268 | + /** |
|
| 269 | + * Return the active theme. |
|
| 270 | + * @return false|string |
|
| 271 | + */ |
|
| 272 | + private function getActiveThemeStat() |
|
| 273 | + { |
|
| 274 | + $theme = wp_get_theme(); |
|
| 275 | + return $theme->get('Name'); |
|
| 276 | + } |
|
| 277 | 277 | |
| 278 | - /** |
|
| 279 | - * @return array |
|
| 280 | - */ |
|
| 281 | - private function paymentMethodStats() |
|
| 282 | - { |
|
| 283 | - $payment_method_stats = array(); |
|
| 284 | - try { |
|
| 285 | - $active_payment_methods = $this->payment_method_model->get_all_active( |
|
| 286 | - null, |
|
| 287 | - array('group_by' => 'PMD_type') |
|
| 288 | - ); |
|
| 289 | - if ($active_payment_methods) { |
|
| 290 | - foreach ($active_payment_methods as $payment_method) { |
|
| 291 | - $payment_method_stats[$payment_method->name() . '_active_payment_method'] = 1; |
|
| 292 | - } |
|
| 293 | - } |
|
| 294 | - } catch (Exception $e) { |
|
| 295 | - //do nothing just prevents fatals. |
|
| 296 | - } |
|
| 297 | - return $payment_method_stats; |
|
| 298 | - } |
|
| 278 | + /** |
|
| 279 | + * @return array |
|
| 280 | + */ |
|
| 281 | + private function paymentMethodStats() |
|
| 282 | + { |
|
| 283 | + $payment_method_stats = array(); |
|
| 284 | + try { |
|
| 285 | + $active_payment_methods = $this->payment_method_model->get_all_active( |
|
| 286 | + null, |
|
| 287 | + array('group_by' => 'PMD_type') |
|
| 288 | + ); |
|
| 289 | + if ($active_payment_methods) { |
|
| 290 | + foreach ($active_payment_methods as $payment_method) { |
|
| 291 | + $payment_method_stats[$payment_method->name() . '_active_payment_method'] = 1; |
|
| 292 | + } |
|
| 293 | + } |
|
| 294 | + } catch (Exception $e) { |
|
| 295 | + //do nothing just prevents fatals. |
|
| 296 | + } |
|
| 297 | + return $payment_method_stats; |
|
| 298 | + } |
|
| 299 | 299 | } |
| 300 | 300 | \ No newline at end of file |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | 'phpversion' => implode('.', array(PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION)) |
| 142 | 142 | )); |
| 143 | 143 | //remove any values that equal null. This ensures any stats that weren't retrieved successfully are excluded. |
| 144 | - return array_filter($stats, function ($value) { |
|
| 144 | + return array_filter($stats, function($value) { |
|
| 145 | 145 | return $value !== null; |
| 146 | 146 | }); |
| 147 | 147 | } |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | ); |
| 289 | 289 | if ($active_payment_methods) { |
| 290 | 290 | foreach ($active_payment_methods as $payment_method) { |
| 291 | - $payment_method_stats[$payment_method->name() . '_active_payment_method'] = 1; |
|
| 291 | + $payment_method_stats[$payment_method->name().'_active_payment_method'] = 1; |
|
| 292 | 292 | } |
| 293 | 293 | } |
| 294 | 294 | } catch (Exception $e) { |
@@ -17,135 +17,135 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class Config |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * @var EE_Network_Config |
|
| 22 | - */ |
|
| 23 | - private $network_config; |
|
| 20 | + /** |
|
| 21 | + * @var EE_Network_Config |
|
| 22 | + */ |
|
| 23 | + private $network_config; |
|
| 24 | 24 | |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * @var EE_Config |
|
| 28 | - */ |
|
| 29 | - private $ee_config; |
|
| 26 | + /** |
|
| 27 | + * @var EE_Config |
|
| 28 | + */ |
|
| 29 | + private $ee_config; |
|
| 30 | 30 | |
| 31 | 31 | |
| 32 | 32 | |
| 33 | - public function __construct(EE_Network_Config $network_config, EE_Config $ee_config) |
|
| 34 | - { |
|
| 35 | - $this->network_config = $network_config; |
|
| 36 | - $this->ee_config = $ee_config; |
|
| 37 | - } |
|
| 33 | + public function __construct(EE_Network_Config $network_config, EE_Config $ee_config) |
|
| 34 | + { |
|
| 35 | + $this->network_config = $network_config; |
|
| 36 | + $this->ee_config = $ee_config; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * Get the site license key for the site. |
|
| 42 | - */ |
|
| 43 | - public function siteLicenseKey() |
|
| 44 | - { |
|
| 45 | - return $this->network_config->core->site_license_key; |
|
| 46 | - } |
|
| 40 | + /** |
|
| 41 | + * Get the site license key for the site. |
|
| 42 | + */ |
|
| 43 | + public function siteLicenseKey() |
|
| 44 | + { |
|
| 45 | + return $this->network_config->core->site_license_key; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | 48 | |
| 49 | 49 | |
| 50 | - public function i18nDomain() |
|
| 51 | - { |
|
| 52 | - return 'event_espresso'; |
|
| 53 | - } |
|
| 50 | + public function i18nDomain() |
|
| 51 | + { |
|
| 52 | + return 'event_espresso'; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | 55 | |
| 56 | 56 | |
| 57 | - public function checkPeriod() |
|
| 58 | - { |
|
| 59 | - return 24; |
|
| 60 | - } |
|
| 57 | + public function checkPeriod() |
|
| 58 | + { |
|
| 59 | + return 24; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | 62 | |
| 63 | 63 | |
| 64 | - public function optionKey() |
|
| 65 | - { |
|
| 66 | - return 'site_license_key'; |
|
| 67 | - } |
|
| 64 | + public function optionKey() |
|
| 65 | + { |
|
| 66 | + return 'site_license_key'; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | 69 | |
| 70 | 70 | |
| 71 | - public function optionsPageSlug() |
|
| 72 | - { |
|
| 73 | - return 'espresso_general_settings'; |
|
| 74 | - } |
|
| 71 | + public function optionsPageSlug() |
|
| 72 | + { |
|
| 73 | + return 'espresso_general_settings'; |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | 76 | |
| 77 | - public function hostServerUrl() |
|
| 78 | - { |
|
| 79 | - return defined('PUE_UPDATES_ENDPOINT') |
|
| 80 | - ? PUE_UPDATES_ENDPOINT |
|
| 81 | - : 'https://eventespresso.com'; |
|
| 82 | - } |
|
| 77 | + public function hostServerUrl() |
|
| 78 | + { |
|
| 79 | + return defined('PUE_UPDATES_ENDPOINT') |
|
| 80 | + ? PUE_UPDATES_ENDPOINT |
|
| 81 | + : 'https://eventespresso.com'; |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | 84 | |
| 85 | - public function pluginSlug() |
|
| 86 | - { |
|
| 87 | - //Note: PUE uses a simple preg_match to determine what type is currently installed based on version number. |
|
| 88 | - // So it's important that you use a key for the version type that is unique and not found in another key. |
|
| 89 | - //For example: |
|
| 90 | - //$plugin_slug['premium']['p'] = 'some-premium-slug'; |
|
| 91 | - //$plugin_slug['prerelease']['pr'] = 'some-pre-release-slug'; |
|
| 92 | - //The above would not work because "p" is found in both keys for the version type. ( i.e 1.0.p vs 1.0.pr ) |
|
| 93 | - // so doing something like: |
|
| 94 | - //$plugin_slug['premium']['p'] = 'some-premium-slug'; |
|
| 95 | - //$plugin_slug['prerelease']['b'] = 'some-pre-release-slug'; |
|
| 96 | - //..WOULD work! |
|
| 97 | - return array( |
|
| 98 | - 'free' => array('decaf' => 'event-espresso-core-decaf'), |
|
| 99 | - 'premium' => array('p' => 'event-espresso-core-reg'), |
|
| 100 | - 'prerelease' => array('beta' => 'event-espresso-core-pr'), |
|
| 101 | - ); |
|
| 102 | - } |
|
| 85 | + public function pluginSlug() |
|
| 86 | + { |
|
| 87 | + //Note: PUE uses a simple preg_match to determine what type is currently installed based on version number. |
|
| 88 | + // So it's important that you use a key for the version type that is unique and not found in another key. |
|
| 89 | + //For example: |
|
| 90 | + //$plugin_slug['premium']['p'] = 'some-premium-slug'; |
|
| 91 | + //$plugin_slug['prerelease']['pr'] = 'some-pre-release-slug'; |
|
| 92 | + //The above would not work because "p" is found in both keys for the version type. ( i.e 1.0.p vs 1.0.pr ) |
|
| 93 | + // so doing something like: |
|
| 94 | + //$plugin_slug['premium']['p'] = 'some-premium-slug'; |
|
| 95 | + //$plugin_slug['prerelease']['b'] = 'some-pre-release-slug'; |
|
| 96 | + //..WOULD work! |
|
| 97 | + return array( |
|
| 98 | + 'free' => array('decaf' => 'event-espresso-core-decaf'), |
|
| 99 | + 'premium' => array('p' => 'event-espresso-core-reg'), |
|
| 100 | + 'prerelease' => array('beta' => 'event-espresso-core-pr'), |
|
| 101 | + ); |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | 104 | |
| 105 | - /** |
|
| 106 | - * Return whether the site is opted in for UXIP or not. |
|
| 107 | - * @return bool |
|
| 108 | - */ |
|
| 109 | - public function isOptedInForUxip() |
|
| 110 | - { |
|
| 111 | - return filter_var($this->ee_config->core->ee_ueip_optin, FILTER_VALIDATE_BOOLEAN); |
|
| 112 | - } |
|
| 105 | + /** |
|
| 106 | + * Return whether the site is opted in for UXIP or not. |
|
| 107 | + * @return bool |
|
| 108 | + */ |
|
| 109 | + public function isOptedInForUxip() |
|
| 110 | + { |
|
| 111 | + return filter_var($this->ee_config->core->ee_ueip_optin, FILTER_VALIDATE_BOOLEAN); |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | 114 | |
| 115 | - /** |
|
| 116 | - * Return whether the site has been notified about UXIP or not. |
|
| 117 | - * @return bool |
|
| 118 | - */ |
|
| 119 | - public function hasNotifiedForUxip() |
|
| 120 | - { |
|
| 121 | - return filter_var($this->ee_config->core->ee_ueip_has_notified, FILTER_VALIDATE_BOOLEAN); |
|
| 122 | - } |
|
| 115 | + /** |
|
| 116 | + * Return whether the site has been notified about UXIP or not. |
|
| 117 | + * @return bool |
|
| 118 | + */ |
|
| 119 | + public function hasNotifiedForUxip() |
|
| 120 | + { |
|
| 121 | + return filter_var($this->ee_config->core->ee_ueip_has_notified, FILTER_VALIDATE_BOOLEAN); |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | 124 | |
| 125 | - /** |
|
| 126 | - * Set the site opted in for UXIP. |
|
| 127 | - */ |
|
| 128 | - public function setHasOptedInForUxip() |
|
| 129 | - { |
|
| 130 | - $this->ee_config->core->ee_ueip_optin = true; |
|
| 131 | - $this->ee_config->update_espresso_config(false, false); |
|
| 132 | - } |
|
| 125 | + /** |
|
| 126 | + * Set the site opted in for UXIP. |
|
| 127 | + */ |
|
| 128 | + public function setHasOptedInForUxip() |
|
| 129 | + { |
|
| 130 | + $this->ee_config->core->ee_ueip_optin = true; |
|
| 131 | + $this->ee_config->update_espresso_config(false, false); |
|
| 132 | + } |
|
| 133 | 133 | |
| 134 | 134 | |
| 135 | - /** |
|
| 136 | - * Set the site opted out for UXIP |
|
| 137 | - */ |
|
| 138 | - public function setHasOptedOutForUxip() |
|
| 139 | - { |
|
| 140 | - $this->ee_config->core->ee_ueip_optin = false; |
|
| 141 | - $this->ee_config->update_espresso_config(false, false); |
|
| 142 | - } |
|
| 135 | + /** |
|
| 136 | + * Set the site opted out for UXIP |
|
| 137 | + */ |
|
| 138 | + public function setHasOptedOutForUxip() |
|
| 139 | + { |
|
| 140 | + $this->ee_config->core->ee_ueip_optin = false; |
|
| 141 | + $this->ee_config->update_espresso_config(false, false); |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | 144 | |
| 145 | 145 | |
| 146 | - public function setHasNotifiedAboutUxip() |
|
| 147 | - { |
|
| 148 | - $this->ee_config->core->ee_ueip_has_notified = true; |
|
| 149 | - $this->ee_config->update_espresso_config(false, false); |
|
| 150 | - } |
|
| 146 | + public function setHasNotifiedAboutUxip() |
|
| 147 | + { |
|
| 148 | + $this->ee_config->core->ee_ueip_has_notified = true; |
|
| 149 | + $this->ee_config->update_espresso_config(false, false); |
|
| 150 | + } |
|
| 151 | 151 | } |