@@ -4,49 +4,49 @@ |
||
| 4 | 4 | |
| 5 | 5 | class RequestSanitizer |
| 6 | 6 | { |
| 7 | - /** |
|
| 8 | - * Will sanitize the supplied request parameter based on the specified data type |
|
| 9 | - * |
|
| 10 | - * @param mixed $param the supplied request parameter |
|
| 11 | - * @param string $type the specified data type (default: "string") |
|
| 12 | - * valid values: "bool", "float", "int", "key", "url", or "string" |
|
| 13 | - * @param bool $is_array if true, then $param will be treated as an array of $type |
|
| 14 | - * @param string $delimiter if $param is a CSV like value (ex: 1,2,3,4,5...) then this is the value separator |
|
| 15 | - * @return array|bool|float|int|string |
|
| 16 | - * @since 4.10.14.p |
|
| 17 | - */ |
|
| 18 | - public function clean($param, $type = 'string', $is_array = false, $delimiter = '') |
|
| 19 | - { |
|
| 20 | - if ($delimiter !== '' && is_string($param)) { |
|
| 21 | - $param = explode($delimiter, $param); |
|
| 22 | - // unset the delimiter else this function will recurse forever when we loop over the array of results |
|
| 23 | - $delimiter = ''; |
|
| 24 | - } |
|
| 25 | - // check if we are getting an improperly typed array and correct |
|
| 26 | - $is_array = $is_array || is_array($param); |
|
| 27 | - if ($is_array) { |
|
| 28 | - $values = []; |
|
| 29 | - foreach ((array) $param as $key => $value) { |
|
| 30 | - $values[ $key ] = $this->clean($value, $type, is_array($value), $delimiter); |
|
| 31 | - } |
|
| 32 | - return $values; |
|
| 33 | - } |
|
| 34 | - switch ($type) { |
|
| 35 | - case 'bool': |
|
| 36 | - return filter_var($param, FILTER_VALIDATE_BOOLEAN); |
|
| 37 | - case 'float': |
|
| 38 | - return (float) $param; |
|
| 39 | - case 'fqcn': |
|
| 40 | - return preg_replace('[^\\\w\d]', '', $param); |
|
| 41 | - case 'int': |
|
| 42 | - return (int) $param; |
|
| 43 | - case 'key': |
|
| 44 | - return sanitize_key($param); |
|
| 45 | - case 'url': |
|
| 46 | - return esc_url_raw($param); |
|
| 47 | - case 'string': |
|
| 48 | - default: |
|
| 49 | - return sanitize_text_field($param); |
|
| 50 | - } |
|
| 51 | - } |
|
| 7 | + /** |
|
| 8 | + * Will sanitize the supplied request parameter based on the specified data type |
|
| 9 | + * |
|
| 10 | + * @param mixed $param the supplied request parameter |
|
| 11 | + * @param string $type the specified data type (default: "string") |
|
| 12 | + * valid values: "bool", "float", "int", "key", "url", or "string" |
|
| 13 | + * @param bool $is_array if true, then $param will be treated as an array of $type |
|
| 14 | + * @param string $delimiter if $param is a CSV like value (ex: 1,2,3,4,5...) then this is the value separator |
|
| 15 | + * @return array|bool|float|int|string |
|
| 16 | + * @since 4.10.14.p |
|
| 17 | + */ |
|
| 18 | + public function clean($param, $type = 'string', $is_array = false, $delimiter = '') |
|
| 19 | + { |
|
| 20 | + if ($delimiter !== '' && is_string($param)) { |
|
| 21 | + $param = explode($delimiter, $param); |
|
| 22 | + // unset the delimiter else this function will recurse forever when we loop over the array of results |
|
| 23 | + $delimiter = ''; |
|
| 24 | + } |
|
| 25 | + // check if we are getting an improperly typed array and correct |
|
| 26 | + $is_array = $is_array || is_array($param); |
|
| 27 | + if ($is_array) { |
|
| 28 | + $values = []; |
|
| 29 | + foreach ((array) $param as $key => $value) { |
|
| 30 | + $values[ $key ] = $this->clean($value, $type, is_array($value), $delimiter); |
|
| 31 | + } |
|
| 32 | + return $values; |
|
| 33 | + } |
|
| 34 | + switch ($type) { |
|
| 35 | + case 'bool': |
|
| 36 | + return filter_var($param, FILTER_VALIDATE_BOOLEAN); |
|
| 37 | + case 'float': |
|
| 38 | + return (float) $param; |
|
| 39 | + case 'fqcn': |
|
| 40 | + return preg_replace('[^\\\w\d]', '', $param); |
|
| 41 | + case 'int': |
|
| 42 | + return (int) $param; |
|
| 43 | + case 'key': |
|
| 44 | + return sanitize_key($param); |
|
| 45 | + case 'url': |
|
| 46 | + return esc_url_raw($param); |
|
| 47 | + case 'string': |
|
| 48 | + default: |
|
| 49 | + return sanitize_text_field($param); |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | 52 | } |
@@ -33,524 +33,524 @@ |
||
| 33 | 33 | class ProcessTicketSelector |
| 34 | 34 | { |
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * @var EE_Cart $cart |
|
| 38 | - */ |
|
| 39 | - private $cart; |
|
| 36 | + /** |
|
| 37 | + * @var EE_Cart $cart |
|
| 38 | + */ |
|
| 39 | + private $cart; |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * @var EE_Core_Config $core_config |
|
| 43 | - */ |
|
| 44 | - private $core_config; |
|
| 41 | + /** |
|
| 42 | + * @var EE_Core_Config $core_config |
|
| 43 | + */ |
|
| 44 | + private $core_config; |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * @var RequestInterface $request |
|
| 48 | - */ |
|
| 49 | - private $request; |
|
| 46 | + /** |
|
| 47 | + * @var RequestInterface $request |
|
| 48 | + */ |
|
| 49 | + private $request; |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @var EE_Session $session |
|
| 53 | - */ |
|
| 54 | - private $session; |
|
| 51 | + /** |
|
| 52 | + * @var EE_Session $session |
|
| 53 | + */ |
|
| 54 | + private $session; |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * @var EEM_Ticket $ticket_model |
|
| 58 | - */ |
|
| 59 | - private $ticket_model; |
|
| 56 | + /** |
|
| 57 | + * @var EEM_Ticket $ticket_model |
|
| 58 | + */ |
|
| 59 | + private $ticket_model; |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * @var TicketDatetimeAvailabilityTracker $tracker |
|
| 63 | - */ |
|
| 64 | - private $tracker; |
|
| 61 | + /** |
|
| 62 | + * @var TicketDatetimeAvailabilityTracker $tracker |
|
| 63 | + */ |
|
| 64 | + private $tracker; |
|
| 65 | 65 | |
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * ProcessTicketSelector constructor. |
|
| 69 | - * NOTE: PLZ use the Loader to instantiate this class if need be |
|
| 70 | - * so that all dependencies get injected correctly (which will happen automatically) |
|
| 71 | - * Null values for parameters are only for backwards compatibility but will be removed later on. |
|
| 72 | - * |
|
| 73 | - * @param EE_Core_Config $core_config |
|
| 74 | - * @param RequestInterface $request |
|
| 75 | - * @param EE_Session $session |
|
| 76 | - * @param EEM_Ticket $ticket_model |
|
| 77 | - * @param TicketDatetimeAvailabilityTracker $tracker |
|
| 78 | - * @throws InvalidArgumentException |
|
| 79 | - * @throws InvalidDataTypeException |
|
| 80 | - * @throws InvalidInterfaceException |
|
| 81 | - */ |
|
| 82 | - public function __construct( |
|
| 83 | - EE_Core_Config $core_config = null, |
|
| 84 | - RequestInterface $request = null, |
|
| 85 | - EE_Session $session = null, |
|
| 86 | - EEM_Ticket $ticket_model = null, |
|
| 87 | - TicketDatetimeAvailabilityTracker $tracker = null |
|
| 88 | - ) { |
|
| 89 | - $loader = LoaderFactory::getLoader(); |
|
| 90 | - $this->core_config = $core_config instanceof EE_Core_Config |
|
| 91 | - ? $core_config |
|
| 92 | - : $loader->getShared('EE_Core_Config'); |
|
| 93 | - $this->request = $request instanceof RequestInterface |
|
| 94 | - ? $request |
|
| 95 | - : $loader->getShared('EventEspresso\core\services\request\Request'); |
|
| 96 | - $this->session = $session instanceof EE_Session |
|
| 97 | - ? $session |
|
| 98 | - : $loader->getShared('EE_Session'); |
|
| 99 | - $this->ticket_model = $ticket_model instanceof EEM_Ticket |
|
| 100 | - ? $ticket_model |
|
| 101 | - : $loader->getShared('EEM_Ticket'); |
|
| 102 | - $this->tracker = $tracker instanceof TicketDatetimeAvailabilityTracker |
|
| 103 | - ? $tracker |
|
| 104 | - : $loader->getShared('EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker'); |
|
| 105 | - } |
|
| 67 | + /** |
|
| 68 | + * ProcessTicketSelector constructor. |
|
| 69 | + * NOTE: PLZ use the Loader to instantiate this class if need be |
|
| 70 | + * so that all dependencies get injected correctly (which will happen automatically) |
|
| 71 | + * Null values for parameters are only for backwards compatibility but will be removed later on. |
|
| 72 | + * |
|
| 73 | + * @param EE_Core_Config $core_config |
|
| 74 | + * @param RequestInterface $request |
|
| 75 | + * @param EE_Session $session |
|
| 76 | + * @param EEM_Ticket $ticket_model |
|
| 77 | + * @param TicketDatetimeAvailabilityTracker $tracker |
|
| 78 | + * @throws InvalidArgumentException |
|
| 79 | + * @throws InvalidDataTypeException |
|
| 80 | + * @throws InvalidInterfaceException |
|
| 81 | + */ |
|
| 82 | + public function __construct( |
|
| 83 | + EE_Core_Config $core_config = null, |
|
| 84 | + RequestInterface $request = null, |
|
| 85 | + EE_Session $session = null, |
|
| 86 | + EEM_Ticket $ticket_model = null, |
|
| 87 | + TicketDatetimeAvailabilityTracker $tracker = null |
|
| 88 | + ) { |
|
| 89 | + $loader = LoaderFactory::getLoader(); |
|
| 90 | + $this->core_config = $core_config instanceof EE_Core_Config |
|
| 91 | + ? $core_config |
|
| 92 | + : $loader->getShared('EE_Core_Config'); |
|
| 93 | + $this->request = $request instanceof RequestInterface |
|
| 94 | + ? $request |
|
| 95 | + : $loader->getShared('EventEspresso\core\services\request\Request'); |
|
| 96 | + $this->session = $session instanceof EE_Session |
|
| 97 | + ? $session |
|
| 98 | + : $loader->getShared('EE_Session'); |
|
| 99 | + $this->ticket_model = $ticket_model instanceof EEM_Ticket |
|
| 100 | + ? $ticket_model |
|
| 101 | + : $loader->getShared('EEM_Ticket'); |
|
| 102 | + $this->tracker = $tracker instanceof TicketDatetimeAvailabilityTracker |
|
| 103 | + ? $tracker |
|
| 104 | + : $loader->getShared('EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker'); |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | 107 | |
| 108 | - /** |
|
| 109 | - * cancelTicketSelections |
|
| 110 | - * |
|
| 111 | - * @return bool |
|
| 112 | - * @throws EE_Error |
|
| 113 | - * @throws InvalidArgumentException |
|
| 114 | - * @throws InvalidInterfaceException |
|
| 115 | - * @throws InvalidDataTypeException |
|
| 116 | - * @throws ReflectionException |
|
| 117 | - */ |
|
| 118 | - public function cancelTicketSelections() |
|
| 119 | - { |
|
| 120 | - // check nonce |
|
| 121 | - if (! $this->processTicketSelectorNonce('cancel_ticket_selections')) { |
|
| 122 | - return false; |
|
| 123 | - } |
|
| 124 | - $this->session->clear_session(__CLASS__, __FUNCTION__); |
|
| 125 | - if ($this->request->requestParamIsSet('event_id')) { |
|
| 126 | - EEH_URL::safeRedirectAndExit( |
|
| 127 | - EEH_Event_View::event_link_url( |
|
| 128 | - $this->request->getRequestParam('event_id', 0, 'int') |
|
| 129 | - ) |
|
| 130 | - ); |
|
| 131 | - } |
|
| 132 | - EEH_URL::safeRedirectAndExit( |
|
| 133 | - site_url('/' . $this->core_config->event_cpt_slug . '/') |
|
| 134 | - ); |
|
| 135 | - return true; |
|
| 136 | - } |
|
| 108 | + /** |
|
| 109 | + * cancelTicketSelections |
|
| 110 | + * |
|
| 111 | + * @return bool |
|
| 112 | + * @throws EE_Error |
|
| 113 | + * @throws InvalidArgumentException |
|
| 114 | + * @throws InvalidInterfaceException |
|
| 115 | + * @throws InvalidDataTypeException |
|
| 116 | + * @throws ReflectionException |
|
| 117 | + */ |
|
| 118 | + public function cancelTicketSelections() |
|
| 119 | + { |
|
| 120 | + // check nonce |
|
| 121 | + if (! $this->processTicketSelectorNonce('cancel_ticket_selections')) { |
|
| 122 | + return false; |
|
| 123 | + } |
|
| 124 | + $this->session->clear_session(__CLASS__, __FUNCTION__); |
|
| 125 | + if ($this->request->requestParamIsSet('event_id')) { |
|
| 126 | + EEH_URL::safeRedirectAndExit( |
|
| 127 | + EEH_Event_View::event_link_url( |
|
| 128 | + $this->request->getRequestParam('event_id', 0, 'int') |
|
| 129 | + ) |
|
| 130 | + ); |
|
| 131 | + } |
|
| 132 | + EEH_URL::safeRedirectAndExit( |
|
| 133 | + site_url('/' . $this->core_config->event_cpt_slug . '/') |
|
| 134 | + ); |
|
| 135 | + return true; |
|
| 136 | + } |
|
| 137 | 137 | |
| 138 | 138 | |
| 139 | - /** |
|
| 140 | - * processTicketSelectorNonce |
|
| 141 | - * |
|
| 142 | - * @param string $nonce_name |
|
| 143 | - * @param string $id |
|
| 144 | - * @return bool |
|
| 145 | - */ |
|
| 146 | - private function processTicketSelectorNonce($nonce_name, $id = '') |
|
| 147 | - { |
|
| 148 | - $nonce_name_with_id = ! empty($id) ? "{$nonce_name}_nonce_{$id}" : "{$nonce_name}_nonce"; |
|
| 149 | - if ( |
|
| 150 | - ! $this->request->isAdmin() |
|
| 151 | - && ( |
|
| 152 | - ! $this->request->requestParamIsSet($nonce_name_with_id) |
|
| 153 | - || ! wp_verify_nonce( |
|
| 154 | - $this->request->getRequestParam($nonce_name_with_id), |
|
| 155 | - $nonce_name |
|
| 156 | - ) |
|
| 157 | - ) |
|
| 158 | - ) { |
|
| 159 | - EE_Error::add_error( |
|
| 160 | - sprintf( |
|
| 161 | - esc_html__( |
|
| 162 | - 'We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.', |
|
| 163 | - 'event_espresso' |
|
| 164 | - ), |
|
| 165 | - '<br/>' |
|
| 166 | - ), |
|
| 167 | - __FILE__, |
|
| 168 | - __FUNCTION__, |
|
| 169 | - __LINE__ |
|
| 170 | - ); |
|
| 171 | - return false; |
|
| 172 | - } |
|
| 173 | - return true; |
|
| 174 | - } |
|
| 139 | + /** |
|
| 140 | + * processTicketSelectorNonce |
|
| 141 | + * |
|
| 142 | + * @param string $nonce_name |
|
| 143 | + * @param string $id |
|
| 144 | + * @return bool |
|
| 145 | + */ |
|
| 146 | + private function processTicketSelectorNonce($nonce_name, $id = '') |
|
| 147 | + { |
|
| 148 | + $nonce_name_with_id = ! empty($id) ? "{$nonce_name}_nonce_{$id}" : "{$nonce_name}_nonce"; |
|
| 149 | + if ( |
|
| 150 | + ! $this->request->isAdmin() |
|
| 151 | + && ( |
|
| 152 | + ! $this->request->requestParamIsSet($nonce_name_with_id) |
|
| 153 | + || ! wp_verify_nonce( |
|
| 154 | + $this->request->getRequestParam($nonce_name_with_id), |
|
| 155 | + $nonce_name |
|
| 156 | + ) |
|
| 157 | + ) |
|
| 158 | + ) { |
|
| 159 | + EE_Error::add_error( |
|
| 160 | + sprintf( |
|
| 161 | + esc_html__( |
|
| 162 | + 'We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.', |
|
| 163 | + 'event_espresso' |
|
| 164 | + ), |
|
| 165 | + '<br/>' |
|
| 166 | + ), |
|
| 167 | + __FILE__, |
|
| 168 | + __FUNCTION__, |
|
| 169 | + __LINE__ |
|
| 170 | + ); |
|
| 171 | + return false; |
|
| 172 | + } |
|
| 173 | + return true; |
|
| 174 | + } |
|
| 175 | 175 | |
| 176 | 176 | |
| 177 | - /** |
|
| 178 | - * process_ticket_selections |
|
| 179 | - * |
|
| 180 | - * @return bool |
|
| 181 | - * @throws EE_Error |
|
| 182 | - * @throws InvalidArgumentException |
|
| 183 | - * @throws InvalidDataTypeException |
|
| 184 | - * @throws InvalidInterfaceException |
|
| 185 | - * @throws ReflectionException |
|
| 186 | - */ |
|
| 187 | - public function processTicketSelections() |
|
| 188 | - { |
|
| 189 | - do_action('EED_Ticket_Selector__process_ticket_selections__before'); |
|
| 190 | - if ($this->request->isBot()) { |
|
| 191 | - EEH_URL::safeRedirectAndExit( |
|
| 192 | - apply_filters( |
|
| 193 | - 'FHEE__EE_Ticket_Selector__process_ticket_selections__bot_redirect_url', |
|
| 194 | - site_url() |
|
| 195 | - ) |
|
| 196 | - ); |
|
| 197 | - } |
|
| 198 | - // do we have an event id? |
|
| 199 | - $id = $this->getEventId(); |
|
| 200 | - // we should really only have 1 registration in the works now |
|
| 201 | - // (ie, no MER) so unless otherwise requested, clear the session |
|
| 202 | - if (apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', true)) { |
|
| 203 | - $this->session->clear_session(__CLASS__, __FUNCTION__); |
|
| 204 | - } |
|
| 205 | - // validate/sanitize/filter data |
|
| 206 | - $valid = apply_filters( |
|
| 207 | - 'FHEE__EED_Ticket_Selector__process_ticket_selections__valid_post_data', |
|
| 208 | - $this->validatePostData($id) |
|
| 209 | - ); |
|
| 210 | - // check total tickets ordered vs max number of attendees that can register |
|
| 211 | - if (! empty($valid) && $valid['total_tickets'] > $valid['max_atndz']) { |
|
| 212 | - $this->maxAttendeesViolation($valid); |
|
| 213 | - } else { |
|
| 214 | - // all data appears to be valid |
|
| 215 | - if ($this->processSuccessfulCart($this->addTicketsToCart($valid))) { |
|
| 216 | - return true; |
|
| 217 | - } |
|
| 218 | - } |
|
| 219 | - // die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL BEFORE REDIRECT |
|
| 220 | - // at this point, just return if registration is being made from admin |
|
| 221 | - if ($this->request->isAdmin() || $this->request->isFrontAjax()) { |
|
| 222 | - return false; |
|
| 223 | - } |
|
| 224 | - if ($valid['return_url']) { |
|
| 225 | - EEH_URL::safeRedirectAndExit($valid['return_url']); |
|
| 226 | - } |
|
| 227 | - if ($id) { |
|
| 228 | - EEH_URL::safeRedirectAndExit(get_permalink($id)); |
|
| 229 | - } |
|
| 230 | - echo EE_Error::get_notices(); // already escaped |
|
| 231 | - return false; |
|
| 232 | - } |
|
| 177 | + /** |
|
| 178 | + * process_ticket_selections |
|
| 179 | + * |
|
| 180 | + * @return bool |
|
| 181 | + * @throws EE_Error |
|
| 182 | + * @throws InvalidArgumentException |
|
| 183 | + * @throws InvalidDataTypeException |
|
| 184 | + * @throws InvalidInterfaceException |
|
| 185 | + * @throws ReflectionException |
|
| 186 | + */ |
|
| 187 | + public function processTicketSelections() |
|
| 188 | + { |
|
| 189 | + do_action('EED_Ticket_Selector__process_ticket_selections__before'); |
|
| 190 | + if ($this->request->isBot()) { |
|
| 191 | + EEH_URL::safeRedirectAndExit( |
|
| 192 | + apply_filters( |
|
| 193 | + 'FHEE__EE_Ticket_Selector__process_ticket_selections__bot_redirect_url', |
|
| 194 | + site_url() |
|
| 195 | + ) |
|
| 196 | + ); |
|
| 197 | + } |
|
| 198 | + // do we have an event id? |
|
| 199 | + $id = $this->getEventId(); |
|
| 200 | + // we should really only have 1 registration in the works now |
|
| 201 | + // (ie, no MER) so unless otherwise requested, clear the session |
|
| 202 | + if (apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', true)) { |
|
| 203 | + $this->session->clear_session(__CLASS__, __FUNCTION__); |
|
| 204 | + } |
|
| 205 | + // validate/sanitize/filter data |
|
| 206 | + $valid = apply_filters( |
|
| 207 | + 'FHEE__EED_Ticket_Selector__process_ticket_selections__valid_post_data', |
|
| 208 | + $this->validatePostData($id) |
|
| 209 | + ); |
|
| 210 | + // check total tickets ordered vs max number of attendees that can register |
|
| 211 | + if (! empty($valid) && $valid['total_tickets'] > $valid['max_atndz']) { |
|
| 212 | + $this->maxAttendeesViolation($valid); |
|
| 213 | + } else { |
|
| 214 | + // all data appears to be valid |
|
| 215 | + if ($this->processSuccessfulCart($this->addTicketsToCart($valid))) { |
|
| 216 | + return true; |
|
| 217 | + } |
|
| 218 | + } |
|
| 219 | + // die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL BEFORE REDIRECT |
|
| 220 | + // at this point, just return if registration is being made from admin |
|
| 221 | + if ($this->request->isAdmin() || $this->request->isFrontAjax()) { |
|
| 222 | + return false; |
|
| 223 | + } |
|
| 224 | + if ($valid['return_url']) { |
|
| 225 | + EEH_URL::safeRedirectAndExit($valid['return_url']); |
|
| 226 | + } |
|
| 227 | + if ($id) { |
|
| 228 | + EEH_URL::safeRedirectAndExit(get_permalink($id)); |
|
| 229 | + } |
|
| 230 | + echo EE_Error::get_notices(); // already escaped |
|
| 231 | + return false; |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | 234 | |
| 235 | - /** |
|
| 236 | - * @return int |
|
| 237 | - */ |
|
| 238 | - private function getEventId() |
|
| 239 | - { |
|
| 240 | - // do we have an event id? |
|
| 241 | - if (! $this->request->requestParamIsSet('tkt-slctr-event-id')) { |
|
| 242 | - // $_POST['tkt-slctr-event-id'] was not set ?!?!?!? |
|
| 243 | - EE_Error::add_error( |
|
| 244 | - sprintf( |
|
| 245 | - esc_html__( |
|
| 246 | - 'An event id was not provided or was not received.%sPlease click the back button on your browser and try again.', |
|
| 247 | - 'event_espresso' |
|
| 248 | - ), |
|
| 249 | - '<br/>' |
|
| 250 | - ), |
|
| 251 | - __FILE__, |
|
| 252 | - __FUNCTION__, |
|
| 253 | - __LINE__ |
|
| 254 | - ); |
|
| 255 | - } |
|
| 256 | - // if event id is valid |
|
| 257 | - return $this->request->getRequestParam('tkt-slctr-event-id', 0, 'int'); |
|
| 258 | - } |
|
| 235 | + /** |
|
| 236 | + * @return int |
|
| 237 | + */ |
|
| 238 | + private function getEventId() |
|
| 239 | + { |
|
| 240 | + // do we have an event id? |
|
| 241 | + if (! $this->request->requestParamIsSet('tkt-slctr-event-id')) { |
|
| 242 | + // $_POST['tkt-slctr-event-id'] was not set ?!?!?!? |
|
| 243 | + EE_Error::add_error( |
|
| 244 | + sprintf( |
|
| 245 | + esc_html__( |
|
| 246 | + 'An event id was not provided or was not received.%sPlease click the back button on your browser and try again.', |
|
| 247 | + 'event_espresso' |
|
| 248 | + ), |
|
| 249 | + '<br/>' |
|
| 250 | + ), |
|
| 251 | + __FILE__, |
|
| 252 | + __FUNCTION__, |
|
| 253 | + __LINE__ |
|
| 254 | + ); |
|
| 255 | + } |
|
| 256 | + // if event id is valid |
|
| 257 | + return $this->request->getRequestParam('tkt-slctr-event-id', 0, 'int'); |
|
| 258 | + } |
|
| 259 | 259 | |
| 260 | 260 | |
| 261 | - /** |
|
| 262 | - * validate_post_data |
|
| 263 | - * |
|
| 264 | - * @param int $id |
|
| 265 | - * @return array |
|
| 266 | - */ |
|
| 267 | - private function validatePostData($id = 0) |
|
| 268 | - { |
|
| 269 | - if (! $id) { |
|
| 270 | - EE_Error::add_error( |
|
| 271 | - esc_html__('The event id provided was not valid.', 'event_espresso'), |
|
| 272 | - __FILE__, |
|
| 273 | - __FUNCTION__, |
|
| 274 | - __LINE__ |
|
| 275 | - ); |
|
| 276 | - return array(); |
|
| 277 | - } |
|
| 278 | - // start with an empty array() |
|
| 279 | - $valid_data = array(); |
|
| 280 | - // grab valid id |
|
| 281 | - $valid_data['id'] = $id; |
|
| 282 | - // array of other form names |
|
| 283 | - $inputs_to_clean = array( |
|
| 284 | - 'max_atndz' => 'tkt-slctr-max-atndz-', |
|
| 285 | - 'rows' => 'tkt-slctr-rows-', |
|
| 286 | - 'qty' => 'tkt-slctr-qty-', |
|
| 287 | - 'ticket_id' => 'tkt-slctr-ticket-id-', |
|
| 288 | - 'return_url' => 'tkt-slctr-return-url-', |
|
| 289 | - ); |
|
| 290 | - // let's track the total number of tickets ordered.' |
|
| 291 | - $valid_data['total_tickets'] = 0; |
|
| 292 | - // cycle through $inputs_to_clean array |
|
| 293 | - foreach ($inputs_to_clean as $what => $input_to_clean) { |
|
| 294 | - $input_key = "{$input_to_clean}{$id}"; |
|
| 295 | - // check for POST data |
|
| 296 | - if ($this->request->requestParamIsSet($input_key)) { |
|
| 297 | - switch ($what) { |
|
| 298 | - // integers |
|
| 299 | - case 'event_id': |
|
| 300 | - case 'rows': |
|
| 301 | - case 'max_atndz': |
|
| 302 | - $valid_data[ $what ] = $this->request->getRequestParam($input_key, 0, 'int'); |
|
| 303 | - break; |
|
| 304 | - // arrays of integers |
|
| 305 | - case 'qty': |
|
| 306 | - $max_atndz = $valid_data['max_atndz'] ?? $this->request->getRequestParam($input_key, 0, 'int'); |
|
| 307 | - $raw_qty = $this->request->getRequestParam($input_key); |
|
| 308 | - // explode integers by the dash if qty is a string |
|
| 309 | - $delimiter = is_string($raw_qty) && strpos($raw_qty, '-') ? '-' : ''; |
|
| 310 | - /** @var array $row_qty */ |
|
| 311 | - $row_qty = $this->request->getRequestParam($input_key, [], 'int', true, $delimiter); |
|
| 312 | - // if qty is coming from a radio button input, then we need to assemble an array of rows |
|
| 313 | - if ($delimiter === '-') { |
|
| 314 | - // get number of rows |
|
| 315 | - $rows = $this->request->getRequestParam('tkt-slctr-rows-' . $id, 1, 'int'); |
|
| 316 | - $row = isset($row_qty[0]) ? absint($row_qty[0]) : 1; |
|
| 317 | - $qty = isset($row_qty[1]) ? absint($row_qty[1]) : 0; |
|
| 318 | - // restructure the row qty array so that $row is now the key instead of the first value |
|
| 319 | - $row_qty = array($row => $qty); |
|
| 320 | - for ($x = 1; $x <= $rows; $x++) { |
|
| 321 | - if (! isset($row_qty[ $x ])) { |
|
| 322 | - $row_qty[ $x ] = 0; |
|
| 323 | - } |
|
| 324 | - } |
|
| 325 | - } |
|
| 326 | - ksort($row_qty); |
|
| 327 | - // cycle thru values |
|
| 328 | - foreach ($row_qty as $qty) { |
|
| 329 | - $qty = absint($qty); |
|
| 330 | - // sanitize as integers |
|
| 331 | - $valid_data[ $what ][] = $qty; |
|
| 332 | - $valid_data['total_tickets'] += $qty; |
|
| 333 | - } |
|
| 334 | - break; |
|
| 335 | - // array of integers |
|
| 336 | - case 'ticket_id': |
|
| 337 | - $ticket_ids = (array) $this->request->getRequestParam($input_key, [], 'int', true); |
|
| 338 | - // cycle thru values |
|
| 339 | - foreach ($ticket_ids as $key => $value) { |
|
| 340 | - // allow only integers |
|
| 341 | - $valid_data[ $what ][ $key ] = absint($value); |
|
| 342 | - } |
|
| 343 | - break; |
|
| 344 | - case 'return_url': |
|
| 345 | - // grab and sanitize return-url |
|
| 346 | - $input_value = $this->request->getRequestParam($input_key, '', 'url'); |
|
| 347 | - // was the request coming from an iframe ? if so, then: |
|
| 348 | - if (strpos($input_value, 'event_list=iframe')) { |
|
| 349 | - // get anchor fragment |
|
| 350 | - $input_value = explode('#', $input_value); |
|
| 351 | - $input_value = end($input_value); |
|
| 352 | - // use event list url instead, but append anchor |
|
| 353 | - $input_value = EEH_Event_View::event_archive_url() . '#' . $input_value; |
|
| 354 | - } |
|
| 355 | - $valid_data[ $what ] = $input_value; |
|
| 356 | - break; |
|
| 357 | - } // end switch $what |
|
| 358 | - } |
|
| 359 | - } // end foreach $inputs_to_clean |
|
| 360 | - return $valid_data; |
|
| 361 | - } |
|
| 261 | + /** |
|
| 262 | + * validate_post_data |
|
| 263 | + * |
|
| 264 | + * @param int $id |
|
| 265 | + * @return array |
|
| 266 | + */ |
|
| 267 | + private function validatePostData($id = 0) |
|
| 268 | + { |
|
| 269 | + if (! $id) { |
|
| 270 | + EE_Error::add_error( |
|
| 271 | + esc_html__('The event id provided was not valid.', 'event_espresso'), |
|
| 272 | + __FILE__, |
|
| 273 | + __FUNCTION__, |
|
| 274 | + __LINE__ |
|
| 275 | + ); |
|
| 276 | + return array(); |
|
| 277 | + } |
|
| 278 | + // start with an empty array() |
|
| 279 | + $valid_data = array(); |
|
| 280 | + // grab valid id |
|
| 281 | + $valid_data['id'] = $id; |
|
| 282 | + // array of other form names |
|
| 283 | + $inputs_to_clean = array( |
|
| 284 | + 'max_atndz' => 'tkt-slctr-max-atndz-', |
|
| 285 | + 'rows' => 'tkt-slctr-rows-', |
|
| 286 | + 'qty' => 'tkt-slctr-qty-', |
|
| 287 | + 'ticket_id' => 'tkt-slctr-ticket-id-', |
|
| 288 | + 'return_url' => 'tkt-slctr-return-url-', |
|
| 289 | + ); |
|
| 290 | + // let's track the total number of tickets ordered.' |
|
| 291 | + $valid_data['total_tickets'] = 0; |
|
| 292 | + // cycle through $inputs_to_clean array |
|
| 293 | + foreach ($inputs_to_clean as $what => $input_to_clean) { |
|
| 294 | + $input_key = "{$input_to_clean}{$id}"; |
|
| 295 | + // check for POST data |
|
| 296 | + if ($this->request->requestParamIsSet($input_key)) { |
|
| 297 | + switch ($what) { |
|
| 298 | + // integers |
|
| 299 | + case 'event_id': |
|
| 300 | + case 'rows': |
|
| 301 | + case 'max_atndz': |
|
| 302 | + $valid_data[ $what ] = $this->request->getRequestParam($input_key, 0, 'int'); |
|
| 303 | + break; |
|
| 304 | + // arrays of integers |
|
| 305 | + case 'qty': |
|
| 306 | + $max_atndz = $valid_data['max_atndz'] ?? $this->request->getRequestParam($input_key, 0, 'int'); |
|
| 307 | + $raw_qty = $this->request->getRequestParam($input_key); |
|
| 308 | + // explode integers by the dash if qty is a string |
|
| 309 | + $delimiter = is_string($raw_qty) && strpos($raw_qty, '-') ? '-' : ''; |
|
| 310 | + /** @var array $row_qty */ |
|
| 311 | + $row_qty = $this->request->getRequestParam($input_key, [], 'int', true, $delimiter); |
|
| 312 | + // if qty is coming from a radio button input, then we need to assemble an array of rows |
|
| 313 | + if ($delimiter === '-') { |
|
| 314 | + // get number of rows |
|
| 315 | + $rows = $this->request->getRequestParam('tkt-slctr-rows-' . $id, 1, 'int'); |
|
| 316 | + $row = isset($row_qty[0]) ? absint($row_qty[0]) : 1; |
|
| 317 | + $qty = isset($row_qty[1]) ? absint($row_qty[1]) : 0; |
|
| 318 | + // restructure the row qty array so that $row is now the key instead of the first value |
|
| 319 | + $row_qty = array($row => $qty); |
|
| 320 | + for ($x = 1; $x <= $rows; $x++) { |
|
| 321 | + if (! isset($row_qty[ $x ])) { |
|
| 322 | + $row_qty[ $x ] = 0; |
|
| 323 | + } |
|
| 324 | + } |
|
| 325 | + } |
|
| 326 | + ksort($row_qty); |
|
| 327 | + // cycle thru values |
|
| 328 | + foreach ($row_qty as $qty) { |
|
| 329 | + $qty = absint($qty); |
|
| 330 | + // sanitize as integers |
|
| 331 | + $valid_data[ $what ][] = $qty; |
|
| 332 | + $valid_data['total_tickets'] += $qty; |
|
| 333 | + } |
|
| 334 | + break; |
|
| 335 | + // array of integers |
|
| 336 | + case 'ticket_id': |
|
| 337 | + $ticket_ids = (array) $this->request->getRequestParam($input_key, [], 'int', true); |
|
| 338 | + // cycle thru values |
|
| 339 | + foreach ($ticket_ids as $key => $value) { |
|
| 340 | + // allow only integers |
|
| 341 | + $valid_data[ $what ][ $key ] = absint($value); |
|
| 342 | + } |
|
| 343 | + break; |
|
| 344 | + case 'return_url': |
|
| 345 | + // grab and sanitize return-url |
|
| 346 | + $input_value = $this->request->getRequestParam($input_key, '', 'url'); |
|
| 347 | + // was the request coming from an iframe ? if so, then: |
|
| 348 | + if (strpos($input_value, 'event_list=iframe')) { |
|
| 349 | + // get anchor fragment |
|
| 350 | + $input_value = explode('#', $input_value); |
|
| 351 | + $input_value = end($input_value); |
|
| 352 | + // use event list url instead, but append anchor |
|
| 353 | + $input_value = EEH_Event_View::event_archive_url() . '#' . $input_value; |
|
| 354 | + } |
|
| 355 | + $valid_data[ $what ] = $input_value; |
|
| 356 | + break; |
|
| 357 | + } // end switch $what |
|
| 358 | + } |
|
| 359 | + } // end foreach $inputs_to_clean |
|
| 360 | + return $valid_data; |
|
| 361 | + } |
|
| 362 | 362 | |
| 363 | 363 | |
| 364 | - /** |
|
| 365 | - * @param array $valid |
|
| 366 | - */ |
|
| 367 | - private function maxAttendeesViolation(array $valid) |
|
| 368 | - { |
|
| 369 | - // ordering too many tickets !!! |
|
| 370 | - $total_tickets_string = esc_html( |
|
| 371 | - _n( |
|
| 372 | - 'You have attempted to purchase %s ticket.', |
|
| 373 | - 'You have attempted to purchase %s tickets.', |
|
| 374 | - $valid['total_tickets'], |
|
| 375 | - 'event_espresso' |
|
| 376 | - ) |
|
| 377 | - ); |
|
| 378 | - $limit_error_1 = sprintf($total_tickets_string, $valid['total_tickets']); |
|
| 379 | - // dev only message |
|
| 380 | - $max_attendees_string = esc_html( |
|
| 381 | - _n( |
|
| 382 | - 'The registration limit for this event is %s ticket per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.', |
|
| 383 | - 'The registration limit for this event is %s tickets per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.', |
|
| 384 | - $valid['max_atndz'], |
|
| 385 | - 'event_espresso' |
|
| 386 | - ) |
|
| 387 | - ); |
|
| 388 | - $limit_error_2 = sprintf($max_attendees_string, $valid['max_atndz'], $valid['max_atndz']); |
|
| 389 | - EE_Error::add_error($limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__); |
|
| 390 | - } |
|
| 364 | + /** |
|
| 365 | + * @param array $valid |
|
| 366 | + */ |
|
| 367 | + private function maxAttendeesViolation(array $valid) |
|
| 368 | + { |
|
| 369 | + // ordering too many tickets !!! |
|
| 370 | + $total_tickets_string = esc_html( |
|
| 371 | + _n( |
|
| 372 | + 'You have attempted to purchase %s ticket.', |
|
| 373 | + 'You have attempted to purchase %s tickets.', |
|
| 374 | + $valid['total_tickets'], |
|
| 375 | + 'event_espresso' |
|
| 376 | + ) |
|
| 377 | + ); |
|
| 378 | + $limit_error_1 = sprintf($total_tickets_string, $valid['total_tickets']); |
|
| 379 | + // dev only message |
|
| 380 | + $max_attendees_string = esc_html( |
|
| 381 | + _n( |
|
| 382 | + 'The registration limit for this event is %s ticket per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.', |
|
| 383 | + 'The registration limit for this event is %s tickets per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.', |
|
| 384 | + $valid['max_atndz'], |
|
| 385 | + 'event_espresso' |
|
| 386 | + ) |
|
| 387 | + ); |
|
| 388 | + $limit_error_2 = sprintf($max_attendees_string, $valid['max_atndz'], $valid['max_atndz']); |
|
| 389 | + EE_Error::add_error($limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__); |
|
| 390 | + } |
|
| 391 | 391 | |
| 392 | 392 | |
| 393 | - /** |
|
| 394 | - * @param array $valid |
|
| 395 | - * @return int |
|
| 396 | - * @throws EE_Error |
|
| 397 | - * @throws InvalidArgumentException |
|
| 398 | - * @throws InvalidDataTypeException |
|
| 399 | - * @throws InvalidInterfaceException |
|
| 400 | - */ |
|
| 401 | - private function addTicketsToCart(array $valid) |
|
| 402 | - { |
|
| 403 | - $tickets_added = 0; |
|
| 404 | - $tickets_selected = false; |
|
| 405 | - if (! empty($valid) && $valid['total_tickets'] > 0) { |
|
| 406 | - // load cart using factory because we don't want to do so until actually needed |
|
| 407 | - $this->cart = CartFactory::getCart(); |
|
| 408 | - // if the user is an admin that can edit registrations, |
|
| 409 | - // then we'll also allow them to add any tickets, even if they are expired |
|
| 410 | - $current_user_is_admin = current_user_can('ee_edit_registrations'); |
|
| 411 | - // cycle thru the number of data rows sent from the event listing |
|
| 412 | - for ($x = 0; $x < $valid['rows']; $x++) { |
|
| 413 | - // does this row actually contain a ticket quantity? |
|
| 414 | - if (isset($valid['qty'][ $x ]) && $valid['qty'][ $x ] > 0) { |
|
| 415 | - // YES we have a ticket quantity |
|
| 416 | - $tickets_selected = true; |
|
| 417 | - $valid_ticket = false; |
|
| 418 | - if (isset($valid['ticket_id'][ $x ])) { |
|
| 419 | - // get ticket via the ticket id we put in the form |
|
| 420 | - $ticket = $this->ticket_model->get_one_by_ID($valid['ticket_id'][ $x ]); |
|
| 421 | - if ($ticket instanceof EE_Ticket && ($ticket->is_on_sale() || $current_user_is_admin)) { |
|
| 422 | - $valid_ticket = true; |
|
| 423 | - $tickets_added += $this->addTicketToCart( |
|
| 424 | - $ticket, |
|
| 425 | - $valid['qty'][ $x ] |
|
| 426 | - ); |
|
| 427 | - } |
|
| 428 | - } |
|
| 429 | - if ($valid_ticket !== true) { |
|
| 430 | - // nothing added to cart retrieved |
|
| 431 | - EE_Error::add_error( |
|
| 432 | - sprintf( |
|
| 433 | - esc_html__( |
|
| 434 | - 'A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.', |
|
| 435 | - 'event_espresso' |
|
| 436 | - ), |
|
| 437 | - '<br/>' |
|
| 438 | - ), |
|
| 439 | - __FILE__, |
|
| 440 | - __FUNCTION__, |
|
| 441 | - __LINE__ |
|
| 442 | - ); |
|
| 443 | - } |
|
| 444 | - if (EE_Error::has_error()) { |
|
| 445 | - break; |
|
| 446 | - } |
|
| 447 | - } |
|
| 448 | - } |
|
| 449 | - } |
|
| 450 | - do_action( |
|
| 451 | - 'AHEE__EE_Ticket_Selector__process_ticket_selections__after_tickets_added_to_cart', |
|
| 452 | - $this->cart, |
|
| 453 | - $this |
|
| 454 | - ); |
|
| 455 | - if (! apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tickets_selected)) { |
|
| 456 | - // no ticket quantities were selected |
|
| 457 | - EE_Error::add_error( |
|
| 458 | - esc_html__('You need to select a ticket quantity before you can proceed.', 'event_espresso'), |
|
| 459 | - __FILE__, |
|
| 460 | - __FUNCTION__, |
|
| 461 | - __LINE__ |
|
| 462 | - ); |
|
| 463 | - } |
|
| 464 | - return $tickets_added; |
|
| 465 | - } |
|
| 393 | + /** |
|
| 394 | + * @param array $valid |
|
| 395 | + * @return int |
|
| 396 | + * @throws EE_Error |
|
| 397 | + * @throws InvalidArgumentException |
|
| 398 | + * @throws InvalidDataTypeException |
|
| 399 | + * @throws InvalidInterfaceException |
|
| 400 | + */ |
|
| 401 | + private function addTicketsToCart(array $valid) |
|
| 402 | + { |
|
| 403 | + $tickets_added = 0; |
|
| 404 | + $tickets_selected = false; |
|
| 405 | + if (! empty($valid) && $valid['total_tickets'] > 0) { |
|
| 406 | + // load cart using factory because we don't want to do so until actually needed |
|
| 407 | + $this->cart = CartFactory::getCart(); |
|
| 408 | + // if the user is an admin that can edit registrations, |
|
| 409 | + // then we'll also allow them to add any tickets, even if they are expired |
|
| 410 | + $current_user_is_admin = current_user_can('ee_edit_registrations'); |
|
| 411 | + // cycle thru the number of data rows sent from the event listing |
|
| 412 | + for ($x = 0; $x < $valid['rows']; $x++) { |
|
| 413 | + // does this row actually contain a ticket quantity? |
|
| 414 | + if (isset($valid['qty'][ $x ]) && $valid['qty'][ $x ] > 0) { |
|
| 415 | + // YES we have a ticket quantity |
|
| 416 | + $tickets_selected = true; |
|
| 417 | + $valid_ticket = false; |
|
| 418 | + if (isset($valid['ticket_id'][ $x ])) { |
|
| 419 | + // get ticket via the ticket id we put in the form |
|
| 420 | + $ticket = $this->ticket_model->get_one_by_ID($valid['ticket_id'][ $x ]); |
|
| 421 | + if ($ticket instanceof EE_Ticket && ($ticket->is_on_sale() || $current_user_is_admin)) { |
|
| 422 | + $valid_ticket = true; |
|
| 423 | + $tickets_added += $this->addTicketToCart( |
|
| 424 | + $ticket, |
|
| 425 | + $valid['qty'][ $x ] |
|
| 426 | + ); |
|
| 427 | + } |
|
| 428 | + } |
|
| 429 | + if ($valid_ticket !== true) { |
|
| 430 | + // nothing added to cart retrieved |
|
| 431 | + EE_Error::add_error( |
|
| 432 | + sprintf( |
|
| 433 | + esc_html__( |
|
| 434 | + 'A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.', |
|
| 435 | + 'event_espresso' |
|
| 436 | + ), |
|
| 437 | + '<br/>' |
|
| 438 | + ), |
|
| 439 | + __FILE__, |
|
| 440 | + __FUNCTION__, |
|
| 441 | + __LINE__ |
|
| 442 | + ); |
|
| 443 | + } |
|
| 444 | + if (EE_Error::has_error()) { |
|
| 445 | + break; |
|
| 446 | + } |
|
| 447 | + } |
|
| 448 | + } |
|
| 449 | + } |
|
| 450 | + do_action( |
|
| 451 | + 'AHEE__EE_Ticket_Selector__process_ticket_selections__after_tickets_added_to_cart', |
|
| 452 | + $this->cart, |
|
| 453 | + $this |
|
| 454 | + ); |
|
| 455 | + if (! apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tickets_selected)) { |
|
| 456 | + // no ticket quantities were selected |
|
| 457 | + EE_Error::add_error( |
|
| 458 | + esc_html__('You need to select a ticket quantity before you can proceed.', 'event_espresso'), |
|
| 459 | + __FILE__, |
|
| 460 | + __FUNCTION__, |
|
| 461 | + __LINE__ |
|
| 462 | + ); |
|
| 463 | + } |
|
| 464 | + return $tickets_added; |
|
| 465 | + } |
|
| 466 | 466 | |
| 467 | 467 | |
| 468 | - /** |
|
| 469 | - * adds a ticket to the cart |
|
| 470 | - * |
|
| 471 | - * @param EE_Ticket $ticket |
|
| 472 | - * @param int $qty |
|
| 473 | - * @return bool TRUE on success, FALSE on fail |
|
| 474 | - * @throws InvalidArgumentException |
|
| 475 | - * @throws InvalidInterfaceException |
|
| 476 | - * @throws InvalidDataTypeException |
|
| 477 | - * @throws EE_Error |
|
| 478 | - */ |
|
| 479 | - private function addTicketToCart(EE_Ticket $ticket, $qty = 1) |
|
| 480 | - { |
|
| 481 | - // get the number of spaces left for this datetime ticket |
|
| 482 | - $available_spaces = $this->tracker->ticketDatetimeAvailability($ticket); |
|
| 483 | - // compare available spaces against the number of tickets being purchased |
|
| 484 | - if ($available_spaces >= $qty) { |
|
| 485 | - // allow addons to prevent a ticket from being added to cart |
|
| 486 | - if ( |
|
| 487 | - ! apply_filters( |
|
| 488 | - 'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart', |
|
| 489 | - true, |
|
| 490 | - $ticket, |
|
| 491 | - $qty, |
|
| 492 | - $available_spaces |
|
| 493 | - ) |
|
| 494 | - ) { |
|
| 495 | - return false; |
|
| 496 | - } |
|
| 497 | - $qty = absint(apply_filters('FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty', $qty, $ticket)); |
|
| 498 | - // add event to cart |
|
| 499 | - if ($this->cart->add_ticket_to_cart($ticket, $qty)) { |
|
| 500 | - $this->tracker->recalculateTicketDatetimeAvailability($ticket, $qty); |
|
| 501 | - return true; |
|
| 502 | - } |
|
| 503 | - return false; |
|
| 504 | - } |
|
| 505 | - $this->tracker->processAvailabilityError($ticket, $qty, $this->cart->all_ticket_quantity_count()); |
|
| 506 | - return false; |
|
| 507 | - } |
|
| 468 | + /** |
|
| 469 | + * adds a ticket to the cart |
|
| 470 | + * |
|
| 471 | + * @param EE_Ticket $ticket |
|
| 472 | + * @param int $qty |
|
| 473 | + * @return bool TRUE on success, FALSE on fail |
|
| 474 | + * @throws InvalidArgumentException |
|
| 475 | + * @throws InvalidInterfaceException |
|
| 476 | + * @throws InvalidDataTypeException |
|
| 477 | + * @throws EE_Error |
|
| 478 | + */ |
|
| 479 | + private function addTicketToCart(EE_Ticket $ticket, $qty = 1) |
|
| 480 | + { |
|
| 481 | + // get the number of spaces left for this datetime ticket |
|
| 482 | + $available_spaces = $this->tracker->ticketDatetimeAvailability($ticket); |
|
| 483 | + // compare available spaces against the number of tickets being purchased |
|
| 484 | + if ($available_spaces >= $qty) { |
|
| 485 | + // allow addons to prevent a ticket from being added to cart |
|
| 486 | + if ( |
|
| 487 | + ! apply_filters( |
|
| 488 | + 'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart', |
|
| 489 | + true, |
|
| 490 | + $ticket, |
|
| 491 | + $qty, |
|
| 492 | + $available_spaces |
|
| 493 | + ) |
|
| 494 | + ) { |
|
| 495 | + return false; |
|
| 496 | + } |
|
| 497 | + $qty = absint(apply_filters('FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty', $qty, $ticket)); |
|
| 498 | + // add event to cart |
|
| 499 | + if ($this->cart->add_ticket_to_cart($ticket, $qty)) { |
|
| 500 | + $this->tracker->recalculateTicketDatetimeAvailability($ticket, $qty); |
|
| 501 | + return true; |
|
| 502 | + } |
|
| 503 | + return false; |
|
| 504 | + } |
|
| 505 | + $this->tracker->processAvailabilityError($ticket, $qty, $this->cart->all_ticket_quantity_count()); |
|
| 506 | + return false; |
|
| 507 | + } |
|
| 508 | 508 | |
| 509 | 509 | |
| 510 | - /** |
|
| 511 | - * @param $tickets_added |
|
| 512 | - * @return bool |
|
| 513 | - * @throws InvalidInterfaceException |
|
| 514 | - * @throws InvalidDataTypeException |
|
| 515 | - * @throws EE_Error |
|
| 516 | - * @throws InvalidArgumentException |
|
| 517 | - */ |
|
| 518 | - private function processSuccessfulCart($tickets_added) |
|
| 519 | - { |
|
| 520 | - // exit('KILL REDIRECT BEFORE CART UPDATE'); // <<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE |
|
| 521 | - if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__success', $tickets_added)) { |
|
| 522 | - // make sure cart is loaded |
|
| 523 | - if (! $this->cart instanceof EE_Cart) { |
|
| 524 | - $this->cart = CartFactory::getCart(); |
|
| 525 | - } |
|
| 526 | - do_action( |
|
| 527 | - 'FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout', |
|
| 528 | - $this->cart, |
|
| 529 | - $this |
|
| 530 | - ); |
|
| 531 | - $this->cart->recalculate_all_cart_totals(); |
|
| 532 | - $this->cart->save_cart(false); |
|
| 533 | - // exit('KILL REDIRECT AFTER CART UPDATE'); // <<<<<<<< OR HERE TO KILL REDIRECT AFTER CART UPDATE |
|
| 534 | - // just return TRUE for registrations being made from admin |
|
| 535 | - if ($this->request->isAdmin() || $this->request->isFrontAjax()) { |
|
| 536 | - return true; |
|
| 537 | - } |
|
| 538 | - EEH_URL::safeRedirectAndExit( |
|
| 539 | - apply_filters( |
|
| 540 | - 'FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url', |
|
| 541 | - $this->core_config->reg_page_url() |
|
| 542 | - ) |
|
| 543 | - ); |
|
| 544 | - } |
|
| 545 | - if (! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) { |
|
| 546 | - // nothing added to cart |
|
| 547 | - EE_Error::add_attention( |
|
| 548 | - esc_html__('No tickets were added for the event', 'event_espresso'), |
|
| 549 | - __FILE__, |
|
| 550 | - __FUNCTION__, |
|
| 551 | - __LINE__ |
|
| 552 | - ); |
|
| 553 | - } |
|
| 554 | - return false; |
|
| 555 | - } |
|
| 510 | + /** |
|
| 511 | + * @param $tickets_added |
|
| 512 | + * @return bool |
|
| 513 | + * @throws InvalidInterfaceException |
|
| 514 | + * @throws InvalidDataTypeException |
|
| 515 | + * @throws EE_Error |
|
| 516 | + * @throws InvalidArgumentException |
|
| 517 | + */ |
|
| 518 | + private function processSuccessfulCart($tickets_added) |
|
| 519 | + { |
|
| 520 | + // exit('KILL REDIRECT BEFORE CART UPDATE'); // <<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE |
|
| 521 | + if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__success', $tickets_added)) { |
|
| 522 | + // make sure cart is loaded |
|
| 523 | + if (! $this->cart instanceof EE_Cart) { |
|
| 524 | + $this->cart = CartFactory::getCart(); |
|
| 525 | + } |
|
| 526 | + do_action( |
|
| 527 | + 'FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout', |
|
| 528 | + $this->cart, |
|
| 529 | + $this |
|
| 530 | + ); |
|
| 531 | + $this->cart->recalculate_all_cart_totals(); |
|
| 532 | + $this->cart->save_cart(false); |
|
| 533 | + // exit('KILL REDIRECT AFTER CART UPDATE'); // <<<<<<<< OR HERE TO KILL REDIRECT AFTER CART UPDATE |
|
| 534 | + // just return TRUE for registrations being made from admin |
|
| 535 | + if ($this->request->isAdmin() || $this->request->isFrontAjax()) { |
|
| 536 | + return true; |
|
| 537 | + } |
|
| 538 | + EEH_URL::safeRedirectAndExit( |
|
| 539 | + apply_filters( |
|
| 540 | + 'FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url', |
|
| 541 | + $this->core_config->reg_page_url() |
|
| 542 | + ) |
|
| 543 | + ); |
|
| 544 | + } |
|
| 545 | + if (! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) { |
|
| 546 | + // nothing added to cart |
|
| 547 | + EE_Error::add_attention( |
|
| 548 | + esc_html__('No tickets were added for the event', 'event_espresso'), |
|
| 549 | + __FILE__, |
|
| 550 | + __FUNCTION__, |
|
| 551 | + __LINE__ |
|
| 552 | + ); |
|
| 553 | + } |
|
| 554 | + return false; |
|
| 555 | + } |
|
| 556 | 556 | } |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | public function cancelTicketSelections() |
| 119 | 119 | { |
| 120 | 120 | // check nonce |
| 121 | - if (! $this->processTicketSelectorNonce('cancel_ticket_selections')) { |
|
| 121 | + if ( ! $this->processTicketSelectorNonce('cancel_ticket_selections')) { |
|
| 122 | 122 | return false; |
| 123 | 123 | } |
| 124 | 124 | $this->session->clear_session(__CLASS__, __FUNCTION__); |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | ); |
| 131 | 131 | } |
| 132 | 132 | EEH_URL::safeRedirectAndExit( |
| 133 | - site_url('/' . $this->core_config->event_cpt_slug . '/') |
|
| 133 | + site_url('/'.$this->core_config->event_cpt_slug.'/') |
|
| 134 | 134 | ); |
| 135 | 135 | return true; |
| 136 | 136 | } |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | $this->validatePostData($id) |
| 209 | 209 | ); |
| 210 | 210 | // check total tickets ordered vs max number of attendees that can register |
| 211 | - if (! empty($valid) && $valid['total_tickets'] > $valid['max_atndz']) { |
|
| 211 | + if ( ! empty($valid) && $valid['total_tickets'] > $valid['max_atndz']) { |
|
| 212 | 212 | $this->maxAttendeesViolation($valid); |
| 213 | 213 | } else { |
| 214 | 214 | // all data appears to be valid |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | private function getEventId() |
| 239 | 239 | { |
| 240 | 240 | // do we have an event id? |
| 241 | - if (! $this->request->requestParamIsSet('tkt-slctr-event-id')) { |
|
| 241 | + if ( ! $this->request->requestParamIsSet('tkt-slctr-event-id')) { |
|
| 242 | 242 | // $_POST['tkt-slctr-event-id'] was not set ?!?!?!? |
| 243 | 243 | EE_Error::add_error( |
| 244 | 244 | sprintf( |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | */ |
| 267 | 267 | private function validatePostData($id = 0) |
| 268 | 268 | { |
| 269 | - if (! $id) { |
|
| 269 | + if ( ! $id) { |
|
| 270 | 270 | EE_Error::add_error( |
| 271 | 271 | esc_html__('The event id provided was not valid.', 'event_espresso'), |
| 272 | 272 | __FILE__, |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | case 'event_id': |
| 300 | 300 | case 'rows': |
| 301 | 301 | case 'max_atndz': |
| 302 | - $valid_data[ $what ] = $this->request->getRequestParam($input_key, 0, 'int'); |
|
| 302 | + $valid_data[$what] = $this->request->getRequestParam($input_key, 0, 'int'); |
|
| 303 | 303 | break; |
| 304 | 304 | // arrays of integers |
| 305 | 305 | case 'qty': |
@@ -312,14 +312,14 @@ discard block |
||
| 312 | 312 | // if qty is coming from a radio button input, then we need to assemble an array of rows |
| 313 | 313 | if ($delimiter === '-') { |
| 314 | 314 | // get number of rows |
| 315 | - $rows = $this->request->getRequestParam('tkt-slctr-rows-' . $id, 1, 'int'); |
|
| 315 | + $rows = $this->request->getRequestParam('tkt-slctr-rows-'.$id, 1, 'int'); |
|
| 316 | 316 | $row = isset($row_qty[0]) ? absint($row_qty[0]) : 1; |
| 317 | 317 | $qty = isset($row_qty[1]) ? absint($row_qty[1]) : 0; |
| 318 | 318 | // restructure the row qty array so that $row is now the key instead of the first value |
| 319 | 319 | $row_qty = array($row => $qty); |
| 320 | 320 | for ($x = 1; $x <= $rows; $x++) { |
| 321 | - if (! isset($row_qty[ $x ])) { |
|
| 322 | - $row_qty[ $x ] = 0; |
|
| 321 | + if ( ! isset($row_qty[$x])) { |
|
| 322 | + $row_qty[$x] = 0; |
|
| 323 | 323 | } |
| 324 | 324 | } |
| 325 | 325 | } |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | foreach ($row_qty as $qty) { |
| 329 | 329 | $qty = absint($qty); |
| 330 | 330 | // sanitize as integers |
| 331 | - $valid_data[ $what ][] = $qty; |
|
| 331 | + $valid_data[$what][] = $qty; |
|
| 332 | 332 | $valid_data['total_tickets'] += $qty; |
| 333 | 333 | } |
| 334 | 334 | break; |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | // cycle thru values |
| 339 | 339 | foreach ($ticket_ids as $key => $value) { |
| 340 | 340 | // allow only integers |
| 341 | - $valid_data[ $what ][ $key ] = absint($value); |
|
| 341 | + $valid_data[$what][$key] = absint($value); |
|
| 342 | 342 | } |
| 343 | 343 | break; |
| 344 | 344 | case 'return_url': |
@@ -350,9 +350,9 @@ discard block |
||
| 350 | 350 | $input_value = explode('#', $input_value); |
| 351 | 351 | $input_value = end($input_value); |
| 352 | 352 | // use event list url instead, but append anchor |
| 353 | - $input_value = EEH_Event_View::event_archive_url() . '#' . $input_value; |
|
| 353 | + $input_value = EEH_Event_View::event_archive_url().'#'.$input_value; |
|
| 354 | 354 | } |
| 355 | - $valid_data[ $what ] = $input_value; |
|
| 355 | + $valid_data[$what] = $input_value; |
|
| 356 | 356 | break; |
| 357 | 357 | } // end switch $what |
| 358 | 358 | } |
@@ -386,7 +386,7 @@ discard block |
||
| 386 | 386 | ) |
| 387 | 387 | ); |
| 388 | 388 | $limit_error_2 = sprintf($max_attendees_string, $valid['max_atndz'], $valid['max_atndz']); |
| 389 | - EE_Error::add_error($limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__); |
|
| 389 | + EE_Error::add_error($limit_error_1.'<br/>'.$limit_error_2, __FILE__, __FUNCTION__, __LINE__); |
|
| 390 | 390 | } |
| 391 | 391 | |
| 392 | 392 | |
@@ -402,7 +402,7 @@ discard block |
||
| 402 | 402 | { |
| 403 | 403 | $tickets_added = 0; |
| 404 | 404 | $tickets_selected = false; |
| 405 | - if (! empty($valid) && $valid['total_tickets'] > 0) { |
|
| 405 | + if ( ! empty($valid) && $valid['total_tickets'] > 0) { |
|
| 406 | 406 | // load cart using factory because we don't want to do so until actually needed |
| 407 | 407 | $this->cart = CartFactory::getCart(); |
| 408 | 408 | // if the user is an admin that can edit registrations, |
@@ -411,18 +411,18 @@ discard block |
||
| 411 | 411 | // cycle thru the number of data rows sent from the event listing |
| 412 | 412 | for ($x = 0; $x < $valid['rows']; $x++) { |
| 413 | 413 | // does this row actually contain a ticket quantity? |
| 414 | - if (isset($valid['qty'][ $x ]) && $valid['qty'][ $x ] > 0) { |
|
| 414 | + if (isset($valid['qty'][$x]) && $valid['qty'][$x] > 0) { |
|
| 415 | 415 | // YES we have a ticket quantity |
| 416 | 416 | $tickets_selected = true; |
| 417 | 417 | $valid_ticket = false; |
| 418 | - if (isset($valid['ticket_id'][ $x ])) { |
|
| 418 | + if (isset($valid['ticket_id'][$x])) { |
|
| 419 | 419 | // get ticket via the ticket id we put in the form |
| 420 | - $ticket = $this->ticket_model->get_one_by_ID($valid['ticket_id'][ $x ]); |
|
| 420 | + $ticket = $this->ticket_model->get_one_by_ID($valid['ticket_id'][$x]); |
|
| 421 | 421 | if ($ticket instanceof EE_Ticket && ($ticket->is_on_sale() || $current_user_is_admin)) { |
| 422 | 422 | $valid_ticket = true; |
| 423 | 423 | $tickets_added += $this->addTicketToCart( |
| 424 | 424 | $ticket, |
| 425 | - $valid['qty'][ $x ] |
|
| 425 | + $valid['qty'][$x] |
|
| 426 | 426 | ); |
| 427 | 427 | } |
| 428 | 428 | } |
@@ -452,7 +452,7 @@ discard block |
||
| 452 | 452 | $this->cart, |
| 453 | 453 | $this |
| 454 | 454 | ); |
| 455 | - if (! apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tickets_selected)) { |
|
| 455 | + if ( ! apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tickets_selected)) { |
|
| 456 | 456 | // no ticket quantities were selected |
| 457 | 457 | EE_Error::add_error( |
| 458 | 458 | esc_html__('You need to select a ticket quantity before you can proceed.', 'event_espresso'), |
@@ -520,7 +520,7 @@ discard block |
||
| 520 | 520 | // exit('KILL REDIRECT BEFORE CART UPDATE'); // <<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE |
| 521 | 521 | if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__success', $tickets_added)) { |
| 522 | 522 | // make sure cart is loaded |
| 523 | - if (! $this->cart instanceof EE_Cart) { |
|
| 523 | + if ( ! $this->cart instanceof EE_Cart) { |
|
| 524 | 524 | $this->cart = CartFactory::getCart(); |
| 525 | 525 | } |
| 526 | 526 | do_action( |
@@ -542,7 +542,7 @@ discard block |
||
| 542 | 542 | ) |
| 543 | 543 | ); |
| 544 | 544 | } |
| 545 | - if (! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) { |
|
| 545 | + if ( ! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) { |
|
| 546 | 546 | // nothing added to cart |
| 547 | 547 | EE_Error::add_attention( |
| 548 | 548 | esc_html__('No tickets were added for the event', 'event_espresso'), |
@@ -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.19.rc.000'); |
|
| 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.19.rc.000'); |
|
| 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 | } |