Completed
Branch FET-10111-shortcode-post-ids (e72a80)
by
unknown
140:54 queued 124:43
created
modules/ticket_selector/EED_Ticket_Selector.module.php 1 patch
Spacing   +207 added lines, -207 removed lines patch added patch discarded remove patch
@@ -65,15 +65,15 @@  discard block
 block discarded – undo
65 65
 	 * @return EED_Ticket_Selector
66 66
 	 */
67 67
 	public static function instance() {
68
-		return parent::get_instance( __CLASS__ );
68
+		return parent::get_instance(__CLASS__);
69 69
 	}
70 70
 
71 71
 
72 72
 
73
-	protected function set_config(){
74
-		$this->set_config_section( 'template_settings' );
75
-		$this->set_config_class( 'EE_Ticket_Selector_Config' );
76
-		$this->set_config_name( 'EED_Ticket_Selector' );
73
+	protected function set_config() {
74
+		$this->set_config_section('template_settings');
75
+		$this->set_config_class('EE_Ticket_Selector_Config');
76
+		$this->set_config_name('EED_Ticket_Selector');
77 77
 	}
78 78
 
79 79
 
@@ -88,14 +88,14 @@  discard block
 block discarded – undo
88 88
 	 */
89 89
 	public static function set_hooks() {
90 90
 		// routing
91
-		EE_Config::register_route( 'iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector' );
92
-		EE_Config::register_route( 'process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections' );
93
-		add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 );
91
+		EE_Config::register_route('iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector');
92
+		EE_Config::register_route('process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections');
93
+		add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2);
94 94
 		//add_action( 'AHEE_event_details_before_post', array( 'EED_Ticket_Selector', 'ticket_selector_form_open' ), 10, 1 );
95
-		add_action( 'AHEE_event_details_header_bottom', array( 'EED_Ticket_Selector', 'display_ticket_selector' ), 10, 1 );
95
+		add_action('AHEE_event_details_header_bottom', array('EED_Ticket_Selector', 'display_ticket_selector'), 10, 1);
96 96
 		//add_action( 'AHEE__ticket_selector_chart__template__after_ticket_selector', array( 'EED_Ticket_Selector', 'display_ticket_selector_submit' ), 10, 1 );
97 97
 		//add_action( 'AHEE_event_details_after_post', array( 'EED_Ticket_Selector', 'ticket_selector_form_close' ), 10 );
98
-		add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets' ), 10 );
98
+		add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets'), 10);
99 99
 	}
100 100
 
101 101
 
@@ -107,10 +107,10 @@  discard block
 block discarded – undo
107 107
 	 *  @return 	void
108 108
 	 */
109 109
 	public static function set_hooks_admin() {
110
-		add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 );
110
+		add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2);
111 111
 		//add button for iframe code to event editor.
112
-		add_filter( 'get_sample_permalink_html', array( 'EED_Ticket_Selector', 'iframe_code_button' ), 10, 4 );
113
-		add_action( 'admin_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets_admin' ), 10 );
112
+		add_filter('get_sample_permalink_html', array('EED_Ticket_Selector', 'iframe_code_button'), 10, 4);
113
+		add_action('admin_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets_admin'), 10);
114 114
 	}
115 115
 
116 116
 
@@ -122,15 +122,15 @@  discard block
 block discarded – undo
122 122
 	 *  @return 	void
123 123
 	 */
124 124
 	public static function set_definitions() {
125
-		define( 'TICKET_SELECTOR_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS );
126
-		define( 'TICKET_SELECTOR_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS );
125
+		define('TICKET_SELECTOR_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS);
126
+		define('TICKET_SELECTOR_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS);
127 127
 
128 128
 		//if config is not set, initialize
129 129
 		//If config is not set, set it.
130
-		if ( ! isset( EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector ) ) {
130
+		if ( ! isset(EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector)) {
131 131
 			EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = new EE_Ticket_Selector_Config();
132 132
 		}
133
-		EE_Registry::$i18n_js_strings[ 'ts_embed_iframe_title' ] = __( 'Copy and Paste the following:', 'event_espresso' );
133
+		EE_Registry::$i18n_js_strings['ts_embed_iframe_title'] = __('Copy and Paste the following:', 'event_espresso');
134 134
 	}
135 135
 
136 136
 
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 * 	@param	object 			$WP
142 142
 	 * 	@return 	void
143 143
 	 */
144
-	public function run( $WP ) {}
144
+	public function run($WP) {}
145 145
 
146 146
 
147 147
 	/**
@@ -153,23 +153,23 @@  discard block
 block discarded – undo
153 153
 	public function ticket_selector_iframe() {
154 154
 		self::$_in_iframe = true;
155 155
 		/** @type EEM_Event $EEM_Event */
156
-		$EEM_Event = EE_Registry::instance()->load_model( 'Event' );
156
+		$EEM_Event = EE_Registry::instance()->load_model('Event');
157 157
 		$event = $EEM_Event->get_one_by_ID(
158
-			EE_Registry::instance()->REQ->get( 'event', 0 )
158
+			EE_Registry::instance()->REQ->get('event', 0)
159 159
 		);
160
-		EE_Registry::instance()->REQ->set_espresso_page( true );
161
-		$template_args['ticket_selector'] = EED_Ticket_Selector::display_ticket_selector( $event );
160
+		EE_Registry::instance()->REQ->set_espresso_page(true);
161
+		$template_args['ticket_selector'] = EED_Ticket_Selector::display_ticket_selector($event);
162 162
 		$template_args['css'] = apply_filters(
163 163
 			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css',
164 164
 			array(
165
-				TICKET_SELECTOR_ASSETS_URL . 'ticket_selector_embed.css?ver=' . EVENT_ESPRESSO_VERSION,
166
-				TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css?ver=' . EVENT_ESPRESSO_VERSION,
167
-				includes_url( 'css/dashicons.min.css?ver=' . $GLOBALS['wp_version'] ),
168
-				EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION
165
+				TICKET_SELECTOR_ASSETS_URL.'ticket_selector_embed.css?ver='.EVENT_ESPRESSO_VERSION,
166
+				TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css?ver='.EVENT_ESPRESSO_VERSION,
167
+				includes_url('css/dashicons.min.css?ver='.$GLOBALS['wp_version']),
168
+				EE_GLOBAL_ASSETS_URL.'css/espresso_default.css?ver='.EVENT_ESPRESSO_VERSION
169 169
 			)
170 170
 		);
171
-		EE_Registry::$i18n_js_strings[ 'ticket_selector_iframe' ] = true;
172
-		EE_Registry::$i18n_js_strings[ 'EEDTicketSelectorMsg' ] = __( 'Please choose at least one ticket before continuing.', 'event_espresso' );
171
+		EE_Registry::$i18n_js_strings['ticket_selector_iframe'] = true;
172
+		EE_Registry::$i18n_js_strings['EEDTicketSelectorMsg'] = __('Please choose at least one ticket before continuing.', 'event_espresso');
173 173
 		$template_args['eei18n'] = apply_filters(
174 174
 			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__eei18n_js_strings',
175 175
 			EE_Registry::localize_i18n_js_strings()
@@ -177,18 +177,18 @@  discard block
 block discarded – undo
177 177
 		$template_args['js'] = apply_filters(
178 178
 			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
179 179
 			array(
180
-				includes_url( 'js/jquery/jquery.js?ver=' . $GLOBALS['wp_version'] ),
181
-				EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js?ver=' . EVENT_ESPRESSO_VERSION,
182
-				TICKET_SELECTOR_ASSETS_URL . 'ticket_selector_iframe_embed.js?ver=' . EVENT_ESPRESSO_VERSION
180
+				includes_url('js/jquery/jquery.js?ver='.$GLOBALS['wp_version']),
181
+				EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js?ver='.EVENT_ESPRESSO_VERSION,
182
+				TICKET_SELECTOR_ASSETS_URL.'ticket_selector_iframe_embed.js?ver='.EVENT_ESPRESSO_VERSION
183 183
 			)
184 184
 		);
185
-		$template_args[ 'notices' ] = EEH_Template::display_template(
186
-			EE_TEMPLATES . 'espresso-ajax-notices.template.php',
185
+		$template_args['notices'] = EEH_Template::display_template(
186
+			EE_TEMPLATES.'espresso-ajax-notices.template.php',
187 187
 			array(),
188 188
 			true
189 189
 		);
190 190
 		EEH_Template::display_template(
191
-			TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_selector_chart_iframe.template.php',
191
+			TICKET_SELECTOR_TEMPLATES_PATH.'ticket_selector_chart_iframe.template.php',
192 192
 			$template_args
193 193
 		);
194 194
 		exit;
@@ -207,25 +207,25 @@  discard block
 block discarded – undo
207 207
 	 *
208 208
 	 * @return string The new html string for the permalink area.
209 209
 	 */
210
-	public static function iframe_code_button( $permalink_string, $id, $new_title, $new_slug ) {
210
+	public static function iframe_code_button($permalink_string, $id, $new_title, $new_slug) {
211 211
 		//make sure this is ONLY when editing and the event id has been set.
212
-		if ( ! empty( $id ) ) {
213
-			$post = get_post( $id );
212
+		if ( ! empty($id)) {
213
+			$post = get_post($id);
214 214
 			//if NOT event then let's get out.
215
-			if ( $post->post_type !== 'espresso_events' ) {
215
+			if ($post->post_type !== 'espresso_events') {
216 216
 				return $permalink_string;
217 217
 			}
218 218
 			$permalink_string .= '<a id="js-ticket-selector-embed-trigger" class="button button-small" href="#"  tabindex="-1">'
219
-			                     . __( 'Embed', 'event_espresso' )
219
+			                     . __('Embed', 'event_espresso')
220 220
 			                     . '</a> ';
221
-			$ticket_selector_url = add_query_arg( array( 'ticket_selector' => 'iframe', 'event' => $id ), site_url() );
221
+			$ticket_selector_url = add_query_arg(array('ticket_selector' => 'iframe', 'event' => $id), site_url());
222 222
 			$iframe_string = esc_html(
223
-				'<iframe src="' . $ticket_selector_url . '" width="100%" height="100%"></iframe>'
223
+				'<iframe src="'.$ticket_selector_url.'" width="100%" height="100%"></iframe>'
224 224
 			);
225 225
 			$permalink_string .= '
226 226
 <div id="js-ts-iframe" style="display:none">
227 227
 	<div style="width:100%; height: 500px;">
228
-		' . $iframe_string . '
228
+		' . $iframe_string.'
229 229
 	</div>
230 230
 </div>';
231 231
 		}
@@ -244,22 +244,22 @@  discard block
 block discarded – undo
244 244
 	 * @param 	mixed $event
245 245
 	 * @return 	bool
246 246
 	 */
247
-	protected static function set_event( $event = null ) {
248
-		if( $event === null ) {
247
+	protected static function set_event($event = null) {
248
+		if ($event === null) {
249 249
 			global $post;
250 250
 			$event = $post;
251 251
 		}
252
-		if ( $event instanceof EE_Event ) {
252
+		if ($event instanceof EE_Event) {
253 253
 			self::$_event = $event;
254
-		} else if ( $event instanceof WP_Post && isset( $event->EE_Event ) && $event->EE_Event instanceof EE_Event ) {
254
+		} else if ($event instanceof WP_Post && isset($event->EE_Event) && $event->EE_Event instanceof EE_Event) {
255 255
 			self::$_event = $event->EE_Event;
256
-		} else if ( $event instanceof WP_Post && $event->post_type == 'espresso_events' ) {
257
-			$event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object( $event );
256
+		} else if ($event instanceof WP_Post && $event->post_type == 'espresso_events') {
257
+			$event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object($event);
258 258
 			self::$_event = $event->EE_Event;
259 259
 		} else {
260
-			$user_msg = __( 'No Event object or an invalid Event object was supplied.', 'event_espresso' );
261
-			$dev_msg = $user_msg . __( 'In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.', 'event_espresso' );
262
-			EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ );
260
+			$user_msg = __('No Event object or an invalid Event object was supplied.', 'event_espresso');
261
+			$dev_msg = $user_msg.__('In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.', 'event_espresso');
262
+			EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__);
263 263
 			return false;
264 264
 		}
265 265
 		return true;
@@ -278,11 +278,11 @@  discard block
 block discarded – undo
278 278
 	 * @param 	bool 	$view_details
279 279
 	 * @return 	string
280 280
 	 */
281
-	public static function display_ticket_selector( $event = NULL, $view_details = FALSE ) {
281
+	public static function display_ticket_selector($event = NULL, $view_details = FALSE) {
282 282
 		// reset filter for displaying submit button
283
-		remove_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' );
283
+		remove_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
284 284
 		// poke and prod incoming event till it tells us what it is
285
-		if ( ! EED_Ticket_Selector::set_event( $event )) {
285
+		if ( ! EED_Ticket_Selector::set_event($event)) {
286 286
 			return false;
287 287
 		}
288 288
 		$event_post = self::$_event instanceof EE_Event ? self::$_event->ID() : $event;
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 			&& (
294 294
 				! self::$_event->display_ticket_selector()
295 295
 				|| $view_details
296
-				|| post_password_required( $event_post )
296
+				|| post_password_required($event_post)
297 297
 				|| (
298 298
 					$_event_active_status != EE_Datetime::active
299 299
 					&& $_event_active_status != EE_Datetime::upcoming
@@ -311,34 +311,34 @@  discard block
 block discarded – undo
311 311
 		$template_args = array();
312 312
 		$template_args['event_status'] = $_event_active_status;
313 313
 
314
-		$template_args['date_format'] = apply_filters( 'FHEE__EED_Ticket_Selector__display_ticket_selector__date_format', get_option( 'date_format' ) );
315
-		$template_args['time_format'] = apply_filters( 'FHEE__EED_Ticket_Selector__display_ticket_selector__time_format', get_option( 'time_format' ) );
314
+		$template_args['date_format'] = apply_filters('FHEE__EED_Ticket_Selector__display_ticket_selector__date_format', get_option('date_format'));
315
+		$template_args['time_format'] = apply_filters('FHEE__EED_Ticket_Selector__display_ticket_selector__time_format', get_option('time_format'));
316 316
 
317 317
 		$template_args['EVT_ID'] = self::$_event->ID();
318 318
 		$template_args['event'] = self::$_event;
319 319
 
320 320
 		// is the event expired ?
321 321
 		$template_args['event_is_expired'] = self::$_event->is_expired();
322
-		if ( $template_args['event_is_expired'] ) {
323
-			return '<div class="ee-event-expired-notice"><span class="important-notice">' . __( 'We\'re sorry, but all tickets sales have ended because the event is expired.', 'event_espresso' ) . '</span></div>';
322
+		if ($template_args['event_is_expired']) {
323
+			return '<div class="ee-event-expired-notice"><span class="important-notice">'.__('We\'re sorry, but all tickets sales have ended because the event is expired.', 'event_espresso').'</span></div>';
324 324
 		}
325 325
 
326 326
 		$ticket_query_args = array(
327
-			array( 'Datetime.EVT_ID' => self::$_event->ID() ),
328
-			'order_by' => array( 'TKT_order' => 'ASC', 'TKT_required' => 'DESC', 'TKT_start_date' => 'ASC', 'TKT_end_date' => 'ASC' , 'Datetime.DTT_EVT_start' => 'DESC' )
327
+			array('Datetime.EVT_ID' => self::$_event->ID()),
328
+			'order_by' => array('TKT_order' => 'ASC', 'TKT_required' => 'DESC', 'TKT_start_date' => 'ASC', 'TKT_end_date' => 'ASC', 'Datetime.DTT_EVT_start' => 'DESC')
329 329
 		);
330 330
 
331
-		if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets ) {
331
+		if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets) {
332 332
 			//use the correct applicable time query depending on what version of core is being run.
333
-			$current_time = method_exists( 'EEM_Datetime', 'current_time_for_query' ) ? time() : current_time('timestamp');
334
-			$ticket_query_args[0]['TKT_end_date'] = array( '>', $current_time );
333
+			$current_time = method_exists('EEM_Datetime', 'current_time_for_query') ? time() : current_time('timestamp');
334
+			$ticket_query_args[0]['TKT_end_date'] = array('>', $current_time);
335 335
 		}
336 336
 
337 337
 		// get all tickets for this event ordered by the datetime
338
-		$template_args['tickets'] = EEM_Ticket::instance()->get_all( $ticket_query_args );
338
+		$template_args['tickets'] = EEM_Ticket::instance()->get_all($ticket_query_args);
339 339
 
340
-		if ( count( $template_args['tickets'] ) < 1 ) {
341
-			return '<div class="ee-event-expired-notice"><span class="important-notice">' . __( 'We\'re sorry, but all ticket sales have ended.', 'event_espresso' ) . '</span></div>';
340
+		if (count($template_args['tickets']) < 1) {
341
+			return '<div class="ee-event-expired-notice"><span class="important-notice">'.__('We\'re sorry, but all ticket sales have ended.', 'event_espresso').'</span></div>';
342 342
 		}
343 343
 
344 344
 		// filter the maximum qty that can appear in the Ticket Selector qty dropdowns
@@ -347,36 +347,36 @@  discard block
 block discarded – undo
347 347
 			self::$_event->additional_limit()
348 348
 		);
349 349
 		$template_args['max_atndz'] = \EED_Ticket_Selector::$_max_atndz;
350
-		if ( $template_args['max_atndz'] < 1 ) {
351
-			$sales_closed_msg = __( 'We\'re sorry, but ticket sales have been closed at this time. Please check back again later.', 'event_espresso' );
352
-			if ( current_user_can( 'edit_post', self::$_event->ID() )) {
353
-				$sales_closed_msg .=  sprintf(
354
-					__( '%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s', 'event_espresso' ),
350
+		if ($template_args['max_atndz'] < 1) {
351
+			$sales_closed_msg = __('We\'re sorry, but ticket sales have been closed at this time. Please check back again later.', 'event_espresso');
352
+			if (current_user_can('edit_post', self::$_event->ID())) {
353
+				$sales_closed_msg .= sprintf(
354
+					__('%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s', 'event_espresso'),
355 355
 					'<div class="ee-attention" style="text-align: left;"><b>',
356 356
 					'</b><br />',
357
-					$link = '<span class="edit-link"><a class="post-edit-link" href="' . get_edit_post_link( self::$_event->ID() ) . '">',
357
+					$link = '<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link(self::$_event->ID()).'">',
358 358
 					'</a></span></div>'
359 359
 				);
360 360
 			}
361
-			return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>';
361
+			return '<p><span class="important-notice">'.$sales_closed_msg.'</span></p>';
362 362
 		}
363 363
 
364
-		$templates['ticket_selector'] = TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_selector_chart.template.php';
365
-		$templates['ticket_selector'] = apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector__template_path', $templates['ticket_selector'], self::$_event );
364
+		$templates['ticket_selector'] = TICKET_SELECTOR_TEMPLATES_PATH.'ticket_selector_chart.template.php';
365
+		$templates['ticket_selector'] = apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector__template_path', $templates['ticket_selector'], self::$_event);
366 366
 
367 367
 		// redirecting to another site for registration ??
368 368
 		$external_url = self::$_event->external_url() !== NULL || self::$_event->external_url() !== '' ? self::$_event->external_url() : FALSE;
369 369
 		// set up the form (but not for the admin)
370
-		$ticket_selector = ! is_admin() ? EED_Ticket_Selector::ticket_selector_form_open( self::$_event->ID(), $external_url ) : '';
370
+		$ticket_selector = ! is_admin() ? EED_Ticket_Selector::ticket_selector_form_open(self::$_event->ID(), $external_url) : '';
371 371
 		// if not redirecting to another site for registration
372
-		if ( ! $external_url ) {
372
+		if ( ! $external_url) {
373 373
 			// then display the ticket selector
374
-			$ticket_selector .= EEH_Template::locate_template( $templates['ticket_selector'], $template_args );
374
+			$ticket_selector .= EEH_Template::locate_template($templates['ticket_selector'], $template_args);
375 375
 		} else {
376 376
 			// if not we still need to trigger the display of the submit button
377
-			add_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' );
377
+			add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
378 378
 			//display notice to admin that registration is external
379
-			$ticket_selector .= ! is_admin() ? '' : __( 'Registration is at an external URL for this event.', 'event_espresso' );
379
+			$ticket_selector .= ! is_admin() ? '' : __('Registration is at an external URL for this event.', 'event_espresso');
380 380
 		}
381 381
 		// submit button and form close tag
382 382
 		$ticket_selector .= ! is_admin() ? EED_Ticket_Selector::display_ticket_selector_submit() : '';
@@ -396,25 +396,25 @@  discard block
 block discarded – undo
396 396
 	 * @param 		string $external_url
397 397
 	 * @return 		string
398 398
 	 */
399
-	public static function ticket_selector_form_open( $ID = 0, $external_url = '' ) {
399
+	public static function ticket_selector_form_open($ID = 0, $external_url = '') {
400 400
 		// if redirecting, we don't need any anything else
401
-		if ( $external_url ) {
402
-			$html = '<form method="GET" action="' . EEH_URL::refactor_url( $external_url ) . '">';
403
-			$query_args = EEH_URL::get_query_string( $external_url );
404
-			foreach ( $query_args as $query_arg => $value ) {
405
-				$html .= '<input type="hidden" name="' . $query_arg . '" value="' . $value . '">';
401
+		if ($external_url) {
402
+			$html = '<form method="GET" action="'.EEH_URL::refactor_url($external_url).'">';
403
+			$query_args = EEH_URL::get_query_string($external_url);
404
+			foreach ($query_args as $query_arg => $value) {
405
+				$html .= '<input type="hidden" name="'.$query_arg.'" value="'.$value.'">';
406 406
 			}
407 407
 			return $html;
408 408
 		}
409
-		$checkout_url = EEH_Event_View::event_link_url( $ID );
410
-		if ( ! $checkout_url ) {
411
-			EE_Error::add_error( __('The URL for the Event Details page could not be retrieved.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
409
+		$checkout_url = EEH_Event_View::event_link_url($ID);
410
+		if ( ! $checkout_url) {
411
+			EE_Error::add_error(__('The URL for the Event Details page could not be retrieved.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
412 412
 		}
413 413
 		$extra_params = self::$_in_iframe ? ' target="_blank"' : '';
414
-		$html = '<form method="POST" action="' . $checkout_url . '"' . $extra_params . '>';
415
-		$html .= wp_nonce_field( 	'process_ticket_selections', 'process_ticket_selections_nonce', TRUE, FALSE );
414
+		$html = '<form method="POST" action="'.$checkout_url.'"'.$extra_params.'>';
415
+		$html .= wp_nonce_field('process_ticket_selections', 'process_ticket_selections_nonce', TRUE, FALSE);
416 416
 		$html .= '<input type="hidden" name="ee" value="process_ticket_selections">';
417
-		$html = apply_filters( 'FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, self::$_event );
417
+		$html = apply_filters('FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, self::$_event);
418 418
 		return $html;
419 419
 	}
420 420
 
@@ -429,30 +429,30 @@  discard block
 block discarded – undo
429 429
 	 * 	@return		string
430 430
 	 */
431 431
 	public static function display_ticket_selector_submit() {
432
-		if ( ! is_admin() ) {
433
-			if ( apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', FALSE ) ) {
432
+		if ( ! is_admin()) {
433
+			if (apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', FALSE)) {
434 434
 				$btn_text = apply_filters(
435 435
 					'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text',
436
-					__('Register Now', 'event_espresso' ),
436
+					__('Register Now', 'event_espresso'),
437 437
 					EED_Ticket_Selector::$_event
438 438
 				);
439 439
 				$external_url = EED_Ticket_Selector::$_event->external_url();
440
-				$html = '<input id="ticket-selector-submit-'. EED_Ticket_Selector::$_event->ID() .'-btn"';
440
+				$html = '<input id="ticket-selector-submit-'.EED_Ticket_Selector::$_event->ID().'-btn"';
441 441
 				$html .= ' class="ticket-selector-submit-btn ';
442
-				$html .= empty( $external_url ) ? 'ticket-selector-submit-ajax"' : '"';
443
-				$html .= ' type="submit" value="' . $btn_text . '" />';
442
+				$html .= empty($external_url) ? 'ticket-selector-submit-ajax"' : '"';
443
+				$html .= ' type="submit" value="'.$btn_text.'" />';
444 444
 				$html .= apply_filters(
445 445
 					'FHEE__EE_Ticket_Selector__after_ticket_selector_submit',
446 446
 					'',
447 447
 					EED_Ticket_Selector::$_event
448 448
 				);
449 449
 				$html .= '<div class="clear"><br/></div></form>';
450
-				if ( ! is_archive() ) {
450
+				if ( ! is_archive()) {
451 451
 					$html .= \EEH_Template::powered_by_event_espresso();
452 452
 				}
453 453
 				return $html;
454
-			} else if ( is_archive() ) {
455
-				return EED_Ticket_Selector::ticket_selector_form_close() . EED_Ticket_Selector::display_view_details_btn();
454
+			} else if (is_archive()) {
455
+				return EED_Ticket_Selector::ticket_selector_form_close().EED_Ticket_Selector::display_view_details_btn();
456 456
 			} else if (
457 457
 				EED_Ticket_Selector::$_event instanceof EE_Event
458 458
 				// if $_max_atndz === 1 (ie: a "Dude Where's my Ticket Selector?" type event)
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
 				$html = apply_filters(
465 465
 					'FHEE__EE_Ticket_Selector__no_ticket_selector_submit',
466 466
 					sprintf(
467
-						__( '%1$s"%2$s" is currently sold out. Please check back again later, as spots may become available.%3$s', 'event_espresso' ),
467
+						__('%1$s"%2$s" is currently sold out. Please check back again later, as spots may become available.%3$s', 'event_espresso'),
468 468
 						'<p class="no-ticket-selector-msg important-notice">',
469 469
 						EED_Ticket_Selector::$_event->name(),
470 470
 						'</p>'
@@ -506,13 +506,13 @@  discard block
 block discarded – undo
506 506
 	 * 	@return		string
507 507
 	 */
508 508
 	public static function display_view_details_btn() {
509
-		if ( ! self::$_event->get_permalink() ) {
510
-			EE_Error::add_error( __('The URL for the Event Details page could not be retrieved.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
509
+		if ( ! self::$_event->get_permalink()) {
510
+			EE_Error::add_error(__('The URL for the Event Details page could not be retrieved.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
511 511
 		}
512
-		$view_details_btn = '<form method="POST" action="' . self::$_event->get_permalink() . '">';
513
-		$btn_text = apply_filters( 'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text', __( 'View Details', 'event_espresso' ), self::$_event );
514
-		$view_details_btn .= '<input id="ticket-selector-submit-'. self::$_event->ID() .'-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="' . $btn_text . '" />';
515
-		$view_details_btn .= apply_filters( 'FHEE__EE_Ticket_Selector__after_view_details_btn', '', self::$_event );
512
+		$view_details_btn = '<form method="POST" action="'.self::$_event->get_permalink().'">';
513
+		$btn_text = apply_filters('FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text', __('View Details', 'event_espresso'), self::$_event);
514
+		$view_details_btn .= '<input id="ticket-selector-submit-'.self::$_event->ID().'-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="'.$btn_text.'" />';
515
+		$view_details_btn .= apply_filters('FHEE__EE_Ticket_Selector__after_view_details_btn', '', self::$_event);
516 516
 		$view_details_btn .= '<div class="clear"><br/></div>';
517 517
 		$view_details_btn .= '</form>';
518 518
 		return $view_details_btn;
@@ -530,11 +530,11 @@  discard block
 block discarded – undo
530 530
 	 * 	@return array|boolean
531 531
 	 */
532 532
 	public function process_ticket_selections() {
533
-        do_action( 'EED_Ticket_Selector__process_ticket_selections__before' );
533
+        do_action('EED_Ticket_Selector__process_ticket_selections__before');
534 534
 		// check nonce
535
-		if ( ! is_admin() && ( ! EE_Registry::instance()->REQ->is_set( 'process_ticket_selections_nonce' ) || ! wp_verify_nonce( EE_Registry::instance()->REQ->get( 'process_ticket_selections_nonce' ), 'process_ticket_selections' ))) {
535
+		if ( ! is_admin() && ( ! EE_Registry::instance()->REQ->is_set('process_ticket_selections_nonce') || ! wp_verify_nonce(EE_Registry::instance()->REQ->get('process_ticket_selections_nonce'), 'process_ticket_selections'))) {
536 536
 			EE_Error::add_error(
537
-				sprintf( __( 'We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.', 'event_espresso' ), '<br/>' ),
537
+				sprintf(__('We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.', 'event_espresso'), '<br/>'),
538 538
 				__FILE__, __FUNCTION__, __LINE__
539 539
 			);
540 540
 			return FALSE;
@@ -548,16 +548,16 @@  discard block
 block discarded – undo
548 548
 
549 549
 		//we should really only have 1 registration in the works now (ie, no MER) so clear any previous items in the cart.
550 550
 		// When MER happens this will probably need to be tweaked, possibly wrapped in a conditional checking for some constant defined in MER etc.
551
-		EE_Registry::instance()->load_core( 'Session' );
551
+		EE_Registry::instance()->load_core('Session');
552 552
 		// unless otherwise requested, clear the session
553
-		if ( apply_filters( 'FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', TRUE )) {
554
-			EE_Registry::instance()->SSN->clear_session( __CLASS__, __FUNCTION__ );
553
+		if (apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', TRUE)) {
554
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
555 555
 		}
556 556
 		//d( EE_Registry::instance()->SSN );
557 557
 
558
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
558
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
559 559
 		// do we have an event id?
560
-		if ( EE_Registry::instance()->REQ->is_set( 'tkt-slctr-event-id' ) ) {
560
+		if (EE_Registry::instance()->REQ->is_set('tkt-slctr-event-id')) {
561 561
 			// validate/sanitize data
562 562
 			$valid = self::_validate_post_data();
563 563
 
@@ -567,41 +567,41 @@  discard block
 block discarded – undo
567 567
 			//EEH_Debug_Tools::printr( $valid[ 'max_atndz' ], 'max_atndz', __FILE__, __LINE__ );
568 568
 
569 569
 			//check total tickets ordered vs max number of attendees that can register
570
-			if ( $valid['total_tickets'] > $valid['max_atndz'] ) {
570
+			if ($valid['total_tickets'] > $valid['max_atndz']) {
571 571
 
572 572
 				// ordering too many tickets !!!
573 573
 				$total_tickets_string = _n('You have attempted to purchase %s ticket.', 'You have attempted to purchase %s tickets.', $valid['total_tickets'], 'event_espresso');
574
-				$limit_error_1 = sprintf( $total_tickets_string, $valid['total_tickets'] );
574
+				$limit_error_1 = sprintf($total_tickets_string, $valid['total_tickets']);
575 575
 				// dev only message
576 576
 				$max_atndz_string = _n('The registration limit for this event is %s ticket per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.', 'The registration limit for this event is %s tickets per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.', $valid['max_atndz'], 'event_espresso');
577
-				$limit_error_2 = sprintf( $max_atndz_string, $valid['max_atndz'], $valid['max_atndz'] );
578
-				EE_Error::add_error( $limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__ );
577
+				$limit_error_2 = sprintf($max_atndz_string, $valid['max_atndz'], $valid['max_atndz']);
578
+				EE_Error::add_error($limit_error_1.'<br/>'.$limit_error_2, __FILE__, __FUNCTION__, __LINE__);
579 579
 			} else {
580 580
 
581 581
 				// all data appears to be valid
582 582
 				$tckts_slctd = FALSE;
583 583
 				$success = TRUE;
584 584
 				// load cart
585
-				EE_Registry::instance()->load_core( 'Cart' );
585
+				EE_Registry::instance()->load_core('Cart');
586 586
 
587 587
 				// cycle thru the number of data rows sent from the event listing
588
-				for ( $x = 0; $x < $valid['rows']; $x++ ) {
588
+				for ($x = 0; $x < $valid['rows']; $x++) {
589 589
 					// does this row actually contain a ticket quantity?
590
-					if ( isset( $valid['qty'][$x] ) && $valid['qty'][$x] > 0 ) {
590
+					if (isset($valid['qty'][$x]) && $valid['qty'][$x] > 0) {
591 591
 						// YES we have a ticket quantity
592 592
 						$tckts_slctd = TRUE;
593 593
 						//						d( $valid['ticket_obj'][$x] );
594
-						if ( $valid['ticket_obj'][$x] instanceof EE_Ticket ) {
594
+						if ($valid['ticket_obj'][$x] instanceof EE_Ticket) {
595 595
 							// then add ticket to cart
596
-							$ticket_added = self::_add_ticket_to_cart( $valid['ticket_obj'][$x], $valid['qty'][$x] );
596
+							$ticket_added = self::_add_ticket_to_cart($valid['ticket_obj'][$x], $valid['qty'][$x]);
597 597
 							$success = ! $ticket_added ? FALSE : $success;
598
-							if ( EE_Error::has_error() ) {
598
+							if (EE_Error::has_error()) {
599 599
 								break;
600 600
 							}
601 601
 						} else {
602 602
 							// nothing added to cart retrieved
603 603
 							EE_Error::add_error(
604
-								sprintf( __( 'A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.', 'event_espresso' ), '<br/>' ),
604
+								sprintf(__('A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.', 'event_espresso'), '<br/>'),
605 605
 								__FILE__, __FUNCTION__, __LINE__
606 606
 							);
607 607
 						}
@@ -610,45 +610,45 @@  discard block
 block discarded – undo
610 610
 				//d( EE_Registry::instance()->CART );
611 611
 				//die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE
612 612
 
613
-				if ( $tckts_slctd ) {
614
-					if ( $success ) {
615
-						do_action( 'FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout', EE_Registry::instance()->CART, $this );
613
+				if ($tckts_slctd) {
614
+					if ($success) {
615
+						do_action('FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout', EE_Registry::instance()->CART, $this);
616 616
 						EE_Registry::instance()->CART->recalculate_all_cart_totals();
617
-						EE_Registry::instance()->CART->save_cart( FALSE );
617
+						EE_Registry::instance()->CART->save_cart(FALSE);
618 618
 						EE_Registry::instance()->SSN->update();
619 619
 						//d( EE_Registry::instance()->CART );
620 620
 						//die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< OR HERE TO KILL REDIRECT AFTER CART UPDATE
621 621
 						// just return TRUE for registrations being made from admin
622
-						if ( is_admin() ) {
622
+						if (is_admin()) {
623 623
 							return TRUE;
624 624
 						}
625
-						wp_safe_redirect( apply_filters( 'FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url', EE_Registry::instance()->CFG->core->reg_page_url() ));
625
+						wp_safe_redirect(apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url', EE_Registry::instance()->CFG->core->reg_page_url()));
626 626
 						exit();
627 627
 
628 628
 					} else {
629
-						if ( ! EE_Error::has_error() ) {
629
+						if ( ! EE_Error::has_error()) {
630 630
 							// nothing added to cart
631
-							EE_Error::add_attention( __( 'No tickets were added for the event', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
631
+							EE_Error::add_attention(__('No tickets were added for the event', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
632 632
 						}
633 633
 					}
634 634
 
635 635
 				} else {
636 636
 					// no ticket quantities were selected
637
-					EE_Error::add_error( __( 'You need to select a ticket quantity before you can proceed.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
637
+					EE_Error::add_error(__('You need to select a ticket quantity before you can proceed.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
638 638
 				}
639 639
 			}
640 640
 			//die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL BEFORE REDIRECT
641 641
 			// at this point, just return if registration is being made from admin
642
-			if ( is_admin() ) {
642
+			if (is_admin()) {
643 643
 				return FALSE;
644 644
 			}
645
-			if ( $valid['return_url'] ) {
646
-				EE_Error::get_notices( FALSE, TRUE );
647
-				wp_safe_redirect( $valid['return_url'] );
645
+			if ($valid['return_url']) {
646
+				EE_Error::get_notices(FALSE, TRUE);
647
+				wp_safe_redirect($valid['return_url']);
648 648
 				exit();
649
-			} elseif ( isset( $event_to_add['id'] )) {
650
-				EE_Error::get_notices( FALSE, TRUE );
651
-				wp_safe_redirect( get_permalink( $event_to_add['id'] ));
649
+			} elseif (isset($event_to_add['id'])) {
650
+				EE_Error::get_notices(FALSE, TRUE);
651
+				wp_safe_redirect(get_permalink($event_to_add['id']));
652 652
 				exit();
653 653
 			} else {
654 654
 				echo EE_Error::get_notices();
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
 		} else {
658 658
 			// $_POST['tkt-slctr-event-id'] was not set ?!?!?!?
659 659
 			EE_Error::add_error(
660
-				sprintf( __( 'An event id was not provided or was not received.%sPlease click the back button on your browser and try again.', 'event_espresso' ), '<br/>' ),
660
+				sprintf(__('An event id was not provided or was not received.%sPlease click the back button on your browser and try again.', 'event_espresso'), '<br/>'),
661 661
 				__FILE__, __FUNCTION__, __LINE__
662 662
 			);
663 663
 		}
@@ -675,18 +675,18 @@  discard block
 block discarded – undo
675 675
 	 * @return        array  or FALSE
676 676
 	 */
677 677
 	private static function _validate_post_data() {
678
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
678
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
679 679
 
680 680
 		// start with an empty array()
681 681
 		$valid_data = array();
682 682
 		//		d( $_POST );
683 683
 		//if event id is valid
684
-		$id = absint( EE_Registry::instance()->REQ->get( 'tkt-slctr-event-id' ));
685
-		if ( $id ) {
684
+		$id = absint(EE_Registry::instance()->REQ->get('tkt-slctr-event-id'));
685
+		if ($id) {
686 686
 			// grab valid id
687 687
 			$valid_data['id'] = $id;
688 688
 			// grab and sanitize return-url
689
-			$valid_data['return_url'] = esc_url_raw( EE_Registry::instance()->REQ->get( 'tkt-slctr-return-url-' . $id ));
689
+			$valid_data['return_url'] = esc_url_raw(EE_Registry::instance()->REQ->get('tkt-slctr-return-url-'.$id));
690 690
 			// array of other form names
691 691
 			$inputs_to_clean = array(
692 692
 				'event_id' => 'tkt-slctr-event-id',
@@ -699,22 +699,22 @@  discard block
 block discarded – undo
699 699
 			// let's track the total number of tickets ordered.'
700 700
 			$valid_data['total_tickets'] = 0;
701 701
 			// cycle through $inputs_to_clean array
702
-			foreach ( $inputs_to_clean as $what => $input_to_clean ) {
702
+			foreach ($inputs_to_clean as $what => $input_to_clean) {
703 703
 				// check for POST data
704
-				if ( EE_Registry::instance()->REQ->is_set( $input_to_clean . $id )) {
704
+				if (EE_Registry::instance()->REQ->is_set($input_to_clean.$id)) {
705 705
 					// grab value
706
-					$input_value = EE_Registry::instance()->REQ->get( $input_to_clean . $id );
706
+					$input_value = EE_Registry::instance()->REQ->get($input_to_clean.$id);
707 707
 					switch ($what) {
708 708
 
709 709
 						// integers
710 710
 						case 'event_id':
711
-							$valid_data[$what] = absint( $input_value );
711
+							$valid_data[$what] = absint($input_value);
712 712
 							// get event via the event id we put in the form
713
-							$valid_data['event'] = EE_Registry::instance()->load_model( 'Event' )->get_one_by_ID( $valid_data['event_id'] );
713
+							$valid_data['event'] = EE_Registry::instance()->load_model('Event')->get_one_by_ID($valid_data['event_id']);
714 714
 							break;
715 715
 						case 'rows':
716 716
 						case 'max_atndz':
717
-							$valid_data[$what] = absint( $input_value );
717
+							$valid_data[$what] = absint($input_value);
718 718
 							break;
719 719
 
720 720
 						// arrays of integers
@@ -722,27 +722,27 @@  discard block
 block discarded – undo
722 722
 							//							d( $input_value );
723 723
 							$row_qty = $input_value;
724 724
 							// if qty is coming from a radio button input, then we need to assemble an array of rows
725
-							if( ! is_array( $row_qty )) {
725
+							if ( ! is_array($row_qty)) {
726 726
 								// get number of rows
727
-								$rows = EE_Registry::instance()->REQ->is_set( 'tkt-slctr-rows-' . $id ) ? absint( EE_Registry::instance()->REQ->get( 'tkt-slctr-rows-' . $id )) : 1;
727
+								$rows = EE_Registry::instance()->REQ->is_set('tkt-slctr-rows-'.$id) ? absint(EE_Registry::instance()->REQ->get('tkt-slctr-rows-'.$id)) : 1;
728 728
 								//								d( $rows );
729 729
 								// explode ints by the dash
730
-								$row_qty = explode( '-', $row_qty );
731
-								$row = isset( $row_qty[0] ) ? ( absint( $row_qty[0] )) : 1;
732
-								$qty = isset( $row_qty[1] ) ? absint( $row_qty[1] ) : 0;
733
-								$row_qty = array( $row => $qty );
730
+								$row_qty = explode('-', $row_qty);
731
+								$row = isset($row_qty[0]) ? (absint($row_qty[0])) : 1;
732
+								$qty = isset($row_qty[1]) ? absint($row_qty[1]) : 0;
733
+								$row_qty = array($row => $qty);
734 734
 								//								 d( $row_qty );
735
-								for( $x = 1; $x <= $rows; $x++ ) {
736
-									if ( ! isset( $row_qty[$x] )) {
735
+								for ($x = 1; $x <= $rows; $x++) {
736
+									if ( ! isset($row_qty[$x])) {
737 737
 										$row_qty[$x] = 0;
738 738
 									}
739 739
 								}
740 740
 							}
741
-							ksort( $row_qty );
741
+							ksort($row_qty);
742 742
 							//							 d( $row_qty );
743 743
 							// cycle thru values
744
-							foreach ( $row_qty as $qty ) {
745
-								$qty = absint( $qty );
744
+							foreach ($row_qty as $qty) {
745
+								$qty = absint($qty);
746 746
 								// sanitize as integers
747 747
 								$valid_data[$what][] = $qty;
748 748
 								$valid_data['total_tickets'] += $qty;
@@ -753,19 +753,19 @@  discard block
 block discarded – undo
753 753
 						case 'ticket_id':
754 754
 							$value_array = array();
755 755
 							// cycle thru values
756
-							foreach ( $input_value as $key=>$value ) {
756
+							foreach ($input_value as $key=>$value) {
757 757
 								// allow only numbers, letters,  spaces, commas and dashes
758
-								$value_array[ $key ] = wp_strip_all_tags( $value );
758
+								$value_array[$key] = wp_strip_all_tags($value);
759 759
 								// get ticket via the ticket id we put in the form
760
-								$ticket_obj = EE_Registry::instance()->load_model( 'Ticket' )->get_one_by_ID( $value );
761
-								$valid_data['ticket_obj'][ $key ] = $ticket_obj;
760
+								$ticket_obj = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($value);
761
+								$valid_data['ticket_obj'][$key] = $ticket_obj;
762 762
 							}
763
-							$valid_data[ $what ] = $value_array;
763
+							$valid_data[$what] = $value_array;
764 764
 							break;
765 765
 
766 766
 						case 'return_url' :
767 767
 							// grab and sanitize return-url
768
-							$valid_data[$what] = esc_url_raw( $input_value );
768
+							$valid_data[$what] = esc_url_raw($input_value);
769 769
 							break;
770 770
 
771 771
 					} 	// end switch $what
@@ -773,7 +773,7 @@  discard block
 block discarded – undo
773 773
 			} 	// end foreach $inputs_to_clean
774 774
 
775 775
 		} else {
776
-			EE_Error::add_error( __('The event id provided was not valid.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
776
+			EE_Error::add_error(__('The event id provided was not valid.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
777 777
 			return FALSE;
778 778
 		}
779 779
 
@@ -791,28 +791,28 @@  discard block
 block discarded – undo
791 791
 	 * @param int       $qty
792 792
 	 * @return TRUE on success, FALSE on fail
793 793
 	 */
794
-	private static function _add_ticket_to_cart( EE_Ticket $ticket = NULL, $qty = 1 ) {
795
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
794
+	private static function _add_ticket_to_cart(EE_Ticket $ticket = NULL, $qty = 1) {
795
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
796 796
 		// get the number of spaces left for this datetime ticket
797
-		$available_spaces = self::_ticket_datetime_availability( $ticket );
797
+		$available_spaces = self::_ticket_datetime_availability($ticket);
798 798
 		// compare available spaces against the number of tickets being purchased
799
-		if ( $available_spaces >= $qty ) {
799
+		if ($available_spaces >= $qty) {
800 800
 			// allow addons to prevent a ticket from being added to cart
801
-			if ( ! apply_filters( 'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart', true, $ticket, $qty, $available_spaces ) ) {
801
+			if ( ! apply_filters('FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart', true, $ticket, $qty, $available_spaces)) {
802 802
 				return false;
803 803
 			}
804 804
 			// add event to cart
805
-			if( EE_Registry::instance()->CART->add_ticket_to_cart( $ticket, $qty )) {
806
-				self::_recalculate_ticket_datetime_availability( $ticket, $qty );
805
+			if (EE_Registry::instance()->CART->add_ticket_to_cart($ticket, $qty)) {
806
+				self::_recalculate_ticket_datetime_availability($ticket, $qty);
807 807
 				return true;
808 808
 			} else {
809 809
 				return false;
810 810
 			}
811 811
 		} else {
812 812
 			// tickets can not be purchased but let's find the exact number left for the last ticket selected PRIOR to subtracting tickets
813
-			$available_spaces = self::_ticket_datetime_availability( $ticket, true );
813
+			$available_spaces = self::_ticket_datetime_availability($ticket, true);
814 814
 			// greedy greedy greedy eh?
815
-			if ( $available_spaces > 0 ) {
815
+			if ($available_spaces > 0) {
816 816
 				// add error messaging - we're using the _n function that will generate the appropriate singular or plural message based on the number of $available_spaces
817 817
 				EE_Error::add_error(
818 818
 					sprintf(
@@ -828,7 +828,7 @@  discard block
 block discarded – undo
828 828
 					__FILE__, __FUNCTION__, __LINE__
829 829
 				);
830 830
 			} else {
831
-				EE_Error::add_error( __('We\'re sorry, but there are no available spaces left for this event at this particular date and time.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
831
+				EE_Error::add_error(__('We\'re sorry, but there are no available spaces left for this event at this particular date and time.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
832 832
 			}
833 833
 			return false;
834 834
 		}
@@ -846,22 +846,22 @@  discard block
 block discarded – undo
846 846
 	 * @param 	bool         $get_original_ticket_spaces
847 847
 	 * @return 	int
848 848
 	 */
849
-	private static function _ticket_datetime_availability( EE_Ticket $ticket, $get_original_ticket_spaces = FALSE ) {
849
+	private static function _ticket_datetime_availability(EE_Ticket $ticket, $get_original_ticket_spaces = FALSE) {
850 850
 		// if the $_available_spaces array has not been set up yet...
851
-		if ( ! isset( self::$_available_spaces['tickets'][ $ticket->ID() ] )) {
852
-				self::_set_initial_ticket_datetime_availability( $ticket );
851
+		if ( ! isset(self::$_available_spaces['tickets'][$ticket->ID()])) {
852
+				self::_set_initial_ticket_datetime_availability($ticket);
853 853
 		}
854 854
 		$available_spaces = $ticket->qty() - $ticket->sold();
855
-		if ( isset( self::$_available_spaces['tickets'][ $ticket->ID() ] )) {
855
+		if (isset(self::$_available_spaces['tickets'][$ticket->ID()])) {
856 856
 			// loop thru tickets, which will ALSO include individual ticket records AND a total
857
-			foreach ( self::$_available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces  ) {
857
+			foreach (self::$_available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) {
858 858
 				// if we want the original datetime availability BEFORE we started subtracting tickets ?
859
-				if ( $get_original_ticket_spaces ) {
859
+				if ($get_original_ticket_spaces) {
860 860
 					// then grab the available spaces from the "tickets" array and compare with the above to get the lowest number
861
-					$available_spaces = min( $available_spaces, self::$_available_spaces['tickets'][ $ticket->ID() ][ $DTD_ID ] );
861
+					$available_spaces = min($available_spaces, self::$_available_spaces['tickets'][$ticket->ID()][$DTD_ID]);
862 862
 				} else {
863 863
 					// we want the updated ticket availability as stored in the "datetimes" array
864
-					$available_spaces = min( $available_spaces, self::$_available_spaces['datetimes'][ $DTD_ID ] );
864
+					$available_spaces = min($available_spaces, self::$_available_spaces['datetimes'][$DTD_ID]);
865 865
 				}
866 866
 			}
867 867
 		}
@@ -877,23 +877,23 @@  discard block
 block discarded – undo
877 877
 	 * @param 	EE_Ticket $ticket
878 878
 	 * @return 	int
879 879
 	 */
880
-	private static function _set_initial_ticket_datetime_availability( EE_Ticket $ticket ) {
880
+	private static function _set_initial_ticket_datetime_availability(EE_Ticket $ticket) {
881 881
 		// first, get all of the datetimes that are available to this ticket
882 882
 		$datetimes = $ticket->get_many_related(
883 883
 			'Datetime',
884
-			array( array( 'DTT_EVT_end' => array( '>=', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_end' ) ) ), 'order_by' => array( 'DTT_EVT_start' => 'ASC' ))
884
+			array(array('DTT_EVT_end' => array('>=', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'))), 'order_by' => array('DTT_EVT_start' => 'ASC'))
885 885
 		);
886
-		if ( ! empty( $datetimes )) {
886
+		if ( ! empty($datetimes)) {
887 887
 			// now loop thru all of the datetimes
888
-			foreach ( $datetimes as $datetime  ) {
889
-				if ( $datetime instanceof EE_Datetime ) {
888
+			foreach ($datetimes as $datetime) {
889
+				if ($datetime instanceof EE_Datetime) {
890 890
 					// the number of spaces available for the datetime without considering individual ticket quantities
891 891
 					$spaces_remaining = $datetime->spaces_remaining();
892 892
 					// save the total available spaces ( the lesser of the ticket qty minus the number of tickets sold or the datetime spaces remaining) to this ticket using the datetime ID as the key
893
-					self::$_available_spaces['tickets'][ $ticket->ID() ][ $datetime->ID() ] = min(( $ticket->qty() - $ticket->sold() ), $spaces_remaining );
893
+					self::$_available_spaces['tickets'][$ticket->ID()][$datetime->ID()] = min(($ticket->qty() - $ticket->sold()), $spaces_remaining);
894 894
 					// if the remaining spaces for this datetime is already set, then compare that against the datetime spaces remaining, and take the lowest number,
895 895
 					// else just take the datetime spaces remaining, and assign to the datetimes array
896
-					self::$_available_spaces['datetimes'][ $datetime->ID() ] = isset( self::$_available_spaces['datetimes'][ $datetime->ID() ] ) ? min( self::$_available_spaces['datetimes'][ $datetime->ID() ], $spaces_remaining ) : $spaces_remaining;
896
+					self::$_available_spaces['datetimes'][$datetime->ID()] = isset(self::$_available_spaces['datetimes'][$datetime->ID()]) ? min(self::$_available_spaces['datetimes'][$datetime->ID()], $spaces_remaining) : $spaces_remaining;
897 897
 				}
898 898
 			}
899 899
 		}
@@ -909,12 +909,12 @@  discard block
 block discarded – undo
909 909
 	 * @param 	int   $qty
910 910
 	 * @return 	int
911 911
 	 */
912
-	private static function _recalculate_ticket_datetime_availability( EE_Ticket $ticket, $qty = 0 ) {
913
-		if ( isset( self::$_available_spaces['tickets'][ $ticket->ID() ] )) {
912
+	private static function _recalculate_ticket_datetime_availability(EE_Ticket $ticket, $qty = 0) {
913
+		if (isset(self::$_available_spaces['tickets'][$ticket->ID()])) {
914 914
 			// loop thru tickets, which will ALSO include individual ticket records AND a total
915
-			foreach ( self::$_available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces  ) {
915
+			foreach (self::$_available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) {
916 916
 				// subtract the qty of selected tickets from each datetime's available spaces this ticket has access to,
917
-				self::$_available_spaces['datetimes'][ $DTD_ID ] = self::$_available_spaces['datetimes'][ $DTD_ID ] - $qty;
917
+				self::$_available_spaces['datetimes'][$DTD_ID] = self::$_available_spaces['datetimes'][$DTD_ID] - $qty;
918 918
 			}
919 919
 		}
920 920
 	}
@@ -931,8 +931,8 @@  discard block
 block discarded – undo
931 931
 	*/
932 932
 	public static function load_tckt_slctr_assets() {
933 933
 		// add some style
934
-		if ( apply_filters( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE ) ) {
935
-			wp_register_style('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css');
934
+		if (apply_filters('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE)) {
935
+			wp_register_style('ticket_selector', TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css');
936 936
 			wp_enqueue_style('ticket_selector');
937 937
 			// make it dance
938 938
 			//			wp_register_script('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js', array('espresso_core'), '', TRUE);
@@ -946,9 +946,9 @@  discard block
 block discarded – undo
946 946
 
947 947
 	public static function load_tckt_slctr_assets_admin() {
948 948
 		//iframe button js on admin event editor page
949
-		if ( EE_Registry::instance()->REQ->get('page') == 'espresso_events' && EE_Registry::instance()->REQ->get('action') == 'edit' ) {
950
-			wp_register_script( 'ticket_selector_embed', TICKET_SELECTOR_ASSETS_URL . 'ticket-selector-embed.js', array( 'ee-dialog' ), EVENT_ESPRESSO_VERSION, true );
951
-			wp_enqueue_script( 'ticket_selector_embed' );
949
+		if (EE_Registry::instance()->REQ->get('page') == 'espresso_events' && EE_Registry::instance()->REQ->get('action') == 'edit') {
950
+			wp_register_script('ticket_selector_embed', TICKET_SELECTOR_ASSETS_URL.'ticket-selector-embed.js', array('ee-dialog'), EVENT_ESPRESSO_VERSION, true);
951
+			wp_enqueue_script('ticket_selector_embed');
952 952
 		}
953 953
 	}
954 954
 
Please login to merge, or discard this patch.
core/admin/PostShortcodeTracking.php 2 patches
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 		);
316 316
 		// verify that post_shortcodes is set
317 317
 		\EE_Config::instance()->core->post_shortcodes = isset( \EE_Config::instance()->core->post_shortcodes )
318
-		                                                && is_array( \EE_Config::instance()->core->post_shortcodes )
318
+														&& is_array( \EE_Config::instance()->core->post_shortcodes )
319 319
 			? \EE_Config::instance()->core->post_shortcodes
320 320
 			: array();
321 321
 		// cycle thru post_shortcodes
@@ -420,31 +420,31 @@  discard block
 block discarded – undo
420 420
 
421 421
 
422 422
 
423
-    /**
424
-     * @param string $shortcode
425
-     * @return array
426
-     */
427
-    public static function get_post_ids_for_shortcode($shortcode='')
428
-    {
429
-        $shortcode = strtoupper($shortcode);
430
-        $shortcode = strpos($shortcode, 'ESPRESSO_') !== 0 ? "ESPRESSO_{$shortcode}" : $shortcode;
431
-        $post_ids = array();
432
-        $page_for_posts = \EE_Config::get_page_for_posts();
433
-        // looking for any references to this post
434
-        foreach (\EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes) {
435
-            // if this is the "Posts Page" (blog), then skip it
436
-            if ($post_name === $page_for_posts) {
437
-                continue;
438
-            }
439
-            // loop thru shortcodes registered for each page, and grab post id for matches
440
-            foreach ((array) $post_shortcodes as $shortcode_class => $post_ID) {
441
-                if ($shortcode_class === $shortcode) {
442
-                    $post_ids[$post_ID] = $post_ID;
443
-                }
444
-            }
445
-        }
446
-        return $post_ids;
447
-    }
423
+	/**
424
+	 * @param string $shortcode
425
+	 * @return array
426
+	 */
427
+	public static function get_post_ids_for_shortcode($shortcode='')
428
+	{
429
+		$shortcode = strtoupper($shortcode);
430
+		$shortcode = strpos($shortcode, 'ESPRESSO_') !== 0 ? "ESPRESSO_{$shortcode}" : $shortcode;
431
+		$post_ids = array();
432
+		$page_for_posts = \EE_Config::get_page_for_posts();
433
+		// looking for any references to this post
434
+		foreach (\EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes) {
435
+			// if this is the "Posts Page" (blog), then skip it
436
+			if ($post_name === $page_for_posts) {
437
+				continue;
438
+			}
439
+			// loop thru shortcodes registered for each page, and grab post id for matches
440
+			foreach ((array) $post_shortcodes as $shortcode_class => $post_ID) {
441
+				if ($shortcode_class === $shortcode) {
442
+					$post_ids[$post_ID] = $post_ID;
443
+				}
444
+			}
445
+		}
446
+		return $post_ids;
447
+	}
448 448
 
449 449
 
450 450
 
Please login to merge, or discard this patch.
Spacing   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace EventEspresso\core\admin;
3 3
 
4
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
5
-	exit( 'No direct script access allowed' );
4
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 
@@ -28,31 +28,31 @@  discard block
 block discarded – undo
28 28
 	public static function set_hooks_admin() {
29 29
 		add_action(
30 30
 			'save_post',
31
-			array( 'EventEspresso\core\admin\PostShortcodeTracking', 'parse_post_content_on_save' ),
31
+			array('EventEspresso\core\admin\PostShortcodeTracking', 'parse_post_content_on_save'),
32 32
 			100,
33 33
 			2
34 34
 		);
35 35
 		add_action(
36 36
 			'delete_post',
37
-			array( 'EventEspresso\core\admin\PostShortcodeTracking', 'unset_post_shortcodes_on_delete' ),
37
+			array('EventEspresso\core\admin\PostShortcodeTracking', 'unset_post_shortcodes_on_delete'),
38 38
 			100,
39 39
 			1
40 40
 		);
41 41
 		add_action(
42 42
 			'add_option_page_for_posts',
43
-			array( 'EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_initial_set' ),
43
+			array('EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_initial_set'),
44 44
 			100,
45 45
 			2
46 46
 		);
47 47
 		add_action(
48 48
 			'update_option',
49
-			array( 'EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_change' ),
49
+			array('EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_change'),
50 50
 			100,
51 51
 			3
52 52
 		);
53 53
 		add_action(
54 54
 			'delete_option',
55
-			array( 'EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_delete' ),
55
+			array('EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_delete'),
56 56
 			100,
57 57
 			1
58 58
 		);
@@ -72,61 +72,61 @@  discard block
 block discarded – undo
72 72
 	 * @param \WP_Post $post
73 73
 	 * @return    void
74 74
 	 */
75
-	public static function parse_post_content_on_save( $post_ID, $post ) {
75
+	public static function parse_post_content_on_save($post_ID, $post) {
76 76
 		// if the post is trashed, then let's remove our post shortcode tracking
77
-		if ( $post instanceof \WP_Post && $post->post_status === 'trash' ) {
78
-			PostShortcodeTracking::unset_post_shortcodes_on_delete( $post_ID );
77
+		if ($post instanceof \WP_Post && $post->post_status === 'trash') {
78
+			PostShortcodeTracking::unset_post_shortcodes_on_delete($post_ID);
79 79
 			return;
80 80
 		}
81 81
 		// default post types
82
-		$post_types = array( 'post' => 0, 'page' => 1 );
82
+		$post_types = array('post' => 0, 'page' => 1);
83 83
 		// add CPTs
84 84
 		$CPTs = \EE_Register_CPTs::get_CPTs();
85
-		$post_types = array_merge( $post_types, $CPTs );
85
+		$post_types = array_merge($post_types, $CPTs);
86 86
 		// for default or CPT posts...
87
-		if ( isset( $post_types[ $post->post_type ] ) ) {
87
+		if (isset($post_types[$post->post_type])) {
88 88
 			// post on frontpage ?
89 89
 			$page_for_posts = \EE_Config::get_page_for_posts();
90
-			if ( $post->post_name === $page_for_posts ) {
91
-				PostShortcodeTracking::set_post_shortcodes_for_posts_page( $page_for_posts );
90
+			if ($post->post_name === $page_for_posts) {
91
+				PostShortcodeTracking::set_post_shortcodes_for_posts_page($page_for_posts);
92 92
 				return;
93 93
 			}
94 94
 			// array of shortcodes indexed by post name
95
-			\EE_Registry::CFG()->core->post_shortcodes = isset( \EE_Registry::CFG()->core->post_shortcodes )
95
+			\EE_Registry::CFG()->core->post_shortcodes = isset(\EE_Registry::CFG()->core->post_shortcodes)
96 96
 				? \EE_Registry::CFG()->core->post_shortcodes
97 97
 				: array();
98 98
 			// whether to proceed with update
99 99
 			$update_post_shortcodes = false;
100 100
 			// empty both arrays
101
-			\EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ] = array();
101
+			\EE_Registry::CFG()->core->post_shortcodes[$post->post_name] = array();
102 102
 			// check that posts page is already being tracked
103
-			if ( ! isset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ] ) ) {
103
+			if ( ! isset(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts])) {
104 104
 				// if not, then ensure that it is properly added
105
-				\EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ] = array();
105
+				\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts] = array();
106 106
 			}
107 107
 			// loop thru shortcodes
108
-			foreach ( \EE_Registry::instance()->shortcodes as $EES_Shortcode => $shortcode_dir ) {
108
+			foreach (\EE_Registry::instance()->shortcodes as $EES_Shortcode => $shortcode_dir) {
109 109
 				// convert to UPPERCASE to get actual shortcode
110
-				$EES_Shortcode = strtoupper( $EES_Shortcode );
110
+				$EES_Shortcode = strtoupper($EES_Shortcode);
111 111
 				// is the shortcode in the post_content ?
112
-				if ( strpos( $post->post_content, $EES_Shortcode ) !== false ) {
112
+				if (strpos($post->post_content, $EES_Shortcode) !== false) {
113 113
 					// map shortcode to post names and post IDs
114
-					\EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] = $post_ID;
114
+					\EE_Registry::CFG()->core->post_shortcodes[$post->post_name][$EES_Shortcode] = $post_ID;
115 115
 					// and add this shortcode to the tracking for the blog page
116
-					PostShortcodeTracking::set_post_shortcode_for_posts_page( $page_for_posts, $EES_Shortcode, $post_ID );
116
+					PostShortcodeTracking::set_post_shortcode_for_posts_page($page_for_posts, $EES_Shortcode, $post_ID);
117 117
 					$update_post_shortcodes = true;
118 118
 				} else {
119 119
 					// shortcode is not present in post content, so check if we were tracking it previously
120 120
 					// stop tracking if shortcode is not used in this specific post
121
-					if ( isset( \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] ) ) {
122
-						unset( \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] );
121
+					if (isset(\EE_Registry::CFG()->core->post_shortcodes[$post->post_name][$EES_Shortcode])) {
122
+						unset(\EE_Registry::CFG()->core->post_shortcodes[$post->post_name][$EES_Shortcode]);
123 123
 						$update_post_shortcodes = true;
124 124
 					}
125 125
 					// make sure that something is set for the shortcode posts (even though we may remove this)
126 126
 					$shortcode_posts = isset(
127
-						\EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ]
127
+						\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode]
128 128
 					)
129
-						? \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ]
129
+						? \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode]
130 130
 						: array();
131 131
 					// and stop tracking for this shortcode on the blog page if it is not used
132 132
 					$update_post_shortcodes = PostShortcodeTracking::unset_posts_page_shortcode_for_post(
@@ -140,8 +140,8 @@  discard block
 block discarded – undo
140 140
 						: $update_post_shortcodes;
141 141
 				}
142 142
 			}
143
-			if ( $update_post_shortcodes ) {
144
-				PostShortcodeTracking::update_post_shortcodes( $page_for_posts );
143
+			if ($update_post_shortcodes) {
144
+				PostShortcodeTracking::update_post_shortcodes($page_for_posts);
145 145
 			}
146 146
 		}
147 147
 	}
@@ -158,15 +158,15 @@  discard block
 block discarded – undo
158 158
 	 * @param  string $page_for_posts
159 159
 	 * @return void
160 160
 	 */
161
-	protected static function set_post_shortcodes_for_posts_page( $page_for_posts ) {
162
-		\EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ] = array();
161
+	protected static function set_post_shortcodes_for_posts_page($page_for_posts) {
162
+		\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts] = array();
163 163
 		// loop thru shortcodes
164
-		foreach ( \EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes ) {
165
-			foreach ( $post_shortcodes as $EES_Shortcode => $post_ID ) {
166
-				PostShortcodeTracking::set_post_shortcode_for_posts_page( $page_for_posts, $EES_Shortcode, $post_ID );
164
+		foreach (\EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes) {
165
+			foreach ($post_shortcodes as $EES_Shortcode => $post_ID) {
166
+				PostShortcodeTracking::set_post_shortcode_for_posts_page($page_for_posts, $EES_Shortcode, $post_ID);
167 167
 			}
168 168
 		}
169
-		PostShortcodeTracking::update_post_shortcodes( $page_for_posts );
169
+		PostShortcodeTracking::update_post_shortcodes($page_for_posts);
170 170
 	}
171 171
 
172 172
 
@@ -181,24 +181,24 @@  discard block
 block discarded – undo
181 181
 	 * @param         $EES_Shortcode
182 182
 	 * @param         $post_ID
183 183
 	 */
184
-	protected static function set_post_shortcode_for_posts_page( $page_for_posts, $EES_Shortcode, $post_ID ) {
184
+	protected static function set_post_shortcode_for_posts_page($page_for_posts, $EES_Shortcode, $post_ID) {
185 185
 		// critical page shortcodes that we do NOT want added to the Posts page (blog)
186 186
 		$critical_shortcodes = \EE_Registry::CFG()->core->get_critical_pages_shortcodes_array();
187 187
 		// if the shortcode is NOT one of the critical page shortcodes like ESPRESSO_TXN_PAGE
188
-		if ( in_array( $EES_Shortcode, $critical_shortcodes ) ) {
188
+		if (in_array($EES_Shortcode, $critical_shortcodes)) {
189 189
 			return;
190 190
 		}
191 191
 		// add shortcode to "Posts page" tracking
192
-		if ( isset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] ) ) {
192
+		if (isset(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode])) {
193 193
 			// make sure tracking is in form of an array
194
-			if ( ! is_array( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] ) ) {
195
-				\EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] = array(
196
-					\EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] => true
194
+			if ( ! is_array(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode])) {
195
+				\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] = array(
196
+					\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] => true
197 197
 				);
198 198
 			}
199
-			\EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] += array( $post_ID => true );
199
+			\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] += array($post_ID => true);
200 200
 		} else {
201
-			\EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] = array( $post_ID => true );
201
+			\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] = array($post_ID => true);
202 202
 		}
203 203
 	}
204 204
 
@@ -211,16 +211,16 @@  discard block
 block discarded – undo
211 211
 	 * @param  int $ID
212 212
 	 * @return void
213 213
 	 */
214
-	public static function unset_post_shortcodes_on_delete( $ID ) {
214
+	public static function unset_post_shortcodes_on_delete($ID) {
215 215
 		$update_post_shortcodes = false;
216 216
 		// post on frontpage ?
217 217
 		$page_for_posts = \EE_Config::get_page_for_posts();
218 218
 		// looking for any references to this post
219
-		foreach ( \EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes ) {
219
+		foreach (\EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes) {
220 220
 			// is this the "Posts Page" (blog) ?
221
-			if ( $post_name === $page_for_posts ) {
221
+			if ($post_name === $page_for_posts) {
222 222
 				// loop thru shortcodes registered for the posts page
223
-				foreach ( $post_shortcodes as $shortcode_class => $shortcode_posts ) {
223
+				foreach ($post_shortcodes as $shortcode_class => $shortcode_posts) {
224 224
 					$update_post_shortcodes = PostShortcodeTracking::unset_posts_page_shortcode_for_post(
225 225
 						$ID,
226 226
 						$shortcode_class,
@@ -233,17 +233,17 @@  discard block
 block discarded – undo
233 233
 				}
234 234
 			} else {
235 235
 				// loop thru shortcodes registered for each page
236
-				foreach ( $post_shortcodes as $shortcode_class => $post_ID ) {
236
+				foreach ($post_shortcodes as $shortcode_class => $post_ID) {
237 237
 					// if this is page is being deleted, then don't track any post shortcodes for it
238
-					if ( $post_ID === $ID ) {
239
-						unset( \EE_Registry::CFG()->core->post_shortcodes[ $post_name ] );
238
+					if ($post_ID === $ID) {
239
+						unset(\EE_Registry::CFG()->core->post_shortcodes[$post_name]);
240 240
 						$update_post_shortcodes = true;
241 241
 					}
242 242
 				}
243 243
 			}
244 244
 		}
245
-		if ( $update_post_shortcodes ) {
246
-			PostShortcodeTracking::update_post_shortcodes( $page_for_posts );
245
+		if ($update_post_shortcodes) {
246
+			PostShortcodeTracking::update_post_shortcodes($page_for_posts);
247 247
 		}
248 248
 	}
249 249
 
@@ -268,20 +268,20 @@  discard block
 block discarded – undo
268 268
 		$update_post_shortcodes = false
269 269
 	) {
270 270
 		// make sure that an array of post IDs is being tracked for each  shortcode
271
-		if ( ! is_array( $shortcode_posts ) ) {
272
-			\EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] = array(
271
+		if ( ! is_array($shortcode_posts)) {
272
+			\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$shortcode_class] = array(
273 273
 				$shortcode_posts => true
274 274
 			);
275 275
 			$update_post_shortcodes = true;
276 276
 		}
277 277
 		// now if the ID of the post being deleted is in the $shortcode_posts array
278
-		if ( is_array( $shortcode_posts ) && isset( $shortcode_posts[ $ID ] ) ) {
279
-			unset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ][ $ID ] );
278
+		if (is_array($shortcode_posts) && isset($shortcode_posts[$ID])) {
279
+			unset(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$shortcode_class][$ID]);
280 280
 			$update_post_shortcodes = true;
281 281
 		}
282 282
 		// if nothing is registered for that shortcode anymore, then delete the shortcode altogether
283
-		if ( empty( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] ) ) {
284
-			unset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] );
283
+		if (empty(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$shortcode_class])) {
284
+			unset(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$shortcode_class]);
285 285
 			$update_post_shortcodes = true;
286 286
 		}
287 287
 		return $update_post_shortcodes;
@@ -296,9 +296,9 @@  discard block
 block discarded – undo
296 296
 	 * @param $page_for_posts
297 297
 	 * @return    void
298 298
 	 */
299
-	public static function update_post_shortcodes( $page_for_posts = '' ) {
299
+	public static function update_post_shortcodes($page_for_posts = '') {
300 300
 		// make sure page_for_posts is set
301
-		$page_for_posts = ! empty( $page_for_posts )
301
+		$page_for_posts = ! empty($page_for_posts)
302 302
 			? $page_for_posts
303 303
 			: \EE_Config::get_page_for_posts();
304 304
 		// allow others to mess stuff up :D
@@ -314,45 +314,45 @@  discard block
 block discarded – undo
314 314
 			$page_for_posts
315 315
 		);
316 316
 		// verify that post_shortcodes is set
317
-		\EE_Config::instance()->core->post_shortcodes = isset( \EE_Config::instance()->core->post_shortcodes )
318
-		                                                && is_array( \EE_Config::instance()->core->post_shortcodes )
317
+		\EE_Config::instance()->core->post_shortcodes = isset(\EE_Config::instance()->core->post_shortcodes)
318
+		                                                && is_array(\EE_Config::instance()->core->post_shortcodes)
319 319
 			? \EE_Config::instance()->core->post_shortcodes
320 320
 			: array();
321 321
 		// cycle thru post_shortcodes
322
-		foreach ( \EE_Config::instance()->core->post_shortcodes as $post_name => $shortcodes ) {
322
+		foreach (\EE_Config::instance()->core->post_shortcodes as $post_name => $shortcodes) {
323 323
 			// are there any shortcodes to track ?
324
-			if ( ! empty( $shortcodes ) ) {
324
+			if ( ! empty($shortcodes)) {
325 325
 				// loop thru list of tracked shortcodes
326
-				foreach ( $shortcodes as $shortcode => $post_id ) {
326
+				foreach ($shortcodes as $shortcode => $post_id) {
327 327
 					// if shortcode is for a critical page,
328 328
 					// BUT this is NOT the corresponding critical page for that shortcode
329
-					if ( $post_name === $page_for_posts ) {
329
+					if ($post_name === $page_for_posts) {
330 330
 						continue;
331 331
 					}
332 332
 					// skip the posts page, because we want all shortcodes registered for it
333
-					if ( $post_name === $page_for_posts ) {
333
+					if ($post_name === $page_for_posts) {
334 334
 						continue;
335 335
 					}
336 336
 					// make sure post still exists
337
-					$post = get_post( $post_id );
337
+					$post = get_post($post_id);
338 338
 					// check that the post name matches what we have saved
339
-					if ( $post && $post->post_name === $post_name ) {
339
+					if ($post && $post->post_name === $post_name) {
340 340
 						// if so, then break before hitting the unset below
341 341
 						continue;
342 342
 					}
343 343
 					// we don't like missing posts around here >:(
344
-					unset( \EE_Config::instance()->core->post_shortcodes[ $post_name ] );
344
+					unset(\EE_Config::instance()->core->post_shortcodes[$post_name]);
345 345
 				}
346 346
 			} else {
347 347
 				// you got no shortcodes to keep track of !
348
-				unset( \EE_Config::instance()->core->post_shortcodes[ $post_name ] );
348
+				unset(\EE_Config::instance()->core->post_shortcodes[$post_name]);
349 349
 			}
350 350
 		}
351 351
 		// critical page shortcodes that we do NOT want added to the Posts page (blog)
352 352
 		$critical_shortcodes = \EE_Config::instance()->core->get_critical_pages_shortcodes_array();
353
-		$critical_shortcodes = array_flip( $critical_shortcodes );
354
-		foreach ( $critical_shortcodes as $critical_shortcode ) {
355
-			unset( \EE_Config::instance()->core->post_shortcodes[ $page_for_posts ][ $critical_shortcode ] );
353
+		$critical_shortcodes = array_flip($critical_shortcodes);
354
+		foreach ($critical_shortcodes as $critical_shortcode) {
355
+			unset(\EE_Config::instance()->core->post_shortcodes[$page_for_posts][$critical_shortcode]);
356 356
 		}
357 357
 		//only show errors
358 358
 		\EE_Config::instance()->update_espresso_config();
@@ -372,8 +372,8 @@  discard block
 block discarded – undo
372 372
 	 * @param  string $value
373 373
 	 * @return void
374 374
 	 */
375
-	public static function reset_page_for_posts_on_initial_set( $option, $value ) {
376
-		PostShortcodeTracking::reset_page_for_posts_on_change( $option, '', $value );
375
+	public static function reset_page_for_posts_on_initial_set($option, $value) {
376
+		PostShortcodeTracking::reset_page_for_posts_on_change($option, '', $value);
377 377
 	}
378 378
 
379 379
 
@@ -390,13 +390,13 @@  discard block
 block discarded – undo
390 390
 	 * @param  string $value
391 391
 	 * @return void
392 392
 	 */
393
-	public static function reset_page_for_posts_on_change( $option, $old_value = '', $value = '' ) {
394
-		if ( $option === 'page_for_posts' ) {
393
+	public static function reset_page_for_posts_on_change($option, $old_value = '', $value = '') {
394
+		if ($option === 'page_for_posts') {
395 395
 			global $wpdb;
396 396
 			$table = $wpdb->posts;
397 397
 			$SQL = "SELECT post_name from $table WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
398
-			$new_page_for_posts = $value ? $wpdb->get_var( $wpdb->prepare( $SQL, $value ) ) : 'posts';
399
-			PostShortcodeTracking::set_post_shortcodes_for_posts_page( $new_page_for_posts );
398
+			$new_page_for_posts = $value ? $wpdb->get_var($wpdb->prepare($SQL, $value)) : 'posts';
399
+			PostShortcodeTracking::set_post_shortcodes_for_posts_page($new_page_for_posts);
400 400
 		}
401 401
 	}
402 402
 
@@ -412,9 +412,9 @@  discard block
 block discarded – undo
412 412
 	 * @param  string $option
413 413
 	 * @return void
414 414
 	 */
415
-	public static function reset_page_for_posts_on_delete( $option ) {
416
-		if ( $option === 'page_for_posts' ) {
417
-			PostShortcodeTracking::set_post_shortcodes_for_posts_page( 'posts' );
415
+	public static function reset_page_for_posts_on_delete($option) {
416
+		if ($option === 'page_for_posts') {
417
+			PostShortcodeTracking::set_post_shortcodes_for_posts_page('posts');
418 418
 		}
419 419
 	}
420 420
 
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
      * @param string $shortcode
425 425
      * @return array
426 426
      */
427
-    public static function get_post_ids_for_shortcode($shortcode='')
427
+    public static function get_post_ids_for_shortcode($shortcode = '')
428 428
     {
429 429
         $shortcode = strtoupper($shortcode);
430 430
         $shortcode = strpos($shortcode, 'ESPRESSO_') !== 0 ? "ESPRESSO_{$shortcode}" : $shortcode;
Please login to merge, or discard this patch.
espresso.php 1 patch
Spacing   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined( 'ABSPATH' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('ABSPATH')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /*
5 5
   Plugin Name:		Event Espresso
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
  *
43 43
  */
44 44
 
45
-if ( function_exists( 'espresso_version' ) ) {
45
+if (function_exists('espresso_version')) {
46 46
 
47 47
 	/**
48 48
 	 *    espresso_duplicate_plugin_error
@@ -51,12 +51,12 @@  discard block
 block discarded – undo
51 51
 	function espresso_duplicate_plugin_error() {
52 52
 		?>
53 53
 		<div class="error">
54
-			<p><?php _e( '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.', 'event_espresso' ); ?></p>
54
+			<p><?php _e('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.', 'event_espresso'); ?></p>
55 55
 		</div>
56 56
 		<?php
57
-		espresso_deactivate_plugin( plugin_basename( __FILE__ ) );
57
+		espresso_deactivate_plugin(plugin_basename(__FILE__));
58 58
 	}
59
-	add_action( 'admin_notices', 'espresso_duplicate_plugin_error', 1 );
59
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
60 60
 
61 61
 } else {
62 62
 
@@ -67,103 +67,103 @@  discard block
 block discarded – undo
67 67
 	 * @return string
68 68
 	 */
69 69
 	function espresso_version() {
70
-		return apply_filters( 'FHEE__espresso__espresso_version', '4.9.13.rc.020' );
70
+		return apply_filters('FHEE__espresso__espresso_version', '4.9.13.rc.020');
71 71
 	}
72 72
 
73 73
 	// define versions
74
-	define( 'EVENT_ESPRESSO_VERSION', espresso_version() );
75
-	define( 'EE_MIN_WP_VER_REQUIRED', '4.1' );
76
-	define( 'EE_MIN_WP_VER_RECOMMENDED', '4.4.2' );
77
-	define( 'EE_MIN_PHP_VER_REQUIRED', '5.3.0' );
78
-	define( 'EE_MIN_PHP_VER_RECOMMENDED', '5.4.44' );
79
-	define( 'EVENT_ESPRESSO_POWERED_BY', 'Event Espresso - ' . EVENT_ESPRESSO_VERSION );
80
-	define( 'EVENT_ESPRESSO_MAIN_FILE', __FILE__ );
74
+	define('EVENT_ESPRESSO_VERSION', espresso_version());
75
+	define('EE_MIN_WP_VER_REQUIRED', '4.1');
76
+	define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2');
77
+	define('EE_MIN_PHP_VER_REQUIRED', '5.3.0');
78
+	define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44');
79
+	define('EVENT_ESPRESSO_POWERED_BY', 'Event Espresso - '.EVENT_ESPRESSO_VERSION);
80
+	define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
81 81
 	//used to be DIRECTORY_SEPARATOR, but that caused issues on windows
82
-	if ( ! defined( 'DS' ) ) {
83
-		define( 'DS', '/' );
82
+	if ( ! defined('DS')) {
83
+		define('DS', '/');
84 84
 	}
85
-	if ( ! defined( 'PS' ) ) {
86
-		define( 'PS', PATH_SEPARATOR );
85
+	if ( ! defined('PS')) {
86
+		define('PS', PATH_SEPARATOR);
87 87
 	}
88
-	if ( ! defined( 'SP' ) ) {
89
-		define( 'SP', ' ' );
88
+	if ( ! defined('SP')) {
89
+		define('SP', ' ');
90 90
 	}
91
-	if ( ! defined( 'EENL' ) ) {
92
-		define( 'EENL', "\n" );
91
+	if ( ! defined('EENL')) {
92
+		define('EENL', "\n");
93 93
 	}
94
-	define( 'EE_SUPPORT_EMAIL', '[email protected]' );
94
+	define('EE_SUPPORT_EMAIL', '[email protected]');
95 95
 	// define the plugin directory and URL
96
-	define( 'EE_PLUGIN_BASENAME', plugin_basename( EVENT_ESPRESSO_MAIN_FILE ) );
97
-	define( 'EE_PLUGIN_DIR_PATH', plugin_dir_path( EVENT_ESPRESSO_MAIN_FILE ) );
98
-	define( 'EE_PLUGIN_DIR_URL', plugin_dir_url( EVENT_ESPRESSO_MAIN_FILE ) );
96
+	define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
97
+	define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE));
98
+	define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE));
99 99
 	// main root folder paths
100
-	define( 'EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS );
101
-	define( 'EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS );
102
-	define( 'EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS );
103
-	define( 'EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS );
104
-	define( 'EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS );
105
-	define( 'EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS );
106
-	define( 'EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS );
107
-	define( 'EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS );
100
+	define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH.'admin_pages'.DS);
101
+	define('EE_CORE', EE_PLUGIN_DIR_PATH.'core'.DS);
102
+	define('EE_MODULES', EE_PLUGIN_DIR_PATH.'modules'.DS);
103
+	define('EE_PUBLIC', EE_PLUGIN_DIR_PATH.'public'.DS);
104
+	define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH.'shortcodes'.DS);
105
+	define('EE_WIDGETS', EE_PLUGIN_DIR_PATH.'widgets'.DS);
106
+	define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH.'payment_methods'.DS);
107
+	define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH.'caffeinated'.DS);
108 108
 	// core system paths
109
-	define( 'EE_ADMIN', EE_CORE . 'admin' . DS );
110
-	define( 'EE_CPTS', EE_CORE . 'CPTs' . DS );
111
-	define( 'EE_CLASSES', EE_CORE . 'db_classes' . DS );
112
-	define( 'EE_INTERFACES', EE_CORE . 'interfaces' . DS );
113
-	define( 'EE_BUSINESS', EE_CORE . 'business' . DS );
114
-	define( 'EE_MODELS', EE_CORE . 'db_models' . DS );
115
-	define( 'EE_HELPERS', EE_CORE . 'helpers' . DS );
116
-	define( 'EE_LIBRARIES', EE_CORE . 'libraries' . DS );
117
-	define( 'EE_TEMPLATES', EE_CORE . 'templates' . DS );
118
-	define( 'EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS );
119
-	define( 'EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS );
120
-	define( 'EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS );
109
+	define('EE_ADMIN', EE_CORE.'admin'.DS);
110
+	define('EE_CPTS', EE_CORE.'CPTs'.DS);
111
+	define('EE_CLASSES', EE_CORE.'db_classes'.DS);
112
+	define('EE_INTERFACES', EE_CORE.'interfaces'.DS);
113
+	define('EE_BUSINESS', EE_CORE.'business'.DS);
114
+	define('EE_MODELS', EE_CORE.'db_models'.DS);
115
+	define('EE_HELPERS', EE_CORE.'helpers'.DS);
116
+	define('EE_LIBRARIES', EE_CORE.'libraries'.DS);
117
+	define('EE_TEMPLATES', EE_CORE.'templates'.DS);
118
+	define('EE_THIRD_PARTY', EE_CORE.'third_party_libs'.DS);
119
+	define('EE_GLOBAL_ASSETS', EE_TEMPLATES.'global_assets'.DS);
120
+	define('EE_FORM_SECTIONS', EE_LIBRARIES.'form_sections'.DS);
121 121
 	// gateways
122
-	define( 'EE_GATEWAYS', EE_MODULES . 'gateways' . DS );
123
-	define( 'EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS );
122
+	define('EE_GATEWAYS', EE_MODULES.'gateways'.DS);
123
+	define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL.'modules'.DS.'gateways'.DS);
124 124
 	// asset URL paths
125
-	define( 'EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS );
126
-	define( 'EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS );
127
-	define( 'EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS );
128
-	define( 'EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS );
129
-	define( 'EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/' );
130
-	define( 'EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/' );
125
+	define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL.'core'.DS.'templates'.DS);
126
+	define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL.'global_assets'.DS);
127
+	define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL.'images'.DS);
128
+	define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL.'core'.DS.'third_party_libs'.DS);
129
+	define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL.'core/helpers/assets/');
130
+	define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL.'core/libraries/');
131 131
 	// define upload paths
132 132
 	$uploads = wp_upload_dir();
133 133
 	// define the uploads directory and URL
134
-	define( 'EVENT_ESPRESSO_UPLOAD_DIR', $uploads[ 'basedir' ] . DS . 'espresso' . DS );
135
-	define( 'EVENT_ESPRESSO_UPLOAD_URL', $uploads[ 'baseurl' ] . DS . 'espresso' . DS );
134
+	define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'].DS.'espresso'.DS);
135
+	define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'].DS.'espresso'.DS);
136 136
 	// define the templates directory and URL
137
-	define( 'EVENT_ESPRESSO_TEMPLATE_DIR', $uploads[ 'basedir' ] . DS . 'espresso' . DS . 'templates' . DS );
138
-	define( 'EVENT_ESPRESSO_TEMPLATE_URL', $uploads[ 'baseurl' ] . DS . 'espresso' . DS . 'templates' . DS );
137
+	define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'].DS.'espresso'.DS.'templates'.DS);
138
+	define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'].DS.'espresso'.DS.'templates'.DS);
139 139
 	// define the gateway directory and URL
140
-	define( 'EVENT_ESPRESSO_GATEWAY_DIR', $uploads[ 'basedir' ] . DS . 'espresso' . DS . 'gateways' . DS );
141
-	define( 'EVENT_ESPRESSO_GATEWAY_URL', $uploads[ 'baseurl' ] . DS . 'espresso' . DS . 'gateways' . DS );
140
+	define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'].DS.'espresso'.DS.'gateways'.DS);
141
+	define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'].DS.'espresso'.DS.'gateways'.DS);
142 142
 	// languages folder/path
143
-	define( 'EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS );
144
-	define( 'EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS );
143
+	define('EE_LANGUAGES_SAFE_LOC', '..'.DS.'uploads'.DS.'espresso'.DS.'languages'.DS);
144
+	define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'languages'.DS);
145 145
 	//check for dompdf fonts in uploads
146
-	if ( file_exists( EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS ) ) {
147
-		define( 'DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS );
146
+	if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS)) {
147
+		define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS);
148 148
 	}
149 149
 	//ajax constants
150
-	define( 'EE_FRONT_AJAX', isset( $_REQUEST[ 'ee_front_ajax' ] ) || isset( $_REQUEST[ 'data' ][ 'ee_front_ajax' ] ) ? true : false );
151
-	define( 'EE_ADMIN_AJAX', isset( $_REQUEST[ 'ee_admin_ajax' ] ) || isset( $_REQUEST[ 'data' ][ 'ee_admin_ajax' ] ) ? true : false );
150
+	define('EE_FRONT_AJAX', isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false);
151
+	define('EE_ADMIN_AJAX', isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false);
152 152
 	//just a handy constant occasionally needed for finding values representing infinity in the DB
153 153
 	//you're better to use this than its straight value (currently -1) in case you ever
154 154
 	//want to change its default value! or find when -1 means infinity
155
-	define( 'EE_INF_IN_DB', -1 );
156
-	define( 'EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX );
157
-	define( 'EE_DEBUG', false );
155
+	define('EE_INF_IN_DB', -1);
156
+	define('EE_INF', INF > (float) PHP_INT_MAX ? INF : PHP_INT_MAX);
157
+	define('EE_DEBUG', false);
158 158
 
159 159
 	/**
160 160
 	 *    espresso_plugin_activation
161 161
 	 *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
162 162
 	 */
163 163
 	function espresso_plugin_activation() {
164
-		update_option( 'ee_espresso_activation', true );
164
+		update_option('ee_espresso_activation', true);
165 165
 	}
166
-	register_activation_hook( EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation' );
166
+	register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
167 167
 
168 168
 
169 169
 
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 		//	}
178 178
 		//
179 179
 	}
180
-	register_deactivation_hook( EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation' );
180
+	register_deactivation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation');
181 181
 
182 182
 
183 183
 
@@ -187,15 +187,15 @@  discard block
 block discarded – undo
187 187
 	 */
188 188
 	function espresso_load_error_handling() {
189 189
 		// load debugging tools
190
-		if ( WP_DEBUG === true && is_readable( EE_HELPERS . 'EEH_Debug_Tools.helper.php' ) ) {
191
-			require_once( EE_HELPERS . 'EEH_Debug_Tools.helper.php' );
190
+		if (WP_DEBUG === true && is_readable(EE_HELPERS.'EEH_Debug_Tools.helper.php')) {
191
+			require_once(EE_HELPERS.'EEH_Debug_Tools.helper.php');
192 192
 			EEH_Debug_Tools::instance();
193 193
 		}
194 194
 		// load error handling
195
-		if ( is_readable( EE_CORE . 'EE_Error.core.php' ) ) {
196
-			require_once( EE_CORE . 'EE_Error.core.php' );
195
+		if (is_readable(EE_CORE.'EE_Error.core.php')) {
196
+			require_once(EE_CORE.'EE_Error.core.php');
197 197
 		} else {
198
-			wp_die( __( 'The EE_Error core class could not be loaded.', 'event_espresso' ) );
198
+			wp_die(__('The EE_Error core class could not be loaded.', 'event_espresso'));
199 199
 		}
200 200
 	}
201 201
 
@@ -209,25 +209,25 @@  discard block
 block discarded – undo
209 209
 	 * @param    string $full_path_to_file
210 210
 	 * @throws    EE_Error
211 211
 	 */
212
-	function espresso_load_required( $classname, $full_path_to_file ) {
212
+	function espresso_load_required($classname, $full_path_to_file) {
213 213
 		static $error_handling_loaded = false;
214
-		if ( ! $error_handling_loaded ) {
214
+		if ( ! $error_handling_loaded) {
215 215
 			espresso_load_error_handling();
216 216
 			$error_handling_loaded = true;
217 217
 		}
218
-		if ( is_readable( $full_path_to_file ) ) {
219
-			require_once( $full_path_to_file );
218
+		if (is_readable($full_path_to_file)) {
219
+			require_once($full_path_to_file);
220 220
 		} else {
221
-			throw new EE_Error ( sprintf(
222
-				__( 'The %s class file could not be located or is not readable due to file permissions.', 'event_espresso' ),
221
+			throw new EE_Error(sprintf(
222
+				__('The %s class file could not be located or is not readable due to file permissions.', 'event_espresso'),
223 223
 				$classname
224
-			) );
224
+			));
225 225
 		}
226 226
 	}
227 227
 
228
-	espresso_load_required( 'EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php' );
229
-	espresso_load_required( 'EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php' );
230
-	espresso_load_required( 'EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php' );
228
+	espresso_load_required('EEH_Base', EE_CORE.'helpers'.DS.'EEH_Base.helper.php');
229
+	espresso_load_required('EEH_File', EE_CORE.'helpers'.DS.'EEH_File.helper.php');
230
+	espresso_load_required('EE_Bootstrap', EE_CORE.'EE_Bootstrap.core.php');
231 231
 	new EE_Bootstrap();
232 232
 
233 233
 
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 
237 237
 
238 238
 
239
-if ( ! function_exists( 'espresso_deactivate_plugin' ) ) {
239
+if ( ! function_exists('espresso_deactivate_plugin')) {
240 240
 	/**
241 241
 	*    deactivate_plugin
242 242
 	* usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
@@ -245,11 +245,11 @@  discard block
 block discarded – undo
245 245
 	* @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
246 246
 	* @return    void
247 247
 	*/
248
-	function espresso_deactivate_plugin( $plugin_basename = '' ) {
249
-		if ( ! function_exists( 'deactivate_plugins' ) ) {
250
-			require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
248
+	function espresso_deactivate_plugin($plugin_basename = '') {
249
+		if ( ! function_exists('deactivate_plugins')) {
250
+			require_once(ABSPATH.'wp-admin/includes/plugin.php');
251 251
 		}
252
-		unset( $_GET[ 'activate' ], $_REQUEST[ 'activate' ] );
253
-		deactivate_plugins( $plugin_basename );
252
+		unset($_GET['activate'], $_REQUEST['activate']);
253
+		deactivate_plugins($plugin_basename);
254 254
 	}
255 255
 }
Please login to merge, or discard this patch.