@@ -29,266 +29,266 @@ |
||
| 29 | 29 | class EspressoEventAttendees extends EspressoShortcode |
| 30 | 30 | { |
| 31 | 31 | |
| 32 | - private $query_params = array( |
|
| 33 | - 0 => array() |
|
| 34 | - ); |
|
| 35 | - |
|
| 36 | - private $template_args = array( |
|
| 37 | - 'contacts' => array(), |
|
| 38 | - 'event' => null, |
|
| 39 | - 'datetime' => null, |
|
| 40 | - 'ticket' => null, |
|
| 41 | - ); |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * the actual shortcode tag that gets registered with WordPress |
|
| 45 | - * |
|
| 46 | - * @return string |
|
| 47 | - */ |
|
| 48 | - public function getTag() |
|
| 49 | - { |
|
| 50 | - return 'ESPRESSO_EVENT_ATTENDEES'; |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * the time in seconds to cache the results of the processShortcode() method |
|
| 57 | - * 0 means the processShortcode() results will NOT be cached at all |
|
| 58 | - * |
|
| 59 | - * @return int |
|
| 60 | - */ |
|
| 61 | - public function cacheExpiration() |
|
| 62 | - { |
|
| 63 | - return 0; |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - |
|
| 67 | - |
|
| 68 | - /** |
|
| 69 | - * a place for adding any initialization code that needs to run prior to wp_header(). |
|
| 70 | - * this may be required for shortcodes that utilize a corresponding module, |
|
| 71 | - * and need to enqueue assets for that module |
|
| 72 | - * |
|
| 73 | - * @return void |
|
| 74 | - */ |
|
| 75 | - public function initializeShortcode() |
|
| 76 | - { |
|
| 77 | - $this->shortcodeHasBeenInitialized(); |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - |
|
| 81 | - |
|
| 82 | - /** |
|
| 83 | - * process_shortcode - ESPRESSO_EVENT_ATTENDEES - Returns a list of attendees to an event. |
|
| 84 | - * [ESPRESSO_EVENT_ATTENDEES] |
|
| 85 | - * - defaults to attendees for earliest active event, or earliest upcoming event. |
|
| 86 | - * |
|
| 87 | - * [ESPRESSO_EVENT_ATTENDEES event_id=123] |
|
| 88 | - * - attendees for specific event. |
|
| 89 | - * |
|
| 90 | - * [ESPRESSO_EVENT_ATTENDEES datetime_id=245] |
|
| 91 | - * - attendees for a specific datetime. |
|
| 92 | - * |
|
| 93 | - * [ESPRESSO_EVENT_ATTENDEES ticket_id=123] |
|
| 94 | - * - attendees for a specific ticket. |
|
| 95 | - * |
|
| 96 | - * [ESPRESSO_EVENT_ATTENDEES status=all] |
|
| 97 | - * - specific registration status (use status id) or all for all attendees regardless of status. |
|
| 98 | - * Note default is to only return approved attendees |
|
| 99 | - * |
|
| 100 | - * [ESPRESSO_EVENT_ATTENDEES show_gravatar=true] |
|
| 101 | - * - default is to not return gravatar. Otherwise if this is set then return gravatar for email address given. |
|
| 102 | - * |
|
| 103 | - * [ESPRESSO_EVENT_ATTENDEES display_on_archives=true] |
|
| 104 | - * - default is to not display attendees list on archive pages. |
|
| 105 | - * |
|
| 106 | - * Note: because of the relationship between event_id, ticket_id, and datetime_id: |
|
| 107 | - * If more than one of those params is included, then preference is given to the following: |
|
| 108 | - * - event_id is used whenever its present and any others are ignored. |
|
| 109 | - * - if no event_id then datetime is used whenever its present and any others are ignored. |
|
| 110 | - * - otherwise ticket_id is used if present. |
|
| 111 | - * |
|
| 112 | - * @param array $attributes |
|
| 113 | - * @return string |
|
| 114 | - * @throws EE_Error |
|
| 115 | - */ |
|
| 116 | - public function processShortcode($attributes = array()) |
|
| 117 | - { |
|
| 118 | - // grab attributes and merge with defaults |
|
| 119 | - $attributes = $this->getAttributes((array)$attributes); |
|
| 120 | - $archive = is_archive(); |
|
| 121 | - $display_on_archives = filter_var($attributes['display_on_archives'], FILTER_VALIDATE_BOOLEAN); |
|
| 122 | - // don't display on archives unless 'display_on_archives' is true |
|
| 123 | - if($archive && ! $display_on_archives) { |
|
| 124 | - return ''; |
|
| 125 | - } |
|
| 126 | - // add attributes to template args |
|
| 127 | - $this->template_args['show_gravatar'] = $attributes['show_gravatar']; |
|
| 128 | - // add required objects: event, datetime, and ticket |
|
| 129 | - $this->template_args['event'] = $this->getEventAndQueryParams($attributes); |
|
| 130 | - $this->template_args['datetime'] = $this->getDatetimeAndQueryParams($attributes); |
|
| 131 | - $this->template_args['ticket'] = $this->getTicketAndQueryParams($attributes); |
|
| 132 | - |
|
| 133 | - // if any of the above objects is invalid or missing, |
|
| 134 | - // then there was an invalid parameter or the shortcode was used incorrectly |
|
| 135 | - // so when WP_DEBUG is set and true, we'll show a message, |
|
| 136 | - // otherwise we'll just return an empty string. |
|
| 137 | - if ( |
|
| 138 | - ! $this->template_args['event'] instanceof EE_Event |
|
| 139 | - || empty($this->query_params[0]) |
|
| 140 | - || ($attributes['datetime_id'] && ! $this->template_args['datetime'] instanceof EE_Datetime) |
|
| 141 | - || ($attributes['ticket_id'] && ! $this->template_args['ticket'] instanceof EE_Ticket) |
|
| 142 | - ) { |
|
| 143 | - if (WP_DEBUG) { |
|
| 144 | - return '<div class="important-notice ee-attention">' |
|
| 145 | - . esc_html__('The [ESPRESSO_EVENT_ATTENDEES] shortcode has been used incorrectly. Please double check the arguments you used for any typos. In the case of ID type arguments, its possible the given ID does not correspond to existing data in the database.', |
|
| 146 | - 'event_espresso') |
|
| 147 | - . '</div>'; |
|
| 148 | - } |
|
| 149 | - return ''; |
|
| 150 | - } |
|
| 151 | - $this->setAdditionalQueryParams($attributes); |
|
| 152 | - //get contacts! |
|
| 153 | - $this->template_args['contacts'] = EEM_Attendee::instance()->get_all($this->query_params); |
|
| 154 | - //all set let's load up the template and return. |
|
| 155 | - return EEH_Template::locate_template( |
|
| 156 | - 'loop-espresso_event_attendees.php', |
|
| 157 | - $this->template_args |
|
| 158 | - ); |
|
| 159 | - |
|
| 160 | - } |
|
| 161 | - |
|
| 162 | - |
|
| 163 | - |
|
| 164 | - /** |
|
| 165 | - * merge incoming attributes with filtered defaults |
|
| 166 | - * |
|
| 167 | - * @param array $attributes |
|
| 168 | - * @return array |
|
| 169 | - */ |
|
| 170 | - private function getAttributes(array $attributes) |
|
| 171 | - { |
|
| 172 | - return (array) apply_filters( |
|
| 173 | - 'EES_Espresso_Event_Attendees__process_shortcode__default_shortcode_atts', |
|
| 174 | - $attributes + array( |
|
| 175 | - 'event_id' => null, |
|
| 176 | - 'datetime_id' => null, |
|
| 177 | - 'ticket_id' => null, |
|
| 178 | - 'status' => EEM_Registration::status_id_approved, |
|
| 179 | - 'show_gravatar' => false, |
|
| 180 | - 'display_on_archives' => false, |
|
| 181 | - ) |
|
| 182 | - ); |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - |
|
| 186 | - |
|
| 187 | - /** |
|
| 188 | - * @param array $attributes |
|
| 189 | - * @return EE_Event|null |
|
| 190 | - * @throws EE_Error |
|
| 191 | - */ |
|
| 192 | - private function getEventAndQueryParams(array $attributes){ |
|
| 193 | - if ( ! empty($attributes['event_id'])) { |
|
| 194 | - $event = EEM_Event::instance()->get_one_by_ID($attributes['event_id']); |
|
| 195 | - if ($event instanceof EE_Event) { |
|
| 196 | - $this->query_params[0]['Registration.EVT_ID'] = $attributes['event_id']; |
|
| 197 | - return $event; |
|
| 198 | - } |
|
| 199 | - } |
|
| 200 | - if (is_espresso_event()) { |
|
| 201 | - $event = EEH_Event_View::get_event(); |
|
| 202 | - if ($event instanceof EE_Event) { |
|
| 203 | - $this->query_params[0]['Registration.EVT_ID'] = $event->ID(); |
|
| 204 | - return $event; |
|
| 205 | - } |
|
| 206 | - } |
|
| 207 | - // one last shot... |
|
| 208 | - // try getting the earliest active event |
|
| 209 | - $events = EEM_Event::instance()->get_active_events(array( |
|
| 210 | - 'limit' => 1, |
|
| 211 | - 'order_by' => array('Datetime.DTT_EVT_start' => 'ASC') |
|
| 212 | - )); |
|
| 213 | - // if none then get the next upcoming |
|
| 214 | - $events = empty($events) |
|
| 215 | - ? EEM_Event::instance()->get_upcoming_events(array( |
|
| 216 | - 'limit' => 1, |
|
| 217 | - 'order_by' => array('Datetime.DTT_EVT_start' => 'ASC') |
|
| 218 | - )) |
|
| 219 | - : $events; |
|
| 220 | - $event = reset($events); |
|
| 221 | - if ($event instanceof EE_Event) { |
|
| 222 | - $this->query_params[0]['Registration.EVT_ID'] = $event->ID(); |
|
| 223 | - return $event; |
|
| 224 | - } |
|
| 225 | - return null; |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - |
|
| 229 | - |
|
| 230 | - /** |
|
| 231 | - * @param array $attributes |
|
| 232 | - * @return EE_Datetime|null |
|
| 233 | - */ |
|
| 234 | - private function getDatetimeAndQueryParams(array $attributes) |
|
| 235 | - { |
|
| 236 | - if ( ! empty($attributes['datetime_id'])) { |
|
| 237 | - $datetime = EEM_Datetime::instance()->get_one_by_ID($attributes['datetime_id']); |
|
| 238 | - if ($datetime instanceof EE_Datetime) { |
|
| 239 | - $this->query_params[0]['Registration.Ticket.Datetime.DTT_ID'] = $attributes['datetime_id']; |
|
| 240 | - $this->query_params['default_where_conditions'] = 'this_model_only'; |
|
| 241 | - if ( ! $this->template_args['event'] instanceof EE_Event) { |
|
| 242 | - $this->template_args['event'] = $datetime->event(); |
|
| 243 | - } |
|
| 244 | - return $datetime; |
|
| 245 | - } |
|
| 246 | - } |
|
| 247 | - return null; |
|
| 248 | - } |
|
| 249 | - |
|
| 250 | - |
|
| 251 | - |
|
| 252 | - /** |
|
| 253 | - * @param array $attributes |
|
| 254 | - * @return \EE_Base_Class|null |
|
| 255 | - * @throws EE_Error |
|
| 256 | - */ |
|
| 257 | - private function getTicketAndQueryParams(array $attributes) |
|
| 258 | - { |
|
| 259 | - if ( ! empty($attributes['ticket_id']) && empty($attributes['event_id']) && empty($attributes['datetime_id'])) { |
|
| 260 | - $ticket = EEM_Ticket::instance()->get_one_by_ID($attributes['ticket_id']); |
|
| 261 | - if ($ticket instanceof EE_Ticket) { |
|
| 262 | - $this->query_params[0]['Registration.TKT_ID'] = $attributes['ticket_id']; |
|
| 263 | - if ( ! $this->template_args['event'] instanceof EE_Event) { |
|
| 264 | - $this->template_args['event'] = $ticket->first_datetime() instanceof EE_Datetime |
|
| 265 | - ? $ticket->first_datetime()->event() |
|
| 266 | - : null; |
|
| 267 | - } |
|
| 268 | - return $ticket; |
|
| 269 | - } |
|
| 270 | - } |
|
| 271 | - return null; |
|
| 272 | - } |
|
| 273 | - |
|
| 274 | - |
|
| 275 | - |
|
| 276 | - /** |
|
| 277 | - * @param array $attributes |
|
| 278 | - * @throws EE_Error |
|
| 279 | - */ |
|
| 280 | - private function setAdditionalQueryParams(array $attributes) |
|
| 281 | - { |
|
| 282 | - $reg_status_array = EEM_Registration::reg_status_array(); |
|
| 283 | - if ($attributes['status'] !== 'all' && isset($reg_status_array[$attributes['status']])) { |
|
| 284 | - $this->query_params[0]['Registration.STS_ID'] = $attributes['status']; |
|
| 285 | - } |
|
| 286 | - $this->query_params['group_by'] = array('ATT_ID'); |
|
| 287 | - $this->query_params['order_by'] = (array) apply_filters( |
|
| 288 | - 'FHEE__EES_Espresso_Event_Attendees__process_shortcode__order_by', |
|
| 289 | - array('ATT_lname' => 'ASC', 'ATT_fname' => 'ASC') |
|
| 290 | - ); |
|
| 291 | - } |
|
| 32 | + private $query_params = array( |
|
| 33 | + 0 => array() |
|
| 34 | + ); |
|
| 35 | + |
|
| 36 | + private $template_args = array( |
|
| 37 | + 'contacts' => array(), |
|
| 38 | + 'event' => null, |
|
| 39 | + 'datetime' => null, |
|
| 40 | + 'ticket' => null, |
|
| 41 | + ); |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * the actual shortcode tag that gets registered with WordPress |
|
| 45 | + * |
|
| 46 | + * @return string |
|
| 47 | + */ |
|
| 48 | + public function getTag() |
|
| 49 | + { |
|
| 50 | + return 'ESPRESSO_EVENT_ATTENDEES'; |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * the time in seconds to cache the results of the processShortcode() method |
|
| 57 | + * 0 means the processShortcode() results will NOT be cached at all |
|
| 58 | + * |
|
| 59 | + * @return int |
|
| 60 | + */ |
|
| 61 | + public function cacheExpiration() |
|
| 62 | + { |
|
| 63 | + return 0; |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + |
|
| 67 | + |
|
| 68 | + /** |
|
| 69 | + * a place for adding any initialization code that needs to run prior to wp_header(). |
|
| 70 | + * this may be required for shortcodes that utilize a corresponding module, |
|
| 71 | + * and need to enqueue assets for that module |
|
| 72 | + * |
|
| 73 | + * @return void |
|
| 74 | + */ |
|
| 75 | + public function initializeShortcode() |
|
| 76 | + { |
|
| 77 | + $this->shortcodeHasBeenInitialized(); |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + |
|
| 81 | + |
|
| 82 | + /** |
|
| 83 | + * process_shortcode - ESPRESSO_EVENT_ATTENDEES - Returns a list of attendees to an event. |
|
| 84 | + * [ESPRESSO_EVENT_ATTENDEES] |
|
| 85 | + * - defaults to attendees for earliest active event, or earliest upcoming event. |
|
| 86 | + * |
|
| 87 | + * [ESPRESSO_EVENT_ATTENDEES event_id=123] |
|
| 88 | + * - attendees for specific event. |
|
| 89 | + * |
|
| 90 | + * [ESPRESSO_EVENT_ATTENDEES datetime_id=245] |
|
| 91 | + * - attendees for a specific datetime. |
|
| 92 | + * |
|
| 93 | + * [ESPRESSO_EVENT_ATTENDEES ticket_id=123] |
|
| 94 | + * - attendees for a specific ticket. |
|
| 95 | + * |
|
| 96 | + * [ESPRESSO_EVENT_ATTENDEES status=all] |
|
| 97 | + * - specific registration status (use status id) or all for all attendees regardless of status. |
|
| 98 | + * Note default is to only return approved attendees |
|
| 99 | + * |
|
| 100 | + * [ESPRESSO_EVENT_ATTENDEES show_gravatar=true] |
|
| 101 | + * - default is to not return gravatar. Otherwise if this is set then return gravatar for email address given. |
|
| 102 | + * |
|
| 103 | + * [ESPRESSO_EVENT_ATTENDEES display_on_archives=true] |
|
| 104 | + * - default is to not display attendees list on archive pages. |
|
| 105 | + * |
|
| 106 | + * Note: because of the relationship between event_id, ticket_id, and datetime_id: |
|
| 107 | + * If more than one of those params is included, then preference is given to the following: |
|
| 108 | + * - event_id is used whenever its present and any others are ignored. |
|
| 109 | + * - if no event_id then datetime is used whenever its present and any others are ignored. |
|
| 110 | + * - otherwise ticket_id is used if present. |
|
| 111 | + * |
|
| 112 | + * @param array $attributes |
|
| 113 | + * @return string |
|
| 114 | + * @throws EE_Error |
|
| 115 | + */ |
|
| 116 | + public function processShortcode($attributes = array()) |
|
| 117 | + { |
|
| 118 | + // grab attributes and merge with defaults |
|
| 119 | + $attributes = $this->getAttributes((array)$attributes); |
|
| 120 | + $archive = is_archive(); |
|
| 121 | + $display_on_archives = filter_var($attributes['display_on_archives'], FILTER_VALIDATE_BOOLEAN); |
|
| 122 | + // don't display on archives unless 'display_on_archives' is true |
|
| 123 | + if($archive && ! $display_on_archives) { |
|
| 124 | + return ''; |
|
| 125 | + } |
|
| 126 | + // add attributes to template args |
|
| 127 | + $this->template_args['show_gravatar'] = $attributes['show_gravatar']; |
|
| 128 | + // add required objects: event, datetime, and ticket |
|
| 129 | + $this->template_args['event'] = $this->getEventAndQueryParams($attributes); |
|
| 130 | + $this->template_args['datetime'] = $this->getDatetimeAndQueryParams($attributes); |
|
| 131 | + $this->template_args['ticket'] = $this->getTicketAndQueryParams($attributes); |
|
| 132 | + |
|
| 133 | + // if any of the above objects is invalid or missing, |
|
| 134 | + // then there was an invalid parameter or the shortcode was used incorrectly |
|
| 135 | + // so when WP_DEBUG is set and true, we'll show a message, |
|
| 136 | + // otherwise we'll just return an empty string. |
|
| 137 | + if ( |
|
| 138 | + ! $this->template_args['event'] instanceof EE_Event |
|
| 139 | + || empty($this->query_params[0]) |
|
| 140 | + || ($attributes['datetime_id'] && ! $this->template_args['datetime'] instanceof EE_Datetime) |
|
| 141 | + || ($attributes['ticket_id'] && ! $this->template_args['ticket'] instanceof EE_Ticket) |
|
| 142 | + ) { |
|
| 143 | + if (WP_DEBUG) { |
|
| 144 | + return '<div class="important-notice ee-attention">' |
|
| 145 | + . esc_html__('The [ESPRESSO_EVENT_ATTENDEES] shortcode has been used incorrectly. Please double check the arguments you used for any typos. In the case of ID type arguments, its possible the given ID does not correspond to existing data in the database.', |
|
| 146 | + 'event_espresso') |
|
| 147 | + . '</div>'; |
|
| 148 | + } |
|
| 149 | + return ''; |
|
| 150 | + } |
|
| 151 | + $this->setAdditionalQueryParams($attributes); |
|
| 152 | + //get contacts! |
|
| 153 | + $this->template_args['contacts'] = EEM_Attendee::instance()->get_all($this->query_params); |
|
| 154 | + //all set let's load up the template and return. |
|
| 155 | + return EEH_Template::locate_template( |
|
| 156 | + 'loop-espresso_event_attendees.php', |
|
| 157 | + $this->template_args |
|
| 158 | + ); |
|
| 159 | + |
|
| 160 | + } |
|
| 161 | + |
|
| 162 | + |
|
| 163 | + |
|
| 164 | + /** |
|
| 165 | + * merge incoming attributes with filtered defaults |
|
| 166 | + * |
|
| 167 | + * @param array $attributes |
|
| 168 | + * @return array |
|
| 169 | + */ |
|
| 170 | + private function getAttributes(array $attributes) |
|
| 171 | + { |
|
| 172 | + return (array) apply_filters( |
|
| 173 | + 'EES_Espresso_Event_Attendees__process_shortcode__default_shortcode_atts', |
|
| 174 | + $attributes + array( |
|
| 175 | + 'event_id' => null, |
|
| 176 | + 'datetime_id' => null, |
|
| 177 | + 'ticket_id' => null, |
|
| 178 | + 'status' => EEM_Registration::status_id_approved, |
|
| 179 | + 'show_gravatar' => false, |
|
| 180 | + 'display_on_archives' => false, |
|
| 181 | + ) |
|
| 182 | + ); |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + |
|
| 186 | + |
|
| 187 | + /** |
|
| 188 | + * @param array $attributes |
|
| 189 | + * @return EE_Event|null |
|
| 190 | + * @throws EE_Error |
|
| 191 | + */ |
|
| 192 | + private function getEventAndQueryParams(array $attributes){ |
|
| 193 | + if ( ! empty($attributes['event_id'])) { |
|
| 194 | + $event = EEM_Event::instance()->get_one_by_ID($attributes['event_id']); |
|
| 195 | + if ($event instanceof EE_Event) { |
|
| 196 | + $this->query_params[0]['Registration.EVT_ID'] = $attributes['event_id']; |
|
| 197 | + return $event; |
|
| 198 | + } |
|
| 199 | + } |
|
| 200 | + if (is_espresso_event()) { |
|
| 201 | + $event = EEH_Event_View::get_event(); |
|
| 202 | + if ($event instanceof EE_Event) { |
|
| 203 | + $this->query_params[0]['Registration.EVT_ID'] = $event->ID(); |
|
| 204 | + return $event; |
|
| 205 | + } |
|
| 206 | + } |
|
| 207 | + // one last shot... |
|
| 208 | + // try getting the earliest active event |
|
| 209 | + $events = EEM_Event::instance()->get_active_events(array( |
|
| 210 | + 'limit' => 1, |
|
| 211 | + 'order_by' => array('Datetime.DTT_EVT_start' => 'ASC') |
|
| 212 | + )); |
|
| 213 | + // if none then get the next upcoming |
|
| 214 | + $events = empty($events) |
|
| 215 | + ? EEM_Event::instance()->get_upcoming_events(array( |
|
| 216 | + 'limit' => 1, |
|
| 217 | + 'order_by' => array('Datetime.DTT_EVT_start' => 'ASC') |
|
| 218 | + )) |
|
| 219 | + : $events; |
|
| 220 | + $event = reset($events); |
|
| 221 | + if ($event instanceof EE_Event) { |
|
| 222 | + $this->query_params[0]['Registration.EVT_ID'] = $event->ID(); |
|
| 223 | + return $event; |
|
| 224 | + } |
|
| 225 | + return null; |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + |
|
| 229 | + |
|
| 230 | + /** |
|
| 231 | + * @param array $attributes |
|
| 232 | + * @return EE_Datetime|null |
|
| 233 | + */ |
|
| 234 | + private function getDatetimeAndQueryParams(array $attributes) |
|
| 235 | + { |
|
| 236 | + if ( ! empty($attributes['datetime_id'])) { |
|
| 237 | + $datetime = EEM_Datetime::instance()->get_one_by_ID($attributes['datetime_id']); |
|
| 238 | + if ($datetime instanceof EE_Datetime) { |
|
| 239 | + $this->query_params[0]['Registration.Ticket.Datetime.DTT_ID'] = $attributes['datetime_id']; |
|
| 240 | + $this->query_params['default_where_conditions'] = 'this_model_only'; |
|
| 241 | + if ( ! $this->template_args['event'] instanceof EE_Event) { |
|
| 242 | + $this->template_args['event'] = $datetime->event(); |
|
| 243 | + } |
|
| 244 | + return $datetime; |
|
| 245 | + } |
|
| 246 | + } |
|
| 247 | + return null; |
|
| 248 | + } |
|
| 249 | + |
|
| 250 | + |
|
| 251 | + |
|
| 252 | + /** |
|
| 253 | + * @param array $attributes |
|
| 254 | + * @return \EE_Base_Class|null |
|
| 255 | + * @throws EE_Error |
|
| 256 | + */ |
|
| 257 | + private function getTicketAndQueryParams(array $attributes) |
|
| 258 | + { |
|
| 259 | + if ( ! empty($attributes['ticket_id']) && empty($attributes['event_id']) && empty($attributes['datetime_id'])) { |
|
| 260 | + $ticket = EEM_Ticket::instance()->get_one_by_ID($attributes['ticket_id']); |
|
| 261 | + if ($ticket instanceof EE_Ticket) { |
|
| 262 | + $this->query_params[0]['Registration.TKT_ID'] = $attributes['ticket_id']; |
|
| 263 | + if ( ! $this->template_args['event'] instanceof EE_Event) { |
|
| 264 | + $this->template_args['event'] = $ticket->first_datetime() instanceof EE_Datetime |
|
| 265 | + ? $ticket->first_datetime()->event() |
|
| 266 | + : null; |
|
| 267 | + } |
|
| 268 | + return $ticket; |
|
| 269 | + } |
|
| 270 | + } |
|
| 271 | + return null; |
|
| 272 | + } |
|
| 273 | + |
|
| 274 | + |
|
| 275 | + |
|
| 276 | + /** |
|
| 277 | + * @param array $attributes |
|
| 278 | + * @throws EE_Error |
|
| 279 | + */ |
|
| 280 | + private function setAdditionalQueryParams(array $attributes) |
|
| 281 | + { |
|
| 282 | + $reg_status_array = EEM_Registration::reg_status_array(); |
|
| 283 | + if ($attributes['status'] !== 'all' && isset($reg_status_array[$attributes['status']])) { |
|
| 284 | + $this->query_params[0]['Registration.STS_ID'] = $attributes['status']; |
|
| 285 | + } |
|
| 286 | + $this->query_params['group_by'] = array('ATT_ID'); |
|
| 287 | + $this->query_params['order_by'] = (array) apply_filters( |
|
| 288 | + 'FHEE__EES_Espresso_Event_Attendees__process_shortcode__order_by', |
|
| 289 | + array('ATT_lname' => 'ASC', 'ATT_fname' => 'ASC') |
|
| 290 | + ); |
|
| 291 | + } |
|
| 292 | 292 | |
| 293 | 293 | |
| 294 | 294 | |
@@ -116,11 +116,11 @@ discard block |
||
| 116 | 116 | public function processShortcode($attributes = array()) |
| 117 | 117 | { |
| 118 | 118 | // grab attributes and merge with defaults |
| 119 | - $attributes = $this->getAttributes((array)$attributes); |
|
| 119 | + $attributes = $this->getAttributes((array) $attributes); |
|
| 120 | 120 | $archive = is_archive(); |
| 121 | 121 | $display_on_archives = filter_var($attributes['display_on_archives'], FILTER_VALIDATE_BOOLEAN); |
| 122 | 122 | // don't display on archives unless 'display_on_archives' is true |
| 123 | - if($archive && ! $display_on_archives) { |
|
| 123 | + if ($archive && ! $display_on_archives) { |
|
| 124 | 124 | return ''; |
| 125 | 125 | } |
| 126 | 126 | // add attributes to template args |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | * @return EE_Event|null |
| 190 | 190 | * @throws EE_Error |
| 191 | 191 | */ |
| 192 | - private function getEventAndQueryParams(array $attributes){ |
|
| 192 | + private function getEventAndQueryParams(array $attributes) { |
|
| 193 | 193 | if ( ! empty($attributes['event_id'])) { |
| 194 | 194 | $event = EEM_Event::instance()->get_one_by_ID($attributes['event_id']); |
| 195 | 195 | if ($event instanceof EE_Event) { |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php use EventEspresso\core\interfaces\InterminableInterface; |
| 2 | 2 | |
| 3 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');} |
|
| 3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); } |
|
| 4 | 4 | /** |
| 5 | 5 | * class EE_Request_Handler |
| 6 | 6 | * |
@@ -51,13 +51,13 @@ discard block |
||
| 51 | 51 | * @access public |
| 52 | 52 | * @param EE_Request $request |
| 53 | 53 | */ |
| 54 | - public function __construct( EE_Request $request ) { |
|
| 54 | + public function __construct(EE_Request $request) { |
|
| 55 | 55 | // grab request vars |
| 56 | 56 | $this->_params = $request->params(); |
| 57 | 57 | // AJAX ??? |
| 58 | - $this->ajax = defined( 'DOING_AJAX' ) && DOING_AJAX ? true : false; |
|
| 59 | - $this->front_ajax = defined( 'EE_FRONT_AJAX' ) && EE_FRONT_AJAX ? true : false; |
|
| 60 | - do_action( 'AHEE__EE_Request_Handler__construct__complete' ); |
|
| 58 | + $this->ajax = defined('DOING_AJAX') && DOING_AJAX ? true : false; |
|
| 59 | + $this->front_ajax = defined('EE_FRONT_AJAX') && EE_FRONT_AJAX ? true : false; |
|
| 60 | + do_action('AHEE__EE_Request_Handler__construct__complete'); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | |
@@ -69,12 +69,12 @@ discard block |
||
| 69 | 69 | * @param WP $wp |
| 70 | 70 | * @return void |
| 71 | 71 | */ |
| 72 | - public function parse_request( $wp = null ) { |
|
| 72 | + public function parse_request($wp = null) { |
|
| 73 | 73 | //if somebody forgot to provide us with WP, that's ok because its global |
| 74 | - if ( ! $wp instanceof WP ) { |
|
| 74 | + if ( ! $wp instanceof WP) { |
|
| 75 | 75 | global $wp; |
| 76 | 76 | } |
| 77 | - $this->set_request_vars( $wp ); |
|
| 77 | + $this->set_request_vars($wp); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | |
@@ -86,14 +86,14 @@ discard block |
||
| 86 | 86 | * @param WP $wp |
| 87 | 87 | * @return void |
| 88 | 88 | */ |
| 89 | - public function set_request_vars( $wp = null ) { |
|
| 90 | - if ( ! is_admin() ) { |
|
| 89 | + public function set_request_vars($wp = null) { |
|
| 90 | + if ( ! is_admin()) { |
|
| 91 | 91 | // set request post_id |
| 92 | - $this->set( 'post_id', $this->get_post_id_from_request( $wp )); |
|
| 92 | + $this->set('post_id', $this->get_post_id_from_request($wp)); |
|
| 93 | 93 | // set request post name |
| 94 | - $this->set( 'post_name', $this->get_post_name_from_request( $wp )); |
|
| 94 | + $this->set('post_name', $this->get_post_name_from_request($wp)); |
|
| 95 | 95 | // set request post_type |
| 96 | - $this->set( 'post_type', $this->get_post_type_from_request( $wp )); |
|
| 96 | + $this->set('post_type', $this->get_post_type_from_request($wp)); |
|
| 97 | 97 | // true or false ? is this page being used by EE ? |
| 98 | 98 | $this->set_espresso_page(); |
| 99 | 99 | } |
@@ -108,19 +108,19 @@ discard block |
||
| 108 | 108 | * @param WP $wp |
| 109 | 109 | * @return int |
| 110 | 110 | */ |
| 111 | - public function get_post_id_from_request( $wp = null ) { |
|
| 112 | - if ( ! $wp instanceof WP ){ |
|
| 111 | + public function get_post_id_from_request($wp = null) { |
|
| 112 | + if ( ! $wp instanceof WP) { |
|
| 113 | 113 | global $wp; |
| 114 | 114 | } |
| 115 | 115 | $post_id = null; |
| 116 | - if ( isset( $wp->query_vars['p'] )) { |
|
| 116 | + if (isset($wp->query_vars['p'])) { |
|
| 117 | 117 | $post_id = $wp->query_vars['p']; |
| 118 | 118 | } |
| 119 | - if ( ! $post_id && isset( $wp->query_vars['page_id'] )) { |
|
| 119 | + if ( ! $post_id && isset($wp->query_vars['page_id'])) { |
|
| 120 | 120 | $post_id = $wp->query_vars['page_id']; |
| 121 | 121 | } |
| 122 | - if ( ! $post_id && isset( $wp->request ) && is_numeric( basename( $wp->request ))) { |
|
| 123 | - $post_id = basename( $wp->request ); |
|
| 122 | + if ( ! $post_id && isset($wp->request) && is_numeric(basename($wp->request))) { |
|
| 123 | + $post_id = basename($wp->request); |
|
| 124 | 124 | } |
| 125 | 125 | return $post_id; |
| 126 | 126 | } |
@@ -134,35 +134,35 @@ discard block |
||
| 134 | 134 | * @param WP $wp |
| 135 | 135 | * @return string |
| 136 | 136 | */ |
| 137 | - public function get_post_name_from_request( $wp = null ) { |
|
| 138 | - if ( ! $wp instanceof WP ){ |
|
| 137 | + public function get_post_name_from_request($wp = null) { |
|
| 138 | + if ( ! $wp instanceof WP) { |
|
| 139 | 139 | global $wp; |
| 140 | 140 | } |
| 141 | 141 | $post_name = null; |
| 142 | - if ( isset( $wp->query_vars['name'] ) && ! empty( $wp->query_vars['name'] )) { |
|
| 142 | + if (isset($wp->query_vars['name']) && ! empty($wp->query_vars['name'])) { |
|
| 143 | 143 | $post_name = $wp->query_vars['name']; |
| 144 | 144 | } |
| 145 | - if ( ! $post_name && isset( $wp->query_vars['pagename'] ) && ! empty( $wp->query_vars['pagename'] )) { |
|
| 145 | + if ( ! $post_name && isset($wp->query_vars['pagename']) && ! empty($wp->query_vars['pagename'])) { |
|
| 146 | 146 | $post_name = $wp->query_vars['pagename']; |
| 147 | 147 | } |
| 148 | - if ( ! $post_name && isset( $wp->request ) && ! empty( $wp->request )) { |
|
| 149 | - $possible_post_name = basename( $wp->request ); |
|
| 150 | - if ( ! is_numeric( $possible_post_name )) { |
|
| 148 | + if ( ! $post_name && isset($wp->request) && ! empty($wp->request)) { |
|
| 149 | + $possible_post_name = basename($wp->request); |
|
| 150 | + if ( ! is_numeric($possible_post_name)) { |
|
| 151 | 151 | /** @type WPDB $wpdb */ |
| 152 | 152 | global $wpdb; |
| 153 | 153 | $SQL = "SELECT ID from {$wpdb->posts} WHERE post_status NOT IN ('auto-draft', 'inherit', 'trash') AND post_name=%s"; |
| 154 | - $possible_post_name = $wpdb->get_var( $wpdb->prepare( $SQL, $possible_post_name )); |
|
| 155 | - if ( $possible_post_name ) { |
|
| 154 | + $possible_post_name = $wpdb->get_var($wpdb->prepare($SQL, $possible_post_name)); |
|
| 155 | + if ($possible_post_name) { |
|
| 156 | 156 | $post_name = $possible_post_name; |
| 157 | 157 | } |
| 158 | 158 | } |
| 159 | 159 | } |
| 160 | - if ( ! $post_name && $this->get( 'post_id' )) { |
|
| 160 | + if ( ! $post_name && $this->get('post_id')) { |
|
| 161 | 161 | /** @type WPDB $wpdb */ |
| 162 | 162 | global $wpdb; |
| 163 | 163 | $SQL = "SELECT post_name from {$wpdb->posts} WHERE post_status NOT IN ('auto-draft', 'inherit', 'trash') AND ID=%d"; |
| 164 | - $possible_post_name = $wpdb->get_var( $wpdb->prepare( $SQL, $this->get( 'post_id' ))); |
|
| 165 | - if( $possible_post_name ) { |
|
| 164 | + $possible_post_name = $wpdb->get_var($wpdb->prepare($SQL, $this->get('post_id'))); |
|
| 165 | + if ($possible_post_name) { |
|
| 166 | 166 | $post_name = $possible_post_name; |
| 167 | 167 | } |
| 168 | 168 | } |
@@ -178,11 +178,11 @@ discard block |
||
| 178 | 178 | * @param WP $wp |
| 179 | 179 | * @return mixed |
| 180 | 180 | */ |
| 181 | - public function get_post_type_from_request( $wp = null ) { |
|
| 182 | - if ( ! $wp instanceof WP ){ |
|
| 181 | + public function get_post_type_from_request($wp = null) { |
|
| 182 | + if ( ! $wp instanceof WP) { |
|
| 183 | 183 | global $wp; |
| 184 | 184 | } |
| 185 | - return isset( $wp->query_vars['post_type'] ) ? $wp->query_vars['post_type'] : null; |
|
| 185 | + return isset($wp->query_vars['post_type']) ? $wp->query_vars['post_type'] : null; |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | |
@@ -192,18 +192,18 @@ discard block |
||
| 192 | 192 | * @param WP $wp |
| 193 | 193 | * @return string |
| 194 | 194 | */ |
| 195 | - public function get_current_page_permalink( $wp = null ) { |
|
| 196 | - $post_id = $this->get_post_id_from_request( $wp ); |
|
| 197 | - if ( $post_id ) { |
|
| 198 | - $current_page_permalink = get_permalink( $post_id ); |
|
| 195 | + public function get_current_page_permalink($wp = null) { |
|
| 196 | + $post_id = $this->get_post_id_from_request($wp); |
|
| 197 | + if ($post_id) { |
|
| 198 | + $current_page_permalink = get_permalink($post_id); |
|
| 199 | 199 | } else { |
| 200 | - if ( ! $wp instanceof WP ) { |
|
| 200 | + if ( ! $wp instanceof WP) { |
|
| 201 | 201 | global $wp; |
| 202 | 202 | } |
| 203 | - if ( $wp->request ) { |
|
| 204 | - $current_page_permalink = site_url( $wp->request ); |
|
| 203 | + if ($wp->request) { |
|
| 204 | + $current_page_permalink = site_url($wp->request); |
|
| 205 | 205 | } else { |
| 206 | - $current_page_permalink = esc_url( site_url( $_SERVER[ 'REQUEST_URI' ] ) ); |
|
| 206 | + $current_page_permalink = esc_url(site_url($_SERVER['REQUEST_URI'])); |
|
| 207 | 207 | } |
| 208 | 208 | } |
| 209 | 209 | return $current_page_permalink; |
@@ -220,31 +220,31 @@ discard block |
||
| 220 | 220 | public function test_for_espresso_page() { |
| 221 | 221 | global $wp; |
| 222 | 222 | /** @type EE_CPT_Strategy $EE_CPT_Strategy */ |
| 223 | - $EE_CPT_Strategy = EE_Registry::instance()->load_core( 'CPT_Strategy' ); |
|
| 223 | + $EE_CPT_Strategy = EE_Registry::instance()->load_core('CPT_Strategy'); |
|
| 224 | 224 | $espresso_CPT_taxonomies = $EE_CPT_Strategy->get_CPT_taxonomies(); |
| 225 | - if ( is_array( $espresso_CPT_taxonomies ) ) { |
|
| 226 | - foreach ( $espresso_CPT_taxonomies as $espresso_CPT_taxonomy =>$details ) { |
|
| 227 | - if ( isset( $wp->query_vars, $wp->query_vars[ $espresso_CPT_taxonomy ] ) ) { |
|
| 225 | + if (is_array($espresso_CPT_taxonomies)) { |
|
| 226 | + foreach ($espresso_CPT_taxonomies as $espresso_CPT_taxonomy =>$details) { |
|
| 227 | + if (isset($wp->query_vars, $wp->query_vars[$espresso_CPT_taxonomy])) { |
|
| 228 | 228 | return true; |
| 229 | 229 | } |
| 230 | 230 | } |
| 231 | 231 | } |
| 232 | 232 | // load espresso CPT endpoints |
| 233 | 233 | $espresso_CPT_endpoints = $EE_CPT_Strategy->get_CPT_endpoints(); |
| 234 | - $post_type_CPT_endpoints = array_flip( $espresso_CPT_endpoints ); |
|
| 235 | - $post_types = (array)$this->get( 'post_type' ); |
|
| 236 | - foreach ( $post_types as $post_type ) { |
|
| 234 | + $post_type_CPT_endpoints = array_flip($espresso_CPT_endpoints); |
|
| 235 | + $post_types = (array) $this->get('post_type'); |
|
| 236 | + foreach ($post_types as $post_type) { |
|
| 237 | 237 | // was a post name passed ? |
| 238 | - if ( isset( $post_type_CPT_endpoints[ $post_type ] ) ) { |
|
| 238 | + if (isset($post_type_CPT_endpoints[$post_type])) { |
|
| 239 | 239 | // kk we know this is an espresso page, but is it a specific post ? |
| 240 | - if ( ! $this->get( 'post_name' ) ) { |
|
| 240 | + if ( ! $this->get('post_name')) { |
|
| 241 | 241 | // there's no specific post name set, so maybe it's one of our endpoints like www.domain.com/events |
| 242 | - $post_name = isset( $post_type_CPT_endpoints[ $this->get( 'post_type' ) ] ) |
|
| 243 | - ? $post_type_CPT_endpoints[ $this->get( 'post_type' ) ] |
|
| 242 | + $post_name = isset($post_type_CPT_endpoints[$this->get('post_type')]) |
|
| 243 | + ? $post_type_CPT_endpoints[$this->get('post_type')] |
|
| 244 | 244 | : ''; |
| 245 | 245 | // if the post type matches on of our then set the endpoint |
| 246 | - if ( $post_name ) { |
|
| 247 | - $this->set( 'post_name', $post_name ); |
|
| 246 | + if ($post_name) { |
|
| 247 | + $this->set('post_name', $post_name); |
|
| 248 | 248 | } |
| 249 | 249 | } |
| 250 | 250 | return true; |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | * @param null|bool $value |
| 263 | 263 | * @return void |
| 264 | 264 | */ |
| 265 | - public function set_espresso_page( $value = null ) { |
|
| 265 | + public function set_espresso_page($value = null) { |
|
| 266 | 266 | $this->_params['is_espresso_page'] = ! empty($value) ? $value : $this->test_for_espresso_page(); |
| 267 | 267 | } |
| 268 | 268 | |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | * @return mixed |
| 276 | 276 | */ |
| 277 | 277 | public function is_espresso_page() { |
| 278 | - return isset( $this->_params['is_espresso_page'] ) ? $this->_params['is_espresso_page'] : false; |
|
| 278 | + return isset($this->_params['is_espresso_page']) ? $this->_params['is_espresso_page'] : false; |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | |
@@ -299,14 +299,14 @@ discard block |
||
| 299 | 299 | * @param bool $override_ee |
| 300 | 300 | * @return void |
| 301 | 301 | */ |
| 302 | - public function set( $key, $value, $override_ee = false ) { |
|
| 302 | + public function set($key, $value, $override_ee = false) { |
|
| 303 | 303 | // don't allow "ee" to be overwritten unless explicitly instructed to do so |
| 304 | 304 | if ( |
| 305 | 305 | $key !== 'ee' || |
| 306 | - ( $key === 'ee' && empty( $this->_params['ee'] )) |
|
| 307 | - || ( $key === 'ee' && ! empty( $this->_params['ee'] ) && $override_ee ) |
|
| 306 | + ($key === 'ee' && empty($this->_params['ee'])) |
|
| 307 | + || ($key === 'ee' && ! empty($this->_params['ee']) && $override_ee) |
|
| 308 | 308 | ) { |
| 309 | - $this->_params[ $key ] = $value; |
|
| 309 | + $this->_params[$key] = $value; |
|
| 310 | 310 | } |
| 311 | 311 | } |
| 312 | 312 | |
@@ -320,8 +320,8 @@ discard block |
||
| 320 | 320 | * @param null $default |
| 321 | 321 | * @return mixed |
| 322 | 322 | */ |
| 323 | - public function get( $key, $default = null ) { |
|
| 324 | - return isset( $this->_params[ $key ] ) ? $this->_params[ $key ] : $default; |
|
| 323 | + public function get($key, $default = null) { |
|
| 324 | + return isset($this->_params[$key]) ? $this->_params[$key] : $default; |
|
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | |
@@ -333,8 +333,8 @@ discard block |
||
| 333 | 333 | * @param $key |
| 334 | 334 | * @return boolean |
| 335 | 335 | */ |
| 336 | - public function is_set( $key ) { |
|
| 337 | - return isset( $this->_params[ $key ] ) ? true : false; |
|
| 336 | + public function is_set($key) { |
|
| 337 | + return isset($this->_params[$key]) ? true : false; |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | |
@@ -346,8 +346,8 @@ discard block |
||
| 346 | 346 | * @param $key |
| 347 | 347 | * @return void |
| 348 | 348 | */ |
| 349 | - public function un_set( $key ) { |
|
| 350 | - unset( $this->_params[ $key ] ); |
|
| 349 | + public function un_set($key) { |
|
| 350 | + unset($this->_params[$key]); |
|
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | |
@@ -360,8 +360,8 @@ discard block |
||
| 360 | 360 | * @param $value |
| 361 | 361 | * @return void |
| 362 | 362 | */ |
| 363 | - public function set_notice( $key, $value ) { |
|
| 364 | - $this->_notice[ $key ] = $value; |
|
| 363 | + public function set_notice($key, $value) { |
|
| 364 | + $this->_notice[$key] = $value; |
|
| 365 | 365 | } |
| 366 | 366 | |
| 367 | 367 | |
@@ -373,8 +373,8 @@ discard block |
||
| 373 | 373 | * @param $key |
| 374 | 374 | * @return mixed |
| 375 | 375 | */ |
| 376 | - public function get_notice( $key ) { |
|
| 377 | - return isset( $this->_notice[ $key ] ) ? $this->_notice[ $key ] : null; |
|
| 376 | + public function get_notice($key) { |
|
| 377 | + return isset($this->_notice[$key]) ? $this->_notice[$key] : null; |
|
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | |
@@ -386,7 +386,7 @@ discard block |
||
| 386 | 386 | * @param $string |
| 387 | 387 | * @return void |
| 388 | 388 | */ |
| 389 | - public function add_output( $string ) { |
|
| 389 | + public function add_output($string) { |
|
| 390 | 390 | $this->_output .= $string; |
| 391 | 391 | } |
| 392 | 392 | |
@@ -408,8 +408,8 @@ discard block |
||
| 408 | 408 | * @param $item |
| 409 | 409 | * @param $key |
| 410 | 410 | */ |
| 411 | - public function sanitize_text_field_for_array_walk( &$item, &$key ) { |
|
| 412 | - $item = strpos( $item, 'email' ) !== false ? sanitize_email( $item ) : sanitize_text_field( $item ); |
|
| 411 | + public function sanitize_text_field_for_array_walk(&$item, &$key) { |
|
| 412 | + $item = strpos($item, 'email') !== false ? sanitize_email($item) : sanitize_text_field($item); |
|
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | |
@@ -419,7 +419,7 @@ discard block |
||
| 419 | 419 | * @param $b |
| 420 | 420 | * @return bool |
| 421 | 421 | */ |
| 422 | - public function __set($a,$b) { return false; } |
|
| 422 | + public function __set($a, $b) { return false; } |
|
| 423 | 423 | |
| 424 | 424 | |
| 425 | 425 | |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | |
| 376 | 376 | |
| 377 | 377 | /** |
| 378 | - * @param mixed $var |
|
| 378 | + * @param string $var |
|
| 379 | 379 | * @param string $var_name |
| 380 | 380 | * @param string $file |
| 381 | 381 | * @param int|string $line |
@@ -513,7 +513,7 @@ discard block |
||
| 513 | 513 | * @param mixed $var |
| 514 | 514 | * @param string $var_name |
| 515 | 515 | * @param string $file |
| 516 | - * @param int|string $line |
|
| 516 | + * @param integer $line |
|
| 517 | 517 | * @param int $heading_tag |
| 518 | 518 | * @param bool $die |
| 519 | 519 | */ |
@@ -576,7 +576,7 @@ discard block |
||
| 576 | 576 | |
| 577 | 577 | /** |
| 578 | 578 | * @deprecated 4.9.39.rc.034 |
| 579 | - * @param null $timer_name |
|
| 579 | + * @param string $timer_name |
|
| 580 | 580 | */ |
| 581 | 581 | public function start_timer($timer_name = null) |
| 582 | 582 | { |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php use EventEspresso\core\services\Benchmark; |
| 2 | 2 | |
| 3 | 3 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
| 4 | - exit('No direct script access allowed'); |
|
| 4 | + exit('No direct script access allowed'); |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | |
@@ -17,632 +17,632 @@ discard block |
||
| 17 | 17 | class EEH_Debug_Tools |
| 18 | 18 | { |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * instance of the EEH_Autoloader object |
|
| 22 | - * |
|
| 23 | - * @var $_instance |
|
| 24 | - * @access private |
|
| 25 | - */ |
|
| 26 | - private static $_instance; |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * @var array |
|
| 30 | - */ |
|
| 31 | - protected $_memory_usage_points = array(); |
|
| 32 | - |
|
| 33 | - |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * @singleton method used to instantiate class object |
|
| 37 | - * @access public |
|
| 38 | - * @return EEH_Debug_Tools |
|
| 39 | - */ |
|
| 40 | - public static function instance() |
|
| 41 | - { |
|
| 42 | - // check if class object is instantiated, and instantiated properly |
|
| 43 | - if (! self::$_instance instanceof EEH_Debug_Tools) { |
|
| 44 | - self::$_instance = new self(); |
|
| 45 | - } |
|
| 46 | - return self::$_instance; |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * private class constructor |
|
| 53 | - */ |
|
| 54 | - private function __construct() |
|
| 55 | - { |
|
| 56 | - // load Kint PHP debugging library |
|
| 57 | - if (! class_exists('Kint') && file_exists(EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php')) { |
|
| 58 | - // despite EE4 having a check for an existing copy of the Kint debugging class, |
|
| 59 | - // if another plugin was loaded AFTER EE4 and they did NOT perform a similar check, |
|
| 60 | - // then hilarity would ensue as PHP throws a "Cannot redeclare class Kint" error |
|
| 61 | - // so we've moved it to our test folder so that it is not included with production releases |
|
| 62 | - // plz use https://wordpress.org/plugins/kint-debugger/ if testing production versions of EE |
|
| 63 | - require_once(EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php'); |
|
| 64 | - } |
|
| 65 | - // if ( ! defined('DOING_AJAX') || $_REQUEST['noheader'] !== 'true' || ! isset( $_REQUEST['noheader'], $_REQUEST['TB_iframe'] ) ) { |
|
| 66 | - //add_action( 'shutdown', array($this,'espresso_session_footer_dump') ); |
|
| 67 | - // } |
|
| 68 | - $plugin = basename(EE_PLUGIN_DIR_PATH); |
|
| 69 | - add_action("activate_{$plugin}", array('EEH_Debug_Tools', 'ee_plugin_activation_errors')); |
|
| 70 | - add_action('activated_plugin', array('EEH_Debug_Tools', 'ee_plugin_activation_errors')); |
|
| 71 | - add_action('shutdown', array('EEH_Debug_Tools', 'show_db_name')); |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * show_db_name |
|
| 78 | - * |
|
| 79 | - * @return void |
|
| 80 | - */ |
|
| 81 | - public static function show_db_name() |
|
| 82 | - { |
|
| 83 | - if (! defined('DOING_AJAX') && (defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS)) { |
|
| 84 | - echo '<p style="font-size:10px;font-weight:normal;color:#E76700;margin: 1em 2em; text-align: right;">DB_NAME: ' |
|
| 85 | - . DB_NAME |
|
| 86 | - . '</p>'; |
|
| 87 | - } |
|
| 88 | - if (EE_DEBUG) { |
|
| 89 | - Benchmark::displayResults(); |
|
| 90 | - } |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - |
|
| 94 | - |
|
| 95 | - /** |
|
| 96 | - * dump EE_Session object at bottom of page after everything else has happened |
|
| 97 | - * |
|
| 98 | - * @return void |
|
| 99 | - */ |
|
| 100 | - public function espresso_session_footer_dump() |
|
| 101 | - { |
|
| 102 | - if ( |
|
| 103 | - (defined('WP_DEBUG') && WP_DEBUG) |
|
| 104 | - && ! defined('DOING_AJAX') |
|
| 105 | - && class_exists('Kint') |
|
| 106 | - && function_exists('wp_get_current_user') |
|
| 107 | - && current_user_can('update_core') |
|
| 108 | - && class_exists('EE_Registry') |
|
| 109 | - ) { |
|
| 110 | - Kint::dump(EE_Registry::instance()->SSN->id()); |
|
| 111 | - Kint::dump(EE_Registry::instance()->SSN); |
|
| 112 | - // Kint::dump( EE_Registry::instance()->SSN->get_session_data('cart')->get_tickets() ); |
|
| 113 | - $this->espresso_list_hooked_functions(); |
|
| 114 | - Benchmark::displayResults(); |
|
| 115 | - } |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - |
|
| 119 | - |
|
| 120 | - /** |
|
| 121 | - * List All Hooked Functions |
|
| 122 | - * to list all functions for a specific hook, add ee_list_hooks={hook-name} to URL |
|
| 123 | - * http://wp.smashingmagazine.com/2009/08/18/10-useful-wordpress-hook-hacks/ |
|
| 124 | - * |
|
| 125 | - * @param string $tag |
|
| 126 | - * @return void |
|
| 127 | - */ |
|
| 128 | - public function espresso_list_hooked_functions($tag = '') |
|
| 129 | - { |
|
| 130 | - global $wp_filter; |
|
| 131 | - echo '<br/><br/><br/><h3>Hooked Functions</h3>'; |
|
| 132 | - if ($tag) { |
|
| 133 | - $hook[$tag] = $wp_filter[$tag]; |
|
| 134 | - if (! is_array($hook[$tag])) { |
|
| 135 | - trigger_error("Nothing found for '$tag' hook", E_USER_WARNING); |
|
| 136 | - return; |
|
| 137 | - } |
|
| 138 | - echo '<h5>For Tag: ' . $tag . '</h5>'; |
|
| 139 | - } else { |
|
| 140 | - $hook = is_array($wp_filter) ? $wp_filter : array($wp_filter); |
|
| 141 | - ksort($hook); |
|
| 142 | - } |
|
| 143 | - foreach ($hook as $tag_name => $priorities) { |
|
| 144 | - echo "<br />>>>>>\t<strong>$tag_name</strong><br />"; |
|
| 145 | - ksort($priorities); |
|
| 146 | - foreach ($priorities as $priority => $function) { |
|
| 147 | - echo $priority; |
|
| 148 | - foreach ($function as $name => $properties) { |
|
| 149 | - echo "\t$name<br />"; |
|
| 150 | - } |
|
| 151 | - } |
|
| 152 | - } |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - |
|
| 156 | - |
|
| 157 | - /** |
|
| 158 | - * registered_filter_callbacks |
|
| 159 | - * |
|
| 160 | - * @param string $hook_name |
|
| 161 | - * @return array |
|
| 162 | - */ |
|
| 163 | - public static function registered_filter_callbacks($hook_name = '') |
|
| 164 | - { |
|
| 165 | - $filters = array(); |
|
| 166 | - global $wp_filter; |
|
| 167 | - if (isset($wp_filter[$hook_name])) { |
|
| 168 | - $filters[$hook_name] = array(); |
|
| 169 | - foreach ($wp_filter[$hook_name] as $priority => $callbacks) { |
|
| 170 | - $filters[$hook_name][$priority] = array(); |
|
| 171 | - foreach ($callbacks as $callback) { |
|
| 172 | - $filters[$hook_name][$priority][] = $callback['function']; |
|
| 173 | - } |
|
| 174 | - } |
|
| 175 | - } |
|
| 176 | - return $filters; |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - |
|
| 180 | - |
|
| 181 | - /** |
|
| 182 | - * captures plugin activation errors for debugging |
|
| 183 | - * |
|
| 184 | - * @return void |
|
| 185 | - * @throws EE_Error |
|
| 186 | - */ |
|
| 187 | - public static function ee_plugin_activation_errors() |
|
| 188 | - { |
|
| 189 | - if (WP_DEBUG) { |
|
| 190 | - $activation_errors = ob_get_contents(); |
|
| 191 | - if (! empty($activation_errors)) { |
|
| 192 | - $activation_errors = date('Y-m-d H:i:s') . "\n" . $activation_errors; |
|
| 193 | - } |
|
| 194 | - espresso_load_required('EEH_File', EE_HELPERS . 'EEH_File.helper.php'); |
|
| 195 | - if (class_exists('EEH_File')) { |
|
| 196 | - try { |
|
| 197 | - EEH_File::ensure_file_exists_and_is_writable( |
|
| 198 | - EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html' |
|
| 199 | - ); |
|
| 200 | - EEH_File::write_to_file( |
|
| 201 | - EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html', |
|
| 202 | - $activation_errors |
|
| 203 | - ); |
|
| 204 | - } catch (EE_Error $e) { |
|
| 205 | - EE_Error::add_error( |
|
| 206 | - sprintf( |
|
| 207 | - __( |
|
| 208 | - 'The Event Espresso activation errors file could not be setup because: %s', |
|
| 209 | - 'event_espresso' |
|
| 210 | - ), |
|
| 211 | - $e->getMessage() |
|
| 212 | - ), |
|
| 213 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 214 | - ); |
|
| 215 | - } |
|
| 216 | - } else { |
|
| 217 | - // old school attempt |
|
| 218 | - file_put_contents( |
|
| 219 | - EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html', |
|
| 220 | - $activation_errors |
|
| 221 | - ); |
|
| 222 | - } |
|
| 223 | - $activation_errors = get_option('ee_plugin_activation_errors', '') . $activation_errors; |
|
| 224 | - update_option('ee_plugin_activation_errors', $activation_errors); |
|
| 225 | - } |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - |
|
| 229 | - |
|
| 230 | - /** |
|
| 231 | - * This basically mimics the WordPress _doing_it_wrong() function except adds our own messaging etc. |
|
| 232 | - * Very useful for providing helpful messages to developers when the method of doing something has been deprecated, |
|
| 233 | - * or we want to make sure they use something the right way. |
|
| 234 | - * |
|
| 235 | - * @access public |
|
| 236 | - * @param string $function The function that was called |
|
| 237 | - * @param string $message A message explaining what has been done incorrectly |
|
| 238 | - * @param string $version The version of Event Espresso where the error was added |
|
| 239 | - * @param string $applies_when a version string for when you want the doing_it_wrong notice to begin appearing |
|
| 240 | - * for a deprecated function. This allows deprecation to occur during one version, |
|
| 241 | - * but not have any notices appear until a later version. This allows developers |
|
| 242 | - * extra time to update their code before notices appear. |
|
| 243 | - * @param int $error_type |
|
| 244 | - * @uses trigger_error() |
|
| 245 | - */ |
|
| 246 | - public function doing_it_wrong( |
|
| 247 | - $function, |
|
| 248 | - $message, |
|
| 249 | - $version, |
|
| 250 | - $applies_when = '', |
|
| 251 | - $error_type = null |
|
| 252 | - ) { |
|
| 253 | - $applies_when = ! empty($applies_when) ? $applies_when : espresso_version(); |
|
| 254 | - $error_type = $error_type !== null ? $error_type : E_USER_NOTICE; |
|
| 255 | - // because we swapped the parameter order around for the last two params, |
|
| 256 | - // let's verify that some third party isn't still passing an error type value for the third param |
|
| 257 | - if (is_int($applies_when)) { |
|
| 258 | - $error_type = $applies_when; |
|
| 259 | - $applies_when = espresso_version(); |
|
| 260 | - } |
|
| 261 | - // if not displaying notices yet, then just leave |
|
| 262 | - if (version_compare(espresso_version(), $applies_when, '<')) { |
|
| 263 | - return; |
|
| 264 | - } |
|
| 265 | - do_action('AHEE__EEH_Debug_Tools__doing_it_wrong_run', $function, $message, $version); |
|
| 266 | - $version = $version === null |
|
| 267 | - ? '' |
|
| 268 | - : sprintf( |
|
| 269 | - __('(This message was added in version %s of Event Espresso)', 'event_espresso'), |
|
| 270 | - $version |
|
| 271 | - ); |
|
| 272 | - $error_message = sprintf( |
|
| 273 | - esc_html__('%1$s was called %2$sincorrectly%3$s. %4$s %5$s', 'event_espresso'), |
|
| 274 | - $function, |
|
| 275 | - '<strong>', |
|
| 276 | - '</strong>', |
|
| 277 | - $message, |
|
| 278 | - $version |
|
| 279 | - ); |
|
| 280 | - // don't trigger error if doing ajax, |
|
| 281 | - // instead we'll add a transient EE_Error notice that in theory should show on the next request. |
|
| 282 | - if (defined('DOING_AJAX') && DOING_AJAX) { |
|
| 283 | - $error_message .= ' ' . esc_html__( |
|
| 284 | - 'This is a doing_it_wrong message that was triggered during an ajax request. The request params on this request were: ', |
|
| 285 | - 'event_espresso' |
|
| 286 | - ); |
|
| 287 | - $error_message .= '<ul><li>'; |
|
| 288 | - $error_message .= implode('</li><li>', EE_Registry::instance()->REQ->params()); |
|
| 289 | - $error_message .= '</ul>'; |
|
| 290 | - EE_Error::add_error($error_message, 'debug::doing_it_wrong', $function, '42'); |
|
| 291 | - //now we set this on the transient so it shows up on the next request. |
|
| 292 | - EE_Error::get_notices(false, true); |
|
| 293 | - } else { |
|
| 294 | - trigger_error($error_message, $error_type); |
|
| 295 | - } |
|
| 296 | - } |
|
| 297 | - |
|
| 298 | - |
|
| 299 | - |
|
| 300 | - |
|
| 301 | - /** |
|
| 302 | - * Logger helpers |
|
| 303 | - */ |
|
| 304 | - /** |
|
| 305 | - * debug |
|
| 306 | - * |
|
| 307 | - * @param string $class |
|
| 308 | - * @param string $func |
|
| 309 | - * @param string $line |
|
| 310 | - * @param array $info |
|
| 311 | - * @param bool $display_request |
|
| 312 | - * @param string $debug_index |
|
| 313 | - * @param string $debug_key |
|
| 314 | - * @throws EE_Error |
|
| 315 | - * @throws \EventEspresso\core\exceptions\InvalidSessionDataException |
|
| 316 | - */ |
|
| 317 | - public static function log( |
|
| 318 | - $class = '', |
|
| 319 | - $func = '', |
|
| 320 | - $line = '', |
|
| 321 | - $info = array(), |
|
| 322 | - $display_request = false, |
|
| 323 | - $debug_index = '', |
|
| 324 | - $debug_key = 'EE_DEBUG_SPCO' |
|
| 325 | - ) { |
|
| 326 | - if (WP_DEBUG) { |
|
| 327 | - $debug_key = $debug_key . '_' . EE_Session::instance()->id(); |
|
| 328 | - $debug_data = get_option($debug_key, array()); |
|
| 329 | - $default_data = array( |
|
| 330 | - $class => $func . '() : ' . $line, |
|
| 331 | - 'REQ' => $display_request ? $_REQUEST : '', |
|
| 332 | - ); |
|
| 333 | - // don't serialize objects |
|
| 334 | - $info = self::strip_objects($info); |
|
| 335 | - $index = ! empty($debug_index) ? $debug_index : 0; |
|
| 336 | - if (! isset($debug_data[$index])) { |
|
| 337 | - $debug_data[$index] = array(); |
|
| 338 | - } |
|
| 339 | - $debug_data[$index][microtime()] = array_merge($default_data, $info); |
|
| 340 | - update_option($debug_key, $debug_data); |
|
| 341 | - } |
|
| 342 | - } |
|
| 343 | - |
|
| 344 | - |
|
| 345 | - |
|
| 346 | - /** |
|
| 347 | - * strip_objects |
|
| 348 | - * |
|
| 349 | - * @param array $info |
|
| 350 | - * @return array |
|
| 351 | - */ |
|
| 352 | - public static function strip_objects($info = array()) |
|
| 353 | - { |
|
| 354 | - foreach ($info as $key => $value) { |
|
| 355 | - if (is_array($value)) { |
|
| 356 | - $info[$key] = self::strip_objects($value); |
|
| 357 | - } else if (is_object($value)) { |
|
| 358 | - $object_class = get_class($value); |
|
| 359 | - $info[$object_class] = array(); |
|
| 360 | - $info[$object_class]['ID'] = method_exists($value, 'ID') ? $value->ID() : spl_object_hash($value); |
|
| 361 | - if (method_exists($value, 'ID')) { |
|
| 362 | - $info[$object_class]['ID'] = $value->ID(); |
|
| 363 | - } |
|
| 364 | - if (method_exists($value, 'status')) { |
|
| 365 | - $info[$object_class]['status'] = $value->status(); |
|
| 366 | - } else if (method_exists($value, 'status_ID')) { |
|
| 367 | - $info[$object_class]['status'] = $value->status_ID(); |
|
| 368 | - } |
|
| 369 | - unset($info[$key]); |
|
| 370 | - } |
|
| 371 | - } |
|
| 372 | - return (array)$info; |
|
| 373 | - } |
|
| 374 | - |
|
| 375 | - |
|
| 376 | - |
|
| 377 | - /** |
|
| 378 | - * @param mixed $var |
|
| 379 | - * @param string $var_name |
|
| 380 | - * @param string $file |
|
| 381 | - * @param int|string $line |
|
| 382 | - * @param int $heading_tag |
|
| 383 | - * @param bool $die |
|
| 384 | - * @param string $margin |
|
| 385 | - */ |
|
| 386 | - public static function printv( |
|
| 387 | - $var, |
|
| 388 | - $var_name = '', |
|
| 389 | - $file = '', |
|
| 390 | - $line = '', |
|
| 391 | - $heading_tag = 5, |
|
| 392 | - $die = false, |
|
| 393 | - $margin = '' |
|
| 394 | - ) { |
|
| 395 | - $var_name = ! $var_name ? 'string' : $var_name; |
|
| 396 | - $var_name = ucwords(str_replace('$', '', $var_name)); |
|
| 397 | - $is_method = method_exists($var_name, $var); |
|
| 398 | - $var_name = ucwords(str_replace('_', ' ', $var_name)); |
|
| 399 | - $heading_tag = is_int($heading_tag) ? "h{$heading_tag}" : 'h5'; |
|
| 400 | - $result = EEH_Debug_Tools::heading($var_name, $heading_tag, $margin); |
|
| 401 | - $result .= $is_method |
|
| 402 | - ? EEH_Debug_Tools::grey_span('::') . EEH_Debug_Tools::orange_span($var . '()') |
|
| 403 | - : EEH_Debug_Tools::grey_span(' : ') . EEH_Debug_Tools::orange_span($var); |
|
| 404 | - $result .= EEH_Debug_Tools::file_and_line($file, $line); |
|
| 405 | - $result .= EEH_Debug_Tools::headingX($heading_tag); |
|
| 406 | - if ($die) { |
|
| 407 | - die($result); |
|
| 408 | - } |
|
| 409 | - echo $result; |
|
| 410 | - } |
|
| 411 | - |
|
| 412 | - |
|
| 413 | - |
|
| 414 | - /** |
|
| 415 | - * @param string $var_name |
|
| 416 | - * @param string $heading_tag |
|
| 417 | - * @param string $margin |
|
| 418 | - * @return string |
|
| 419 | - */ |
|
| 420 | - protected static function heading($var_name = '', $heading_tag = 'h5', $margin = '') |
|
| 421 | - { |
|
| 422 | - if (defined('EE_TESTS_DIR')) { |
|
| 423 | - return "\n{$var_name}"; |
|
| 424 | - } |
|
| 425 | - $margin = "25px 0 0 {$margin}"; |
|
| 426 | - return '<' . $heading_tag . ' style="color:#2EA2CC; margin:' . $margin . ';"><b>' . $var_name . '</b>'; |
|
| 427 | - } |
|
| 428 | - |
|
| 429 | - |
|
| 430 | - |
|
| 431 | - /** |
|
| 432 | - * @param string $heading_tag |
|
| 433 | - * @return string |
|
| 434 | - */ |
|
| 435 | - protected static function headingX($heading_tag = 'h5') |
|
| 436 | - { |
|
| 437 | - if (defined('EE_TESTS_DIR')) { |
|
| 438 | - return ''; |
|
| 439 | - } |
|
| 440 | - return '</' . $heading_tag . '>'; |
|
| 441 | - } |
|
| 442 | - |
|
| 443 | - |
|
| 444 | - |
|
| 445 | - /** |
|
| 446 | - * @param string $content |
|
| 447 | - * @return string |
|
| 448 | - */ |
|
| 449 | - protected static function grey_span($content = '') |
|
| 450 | - { |
|
| 451 | - if (defined('EE_TESTS_DIR')) { |
|
| 452 | - return $content; |
|
| 453 | - } |
|
| 454 | - return '<span style="color:#999">' . $content . '</span>'; |
|
| 455 | - } |
|
| 456 | - |
|
| 457 | - |
|
| 458 | - |
|
| 459 | - /** |
|
| 460 | - * @param string $file |
|
| 461 | - * @param int $line |
|
| 462 | - * @return string |
|
| 463 | - */ |
|
| 464 | - protected static function file_and_line($file, $line) |
|
| 465 | - { |
|
| 466 | - if ($file === '' || $line === '') { |
|
| 467 | - return ''; |
|
| 468 | - } |
|
| 469 | - if (defined('EE_TESTS_DIR')) { |
|
| 470 | - return "\n (" . $file . ' line no: ' . $line . ' ) '; |
|
| 471 | - } |
|
| 472 | - return '<br /><span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;">' |
|
| 473 | - . $file |
|
| 474 | - . '<br />line no: ' |
|
| 475 | - . $line |
|
| 476 | - . '</span>'; |
|
| 477 | - } |
|
| 478 | - |
|
| 479 | - |
|
| 480 | - |
|
| 481 | - /** |
|
| 482 | - * @param string $content |
|
| 483 | - * @return string |
|
| 484 | - */ |
|
| 485 | - protected static function orange_span($content = '') |
|
| 486 | - { |
|
| 487 | - if (defined('EE_TESTS_DIR')) { |
|
| 488 | - return $content; |
|
| 489 | - } |
|
| 490 | - return '<span style="color:#E76700">' . $content . '</span>'; |
|
| 491 | - } |
|
| 492 | - |
|
| 493 | - |
|
| 494 | - |
|
| 495 | - /** |
|
| 496 | - * @param mixed $var |
|
| 497 | - * @return string |
|
| 498 | - */ |
|
| 499 | - protected static function pre_span($var) |
|
| 500 | - { |
|
| 501 | - ob_start(); |
|
| 502 | - var_dump($var); |
|
| 503 | - $var = ob_get_clean(); |
|
| 504 | - if (defined('EE_TESTS_DIR')) { |
|
| 505 | - return "\n" . $var; |
|
| 506 | - } |
|
| 507 | - return '<pre style="color:#999; padding:1em; background: #fff">' . $var . '</pre>'; |
|
| 508 | - } |
|
| 509 | - |
|
| 510 | - |
|
| 511 | - |
|
| 512 | - /** |
|
| 513 | - * @param mixed $var |
|
| 514 | - * @param string $var_name |
|
| 515 | - * @param string $file |
|
| 516 | - * @param int|string $line |
|
| 517 | - * @param int $heading_tag |
|
| 518 | - * @param bool $die |
|
| 519 | - */ |
|
| 520 | - public static function printr( |
|
| 521 | - $var, |
|
| 522 | - $var_name = '', |
|
| 523 | - $file = '', |
|
| 524 | - $line = '', |
|
| 525 | - $heading_tag = 5, |
|
| 526 | - $die = false |
|
| 527 | - ) { |
|
| 528 | - // return; |
|
| 529 | - $file = str_replace(rtrim(ABSPATH, '\\/'), '', $file); |
|
| 530 | - $margin = is_admin() ? ' 180px' : '0'; |
|
| 531 | - //$print_r = false; |
|
| 532 | - if (is_string($var)) { |
|
| 533 | - EEH_Debug_Tools::printv($var, $var_name, $file, $line, $heading_tag, $die, $margin); |
|
| 534 | - return; |
|
| 535 | - } |
|
| 536 | - if (is_object($var)) { |
|
| 537 | - $var_name = ! $var_name ? 'object' : $var_name; |
|
| 538 | - //$print_r = true; |
|
| 539 | - } else if (is_array($var)) { |
|
| 540 | - $var_name = ! $var_name ? 'array' : $var_name; |
|
| 541 | - //$print_r = true; |
|
| 542 | - } else if (is_numeric($var)) { |
|
| 543 | - $var_name = ! $var_name ? 'numeric' : $var_name; |
|
| 544 | - } else if ($var === null) { |
|
| 545 | - $var_name = ! $var_name ? 'null' : $var_name; |
|
| 546 | - } |
|
| 547 | - $var_name = ucwords(str_replace(array('$', '_'), array('', ' '), $var_name)); |
|
| 548 | - $heading_tag = is_int($heading_tag) ? "h{$heading_tag}" : 'h5'; |
|
| 549 | - $result = EEH_Debug_Tools::heading($var_name, $heading_tag, $margin); |
|
| 550 | - $result .= EEH_Debug_Tools::grey_span(' : ') . EEH_Debug_Tools::orange_span( |
|
| 551 | - EEH_Debug_Tools::pre_span($var) |
|
| 552 | - ); |
|
| 553 | - $result .= EEH_Debug_Tools::file_and_line($file, $line); |
|
| 554 | - $result .= EEH_Debug_Tools::headingX($heading_tag); |
|
| 555 | - if ($die) { |
|
| 556 | - die($result); |
|
| 557 | - } |
|
| 558 | - echo $result; |
|
| 559 | - } |
|
| 560 | - |
|
| 561 | - |
|
| 562 | - |
|
| 563 | - /******************** deprecated ********************/ |
|
| 564 | - |
|
| 565 | - |
|
| 566 | - |
|
| 567 | - /** |
|
| 568 | - * @deprecated 4.9.39.rc.034 |
|
| 569 | - */ |
|
| 570 | - public function reset_times() |
|
| 571 | - { |
|
| 572 | - Benchmark::resetTimes(); |
|
| 573 | - } |
|
| 574 | - |
|
| 575 | - |
|
| 576 | - |
|
| 577 | - /** |
|
| 578 | - * @deprecated 4.9.39.rc.034 |
|
| 579 | - * @param null $timer_name |
|
| 580 | - */ |
|
| 581 | - public function start_timer($timer_name = null) |
|
| 582 | - { |
|
| 583 | - Benchmark::startTimer($timer_name); |
|
| 584 | - } |
|
| 585 | - |
|
| 586 | - |
|
| 587 | - |
|
| 588 | - /** |
|
| 589 | - * @deprecated 4.9.39.rc.034 |
|
| 590 | - * @param string $timer_name |
|
| 591 | - */ |
|
| 592 | - public function stop_timer($timer_name = '') |
|
| 593 | - { |
|
| 594 | - Benchmark::stopTimer($timer_name); |
|
| 595 | - } |
|
| 596 | - |
|
| 597 | - |
|
| 598 | - |
|
| 599 | - /** |
|
| 600 | - * @deprecated 4.9.39.rc.034 |
|
| 601 | - * @param string $label The label to show for this time eg "Start of calling Some_Class::some_function" |
|
| 602 | - * @param boolean $output_now whether to echo now, or wait until EEH_Debug_Tools::show_times() is called |
|
| 603 | - * @return void |
|
| 604 | - */ |
|
| 605 | - public function measure_memory($label, $output_now = false) |
|
| 606 | - { |
|
| 607 | - Benchmark::measureMemory($label, $output_now); |
|
| 608 | - } |
|
| 609 | - |
|
| 610 | - |
|
| 611 | - |
|
| 612 | - /** |
|
| 613 | - * @deprecated 4.9.39.rc.034 |
|
| 614 | - * @param int $size |
|
| 615 | - * @return string |
|
| 616 | - */ |
|
| 617 | - public function convert($size) |
|
| 618 | - { |
|
| 619 | - return Benchmark::convert($size); |
|
| 620 | - } |
|
| 621 | - |
|
| 622 | - |
|
| 623 | - |
|
| 624 | - /** |
|
| 625 | - * @deprecated 4.9.39.rc.034 |
|
| 626 | - * @param bool $output_now |
|
| 627 | - * @return string |
|
| 628 | - */ |
|
| 629 | - public function show_times($output_now = true) |
|
| 630 | - { |
|
| 631 | - return Benchmark::displayResults($output_now); |
|
| 632 | - } |
|
| 633 | - |
|
| 634 | - |
|
| 635 | - |
|
| 636 | - /** |
|
| 637 | - * @deprecated 4.9.39.rc.034 |
|
| 638 | - * @param string $timer_name |
|
| 639 | - * @param float $total_time |
|
| 640 | - * @return string |
|
| 641 | - */ |
|
| 642 | - public function format_time($timer_name, $total_time) |
|
| 643 | - { |
|
| 644 | - return Benchmark::formatTime($timer_name, $total_time); |
|
| 645 | - } |
|
| 20 | + /** |
|
| 21 | + * instance of the EEH_Autoloader object |
|
| 22 | + * |
|
| 23 | + * @var $_instance |
|
| 24 | + * @access private |
|
| 25 | + */ |
|
| 26 | + private static $_instance; |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * @var array |
|
| 30 | + */ |
|
| 31 | + protected $_memory_usage_points = array(); |
|
| 32 | + |
|
| 33 | + |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * @singleton method used to instantiate class object |
|
| 37 | + * @access public |
|
| 38 | + * @return EEH_Debug_Tools |
|
| 39 | + */ |
|
| 40 | + public static function instance() |
|
| 41 | + { |
|
| 42 | + // check if class object is instantiated, and instantiated properly |
|
| 43 | + if (! self::$_instance instanceof EEH_Debug_Tools) { |
|
| 44 | + self::$_instance = new self(); |
|
| 45 | + } |
|
| 46 | + return self::$_instance; |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * private class constructor |
|
| 53 | + */ |
|
| 54 | + private function __construct() |
|
| 55 | + { |
|
| 56 | + // load Kint PHP debugging library |
|
| 57 | + if (! class_exists('Kint') && file_exists(EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php')) { |
|
| 58 | + // despite EE4 having a check for an existing copy of the Kint debugging class, |
|
| 59 | + // if another plugin was loaded AFTER EE4 and they did NOT perform a similar check, |
|
| 60 | + // then hilarity would ensue as PHP throws a "Cannot redeclare class Kint" error |
|
| 61 | + // so we've moved it to our test folder so that it is not included with production releases |
|
| 62 | + // plz use https://wordpress.org/plugins/kint-debugger/ if testing production versions of EE |
|
| 63 | + require_once(EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php'); |
|
| 64 | + } |
|
| 65 | + // if ( ! defined('DOING_AJAX') || $_REQUEST['noheader'] !== 'true' || ! isset( $_REQUEST['noheader'], $_REQUEST['TB_iframe'] ) ) { |
|
| 66 | + //add_action( 'shutdown', array($this,'espresso_session_footer_dump') ); |
|
| 67 | + // } |
|
| 68 | + $plugin = basename(EE_PLUGIN_DIR_PATH); |
|
| 69 | + add_action("activate_{$plugin}", array('EEH_Debug_Tools', 'ee_plugin_activation_errors')); |
|
| 70 | + add_action('activated_plugin', array('EEH_Debug_Tools', 'ee_plugin_activation_errors')); |
|
| 71 | + add_action('shutdown', array('EEH_Debug_Tools', 'show_db_name')); |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * show_db_name |
|
| 78 | + * |
|
| 79 | + * @return void |
|
| 80 | + */ |
|
| 81 | + public static function show_db_name() |
|
| 82 | + { |
|
| 83 | + if (! defined('DOING_AJAX') && (defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS)) { |
|
| 84 | + echo '<p style="font-size:10px;font-weight:normal;color:#E76700;margin: 1em 2em; text-align: right;">DB_NAME: ' |
|
| 85 | + . DB_NAME |
|
| 86 | + . '</p>'; |
|
| 87 | + } |
|
| 88 | + if (EE_DEBUG) { |
|
| 89 | + Benchmark::displayResults(); |
|
| 90 | + } |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + |
|
| 94 | + |
|
| 95 | + /** |
|
| 96 | + * dump EE_Session object at bottom of page after everything else has happened |
|
| 97 | + * |
|
| 98 | + * @return void |
|
| 99 | + */ |
|
| 100 | + public function espresso_session_footer_dump() |
|
| 101 | + { |
|
| 102 | + if ( |
|
| 103 | + (defined('WP_DEBUG') && WP_DEBUG) |
|
| 104 | + && ! defined('DOING_AJAX') |
|
| 105 | + && class_exists('Kint') |
|
| 106 | + && function_exists('wp_get_current_user') |
|
| 107 | + && current_user_can('update_core') |
|
| 108 | + && class_exists('EE_Registry') |
|
| 109 | + ) { |
|
| 110 | + Kint::dump(EE_Registry::instance()->SSN->id()); |
|
| 111 | + Kint::dump(EE_Registry::instance()->SSN); |
|
| 112 | + // Kint::dump( EE_Registry::instance()->SSN->get_session_data('cart')->get_tickets() ); |
|
| 113 | + $this->espresso_list_hooked_functions(); |
|
| 114 | + Benchmark::displayResults(); |
|
| 115 | + } |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + |
|
| 119 | + |
|
| 120 | + /** |
|
| 121 | + * List All Hooked Functions |
|
| 122 | + * to list all functions for a specific hook, add ee_list_hooks={hook-name} to URL |
|
| 123 | + * http://wp.smashingmagazine.com/2009/08/18/10-useful-wordpress-hook-hacks/ |
|
| 124 | + * |
|
| 125 | + * @param string $tag |
|
| 126 | + * @return void |
|
| 127 | + */ |
|
| 128 | + public function espresso_list_hooked_functions($tag = '') |
|
| 129 | + { |
|
| 130 | + global $wp_filter; |
|
| 131 | + echo '<br/><br/><br/><h3>Hooked Functions</h3>'; |
|
| 132 | + if ($tag) { |
|
| 133 | + $hook[$tag] = $wp_filter[$tag]; |
|
| 134 | + if (! is_array($hook[$tag])) { |
|
| 135 | + trigger_error("Nothing found for '$tag' hook", E_USER_WARNING); |
|
| 136 | + return; |
|
| 137 | + } |
|
| 138 | + echo '<h5>For Tag: ' . $tag . '</h5>'; |
|
| 139 | + } else { |
|
| 140 | + $hook = is_array($wp_filter) ? $wp_filter : array($wp_filter); |
|
| 141 | + ksort($hook); |
|
| 142 | + } |
|
| 143 | + foreach ($hook as $tag_name => $priorities) { |
|
| 144 | + echo "<br />>>>>>\t<strong>$tag_name</strong><br />"; |
|
| 145 | + ksort($priorities); |
|
| 146 | + foreach ($priorities as $priority => $function) { |
|
| 147 | + echo $priority; |
|
| 148 | + foreach ($function as $name => $properties) { |
|
| 149 | + echo "\t$name<br />"; |
|
| 150 | + } |
|
| 151 | + } |
|
| 152 | + } |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + |
|
| 156 | + |
|
| 157 | + /** |
|
| 158 | + * registered_filter_callbacks |
|
| 159 | + * |
|
| 160 | + * @param string $hook_name |
|
| 161 | + * @return array |
|
| 162 | + */ |
|
| 163 | + public static function registered_filter_callbacks($hook_name = '') |
|
| 164 | + { |
|
| 165 | + $filters = array(); |
|
| 166 | + global $wp_filter; |
|
| 167 | + if (isset($wp_filter[$hook_name])) { |
|
| 168 | + $filters[$hook_name] = array(); |
|
| 169 | + foreach ($wp_filter[$hook_name] as $priority => $callbacks) { |
|
| 170 | + $filters[$hook_name][$priority] = array(); |
|
| 171 | + foreach ($callbacks as $callback) { |
|
| 172 | + $filters[$hook_name][$priority][] = $callback['function']; |
|
| 173 | + } |
|
| 174 | + } |
|
| 175 | + } |
|
| 176 | + return $filters; |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + |
|
| 180 | + |
|
| 181 | + /** |
|
| 182 | + * captures plugin activation errors for debugging |
|
| 183 | + * |
|
| 184 | + * @return void |
|
| 185 | + * @throws EE_Error |
|
| 186 | + */ |
|
| 187 | + public static function ee_plugin_activation_errors() |
|
| 188 | + { |
|
| 189 | + if (WP_DEBUG) { |
|
| 190 | + $activation_errors = ob_get_contents(); |
|
| 191 | + if (! empty($activation_errors)) { |
|
| 192 | + $activation_errors = date('Y-m-d H:i:s') . "\n" . $activation_errors; |
|
| 193 | + } |
|
| 194 | + espresso_load_required('EEH_File', EE_HELPERS . 'EEH_File.helper.php'); |
|
| 195 | + if (class_exists('EEH_File')) { |
|
| 196 | + try { |
|
| 197 | + EEH_File::ensure_file_exists_and_is_writable( |
|
| 198 | + EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html' |
|
| 199 | + ); |
|
| 200 | + EEH_File::write_to_file( |
|
| 201 | + EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html', |
|
| 202 | + $activation_errors |
|
| 203 | + ); |
|
| 204 | + } catch (EE_Error $e) { |
|
| 205 | + EE_Error::add_error( |
|
| 206 | + sprintf( |
|
| 207 | + __( |
|
| 208 | + 'The Event Espresso activation errors file could not be setup because: %s', |
|
| 209 | + 'event_espresso' |
|
| 210 | + ), |
|
| 211 | + $e->getMessage() |
|
| 212 | + ), |
|
| 213 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 214 | + ); |
|
| 215 | + } |
|
| 216 | + } else { |
|
| 217 | + // old school attempt |
|
| 218 | + file_put_contents( |
|
| 219 | + EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html', |
|
| 220 | + $activation_errors |
|
| 221 | + ); |
|
| 222 | + } |
|
| 223 | + $activation_errors = get_option('ee_plugin_activation_errors', '') . $activation_errors; |
|
| 224 | + update_option('ee_plugin_activation_errors', $activation_errors); |
|
| 225 | + } |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + |
|
| 229 | + |
|
| 230 | + /** |
|
| 231 | + * This basically mimics the WordPress _doing_it_wrong() function except adds our own messaging etc. |
|
| 232 | + * Very useful for providing helpful messages to developers when the method of doing something has been deprecated, |
|
| 233 | + * or we want to make sure they use something the right way. |
|
| 234 | + * |
|
| 235 | + * @access public |
|
| 236 | + * @param string $function The function that was called |
|
| 237 | + * @param string $message A message explaining what has been done incorrectly |
|
| 238 | + * @param string $version The version of Event Espresso where the error was added |
|
| 239 | + * @param string $applies_when a version string for when you want the doing_it_wrong notice to begin appearing |
|
| 240 | + * for a deprecated function. This allows deprecation to occur during one version, |
|
| 241 | + * but not have any notices appear until a later version. This allows developers |
|
| 242 | + * extra time to update their code before notices appear. |
|
| 243 | + * @param int $error_type |
|
| 244 | + * @uses trigger_error() |
|
| 245 | + */ |
|
| 246 | + public function doing_it_wrong( |
|
| 247 | + $function, |
|
| 248 | + $message, |
|
| 249 | + $version, |
|
| 250 | + $applies_when = '', |
|
| 251 | + $error_type = null |
|
| 252 | + ) { |
|
| 253 | + $applies_when = ! empty($applies_when) ? $applies_when : espresso_version(); |
|
| 254 | + $error_type = $error_type !== null ? $error_type : E_USER_NOTICE; |
|
| 255 | + // because we swapped the parameter order around for the last two params, |
|
| 256 | + // let's verify that some third party isn't still passing an error type value for the third param |
|
| 257 | + if (is_int($applies_when)) { |
|
| 258 | + $error_type = $applies_when; |
|
| 259 | + $applies_when = espresso_version(); |
|
| 260 | + } |
|
| 261 | + // if not displaying notices yet, then just leave |
|
| 262 | + if (version_compare(espresso_version(), $applies_when, '<')) { |
|
| 263 | + return; |
|
| 264 | + } |
|
| 265 | + do_action('AHEE__EEH_Debug_Tools__doing_it_wrong_run', $function, $message, $version); |
|
| 266 | + $version = $version === null |
|
| 267 | + ? '' |
|
| 268 | + : sprintf( |
|
| 269 | + __('(This message was added in version %s of Event Espresso)', 'event_espresso'), |
|
| 270 | + $version |
|
| 271 | + ); |
|
| 272 | + $error_message = sprintf( |
|
| 273 | + esc_html__('%1$s was called %2$sincorrectly%3$s. %4$s %5$s', 'event_espresso'), |
|
| 274 | + $function, |
|
| 275 | + '<strong>', |
|
| 276 | + '</strong>', |
|
| 277 | + $message, |
|
| 278 | + $version |
|
| 279 | + ); |
|
| 280 | + // don't trigger error if doing ajax, |
|
| 281 | + // instead we'll add a transient EE_Error notice that in theory should show on the next request. |
|
| 282 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
| 283 | + $error_message .= ' ' . esc_html__( |
|
| 284 | + 'This is a doing_it_wrong message that was triggered during an ajax request. The request params on this request were: ', |
|
| 285 | + 'event_espresso' |
|
| 286 | + ); |
|
| 287 | + $error_message .= '<ul><li>'; |
|
| 288 | + $error_message .= implode('</li><li>', EE_Registry::instance()->REQ->params()); |
|
| 289 | + $error_message .= '</ul>'; |
|
| 290 | + EE_Error::add_error($error_message, 'debug::doing_it_wrong', $function, '42'); |
|
| 291 | + //now we set this on the transient so it shows up on the next request. |
|
| 292 | + EE_Error::get_notices(false, true); |
|
| 293 | + } else { |
|
| 294 | + trigger_error($error_message, $error_type); |
|
| 295 | + } |
|
| 296 | + } |
|
| 297 | + |
|
| 298 | + |
|
| 299 | + |
|
| 300 | + |
|
| 301 | + /** |
|
| 302 | + * Logger helpers |
|
| 303 | + */ |
|
| 304 | + /** |
|
| 305 | + * debug |
|
| 306 | + * |
|
| 307 | + * @param string $class |
|
| 308 | + * @param string $func |
|
| 309 | + * @param string $line |
|
| 310 | + * @param array $info |
|
| 311 | + * @param bool $display_request |
|
| 312 | + * @param string $debug_index |
|
| 313 | + * @param string $debug_key |
|
| 314 | + * @throws EE_Error |
|
| 315 | + * @throws \EventEspresso\core\exceptions\InvalidSessionDataException |
|
| 316 | + */ |
|
| 317 | + public static function log( |
|
| 318 | + $class = '', |
|
| 319 | + $func = '', |
|
| 320 | + $line = '', |
|
| 321 | + $info = array(), |
|
| 322 | + $display_request = false, |
|
| 323 | + $debug_index = '', |
|
| 324 | + $debug_key = 'EE_DEBUG_SPCO' |
|
| 325 | + ) { |
|
| 326 | + if (WP_DEBUG) { |
|
| 327 | + $debug_key = $debug_key . '_' . EE_Session::instance()->id(); |
|
| 328 | + $debug_data = get_option($debug_key, array()); |
|
| 329 | + $default_data = array( |
|
| 330 | + $class => $func . '() : ' . $line, |
|
| 331 | + 'REQ' => $display_request ? $_REQUEST : '', |
|
| 332 | + ); |
|
| 333 | + // don't serialize objects |
|
| 334 | + $info = self::strip_objects($info); |
|
| 335 | + $index = ! empty($debug_index) ? $debug_index : 0; |
|
| 336 | + if (! isset($debug_data[$index])) { |
|
| 337 | + $debug_data[$index] = array(); |
|
| 338 | + } |
|
| 339 | + $debug_data[$index][microtime()] = array_merge($default_data, $info); |
|
| 340 | + update_option($debug_key, $debug_data); |
|
| 341 | + } |
|
| 342 | + } |
|
| 343 | + |
|
| 344 | + |
|
| 345 | + |
|
| 346 | + /** |
|
| 347 | + * strip_objects |
|
| 348 | + * |
|
| 349 | + * @param array $info |
|
| 350 | + * @return array |
|
| 351 | + */ |
|
| 352 | + public static function strip_objects($info = array()) |
|
| 353 | + { |
|
| 354 | + foreach ($info as $key => $value) { |
|
| 355 | + if (is_array($value)) { |
|
| 356 | + $info[$key] = self::strip_objects($value); |
|
| 357 | + } else if (is_object($value)) { |
|
| 358 | + $object_class = get_class($value); |
|
| 359 | + $info[$object_class] = array(); |
|
| 360 | + $info[$object_class]['ID'] = method_exists($value, 'ID') ? $value->ID() : spl_object_hash($value); |
|
| 361 | + if (method_exists($value, 'ID')) { |
|
| 362 | + $info[$object_class]['ID'] = $value->ID(); |
|
| 363 | + } |
|
| 364 | + if (method_exists($value, 'status')) { |
|
| 365 | + $info[$object_class]['status'] = $value->status(); |
|
| 366 | + } else if (method_exists($value, 'status_ID')) { |
|
| 367 | + $info[$object_class]['status'] = $value->status_ID(); |
|
| 368 | + } |
|
| 369 | + unset($info[$key]); |
|
| 370 | + } |
|
| 371 | + } |
|
| 372 | + return (array)$info; |
|
| 373 | + } |
|
| 374 | + |
|
| 375 | + |
|
| 376 | + |
|
| 377 | + /** |
|
| 378 | + * @param mixed $var |
|
| 379 | + * @param string $var_name |
|
| 380 | + * @param string $file |
|
| 381 | + * @param int|string $line |
|
| 382 | + * @param int $heading_tag |
|
| 383 | + * @param bool $die |
|
| 384 | + * @param string $margin |
|
| 385 | + */ |
|
| 386 | + public static function printv( |
|
| 387 | + $var, |
|
| 388 | + $var_name = '', |
|
| 389 | + $file = '', |
|
| 390 | + $line = '', |
|
| 391 | + $heading_tag = 5, |
|
| 392 | + $die = false, |
|
| 393 | + $margin = '' |
|
| 394 | + ) { |
|
| 395 | + $var_name = ! $var_name ? 'string' : $var_name; |
|
| 396 | + $var_name = ucwords(str_replace('$', '', $var_name)); |
|
| 397 | + $is_method = method_exists($var_name, $var); |
|
| 398 | + $var_name = ucwords(str_replace('_', ' ', $var_name)); |
|
| 399 | + $heading_tag = is_int($heading_tag) ? "h{$heading_tag}" : 'h5'; |
|
| 400 | + $result = EEH_Debug_Tools::heading($var_name, $heading_tag, $margin); |
|
| 401 | + $result .= $is_method |
|
| 402 | + ? EEH_Debug_Tools::grey_span('::') . EEH_Debug_Tools::orange_span($var . '()') |
|
| 403 | + : EEH_Debug_Tools::grey_span(' : ') . EEH_Debug_Tools::orange_span($var); |
|
| 404 | + $result .= EEH_Debug_Tools::file_and_line($file, $line); |
|
| 405 | + $result .= EEH_Debug_Tools::headingX($heading_tag); |
|
| 406 | + if ($die) { |
|
| 407 | + die($result); |
|
| 408 | + } |
|
| 409 | + echo $result; |
|
| 410 | + } |
|
| 411 | + |
|
| 412 | + |
|
| 413 | + |
|
| 414 | + /** |
|
| 415 | + * @param string $var_name |
|
| 416 | + * @param string $heading_tag |
|
| 417 | + * @param string $margin |
|
| 418 | + * @return string |
|
| 419 | + */ |
|
| 420 | + protected static function heading($var_name = '', $heading_tag = 'h5', $margin = '') |
|
| 421 | + { |
|
| 422 | + if (defined('EE_TESTS_DIR')) { |
|
| 423 | + return "\n{$var_name}"; |
|
| 424 | + } |
|
| 425 | + $margin = "25px 0 0 {$margin}"; |
|
| 426 | + return '<' . $heading_tag . ' style="color:#2EA2CC; margin:' . $margin . ';"><b>' . $var_name . '</b>'; |
|
| 427 | + } |
|
| 428 | + |
|
| 429 | + |
|
| 430 | + |
|
| 431 | + /** |
|
| 432 | + * @param string $heading_tag |
|
| 433 | + * @return string |
|
| 434 | + */ |
|
| 435 | + protected static function headingX($heading_tag = 'h5') |
|
| 436 | + { |
|
| 437 | + if (defined('EE_TESTS_DIR')) { |
|
| 438 | + return ''; |
|
| 439 | + } |
|
| 440 | + return '</' . $heading_tag . '>'; |
|
| 441 | + } |
|
| 442 | + |
|
| 443 | + |
|
| 444 | + |
|
| 445 | + /** |
|
| 446 | + * @param string $content |
|
| 447 | + * @return string |
|
| 448 | + */ |
|
| 449 | + protected static function grey_span($content = '') |
|
| 450 | + { |
|
| 451 | + if (defined('EE_TESTS_DIR')) { |
|
| 452 | + return $content; |
|
| 453 | + } |
|
| 454 | + return '<span style="color:#999">' . $content . '</span>'; |
|
| 455 | + } |
|
| 456 | + |
|
| 457 | + |
|
| 458 | + |
|
| 459 | + /** |
|
| 460 | + * @param string $file |
|
| 461 | + * @param int $line |
|
| 462 | + * @return string |
|
| 463 | + */ |
|
| 464 | + protected static function file_and_line($file, $line) |
|
| 465 | + { |
|
| 466 | + if ($file === '' || $line === '') { |
|
| 467 | + return ''; |
|
| 468 | + } |
|
| 469 | + if (defined('EE_TESTS_DIR')) { |
|
| 470 | + return "\n (" . $file . ' line no: ' . $line . ' ) '; |
|
| 471 | + } |
|
| 472 | + return '<br /><span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;">' |
|
| 473 | + . $file |
|
| 474 | + . '<br />line no: ' |
|
| 475 | + . $line |
|
| 476 | + . '</span>'; |
|
| 477 | + } |
|
| 478 | + |
|
| 479 | + |
|
| 480 | + |
|
| 481 | + /** |
|
| 482 | + * @param string $content |
|
| 483 | + * @return string |
|
| 484 | + */ |
|
| 485 | + protected static function orange_span($content = '') |
|
| 486 | + { |
|
| 487 | + if (defined('EE_TESTS_DIR')) { |
|
| 488 | + return $content; |
|
| 489 | + } |
|
| 490 | + return '<span style="color:#E76700">' . $content . '</span>'; |
|
| 491 | + } |
|
| 492 | + |
|
| 493 | + |
|
| 494 | + |
|
| 495 | + /** |
|
| 496 | + * @param mixed $var |
|
| 497 | + * @return string |
|
| 498 | + */ |
|
| 499 | + protected static function pre_span($var) |
|
| 500 | + { |
|
| 501 | + ob_start(); |
|
| 502 | + var_dump($var); |
|
| 503 | + $var = ob_get_clean(); |
|
| 504 | + if (defined('EE_TESTS_DIR')) { |
|
| 505 | + return "\n" . $var; |
|
| 506 | + } |
|
| 507 | + return '<pre style="color:#999; padding:1em; background: #fff">' . $var . '</pre>'; |
|
| 508 | + } |
|
| 509 | + |
|
| 510 | + |
|
| 511 | + |
|
| 512 | + /** |
|
| 513 | + * @param mixed $var |
|
| 514 | + * @param string $var_name |
|
| 515 | + * @param string $file |
|
| 516 | + * @param int|string $line |
|
| 517 | + * @param int $heading_tag |
|
| 518 | + * @param bool $die |
|
| 519 | + */ |
|
| 520 | + public static function printr( |
|
| 521 | + $var, |
|
| 522 | + $var_name = '', |
|
| 523 | + $file = '', |
|
| 524 | + $line = '', |
|
| 525 | + $heading_tag = 5, |
|
| 526 | + $die = false |
|
| 527 | + ) { |
|
| 528 | + // return; |
|
| 529 | + $file = str_replace(rtrim(ABSPATH, '\\/'), '', $file); |
|
| 530 | + $margin = is_admin() ? ' 180px' : '0'; |
|
| 531 | + //$print_r = false; |
|
| 532 | + if (is_string($var)) { |
|
| 533 | + EEH_Debug_Tools::printv($var, $var_name, $file, $line, $heading_tag, $die, $margin); |
|
| 534 | + return; |
|
| 535 | + } |
|
| 536 | + if (is_object($var)) { |
|
| 537 | + $var_name = ! $var_name ? 'object' : $var_name; |
|
| 538 | + //$print_r = true; |
|
| 539 | + } else if (is_array($var)) { |
|
| 540 | + $var_name = ! $var_name ? 'array' : $var_name; |
|
| 541 | + //$print_r = true; |
|
| 542 | + } else if (is_numeric($var)) { |
|
| 543 | + $var_name = ! $var_name ? 'numeric' : $var_name; |
|
| 544 | + } else if ($var === null) { |
|
| 545 | + $var_name = ! $var_name ? 'null' : $var_name; |
|
| 546 | + } |
|
| 547 | + $var_name = ucwords(str_replace(array('$', '_'), array('', ' '), $var_name)); |
|
| 548 | + $heading_tag = is_int($heading_tag) ? "h{$heading_tag}" : 'h5'; |
|
| 549 | + $result = EEH_Debug_Tools::heading($var_name, $heading_tag, $margin); |
|
| 550 | + $result .= EEH_Debug_Tools::grey_span(' : ') . EEH_Debug_Tools::orange_span( |
|
| 551 | + EEH_Debug_Tools::pre_span($var) |
|
| 552 | + ); |
|
| 553 | + $result .= EEH_Debug_Tools::file_and_line($file, $line); |
|
| 554 | + $result .= EEH_Debug_Tools::headingX($heading_tag); |
|
| 555 | + if ($die) { |
|
| 556 | + die($result); |
|
| 557 | + } |
|
| 558 | + echo $result; |
|
| 559 | + } |
|
| 560 | + |
|
| 561 | + |
|
| 562 | + |
|
| 563 | + /******************** deprecated ********************/ |
|
| 564 | + |
|
| 565 | + |
|
| 566 | + |
|
| 567 | + /** |
|
| 568 | + * @deprecated 4.9.39.rc.034 |
|
| 569 | + */ |
|
| 570 | + public function reset_times() |
|
| 571 | + { |
|
| 572 | + Benchmark::resetTimes(); |
|
| 573 | + } |
|
| 574 | + |
|
| 575 | + |
|
| 576 | + |
|
| 577 | + /** |
|
| 578 | + * @deprecated 4.9.39.rc.034 |
|
| 579 | + * @param null $timer_name |
|
| 580 | + */ |
|
| 581 | + public function start_timer($timer_name = null) |
|
| 582 | + { |
|
| 583 | + Benchmark::startTimer($timer_name); |
|
| 584 | + } |
|
| 585 | + |
|
| 586 | + |
|
| 587 | + |
|
| 588 | + /** |
|
| 589 | + * @deprecated 4.9.39.rc.034 |
|
| 590 | + * @param string $timer_name |
|
| 591 | + */ |
|
| 592 | + public function stop_timer($timer_name = '') |
|
| 593 | + { |
|
| 594 | + Benchmark::stopTimer($timer_name); |
|
| 595 | + } |
|
| 596 | + |
|
| 597 | + |
|
| 598 | + |
|
| 599 | + /** |
|
| 600 | + * @deprecated 4.9.39.rc.034 |
|
| 601 | + * @param string $label The label to show for this time eg "Start of calling Some_Class::some_function" |
|
| 602 | + * @param boolean $output_now whether to echo now, or wait until EEH_Debug_Tools::show_times() is called |
|
| 603 | + * @return void |
|
| 604 | + */ |
|
| 605 | + public function measure_memory($label, $output_now = false) |
|
| 606 | + { |
|
| 607 | + Benchmark::measureMemory($label, $output_now); |
|
| 608 | + } |
|
| 609 | + |
|
| 610 | + |
|
| 611 | + |
|
| 612 | + /** |
|
| 613 | + * @deprecated 4.9.39.rc.034 |
|
| 614 | + * @param int $size |
|
| 615 | + * @return string |
|
| 616 | + */ |
|
| 617 | + public function convert($size) |
|
| 618 | + { |
|
| 619 | + return Benchmark::convert($size); |
|
| 620 | + } |
|
| 621 | + |
|
| 622 | + |
|
| 623 | + |
|
| 624 | + /** |
|
| 625 | + * @deprecated 4.9.39.rc.034 |
|
| 626 | + * @param bool $output_now |
|
| 627 | + * @return string |
|
| 628 | + */ |
|
| 629 | + public function show_times($output_now = true) |
|
| 630 | + { |
|
| 631 | + return Benchmark::displayResults($output_now); |
|
| 632 | + } |
|
| 633 | + |
|
| 634 | + |
|
| 635 | + |
|
| 636 | + /** |
|
| 637 | + * @deprecated 4.9.39.rc.034 |
|
| 638 | + * @param string $timer_name |
|
| 639 | + * @param float $total_time |
|
| 640 | + * @return string |
|
| 641 | + */ |
|
| 642 | + public function format_time($timer_name, $total_time) |
|
| 643 | + { |
|
| 644 | + return Benchmark::formatTime($timer_name, $total_time); |
|
| 645 | + } |
|
| 646 | 646 | |
| 647 | 647 | |
| 648 | 648 | |
@@ -655,31 +655,31 @@ discard block |
||
| 655 | 655 | * Plugin URI: http://upthemes.com/plugins/kint-debugger/ |
| 656 | 656 | */ |
| 657 | 657 | if (class_exists('Kint') && ! function_exists('dump_wp_query')) { |
| 658 | - function dump_wp_query() |
|
| 659 | - { |
|
| 660 | - global $wp_query; |
|
| 661 | - d($wp_query); |
|
| 662 | - } |
|
| 658 | + function dump_wp_query() |
|
| 659 | + { |
|
| 660 | + global $wp_query; |
|
| 661 | + d($wp_query); |
|
| 662 | + } |
|
| 663 | 663 | } |
| 664 | 664 | /** |
| 665 | 665 | * borrowed from Kint Debugger |
| 666 | 666 | * Plugin URI: http://upthemes.com/plugins/kint-debugger/ |
| 667 | 667 | */ |
| 668 | 668 | if (class_exists('Kint') && ! function_exists('dump_wp')) { |
| 669 | - function dump_wp() |
|
| 670 | - { |
|
| 671 | - global $wp; |
|
| 672 | - d($wp); |
|
| 673 | - } |
|
| 669 | + function dump_wp() |
|
| 670 | + { |
|
| 671 | + global $wp; |
|
| 672 | + d($wp); |
|
| 673 | + } |
|
| 674 | 674 | } |
| 675 | 675 | /** |
| 676 | 676 | * borrowed from Kint Debugger |
| 677 | 677 | * Plugin URI: http://upthemes.com/plugins/kint-debugger/ |
| 678 | 678 | */ |
| 679 | 679 | if (class_exists('Kint') && ! function_exists('dump_post')) { |
| 680 | - function dump_post() |
|
| 681 | - { |
|
| 682 | - global $post; |
|
| 683 | - d($post); |
|
| 684 | - } |
|
| 680 | + function dump_post() |
|
| 681 | + { |
|
| 682 | + global $post; |
|
| 683 | + d($post); |
|
| 684 | + } |
|
| 685 | 685 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php use EventEspresso\core\services\Benchmark; |
| 2 | 2 | |
| 3 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 4 | 4 | exit('No direct script access allowed'); |
| 5 | 5 | } |
| 6 | 6 | |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | public static function instance() |
| 41 | 41 | { |
| 42 | 42 | // check if class object is instantiated, and instantiated properly |
| 43 | - if (! self::$_instance instanceof EEH_Debug_Tools) { |
|
| 43 | + if ( ! self::$_instance instanceof EEH_Debug_Tools) { |
|
| 44 | 44 | self::$_instance = new self(); |
| 45 | 45 | } |
| 46 | 46 | return self::$_instance; |
@@ -54,13 +54,13 @@ discard block |
||
| 54 | 54 | private function __construct() |
| 55 | 55 | { |
| 56 | 56 | // load Kint PHP debugging library |
| 57 | - if (! class_exists('Kint') && file_exists(EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php')) { |
|
| 57 | + if ( ! class_exists('Kint') && file_exists(EE_PLUGIN_DIR_PATH.'tests'.DS.'kint'.DS.'Kint.class.php')) { |
|
| 58 | 58 | // despite EE4 having a check for an existing copy of the Kint debugging class, |
| 59 | 59 | // if another plugin was loaded AFTER EE4 and they did NOT perform a similar check, |
| 60 | 60 | // then hilarity would ensue as PHP throws a "Cannot redeclare class Kint" error |
| 61 | 61 | // so we've moved it to our test folder so that it is not included with production releases |
| 62 | 62 | // plz use https://wordpress.org/plugins/kint-debugger/ if testing production versions of EE |
| 63 | - require_once(EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php'); |
|
| 63 | + require_once(EE_PLUGIN_DIR_PATH.'tests'.DS.'kint'.DS.'Kint.class.php'); |
|
| 64 | 64 | } |
| 65 | 65 | // if ( ! defined('DOING_AJAX') || $_REQUEST['noheader'] !== 'true' || ! isset( $_REQUEST['noheader'], $_REQUEST['TB_iframe'] ) ) { |
| 66 | 66 | //add_action( 'shutdown', array($this,'espresso_session_footer_dump') ); |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | public static function show_db_name() |
| 82 | 82 | { |
| 83 | - if (! defined('DOING_AJAX') && (defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS)) { |
|
| 83 | + if ( ! defined('DOING_AJAX') && (defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS)) { |
|
| 84 | 84 | echo '<p style="font-size:10px;font-weight:normal;color:#E76700;margin: 1em 2em; text-align: right;">DB_NAME: ' |
| 85 | 85 | . DB_NAME |
| 86 | 86 | . '</p>'; |
@@ -131,11 +131,11 @@ discard block |
||
| 131 | 131 | echo '<br/><br/><br/><h3>Hooked Functions</h3>'; |
| 132 | 132 | if ($tag) { |
| 133 | 133 | $hook[$tag] = $wp_filter[$tag]; |
| 134 | - if (! is_array($hook[$tag])) { |
|
| 134 | + if ( ! is_array($hook[$tag])) { |
|
| 135 | 135 | trigger_error("Nothing found for '$tag' hook", E_USER_WARNING); |
| 136 | 136 | return; |
| 137 | 137 | } |
| 138 | - echo '<h5>For Tag: ' . $tag . '</h5>'; |
|
| 138 | + echo '<h5>For Tag: '.$tag.'</h5>'; |
|
| 139 | 139 | } else { |
| 140 | 140 | $hook = is_array($wp_filter) ? $wp_filter : array($wp_filter); |
| 141 | 141 | ksort($hook); |
@@ -188,17 +188,17 @@ discard block |
||
| 188 | 188 | { |
| 189 | 189 | if (WP_DEBUG) { |
| 190 | 190 | $activation_errors = ob_get_contents(); |
| 191 | - if (! empty($activation_errors)) { |
|
| 192 | - $activation_errors = date('Y-m-d H:i:s') . "\n" . $activation_errors; |
|
| 191 | + if ( ! empty($activation_errors)) { |
|
| 192 | + $activation_errors = date('Y-m-d H:i:s')."\n".$activation_errors; |
|
| 193 | 193 | } |
| 194 | - espresso_load_required('EEH_File', EE_HELPERS . 'EEH_File.helper.php'); |
|
| 194 | + espresso_load_required('EEH_File', EE_HELPERS.'EEH_File.helper.php'); |
|
| 195 | 195 | if (class_exists('EEH_File')) { |
| 196 | 196 | try { |
| 197 | 197 | EEH_File::ensure_file_exists_and_is_writable( |
| 198 | - EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html' |
|
| 198 | + EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html' |
|
| 199 | 199 | ); |
| 200 | 200 | EEH_File::write_to_file( |
| 201 | - EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html', |
|
| 201 | + EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html', |
|
| 202 | 202 | $activation_errors |
| 203 | 203 | ); |
| 204 | 204 | } catch (EE_Error $e) { |
@@ -216,11 +216,11 @@ discard block |
||
| 216 | 216 | } else { |
| 217 | 217 | // old school attempt |
| 218 | 218 | file_put_contents( |
| 219 | - EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html', |
|
| 219 | + EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html', |
|
| 220 | 220 | $activation_errors |
| 221 | 221 | ); |
| 222 | 222 | } |
| 223 | - $activation_errors = get_option('ee_plugin_activation_errors', '') . $activation_errors; |
|
| 223 | + $activation_errors = get_option('ee_plugin_activation_errors', '').$activation_errors; |
|
| 224 | 224 | update_option('ee_plugin_activation_errors', $activation_errors); |
| 225 | 225 | } |
| 226 | 226 | } |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | // don't trigger error if doing ajax, |
| 281 | 281 | // instead we'll add a transient EE_Error notice that in theory should show on the next request. |
| 282 | 282 | if (defined('DOING_AJAX') && DOING_AJAX) { |
| 283 | - $error_message .= ' ' . esc_html__( |
|
| 283 | + $error_message .= ' '.esc_html__( |
|
| 284 | 284 | 'This is a doing_it_wrong message that was triggered during an ajax request. The request params on this request were: ', |
| 285 | 285 | 'event_espresso' |
| 286 | 286 | ); |
@@ -324,16 +324,16 @@ discard block |
||
| 324 | 324 | $debug_key = 'EE_DEBUG_SPCO' |
| 325 | 325 | ) { |
| 326 | 326 | if (WP_DEBUG) { |
| 327 | - $debug_key = $debug_key . '_' . EE_Session::instance()->id(); |
|
| 327 | + $debug_key = $debug_key.'_'.EE_Session::instance()->id(); |
|
| 328 | 328 | $debug_data = get_option($debug_key, array()); |
| 329 | 329 | $default_data = array( |
| 330 | - $class => $func . '() : ' . $line, |
|
| 330 | + $class => $func.'() : '.$line, |
|
| 331 | 331 | 'REQ' => $display_request ? $_REQUEST : '', |
| 332 | 332 | ); |
| 333 | 333 | // don't serialize objects |
| 334 | 334 | $info = self::strip_objects($info); |
| 335 | 335 | $index = ! empty($debug_index) ? $debug_index : 0; |
| 336 | - if (! isset($debug_data[$index])) { |
|
| 336 | + if ( ! isset($debug_data[$index])) { |
|
| 337 | 337 | $debug_data[$index] = array(); |
| 338 | 338 | } |
| 339 | 339 | $debug_data[$index][microtime()] = array_merge($default_data, $info); |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | unset($info[$key]); |
| 370 | 370 | } |
| 371 | 371 | } |
| 372 | - return (array)$info; |
|
| 372 | + return (array) $info; |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | |
@@ -399,8 +399,8 @@ discard block |
||
| 399 | 399 | $heading_tag = is_int($heading_tag) ? "h{$heading_tag}" : 'h5'; |
| 400 | 400 | $result = EEH_Debug_Tools::heading($var_name, $heading_tag, $margin); |
| 401 | 401 | $result .= $is_method |
| 402 | - ? EEH_Debug_Tools::grey_span('::') . EEH_Debug_Tools::orange_span($var . '()') |
|
| 403 | - : EEH_Debug_Tools::grey_span(' : ') . EEH_Debug_Tools::orange_span($var); |
|
| 402 | + ? EEH_Debug_Tools::grey_span('::').EEH_Debug_Tools::orange_span($var.'()') |
|
| 403 | + : EEH_Debug_Tools::grey_span(' : ').EEH_Debug_Tools::orange_span($var); |
|
| 404 | 404 | $result .= EEH_Debug_Tools::file_and_line($file, $line); |
| 405 | 405 | $result .= EEH_Debug_Tools::headingX($heading_tag); |
| 406 | 406 | if ($die) { |
@@ -423,7 +423,7 @@ discard block |
||
| 423 | 423 | return "\n{$var_name}"; |
| 424 | 424 | } |
| 425 | 425 | $margin = "25px 0 0 {$margin}"; |
| 426 | - return '<' . $heading_tag . ' style="color:#2EA2CC; margin:' . $margin . ';"><b>' . $var_name . '</b>'; |
|
| 426 | + return '<'.$heading_tag.' style="color:#2EA2CC; margin:'.$margin.';"><b>'.$var_name.'</b>'; |
|
| 427 | 427 | } |
| 428 | 428 | |
| 429 | 429 | |
@@ -437,7 +437,7 @@ discard block |
||
| 437 | 437 | if (defined('EE_TESTS_DIR')) { |
| 438 | 438 | return ''; |
| 439 | 439 | } |
| 440 | - return '</' . $heading_tag . '>'; |
|
| 440 | + return '</'.$heading_tag.'>'; |
|
| 441 | 441 | } |
| 442 | 442 | |
| 443 | 443 | |
@@ -451,7 +451,7 @@ discard block |
||
| 451 | 451 | if (defined('EE_TESTS_DIR')) { |
| 452 | 452 | return $content; |
| 453 | 453 | } |
| 454 | - return '<span style="color:#999">' . $content . '</span>'; |
|
| 454 | + return '<span style="color:#999">'.$content.'</span>'; |
|
| 455 | 455 | } |
| 456 | 456 | |
| 457 | 457 | |
@@ -467,7 +467,7 @@ discard block |
||
| 467 | 467 | return ''; |
| 468 | 468 | } |
| 469 | 469 | if (defined('EE_TESTS_DIR')) { |
| 470 | - return "\n (" . $file . ' line no: ' . $line . ' ) '; |
|
| 470 | + return "\n (".$file.' line no: '.$line.' ) '; |
|
| 471 | 471 | } |
| 472 | 472 | return '<br /><span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;">' |
| 473 | 473 | . $file |
@@ -487,7 +487,7 @@ discard block |
||
| 487 | 487 | if (defined('EE_TESTS_DIR')) { |
| 488 | 488 | return $content; |
| 489 | 489 | } |
| 490 | - return '<span style="color:#E76700">' . $content . '</span>'; |
|
| 490 | + return '<span style="color:#E76700">'.$content.'</span>'; |
|
| 491 | 491 | } |
| 492 | 492 | |
| 493 | 493 | |
@@ -502,9 +502,9 @@ discard block |
||
| 502 | 502 | var_dump($var); |
| 503 | 503 | $var = ob_get_clean(); |
| 504 | 504 | if (defined('EE_TESTS_DIR')) { |
| 505 | - return "\n" . $var; |
|
| 505 | + return "\n".$var; |
|
| 506 | 506 | } |
| 507 | - return '<pre style="color:#999; padding:1em; background: #fff">' . $var . '</pre>'; |
|
| 507 | + return '<pre style="color:#999; padding:1em; background: #fff">'.$var.'</pre>'; |
|
| 508 | 508 | } |
| 509 | 509 | |
| 510 | 510 | |
@@ -547,7 +547,7 @@ discard block |
||
| 547 | 547 | $var_name = ucwords(str_replace(array('$', '_'), array('', ' '), $var_name)); |
| 548 | 548 | $heading_tag = is_int($heading_tag) ? "h{$heading_tag}" : 'h5'; |
| 549 | 549 | $result = EEH_Debug_Tools::heading($var_name, $heading_tag, $margin); |
| 550 | - $result .= EEH_Debug_Tools::grey_span(' : ') . EEH_Debug_Tools::orange_span( |
|
| 550 | + $result .= EEH_Debug_Tools::grey_span(' : ').EEH_Debug_Tools::orange_span( |
|
| 551 | 551 | EEH_Debug_Tools::pre_span($var) |
| 552 | 552 | ); |
| 553 | 553 | $result .= EEH_Debug_Tools::file_and_line($file, $line); |
@@ -14,121 +14,121 @@ |
||
| 14 | 14 | abstract class EED_Module extends EE_Configurable implements ResettableInterface |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * rendered output to be returned to WP |
|
| 19 | - * |
|
| 20 | - * @var string $output |
|
| 21 | - */ |
|
| 22 | - protected $output = ''; |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * the current active espresso template theme |
|
| 26 | - * |
|
| 27 | - * @var string $theme |
|
| 28 | - */ |
|
| 29 | - protected $theme = ''; |
|
| 30 | - |
|
| 31 | - |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * @return void |
|
| 35 | - */ |
|
| 36 | - public static function reset() |
|
| 37 | - { |
|
| 38 | - $module_name = get_called_class(); |
|
| 39 | - new $module_name(); |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
| 46 | - * |
|
| 47 | - * @access public |
|
| 48 | - * @return void |
|
| 49 | - */ |
|
| 50 | - public static function set_hooks() |
|
| 51 | - { |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
| 58 | - * |
|
| 59 | - * @access public |
|
| 60 | - * @return void |
|
| 61 | - */ |
|
| 62 | - public static function set_hooks_admin() |
|
| 63 | - { |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - |
|
| 67 | - |
|
| 68 | - /** |
|
| 69 | - * run - initial module setup |
|
| 70 | - * this method is primarily used for activating resources in the EE_Front_Controller thru the use of filters |
|
| 71 | - * |
|
| 72 | - * @access public |
|
| 73 | - * @var WP $WP |
|
| 74 | - * @return void |
|
| 75 | - */ |
|
| 76 | - abstract public function run($WP); |
|
| 77 | - |
|
| 78 | - |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * EED_Module constructor. |
|
| 82 | - */ |
|
| 83 | - final public function __construct() |
|
| 84 | - { |
|
| 85 | - $this->theme = EE_Config::get_current_theme(); |
|
| 86 | - $module_name = $this->module_name(); |
|
| 87 | - EE_Registry::instance()->modules->{$module_name} = $this; |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * @param $module_name |
|
| 94 | - * @return EED_Module |
|
| 95 | - */ |
|
| 96 | - protected static function get_instance($module_name = '') |
|
| 97 | - { |
|
| 98 | - $module_name = ! empty($module_name) |
|
| 99 | - ? $module_name |
|
| 100 | - : get_called_class(); |
|
| 101 | - if ( |
|
| 102 | - ! isset(EE_Registry::instance()->modules->{$module_name}) |
|
| 103 | - || ! EE_Registry::instance()->modules->{$module_name} instanceof EED_Module |
|
| 104 | - ) { |
|
| 105 | - EE_Registry::instance()->add_module($module_name); |
|
| 106 | - } |
|
| 107 | - return EE_Registry::instance()->get_module($module_name); |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * module_name |
|
| 114 | - * |
|
| 115 | - * @access public |
|
| 116 | - * @return string |
|
| 117 | - */ |
|
| 118 | - public function module_name() |
|
| 119 | - { |
|
| 120 | - return get_class($this); |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - |
|
| 124 | - |
|
| 125 | - /** |
|
| 126 | - * @return string |
|
| 127 | - */ |
|
| 128 | - public function theme() |
|
| 129 | - { |
|
| 130 | - return $this->theme; |
|
| 131 | - } |
|
| 17 | + /** |
|
| 18 | + * rendered output to be returned to WP |
|
| 19 | + * |
|
| 20 | + * @var string $output |
|
| 21 | + */ |
|
| 22 | + protected $output = ''; |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * the current active espresso template theme |
|
| 26 | + * |
|
| 27 | + * @var string $theme |
|
| 28 | + */ |
|
| 29 | + protected $theme = ''; |
|
| 30 | + |
|
| 31 | + |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * @return void |
|
| 35 | + */ |
|
| 36 | + public static function reset() |
|
| 37 | + { |
|
| 38 | + $module_name = get_called_class(); |
|
| 39 | + new $module_name(); |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
| 46 | + * |
|
| 47 | + * @access public |
|
| 48 | + * @return void |
|
| 49 | + */ |
|
| 50 | + public static function set_hooks() |
|
| 51 | + { |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
| 58 | + * |
|
| 59 | + * @access public |
|
| 60 | + * @return void |
|
| 61 | + */ |
|
| 62 | + public static function set_hooks_admin() |
|
| 63 | + { |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + |
|
| 67 | + |
|
| 68 | + /** |
|
| 69 | + * run - initial module setup |
|
| 70 | + * this method is primarily used for activating resources in the EE_Front_Controller thru the use of filters |
|
| 71 | + * |
|
| 72 | + * @access public |
|
| 73 | + * @var WP $WP |
|
| 74 | + * @return void |
|
| 75 | + */ |
|
| 76 | + abstract public function run($WP); |
|
| 77 | + |
|
| 78 | + |
|
| 79 | + |
|
| 80 | + /** |
|
| 81 | + * EED_Module constructor. |
|
| 82 | + */ |
|
| 83 | + final public function __construct() |
|
| 84 | + { |
|
| 85 | + $this->theme = EE_Config::get_current_theme(); |
|
| 86 | + $module_name = $this->module_name(); |
|
| 87 | + EE_Registry::instance()->modules->{$module_name} = $this; |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * @param $module_name |
|
| 94 | + * @return EED_Module |
|
| 95 | + */ |
|
| 96 | + protected static function get_instance($module_name = '') |
|
| 97 | + { |
|
| 98 | + $module_name = ! empty($module_name) |
|
| 99 | + ? $module_name |
|
| 100 | + : get_called_class(); |
|
| 101 | + if ( |
|
| 102 | + ! isset(EE_Registry::instance()->modules->{$module_name}) |
|
| 103 | + || ! EE_Registry::instance()->modules->{$module_name} instanceof EED_Module |
|
| 104 | + ) { |
|
| 105 | + EE_Registry::instance()->add_module($module_name); |
|
| 106 | + } |
|
| 107 | + return EE_Registry::instance()->get_module($module_name); |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * module_name |
|
| 114 | + * |
|
| 115 | + * @access public |
|
| 116 | + * @return string |
|
| 117 | + */ |
|
| 118 | + public function module_name() |
|
| 119 | + { |
|
| 120 | + return get_class($this); |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + |
|
| 124 | + |
|
| 125 | + /** |
|
| 126 | + * @return string |
|
| 127 | + */ |
|
| 128 | + public function theme() |
|
| 129 | + { |
|
| 130 | + return $this->theme; |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | 133 | |
| 134 | 134 | |
@@ -17,74 +17,74 @@ discard block |
||
| 17 | 17 | class EEH_Schema { |
| 18 | 18 | |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * generates JSON-based linked data for an event |
|
| 22 | - * |
|
| 23 | - * @param EE_Event $event |
|
| 24 | - * @throws EE_Error |
|
| 25 | - */ |
|
| 26 | - public static function add_json_linked_data_for_event(EE_Event $event) |
|
| 27 | - { |
|
| 28 | - //Check we have a valid datetime for the event |
|
| 29 | - if(! $event->primary_datetime() instanceof EE_Datetime) { |
|
| 30 | - return; |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - $template_args = array( |
|
| 34 | - 'event_permalink' => '', |
|
| 35 | - 'event_name' => '', |
|
| 36 | - 'event_description' => '', |
|
| 37 | - 'event_start' => '', |
|
| 38 | - 'event_end' => '', |
|
| 39 | - 'currency' => '', |
|
| 40 | - 'event_tickets' => array(), |
|
| 41 | - 'venue_name' => '', |
|
| 42 | - 'venue_url' => '', |
|
| 43 | - 'venue_locality' => '', |
|
| 44 | - 'venue_region' => '', |
|
| 45 | - 'event_image' => '', |
|
| 46 | - ); |
|
| 47 | - $template_args['event_permalink'] = $event->get_permalink(); |
|
| 48 | - $template_args['event_name'] = $event->name(); |
|
| 49 | - $template_args['event_description'] = wp_strip_all_tags($event->short_description(200)); |
|
| 50 | - // clone datetime so that date formats don't override those for the original datetime |
|
| 51 | - $primary_datetime = clone $event->primary_datetime(); |
|
| 52 | - $template_args['event_start'] = $primary_datetime->start_date(DateTime::ATOM); |
|
| 53 | - $template_args['event_end'] = $primary_datetime->end_date(DateTime::ATOM); |
|
| 54 | - unset($primary_datetime); |
|
| 55 | - $template_args['currency'] = EE_Registry::instance()->CFG->currency->code; |
|
| 56 | - foreach ($event->tickets() as $original_ticket) { |
|
| 57 | - // clone tickets so that date formats don't override those for the original ticket |
|
| 58 | - $ticket= clone $original_ticket; |
|
| 59 | - $ID = $ticket->ID(); |
|
| 60 | - $template_args['event_tickets'][$ID]['start_date'] = $ticket->start_date(DateTime::ATOM, null); |
|
| 61 | - $template_args['event_tickets'][$ID]['end_date'] = $ticket->end_date(DateTime::ATOM, null); |
|
| 62 | - $template_args['event_tickets'][$ID]['price'] = number_format( |
|
| 63 | - $ticket->price(), |
|
| 64 | - EE_Registry::instance()->CFG->currency->dec_plc, |
|
| 65 | - EE_Registry::instance()->CFG->currency->dec_mrk, |
|
| 66 | - EE_Registry::instance()->CFG->currency->thsnds |
|
| 67 | - ); |
|
| 68 | - unset($ticket); |
|
| 69 | - } |
|
| 70 | - $VNU_ID = espresso_venue_id(); |
|
| 71 | - if ( ! empty($VNU_ID) && ! espresso_is_venue_private($VNU_ID)) { |
|
| 72 | - $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
| 73 | - $template_args['venue_name'] = get_the_title($VNU_ID); |
|
| 74 | - $template_args['venue_url'] = get_permalink($VNU_ID); |
|
| 75 | - $template_args['venue_locality'] = $venue->city(); |
|
| 76 | - $template_args['venue_region'] = $venue->state_name(); |
|
| 77 | - } |
|
| 78 | - $template_args['event_image'] = $event->feature_image_url(); |
|
| 79 | - $template_args = apply_filters( |
|
| 80 | - 'FHEE__EEH_Schema__add_json_linked_data_for_event__template_args', |
|
| 81 | - $template_args, |
|
| 82 | - $event, |
|
| 83 | - $VNU_ID |
|
| 84 | - ); |
|
| 85 | - extract($template_args, EXTR_OVERWRITE); |
|
| 86 | - include EE_TEMPLATES . 'json_linked_data_for_event.template.php'; |
|
| 87 | - } |
|
| 20 | + /** |
|
| 21 | + * generates JSON-based linked data for an event |
|
| 22 | + * |
|
| 23 | + * @param EE_Event $event |
|
| 24 | + * @throws EE_Error |
|
| 25 | + */ |
|
| 26 | + public static function add_json_linked_data_for_event(EE_Event $event) |
|
| 27 | + { |
|
| 28 | + //Check we have a valid datetime for the event |
|
| 29 | + if(! $event->primary_datetime() instanceof EE_Datetime) { |
|
| 30 | + return; |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + $template_args = array( |
|
| 34 | + 'event_permalink' => '', |
|
| 35 | + 'event_name' => '', |
|
| 36 | + 'event_description' => '', |
|
| 37 | + 'event_start' => '', |
|
| 38 | + 'event_end' => '', |
|
| 39 | + 'currency' => '', |
|
| 40 | + 'event_tickets' => array(), |
|
| 41 | + 'venue_name' => '', |
|
| 42 | + 'venue_url' => '', |
|
| 43 | + 'venue_locality' => '', |
|
| 44 | + 'venue_region' => '', |
|
| 45 | + 'event_image' => '', |
|
| 46 | + ); |
|
| 47 | + $template_args['event_permalink'] = $event->get_permalink(); |
|
| 48 | + $template_args['event_name'] = $event->name(); |
|
| 49 | + $template_args['event_description'] = wp_strip_all_tags($event->short_description(200)); |
|
| 50 | + // clone datetime so that date formats don't override those for the original datetime |
|
| 51 | + $primary_datetime = clone $event->primary_datetime(); |
|
| 52 | + $template_args['event_start'] = $primary_datetime->start_date(DateTime::ATOM); |
|
| 53 | + $template_args['event_end'] = $primary_datetime->end_date(DateTime::ATOM); |
|
| 54 | + unset($primary_datetime); |
|
| 55 | + $template_args['currency'] = EE_Registry::instance()->CFG->currency->code; |
|
| 56 | + foreach ($event->tickets() as $original_ticket) { |
|
| 57 | + // clone tickets so that date formats don't override those for the original ticket |
|
| 58 | + $ticket= clone $original_ticket; |
|
| 59 | + $ID = $ticket->ID(); |
|
| 60 | + $template_args['event_tickets'][$ID]['start_date'] = $ticket->start_date(DateTime::ATOM, null); |
|
| 61 | + $template_args['event_tickets'][$ID]['end_date'] = $ticket->end_date(DateTime::ATOM, null); |
|
| 62 | + $template_args['event_tickets'][$ID]['price'] = number_format( |
|
| 63 | + $ticket->price(), |
|
| 64 | + EE_Registry::instance()->CFG->currency->dec_plc, |
|
| 65 | + EE_Registry::instance()->CFG->currency->dec_mrk, |
|
| 66 | + EE_Registry::instance()->CFG->currency->thsnds |
|
| 67 | + ); |
|
| 68 | + unset($ticket); |
|
| 69 | + } |
|
| 70 | + $VNU_ID = espresso_venue_id(); |
|
| 71 | + if ( ! empty($VNU_ID) && ! espresso_is_venue_private($VNU_ID)) { |
|
| 72 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
| 73 | + $template_args['venue_name'] = get_the_title($VNU_ID); |
|
| 74 | + $template_args['venue_url'] = get_permalink($VNU_ID); |
|
| 75 | + $template_args['venue_locality'] = $venue->city(); |
|
| 76 | + $template_args['venue_region'] = $venue->state_name(); |
|
| 77 | + } |
|
| 78 | + $template_args['event_image'] = $event->feature_image_url(); |
|
| 79 | + $template_args = apply_filters( |
|
| 80 | + 'FHEE__EEH_Schema__add_json_linked_data_for_event__template_args', |
|
| 81 | + $template_args, |
|
| 82 | + $event, |
|
| 83 | + $VNU_ID |
|
| 84 | + ); |
|
| 85 | + extract($template_args, EXTR_OVERWRITE); |
|
| 86 | + include EE_TEMPLATES . 'json_linked_data_for_event.template.php'; |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | 89 | |
| 90 | 90 | /** |
@@ -98,8 +98,8 @@ discard block |
||
| 98 | 98 | */ |
| 99 | 99 | public static function location( $location = null ) { |
| 100 | 100 | return ! empty( $location ) ? '<div itemprop="location" itemscope itemtype="http://schema.org/Place">' |
| 101 | - . $location |
|
| 102 | - . '</div>' : ''; |
|
| 101 | + . $location |
|
| 102 | + . '</div>' : ''; |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | |
@@ -219,8 +219,8 @@ discard block |
||
| 219 | 219 | */ |
| 220 | 220 | public static function postalCode( EEI_Address $obj_with_address = null ) { |
| 221 | 221 | return $obj_with_address->zip() !== null && $obj_with_address->zip() !== '' ? '<span itemprop="postalCode">' |
| 222 | - . $obj_with_address->zip() |
|
| 223 | - . '</span>' : ''; |
|
| 222 | + . $obj_with_address->zip() |
|
| 223 | + . '</span>' : ''; |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | //Check the URL includes a scheme |
| 255 | 255 | $parsed_url = parse_url($url); |
| 256 | 256 | if ( empty($parsed_url['scheme']) ) { |
| 257 | - $url = 'http://' . ltrim($url, '/'); |
|
| 257 | + $url = 'http://' . ltrim($url, '/'); |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | $atts = ''; |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 4 | - exit( 'No direct script access allowed' ); |
|
| 3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 4 | + exit('No direct script access allowed'); |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | public static function add_json_linked_data_for_event(EE_Event $event) |
| 27 | 27 | { |
| 28 | 28 | //Check we have a valid datetime for the event |
| 29 | - if(! $event->primary_datetime() instanceof EE_Datetime) { |
|
| 29 | + if ( ! $event->primary_datetime() instanceof EE_Datetime) { |
|
| 30 | 30 | return; |
| 31 | 31 | } |
| 32 | 32 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | $template_args['currency'] = EE_Registry::instance()->CFG->currency->code; |
| 56 | 56 | foreach ($event->tickets() as $original_ticket) { |
| 57 | 57 | // clone tickets so that date formats don't override those for the original ticket |
| 58 | - $ticket= clone $original_ticket; |
|
| 58 | + $ticket = clone $original_ticket; |
|
| 59 | 59 | $ID = $ticket->ID(); |
| 60 | 60 | $template_args['event_tickets'][$ID]['start_date'] = $ticket->start_date(DateTime::ATOM, null); |
| 61 | 61 | $template_args['event_tickets'][$ID]['end_date'] = $ticket->end_date(DateTime::ATOM, null); |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | $VNU_ID |
| 84 | 84 | ); |
| 85 | 85 | extract($template_args, EXTR_OVERWRITE); |
| 86 | - include EE_TEMPLATES . 'json_linked_data_for_event.template.php'; |
|
| 86 | + include EE_TEMPLATES.'json_linked_data_for_event.template.php'; |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | |
@@ -96,8 +96,8 @@ discard block |
||
| 96 | 96 | * @param string $location |
| 97 | 97 | * @return string |
| 98 | 98 | */ |
| 99 | - public static function location( $location = null ) { |
|
| 100 | - return ! empty( $location ) ? '<div itemprop="location" itemscope itemtype="http://schema.org/Place">' |
|
| 99 | + public static function location($location = null) { |
|
| 100 | + return ! empty($location) ? '<div itemprop="location" itemscope itemtype="http://schema.org/Place">' |
|
| 101 | 101 | . $location |
| 102 | 102 | . '</div>' : ''; |
| 103 | 103 | } |
@@ -112,8 +112,8 @@ discard block |
||
| 112 | 112 | * @param string $name |
| 113 | 113 | * @return string |
| 114 | 114 | */ |
| 115 | - public static function name( $name = null ) { |
|
| 116 | - return ! empty( $name ) ? '<span itemprop="name">' . $name . '</span>' : ''; |
|
| 115 | + public static function name($name = null) { |
|
| 116 | + return ! empty($name) ? '<span itemprop="name">'.$name.'</span>' : ''; |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | |
@@ -126,9 +126,9 @@ discard block |
||
| 126 | 126 | * @param EEI_Address $obj_with_address |
| 127 | 127 | * @return string |
| 128 | 128 | */ |
| 129 | - public static function streetAddress( EEI_Address $obj_with_address = null ) { |
|
| 129 | + public static function streetAddress(EEI_Address $obj_with_address = null) { |
|
| 130 | 130 | return $obj_with_address->address() !== null && $obj_with_address->address() !== '' |
| 131 | - ? '<span itemprop="streetAddress">' . $obj_with_address->address() . '</span>' : ''; |
|
| 131 | + ? '<span itemprop="streetAddress">'.$obj_with_address->address().'</span>' : ''; |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | |
@@ -141,14 +141,14 @@ discard block |
||
| 141 | 141 | * @param EEI_Address $obj_with_address |
| 142 | 142 | * @return string |
| 143 | 143 | */ |
| 144 | - public static function postOfficeBoxNumber( EEI_Address $obj_with_address = null ) { |
|
| 144 | + public static function postOfficeBoxNumber(EEI_Address $obj_with_address = null) { |
|
| 145 | 145 | // regex check for some form of PO Box or P.O. Box, etc, etc, etc |
| 146 | - if ( preg_match( |
|
| 146 | + if (preg_match( |
|
| 147 | 147 | "/^\s*((P(OST)?.?\s*(O(FF(ICE)?)?)?.?\s+(B(IN|OX))?)|B(IN|OX))/i", |
| 148 | 148 | $obj_with_address->address2() |
| 149 | - ) ) { |
|
| 149 | + )) { |
|
| 150 | 150 | return $obj_with_address->address2() !== null && $obj_with_address->address2() !== '' |
| 151 | - ? '<span itemprop="postOfficeBoxNumber">' . $obj_with_address->address2() . '</span>' : ''; |
|
| 151 | + ? '<span itemprop="postOfficeBoxNumber">'.$obj_with_address->address2().'</span>' : ''; |
|
| 152 | 152 | } else { |
| 153 | 153 | return $obj_with_address->address2(); |
| 154 | 154 | } |
@@ -164,9 +164,9 @@ discard block |
||
| 164 | 164 | * @param EEI_Address $obj_with_address |
| 165 | 165 | * @return string |
| 166 | 166 | */ |
| 167 | - public static function addressLocality( EEI_Address $obj_with_address = null ) { |
|
| 167 | + public static function addressLocality(EEI_Address $obj_with_address = null) { |
|
| 168 | 168 | return $obj_with_address->city() !== null && $obj_with_address->city() !== '' |
| 169 | - ? '<span itemprop="addressLocality">' . $obj_with_address->city() . '</span>' : ''; |
|
| 169 | + ? '<span itemprop="addressLocality">'.$obj_with_address->city().'</span>' : ''; |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | |
@@ -179,10 +179,10 @@ discard block |
||
| 179 | 179 | * @param EEI_Address $obj_with_address |
| 180 | 180 | * @return string |
| 181 | 181 | */ |
| 182 | - public static function addressRegion( EEI_Address $obj_with_address = null ) { |
|
| 182 | + public static function addressRegion(EEI_Address $obj_with_address = null) { |
|
| 183 | 183 | $state = $obj_with_address->state_name(); |
| 184 | - if ( ! empty( $state ) ) { |
|
| 185 | - return '<span itemprop="addressRegion">' . $state . '</span>'; |
|
| 184 | + if ( ! empty($state)) { |
|
| 185 | + return '<span itemprop="addressRegion">'.$state.'</span>'; |
|
| 186 | 186 | } else { |
| 187 | 187 | return ''; |
| 188 | 188 | } |
@@ -198,10 +198,10 @@ discard block |
||
| 198 | 198 | * @param EEI_Address $obj_with_address |
| 199 | 199 | * @return string |
| 200 | 200 | */ |
| 201 | - public static function addressCountry( EEI_Address $obj_with_address = null ) { |
|
| 201 | + public static function addressCountry(EEI_Address $obj_with_address = null) { |
|
| 202 | 202 | $country = $obj_with_address->country_name(); |
| 203 | - if ( ! empty( $country ) ) { |
|
| 204 | - return '<span itemprop="addressCountry">' . $country . '</span>'; |
|
| 203 | + if ( ! empty($country)) { |
|
| 204 | + return '<span itemprop="addressCountry">'.$country.'</span>'; |
|
| 205 | 205 | } else { |
| 206 | 206 | return ''; |
| 207 | 207 | } |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | * @param EEI_Address $obj_with_address |
| 218 | 218 | * @return string |
| 219 | 219 | */ |
| 220 | - public static function postalCode( EEI_Address $obj_with_address = null ) { |
|
| 220 | + public static function postalCode(EEI_Address $obj_with_address = null) { |
|
| 221 | 221 | return $obj_with_address->zip() !== null && $obj_with_address->zip() !== '' ? '<span itemprop="postalCode">' |
| 222 | 222 | . $obj_with_address->zip() |
| 223 | 223 | . '</span>' : ''; |
@@ -233,8 +233,8 @@ discard block |
||
| 233 | 233 | * @param string $phone_nmbr |
| 234 | 234 | * @return string |
| 235 | 235 | */ |
| 236 | - public static function telephone( $phone_nmbr = null ) { |
|
| 237 | - return $phone_nmbr !== null && $phone_nmbr !== '' ? '<span itemprop="telephone">' . $phone_nmbr . '</span>' |
|
| 236 | + public static function telephone($phone_nmbr = null) { |
|
| 237 | + return $phone_nmbr !== null && $phone_nmbr !== '' ? '<span itemprop="telephone">'.$phone_nmbr.'</span>' |
|
| 238 | 238 | : ''; |
| 239 | 239 | } |
| 240 | 240 | |
@@ -250,19 +250,19 @@ discard block |
||
| 250 | 250 | * @param array $attributes - array of additional link attributes in attribute_name => value pairs. ie: array( 'title' => 'click here', 'class' => 'link-class' ) |
| 251 | 251 | * @return string (link) |
| 252 | 252 | */ |
| 253 | - public static function url( $url = null, $text = null, $attributes = array() ) { |
|
| 253 | + public static function url($url = null, $text = null, $attributes = array()) { |
|
| 254 | 254 | //Check the URL includes a scheme |
| 255 | 255 | $parsed_url = parse_url($url); |
| 256 | - if ( empty($parsed_url['scheme']) ) { |
|
| 257 | - $url = 'http://' . ltrim($url, '/'); |
|
| 256 | + if (empty($parsed_url['scheme'])) { |
|
| 257 | + $url = 'http://'.ltrim($url, '/'); |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | $atts = ''; |
| 261 | - foreach ( $attributes as $attribute => $value ) { |
|
| 262 | - $atts .= ' ' . $attribute . '="' . $value . '"'; |
|
| 261 | + foreach ($attributes as $attribute => $value) { |
|
| 262 | + $atts .= ' '.$attribute.'="'.$value.'"'; |
|
| 263 | 263 | } |
| 264 | 264 | $text = $text !== null && $text !== '' ? $text : $url; |
| 265 | - return $url !== null && $url !== '' ? '<a itemprop="url" href="' . $url . '"' . $atts . '>' . $text . '</a>' |
|
| 265 | + return $url !== null && $url !== '' ? '<a itemprop="url" href="'.$url.'"'.$atts.'>'.$text.'</a>' |
|
| 266 | 266 | : ''; |
| 267 | 267 | } |
| 268 | 268 | |
@@ -165,7 +165,7 @@ |
||
| 165 | 165 | |
| 166 | 166 | /** |
| 167 | 167 | * @param EE_Event $item |
| 168 | - * @return mixed|string |
|
| 168 | + * @return string |
|
| 169 | 169 | */ |
| 170 | 170 | public function column_id(EE_Event $item) |
| 171 | 171 | { |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
| 3 | - exit('NO direct script access allowed'); |
|
| 3 | + exit('NO direct script access allowed'); |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | /** |
@@ -26,406 +26,406 @@ discard block |
||
| 26 | 26 | { |
| 27 | 27 | |
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * @var EE_Datetime |
|
| 31 | - */ |
|
| 32 | - private $_dtt; |
|
| 33 | - |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * Events_Admin_List_Table constructor. |
|
| 37 | - * |
|
| 38 | - * @param EE_Admin_Page $admin_page |
|
| 39 | - */ |
|
| 40 | - public function __construct($admin_page) |
|
| 41 | - { |
|
| 42 | - parent::__construct($admin_page); |
|
| 43 | - require_once(EE_HELPERS . 'EEH_DTT_Helper.helper.php'); |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * Initial setup of data properties for the list table. |
|
| 49 | - */ |
|
| 50 | - protected function _setup_data() |
|
| 51 | - { |
|
| 52 | - $this->_data = $this->_admin_page->get_events($this->_per_page, $this->_current_page); |
|
| 53 | - $this->_all_data_count = $this->_admin_page->get_events(0, 0, true); |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * Set up of additional properties for the list table. |
|
| 59 | - */ |
|
| 60 | - protected function _set_properties() |
|
| 61 | - { |
|
| 62 | - $this->_wp_list_args = array( |
|
| 63 | - 'singular' => __('event', 'event_espresso'), |
|
| 64 | - 'plural' => __('events', 'event_espresso'), |
|
| 65 | - 'ajax' => true, //for now |
|
| 66 | - 'screen' => $this->_admin_page->get_current_screen()->id, |
|
| 67 | - ); |
|
| 68 | - |
|
| 69 | - |
|
| 70 | - $this->_columns = array( |
|
| 71 | - 'cb' => '<input type="checkbox" />', |
|
| 72 | - 'id' => __('ID', 'event_espresso'), |
|
| 73 | - 'name' => __('Name', 'event_espresso'), |
|
| 74 | - 'author' => __('Author', 'event_espresso'), |
|
| 75 | - 'venue' => __('Venue', 'event_espresso'), |
|
| 76 | - 'start_date_time' => __('Event Start', 'event_espresso'), |
|
| 77 | - 'reg_begins' => __('On Sale', 'event_espresso'), |
|
| 78 | - 'attendees' => '<span class="dashicons dashicons-groups ee-icon-color-ee-green ee-icon-size-20"></span>', |
|
| 79 | - //'tkts_sold' => __('Tickets Sold', 'event_espresso'), |
|
| 80 | - 'actions' => __('Actions', 'event_espresso'), |
|
| 81 | - ); |
|
| 82 | - |
|
| 83 | - |
|
| 84 | - $this->_sortable_columns = array( |
|
| 85 | - 'id' => array('EVT_ID' => true), |
|
| 86 | - 'name' => array('EVT_name' => false), |
|
| 87 | - 'author' => array('EVT_wp_user' => false), |
|
| 88 | - 'venue' => array('Venue.VNU_name' => false), |
|
| 89 | - 'start_date_time' => array('Datetime.DTT_EVT_start' => false), |
|
| 90 | - 'reg_begins' => array('Datetime.Ticket.TKT_start_date' => false), |
|
| 91 | - ); |
|
| 92 | - |
|
| 93 | - $this->_primary_column = 'id'; |
|
| 94 | - |
|
| 95 | - $this->_hidden_columns = array('author'); |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - |
|
| 99 | - /** |
|
| 100 | - * @return array |
|
| 101 | - */ |
|
| 102 | - protected function _get_table_filters() |
|
| 103 | - { |
|
| 104 | - return array(); //no filters with decaf |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - |
|
| 108 | - /** |
|
| 109 | - * Setup of views properties. |
|
| 110 | - */ |
|
| 111 | - protected function _add_view_counts() |
|
| 112 | - { |
|
| 113 | - $this->_views['all']['count'] = $this->_admin_page->total_events(); |
|
| 114 | - $this->_views['draft']['count'] = $this->_admin_page->total_events_draft(); |
|
| 115 | - if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) { |
|
| 116 | - $this->_views['trash']['count'] = $this->_admin_page->total_trashed_events(); |
|
| 117 | - } |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - |
|
| 121 | - /** |
|
| 122 | - * @param EE_Event $item |
|
| 123 | - * @return string |
|
| 124 | - */ |
|
| 125 | - protected function _get_row_class($item) |
|
| 126 | - { |
|
| 127 | - $class = parent::_get_row_class($item); |
|
| 128 | - //add status class |
|
| 129 | - $class .= $item instanceof EE_Event ? ' ee-status-strip event-status-' . $item->get_active_status() : ''; |
|
| 130 | - if ($this->_has_checkbox_column) { |
|
| 131 | - $class .= ' has-checkbox-column'; |
|
| 132 | - } |
|
| 133 | - return $class; |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - |
|
| 137 | - /** |
|
| 138 | - * @param EE_Event $item |
|
| 139 | - * @return string |
|
| 140 | - */ |
|
| 141 | - public function column_status(EE_Event $item) |
|
| 142 | - { |
|
| 143 | - return '<span class="ee-status-strip ee-status-strip-td event-status-' . $item->get_active_status() . '"></span>'; |
|
| 144 | - }/**/ |
|
| 145 | - |
|
| 146 | - |
|
| 147 | - /** |
|
| 148 | - * @param EE_Event $item |
|
| 149 | - * @return string |
|
| 150 | - */ |
|
| 151 | - public function column_cb($item) |
|
| 152 | - { |
|
| 153 | - if (! $item instanceof EE_Event) { |
|
| 154 | - return ''; |
|
| 155 | - } |
|
| 156 | - $this->_dtt = $item->primary_datetime(); //set this for use in other columns |
|
| 157 | - |
|
| 158 | - //does event have any attached registrations? |
|
| 159 | - $regs = $item->count_related('Registration'); |
|
| 160 | - return $regs > 0 && $this->_view == 'trash' ? '<span class="ee-lock-icon"></span>' : sprintf( |
|
| 161 | - '<input type="checkbox" name="EVT_IDs[]" value="%s" />', $item->ID() |
|
| 162 | - ); |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - |
|
| 166 | - /** |
|
| 167 | - * @param EE_Event $item |
|
| 168 | - * @return mixed|string |
|
| 169 | - */ |
|
| 170 | - public function column_id(EE_Event $item) |
|
| 171 | - { |
|
| 172 | - $content = $item->ID(); |
|
| 173 | - $content .= ' <span class="show-on-mobile-view-only">' . $item->name() . '</span>'; |
|
| 174 | - return $content; |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - |
|
| 178 | - /** |
|
| 179 | - * @param EE_Event $item |
|
| 180 | - * @return string |
|
| 181 | - */ |
|
| 182 | - public function column_name(EE_Event $item) |
|
| 183 | - { |
|
| 184 | - $edit_query_args = array( |
|
| 185 | - 'action' => 'edit', |
|
| 186 | - 'post' => $item->ID(), |
|
| 187 | - ); |
|
| 188 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
| 189 | - $actions = $this->_column_name_action_setup($item); |
|
| 190 | - $status = ''; //$item->status() !== 'publish' ? ' (' . $item->status() . ')' : ''; |
|
| 191 | - $content = '<strong><a class="row-title" href="' . $edit_link . '">' . $item->name() . '</a></strong>' . $status; |
|
| 192 | - $content .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status($item->get_active_status(), |
|
| 193 | - false, 'sentence') . '</span>'; |
|
| 194 | - $content .= $this->row_actions($actions); |
|
| 195 | - return $content; |
|
| 196 | - |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - |
|
| 200 | - /** |
|
| 201 | - * Just a method for setting up the actions for the name column |
|
| 202 | - * |
|
| 203 | - * @param EE_Event $item |
|
| 204 | - * @return array array of actions |
|
| 205 | - */ |
|
| 206 | - protected function _column_name_action_setup(EE_Event $item) |
|
| 207 | - { |
|
| 208 | - //todo: remove when attendees is active |
|
| 209 | - if (! defined('REG_ADMIN_URL')) { |
|
| 210 | - define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - $actions = array(); |
|
| 214 | - |
|
| 215 | - if (EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'espresso_events_edit', $item->ID())) { |
|
| 216 | - $edit_query_args = array( |
|
| 217 | - 'action' => 'edit', |
|
| 218 | - 'post' => $item->ID(), |
|
| 219 | - ); |
|
| 220 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
| 221 | - $actions['edit'] = '<a href="' . $edit_link . '" title="' . esc_attr__('Edit Event', |
|
| 222 | - 'event_espresso') . '">' . __('Edit', 'event_espresso') . '</a>'; |
|
| 223 | - |
|
| 224 | - } |
|
| 225 | - |
|
| 226 | - if (EE_Registry::instance()->CAP->current_user_can('ee_read_registration', |
|
| 227 | - 'espresso_registrations_view_registration', $item->ID())) { |
|
| 228 | - $attendees_query_args = array( |
|
| 229 | - 'action' => 'default', |
|
| 230 | - 'event_id' => $item->ID(), |
|
| 231 | - ); |
|
| 232 | - $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
|
| 233 | - $actions['attendees'] = '<a href="' . $attendees_link . '" title="' . esc_attr__('View Registrations', |
|
| 234 | - 'event_espresso') . '">' . __('Registrations', 'event_espresso') . '</a>'; |
|
| 235 | - } |
|
| 236 | - |
|
| 237 | - if (EE_Registry::instance()->CAP->current_user_can('ee_delete_event', 'espresso_events_trash_event', |
|
| 238 | - $item->ID())) { |
|
| 239 | - $trash_event_query_args = array( |
|
| 240 | - 'action' => 'trash_event', |
|
| 241 | - 'EVT_ID' => $item->ID(), |
|
| 242 | - ); |
|
| 243 | - $trash_event_link = EE_Admin_Page::add_query_args_and_nonce($trash_event_query_args, |
|
| 244 | - EVENTS_ADMIN_URL); |
|
| 245 | - } |
|
| 246 | - |
|
| 247 | - if (EE_Registry::instance()->CAP->current_user_can('ee_delete_event', 'espresso_events_restore_event', |
|
| 248 | - $item->ID())) { |
|
| 249 | - $restore_event_query_args = array( |
|
| 250 | - 'action' => 'restore_event', |
|
| 251 | - 'EVT_ID' => $item->ID(), |
|
| 252 | - ); |
|
| 253 | - $restore_event_link = EE_Admin_Page::add_query_args_and_nonce($restore_event_query_args, |
|
| 254 | - EVENTS_ADMIN_URL); |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - if (EE_Registry::instance()->CAP->current_user_can('ee_delete_event', 'espresso_events_delete_event', |
|
| 258 | - $item->ID())) { |
|
| 259 | - $delete_event_query_args = array( |
|
| 260 | - 'action' => 'delete_event', |
|
| 261 | - 'EVT_ID' => $item->ID(), |
|
| 262 | - ); |
|
| 263 | - $delete_event_link = EE_Admin_Page::add_query_args_and_nonce($delete_event_query_args, |
|
| 264 | - EVENTS_ADMIN_URL); |
|
| 265 | - } |
|
| 266 | - |
|
| 267 | - $view_link = get_permalink($item->ID()); |
|
| 268 | - |
|
| 269 | - $actions['view'] = '<a href="' . $view_link . '" title="' . esc_attr__('View Event', |
|
| 270 | - 'event_espresso') . '">' . __('View', 'event_espresso') . '</a>'; |
|
| 271 | - |
|
| 272 | - switch ($item->get('status')) { |
|
| 273 | - case 'trash' : |
|
| 274 | - if (EE_Registry::instance()->CAP->current_user_can('ee_delete_event', 'espresso_events_restore_event', |
|
| 275 | - $item->ID())) { |
|
| 276 | - $actions['restore_from_trash'] = '<a href="' . $restore_event_link . '" title="' . esc_attr__('Restore from Trash', |
|
| 277 | - 'event_espresso') . '">' . __('Restore from Trash', 'event_espresso') . '</a>'; |
|
| 278 | - } |
|
| 279 | - if ($item->count_related('Registration') === 0 && EE_Registry::instance()->CAP->current_user_can('ee_delete_event', |
|
| 280 | - 'espresso_events_delete_event', $item->ID())) { |
|
| 281 | - $actions['delete'] = '<a href="' . $delete_event_link . '" title="' . esc_attr__('Delete Permanently', |
|
| 282 | - 'event_espresso') . '">' . __('Delete Permanently', 'event_espresso') . '</a>'; |
|
| 283 | - } |
|
| 284 | - break; |
|
| 285 | - default : |
|
| 286 | - if (EE_Registry::instance()->CAP->current_user_can('ee_delete_event', 'espresso_events_trash_event', |
|
| 287 | - $item->ID())) { |
|
| 288 | - $actions['move to trash'] = '<a href="' . $trash_event_link . '" title="' . esc_attr__('Trash Event', |
|
| 289 | - 'event_espresso') . '">' . __('Trash', 'event_espresso') . '</a>'; |
|
| 290 | - } |
|
| 291 | - } |
|
| 292 | - return $actions; |
|
| 293 | - } |
|
| 294 | - |
|
| 295 | - |
|
| 296 | - /** |
|
| 297 | - * @param EE_Event $item |
|
| 298 | - * @return string |
|
| 299 | - */ |
|
| 300 | - public function column_author(EE_Event $item) |
|
| 301 | - { |
|
| 302 | - //user author info |
|
| 303 | - $event_author = get_userdata($item->wp_user()); |
|
| 304 | - $gravatar = get_avatar($item->wp_user(), '15'); |
|
| 305 | - //filter link |
|
| 306 | - $query_args = array( |
|
| 307 | - 'action' => 'default', |
|
| 308 | - 'EVT_wp_user' => $item->wp_user(), |
|
| 309 | - ); |
|
| 310 | - $filter_url = EE_Admin_Page::add_query_args_and_nonce($query_args, EVENTS_ADMIN_URL); |
|
| 311 | - return $gravatar . ' <a href="' . $filter_url . '" title="' . esc_attr__('Click to filter events by this author.', |
|
| 312 | - 'event_espresso') . '">' . $event_author->display_name . '</a>'; |
|
| 313 | - } |
|
| 314 | - |
|
| 315 | - |
|
| 316 | - /** |
|
| 317 | - * @param EE_Event $item |
|
| 318 | - * @return string |
|
| 319 | - */ |
|
| 320 | - public function column_venue(EE_Event $item) |
|
| 321 | - { |
|
| 322 | - $venue = $item->get_first_related('Venue'); |
|
| 323 | - return ! empty($venue) ? $venue->name() : ''; |
|
| 324 | - } |
|
| 325 | - |
|
| 326 | - |
|
| 327 | - /** |
|
| 328 | - * @param EE_Event $item |
|
| 329 | - * @throws EE_Error |
|
| 330 | - */ |
|
| 331 | - public function column_start_date_time(EE_Event $item) |
|
| 332 | - { |
|
| 333 | - echo ! empty($this->_dtt) ? $this->_dtt->get_i18n_datetime('DTT_EVT_start') : __('No Date was saved for this Event', |
|
| 334 | - 'event_espresso'); |
|
| 335 | - //display in user's timezone? |
|
| 336 | - echo ! empty($this->_dtt) ? $this->_dtt->display_in_my_timezone('DTT_EVT_start', 'get_i18n_datetime', '', |
|
| 337 | - 'My Timezone: ') : ''; |
|
| 338 | - |
|
| 339 | - } |
|
| 340 | - |
|
| 341 | - |
|
| 342 | - /** |
|
| 343 | - * @param EE_Event $item |
|
| 344 | - * @throws EE_Error |
|
| 345 | - */ |
|
| 346 | - public function column_reg_begins(EE_Event $item) |
|
| 347 | - { |
|
| 348 | - $reg_start = $item->get_ticket_with_earliest_start_time(); |
|
| 349 | - echo ! empty($reg_start) ? $reg_start->get_i18n_datetime('TKT_start_date') : __('No Tickets have been setup for this Event', |
|
| 350 | - 'event_espresso'); |
|
| 351 | - //display in user's timezone? |
|
| 352 | - echo ! empty($reg_start) ? $reg_start->display_in_my_timezone('TKT_start_date', 'get_i18n_datetime', '', |
|
| 353 | - 'My Timezone: ') : '';/**/ |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - |
|
| 357 | - /** |
|
| 358 | - * @param EE_Event $item |
|
| 359 | - * @return int|string |
|
| 360 | - */ |
|
| 361 | - public function column_attendees(EE_Event $item) |
|
| 362 | - { |
|
| 363 | - $attendees_query_args = array( |
|
| 364 | - 'action' => 'default', |
|
| 365 | - 'event_id' => $item->ID(), |
|
| 366 | - ); |
|
| 367 | - $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
|
| 368 | - $registered_attendees = EEM_Registration::instance()->get_event_registration_count($item->ID()); |
|
| 369 | - return EE_Registry::instance()->CAP->current_user_can('ee_read_registration', |
|
| 370 | - 'espresso_registrations_view_registration', |
|
| 371 | - $item->ID()) ? '<a href="' . $attendees_link . '">' . $registered_attendees . '</a>' : $registered_attendees; |
|
| 372 | - } |
|
| 373 | - |
|
| 374 | - |
|
| 375 | - /** |
|
| 376 | - * @param EE_Event $item |
|
| 377 | - * @return float |
|
| 378 | - */ |
|
| 379 | - public function column_tkts_sold(EE_Event $item) |
|
| 380 | - { |
|
| 381 | - return EEM_Ticket::instance()->sum(array(array('Datetime.EVT_ID' => $item->ID())), 'TKT_sold'); |
|
| 382 | - } |
|
| 383 | - |
|
| 384 | - |
|
| 385 | - /** |
|
| 386 | - * @param EE_Event $item |
|
| 387 | - * @return string |
|
| 388 | - */ |
|
| 389 | - public function column_actions(EE_Event $item) |
|
| 390 | - { |
|
| 391 | - //todo: remove when attendees is active |
|
| 392 | - if (! defined('REG_ADMIN_URL')) { |
|
| 393 | - define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
|
| 394 | - } |
|
| 395 | - $actionlinks = array(); |
|
| 396 | - |
|
| 397 | - $view_link = get_permalink($item->ID()); |
|
| 398 | - |
|
| 399 | - $actionlinks[] = '<a href="' . $view_link . '" title="' . esc_attr__('View Event', |
|
| 400 | - 'event_espresso') . '" target="_blank">'; |
|
| 401 | - $actionlinks[] = '<div class="dashicons dashicons-search"></div></a>'; |
|
| 402 | - |
|
| 403 | - if (EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'espresso_events_edit', $item->ID())) { |
|
| 404 | - $edit_query_args = array( |
|
| 405 | - 'action' => 'edit', |
|
| 406 | - 'post' => $item->ID(), |
|
| 407 | - ); |
|
| 408 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
| 409 | - $actionlinks[] = '<a href="' . $edit_link . '" title="' . esc_attr__('Edit Event', |
|
| 410 | - 'event_espresso') . '"><div class="ee-icon ee-icon-calendar-edit"></div></a>'; |
|
| 411 | - } |
|
| 412 | - |
|
| 413 | - if (EE_Registry::instance()->CAP->current_user_can('ee_read_registration', |
|
| 414 | - 'espresso_registrations_view_registration', $item->ID())) { |
|
| 415 | - $attendees_query_args = array( |
|
| 416 | - 'action' => 'default', |
|
| 417 | - 'event_id' => $item->ID(), |
|
| 418 | - ); |
|
| 419 | - $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
|
| 420 | - $actionlinks[] = '<a href="' . $attendees_link . '" title="' . esc_attr__('View Registrants', |
|
| 421 | - 'event_espresso') . '"><div class="dashicons dashicons-groups"></div></a>'; |
|
| 422 | - } |
|
| 423 | - |
|
| 424 | - $actionlinks = apply_filters('FHEE__Events_Admin_List_Table__column_actions__action_links', $actionlinks, |
|
| 425 | - $item); |
|
| 426 | - |
|
| 427 | - return $this->_action_string(implode("\n\t", $actionlinks), $item, 'div'); |
|
| 428 | - } |
|
| 29 | + /** |
|
| 30 | + * @var EE_Datetime |
|
| 31 | + */ |
|
| 32 | + private $_dtt; |
|
| 33 | + |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * Events_Admin_List_Table constructor. |
|
| 37 | + * |
|
| 38 | + * @param EE_Admin_Page $admin_page |
|
| 39 | + */ |
|
| 40 | + public function __construct($admin_page) |
|
| 41 | + { |
|
| 42 | + parent::__construct($admin_page); |
|
| 43 | + require_once(EE_HELPERS . 'EEH_DTT_Helper.helper.php'); |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * Initial setup of data properties for the list table. |
|
| 49 | + */ |
|
| 50 | + protected function _setup_data() |
|
| 51 | + { |
|
| 52 | + $this->_data = $this->_admin_page->get_events($this->_per_page, $this->_current_page); |
|
| 53 | + $this->_all_data_count = $this->_admin_page->get_events(0, 0, true); |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * Set up of additional properties for the list table. |
|
| 59 | + */ |
|
| 60 | + protected function _set_properties() |
|
| 61 | + { |
|
| 62 | + $this->_wp_list_args = array( |
|
| 63 | + 'singular' => __('event', 'event_espresso'), |
|
| 64 | + 'plural' => __('events', 'event_espresso'), |
|
| 65 | + 'ajax' => true, //for now |
|
| 66 | + 'screen' => $this->_admin_page->get_current_screen()->id, |
|
| 67 | + ); |
|
| 68 | + |
|
| 69 | + |
|
| 70 | + $this->_columns = array( |
|
| 71 | + 'cb' => '<input type="checkbox" />', |
|
| 72 | + 'id' => __('ID', 'event_espresso'), |
|
| 73 | + 'name' => __('Name', 'event_espresso'), |
|
| 74 | + 'author' => __('Author', 'event_espresso'), |
|
| 75 | + 'venue' => __('Venue', 'event_espresso'), |
|
| 76 | + 'start_date_time' => __('Event Start', 'event_espresso'), |
|
| 77 | + 'reg_begins' => __('On Sale', 'event_espresso'), |
|
| 78 | + 'attendees' => '<span class="dashicons dashicons-groups ee-icon-color-ee-green ee-icon-size-20"></span>', |
|
| 79 | + //'tkts_sold' => __('Tickets Sold', 'event_espresso'), |
|
| 80 | + 'actions' => __('Actions', 'event_espresso'), |
|
| 81 | + ); |
|
| 82 | + |
|
| 83 | + |
|
| 84 | + $this->_sortable_columns = array( |
|
| 85 | + 'id' => array('EVT_ID' => true), |
|
| 86 | + 'name' => array('EVT_name' => false), |
|
| 87 | + 'author' => array('EVT_wp_user' => false), |
|
| 88 | + 'venue' => array('Venue.VNU_name' => false), |
|
| 89 | + 'start_date_time' => array('Datetime.DTT_EVT_start' => false), |
|
| 90 | + 'reg_begins' => array('Datetime.Ticket.TKT_start_date' => false), |
|
| 91 | + ); |
|
| 92 | + |
|
| 93 | + $this->_primary_column = 'id'; |
|
| 94 | + |
|
| 95 | + $this->_hidden_columns = array('author'); |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + |
|
| 99 | + /** |
|
| 100 | + * @return array |
|
| 101 | + */ |
|
| 102 | + protected function _get_table_filters() |
|
| 103 | + { |
|
| 104 | + return array(); //no filters with decaf |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + |
|
| 108 | + /** |
|
| 109 | + * Setup of views properties. |
|
| 110 | + */ |
|
| 111 | + protected function _add_view_counts() |
|
| 112 | + { |
|
| 113 | + $this->_views['all']['count'] = $this->_admin_page->total_events(); |
|
| 114 | + $this->_views['draft']['count'] = $this->_admin_page->total_events_draft(); |
|
| 115 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) { |
|
| 116 | + $this->_views['trash']['count'] = $this->_admin_page->total_trashed_events(); |
|
| 117 | + } |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + |
|
| 121 | + /** |
|
| 122 | + * @param EE_Event $item |
|
| 123 | + * @return string |
|
| 124 | + */ |
|
| 125 | + protected function _get_row_class($item) |
|
| 126 | + { |
|
| 127 | + $class = parent::_get_row_class($item); |
|
| 128 | + //add status class |
|
| 129 | + $class .= $item instanceof EE_Event ? ' ee-status-strip event-status-' . $item->get_active_status() : ''; |
|
| 130 | + if ($this->_has_checkbox_column) { |
|
| 131 | + $class .= ' has-checkbox-column'; |
|
| 132 | + } |
|
| 133 | + return $class; |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + |
|
| 137 | + /** |
|
| 138 | + * @param EE_Event $item |
|
| 139 | + * @return string |
|
| 140 | + */ |
|
| 141 | + public function column_status(EE_Event $item) |
|
| 142 | + { |
|
| 143 | + return '<span class="ee-status-strip ee-status-strip-td event-status-' . $item->get_active_status() . '"></span>'; |
|
| 144 | + }/**/ |
|
| 145 | + |
|
| 146 | + |
|
| 147 | + /** |
|
| 148 | + * @param EE_Event $item |
|
| 149 | + * @return string |
|
| 150 | + */ |
|
| 151 | + public function column_cb($item) |
|
| 152 | + { |
|
| 153 | + if (! $item instanceof EE_Event) { |
|
| 154 | + return ''; |
|
| 155 | + } |
|
| 156 | + $this->_dtt = $item->primary_datetime(); //set this for use in other columns |
|
| 157 | + |
|
| 158 | + //does event have any attached registrations? |
|
| 159 | + $regs = $item->count_related('Registration'); |
|
| 160 | + return $regs > 0 && $this->_view == 'trash' ? '<span class="ee-lock-icon"></span>' : sprintf( |
|
| 161 | + '<input type="checkbox" name="EVT_IDs[]" value="%s" />', $item->ID() |
|
| 162 | + ); |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + |
|
| 166 | + /** |
|
| 167 | + * @param EE_Event $item |
|
| 168 | + * @return mixed|string |
|
| 169 | + */ |
|
| 170 | + public function column_id(EE_Event $item) |
|
| 171 | + { |
|
| 172 | + $content = $item->ID(); |
|
| 173 | + $content .= ' <span class="show-on-mobile-view-only">' . $item->name() . '</span>'; |
|
| 174 | + return $content; |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + |
|
| 178 | + /** |
|
| 179 | + * @param EE_Event $item |
|
| 180 | + * @return string |
|
| 181 | + */ |
|
| 182 | + public function column_name(EE_Event $item) |
|
| 183 | + { |
|
| 184 | + $edit_query_args = array( |
|
| 185 | + 'action' => 'edit', |
|
| 186 | + 'post' => $item->ID(), |
|
| 187 | + ); |
|
| 188 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
| 189 | + $actions = $this->_column_name_action_setup($item); |
|
| 190 | + $status = ''; //$item->status() !== 'publish' ? ' (' . $item->status() . ')' : ''; |
|
| 191 | + $content = '<strong><a class="row-title" href="' . $edit_link . '">' . $item->name() . '</a></strong>' . $status; |
|
| 192 | + $content .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status($item->get_active_status(), |
|
| 193 | + false, 'sentence') . '</span>'; |
|
| 194 | + $content .= $this->row_actions($actions); |
|
| 195 | + return $content; |
|
| 196 | + |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + |
|
| 200 | + /** |
|
| 201 | + * Just a method for setting up the actions for the name column |
|
| 202 | + * |
|
| 203 | + * @param EE_Event $item |
|
| 204 | + * @return array array of actions |
|
| 205 | + */ |
|
| 206 | + protected function _column_name_action_setup(EE_Event $item) |
|
| 207 | + { |
|
| 208 | + //todo: remove when attendees is active |
|
| 209 | + if (! defined('REG_ADMIN_URL')) { |
|
| 210 | + define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + $actions = array(); |
|
| 214 | + |
|
| 215 | + if (EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'espresso_events_edit', $item->ID())) { |
|
| 216 | + $edit_query_args = array( |
|
| 217 | + 'action' => 'edit', |
|
| 218 | + 'post' => $item->ID(), |
|
| 219 | + ); |
|
| 220 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
| 221 | + $actions['edit'] = '<a href="' . $edit_link . '" title="' . esc_attr__('Edit Event', |
|
| 222 | + 'event_espresso') . '">' . __('Edit', 'event_espresso') . '</a>'; |
|
| 223 | + |
|
| 224 | + } |
|
| 225 | + |
|
| 226 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registration', |
|
| 227 | + 'espresso_registrations_view_registration', $item->ID())) { |
|
| 228 | + $attendees_query_args = array( |
|
| 229 | + 'action' => 'default', |
|
| 230 | + 'event_id' => $item->ID(), |
|
| 231 | + ); |
|
| 232 | + $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
|
| 233 | + $actions['attendees'] = '<a href="' . $attendees_link . '" title="' . esc_attr__('View Registrations', |
|
| 234 | + 'event_espresso') . '">' . __('Registrations', 'event_espresso') . '</a>'; |
|
| 235 | + } |
|
| 236 | + |
|
| 237 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_event', 'espresso_events_trash_event', |
|
| 238 | + $item->ID())) { |
|
| 239 | + $trash_event_query_args = array( |
|
| 240 | + 'action' => 'trash_event', |
|
| 241 | + 'EVT_ID' => $item->ID(), |
|
| 242 | + ); |
|
| 243 | + $trash_event_link = EE_Admin_Page::add_query_args_and_nonce($trash_event_query_args, |
|
| 244 | + EVENTS_ADMIN_URL); |
|
| 245 | + } |
|
| 246 | + |
|
| 247 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_event', 'espresso_events_restore_event', |
|
| 248 | + $item->ID())) { |
|
| 249 | + $restore_event_query_args = array( |
|
| 250 | + 'action' => 'restore_event', |
|
| 251 | + 'EVT_ID' => $item->ID(), |
|
| 252 | + ); |
|
| 253 | + $restore_event_link = EE_Admin_Page::add_query_args_and_nonce($restore_event_query_args, |
|
| 254 | + EVENTS_ADMIN_URL); |
|
| 255 | + } |
|
| 256 | + |
|
| 257 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_event', 'espresso_events_delete_event', |
|
| 258 | + $item->ID())) { |
|
| 259 | + $delete_event_query_args = array( |
|
| 260 | + 'action' => 'delete_event', |
|
| 261 | + 'EVT_ID' => $item->ID(), |
|
| 262 | + ); |
|
| 263 | + $delete_event_link = EE_Admin_Page::add_query_args_and_nonce($delete_event_query_args, |
|
| 264 | + EVENTS_ADMIN_URL); |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + $view_link = get_permalink($item->ID()); |
|
| 268 | + |
|
| 269 | + $actions['view'] = '<a href="' . $view_link . '" title="' . esc_attr__('View Event', |
|
| 270 | + 'event_espresso') . '">' . __('View', 'event_espresso') . '</a>'; |
|
| 271 | + |
|
| 272 | + switch ($item->get('status')) { |
|
| 273 | + case 'trash' : |
|
| 274 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_event', 'espresso_events_restore_event', |
|
| 275 | + $item->ID())) { |
|
| 276 | + $actions['restore_from_trash'] = '<a href="' . $restore_event_link . '" title="' . esc_attr__('Restore from Trash', |
|
| 277 | + 'event_espresso') . '">' . __('Restore from Trash', 'event_espresso') . '</a>'; |
|
| 278 | + } |
|
| 279 | + if ($item->count_related('Registration') === 0 && EE_Registry::instance()->CAP->current_user_can('ee_delete_event', |
|
| 280 | + 'espresso_events_delete_event', $item->ID())) { |
|
| 281 | + $actions['delete'] = '<a href="' . $delete_event_link . '" title="' . esc_attr__('Delete Permanently', |
|
| 282 | + 'event_espresso') . '">' . __('Delete Permanently', 'event_espresso') . '</a>'; |
|
| 283 | + } |
|
| 284 | + break; |
|
| 285 | + default : |
|
| 286 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_event', 'espresso_events_trash_event', |
|
| 287 | + $item->ID())) { |
|
| 288 | + $actions['move to trash'] = '<a href="' . $trash_event_link . '" title="' . esc_attr__('Trash Event', |
|
| 289 | + 'event_espresso') . '">' . __('Trash', 'event_espresso') . '</a>'; |
|
| 290 | + } |
|
| 291 | + } |
|
| 292 | + return $actions; |
|
| 293 | + } |
|
| 294 | + |
|
| 295 | + |
|
| 296 | + /** |
|
| 297 | + * @param EE_Event $item |
|
| 298 | + * @return string |
|
| 299 | + */ |
|
| 300 | + public function column_author(EE_Event $item) |
|
| 301 | + { |
|
| 302 | + //user author info |
|
| 303 | + $event_author = get_userdata($item->wp_user()); |
|
| 304 | + $gravatar = get_avatar($item->wp_user(), '15'); |
|
| 305 | + //filter link |
|
| 306 | + $query_args = array( |
|
| 307 | + 'action' => 'default', |
|
| 308 | + 'EVT_wp_user' => $item->wp_user(), |
|
| 309 | + ); |
|
| 310 | + $filter_url = EE_Admin_Page::add_query_args_and_nonce($query_args, EVENTS_ADMIN_URL); |
|
| 311 | + return $gravatar . ' <a href="' . $filter_url . '" title="' . esc_attr__('Click to filter events by this author.', |
|
| 312 | + 'event_espresso') . '">' . $event_author->display_name . '</a>'; |
|
| 313 | + } |
|
| 314 | + |
|
| 315 | + |
|
| 316 | + /** |
|
| 317 | + * @param EE_Event $item |
|
| 318 | + * @return string |
|
| 319 | + */ |
|
| 320 | + public function column_venue(EE_Event $item) |
|
| 321 | + { |
|
| 322 | + $venue = $item->get_first_related('Venue'); |
|
| 323 | + return ! empty($venue) ? $venue->name() : ''; |
|
| 324 | + } |
|
| 325 | + |
|
| 326 | + |
|
| 327 | + /** |
|
| 328 | + * @param EE_Event $item |
|
| 329 | + * @throws EE_Error |
|
| 330 | + */ |
|
| 331 | + public function column_start_date_time(EE_Event $item) |
|
| 332 | + { |
|
| 333 | + echo ! empty($this->_dtt) ? $this->_dtt->get_i18n_datetime('DTT_EVT_start') : __('No Date was saved for this Event', |
|
| 334 | + 'event_espresso'); |
|
| 335 | + //display in user's timezone? |
|
| 336 | + echo ! empty($this->_dtt) ? $this->_dtt->display_in_my_timezone('DTT_EVT_start', 'get_i18n_datetime', '', |
|
| 337 | + 'My Timezone: ') : ''; |
|
| 338 | + |
|
| 339 | + } |
|
| 340 | + |
|
| 341 | + |
|
| 342 | + /** |
|
| 343 | + * @param EE_Event $item |
|
| 344 | + * @throws EE_Error |
|
| 345 | + */ |
|
| 346 | + public function column_reg_begins(EE_Event $item) |
|
| 347 | + { |
|
| 348 | + $reg_start = $item->get_ticket_with_earliest_start_time(); |
|
| 349 | + echo ! empty($reg_start) ? $reg_start->get_i18n_datetime('TKT_start_date') : __('No Tickets have been setup for this Event', |
|
| 350 | + 'event_espresso'); |
|
| 351 | + //display in user's timezone? |
|
| 352 | + echo ! empty($reg_start) ? $reg_start->display_in_my_timezone('TKT_start_date', 'get_i18n_datetime', '', |
|
| 353 | + 'My Timezone: ') : '';/**/ |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + |
|
| 357 | + /** |
|
| 358 | + * @param EE_Event $item |
|
| 359 | + * @return int|string |
|
| 360 | + */ |
|
| 361 | + public function column_attendees(EE_Event $item) |
|
| 362 | + { |
|
| 363 | + $attendees_query_args = array( |
|
| 364 | + 'action' => 'default', |
|
| 365 | + 'event_id' => $item->ID(), |
|
| 366 | + ); |
|
| 367 | + $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
|
| 368 | + $registered_attendees = EEM_Registration::instance()->get_event_registration_count($item->ID()); |
|
| 369 | + return EE_Registry::instance()->CAP->current_user_can('ee_read_registration', |
|
| 370 | + 'espresso_registrations_view_registration', |
|
| 371 | + $item->ID()) ? '<a href="' . $attendees_link . '">' . $registered_attendees . '</a>' : $registered_attendees; |
|
| 372 | + } |
|
| 373 | + |
|
| 374 | + |
|
| 375 | + /** |
|
| 376 | + * @param EE_Event $item |
|
| 377 | + * @return float |
|
| 378 | + */ |
|
| 379 | + public function column_tkts_sold(EE_Event $item) |
|
| 380 | + { |
|
| 381 | + return EEM_Ticket::instance()->sum(array(array('Datetime.EVT_ID' => $item->ID())), 'TKT_sold'); |
|
| 382 | + } |
|
| 383 | + |
|
| 384 | + |
|
| 385 | + /** |
|
| 386 | + * @param EE_Event $item |
|
| 387 | + * @return string |
|
| 388 | + */ |
|
| 389 | + public function column_actions(EE_Event $item) |
|
| 390 | + { |
|
| 391 | + //todo: remove when attendees is active |
|
| 392 | + if (! defined('REG_ADMIN_URL')) { |
|
| 393 | + define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
|
| 394 | + } |
|
| 395 | + $actionlinks = array(); |
|
| 396 | + |
|
| 397 | + $view_link = get_permalink($item->ID()); |
|
| 398 | + |
|
| 399 | + $actionlinks[] = '<a href="' . $view_link . '" title="' . esc_attr__('View Event', |
|
| 400 | + 'event_espresso') . '" target="_blank">'; |
|
| 401 | + $actionlinks[] = '<div class="dashicons dashicons-search"></div></a>'; |
|
| 402 | + |
|
| 403 | + if (EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'espresso_events_edit', $item->ID())) { |
|
| 404 | + $edit_query_args = array( |
|
| 405 | + 'action' => 'edit', |
|
| 406 | + 'post' => $item->ID(), |
|
| 407 | + ); |
|
| 408 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
| 409 | + $actionlinks[] = '<a href="' . $edit_link . '" title="' . esc_attr__('Edit Event', |
|
| 410 | + 'event_espresso') . '"><div class="ee-icon ee-icon-calendar-edit"></div></a>'; |
|
| 411 | + } |
|
| 412 | + |
|
| 413 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registration', |
|
| 414 | + 'espresso_registrations_view_registration', $item->ID())) { |
|
| 415 | + $attendees_query_args = array( |
|
| 416 | + 'action' => 'default', |
|
| 417 | + 'event_id' => $item->ID(), |
|
| 418 | + ); |
|
| 419 | + $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
|
| 420 | + $actionlinks[] = '<a href="' . $attendees_link . '" title="' . esc_attr__('View Registrants', |
|
| 421 | + 'event_espresso') . '"><div class="dashicons dashicons-groups"></div></a>'; |
|
| 422 | + } |
|
| 423 | + |
|
| 424 | + $actionlinks = apply_filters('FHEE__Events_Admin_List_Table__column_actions__action_links', $actionlinks, |
|
| 425 | + $item); |
|
| 426 | + |
|
| 427 | + return $this->_action_string(implode("\n\t", $actionlinks), $item, 'div'); |
|
| 428 | + } |
|
| 429 | 429 | |
| 430 | 430 | |
| 431 | 431 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 3 | 3 | exit('NO direct script access allowed'); |
| 4 | 4 | } |
| 5 | 5 | |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | public function __construct($admin_page) |
| 41 | 41 | { |
| 42 | 42 | parent::__construct($admin_page); |
| 43 | - require_once(EE_HELPERS . 'EEH_DTT_Helper.helper.php'); |
|
| 43 | + require_once(EE_HELPERS.'EEH_DTT_Helper.helper.php'); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | { |
| 127 | 127 | $class = parent::_get_row_class($item); |
| 128 | 128 | //add status class |
| 129 | - $class .= $item instanceof EE_Event ? ' ee-status-strip event-status-' . $item->get_active_status() : ''; |
|
| 129 | + $class .= $item instanceof EE_Event ? ' ee-status-strip event-status-'.$item->get_active_status() : ''; |
|
| 130 | 130 | if ($this->_has_checkbox_column) { |
| 131 | 131 | $class .= ' has-checkbox-column'; |
| 132 | 132 | } |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | */ |
| 141 | 141 | public function column_status(EE_Event $item) |
| 142 | 142 | { |
| 143 | - return '<span class="ee-status-strip ee-status-strip-td event-status-' . $item->get_active_status() . '"></span>'; |
|
| 143 | + return '<span class="ee-status-strip ee-status-strip-td event-status-'.$item->get_active_status().'"></span>'; |
|
| 144 | 144 | }/**/ |
| 145 | 145 | |
| 146 | 146 | |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | */ |
| 151 | 151 | public function column_cb($item) |
| 152 | 152 | { |
| 153 | - if (! $item instanceof EE_Event) { |
|
| 153 | + if ( ! $item instanceof EE_Event) { |
|
| 154 | 154 | return ''; |
| 155 | 155 | } |
| 156 | 156 | $this->_dtt = $item->primary_datetime(); //set this for use in other columns |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | public function column_id(EE_Event $item) |
| 171 | 171 | { |
| 172 | 172 | $content = $item->ID(); |
| 173 | - $content .= ' <span class="show-on-mobile-view-only">' . $item->name() . '</span>'; |
|
| 173 | + $content .= ' <span class="show-on-mobile-view-only">'.$item->name().'</span>'; |
|
| 174 | 174 | return $content; |
| 175 | 175 | } |
| 176 | 176 | |
@@ -188,9 +188,9 @@ discard block |
||
| 188 | 188 | $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
| 189 | 189 | $actions = $this->_column_name_action_setup($item); |
| 190 | 190 | $status = ''; //$item->status() !== 'publish' ? ' (' . $item->status() . ')' : ''; |
| 191 | - $content = '<strong><a class="row-title" href="' . $edit_link . '">' . $item->name() . '</a></strong>' . $status; |
|
| 192 | - $content .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status($item->get_active_status(), |
|
| 193 | - false, 'sentence') . '</span>'; |
|
| 191 | + $content = '<strong><a class="row-title" href="'.$edit_link.'">'.$item->name().'</a></strong>'.$status; |
|
| 192 | + $content .= '<br><span class="ee-status-text-small">'.EEH_Template::pretty_status($item->get_active_status(), |
|
| 193 | + false, 'sentence').'</span>'; |
|
| 194 | 194 | $content .= $this->row_actions($actions); |
| 195 | 195 | return $content; |
| 196 | 196 | |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | protected function _column_name_action_setup(EE_Event $item) |
| 207 | 207 | { |
| 208 | 208 | //todo: remove when attendees is active |
| 209 | - if (! defined('REG_ADMIN_URL')) { |
|
| 209 | + if ( ! defined('REG_ADMIN_URL')) { |
|
| 210 | 210 | define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
| 211 | 211 | } |
| 212 | 212 | |
@@ -218,8 +218,8 @@ discard block |
||
| 218 | 218 | 'post' => $item->ID(), |
| 219 | 219 | ); |
| 220 | 220 | $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
| 221 | - $actions['edit'] = '<a href="' . $edit_link . '" title="' . esc_attr__('Edit Event', |
|
| 222 | - 'event_espresso') . '">' . __('Edit', 'event_espresso') . '</a>'; |
|
| 221 | + $actions['edit'] = '<a href="'.$edit_link.'" title="'.esc_attr__('Edit Event', |
|
| 222 | + 'event_espresso').'">'.__('Edit', 'event_espresso').'</a>'; |
|
| 223 | 223 | |
| 224 | 224 | } |
| 225 | 225 | |
@@ -230,8 +230,8 @@ discard block |
||
| 230 | 230 | 'event_id' => $item->ID(), |
| 231 | 231 | ); |
| 232 | 232 | $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
| 233 | - $actions['attendees'] = '<a href="' . $attendees_link . '" title="' . esc_attr__('View Registrations', |
|
| 234 | - 'event_espresso') . '">' . __('Registrations', 'event_espresso') . '</a>'; |
|
| 233 | + $actions['attendees'] = '<a href="'.$attendees_link.'" title="'.esc_attr__('View Registrations', |
|
| 234 | + 'event_espresso').'">'.__('Registrations', 'event_espresso').'</a>'; |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | if (EE_Registry::instance()->CAP->current_user_can('ee_delete_event', 'espresso_events_trash_event', |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | 'action' => 'trash_event', |
| 241 | 241 | 'EVT_ID' => $item->ID(), |
| 242 | 242 | ); |
| 243 | - $trash_event_link = EE_Admin_Page::add_query_args_and_nonce($trash_event_query_args, |
|
| 243 | + $trash_event_link = EE_Admin_Page::add_query_args_and_nonce($trash_event_query_args, |
|
| 244 | 244 | EVENTS_ADMIN_URL); |
| 245 | 245 | } |
| 246 | 246 | |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | 'action' => 'restore_event', |
| 251 | 251 | 'EVT_ID' => $item->ID(), |
| 252 | 252 | ); |
| 253 | - $restore_event_link = EE_Admin_Page::add_query_args_and_nonce($restore_event_query_args, |
|
| 253 | + $restore_event_link = EE_Admin_Page::add_query_args_and_nonce($restore_event_query_args, |
|
| 254 | 254 | EVENTS_ADMIN_URL); |
| 255 | 255 | } |
| 256 | 256 | |
@@ -260,33 +260,33 @@ discard block |
||
| 260 | 260 | 'action' => 'delete_event', |
| 261 | 261 | 'EVT_ID' => $item->ID(), |
| 262 | 262 | ); |
| 263 | - $delete_event_link = EE_Admin_Page::add_query_args_and_nonce($delete_event_query_args, |
|
| 263 | + $delete_event_link = EE_Admin_Page::add_query_args_and_nonce($delete_event_query_args, |
|
| 264 | 264 | EVENTS_ADMIN_URL); |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | $view_link = get_permalink($item->ID()); |
| 268 | 268 | |
| 269 | - $actions['view'] = '<a href="' . $view_link . '" title="' . esc_attr__('View Event', |
|
| 270 | - 'event_espresso') . '">' . __('View', 'event_espresso') . '</a>'; |
|
| 269 | + $actions['view'] = '<a href="'.$view_link.'" title="'.esc_attr__('View Event', |
|
| 270 | + 'event_espresso').'">'.__('View', 'event_espresso').'</a>'; |
|
| 271 | 271 | |
| 272 | 272 | switch ($item->get('status')) { |
| 273 | 273 | case 'trash' : |
| 274 | 274 | if (EE_Registry::instance()->CAP->current_user_can('ee_delete_event', 'espresso_events_restore_event', |
| 275 | 275 | $item->ID())) { |
| 276 | - $actions['restore_from_trash'] = '<a href="' . $restore_event_link . '" title="' . esc_attr__('Restore from Trash', |
|
| 277 | - 'event_espresso') . '">' . __('Restore from Trash', 'event_espresso') . '</a>'; |
|
| 276 | + $actions['restore_from_trash'] = '<a href="'.$restore_event_link.'" title="'.esc_attr__('Restore from Trash', |
|
| 277 | + 'event_espresso').'">'.__('Restore from Trash', 'event_espresso').'</a>'; |
|
| 278 | 278 | } |
| 279 | 279 | if ($item->count_related('Registration') === 0 && EE_Registry::instance()->CAP->current_user_can('ee_delete_event', |
| 280 | 280 | 'espresso_events_delete_event', $item->ID())) { |
| 281 | - $actions['delete'] = '<a href="' . $delete_event_link . '" title="' . esc_attr__('Delete Permanently', |
|
| 282 | - 'event_espresso') . '">' . __('Delete Permanently', 'event_espresso') . '</a>'; |
|
| 281 | + $actions['delete'] = '<a href="'.$delete_event_link.'" title="'.esc_attr__('Delete Permanently', |
|
| 282 | + 'event_espresso').'">'.__('Delete Permanently', 'event_espresso').'</a>'; |
|
| 283 | 283 | } |
| 284 | 284 | break; |
| 285 | 285 | default : |
| 286 | 286 | if (EE_Registry::instance()->CAP->current_user_can('ee_delete_event', 'espresso_events_trash_event', |
| 287 | 287 | $item->ID())) { |
| 288 | - $actions['move to trash'] = '<a href="' . $trash_event_link . '" title="' . esc_attr__('Trash Event', |
|
| 289 | - 'event_espresso') . '">' . __('Trash', 'event_espresso') . '</a>'; |
|
| 288 | + $actions['move to trash'] = '<a href="'.$trash_event_link.'" title="'.esc_attr__('Trash Event', |
|
| 289 | + 'event_espresso').'">'.__('Trash', 'event_espresso').'</a>'; |
|
| 290 | 290 | } |
| 291 | 291 | } |
| 292 | 292 | return $actions; |
@@ -308,8 +308,8 @@ discard block |
||
| 308 | 308 | 'EVT_wp_user' => $item->wp_user(), |
| 309 | 309 | ); |
| 310 | 310 | $filter_url = EE_Admin_Page::add_query_args_and_nonce($query_args, EVENTS_ADMIN_URL); |
| 311 | - return $gravatar . ' <a href="' . $filter_url . '" title="' . esc_attr__('Click to filter events by this author.', |
|
| 312 | - 'event_espresso') . '">' . $event_author->display_name . '</a>'; |
|
| 311 | + return $gravatar.' <a href="'.$filter_url.'" title="'.esc_attr__('Click to filter events by this author.', |
|
| 312 | + 'event_espresso').'">'.$event_author->display_name.'</a>'; |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | 'event_espresso'); |
| 351 | 351 | //display in user's timezone? |
| 352 | 352 | echo ! empty($reg_start) ? $reg_start->display_in_my_timezone('TKT_start_date', 'get_i18n_datetime', '', |
| 353 | - 'My Timezone: ') : '';/**/ |
|
| 353 | + 'My Timezone: ') : ''; /**/ |
|
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | $registered_attendees = EEM_Registration::instance()->get_event_registration_count($item->ID()); |
| 369 | 369 | return EE_Registry::instance()->CAP->current_user_can('ee_read_registration', |
| 370 | 370 | 'espresso_registrations_view_registration', |
| 371 | - $item->ID()) ? '<a href="' . $attendees_link . '">' . $registered_attendees . '</a>' : $registered_attendees; |
|
| 371 | + $item->ID()) ? '<a href="'.$attendees_link.'">'.$registered_attendees.'</a>' : $registered_attendees; |
|
| 372 | 372 | } |
| 373 | 373 | |
| 374 | 374 | |
@@ -389,15 +389,15 @@ discard block |
||
| 389 | 389 | public function column_actions(EE_Event $item) |
| 390 | 390 | { |
| 391 | 391 | //todo: remove when attendees is active |
| 392 | - if (! defined('REG_ADMIN_URL')) { |
|
| 392 | + if ( ! defined('REG_ADMIN_URL')) { |
|
| 393 | 393 | define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
| 394 | 394 | } |
| 395 | 395 | $actionlinks = array(); |
| 396 | 396 | |
| 397 | 397 | $view_link = get_permalink($item->ID()); |
| 398 | 398 | |
| 399 | - $actionlinks[] = '<a href="' . $view_link . '" title="' . esc_attr__('View Event', |
|
| 400 | - 'event_espresso') . '" target="_blank">'; |
|
| 399 | + $actionlinks[] = '<a href="'.$view_link.'" title="'.esc_attr__('View Event', |
|
| 400 | + 'event_espresso').'" target="_blank">'; |
|
| 401 | 401 | $actionlinks[] = '<div class="dashicons dashicons-search"></div></a>'; |
| 402 | 402 | |
| 403 | 403 | if (EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'espresso_events_edit', $item->ID())) { |
@@ -406,8 +406,8 @@ discard block |
||
| 406 | 406 | 'post' => $item->ID(), |
| 407 | 407 | ); |
| 408 | 408 | $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
| 409 | - $actionlinks[] = '<a href="' . $edit_link . '" title="' . esc_attr__('Edit Event', |
|
| 410 | - 'event_espresso') . '"><div class="ee-icon ee-icon-calendar-edit"></div></a>'; |
|
| 409 | + $actionlinks[] = '<a href="'.$edit_link.'" title="'.esc_attr__('Edit Event', |
|
| 410 | + 'event_espresso').'"><div class="ee-icon ee-icon-calendar-edit"></div></a>'; |
|
| 411 | 411 | } |
| 412 | 412 | |
| 413 | 413 | if (EE_Registry::instance()->CAP->current_user_can('ee_read_registration', |
@@ -417,8 +417,8 @@ discard block |
||
| 417 | 417 | 'event_id' => $item->ID(), |
| 418 | 418 | ); |
| 419 | 419 | $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
| 420 | - $actionlinks[] = '<a href="' . $attendees_link . '" title="' . esc_attr__('View Registrants', |
|
| 421 | - 'event_espresso') . '"><div class="dashicons dashicons-groups"></div></a>'; |
|
| 420 | + $actionlinks[] = '<a href="'.$attendees_link.'" title="'.esc_attr__('View Registrants', |
|
| 421 | + 'event_espresso').'"><div class="dashicons dashicons-groups"></div></a>'; |
|
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | $actionlinks = apply_filters('FHEE__Events_Admin_List_Table__column_actions__action_links', $actionlinks, |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php if ( ! defined('ABSPATH')) { |
| 2 | - exit('No direct script access allowed'); |
|
| 2 | + exit('No direct script access allowed'); |
|
| 3 | 3 | } |
| 4 | 4 | /* |
| 5 | 5 | Plugin Name: Event Espresso |
@@ -40,243 +40,243 @@ discard block |
||
| 40 | 40 | * @since 4.0 |
| 41 | 41 | */ |
| 42 | 42 | if (function_exists('espresso_version')) { |
| 43 | - /** |
|
| 44 | - * espresso_duplicate_plugin_error |
|
| 45 | - * displays if more than one version of EE is activated at the same time |
|
| 46 | - */ |
|
| 47 | - function espresso_duplicate_plugin_error() |
|
| 48 | - { |
|
| 49 | - ?> |
|
| 43 | + /** |
|
| 44 | + * espresso_duplicate_plugin_error |
|
| 45 | + * displays if more than one version of EE is activated at the same time |
|
| 46 | + */ |
|
| 47 | + function espresso_duplicate_plugin_error() |
|
| 48 | + { |
|
| 49 | + ?> |
|
| 50 | 50 | <div class="error"> |
| 51 | 51 | <p> |
| 52 | 52 | <?php 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 | - ); ?> |
|
| 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 | - } |
|
| 59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
| 62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
| 63 | 63 | } else { |
| 64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
| 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.3.9'); |
|
| 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 | - /** |
|
| 97 | - * espresso_version |
|
| 98 | - * Returns the plugin version |
|
| 99 | - * |
|
| 100 | - * @return string |
|
| 101 | - */ |
|
| 102 | - function espresso_version() |
|
| 103 | - { |
|
| 104 | - return apply_filters('FHEE__espresso__espresso_version', '4.9.46.rc.011'); |
|
| 105 | - } |
|
| 94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
| 95 | + } else { |
|
| 96 | + /** |
|
| 97 | + * espresso_version |
|
| 98 | + * Returns the plugin version |
|
| 99 | + * |
|
| 100 | + * @return string |
|
| 101 | + */ |
|
| 102 | + function espresso_version() |
|
| 103 | + { |
|
| 104 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.46.rc.011'); |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | - // define versions |
|
| 108 | - define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
| 109 | - define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
| 110 | - define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
| 111 | - define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
| 112 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
| 113 | - //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
|
| 114 | - if ( ! defined('DS')) { |
|
| 115 | - define('DS', '/'); |
|
| 116 | - } |
|
| 117 | - if ( ! defined('PS')) { |
|
| 118 | - define('PS', PATH_SEPARATOR); |
|
| 119 | - } |
|
| 120 | - if ( ! defined('SP')) { |
|
| 121 | - define('SP', ' '); |
|
| 122 | - } |
|
| 123 | - if ( ! defined('EENL')) { |
|
| 124 | - define('EENL', "\n"); |
|
| 125 | - } |
|
| 126 | - define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
| 127 | - // define the plugin directory and URL |
|
| 128 | - define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 129 | - define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 130 | - define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 131 | - // main root folder paths |
|
| 132 | - define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS); |
|
| 133 | - define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS); |
|
| 134 | - define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS); |
|
| 135 | - define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS); |
|
| 136 | - define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS); |
|
| 137 | - define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS); |
|
| 138 | - define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS); |
|
| 139 | - define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS); |
|
| 140 | - // core system paths |
|
| 141 | - define('EE_ADMIN', EE_CORE . 'admin' . DS); |
|
| 142 | - define('EE_CPTS', EE_CORE . 'CPTs' . DS); |
|
| 143 | - define('EE_CLASSES', EE_CORE . 'db_classes' . DS); |
|
| 144 | - define('EE_INTERFACES', EE_CORE . 'interfaces' . DS); |
|
| 145 | - define('EE_BUSINESS', EE_CORE . 'business' . DS); |
|
| 146 | - define('EE_MODELS', EE_CORE . 'db_models' . DS); |
|
| 147 | - define('EE_HELPERS', EE_CORE . 'helpers' . DS); |
|
| 148 | - define('EE_LIBRARIES', EE_CORE . 'libraries' . DS); |
|
| 149 | - define('EE_TEMPLATES', EE_CORE . 'templates' . DS); |
|
| 150 | - define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS); |
|
| 151 | - define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS); |
|
| 152 | - define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS); |
|
| 153 | - // gateways |
|
| 154 | - define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS); |
|
| 155 | - define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS); |
|
| 156 | - // asset URL paths |
|
| 157 | - define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS); |
|
| 158 | - define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS); |
|
| 159 | - define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS); |
|
| 160 | - define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS); |
|
| 161 | - define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/'); |
|
| 162 | - define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/'); |
|
| 163 | - // define upload paths |
|
| 164 | - $uploads = wp_upload_dir(); |
|
| 165 | - // define the uploads directory and URL |
|
| 166 | - define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS); |
|
| 167 | - define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS); |
|
| 168 | - // define the templates directory and URL |
|
| 169 | - define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS); |
|
| 170 | - define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS); |
|
| 171 | - // define the gateway directory and URL |
|
| 172 | - define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
| 173 | - define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
| 174 | - // languages folder/path |
|
| 175 | - define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS); |
|
| 176 | - define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); |
|
| 177 | - //check for dompdf fonts in uploads |
|
| 178 | - if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { |
|
| 179 | - define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); |
|
| 180 | - } |
|
| 181 | - //ajax constants |
|
| 182 | - define( |
|
| 183 | - 'EE_FRONT_AJAX', |
|
| 184 | - isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false |
|
| 185 | - ); |
|
| 186 | - define( |
|
| 187 | - 'EE_ADMIN_AJAX', |
|
| 188 | - isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false |
|
| 189 | - ); |
|
| 190 | - //just a handy constant occasionally needed for finding values representing infinity in the DB |
|
| 191 | - //you're better to use this than its straight value (currently -1) in case you ever |
|
| 192 | - //want to change its default value! or find when -1 means infinity |
|
| 193 | - define('EE_INF_IN_DB', -1); |
|
| 194 | - define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
| 195 | - define('EE_DEBUG', false); |
|
| 196 | - // for older WP versions |
|
| 197 | - if ( ! defined('MONTH_IN_SECONDS')) { |
|
| 198 | - define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30); |
|
| 199 | - } |
|
| 200 | - /** |
|
| 201 | - * espresso_plugin_activation |
|
| 202 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
| 203 | - */ |
|
| 204 | - function espresso_plugin_activation() |
|
| 205 | - { |
|
| 206 | - update_option('ee_espresso_activation', true); |
|
| 207 | - } |
|
| 107 | + // define versions |
|
| 108 | + define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
| 109 | + define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
| 110 | + define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
| 111 | + define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
| 112 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
| 113 | + //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
|
| 114 | + if ( ! defined('DS')) { |
|
| 115 | + define('DS', '/'); |
|
| 116 | + } |
|
| 117 | + if ( ! defined('PS')) { |
|
| 118 | + define('PS', PATH_SEPARATOR); |
|
| 119 | + } |
|
| 120 | + if ( ! defined('SP')) { |
|
| 121 | + define('SP', ' '); |
|
| 122 | + } |
|
| 123 | + if ( ! defined('EENL')) { |
|
| 124 | + define('EENL', "\n"); |
|
| 125 | + } |
|
| 126 | + define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
| 127 | + // define the plugin directory and URL |
|
| 128 | + define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 129 | + define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 130 | + define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 131 | + // main root folder paths |
|
| 132 | + define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS); |
|
| 133 | + define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS); |
|
| 134 | + define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS); |
|
| 135 | + define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS); |
|
| 136 | + define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS); |
|
| 137 | + define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS); |
|
| 138 | + define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS); |
|
| 139 | + define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS); |
|
| 140 | + // core system paths |
|
| 141 | + define('EE_ADMIN', EE_CORE . 'admin' . DS); |
|
| 142 | + define('EE_CPTS', EE_CORE . 'CPTs' . DS); |
|
| 143 | + define('EE_CLASSES', EE_CORE . 'db_classes' . DS); |
|
| 144 | + define('EE_INTERFACES', EE_CORE . 'interfaces' . DS); |
|
| 145 | + define('EE_BUSINESS', EE_CORE . 'business' . DS); |
|
| 146 | + define('EE_MODELS', EE_CORE . 'db_models' . DS); |
|
| 147 | + define('EE_HELPERS', EE_CORE . 'helpers' . DS); |
|
| 148 | + define('EE_LIBRARIES', EE_CORE . 'libraries' . DS); |
|
| 149 | + define('EE_TEMPLATES', EE_CORE . 'templates' . DS); |
|
| 150 | + define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS); |
|
| 151 | + define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS); |
|
| 152 | + define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS); |
|
| 153 | + // gateways |
|
| 154 | + define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS); |
|
| 155 | + define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS); |
|
| 156 | + // asset URL paths |
|
| 157 | + define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS); |
|
| 158 | + define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS); |
|
| 159 | + define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS); |
|
| 160 | + define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS); |
|
| 161 | + define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/'); |
|
| 162 | + define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/'); |
|
| 163 | + // define upload paths |
|
| 164 | + $uploads = wp_upload_dir(); |
|
| 165 | + // define the uploads directory and URL |
|
| 166 | + define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS); |
|
| 167 | + define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS); |
|
| 168 | + // define the templates directory and URL |
|
| 169 | + define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS); |
|
| 170 | + define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS); |
|
| 171 | + // define the gateway directory and URL |
|
| 172 | + define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
| 173 | + define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
| 174 | + // languages folder/path |
|
| 175 | + define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS); |
|
| 176 | + define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); |
|
| 177 | + //check for dompdf fonts in uploads |
|
| 178 | + if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { |
|
| 179 | + define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); |
|
| 180 | + } |
|
| 181 | + //ajax constants |
|
| 182 | + define( |
|
| 183 | + 'EE_FRONT_AJAX', |
|
| 184 | + isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false |
|
| 185 | + ); |
|
| 186 | + define( |
|
| 187 | + 'EE_ADMIN_AJAX', |
|
| 188 | + isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false |
|
| 189 | + ); |
|
| 190 | + //just a handy constant occasionally needed for finding values representing infinity in the DB |
|
| 191 | + //you're better to use this than its straight value (currently -1) in case you ever |
|
| 192 | + //want to change its default value! or find when -1 means infinity |
|
| 193 | + define('EE_INF_IN_DB', -1); |
|
| 194 | + define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
| 195 | + define('EE_DEBUG', false); |
|
| 196 | + // for older WP versions |
|
| 197 | + if ( ! defined('MONTH_IN_SECONDS')) { |
|
| 198 | + define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30); |
|
| 199 | + } |
|
| 200 | + /** |
|
| 201 | + * espresso_plugin_activation |
|
| 202 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
| 203 | + */ |
|
| 204 | + function espresso_plugin_activation() |
|
| 205 | + { |
|
| 206 | + update_option('ee_espresso_activation', true); |
|
| 207 | + } |
|
| 208 | 208 | |
| 209 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
| 210 | - /** |
|
| 211 | - * espresso_load_error_handling |
|
| 212 | - * this function loads EE's class for handling exceptions and errors |
|
| 213 | - */ |
|
| 214 | - function espresso_load_error_handling() |
|
| 215 | - { |
|
| 216 | - // load debugging tools |
|
| 217 | - if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
| 218 | - require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php'); |
|
| 219 | - EEH_Debug_Tools::instance(); |
|
| 220 | - } |
|
| 221 | - // load error handling |
|
| 222 | - if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
| 223 | - require_once(EE_CORE . 'EE_Error.core.php'); |
|
| 224 | - } else { |
|
| 225 | - wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
| 226 | - } |
|
| 227 | - } |
|
| 209 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
| 210 | + /** |
|
| 211 | + * espresso_load_error_handling |
|
| 212 | + * this function loads EE's class for handling exceptions and errors |
|
| 213 | + */ |
|
| 214 | + function espresso_load_error_handling() |
|
| 215 | + { |
|
| 216 | + // load debugging tools |
|
| 217 | + if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
| 218 | + require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php'); |
|
| 219 | + EEH_Debug_Tools::instance(); |
|
| 220 | + } |
|
| 221 | + // load error handling |
|
| 222 | + if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
| 223 | + require_once(EE_CORE . 'EE_Error.core.php'); |
|
| 224 | + } else { |
|
| 225 | + wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
| 226 | + } |
|
| 227 | + } |
|
| 228 | 228 | |
| 229 | - /** |
|
| 230 | - * espresso_load_required |
|
| 231 | - * given a class name and path, this function will load that file or throw an exception |
|
| 232 | - * |
|
| 233 | - * @param string $classname |
|
| 234 | - * @param string $full_path_to_file |
|
| 235 | - * @throws EE_Error |
|
| 236 | - */ |
|
| 237 | - function espresso_load_required($classname, $full_path_to_file) |
|
| 238 | - { |
|
| 239 | - static $error_handling_loaded = false; |
|
| 240 | - if ( ! $error_handling_loaded) { |
|
| 241 | - espresso_load_error_handling(); |
|
| 242 | - $error_handling_loaded = true; |
|
| 243 | - } |
|
| 244 | - if (is_readable($full_path_to_file)) { |
|
| 245 | - require_once($full_path_to_file); |
|
| 246 | - } else { |
|
| 247 | - throw new EE_Error ( |
|
| 248 | - sprintf( |
|
| 249 | - esc_html__( |
|
| 250 | - 'The %s class file could not be located or is not readable due to file permissions.', |
|
| 251 | - 'event_espresso' |
|
| 252 | - ), |
|
| 253 | - $classname |
|
| 254 | - ) |
|
| 255 | - ); |
|
| 256 | - } |
|
| 257 | - } |
|
| 229 | + /** |
|
| 230 | + * espresso_load_required |
|
| 231 | + * given a class name and path, this function will load that file or throw an exception |
|
| 232 | + * |
|
| 233 | + * @param string $classname |
|
| 234 | + * @param string $full_path_to_file |
|
| 235 | + * @throws EE_Error |
|
| 236 | + */ |
|
| 237 | + function espresso_load_required($classname, $full_path_to_file) |
|
| 238 | + { |
|
| 239 | + static $error_handling_loaded = false; |
|
| 240 | + if ( ! $error_handling_loaded) { |
|
| 241 | + espresso_load_error_handling(); |
|
| 242 | + $error_handling_loaded = true; |
|
| 243 | + } |
|
| 244 | + if (is_readable($full_path_to_file)) { |
|
| 245 | + require_once($full_path_to_file); |
|
| 246 | + } else { |
|
| 247 | + throw new EE_Error ( |
|
| 248 | + sprintf( |
|
| 249 | + esc_html__( |
|
| 250 | + 'The %s class file could not be located or is not readable due to file permissions.', |
|
| 251 | + 'event_espresso' |
|
| 252 | + ), |
|
| 253 | + $classname |
|
| 254 | + ) |
|
| 255 | + ); |
|
| 256 | + } |
|
| 257 | + } |
|
| 258 | 258 | |
| 259 | - espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); |
|
| 260 | - espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); |
|
| 261 | - espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); |
|
| 262 | - new EE_Bootstrap(); |
|
| 263 | - } |
|
| 259 | + espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); |
|
| 260 | + espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); |
|
| 261 | + espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); |
|
| 262 | + new EE_Bootstrap(); |
|
| 263 | + } |
|
| 264 | 264 | } |
| 265 | 265 | if ( ! function_exists('espresso_deactivate_plugin')) { |
| 266 | - /** |
|
| 267 | - * deactivate_plugin |
|
| 268 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
| 269 | - * |
|
| 270 | - * @access public |
|
| 271 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
| 272 | - * @return void |
|
| 273 | - */ |
|
| 274 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
| 275 | - { |
|
| 276 | - if ( ! function_exists('deactivate_plugins')) { |
|
| 277 | - require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
| 278 | - } |
|
| 279 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
| 280 | - deactivate_plugins($plugin_basename); |
|
| 281 | - } |
|
| 266 | + /** |
|
| 267 | + * deactivate_plugin |
|
| 268 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
| 269 | + * |
|
| 270 | + * @access public |
|
| 271 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
| 272 | + * @return void |
|
| 273 | + */ |
|
| 274 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
| 275 | + { |
|
| 276 | + if ( ! function_exists('deactivate_plugins')) { |
|
| 277 | + require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
| 278 | + } |
|
| 279 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
| 280 | + deactivate_plugins($plugin_basename); |
|
| 281 | + } |
|
| 282 | 282 | } |
| 283 | 283 | \ No newline at end of file |
@@ -17,243 +17,243 @@ |
||
| 17 | 17 | final class EE_Module_Request_Router implements InterminableInterface |
| 18 | 18 | { |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * @var array $_previous_routes |
|
| 22 | - */ |
|
| 23 | - private static $_previous_routes = array(); |
|
| 20 | + /** |
|
| 21 | + * @var array $_previous_routes |
|
| 22 | + */ |
|
| 23 | + private static $_previous_routes = array(); |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * @var WP_Query $WP_Query |
|
| 27 | - */ |
|
| 28 | - public $WP_Query; |
|
| 25 | + /** |
|
| 26 | + * @var WP_Query $WP_Query |
|
| 27 | + */ |
|
| 28 | + public $WP_Query; |
|
| 29 | 29 | |
| 30 | 30 | |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * EE_Module_Request_Router constructor. |
|
| 34 | - */ |
|
| 35 | - public function __construct() |
|
| 36 | - { |
|
| 37 | - } |
|
| 32 | + /** |
|
| 33 | + * EE_Module_Request_Router constructor. |
|
| 34 | + */ |
|
| 35 | + public function __construct() |
|
| 36 | + { |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | 39 | |
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * on the first call to this method, it checks the EE_Request_Handler for a "route" |
|
| 43 | - * on subsequent calls to this method, |
|
| 44 | - * instead of checking the EE_Request_Handler for a route, it checks the previous routes array, |
|
| 45 | - * and checks if the last called route has any forwarding routes registered for it |
|
| 46 | - * |
|
| 47 | - * @param WP_Query $WP_Query |
|
| 48 | - * @return NULL|string |
|
| 49 | - * @throws EE_Error |
|
| 50 | - * @throws ReflectionException |
|
| 51 | - */ |
|
| 52 | - public function get_route(WP_Query $WP_Query) |
|
| 53 | - { |
|
| 54 | - $this->WP_Query = $WP_Query; |
|
| 55 | - // assume this if first route being called |
|
| 56 | - $previous_route = false; |
|
| 57 | - // but is it really ??? |
|
| 58 | - if (! empty(self::$_previous_routes)) { |
|
| 59 | - // get last run route |
|
| 60 | - $previous_routes = array_values(self::$_previous_routes); |
|
| 61 | - $previous_route = array_pop($previous_routes); |
|
| 62 | - } |
|
| 63 | - // has another route already been run ? |
|
| 64 | - if ($previous_route) { |
|
| 65 | - // check if forwarding has been set |
|
| 66 | - $current_route = $this->get_forward($previous_route); |
|
| 67 | - try { |
|
| 68 | - //check for recursive forwarding |
|
| 69 | - if (isset(self::$_previous_routes[$current_route])) { |
|
| 70 | - throw new EE_Error( |
|
| 71 | - sprintf( |
|
| 72 | - __( |
|
| 73 | - 'An error occurred. The %s route has already been called, and therefore can not be forwarded to, because an infinite loop would be created and break the interweb.', |
|
| 74 | - 'event_espresso' |
|
| 75 | - ), |
|
| 76 | - $current_route |
|
| 77 | - ) |
|
| 78 | - ); |
|
| 79 | - } |
|
| 80 | - } catch (EE_Error $e) { |
|
| 81 | - $e->get_error(); |
|
| 82 | - return null; |
|
| 83 | - } |
|
| 84 | - } else { |
|
| 85 | - // first route called |
|
| 86 | - $current_route = null; |
|
| 87 | - // grab all routes |
|
| 88 | - $routes = EE_Config::get_routes(); |
|
| 89 | - //d( $routes ); |
|
| 90 | - foreach ($routes as $key => $route) { |
|
| 91 | - // check request for module route |
|
| 92 | - if (EE_Registry::instance()->REQ->is_set($key)) { |
|
| 93 | - //echo '<b style="color:#2EA2CC;">key : <span style="color:#E76700">' . $key . '</span></b><br />'; |
|
| 94 | - $current_route = sanitize_text_field(EE_Registry::instance()->REQ->get($key)); |
|
| 95 | - if ($current_route) { |
|
| 96 | - $current_route = array($key, $current_route); |
|
| 97 | - //echo '<b style="color:#2EA2CC;">current_route : <span style="color:#E76700">' . $current_route . '</span></b><br />'; |
|
| 98 | - break; |
|
| 99 | - } |
|
| 100 | - } |
|
| 101 | - } |
|
| 102 | - } |
|
| 103 | - // sorry, but I can't read what you route ! |
|
| 104 | - if (empty($current_route)) { |
|
| 105 | - return null; |
|
| 106 | - } |
|
| 107 | - //add route to previous routes array |
|
| 108 | - self::$_previous_routes[] = $current_route; |
|
| 109 | - return $current_route; |
|
| 110 | - } |
|
| 41 | + /** |
|
| 42 | + * on the first call to this method, it checks the EE_Request_Handler for a "route" |
|
| 43 | + * on subsequent calls to this method, |
|
| 44 | + * instead of checking the EE_Request_Handler for a route, it checks the previous routes array, |
|
| 45 | + * and checks if the last called route has any forwarding routes registered for it |
|
| 46 | + * |
|
| 47 | + * @param WP_Query $WP_Query |
|
| 48 | + * @return NULL|string |
|
| 49 | + * @throws EE_Error |
|
| 50 | + * @throws ReflectionException |
|
| 51 | + */ |
|
| 52 | + public function get_route(WP_Query $WP_Query) |
|
| 53 | + { |
|
| 54 | + $this->WP_Query = $WP_Query; |
|
| 55 | + // assume this if first route being called |
|
| 56 | + $previous_route = false; |
|
| 57 | + // but is it really ??? |
|
| 58 | + if (! empty(self::$_previous_routes)) { |
|
| 59 | + // get last run route |
|
| 60 | + $previous_routes = array_values(self::$_previous_routes); |
|
| 61 | + $previous_route = array_pop($previous_routes); |
|
| 62 | + } |
|
| 63 | + // has another route already been run ? |
|
| 64 | + if ($previous_route) { |
|
| 65 | + // check if forwarding has been set |
|
| 66 | + $current_route = $this->get_forward($previous_route); |
|
| 67 | + try { |
|
| 68 | + //check for recursive forwarding |
|
| 69 | + if (isset(self::$_previous_routes[$current_route])) { |
|
| 70 | + throw new EE_Error( |
|
| 71 | + sprintf( |
|
| 72 | + __( |
|
| 73 | + 'An error occurred. The %s route has already been called, and therefore can not be forwarded to, because an infinite loop would be created and break the interweb.', |
|
| 74 | + 'event_espresso' |
|
| 75 | + ), |
|
| 76 | + $current_route |
|
| 77 | + ) |
|
| 78 | + ); |
|
| 79 | + } |
|
| 80 | + } catch (EE_Error $e) { |
|
| 81 | + $e->get_error(); |
|
| 82 | + return null; |
|
| 83 | + } |
|
| 84 | + } else { |
|
| 85 | + // first route called |
|
| 86 | + $current_route = null; |
|
| 87 | + // grab all routes |
|
| 88 | + $routes = EE_Config::get_routes(); |
|
| 89 | + //d( $routes ); |
|
| 90 | + foreach ($routes as $key => $route) { |
|
| 91 | + // check request for module route |
|
| 92 | + if (EE_Registry::instance()->REQ->is_set($key)) { |
|
| 93 | + //echo '<b style="color:#2EA2CC;">key : <span style="color:#E76700">' . $key . '</span></b><br />'; |
|
| 94 | + $current_route = sanitize_text_field(EE_Registry::instance()->REQ->get($key)); |
|
| 95 | + if ($current_route) { |
|
| 96 | + $current_route = array($key, $current_route); |
|
| 97 | + //echo '<b style="color:#2EA2CC;">current_route : <span style="color:#E76700">' . $current_route . '</span></b><br />'; |
|
| 98 | + break; |
|
| 99 | + } |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | + } |
|
| 103 | + // sorry, but I can't read what you route ! |
|
| 104 | + if (empty($current_route)) { |
|
| 105 | + return null; |
|
| 106 | + } |
|
| 107 | + //add route to previous routes array |
|
| 108 | + self::$_previous_routes[] = $current_route; |
|
| 109 | + return $current_route; |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | 112 | |
| 113 | 113 | |
| 114 | - /** |
|
| 115 | - * this method simply takes a valid route, and resolves what module class method the route points to |
|
| 116 | - * |
|
| 117 | - * @param string $key |
|
| 118 | - * @param string $current_route |
|
| 119 | - * @return mixed EED_Module | boolean |
|
| 120 | - * @throws EE_Error |
|
| 121 | - * @throws ReflectionException |
|
| 122 | - */ |
|
| 123 | - public function resolve_route($key, $current_route) |
|
| 124 | - { |
|
| 125 | - // get module method that route has been mapped to |
|
| 126 | - $module_method = EE_Config::get_route($current_route, $key); |
|
| 127 | - //EEH_Debug_Tools::printr( $module_method, '$module_method <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
|
| 128 | - // verify result was returned |
|
| 129 | - if (empty($module_method)) { |
|
| 130 | - $msg = sprintf( |
|
| 131 | - __('The requested route %s could not be mapped to any registered modules.', 'event_espresso'), |
|
| 132 | - $current_route |
|
| 133 | - ); |
|
| 134 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 135 | - return false; |
|
| 136 | - } |
|
| 137 | - // verify that result is an array |
|
| 138 | - if (! is_array($module_method)) { |
|
| 139 | - $msg = sprintf(__('The %s route has not been properly registered.', 'event_espresso'), $current_route); |
|
| 140 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 141 | - return false; |
|
| 142 | - } |
|
| 143 | - // grab module name |
|
| 144 | - $module_name = $module_method[0]; |
|
| 145 | - // verify that a class method was registered properly |
|
| 146 | - if (! isset($module_method[1])) { |
|
| 147 | - $msg = sprintf( |
|
| 148 | - __('A class method for the %s route has not been properly registered.', 'event_espresso'), |
|
| 149 | - $current_route |
|
| 150 | - ); |
|
| 151 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 152 | - return false; |
|
| 153 | - } |
|
| 154 | - // grab method |
|
| 155 | - $method = $module_method[1]; |
|
| 156 | - // verify that class exists |
|
| 157 | - if (! class_exists($module_name)) { |
|
| 158 | - $msg = sprintf(__('The requested %s class could not be found.', 'event_espresso'), $module_name); |
|
| 159 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 160 | - return false; |
|
| 161 | - } |
|
| 162 | - // verify that method exists |
|
| 163 | - if (! method_exists($module_name, $method)) { |
|
| 164 | - $msg = sprintf( |
|
| 165 | - __('The class method %s for the %s route is in invalid.', 'event_espresso'), $method, $current_route |
|
| 166 | - ); |
|
| 167 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 168 | - return false; |
|
| 169 | - } |
|
| 170 | - // instantiate module and call route method |
|
| 171 | - return $this->_module_router($module_name, $method); |
|
| 172 | - } |
|
| 114 | + /** |
|
| 115 | + * this method simply takes a valid route, and resolves what module class method the route points to |
|
| 116 | + * |
|
| 117 | + * @param string $key |
|
| 118 | + * @param string $current_route |
|
| 119 | + * @return mixed EED_Module | boolean |
|
| 120 | + * @throws EE_Error |
|
| 121 | + * @throws ReflectionException |
|
| 122 | + */ |
|
| 123 | + public function resolve_route($key, $current_route) |
|
| 124 | + { |
|
| 125 | + // get module method that route has been mapped to |
|
| 126 | + $module_method = EE_Config::get_route($current_route, $key); |
|
| 127 | + //EEH_Debug_Tools::printr( $module_method, '$module_method <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
|
| 128 | + // verify result was returned |
|
| 129 | + if (empty($module_method)) { |
|
| 130 | + $msg = sprintf( |
|
| 131 | + __('The requested route %s could not be mapped to any registered modules.', 'event_espresso'), |
|
| 132 | + $current_route |
|
| 133 | + ); |
|
| 134 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 135 | + return false; |
|
| 136 | + } |
|
| 137 | + // verify that result is an array |
|
| 138 | + if (! is_array($module_method)) { |
|
| 139 | + $msg = sprintf(__('The %s route has not been properly registered.', 'event_espresso'), $current_route); |
|
| 140 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 141 | + return false; |
|
| 142 | + } |
|
| 143 | + // grab module name |
|
| 144 | + $module_name = $module_method[0]; |
|
| 145 | + // verify that a class method was registered properly |
|
| 146 | + if (! isset($module_method[1])) { |
|
| 147 | + $msg = sprintf( |
|
| 148 | + __('A class method for the %s route has not been properly registered.', 'event_espresso'), |
|
| 149 | + $current_route |
|
| 150 | + ); |
|
| 151 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 152 | + return false; |
|
| 153 | + } |
|
| 154 | + // grab method |
|
| 155 | + $method = $module_method[1]; |
|
| 156 | + // verify that class exists |
|
| 157 | + if (! class_exists($module_name)) { |
|
| 158 | + $msg = sprintf(__('The requested %s class could not be found.', 'event_espresso'), $module_name); |
|
| 159 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 160 | + return false; |
|
| 161 | + } |
|
| 162 | + // verify that method exists |
|
| 163 | + if (! method_exists($module_name, $method)) { |
|
| 164 | + $msg = sprintf( |
|
| 165 | + __('The class method %s for the %s route is in invalid.', 'event_espresso'), $method, $current_route |
|
| 166 | + ); |
|
| 167 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 168 | + return false; |
|
| 169 | + } |
|
| 170 | + // instantiate module and call route method |
|
| 171 | + return $this->_module_router($module_name, $method); |
|
| 172 | + } |
|
| 173 | 173 | |
| 174 | 174 | |
| 175 | 175 | |
| 176 | - /** |
|
| 177 | - * this method instantiates modules and calls the method that was defined when the route was registered |
|
| 178 | - * |
|
| 179 | - * @param string $module_name |
|
| 180 | - * @return EED_Module|object|null |
|
| 181 | - * @throws ReflectionException |
|
| 182 | - */ |
|
| 183 | - public static function module_factory($module_name) |
|
| 184 | - { |
|
| 185 | - if ($module_name === 'EED_Module') { |
|
| 186 | - EE_Error::add_error( |
|
| 187 | - sprintf( |
|
| 188 | - __( |
|
| 189 | - 'EED_Module is an abstract parent class an can not be instantiated. Please provide a proper module name.', |
|
| 190 | - 'event_espresso' |
|
| 191 | - ), $module_name |
|
| 192 | - ), __FILE__, __FUNCTION__, __LINE__ |
|
| 193 | - ); |
|
| 194 | - return null; |
|
| 195 | - } |
|
| 196 | - // instantiate module class |
|
| 197 | - $module = new $module_name(); |
|
| 198 | - // ensure that class is actually a module |
|
| 199 | - if (! $module instanceof EED_Module) { |
|
| 200 | - EE_Error::add_error( |
|
| 201 | - sprintf(__('The requested %s module is not of the class EED_Module.', 'event_espresso'), $module_name), |
|
| 202 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 203 | - ); |
|
| 204 | - return null; |
|
| 205 | - } |
|
| 206 | - return $module; |
|
| 207 | - } |
|
| 176 | + /** |
|
| 177 | + * this method instantiates modules and calls the method that was defined when the route was registered |
|
| 178 | + * |
|
| 179 | + * @param string $module_name |
|
| 180 | + * @return EED_Module|object|null |
|
| 181 | + * @throws ReflectionException |
|
| 182 | + */ |
|
| 183 | + public static function module_factory($module_name) |
|
| 184 | + { |
|
| 185 | + if ($module_name === 'EED_Module') { |
|
| 186 | + EE_Error::add_error( |
|
| 187 | + sprintf( |
|
| 188 | + __( |
|
| 189 | + 'EED_Module is an abstract parent class an can not be instantiated. Please provide a proper module name.', |
|
| 190 | + 'event_espresso' |
|
| 191 | + ), $module_name |
|
| 192 | + ), __FILE__, __FUNCTION__, __LINE__ |
|
| 193 | + ); |
|
| 194 | + return null; |
|
| 195 | + } |
|
| 196 | + // instantiate module class |
|
| 197 | + $module = new $module_name(); |
|
| 198 | + // ensure that class is actually a module |
|
| 199 | + if (! $module instanceof EED_Module) { |
|
| 200 | + EE_Error::add_error( |
|
| 201 | + sprintf(__('The requested %s module is not of the class EED_Module.', 'event_espresso'), $module_name), |
|
| 202 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 203 | + ); |
|
| 204 | + return null; |
|
| 205 | + } |
|
| 206 | + return $module; |
|
| 207 | + } |
|
| 208 | 208 | |
| 209 | 209 | |
| 210 | 210 | |
| 211 | - /** |
|
| 212 | - * this method instantiates modules and calls the method that was defined when the route was registered |
|
| 213 | - * |
|
| 214 | - * @param string $module_name |
|
| 215 | - * @param string $method |
|
| 216 | - * @return EED_Module|null |
|
| 217 | - * @throws EE_Error |
|
| 218 | - * @throws ReflectionException |
|
| 219 | - */ |
|
| 220 | - private function _module_router($module_name, $method) |
|
| 221 | - { |
|
| 222 | - // instantiate module class |
|
| 223 | - $module = EE_Module_Request_Router::module_factory($module_name); |
|
| 224 | - if ($module instanceof EED_Module) { |
|
| 225 | - // and call whatever action the route was for |
|
| 226 | - try { |
|
| 227 | - call_user_func(array($module, $method), $this->WP_Query); |
|
| 228 | - } catch (EE_Error $e) { |
|
| 229 | - $e->get_error(); |
|
| 230 | - return null; |
|
| 231 | - } |
|
| 232 | - } |
|
| 233 | - return $module; |
|
| 234 | - } |
|
| 211 | + /** |
|
| 212 | + * this method instantiates modules and calls the method that was defined when the route was registered |
|
| 213 | + * |
|
| 214 | + * @param string $module_name |
|
| 215 | + * @param string $method |
|
| 216 | + * @return EED_Module|null |
|
| 217 | + * @throws EE_Error |
|
| 218 | + * @throws ReflectionException |
|
| 219 | + */ |
|
| 220 | + private function _module_router($module_name, $method) |
|
| 221 | + { |
|
| 222 | + // instantiate module class |
|
| 223 | + $module = EE_Module_Request_Router::module_factory($module_name); |
|
| 224 | + if ($module instanceof EED_Module) { |
|
| 225 | + // and call whatever action the route was for |
|
| 226 | + try { |
|
| 227 | + call_user_func(array($module, $method), $this->WP_Query); |
|
| 228 | + } catch (EE_Error $e) { |
|
| 229 | + $e->get_error(); |
|
| 230 | + return null; |
|
| 231 | + } |
|
| 232 | + } |
|
| 233 | + return $module; |
|
| 234 | + } |
|
| 235 | 235 | |
| 236 | 236 | |
| 237 | 237 | |
| 238 | - /** |
|
| 239 | - * @param $current_route |
|
| 240 | - * @return string |
|
| 241 | - */ |
|
| 242 | - public function get_forward($current_route) |
|
| 243 | - { |
|
| 244 | - return EE_Config::get_forward($current_route); |
|
| 245 | - } |
|
| 238 | + /** |
|
| 239 | + * @param $current_route |
|
| 240 | + * @return string |
|
| 241 | + */ |
|
| 242 | + public function get_forward($current_route) |
|
| 243 | + { |
|
| 244 | + return EE_Config::get_forward($current_route); |
|
| 245 | + } |
|
| 246 | 246 | |
| 247 | 247 | |
| 248 | 248 | |
| 249 | - /** |
|
| 250 | - * @param $current_route |
|
| 251 | - * @return string |
|
| 252 | - */ |
|
| 253 | - public function get_view($current_route) |
|
| 254 | - { |
|
| 255 | - return EE_Config::get_view($current_route); |
|
| 256 | - } |
|
| 249 | + /** |
|
| 250 | + * @param $current_route |
|
| 251 | + * @return string |
|
| 252 | + */ |
|
| 253 | + public function get_view($current_route) |
|
| 254 | + { |
|
| 255 | + return EE_Config::get_view($current_route); |
|
| 256 | + } |
|
| 257 | 257 | |
| 258 | 258 | |
| 259 | 259 | } |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | // assume this if first route being called |
| 56 | 56 | $previous_route = false; |
| 57 | 57 | // but is it really ??? |
| 58 | - if (! empty(self::$_previous_routes)) { |
|
| 58 | + if ( ! empty(self::$_previous_routes)) { |
|
| 59 | 59 | // get last run route |
| 60 | 60 | $previous_routes = array_values(self::$_previous_routes); |
| 61 | 61 | $previous_route = array_pop($previous_routes); |
@@ -135,36 +135,36 @@ discard block |
||
| 135 | 135 | return false; |
| 136 | 136 | } |
| 137 | 137 | // verify that result is an array |
| 138 | - if (! is_array($module_method)) { |
|
| 138 | + if ( ! is_array($module_method)) { |
|
| 139 | 139 | $msg = sprintf(__('The %s route has not been properly registered.', 'event_espresso'), $current_route); |
| 140 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 140 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 141 | 141 | return false; |
| 142 | 142 | } |
| 143 | 143 | // grab module name |
| 144 | 144 | $module_name = $module_method[0]; |
| 145 | 145 | // verify that a class method was registered properly |
| 146 | - if (! isset($module_method[1])) { |
|
| 146 | + if ( ! isset($module_method[1])) { |
|
| 147 | 147 | $msg = sprintf( |
| 148 | 148 | __('A class method for the %s route has not been properly registered.', 'event_espresso'), |
| 149 | 149 | $current_route |
| 150 | 150 | ); |
| 151 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 151 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 152 | 152 | return false; |
| 153 | 153 | } |
| 154 | 154 | // grab method |
| 155 | 155 | $method = $module_method[1]; |
| 156 | 156 | // verify that class exists |
| 157 | - if (! class_exists($module_name)) { |
|
| 157 | + if ( ! class_exists($module_name)) { |
|
| 158 | 158 | $msg = sprintf(__('The requested %s class could not be found.', 'event_espresso'), $module_name); |
| 159 | 159 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
| 160 | 160 | return false; |
| 161 | 161 | } |
| 162 | 162 | // verify that method exists |
| 163 | - if (! method_exists($module_name, $method)) { |
|
| 163 | + if ( ! method_exists($module_name, $method)) { |
|
| 164 | 164 | $msg = sprintf( |
| 165 | 165 | __('The class method %s for the %s route is in invalid.', 'event_espresso'), $method, $current_route |
| 166 | 166 | ); |
| 167 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 167 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 168 | 168 | return false; |
| 169 | 169 | } |
| 170 | 170 | // instantiate module and call route method |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | // instantiate module class |
| 197 | 197 | $module = new $module_name(); |
| 198 | 198 | // ensure that class is actually a module |
| 199 | - if (! $module instanceof EED_Module) { |
|
| 199 | + if ( ! $module instanceof EED_Module) { |
|
| 200 | 200 | EE_Error::add_error( |
| 201 | 201 | sprintf(__('The requested %s module is not of the class EED_Module.', 'event_espresso'), $module_name), |
| 202 | 202 | __FILE__, __FUNCTION__, __LINE__ |
@@ -9,20 +9,20 @@ |
||
| 9 | 9 | interface LoaderDecoratorInterface |
| 10 | 10 | { |
| 11 | 11 | |
| 12 | - /** |
|
| 13 | - * @param string $fqcn |
|
| 14 | - * @param array $arguments |
|
| 15 | - * @param bool $shared |
|
| 16 | - * @return mixed |
|
| 17 | - */ |
|
| 18 | - public function load($fqcn, $arguments = array(), $shared = true); |
|
| 12 | + /** |
|
| 13 | + * @param string $fqcn |
|
| 14 | + * @param array $arguments |
|
| 15 | + * @param bool $shared |
|
| 16 | + * @return mixed |
|
| 17 | + */ |
|
| 18 | + public function load($fqcn, $arguments = array(), $shared = true); |
|
| 19 | 19 | |
| 20 | 20 | |
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * calls reset() on loader if method exists |
|
| 24 | - */ |
|
| 25 | - public function reset(); |
|
| 22 | + /** |
|
| 23 | + * calls reset() on loader if method exists |
|
| 24 | + */ |
|
| 25 | + public function reset(); |
|
| 26 | 26 | |
| 27 | 27 | } |
| 28 | 28 | // End of file LoaderInterface.php |