@@ -16,225 +16,225 @@ |
||
| 16 | 16 | class ProcessTicketSelectorPostData |
| 17 | 17 | { |
| 18 | 18 | |
| 19 | - const DATA_KEY_EVENT_ID = 'id'; |
|
| 20 | - |
|
| 21 | - const DATA_KEY_MAX_ATNDZ = 'max_atndz'; |
|
| 22 | - |
|
| 23 | - const DATA_KEY_QUANTITY = 'ticket-selections'; |
|
| 24 | - |
|
| 25 | - const DATA_KEY_RETURN_URL = 'return_url'; |
|
| 26 | - |
|
| 27 | - const DATA_KEY_ROWS = 'rows'; |
|
| 28 | - |
|
| 29 | - const DATA_KEY_TICKET_ID = 'ticket_id'; |
|
| 30 | - |
|
| 31 | - const DATA_KEY_TOTAL_TICKETS = 'total_tickets'; |
|
| 32 | - |
|
| 33 | - const INPUT_KEY_EVENT_ID = 'tkt-slctr-event-id'; |
|
| 34 | - |
|
| 35 | - const INPUT_KEY_MAX_ATNDZ = 'tkt-slctr-max-atndz-'; |
|
| 36 | - |
|
| 37 | - const INPUT_KEY_ROWS = 'tkt-slctr-rows-'; |
|
| 38 | - |
|
| 39 | - const INPUT_KEY_QTY = 'tkt-slctr-qty-'; |
|
| 40 | - |
|
| 41 | - const INPUT_KEY_TICKET_ID = 'tkt-slctr-ticket-id-'; |
|
| 42 | - |
|
| 43 | - const INPUT_KEY_RETURN_URL = 'tkt-slctr-return-url-'; |
|
| 44 | - |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * @var int |
|
| 48 | - */ |
|
| 49 | - protected $event_id; |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * @var array |
|
| 53 | - */ |
|
| 54 | - protected $inputs_to_clean = []; |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * @var array |
|
| 58 | - */ |
|
| 59 | - protected $valid_data = []; |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * @var RequestInterface |
|
| 63 | - */ |
|
| 64 | - protected $request; |
|
| 65 | - |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * @param RequestInterface $request |
|
| 69 | - */ |
|
| 70 | - public function __construct(RequestInterface $request) |
|
| 71 | - { |
|
| 72 | - $this->request = $request; |
|
| 73 | - $this->inputs_to_clean = [ |
|
| 74 | - self::DATA_KEY_MAX_ATNDZ => self::INPUT_KEY_MAX_ATNDZ, |
|
| 75 | - self::DATA_KEY_RETURN_URL => self::INPUT_KEY_RETURN_URL, |
|
| 76 | - self::DATA_KEY_ROWS => self::INPUT_KEY_ROWS, |
|
| 77 | - self::DATA_KEY_TOTAL_TICKETS => self::INPUT_KEY_TICKET_ID, |
|
| 78 | - self::DATA_KEY_QUANTITY => self::INPUT_KEY_QTY, |
|
| 79 | - ]; |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - |
|
| 83 | - /** |
|
| 84 | - * @return int |
|
| 85 | - * @throws DomainException |
|
| 86 | - */ |
|
| 87 | - public function getEventId() |
|
| 88 | - { |
|
| 89 | - // do we have an event id? |
|
| 90 | - if ($this->event_id === null) { |
|
| 91 | - $this->event_id = $this->request->getRequestParam(self::INPUT_KEY_EVENT_ID, 0, 'int'); |
|
| 92 | - if (! $this->event_id) { |
|
| 93 | - // $_POST['tkt-slctr-event-id'] was not set ?!?!?!? |
|
| 94 | - throw new DomainException( |
|
| 95 | - sprintf( |
|
| 96 | - esc_html__( |
|
| 97 | - 'An event id was not provided or was not received.%sPlease click the back button on your browser and try again.', |
|
| 98 | - 'event_espresso' |
|
| 99 | - ), |
|
| 100 | - '<br/>' |
|
| 101 | - ) |
|
| 102 | - ); |
|
| 103 | - } |
|
| 104 | - } |
|
| 105 | - // event id is valid |
|
| 106 | - return $this->event_id; |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - |
|
| 110 | - /** |
|
| 111 | - * @return array |
|
| 112 | - * @throws DomainException |
|
| 113 | - */ |
|
| 114 | - public function validatePostData() |
|
| 115 | - { |
|
| 116 | - // grab valid id |
|
| 117 | - $this->valid_data[ self::DATA_KEY_EVENT_ID ] = $this->getEventId(); |
|
| 118 | - // let's track the total number of tickets ordered.' |
|
| 119 | - $this->valid_data[ self:: DATA_KEY_TOTAL_TICKETS ] = 0; |
|
| 120 | - // cycle through $inputs_to_clean array |
|
| 121 | - foreach ($this->inputs_to_clean as $what => $input_to_clean) { |
|
| 122 | - $input_key = "{$input_to_clean}{$this->event_id}"; |
|
| 123 | - // check for POST data |
|
| 124 | - if ($this->request->requestParamIsSet($input_key)) { |
|
| 125 | - switch ($what) { |
|
| 126 | - // integers |
|
| 127 | - case self::DATA_KEY_ROWS: |
|
| 128 | - case self::DATA_KEY_MAX_ATNDZ: |
|
| 129 | - $this->processInteger($what, $input_key); |
|
| 130 | - break; |
|
| 131 | - // arrays of integers |
|
| 132 | - case self::DATA_KEY_QUANTITY: |
|
| 133 | - $this->processQuantity($input_key); |
|
| 134 | - break; |
|
| 135 | - // array of integers |
|
| 136 | - case self::DATA_KEY_TOTAL_TICKETS: |
|
| 137 | - $this->processTicketIDs($input_key); |
|
| 138 | - break; |
|
| 139 | - case self::DATA_KEY_RETURN_URL: |
|
| 140 | - $this->processReturnURL($input_key); |
|
| 141 | - break; |
|
| 142 | - } |
|
| 143 | - } |
|
| 144 | - } |
|
| 145 | - return $this->valid_data; |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - |
|
| 149 | - /** |
|
| 150 | - * @param string $what |
|
| 151 | - * @param string $input_key |
|
| 152 | - */ |
|
| 153 | - protected function processInteger($what, $input_key) |
|
| 154 | - { |
|
| 155 | - $this->valid_data[ $what ] = $this->request->getRequestParam($input_key, 0, 'int'); |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - |
|
| 159 | - /** |
|
| 160 | - * @param string $input_key |
|
| 161 | - * @throws DomainException |
|
| 162 | - */ |
|
| 163 | - protected function processQuantity($input_key) |
|
| 164 | - { |
|
| 165 | - /** @var array $row_qty */ |
|
| 166 | - $row_qty = $this->request->getRequestParam($input_key, [], 'int', true); |
|
| 167 | - if (empty($row_qty) || ! is_array($row_qty)) { |
|
| 168 | - throw new DomainException( |
|
| 169 | - sprintf( |
|
| 170 | - esc_html__( |
|
| 171 | - 'An error occurred while trying to retrieve the ticket selections for the event.%sPlease click the back button on your browser and try again.', |
|
| 172 | - 'event_espresso' |
|
| 173 | - ), |
|
| 174 | - '<br/>' |
|
| 175 | - ) |
|
| 176 | - ); |
|
| 177 | - } |
|
| 178 | - $max_atndz = $this->valid_data[ self::DATA_KEY_MAX_ATNDZ ]; |
|
| 179 | - // if max attendees is 1 then the incoming row qty array |
|
| 180 | - // will only have one element and the value will be the ticket ID |
|
| 181 | - // ex: row qty = [ 0 => TKT_ID ] |
|
| 182 | - if ($max_atndz === 1 && count($row_qty) === 1) { |
|
| 183 | - // so we'll grab that ticket ID, use it as the key, and set the value to 1 |
|
| 184 | - // ex: row qty = [ TKT_ID => 1 ] |
|
| 185 | - $ticket_id = array_pop($row_qty); |
|
| 186 | - $row_qty = [ $ticket_id => 1 ]; |
|
| 187 | - } |
|
| 188 | - foreach ($this->valid_data[ self::DATA_KEY_TICKET_ID ] as $ticket_id) { |
|
| 189 | - $qty = isset($row_qty[ $ticket_id ]) ? $row_qty[ $ticket_id ] : 0; |
|
| 190 | - $this->valid_data[ self::DATA_KEY_QUANTITY ][ $ticket_id ] = $qty; |
|
| 191 | - $this->valid_data[ self:: DATA_KEY_TOTAL_TICKETS ] += $qty; |
|
| 192 | - } |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - |
|
| 196 | - /** |
|
| 197 | - * @param string $input_key |
|
| 198 | - */ |
|
| 199 | - protected function processReturnURL($input_key) |
|
| 200 | - { |
|
| 201 | - // grab and sanitize return-url |
|
| 202 | - $input_value = $this->request->getRequestParam($input_key, '', 'url'); |
|
| 203 | - // was the request coming from an iframe ? if so, then: |
|
| 204 | - if (strpos($input_value, 'event_list=iframe')) { |
|
| 205 | - // get anchor fragment |
|
| 206 | - $input_value = explode('#', $input_value); |
|
| 207 | - $input_value = end($input_value); |
|
| 208 | - // use event list url instead, but append anchor |
|
| 209 | - $input_value = EEH_Event_View::event_archive_url() . '#' . $input_value; |
|
| 210 | - } |
|
| 211 | - $this->valid_data[ self::DATA_KEY_RETURN_URL ] = $input_value; |
|
| 212 | - } |
|
| 213 | - |
|
| 214 | - |
|
| 215 | - /** |
|
| 216 | - * @param string $input_key |
|
| 217 | - * @throws DomainException |
|
| 218 | - */ |
|
| 219 | - protected function processTicketIDs($input_key) |
|
| 220 | - { |
|
| 221 | - $ticket_ids = (array) $this->request->getRequestParam($input_key, [], 'int', true); |
|
| 222 | - $filtered_ticket_ids = array_filter($ticket_ids); |
|
| 223 | - if (empty($filtered_ticket_ids)) { |
|
| 224 | - throw new DomainException( |
|
| 225 | - sprintf( |
|
| 226 | - esc_html__( |
|
| 227 | - 'An error occurred while trying to retrieve the ticket IDs for the event.%sPlease click the back button on your browser and try again.', |
|
| 228 | - 'event_espresso' |
|
| 229 | - ), |
|
| 230 | - '<br/>' |
|
| 231 | - ) |
|
| 232 | - ); |
|
| 233 | - } |
|
| 234 | - // cycle thru values |
|
| 235 | - foreach ($ticket_ids as $key => $value) { |
|
| 236 | - // allow only integers |
|
| 237 | - $this->valid_data[ self::DATA_KEY_TICKET_ID ][ $key ] = absint($value); |
|
| 238 | - } |
|
| 239 | - } |
|
| 19 | + const DATA_KEY_EVENT_ID = 'id'; |
|
| 20 | + |
|
| 21 | + const DATA_KEY_MAX_ATNDZ = 'max_atndz'; |
|
| 22 | + |
|
| 23 | + const DATA_KEY_QUANTITY = 'ticket-selections'; |
|
| 24 | + |
|
| 25 | + const DATA_KEY_RETURN_URL = 'return_url'; |
|
| 26 | + |
|
| 27 | + const DATA_KEY_ROWS = 'rows'; |
|
| 28 | + |
|
| 29 | + const DATA_KEY_TICKET_ID = 'ticket_id'; |
|
| 30 | + |
|
| 31 | + const DATA_KEY_TOTAL_TICKETS = 'total_tickets'; |
|
| 32 | + |
|
| 33 | + const INPUT_KEY_EVENT_ID = 'tkt-slctr-event-id'; |
|
| 34 | + |
|
| 35 | + const INPUT_KEY_MAX_ATNDZ = 'tkt-slctr-max-atndz-'; |
|
| 36 | + |
|
| 37 | + const INPUT_KEY_ROWS = 'tkt-slctr-rows-'; |
|
| 38 | + |
|
| 39 | + const INPUT_KEY_QTY = 'tkt-slctr-qty-'; |
|
| 40 | + |
|
| 41 | + const INPUT_KEY_TICKET_ID = 'tkt-slctr-ticket-id-'; |
|
| 42 | + |
|
| 43 | + const INPUT_KEY_RETURN_URL = 'tkt-slctr-return-url-'; |
|
| 44 | + |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * @var int |
|
| 48 | + */ |
|
| 49 | + protected $event_id; |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * @var array |
|
| 53 | + */ |
|
| 54 | + protected $inputs_to_clean = []; |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * @var array |
|
| 58 | + */ |
|
| 59 | + protected $valid_data = []; |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * @var RequestInterface |
|
| 63 | + */ |
|
| 64 | + protected $request; |
|
| 65 | + |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * @param RequestInterface $request |
|
| 69 | + */ |
|
| 70 | + public function __construct(RequestInterface $request) |
|
| 71 | + { |
|
| 72 | + $this->request = $request; |
|
| 73 | + $this->inputs_to_clean = [ |
|
| 74 | + self::DATA_KEY_MAX_ATNDZ => self::INPUT_KEY_MAX_ATNDZ, |
|
| 75 | + self::DATA_KEY_RETURN_URL => self::INPUT_KEY_RETURN_URL, |
|
| 76 | + self::DATA_KEY_ROWS => self::INPUT_KEY_ROWS, |
|
| 77 | + self::DATA_KEY_TOTAL_TICKETS => self::INPUT_KEY_TICKET_ID, |
|
| 78 | + self::DATA_KEY_QUANTITY => self::INPUT_KEY_QTY, |
|
| 79 | + ]; |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * @return int |
|
| 85 | + * @throws DomainException |
|
| 86 | + */ |
|
| 87 | + public function getEventId() |
|
| 88 | + { |
|
| 89 | + // do we have an event id? |
|
| 90 | + if ($this->event_id === null) { |
|
| 91 | + $this->event_id = $this->request->getRequestParam(self::INPUT_KEY_EVENT_ID, 0, 'int'); |
|
| 92 | + if (! $this->event_id) { |
|
| 93 | + // $_POST['tkt-slctr-event-id'] was not set ?!?!?!? |
|
| 94 | + throw new DomainException( |
|
| 95 | + sprintf( |
|
| 96 | + esc_html__( |
|
| 97 | + 'An event id was not provided or was not received.%sPlease click the back button on your browser and try again.', |
|
| 98 | + 'event_espresso' |
|
| 99 | + ), |
|
| 100 | + '<br/>' |
|
| 101 | + ) |
|
| 102 | + ); |
|
| 103 | + } |
|
| 104 | + } |
|
| 105 | + // event id is valid |
|
| 106 | + return $this->event_id; |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + |
|
| 110 | + /** |
|
| 111 | + * @return array |
|
| 112 | + * @throws DomainException |
|
| 113 | + */ |
|
| 114 | + public function validatePostData() |
|
| 115 | + { |
|
| 116 | + // grab valid id |
|
| 117 | + $this->valid_data[ self::DATA_KEY_EVENT_ID ] = $this->getEventId(); |
|
| 118 | + // let's track the total number of tickets ordered.' |
|
| 119 | + $this->valid_data[ self:: DATA_KEY_TOTAL_TICKETS ] = 0; |
|
| 120 | + // cycle through $inputs_to_clean array |
|
| 121 | + foreach ($this->inputs_to_clean as $what => $input_to_clean) { |
|
| 122 | + $input_key = "{$input_to_clean}{$this->event_id}"; |
|
| 123 | + // check for POST data |
|
| 124 | + if ($this->request->requestParamIsSet($input_key)) { |
|
| 125 | + switch ($what) { |
|
| 126 | + // integers |
|
| 127 | + case self::DATA_KEY_ROWS: |
|
| 128 | + case self::DATA_KEY_MAX_ATNDZ: |
|
| 129 | + $this->processInteger($what, $input_key); |
|
| 130 | + break; |
|
| 131 | + // arrays of integers |
|
| 132 | + case self::DATA_KEY_QUANTITY: |
|
| 133 | + $this->processQuantity($input_key); |
|
| 134 | + break; |
|
| 135 | + // array of integers |
|
| 136 | + case self::DATA_KEY_TOTAL_TICKETS: |
|
| 137 | + $this->processTicketIDs($input_key); |
|
| 138 | + break; |
|
| 139 | + case self::DATA_KEY_RETURN_URL: |
|
| 140 | + $this->processReturnURL($input_key); |
|
| 141 | + break; |
|
| 142 | + } |
|
| 143 | + } |
|
| 144 | + } |
|
| 145 | + return $this->valid_data; |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + |
|
| 149 | + /** |
|
| 150 | + * @param string $what |
|
| 151 | + * @param string $input_key |
|
| 152 | + */ |
|
| 153 | + protected function processInteger($what, $input_key) |
|
| 154 | + { |
|
| 155 | + $this->valid_data[ $what ] = $this->request->getRequestParam($input_key, 0, 'int'); |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + |
|
| 159 | + /** |
|
| 160 | + * @param string $input_key |
|
| 161 | + * @throws DomainException |
|
| 162 | + */ |
|
| 163 | + protected function processQuantity($input_key) |
|
| 164 | + { |
|
| 165 | + /** @var array $row_qty */ |
|
| 166 | + $row_qty = $this->request->getRequestParam($input_key, [], 'int', true); |
|
| 167 | + if (empty($row_qty) || ! is_array($row_qty)) { |
|
| 168 | + throw new DomainException( |
|
| 169 | + sprintf( |
|
| 170 | + esc_html__( |
|
| 171 | + 'An error occurred while trying to retrieve the ticket selections for the event.%sPlease click the back button on your browser and try again.', |
|
| 172 | + 'event_espresso' |
|
| 173 | + ), |
|
| 174 | + '<br/>' |
|
| 175 | + ) |
|
| 176 | + ); |
|
| 177 | + } |
|
| 178 | + $max_atndz = $this->valid_data[ self::DATA_KEY_MAX_ATNDZ ]; |
|
| 179 | + // if max attendees is 1 then the incoming row qty array |
|
| 180 | + // will only have one element and the value will be the ticket ID |
|
| 181 | + // ex: row qty = [ 0 => TKT_ID ] |
|
| 182 | + if ($max_atndz === 1 && count($row_qty) === 1) { |
|
| 183 | + // so we'll grab that ticket ID, use it as the key, and set the value to 1 |
|
| 184 | + // ex: row qty = [ TKT_ID => 1 ] |
|
| 185 | + $ticket_id = array_pop($row_qty); |
|
| 186 | + $row_qty = [ $ticket_id => 1 ]; |
|
| 187 | + } |
|
| 188 | + foreach ($this->valid_data[ self::DATA_KEY_TICKET_ID ] as $ticket_id) { |
|
| 189 | + $qty = isset($row_qty[ $ticket_id ]) ? $row_qty[ $ticket_id ] : 0; |
|
| 190 | + $this->valid_data[ self::DATA_KEY_QUANTITY ][ $ticket_id ] = $qty; |
|
| 191 | + $this->valid_data[ self:: DATA_KEY_TOTAL_TICKETS ] += $qty; |
|
| 192 | + } |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + |
|
| 196 | + /** |
|
| 197 | + * @param string $input_key |
|
| 198 | + */ |
|
| 199 | + protected function processReturnURL($input_key) |
|
| 200 | + { |
|
| 201 | + // grab and sanitize return-url |
|
| 202 | + $input_value = $this->request->getRequestParam($input_key, '', 'url'); |
|
| 203 | + // was the request coming from an iframe ? if so, then: |
|
| 204 | + if (strpos($input_value, 'event_list=iframe')) { |
|
| 205 | + // get anchor fragment |
|
| 206 | + $input_value = explode('#', $input_value); |
|
| 207 | + $input_value = end($input_value); |
|
| 208 | + // use event list url instead, but append anchor |
|
| 209 | + $input_value = EEH_Event_View::event_archive_url() . '#' . $input_value; |
|
| 210 | + } |
|
| 211 | + $this->valid_data[ self::DATA_KEY_RETURN_URL ] = $input_value; |
|
| 212 | + } |
|
| 213 | + |
|
| 214 | + |
|
| 215 | + /** |
|
| 216 | + * @param string $input_key |
|
| 217 | + * @throws DomainException |
|
| 218 | + */ |
|
| 219 | + protected function processTicketIDs($input_key) |
|
| 220 | + { |
|
| 221 | + $ticket_ids = (array) $this->request->getRequestParam($input_key, [], 'int', true); |
|
| 222 | + $filtered_ticket_ids = array_filter($ticket_ids); |
|
| 223 | + if (empty($filtered_ticket_ids)) { |
|
| 224 | + throw new DomainException( |
|
| 225 | + sprintf( |
|
| 226 | + esc_html__( |
|
| 227 | + 'An error occurred while trying to retrieve the ticket IDs for the event.%sPlease click the back button on your browser and try again.', |
|
| 228 | + 'event_espresso' |
|
| 229 | + ), |
|
| 230 | + '<br/>' |
|
| 231 | + ) |
|
| 232 | + ); |
|
| 233 | + } |
|
| 234 | + // cycle thru values |
|
| 235 | + foreach ($ticket_ids as $key => $value) { |
|
| 236 | + // allow only integers |
|
| 237 | + $this->valid_data[ self::DATA_KEY_TICKET_ID ][ $key ] = absint($value); |
|
| 238 | + } |
|
| 239 | + } |
|
| 240 | 240 | } |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | // do we have an event id? |
| 90 | 90 | if ($this->event_id === null) { |
| 91 | 91 | $this->event_id = $this->request->getRequestParam(self::INPUT_KEY_EVENT_ID, 0, 'int'); |
| 92 | - if (! $this->event_id) { |
|
| 92 | + if ( ! $this->event_id) { |
|
| 93 | 93 | // $_POST['tkt-slctr-event-id'] was not set ?!?!?!? |
| 94 | 94 | throw new DomainException( |
| 95 | 95 | sprintf( |
@@ -114,9 +114,9 @@ discard block |
||
| 114 | 114 | public function validatePostData() |
| 115 | 115 | { |
| 116 | 116 | // grab valid id |
| 117 | - $this->valid_data[ self::DATA_KEY_EVENT_ID ] = $this->getEventId(); |
|
| 117 | + $this->valid_data[self::DATA_KEY_EVENT_ID] = $this->getEventId(); |
|
| 118 | 118 | // let's track the total number of tickets ordered.' |
| 119 | - $this->valid_data[ self:: DATA_KEY_TOTAL_TICKETS ] = 0; |
|
| 119 | + $this->valid_data[self:: DATA_KEY_TOTAL_TICKETS] = 0; |
|
| 120 | 120 | // cycle through $inputs_to_clean array |
| 121 | 121 | foreach ($this->inputs_to_clean as $what => $input_to_clean) { |
| 122 | 122 | $input_key = "{$input_to_clean}{$this->event_id}"; |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | */ |
| 153 | 153 | protected function processInteger($what, $input_key) |
| 154 | 154 | { |
| 155 | - $this->valid_data[ $what ] = $this->request->getRequestParam($input_key, 0, 'int'); |
|
| 155 | + $this->valid_data[$what] = $this->request->getRequestParam($input_key, 0, 'int'); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | ) |
| 176 | 176 | ); |
| 177 | 177 | } |
| 178 | - $max_atndz = $this->valid_data[ self::DATA_KEY_MAX_ATNDZ ]; |
|
| 178 | + $max_atndz = $this->valid_data[self::DATA_KEY_MAX_ATNDZ]; |
|
| 179 | 179 | // if max attendees is 1 then the incoming row qty array |
| 180 | 180 | // will only have one element and the value will be the ticket ID |
| 181 | 181 | // ex: row qty = [ 0 => TKT_ID ] |
@@ -183,12 +183,12 @@ discard block |
||
| 183 | 183 | // so we'll grab that ticket ID, use it as the key, and set the value to 1 |
| 184 | 184 | // ex: row qty = [ TKT_ID => 1 ] |
| 185 | 185 | $ticket_id = array_pop($row_qty); |
| 186 | - $row_qty = [ $ticket_id => 1 ]; |
|
| 186 | + $row_qty = [$ticket_id => 1]; |
|
| 187 | 187 | } |
| 188 | - foreach ($this->valid_data[ self::DATA_KEY_TICKET_ID ] as $ticket_id) { |
|
| 189 | - $qty = isset($row_qty[ $ticket_id ]) ? $row_qty[ $ticket_id ] : 0; |
|
| 190 | - $this->valid_data[ self::DATA_KEY_QUANTITY ][ $ticket_id ] = $qty; |
|
| 191 | - $this->valid_data[ self:: DATA_KEY_TOTAL_TICKETS ] += $qty; |
|
| 188 | + foreach ($this->valid_data[self::DATA_KEY_TICKET_ID] as $ticket_id) { |
|
| 189 | + $qty = isset($row_qty[$ticket_id]) ? $row_qty[$ticket_id] : 0; |
|
| 190 | + $this->valid_data[self::DATA_KEY_QUANTITY][$ticket_id] = $qty; |
|
| 191 | + $this->valid_data[self:: DATA_KEY_TOTAL_TICKETS] += $qty; |
|
| 192 | 192 | } |
| 193 | 193 | } |
| 194 | 194 | |
@@ -206,9 +206,9 @@ discard block |
||
| 206 | 206 | $input_value = explode('#', $input_value); |
| 207 | 207 | $input_value = end($input_value); |
| 208 | 208 | // use event list url instead, but append anchor |
| 209 | - $input_value = EEH_Event_View::event_archive_url() . '#' . $input_value; |
|
| 209 | + $input_value = EEH_Event_View::event_archive_url().'#'.$input_value; |
|
| 210 | 210 | } |
| 211 | - $this->valid_data[ self::DATA_KEY_RETURN_URL ] = $input_value; |
|
| 211 | + $this->valid_data[self::DATA_KEY_RETURN_URL] = $input_value; |
|
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | // cycle thru values |
| 235 | 235 | foreach ($ticket_ids as $key => $value) { |
| 236 | 236 | // allow only integers |
| 237 | - $this->valid_data[ self::DATA_KEY_TICKET_ID ][ $key ] = absint($value); |
|
| 237 | + $this->valid_data[self::DATA_KEY_TICKET_ID][$key] = absint($value); |
|
| 238 | 238 | } |
| 239 | 239 | } |
| 240 | 240 | } |
@@ -20,364 +20,364 @@ |
||
| 20 | 20 | class TicketSelectorRowStandard extends TicketSelectorRow |
| 21 | 21 | { |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * @var TicketDetails |
|
| 25 | - */ |
|
| 26 | - protected $ticket_details; |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * @var EE_Ticket_Selector_Config |
|
| 30 | - */ |
|
| 31 | - protected $template_settings; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * @var EE_Tax_Config |
|
| 35 | - */ |
|
| 36 | - protected $tax_settings; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * @var boolean |
|
| 40 | - */ |
|
| 41 | - protected $prices_displayed_including_taxes; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * @var int |
|
| 45 | - */ |
|
| 46 | - protected $row; |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * @var int |
|
| 50 | - */ |
|
| 51 | - protected $cols; |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * @var boolean |
|
| 55 | - */ |
|
| 56 | - protected $hidden_input_qty = false; |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * @var string |
|
| 60 | - */ |
|
| 61 | - protected $ticket_datetime_classes; |
|
| 62 | - |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * TicketDetails constructor. |
|
| 66 | - * |
|
| 67 | - * @param TicketDetails $ticket_details |
|
| 68 | - * @param EE_Tax_Config $tax_settings |
|
| 69 | - * @param int $total_tickets |
|
| 70 | - * @param int $max_attendees |
|
| 71 | - * @param int $row |
|
| 72 | - * @param int $cols |
|
| 73 | - * @param boolean $required_ticket_sold_out |
|
| 74 | - * @param string $event_status |
|
| 75 | - * @param string $ticket_datetime_classes |
|
| 76 | - * @throws EE_Error |
|
| 77 | - * @throws UnexpectedEntityException |
|
| 78 | - */ |
|
| 79 | - public function __construct( |
|
| 80 | - TicketDetails $ticket_details, |
|
| 81 | - EE_Tax_Config $tax_settings, |
|
| 82 | - $total_tickets, |
|
| 83 | - $max_attendees, |
|
| 84 | - $row, |
|
| 85 | - $cols, |
|
| 86 | - $required_ticket_sold_out, |
|
| 87 | - $event_status, |
|
| 88 | - $ticket_datetime_classes |
|
| 89 | - ) { |
|
| 90 | - $this->ticket_details = $ticket_details; |
|
| 91 | - $this->template_settings = $ticket_details->getTemplateSettings(); |
|
| 92 | - $this->tax_settings = $tax_settings; |
|
| 93 | - $this->row = $row; |
|
| 94 | - $this->cols = $cols; |
|
| 95 | - $this->ticket_datetime_classes = $ticket_datetime_classes; |
|
| 96 | - parent::__construct( |
|
| 97 | - $ticket_details->getTicket(), |
|
| 98 | - $max_attendees, |
|
| 99 | - $ticket_details->getDateFormat(), |
|
| 100 | - $event_status, |
|
| 101 | - $required_ticket_sold_out, |
|
| 102 | - $total_tickets |
|
| 103 | - ); |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - |
|
| 107 | - /** |
|
| 108 | - * other ticket rows will need to know if a required ticket is sold out, |
|
| 109 | - * so that they are not offered for sale |
|
| 110 | - * |
|
| 111 | - * @return boolean |
|
| 112 | - */ |
|
| 113 | - public function getRequiredTicketSoldOut() |
|
| 114 | - { |
|
| 115 | - return $this->required_ticket_sold_out; |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - |
|
| 119 | - /** |
|
| 120 | - * @return int |
|
| 121 | - */ |
|
| 122 | - public function getCols() |
|
| 123 | - { |
|
| 124 | - return $this->cols; |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - |
|
| 128 | - /** |
|
| 129 | - * getHtml |
|
| 130 | - * |
|
| 131 | - * @return string |
|
| 132 | - * @throws EE_Error |
|
| 133 | - * @throws ReflectionException |
|
| 134 | - */ |
|
| 135 | - public function getHtml() |
|
| 136 | - { |
|
| 137 | - $this->min = 0; |
|
| 138 | - $this->max = $this->ticket->max(); |
|
| 139 | - $remaining = $this->ticket->remaining(); |
|
| 140 | - $this->setTicketMinAndMax($remaining); |
|
| 141 | - // set flag if ticket is required (flag is set to start date so that future tickets are not blocked) |
|
| 142 | - $this->required_ticket_sold_out = $this->ticket->required() && ! $remaining |
|
| 143 | - ? $this->ticket->start_date() |
|
| 144 | - : $this->required_ticket_sold_out; |
|
| 145 | - $this->setTicketPriceDetails(); |
|
| 146 | - $this->setTicketStatusClasses($remaining); |
|
| 147 | - $filtered_row_html = $this->getFilteredRowHtml(); |
|
| 148 | - if ($filtered_row_html !== false) { |
|
| 149 | - return $filtered_row_html; |
|
| 150 | - } |
|
| 151 | - $ticket_selector_row_html = EEH_HTML::tr( |
|
| 152 | - '', |
|
| 153 | - '', |
|
| 154 | - "tckt-slctr-tbl-tr {$this->status_class}{$this->ticket_datetime_classes} " |
|
| 155 | - . espresso_get_object_css_class($this->ticket) |
|
| 156 | - ); |
|
| 157 | - $filtered_row_content = $this->getFilteredRowContents(); |
|
| 158 | - if ($filtered_row_content !== false) { |
|
| 159 | - if ($this->max_attendees === 1) { |
|
| 160 | - return $ticket_selector_row_html |
|
| 161 | - . $filtered_row_content |
|
| 162 | - . $this->ticketQtyAndIdHiddenInputs() |
|
| 163 | - . EEH_HTML::trx(); |
|
| 164 | - } |
|
| 165 | - return $ticket_selector_row_html |
|
| 166 | - . $filtered_row_content |
|
| 167 | - . EEH_HTML::trx(); |
|
| 168 | - } |
|
| 169 | - $this->hidden_input_qty = $this->max_attendees > 1; |
|
| 170 | - |
|
| 171 | - $ticket_selector_row_html .= $this->ticketNameTableCell(); |
|
| 172 | - $ticket_selector_row_html .= $this->ticketPriceTableCell(); |
|
| 173 | - $ticket_selector_row_html .= EEH_HTML::td( |
|
| 174 | - '', |
|
| 175 | - '', |
|
| 176 | - 'tckt-slctr-tbl-td-qty cntr', |
|
| 177 | - '', |
|
| 178 | - 'headers="quantity-' . $this->EVT_ID . '"' |
|
| 179 | - ); |
|
| 180 | - $this->setTicketStatusDisplay($remaining); |
|
| 181 | - if (empty($this->ticket_status_display)) { |
|
| 182 | - if ($this->max_attendees === 1) { |
|
| 183 | - // only ONE attendee is allowed to register at a time |
|
| 184 | - $ticket_selector_row_html .= $this->onlyOneAttendeeCanRegister(); |
|
| 185 | - } elseif ($this->max > 0) { |
|
| 186 | - $ticket_selector_row_html .= $this->ticketQuantitySelector(); |
|
| 187 | - } |
|
| 188 | - } |
|
| 189 | - $ticket_selector_row_html .= $this->ticket_status_display; |
|
| 190 | - $ticket_selector_row_html .= $this->ticketQtyAndIdHiddenInputs(); |
|
| 191 | - $ticket_selector_row_html .= $this->ticket_details->display( |
|
| 192 | - $this->ticket_price, |
|
| 193 | - $remaining, |
|
| 194 | - $this->cols |
|
| 195 | - ); |
|
| 196 | - $ticket_selector_row_html .= EEH_HTML::tdx(); |
|
| 197 | - $ticket_selector_row_html .= EEH_HTML::trx(); |
|
| 198 | - |
|
| 199 | - |
|
| 200 | - $this->row++; |
|
| 201 | - return $ticket_selector_row_html; |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - |
|
| 205 | - /** |
|
| 206 | - * getTicketPriceDetails |
|
| 207 | - * |
|
| 208 | - * @return void |
|
| 209 | - * @throws EE_Error |
|
| 210 | - */ |
|
| 211 | - protected function setTicketPriceDetails() |
|
| 212 | - { |
|
| 213 | - $this->ticket_price = $this->tax_settings->prices_displayed_including_taxes |
|
| 214 | - ? $this->ticket->get_ticket_total_with_taxes() |
|
| 215 | - : $this->ticket->get_ticket_subtotal(); |
|
| 216 | - $this->ticket_bundle = false; |
|
| 217 | - $ticket_min = $this->ticket->min(); |
|
| 218 | - // for ticket bundles, set min and max qty the same |
|
| 219 | - if ($ticket_min !== 0 && $ticket_min === $this->ticket->max()) { |
|
| 220 | - $this->ticket_price *= $ticket_min; |
|
| 221 | - $this->ticket_bundle = true; |
|
| 222 | - } |
|
| 223 | - $this->ticket_price = apply_filters( |
|
| 224 | - 'FHEE__ticket_selector_chart_template__ticket_price', |
|
| 225 | - $this->ticket_price, |
|
| 226 | - $this->ticket |
|
| 227 | - ); |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - |
|
| 231 | - /** |
|
| 232 | - * ticketNameTableCell |
|
| 233 | - * |
|
| 234 | - * @return string |
|
| 235 | - * @throws EE_Error |
|
| 236 | - * @throws ReflectionException |
|
| 237 | - */ |
|
| 238 | - protected function ticketNameTableCell() |
|
| 239 | - { |
|
| 240 | - $html = EEH_HTML::td( |
|
| 241 | - '', |
|
| 242 | - '', |
|
| 243 | - 'tckt-slctr-tbl-td-name', |
|
| 244 | - '', |
|
| 245 | - 'headers="details-' . $this->EVT_ID . '"' |
|
| 246 | - ); |
|
| 247 | - $html .= EEH_HTML::strong($this->ticket->get_pretty('TKT_name')); |
|
| 248 | - $html .= $this->ticket_details->getShowHideLinks(); |
|
| 249 | - if ($this->ticket->required()) { |
|
| 250 | - $html .= EEH_HTML::p( |
|
| 251 | - apply_filters( |
|
| 252 | - 'FHEE__ticket_selector_chart_template__ticket_required_message', |
|
| 253 | - esc_html__('This ticket is required and must be purchased.', 'event_espresso') |
|
| 254 | - ), |
|
| 255 | - '', |
|
| 256 | - 'ticket-required-pg' |
|
| 257 | - ); |
|
| 258 | - } |
|
| 259 | - $html .= EEH_HTML::tdx(); |
|
| 260 | - return $html; |
|
| 261 | - } |
|
| 262 | - |
|
| 263 | - |
|
| 264 | - /** |
|
| 265 | - * ticketPriceTableCell |
|
| 266 | - * |
|
| 267 | - * @return string |
|
| 268 | - * @throws EE_Error |
|
| 269 | - */ |
|
| 270 | - protected function ticketPriceTableCell() |
|
| 271 | - { |
|
| 272 | - $html = ''; |
|
| 273 | - if (apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', true)) { |
|
| 274 | - $html .= EEH_HTML::td( |
|
| 275 | - '', |
|
| 276 | - '', |
|
| 277 | - 'tckt-slctr-tbl-td-price jst-rght', |
|
| 278 | - '', |
|
| 279 | - 'headers="price-' . $this->EVT_ID . '"' |
|
| 280 | - ); |
|
| 281 | - $html .= EEH_Template::format_currency($this->ticket_price); |
|
| 282 | - $html .= $this->ticket->taxable() |
|
| 283 | - ? EEH_HTML::span('*', '', 'taxable-tickets-asterisk grey-text') |
|
| 284 | - : ''; |
|
| 285 | - $html .= ' '; |
|
| 286 | - // phpcs:disable WordPress.WP.I18n.NoEmptyStrings |
|
| 287 | - $html .= EEH_HTML::span( |
|
| 288 | - $this->ticket_bundle |
|
| 289 | - ? apply_filters( |
|
| 290 | - 'FHEE__ticket_selector_chart_template__per_ticket_bundle_text', |
|
| 291 | - esc_html__(' / bundle', 'event_espresso') |
|
| 292 | - ) |
|
| 293 | - : apply_filters( |
|
| 294 | - 'FHEE__ticket_selector_chart_template__per_ticket_text', |
|
| 295 | - esc_html__('', 'event_espresso') |
|
| 296 | - ), |
|
| 297 | - '', |
|
| 298 | - 'smaller-text no-bold' |
|
| 299 | - ); |
|
| 300 | - $html .= ' '; |
|
| 301 | - $html .= EEH_HTML::tdx(); |
|
| 302 | - $this->cols++; |
|
| 303 | - } |
|
| 304 | - return $html; |
|
| 305 | - } |
|
| 306 | - |
|
| 307 | - |
|
| 308 | - /** |
|
| 309 | - * onlyOneAttendeeCanRegister |
|
| 310 | - * |
|
| 311 | - * @return string |
|
| 312 | - * @throws EE_Error |
|
| 313 | - */ |
|
| 314 | - protected function onlyOneAttendeeCanRegister() |
|
| 315 | - { |
|
| 316 | - $this->hidden_input_qty = false; |
|
| 317 | - // display submit button since we have tickets available |
|
| 318 | - add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
| 319 | - |
|
| 320 | - $TKT = $this->ticket->ID(); |
|
| 321 | - $label = esc_html__('Select this ticket', 'event_espresso'); |
|
| 322 | - $name = "tkt-slctr-qty-{$this->EVT_ID}[]"; |
|
| 323 | - $class = "ticket-selector-tbl-qty-slct"; |
|
| 324 | - $id = "{$class}-{$this->EVT_ID}-{$this->row}"; |
|
| 325 | - $checked = $this->total_tickets === 1 ? ' checked="checked"' : ''; |
|
| 326 | - |
|
| 327 | - $html = "<label class='ee-a11y-screen-reader-text' for='{$id}' >{$label}</label>"; |
|
| 328 | - $html .= "<input type='radio'{$checked} name='{$name}' id='{$id}' class='{$class}' value='{$TKT}' title='' />"; |
|
| 329 | - return $html; |
|
| 330 | - } |
|
| 331 | - |
|
| 332 | - |
|
| 333 | - /** |
|
| 334 | - * ticketQuantitySelector |
|
| 335 | - * |
|
| 336 | - * @return string |
|
| 337 | - * @throws EE_Error |
|
| 338 | - */ |
|
| 339 | - protected function ticketQuantitySelector() |
|
| 340 | - { |
|
| 341 | - $this->hidden_input_qty = false; |
|
| 342 | - // display submit button since we have tickets available |
|
| 343 | - add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
| 344 | - |
|
| 345 | - $TKT = $this->ticket->ID(); |
|
| 346 | - $label = esc_html__('Quantity', 'event_espresso'); |
|
| 347 | - $class = 'ticket-selector-tbl-qty-slct'; |
|
| 348 | - $id = "{$class}-{$this->EVT_ID}-{$this->row}"; |
|
| 349 | - |
|
| 350 | - $html = "<label class='ee-a11y-screen-reader-text' for='{$id}' >{$label}</label>"; |
|
| 351 | - $html .= "<select name='tkt-slctr-qty-{$this->EVT_ID}[{$TKT}]' id='{$id}' class='{$class}'>"; |
|
| 352 | - // this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased |
|
| 353 | - if ($this->min !== 0 && ! $this->ticket->required()) { |
|
| 354 | - $html .= "<option value='0'> 0 </option>"; |
|
| 355 | - } |
|
| 356 | - // offer ticket quantities from the min to the max |
|
| 357 | - for ($i = $this->min; $i <= $this->max; $i++) { |
|
| 358 | - $html .= "<option value='{$i}'> {$i} </option>"; |
|
| 359 | - } |
|
| 360 | - $html .= "</select>"; |
|
| 361 | - return $html; |
|
| 362 | - } |
|
| 363 | - |
|
| 364 | - |
|
| 365 | - /** |
|
| 366 | - * getHiddenInputs |
|
| 367 | - * |
|
| 368 | - * @return string |
|
| 369 | - * @throws EE_Error |
|
| 370 | - */ |
|
| 371 | - protected function ticketQtyAndIdHiddenInputs() |
|
| 372 | - { |
|
| 373 | - $html = ''; |
|
| 374 | - $EVT = $this->EVT_ID; |
|
| 375 | - $TKT = $this->ticket->ID(); |
|
| 376 | - // depending on group reg we need to change the format for qty |
|
| 377 | - if ($this->hidden_input_qty) { |
|
| 378 | - $html .= "<input type='hidden' name='tkt-slctr-qty-{$EVT}[]' value='0' />"; |
|
| 379 | - } |
|
| 380 | - $html .= "<input type='hidden' name='tkt-slctr-ticket-id-{$EVT}[]' value='{$TKT}' />"; |
|
| 381 | - return $html; |
|
| 382 | - } |
|
| 23 | + /** |
|
| 24 | + * @var TicketDetails |
|
| 25 | + */ |
|
| 26 | + protected $ticket_details; |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * @var EE_Ticket_Selector_Config |
|
| 30 | + */ |
|
| 31 | + protected $template_settings; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * @var EE_Tax_Config |
|
| 35 | + */ |
|
| 36 | + protected $tax_settings; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * @var boolean |
|
| 40 | + */ |
|
| 41 | + protected $prices_displayed_including_taxes; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * @var int |
|
| 45 | + */ |
|
| 46 | + protected $row; |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * @var int |
|
| 50 | + */ |
|
| 51 | + protected $cols; |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * @var boolean |
|
| 55 | + */ |
|
| 56 | + protected $hidden_input_qty = false; |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * @var string |
|
| 60 | + */ |
|
| 61 | + protected $ticket_datetime_classes; |
|
| 62 | + |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * TicketDetails constructor. |
|
| 66 | + * |
|
| 67 | + * @param TicketDetails $ticket_details |
|
| 68 | + * @param EE_Tax_Config $tax_settings |
|
| 69 | + * @param int $total_tickets |
|
| 70 | + * @param int $max_attendees |
|
| 71 | + * @param int $row |
|
| 72 | + * @param int $cols |
|
| 73 | + * @param boolean $required_ticket_sold_out |
|
| 74 | + * @param string $event_status |
|
| 75 | + * @param string $ticket_datetime_classes |
|
| 76 | + * @throws EE_Error |
|
| 77 | + * @throws UnexpectedEntityException |
|
| 78 | + */ |
|
| 79 | + public function __construct( |
|
| 80 | + TicketDetails $ticket_details, |
|
| 81 | + EE_Tax_Config $tax_settings, |
|
| 82 | + $total_tickets, |
|
| 83 | + $max_attendees, |
|
| 84 | + $row, |
|
| 85 | + $cols, |
|
| 86 | + $required_ticket_sold_out, |
|
| 87 | + $event_status, |
|
| 88 | + $ticket_datetime_classes |
|
| 89 | + ) { |
|
| 90 | + $this->ticket_details = $ticket_details; |
|
| 91 | + $this->template_settings = $ticket_details->getTemplateSettings(); |
|
| 92 | + $this->tax_settings = $tax_settings; |
|
| 93 | + $this->row = $row; |
|
| 94 | + $this->cols = $cols; |
|
| 95 | + $this->ticket_datetime_classes = $ticket_datetime_classes; |
|
| 96 | + parent::__construct( |
|
| 97 | + $ticket_details->getTicket(), |
|
| 98 | + $max_attendees, |
|
| 99 | + $ticket_details->getDateFormat(), |
|
| 100 | + $event_status, |
|
| 101 | + $required_ticket_sold_out, |
|
| 102 | + $total_tickets |
|
| 103 | + ); |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + |
|
| 107 | + /** |
|
| 108 | + * other ticket rows will need to know if a required ticket is sold out, |
|
| 109 | + * so that they are not offered for sale |
|
| 110 | + * |
|
| 111 | + * @return boolean |
|
| 112 | + */ |
|
| 113 | + public function getRequiredTicketSoldOut() |
|
| 114 | + { |
|
| 115 | + return $this->required_ticket_sold_out; |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + |
|
| 119 | + /** |
|
| 120 | + * @return int |
|
| 121 | + */ |
|
| 122 | + public function getCols() |
|
| 123 | + { |
|
| 124 | + return $this->cols; |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + |
|
| 128 | + /** |
|
| 129 | + * getHtml |
|
| 130 | + * |
|
| 131 | + * @return string |
|
| 132 | + * @throws EE_Error |
|
| 133 | + * @throws ReflectionException |
|
| 134 | + */ |
|
| 135 | + public function getHtml() |
|
| 136 | + { |
|
| 137 | + $this->min = 0; |
|
| 138 | + $this->max = $this->ticket->max(); |
|
| 139 | + $remaining = $this->ticket->remaining(); |
|
| 140 | + $this->setTicketMinAndMax($remaining); |
|
| 141 | + // set flag if ticket is required (flag is set to start date so that future tickets are not blocked) |
|
| 142 | + $this->required_ticket_sold_out = $this->ticket->required() && ! $remaining |
|
| 143 | + ? $this->ticket->start_date() |
|
| 144 | + : $this->required_ticket_sold_out; |
|
| 145 | + $this->setTicketPriceDetails(); |
|
| 146 | + $this->setTicketStatusClasses($remaining); |
|
| 147 | + $filtered_row_html = $this->getFilteredRowHtml(); |
|
| 148 | + if ($filtered_row_html !== false) { |
|
| 149 | + return $filtered_row_html; |
|
| 150 | + } |
|
| 151 | + $ticket_selector_row_html = EEH_HTML::tr( |
|
| 152 | + '', |
|
| 153 | + '', |
|
| 154 | + "tckt-slctr-tbl-tr {$this->status_class}{$this->ticket_datetime_classes} " |
|
| 155 | + . espresso_get_object_css_class($this->ticket) |
|
| 156 | + ); |
|
| 157 | + $filtered_row_content = $this->getFilteredRowContents(); |
|
| 158 | + if ($filtered_row_content !== false) { |
|
| 159 | + if ($this->max_attendees === 1) { |
|
| 160 | + return $ticket_selector_row_html |
|
| 161 | + . $filtered_row_content |
|
| 162 | + . $this->ticketQtyAndIdHiddenInputs() |
|
| 163 | + . EEH_HTML::trx(); |
|
| 164 | + } |
|
| 165 | + return $ticket_selector_row_html |
|
| 166 | + . $filtered_row_content |
|
| 167 | + . EEH_HTML::trx(); |
|
| 168 | + } |
|
| 169 | + $this->hidden_input_qty = $this->max_attendees > 1; |
|
| 170 | + |
|
| 171 | + $ticket_selector_row_html .= $this->ticketNameTableCell(); |
|
| 172 | + $ticket_selector_row_html .= $this->ticketPriceTableCell(); |
|
| 173 | + $ticket_selector_row_html .= EEH_HTML::td( |
|
| 174 | + '', |
|
| 175 | + '', |
|
| 176 | + 'tckt-slctr-tbl-td-qty cntr', |
|
| 177 | + '', |
|
| 178 | + 'headers="quantity-' . $this->EVT_ID . '"' |
|
| 179 | + ); |
|
| 180 | + $this->setTicketStatusDisplay($remaining); |
|
| 181 | + if (empty($this->ticket_status_display)) { |
|
| 182 | + if ($this->max_attendees === 1) { |
|
| 183 | + // only ONE attendee is allowed to register at a time |
|
| 184 | + $ticket_selector_row_html .= $this->onlyOneAttendeeCanRegister(); |
|
| 185 | + } elseif ($this->max > 0) { |
|
| 186 | + $ticket_selector_row_html .= $this->ticketQuantitySelector(); |
|
| 187 | + } |
|
| 188 | + } |
|
| 189 | + $ticket_selector_row_html .= $this->ticket_status_display; |
|
| 190 | + $ticket_selector_row_html .= $this->ticketQtyAndIdHiddenInputs(); |
|
| 191 | + $ticket_selector_row_html .= $this->ticket_details->display( |
|
| 192 | + $this->ticket_price, |
|
| 193 | + $remaining, |
|
| 194 | + $this->cols |
|
| 195 | + ); |
|
| 196 | + $ticket_selector_row_html .= EEH_HTML::tdx(); |
|
| 197 | + $ticket_selector_row_html .= EEH_HTML::trx(); |
|
| 198 | + |
|
| 199 | + |
|
| 200 | + $this->row++; |
|
| 201 | + return $ticket_selector_row_html; |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + |
|
| 205 | + /** |
|
| 206 | + * getTicketPriceDetails |
|
| 207 | + * |
|
| 208 | + * @return void |
|
| 209 | + * @throws EE_Error |
|
| 210 | + */ |
|
| 211 | + protected function setTicketPriceDetails() |
|
| 212 | + { |
|
| 213 | + $this->ticket_price = $this->tax_settings->prices_displayed_including_taxes |
|
| 214 | + ? $this->ticket->get_ticket_total_with_taxes() |
|
| 215 | + : $this->ticket->get_ticket_subtotal(); |
|
| 216 | + $this->ticket_bundle = false; |
|
| 217 | + $ticket_min = $this->ticket->min(); |
|
| 218 | + // for ticket bundles, set min and max qty the same |
|
| 219 | + if ($ticket_min !== 0 && $ticket_min === $this->ticket->max()) { |
|
| 220 | + $this->ticket_price *= $ticket_min; |
|
| 221 | + $this->ticket_bundle = true; |
|
| 222 | + } |
|
| 223 | + $this->ticket_price = apply_filters( |
|
| 224 | + 'FHEE__ticket_selector_chart_template__ticket_price', |
|
| 225 | + $this->ticket_price, |
|
| 226 | + $this->ticket |
|
| 227 | + ); |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + |
|
| 231 | + /** |
|
| 232 | + * ticketNameTableCell |
|
| 233 | + * |
|
| 234 | + * @return string |
|
| 235 | + * @throws EE_Error |
|
| 236 | + * @throws ReflectionException |
|
| 237 | + */ |
|
| 238 | + protected function ticketNameTableCell() |
|
| 239 | + { |
|
| 240 | + $html = EEH_HTML::td( |
|
| 241 | + '', |
|
| 242 | + '', |
|
| 243 | + 'tckt-slctr-tbl-td-name', |
|
| 244 | + '', |
|
| 245 | + 'headers="details-' . $this->EVT_ID . '"' |
|
| 246 | + ); |
|
| 247 | + $html .= EEH_HTML::strong($this->ticket->get_pretty('TKT_name')); |
|
| 248 | + $html .= $this->ticket_details->getShowHideLinks(); |
|
| 249 | + if ($this->ticket->required()) { |
|
| 250 | + $html .= EEH_HTML::p( |
|
| 251 | + apply_filters( |
|
| 252 | + 'FHEE__ticket_selector_chart_template__ticket_required_message', |
|
| 253 | + esc_html__('This ticket is required and must be purchased.', 'event_espresso') |
|
| 254 | + ), |
|
| 255 | + '', |
|
| 256 | + 'ticket-required-pg' |
|
| 257 | + ); |
|
| 258 | + } |
|
| 259 | + $html .= EEH_HTML::tdx(); |
|
| 260 | + return $html; |
|
| 261 | + } |
|
| 262 | + |
|
| 263 | + |
|
| 264 | + /** |
|
| 265 | + * ticketPriceTableCell |
|
| 266 | + * |
|
| 267 | + * @return string |
|
| 268 | + * @throws EE_Error |
|
| 269 | + */ |
|
| 270 | + protected function ticketPriceTableCell() |
|
| 271 | + { |
|
| 272 | + $html = ''; |
|
| 273 | + if (apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', true)) { |
|
| 274 | + $html .= EEH_HTML::td( |
|
| 275 | + '', |
|
| 276 | + '', |
|
| 277 | + 'tckt-slctr-tbl-td-price jst-rght', |
|
| 278 | + '', |
|
| 279 | + 'headers="price-' . $this->EVT_ID . '"' |
|
| 280 | + ); |
|
| 281 | + $html .= EEH_Template::format_currency($this->ticket_price); |
|
| 282 | + $html .= $this->ticket->taxable() |
|
| 283 | + ? EEH_HTML::span('*', '', 'taxable-tickets-asterisk grey-text') |
|
| 284 | + : ''; |
|
| 285 | + $html .= ' '; |
|
| 286 | + // phpcs:disable WordPress.WP.I18n.NoEmptyStrings |
|
| 287 | + $html .= EEH_HTML::span( |
|
| 288 | + $this->ticket_bundle |
|
| 289 | + ? apply_filters( |
|
| 290 | + 'FHEE__ticket_selector_chart_template__per_ticket_bundle_text', |
|
| 291 | + esc_html__(' / bundle', 'event_espresso') |
|
| 292 | + ) |
|
| 293 | + : apply_filters( |
|
| 294 | + 'FHEE__ticket_selector_chart_template__per_ticket_text', |
|
| 295 | + esc_html__('', 'event_espresso') |
|
| 296 | + ), |
|
| 297 | + '', |
|
| 298 | + 'smaller-text no-bold' |
|
| 299 | + ); |
|
| 300 | + $html .= ' '; |
|
| 301 | + $html .= EEH_HTML::tdx(); |
|
| 302 | + $this->cols++; |
|
| 303 | + } |
|
| 304 | + return $html; |
|
| 305 | + } |
|
| 306 | + |
|
| 307 | + |
|
| 308 | + /** |
|
| 309 | + * onlyOneAttendeeCanRegister |
|
| 310 | + * |
|
| 311 | + * @return string |
|
| 312 | + * @throws EE_Error |
|
| 313 | + */ |
|
| 314 | + protected function onlyOneAttendeeCanRegister() |
|
| 315 | + { |
|
| 316 | + $this->hidden_input_qty = false; |
|
| 317 | + // display submit button since we have tickets available |
|
| 318 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
| 319 | + |
|
| 320 | + $TKT = $this->ticket->ID(); |
|
| 321 | + $label = esc_html__('Select this ticket', 'event_espresso'); |
|
| 322 | + $name = "tkt-slctr-qty-{$this->EVT_ID}[]"; |
|
| 323 | + $class = "ticket-selector-tbl-qty-slct"; |
|
| 324 | + $id = "{$class}-{$this->EVT_ID}-{$this->row}"; |
|
| 325 | + $checked = $this->total_tickets === 1 ? ' checked="checked"' : ''; |
|
| 326 | + |
|
| 327 | + $html = "<label class='ee-a11y-screen-reader-text' for='{$id}' >{$label}</label>"; |
|
| 328 | + $html .= "<input type='radio'{$checked} name='{$name}' id='{$id}' class='{$class}' value='{$TKT}' title='' />"; |
|
| 329 | + return $html; |
|
| 330 | + } |
|
| 331 | + |
|
| 332 | + |
|
| 333 | + /** |
|
| 334 | + * ticketQuantitySelector |
|
| 335 | + * |
|
| 336 | + * @return string |
|
| 337 | + * @throws EE_Error |
|
| 338 | + */ |
|
| 339 | + protected function ticketQuantitySelector() |
|
| 340 | + { |
|
| 341 | + $this->hidden_input_qty = false; |
|
| 342 | + // display submit button since we have tickets available |
|
| 343 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
| 344 | + |
|
| 345 | + $TKT = $this->ticket->ID(); |
|
| 346 | + $label = esc_html__('Quantity', 'event_espresso'); |
|
| 347 | + $class = 'ticket-selector-tbl-qty-slct'; |
|
| 348 | + $id = "{$class}-{$this->EVT_ID}-{$this->row}"; |
|
| 349 | + |
|
| 350 | + $html = "<label class='ee-a11y-screen-reader-text' for='{$id}' >{$label}</label>"; |
|
| 351 | + $html .= "<select name='tkt-slctr-qty-{$this->EVT_ID}[{$TKT}]' id='{$id}' class='{$class}'>"; |
|
| 352 | + // this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased |
|
| 353 | + if ($this->min !== 0 && ! $this->ticket->required()) { |
|
| 354 | + $html .= "<option value='0'> 0 </option>"; |
|
| 355 | + } |
|
| 356 | + // offer ticket quantities from the min to the max |
|
| 357 | + for ($i = $this->min; $i <= $this->max; $i++) { |
|
| 358 | + $html .= "<option value='{$i}'> {$i} </option>"; |
|
| 359 | + } |
|
| 360 | + $html .= "</select>"; |
|
| 361 | + return $html; |
|
| 362 | + } |
|
| 363 | + |
|
| 364 | + |
|
| 365 | + /** |
|
| 366 | + * getHiddenInputs |
|
| 367 | + * |
|
| 368 | + * @return string |
|
| 369 | + * @throws EE_Error |
|
| 370 | + */ |
|
| 371 | + protected function ticketQtyAndIdHiddenInputs() |
|
| 372 | + { |
|
| 373 | + $html = ''; |
|
| 374 | + $EVT = $this->EVT_ID; |
|
| 375 | + $TKT = $this->ticket->ID(); |
|
| 376 | + // depending on group reg we need to change the format for qty |
|
| 377 | + if ($this->hidden_input_qty) { |
|
| 378 | + $html .= "<input type='hidden' name='tkt-slctr-qty-{$EVT}[]' value='0' />"; |
|
| 379 | + } |
|
| 380 | + $html .= "<input type='hidden' name='tkt-slctr-ticket-id-{$EVT}[]' value='{$TKT}' />"; |
|
| 381 | + return $html; |
|
| 382 | + } |
|
| 383 | 383 | } |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | '', |
| 176 | 176 | 'tckt-slctr-tbl-td-qty cntr', |
| 177 | 177 | '', |
| 178 | - 'headers="quantity-' . $this->EVT_ID . '"' |
|
| 178 | + 'headers="quantity-'.$this->EVT_ID.'"' |
|
| 179 | 179 | ); |
| 180 | 180 | $this->setTicketStatusDisplay($remaining); |
| 181 | 181 | if (empty($this->ticket_status_display)) { |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | '', |
| 243 | 243 | 'tckt-slctr-tbl-td-name', |
| 244 | 244 | '', |
| 245 | - 'headers="details-' . $this->EVT_ID . '"' |
|
| 245 | + 'headers="details-'.$this->EVT_ID.'"' |
|
| 246 | 246 | ); |
| 247 | 247 | $html .= EEH_HTML::strong($this->ticket->get_pretty('TKT_name')); |
| 248 | 248 | $html .= $this->ticket_details->getShowHideLinks(); |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | '', |
| 277 | 277 | 'tckt-slctr-tbl-td-price jst-rght', |
| 278 | 278 | '', |
| 279 | - 'headers="price-' . $this->EVT_ID . '"' |
|
| 279 | + 'headers="price-'.$this->EVT_ID.'"' |
|
| 280 | 280 | ); |
| 281 | 281 | $html .= EEH_Template::format_currency($this->ticket_price); |
| 282 | 282 | $html .= $this->ticket->taxable() |
@@ -38,103 +38,103 @@ |
||
| 38 | 38 | * @since 4.0 |
| 39 | 39 | */ |
| 40 | 40 | if (function_exists('espresso_version')) { |
| 41 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
| 42 | - /** |
|
| 43 | - * espresso_duplicate_plugin_error |
|
| 44 | - * displays if more than one version of EE is activated at the same time |
|
| 45 | - */ |
|
| 46 | - function espresso_duplicate_plugin_error() |
|
| 47 | - { |
|
| 48 | - ?> |
|
| 41 | + if (! function_exists('espresso_duplicate_plugin_error')) { |
|
| 42 | + /** |
|
| 43 | + * espresso_duplicate_plugin_error |
|
| 44 | + * displays if more than one version of EE is activated at the same time |
|
| 45 | + */ |
|
| 46 | + function espresso_duplicate_plugin_error() |
|
| 47 | + { |
|
| 48 | + ?> |
|
| 49 | 49 | <div class="error"> |
| 50 | 50 | <p> |
| 51 | 51 | <?php |
| 52 | - echo esc_html__( |
|
| 53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
| 54 | - 'event_espresso' |
|
| 55 | - ); ?> |
|
| 52 | + echo esc_html__( |
|
| 53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
| 54 | + 'event_espresso' |
|
| 55 | + ); ?> |
|
| 56 | 56 | </p> |
| 57 | 57 | </div> |
| 58 | 58 | <?php |
| 59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 60 | - } |
|
| 61 | - } |
|
| 62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
| 59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
| 63 | 63 | } else { |
| 64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.6.2'); |
|
| 65 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
| 66 | - /** |
|
| 67 | - * espresso_minimum_php_version_error |
|
| 68 | - * |
|
| 69 | - * @return void |
|
| 70 | - */ |
|
| 71 | - function espresso_minimum_php_version_error() |
|
| 72 | - { |
|
| 73 | - ?> |
|
| 64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.6.2'); |
|
| 65 | + if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
| 66 | + /** |
|
| 67 | + * espresso_minimum_php_version_error |
|
| 68 | + * |
|
| 69 | + * @return void |
|
| 70 | + */ |
|
| 71 | + function espresso_minimum_php_version_error() |
|
| 72 | + { |
|
| 73 | + ?> |
|
| 74 | 74 | <div class="error"> |
| 75 | 75 | <p> |
| 76 | 76 | <?php |
| 77 | - printf( |
|
| 78 | - esc_html__( |
|
| 79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
| 80 | - 'event_espresso' |
|
| 81 | - ), |
|
| 82 | - EE_MIN_PHP_VER_REQUIRED, |
|
| 83 | - PHP_VERSION, |
|
| 84 | - '<br/>', |
|
| 85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
| 86 | - ); |
|
| 87 | - ?> |
|
| 77 | + printf( |
|
| 78 | + esc_html__( |
|
| 79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
| 80 | + 'event_espresso' |
|
| 81 | + ), |
|
| 82 | + EE_MIN_PHP_VER_REQUIRED, |
|
| 83 | + PHP_VERSION, |
|
| 84 | + '<br/>', |
|
| 85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
| 86 | + ); |
|
| 87 | + ?> |
|
| 88 | 88 | </p> |
| 89 | 89 | </div> |
| 90 | 90 | <?php |
| 91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 92 | - } |
|
| 91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
| 95 | - } else { |
|
| 96 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
| 97 | - /** |
|
| 98 | - * espresso_version |
|
| 99 | - * Returns the plugin version |
|
| 100 | - * |
|
| 101 | - * @return string |
|
| 102 | - */ |
|
| 103 | - function espresso_version() |
|
| 104 | - { |
|
| 105 | - return apply_filters('FHEE__espresso__espresso_version', '4.10.24.rc.004'); |
|
| 106 | - } |
|
| 94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
| 95 | + } else { |
|
| 96 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
| 97 | + /** |
|
| 98 | + * espresso_version |
|
| 99 | + * Returns the plugin version |
|
| 100 | + * |
|
| 101 | + * @return string |
|
| 102 | + */ |
|
| 103 | + function espresso_version() |
|
| 104 | + { |
|
| 105 | + return apply_filters('FHEE__espresso__espresso_version', '4.10.24.rc.004'); |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - /** |
|
| 109 | - * espresso_plugin_activation |
|
| 110 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
| 111 | - */ |
|
| 112 | - function espresso_plugin_activation() |
|
| 113 | - { |
|
| 114 | - update_option('ee_espresso_activation', true); |
|
| 115 | - } |
|
| 108 | + /** |
|
| 109 | + * espresso_plugin_activation |
|
| 110 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
| 111 | + */ |
|
| 112 | + function espresso_plugin_activation() |
|
| 113 | + { |
|
| 114 | + update_option('ee_espresso_activation', true); |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
| 117 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
| 118 | 118 | |
| 119 | - require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
| 120 | - bootstrap_espresso(); |
|
| 121 | - } |
|
| 119 | + require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
| 120 | + bootstrap_espresso(); |
|
| 121 | + } |
|
| 122 | 122 | } |
| 123 | 123 | if (! function_exists('espresso_deactivate_plugin')) { |
| 124 | - /** |
|
| 125 | - * deactivate_plugin |
|
| 126 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
| 127 | - * |
|
| 128 | - * @access public |
|
| 129 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
| 130 | - * @return void |
|
| 131 | - */ |
|
| 132 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
| 133 | - { |
|
| 134 | - if (! function_exists('deactivate_plugins')) { |
|
| 135 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
| 136 | - } |
|
| 137 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
| 138 | - deactivate_plugins($plugin_basename); |
|
| 139 | - } |
|
| 124 | + /** |
|
| 125 | + * deactivate_plugin |
|
| 126 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
| 127 | + * |
|
| 128 | + * @access public |
|
| 129 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
| 130 | + * @return void |
|
| 131 | + */ |
|
| 132 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
| 133 | + { |
|
| 134 | + if (! function_exists('deactivate_plugins')) { |
|
| 135 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
| 136 | + } |
|
| 137 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
| 138 | + deactivate_plugins($plugin_basename); |
|
| 139 | + } |
|
| 140 | 140 | } |