Completed
Branch FET-5580-registration-cancella... (6ecb7e)
by
unknown
38:22 queued 19:18
created
core/domain/services/registration/CreateRegistrationService.php 1 patch
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 use EventEspresso\core\exceptions\UnexpectedEntityException;
8 8
 
9 9
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
10
-    exit('No direct script access allowed');
10
+	exit('No direct script access allowed');
11 11
 }
12 12
 
13 13
 
@@ -24,97 +24,97 @@  discard block
 block discarded – undo
24 24
 {
25 25
 
26 26
 
27
-    /**
28
-     * @param \EE_Event       $event
29
-     * @param \EE_Transaction $transaction
30
-     * @param \EE_Ticket      $ticket
31
-     * @param \EE_Line_Item   $ticket_line_item
32
-     * @param                 $reg_count
33
-     * @param                 $reg_group_size
34
-     * @return \EE_Registration
35
-     * @throws \EE_Error
36
-     * @throws UnexpectedEntityException
37
-     */
38
-    public function create(
39
-        \EE_Event $event,
40
-        \EE_Transaction $transaction,
41
-        \EE_Ticket $ticket,
42
-        \EE_Line_Item $ticket_line_item,
43
-        $reg_count,
44
-        $reg_group_size
45
-    ) {
46
-        $registrations = $transaction->registrations();
47
-        $reg_count = $reg_count ? $reg_count : count($registrations) + 1;
48
-        $reg_url_link = new RegUrlLink($reg_count, $ticket_line_item);
49
-        $reg_code = new RegCode($reg_url_link, $transaction, $ticket);
50
-        // generate new EE_Registration
51
-        $registration = \EE_Registration::new_instance(
52
-            array(
53
-                'EVT_ID'          => $event->ID(),
54
-                'TXN_ID'          => $transaction->ID(),
55
-                'TKT_ID'          => $ticket->ID(),
56
-                'STS_ID'          => \EEM_Registration::status_id_incomplete,
57
-                'REG_final_price' => $this->resolveFinalPrice($transaction, $ticket, $ticket_line_item),
58
-                'REG_session'     => \EE_Registry::instance()->SSN->id(),
59
-                'REG_count'       => $reg_count,
60
-                'REG_group_size'  => $reg_group_size ? $reg_group_size : $this->incrementRegCount($registrations),
61
-                'REG_url_link'    => $reg_url_link,
62
-                'REG_code'        => $reg_code,
63
-            )
64
-        );
65
-        if ( ! $registration instanceof \EE_Registration) {
66
-            throw new UnexpectedEntityException($registration, 'EE_Registration');
67
-        }
68
-        $registration->save();
69
-        $registration->_add_relation_to($event, 'Event', array(), $event->ID());
70
-        $registration->_add_relation_to($ticket, 'Ticket', array(), $ticket->ID());
71
-        $transaction->_add_relation_to($registration, 'Registration', array(), $registration->ID());
72
-        $registration->save();
73
-        return $registration;
74
-    }
27
+	/**
28
+	 * @param \EE_Event       $event
29
+	 * @param \EE_Transaction $transaction
30
+	 * @param \EE_Ticket      $ticket
31
+	 * @param \EE_Line_Item   $ticket_line_item
32
+	 * @param                 $reg_count
33
+	 * @param                 $reg_group_size
34
+	 * @return \EE_Registration
35
+	 * @throws \EE_Error
36
+	 * @throws UnexpectedEntityException
37
+	 */
38
+	public function create(
39
+		\EE_Event $event,
40
+		\EE_Transaction $transaction,
41
+		\EE_Ticket $ticket,
42
+		\EE_Line_Item $ticket_line_item,
43
+		$reg_count,
44
+		$reg_group_size
45
+	) {
46
+		$registrations = $transaction->registrations();
47
+		$reg_count = $reg_count ? $reg_count : count($registrations) + 1;
48
+		$reg_url_link = new RegUrlLink($reg_count, $ticket_line_item);
49
+		$reg_code = new RegCode($reg_url_link, $transaction, $ticket);
50
+		// generate new EE_Registration
51
+		$registration = \EE_Registration::new_instance(
52
+			array(
53
+				'EVT_ID'          => $event->ID(),
54
+				'TXN_ID'          => $transaction->ID(),
55
+				'TKT_ID'          => $ticket->ID(),
56
+				'STS_ID'          => \EEM_Registration::status_id_incomplete,
57
+				'REG_final_price' => $this->resolveFinalPrice($transaction, $ticket, $ticket_line_item),
58
+				'REG_session'     => \EE_Registry::instance()->SSN->id(),
59
+				'REG_count'       => $reg_count,
60
+				'REG_group_size'  => $reg_group_size ? $reg_group_size : $this->incrementRegCount($registrations),
61
+				'REG_url_link'    => $reg_url_link,
62
+				'REG_code'        => $reg_code,
63
+			)
64
+		);
65
+		if ( ! $registration instanceof \EE_Registration) {
66
+			throw new UnexpectedEntityException($registration, 'EE_Registration');
67
+		}
68
+		$registration->save();
69
+		$registration->_add_relation_to($event, 'Event', array(), $event->ID());
70
+		$registration->_add_relation_to($ticket, 'Ticket', array(), $ticket->ID());
71
+		$transaction->_add_relation_to($registration, 'Registration', array(), $registration->ID());
72
+		$registration->save();
73
+		return $registration;
74
+	}
75 75
 
76 76
 
77 77
 
78
-    /**
79
-     * @param \EE_Transaction $transaction
80
-     * @param \EE_Ticket      $ticket
81
-     * @param \EE_Line_Item   $ticket_line_item
82
-     * @return float
83
-     */
84
-    protected function resolveFinalPrice(
85
-        \EE_Transaction $transaction,
86
-        \EE_Ticket $ticket,
87
-        \EE_Line_Item $ticket_line_item
88
-    ) {
89
-        $final_price = \EEH_Line_Item::calculate_final_price_for_ticket_line_item(
90
-            $transaction->total_line_item(),
91
-            $ticket_line_item
92
-        );
93
-        $final_price = $final_price !== null ? $final_price : $ticket->get_ticket_total_with_taxes();
94
-        return (float)$final_price;
95
-    }
78
+	/**
79
+	 * @param \EE_Transaction $transaction
80
+	 * @param \EE_Ticket      $ticket
81
+	 * @param \EE_Line_Item   $ticket_line_item
82
+	 * @return float
83
+	 */
84
+	protected function resolveFinalPrice(
85
+		\EE_Transaction $transaction,
86
+		\EE_Ticket $ticket,
87
+		\EE_Line_Item $ticket_line_item
88
+	) {
89
+		$final_price = \EEH_Line_Item::calculate_final_price_for_ticket_line_item(
90
+			$transaction->total_line_item(),
91
+			$ticket_line_item
92
+		);
93
+		$final_price = $final_price !== null ? $final_price : $ticket->get_ticket_total_with_taxes();
94
+		return (float)$final_price;
95
+	}
96 96
 
97 97
 
98 98
 
99
-    /**
100
-     * @param  \EE_Registration[] $registrations
101
-     * @param  boolean            $update_existing_registrations
102
-     * @return int
103
-     * @throws \EE_Error
104
-     */
105
-    protected function incrementRegCount(array $registrations, $update_existing_registrations = true)
106
-    {
107
-        $new_reg_count = count($registrations) + 1;
108
-        if ($update_existing_registrations) {
109
-            foreach ($registrations as $registration) {
110
-                if ($registration instanceof \EE_Registration) {
111
-                    $registration->set_count($new_reg_count);
112
-                    $registration->save();
113
-                }
114
-            }
115
-        }
116
-        return $new_reg_count;
117
-    }
99
+	/**
100
+	 * @param  \EE_Registration[] $registrations
101
+	 * @param  boolean            $update_existing_registrations
102
+	 * @return int
103
+	 * @throws \EE_Error
104
+	 */
105
+	protected function incrementRegCount(array $registrations, $update_existing_registrations = true)
106
+	{
107
+		$new_reg_count = count($registrations) + 1;
108
+		if ($update_existing_registrations) {
109
+			foreach ($registrations as $registration) {
110
+				if ($registration instanceof \EE_Registration) {
111
+					$registration->set_count($new_reg_count);
112
+					$registration->save();
113
+				}
114
+			}
115
+		}
116
+		return $new_reg_count;
117
+	}
118 118
 
119 119
 
120 120
 }
Please login to merge, or discard this patch.
modules/single_page_checkout/EED_Single_Page_Checkout.module.php 2 patches
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -822,12 +822,12 @@  discard block
 block discarded – undo
822 822
 			if ( $registration instanceof EE_Registration ) {
823 823
 				// we display all attendee info for the primary registrant
824 824
 				if ( $this->checkout->reg_url_link === $registration->reg_url_link()
825
-				     && $registration->is_primary_registrant()
825
+					 && $registration->is_primary_registrant()
826 826
 				) {
827 827
 					$this->checkout->primary_revisit = true;
828 828
 					break;
829 829
 				} else if ( $this->checkout->revisit
830
-				            && $this->checkout->reg_url_link !== $registration->reg_url_link()
830
+							&& $this->checkout->reg_url_link !== $registration->reg_url_link()
831 831
 				) {
832 832
 					// but hide info if it doesn't belong to you
833 833
 					$transaction->clear_cache( 'Registration', $registration->ID() );
@@ -859,23 +859,23 @@  discard block
 block discarded – undo
859 859
 				//do the following for each ticket of this type they selected
860 860
 				for ( $x = 1; $x <= $line_item->quantity(); $x++ ) {
861 861
 					$att_nmbr++;
862
-                    /** @var EventEspresso\core\services\commands\registration\CreateRegistrationCommand $CreateRegistrationCommand */
863
-                    $CreateRegistrationCommand = EE_Registry::instance()
864
-                        ->create(
865
-                           'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
866
-                           array(
867
-	                           $transaction,
868
-	                           $line_item,
869
-	                           $att_nmbr,
870
-	                           $this->checkout->total_ticket_count
871
-                           )
872
-                        );
873
-                    // override capabilities for frontend registrations
874
-                    if ( ! is_admin()) {
875
-                        $CreateRegistrationCommand->setCapCheck(
876
-	                        new PublicCapabilities( '', 'create_new_registration' )
877
-                        );
878
-                    }
862
+					/** @var EventEspresso\core\services\commands\registration\CreateRegistrationCommand $CreateRegistrationCommand */
863
+					$CreateRegistrationCommand = EE_Registry::instance()
864
+						->create(
865
+						   'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
866
+						   array(
867
+							   $transaction,
868
+							   $line_item,
869
+							   $att_nmbr,
870
+							   $this->checkout->total_ticket_count
871
+						   )
872
+						);
873
+					// override capabilities for frontend registrations
874
+					if ( ! is_admin()) {
875
+						$CreateRegistrationCommand->setCapCheck(
876
+							new PublicCapabilities( '', 'create_new_registration' )
877
+						);
878
+					}
879 879
 					$registration = EE_Registry::instance()->BUS->execute( $CreateRegistrationCommand );
880 880
 					if ( ! $registration instanceof EE_Registration ) {
881 881
 						throw new InvalidEntityException( $registration, 'EE_Registration' );
Please login to merge, or discard this patch.
Spacing   +265 added lines, -265 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php use EventEspresso\core\domain\services\capabilities\PublicCapabilities;
2 2
 use EventEspresso\core\exceptions\InvalidEntityException;
3 3
 
4
-if ( ! defined( 'EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');}
4
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); }
5 5
 /**
6 6
  * Single Page Checkout (SPCO)
7 7
  *
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
 	 * @return EED_Single_Page_Checkout
51 51
 	 */
52 52
 	public static function instance() {
53
-		add_filter( 'EED_Single_Page_Checkout__SPCO_active', '__return_true' );
54
-		return parent::get_instance( __CLASS__ );
53
+		add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true');
54
+		return parent::get_instance(__CLASS__);
55 55
 	}
56 56
 
57 57
 
@@ -96,22 +96,22 @@  discard block
 block discarded – undo
96 96
 	 */
97 97
 	public static function set_hooks_admin() {
98 98
 		EED_Single_Page_Checkout::set_definitions();
99
-		if ( defined( 'DOING_AJAX' )) {
99
+		if (defined('DOING_AJAX')) {
100 100
 			// going to start an output buffer in case anything gets accidentally output that might disrupt our JSON response
101 101
 			ob_start();
102 102
 			EED_Single_Page_Checkout::load_request_handler();
103 103
 			EED_Single_Page_Checkout::load_reg_steps();
104 104
 		} else {
105 105
 			// hook into the top of pre_get_posts to set the reg step routing, which gives other modules or plugins a chance to modify the reg steps, but just before the routes get called
106
-			add_action( 'pre_get_posts', array( 'EED_Single_Page_Checkout', 'load_reg_steps' ), 1 );
106
+			add_action('pre_get_posts', array('EED_Single_Page_Checkout', 'load_reg_steps'), 1);
107 107
 		}
108 108
 		// set ajax hooks
109
-		add_action( 'wp_ajax_process_reg_step', array( 'EED_Single_Page_Checkout', 'process_reg_step' ));
110
-		add_action( 'wp_ajax_nopriv_process_reg_step', array( 'EED_Single_Page_Checkout', 'process_reg_step' ));
111
-		add_action( 'wp_ajax_display_spco_reg_step', array( 'EED_Single_Page_Checkout', 'display_reg_step' ));
112
-		add_action( 'wp_ajax_nopriv_display_spco_reg_step', array( 'EED_Single_Page_Checkout', 'display_reg_step' ));
113
-		add_action( 'wp_ajax_update_reg_step', array( 'EED_Single_Page_Checkout', 'update_reg_step' ));
114
-		add_action( 'wp_ajax_nopriv_update_reg_step', array( 'EED_Single_Page_Checkout', 'update_reg_step' ));
109
+		add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step'));
110
+		add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step'));
111
+		add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step'));
112
+		add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step'));
113
+		add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step'));
114
+		add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step'));
115 115
 	}
116 116
 
117 117
 
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
 	 * @param string $ajax_action
123 123
 	 * @throws \EE_Error
124 124
 	 */
125
-	public static function process_ajax_request( $ajax_action ) {
126
-		EE_Registry::instance()->REQ->set( 'action', $ajax_action );
125
+	public static function process_ajax_request($ajax_action) {
126
+		EE_Registry::instance()->REQ->set('action', $ajax_action);
127 127
 		EED_Single_Page_Checkout::instance()->_initialize();
128 128
 	}
129 129
 
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	 * @throws \EE_Error
136 136
 	 */
137 137
 	public static function display_reg_step() {
138
-		EED_Single_Page_Checkout::process_ajax_request( 'display_spco_reg_step' );
138
+		EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step');
139 139
 	}
140 140
 
141 141
 
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 	 * @throws \EE_Error
147 147
 	 */
148 148
 	public static function process_reg_step() {
149
-		EED_Single_Page_Checkout::process_ajax_request( 'process_reg_step' );
149
+		EED_Single_Page_Checkout::process_ajax_request('process_reg_step');
150 150
 	}
151 151
 
152 152
 
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 	 * @throws \EE_Error
158 158
 	 */
159 159
 	public static function update_reg_step() {
160
-		EED_Single_Page_Checkout::process_ajax_request( 'update_reg_step' );
160
+		EED_Single_Page_Checkout::process_ajax_request('update_reg_step');
161 161
 	}
162 162
 
163 163
 
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 	 * @throws \EE_Error
171 171
 	 */
172 172
 	public static function update_checkout() {
173
-		EED_Single_Page_Checkout::process_ajax_request( 'update_checkout' );
173
+		EED_Single_Page_Checkout::process_ajax_request('update_checkout');
174 174
 	}
175 175
 
176 176
 
@@ -183,8 +183,8 @@  discard block
 block discarded – undo
183 183
 	 */
184 184
 	public static function load_request_handler() {
185 185
 		// load core Request_Handler class
186
-		if ( ! isset( EE_Registry::instance()->REQ )) {
187
-			EE_Registry::instance()->load_core( 'Request_Handler' );
186
+		if ( ! isset(EE_Registry::instance()->REQ)) {
187
+			EE_Registry::instance()->load_core('Request_Handler');
188 188
 		}
189 189
 	}
190 190
 
@@ -198,14 +198,14 @@  discard block
 block discarded – undo
198 198
 	 * @throws \EE_Error
199 199
 	 */
200 200
 	public static function set_definitions() {
201
-		define( 'SPCO_BASE_PATH', rtrim( str_replace( array( '\\', '/' ), DS, plugin_dir_path( __FILE__ )), DS ) . DS );
202
-		define( 'SPCO_CSS_URL', plugin_dir_url( __FILE__ ) . 'css' . DS );
203
-		define( 'SPCO_IMG_URL', plugin_dir_url( __FILE__ ) . 'img' . DS );
204
-		define( 'SPCO_JS_URL', plugin_dir_url( __FILE__ ) . 'js' . DS );
205
-		define( 'SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS );
206
-		define( 'SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS );
207
-		define( 'SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS );
208
-		EEH_Autoloader::register_autoloaders_for_each_file_in_folder( SPCO_BASE_PATH, TRUE );
201
+		define('SPCO_BASE_PATH', rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS).DS);
202
+		define('SPCO_CSS_URL', plugin_dir_url(__FILE__).'css'.DS);
203
+		define('SPCO_IMG_URL', plugin_dir_url(__FILE__).'img'.DS);
204
+		define('SPCO_JS_URL', plugin_dir_url(__FILE__).'js'.DS);
205
+		define('SPCO_INC_PATH', SPCO_BASE_PATH.'inc'.DS);
206
+		define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH.'reg_steps'.DS);
207
+		define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH.'templates'.DS);
208
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, TRUE);
209 209
 	}
210 210
 
211 211
 
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 	 */
221 221
 	public static function load_reg_steps() {
222 222
 		static $reg_steps_loaded = FALSE;
223
-		if ( $reg_steps_loaded ) {
223
+		if ($reg_steps_loaded) {
224 224
 			return;
225 225
 		}
226 226
 		// filter list of reg_steps
@@ -229,24 +229,24 @@  discard block
 block discarded – undo
229 229
 			EED_Single_Page_Checkout::get_reg_steps()
230 230
 		);
231 231
 		// sort by key (order)
232
-		ksort( $reg_steps_to_load );
232
+		ksort($reg_steps_to_load);
233 233
 		// loop through folders
234
-		foreach ( $reg_steps_to_load as $order => $reg_step ) {
234
+		foreach ($reg_steps_to_load as $order => $reg_step) {
235 235
 			// we need a
236
-			if ( isset( $reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'] )) {
236
+			if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) {
237 237
 				// copy over to the reg_steps_array
238
-				EED_Single_Page_Checkout::$_reg_steps_array[ $order ] = $reg_step;
238
+				EED_Single_Page_Checkout::$_reg_steps_array[$order] = $reg_step;
239 239
 				// register custom key route for each reg step
240 240
 				// ie: step=>"slug" - this is the entire reason we load the reg steps array now
241
-				EE_Config::register_route( $reg_step['slug'], 'EED_Single_Page_Checkout', 'run', 'step' );
241
+				EE_Config::register_route($reg_step['slug'], 'EED_Single_Page_Checkout', 'run', 'step');
242 242
 				// add AJAX or other hooks
243
-				if ( isset( $reg_step['has_hooks'] ) && $reg_step['has_hooks'] ) {
243
+				if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) {
244 244
 					// setup autoloaders if necessary
245
-					if ( ! class_exists( $reg_step['class_name'] )) {
246
-						EEH_Autoloader::register_autoloaders_for_each_file_in_folder( $reg_step['file_path'], TRUE );
245
+					if ( ! class_exists($reg_step['class_name'])) {
246
+						EEH_Autoloader::register_autoloaders_for_each_file_in_folder($reg_step['file_path'], TRUE);
247 247
 					}
248
-					if ( is_callable( $reg_step['class_name'], 'set_hooks' )) {
249
-						call_user_func( array( $reg_step['class_name'], 'set_hooks' ));
248
+					if (is_callable($reg_step['class_name'], 'set_hooks')) {
249
+						call_user_func(array($reg_step['class_name'], 'set_hooks'));
250 250
 					}
251 251
 				}
252 252
 			}
@@ -265,28 +265,28 @@  discard block
 block discarded – undo
265 265
 	 */
266 266
 	public static function get_reg_steps() {
267 267
 		$reg_steps = EE_Registry::instance()->CFG->registration->reg_steps;
268
-		if ( empty( $reg_steps )) {
268
+		if (empty($reg_steps)) {
269 269
 			$reg_steps = array(
270 270
 				10 => array(
271
-					'file_path' => SPCO_REG_STEPS_PATH . 'attendee_information',
271
+					'file_path' => SPCO_REG_STEPS_PATH.'attendee_information',
272 272
 					'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information',
273 273
 					'slug' => 'attendee_information',
274 274
 					'has_hooks' => FALSE
275 275
 				),
276 276
 				20 => array(
277
-					'file_path' => SPCO_REG_STEPS_PATH . 'registration_confirmation',
277
+					'file_path' => SPCO_REG_STEPS_PATH.'registration_confirmation',
278 278
 					'class_name' => 'EE_SPCO_Reg_Step_Registration_Confirmation',
279 279
 					'slug' => 'registration_confirmation',
280 280
 					'has_hooks' => FALSE
281 281
 				),
282 282
 				30 => array(
283
-					'file_path' => SPCO_REG_STEPS_PATH . 'payment_options',
283
+					'file_path' => SPCO_REG_STEPS_PATH.'payment_options',
284 284
 					'class_name' => 'EE_SPCO_Reg_Step_Payment_Options',
285 285
 					'slug' => 'payment_options',
286 286
 					'has_hooks' => TRUE
287 287
 				),
288 288
 				999 => array(
289
-					'file_path' => SPCO_REG_STEPS_PATH . 'finalize_registration',
289
+					'file_path' => SPCO_REG_STEPS_PATH.'finalize_registration',
290 290
 					'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration',
291 291
 					'slug' => 'finalize_registration',
292 292
 					'has_hooks' => FALSE
@@ -307,9 +307,9 @@  discard block
 block discarded – undo
307 307
 	 */
308 308
 	public static function registration_checkout_for_admin() {
309 309
 		EED_Single_Page_Checkout::load_reg_steps();
310
-		EE_Registry::instance()->REQ->set( 'step', 'attendee_information' );
311
-		EE_Registry::instance()->REQ->set( 'action', 'display_spco_reg_step' );
312
-		EE_Registry::instance()->REQ->set( 'process_form_submission', false );
310
+		EE_Registry::instance()->REQ->set('step', 'attendee_information');
311
+		EE_Registry::instance()->REQ->set('action', 'display_spco_reg_step');
312
+		EE_Registry::instance()->REQ->set('process_form_submission', false);
313 313
 		EED_Single_Page_Checkout::instance()->_initialize();
314 314
 		EED_Single_Page_Checkout::instance()->_display_spco_reg_form();
315 315
 		return EE_Registry::instance()->REQ->get_output();
@@ -326,15 +326,15 @@  discard block
 block discarded – undo
326 326
 	 */
327 327
 	public static function process_registration_from_admin() {
328 328
 		EED_Single_Page_Checkout::load_reg_steps();
329
-		EE_Registry::instance()->REQ->set( 'step', 'attendee_information' );
330
-		EE_Registry::instance()->REQ->set( 'action', 'process_reg_step' );
331
-		EE_Registry::instance()->REQ->set( 'process_form_submission', true );
329
+		EE_Registry::instance()->REQ->set('step', 'attendee_information');
330
+		EE_Registry::instance()->REQ->set('action', 'process_reg_step');
331
+		EE_Registry::instance()->REQ->set('process_form_submission', true);
332 332
 		EED_Single_Page_Checkout::instance()->_initialize();
333
-		if ( EED_Single_Page_Checkout::instance()->checkout->current_step->completed() ) {
334
-			$final_reg_step = end( EED_Single_Page_Checkout::instance()->checkout->reg_steps );
335
-			if ( $final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration ) {
336
-				EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated( $final_reg_step );
337
-				if ( $final_reg_step->process_reg_step() ) {
333
+		if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) {
334
+			$final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps);
335
+			if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) {
336
+				EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step);
337
+				if ($final_reg_step->process_reg_step()) {
338 338
 					$final_reg_step->set_completed();
339 339
 					EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array();
340 340
 					return EED_Single_Page_Checkout::instance()->checkout->transaction;
@@ -354,11 +354,11 @@  discard block
 block discarded – undo
354 354
 	 * @return    void
355 355
 	 * @throws \EE_Error
356 356
 	 */
357
-	public function run( $WP_Query ) {
357
+	public function run($WP_Query) {
358 358
 		if (
359 359
 			$WP_Query instanceof WP_Query
360 360
 			&& $WP_Query->is_main_query()
361
-			&& apply_filters( 'FHEE__EED_Single_Page_Checkout__run', true )
361
+			&& apply_filters('FHEE__EED_Single_Page_Checkout__run', true)
362 362
 		) {
363 363
 			$this->_initialize();
364 364
 		}
@@ -374,8 +374,8 @@  discard block
 block discarded – undo
374 374
 	 * @return    void
375 375
 	 * @throws \EE_Error
376 376
 	 */
377
-	public static function init( $WP_Query ) {
378
-		EED_Single_Page_Checkout::instance()->run( $WP_Query );
377
+	public static function init($WP_Query) {
378
+		EED_Single_Page_Checkout::instance()->run($WP_Query);
379 379
 	}
380 380
 
381 381
 
@@ -389,34 +389,34 @@  discard block
 block discarded – undo
389 389
 	 */
390 390
 	private function _initialize() {
391 391
 		// ensure SPCO doesn't run twice
392
-		if ( EED_Single_Page_Checkout::$_initialized ) {
392
+		if (EED_Single_Page_Checkout::$_initialized) {
393 393
 			return;
394 394
 		}
395 395
 		try {
396 396
 			// setup the EE_Checkout object
397 397
 			$this->checkout = $this->_initialize_checkout();
398 398
 			// filter checkout
399
-			$this->checkout = apply_filters( 'FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout );
399
+			$this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout);
400 400
 			// get the $_GET
401 401
 			$this->_get_request_vars();
402 402
 			// filter continue_reg
403
-			$this->checkout->continue_reg = apply_filters( 'FHEE__EED_Single_Page_Checkout__init___continue_reg', TRUE, $this->checkout );
403
+			$this->checkout->continue_reg = apply_filters('FHEE__EED_Single_Page_Checkout__init___continue_reg', TRUE, $this->checkout);
404 404
 			// load the reg steps array
405
-			if ( ! $this->_load_and_instantiate_reg_steps() ) {
405
+			if ( ! $this->_load_and_instantiate_reg_steps()) {
406 406
 				EED_Single_Page_Checkout::$_initialized = true;
407 407
 				return;
408 408
 			}
409 409
 			// set the current step
410
-			$this->checkout->set_current_step( $this->checkout->step );
410
+			$this->checkout->set_current_step($this->checkout->step);
411 411
 			// and the next step
412 412
 			$this->checkout->set_next_step();
413 413
 			// was there already a valid transaction in the checkout from the session ?
414
-			if ( ! $this->checkout->transaction instanceof EE_Transaction ) {
414
+			if ( ! $this->checkout->transaction instanceof EE_Transaction) {
415 415
 				// get transaction from db or session
416 416
 				$this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin()
417 417
 					? $this->_get_transaction_and_cart_for_previous_visit()
418 418
 					: $this->_get_cart_for_current_session_and_setup_new_transaction();
419
-				if ( ! $this->checkout->transaction instanceof EE_Transaction ) {
419
+				if ( ! $this->checkout->transaction instanceof EE_Transaction) {
420 420
 					// add some style and make it dance
421 421
 					$this->checkout->transaction = EE_Transaction::new_instance();
422 422
 					$this->add_styles_and_scripts();
@@ -424,10 +424,10 @@  discard block
 block discarded – undo
424 424
 					return;
425 425
 				}
426 426
 				// and the registrations for the transaction
427
-				$this->_get_registrations( $this->checkout->transaction );
427
+				$this->_get_registrations($this->checkout->transaction);
428 428
 			}
429 429
 			// verify that everything has been setup correctly
430
-			if ( ! $this->_final_verifications() ) {
430
+			if ( ! $this->_final_verifications()) {
431 431
 				EED_Single_Page_Checkout::$_initialized = true;
432 432
 				return;
433 433
 			}
@@ -452,9 +452,9 @@  discard block
 block discarded – undo
452 452
 			// set no cache headers and constants
453 453
 			EE_System::do_not_cache();
454 454
 			// add anchor
455
-			add_action( 'loop_start', array( $this, 'set_checkout_anchor' ), 1 );
456
-		} catch ( Exception $e ) {
457
-			EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ );
455
+			add_action('loop_start', array($this, 'set_checkout_anchor'), 1);
456
+		} catch (Exception $e) {
457
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
458 458
 		}
459 459
 	}
460 460
 
@@ -472,20 +472,20 @@  discard block
 block discarded – undo
472 472
 		// look in session for existing checkout
473 473
 		$checkout = EE_Registry::instance()->SSN->checkout();
474 474
 		// verify
475
-		if ( ! $checkout instanceof EE_Checkout ) {
475
+		if ( ! $checkout instanceof EE_Checkout) {
476 476
 			// instantiate EE_Checkout object for handling the properties of the current checkout process
477
-			$checkout = EE_Registry::instance()->load_file( SPCO_INC_PATH, 'EE_Checkout', 'class', array(), FALSE  );
477
+			$checkout = EE_Registry::instance()->load_file(SPCO_INC_PATH, 'EE_Checkout', 'class', array(), FALSE);
478 478
 		} else {
479
-			if ( $checkout->current_step->is_final_step() && $checkout->exit_spco() === true )  {
479
+			if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) {
480 480
 				$this->unlock_transaction();
481
-				wp_safe_redirect( $checkout->redirect_url );
481
+				wp_safe_redirect($checkout->redirect_url);
482 482
 				exit();
483 483
 			}
484 484
 		}
485
-		$checkout = apply_filters( 'FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout );
485
+		$checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout);
486 486
 		// verify again
487
-		if ( ! $checkout instanceof EE_Checkout ) {
488
-			throw new EE_Error( __( 'The EE_Checkout class could not be loaded.', 'event_espresso' ) );
487
+		if ( ! $checkout instanceof EE_Checkout) {
488
+			throw new EE_Error(__('The EE_Checkout class could not be loaded.', 'event_espresso'));
489 489
 		}
490 490
 		// reset anything that needs a clean slate for each request
491 491
 		$checkout->reset_for_current_request();
@@ -505,24 +505,24 @@  discard block
 block discarded – undo
505 505
 		// load classes
506 506
 		EED_Single_Page_Checkout::load_request_handler();
507 507
 		//make sure this request is marked as belonging to EE
508
-		EE_Registry::instance()->REQ->set_espresso_page( TRUE );
508
+		EE_Registry::instance()->REQ->set_espresso_page(TRUE);
509 509
 		// which step is being requested ?
510
-		$this->checkout->step = EE_Registry::instance()->REQ->get( 'step', $this->_get_first_step() );
510
+		$this->checkout->step = EE_Registry::instance()->REQ->get('step', $this->_get_first_step());
511 511
 		// which step is being edited ?
512
-		$this->checkout->edit_step = EE_Registry::instance()->REQ->get( 'edit_step', '' );
512
+		$this->checkout->edit_step = EE_Registry::instance()->REQ->get('edit_step', '');
513 513
 		// and what we're doing on the current step
514
-		$this->checkout->action = EE_Registry::instance()->REQ->get( 'action', 'display_spco_reg_step' );
514
+		$this->checkout->action = EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step');
515 515
 		// returning to edit ?
516
-		$this->checkout->reg_url_link = EE_Registry::instance()->REQ->get( 'e_reg_url_link', '' );
516
+		$this->checkout->reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link', '');
517 517
 		// or some other kind of revisit ?
518
-		$this->checkout->revisit = EE_Registry::instance()->REQ->get( 'revisit', FALSE );
518
+		$this->checkout->revisit = EE_Registry::instance()->REQ->get('revisit', FALSE);
519 519
 		// and whether or not to generate a reg form for this request
520
-		$this->checkout->generate_reg_form = EE_Registry::instance()->REQ->get( 'generate_reg_form', TRUE ); 		// TRUE 	FALSE
520
+		$this->checkout->generate_reg_form = EE_Registry::instance()->REQ->get('generate_reg_form', TRUE); // TRUE 	FALSE
521 521
 		// and whether or not to process a reg form submission for this request
522
-		$this->checkout->process_form_submission = EE_Registry::instance()->REQ->get( 'process_form_submission', FALSE ); 		// TRUE 	FALSE
522
+		$this->checkout->process_form_submission = EE_Registry::instance()->REQ->get('process_form_submission', FALSE); // TRUE 	FALSE
523 523
 		$this->checkout->process_form_submission = $this->checkout->action !== 'display_spco_reg_step'
524 524
 			? $this->checkout->process_form_submission
525
-			: FALSE; 		// TRUE 	FALSE
525
+			: FALSE; // TRUE 	FALSE
526 526
 		// $this->_display_request_vars();
527 527
 	}
528 528
 
@@ -535,17 +535,17 @@  discard block
 block discarded – undo
535 535
 	 * @return    void
536 536
 	 */
537 537
 	protected function _display_request_vars() {
538
-		if ( ! WP_DEBUG ) {
538
+		if ( ! WP_DEBUG) {
539 539
 			return;
540 540
 		}
541
-		EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ );
542
-		EEH_Debug_Tools::printr( $this->checkout->step, '$this->checkout->step', __FILE__, __LINE__ );
543
-		EEH_Debug_Tools::printr( $this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__ );
544
-		EEH_Debug_Tools::printr( $this->checkout->action, '$this->checkout->action', __FILE__, __LINE__ );
545
-		EEH_Debug_Tools::printr( $this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__ );
546
-		EEH_Debug_Tools::printr( $this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__ );
547
-		EEH_Debug_Tools::printr( $this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__ );
548
-		EEH_Debug_Tools::printr( $this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__ );
541
+		EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__);
542
+		EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__);
543
+		EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__);
544
+		EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__);
545
+		EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__);
546
+		EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__);
547
+		EEH_Debug_Tools::printr($this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__);
548
+		EEH_Debug_Tools::printr($this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__);
549 549
 	}
550 550
 
551 551
 
@@ -559,8 +559,8 @@  discard block
 block discarded – undo
559 559
 	 * @return    array
560 560
 	 */
561 561
 	private function _get_first_step() {
562
-		$first_step = reset( EED_Single_Page_Checkout::$_reg_steps_array );
563
-		return isset( $first_step['slug'] ) ? $first_step['slug'] : 'attendee_information';
562
+		$first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array);
563
+		return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information';
564 564
 	}
565 565
 
566 566
 
@@ -576,27 +576,27 @@  discard block
 block discarded – undo
576 576
 	private function _load_and_instantiate_reg_steps() {
577 577
 		// have reg_steps already been instantiated ?
578 578
 		if (
579
-			empty( $this->checkout->reg_steps ) ||
580
-			apply_filters( 'FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout )
579
+			empty($this->checkout->reg_steps) ||
580
+			apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout)
581 581
 		) {
582 582
 			// if not, then loop through raw reg steps array
583
-			foreach ( EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step ) {
584
-				if ( ! $this->_load_and_instantiate_reg_step( $reg_step, $order )) {
583
+			foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) {
584
+				if ( ! $this->_load_and_instantiate_reg_step($reg_step, $order)) {
585 585
 					return false;
586 586
 				}
587 587
 			}
588 588
 			EE_Registry::instance()->CFG->registration->skip_reg_confirmation = TRUE;
589 589
 			EE_Registry::instance()->CFG->registration->reg_confirmation_last = TRUE;
590 590
 			// skip the registration_confirmation page ?
591
-			if ( EE_Registry::instance()->CFG->registration->skip_reg_confirmation ) {
591
+			if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) {
592 592
 				// just remove it from the reg steps array
593
-				$this->checkout->remove_reg_step( 'registration_confirmation', false );
593
+				$this->checkout->remove_reg_step('registration_confirmation', false);
594 594
 			} else if (
595
-				isset( $this->checkout->reg_steps['registration_confirmation'] )
595
+				isset($this->checkout->reg_steps['registration_confirmation'])
596 596
 				&& EE_Registry::instance()->CFG->registration->reg_confirmation_last
597 597
 			) {
598 598
 				// set the order to something big like 100
599
-				$this->checkout->set_reg_step_order( 'registration_confirmation', 100 );
599
+				$this->checkout->set_reg_step_order('registration_confirmation', 100);
600 600
 			}
601 601
 			// filter the array for good luck
602 602
 			$this->checkout->reg_steps = apply_filters(
@@ -606,13 +606,13 @@  discard block
 block discarded – undo
606 606
 			// finally re-sort based on the reg step class order properties
607 607
 			$this->checkout->sort_reg_steps();
608 608
 		} else {
609
-			foreach ( $this->checkout->reg_steps as $reg_step ) {
609
+			foreach ($this->checkout->reg_steps as $reg_step) {
610 610
 				// set all current step stati to FALSE
611
-				$reg_step->set_is_current_step( FALSE );
611
+				$reg_step->set_is_current_step(FALSE);
612 612
 			}
613 613
 		}
614
-		if ( empty( $this->checkout->reg_steps )) {
615
-			EE_Error::add_error( __( 'No Reg Steps were loaded..', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__);
614
+		if (empty($this->checkout->reg_steps)) {
615
+			EE_Error::add_error(__('No Reg Steps were loaded..', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
616 616
 			return false;
617 617
 		}
618 618
 			// make reg step details available to JS
@@ -630,10 +630,10 @@  discard block
 block discarded – undo
630 630
 	 * @param int   $order
631 631
 	 * @return bool
632 632
 	 */
633
-	private function _load_and_instantiate_reg_step( $reg_step = array(), $order = 0 ) {
633
+	private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0) {
634 634
 
635 635
 		// we need a file_path, class_name, and slug to add a reg step
636
-		if ( isset( $reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'] )) {
636
+		if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) {
637 637
 			// if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step)
638 638
 			if (
639 639
 				$this->checkout->reg_url_link
@@ -651,26 +651,26 @@  discard block
 block discarded – undo
651 651
 				FALSE
652 652
 			);
653 653
 			// did we gets the goods ?
654
-			if ( $reg_step_obj instanceof EE_SPCO_Reg_Step ) {
654
+			if ($reg_step_obj instanceof EE_SPCO_Reg_Step) {
655 655
 				// set reg step order based on config
656
-				$reg_step_obj->set_order( $order );
656
+				$reg_step_obj->set_order($order);
657 657
 				// add instantiated reg step object to the master reg steps array
658
-				$this->checkout->add_reg_step( $reg_step_obj );
658
+				$this->checkout->add_reg_step($reg_step_obj);
659 659
 			} else {
660 660
 				EE_Error::add_error(
661
-					__( 'The current step could not be set.', 'event_espresso' ),
661
+					__('The current step could not be set.', 'event_espresso'),
662 662
 					__FILE__, __FUNCTION__, __LINE__
663 663
 				);
664 664
 				return false;
665 665
 			}
666 666
 		} else {
667
-			if ( WP_DEBUG ) {
667
+			if (WP_DEBUG) {
668 668
 				EE_Error::add_error(
669 669
 					sprintf(
670
-						__( 'A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s', 'event_espresso' ),
671
-						isset( $reg_step['file_path'] ) ? $reg_step['file_path'] : '',
672
-						isset( $reg_step['class_name'] ) ? $reg_step['class_name'] : '',
673
-						isset( $reg_step['slug'] ) ? $reg_step['slug'] : '',
670
+						__('A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s', 'event_espresso'),
671
+						isset($reg_step['file_path']) ? $reg_step['file_path'] : '',
672
+						isset($reg_step['class_name']) ? $reg_step['class_name'] : '',
673
+						isset($reg_step['slug']) ? $reg_step['slug'] : '',
674 674
 						'<ul>',
675 675
 						'<li>',
676 676
 						'</li>',
@@ -694,16 +694,16 @@  discard block
 block discarded – undo
694 694
 	 */
695 695
 	private function _get_transaction_and_cart_for_previous_visit() {
696 696
 		/** @var $TXN_model EEM_Transaction */
697
-		$TXN_model = EE_Registry::instance()->load_model( 'Transaction' );
697
+		$TXN_model = EE_Registry::instance()->load_model('Transaction');
698 698
 		// because the reg_url_link is present in the request, this is a return visit to SPCO, so we'll get the transaction data from the db
699
-		$transaction = $TXN_model->get_transaction_from_reg_url_link( $this->checkout->reg_url_link );
699
+		$transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link);
700 700
 		// verify transaction
701
-		if ( $transaction instanceof EE_Transaction ) {
701
+		if ($transaction instanceof EE_Transaction) {
702 702
 			// and get the cart that was used for that transaction
703
-			$this->checkout->cart = $this->_get_cart_for_transaction( $transaction );
703
+			$this->checkout->cart = $this->_get_cart_for_transaction($transaction);
704 704
 			return $transaction;
705 705
 		} else {
706
-			EE_Error::add_error( __( 'Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__);
706
+			EE_Error::add_error(__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
707 707
 			return NULL;
708 708
 		}
709 709
 	}
@@ -717,8 +717,8 @@  discard block
 block discarded – undo
717 717
 	 * @param EE_Transaction $transaction
718 718
 	 * @return EE_Cart
719 719
 	 */
720
-	private function _get_cart_for_transaction( $transaction ) {
721
-		return $this->checkout->get_cart_for_transaction( $transaction );
720
+	private function _get_cart_for_transaction($transaction) {
721
+		return $this->checkout->get_cart_for_transaction($transaction);
722 722
 	}
723 723
 
724 724
 
@@ -730,8 +730,8 @@  discard block
 block discarded – undo
730 730
 	 * @param EE_Transaction $transaction
731 731
 	 * @return EE_Cart
732 732
 	 */
733
-	public function get_cart_for_transaction( EE_Transaction $transaction ) {
734
-		return $this->checkout->get_cart_for_transaction( $transaction );
733
+	public function get_cart_for_transaction(EE_Transaction $transaction) {
734
+		return $this->checkout->get_cart_for_transaction($transaction);
735 735
 	}
736 736
 
737 737
 
@@ -747,17 +747,17 @@  discard block
 block discarded – undo
747 747
 	private function _get_cart_for_current_session_and_setup_new_transaction() {
748 748
 		//  if there's no transaction, then this is the FIRST visit to SPCO
749 749
 		// so load up the cart ( passing nothing for the TXN because it doesn't exist yet )
750
-		$this->checkout->cart = $this->_get_cart_for_transaction( NULL );
750
+		$this->checkout->cart = $this->_get_cart_for_transaction(NULL);
751 751
 		// and then create a new transaction
752 752
 		$transaction = $this->_initialize_transaction();
753 753
 		// verify transaction
754
-		if ( $transaction instanceof EE_Transaction ) {
754
+		if ($transaction instanceof EE_Transaction) {
755 755
 			// save it so that we have an ID for other objects to use
756 756
 			$transaction->save();
757 757
 			// and save TXN data to the cart
758
-			$this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn( $transaction->ID() );
758
+			$this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID());
759 759
 		} else {
760
-			EE_Error::add_error( __( 'A Valid Transaction could not be initialized.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
760
+			EE_Error::add_error(__('A Valid Transaction could not be initialized.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
761 761
 		}
762 762
 		return $transaction;
763 763
 	}
@@ -785,8 +785,8 @@  discard block
 block discarded – undo
785 785
 					'STS_ID'        => EEM_Transaction::failed_status_code,
786 786
 				)
787 787
 			);
788
-		} catch( Exception $e ) {
789
-			EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
788
+		} catch (Exception $e) {
789
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
790 790
 		}
791 791
 		return NULL;
792 792
 	}
@@ -801,38 +801,38 @@  discard block
 block discarded – undo
801 801
 	 * @return EE_Cart
802 802
 	 * @throws \EE_Error
803 803
 	 */
804
-	private function _get_registrations( EE_Transaction $transaction ) {
804
+	private function _get_registrations(EE_Transaction $transaction) {
805 805
 		// first step: grab the registrants  { : o
806
-		$registrations = $transaction->registrations( $this->checkout->reg_cache_where_params, true );
806
+		$registrations = $transaction->registrations($this->checkout->reg_cache_where_params, true);
807 807
 		// verify registrations have been set
808
-		if ( empty( $registrations )) {
808
+		if (empty($registrations)) {
809 809
 			// if no cached registrations, then check the db
810
-			$registrations = $transaction->registrations( $this->checkout->reg_cache_where_params, false );
810
+			$registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false);
811 811
 			// still nothing ? well as long as this isn't a revisit
812
-			if ( empty( $registrations ) && ! $this->checkout->revisit ) {
812
+			if (empty($registrations) && ! $this->checkout->revisit) {
813 813
 				// generate new registrations from scratch
814
-				$registrations = $this->_initialize_registrations( $transaction );
814
+				$registrations = $this->_initialize_registrations($transaction);
815 815
 			}
816 816
 		}
817 817
 		// sort by their original registration order
818
-		usort( $registrations, array( 'EED_Single_Page_Checkout', 'sort_registrations_by_REG_count' ));
818
+		usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count'));
819 819
 		// then loop thru the array
820
-		foreach ( $registrations as $registration ) {
820
+		foreach ($registrations as $registration) {
821 821
 			// verify each registration
822
-			if ( $registration instanceof EE_Registration ) {
822
+			if ($registration instanceof EE_Registration) {
823 823
 				// we display all attendee info for the primary registrant
824
-				if ( $this->checkout->reg_url_link === $registration->reg_url_link()
824
+				if ($this->checkout->reg_url_link === $registration->reg_url_link()
825 825
 				     && $registration->is_primary_registrant()
826 826
 				) {
827 827
 					$this->checkout->primary_revisit = true;
828 828
 					break;
829
-				} else if ( $this->checkout->revisit
829
+				} else if ($this->checkout->revisit
830 830
 				            && $this->checkout->reg_url_link !== $registration->reg_url_link()
831 831
 				) {
832 832
 					// but hide info if it doesn't belong to you
833
-					$transaction->clear_cache( 'Registration', $registration->ID() );
833
+					$transaction->clear_cache('Registration', $registration->ID());
834 834
 				}
835
-				$this->checkout->set_reg_status_updated( $registration->ID(), false );
835
+				$this->checkout->set_reg_status_updated($registration->ID(), false);
836 836
 			}
837 837
 		}
838 838
 	}
@@ -847,17 +847,17 @@  discard block
 block discarded – undo
847 847
 	 * @return    array
848 848
 	 * @throws \EE_Error
849 849
 	 */
850
-	private function _initialize_registrations( EE_Transaction $transaction ) {
850
+	private function _initialize_registrations(EE_Transaction $transaction) {
851 851
 		$att_nmbr = 0;
852 852
 		$registrations = array();
853
-		if ( $transaction instanceof EE_Transaction ) {
853
+		if ($transaction instanceof EE_Transaction) {
854 854
 			/** @type EE_Registration_Processor $registration_processor */
855
-			$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
855
+			$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
856 856
 			$this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count();
857 857
 			// now let's add the cart items to the $transaction
858
-			foreach ( $this->checkout->cart->get_tickets() as $line_item ) {
858
+			foreach ($this->checkout->cart->get_tickets() as $line_item) {
859 859
 				//do the following for each ticket of this type they selected
860
-				for ( $x = 1; $x <= $line_item->quantity(); $x++ ) {
860
+				for ($x = 1; $x <= $line_item->quantity(); $x++) {
861 861
 					$att_nmbr++;
862 862
                     /** @var EventEspresso\core\services\commands\registration\CreateRegistrationCommand $CreateRegistrationCommand */
863 863
                     $CreateRegistrationCommand = EE_Registry::instance()
@@ -873,17 +873,17 @@  discard block
 block discarded – undo
873 873
                     // override capabilities for frontend registrations
874 874
                     if ( ! is_admin()) {
875 875
                         $CreateRegistrationCommand->setCapCheck(
876
-	                        new PublicCapabilities( '', 'create_new_registration' )
876
+	                        new PublicCapabilities('', 'create_new_registration')
877 877
                         );
878 878
                     }
879
-					$registration = EE_Registry::instance()->BUS->execute( $CreateRegistrationCommand );
880
-					if ( ! $registration instanceof EE_Registration ) {
881
-						throw new InvalidEntityException( $registration, 'EE_Registration' );
879
+					$registration = EE_Registry::instance()->BUS->execute($CreateRegistrationCommand);
880
+					if ( ! $registration instanceof EE_Registration) {
881
+						throw new InvalidEntityException($registration, 'EE_Registration');
882 882
 					}
883
-					$registrations[ $registration->ID() ] = $registration;
883
+					$registrations[$registration->ID()] = $registration;
884 884
 				}
885 885
 			}
886
-			$registration_processor->fix_reg_final_price_rounding_issue( $transaction );
886
+			$registration_processor->fix_reg_final_price_rounding_issue($transaction);
887 887
 		}
888 888
 		return $registrations;
889 889
 	}
@@ -898,12 +898,12 @@  discard block
 block discarded – undo
898 898
 	 * @param EE_Registration $reg_B
899 899
 	 * @return int
900 900
 	 */
901
-	public static function sort_registrations_by_REG_count( EE_Registration $reg_A, EE_Registration $reg_B ) {
901
+	public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B) {
902 902
 		// this shouldn't ever happen within the same TXN, but oh well
903
-		if ( $reg_A->count() === $reg_B->count() ) {
903
+		if ($reg_A->count() === $reg_B->count()) {
904 904
 			return 0;
905 905
 		}
906
-		return ( $reg_A->count() > $reg_B->count() ) ? 1 : -1;
906
+		return ($reg_A->count() > $reg_B->count()) ? 1 : -1;
907 907
 	}
908 908
 
909 909
 
@@ -918,21 +918,21 @@  discard block
 block discarded – undo
918 918
 	 */
919 919
 	private function _final_verifications() {
920 920
 		// filter checkout
921
-		$this->checkout = apply_filters( 'FHEE__EED_Single_Page_Checkout___final_verifications__checkout', $this->checkout );
921
+		$this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___final_verifications__checkout', $this->checkout);
922 922
 		//verify that current step is still set correctly
923
-		if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step ) {
924
-			EE_Error::add_error( __( 'We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
923
+		if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) {
924
+			EE_Error::add_error(__('We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
925 925
 			return false;
926 926
 		}
927 927
 		// if returning to SPCO, then verify that primary registrant is set
928
-		if ( ! empty( $this->checkout->reg_url_link )) {
928
+		if ( ! empty($this->checkout->reg_url_link)) {
929 929
 			$valid_registrant = $this->checkout->transaction->primary_registration();
930
-			if ( ! $valid_registrant instanceof EE_Registration ) {
931
-				EE_Error::add_error( __( 'We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
930
+			if ( ! $valid_registrant instanceof EE_Registration) {
931
+				EE_Error::add_error(__('We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
932 932
 				return false;
933 933
 			}
934 934
 			$valid_registrant = null;
935
-			foreach ( $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ) as $registration ) {
935
+			foreach ($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration) {
936 936
 				if (
937 937
 					$registration instanceof EE_Registration
938 938
 					&& $registration->reg_url_link() === $this->checkout->reg_url_link
@@ -940,9 +940,9 @@  discard block
 block discarded – undo
940 940
 					$valid_registrant = $registration;
941 941
 				}
942 942
 			}
943
-			if ( ! $valid_registrant instanceof EE_Registration ) {
943
+			if ( ! $valid_registrant instanceof EE_Registration) {
944 944
 				// hmmm... maybe we have the wrong session because the user is opening multiple tabs ?
945
-				if ( EED_Single_Page_Checkout::$_checkout_verified ) {
945
+				if (EED_Single_Page_Checkout::$_checkout_verified) {
946 946
 					// clear the session, mark the checkout as unverified, and try again
947 947
 					EE_Registry::instance()->SSN->clear_session();
948 948
 					EED_Single_Page_Checkout::$_initialized = false;
@@ -951,13 +951,13 @@  discard block
 block discarded – undo
951 951
 					EE_Error::reset_notices();
952 952
 					return false;
953 953
 				}
954
-				EE_Error::add_error( __( 'We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
954
+				EE_Error::add_error(__('We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
955 955
 				return false;
956 956
 			}
957 957
 		}
958 958
 		// now that things have been kinda sufficiently verified,
959 959
 		// let's add the checkout to the session so that's available other systems
960
-		EE_Registry::instance()->SSN->set_checkout( $this->checkout );
960
+		EE_Registry::instance()->SSN->set_checkout($this->checkout);
961 961
 		return true;
962 962
 	}
963 963
 
@@ -972,15 +972,15 @@  discard block
 block discarded – undo
972 972
 	 * @param bool $reinitializing
973 973
 	 * @throws \EE_Error
974 974
 	 */
975
-	private function _initialize_reg_steps( $reinitializing = false ) {
976
-		$this->checkout->set_reg_step_initiated( $this->checkout->current_step );
975
+	private function _initialize_reg_steps($reinitializing = false) {
976
+		$this->checkout->set_reg_step_initiated($this->checkout->current_step);
977 977
 		// loop thru all steps to call their individual "initialize" methods and set i18n strings for JS
978
-		foreach ( $this->checkout->reg_steps as $reg_step ) {
979
-			if ( ! $reg_step->initialize_reg_step() ) {
978
+		foreach ($this->checkout->reg_steps as $reg_step) {
979
+			if ( ! $reg_step->initialize_reg_step()) {
980 980
 				// if not initialized then maybe this step is being removed...
981
-				if ( ! $reinitializing && $reg_step->is_current_step() ) {
981
+				if ( ! $reinitializing && $reg_step->is_current_step()) {
982 982
 					// if it was the current step, then we need to start over here
983
-					$this->_initialize_reg_steps( true );
983
+					$this->_initialize_reg_steps(true);
984 984
 					return;
985 985
 				}
986 986
 				continue;
@@ -989,13 +989,13 @@  discard block
 block discarded – undo
989 989
 			$reg_step->enqueue_styles_and_scripts();
990 990
 			// i18n
991 991
 			$reg_step->translate_js_strings();
992
-			if ( $reg_step->is_current_step() ) {
992
+			if ($reg_step->is_current_step()) {
993 993
 				// the text that appears on the reg step form submit button
994 994
 				$reg_step->set_submit_button_text();
995 995
 			}
996 996
 		}
997 997
 		// dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information
998
-		do_action( "AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", $this->checkout->current_step );
998
+		do_action("AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", $this->checkout->current_step);
999 999
 	}
1000 1000
 
1001 1001
 
@@ -1008,43 +1008,43 @@  discard block
 block discarded – undo
1008 1008
 	 */
1009 1009
 	private function _check_form_submission() {
1010 1010
 		//does this request require the reg form to be generated ?
1011
-		if ( $this->checkout->generate_reg_form ) {
1011
+		if ($this->checkout->generate_reg_form) {
1012 1012
 			// ever heard that song by Blue Rodeo ?
1013 1013
 			try {
1014 1014
 				$this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form();
1015 1015
 				// if not displaying a form, then check for form submission
1016
-				if ( $this->checkout->process_form_submission && $this->checkout->current_step->reg_form->was_submitted() ) {
1016
+				if ($this->checkout->process_form_submission && $this->checkout->current_step->reg_form->was_submitted()) {
1017 1017
 					// clear out any old data in case this step is being run again
1018
-					$this->checkout->current_step->set_valid_data( array() );
1018
+					$this->checkout->current_step->set_valid_data(array());
1019 1019
 					// capture submitted form data
1020 1020
 					$this->checkout->current_step->reg_form->receive_form_submission(
1021
-						apply_filters( 'FHEE__Single_Page_Checkout___check_form_submission__request_params', EE_Registry::instance()->REQ->params(), $this->checkout )
1021
+						apply_filters('FHEE__Single_Page_Checkout___check_form_submission__request_params', EE_Registry::instance()->REQ->params(), $this->checkout)
1022 1022
 					);
1023 1023
 					// validate submitted form data
1024
-					if ( ! $this->checkout->continue_reg && ! $this->checkout->current_step->reg_form->is_valid() ) {
1024
+					if ( ! $this->checkout->continue_reg && ! $this->checkout->current_step->reg_form->is_valid()) {
1025 1025
 						// thou shall not pass !!!
1026 1026
 						$this->checkout->continue_reg = FALSE;
1027 1027
 						// any form validation errors?
1028
-						if ( $this->checkout->current_step->reg_form->submission_error_message() !== '' ) {
1028
+						if ($this->checkout->current_step->reg_form->submission_error_message() !== '') {
1029 1029
 							$submission_error_messages = array();
1030 1030
 							// bad, bad, bad registrant
1031
-							foreach( $this->checkout->current_step->reg_form->get_validation_errors_accumulated() as $validation_error ){
1032
-								if ( $validation_error instanceof EE_Validation_Error ) {
1031
+							foreach ($this->checkout->current_step->reg_form->get_validation_errors_accumulated() as $validation_error) {
1032
+								if ($validation_error instanceof EE_Validation_Error) {
1033 1033
 									$submission_error_messages[] = sprintf(
1034
-										__( '%s : %s', 'event_espresso' ),
1034
+										__('%s : %s', 'event_espresso'),
1035 1035
 										$validation_error->get_form_section()->html_label_text(),
1036 1036
 										$validation_error->getMessage()
1037 1037
 									);
1038 1038
 								}
1039 1039
 							}
1040
-							EE_Error::add_error( implode( '<br />', $submission_error_messages ), __FILE__, __FUNCTION__, __LINE__ );
1040
+							EE_Error::add_error(implode('<br />', $submission_error_messages), __FILE__, __FUNCTION__, __LINE__);
1041 1041
 						}
1042 1042
 						// well not really... what will happen is we'll just get redirected back to redo the current step
1043 1043
 						$this->go_to_next_step();
1044 1044
 						return;
1045 1045
 					}
1046 1046
 				}
1047
-			} catch( EE_Error $e ) {
1047
+			} catch (EE_Error $e) {
1048 1048
 				$e->get_error();
1049 1049
 			}
1050 1050
 		}
@@ -1061,22 +1061,22 @@  discard block
 block discarded – undo
1061 1061
 	 */
1062 1062
 	private function _process_form_action() {
1063 1063
 		// what cha wanna do?
1064
-		switch( $this->checkout->action ) {
1064
+		switch ($this->checkout->action) {
1065 1065
 			// AJAX next step reg form
1066 1066
 			case 'display_spco_reg_step' :
1067 1067
 				$this->checkout->redirect = FALSE;
1068
-				if ( EE_Registry::instance()->REQ->ajax ) {
1069
-					$this->checkout->json_response->set_reg_step_html( $this->checkout->current_step->display_reg_form() );
1068
+				if (EE_Registry::instance()->REQ->ajax) {
1069
+					$this->checkout->json_response->set_reg_step_html($this->checkout->current_step->display_reg_form());
1070 1070
 				}
1071 1071
 				break;
1072 1072
 
1073 1073
 			default :
1074 1074
 				// meh... do one of those other steps first
1075
-				if ( ! empty( $this->checkout->action ) && is_callable( array( $this->checkout->current_step, $this->checkout->action ))) {
1075
+				if ( ! empty($this->checkout->action) && is_callable(array($this->checkout->current_step, $this->checkout->action))) {
1076 1076
 					// dynamically creates hook point like: AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step
1077
-					do_action( "AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step );
1077
+					do_action("AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step);
1078 1078
 					// call action on current step
1079
-					if ( call_user_func( array( $this->checkout->current_step, $this->checkout->action )) ) {
1079
+					if (call_user_func(array($this->checkout->current_step, $this->checkout->action))) {
1080 1080
 						// good registrant, you get to proceed
1081 1081
 						if (
1082 1082
 							$this->checkout->current_step->success_message() !== ''
@@ -1087,7 +1087,7 @@  discard block
 block discarded – undo
1087 1087
 						) {
1088 1088
 								EE_Error::add_success(
1089 1089
 									$this->checkout->current_step->success_message()
1090
-									. '<br />' . $this->checkout->next_step->_instructions()
1090
+									. '<br />'.$this->checkout->next_step->_instructions()
1091 1091
 								);
1092 1092
 
1093 1093
 						}
@@ -1095,12 +1095,12 @@  discard block
 block discarded – undo
1095 1095
 						$this->_setup_redirect();
1096 1096
 					}
1097 1097
 					// dynamically creates hook point like: AHEE__Single_Page_Checkout__after_payment_options__process_reg_step
1098
-					do_action( "AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step );
1098
+					do_action("AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step);
1099 1099
 
1100 1100
 				} else {
1101 1101
 					EE_Error::add_error(
1102 1102
 						sprintf(
1103
-							__( 'The requested form action "%s" does not exist for the current "%s" registration step.', 'event_espresso' ),
1103
+							__('The requested form action "%s" does not exist for the current "%s" registration step.', 'event_espresso'),
1104 1104
 							$this->checkout->action,
1105 1105
 							$this->checkout->current_step->name()
1106 1106
 						),
@@ -1126,10 +1126,10 @@  discard block
 block discarded – undo
1126 1126
 	public function add_styles_and_scripts() {
1127 1127
 		// i18n
1128 1128
 		$this->translate_js_strings();
1129
-		if ( $this->checkout->admin_request ) {
1130
-			add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10 );
1129
+		if ($this->checkout->admin_request) {
1130
+			add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10);
1131 1131
 		} else {
1132
-			add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles_and_scripts' ), 10 );
1132
+			add_action('wp_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10);
1133 1133
 		}
1134 1134
 	}
1135 1135
 
@@ -1145,42 +1145,42 @@  discard block
 block discarded – undo
1145 1145
 		EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit;
1146 1146
 		EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link;
1147 1147
 		EE_Registry::$i18n_js_strings['server_error'] = __('An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso');
1148
-		EE_Registry::$i18n_js_strings['invalid_json_response'] = __( 'An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso' );
1149
-		EE_Registry::$i18n_js_strings['validation_error'] = __( 'There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.', 'event_espresso' );
1150
-		EE_Registry::$i18n_js_strings['invalid_payment_method'] = __( 'There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.', 'event_espresso' );
1148
+		EE_Registry::$i18n_js_strings['invalid_json_response'] = __('An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso');
1149
+		EE_Registry::$i18n_js_strings['validation_error'] = __('There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.', 'event_espresso');
1150
+		EE_Registry::$i18n_js_strings['invalid_payment_method'] = __('There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.', 'event_espresso');
1151 1151
 		EE_Registry::$i18n_js_strings['reg_step_error'] = __('This registration step could not be completed. Please refresh the page and try again.', 'event_espresso');
1152 1152
 		EE_Registry::$i18n_js_strings['invalid_coupon'] = __('We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.', 'event_espresso');
1153
-		EE_Registry::$i18n_js_strings['process_registration'] = sprintf( __( 'Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.', 'event_espresso' ), '<br/>', '<br/>' );
1154
-		EE_Registry::$i18n_js_strings['language'] = get_bloginfo( 'language' );
1153
+		EE_Registry::$i18n_js_strings['process_registration'] = sprintf(__('Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.', 'event_espresso'), '<br/>', '<br/>');
1154
+		EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language');
1155 1155
 		EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id();
1156 1156
 		EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency;
1157 1157
 		EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20';
1158
-		EE_Registry::$i18n_js_strings['timer_years'] = __( 'years', 'event_espresso' );
1159
-		EE_Registry::$i18n_js_strings['timer_months'] = __( 'months', 'event_espresso' );
1160
-		EE_Registry::$i18n_js_strings['timer_weeks'] = __( 'weeks', 'event_espresso' );
1161
-		EE_Registry::$i18n_js_strings['timer_days'] = __( 'days', 'event_espresso' );
1162
-		EE_Registry::$i18n_js_strings['timer_hours'] = __( 'hours', 'event_espresso' );
1163
-		EE_Registry::$i18n_js_strings['timer_minutes'] = __( 'minutes', 'event_espresso' );
1164
-		EE_Registry::$i18n_js_strings['timer_seconds'] = __( 'seconds', 'event_espresso' );
1165
-		EE_Registry::$i18n_js_strings['timer_year'] = __( 'year', 'event_espresso' );
1166
-		EE_Registry::$i18n_js_strings['timer_month'] = __( 'month', 'event_espresso' );
1167
-		EE_Registry::$i18n_js_strings['timer_week'] = __( 'week', 'event_espresso' );
1168
-		EE_Registry::$i18n_js_strings['timer_day'] = __( 'day', 'event_espresso' );
1169
-		EE_Registry::$i18n_js_strings['timer_hour'] = __( 'hour', 'event_espresso' );
1170
-		EE_Registry::$i18n_js_strings['timer_minute'] = __( 'minute', 'event_espresso' );
1171
-		EE_Registry::$i18n_js_strings['timer_second'] = __( 'second', 'event_espresso' );
1158
+		EE_Registry::$i18n_js_strings['timer_years'] = __('years', 'event_espresso');
1159
+		EE_Registry::$i18n_js_strings['timer_months'] = __('months', 'event_espresso');
1160
+		EE_Registry::$i18n_js_strings['timer_weeks'] = __('weeks', 'event_espresso');
1161
+		EE_Registry::$i18n_js_strings['timer_days'] = __('days', 'event_espresso');
1162
+		EE_Registry::$i18n_js_strings['timer_hours'] = __('hours', 'event_espresso');
1163
+		EE_Registry::$i18n_js_strings['timer_minutes'] = __('minutes', 'event_espresso');
1164
+		EE_Registry::$i18n_js_strings['timer_seconds'] = __('seconds', 'event_espresso');
1165
+		EE_Registry::$i18n_js_strings['timer_year'] = __('year', 'event_espresso');
1166
+		EE_Registry::$i18n_js_strings['timer_month'] = __('month', 'event_espresso');
1167
+		EE_Registry::$i18n_js_strings['timer_week'] = __('week', 'event_espresso');
1168
+		EE_Registry::$i18n_js_strings['timer_day'] = __('day', 'event_espresso');
1169
+		EE_Registry::$i18n_js_strings['timer_hour'] = __('hour', 'event_espresso');
1170
+		EE_Registry::$i18n_js_strings['timer_minute'] = __('minute', 'event_espresso');
1171
+		EE_Registry::$i18n_js_strings['timer_second'] = __('second', 'event_espresso');
1172 1172
 		EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf(
1173
-			__( '%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s', 'event_espresso' ),
1173
+			__('%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s', 'event_espresso'),
1174 1174
 			'<h4 class="important-notice">',
1175 1175
 			'</h4>',
1176 1176
 			'<br />',
1177 1177
 			'<p>',
1178
-			'<a href="'. get_post_type_archive_link( 'espresso_events' ) . '" title="',
1178
+			'<a href="'.get_post_type_archive_link('espresso_events').'" title="',
1179 1179
 			'">',
1180 1180
 			'</a>',
1181 1181
 			'</p>'
1182 1182
 		);
1183
-		EE_Registry::$i18n_js_strings[ 'ajax_submit' ] = apply_filters( 'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', true );
1183
+		EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters('FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', true);
1184 1184
 	}
1185 1185
 
1186 1186
 
@@ -1193,25 +1193,25 @@  discard block
 block discarded – undo
1193 1193
 	 */
1194 1194
 	public function enqueue_styles_and_scripts() {
1195 1195
 		// load css
1196
-		wp_register_style( 'single_page_checkout', SPCO_CSS_URL . 'single_page_checkout.css', array(), EVENT_ESPRESSO_VERSION );
1197
-		wp_enqueue_style( 'single_page_checkout' );
1196
+		wp_register_style('single_page_checkout', SPCO_CSS_URL.'single_page_checkout.css', array(), EVENT_ESPRESSO_VERSION);
1197
+		wp_enqueue_style('single_page_checkout');
1198 1198
 		// load JS
1199
-		wp_register_script( 'jquery_plugin', EE_THIRD_PARTY_URL . 'jquery	.plugin.min.js', array( 'jquery' ), '1.0.1', TRUE );
1200
-		wp_register_script( 'jquery_countdown', EE_THIRD_PARTY_URL . 'jquery	.countdown.min.js', array( 'jquery_plugin' ), '2.0.2', TRUE );
1201
-		wp_register_script( 'single_page_checkout', SPCO_JS_URL . 'single_page_checkout.js', array( 'espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown' ), EVENT_ESPRESSO_VERSION, TRUE );
1202
-		wp_enqueue_script( 'single_page_checkout' );
1199
+		wp_register_script('jquery_plugin', EE_THIRD_PARTY_URL.'jquery	.plugin.min.js', array('jquery'), '1.0.1', TRUE);
1200
+		wp_register_script('jquery_countdown', EE_THIRD_PARTY_URL.'jquery	.countdown.min.js', array('jquery_plugin'), '2.0.2', TRUE);
1201
+		wp_register_script('single_page_checkout', SPCO_JS_URL.'single_page_checkout.js', array('espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown'), EVENT_ESPRESSO_VERSION, TRUE);
1202
+		wp_enqueue_script('single_page_checkout');
1203 1203
 
1204 1204
 		/**
1205 1205
 		 * global action hook for enqueueing styles and scripts with
1206 1206
 		 * spco calls.
1207 1207
 		 */
1208
-		do_action( 'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this );
1208
+		do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this);
1209 1209
 
1210 1210
 		/**
1211 1211
 		 * dynamic action hook for enqueueing styles and scripts with spco calls.
1212 1212
 		 * The hook will end up being something like AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information
1213 1213
 		 */
1214
-		do_action( 'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(), $this );
1214
+		do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__'.$this->checkout->current_step->slug(), $this);
1215 1215
 
1216 1216
 	}
1217 1217
 
@@ -1226,19 +1226,19 @@  discard block
 block discarded – undo
1226 1226
 	 */
1227 1227
 	private function _display_spco_reg_form() {
1228 1228
 		// if registering via the admin, just display the reg form for the current step
1229
-		if ( $this->checkout->admin_request ) {
1230
-			EE_Registry::instance()->REQ->add_output( $this->checkout->current_step->display_reg_form() );
1229
+		if ($this->checkout->admin_request) {
1230
+			EE_Registry::instance()->REQ->add_output($this->checkout->current_step->display_reg_form());
1231 1231
 		} else {
1232 1232
 			// add powered by EE msg
1233
-			add_action( 'AHEE__SPCO__reg_form_footer', array( 'EED_Single_Page_Checkout', 'display_registration_footer' ));
1233
+			add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer'));
1234 1234
 
1235
-			$empty_cart = count( $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ) ) < 1 ? true : false;
1235
+			$empty_cart = count($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params)) < 1 ? true : false;
1236 1236
 			$cookies_not_set_msg = '';
1237
-			if ( $empty_cart && ! isset( $_COOKIE[ 'ee_cookie_test' ] ) ) {
1237
+			if ($empty_cart && ! isset($_COOKIE['ee_cookie_test'])) {
1238 1238
 				$cookies_not_set_msg = apply_filters(
1239 1239
 					'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg',
1240 1240
 					sprintf(
1241
-						__( '%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s', 'event_espresso' ),
1241
+						__('%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s', 'event_espresso'),
1242 1242
 						'<div class="ee-attention">',
1243 1243
 						'</div>',
1244 1244
 						'<h6 class="important-notice">',
@@ -1258,7 +1258,7 @@  discard block
 block discarded – undo
1258 1258
 					'layout_strategy' =>
1259 1259
 						new EE_Template_Layout(
1260 1260
 							array(
1261
-								'layout_template_file' 			=> SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php',
1261
+								'layout_template_file' 			=> SPCO_TEMPLATES_PATH.'registration_page_wrapper.template.php',
1262 1262
 								'template_args' => array(
1263 1263
 									'empty_cart' 		=> $empty_cart,
1264 1264
 									'revisit' 				=> $this->checkout->revisit,
@@ -1267,8 +1267,8 @@  discard block
 block discarded – undo
1267 1267
 									'empty_msg' 		=> apply_filters(
1268 1268
 										'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg',
1269 1269
 										sprintf(
1270
-											__( 'You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', 'event_espresso' ),
1271
-											'<a href="' . get_post_type_archive_link( 'espresso_events' ) . '" title="',
1270
+											__('You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', 'event_espresso'),
1271
+											'<a href="'.get_post_type_archive_link('espresso_events').'" title="',
1272 1272
 											'">',
1273 1273
 											'</a>'
1274 1274
 										)
@@ -1276,14 +1276,14 @@  discard block
 block discarded – undo
1276 1276
 									'cookies_not_set_msg' 		=> $cookies_not_set_msg,
1277 1277
 									'registration_time_limit' 	=> $this->checkout->get_registration_time_limit(),
1278 1278
 									'session_expiration' 			=>
1279
-										gmdate( 'M d, Y H:i:s', EE_Registry::instance()->SSN->expiration() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) )
1279
+										gmdate('M d, Y H:i:s', EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS))
1280 1280
 							)
1281 1281
 						)
1282 1282
 					)
1283 1283
 				)
1284 1284
 			);
1285 1285
 			// load template and add to output sent that gets filtered into the_content()
1286
-			EE_Registry::instance()->REQ->add_output( $this->checkout->registration_form->get_html_and_js() );
1286
+			EE_Registry::instance()->REQ->add_output($this->checkout->registration_form->get_html_and_js());
1287 1287
 		}
1288 1288
 	}
1289 1289
 
@@ -1297,8 +1297,8 @@  discard block
 block discarded – undo
1297 1297
 	 * @internal  param string $label
1298 1298
 	 * @return        string
1299 1299
 	 */
1300
-	public function add_extra_finalize_registration_inputs( $next_step ) {
1301
-		if ( $next_step === 'finalize_registration' ) {
1300
+	public function add_extra_finalize_registration_inputs($next_step) {
1301
+		if ($next_step === 'finalize_registration') {
1302 1302
 			echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>';
1303 1303
 		}
1304 1304
 	}
@@ -1312,18 +1312,18 @@  discard block
 block discarded – undo
1312 1312
 	 *  @return 	string
1313 1313
 	 */
1314 1314
 	public static function display_registration_footer() {
1315
-		if ( apply_filters( 'FHEE__EE_Front__Controller__show_reg_footer', EE_Registry::instance()->CFG->admin->show_reg_footer ) ) {
1316
-			EE_Registry::instance()->CFG->admin->affiliate_id = ! empty( EE_Registry::instance()->CFG->admin->affiliate_id ) ? EE_Registry::instance()->CFG->admin->affiliate_id : 'default';
1317
-			$url = add_query_arg( array( 'ap_id' => EE_Registry::instance()->CFG->admin->affiliate_id ), 'https://eventespresso.com/' );
1318
-			$url = apply_filters( 'FHEE__EE_Front_Controller__registration_footer__url', $url );
1315
+		if (apply_filters('FHEE__EE_Front__Controller__show_reg_footer', EE_Registry::instance()->CFG->admin->show_reg_footer)) {
1316
+			EE_Registry::instance()->CFG->admin->affiliate_id = ! empty(EE_Registry::instance()->CFG->admin->affiliate_id) ? EE_Registry::instance()->CFG->admin->affiliate_id : 'default';
1317
+			$url = add_query_arg(array('ap_id' => EE_Registry::instance()->CFG->admin->affiliate_id), 'https://eventespresso.com/');
1318
+			$url = apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url);
1319 1319
 			echo apply_filters(
1320 1320
 				'FHEE__EE_Front_Controller__display_registration_footer',
1321 1321
 				sprintf(
1322
-					__( '%1$sEvent Registration Powered by Event Espresso%2$sEvent Registration and Ticketing%3$s Powered by %4$sEvent Espresso - Event Registration and Management System for WordPress%5$sEvent Espresso%6$s', 'event_espresso' ),
1323
-					'<div id="espresso-registration-footer-dv"><a href="' . $url . '" title="',
1322
+					__('%1$sEvent Registration Powered by Event Espresso%2$sEvent Registration and Ticketing%3$s Powered by %4$sEvent Espresso - Event Registration and Management System for WordPress%5$sEvent Espresso%6$s', 'event_espresso'),
1323
+					'<div id="espresso-registration-footer-dv"><a href="'.$url.'" title="',
1324 1324
 					'" target="_blank">',
1325 1325
 					'</a>',
1326
-					'<a href="' . $url . '" title="',
1326
+					'<a href="'.$url.'" title="',
1327 1327
 					'" target="_blank">',
1328 1328
 					'</a></div>'
1329 1329
 				)
@@ -1341,7 +1341,7 @@  discard block
 block discarded – undo
1341 1341
 	 * @throws \EE_Error
1342 1342
 	 */
1343 1343
 	public function unlock_transaction() {
1344
-		if ( $this->checkout->transaction instanceof EE_Transaction ) {
1344
+		if ($this->checkout->transaction instanceof EE_Transaction) {
1345 1345
 			$this->checkout->transaction->unlock();
1346 1346
 		}
1347 1347
 	}
@@ -1356,12 +1356,12 @@  discard block
 block discarded – undo
1356 1356
 	 * @return 	array
1357 1357
 	 */
1358 1358
 	private function _setup_redirect() {
1359
-		if ( $this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step ) {
1359
+		if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
1360 1360
 			$this->checkout->redirect = TRUE;
1361
-			if ( empty( $this->checkout->redirect_url )) {
1361
+			if (empty($this->checkout->redirect_url)) {
1362 1362
 				$this->checkout->redirect_url = $this->checkout->next_step->reg_step_url();
1363 1363
 			}
1364
-			$this->checkout->redirect_url = apply_filters( 'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', $this->checkout->redirect_url, $this->checkout );
1364
+			$this->checkout->redirect_url = apply_filters('FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', $this->checkout->redirect_url, $this->checkout);
1365 1365
 		}
1366 1366
 	}
1367 1367
 
@@ -1375,9 +1375,9 @@  discard block
 block discarded – undo
1375 1375
 	 * @throws \EE_Error
1376 1376
 	 */
1377 1377
 	public function go_to_next_step() {
1378
-		if ( EE_Registry::instance()->REQ->ajax ) {
1378
+		if (EE_Registry::instance()->REQ->ajax) {
1379 1379
 			// capture contents of output buffer we started earlier in the request, and insert into JSON response
1380
-			$this->checkout->json_response->set_unexpected_errors( ob_get_clean() );
1380
+			$this->checkout->json_response->set_unexpected_errors(ob_get_clean());
1381 1381
 		}
1382 1382
 		$this->unlock_transaction();
1383 1383
 		// just return for these conditions
@@ -1406,7 +1406,7 @@  discard block
 block discarded – undo
1406 1406
 	 */
1407 1407
 	protected function _handle_json_response() {
1408 1408
 		// if this is an ajax request
1409
-		if ( EE_Registry::instance()->REQ->ajax ) {
1409
+		if (EE_Registry::instance()->REQ->ajax) {
1410 1410
 			// DEBUG LOG
1411 1411
 			//$this->checkout->log(
1412 1412
 			//	__CLASS__, __FUNCTION__, __LINE__,
@@ -1419,7 +1419,7 @@  discard block
 block discarded – undo
1419 1419
 			$this->checkout->json_response->set_registration_time_limit(
1420 1420
 				$this->checkout->get_registration_time_limit()
1421 1421
 			);
1422
-			$this->checkout->json_response->set_payment_amount( $this->checkout->amount_owing );
1422
+			$this->checkout->json_response->set_payment_amount($this->checkout->amount_owing);
1423 1423
 			// just send the ajax (
1424 1424
 			$json_response = apply_filters(
1425 1425
 				'FHEE__EE_Single_Page_Checkout__JSON_response',
@@ -1440,9 +1440,9 @@  discard block
 block discarded – undo
1440 1440
 	 */
1441 1441
 	protected function _handle_html_redirects() {
1442 1442
 		// going somewhere ?
1443
-		if ( $this->checkout->redirect && ! empty( $this->checkout->redirect_url ) ) {
1443
+		if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) {
1444 1444
 			// store notices in a transient
1445
-			EE_Error::get_notices( false, true, true );
1445
+			EE_Error::get_notices(false, true, true);
1446 1446
 			// DEBUG LOG
1447 1447
 			//$this->checkout->log(
1448 1448
 			//	__CLASS__, __FUNCTION__, __LINE__,
@@ -1452,7 +1452,7 @@  discard block
 block discarded – undo
1452 1452
 			//		'headers_list'    => headers_list(),
1453 1453
 			//	)
1454 1454
 			//);
1455
-			wp_safe_redirect( $this->checkout->redirect_url );
1455
+			wp_safe_redirect($this->checkout->redirect_url);
1456 1456
 			exit();
1457 1457
 		}
1458 1458
 	}
Please login to merge, or discard this patch.
admin_pages/registrations/Registrations_Admin_Page.core.php 1 patch
Spacing   +581 added lines, -581 removed lines patch added patch discarded remove patch
@@ -56,26 +56,26 @@  discard block
 block discarded – undo
56 56
 	 * @param bool $routing
57 57
 	 * @return Registrations_Admin_Page
58 58
 	 */
59
-	public function __construct( $routing = TRUE ) {
60
-		parent::__construct( $routing );
61
-		add_action( 'wp_loaded', array( $this, 'wp_loaded' ));
59
+	public function __construct($routing = TRUE) {
60
+		parent::__construct($routing);
61
+		add_action('wp_loaded', array($this, 'wp_loaded'));
62 62
 	}
63 63
 
64 64
 
65 65
 
66 66
 	public function wp_loaded() {
67 67
 		// when adding a new registration...
68
-		if ( isset( $this->_req_data[ 'action' ] ) && $this->_req_data[ 'action' ] == 'new_registration' ) {
68
+		if (isset($this->_req_data['action']) && $this->_req_data['action'] == 'new_registration') {
69 69
 			EE_System::do_not_cache();
70 70
 			if (
71
-				! isset( $this->_req_data[ 'processing_registration' ] )
72
-				|| absint( $this->_req_data[ 'processing_registration' ] ) !== 1
71
+				! isset($this->_req_data['processing_registration'])
72
+				|| absint($this->_req_data['processing_registration']) !== 1
73 73
 			) {
74 74
 				// and it's NOT the attendee information reg step
75 75
 				// force cookie expiration by setting time to last week
76
-				setcookie( 'ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/' );
76
+				setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/');
77 77
 				// and update the global
78
-				$_COOKIE[ 'ee_registration_added' ] = 0;
78
+				$_COOKIE['ee_registration_added'] = 0;
79 79
 			}
80 80
 		}
81 81
 	}
@@ -109,16 +109,16 @@  discard block
 block discarded – undo
109 109
 				'trash' => 'post.php'
110 110
 			);
111 111
 
112
-		add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10 );
112
+		add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10);
113 113
 		//add filters so that the comment urls don't take users to a confusing 404 page
114
-		add_filter('get_comment_link', array( $this, 'clear_comment_link' ), 10, 3 );
114
+		add_filter('get_comment_link', array($this, 'clear_comment_link'), 10, 3);
115 115
 	}
116 116
 
117 117
 
118
-	public function clear_comment_link( $link, $comment, $args ) {
118
+	public function clear_comment_link($link, $comment, $args) {
119 119
 		//gotta make sure this only happens on this route
120
-		$post_type = get_post_type( $comment->comment_post_ID);
121
-		if ( $post_type == 'espresso_attendees' )
120
+		$post_type = get_post_type($comment->comment_post_ID);
121
+		if ($post_type == 'espresso_attendees')
122 122
 			return '#commentsdiv';
123 123
 		return $link;
124 124
 	}
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 
127 127
 	protected function _ajax_hooks() {
128 128
 		//todo: all hooks for registrations ajax goes in here
129
-		add_action( 'wp_ajax_toggle_checkin_status', array( $this, 'toggle_checkin_status' ));
129
+		add_action('wp_ajax_toggle_checkin_status', array($this, 'toggle_checkin_status'));
130 130
 	}
131 131
 
132 132
 
@@ -141,8 +141,8 @@  discard block
 block discarded – undo
141 141
 				'add-attendee' => __('Add Contact', 'event_espresso'),
142 142
 				'edit' => __('Edit Contact', 'event_espresso'),
143 143
 				'report'=>  __("Event Registrations CSV Report", "event_espresso"),
144
-				'report_all' => __( 'All Registrations CSV Report', 'event_espresso' ),
145
-				'contact_list_report' => __( 'Contact List Report', 'event_espresso' ),
144
+				'report_all' => __('All Registrations CSV Report', 'event_espresso'),
145
+				'contact_list_report' => __('Contact List Report', 'event_espresso'),
146 146
 				'contact_list_export'=>  __("Export Data", "event_espresso"),
147 147
 			),
148 148
 			'publishbox' => array(
@@ -170,9 +170,9 @@  discard block
 block discarded – undo
170 170
 
171 171
 		$this->_get_registration_status_array();
172 172
 
173
-		$reg_id = ! empty( $this->_req_data['_REG_ID'] ) && ! is_array( $this->_req_data['_REG_ID'] ) ? $this->_req_data['_REG_ID'] : 0;
174
-		$att_id = ! empty( $this->_req_data[ 'ATT_ID' ] ) && ! is_array( $this->_req_data['ATT_ID'] ) ? $this->_req_data['ATT_ID'] : 0;
175
-		$att_id = ! empty( $this->_req_data['post'] ) && ! is_array( $this->_req_data['post'] ) ? $this->_req_data['post'] : $att_id;
173
+		$reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0;
174
+		$att_id = ! empty($this->_req_data['ATT_ID']) && ! is_array($this->_req_data['ATT_ID']) ? $this->_req_data['ATT_ID'] : 0;
175
+		$att_id = ! empty($this->_req_data['post']) && ! is_array($this->_req_data['post']) ? $this->_req_data['post'] : $att_id;
176 176
 
177 177
 		$this->_page_routes = array(
178 178
 
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 
206 206
 				'restore_registrations' => array(
207 207
 					'func' => '_trash_or_restore_registrations',
208
-					'args' => array( 'trash' => FALSE ),
208
+					'args' => array('trash' => FALSE),
209 209
 					'noheader' => TRUE,
210 210
 					'capability' => 'ee_delete_registrations'
211 211
 					),
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
 						'filename' => 'registrations_overview_other'
439 439
 					)
440 440
                 ),
441
-				'help_tour' => array( 'Registration_Overview_Help_Tour' ),
441
+				'help_tour' => array('Registration_Overview_Help_Tour'),
442 442
 				'qtips' => array('Registration_List_Table_Tips'),
443 443
 				'list_table' => 'EE_Registrations_List_Table',
444 444
 				'require_nonce' => FALSE
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
 					'order' => 15,
451 451
 					'url' => isset($this->_req_data['_REG_ID'])
452 452
 						? add_query_arg(
453
-							array('_REG_ID' => $this->_req_data['_REG_ID'] ),
453
+							array('_REG_ID' => $this->_req_data['_REG_ID']),
454 454
 							$this->_current_page_view_url
455 455
 						)
456 456
 						: $this->_admin_base_url,
@@ -474,8 +474,8 @@  discard block
 block discarded – undo
474 474
 						'filename' => 'registrations_details_registrant_details'
475 475
 					)
476 476
 				),
477
-				'help_tour' => array( 'Registration_Details_Help_Tour' ),
478
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_registration_details_metaboxes' ) ),
477
+				'help_tour' => array('Registration_Details_Help_Tour'),
478
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_registration_details_metaboxes')),
479 479
 				'require_nonce' => FALSE
480 480
 			),
481 481
 
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
 					'order' => 15,
500 500
 					'persistent' => FALSE
501 501
 				),
502
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box', 'attendee_editor_metaboxes' ) ),
502
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box', 'attendee_editor_metaboxes')),
503 503
 				'require_nonce' => FALSE
504 504
 			),
505 505
 
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
 					'label' => __('Edit Contact', 'event_espresso'),
509 509
 					'order' => 15,
510 510
 					'persistent' => FALSE,
511
-					'url' => isset($this->_req_data['ATT_ID']) ? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID'] ), $this->_current_page_view_url )  : $this->_admin_base_url
511
+					'url' => isset($this->_req_data['ATT_ID']) ? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID']), $this->_current_page_view_url) : $this->_admin_base_url
512 512
 				),
513 513
 				'metaboxes' => array('attendee_editor_metaboxes'),
514 514
 				'require_nonce' => FALSE
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
 						'filename' => 'registrations_contact_list_other'
539 539
 					)
540 540
                 ),
541
-				'help_tour' => array( 'Contact_List_Help_Tour' ),
541
+				'help_tour' => array('Contact_List_Help_Tour'),
542 542
 				'metaboxes' => array(),
543 543
 				'require_nonce' => FALSE
544 544
 			),
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
 	protected function _add_screen_options() {}
558 558
 	protected function _add_feature_pointers() {}
559 559
 	public function admin_init() {
560
-		EE_Registry::$i18n_js_strings[ 'update_att_qstns' ] = __( 'click "Update Registration Questions" to save your changes', 'event_espresso' );
560
+		EE_Registry::$i18n_js_strings['update_att_qstns'] = __('click "Update Registration Questions" to save your changes', 'event_espresso');
561 561
 	}
562 562
 	public function admin_notices() {}
563 563
 	public function admin_footer_scripts() {}
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
 	*		@return void
576 576
 	*/
577 577
 	private function _get_registration_status_array() {
578
-		self::$_reg_status = EEM_Registration::reg_status_array( array(), TRUE);
578
+		self::$_reg_status = EEM_Registration::reg_status_array(array(), TRUE);
579 579
 	}
580 580
 
581 581
 
@@ -598,11 +598,11 @@  discard block
 block discarded – undo
598 598
 	public function load_scripts_styles() {
599 599
 		//style
600 600
 		//wp_register_style('espresso_attendees', ATT_ASSETS_URL . 'espresso_attendees_admin.css', array(), EVENT_ESPRESSO_VERSION );
601
-		wp_register_style('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION );
601
+		wp_register_style('espresso_reg', REG_ASSETS_URL.'espresso_registrations_admin.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION);
602 602
 		wp_enqueue_style('espresso_reg');
603 603
 
604 604
 		//script
605
-		wp_register_script('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.js', array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'), EVENT_ESPRESSO_VERSION, TRUE);
605
+		wp_register_script('espresso_reg', REG_ASSETS_URL.'espresso_registrations_admin.js', array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'), EVENT_ESPRESSO_VERSION, TRUE);
606 606
 		wp_enqueue_script('espresso_reg');
607 607
 	}
608 608
 
@@ -611,9 +611,9 @@  discard block
 block discarded – undo
611 611
 	public function load_scripts_styles_edit_attendee() {
612 612
 		//stuff to only show up on our attendee edit details page.
613 613
 		$attendee_details_translations = array(
614
-			'att_publish_text' => sprintf( __('Created on: <b>%1$s</b>', 'event_espresso'), $this->_cpt_model_obj->get_datetime('ATT_created') )
614
+			'att_publish_text' => sprintf(__('Created on: <b>%1$s</b>', 'event_espresso'), $this->_cpt_model_obj->get_datetime('ATT_created'))
615 615
 			);
616
-		wp_localize_script( 'espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations );
616
+		wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
617 617
 		wp_enqueue_script('jquery-validate');
618 618
 	}
619 619
 
@@ -622,8 +622,8 @@  discard block
 block discarded – undo
622 622
 		//styles
623 623
 		wp_enqueue_style('espresso-ui-theme');
624 624
 		//scripts
625
-		$this->_get_reg_custom_questions_form( $this->_registration->ID() );
626
-		$this->_reg_custom_questions_form->wp_enqueue_scripts( true );
625
+		$this->_get_reg_custom_questions_form($this->_registration->ID());
626
+		$this->_reg_custom_questions_form->wp_enqueue_scripts(true);
627 627
 	}
628 628
 
629 629
 
@@ -633,7 +633,7 @@  discard block
 block discarded – undo
633 633
 
634 634
 	public function load_scripts_styles_contact_list() {
635 635
 		wp_deregister_style('espresso_reg');
636
-		wp_register_style('espresso_att', REG_ASSETS_URL . 'espresso_attendees_admin.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION );
636
+		wp_register_style('espresso_att', REG_ASSETS_URL.'espresso_attendees_admin.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION);
637 637
 		wp_enqueue_style('espresso_att');
638 638
 	}
639 639
 
@@ -642,9 +642,9 @@  discard block
 block discarded – undo
642 642
 
643 643
 
644 644
 	public function load_scripts_styles_new_registration() {
645
-		wp_register_script( 'ee-spco-for-admin', REG_ASSETS_URL . 'spco_for_admin.js', array('underscore', 'jquery'), EVENT_ESPRESSO_VERSION, TRUE );
645
+		wp_register_script('ee-spco-for-admin', REG_ASSETS_URL.'spco_for_admin.js', array('underscore', 'jquery'), EVENT_ESPRESSO_VERSION, TRUE);
646 646
 		wp_enqueue_script('ee-spco-for-admin');
647
-		add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true' );
647
+		add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
648 648
 		EE_Form_Section_Proper::wp_enqueue_scripts();
649 649
 		EED_Ticket_Selector::load_tckt_slctr_assets();
650 650
 		EE_Datepicker_Input::enqueue_styles_and_scripts();
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
 		//for notification related bulk actions we need to make sure only active messengers have an option.
672 672
 		EED_Messages::set_autoloaders();
673 673
 		/** @type EE_Message_Resource_Manager $message_resource_manager */
674
-		$message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' );
674
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
675 675
 		$active_mts = $message_resource_manager->list_of_active_message_types();
676 676
 		//key= bulk_action_slug, value= message type.
677 677
 		$match_array = array(
@@ -684,23 +684,23 @@  discard block
 block discarded – undo
684 684
 
685 685
 		/** setup reg status bulk actions **/
686 686
 		$def_reg_status_actions['approve_registration'] = __('Approve Registrations', 'event_espresso');
687
-		if ( in_array( $match_array['approve_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) {
687
+		if (in_array($match_array['approve_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) {
688 688
 			$def_reg_status_actions['approve_and_notify_registration'] = __('Approve and Notify Registrations', 'event_espresso');
689 689
 		}
690 690
 		$def_reg_status_actions['decline_registration'] = __('Decline Registrations', 'event_espresso');
691
-		if ( in_array( $match_array['decline_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) {
691
+		if (in_array($match_array['decline_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) {
692 692
 			$def_reg_status_actions['decline_and_notify_registration'] = __('Decline and Notify Registrations', 'event_espresso');
693 693
 		}
694 694
 		$def_reg_status_actions['pending_registration'] = __('Set Registrations to Pending Payment', 'event_espresso');
695
-		if ( in_array( $match_array['pending_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) {
695
+		if (in_array($match_array['pending_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) {
696 696
 			$def_reg_status_actions['pending_and_notify_registration'] = __('Set Registrations to Pending Payment and Notify', 'event_espresso');
697 697
 		}
698 698
 		$def_reg_status_actions['no_approve_registration'] = __('Set Registrations to Not Approved', 'event_espresso');
699
-		if ( in_array( $match_array['no_approve_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) {
699
+		if (in_array($match_array['no_approve_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) {
700 700
 			$def_reg_status_actions['no_approve_and_notify_registration'] = __('Set Registrations to Not Approved and Notify', 'event_espresso');
701 701
 		}
702 702
 		$def_reg_status_actions['cancel_registration'] = __('Cancel Registrations', 'event_espresso');
703
-		if ( in_array( $match_array['cancel_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) {
703
+		if (in_array($match_array['cancel_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) {
704 704
 			$def_reg_status_actions['cancel_and_notify_registration'] = __('Cancel Registrations and Notify', 'event_espresso');
705 705
 		}
706 706
 
@@ -709,29 +709,29 @@  discard block
 block discarded – undo
709 709
 				'slug' => 'all',
710 710
 				'label' => __('View All Registrations', 'event_espresso'),
711 711
 				'count' => 0,
712
-				'bulk_action' => array_merge( $def_reg_status_actions, array(
712
+				'bulk_action' => array_merge($def_reg_status_actions, array(
713 713
 					'trash_registrations' => __('Trash Registrations', 'event_espresso')
714
-					) )
714
+					))
715 715
 				),
716 716
 			'month' => array(
717 717
 				'slug' => 'month',
718 718
 				'label' => __('This Month', 'event_espresso'),
719 719
 				'count' => 0,
720
-				'bulk_action' => array_merge( $def_reg_status_actions, array(
720
+				'bulk_action' => array_merge($def_reg_status_actions, array(
721 721
 					'trash_registrations' => __('Trash Registrations', 'event_espresso')
722 722
 					))
723 723
 				),
724 724
 			'today' => array(
725 725
 				'slug' => 'today',
726
-				'label' => sprintf( __('Today - %s', 'event_espresso'), date('M d, Y', current_time('timestamp' ) ) ),
726
+				'label' => sprintf(__('Today - %s', 'event_espresso'), date('M d, Y', current_time('timestamp'))),
727 727
 				'count' => 0,
728
-				'bulk_action' => array_merge( $def_reg_status_actions,  array(
728
+				'bulk_action' => array_merge($def_reg_status_actions, array(
729 729
 					'trash_registrations' => __('Trash Registrations', 'event_espresso')
730 730
 					))
731 731
 				)
732 732
 			);
733 733
 
734
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_registrations', 'espresso_registrations_delete_registration' ) ) {
734
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registrations', 'espresso_registrations_delete_registration')) {
735 735
 			$this->_views['incomplete'] = array(
736 736
 				'slug' => 'incomplete',
737 737
 				'label' => __('Incomplete', 'event_espresso'),
@@ -767,7 +767,7 @@  discard block
 block discarded – undo
767 767
 				)
768 768
 			);
769 769
 
770
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_contacts', 'espresso_registrations_trash_attendees' ) ) {
770
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_contacts', 'espresso_registrations_trash_attendees')) {
771 771
 			$this->_views['trash'] = array(
772 772
 				'slug' => 'trash',
773 773
 				'label' => __('Trash', 'event_espresso'),
@@ -806,18 +806,18 @@  discard block
 block discarded – undo
806 806
 				'desc' => __('View Transaction Invoice', 'event_espresso')
807 807
 				),
808 808
  			);
809
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'espresso_registrations_resend_registration' ) ) {
809
+		if (EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'espresso_registrations_resend_registration')) {
810 810
 			$fc_items['resend_registration'] = array(
811 811
 				'class' => 'dashicons dashicons-email-alt',
812 812
 				'desc' => __('Resend Registration Details', 'event_espresso')
813 813
 				);
814 814
 		} else {
815
-			$fc_items['blank'] = array( 'class' => 'blank', 'desc' => '' );
815
+			$fc_items['blank'] = array('class' => 'blank', 'desc' => '');
816 816
 		}
817 817
 
818
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_global_messages', 'view_filtered_messages' ) ) {
819
-			$related_for_icon = EEH_MSG_Template::get_message_action_icon( 'see_notifications_for' );
820
-			if ( isset( $related_for_icon['css_class']) && isset( $related_for_icon['label'] ) ) {
818
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
819
+			$related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
820
+			if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) {
821 821
 				$fc_items['view_related_messages'] = array(
822 822
 					'class' => $related_for_icon['css_class'],
823 823
 					'desc' => $related_for_icon['label'],
@@ -827,35 +827,35 @@  discard block
 block discarded – undo
827 827
 
828 828
 		$sc_items = array(
829 829
 			'approved_status' => array(
830
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
831
-				'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_approved, FALSE, 'sentence' )
830
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_approved,
831
+				'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, FALSE, 'sentence')
832 832
 				),
833 833
 			'pending_status' => array(
834
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
835
-				'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_pending_payment, FALSE, 'sentence' )
834
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_pending_payment,
835
+				'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, FALSE, 'sentence')
836 836
 				),
837 837
 			'wait_list' => array(
838
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
839
-				'desc'  => EEH_Template::pretty_status( EEM_Registration::status_id_wait_list, false, 'sentence' )
838
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_wait_list,
839
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence')
840 840
 			),
841 841
 			'incomplete_status' => array(
842
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete,
843
-				'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_incomplete, FALSE, 'sentence' )
842
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_incomplete,
843
+				'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_incomplete, FALSE, 'sentence')
844 844
 			),
845 845
 			'not_approved' => array(
846
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
847
-				'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_not_approved, FALSE, 'sentence' )
846
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_not_approved,
847
+				'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, FALSE, 'sentence')
848 848
 				),
849 849
 			'declined_status' => array(
850
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
851
-				'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_declined, FALSE, 'sentence' )
850
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_declined,
851
+				'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, FALSE, 'sentence')
852 852
 				),
853 853
 			'cancelled_status' => array(
854
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
855
-				'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_cancelled, FALSE, 'sentence' )
854
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_cancelled,
855
+				'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, FALSE, 'sentence')
856 856
 				)
857 857
 			);
858
-		return array_merge( $fc_items, $sc_items );
858
+		return array_merge($fc_items, $sc_items);
859 859
 	}
860 860
 
861 861
 
@@ -869,45 +869,45 @@  discard block
 block discarded – undo
869 869
 	 */
870 870
 	protected function _registrations_overview_list_table() {
871 871
 		$this->_template_args['admin_page_header'] = '';
872
-		$EVT_ID = ! empty( $this->_req_data['event_id'] ) ? absint( $this->_req_data['event_id'] ) : 0;
873
-		if ( $EVT_ID ) {
874
-			if ( EE_Registry::instance()->CAP->current_user_can(
872
+		$EVT_ID = ! empty($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : 0;
873
+		if ($EVT_ID) {
874
+			if (EE_Registry::instance()->CAP->current_user_can(
875 875
 				'ee_edit_registrations',
876 876
 				'espresso_registrations_new_registration',
877 877
 				$EVT_ID
878 878
 				)
879 879
 			) {
880
-				$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
880
+				$this->_admin_page_title .= ' '.$this->get_action_link_or_button(
881 881
 					'new_registration',
882 882
 					'add-registrant',
883
-					array( 'event_id' => $EVT_ID ),
883
+					array('event_id' => $EVT_ID),
884 884
 					'add-new-h2'
885 885
 				);
886 886
 			}
887
-			$event = EEM_Event::instance()->get_one_by_ID( $EVT_ID );
888
-			if ( $event instanceof EE_Event ) {
887
+			$event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
888
+			if ($event instanceof EE_Event) {
889 889
 				$this->_template_args['admin_page_header'] = sprintf(
890
-					__( '%s Viewing registrations for the event: %s%s', 'event_espresso' ),
890
+					__('%s Viewing registrations for the event: %s%s', 'event_espresso'),
891 891
 					'<h3 style="line-height:1.5em;">',
892
-					'<br /><a href="' . EE_Admin_Page::add_query_args_and_nonce(
893
-						array( 'action' => 'edit', 'post' => $event->ID() ),
892
+					'<br /><a href="'.EE_Admin_Page::add_query_args_and_nonce(
893
+						array('action' => 'edit', 'post' => $event->ID()),
894 894
 						EVENTS_ADMIN_URL
895
-					) . '">&nbsp;' . $event->get( 'EVT_name' ) . '&nbsp;</a>&nbsp;',
895
+					).'">&nbsp;'.$event->get('EVT_name').'&nbsp;</a>&nbsp;',
896 896
 					'</h3>'
897 897
 				);
898 898
 			}
899
-			$DTT_ID = ! empty( $this->_req_data['datetime_id'] ) ? absint( $this->_req_data['datetime_id'] ) : 0;
900
-			$datetime = EEM_Datetime::instance()->get_one_by_ID( $DTT_ID );
901
-			if ( $datetime instanceof EE_Datetime && $this->_template_args['admin_page_header'] !== '' ) {
902
-				$this->_template_args['admin_page_header'] = substr( $this->_template_args['admin_page_header'], 0, -5 );
899
+			$DTT_ID = ! empty($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : 0;
900
+			$datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID);
901
+			if ($datetime instanceof EE_Datetime && $this->_template_args['admin_page_header'] !== '') {
902
+				$this->_template_args['admin_page_header'] = substr($this->_template_args['admin_page_header'], 0, -5);
903 903
 				$this->_template_args['admin_page_header'] .= ' &nbsp;<span class="drk-grey-text">';
904 904
 				$this->_template_args['admin_page_header'] .= '<span class="dashicons dashicons-calendar"></span>';
905 905
 				$this->_template_args['admin_page_header'] .= $datetime->name();
906
-				$this->_template_args['admin_page_header'] .= ' ( ' . $datetime->start_date() . ' )';
906
+				$this->_template_args['admin_page_header'] .= ' ( '.$datetime->start_date().' )';
907 907
 				$this->_template_args['admin_page_header'] .= '</span></h3>';
908 908
 			}
909 909
 		}
910
-		$this->_template_args['after_list_table'] = $this->_display_legend( $this->_registration_legend_items() );
910
+		$this->_template_args['after_list_table'] = $this->_display_legend($this->_registration_legend_items());
911 911
 		$this->display_admin_list_table_page_with_no_sidebar();
912 912
 	}
913 913
 
@@ -922,19 +922,19 @@  discard block
 block discarded – undo
922 922
 	 */
923 923
 	private function _set_registration_object() {
924 924
 		//get out if we've already set the object
925
-		if ( is_object( $this->_registration )) {
925
+		if (is_object($this->_registration)) {
926 926
 			return TRUE;
927 927
 		}
928 928
 
929 929
 	    $REG = EEM_Registration::instance();
930 930
 
931
-		$REG_ID = ( ! empty( $this->_req_data['_REG_ID'] )) ? absint( $this->_req_data['_REG_ID'] ) : FALSE;
931
+		$REG_ID = ( ! empty($this->_req_data['_REG_ID'])) ? absint($this->_req_data['_REG_ID']) : FALSE;
932 932
 
933
-		if ( $this->_registration = $REG->get_one_by_ID( $REG_ID ))
933
+		if ($this->_registration = $REG->get_one_by_ID($REG_ID))
934 934
 			return TRUE;
935 935
 		else {
936
-			$error_msg = sprintf( __('An error occurred and the details for Registration ID #%s could not be retrieved.', 'event_espresso'), $REG_ID );
937
-			EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ );
936
+			$error_msg = sprintf(__('An error occurred and the details for Registration ID #%s could not be retrieved.', 'event_espresso'), $REG_ID);
937
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
938 938
 			$this->_registration = NULL;
939 939
 			return FALSE;
940 940
 		}
@@ -952,25 +952,25 @@  discard block
 block discarded – undo
952 952
 	 * @throws \EE_Error
953 953
 	 * @return mixed (int|array)  int = count || array of registration objects
954 954
 	 */
955
-	public function get_registrations( $per_page = 10, $count = FALSE, $this_month = FALSE, $today = FALSE ) {
956
-		$EVT_ID = ! empty( $this->_req_data['event_id'] ) && $this->_req_data['event_id'] > 0 ? absint( $this->_req_data['event_id'] ) : FALSE;
957
-		$CAT_ID = ! empty( $this->_req_data['EVT_CAT'] ) && (int) $this->_req_data['EVT_CAT'] > 0? absint( $this->_req_data['EVT_CAT'] ) : FALSE;
958
-		$DTT_ID = isset( $this->_req_data['datetime_id'] ) ? absint( $this->_req_data['datetime_id'] ) : null;
959
-		$reg_status = ! empty( $this->_req_data['_reg_status'] ) ? sanitize_text_field( $this->_req_data['_reg_status'] ) : FALSE;
960
-		$month_range = ! empty( $this->_req_data['month_range'] ) ? sanitize_text_field( $this->_req_data['month_range'] ) : FALSE;//should be like 2013-april
961
-		$today_a = ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] === 'today' ? TRUE : FALSE;
962
-		$this_month_a = ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] === 'month' ? TRUE  : FALSE;
955
+	public function get_registrations($per_page = 10, $count = FALSE, $this_month = FALSE, $today = FALSE) {
956
+		$EVT_ID = ! empty($this->_req_data['event_id']) && $this->_req_data['event_id'] > 0 ? absint($this->_req_data['event_id']) : FALSE;
957
+		$CAT_ID = ! empty($this->_req_data['EVT_CAT']) && (int) $this->_req_data['EVT_CAT'] > 0 ? absint($this->_req_data['EVT_CAT']) : FALSE;
958
+		$DTT_ID = isset($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : null;
959
+		$reg_status = ! empty($this->_req_data['_reg_status']) ? sanitize_text_field($this->_req_data['_reg_status']) : FALSE;
960
+		$month_range = ! empty($this->_req_data['month_range']) ? sanitize_text_field($this->_req_data['month_range']) : FALSE; //should be like 2013-april
961
+		$today_a = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'today' ? TRUE : FALSE;
962
+		$this_month_a = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'month' ? TRUE : FALSE;
963 963
 		$start_date = FALSE;
964 964
 		$end_date = FALSE;
965 965
 		$_where = array();
966
-		$trash = ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] === 'trash' ? TRUE : FALSE;
967
-		$incomplete = ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] === 'incomplete' ? TRUE : FALSE;
966
+		$trash = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'trash' ? TRUE : FALSE;
967
+		$incomplete = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'incomplete' ? TRUE : FALSE;
968 968
 
969 969
 		//set orderby
970 970
 		$this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
971 971
 
972 972
 
973
-		switch ( $this->_req_data['orderby'] ) {
973
+		switch ($this->_req_data['orderby']) {
974 974
 			case '_REG_ID':
975 975
 				$orderby = 'REG_ID';
976 976
 				break;
@@ -990,30 +990,30 @@  discard block
 block discarded – undo
990 990
 				$orderby = 'REG_date';
991 991
 		}
992 992
 
993
-		$sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'DESC';
994
-		$current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1;
995
-		$per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page;
993
+		$sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'DESC';
994
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1;
995
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page;
996 996
 
997 997
 
998
-		$offset = ($current_page-1)*$per_page;
999
-		$limit = $count  ? NULL : array( $offset, $per_page );
998
+		$offset = ($current_page - 1) * $per_page;
999
+		$limit = $count ? NULL : array($offset, $per_page);
1000 1000
 
1001
-		if($EVT_ID){
1002
-			$_where['EVT_ID']=$EVT_ID;
1001
+		if ($EVT_ID) {
1002
+			$_where['EVT_ID'] = $EVT_ID;
1003 1003
 		}
1004
-		if($CAT_ID){
1004
+		if ($CAT_ID) {
1005 1005
 			$_where['Event.Term_Taxonomy.term_id'] = $CAT_ID;
1006 1006
 		}
1007 1007
 		//if DTT is included we filter by that datetime.
1008
-		if ( $DTT_ID ) {
1008
+		if ($DTT_ID) {
1009 1009
 			$_where['Ticket.Datetime.DTT_ID'] = $DTT_ID;
1010 1010
 		}
1011
-		if ( $incomplete ) {
1011
+		if ($incomplete) {
1012 1012
 			$_where['STS_ID'] = EEM_Registration::status_id_incomplete;
1013 1013
 		} else if ( ! $trash) {
1014
-			$_where['STS_ID'] = array( '!=', EEM_Registration::status_id_incomplete );
1014
+			$_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
1015 1015
 		}
1016
-		if($reg_status){
1016
+		if ($reg_status) {
1017 1017
 			$_where['STS_ID'] = $reg_status;
1018 1018
 		}
1019 1019
 
@@ -1025,103 +1025,103 @@  discard block
 block discarded – undo
1025 1025
 		$time_start = ' 00:00:00';
1026 1026
 		$time_end = ' 23:59:59';
1027 1027
 
1028
-		if($today_a || $today ){
1028
+		if ($today_a || $today) {
1029 1029
 			$curdate = date('Y-m-d', current_time('timestamp'));
1030
-			$_where['REG_date']= array('BETWEEN',
1030
+			$_where['REG_date'] = array('BETWEEN',
1031 1031
 				array(
1032
-					EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $curdate . $time_start, 'Y-m-d H:i:s' ),
1033
-					EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $curdate . $time_end, 'Y-m-d H:i:s' ),
1032
+					EEM_Registration::instance()->convert_datetime_for_query('REG_date', $curdate.$time_start, 'Y-m-d H:i:s'),
1033
+					EEM_Registration::instance()->convert_datetime_for_query('REG_date', $curdate.$time_end, 'Y-m-d H:i:s'),
1034 1034
 			));
1035
-		}elseif($this_month_a || $this_month){
1035
+		}elseif ($this_month_a || $this_month) {
1036 1036
 			$this_month_r = date('m', current_time('timestamp'));
1037
-			$days_this_month = date( 't', current_time('timestamp') );
1038
-			$_where['REG_date']= array('BETWEEN',
1037
+			$days_this_month = date('t', current_time('timestamp'));
1038
+			$_where['REG_date'] = array('BETWEEN',
1039 1039
 				array(
1040
-					EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start, 'Y-m-d H:i:s' ),
1041
-					EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end, 'Y-m-d H:i:s' )
1040
+					EEM_Registration::instance()->convert_datetime_for_query('REG_date', $this_year_r.'-'.$this_month_r.'-01'.' '.$time_start, 'Y-m-d H:i:s'),
1041
+					EEM_Registration::instance()->convert_datetime_for_query('REG_date', $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' '.$time_end, 'Y-m-d H:i:s')
1042 1042
 			));
1043
-		}elseif($month_range){
1043
+		}elseif ($month_range) {
1044 1044
 			$pieces = explode(' ', $this->_req_data['month_range'], 3);
1045
-			$month_r = !empty($pieces[0]) ? date('m', strtotime( $month_range ) ) : '';
1046
-			$year_r = !empty($pieces[1]) ? $pieces[1] : '';
1047
-			$days_in_month = date('t', strtotime($year_r .  '-' . $month_r . '-' . '01') );
1048
-			$_where['REG_date']= array('BETWEEN',
1049
-				array(  EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $year_r . '-' . $month_r . '-01 00:00:00', 'Y-m-d H:i:s'), EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $year_r . '-' . $month_r . '-' . $days_in_month .  ' 23:59:59', 'Y-m-d H:i:s' ) ) );
1050
-		}elseif($start_date && $end_date){
1045
+			$month_r = ! empty($pieces[0]) ? date('m', strtotime($month_range)) : '';
1046
+			$year_r = ! empty($pieces[1]) ? $pieces[1] : '';
1047
+			$days_in_month = date('t', strtotime($year_r.'-'.$month_r.'-'.'01'));
1048
+			$_where['REG_date'] = array('BETWEEN',
1049
+				array(EEM_Registration::instance()->convert_datetime_for_query('REG_date', $year_r.'-'.$month_r.'-01 00:00:00', 'Y-m-d H:i:s'), EEM_Registration::instance()->convert_datetime_for_query('REG_date', $year_r.'-'.$month_r.'-'.$days_in_month.' 23:59:59', 'Y-m-d H:i:s')));
1050
+		}elseif ($start_date && $end_date) {
1051 1051
 			throw new EE_Error("not yet supported");
1052
-		}elseif($start_date){
1052
+		}elseif ($start_date) {
1053 1053
 			throw new EE_Error("not yet supported");
1054
-		}elseif($end_date){
1054
+		}elseif ($end_date) {
1055 1055
 			throw new EE_Error("not yet supported");
1056 1056
 		}
1057 1057
 
1058
-		if ( ! empty( $this->_req_data['s'] ) ) {
1059
-			$sstr = '%' . $this->_req_data['s'] . '%';
1058
+		if ( ! empty($this->_req_data['s'])) {
1059
+			$sstr = '%'.$this->_req_data['s'].'%';
1060 1060
 			$_where['OR'] = array(
1061
-				'Event.EVT_name' => array( 'LIKE', $sstr),
1062
-				'Event.EVT_desc' => array( 'LIKE', $sstr ),
1063
-				'Event.EVT_short_desc' => array( 'LIKE' , $sstr ),
1064
-				'Attendee.ATT_full_name' => array( 'LIKE', $sstr ),
1065
-				'Attendee.ATT_fname' => array( 'LIKE', $sstr ),
1066
-				'Attendee.ATT_lname' => array( 'LIKE', $sstr ),
1067
-				'Attendee.ATT_short_bio' => array( 'LIKE', $sstr ),
1068
-				'Attendee.ATT_email' => array('LIKE', $sstr ),
1069
-				'Attendee.ATT_address' => array( 'LIKE', $sstr ),
1070
-				'Attendee.ATT_address2' => array( 'LIKE', $sstr ),
1071
-				'Attendee.ATT_city' => array( 'LIKE', $sstr ),
1072
-				'REG_final_price' => array( 'LIKE', $sstr ),
1073
-				'REG_code' => array( 'LIKE', $sstr ),
1074
-				'REG_count' => array( 'LIKE' , $sstr ),
1075
-				'REG_group_size' => array( 'LIKE' , $sstr ),
1076
-				'Ticket.TKT_name' => array( 'LIKE', $sstr ),
1077
-				'Ticket.TKT_description' => array( 'LIKE', $sstr ),
1078
-				'Transaction.Payment.PAY_txn_id_chq_nmbr' => array( 'LIKE', $sstr )
1061
+				'Event.EVT_name' => array('LIKE', $sstr),
1062
+				'Event.EVT_desc' => array('LIKE', $sstr),
1063
+				'Event.EVT_short_desc' => array('LIKE', $sstr),
1064
+				'Attendee.ATT_full_name' => array('LIKE', $sstr),
1065
+				'Attendee.ATT_fname' => array('LIKE', $sstr),
1066
+				'Attendee.ATT_lname' => array('LIKE', $sstr),
1067
+				'Attendee.ATT_short_bio' => array('LIKE', $sstr),
1068
+				'Attendee.ATT_email' => array('LIKE', $sstr),
1069
+				'Attendee.ATT_address' => array('LIKE', $sstr),
1070
+				'Attendee.ATT_address2' => array('LIKE', $sstr),
1071
+				'Attendee.ATT_city' => array('LIKE', $sstr),
1072
+				'REG_final_price' => array('LIKE', $sstr),
1073
+				'REG_code' => array('LIKE', $sstr),
1074
+				'REG_count' => array('LIKE', $sstr),
1075
+				'REG_group_size' => array('LIKE', $sstr),
1076
+				'Ticket.TKT_name' => array('LIKE', $sstr),
1077
+				'Ticket.TKT_description' => array('LIKE', $sstr),
1078
+				'Transaction.Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $sstr)
1079 1079
 			);
1080 1080
 		}
1081 1081
 
1082 1082
 		//capability checks
1083
-		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'get_registrations' ) ) {
1083
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'get_registrations')) {
1084 1084
 			$_where['AND'] = array(
1085 1085
 				'Event.EVT_wp_user' => get_current_user_id()
1086 1086
 				);
1087 1087
 		}
1088 1088
 
1089
-		if( $count ){
1090
-			if ( $trash ) {
1091
-				return EEM_Registration::instance()->count_deleted( array( $_where ));
1092
-			} else if ( $incomplete ) {
1093
-				return EEM_Registration::instance()->count( array( $_where ));
1089
+		if ($count) {
1090
+			if ($trash) {
1091
+				return EEM_Registration::instance()->count_deleted(array($_where));
1092
+			} else if ($incomplete) {
1093
+				return EEM_Registration::instance()->count(array($_where));
1094 1094
 			} else {
1095
-				return EEM_Registration::instance()->count( array( $_where, 'default_where_conditions' => 'this_model_only' ));
1095
+				return EEM_Registration::instance()->count(array($_where, 'default_where_conditions' => 'this_model_only'));
1096 1096
 			}
1097 1097
 		} else {
1098 1098
 			//make sure we remove default where conditions cause all registrations matching query are returned
1099
-			$query_params = array( $_where, 'order_by' => array( $orderby => $sort ), 'default_where_conditions' => 'this_model_only' );
1100
-			if ( $per_page !== -1 ) {
1099
+			$query_params = array($_where, 'order_by' => array($orderby => $sort), 'default_where_conditions' => 'this_model_only');
1100
+			if ($per_page !== -1) {
1101 1101
 				$query_params['limit'] = $limit;
1102 1102
 			}
1103
-			$registrations =  $trash ? EEM_Registration::instance()->get_all_deleted($query_params) : EEM_Registration::instance()->get_all($query_params);
1103
+			$registrations = $trash ? EEM_Registration::instance()->get_all_deleted($query_params) : EEM_Registration::instance()->get_all($query_params);
1104 1104
 
1105
-			if ( $EVT_ID && isset( $registrations[0] ) && $registrations[0] instanceof EE_Registration &&  $registrations[0]->event_obj()) {
1105
+			if ($EVT_ID && isset($registrations[0]) && $registrations[0] instanceof EE_Registration && $registrations[0]->event_obj()) {
1106 1106
 				$first_registration = $registrations[0];
1107 1107
 				//EEH_Debug_Tools::printr( $registrations[0], '$registrations  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
1108 1108
 				$event_name = $first_registration->event_obj()->name();
1109
-				$event_date = $first_registration->date_obj()->start_date_and_time('l F j, Y,', 'g:i:s a');// isset( $registrations[0]->DTT_EVT_start ) ? date( 'l F j, Y,    g:i:s a', $registrations[0]->DTT_EVT_start ) : '';
1109
+				$event_date = $first_registration->date_obj()->start_date_and_time('l F j, Y,', 'g:i:s a'); // isset( $registrations[0]->DTT_EVT_start ) ? date( 'l F j, Y,    g:i:s a', $registrations[0]->DTT_EVT_start ) : '';
1110 1110
 				// edit event link
1111
-				if ( $event_name != '' ) {
1112
-					$edit_event_url = self::add_query_args_and_nonce( array( 'action'=>'edit_event', 'EVT_ID'=>$EVT_ID ), EVENTS_ADMIN_URL );
1113
-					$edit_event_lnk = '<a href="'.$edit_event_url.'" title="' . esc_attr__( 'Edit ', 'event_espresso' ) . $event_name . '">' . __( 'Edit Event', 'event_espresso' ) . '</a>';
1114
-					$event_name .= ' <span class="admin-page-header-edit-lnk not-bold">' . $edit_event_lnk . '</span>' ;
1111
+				if ($event_name != '') {
1112
+					$edit_event_url = self::add_query_args_and_nonce(array('action'=>'edit_event', 'EVT_ID'=>$EVT_ID), EVENTS_ADMIN_URL);
1113
+					$edit_event_lnk = '<a href="'.$edit_event_url.'" title="'.esc_attr__('Edit ', 'event_espresso').$event_name.'">'.__('Edit Event', 'event_espresso').'</a>';
1114
+					$event_name .= ' <span class="admin-page-header-edit-lnk not-bold">'.$edit_event_lnk.'</span>';
1115 1115
 				}
1116 1116
 
1117
-				$back_2_reg_url = self::add_query_args_and_nonce( array( 'action'=>'default' ), REG_ADMIN_URL );
1118
-				$back_2_reg_lnk = '<a href="'.$back_2_reg_url.'" title="' . esc_attr__( 'click to return to viewing all registrations ', 'event_espresso' ) . '">&laquo; ' . __( 'Back to All Registrations', 'event_espresso' ) . '</a>';
1117
+				$back_2_reg_url = self::add_query_args_and_nonce(array('action'=>'default'), REG_ADMIN_URL);
1118
+				$back_2_reg_lnk = '<a href="'.$back_2_reg_url.'" title="'.esc_attr__('click to return to viewing all registrations ', 'event_espresso').'">&laquo; '.__('Back to All Registrations', 'event_espresso').'</a>';
1119 1119
 
1120 1120
 				$this->_template_args['before_admin_page_content'] = '
1121 1121
 			<div id="admin-page-header">
1122
-				<h1><span class="small-text not-bold">'.__( 'Event: ', 'event_espresso' ).'</span>'. $event_name .'</h1>
1123
-				<h3><span class="small-text not-bold">'.__( 'Date: ', 'event_espresso' ). '</span>'. $event_date .'</h3>
1124
-				<span class="admin-page-header-go-back-lnk not-bold">' . $back_2_reg_lnk . '</span>
1122
+				<h1><span class="small-text not-bold">'.__('Event: ', 'event_espresso').'</span>'.$event_name.'</h1>
1123
+				<h3><span class="small-text not-bold">'.__('Date: ', 'event_espresso').'</span>'.$event_date.'</h3>
1124
+				<span class="admin-page-header-go-back-lnk not-bold">' . $back_2_reg_lnk.'</span>
1125 1125
 			</div>
1126 1126
 			';
1127 1127
 
@@ -1159,7 +1159,7 @@  discard block
 block discarded – undo
1159 1159
 
1160 1160
 		$this->_set_registration_object();
1161 1161
 
1162
-		if ( is_object( $this->_registration )) {
1162
+		if (is_object($this->_registration)) {
1163 1163
 			$transaction = $this->_registration->transaction() ? $this->_registration->transaction() : EE_Transaction::new_instance();
1164 1164
 			$this->_session = $transaction->session_data();
1165 1165
 
@@ -1167,10 +1167,10 @@  discard block
 block discarded – undo
1167 1167
 
1168 1168
 
1169 1169
 			$this->_template_args['reg_nmbr']['value'] = $this->_registration->ID();
1170
-			$this->_template_args['reg_nmbr']['label'] = __( 'Registration Number', 'event_espresso' );
1170
+			$this->_template_args['reg_nmbr']['label'] = __('Registration Number', 'event_espresso');
1171 1171
 
1172
-			$this->_template_args['reg_datetime']['value'] =  $this->_registration->get_i18n_datetime( 'REG_date' );
1173
-			$this->_template_args['reg_datetime']['label'] = __( 'Date', 'event_espresso' );
1172
+			$this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date');
1173
+			$this->_template_args['reg_datetime']['label'] = __('Date', 'event_espresso');
1174 1174
 
1175 1175
 			$this->_template_args['grand_total'] = $transaction->total();
1176 1176
 
@@ -1178,19 +1178,19 @@  discard block
 block discarded – undo
1178 1178
 			// link back to overview
1179 1179
 			$this->_template_args['reg_overview_url'] = REG_ADMIN_URL;
1180 1180
 			$this->_template_args['registration'] = $this->_registration;
1181
-			$this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'default', 'event_id' => $event_id ), REG_ADMIN_URL );
1182
-			$this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'default', 'EVT_ID' => $event_id, 'page' => 'espresso_transactions' ), admin_url( 'admin.php' ) );
1183
-			$this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce( array( 'page' => 'espresso_events', 'action' => 'edit', 'post' => $event_id ), admin_url( 'admin.php' ) );
1181
+			$this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'default', 'event_id' => $event_id), REG_ADMIN_URL);
1182
+			$this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'default', 'EVT_ID' => $event_id, 'page' => 'espresso_transactions'), admin_url('admin.php'));
1183
+			$this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(array('page' => 'espresso_events', 'action' => 'edit', 'post' => $event_id), admin_url('admin.php'));
1184 1184
 
1185 1185
 			//next and previous links
1186
-			$next_reg = $this->_registration->next(null, array(), 'REG_ID' );
1187
-			$this->_template_args['next_registration'] = $next_reg ? $this->_next_link( EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'view_registration', '_REG_ID' => $next_reg['REG_ID'] ), REG_ADMIN_URL ), 'dashicons dashicons-arrow-right ee-icon-size-22' ) : '';
1188
-			$previous_reg = $this->_registration->previous( null, array(), 'REG_ID' );
1189
-			$this->_template_args['previous_registration'] = $previous_reg ? $this->_previous_link( EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'view_registration', '_REG_ID' => $previous_reg['REG_ID'] ), REG_ADMIN_URL ), 'dashicons dashicons-arrow-left ee-icon-size-22' ) : '';
1186
+			$next_reg = $this->_registration->next(null, array(), 'REG_ID');
1187
+			$this->_template_args['next_registration'] = $next_reg ? $this->_next_link(EE_Admin_Page::add_query_args_and_nonce(array('action' => 'view_registration', '_REG_ID' => $next_reg['REG_ID']), REG_ADMIN_URL), 'dashicons dashicons-arrow-right ee-icon-size-22') : '';
1188
+			$previous_reg = $this->_registration->previous(null, array(), 'REG_ID');
1189
+			$this->_template_args['previous_registration'] = $previous_reg ? $this->_previous_link(EE_Admin_Page::add_query_args_and_nonce(array('action' => 'view_registration', '_REG_ID' => $previous_reg['REG_ID']), REG_ADMIN_URL), 'dashicons dashicons-arrow-left ee-icon-size-22') : '';
1190 1190
 
1191 1191
 			// grab header
1192
-			$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1193
-			$this->_template_args['admin_page_header'] = EEH_Template::display_template( $template_path, $this->_template_args, TRUE );
1192
+			$template_path = REG_TEMPLATE_PATH.'reg_admin_details_header.template.php';
1193
+			$this->_template_args['admin_page_header'] = EEH_Template::display_template($template_path, $this->_template_args, TRUE);
1194 1194
 
1195 1195
 		} else {
1196 1196
 
@@ -1209,17 +1209,17 @@  discard block
 block discarded – undo
1209 1209
 
1210 1210
 
1211 1211
 	protected function _registration_details_metaboxes() {
1212
-		do_action( 'AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this );
1212
+		do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this);
1213 1213
 		$this->_set_registration_object();
1214 1214
 		$attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null;
1215
-		add_meta_box( 'edit-reg-status-mbox', __( 'Registration Status', 'event_espresso' ), array( $this, 'set_reg_status_buttons_metabox' ), $this->wp_page_slug, 'normal', 'high' );
1216
-		add_meta_box( 'edit-reg-details-mbox', __( 'Registration Details', 'event_espresso' ), array( $this, '_reg_details_meta_box' ), $this->wp_page_slug, 'normal', 'high' );
1217
-		if ( $attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can('ee_edit_registration', 'edit-reg-questions-mbox' ) ) {
1218
-			add_meta_box( 'edit-reg-questions-mbox', __( 'Registration Form Answers', 'event_espresso' ), array( $this, '_reg_questions_meta_box' ), $this->wp_page_slug, 'normal', 'high' );
1215
+		add_meta_box('edit-reg-status-mbox', __('Registration Status', 'event_espresso'), array($this, 'set_reg_status_buttons_metabox'), $this->wp_page_slug, 'normal', 'high');
1216
+		add_meta_box('edit-reg-details-mbox', __('Registration Details', 'event_espresso'), array($this, '_reg_details_meta_box'), $this->wp_page_slug, 'normal', 'high');
1217
+		if ($attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can('ee_edit_registration', 'edit-reg-questions-mbox')) {
1218
+			add_meta_box('edit-reg-questions-mbox', __('Registration Form Answers', 'event_espresso'), array($this, '_reg_questions_meta_box'), $this->wp_page_slug, 'normal', 'high');
1219 1219
 		}
1220
-		add_meta_box( 'edit-reg-registrant-mbox', __( 'Contact Details', 'event_espresso' ), array( $this, '_reg_registrant_side_meta_box' ), $this->wp_page_slug, 'side', 'high' );
1221
-		if ( $this->_registration->group_size() > 1 ) {
1222
-			add_meta_box( 'edit-reg-attendees-mbox', __( 'Other Registrations in this Transaction', 'event_espresso' ), array( $this, '_reg_attendees_meta_box' ), $this->wp_page_slug, 'normal', 'high' );
1220
+		add_meta_box('edit-reg-registrant-mbox', __('Contact Details', 'event_espresso'), array($this, '_reg_registrant_side_meta_box'), $this->wp_page_slug, 'side', 'high');
1221
+		if ($this->_registration->group_size() > 1) {
1222
+			add_meta_box('edit-reg-attendees-mbox', __('Other Registrations in this Transaction', 'event_espresso'), array($this, '_reg_attendees_meta_box'), $this->wp_page_slug, 'normal', 'high');
1223 1223
 		}
1224 1224
 	}
1225 1225
 
@@ -1261,25 +1261,25 @@  discard block
 block discarded – undo
1261 1261
 				'html_id'         => 'reg-status-change-form',
1262 1262
 				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1263 1263
 				'subsections'     => array(
1264
-					'return' => new EE_Hidden_Input( array(
1264
+					'return' => new EE_Hidden_Input(array(
1265 1265
 						'name'    => 'return',
1266 1266
 						'default' => 'view_registration'
1267
-					) ),
1268
-					'REG_ID' => new EE_Hidden_Input( array(
1267
+					)),
1268
+					'REG_ID' => new EE_Hidden_Input(array(
1269 1269
 						'name'    => 'REG_ID',
1270 1270
 						'default' => $this->_registration->ID()
1271
-					) ),
1271
+					)),
1272 1272
 					'current_status' => new EE_Form_Section_HTML(
1273 1273
 						EEH_HTML::tr(
1274 1274
 							EEH_HTML::th(
1275 1275
 								EEH_HTML::label(
1276
-									EEH_HTML::strong( __( 'Current Registration Status', 'event_espresso' ) )
1276
+									EEH_HTML::strong(__('Current Registration Status', 'event_espresso'))
1277 1277
 								)
1278
-							) .
1278
+							).
1279 1279
 							EEH_HTML::td(
1280 1280
 								EEH_HTML::strong(
1281 1281
 									$this->_registration->pretty_status(),
1282
-									'', 'status-' . $this->_registration->status_ID(), 'line-height: 1em; font-size: 1.5em; font-weight: bold;'
1282
+									'', 'status-'.$this->_registration->status_ID(), 'line-height: 1em; font-size: 1.5em; font-weight: bold;'
1283 1283
 								)
1284 1284
 							)
1285 1285
 						)
@@ -1287,22 +1287,22 @@  discard block
 block discarded – undo
1287 1287
 					'reg_status' => new EE_Select_Input(
1288 1288
 						$this->_get_reg_statuses(),
1289 1289
 						array(
1290
-							'html_label_text' => __( 'Change Registration Status to', 'event_espresso' ),
1290
+							'html_label_text' => __('Change Registration Status to', 'event_espresso'),
1291 1291
 							'default'         => $this->_registration->status_ID(),
1292 1292
 						)
1293 1293
 					),
1294 1294
 					'send_notifications' => new EE_Yes_No_Input(
1295 1295
 						array(
1296
-							'html_label_text' => __( 'Send Related Messages', 'event_espresso' ),
1296
+							'html_label_text' => __('Send Related Messages', 'event_espresso'),
1297 1297
 							'default'         => false,
1298
-							'html_help_text'  => __( 'If set to "Yes", then the related messages will be sent to the registrant.', 'event_espresso' ),
1298
+							'html_help_text'  => __('If set to "Yes", then the related messages will be sent to the registrant.', 'event_espresso'),
1299 1299
 						)
1300 1300
 					),
1301
-					'submit' => new EE_Submit_Input( array(
1301
+					'submit' => new EE_Submit_Input(array(
1302 1302
 						'html_class'      => 'button-primary',
1303 1303
 						'html_label_text' => '&nbsp;',
1304
-						'default'         => __( 'Update Registration Status', 'event_espresso' )
1305
-					) ),
1304
+						'default'         => __('Update Registration Status', 'event_espresso')
1305
+					)),
1306 1306
 				),
1307 1307
 			)
1308 1308
 		);
@@ -1315,7 +1315,7 @@  discard block
 block discarded – undo
1315 1315
 	 * Returns an array of all the buttons for the various statuses and switch status actions
1316 1316
 	 * @return string
1317 1317
 	 */
1318
-	protected function _get_current_reg_status_help_text( $STS_ID = '' ) {
1318
+	protected function _get_current_reg_status_help_text($STS_ID = '') {
1319 1319
 		//$reg_status_help_text = array(
1320 1320
 		//	'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ),
1321 1321
 		//	'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ),
@@ -1348,14 +1348,14 @@  discard block
 block discarded – undo
1348 1348
 	 */
1349 1349
 	protected function _get_reg_statuses() {
1350 1350
 		$reg_status_array = EEM_Registration::instance()->reg_status_array();
1351
-		unset ( $reg_status_array[ EEM_Registration::status_id_incomplete ] );
1351
+		unset ($reg_status_array[EEM_Registration::status_id_incomplete]);
1352 1352
 		// get current reg status
1353 1353
 		$current_status = $this->_registration->status_ID();
1354 1354
 		// is registration for free event? This will determine whether to display the pending payment option
1355
-		if ( $current_status != EEM_Registration::status_id_pending_payment && $this->_registration->transaction()->is_free() ) {
1356
-			unset( $reg_status_array[ EEM_Registration::status_id_pending_payment ] );
1355
+		if ($current_status != EEM_Registration::status_id_pending_payment && $this->_registration->transaction()->is_free()) {
1356
+			unset($reg_status_array[EEM_Registration::status_id_pending_payment]);
1357 1357
 		}
1358
-		return EEM_Status::instance()->localized_status( $reg_status_array, false, 'sentence' );
1358
+		return EEM_Status::instance()->localized_status($reg_status_array, false, 'sentence');
1359 1359
 	}
1360 1360
 
1361 1361
 
@@ -1368,15 +1368,15 @@  discard block
 block discarded – undo
1368 1368
 	 *
1369 1369
 	 * @return array  (array with reg_id(s) updated and whether update was successful.
1370 1370
 	 */
1371
-	protected function _set_registration_status_from_request( $status = false, $notify = false ) {
1372
-		if ( isset( $this->_req_data[ 'reg_status_change_form' ] ) ) {
1373
-			$REG_IDs = isset( $this->_req_data[ 'reg_status_change_form' ][ 'REG_ID' ] )
1374
-				? (array)$this->_req_data[ 'reg_status_change_form' ][ 'REG_ID' ]
1371
+	protected function _set_registration_status_from_request($status = false, $notify = false) {
1372
+		if (isset($this->_req_data['reg_status_change_form'])) {
1373
+			$REG_IDs = isset($this->_req_data['reg_status_change_form']['REG_ID'])
1374
+				? (array) $this->_req_data['reg_status_change_form']['REG_ID']
1375 1375
 				: array();
1376 1376
 		} else {
1377
-			$REG_IDs = isset( $this->_req_data[ '_REG_ID' ] ) ? (array)$this->_req_data[ '_REG_ID' ] : array();
1377
+			$REG_IDs = isset($this->_req_data['_REG_ID']) ? (array) $this->_req_data['_REG_ID'] : array();
1378 1378
 		}
1379
-		$success = $this->_set_registration_status( $REG_IDs, $status );
1379
+		$success = $this->_set_registration_status($REG_IDs, $status);
1380 1380
 		//notify?
1381 1381
 		if (
1382 1382
 			$success
@@ -1403,21 +1403,21 @@  discard block
 block discarded – undo
1403 1403
 	 * @param bool $status
1404 1404
 	 * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as the array of updated registrations).
1405 1405
 	 */
1406
-	protected function _set_registration_status( $REG_IDs = array(), $status = false ) {
1406
+	protected function _set_registration_status($REG_IDs = array(), $status = false) {
1407 1407
 		$success = false;
1408 1408
 		// typecast $REG_IDs
1409
-		$REG_IDs = (array)$REG_IDs;
1410
-		if ( ! empty( $REG_IDs ) ) {
1409
+		$REG_IDs = (array) $REG_IDs;
1410
+		if ( ! empty($REG_IDs)) {
1411 1411
 			$success = true;
1412 1412
 			// set default status if none is passed
1413 1413
 			$status = $status ? $status : EEM_Registration::status_id_pending_payment;
1414 1414
 			// sanitize $REG_IDs
1415
-			$REG_IDs = array_filter( $REG_IDs, 'absint' );
1415
+			$REG_IDs = array_filter($REG_IDs, 'absint');
1416 1416
 			//loop through REG_ID's and change status
1417
-			foreach ( $REG_IDs as $REG_ID ) {
1418
-				$registration = EEM_Registration::instance()->get_one_by_ID( $REG_ID );
1419
-				if ( $registration instanceof EE_Registration ) {
1420
-					$registration->set_status( $status );
1417
+			foreach ($REG_IDs as $REG_ID) {
1418
+				$registration = EEM_Registration::instance()->get_one_by_ID($REG_ID);
1419
+				if ($registration instanceof EE_Registration) {
1420
+					$registration->set_status($status);
1421 1421
 					$result = $registration->save();
1422 1422
 					// verifying explicit fails because update *may* just return 0 for 0 rows affected
1423 1423
 					$success = $result !== false ? $success : false;
@@ -1427,7 +1427,7 @@  discard block
 block discarded – undo
1427 1427
 		//reset _req_data['_REG_ID'] for any potential future messages notifications
1428 1428
 		$this->_req_data['_REG_ID'] = $REG_IDs;
1429 1429
 		//return $success and processed registrations
1430
-		return array( 'REG_ID' => $REG_IDs, 'success' => $success );
1430
+		return array('REG_ID' => $REG_IDs, 'success' => $success);
1431 1431
 	}
1432 1432
 
1433 1433
 
@@ -1439,49 +1439,49 @@  discard block
 block discarded – undo
1439 1439
 	 * @param   bool    $notify indicates whether the _set_registration_status_from_request does notifications or not.
1440 1440
 	 * @return void
1441 1441
 	 */
1442
-	protected function _reg_status_change_return( $STS_ID, $notify = false ) {
1443
-		$result = ! empty( $STS_ID )
1444
-            ? $this->_set_registration_status_from_request( $STS_ID, $notify )
1445
-            : array( 'success' => false );
1446
-		$success = isset( $result['success'] ) && $result['success'];
1442
+	protected function _reg_status_change_return($STS_ID, $notify = false) {
1443
+		$result = ! empty($STS_ID)
1444
+            ? $this->_set_registration_status_from_request($STS_ID, $notify)
1445
+            : array('success' => false);
1446
+		$success = isset($result['success']) && $result['success'];
1447 1447
 		//setup success message
1448
-		if ( $success ) {
1449
-			if ( is_array( $result[ 'REG_ID' ] ) && count( $result[ 'REG_ID' ] ) === 1 ) {
1448
+		if ($success) {
1449
+			if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) {
1450 1450
 				$msg = sprintf(
1451
-					__( 'Registration status has been set to %s', 'event_espresso' ),
1452
-					EEH_Template::pretty_status( $STS_ID, false, 'lower' )
1451
+					__('Registration status has been set to %s', 'event_espresso'),
1452
+					EEH_Template::pretty_status($STS_ID, false, 'lower')
1453 1453
 				);
1454 1454
 			} else {
1455 1455
 				$msg = sprintf(
1456
-					__( 'Registrations have been set to %s.', 'event_espresso' ),
1457
-					EEH_Template::pretty_status( $STS_ID, false, 'lower' )
1456
+					__('Registrations have been set to %s.', 'event_espresso'),
1457
+					EEH_Template::pretty_status($STS_ID, false, 'lower')
1458 1458
 				);
1459 1459
 			}
1460
-			EE_Error::add_success( $msg );
1460
+			EE_Error::add_success($msg);
1461 1461
 		} else {
1462 1462
 			EE_Error::add_error(
1463
-				__( 'Something went wrong, and the status was not changed', 'event_espresso' ),
1463
+				__('Something went wrong, and the status was not changed', 'event_espresso'),
1464 1464
 				__FILE__, __LINE__, __FUNCTION__
1465 1465
 			);
1466 1466
 		}
1467
-		if ( isset( $this->_req_data[ 'return' ] ) && $this->_req_data[ 'return' ] == 'view_registration' ) {
1468
-			$route = array( 'action' => 'view_registration', '_REG_ID' => reset( $result[ 'REG_ID' ] ) );
1467
+		if (isset($this->_req_data['return']) && $this->_req_data['return'] == 'view_registration') {
1468
+			$route = array('action' => 'view_registration', '_REG_ID' => reset($result['REG_ID']));
1469 1469
 		} else {
1470
-			$route = array( 'action' => 'default' );
1470
+			$route = array('action' => 'default');
1471 1471
 		}
1472 1472
 		//unset nonces
1473
-		foreach ( $this->_req_data as $ref => $value ) {
1474
-			if ( strpos( $ref, 'nonce' ) !== false ) {
1475
-				unset( $this->_req_data[$ref] );
1473
+		foreach ($this->_req_data as $ref => $value) {
1474
+			if (strpos($ref, 'nonce') !== false) {
1475
+				unset($this->_req_data[$ref]);
1476 1476
 				continue;
1477 1477
 			}
1478 1478
 
1479
-			$value = is_array( $value ) ? array_map( 'urlencode', $value ) : urlencode( $value );
1479
+			$value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
1480 1480
 			$this->_req_data[$ref] = $value;
1481 1481
 		}
1482 1482
 		//merge request vars so that the reloaded list table contains any existing filter query params
1483
-		$route = array_merge( $this->_req_data, $route );
1484
-		$this->_redirect_after_action( $success, '', '', $route, true );
1483
+		$route = array_merge($this->_req_data, $route);
1484
+		$this->_redirect_after_action($success, '', '', $route, true);
1485 1485
 	}
1486 1486
 
1487 1487
 
@@ -1492,51 +1492,51 @@  discard block
 block discarded – undo
1492 1492
 	protected function _change_reg_status() {
1493 1493
 		$this->_req_data['return'] = 'view_registration';
1494 1494
 		//set notify based on whether the send notifications toggle is set or not
1495
-		$notify = ! empty( $this->_req_data['reg_status_change_form']['send_notifications'] );
1495
+		$notify = ! empty($this->_req_data['reg_status_change_form']['send_notifications']);
1496 1496
 		//$notify = ! empty( $this->_req_data['txn_reg_status_change']['send_notifications'] );
1497
-		$this->_req_data[ 'reg_status_change_form' ][ 'reg_status' ] = isset(
1498
-			$this->_req_data[ 'reg_status_change_form' ][ 'reg_status' ]
1497
+		$this->_req_data['reg_status_change_form']['reg_status'] = isset(
1498
+			$this->_req_data['reg_status_change_form']['reg_status']
1499 1499
 		)
1500
-			? $this->_req_data[ 'reg_status_change_form' ][ 'reg_status' ]
1500
+			? $this->_req_data['reg_status_change_form']['reg_status']
1501 1501
 			: '';
1502 1502
 
1503
-		switch ( $this->_req_data[ 'reg_status_change_form' ]['reg_status'] ) {
1503
+		switch ($this->_req_data['reg_status_change_form']['reg_status']) {
1504 1504
 
1505 1505
 			case EEM_Registration::status_id_approved :
1506
-			case EEH_Template::pretty_status( EEM_Registration::status_id_approved, false, 'sentence' ) :
1507
-				$this->approve_registration( $notify );
1506
+			case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence') :
1507
+				$this->approve_registration($notify);
1508 1508
 				break;
1509 1509
 
1510 1510
 			case EEM_Registration::status_id_pending_payment :
1511
-			case EEH_Template::pretty_status( EEM_Registration::status_id_pending_payment, false, 'sentence' ) :
1512
-				$this->pending_registration( $notify );
1511
+			case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence') :
1512
+				$this->pending_registration($notify);
1513 1513
 				break;
1514 1514
 
1515 1515
 			case EEM_Registration::status_id_not_approved :
1516
-			case EEH_Template::pretty_status( EEM_Registration::status_id_not_approved, false, 'sentence' ) :
1517
-				$this->not_approve_registration( $notify );
1516
+			case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence') :
1517
+				$this->not_approve_registration($notify);
1518 1518
 				break;
1519 1519
 
1520 1520
 			case EEM_Registration::status_id_declined :
1521
-			case EEH_Template::pretty_status( EEM_Registration::status_id_declined, false, 'sentence' ) :
1522
-				$this->decline_registration( $notify );
1521
+			case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence') :
1522
+				$this->decline_registration($notify);
1523 1523
 				break;
1524 1524
 
1525 1525
 			case EEM_Registration::status_id_cancelled :
1526
-			case EEH_Template::pretty_status( EEM_Registration::status_id_cancelled, false, 'sentence' ) :
1527
-				$this->cancel_registration( $notify );
1526
+			case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence') :
1527
+				$this->cancel_registration($notify);
1528 1528
 				break;
1529 1529
 
1530 1530
 			case EEM_Registration::status_id_wait_list :
1531
-			case EEH_Template::pretty_status( EEM_Registration::status_id_wait_list, false, 'sentence' ) :
1532
-				$this->waitlist_registration( $notify );
1531
+			case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence') :
1532
+				$this->waitlist_registration($notify);
1533 1533
 				break;
1534 1534
 
1535 1535
 			case EEM_Registration::status_id_incomplete :
1536 1536
 			default :
1537 1537
 				$result['success'] = false;
1538
-				unset( $this->_req_data['return'] );
1539
-				$this->_reg_status_change_return( '', false );
1538
+				unset($this->_req_data['return']);
1539
+				$this->_reg_status_change_return('', false);
1540 1540
 				break;
1541 1541
 		}
1542 1542
 	}
@@ -1550,8 +1550,8 @@  discard block
 block discarded – undo
1550 1550
 	 * @param bool $notify whether or not to notify the registrant about their approval.
1551 1551
 	 * @return void
1552 1552
 	 */
1553
-	protected function approve_registration( $notify = false ) {
1554
-		$this->_reg_status_change_return( EEM_Registration::status_id_approved, $notify );
1553
+	protected function approve_registration($notify = false) {
1554
+		$this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify);
1555 1555
 	}
1556 1556
 
1557 1557
 
@@ -1563,8 +1563,8 @@  discard block
 block discarded – undo
1563 1563
 	 * @param bool $notify whether or not to notify the registrant about their status change.
1564 1564
 	 * @return void
1565 1565
 	 */
1566
-	protected function decline_registration( $notify = false ) {
1567
-		$this->_reg_status_change_return( EEM_Registration::status_id_declined, $notify );
1566
+	protected function decline_registration($notify = false) {
1567
+		$this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify);
1568 1568
 	}
1569 1569
 
1570 1570
 
@@ -1576,8 +1576,8 @@  discard block
 block discarded – undo
1576 1576
 	 * @param bool $notify whether or not to notify the registrant about their status change.
1577 1577
 	 * @return void
1578 1578
 	 */
1579
-	protected function cancel_registration( $notify = false ) {
1580
-		$this->_reg_status_change_return( EEM_Registration::status_id_cancelled, $notify );
1579
+	protected function cancel_registration($notify = false) {
1580
+		$this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify);
1581 1581
 	}
1582 1582
 
1583 1583
 
@@ -1589,8 +1589,8 @@  discard block
 block discarded – undo
1589 1589
 	 * @param bool $notify whether or not to notify the registrant about their status change.
1590 1590
 	 * @return void
1591 1591
 	 */
1592
-	protected function not_approve_registration( $notify = false ) {
1593
-		$this->_reg_status_change_return( EEM_Registration::status_id_not_approved, $notify );
1592
+	protected function not_approve_registration($notify = false) {
1593
+		$this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify);
1594 1594
 	}
1595 1595
 
1596 1596
 
@@ -1602,8 +1602,8 @@  discard block
 block discarded – undo
1602 1602
 	 * @param bool $notify whether or not to notify the registrant about their status change.
1603 1603
 	 * @return void
1604 1604
 	 */
1605
-	protected function pending_registration( $notify = false ) {
1606
-		$this->_reg_status_change_return( EEM_Registration::status_id_pending_payment, $notify );
1605
+	protected function pending_registration($notify = false) {
1606
+		$this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify);
1607 1607
 	}
1608 1608
 
1609 1609
 
@@ -1615,8 +1615,8 @@  discard block
 block discarded – undo
1615 1615
 	 * @param bool $notify whether or not to notify the registrant about their status change.
1616 1616
 	 * @return void
1617 1617
 	 */
1618
-	protected function waitlist_registration( $notify = false ) {
1619
-		$this->_reg_status_change_return( EEM_Registration::status_id_wait_list, $notify );
1618
+	protected function waitlist_registration($notify = false) {
1619
+		$this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify);
1620 1620
 	}
1621 1621
 
1622 1622
 
@@ -1630,14 +1630,14 @@  discard block
 block discarded – undo
1630 1630
 	public function _reg_details_meta_box() {
1631 1631
 		EEH_Autoloader::register_line_item_display_autoloaders();
1632 1632
 		EEH_Autoloader::register_line_item_filter_autoloaders();
1633
-		EE_Registry::instance()->load_helper( 'Line_Item' );
1633
+		EE_Registry::instance()->load_helper('Line_Item');
1634 1634
 		$transaction = $this->_registration->transaction() ? $this->_registration->transaction() : EE_Transaction::new_instance();
1635 1635
 		$this->_session = $transaction->session_data();
1636 1636
 
1637 1637
 		$filters = new EE_Line_Item_Filter_Collection();
1638 1638
 		//$filters->add( new EE_Non_Zero_Line_Item_Filter() );
1639
-		$filters->add( new EE_Single_Registration_Line_Item_Filter( $this->_registration ) );
1640
-		$line_item_filter_processor = new EE_Line_Item_Filter_Processor( $filters, $transaction->total_line_item() );
1639
+		$filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
1640
+		$line_item_filter_processor = new EE_Line_Item_Filter_Processor($filters, $transaction->total_line_item());
1641 1641
 		$filtered_line_item_tree = $line_item_filter_processor->process();
1642 1642
 		$line_item_display = new EE_Line_Item_Display(
1643 1643
 			'reg_admin_table',
@@ -1645,7 +1645,7 @@  discard block
 block discarded – undo
1645 1645
 		);
1646 1646
 		$this->_template_args['line_item_table'] = $line_item_display->display_line_item(
1647 1647
 			$filtered_line_item_tree,
1648
-			array( 'EE_Registration' => $this->_registration )
1648
+			array('EE_Registration' => $this->_registration)
1649 1649
 		);
1650 1650
 		$attendee = $this->_registration->attendee();
1651 1651
 
@@ -1655,7 +1655,7 @@  discard block
 block discarded – undo
1655 1655
 				'espresso_transactions_view_transaction'
1656 1656
 			)
1657 1657
 		) {
1658
-			$this->_template_args[ 'view_transaction_button' ] =  EEH_Template::get_button_or_link(
1658
+			$this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link(
1659 1659
 				EE_Admin_Page::add_query_args_and_nonce(
1660 1660
 					array(
1661 1661
 						'action' => 'view_transaction',
@@ -1663,12 +1663,12 @@  discard block
 block discarded – undo
1663 1663
 					),
1664 1664
 					TXN_ADMIN_URL
1665 1665
 				),
1666
-				esc_html__( ' View Transaction' ),
1666
+				esc_html__(' View Transaction'),
1667 1667
 				'button secondary-button right',
1668 1668
 				'dashicons dashicons-cart'
1669 1669
 			);
1670 1670
 		} else {
1671
-			$this->_template_args[ 'view_transaction_button' ] = '';
1671
+			$this->_template_args['view_transaction_button'] = '';
1672 1672
 		}
1673 1673
 
1674 1674
 		if (
@@ -1678,7 +1678,7 @@  discard block
 block discarded – undo
1678 1678
 				'espresso_registrations_resend_registration'
1679 1679
 			)
1680 1680
 		) {
1681
-			$this->_template_args[ 'resend_registration_button' ] = EEH_Template::get_button_or_link(
1681
+			$this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link(
1682 1682
 				EE_Admin_Page::add_query_args_and_nonce(
1683 1683
 					array(
1684 1684
 						'action' 		=> 'resend_registration',
@@ -1687,55 +1687,55 @@  discard block
 block discarded – undo
1687 1687
 					),
1688 1688
 					REG_ADMIN_URL
1689 1689
 				),
1690
-				esc_html__( ' Resend Registration' ),
1690
+				esc_html__(' Resend Registration'),
1691 1691
 				'button secondary-button right',
1692 1692
 				'dashicons dashicons-email-alt'
1693 1693
 			);
1694 1694
 		} else {
1695
-			$this->_template_args[ 'resend_registration_button' ] = '';
1695
+			$this->_template_args['resend_registration_button'] = '';
1696 1696
 		}
1697 1697
 
1698 1698
 		$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
1699
-		$payment = $transaction->get_first_related( 'Payment' );
1699
+		$payment = $transaction->get_first_related('Payment');
1700 1700
 		$payment = ! $payment instanceof EE_Payment ? EE_Payment::new_instance() : $payment;
1701
-		$payment_method = $payment->get_first_related( 'Payment_Method' );
1701
+		$payment_method = $payment->get_first_related('Payment_Method');
1702 1702
 		$payment_method = ! $payment_method instanceof EE_Payment_Method ? EE_Payment_Method::new_instance() : $payment_method;
1703 1703
 
1704 1704
 		$reg_details = array(
1705 1705
 			'payment_method' => $payment_method->name(),
1706 1706
 			'response_msg' => $payment->gateway_response(),
1707
-			'registration_id' => $this->_registration->get( 'REG_code' ),
1707
+			'registration_id' => $this->_registration->get('REG_code'),
1708 1708
 			'registration_session' => $this->_registration->session_ID(),
1709
-			'ip_address' => isset( $this->_session['ip_address'] ) ? $this->_session['ip_address'] : '',
1710
-			'user_agent' => isset( $this->_session['user_agent'] ) ? $this->_session['user_agent'] : '',
1709
+			'ip_address' => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '',
1710
+			'user_agent' => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '',
1711 1711
 		);
1712 1712
 
1713 1713
 
1714
-		if ( isset( $reg_details['registration_id'] )) {
1714
+		if (isset($reg_details['registration_id'])) {
1715 1715
 			$this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
1716
-			$this->_template_args['reg_details']['registration_id']['label'] = __( 'Registration ID', 'event_espresso' );
1716
+			$this->_template_args['reg_details']['registration_id']['label'] = __('Registration ID', 'event_espresso');
1717 1717
 			$this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
1718 1718
 		}
1719 1719
 
1720
-		if ( isset( $reg_details['payment_method'] ) ) {
1720
+		if (isset($reg_details['payment_method'])) {
1721 1721
 			$this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method'];
1722
-			$this->_template_args['reg_details']['payment_method']['label'] = __( 'Most Recent Payment Method', 'event_espresso' );
1722
+			$this->_template_args['reg_details']['payment_method']['label'] = __('Most Recent Payment Method', 'event_espresso');
1723 1723
 			$this->_template_args['reg_details']['payment_method']['class'] = 'regular-text';
1724 1724
 			$this->_template_args['reg_details']['response_msg']['value'] = $reg_details['response_msg'];
1725
-			$this->_template_args['reg_details']['response_msg']['label'] = __( 'Payment method response', 'event_espresso' );
1725
+			$this->_template_args['reg_details']['response_msg']['label'] = __('Payment method response', 'event_espresso');
1726 1726
 			$this->_template_args['reg_details']['response_msg']['class'] = 'regular-text';
1727 1727
 		}
1728 1728
 
1729 1729
 		$this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
1730
-		$this->_template_args['reg_details']['registration_session']['label'] = __( 'Registration Session', 'event_espresso' );
1730
+		$this->_template_args['reg_details']['registration_session']['label'] = __('Registration Session', 'event_espresso');
1731 1731
 		$this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
1732 1732
 
1733 1733
 		$this->_template_args['reg_details']['ip_address']['value'] = $reg_details['ip_address'];
1734
-		$this->_template_args['reg_details']['ip_address']['label'] = __( 'Registration placed from IP', 'event_espresso' );
1734
+		$this->_template_args['reg_details']['ip_address']['label'] = __('Registration placed from IP', 'event_espresso');
1735 1735
 		$this->_template_args['reg_details']['ip_address']['class'] = 'regular-text';
1736 1736
 
1737 1737
 		$this->_template_args['reg_details']['user_agent']['value'] = $reg_details['user_agent'];
1738
-		$this->_template_args['reg_details']['user_agent']['label'] = __( 'Registrant User Agent', 'event_espresso' );
1738
+		$this->_template_args['reg_details']['user_agent']['label'] = __('Registrant User Agent', 'event_espresso');
1739 1739
 		$this->_template_args['reg_details']['user_agent']['class'] = 'large-text';
1740 1740
 
1741 1741
 		$this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(
@@ -1748,8 +1748,8 @@  discard block
 block discarded – undo
1748 1748
 		$this->_template_args['REG_ID'] = $this->_registration->ID();
1749 1749
 		$this->_template_args['event_id'] = $this->_registration->event_ID();
1750 1750
 
1751
-		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
1752
-		echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE );
1751
+		$template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_details.template.php';
1752
+		echo EEH_Template::display_template($template_path, $this->_template_args, TRUE);
1753 1753
 
1754 1754
 	}
1755 1755
 
@@ -1763,14 +1763,14 @@  discard block
 block discarded – undo
1763 1763
 	*/
1764 1764
 	public function _reg_questions_meta_box() {
1765 1765
 		//allow someone to override this method entirely
1766
-		if( apply_filters( 'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', true, $this, $this->_registration ) ) {
1767
-			$form = $this->_get_reg_custom_questions_form( $this->_registration->ID() );
1768
-			$this->_template_args[ 'att_questions' ] = count( $form->subforms() ) > 0 ? $form->get_html_and_js() : '';
1766
+		if (apply_filters('FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', true, $this, $this->_registration)) {
1767
+			$form = $this->_get_reg_custom_questions_form($this->_registration->ID());
1768
+			$this->_template_args['att_questions'] = count($form->subforms()) > 0 ? $form->get_html_and_js() : '';
1769 1769
 			$this->_template_args['reg_questions_form_action'] = 'edit_registration';
1770 1770
 			$this->_template_args['REG_ID'] = $this->_registration->ID();
1771 1771
 
1772
-			$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
1773
-			echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE );
1772
+			$template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_questions.template.php';
1773
+			echo EEH_Template::display_template($template_path, $this->_template_args, TRUE);
1774 1774
 		}
1775 1775
 	}
1776 1776
 
@@ -1784,12 +1784,12 @@  discard block
 block discarded – undo
1784 1784
 	 * @param        string $output
1785 1785
 	 * @return        string
1786 1786
 	 */
1787
-	public function form_before_question_group( $output ) {
1787
+	public function form_before_question_group($output) {
1788 1788
 		EE_Error::doing_it_wrong(
1789
-			__CLASS__ . '::' . __FUNCTION__,
1790
-			__( 'This method would have been protected but was used on a filter callback'
1789
+			__CLASS__.'::'.__FUNCTION__,
1790
+			__('This method would have been protected but was used on a filter callback'
1791 1791
 				. 'so needed to be public. Please discontinue usage as it will be removed soon.',
1792
-				'event_espresso' ),
1792
+				'event_espresso'),
1793 1793
 			'4.8.32.rc.000'
1794 1794
 		);
1795 1795
 		return '
@@ -1808,20 +1808,20 @@  discard block
 block discarded – undo
1808 1808
 	 * @param        string $output
1809 1809
 	 * @return        string
1810 1810
 	 */
1811
-	public function form_after_question_group( $output ) {
1811
+	public function form_after_question_group($output) {
1812 1812
 		EE_Error::doing_it_wrong(
1813
-			__CLASS__ . '::' . __FUNCTION__,
1814
-			__( 'This method would have been protected but was used on a filter callback'
1813
+			__CLASS__.'::'.__FUNCTION__,
1814
+			__('This method would have been protected but was used on a filter callback'
1815 1815
 				. 'so needed to be public. Please discontinue usage as it will be removed soon.',
1816
-				'event_espresso' ),
1816
+				'event_espresso'),
1817 1817
 			'4.8.32.rc.000'
1818 1818
 		);
1819 1819
 		return  '
1820 1820
 			<tr class="hide-if-no-js">
1821 1821
 				<th> </th>
1822 1822
 				<td class="reg-admin-edit-attendee-question-td">
1823
-					<a class="reg-admin-edit-attendee-question-lnk" href="#" title="' . esc_attr__( 'click to edit question', 'event_espresso' ) . '">
1824
-						<span class="reg-admin-edit-question-group-spn lt-grey-txt">' . __( 'edit the above question group', 'event_espresso' ) . '</span>
1823
+					<a class="reg-admin-edit-attendee-question-lnk" href="#" title="' . esc_attr__('click to edit question', 'event_espresso').'">
1824
+						<span class="reg-admin-edit-question-group-spn lt-grey-txt">' . __('edit the above question group', 'event_espresso').'</span>
1825 1825
 						<div class="dashicons dashicons-edit"></div>
1826 1826
 					</a>
1827 1827
 				</td>
@@ -1841,18 +1841,18 @@  discard block
 block discarded – undo
1841 1841
 	 * @param        string $label
1842 1842
 	 * @return        string
1843 1843
 	 */
1844
-	public function form_form_field_label_wrap( $label ) {
1844
+	public function form_form_field_label_wrap($label) {
1845 1845
 		EE_Error::doing_it_wrong(
1846
-			__CLASS__ . '::' . __FUNCTION__,
1847
-			__( 'This method would have been protected but was used on a filter callback'
1846
+			__CLASS__.'::'.__FUNCTION__,
1847
+			__('This method would have been protected but was used on a filter callback'
1848 1848
 				. 'so needed to be public. Please discontinue usage as it will be removed soon.',
1849
-				'event_espresso' ),
1849
+				'event_espresso'),
1850 1850
 			'4.8.32.rc.000'
1851 1851
 		);
1852 1852
 		return '
1853 1853
 			<tr>
1854 1854
 				<th>
1855
-					' . $label  . '
1855
+					' . $label.'
1856 1856
 				</th>';
1857 1857
 	}
1858 1858
 
@@ -1866,17 +1866,17 @@  discard block
 block discarded – undo
1866 1866
 	 * @param        string $input
1867 1867
 	 * @return        string
1868 1868
 	 */
1869
-	public function form_form_field_input__wrap( $input ) {
1869
+	public function form_form_field_input__wrap($input) {
1870 1870
 		EE_Error::doing_it_wrong(
1871
-			__CLASS__ . '::' . __FUNCTION__,
1872
-			__( 'This method would have been protected but was used on a filter callback'
1871
+			__CLASS__.'::'.__FUNCTION__,
1872
+			__('This method would have been protected but was used on a filter callback'
1873 1873
 				. 'so needed to be public. Please discontinue usage as it will be removed soon.',
1874
-				'event_espresso' ),
1874
+				'event_espresso'),
1875 1875
 			'4.8.32.rc.000'
1876 1876
 		);
1877 1877
 		return '
1878 1878
 				<td class="reg-admin-attendee-questions-input-td disabled-input">
1879
-					' . $input . '
1879
+					' . $input.'
1880 1880
 				</td>
1881 1881
 			</tr>';
1882 1882
 	}
@@ -1890,14 +1890,14 @@  discard block
 block discarded – undo
1890 1890
 	 * @return void
1891 1891
 	 */
1892 1892
 	protected function _update_attendee_registration_form() {
1893
-		do_action( 'AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this );
1894
-		if( $_SERVER['REQUEST_METHOD'] == 'POST'){
1895
-			$REG_ID = isset( $this->_req_data['_REG_ID'] ) ? absint( $this->_req_data['_REG_ID'] ) : FALSE;
1896
-			$success = $this->_save_reg_custom_questions_form( $REG_ID );
1897
-			if( $success ) {
1893
+		do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this);
1894
+		if ($_SERVER['REQUEST_METHOD'] == 'POST') {
1895
+			$REG_ID = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : FALSE;
1896
+			$success = $this->_save_reg_custom_questions_form($REG_ID);
1897
+			if ($success) {
1898 1898
 				$what = __('Registration Form', 'event_espresso');
1899
-				$route = $REG_ID ? array( 'action' => 'view_registration', '_REG_ID' => $REG_ID ) : array( 'action' => 'default' );
1900
-				$this->_redirect_after_action( $success, $what, __('updated', 'event_espresso'), $route );
1899
+				$route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) : array('action' => 'default');
1900
+				$this->_redirect_after_action($success, $what, __('updated', 'event_espresso'), $route);
1901 1901
 			}
1902 1902
 		}
1903 1903
 	}
@@ -1908,11 +1908,11 @@  discard block
 block discarded – undo
1908 1908
 	 * @param int $REG_ID
1909 1909
 	 * @return EE_Registration_Custom_Questions_Form
1910 1910
 	 */
1911
-	protected function _get_reg_custom_questions_form( $REG_ID ) {
1912
-		if( ! $this->_reg_custom_questions_form ) {
1913
-			require_once( REG_ADMIN . 'form_sections' . DS . 'EE_Registration_Custom_Questions_Form.form.php' );
1914
-			$this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form( EEM_Registration::instance()->get_one_by_ID( $REG_ID ) );
1915
-			$this->_reg_custom_questions_form->_construct_finalize( null, null );
1911
+	protected function _get_reg_custom_questions_form($REG_ID) {
1912
+		if ( ! $this->_reg_custom_questions_form) {
1913
+			require_once(REG_ADMIN.'form_sections'.DS.'EE_Registration_Custom_Questions_Form.form.php');
1914
+			$this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(EEM_Registration::instance()->get_one_by_ID($REG_ID));
1915
+			$this->_reg_custom_questions_form->_construct_finalize(null, null);
1916 1916
 		}
1917 1917
 		return $this->_reg_custom_questions_form;
1918 1918
 	}
@@ -1925,17 +1925,17 @@  discard block
 block discarded – undo
1925 1925
 	 * @param bool $REG_ID
1926 1926
 	 * @return bool
1927 1927
 	 */
1928
-	private function _save_reg_custom_questions_form( $REG_ID = FALSE ) {
1928
+	private function _save_reg_custom_questions_form($REG_ID = FALSE) {
1929 1929
 
1930 1930
 		if ( ! $REG_ID) {
1931
-			EE_Error::add_error( __('An error occurred. No registration ID was received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
1931
+			EE_Error::add_error(__('An error occurred. No registration ID was received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1932 1932
 		}
1933
-		$form = $this->_get_reg_custom_questions_form( $REG_ID );
1934
-		$form->receive_form_submission( $this->_req_data );
1933
+		$form = $this->_get_reg_custom_questions_form($REG_ID);
1934
+		$form->receive_form_submission($this->_req_data);
1935 1935
 		$success = false;
1936
-		if( $form->is_valid() ) {
1937
-			foreach( $form->subforms() as $question_group_id => $question_group_form ) {
1938
-				foreach( $question_group_form->inputs() as $question_id => $input ) {
1936
+		if ($form->is_valid()) {
1937
+			foreach ($form->subforms() as $question_group_id => $question_group_form) {
1938
+				foreach ($question_group_form->inputs() as $question_id => $input) {
1939 1939
 					$where_conditions = array(
1940 1940
 							'QST_ID' => $question_id,
1941 1941
 							'REG_ID' => $REG_ID
@@ -1943,19 +1943,19 @@  discard block
 block discarded – undo
1943 1943
 					$possibly_new_values = array(
1944 1944
 							'ANS_value' => $input->normalized_value()
1945 1945
 						);
1946
-					$answer = EEM_Answer::instance()->get_one( array( $where_conditions ) );
1947
-					if( $answer instanceof EE_Answer ) {
1948
-						$success = $answer->save( $possibly_new_values );
1946
+					$answer = EEM_Answer::instance()->get_one(array($where_conditions));
1947
+					if ($answer instanceof EE_Answer) {
1948
+						$success = $answer->save($possibly_new_values);
1949 1949
 					} else {
1950 1950
 						//insert it then
1951
-						$cols_n_vals = array_merge( $where_conditions, $possibly_new_values );
1952
-						$answer = EE_Answer::new_instance( $cols_n_vals );
1951
+						$cols_n_vals = array_merge($where_conditions, $possibly_new_values);
1952
+						$answer = EE_Answer::new_instance($cols_n_vals);
1953 1953
 						$success = $answer->save();
1954 1954
 					}
1955 1955
 				}
1956 1956
 			}
1957 1957
 		} else {
1958
-			EE_Error::add_error( $form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__ );
1958
+			EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__);
1959 1959
 		}
1960 1960
 		return $success;
1961 1961
 	}
@@ -1973,31 +1973,31 @@  discard block
 block discarded – undo
1973 1973
 		$registrations = $REG->get_all(array(
1974 1974
 			array(
1975 1975
 				'TXN_ID'=>$this->_registration->transaction_ID(),
1976
-				'REG_ID'=>array('!=',$this->_registration->ID())
1976
+				'REG_ID'=>array('!=', $this->_registration->ID())
1977 1977
 			),
1978 1978
 			'force_join'=>array('Attendee')));
1979 1979
 
1980 1980
 		$this->_template_args['attendees'] = array();
1981 1981
 		$this->_template_args['attendee_notice'] = '';
1982
-		if ( empty( $registrations)  || ( is_array($registrations) &&  ! EEH_Array::get_one_item_from_array($registrations) ) ) {
1983
-			EE_Error::add_error( __('There are no records attached to this registration. Something may have gone wrong with the registration', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
1982
+		if (empty($registrations) || (is_array($registrations) && ! EEH_Array::get_one_item_from_array($registrations))) {
1983
+			EE_Error::add_error(__('There are no records attached to this registration. Something may have gone wrong with the registration', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1984 1984
 			$this->_template_args['attendee_notice'] = EE_Error::get_notices();
1985 1985
 		} else {
1986 1986
 
1987 1987
 			$att_nmbr = 1;
1988
-			foreach ( $registrations as $registration ) {
1988
+			foreach ($registrations as $registration) {
1989 1989
 				/* @var $registration EE_Registration */
1990 1990
 				$attendee = $registration->attendee() ? $registration->attendee() : EEM_Attendee::instance()->create_default_object();
1991
-				$this->_template_args['attendees'][ $att_nmbr ]['STS_ID'] = $registration->status_ID();
1992
-				$this->_template_args['attendees'][ $att_nmbr ]['fname'] = $attendee->fname();//( isset( $registration->ATT_fname ) & ! empty( $registration->ATT_fname ) ) ? $registration->ATT_fname : '';
1993
-				$this->_template_args['attendees'][ $att_nmbr ]['lname'] = $attendee->lname();//( isset( $registration->ATT_lname ) & ! empty( $registration->ATT_lname ) ) ? $registration->ATT_lname : '';
1994
-				$this->_template_args['attendees'][ $att_nmbr ]['email'] = $attendee->email();//( isset( $registration->ATT_email ) & ! empty( $registration->ATT_email ) ) ? $registration->ATT_email : '';
1995
-				$this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();//( isset( $registration->REG_final_price ) & ! empty( $registration->REG_final_price ) ) ? $registration->REG_final_price : '';
1991
+				$this->_template_args['attendees'][$att_nmbr]['STS_ID'] = $registration->status_ID();
1992
+				$this->_template_args['attendees'][$att_nmbr]['fname'] = $attendee->fname(); //( isset( $registration->ATT_fname ) & ! empty( $registration->ATT_fname ) ) ? $registration->ATT_fname : '';
1993
+				$this->_template_args['attendees'][$att_nmbr]['lname'] = $attendee->lname(); //( isset( $registration->ATT_lname ) & ! empty( $registration->ATT_lname ) ) ? $registration->ATT_lname : '';
1994
+				$this->_template_args['attendees'][$att_nmbr]['email'] = $attendee->email(); //( isset( $registration->ATT_email ) & ! empty( $registration->ATT_email ) ) ? $registration->ATT_email : '';
1995
+				$this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->final_price(); //( isset( $registration->REG_final_price ) & ! empty( $registration->REG_final_price ) ) ? $registration->REG_final_price : '';
1996 1996
 
1997
-				$this->_template_args['attendees'][ $att_nmbr ]['address'] = implode( ', ', $attendee->full_address_as_array() );
1997
+				$this->_template_args['attendees'][$att_nmbr]['address'] = implode(', ', $attendee->full_address_as_array());
1998 1998
 
1999
-				$this->_template_args['attendees'][ $att_nmbr ]['att_link'] = self::add_query_args_and_nonce( array( 'action'=>'edit_attendee', 'post'=>$attendee->ID() ), REG_ADMIN_URL );
2000
-				$this->_template_args['attendees'][ $att_nmbr ]['event_name'] = $registration->event_obj()->name();
1999
+				$this->_template_args['attendees'][$att_nmbr]['att_link'] = self::add_query_args_and_nonce(array('action'=>'edit_attendee', 'post'=>$attendee->ID()), REG_ADMIN_URL);
2000
+				$this->_template_args['attendees'][$att_nmbr]['event_name'] = $registration->event_obj()->name();
2001 2001
 
2002 2002
 				$att_nmbr++;
2003 2003
 			}
@@ -2007,8 +2007,8 @@  discard block
 block discarded – undo
2007 2007
 
2008 2008
 	//			$this->_template_args['registration_form_url'] = add_query_arg( array( 'action' => 'edit_registration', 'process' => 'attendees'  ), REG_ADMIN_URL );
2009 2009
 		}
2010
-		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
2011
-		echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE );
2010
+		$template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_attendees.template.php';
2011
+		echo EEH_Template::display_template($template_path, $this->_template_args, TRUE);
2012 2012
 
2013 2013
 	}
2014 2014
 
@@ -2029,14 +2029,14 @@  discard block
 block discarded – undo
2029 2029
 		$attendee = $att_check instanceof EE_Attendee ? $att_check : EEM_Attendee::instance()->create_default_object();
2030 2030
 
2031 2031
 		//now let's determine if this is not the primary registration.  If it isn't then we set the primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the primary registration object (that way we know if we need to show create button or not)
2032
-		if ( ! $this->_registration->is_primary_registrant() ) {
2032
+		if ( ! $this->_registration->is_primary_registrant()) {
2033 2033
 
2034 2034
 			$primary_registration = $this->_registration->get_primary_registration();
2035 2035
 			$primary_attendee = $primary_registration instanceof EE_Registration
2036 2036
 				? $primary_registration->attendee()
2037 2037
 				: null;
2038 2038
 
2039
-			if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID() ) {
2039
+			if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2040 2040
 				//in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own custom attendee object so let's not worry about the primary reg.
2041 2041
 				$primary_registration = NULL;
2042 2042
 			}
@@ -2045,27 +2045,27 @@  discard block
 block discarded – undo
2045 2045
 		}
2046 2046
 
2047 2047
 		$this->_template_args['ATT_ID'] = $attendee->ID();
2048
-		$this->_template_args['fname'] = $attendee->fname();//$this->_registration->ATT_fname;
2049
-		$this->_template_args['lname'] = $attendee->lname();//$this->_registration->ATT_lname;
2050
-		$this->_template_args['email'] = $attendee->email();//$this->_registration->ATT_email;
2048
+		$this->_template_args['fname'] = $attendee->fname(); //$this->_registration->ATT_fname;
2049
+		$this->_template_args['lname'] = $attendee->lname(); //$this->_registration->ATT_lname;
2050
+		$this->_template_args['email'] = $attendee->email(); //$this->_registration->ATT_email;
2051 2051
 		$this->_template_args['phone'] = $attendee->phone();
2052 2052
 
2053
-		$this->_template_args[ 'formatted_address' ] = EEH_Address::format( $attendee );
2053
+		$this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2054 2054
 
2055 2055
 
2056 2056
 		//edit link
2057
-		$this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'edit_attendee', 'post'=>$attendee->ID() ), REG_ADMIN_URL );
2057
+		$this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'edit_attendee', 'post'=>$attendee->ID()), REG_ADMIN_URL);
2058 2058
 		$this->_template_args['att_edit_label'] = __('View/Edit Contact', 'event_espresso');
2059 2059
 
2060 2060
 		//create link
2061
-		$this->_template_args['create_link'] = $primary_registration instanceof EE_Registration ? EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'duplicate_attendee',  '_REG_ID' => $this->_registration->ID() ), REG_ADMIN_URL ): '';
2061
+		$this->_template_args['create_link'] = $primary_registration instanceof EE_Registration ? EE_Admin_Page::add_query_args_and_nonce(array('action' => 'duplicate_attendee', '_REG_ID' => $this->_registration->ID()), REG_ADMIN_URL) : '';
2062 2062
 		$this->_template_args['create_label'] = __('Create Contact', 'event_espresso');
2063 2063
 
2064 2064
 		$this->_template_args['att_check'] = $att_check;
2065 2065
 
2066 2066
 
2067
-		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2068
-		echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE );
2067
+		$template_path = REG_TEMPLATE_PATH.'reg_admin_details_side_meta_box_registrant.template.php';
2068
+		echo EEH_Template::display_template($template_path, $this->_template_args, TRUE);
2069 2069
 	}
2070 2070
 
2071 2071
 
@@ -2078,7 +2078,7 @@  discard block
 block discarded – undo
2078 2078
 	 * @access protected
2079 2079
 	 * @return void
2080 2080
 	 */
2081
-	protected function _trash_or_restore_registrations( $trash = TRUE ) {
2081
+	protected function _trash_or_restore_registrations($trash = TRUE) {
2082 2082
 		$REGM = EEM_Registration::instance();
2083 2083
 
2084 2084
 		$success = 1;
@@ -2088,26 +2088,26 @@  discard block
 block discarded – undo
2088 2088
 		$dtts = array();
2089 2089
 
2090 2090
 		//if empty _REG_ID then get out because there's nothing to do
2091
-		if ( empty( $this->_req_data['_REG_ID'] ) ) {
2091
+		if (empty($this->_req_data['_REG_ID'])) {
2092 2092
 			$msg = $trash ? __('In order to trash registrations you must select which ones you wish to trash by clicking the checkboxes.', 'event_espresso') : __('In order to restore registrations you must select which ones you wish to restore by clicking the checkboxes.', 'event_espresso');
2093
-			EE_Error::add_error( $msg, __FILE__, __LINE__, __FUNCTION__ );
2094
-			$this->_redirect_after_action(FALSE, '', '', array(), TRUE );
2093
+			EE_Error::add_error($msg, __FILE__, __LINE__, __FUNCTION__);
2094
+			$this->_redirect_after_action(FALSE, '', '', array(), TRUE);
2095 2095
 		}
2096 2096
 
2097 2097
 		//Checkboxes
2098
-		if (!empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) {
2098
+		if ( ! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) {
2099 2099
 			// if array has more than one element than success message should be plural
2100
-			$success = count( $this->_req_data['_REG_ID'] ) > 1 ? 2 : 1;
2100
+			$success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1;
2101 2101
 			// cycle thru checkboxes
2102
-			while (list( $ind, $REG_ID ) = each($this->_req_data['_REG_ID'])) {
2102
+			while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) {
2103 2103
 				/** @var EE_Registration $REG */
2104
-				$REG = $REGM->get_one_by_ID( $REG_ID);
2104
+				$REG = $REGM->get_one_by_ID($REG_ID);
2105 2105
 				$payment_count = $REG->get_first_related('Transaction')->count_related('Payment');
2106
-				if ( $payment_count > 0 ) {
2107
-					$name = $REG->attendee() instanceof EE_Attendee ? $REG->attendee()->full_name() : __( 'Unknown Attendee', 'event_espresso' );
2106
+				if ($payment_count > 0) {
2107
+					$name = $REG->attendee() instanceof EE_Attendee ? $REG->attendee()->full_name() : __('Unknown Attendee', 'event_espresso');
2108 2108
 					$error = 1;
2109 2109
 					$success = 0;
2110
-					EE_Error::add_error( sprintf( __('The registration for %s could not be trashed because it has payments attached to the related transaction.  If you wish to trash this registration you must first delete the payments on the related transaction.', 'event_espresso'), $name ), __FILE__, __FUNCTION__, __LINE__ );
2110
+					EE_Error::add_error(sprintf(__('The registration for %s could not be trashed because it has payments attached to the related transaction.  If you wish to trash this registration you must first delete the payments on the related transaction.', 'event_espresso'), $name), __FILE__, __FUNCTION__, __LINE__);
2111 2111
 					continue; //can't trash this registration because it has payments.
2112 2112
 				}
2113 2113
 				$ticket = $REG->get_first_related('Ticket');
@@ -2116,7 +2116,7 @@  discard block
 block discarded – undo
2116 2116
 				$dtts = array_merge($dtts, $dtt);
2117 2117
 
2118 2118
 				$updated = $trash ? $REG->delete() : $REG->restore();
2119
-				if ( !$updated ) {
2119
+				if ( ! $updated) {
2120 2120
 					$success = 0;
2121 2121
 				} else {
2122 2122
 					$success = 2;
@@ -2131,7 +2131,7 @@  discard block
 block discarded – undo
2131 2131
 			$tickets[$ticket->ID()] = $ticket;
2132 2132
 			$dtts = $ticket->get_many_related('Datetime');
2133 2133
 			$updated = $trash ? $REG->delete() : $REG->restore();
2134
-			if ( ! $updated ) {
2134
+			if ( ! $updated) {
2135 2135
 				$success = 0;
2136 2136
 			}
2137 2137
 
@@ -2141,10 +2141,10 @@  discard block
 block discarded – undo
2141 2141
 		EEM_Ticket::instance()->update_tickets_sold($tickets);
2142 2142
 		EEM_Datetime::instance()->update_sold($dtts);
2143 2143
 
2144
-		$what = $success > 1 ? __( 'Registrations', 'event_espresso' ) : __( 'Registration', 'event_espresso' );
2145
-		$action_desc = $trash ? __( 'moved to the trash', 'event_espresso' ) : __( 'restored', 'event_espresso' );
2144
+		$what = $success > 1 ? __('Registrations', 'event_espresso') : __('Registration', 'event_espresso');
2145
+		$action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso');
2146 2146
 		$overwrite_msgs = $error ? TRUE : FALSE;
2147
-		$this->_redirect_after_action( $success, $what, $action_desc, array( 'action' => 'default' ), $overwrite_msgs );
2147
+		$this->_redirect_after_action($success, $what, $action_desc, array('action' => 'default'), $overwrite_msgs);
2148 2148
 	}
2149 2149
 
2150 2150
 
@@ -2168,16 +2168,16 @@  discard block
 block discarded – undo
2168 2168
 		$success = 1;
2169 2169
 
2170 2170
 		//Checkboxes
2171
-		if (!empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) {
2171
+		if ( ! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) {
2172 2172
 			// if array has more than one element than success message should be plural
2173
-			$success = count( $this->_req_data['_REG_ID'] ) > 1 ? 2 : 1;
2173
+			$success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1;
2174 2174
 			// cycle thru checkboxes
2175
-			while (list( $ind, $REG_ID ) = each($this->_req_data['_REG_ID'])) {
2175
+			while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) {
2176 2176
 				$REG = $REG_MDL->get_one_by_ID($REG_ID);
2177
-				if ( ! $REG instanceof EE_Registration )
2177
+				if ( ! $REG instanceof EE_Registration)
2178 2178
 					continue;
2179 2179
 				$deleted = $this->_delete_registration($REG);
2180
-				if ( !$deleted ) {
2180
+				if ( ! $deleted) {
2181 2181
 					$success = 0;
2182 2182
 				}
2183 2183
 			}
@@ -2187,15 +2187,15 @@  discard block
 block discarded – undo
2187 2187
 			$REG_ID = $this->_req_data['_REG_ID'];
2188 2188
 			$REG = $REG_MDL->get_one_by_ID($REG_ID);
2189 2189
 			$deleted = $this->_delete_registration($REG);
2190
-			if ( ! $deleted ) {
2190
+			if ( ! $deleted) {
2191 2191
 				$success = 0;
2192 2192
 			}
2193 2193
 
2194 2194
 		}
2195 2195
 
2196
-		$what = $success > 1 ? __( 'Registrations', 'event_espresso' ) : __( 'Registration', 'event_espresso' );
2197
-		$action_desc = __( 'permanently deleted.', 'event_espresso' );
2198
-		$this->_redirect_after_action( $success, $what, $action_desc, array( 'action' => 'default' ), TRUE );
2196
+		$what = $success > 1 ? __('Registrations', 'event_espresso') : __('Registration', 'event_espresso');
2197
+		$action_desc = __('permanently deleted.', 'event_espresso');
2198
+		$this->_redirect_after_action($success, $what, $action_desc, array('action' => 'default'), TRUE);
2199 2199
 	}
2200 2200
 
2201 2201
 
@@ -2207,31 +2207,31 @@  discard block
 block discarded – undo
2207 2207
 	 * @param  EE_Registration $REG registration to be deleted permenantly
2208 2208
 	 * @return boolean              true = successful deletion, false = fail.
2209 2209
 	 */
2210
-	protected function _delete_registration( EE_Registration $REG ) {
2210
+	protected function _delete_registration(EE_Registration $REG) {
2211 2211
 		//first we start with the transaction... ultimately, we WILL not delete permanently if there are any related registrations on the transaction that are NOT trashed.
2212 2212
 		$TXN = $REG->get_first_related('Transaction');
2213 2213
 		$REGS = $TXN->get_many_related('Registration');
2214 2214
 
2215 2215
 		$all_trashed = TRUE;
2216
-		foreach ( $REGS as $registration ) {
2217
-			if ( ! $registration->get('REG_deleted') )
2216
+		foreach ($REGS as $registration) {
2217
+			if ( ! $registration->get('REG_deleted'))
2218 2218
 				$all_trashed = FALSE;
2219 2219
 		}
2220 2220
 
2221
-		if ( ! $all_trashed ) {
2222
-			EE_Error::add_error( __('Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well.  These registrations will be permanently deleted in the same action.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
2221
+		if ( ! $all_trashed) {
2222
+			EE_Error::add_error(__('Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well.  These registrations will be permanently deleted in the same action.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
2223 2223
 			return false;
2224 2224
 		}
2225 2225
 
2226 2226
 		//k made it here so that means we can delete all the related transactions and their answers (but let's do them separately from THIS one).
2227
-		foreach ( $REGS as $registration ) {
2227
+		foreach ($REGS as $registration) {
2228 2228
 
2229 2229
 			//delete related answers
2230 2230
 			$registration->delete_related_permanently('Answer');
2231 2231
 
2232 2232
 			//remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact)
2233 2233
 			$attendee = $registration->get_first_related('Attendee');
2234
-			if ( $attendee instanceof EE_Attendee ) {
2234
+			if ($attendee instanceof EE_Attendee) {
2235 2235
 				$registration->_remove_relation_to($attendee, 'Attendee');
2236 2236
 			}
2237 2237
 
@@ -2241,7 +2241,7 @@  discard block
 block discarded – undo
2241 2241
 			//now delete permanently the checkins related to this registration.
2242 2242
 			$registration->delete_related_permanently('Checkin');
2243 2243
 
2244
-			if ( $registration->ID() === $REG->ID() )
2244
+			if ($registration->ID() === $REG->ID())
2245 2245
 				continue; //we don't want to delete permanently the existing registration just yet.
2246 2246
 
2247 2247
 			//remove relation to transaction for these registrations if NOT the existing registrations
@@ -2278,35 +2278,35 @@  discard block
 block discarded – undo
2278 2278
 	 * @return void
2279 2279
 	 */
2280 2280
 	public function new_registration() {
2281
-		if ( ! $this->_set_reg_event() ) {
2282
-			throw new EE_Error(__('Unable to continue with registering because there is no Event ID in the request', 'event_espresso') );
2281
+		if ( ! $this->_set_reg_event()) {
2282
+			throw new EE_Error(__('Unable to continue with registering because there is no Event ID in the request', 'event_espresso'));
2283 2283
 		}
2284
-		EE_Registry::instance()->REQ->set_espresso_page( TRUE );
2284
+		EE_Registry::instance()->REQ->set_espresso_page(TRUE);
2285 2285
 		// gotta start with a clean slate if we're not coming here via ajax
2286 2286
 		if (
2287
-			! defined('DOING_AJAX' )
2288
-			&& ( ! isset( $this->_req_data['processing_registration'] ) || isset( $this->_req_data['step_error'] ) )
2287
+			! defined('DOING_AJAX')
2288
+			&& ( ! isset($this->_req_data['processing_registration']) || isset($this->_req_data['step_error']))
2289 2289
 		) {
2290
-			EE_Registry::instance()->SSN->clear_session( __CLASS__, __FUNCTION__ );
2290
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2291 2291
 		}
2292 2292
 
2293
-		$this->_template_args['event_name'] = '' ;
2293
+		$this->_template_args['event_name'] = '';
2294 2294
 		// event name
2295
-		if ( $this->_reg_event ) {
2295
+		if ($this->_reg_event) {
2296 2296
 			$this->_template_args['event_name'] = $this->_reg_event->name();
2297
-			$edit_event_url = self::add_query_args_and_nonce( array( 'action'=>'edit', 'post'=>$this->_reg_event->ID() ), EVENTS_ADMIN_URL );
2298
-			$edit_event_lnk = '<a href="'.$edit_event_url.'" title="' . esc_attr__( 'Edit ', 'event_espresso' ) . $this->_reg_event->name() . '">' . __( 'Edit Event', 'event_espresso' ) . '</a>';
2299
-			$this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">' . $edit_event_lnk . '</span>' ;
2297
+			$edit_event_url = self::add_query_args_and_nonce(array('action'=>'edit', 'post'=>$this->_reg_event->ID()), EVENTS_ADMIN_URL);
2298
+			$edit_event_lnk = '<a href="'.$edit_event_url.'" title="'.esc_attr__('Edit ', 'event_espresso').$this->_reg_event->name().'">'.__('Edit Event', 'event_espresso').'</a>';
2299
+			$this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">'.$edit_event_lnk.'</span>';
2300 2300
 		}
2301 2301
 
2302 2302
 		$this->_template_args['step_content'] = $this->_get_registration_step_content();
2303 2303
 
2304
-		if ( defined('DOING_AJAX' ) ) {
2304
+		if (defined('DOING_AJAX')) {
2305 2305
 			$this->_return_json();
2306 2306
 		}
2307 2307
 		// grab header
2308
-		$template_path = REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2309
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( $template_path, $this->_template_args, TRUE );
2308
+		$template_path = REG_TEMPLATE_PATH.'reg_admin_register_new_attendee.template.php';
2309
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, TRUE);
2310 2310
 
2311 2311
 		//$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
2312 2312
 		// the details template wrapper
@@ -2323,7 +2323,7 @@  discard block
 block discarded – undo
2323 2323
 	 * @return string html
2324 2324
 	 */
2325 2325
 	protected function _get_registration_step_content() {
2326
-		if ( isset( $_COOKIE[ 'ee_registration_added' ] ) && $_COOKIE[ 'ee_registration_added' ] ) {
2326
+		if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) {
2327 2327
 			$warning_msg = sprintf(
2328 2328
 				__(
2329 2329
 					'%2$sWARNING!!!%3$s%1$sPlease do not use the back button to return to this page for the purpose of adding another registration.%1$sThis can result in lost and/or corrupted data.%1$sIf you wish to add another registration, then please click the%1$s%7$s"Add Another New Registration to Event"%8$s button%1$son the Transaction details page, after you are redirected.%1$s%1$s%4$s redirecting in %5$s seconds %6$s',
@@ -2339,7 +2339,7 @@  discard block
 block discarded – undo
2339 2339
 				'</b>'
2340 2340
 			);
2341 2341
 			return '
2342
-	<div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div>
2342
+	<div id="ee-add-reg-back-button-dv"><p>' . $warning_msg.'</p></div>
2343 2343
 	<script >
2344 2344
 		// WHOAH !!! it appears that someone is using the back button from the Transaction admin page
2345 2345
 		// after just adding a new registration... we gotta try to put a stop to that !!!
@@ -2374,16 +2374,16 @@  discard block
 block discarded – undo
2374 2374
 		$cart = EE_Registry::instance()->SSN->cart();
2375 2375
 		$step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
2376 2376
 
2377
-		switch ( $step ) {
2377
+		switch ($step) {
2378 2378
 			case 'ticket' :
2379 2379
 				$hidden_fields['processing_registration']['value'] = 1;
2380 2380
 				$template_args['title'] = __('Step One: Select the Ticket for this registration', 'event_espresso');
2381
-				$template_args['content'] = EED_Ticket_Selector::instance()->display_ticket_selector( $this->_reg_event );
2381
+				$template_args['content'] = EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
2382 2382
 				$template_args['step_button_text'] = __('Add Tickets and Continue to Registrant Details', 'event_espresso');
2383 2383
 				$template_args['show_notification_toggle'] = FALSE;
2384 2384
 				break;
2385 2385
 			case 'questions' :
2386
-				$hidden_fields[ 'processing_registration' ][ 'value' ] = 2;
2386
+				$hidden_fields['processing_registration']['value'] = 2;
2387 2387
 				$template_args['title'] = __('Step Two: Add Registrant Details for this Registration', 'event_espresso');
2388 2388
 				//in theory we should be able to run EED_SPCO at this point because the cart should have been setup properly by the first process_reg_step run.
2389 2389
 				$template_args['content'] = EED_Single_Page_Checkout::registration_checkout_for_admin();
@@ -2392,10 +2392,10 @@  discard block
 block discarded – undo
2392 2392
 				break;
2393 2393
 		}
2394 2394
 
2395
-		$this->_set_add_edit_form_tags( 'process_reg_step', $hidden_fields ); //we come back to the process_registration_step route.
2395
+		$this->_set_add_edit_form_tags('process_reg_step', $hidden_fields); //we come back to the process_registration_step route.
2396 2396
 
2397 2397
 		return EEH_Template::display_template(
2398
-			REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php', $template_args, TRUE
2398
+			REG_TEMPLATE_PATH.'reg_admin_register_new_attendee_step_content.template.php', $template_args, TRUE
2399 2399
 		);
2400 2400
 	}
2401 2401
 
@@ -2410,11 +2410,11 @@  discard block
 block discarded – undo
2410 2410
 	*		@return boolean
2411 2411
 	*/
2412 2412
 	private function _set_reg_event() {
2413
-		if ( is_object( $this->_reg_event )) {
2413
+		if (is_object($this->_reg_event)) {
2414 2414
 			return TRUE;
2415 2415
 		}
2416
-		$EVT_ID = ( ! empty( $this->_req_data['event_id'] )) ? absint( $this->_req_data['event_id'] ) : FALSE;
2417
-		if ( ! $EVT_ID ) {
2416
+		$EVT_ID = ( ! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : FALSE;
2417
+		if ( ! $EVT_ID) {
2418 2418
 			return FALSE;
2419 2419
 		}
2420 2420
 
@@ -2435,82 +2435,82 @@  discard block
 block discarded – undo
2435 2435
 	public function process_reg_step() {
2436 2436
 		EE_System::do_not_cache();
2437 2437
 		$this->_set_reg_event();
2438
-		EE_Registry::instance()->REQ->set_espresso_page( TRUE );
2438
+		EE_Registry::instance()->REQ->set_espresso_page(TRUE);
2439 2439
 
2440 2440
 		//what step are we on?
2441 2441
 		$cart = EE_Registry::instance()->SSN->cart();
2442 2442
 		$step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
2443 2443
 
2444 2444
 		//if doing ajax then we need to verify the nonce
2445
-		if ( defined( 'DOING_AJAX' ) ) {
2446
-			$nonce = isset( $this->_req_data[$this->_req_nonce] ) ? sanitize_text_field( $this->_req_data[$this->_req_nonce] ) : '';
2447
-			$this->_verify_nonce( $nonce, $this->_req_nonce );
2445
+		if (defined('DOING_AJAX')) {
2446
+			$nonce = isset($this->_req_data[$this->_req_nonce]) ? sanitize_text_field($this->_req_data[$this->_req_nonce]) : '';
2447
+			$this->_verify_nonce($nonce, $this->_req_nonce);
2448 2448
 		}
2449 2449
 
2450
-		switch ( $step ) {
2450
+		switch ($step) {
2451 2451
 
2452 2452
 			case 'ticket' :
2453 2453
 				//process ticket selection
2454 2454
 				$success = EED_Ticket_Selector::instance()->process_ticket_selections();
2455
-				if ( $success ) {
2456
-					EE_Error::add_success( __('Tickets Selected. Now complete the registration.'), 'event_espresso');
2455
+				if ($success) {
2456
+					EE_Error::add_success(__('Tickets Selected. Now complete the registration.'), 'event_espresso');
2457 2457
 				} else {
2458 2458
 					$query_args['step_error'] = $this->_req_data['step_error'] = TRUE;
2459 2459
 				}
2460
-				if ( defined('DOING_AJAX') ) {
2460
+				if (defined('DOING_AJAX')) {
2461 2461
 					$this->new_registration(); //display next step
2462 2462
 				} else {
2463 2463
 					$query_args['action'] = 'new_registration';
2464 2464
 					$query_args['processing_registration'] = 1;
2465 2465
 					$query_args['event_id'] = $this->_reg_event->ID();
2466
-					$this->_redirect_after_action( FALSE, '', '', $query_args, TRUE );
2466
+					$this->_redirect_after_action(FALSE, '', '', $query_args, TRUE);
2467 2467
 				}
2468 2468
 				break;
2469 2469
 
2470 2470
 			case 'questions' :
2471
-				if( ! isset( $this->_req_data[ 'txn_reg_status_change' ], $this->_req_data[ 'txn_reg_status_change' ][ 'send_notifications' ] ) ) {
2472
-					add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15 );
2471
+				if ( ! isset($this->_req_data['txn_reg_status_change'], $this->_req_data['txn_reg_status_change']['send_notifications'])) {
2472
+					add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
2473 2473
 				}
2474 2474
 				//process registration
2475 2475
 				$transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin();
2476
-				if ( $cart instanceof EE_Cart ) {
2476
+				if ($cart instanceof EE_Cart) {
2477 2477
 					$grand_total = $cart->get_cart_grand_total();
2478
-					if ( $grand_total instanceof EE_Line_Item ) {
2478
+					if ($grand_total instanceof EE_Line_Item) {
2479 2479
 						$grand_total->save_this_and_descendants_to_txn();
2480 2480
 					}
2481 2481
 				}
2482
-				if ( ! $transaction instanceof EE_Transaction ) {
2482
+				if ( ! $transaction instanceof EE_Transaction) {
2483 2483
 					$query_args = array(
2484 2484
 						'action' => 'new_registration',
2485 2485
 						'processing_registration' => 2,
2486 2486
 						'event_id' => $this->_reg_event->ID()
2487 2487
 					);
2488 2488
 
2489
-					if ( defined('DOING_AJAX' )) {
2489
+					if (defined('DOING_AJAX')) {
2490 2490
 						//display registration form again because there are errors (maybe validation?)
2491 2491
 						$this->new_registration();
2492 2492
 						return;
2493 2493
 					} else {
2494
-						$this->_redirect_after_action( FALSE, '', '', $query_args, TRUE );
2494
+						$this->_redirect_after_action(FALSE, '', '', $query_args, TRUE);
2495 2495
 						return;
2496 2496
 					}
2497 2497
 				}
2498 2498
 				/** @type EE_Transaction_Payments $transaction_payments */
2499
-				$transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' );
2499
+				$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
2500 2500
 				// maybe update status, and make sure to save transaction if not done already
2501
-				if ( ! $transaction_payments->update_transaction_status_based_on_total_paid( $transaction )) {
2501
+				if ( ! $transaction_payments->update_transaction_status_based_on_total_paid($transaction)) {
2502 2502
 					$transaction->save();
2503 2503
 				}
2504
-				EE_Registry::instance()->SSN->clear_session( __CLASS__, __FUNCTION__ );
2504
+				EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2505 2505
 				$this->_req_data = array();
2506 2506
 				$query_args = array(
2507 2507
 					'action'        => 'redirect_to_txn',
2508 2508
 					'TXN_ID'        => $transaction->ID(),
2509 2509
 					'EVT_ID'        => $this->_reg_event->ID(),
2510
-					'event_name'    => urlencode( $this->_reg_event->name() ),
2510
+					'event_name'    => urlencode($this->_reg_event->name()),
2511 2511
 					'redirect_from' => 'new_registration'
2512 2512
 				);
2513
-				$this->_redirect_after_action( false, '', '', $query_args, true );
2513
+				$this->_redirect_after_action(false, '', '', $query_args, true);
2514 2514
 				break;
2515 2515
 		}
2516 2516
 
@@ -2527,21 +2527,21 @@  discard block
 block discarded – undo
2527 2527
 	 */
2528 2528
 	public function redirect_to_txn() {
2529 2529
 		EE_System::do_not_cache();
2530
-		EE_Registry::instance()->SSN->clear_session( __CLASS__, __FUNCTION__ );
2530
+		EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2531 2531
 		$query_args = array(
2532 2532
 			'action' => 'view_transaction',
2533
-			'TXN_ID' => isset( $this->_req_data['TXN_ID'] ) ? absint( $this->_req_data[ 'TXN_ID' ] )  : 0,
2533
+			'TXN_ID' => isset($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : 0,
2534 2534
 			'page'   => 'espresso_transactions'
2535 2535
 		);
2536
-		if ( isset( $this->_req_data[ 'EVT_ID' ], $this->_req_data[ 'redirect_from' ] ) ) {
2537
-			$query_args['EVT_ID'] = $this->_req_data[ 'EVT_ID' ];
2538
-			$query_args['event_name'] = urlencode( $this->_req_data[ 'event_name' ] );
2539
-			$query_args['redirect_from'] = $this->_req_data[ 'redirect_from' ];
2536
+		if (isset($this->_req_data['EVT_ID'], $this->_req_data['redirect_from'])) {
2537
+			$query_args['EVT_ID'] = $this->_req_data['EVT_ID'];
2538
+			$query_args['event_name'] = urlencode($this->_req_data['event_name']);
2539
+			$query_args['redirect_from'] = $this->_req_data['redirect_from'];
2540 2540
 		}
2541 2541
 		EE_Error::add_success(
2542
-			__( 'Registration Created.  Please review the transaction and add any payments as necessary', 'event_espresso' )
2542
+			__('Registration Created.  Please review the transaction and add any payments as necessary', 'event_espresso')
2543 2543
 		);
2544
-		$this->_redirect_after_action( false, '', '', $query_args, true );
2544
+		$this->_redirect_after_action(false, '', '', $query_args, true);
2545 2545
 	}
2546 2546
 
2547 2547
 
@@ -2552,7 +2552,7 @@  discard block
 block discarded – undo
2552 2552
 	*		@return void
2553 2553
 	*/
2554 2554
 	protected function _attendee_contact_list_table() {
2555
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
2555
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2556 2556
 		$this->_search_btn_label = __('Contacts', 'event_espresso');
2557 2557
 		$this->display_admin_list_table_page_with_no_sidebar();
2558 2558
 	}
@@ -2567,10 +2567,10 @@  discard block
 block discarded – undo
2567 2567
 	*		@access public
2568 2568
 	*		@return array
2569 2569
 	*/
2570
-	public function get_attendees( $per_page, $count = FALSE, $trash = FALSE ) {
2570
+	public function get_attendees($per_page, $count = FALSE, $trash = FALSE) {
2571 2571
 
2572
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
2573
-		require_once( REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php' );
2572
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2573
+		require_once(REG_ADMIN.'EE_Attendee_Contact_List_Table.class.php');
2574 2574
 		$ATT_MDL = EEM_Attendee::instance();
2575 2575
 
2576 2576
 		$this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
@@ -2598,47 +2598,47 @@  discard block
 block discarded – undo
2598 2598
 				$orderby = 'ATT_lname';
2599 2599
 		}
2600 2600
 
2601
-		$sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'ASC';
2601
+		$sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC';
2602 2602
 
2603
-		$current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1;
2604
-		$per_page = isset( $per_page ) && !empty( $per_page ) ? $per_page : 10;
2605
-		$per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page;
2603
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1;
2604
+		$per_page = isset($per_page) && ! empty($per_page) ? $per_page : 10;
2605
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page;
2606 2606
 
2607 2607
 		$_where = array();
2608 2608
 
2609
-		if ( ! empty( $this->_req_data['s'] ) ) {
2610
-			$sstr = '%' . $this->_req_data['s'] . '%';
2609
+		if ( ! empty($this->_req_data['s'])) {
2610
+			$sstr = '%'.$this->_req_data['s'].'%';
2611 2611
 			$_where['OR'] = array(
2612
-				'Registration.Event.EVT_name' => array( 'LIKE', $sstr),
2613
-				'Registration.Event.EVT_desc' => array( 'LIKE', $sstr ),
2614
-				'Registration.Event.EVT_short_desc' => array( 'LIKE' , $sstr ),
2615
-				'ATT_fname' => array( 'LIKE', $sstr ),
2616
-				'ATT_lname' => array( 'LIKE', $sstr ),
2617
-				'ATT_short_bio' => array( 'LIKE', $sstr ),
2618
-				'ATT_email' => array('LIKE', $sstr ),
2619
-				'ATT_address' => array( 'LIKE', $sstr ),
2620
-				'ATT_address2' => array( 'LIKE', $sstr ),
2621
-				'ATT_city' => array( 'LIKE', $sstr ),
2622
-				'Country.CNT_name' => array( 'LIKE', $sstr ),
2623
-				'State.STA_name' => array('LIKE', $sstr ),
2624
-				'ATT_phone' => array( 'LIKE', $sstr ),
2625
-				'Registration.REG_final_price' => array( 'LIKE', $sstr ),
2626
-				'Registration.REG_code' => array( 'LIKE', $sstr ),
2627
-				'Registration.REG_count' => array( 'LIKE' , $sstr ),
2628
-				'Registration.REG_group_size' => array( 'LIKE' , $sstr )
2612
+				'Registration.Event.EVT_name' => array('LIKE', $sstr),
2613
+				'Registration.Event.EVT_desc' => array('LIKE', $sstr),
2614
+				'Registration.Event.EVT_short_desc' => array('LIKE', $sstr),
2615
+				'ATT_fname' => array('LIKE', $sstr),
2616
+				'ATT_lname' => array('LIKE', $sstr),
2617
+				'ATT_short_bio' => array('LIKE', $sstr),
2618
+				'ATT_email' => array('LIKE', $sstr),
2619
+				'ATT_address' => array('LIKE', $sstr),
2620
+				'ATT_address2' => array('LIKE', $sstr),
2621
+				'ATT_city' => array('LIKE', $sstr),
2622
+				'Country.CNT_name' => array('LIKE', $sstr),
2623
+				'State.STA_name' => array('LIKE', $sstr),
2624
+				'ATT_phone' => array('LIKE', $sstr),
2625
+				'Registration.REG_final_price' => array('LIKE', $sstr),
2626
+				'Registration.REG_code' => array('LIKE', $sstr),
2627
+				'Registration.REG_count' => array('LIKE', $sstr),
2628
+				'Registration.REG_group_size' => array('LIKE', $sstr)
2629 2629
 				);
2630 2630
 		}
2631 2631
 
2632 2632
 
2633
-		$offset = ($current_page-1)*$per_page;
2634
-		$limit = $count ? NULL : array( $offset, $per_page );
2633
+		$offset = ($current_page - 1) * $per_page;
2634
+		$limit = $count ? NULL : array($offset, $per_page);
2635 2635
 
2636
-		if ( $trash ) {
2637
-			$_where['status'] = array( '!=', 'publish' );
2638
-			$all_attendees = $count ? $ATT_MDL->count( array($_where,'order_by'=>array($orderby=>$sort), 'limit'=>$limit), 'ATT_ID', true ): $ATT_MDL->get_all( array($_where,'order_by'=>array($orderby=>$sort), 'limit'=>$limit));
2636
+		if ($trash) {
2637
+			$_where['status'] = array('!=', 'publish');
2638
+			$all_attendees = $count ? $ATT_MDL->count(array($_where, 'order_by'=>array($orderby=>$sort), 'limit'=>$limit), 'ATT_ID', true) : $ATT_MDL->get_all(array($_where, 'order_by'=>array($orderby=>$sort), 'limit'=>$limit));
2639 2639
 		} else {
2640
-			$_where['status'] = array( 'IN', array( 'publish' ) );
2641
-			$all_attendees = $count ? $ATT_MDL->count( array($_where, 'order_by'=>array($orderby=>$sort),'limit'=>$limit ), 'ATT_ID' , true ) : $ATT_MDL->get_all( array($_where, 'order_by'=>array($orderby=>$sort), 'limit'=>$limit) );
2640
+			$_where['status'] = array('IN', array('publish'));
2641
+			$all_attendees = $count ? $ATT_MDL->count(array($_where, 'order_by'=>array($orderby=>$sort), 'limit'=>$limit), 'ATT_ID', true) : $ATT_MDL->get_all(array($_where, 'order_by'=>array($orderby=>$sort), 'limit'=>$limit));
2642 2642
 		}
2643 2643
 
2644 2644
 		return $all_attendees;
@@ -2655,10 +2655,10 @@  discard block
 block discarded – undo
2655 2655
 	 */
2656 2656
 	protected function _resend_registration() {
2657 2657
 		$this->_process_resend_registration();
2658
-		$query_args = isset($this->_req_data['redirect_to'] ) ? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID'] ) : array(
2658
+		$query_args = isset($this->_req_data['redirect_to']) ? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID']) : array(
2659 2659
 			'action' => 'default'
2660 2660
 		);
2661
-		$this->_redirect_after_action(FALSE, '', '', $query_args, TRUE );
2661
+		$this->_redirect_after_action(FALSE, '', '', $query_args, TRUE);
2662 2662
 	}
2663 2663
 
2664 2664
 
@@ -2666,26 +2666,26 @@  discard block
 block discarded – undo
2666 2666
 
2667 2667
 
2668 2668
 
2669
-	public function _registrations_report(){
2670
-		if( ! defined( 'EE_USE_OLD_CSV_REPORT_CLASS' ) ) {
2671
-			wp_redirect( EE_Admin_Page::add_query_args_and_nonce(
2669
+	public function _registrations_report() {
2670
+		if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
2671
+			wp_redirect(EE_Admin_Page::add_query_args_and_nonce(
2672 2672
 				array(
2673 2673
 					'page' => 'espresso_batch',
2674 2674
 					'batch' => 'file',
2675
-					'EVT_ID' => isset( $this->_req_data[ 'EVT_ID'] ) ? $this->_req_data[ 'EVT_ID' ] : NULL,
2676
-					'job_handler' => urlencode( 'EventEspressoBatchRequest\JobHandlers\RegistrationsReport' ),
2677
-					'return_url' => urlencode( $this->_req_data[ 'return_url' ] ),
2678
-				)) );
2675
+					'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : NULL,
2676
+					'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'),
2677
+					'return_url' => urlencode($this->_req_data['return_url']),
2678
+				)));
2679 2679
 		} else {
2680 2680
 			$new_request_args = array(
2681 2681
 				'export' => 'report',
2682 2682
 				'action' => 'registrations_report_for_event',
2683
-				'EVT_ID' => isset( $this->_req_data[ 'EVT_ID'] ) ? $this->_req_data[ 'EVT_ID' ] : NULL,
2683
+				'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : NULL,
2684 2684
 			);
2685 2685
 			$this->_req_data = array_merge($this->_req_data, $new_request_args);
2686 2686
 
2687
-			if ( is_readable(EE_CLASSES . 'EE_Export.class.php')) {
2688
-				require_once(EE_CLASSES . 'EE_Export.class.php');
2687
+			if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
2688
+				require_once(EE_CLASSES.'EE_Export.class.php');
2689 2689
 				$EE_Export = EE_Export::instance($this->_req_data);
2690 2690
 				$EE_Export->export();
2691 2691
 			}
@@ -2694,26 +2694,26 @@  discard block
 block discarded – undo
2694 2694
 
2695 2695
 
2696 2696
 
2697
-	public function _contact_list_export(){
2698
-		if ( is_readable(EE_CLASSES . 'EE_Export.class.php')) {
2699
-			require_once(EE_CLASSES . 'EE_Export.class.php');
2697
+	public function _contact_list_export() {
2698
+		if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
2699
+			require_once(EE_CLASSES.'EE_Export.class.php');
2700 2700
 			$EE_Export = EE_Export::instance($this->_req_data);
2701 2701
 			$EE_Export->export_attendees();
2702 2702
 		}
2703 2703
 	}
2704 2704
 
2705
-	public function _contact_list_report(){
2706
-		if( ! defined( 'EE_USE_OLD_CSV_REPORT_CLASS' ) ) {
2707
-			wp_redirect( EE_Admin_Page::add_query_args_and_nonce(
2705
+	public function _contact_list_report() {
2706
+		if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
2707
+			wp_redirect(EE_Admin_Page::add_query_args_and_nonce(
2708 2708
 				array(
2709 2709
 					'page' => 'espresso_batch',
2710 2710
 					'batch' => 'file',
2711
-					'job_handler' => urlencode( 'EventEspressoBatchRequest\JobHandlers\AttendeesReport' ),
2712
-					'return_url' => urlencode( $this->_req_data[ 'return_url' ] ),
2713
-				)) );
2711
+					'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'),
2712
+					'return_url' => urlencode($this->_req_data['return_url']),
2713
+				)));
2714 2714
 		} else {
2715
-			if ( is_readable(EE_CLASSES . 'EE_Export.class.php')) {
2716
-				require_once(EE_CLASSES . 'EE_Export.class.php');
2715
+			if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
2716
+				require_once(EE_CLASSES.'EE_Export.class.php');
2717 2717
 				$EE_Export = EE_Export::instance($this->_req_data);
2718 2718
 				$EE_Export->report_attendees();
2719 2719
 			}
@@ -2732,73 +2732,73 @@  discard block
 block discarded – undo
2732 2732
 	 * @return void
2733 2733
 	 */
2734 2734
 	protected function _duplicate_attendee() {
2735
-		$action = !empty( $this->_req_data['return'] ) ? $this->_req_data['return'] : 'default';
2735
+		$action = ! empty($this->_req_data['return']) ? $this->_req_data['return'] : 'default';
2736 2736
 		//verify we have necessary info
2737
-		if ( empty($this->_req_data['_REG_ID'] )  ) {
2738
-			EE_Error::add_error( __('Unable to create the contact for the registration because the required parameters are not present (_REG_ID )', 'event_espresso'),  __FILE__, __LINE__, __FUNCTION__ );
2739
-			$query_args = array( 'action' => $action );
2737
+		if (empty($this->_req_data['_REG_ID'])) {
2738
+			EE_Error::add_error(__('Unable to create the contact for the registration because the required parameters are not present (_REG_ID )', 'event_espresso'), __FILE__, __LINE__, __FUNCTION__);
2739
+			$query_args = array('action' => $action);
2740 2740
 			$this->_redirect_after_action('', '', '', $query_args, TRUE);
2741 2741
 		}
2742 2742
 
2743 2743
 		//okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
2744
-		$registration = EEM_Registration::instance()->get_one_by_ID( $this->_req_data['_REG_ID'] );
2744
+		$registration = EEM_Registration::instance()->get_one_by_ID($this->_req_data['_REG_ID']);
2745 2745
 		$attendee = $registration->attendee();
2746 2746
 
2747 2747
 		//remove relation of existing attendee on registration
2748
-		$registration->_remove_relation_to($attendee, 'Attendee' );
2748
+		$registration->_remove_relation_to($attendee, 'Attendee');
2749 2749
 		//new attendee
2750 2750
 		$new_attendee = clone $attendee;
2751
-		$new_attendee->set( 'ATT_ID', 0 );
2751
+		$new_attendee->set('ATT_ID', 0);
2752 2752
 		$new_attendee->save();
2753 2753
 
2754 2754
 		//add new attendee to reg
2755
-		$registration->_add_relation_to( $new_attendee, 'Attendee');
2755
+		$registration->_add_relation_to($new_attendee, 'Attendee');
2756 2756
 
2757
-		EE_Error::add_success( __('New Contact record created.  Now make any edits you wish to make for this contact.', 'event_espresso') );
2757
+		EE_Error::add_success(__('New Contact record created.  Now make any edits you wish to make for this contact.', 'event_espresso'));
2758 2758
 
2759 2759
 		//redirect to edit page for attendee
2760
-		$query_args = array( 'post' => $new_attendee->ID(), 'action' => 'edit_attendee' );
2760
+		$query_args = array('post' => $new_attendee->ID(), 'action' => 'edit_attendee');
2761 2761
 
2762
-		$this->_redirect_after_action( '', '', '', $query_args, TRUE );
2762
+		$this->_redirect_after_action('', '', '', $query_args, TRUE);
2763 2763
 	}
2764 2764
 
2765 2765
 
2766 2766
 	//related to cpt routes
2767 2767
 	protected function _insert_update_cpt_item($post_id, $post) {
2768 2768
 		$success = true;
2769
-		$attendee = EEM_Attendee::instance()->get_one_by_ID( $post_id );
2769
+		$attendee = EEM_Attendee::instance()->get_one_by_ID($post_id);
2770 2770
 		//for attendee updates
2771
-		if ( $post->post_type = 'espresso_attendees' && !empty( $attendee ) ) {
2771
+		if ($post->post_type = 'espresso_attendees' && ! empty($attendee)) {
2772 2772
 			//note we should only be UPDATING attendees at this point.
2773 2773
 			$updated_fields = array(
2774 2774
 				'ATT_fname' => $this->_req_data['ATT_fname'],
2775 2775
 				'ATT_lname' => $this->_req_data['ATT_lname'],
2776
-				'ATT_full_name'=> $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'],
2776
+				'ATT_full_name'=> $this->_req_data['ATT_fname'].' '.$this->_req_data['ATT_lname'],
2777 2777
 				'ATT_address' => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '',
2778 2778
 				'ATT_address2' => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '',
2779
-				'ATT_city' => isset( $this->_req_data['ATT_city'] ) ? $this->_req_data['ATT_city'] : '',
2780
-				'STA_ID' => isset( $this->_req_data['STA_ID'] ) ? $this->_req_data['STA_ID'] : '',
2781
-				'CNT_ISO' => isset( $this->_req_data['CNT_ISO'] ) ? $this->_req_data['CNT_ISO'] : '',
2782
-				'ATT_zip' => isset( $this->_req_data['ATT_zip'] ) ? $this->_req_data['ATT_zip'] : '',
2783
-				'ATT_email' => isset( $this->_req_data['ATT_email'] ) ? $this->_req_data['ATT_email'] : '',
2784
-				'ATT_phone' => isset( $this->_req_data['ATT_phone'] ) ? $this->_req_data['ATT_phone'] : ''
2779
+				'ATT_city' => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '',
2780
+				'STA_ID' => isset($this->_req_data['STA_ID']) ? $this->_req_data['STA_ID'] : '',
2781
+				'CNT_ISO' => isset($this->_req_data['CNT_ISO']) ? $this->_req_data['CNT_ISO'] : '',
2782
+				'ATT_zip' => isset($this->_req_data['ATT_zip']) ? $this->_req_data['ATT_zip'] : '',
2783
+				'ATT_email' => isset($this->_req_data['ATT_email']) ? $this->_req_data['ATT_email'] : '',
2784
+				'ATT_phone' => isset($this->_req_data['ATT_phone']) ? $this->_req_data['ATT_phone'] : ''
2785 2785
 				);
2786
-			foreach ( $updated_fields as $field => $value ) {
2786
+			foreach ($updated_fields as $field => $value) {
2787 2787
 				$attendee->set($field, $value);
2788 2788
 			}
2789 2789
 
2790 2790
 			$success = $attendee->save();
2791 2791
 
2792
-			$attendee_update_callbacks = apply_filters( 'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update', array() );
2793
-			foreach ( $attendee_update_callbacks as $a_callback ) {
2794
-				if ( FALSE === call_user_func_array( $a_callback, array($attendee, $this->_req_data ) ) ) {
2795
-					throw new EE_Error( sprintf( __('The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback.  Please check the spelling.', 'event_espresso'), $a_callback ) );
2792
+			$attendee_update_callbacks = apply_filters('FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update', array());
2793
+			foreach ($attendee_update_callbacks as $a_callback) {
2794
+				if (FALSE === call_user_func_array($a_callback, array($attendee, $this->_req_data))) {
2795
+					throw new EE_Error(sprintf(__('The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback.  Please check the spelling.', 'event_espresso'), $a_callback));
2796 2796
 				}
2797 2797
 			}
2798 2798
 		}
2799 2799
 
2800
-		if ( $success === FALSE )
2801
-			EE_Error::add_error(__('Something went wrong with updating the meta table data for the registration.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
2800
+		if ($success === FALSE)
2801
+			EE_Error::add_error(__('Something went wrong with updating the meta table data for the registration.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
2802 2802
 
2803 2803
 	}
2804 2804
 
@@ -2818,17 +2818,17 @@  discard block
 block discarded – undo
2818 2818
 		remove_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', $this->_cpt_routes[$this->_req_action], 'normal', 'core');
2819 2819
 		remove_meta_box('commentstatusdiv', $this->_cpt_routes[$this->_req_action], 'normal', 'core');
2820 2820
 
2821
-		if ( post_type_supports( 'espresso_attendees', 'excerpt') ) {
2822
-			add_meta_box('postexcerpt', __('Short Biography', 'event_espresso'), 'post_excerpt_meta_box', $this->_cpt_routes[$this->_req_action], 'normal' );
2821
+		if (post_type_supports('espresso_attendees', 'excerpt')) {
2822
+			add_meta_box('postexcerpt', __('Short Biography', 'event_espresso'), 'post_excerpt_meta_box', $this->_cpt_routes[$this->_req_action], 'normal');
2823 2823
 		}
2824 2824
 
2825
-		if ( post_type_supports( 'espresso_attendees', 'comments') ) {
2825
+		if (post_type_supports('espresso_attendees', 'comments')) {
2826 2826
 			add_meta_box('commentsdiv', __('Notes on the Contact', 'event_espresso'), 'post_comment_meta_box', $this->_cpt_routes[$this->_req_action], 'normal', 'core');
2827 2827
 		}
2828 2828
 
2829
-		add_meta_box('attendee_contact_info', __('Contact Info', 'event_espresso'), array( $this, 'attendee_contact_info'), $this->_cpt_routes[$this->_req_action], 'side', 'core' );
2830
-		add_meta_box('attendee_details_address', __('Address Details', 'event_espresso'), array($this, 'attendee_address_details'), $this->_cpt_routes[$this->_req_action], 'normal', 'core' );
2831
-		add_meta_box('attendee_registrations', __('Registrations for this Contact', 'event_espresso'), array( $this, 'attendee_registrations_meta_box'), $this->_cpt_routes[$this->_req_action], 'normal', 'high');
2829
+		add_meta_box('attendee_contact_info', __('Contact Info', 'event_espresso'), array($this, 'attendee_contact_info'), $this->_cpt_routes[$this->_req_action], 'side', 'core');
2830
+		add_meta_box('attendee_details_address', __('Address Details', 'event_espresso'), array($this, 'attendee_address_details'), $this->_cpt_routes[$this->_req_action], 'normal', 'core');
2831
+		add_meta_box('attendee_registrations', __('Registrations for this Contact', 'event_espresso'), array($this, 'attendee_registrations_meta_box'), $this->_cpt_routes[$this->_req_action], 'normal', 'high');
2832 2832
 	}
2833 2833
 
2834 2834
 
@@ -2837,10 +2837,10 @@  discard block
 block discarded – undo
2837 2837
 	 * @param  WP_Post $post wp post object
2838 2838
 	 * @return string        attendee contact info ( and form )
2839 2839
 	 */
2840
-	public function attendee_contact_info( $post ) {
2840
+	public function attendee_contact_info($post) {
2841 2841
 		//get attendee object ( should already have it )
2842 2842
 		$this->_template_args['attendee'] = $this->_cpt_model_obj;
2843
-		$template = REG_TEMPLATE_PATH . 'attendee_contact_info_metabox_content.template.php';
2843
+		$template = REG_TEMPLATE_PATH.'attendee_contact_info_metabox_content.template.php';
2844 2844
 		EEH_Template::display_template($template, $this->_template_args);
2845 2845
 	}
2846 2846
 
@@ -2856,12 +2856,12 @@  discard block
 block discarded – undo
2856 2856
 		$this->_template_args['attendee'] = $this->_cpt_model_obj;
2857 2857
 		$this->_template_args['state_html'] = EEH_Form_Fields::generate_form_input(
2858 2858
 				new EE_Question_Form_Input(
2859
-				EE_Question::new_instance( array(
2859
+				EE_Question::new_instance(array(
2860 2860
 					'QST_ID' => 0,
2861 2861
 					'QST_display_text' => __('State/Province', 'event_espresso'),
2862 2862
 					'QST_system' => 'admin-state'
2863 2863
 					)),
2864
-				EE_Answer::new_instance( array(
2864
+				EE_Answer::new_instance(array(
2865 2865
 					'ANS_ID' => 0,
2866 2866
 					'ANS_value' => $this->_cpt_model_obj->state_ID()
2867 2867
 					)),
@@ -2874,12 +2874,12 @@  discard block
 block discarded – undo
2874 2874
 			));
2875 2875
 		$this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(
2876 2876
 				new EE_Question_Form_Input(
2877
-				EE_Question::new_instance( array(
2877
+				EE_Question::new_instance(array(
2878 2878
 					'QST_ID' => 0,
2879 2879
 					'QST_display_text' => __('Country', 'event_espresso'),
2880 2880
 					'QST_system' => 'admin-country'
2881 2881
 					)),
2882
-				EE_Answer::new_instance( array(
2882
+				EE_Answer::new_instance(array(
2883 2883
 					'ANS_ID' => 0,
2884 2884
 					'ANS_value' => $this->_cpt_model_obj->country_ID()
2885 2885
 					)),
@@ -2890,8 +2890,8 @@  discard block
 block discarded – undo
2890 2890
 					'append_qstn_id' => FALSE
2891 2891
 					)
2892 2892
 				));
2893
-		$template = REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
2894
-		EEH_Template::display_template($template, $this->_template_args );
2893
+		$template = REG_TEMPLATE_PATH.'attendee_address_details_metabox_content.template.php';
2894
+		EEH_Template::display_template($template, $this->_template_args);
2895 2895
 
2896 2896
 	}
2897 2897
 
@@ -2901,11 +2901,11 @@  discard block
 block discarded – undo
2901 2901
 	*		@access protected
2902 2902
 	*		@return void
2903 2903
 	*/
2904
-	public function attendee_registrations_meta_box( $post ) {
2904
+	public function attendee_registrations_meta_box($post) {
2905 2905
 
2906 2906
 		$this->_template_args['attendee'] = $this->_cpt_model_obj;
2907 2907
 		$this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
2908
-		$template = REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
2908
+		$template = REG_TEMPLATE_PATH.'attendee_registrations_main_meta_box.template.php';
2909 2909
 		EEH_Template::display_template($template, $this->_template_args);
2910 2910
 
2911 2911
 	}
@@ -2919,8 +2919,8 @@  discard block
 block discarded – undo
2919 2919
 	 * @return string        html for new form.
2920 2920
 	 */
2921 2921
 	public function after_title_form_fields($post) {
2922
-		if ( $post->post_type == 'espresso_attendees' ) {
2923
-			$template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
2922
+		if ($post->post_type == 'espresso_attendees') {
2923
+			$template = REG_TEMPLATE_PATH.'attendee_details_after_title_form_fields.template.php';
2924 2924
 			$template_args['attendee'] = $this->_cpt_model_obj;
2925 2925
 			EEH_Template::display_template($template, $template_args);
2926 2926
 		}
@@ -2937,21 +2937,21 @@  discard block
 block discarded – undo
2937 2937
 	*		@access protected
2938 2938
 	*		@return void
2939 2939
 	*/
2940
-	protected function _trash_or_restore_attendees( $trash = TRUE ) {
2940
+	protected function _trash_or_restore_attendees($trash = TRUE) {
2941 2941
 
2942
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
2942
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2943 2943
 
2944 2944
 		$ATT_MDL = EEM_Attendee::instance();
2945 2945
 
2946 2946
 		$success = 1;
2947 2947
 		//Checkboxes
2948
-		if (!empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
2948
+		if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
2949 2949
 			// if array has more than one element than success message should be plural
2950
-			$success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1;
2950
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
2951 2951
 			// cycle thru checkboxes
2952
-			while (list( $ATT_ID, $value ) = each($this->_req_data['checkbox'])) {
2953
-				$updated = $trash ? $ATT_MDL->update_by_ID(array( 'status' => 'trash' ), $ATT_ID) : $ATT_MDL->update_by_ID( array('status' => 'publish' ), $ATT_ID);
2954
-				if ( !$updated ) {
2952
+			while (list($ATT_ID, $value) = each($this->_req_data['checkbox'])) {
2953
+				$updated = $trash ? $ATT_MDL->update_by_ID(array('status' => 'trash'), $ATT_ID) : $ATT_MDL->update_by_ID(array('status' => 'publish'), $ATT_ID);
2954
+				if ( ! $updated) {
2955 2955
 					$success = 0;
2956 2956
 				}
2957 2957
 			}
@@ -2960,18 +2960,18 @@  discard block
 block discarded – undo
2960 2960
 			// grab single id and delete
2961 2961
 			$ATT_ID = absint($this->_req_data['ATT_ID']);
2962 2962
 			//get attendee
2963
-			$att = $ATT_MDL->get_one_by_ID( $ATT_ID );
2963
+			$att = $ATT_MDL->get_one_by_ID($ATT_ID);
2964 2964
 			$updated = $trash ? $att->set_status('trash') : $att->set_status('publish');
2965 2965
 			$updated = $att->save();
2966
-			if ( ! $updated ) {
2966
+			if ( ! $updated) {
2967 2967
 				$success = 0;
2968 2968
 			}
2969 2969
 
2970 2970
 		}
2971 2971
 
2972
-		$what = $success > 1 ? __( 'Contacts', 'event_espresso' ) : __( 'Contact', 'event_espresso' );
2973
-		$action_desc = $trash ? __( 'moved to the trash', 'event_espresso' ) : __( 'restored', 'event_espresso' );
2974
-		$this->_redirect_after_action( $success, $what, $action_desc, array( 'action' => 'contact_list' ) );
2972
+		$what = $success > 1 ? __('Contacts', 'event_espresso') : __('Contact', 'event_espresso');
2973
+		$action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso');
2974
+		$this->_redirect_after_action($success, $what, $action_desc, array('action' => 'contact_list'));
2975 2975
 
2976 2976
 	}
2977 2977
 
Please login to merge, or discard this patch.
admin_pages/transactions/Transactions_Admin_Page.core.php 1 patch
Spacing   +418 added lines, -418 removed lines patch added patch discarded remove patch
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
 	 * @param bool $routing
57 57
 	 * @return Transactions_Admin_Page
58 58
 	 */
59
-	public function __construct( $routing = TRUE ) {
60
-		parent::__construct( $routing );
59
+	public function __construct($routing = TRUE) {
60
+		parent::__construct($routing);
61 61
 	}
62 62
 
63 63
 
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
 	 * @return void
81 81
 	 */
82 82
 	protected function _ajax_hooks() {
83
-		add_action('wp_ajax_espresso_apply_payment', array( $this, 'apply_payments_or_refunds'));
84
-		add_action('wp_ajax_espresso_apply_refund', array( $this, 'apply_payments_or_refunds'));
85
-		add_action('wp_ajax_espresso_delete_payment', array( $this, 'delete_payment'));
83
+		add_action('wp_ajax_espresso_apply_payment', array($this, 'apply_payments_or_refunds'));
84
+		add_action('wp_ajax_espresso_apply_refund', array($this, 'apply_payments_or_refunds'));
85
+		add_action('wp_ajax_espresso_delete_payment', array($this, 'delete_payment'));
86 86
 	}
87 87
 
88 88
 
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 			'buttons' => array(
98 98
 				'add' => esc_html__('Add New Transaction', 'event_espresso'),
99 99
 				'edit' => esc_html__('Edit Transaction', 'event_espresso'),
100
-				'delete' => esc_html__('Delete Transaction','event_espresso'),
100
+				'delete' => esc_html__('Delete Transaction', 'event_espresso'),
101 101
 			)
102 102
 		);
103 103
 	}
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 
114 114
 		$this->_set_transaction_status_array();
115 115
 
116
-		$txn_id = ! empty( $this->_req_data['TXN_ID'] ) && ! is_array( $this->_req_data['TXN_ID'] ) ? $this->_req_data['TXN_ID'] : 0;
116
+		$txn_id = ! empty($this->_req_data['TXN_ID']) && ! is_array($this->_req_data['TXN_ID']) ? $this->_req_data['TXN_ID'] : 0;
117 117
 
118 118
 		$this->_page_routes = array(
119 119
 
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 						'filename' => 'transactions_overview_views_filters_search'
186 186
 					),
187 187
 				),
188
-				'help_tour' => array( 'Transactions_Overview_Help_Tour' ),
188
+				'help_tour' => array('Transactions_Overview_Help_Tour'),
189 189
 				/**
190 190
 				 * commented out because currently we are not displaying tips for transaction list table status but this
191 191
 				 * may change in a later iteration so want to keep the code for then.
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 				'nav' => array(
198 198
 					'label' => esc_html__('View Transaction', 'event_espresso'),
199 199
 					'order' => 5,
200
-					'url' => isset($this->_req_data['TXN_ID']) ? add_query_arg(array('TXN_ID' => $this->_req_data['TXN_ID'] ), $this->_current_page_view_url )  : $this->_admin_base_url,
200
+					'url' => isset($this->_req_data['TXN_ID']) ? add_query_arg(array('TXN_ID' => $this->_req_data['TXN_ID']), $this->_current_page_view_url) : $this->_admin_base_url,
201 201
 					'persistent' => FALSE
202 202
 					),
203 203
 				'help_tabs' => array(
@@ -218,8 +218,8 @@  discard block
 block discarded – undo
218 218
 						'filename' => 'transactions_view_transaction_primary_registrant_billing_information'
219 219
 					),
220 220
 				),
221
-				'qtips' => array( 'Transaction_Details_Tips' ),
222
-				'help_tour' => array( 'Transaction_Details_Help_Tour' ),
221
+				'qtips' => array('Transaction_Details_Tips'),
222
+				'help_tour' => array('Transaction_Details_Help_Tour'),
223 223
 				'metaboxes' => array('_transaction_details_metaboxes'),
224 224
 
225 225
 				'require_nonce' => FALSE
@@ -237,23 +237,23 @@  discard block
 block discarded – undo
237 237
 		// IF a registration was JUST added via the admin...
238 238
 		if (
239 239
 		isset(
240
-			$this->_req_data[ 'redirect_from' ],
241
-			$this->_req_data[ 'EVT_ID' ],
242
-			$this->_req_data[ 'event_name' ]
240
+			$this->_req_data['redirect_from'],
241
+			$this->_req_data['EVT_ID'],
242
+			$this->_req_data['event_name']
243 243
 		)
244 244
 		) {
245 245
 			// then set a cookie so that we can block any attempts to use
246 246
 			// the back button as a way to enter another registration.
247
-			setcookie( 'ee_registration_added', $this->_req_data[ 'EVT_ID' ], time() + WEEK_IN_SECONDS, '/' );
247
+			setcookie('ee_registration_added', $this->_req_data['EVT_ID'], time() + WEEK_IN_SECONDS, '/');
248 248
 			// and update the global
249
-			$_COOKIE[ 'ee_registration_added' ] = $this->_req_data[ 'EVT_ID' ];
249
+			$_COOKIE['ee_registration_added'] = $this->_req_data['EVT_ID'];
250 250
 		}
251
-		EE_Registry::$i18n_js_strings[ 'invalid_server_response' ] = esc_html__( 'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.', 'event_espresso' );
252
-		EE_Registry::$i18n_js_strings[ 'error_occurred' ] = esc_html__( 'An error occurred! Please refresh the page and try again.', 'event_espresso' );
253
-		EE_Registry::$i18n_js_strings[ 'txn_status_array' ] = self::$_txn_status;
254
-		EE_Registry::$i18n_js_strings[ 'pay_status_array' ] = self::$_pay_status;
255
-		EE_Registry::$i18n_js_strings[ 'payments_total' ] = esc_html__( 'Payments Total', 'event_espresso' );
256
-		EE_Registry::$i18n_js_strings[ 'transaction_overpaid' ] = esc_html__( 'This transaction has been overpaid ! Payments Total', 'event_espresso' );
251
+		EE_Registry::$i18n_js_strings['invalid_server_response'] = esc_html__('An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.', 'event_espresso');
252
+		EE_Registry::$i18n_js_strings['error_occurred'] = esc_html__('An error occurred! Please refresh the page and try again.', 'event_espresso');
253
+		EE_Registry::$i18n_js_strings['txn_status_array'] = self::$_txn_status;
254
+		EE_Registry::$i18n_js_strings['pay_status_array'] = self::$_pay_status;
255
+		EE_Registry::$i18n_js_strings['payments_total'] = esc_html__('Payments Total', 'event_espresso');
256
+		EE_Registry::$i18n_js_strings['transaction_overpaid'] = esc_html__('This transaction has been overpaid ! Payments Total', 'event_espresso');
257 257
 	}
258 258
 	public function admin_notices() {}
259 259
 	public function admin_footer_scripts() {}
@@ -320,14 +320,14 @@  discard block
 block discarded – undo
320 320
 	 */
321 321
 	public function load_scripts_styles() {
322 322
 		//enqueue style
323
-		wp_register_style( 'espresso_txn', TXN_ASSETS_URL . 'espresso_transactions_admin.css', array(), EVENT_ESPRESSO_VERSION );
323
+		wp_register_style('espresso_txn', TXN_ASSETS_URL.'espresso_transactions_admin.css', array(), EVENT_ESPRESSO_VERSION);
324 324
 		wp_enqueue_style('espresso_txn');
325 325
 
326 326
 		//scripts
327 327
 		add_filter('FHEE_load_accounting_js', '__return_true');
328 328
 
329 329
 		//scripts
330
-		wp_register_script('espresso_txn', TXN_ASSETS_URL . 'espresso_transactions_admin.js', array('ee_admin_js', 'ee-datepicker', 'jquery-ui-datepicker', 'jquery-ui-draggable', 'ee-dialog', 'ee-accounting', 'ee-serialize-full-array'), EVENT_ESPRESSO_VERSION, TRUE);
330
+		wp_register_script('espresso_txn', TXN_ASSETS_URL.'espresso_transactions_admin.js', array('ee_admin_js', 'ee-datepicker', 'jquery-ui-datepicker', 'jquery-ui-draggable', 'ee-dialog', 'ee-accounting', 'ee-serialize-full-array'), EVENT_ESPRESSO_VERSION, TRUE);
331 331
 		wp_enqueue_script('espresso_txn');
332 332
 
333 333
 	}
@@ -367,8 +367,8 @@  discard block
 block discarded – undo
367 367
 	 *	@return void
368 368
 	 */
369 369
 	protected function _set_list_table_views_default() {
370
-		$this->_views = array (
371
-			'all' => array (
370
+		$this->_views = array(
371
+			'all' => array(
372 372
 				'slug' 		=> 'all',
373 373
 				'label' 		=> esc_html__('View All Transactions', 'event_espresso'),
374 374
 				'count' 	=> 0
@@ -396,20 +396,20 @@  discard block
 block discarded – undo
396 396
 	 *	@return void
397 397
 	 */
398 398
 	private function _set_transaction_object() {
399
-		if ( is_object( $this->_transaction) )
399
+		if (is_object($this->_transaction))
400 400
 			return; //get out we've already set the object
401 401
 
402 402
 	    $TXN = EEM_Transaction::instance();
403 403
 
404
-	    $TXN_ID = ( ! empty( $this->_req_data['TXN_ID'] )) ? absint( $this->_req_data['TXN_ID'] ) : FALSE;
404
+	    $TXN_ID = ( ! empty($this->_req_data['TXN_ID'])) ? absint($this->_req_data['TXN_ID']) : FALSE;
405 405
 
406 406
 	    //get transaction object
407 407
 	    $this->_transaction = $TXN->get_one_by_ID($TXN_ID);
408
-	    $this->_session = !empty( $this->_transaction ) ? $this->_transaction->get('TXN_session_data') : NULL;
408
+	    $this->_session = ! empty($this->_transaction) ? $this->_transaction->get('TXN_session_data') : NULL;
409 409
 
410
-	 	if ( empty( $this->_transaction ) ) {
411
-	    	$error_msg = esc_html__('An error occurred and the details for Transaction ID #', 'event_espresso') . $TXN_ID .  esc_html__(' could not be retrieved.', 'event_espresso');
412
-			EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ );
410
+	 	if (empty($this->_transaction)) {
411
+	    	$error_msg = esc_html__('An error occurred and the details for Transaction ID #', 'event_espresso').$TXN_ID.esc_html__(' could not be retrieved.', 'event_espresso');
412
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
413 413
 	    }
414 414
 	}
415 415
 
@@ -422,12 +422,12 @@  discard block
 block discarded – undo
422 422
 	 *	@return array
423 423
 	 */
424 424
 	protected function _transaction_legend_items() {
425
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
425
+		EE_Registry::instance()->load_helper('MSG_Template');
426 426
 		$items = array();
427 427
 
428
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_global_messages', 'view_filtered_messages' ) ) {
429
-			$related_for_icon = EEH_MSG_Template::get_message_action_icon( 'see_notifications_for' );
430
-			if ( isset( $related_for_icon['css_class']) && isset( $related_for_icon['label'] ) ) {
428
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
429
+			$related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
430
+			if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) {
431 431
 				$items['view_related_messages'] = array(
432 432
 					'class' => $related_for_icon['css_class'],
433 433
 					'desc' => $related_for_icon['label'],
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 
438 438
 		$items = apply_filters(
439 439
 			'FHEE__Transactions_Admin_Page___transaction_legend_items__items',
440
-			array_merge( $items,
440
+			array_merge($items,
441 441
 				array(
442 442
 					'view_details' => array(
443 443
 						'class' => 'dashicons dashicons-cart',
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
 					),
450 450
 					'view_receipt' => array(
451 451
 						'class' => 'dashicons dashicons-media-default',
452
-						'desc' => esc_html__('View Transaction Receipt', 'event_espresso' )
452
+						'desc' => esc_html__('View Transaction Receipt', 'event_espresso')
453 453
 					),
454 454
 					'view_registration' => array(
455 455
 						'class' => 'dashicons dashicons-clipboard',
@@ -459,8 +459,8 @@  discard block
 block discarded – undo
459 459
 			)
460 460
 		);
461 461
 
462
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'espresso_transactions_send_payment_reminder' ) ) {
463
-			if ( EEH_MSG_Template::is_mt_active( 'payment_reminder' ) ) {
462
+		if (EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'espresso_transactions_send_payment_reminder')) {
463
+			if (EEH_MSG_Template::is_mt_active('payment_reminder')) {
464 464
 				$items['send_payment_reminder'] = array(
465 465
 					'class' => 'dashicons dashicons-email-alt',
466 466
 					'desc' => esc_html__('Send Payment Reminder', 'event_espresso')
@@ -481,29 +481,29 @@  discard block
 block discarded – undo
481 481
 			'FHEE__Transactions_Admin_Page___transaction_legend_items__more_items',
482 482
 			array(
483 483
 				'overpaid'   => array(
484
-					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::overpaid_status_code,
485
-					'desc'  => EEH_Template::pretty_status( EEM_Transaction::overpaid_status_code, FALSE, 'sentence' )
484
+					'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::overpaid_status_code,
485
+					'desc'  => EEH_Template::pretty_status(EEM_Transaction::overpaid_status_code, FALSE, 'sentence')
486 486
 				),
487 487
 				'complete'   => array(
488
-					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::complete_status_code,
489
-					'desc'  => EEH_Template::pretty_status( EEM_Transaction::complete_status_code, FALSE, 'sentence' )
488
+					'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::complete_status_code,
489
+					'desc'  => EEH_Template::pretty_status(EEM_Transaction::complete_status_code, FALSE, 'sentence')
490 490
 				),
491 491
 				'incomplete' => array(
492
-					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::incomplete_status_code,
493
-					'desc'  => EEH_Template::pretty_status( EEM_Transaction::incomplete_status_code, FALSE, 'sentence' )
492
+					'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::incomplete_status_code,
493
+					'desc'  => EEH_Template::pretty_status(EEM_Transaction::incomplete_status_code, FALSE, 'sentence')
494 494
 				),
495 495
 				'abandoned'  => array(
496
-					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::abandoned_status_code,
497
-					'desc'  => EEH_Template::pretty_status( EEM_Transaction::abandoned_status_code, FALSE, 'sentence' )
496
+					'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::abandoned_status_code,
497
+					'desc'  => EEH_Template::pretty_status(EEM_Transaction::abandoned_status_code, FALSE, 'sentence')
498 498
 				),
499 499
 				'failed'     => array(
500
-					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::failed_status_code,
501
-					'desc'  => EEH_Template::pretty_status( EEM_Transaction::failed_status_code, FALSE, 'sentence' )
500
+					'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::failed_status_code,
501
+					'desc'  => EEH_Template::pretty_status(EEM_Transaction::failed_status_code, FALSE, 'sentence')
502 502
 				)
503 503
 			)
504 504
 		);
505 505
 
506
-		return array_merge( $items, $more_items);
506
+		return array_merge($items, $more_items);
507 507
 	}
508 508
 
509 509
 
@@ -516,9 +516,9 @@  discard block
 block discarded – undo
516 516
 	 */
517 517
 	protected function _transactions_overview_list_table() {
518 518
 		$this->_admin_page_title = esc_html__('Transactions', 'event_espresso');
519
-		$event = isset($this->_req_data['EVT_ID']) ? EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID'] ) : NULL;
520
-		$this->_template_args['admin_page_header'] = $event instanceof EE_Event ? sprintf( esc_html__('%sViewing Transactions for the Event: %s%s', 'event_espresso'), '<h3>', '<a href="' . EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $event->ID()), EVENTS_ADMIN_URL ) . '" title="' . esc_attr__('Click to Edit event', 'event_espresso') . '">' . $event->get('EVT_name') . '</a>', '</h3>' ) : '';
521
-		$this->_template_args['after_list_table'] = $this->_display_legend( $this->_transaction_legend_items() );
519
+		$event = isset($this->_req_data['EVT_ID']) ? EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']) : NULL;
520
+		$this->_template_args['admin_page_header'] = $event instanceof EE_Event ? sprintf(esc_html__('%sViewing Transactions for the Event: %s%s', 'event_espresso'), '<h3>', '<a href="'.EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $event->ID()), EVENTS_ADMIN_URL).'" title="'.esc_attr__('Click to Edit event', 'event_espresso').'">'.$event->get('EVT_name').'</a>', '</h3>') : '';
521
+		$this->_template_args['after_list_table'] = $this->_display_legend($this->_transaction_legend_items());
522 522
 		$this->display_admin_list_table_page_with_no_sidebar();
523 523
 	}
524 524
 
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
 	*	@return void
533 533
 	*/
534 534
 	protected function _transaction_details() {
535
-		do_action( 'AHEE__Transactions_Admin_Page__transaction_details__start', $this->_transaction );
535
+		do_action('AHEE__Transactions_Admin_Page__transaction_details__start', $this->_transaction);
536 536
 
537 537
 		$this->_set_transaction_status_array();
538 538
 
@@ -545,14 +545,14 @@  discard block
 block discarded – undo
545 545
 		$attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee() : NULL;
546 546
 
547 547
 		$this->_template_args['txn_nmbr']['value'] = $this->_transaction->ID();
548
-		$this->_template_args['txn_nmbr']['label'] = esc_html__( 'Transaction Number', 'event_espresso' );
548
+		$this->_template_args['txn_nmbr']['label'] = esc_html__('Transaction Number', 'event_espresso');
549 549
 
550 550
 		$this->_template_args['txn_datetime']['value'] = $this->_transaction->get_i18n_datetime('TXN_timestamp');
551
-		$this->_template_args['txn_datetime']['label'] = esc_html__( 'Date', 'event_espresso' );
551
+		$this->_template_args['txn_datetime']['label'] = esc_html__('Date', 'event_espresso');
552 552
 
553
-		$this->_template_args['txn_status']['value'] = self::$_txn_status[ $this->_transaction->get('STS_ID') ];
554
-		$this->_template_args['txn_status']['label'] = esc_html__( 'Transaction Status', 'event_espresso' );
555
-		$this->_template_args['txn_status']['class'] = 'status-' . $this->_transaction->get('STS_ID');
553
+		$this->_template_args['txn_status']['value'] = self::$_txn_status[$this->_transaction->get('STS_ID')];
554
+		$this->_template_args['txn_status']['label'] = esc_html__('Transaction Status', 'event_espresso');
555
+		$this->_template_args['txn_status']['class'] = 'status-'.$this->_transaction->get('STS_ID');
556 556
 
557 557
 		$this->_template_args['grand_total'] = $this->_transaction->get('TXN_total');
558 558
 		$this->_template_args['total_paid'] = $this->_transaction->get('TXN_paid');
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
 			)
566 566
 		) {
567 567
 			$this->_template_args['send_payment_reminder_button'] =
568
-				EEH_MSG_Template::is_mt_active( 'payment_reminder' )
568
+				EEH_MSG_Template::is_mt_active('payment_reminder')
569 569
 				&& $this->_transaction->get('STS_ID') != EEM_Transaction::complete_status_code
570 570
 				&& $this->_transaction->get('STS_ID') != EEM_Transaction::overpaid_status_code
571 571
 					? EEH_Template::get_button_or_link(
@@ -587,40 +587,40 @@  discard block
 block discarded – undo
587 587
 		}
588 588
 
589 589
 		$amount_due = $this->_transaction->get('TXN_total') - $this->_transaction->get('TXN_paid');
590
-		$this->_template_args['amount_due'] = EEH_Template::format_currency( $amount_due, TRUE );
591
-		if ( EE_Registry::instance()->CFG->currency->sign_b4 ) {
592
-			$this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign . $this->_template_args['amount_due'];
590
+		$this->_template_args['amount_due'] = EEH_Template::format_currency($amount_due, TRUE);
591
+		if (EE_Registry::instance()->CFG->currency->sign_b4) {
592
+			$this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign.$this->_template_args['amount_due'];
593 593
 		} else {
594
-			$this->_template_args['amount_due'] = $this->_template_args['amount_due'] . EE_Registry::instance()->CFG->currency->sign;
594
+			$this->_template_args['amount_due'] = $this->_template_args['amount_due'].EE_Registry::instance()->CFG->currency->sign;
595 595
 		}
596
-		$this->_template_args['amount_due_class'] =  '';
596
+		$this->_template_args['amount_due_class'] = '';
597 597
 
598
-		if ( $this->_transaction->get('TXN_paid') == $this->_transaction->get('TXN_total') ) {
598
+		if ($this->_transaction->get('TXN_paid') == $this->_transaction->get('TXN_total')) {
599 599
 			// paid in full
600
-			$this->_template_args['amount_due'] =  FALSE;
601
-		} elseif ( $this->_transaction->get('TXN_paid') > $this->_transaction->get('TXN_total') ) {
600
+			$this->_template_args['amount_due'] = FALSE;
601
+		} elseif ($this->_transaction->get('TXN_paid') > $this->_transaction->get('TXN_total')) {
602 602
 			// overpaid
603
-			$this->_template_args['amount_due_class'] =  'txn-overview-no-payment-spn';
604
-		} elseif (( $this->_transaction->get('TXN_total') > 0 ) && ( $this->_transaction->get('TXN_paid') > 0 )) {
603
+			$this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn';
604
+		} elseif (($this->_transaction->get('TXN_total') > 0) && ($this->_transaction->get('TXN_paid') > 0)) {
605 605
 			// monies owing
606
-			$this->_template_args['amount_due_class'] =  'txn-overview-part-payment-spn';
607
-		} elseif (( $this->_transaction->get('TXN_total') > 0 ) && ( $this->_transaction->get('TXN_paid') == 0 )) {
606
+			$this->_template_args['amount_due_class'] = 'txn-overview-part-payment-spn';
607
+		} elseif (($this->_transaction->get('TXN_total') > 0) && ($this->_transaction->get('TXN_paid') == 0)) {
608 608
 			// no payments made yet
609
-			$this->_template_args['amount_due_class'] =  'txn-overview-no-payment-spn';
610
-		} elseif ( $this->_transaction->get('TXN_total') == 0 ) {
609
+			$this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn';
610
+		} elseif ($this->_transaction->get('TXN_total') == 0) {
611 611
 			// free event
612
-			$this->_template_args['amount_due'] =  FALSE;
612
+			$this->_template_args['amount_due'] = FALSE;
613 613
 		}
614 614
 
615 615
 		$payment_method = $this->_transaction->payment_method();
616 616
 
617 617
 		$this->_template_args['method_of_payment_name'] = $payment_method instanceof EE_Payment_Method
618 618
 			? $payment_method->admin_name()
619
-			: esc_html__( 'Unknown', 'event_espresso' );
619
+			: esc_html__('Unknown', 'event_espresso');
620 620
 
621 621
 		$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
622 622
 		// link back to overview
623
-		$this->_template_args['txn_overview_url'] = ! empty ( $_SERVER['HTTP_REFERER'] )
623
+		$this->_template_args['txn_overview_url'] = ! empty ($_SERVER['HTTP_REFERER'])
624 624
 			? $_SERVER['HTTP_REFERER']
625 625
 			: TXN_ADMIN_URL;
626 626
 
@@ -628,13 +628,13 @@  discard block
 block discarded – undo
628 628
 		// next link
629 629
 		$next_txn = $this->_transaction->next(
630 630
 			null,
631
-			array( array( 'STS_ID' => array( '!=', EEM_Transaction::failed_status_code ) ) ),
631
+			array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))),
632 632
 			'TXN_ID'
633 633
 		);
634 634
 		$this->_template_args['next_transaction'] = $next_txn
635 635
 			? $this->_next_link(
636 636
 				EE_Admin_Page::add_query_args_and_nonce(
637
-					array( 'action' => 'view_transaction', 'TXN_ID' => $next_txn['TXN_ID'] ),
637
+					array('action' => 'view_transaction', 'TXN_ID' => $next_txn['TXN_ID']),
638 638
 					TXN_ADMIN_URL
639 639
 				),
640 640
 				'dashicons dashicons-arrow-right ee-icon-size-22'
@@ -643,13 +643,13 @@  discard block
 block discarded – undo
643 643
 		// previous link
644 644
 		$previous_txn = $this->_transaction->previous(
645 645
 			null,
646
-			array( array( 'STS_ID' => array( '!=', EEM_Transaction::failed_status_code ) ) ),
646
+			array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))),
647 647
 			'TXN_ID'
648 648
 		);
649 649
 		$this->_template_args['previous_transaction'] = $previous_txn
650 650
 			? $this->_previous_link(
651 651
 				EE_Admin_Page::add_query_args_and_nonce(
652
-					array( 'action' => 'view_transaction', 'TXN_ID' => $previous_txn['TXN_ID'] ),
652
+					array('action' => 'view_transaction', 'TXN_ID' => $previous_txn['TXN_ID']),
653 653
 					TXN_ADMIN_URL
654 654
 				),
655 655
 				'dashicons dashicons-arrow-left ee-icon-size-22'
@@ -659,16 +659,16 @@  discard block
 block discarded – undo
659 659
 		// were we just redirected here after adding a new registration ???
660 660
 		if (
661 661
 			isset(
662
-				$this->_req_data[ 'redirect_from' ],
663
-				$this->_req_data[ 'EVT_ID' ],
664
-				$this->_req_data[ 'event_name' ]
662
+				$this->_req_data['redirect_from'],
663
+				$this->_req_data['EVT_ID'],
664
+				$this->_req_data['event_name']
665 665
 			)
666 666
 		) {
667 667
 			if (
668 668
 				EE_Registry::instance()->CAP->current_user_can(
669 669
 					'ee_edit_registrations',
670 670
 					'espresso_registrations_new_registration',
671
-					$this->_req_data[ 'EVT_ID' ]
671
+					$this->_req_data['EVT_ID']
672 672
 				)
673 673
 			) {
674 674
 				$this->_admin_page_title .= '<a id="add-new-registration" class="add-new-h2 button-primary" href="';
@@ -678,25 +678,25 @@  discard block
 block discarded – undo
678 678
 						'action'   => 'new_registration',
679 679
 						'return'   => 'default',
680 680
 						'TXN_ID'   => $this->_transaction->ID(),
681
-						'event_id' => $this->_req_data[ 'EVT_ID' ],
681
+						'event_id' => $this->_req_data['EVT_ID'],
682 682
 					),
683 683
 					REG_ADMIN_URL
684 684
 				);
685 685
 				$this->_admin_page_title .= '">';
686 686
 
687 687
 				$this->_admin_page_title .= sprintf(
688
-					esc_html__('Add Another New Registration to Event: "%1$s" ?', 'event_espresso' ),
689
-					htmlentities( urldecode( $this->_req_data[ 'event_name' ] ), ENT_QUOTES, 'UTF-8' )
688
+					esc_html__('Add Another New Registration to Event: "%1$s" ?', 'event_espresso'),
689
+					htmlentities(urldecode($this->_req_data['event_name']), ENT_QUOTES, 'UTF-8')
690 690
 				);
691 691
 				$this->_admin_page_title .= '</a>';
692 692
 			}
693
-			EE_Registry::instance()->SSN->clear_session( __CLASS__, __FUNCTION__ );
693
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
694 694
 		}
695 695
 		// grab messages at the last second
696 696
 		$this->_template_args['notices'] = EE_Error::get_notices();
697 697
 		// path to template
698
-		$template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_header.template.php';
699
-		$this->_template_args['admin_page_header'] = EEH_Template::display_template( $template_path, $this->_template_args, TRUE );
698
+		$template_path = TXN_TEMPLATE_PATH.'txn_admin_details_header.template.php';
699
+		$this->_template_args['admin_page_header'] = EEH_Template::display_template($template_path, $this->_template_args, TRUE);
700 700
 
701 701
 		// the details template wrapper
702 702
 		$this->display_admin_page_with_sidebar();
@@ -715,18 +715,18 @@  discard block
 block discarded – undo
715 715
 
716 716
 		$this->_set_transaction_object();
717 717
 
718
-		add_meta_box( 'edit-txn-details-mbox', esc_html__( 'Transaction Details', 'event_espresso' ), array( $this, 'txn_details_meta_box' ), $this->_wp_page_slug, 'normal', 'high' );
718
+		add_meta_box('edit-txn-details-mbox', esc_html__('Transaction Details', 'event_espresso'), array($this, 'txn_details_meta_box'), $this->_wp_page_slug, 'normal', 'high');
719 719
 		add_meta_box(
720 720
 			'edit-txn-attendees-mbox',
721
-			esc_html__( 'Attendees Registered in this Transaction', 'event_espresso' ),
722
-			array( $this, 'txn_attendees_meta_box' ),
721
+			esc_html__('Attendees Registered in this Transaction', 'event_espresso'),
722
+			array($this, 'txn_attendees_meta_box'),
723 723
 			$this->_wp_page_slug,
724 724
 			'normal',
725 725
 			'high',
726
-			array( 'TXN_ID' => $this->_transaction->ID() )
726
+			array('TXN_ID' => $this->_transaction->ID())
727 727
 		);
728
-		add_meta_box( 'edit-txn-registrant-mbox', esc_html__( 'Primary Contact', 'event_espresso' ), array( $this, 'txn_registrant_side_meta_box' ), $this->_wp_page_slug, 'side', 'high' );
729
-		add_meta_box( 'edit-txn-billing-info-mbox', esc_html__( 'Billing Information', 'event_espresso' ), array( $this, 'txn_billing_info_side_meta_box' ), $this->_wp_page_slug, 'side', 'high' );
728
+		add_meta_box('edit-txn-registrant-mbox', esc_html__('Primary Contact', 'event_espresso'), array($this, 'txn_registrant_side_meta_box'), $this->_wp_page_slug, 'side', 'high');
729
+		add_meta_box('edit-txn-billing-info-mbox', esc_html__('Billing Information', 'event_espresso'), array($this, 'txn_billing_info_side_meta_box'), $this->_wp_page_slug, 'side', 'high');
730 730
 
731 731
 	}
732 732
 
@@ -747,15 +747,15 @@  discard block
 block discarded – undo
747 747
 
748 748
 		//get line table
749 749
 		EEH_Autoloader::register_line_item_display_autoloaders();
750
-		$Line_Item_Display = new EE_Line_Item_Display( 'admin_table', 'EE_Admin_Table_Line_Item_Display_Strategy' );
751
-		$this->_template_args['line_item_table'] = $Line_Item_Display->display_line_item( $this->_transaction->total_line_item() );
750
+		$Line_Item_Display = new EE_Line_Item_Display('admin_table', 'EE_Admin_Table_Line_Item_Display_Strategy');
751
+		$this->_template_args['line_item_table'] = $Line_Item_Display->display_line_item($this->_transaction->total_line_item());
752 752
 		$this->_template_args['REG_code'] = $this->_transaction->get_first_related('Registration')->get('REG_code');
753 753
 
754 754
 		// process taxes
755
-		$taxes = $this->_transaction->get_many_related( 'Line_Item', array( array( 'LIN_type' => EEM_Line_Item::type_tax )));
756
-		$this->_template_args['taxes'] = ! empty( $taxes ) ? $taxes : FALSE;
755
+		$taxes = $this->_transaction->get_many_related('Line_Item', array(array('LIN_type' => EEM_Line_Item::type_tax)));
756
+		$this->_template_args['taxes'] = ! empty($taxes) ? $taxes : FALSE;
757 757
 
758
-		$this->_template_args['grand_total'] = EEH_Template::format_currency($this->_transaction->get('TXN_total'), FALSE, FALSE );
758
+		$this->_template_args['grand_total'] = EEH_Template::format_currency($this->_transaction->get('TXN_total'), FALSE, FALSE);
759 759
 		$this->_template_args['grand_raw_total'] = $this->_transaction->get('TXN_total');
760 760
 		$this->_template_args['TXN_status'] = $this->_transaction->get('STS_ID');
761 761
 
@@ -763,63 +763,63 @@  discard block
 block discarded – undo
763 763
 
764 764
 		// process payment details
765 765
 		$payments = $this->_transaction->get_many_related('Payment');
766
-		if( ! empty(  $payments ) ) {
767
-			$this->_template_args[ 'payments' ] = $payments;
768
-			$this->_template_args[ 'existing_reg_payments' ] = $this->_get_registration_payment_IDs( $payments );
766
+		if ( ! empty($payments)) {
767
+			$this->_template_args['payments'] = $payments;
768
+			$this->_template_args['existing_reg_payments'] = $this->_get_registration_payment_IDs($payments);
769 769
 		} else {
770
-			$this->_template_args[ 'payments' ] = false;
771
-			$this->_template_args[ 'existing_reg_payments' ] = array();
770
+			$this->_template_args['payments'] = false;
771
+			$this->_template_args['existing_reg_payments'] = array();
772 772
 		}
773 773
 
774
-		$this->_template_args['edit_payment_url'] = add_query_arg( array( 'action' => 'edit_payment'  ), TXN_ADMIN_URL );
775
-		$this->_template_args['delete_payment_url'] = add_query_arg( array( 'action' => 'espresso_delete_payment' ), TXN_ADMIN_URL );
774
+		$this->_template_args['edit_payment_url'] = add_query_arg(array('action' => 'edit_payment'), TXN_ADMIN_URL);
775
+		$this->_template_args['delete_payment_url'] = add_query_arg(array('action' => 'espresso_delete_payment'), TXN_ADMIN_URL);
776 776
 
777
-		if ( isset( $txn_details['invoice_number'] )) {
777
+		if (isset($txn_details['invoice_number'])) {
778 778
 			$this->_template_args['txn_details']['invoice_number']['value'] = $this->_template_args['REG_code'];
779
-			$this->_template_args['txn_details']['invoice_number']['label'] = esc_html__( 'Invoice Number', 'event_espresso' );
779
+			$this->_template_args['txn_details']['invoice_number']['label'] = esc_html__('Invoice Number', 'event_espresso');
780 780
 		}
781 781
 
782 782
 		$this->_template_args['txn_details']['registration_session']['value'] = $this->_transaction->get_first_related('Registration')->get('REG_session');
783
-		$this->_template_args['txn_details']['registration_session']['label'] = esc_html__( 'Registration Session', 'event_espresso' );
783
+		$this->_template_args['txn_details']['registration_session']['label'] = esc_html__('Registration Session', 'event_espresso');
784 784
 
785
-		$this->_template_args['txn_details']['ip_address']['value'] = isset( $this->_session['ip_address'] ) ? $this->_session['ip_address'] : '';
786
-		$this->_template_args['txn_details']['ip_address']['label'] = esc_html__( 'Transaction placed from IP', 'event_espresso' );
785
+		$this->_template_args['txn_details']['ip_address']['value'] = isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '';
786
+		$this->_template_args['txn_details']['ip_address']['label'] = esc_html__('Transaction placed from IP', 'event_espresso');
787 787
 
788
-		$this->_template_args['txn_details']['user_agent']['value'] = isset( $this->_session['user_agent'] ) ? $this->_session['user_agent'] : '';
789
-		$this->_template_args['txn_details']['user_agent']['label'] = esc_html__( 'Registrant User Agent', 'event_espresso' );
788
+		$this->_template_args['txn_details']['user_agent']['value'] = isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '';
789
+		$this->_template_args['txn_details']['user_agent']['label'] = esc_html__('Registrant User Agent', 'event_espresso');
790 790
 
791 791
 		$reg_steps = '<ul>';
792
-		foreach ( $this->_transaction->reg_steps() as $reg_step => $reg_step_status ) {
793
-			if ( $reg_step_status === true ) {
794
-				$reg_steps .= '<li style="color:#70cc50">' . sprintf( esc_html__( '%1$s : Completed', 'event_espresso' ), ucwords( str_replace( '_', ' ', $reg_step ) ) ) . '</li>';
795
-			} else if ( is_numeric( $reg_step_status ) && $reg_step_status !== false ) {
796
-					$reg_steps .= '<li style="color:#2EA2CC">' . sprintf(
797
-							esc_html__( '%1$s : Initiated %2$s', 'event_espresso' ),
798
-							ucwords( str_replace( '_', ' ', $reg_step ) ),
799
-							gmdate( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), ( $reg_step_status + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ) )
800
-						) . '</li>';
792
+		foreach ($this->_transaction->reg_steps() as $reg_step => $reg_step_status) {
793
+			if ($reg_step_status === true) {
794
+				$reg_steps .= '<li style="color:#70cc50">'.sprintf(esc_html__('%1$s : Completed', 'event_espresso'), ucwords(str_replace('_', ' ', $reg_step))).'</li>';
795
+			} else if (is_numeric($reg_step_status) && $reg_step_status !== false) {
796
+					$reg_steps .= '<li style="color:#2EA2CC">'.sprintf(
797
+							esc_html__('%1$s : Initiated %2$s', 'event_espresso'),
798
+							ucwords(str_replace('_', ' ', $reg_step)),
799
+							gmdate(get_option('date_format').' '.get_option('time_format'), ($reg_step_status + (get_option('gmt_offset') * HOUR_IN_SECONDS)))
800
+						).'</li>';
801 801
 				} else {
802
-				$reg_steps .= '<li style="color:#E76700">' . sprintf( esc_html__( '%1$s : Never Initiated', 'event_espresso' ), ucwords( str_replace( '_', ' ', $reg_step ) ) ) . '</li>';
802
+				$reg_steps .= '<li style="color:#E76700">'.sprintf(esc_html__('%1$s : Never Initiated', 'event_espresso'), ucwords(str_replace('_', ' ', $reg_step))).'</li>';
803 803
 			}
804 804
 		}
805 805
 		$reg_steps .= '</ul>';
806 806
 		$this->_template_args['txn_details']['reg_steps']['value'] = $reg_steps;
807
-		$this->_template_args['txn_details']['reg_steps']['label'] = esc_html__( 'Registration Step Progress', 'event_espresso' );
807
+		$this->_template_args['txn_details']['reg_steps']['label'] = esc_html__('Registration Step Progress', 'event_espresso');
808 808
 
809 809
 
810 810
 		$this->_get_registrations_to_apply_payment_to();
811
-		$this->_get_payment_methods( $payments );
811
+		$this->_get_payment_methods($payments);
812 812
 		$this->_get_payment_status_array();
813 813
 		$this->_get_reg_status_selection(); //sets up the template args for the reg status array for the transaction.
814 814
 
815
-		$this->_template_args['transaction_form_url'] = add_query_arg( array( 'action' => 'edit_transaction', 'process' => 'transaction'  ), TXN_ADMIN_URL );
816
-		$this->_template_args['apply_payment_form_url'] = add_query_arg( array( 'page' => 'espresso_transactions', 'action' => 'espresso_apply_payment' ), WP_AJAX_URL );
817
-		$this->_template_args['delete_payment_form_url'] = add_query_arg( array( 'page' => 'espresso_transactions', 'action' => 'espresso_delete_payment' ), WP_AJAX_URL );
815
+		$this->_template_args['transaction_form_url'] = add_query_arg(array('action' => 'edit_transaction', 'process' => 'transaction'), TXN_ADMIN_URL);
816
+		$this->_template_args['apply_payment_form_url'] = add_query_arg(array('page' => 'espresso_transactions', 'action' => 'espresso_apply_payment'), WP_AJAX_URL);
817
+		$this->_template_args['delete_payment_form_url'] = add_query_arg(array('page' => 'espresso_transactions', 'action' => 'espresso_delete_payment'), WP_AJAX_URL);
818 818
 
819 819
 		// 'espresso_delete_payment_nonce'
820 820
 
821
-		$template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_txn_details.template.php';
822
-		echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE );
821
+		$template_path = TXN_TEMPLATE_PATH.'txn_admin_details_main_meta_box_txn_details.template.php';
822
+		echo EEH_Template::display_template($template_path, $this->_template_args, TRUE);
823 823
 
824 824
 	}
825 825
 
@@ -834,27 +834,27 @@  discard block
 block discarded – undo
834 834
 	 * @param EE_Payment[] $payments
835 835
 	 * @return array
836 836
 	 */
837
-	protected function _get_registration_payment_IDs( $payments = array() ) {
837
+	protected function _get_registration_payment_IDs($payments = array()) {
838 838
 		$existing_reg_payments = array();
839 839
 		// get all reg payments for these payments
840
-		$reg_payments = EEM_Registration_Payment::instance()->get_all( array(
840
+		$reg_payments = EEM_Registration_Payment::instance()->get_all(array(
841 841
 			array(
842 842
 				'PAY_ID' => array(
843 843
 					'IN',
844
-					array_keys( $payments )
844
+					array_keys($payments)
845 845
 				)
846 846
 			)
847
-		) );
848
-		if ( ! empty( $reg_payments ) ) {
849
-			foreach ( $payments as $payment ) {
850
-				if ( ! $payment instanceof EE_Payment ) {
847
+		));
848
+		if ( ! empty($reg_payments)) {
849
+			foreach ($payments as $payment) {
850
+				if ( ! $payment instanceof EE_Payment) {
851 851
 					continue;
852
-				} else if ( ! isset( $existing_reg_payments[ $payment->ID() ] ) ) {
853
-					$existing_reg_payments[ $payment->ID() ] = array();
852
+				} else if ( ! isset($existing_reg_payments[$payment->ID()])) {
853
+					$existing_reg_payments[$payment->ID()] = array();
854 854
 				}
855
-				foreach ( $reg_payments as $reg_payment ) {
856
-					if ( $reg_payment instanceof EE_Registration_Payment && $reg_payment->payment_ID() === $payment->ID() ) {
857
-						$existing_reg_payments[ $payment->ID() ][ ] = $reg_payment->registration_ID();
855
+				foreach ($reg_payments as $reg_payment) {
856
+					if ($reg_payment instanceof EE_Registration_Payment && $reg_payment->payment_ID() === $payment->ID()) {
857
+						$existing_reg_payments[$payment->ID()][] = $reg_payment->registration_ID();
858 858
 					}
859 859
 				}
860 860
 			}
@@ -887,54 +887,54 @@  discard block
 block discarded – undo
887 887
 				)
888 888
 			)
889 889
 		);
890
-		$registrations_to_apply_payment_to = EEH_HTML::br() . EEH_HTML::div(
890
+		$registrations_to_apply_payment_to = EEH_HTML::br().EEH_HTML::div(
891 891
 			'', 'txn-admin-apply-payment-to-registrations-dv', '', 'clear: both; margin: 1.5em 0 0; display: none;'
892 892
 		);
893
-		$registrations_to_apply_payment_to .= EEH_HTML::br() . EEH_HTML::div( '', '', 'admin-primary-mbox-tbl-wrap' );
894
-		$registrations_to_apply_payment_to .= EEH_HTML::table( '', '', 'admin-primary-mbox-tbl' );
893
+		$registrations_to_apply_payment_to .= EEH_HTML::br().EEH_HTML::div('', '', 'admin-primary-mbox-tbl-wrap');
894
+		$registrations_to_apply_payment_to .= EEH_HTML::table('', '', 'admin-primary-mbox-tbl');
895 895
 		$registrations_to_apply_payment_to .= EEH_HTML::thead(
896 896
 			EEH_HTML::tr(
897
-				EEH_HTML::th( esc_html__( 'ID', 'event_espresso' ) ) .
898
-				EEH_HTML::th( esc_html__( 'Registrant', 'event_espresso' ) ) .
899
-				EEH_HTML::th( esc_html__( 'Ticket', 'event_espresso' ) ) .
900
-				EEH_HTML::th( esc_html__( 'Event', 'event_espresso' ) ) .
901
-				EEH_HTML::th( esc_html__( 'Paid', 'event_espresso' ), '', 'txn-admin-payment-paid-td jst-cntr' ) .
902
-				EEH_HTML::th( esc_html__( 'Owing', 'event_espresso' ), '', 'txn-admin-payment-owing-td jst-cntr' ) .
903
-				EEH_HTML::th( esc_html__( 'Apply', 'event_espresso' ), '', 'jst-cntr' )
897
+				EEH_HTML::th(esc_html__('ID', 'event_espresso')).
898
+				EEH_HTML::th(esc_html__('Registrant', 'event_espresso')).
899
+				EEH_HTML::th(esc_html__('Ticket', 'event_espresso')).
900
+				EEH_HTML::th(esc_html__('Event', 'event_espresso')).
901
+				EEH_HTML::th(esc_html__('Paid', 'event_espresso'), '', 'txn-admin-payment-paid-td jst-cntr').
902
+				EEH_HTML::th(esc_html__('Owing', 'event_espresso'), '', 'txn-admin-payment-owing-td jst-cntr').
903
+				EEH_HTML::th(esc_html__('Apply', 'event_espresso'), '', 'jst-cntr')
904 904
 			)
905 905
 		);
906 906
 		$registrations_to_apply_payment_to .= EEH_HTML::tbody();
907 907
 		// get registrations for TXN
908
-		$registrations = $this->_transaction->registrations( $query_params );
909
-		foreach ( $registrations as $registration ) {
910
-			if ( $registration instanceof EE_Registration ) {
908
+		$registrations = $this->_transaction->registrations($query_params);
909
+		foreach ($registrations as $registration) {
910
+			if ($registration instanceof EE_Registration) {
911 911
 				$attendee_name = $registration->attendee() instanceof EE_Attendee
912 912
 					? $registration->attendee()->full_name()
913
-					: esc_html__( 'Unknown Attendee', 'event_espresso' );
913
+					: esc_html__('Unknown Attendee', 'event_espresso');
914 914
 				$owing = $registration->final_price() - $registration->paid();
915 915
 				$taxable = $registration->ticket()->taxable()
916
-					? ' <span class="smaller-text lt-grey-text"> ' . esc_html__( '+ tax', 'event_espresso' ) . '</span>'
916
+					? ' <span class="smaller-text lt-grey-text"> '.esc_html__('+ tax', 'event_espresso').'</span>'
917 917
 					: '';
918
-				$checked = empty( $existing_reg_payments ) || in_array( $registration->ID(), $existing_reg_payments )
918
+				$checked = empty($existing_reg_payments) || in_array($registration->ID(), $existing_reg_payments)
919 919
 					? ' checked="checked"'
920 920
 					: '';
921 921
 				$disabled = $registration->final_price() > 0 ? '' : ' disabled';
922 922
 				$registrations_to_apply_payment_to .= EEH_HTML::tr(
923
-					EEH_HTML::td( $registration->ID() ) .
924
-					EEH_HTML::td( $attendee_name ) .
923
+					EEH_HTML::td($registration->ID()).
924
+					EEH_HTML::td($attendee_name).
925 925
 					EEH_HTML::td(
926
-						$registration->ticket()->name() . ' : ' . $registration->ticket()->pretty_price() . $taxable
927
-					) .
928
-					EEH_HTML::td( $registration->event_name() ) .
929
-					EEH_HTML::td( $registration->pretty_paid(), '', 'txn-admin-payment-paid-td jst-cntr' ) .
930
-					EEH_HTML::td( EEH_Template::format_currency( $owing ), '', 'txn-admin-payment-owing-td jst-cntr' ) .
926
+						$registration->ticket()->name().' : '.$registration->ticket()->pretty_price().$taxable
927
+					).
928
+					EEH_HTML::td($registration->event_name()).
929
+					EEH_HTML::td($registration->pretty_paid(), '', 'txn-admin-payment-paid-td jst-cntr').
930
+					EEH_HTML::td(EEH_Template::format_currency($owing), '', 'txn-admin-payment-owing-td jst-cntr').
931 931
 					EEH_HTML::td(
932
-						'<input type="checkbox" value="' . $registration->ID()
932
+						'<input type="checkbox" value="'.$registration->ID()
933 933
 						. '" name="txn_admin_payment[registrations]"'
934
-						. $checked . $disabled . '>',
934
+						. $checked.$disabled.'>',
935 935
 						'', 'jst-cntr'
936 936
 					),
937
-					'apply-payment-registration-row-' . $registration->ID()
937
+					'apply-payment-registration-row-'.$registration->ID()
938 938
 				);
939 939
 			}
940 940
 		}
@@ -949,7 +949,7 @@  discard block
 block discarded – undo
949 949
 			'', 'clear description'
950 950
 		);
951 951
 		$registrations_to_apply_payment_to .= EEH_HTML::divx();
952
-		$this->_template_args[ 'registrations_to_apply_payment_to' ] = $registrations_to_apply_payment_to;
952
+		$this->_template_args['registrations_to_apply_payment_to'] = $registrations_to_apply_payment_to;
953 953
 	}
954 954
 
955 955
 
@@ -966,9 +966,9 @@  discard block
 block discarded – undo
966 966
 		$statuses = EEM_Registration::reg_status_array(array(), TRUE);
967 967
 		//let's add a "don't change" option.
968 968
 		$status_array['NAN'] = esc_html__('Leave the Same', 'event_espresso');
969
-		$status_array = array_merge( $status_array, $statuses );
970
-		$this->_template_args['status_change_select'] = EEH_Form_Fields::select_input( 'txn_reg_status_change[reg_status]', $status_array, 'NAN', 'id="txn-admin-payment-reg-status-inp"', 'txn-reg-status-change-reg-status' );
971
-		$this->_template_args['delete_status_change_select'] = EEH_Form_Fields::select_input( 'delete_txn_reg_status_change[reg_status]', $status_array, 'NAN', 'delete-txn-admin-payment-reg-status-inp', 'delete-txn-reg-status-change-reg-status' );
969
+		$status_array = array_merge($status_array, $statuses);
970
+		$this->_template_args['status_change_select'] = EEH_Form_Fields::select_input('txn_reg_status_change[reg_status]', $status_array, 'NAN', 'id="txn-admin-payment-reg-status-inp"', 'txn-reg-status-change-reg-status');
971
+		$this->_template_args['delete_status_change_select'] = EEH_Form_Fields::select_input('delete_txn_reg_status_change[reg_status]', $status_array, 'NAN', 'delete-txn-admin-payment-reg-status-inp', 'delete-txn-reg-status-change-reg-status');
972 972
 
973 973
 	}
974 974
 
@@ -983,21 +983,21 @@  discard block
 block discarded – undo
983 983
 	 * @param EE_Payment[] to show on this page
984 984
 	 *	@return void
985 985
 	 */
986
-	private function _get_payment_methods( $payments = array() ) {
986
+	private function _get_payment_methods($payments = array()) {
987 987
 		$payment_methods_of_payments = array();
988
-		foreach( $payments as $payment ){
989
-			if( $payment instanceof EE_Payment ){
990
-				$payment_methods_of_payments[] = $payment->get( 'PMD_ID' );
988
+		foreach ($payments as $payment) {
989
+			if ($payment instanceof EE_Payment) {
990
+				$payment_methods_of_payments[] = $payment->get('PMD_ID');
991 991
 			}
992 992
 		}
993
-		if( $payment_methods_of_payments ){
994
-			$query_args = array( array( 'OR*payment_method_for_payment' => array(
995
-					'PMD_ID' => array( 'IN', $payment_methods_of_payments ),
996
-					'PMD_scope' => array( 'LIKE', '%' . EEM_Payment_Method::scope_admin . '%' ) ) ) );
997
-		}else{
998
-			$query_args = array( array( 'PMD_scope' => array( 'LIKE', '%' . EEM_Payment_Method::scope_admin . '%' ) ) );
993
+		if ($payment_methods_of_payments) {
994
+			$query_args = array(array('OR*payment_method_for_payment' => array(
995
+					'PMD_ID' => array('IN', $payment_methods_of_payments),
996
+					'PMD_scope' => array('LIKE', '%'.EEM_Payment_Method::scope_admin.'%') )));
997
+		} else {
998
+			$query_args = array(array('PMD_scope' => array('LIKE', '%'.EEM_Payment_Method::scope_admin.'%')));
999 999
 		}
1000
-		$this->_template_args['payment_methods'] = EEM_Payment_Method::instance()->get_all( $query_args );
1000
+		$this->_template_args['payment_methods'] = EEM_Payment_Method::instance()->get_all($query_args);
1001 1001
 	}
1002 1002
 
1003 1003
 
@@ -1011,17 +1011,17 @@  discard block
 block discarded – undo
1011 1011
 	 * @param array $metabox
1012 1012
 	 * @return void
1013 1013
 	 */
1014
-	public function txn_attendees_meta_box( $post, $metabox = array( 'args' => array() )) {
1014
+	public function txn_attendees_meta_box($post, $metabox = array('args' => array())) {
1015 1015
 
1016
-		extract( $metabox['args'] );
1016
+		extract($metabox['args']);
1017 1017
 		$this->_template_args['post'] = $post;
1018 1018
 		$this->_template_args['event_attendees'] = array();
1019 1019
 		// process items in cart
1020
-		$line_items = $this->_transaction->get_many_related('Line_Item', array( array( 'LIN_type' => 'line-item' ) ) );
1021
-		if ( ! empty( $line_items )) {
1022
-			foreach ( $line_items as $item ) {
1023
-				if ( $item instanceof EE_Line_Item ) {
1024
-					switch( $item->OBJ_type() ) {
1020
+		$line_items = $this->_transaction->get_many_related('Line_Item', array(array('LIN_type' => 'line-item')));
1021
+		if ( ! empty($line_items)) {
1022
+			foreach ($line_items as $item) {
1023
+				if ($item instanceof EE_Line_Item) {
1024
+					switch ($item->OBJ_type()) {
1025 1025
 
1026 1026
 						case 'Event' :
1027 1027
 							break;
@@ -1029,39 +1029,39 @@  discard block
 block discarded – undo
1029 1029
 						case 'Ticket' :
1030 1030
 							$ticket = $item->ticket();
1031 1031
 							//right now we're only handling tickets here.  Cause its expected that only tickets will have attendees right?
1032
-							if ( ! $ticket instanceof EE_Ticket ) {
1032
+							if ( ! $ticket instanceof EE_Ticket) {
1033 1033
 								continue;
1034 1034
 							}
1035 1035
 							try {
1036 1036
 								$event_name = $ticket->get_event_name();
1037
-							} catch ( Exception $e ) {
1038
-								EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ );
1039
-								$event_name = esc_html__( 'Unknown Event', 'event_espresso' );
1037
+							} catch (Exception $e) {
1038
+								EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1039
+								$event_name = esc_html__('Unknown Event', 'event_espresso');
1040 1040
 							}
1041
-							$event_name .= ' - ' . $item->get( 'LIN_name' );
1042
-							$ticket_price = EEH_Template::format_currency( $item->get( 'LIN_unit_price' ) );
1041
+							$event_name .= ' - '.$item->get('LIN_name');
1042
+							$ticket_price = EEH_Template::format_currency($item->get('LIN_unit_price'));
1043 1043
 							// now get all of the registrations for this transaction that use this ticket
1044
-							$registrations = $ticket->get_many_related('Registration', array( array('TXN_ID' => $this->_transaction->ID() )));
1045
-							foreach( $registrations as $registration ) {
1046
-								if ( ! $registration instanceof EE_Registration ) {
1044
+							$registrations = $ticket->get_many_related('Registration', array(array('TXN_ID' => $this->_transaction->ID())));
1045
+							foreach ($registrations as $registration) {
1046
+								if ( ! $registration instanceof EE_Registration) {
1047 1047
 									continue;
1048 1048
 								}
1049
-								$this->_template_args['event_attendees'][$registration->ID()]['STS_ID'] 			= $registration->status_ID();
1050
-								$this->_template_args['event_attendees'][$registration->ID()]['att_num'] 			= $registration->count();
1051
-								$this->_template_args['event_attendees'][$registration->ID()]['event_ticket_name'] 	= $event_name;
1052
-								$this->_template_args['event_attendees'][$registration->ID()]['ticket_price'] 		= $ticket_price;
1049
+								$this->_template_args['event_attendees'][$registration->ID()]['STS_ID'] = $registration->status_ID();
1050
+								$this->_template_args['event_attendees'][$registration->ID()]['att_num'] = $registration->count();
1051
+								$this->_template_args['event_attendees'][$registration->ID()]['event_ticket_name'] = $event_name;
1052
+								$this->_template_args['event_attendees'][$registration->ID()]['ticket_price'] = $ticket_price;
1053 1053
 								// attendee info
1054 1054
 								$attendee = $registration->get_first_related('Attendee');
1055
-								if ( $attendee instanceof EE_Attendee ) {
1056
-									$this->_template_args['event_attendees'][$registration->ID()]['att_id'] 	= $attendee->ID();
1057
-									$this->_template_args['event_attendees'][$registration->ID()]['attendee'] 	= $attendee->full_name();
1058
-									$this->_template_args['event_attendees'][$registration->ID()]['email']		= '<a href="mailto:' . $attendee->email() . '?subject=' . $event_name . esc_html__(' Event', 'event_espresso') . '">' . $attendee->email() . '</a>';
1059
-									$this->_template_args['event_attendees'][$registration->ID()]['address'] 	= EEH_Address::format( $attendee, 'inline', false, false );
1055
+								if ($attendee instanceof EE_Attendee) {
1056
+									$this->_template_args['event_attendees'][$registration->ID()]['att_id'] = $attendee->ID();
1057
+									$this->_template_args['event_attendees'][$registration->ID()]['attendee'] = $attendee->full_name();
1058
+									$this->_template_args['event_attendees'][$registration->ID()]['email'] = '<a href="mailto:'.$attendee->email().'?subject='.$event_name.esc_html__(' Event', 'event_espresso').'">'.$attendee->email().'</a>';
1059
+									$this->_template_args['event_attendees'][$registration->ID()]['address'] = EEH_Address::format($attendee, 'inline', false, false);
1060 1060
 								} else {
1061 1061
 									$this->_template_args['event_attendees'][$registration->ID()]['att_id'] 	= '';
1062
-									$this->_template_args['event_attendees'][$registration->ID()]['attendee'] 	= '';
1062
+									$this->_template_args['event_attendees'][$registration->ID()]['attendee'] = '';
1063 1063
 									$this->_template_args['event_attendees'][$registration->ID()]['email'] 		= '';
1064
-									$this->_template_args['event_attendees'][$registration->ID()]['address'] 	= '';
1064
+									$this->_template_args['event_attendees'][$registration->ID()]['address'] = '';
1065 1065
 								}
1066 1066
 							}
1067 1067
 							break;
@@ -1070,12 +1070,12 @@  discard block
 block discarded – undo
1070 1070
 				}
1071 1071
 			}
1072 1072
 
1073
-			$this->_template_args['transaction_form_url'] = add_query_arg( array( 'action' => 'edit_transaction', 'process' => 'attendees'  ), TXN_ADMIN_URL );
1074
-			echo EEH_Template::display_template( TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_attendees.template.php', $this->_template_args, TRUE );
1073
+			$this->_template_args['transaction_form_url'] = add_query_arg(array('action' => 'edit_transaction', 'process' => 'attendees'), TXN_ADMIN_URL);
1074
+			echo EEH_Template::display_template(TXN_TEMPLATE_PATH.'txn_admin_details_main_meta_box_attendees.template.php', $this->_template_args, TRUE);
1075 1075
 
1076 1076
 		} else {
1077 1077
 			echo sprintf(
1078
-				esc_html__( '%1$sFor some reason, there are no attendees registered for this transaction. Likely the registration was abandoned in process.%2$s', 'event_espresso' ),
1078
+				esc_html__('%1$sFor some reason, there are no attendees registered for this transaction. Likely the registration was abandoned in process.%2$s', 'event_espresso'),
1079 1079
 				'<p class="important-notice">',
1080 1080
 				'</p>'
1081 1081
 			);
@@ -1094,19 +1094,19 @@  discard block
 block discarded – undo
1094 1094
 	 */
1095 1095
 	public function txn_registrant_side_meta_box() {
1096 1096
 		$primary_att = $this->_transaction->primary_registration() instanceof EE_Registration ? $this->_transaction->primary_registration()->get_first_related('Attendee') : null;
1097
-		if ( ! $primary_att instanceof EE_Attendee ) {
1097
+		if ( ! $primary_att instanceof EE_Attendee) {
1098 1098
 			$this->_template_args['no_attendee_message'] = esc_html__('There is no attached contact for this transaction.  The transaction either failed due to an error or was abandoned.', 'event_espresso');
1099 1099
 			$primary_att = EEM_Attendee::instance()->create_default_object();
1100 1100
 		}
1101
-		$this->_template_args['ATT_ID'] 						= $primary_att->ID();
1101
+		$this->_template_args['ATT_ID'] = $primary_att->ID();
1102 1102
 		$this->_template_args['prime_reg_fname']		= $primary_att->fname();
1103 1103
 		$this->_template_args['prime_reg_lname']		= $primary_att->lname();
1104
-		$this->_template_args['prime_reg_email'] 		= $primary_att->email();
1104
+		$this->_template_args['prime_reg_email'] = $primary_att->email();
1105 1105
 		$this->_template_args['prime_reg_phone'] 	= $primary_att->phone();
1106
-		$this->_template_args['edit_attendee_url'] 	= EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'edit_attendee', 'post' => $primary_att->ID()  ), REG_ADMIN_URL );
1106
+		$this->_template_args['edit_attendee_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit_attendee', 'post' => $primary_att->ID()), REG_ADMIN_URL);
1107 1107
 		// get formatted address for registrant
1108
-		$this->_template_args[ 'formatted_address' ] = EEH_Address::format( $primary_att );
1109
-		echo EEH_Template::display_template( TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_registrant.template.php', $this->_template_args, TRUE );
1108
+		$this->_template_args['formatted_address'] = EEH_Address::format($primary_att);
1109
+		echo EEH_Template::display_template(TXN_TEMPLATE_PATH.'txn_admin_details_side_meta_box_registrant.template.php', $this->_template_args, TRUE);
1110 1110
 	}
1111 1111
 
1112 1112
 
@@ -1122,12 +1122,12 @@  discard block
 block discarded – undo
1122 1122
 
1123 1123
 		$this->_template_args['billing_form'] = $this->_transaction->billing_info();
1124 1124
 		$this->_template_args['billing_form_url'] = add_query_arg(
1125
-			array( 'action' => 'edit_transaction', 'process' => 'billing'  ),
1125
+			array('action' => 'edit_transaction', 'process' => 'billing'),
1126 1126
 			TXN_ADMIN_URL
1127 1127
 		);
1128 1128
 
1129
-		$template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_billing_info.template.php';
1130
-		echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE );/**/
1129
+		$template_path = TXN_TEMPLATE_PATH.'txn_admin_details_side_meta_box_billing_info.template.php';
1130
+		echo EEH_Template::display_template($template_path, $this->_template_args, TRUE); /**/
1131 1131
 	}
1132 1132
 
1133 1133
 
@@ -1140,42 +1140,42 @@  discard block
 block discarded – undo
1140 1140
 	*	@return void
1141 1141
 	*/
1142 1142
 	public function apply_payments_or_refunds() {
1143
-		$json_response_data = array( 'return_data' => FALSE );
1143
+		$json_response_data = array('return_data' => FALSE);
1144 1144
 		$valid_data = $this->_validate_payment_request_data();
1145
-		if ( ! empty( $valid_data ) ) {
1146
-			$PAY_ID = $valid_data[ 'PAY_ID' ];
1145
+		if ( ! empty($valid_data)) {
1146
+			$PAY_ID = $valid_data['PAY_ID'];
1147 1147
 			//save  the new payment
1148
-			$payment = $this->_create_payment_from_request_data( $valid_data );
1148
+			$payment = $this->_create_payment_from_request_data($valid_data);
1149 1149
 			// get the TXN for this payment
1150 1150
 			$transaction = $payment->transaction();
1151 1151
 			// verify transaction
1152
-			if ( $transaction instanceof EE_Transaction ) {
1152
+			if ($transaction instanceof EE_Transaction) {
1153 1153
 				// calculate_total_payments_and_update_status
1154
-				$this->_process_transaction_payments( $transaction );
1155
-				$REG_IDs = $this->_get_REG_IDs_to_apply_payment_to( $payment );
1156
-				$this->_remove_existing_registration_payments( $payment, $PAY_ID );
1154
+				$this->_process_transaction_payments($transaction);
1155
+				$REG_IDs = $this->_get_REG_IDs_to_apply_payment_to($payment);
1156
+				$this->_remove_existing_registration_payments($payment, $PAY_ID);
1157 1157
 				// apply payment to registrations (if applicable)
1158
-				if ( ! empty( $REG_IDs ) ) {
1159
-					$this->_update_registration_payments( $transaction, $payment, $REG_IDs );
1158
+				if ( ! empty($REG_IDs)) {
1159
+					$this->_update_registration_payments($transaction, $payment, $REG_IDs);
1160 1160
 					$this->_maybe_send_notifications();
1161 1161
 					// now process status changes for the same registrations
1162
-					$this->_process_registration_status_change( $transaction, $REG_IDs );
1162
+					$this->_process_registration_status_change($transaction, $REG_IDs);
1163 1163
 				}
1164
-				$this->_maybe_send_notifications( $payment );
1164
+				$this->_maybe_send_notifications($payment);
1165 1165
 				//prepare to render page
1166
-				$json_response_data[ 'return_data' ] = $this->_build_payment_json_response( $payment, $REG_IDs );
1167
-				do_action( 'AHEE__Transactions_Admin_Page__apply_payments_or_refund__after_recording', $transaction, $payment );
1166
+				$json_response_data['return_data'] = $this->_build_payment_json_response($payment, $REG_IDs);
1167
+				do_action('AHEE__Transactions_Admin_Page__apply_payments_or_refund__after_recording', $transaction, $payment);
1168 1168
 			} else {
1169 1169
 				EE_Error::add_error(
1170
-					esc_html__( 'A valid Transaction for this payment could not be retrieved.', 'event_espresso' ),
1170
+					esc_html__('A valid Transaction for this payment could not be retrieved.', 'event_espresso'),
1171 1171
 					__FILE__, __FUNCTION__, __LINE__
1172 1172
 				);
1173 1173
 			}
1174 1174
 		} else {
1175
-			EE_Error::add_error( esc_html__( 'The payment form data could not be processed. Please try again.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
1175
+			EE_Error::add_error(esc_html__('The payment form data could not be processed. Please try again.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1176 1176
 		}
1177 1177
 
1178
-		$notices = EE_Error::get_notices( false, false, false );
1178
+		$notices = EE_Error::get_notices(false, false, false);
1179 1179
 		$this->_template_args = array(
1180 1180
 			'data' => $json_response_data,
1181 1181
 			'error' => $notices['errors'],
@@ -1192,30 +1192,30 @@  discard block
 block discarded – undo
1192 1192
 	 * @return array
1193 1193
 	 */
1194 1194
 	protected function _validate_payment_request_data() {
1195
-		if ( ! isset( $this->_req_data[ 'txn_admin_payment' ] ) ) {
1195
+		if ( ! isset($this->_req_data['txn_admin_payment'])) {
1196 1196
 			return false;
1197 1197
 		}
1198 1198
 		$payment_form = $this->_generate_payment_form_section();
1199 1199
 		try {
1200
-			if ( $payment_form->was_submitted() ) {
1200
+			if ($payment_form->was_submitted()) {
1201 1201
 				$payment_form->receive_form_submission();
1202
-				if ( ! $payment_form->is_valid() ) {
1202
+				if ( ! $payment_form->is_valid()) {
1203 1203
 					$submission_error_messages = array();
1204
-					foreach ( $payment_form->get_validation_errors_accumulated() as $validation_error ) {
1205
-						if ( $validation_error instanceof EE_Validation_Error ) {
1204
+					foreach ($payment_form->get_validation_errors_accumulated() as $validation_error) {
1205
+						if ($validation_error instanceof EE_Validation_Error) {
1206 1206
 							$submission_error_messages[] = sprintf(
1207
-								_x( '%s : %s', 'Form Section Name : Form Validation Error', 'event_espresso' ),
1207
+								_x('%s : %s', 'Form Section Name : Form Validation Error', 'event_espresso'),
1208 1208
 								$validation_error->get_form_section()->html_label_text(),
1209 1209
 								$validation_error->getMessage()
1210 1210
 							);
1211 1211
 						}
1212 1212
 					}
1213
-					EE_Error::add_error( join( '<br />', $submission_error_messages ), __FILE__, __FUNCTION__, __LINE__ );
1213
+					EE_Error::add_error(join('<br />', $submission_error_messages), __FILE__, __FUNCTION__, __LINE__);
1214 1214
 					return array();
1215 1215
 				}
1216 1216
 			}
1217
-		} catch ( EE_Error $e ) {
1218
-			EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ );
1217
+		} catch (EE_Error $e) {
1218
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1219 1219
 			return array();
1220 1220
 		}
1221 1221
 		return $payment_form->valid_data();
@@ -1237,63 +1237,63 @@  discard block
 block discarded – undo
1237 1237
 						array(
1238 1238
 							'default' => 0,
1239 1239
 							'required' => false,
1240
-							'html_label_text' => esc_html__( 'Payment ID', 'event_espresso' ),
1241
-							'validation_strategies' => array( new EE_Int_Normalization() )
1240
+							'html_label_text' => esc_html__('Payment ID', 'event_espresso'),
1241
+							'validation_strategies' => array(new EE_Int_Normalization())
1242 1242
 						)
1243 1243
 					),
1244 1244
 					'TXN_ID' => new EE_Text_Input(
1245 1245
 						array(
1246 1246
 							'default' => 0,
1247 1247
 							'required' => true,
1248
-							'html_label_text' => esc_html__( 'Transaction ID', 'event_espresso' ),
1249
-							'validation_strategies' => array( new EE_Int_Normalization() )
1248
+							'html_label_text' => esc_html__('Transaction ID', 'event_espresso'),
1249
+							'validation_strategies' => array(new EE_Int_Normalization())
1250 1250
 						)
1251 1251
 					),
1252 1252
 					'type' => new EE_Text_Input(
1253 1253
 						array(
1254 1254
 							'default' => 1,
1255 1255
 							'required' => true,
1256
-							'html_label_text' => esc_html__( 'Payment or Refund', 'event_espresso' ),
1257
-							'validation_strategies' => array( new EE_Int_Normalization() )
1256
+							'html_label_text' => esc_html__('Payment or Refund', 'event_espresso'),
1257
+							'validation_strategies' => array(new EE_Int_Normalization())
1258 1258
 						)
1259 1259
 					),
1260 1260
 					'amount' => new EE_Text_Input(
1261 1261
 						array(
1262 1262
 							'default' => 0,
1263 1263
 							'required' => true,
1264
-							'html_label_text' => esc_html__( 'Payment amount', 'event_espresso' ),
1265
-							'validation_strategies' => array( new EE_Float_Normalization() )
1264
+							'html_label_text' => esc_html__('Payment amount', 'event_espresso'),
1265
+							'validation_strategies' => array(new EE_Float_Normalization())
1266 1266
 						)
1267 1267
 					),
1268 1268
 					'status' => new EE_Text_Input(
1269 1269
 						array(
1270 1270
 							'default' => EEM_Payment::status_id_approved,
1271 1271
 							'required' => true,
1272
-							'html_label_text' => esc_html__( 'Payment status', 'event_espresso' ),
1272
+							'html_label_text' => esc_html__('Payment status', 'event_espresso'),
1273 1273
 						)
1274 1274
 					),
1275 1275
 					'PMD_ID' => new EE_Text_Input(
1276 1276
 						array(
1277 1277
 							'default' => 2,
1278 1278
 							'required' => true,
1279
-							'html_label_text' => esc_html__( 'Payment Method', 'event_espresso' ),
1280
-							'validation_strategies' => array( new EE_Int_Normalization() )
1279
+							'html_label_text' => esc_html__('Payment Method', 'event_espresso'),
1280
+							'validation_strategies' => array(new EE_Int_Normalization())
1281 1281
 						)
1282 1282
 					),
1283 1283
 					'date' => new EE_Text_Input(
1284 1284
 						array(
1285 1285
 							'default' => time(),
1286 1286
 							'required' => true,
1287
-							'html_label_text' => esc_html__( 'Payment date', 'event_espresso' ),
1287
+							'html_label_text' => esc_html__('Payment date', 'event_espresso'),
1288 1288
 						)
1289 1289
 					),
1290 1290
 					'txn_id_chq_nmbr' => new EE_Text_Input(
1291 1291
 						array(
1292 1292
 							'default' => '',
1293 1293
 							'required' => false,
1294
-							'html_label_text' => esc_html__( 'Transaction or Cheque Number', 'event_espresso' ),
1294
+							'html_label_text' => esc_html__('Transaction or Cheque Number', 'event_espresso'),
1295 1295
                                                         'validation_strategies' => array(
1296
-                                                            new EE_Max_Length_Validation_Strategy( esc_html__('Input too long', 'event_espresso'), 100 ),
1296
+                                                            new EE_Max_Length_Validation_Strategy(esc_html__('Input too long', 'event_espresso'), 100),
1297 1297
                                                         )
1298 1298
 						)
1299 1299
 					),
@@ -1301,9 +1301,9 @@  discard block
 block discarded – undo
1301 1301
 						array(
1302 1302
 							'default' => '',
1303 1303
 							'required' => false,
1304
-							'html_label_text' => esc_html__( 'Purchase Order Number', 'event_espresso' ),
1304
+							'html_label_text' => esc_html__('Purchase Order Number', 'event_espresso'),
1305 1305
                                                         'validation_strategies' => array(
1306
-                                                            new EE_Max_Length_Validation_Strategy( esc_html__('Input too long', 'event_espresso'), 100 ),
1306
+                                                            new EE_Max_Length_Validation_Strategy(esc_html__('Input too long', 'event_espresso'), 100),
1307 1307
                                                         )
1308 1308
 						)
1309 1309
 					),
@@ -1311,9 +1311,9 @@  discard block
 block discarded – undo
1311 1311
 						array(
1312 1312
 							'default' => '',
1313 1313
 							'required' => false,
1314
-							'html_label_text' => esc_html__( 'Extra Field for Accounting', 'event_espresso' ),
1314
+							'html_label_text' => esc_html__('Extra Field for Accounting', 'event_espresso'),
1315 1315
                                                         'validation_strategies' => array(
1316
-                                                            new EE_Max_Length_Validation_Strategy( esc_html__('Input too long', 'event_espresso'), 100 ),
1316
+                                                            new EE_Max_Length_Validation_Strategy(esc_html__('Input too long', 'event_espresso'), 100),
1317 1317
                                                         )
1318 1318
 						)
1319 1319
 					),
@@ -1330,37 +1330,37 @@  discard block
 block discarded – undo
1330 1330
 	 * @param array $valid_data
1331 1331
 	 * @return EE_Payment
1332 1332
 	 */
1333
-	protected function _create_payment_from_request_data( $valid_data ) {
1334
-		$PAY_ID = $valid_data[ 'PAY_ID' ];
1333
+	protected function _create_payment_from_request_data($valid_data) {
1334
+		$PAY_ID = $valid_data['PAY_ID'];
1335 1335
 		// get payment amount
1336
-		$amount = $valid_data[ 'amount' ] ? abs( $valid_data[ 'amount' ] ) : 0;
1336
+		$amount = $valid_data['amount'] ? abs($valid_data['amount']) : 0;
1337 1337
 		// payments have a type value of 1 and refunds have a type value of -1
1338 1338
 		// so multiplying amount by type will give a positive value for payments, and negative values for refunds
1339
-		$amount = $valid_data[ 'type' ] < 0 ? $amount * -1 : $amount;
1339
+		$amount = $valid_data['type'] < 0 ? $amount * -1 : $amount;
1340 1340
 		// for some reason the date string coming in has extra spaces between the date and time.  This fixes that.
1341
-		$date = $valid_data['date'] ? preg_replace( '/\s+/', ' ', $valid_data['date'] ) : date( 'Y-m-d g:i a', current_time( 'timestamp' ) );
1341
+		$date = $valid_data['date'] ? preg_replace('/\s+/', ' ', $valid_data['date']) : date('Y-m-d g:i a', current_time('timestamp'));
1342 1342
 		$payment = EE_Payment::new_instance(
1343 1343
 			array(
1344
-				'TXN_ID' 								=> $valid_data[ 'TXN_ID' ],
1345
-				'STS_ID' 								=> $valid_data[ 'status' ],
1344
+				'TXN_ID' 								=> $valid_data['TXN_ID'],
1345
+				'STS_ID' 								=> $valid_data['status'],
1346 1346
 				'PAY_timestamp' 				=> $date,
1347 1347
 				'PAY_source'           			=> EEM_Payment_Method::scope_admin,
1348
-				'PMD_ID'               				=> $valid_data[ 'PMD_ID' ],
1348
+				'PMD_ID'               				=> $valid_data['PMD_ID'],
1349 1349
 				'PAY_amount'           			=> $amount,
1350
-				'PAY_txn_id_chq_nmbr'  	=> $valid_data[ 'txn_id_chq_nmbr' ],
1351
-				'PAY_po_number'        		=> $valid_data[ 'po_number' ],
1352
-				'PAY_extra_accntng'    		=> $valid_data[ 'accounting' ],
1350
+				'PAY_txn_id_chq_nmbr'  	=> $valid_data['txn_id_chq_nmbr'],
1351
+				'PAY_po_number'        		=> $valid_data['po_number'],
1352
+				'PAY_extra_accntng'    		=> $valid_data['accounting'],
1353 1353
 				'PAY_details'          				=> $valid_data,
1354 1354
 				'PAY_ID'               				=> $PAY_ID
1355 1355
 			),
1356 1356
 			'',
1357
-			array( 'Y-m-d', 'g:i a' )
1357
+			array('Y-m-d', 'g:i a')
1358 1358
 		);
1359 1359
 
1360
-		if ( ! $payment->save() ) {
1360
+		if ( ! $payment->save()) {
1361 1361
 			EE_Error::add_error(
1362 1362
 				sprintf(
1363
-					esc_html__( 'Payment %1$d has not been successfully saved to the database.', 'event_espresso' ),
1363
+					esc_html__('Payment %1$d has not been successfully saved to the database.', 'event_espresso'),
1364 1364
 					$payment->ID()
1365 1365
 				),
1366 1366
 				__FILE__, __FUNCTION__, __LINE__
@@ -1377,15 +1377,15 @@  discard block
 block discarded – undo
1377 1377
 	 * @param \EE_Transaction $transaction
1378 1378
 	 * @return array
1379 1379
 	 */
1380
-	protected function _process_transaction_payments( EE_Transaction $transaction ) {
1380
+	protected function _process_transaction_payments(EE_Transaction $transaction) {
1381 1381
 		/** @type EE_Transaction_Payments $transaction_payments */
1382
-		$transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' );
1382
+		$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
1383 1383
 		//update the transaction with this payment
1384
-		if ( $transaction_payments->calculate_total_payments_and_update_status( $transaction ) ) {
1385
-			EE_Error::add_success( esc_html__( 'The payment has been processed successfully.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
1384
+		if ($transaction_payments->calculate_total_payments_and_update_status($transaction)) {
1385
+			EE_Error::add_success(esc_html__('The payment has been processed successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1386 1386
 		} else {
1387 1387
 			EE_Error::add_error(
1388
-				esc_html__( 'The payment was processed successfully but the amount paid for the transaction was not updated.', 'event_espresso' )
1388
+				esc_html__('The payment was processed successfully but the amount paid for the transaction was not updated.', 'event_espresso')
1389 1389
 				, __FILE__, __FUNCTION__, __LINE__
1390 1390
 			);
1391 1391
 		}
@@ -1401,19 +1401,19 @@  discard block
 block discarded – undo
1401 1401
 	 * @param \EE_Payment $payment
1402 1402
 	 * @return array
1403 1403
 	 */
1404
-	protected function _get_REG_IDs_to_apply_payment_to( EE_Payment $payment ) {
1404
+	protected function _get_REG_IDs_to_apply_payment_to(EE_Payment $payment) {
1405 1405
 		$REG_IDs = array();
1406 1406
 		// grab array of IDs for specific registrations to apply changes to
1407
-		if ( isset( $this->_req_data[ 'txn_admin_payment' ][ 'registrations' ] ) ) {
1408
-			$REG_IDs = (array)$this->_req_data[ 'txn_admin_payment' ][ 'registrations' ];
1407
+		if (isset($this->_req_data['txn_admin_payment']['registrations'])) {
1408
+			$REG_IDs = (array) $this->_req_data['txn_admin_payment']['registrations'];
1409 1409
 		}
1410 1410
 		//nothing specified ? then get all reg IDs
1411
-		if ( empty( $REG_IDs ) ) {
1411
+		if (empty($REG_IDs)) {
1412 1412
 			$registrations = $payment->transaction()->registrations();
1413
-			$REG_IDs = ! empty( $registrations ) ? array_keys( $registrations ) : $this->_get_existing_reg_payment_REG_IDs( $payment );
1413
+			$REG_IDs = ! empty($registrations) ? array_keys($registrations) : $this->_get_existing_reg_payment_REG_IDs($payment);
1414 1414
 		}
1415 1415
 		// ensure that REG_IDs are integers and NOT strings
1416
-		return array_map( 'intval', $REG_IDs );
1416
+		return array_map('intval', $REG_IDs);
1417 1417
 	}
1418 1418
 
1419 1419
 
@@ -1430,7 +1430,7 @@  discard block
 block discarded – undo
1430 1430
 	/**
1431 1431
 	 * @param array $existing_reg_payment_REG_IDs
1432 1432
 	 */
1433
-	public function set_existing_reg_payment_REG_IDs( $existing_reg_payment_REG_IDs = null ) {
1433
+	public function set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs = null) {
1434 1434
 		$this->_existing_reg_payment_REG_IDs = $existing_reg_payment_REG_IDs;
1435 1435
 	}
1436 1436
 
@@ -1445,13 +1445,13 @@  discard block
 block discarded – undo
1445 1445
 	 * @param \EE_Payment $payment
1446 1446
 	 * @return array
1447 1447
 	 */
1448
-	protected function _get_existing_reg_payment_REG_IDs( EE_Payment $payment ) {
1449
-		if ( $this->existing_reg_payment_REG_IDs() === null ) {
1448
+	protected function _get_existing_reg_payment_REG_IDs(EE_Payment $payment) {
1449
+		if ($this->existing_reg_payment_REG_IDs() === null) {
1450 1450
 			// let's get any existing reg payment records for this payment
1451
-			$existing_reg_payment_REG_IDs = $payment->get_many_related( 'Registration' );
1451
+			$existing_reg_payment_REG_IDs = $payment->get_many_related('Registration');
1452 1452
 			// but we only want the REG IDs, so grab the array keys
1453
-			$existing_reg_payment_REG_IDs = ! empty( $existing_reg_payment_REG_IDs ) ? array_keys( $existing_reg_payment_REG_IDs ) : array();
1454
-			$this->set_existing_reg_payment_REG_IDs( $existing_reg_payment_REG_IDs );
1453
+			$existing_reg_payment_REG_IDs = ! empty($existing_reg_payment_REG_IDs) ? array_keys($existing_reg_payment_REG_IDs) : array();
1454
+			$this->set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs);
1455 1455
 		}
1456 1456
 		return $this->existing_reg_payment_REG_IDs();
1457 1457
 	}
@@ -1470,23 +1470,23 @@  discard block
 block discarded – undo
1470 1470
 	 * @param int         $PAY_ID
1471 1471
 	 * @return bool;
1472 1472
 	 */
1473
-	protected function _remove_existing_registration_payments( EE_Payment $payment, $PAY_ID = 0 ) {
1473
+	protected function _remove_existing_registration_payments(EE_Payment $payment, $PAY_ID = 0) {
1474 1474
 		// newly created payments will have nothing recorded for $PAY_ID
1475
-		if ( $PAY_ID == 0 ) {
1475
+		if ($PAY_ID == 0) {
1476 1476
 			return false;
1477 1477
 		}
1478
-		$existing_reg_payment_REG_IDs = $this->_get_existing_reg_payment_REG_IDs( $payment );
1479
-		if ( empty( $existing_reg_payment_REG_IDs )) {
1478
+		$existing_reg_payment_REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment);
1479
+		if (empty($existing_reg_payment_REG_IDs)) {
1480 1480
 			return false;
1481 1481
 		}
1482 1482
 		/** @type EE_Transaction_Payments $transaction_payments */
1483
-		$transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' );
1483
+		$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
1484 1484
 		return $transaction_payments->delete_registration_payments_and_update_registrations(
1485 1485
 			$payment,
1486 1486
 			array(
1487 1487
 				array(
1488 1488
 					'PAY_ID' => $payment->ID(),
1489
-					'REG_ID' => array( 'IN', $existing_reg_payment_REG_IDs ),
1489
+					'REG_ID' => array('IN', $existing_reg_payment_REG_IDs),
1490 1490
 				)
1491 1491
 			)
1492 1492
 		);
@@ -1505,25 +1505,25 @@  discard block
 block discarded – undo
1505 1505
 	 * @param array $REG_IDs
1506 1506
 	 * @return bool
1507 1507
 	 */
1508
-	protected function _update_registration_payments( EE_Transaction $transaction, EE_Payment $payment, $REG_IDs = array() ) {
1508
+	protected function _update_registration_payments(EE_Transaction $transaction, EE_Payment $payment, $REG_IDs = array()) {
1509 1509
 		// we can pass our own custom set of registrations to EE_Payment_Processor::process_registration_payments()
1510 1510
 		// so let's do that using our set of REG_IDs from the form
1511 1511
 		$registration_query_where_params = array(
1512
-			'REG_ID' => array( 'IN', $REG_IDs )
1512
+			'REG_ID' => array('IN', $REG_IDs)
1513 1513
 		);
1514 1514
 		// but add in some conditions regarding payment,
1515 1515
 		// so that we don't apply payments to registrations that are free or have already been paid for
1516 1516
 		// but ONLY if the payment is NOT a refund ( ie: the payment amount is not negative )
1517
-		if ( ! $payment->is_a_refund() ) {
1518
-			$registration_query_where_params[ 'REG_final_price' ]  = array( '!=', 0 );
1519
-			$registration_query_where_params[ 'REG_final_price*' ]  = array( '!=', 'REG_paid', true );
1517
+		if ( ! $payment->is_a_refund()) {
1518
+			$registration_query_where_params['REG_final_price'] = array('!=', 0);
1519
+			$registration_query_where_params['REG_final_price*'] = array('!=', 'REG_paid', true);
1520 1520
 		}
1521 1521
 		//EEH_Debug_Tools::printr( $registration_query_where_params, '$registration_query_where_params', __FILE__, __LINE__ );
1522
-		$registrations = $transaction->registrations( array( $registration_query_where_params ) );
1523
-		if ( ! empty( $registrations ) ) {
1522
+		$registrations = $transaction->registrations(array($registration_query_where_params));
1523
+		if ( ! empty($registrations)) {
1524 1524
 			/** @type EE_Payment_Processor $payment_processor */
1525
-			$payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' );
1526
-			$payment_processor->process_registration_payments( $transaction, $payment, $registrations );
1525
+			$payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
1526
+			$payment_processor->process_registration_payments($transaction, $payment, $registrations);
1527 1527
 		}
1528 1528
 	}
1529 1529
 
@@ -1539,22 +1539,22 @@  discard block
 block discarded – undo
1539 1539
 	 * @param array $REG_IDs
1540 1540
 	 * @return bool
1541 1541
 	 */
1542
-	protected function _process_registration_status_change( EE_Transaction $transaction, $REG_IDs = array() ) {
1542
+	protected function _process_registration_status_change(EE_Transaction $transaction, $REG_IDs = array()) {
1543 1543
 		// first if there is no change in status then we get out.
1544 1544
 		if (
1545
-			! isset( $this->_req_data['txn_reg_status_change'], $this->_req_data[ 'txn_reg_status_change' ][ 'reg_status' ] )
1545
+			! isset($this->_req_data['txn_reg_status_change'], $this->_req_data['txn_reg_status_change']['reg_status'])
1546 1546
 			|| $this->_req_data['txn_reg_status_change']['reg_status'] == 'NAN'
1547 1547
 		) {
1548 1548
 			//no error message, no change requested, just nothing to do man.
1549 1549
 			return FALSE;
1550 1550
 		}
1551 1551
 		/** @type EE_Transaction_Processor $transaction_processor */
1552
-		$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
1552
+		$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
1553 1553
 		// made it here dude?  Oh WOW.  K, let's take care of changing the statuses
1554 1554
 		return $transaction_processor->manually_update_registration_statuses(
1555 1555
 			$transaction,
1556
-			sanitize_text_field( $this->_req_data[ 'txn_reg_status_change' ][ 'reg_status' ] ),
1557
-			array( array( 'REG_ID' => array( 'IN', $REG_IDs ) ) )
1556
+			sanitize_text_field($this->_req_data['txn_reg_status_change']['reg_status']),
1557
+			array(array('REG_ID' => array('IN', $REG_IDs)))
1558 1558
 		);
1559 1559
 	}
1560 1560
 
@@ -1569,16 +1569,16 @@  discard block
 block discarded – undo
1569 1569
 	 * @param bool | null        $delete_txn_reg_status_change
1570 1570
 	 * @return array
1571 1571
 	 */
1572
-	protected function _build_payment_json_response( EE_Payment $payment, $REG_IDs = array(), $delete_txn_reg_status_change = null ) {
1572
+	protected function _build_payment_json_response(EE_Payment $payment, $REG_IDs = array(), $delete_txn_reg_status_change = null) {
1573 1573
 		// was the payment deleted ?
1574
-		if ( is_bool( $delete_txn_reg_status_change )) {
1574
+		if (is_bool($delete_txn_reg_status_change)) {
1575 1575
 			return array(
1576 1576
 				'PAY_ID' 				=> $payment->ID(),
1577 1577
 				'amount' 			=> $payment->amount(),
1578 1578
 				'total_paid' 			=> $payment->transaction()->paid(),
1579 1579
 				'txn_status' 			=> $payment->transaction()->status_ID(),
1580 1580
 				'pay_status' 		=> $payment->STS_ID(),
1581
-				'registrations' 	=> $this->_registration_payment_data_array( $REG_IDs ),
1581
+				'registrations' 	=> $this->_registration_payment_data_array($REG_IDs),
1582 1582
 				'delete_txn_reg_status_change' => $delete_txn_reg_status_change,
1583 1583
 			);
1584 1584
 		} else {
@@ -1590,16 +1590,16 @@  discard block
 block discarded – undo
1590 1590
 				'pay_status' 	=> $payment->STS_ID(),
1591 1591
 				'PAY_ID'           => $payment->ID(),
1592 1592
 				'STS_ID' 			=> $payment->STS_ID(),
1593
-				'status' 			=> self::$_pay_status[ $payment->STS_ID() ],
1594
-				'date' 				=> $payment->timestamp( 'Y-m-d', 'h:i a' ),
1595
-				'method' 		=> strtoupper( $payment->source() ),
1593
+				'status' 			=> self::$_pay_status[$payment->STS_ID()],
1594
+				'date' 				=> $payment->timestamp('Y-m-d', 'h:i a'),
1595
+				'method' 		=> strtoupper($payment->source()),
1596 1596
 				'PM_ID' 			=> $payment->payment_method() ? $payment->payment_method()->ID() : 1,
1597
-				'gateway' 		=> $payment->payment_method() ? $payment->payment_method()->admin_name() : esc_html__( "Unknown", 'event_espresso' ),
1597
+				'gateway' 		=> $payment->payment_method() ? $payment->payment_method()->admin_name() : esc_html__("Unknown", 'event_espresso'),
1598 1598
 				'gateway_response' 	=> $payment->gateway_response(),
1599 1599
 				'txn_id_chq_nmbr'  	=> $payment->txn_id_chq_nmbr(),
1600 1600
 				'po_number'        		=> $payment->po_number(),
1601 1601
 				'extra_accntng'    		=> $payment->extra_accntng(),
1602
-				'registrations'    			=> $this->_registration_payment_data_array( $REG_IDs ),
1602
+				'registrations'    			=> $this->_registration_payment_data_array($REG_IDs),
1603 1603
 			);
1604 1604
 		}
1605 1605
 	}
@@ -1614,39 +1614,39 @@  discard block
 block discarded – undo
1614 1614
 	*	@return void
1615 1615
 	*/
1616 1616
 	public function delete_payment() {
1617
-		$json_response_data = array( 'return_data' => FALSE );
1618
-		$PAY_ID = isset( $this->_req_data['delete_txn_admin_payment'], $this->_req_data['delete_txn_admin_payment']['PAY_ID'] ) ? absint( $this->_req_data['delete_txn_admin_payment']['PAY_ID'] ) : 0;
1619
-		if ( $PAY_ID ) {
1620
-			$delete_txn_reg_status_change = isset( $this->_req_data[ 'delete_txn_reg_status_change' ] ) ? $this->_req_data[ 'delete_txn_reg_status_change' ] : false;
1621
-			$payment = EEM_Payment::instance()->get_one_by_ID( $PAY_ID );
1622
-			if ( $payment instanceof EE_Payment ) {
1623
-				$REG_IDs = $this->_get_existing_reg_payment_REG_IDs( $payment );
1617
+		$json_response_data = array('return_data' => FALSE);
1618
+		$PAY_ID = isset($this->_req_data['delete_txn_admin_payment'], $this->_req_data['delete_txn_admin_payment']['PAY_ID']) ? absint($this->_req_data['delete_txn_admin_payment']['PAY_ID']) : 0;
1619
+		if ($PAY_ID) {
1620
+			$delete_txn_reg_status_change = isset($this->_req_data['delete_txn_reg_status_change']) ? $this->_req_data['delete_txn_reg_status_change'] : false;
1621
+			$payment = EEM_Payment::instance()->get_one_by_ID($PAY_ID);
1622
+			if ($payment instanceof EE_Payment) {
1623
+				$REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment);
1624 1624
 				/** @type EE_Transaction_Payments $transaction_payments */
1625
-				$transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' );
1626
-				if ( $transaction_payments->delete_payment_and_update_transaction( $payment )) {
1627
-					$json_response_data['return_data'] = $this->_build_payment_json_response( $payment, $REG_IDs, $delete_txn_reg_status_change );
1628
-					if ( $delete_txn_reg_status_change ) {
1625
+				$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
1626
+				if ($transaction_payments->delete_payment_and_update_transaction($payment)) {
1627
+					$json_response_data['return_data'] = $this->_build_payment_json_response($payment, $REG_IDs, $delete_txn_reg_status_change);
1628
+					if ($delete_txn_reg_status_change) {
1629 1629
 						$this->_req_data['txn_reg_status_change'] = $delete_txn_reg_status_change;
1630 1630
 						//MAKE sure we also add the delete_txn_req_status_change to the
1631 1631
 						//$_REQUEST global because that's how messages will be looking for it.
1632 1632
 						$_REQUEST['txn_reg_status_change'] = $delete_txn_reg_status_change;
1633 1633
 						$this->_maybe_send_notifications();
1634
-						$this->_process_registration_status_change( $payment->transaction(), $REG_IDs );
1634
+						$this->_process_registration_status_change($payment->transaction(), $REG_IDs);
1635 1635
 					}
1636 1636
 				}
1637 1637
 			} else {
1638 1638
 				EE_Error::add_error(
1639
-					esc_html__( 'Valid Payment data could not be retrieved from the database.', 'event_espresso' ),
1639
+					esc_html__('Valid Payment data could not be retrieved from the database.', 'event_espresso'),
1640 1640
 					__FILE__, __FUNCTION__, __LINE__
1641 1641
 				);
1642 1642
 			}
1643 1643
 		} else {
1644 1644
 			EE_Error::add_error(
1645
-				esc_html__( 'A valid Payment ID was not received, therefore payment form data could not be loaded.', 'event_espresso' ),
1645
+				esc_html__('A valid Payment ID was not received, therefore payment form data could not be loaded.', 'event_espresso'),
1646 1646
 				__FILE__, __FUNCTION__, __LINE__
1647 1647
 			);
1648 1648
 		}
1649
-		$notices = EE_Error::get_notices( false, false, false);
1649
+		$notices = EE_Error::get_notices(false, false, false);
1650 1650
 		$this->_template_args = array(
1651 1651
 			'data' => $json_response_data,
1652 1652
 			'success' => $notices['success'],
@@ -1666,16 +1666,16 @@  discard block
 block discarded – undo
1666 1666
 	 * @param array $REG_IDs
1667 1667
 	 * @return array
1668 1668
 	 */
1669
-	protected function _registration_payment_data_array( $REG_IDs ) {
1669
+	protected function _registration_payment_data_array($REG_IDs) {
1670 1670
 		$registration_payment_data = array();
1671 1671
 		//if non empty reg_ids lets get an array of registrations and update the values for the apply_payment/refund rows.
1672
-		if ( ! empty( $REG_IDs ) ) {
1673
-			$registrations = EEM_Registration::instance()->get_all( array( array( 'REG_ID' => array( 'IN', $REG_IDs ) ) ) );
1674
-			foreach ( $registrations as $registration ) {
1675
-				if ( $registration instanceof EE_Registration ) {
1676
-					$registration_payment_data[ $registration->ID() ] = array(
1672
+		if ( ! empty($REG_IDs)) {
1673
+			$registrations = EEM_Registration::instance()->get_all(array(array('REG_ID' => array('IN', $REG_IDs))));
1674
+			foreach ($registrations as $registration) {
1675
+				if ($registration instanceof EE_Registration) {
1676
+					$registration_payment_data[$registration->ID()] = array(
1677 1677
 						'paid' => $registration->pretty_paid(),
1678
-						'owing' => EEH_Template::format_currency( $registration->final_price() - $registration->paid() ),
1678
+						'owing' => EEH_Template::format_currency($registration->final_price() - $registration->paid()),
1679 1679
 					);
1680 1680
 				}
1681 1681
 			}
@@ -1695,30 +1695,30 @@  discard block
 block discarded – undo
1695 1695
 	 * @access protected
1696 1696
 	 * @param \EE_Payment | null $payment
1697 1697
 	 */
1698
-	protected function _maybe_send_notifications( $payment = null ) {
1699
-		switch ( $payment instanceof EE_Payment ) {
1698
+	protected function _maybe_send_notifications($payment = null) {
1699
+		switch ($payment instanceof EE_Payment) {
1700 1700
 			// payment notifications
1701 1701
 			case true :
1702 1702
 				if (
1703 1703
 					isset(
1704
-						$this->_req_data[ 'txn_payments' ],
1705
-						$this->_req_data[ 'txn_payments' ][ 'send_notifications' ]
1704
+						$this->_req_data['txn_payments'],
1705
+						$this->_req_data['txn_payments']['send_notifications']
1706 1706
 					) &&
1707
-					filter_var( $this->_req_data[ 'txn_payments' ][ 'send_notifications' ], FILTER_VALIDATE_BOOLEAN )
1707
+					filter_var($this->_req_data['txn_payments']['send_notifications'], FILTER_VALIDATE_BOOLEAN)
1708 1708
 				) {
1709
-					$this->_process_payment_notification( $payment );
1709
+					$this->_process_payment_notification($payment);
1710 1710
 				}
1711 1711
 				break;
1712 1712
 			// registration notifications
1713 1713
 			case false :
1714 1714
 				if (
1715 1715
 					isset(
1716
-						$this->_req_data[ 'txn_reg_status_change' ],
1717
-						$this->_req_data[ 'txn_reg_status_change' ][ 'send_notifications' ]
1716
+						$this->_req_data['txn_reg_status_change'],
1717
+						$this->_req_data['txn_reg_status_change']['send_notifications']
1718 1718
 					) &&
1719
-					filter_var( $this->_req_data[ 'txn_reg_status_change' ][ 'send_notifications' ], FILTER_VALIDATE_BOOLEAN )
1719
+					filter_var($this->_req_data['txn_reg_status_change']['send_notifications'], FILTER_VALIDATE_BOOLEAN)
1720 1720
 				) {
1721
-					add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true' );
1721
+					add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true');
1722 1722
 				}
1723 1723
 				break;
1724 1724
 		}
@@ -1734,11 +1734,11 @@  discard block
 block discarded – undo
1734 1734
 	*	@return void
1735 1735
 	*/
1736 1736
 	protected function _send_payment_reminder() {
1737
-	    $TXN_ID = ( ! empty( $this->_req_data['TXN_ID'] )) ? absint( $this->_req_data['TXN_ID'] ) : FALSE;
1738
-		$transaction = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID );
1739
-		$query_args = isset($this->_req_data['redirect_to'] ) ? array('action' => $this->_req_data['redirect_to'], 'TXN_ID' => $this->_req_data['TXN_ID'] ) : array();
1740
-		do_action( 'AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', $transaction );
1741
-		$this->_redirect_after_action( FALSE, esc_html__('payment reminder', 'event_espresso'), esc_html__('sent', 'event_espresso'), $query_args, TRUE );
1737
+	    $TXN_ID = ( ! empty($this->_req_data['TXN_ID'])) ? absint($this->_req_data['TXN_ID']) : FALSE;
1738
+		$transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
1739
+		$query_args = isset($this->_req_data['redirect_to']) ? array('action' => $this->_req_data['redirect_to'], 'TXN_ID' => $this->_req_data['TXN_ID']) : array();
1740
+		do_action('AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', $transaction);
1741
+		$this->_redirect_after_action(FALSE, esc_html__('payment reminder', 'event_espresso'), esc_html__('sent', 'event_espresso'), $query_args, TRUE);
1742 1742
 	}
1743 1743
 
1744 1744
 
@@ -1752,36 +1752,36 @@  discard block
 block discarded – undo
1752 1752
 	 * @param string   $view
1753 1753
 	 * @return mixed int = count || array of transaction objects
1754 1754
 	 */
1755
-	public function get_transactions( $perpage, $count = FALSE, $view = '' ) {
1755
+	public function get_transactions($perpage, $count = FALSE, $view = '') {
1756 1756
 
1757 1757
 		$TXN = EEM_Transaction::instance();
1758 1758
 
1759
-	    $start_date = isset( $this->_req_data['txn-filter-start-date'] ) ? wp_strip_all_tags( $this->_req_data['txn-filter-start-date'] ) : date( 'm/d/Y', strtotime( '-10 year' ));
1760
-	    $end_date = isset( $this->_req_data['txn-filter-end-date'] ) ? wp_strip_all_tags( $this->_req_data['txn-filter-end-date'] ) : date( 'm/d/Y' );
1759
+	    $start_date = isset($this->_req_data['txn-filter-start-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-start-date']) : date('m/d/Y', strtotime('-10 year'));
1760
+	    $end_date = isset($this->_req_data['txn-filter-end-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-end-date']) : date('m/d/Y');
1761 1761
 
1762 1762
 	    //make sure our timestamps start and end right at the boundaries for each day
1763
-	    $start_date = date( 'Y-m-d', strtotime( $start_date ) ) . ' 00:00:00';
1764
-	    $end_date = date( 'Y-m-d', strtotime( $end_date ) ) . ' 23:59:59';
1763
+	    $start_date = date('Y-m-d', strtotime($start_date)).' 00:00:00';
1764
+	    $end_date = date('Y-m-d', strtotime($end_date)).' 23:59:59';
1765 1765
 
1766 1766
 
1767 1767
 	    //convert to timestamps
1768
-	    $start_date = strtotime( $start_date );
1769
-	    $end_date = strtotime( $end_date );
1768
+	    $start_date = strtotime($start_date);
1769
+	    $end_date = strtotime($end_date);
1770 1770
 
1771 1771
 	    //makes sure start date is the lowest value and vice versa
1772
-	    $start_date = min( $start_date, $end_date );
1773
-	    $end_date = max( $start_date, $end_date );
1772
+	    $start_date = min($start_date, $end_date);
1773
+	    $end_date = max($start_date, $end_date);
1774 1774
 
1775 1775
 	    //convert to correct format for query
1776
-	$start_date = EEM_Transaction::instance()->convert_datetime_for_query( 'TXN_timestamp', date( 'Y-m-d H:i:s', $start_date ), 'Y-m-d H:i:s' );
1777
-	$end_date = EEM_Transaction::instance()->convert_datetime_for_query( 'TXN_timestamp', date( 'Y-m-d H:i:s', $end_date ), 'Y-m-d H:i:s' );
1776
+	$start_date = EEM_Transaction::instance()->convert_datetime_for_query('TXN_timestamp', date('Y-m-d H:i:s', $start_date), 'Y-m-d H:i:s');
1777
+	$end_date = EEM_Transaction::instance()->convert_datetime_for_query('TXN_timestamp', date('Y-m-d H:i:s', $end_date), 'Y-m-d H:i:s');
1778 1778
 
1779 1779
 
1780 1780
 
1781 1781
 	    //set orderby
1782 1782
 		$this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
1783 1783
 
1784
-		switch ( $this->_req_data['orderby'] ) {
1784
+		switch ($this->_req_data['orderby']) {
1785 1785
 			case 'TXN_ID':
1786 1786
 				$orderby = 'TXN_ID';
1787 1787
 				break;
@@ -1795,66 +1795,66 @@  discard block
 block discarded – undo
1795 1795
 				$orderby = 'TXN_timestamp';
1796 1796
 		}
1797 1797
 
1798
-		$sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'DESC';
1799
-		$current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1;
1800
-		$per_page = isset( $perpage ) && !empty( $perpage ) ? $perpage : 10;
1801
-		$per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page;
1798
+		$sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'DESC';
1799
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1;
1800
+		$per_page = isset($perpage) && ! empty($perpage) ? $perpage : 10;
1801
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page;
1802 1802
 
1803
-		$offset = ($current_page-1)*$per_page;
1804
-		$limit = array( $offset, $per_page );
1803
+		$offset = ($current_page - 1) * $per_page;
1804
+		$limit = array($offset, $per_page);
1805 1805
 
1806 1806
 		$_where = array(
1807
-			'TXN_timestamp' => array('BETWEEN', array($start_date, $end_date) ),
1807
+			'TXN_timestamp' => array('BETWEEN', array($start_date, $end_date)),
1808 1808
 			'Registration.REG_count' => 1
1809 1809
 		);
1810 1810
 
1811
-		if ( isset( $this->_req_data['EVT_ID'] ) ) {
1811
+		if (isset($this->_req_data['EVT_ID'])) {
1812 1812
 			$_where['Registration.EVT_ID'] = $this->_req_data['EVT_ID'];
1813 1813
 		}
1814 1814
 
1815
-		if ( isset( $this->_req_data['s'] ) ) {
1816
-			$search_string = '%' . $this->_req_data['s'] . '%';
1815
+		if (isset($this->_req_data['s'])) {
1816
+			$search_string = '%'.$this->_req_data['s'].'%';
1817 1817
 			$_where['OR'] = array(
1818
-				'Registration.Event.EVT_name' => array( 'LIKE', $search_string ),
1819
-				'Registration.Event.EVT_desc' => array( 'LIKE', $search_string ),
1820
-				'Registration.Event.EVT_short_desc' => array( 'LIKE' , $search_string ),
1821
-				'Registration.Attendee.ATT_full_name' => array( 'LIKE', $search_string ),
1822
-				'Registration.Attendee.ATT_fname' => array( 'LIKE', $search_string ),
1823
-				'Registration.Attendee.ATT_lname' => array( 'LIKE', $search_string ),
1824
-				'Registration.Attendee.ATT_short_bio' => array( 'LIKE', $search_string ),
1825
-				'Registration.Attendee.ATT_email' => array('LIKE', $search_string ),
1826
-				'Registration.Attendee.ATT_address' => array( 'LIKE', $search_string ),
1827
-				'Registration.Attendee.ATT_address2' => array( 'LIKE', $search_string ),
1828
-				'Registration.Attendee.ATT_city' => array( 'LIKE', $search_string ),
1829
-				'Registration.REG_final_price' => array( 'LIKE', $search_string ),
1830
-				'Registration.REG_code' => array( 'LIKE', $search_string ),
1831
-				'Registration.REG_count' => array( 'LIKE' , $search_string ),
1832
-				'Registration.REG_group_size' => array( 'LIKE' , $search_string ),
1833
-				'Registration.Ticket.TKT_name' => array( 'LIKE', $search_string ),
1834
-				'Registration.Ticket.TKT_description' => array( 'LIKE', $search_string ),
1835
-				'Payment.PAY_source' => array('LIKE', $search_string ),
1836
-				'Payment.Payment_Method.PMD_name' => array('LIKE', $search_string ),
1837
-				'TXN_session_data' => array( 'LIKE', $search_string ),
1838
-				'Payment.PAY_txn_id_chq_nmbr' => array( 'LIKE', $search_string )
1818
+				'Registration.Event.EVT_name' => array('LIKE', $search_string),
1819
+				'Registration.Event.EVT_desc' => array('LIKE', $search_string),
1820
+				'Registration.Event.EVT_short_desc' => array('LIKE', $search_string),
1821
+				'Registration.Attendee.ATT_full_name' => array('LIKE', $search_string),
1822
+				'Registration.Attendee.ATT_fname' => array('LIKE', $search_string),
1823
+				'Registration.Attendee.ATT_lname' => array('LIKE', $search_string),
1824
+				'Registration.Attendee.ATT_short_bio' => array('LIKE', $search_string),
1825
+				'Registration.Attendee.ATT_email' => array('LIKE', $search_string),
1826
+				'Registration.Attendee.ATT_address' => array('LIKE', $search_string),
1827
+				'Registration.Attendee.ATT_address2' => array('LIKE', $search_string),
1828
+				'Registration.Attendee.ATT_city' => array('LIKE', $search_string),
1829
+				'Registration.REG_final_price' => array('LIKE', $search_string),
1830
+				'Registration.REG_code' => array('LIKE', $search_string),
1831
+				'Registration.REG_count' => array('LIKE', $search_string),
1832
+				'Registration.REG_group_size' => array('LIKE', $search_string),
1833
+				'Registration.Ticket.TKT_name' => array('LIKE', $search_string),
1834
+				'Registration.Ticket.TKT_description' => array('LIKE', $search_string),
1835
+				'Payment.PAY_source' => array('LIKE', $search_string),
1836
+				'Payment.Payment_Method.PMD_name' => array('LIKE', $search_string),
1837
+				'TXN_session_data' => array('LIKE', $search_string),
1838
+				'Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $search_string)
1839 1839
 				);
1840 1840
 		}
1841 1841
 
1842 1842
 		//failed transactions
1843
-		$failed = ( ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] == 'failed' && ! $count ) || ( $count && $view == 'failed' ) ? TRUE: FALSE;
1844
-		$abandoned = ( ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] == 'abandoned' && ! $count ) || ( $count && $view == 'abandoned' ) ? TRUE: FALSE;
1843
+		$failed = ( ! empty($this->_req_data['status']) && $this->_req_data['status'] == 'failed' && ! $count) || ($count && $view == 'failed') ? TRUE : FALSE;
1844
+		$abandoned = ( ! empty($this->_req_data['status']) && $this->_req_data['status'] == 'abandoned' && ! $count) || ($count && $view == 'abandoned') ? TRUE : FALSE;
1845 1845
 
1846
-		if ( $failed ) {
1847
-			$_where[ 'STS_ID' ] = EEM_Transaction::failed_status_code;
1848
-		} else if ( $abandoned ) {
1846
+		if ($failed) {
1847
+			$_where['STS_ID'] = EEM_Transaction::failed_status_code;
1848
+		} else if ($abandoned) {
1849 1849
 				$_where['STS_ID'] = EEM_Transaction::abandoned_status_code;
1850 1850
 		} else {
1851
-				$_where['STS_ID'] = array( '!=', EEM_Transaction::failed_status_code );
1852
-				$_where['STS_ID*'] = array( '!=', EEM_Transaction::abandoned_status_code );
1851
+				$_where['STS_ID'] = array('!=', EEM_Transaction::failed_status_code);
1852
+				$_where['STS_ID*'] = array('!=', EEM_Transaction::abandoned_status_code);
1853 1853
 		}
1854 1854
 
1855
-		$query_params = array( $_where, 'order_by' => array( $orderby => $sort ), 'limit' => $limit );
1855
+		$query_params = array($_where, 'order_by' => array($orderby => $sort), 'limit' => $limit);
1856 1856
 
1857
-		$transactions = $count ? $TXN->count( array($_where), 'TXN_ID', TRUE ) : $TXN->get_all($query_params);
1857
+		$transactions = $count ? $TXN->count(array($_where), 'TXN_ID', TRUE) : $TXN->get_all($query_params);
1858 1858
 
1859 1859
 
1860 1860
 		return $transactions;
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_Form_Input_Base.input.php 1 patch
Spacing   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @subpackage
9 9
  * @author				Mike Nelson
10 10
  */
11
-abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable{
11
+abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable {
12 12
 
13 13
 	/**
14 14
 	 * the input's name attribute
@@ -143,54 +143,54 @@  discard block
 block discarded – undo
143 143
 	 *  @type EE_Validation_Strategy_Base[]  $validation_strategies
144 144
 	 * }
145 145
 	 */
146
-	public function __construct( $input_args = array() ){
147
-		$input_args = (array) apply_filters( 'FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this );
146
+	public function __construct($input_args = array()) {
147
+		$input_args = (array) apply_filters('FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this);
148 148
 		// the following properties must be cast as arrays
149
-		if ( isset( $input_args['validation_strategies'] ) ) {
150
-			foreach ( (array) $input_args['validation_strategies'] as $validation_strategy ) {
151
-				if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) {
152
-					$this->_validation_strategies[ get_class( $validation_strategy ) ] = $validation_strategy;
149
+		if (isset($input_args['validation_strategies'])) {
150
+			foreach ((array) $input_args['validation_strategies'] as $validation_strategy) {
151
+				if ($validation_strategy instanceof EE_Validation_Strategy_Base) {
152
+					$this->_validation_strategies[get_class($validation_strategy)] = $validation_strategy;
153 153
 				}
154 154
 			}
155
-			unset( $input_args['validation_strategies'] );
155
+			unset($input_args['validation_strategies']);
156 156
 		}
157 157
 		// loop thru incoming options
158
-		foreach( $input_args as $key => $value ) {
158
+		foreach ($input_args as $key => $value) {
159 159
 			// add underscore to $key to match property names
160
-			$_key = '_' . $key;
161
-			if ( property_exists( $this, $_key )) {
160
+			$_key = '_'.$key;
161
+			if (property_exists($this, $_key)) {
162 162
 				$this->{$_key} = $value;
163 163
 			}
164 164
 		}
165 165
 		// ensure that "required" is set correctly
166 166
 		$this->set_required(
167
-			$this->_required, isset( $input_args[ 'required_validation_error_message' ] )
168
-				? $input_args[ 'required_validation_error_message' ]
167
+			$this->_required, isset($input_args['required_validation_error_message'])
168
+				? $input_args['required_validation_error_message']
169 169
 				: null
170 170
 		);
171 171
 
172 172
 		//$this->_html_name_specified = isset( $input_args['html_name'] ) ? TRUE : FALSE;
173 173
 
174 174
 		$this->_display_strategy->_construct_finalize($this);
175
-		foreach( $this->_validation_strategies as $validation_strategy ){
175
+		foreach ($this->_validation_strategies as $validation_strategy) {
176 176
 			$validation_strategy->_construct_finalize($this);
177 177
 		}
178 178
 
179
-		if( ! $this->_normalization_strategy){
179
+		if ( ! $this->_normalization_strategy) {
180 180
 			$this->_normalization_strategy = new EE_Text_Normalization();
181 181
 		}
182 182
 		$this->_normalization_strategy->_construct_finalize($this);
183 183
 
184 184
 		//at least we can use the normalization strategy to populate the default
185
-		if( isset( $input_args[ 'default' ] ) ) {
186
-			$this->set_default( $input_args[ 'default' ] );
185
+		if (isset($input_args['default'])) {
186
+			$this->set_default($input_args['default']);
187 187
 		}
188 188
 
189
-		if( ! $this->_sensitive_data_removal_strategy){
189
+		if ( ! $this->_sensitive_data_removal_strategy) {
190 190
 			$this->_sensitive_data_removal_strategy = new EE_No_Sensitive_Data_Removal();
191 191
 		}
192 192
 		$this->_sensitive_data_removal_strategy->_construct_finalize($this);
193
-		parent::__construct( $input_args );
193
+		parent::__construct($input_args);
194 194
 	}
195 195
 
196 196
 
@@ -201,11 +201,11 @@  discard block
 block discarded – undo
201 201
 	 *
202 202
 	 * @throws \EE_Error
203 203
 	 */
204
-	protected function _set_default_html_name_if_empty(){
205
-		if( ! $this->_html_name){
204
+	protected function _set_default_html_name_if_empty() {
205
+		if ( ! $this->_html_name) {
206 206
 			$this->_html_name = $this->name();
207
-			if( $this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper){
208
-				$this->_html_name = $this->_parent_section->html_name_prefix() . "[{$this->name()}]";
207
+			if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) {
208
+				$this->_html_name = $this->_parent_section->html_name_prefix()."[{$this->name()}]";
209 209
 			}
210 210
 		}
211 211
 	}
@@ -220,10 +220,10 @@  discard block
 block discarded – undo
220 220
 	public function _construct_finalize($parent_form_section, $name) {
221 221
 		parent::_construct_finalize($parent_form_section, $name);
222 222
 		$this->_set_default_html_name_if_empty();
223
-		if( $this->_html_label === null && $this->_html_label_text === null ){
224
-			$this->_html_label_text = ucwords( str_replace("_"," ",$name));
223
+		if ($this->_html_label === null && $this->_html_label_text === null) {
224
+			$this->_html_label_text = ucwords(str_replace("_", " ", $name));
225 225
 		}
226
-		do_action( 'AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name );
226
+		do_action('AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name);
227 227
 	}
228 228
 
229 229
 	 /**
@@ -231,8 +231,8 @@  discard block
 block discarded – undo
231 231
 	  * @return EE_Display_Strategy_Base
232 232
 	  * @throws EE_Error
233 233
 	  */
234
-	protected function _get_display_strategy(){
235
-		if( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base){
234
+	protected function _get_display_strategy() {
235
+		if ( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base) {
236 236
 			throw new EE_Error(
237 237
 				sprintf(
238 238
 					__(
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 					$this->html_id()
244 244
 				)
245 245
 			);
246
-		}else{
246
+		} else {
247 247
 			return $this->_display_strategy;
248 248
 		}
249 249
 	}
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 	 * Sets the display strategy.
252 252
 	 * @param EE_Display_Strategy_Base $strategy
253 253
 	 */
254
-	protected function _set_display_strategy(EE_Display_Strategy_Base $strategy){
254
+	protected function _set_display_strategy(EE_Display_Strategy_Base $strategy) {
255 255
 		$this->_display_strategy = $strategy;
256 256
 	}
257 257
 
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 	 * Sets the sanitization strategy
260 260
 	 * @param EE_Normalization_Strategy_Base $strategy
261 261
 	 */
262
-	protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy){
262
+	protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy) {
263 263
 		$this->_normalization_strategy = $strategy;
264 264
 	}
265 265
 
@@ -285,14 +285,14 @@  discard block
 block discarded – undo
285 285
 	 * Gets the display strategy for this input
286 286
 	 * @return EE_Display_Strategy_Base
287 287
 	 */
288
-	public function get_display_strategy(){
288
+	public function get_display_strategy() {
289 289
 		return $this->_display_strategy;
290 290
 	}
291 291
 	/**
292 292
 	 * Overwrites the display strategy
293 293
 	 * @param EE_Display_Strategy_Base $display_strategy
294 294
 	 */
295
-	public function set_display_strategy($display_strategy){
295
+	public function set_display_strategy($display_strategy) {
296 296
 		$this->_display_strategy = $display_strategy;
297 297
 		$this->_display_strategy->_construct_finalize($this);
298 298
 	}
@@ -300,14 +300,14 @@  discard block
 block discarded – undo
300 300
 	 * Gets the normalization strategy set on this input
301 301
 	 * @return EE_Normalization_Strategy_Base
302 302
 	 */
303
-	public function get_normalization_strategy(){
303
+	public function get_normalization_strategy() {
304 304
 		return $this->_normalization_strategy;
305 305
 	}
306 306
 	/**
307 307
 	 * Overwrites the normalization strategy
308 308
 	 * @param EE_Normalization_Strategy_Base $normalization_strategy
309 309
 	 */
310
-	public function set_normalization_strategy($normalization_strategy){
310
+	public function set_normalization_strategy($normalization_strategy) {
311 311
 		$this->_normalization_strategy = $normalization_strategy;
312 312
 		$this->_normalization_strategy->_construct_finalize($this);
313 313
 	}
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 	 * Returns all teh validation strategies which apply to this field, numerically indexed
317 317
 	 * @return EE_Validation_Strategy_Base[]
318 318
 	 */
319
-	public function get_validation_strategies(){
319
+	public function get_validation_strategies() {
320 320
 		return $this->_validation_strategies;
321 321
 	}
322 322
 
@@ -327,8 +327,8 @@  discard block
 block discarded – undo
327 327
 	 * @param EE_Validation_Strategy_Base $validation_strategy
328 328
 	 * @return void
329 329
 	 */
330
-	protected function _add_validation_strategy( EE_Validation_Strategy_Base $validation_strategy ){
331
-		$validation_strategy->_construct_finalize( $this );
330
+	protected function _add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) {
331
+		$validation_strategy->_construct_finalize($this);
332 332
 		$this->_validation_strategies[] = $validation_strategy;
333 333
 	}
334 334
 
@@ -339,8 +339,8 @@  discard block
 block discarded – undo
339 339
 	 * @param EE_Validation_Strategy_Base $validation_strategy
340 340
 	 * @return void
341 341
 	 */
342
-	public function add_validation_strategy( EE_Validation_Strategy_Base $validation_strategy ) {
343
-		$this->_add_validation_strategy( $validation_strategy );
342
+	public function add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) {
343
+		$this->_add_validation_strategy($validation_strategy);
344 344
 	}
345 345
 
346 346
 
@@ -350,13 +350,13 @@  discard block
 block discarded – undo
350 350
 	 *
351 351
 	 * @param string $validation_strategy_classname
352 352
 	 */
353
-	public function remove_validation_strategy( $validation_strategy_classname ) {
354
-		foreach( $this->_validation_strategies as $key => $validation_strategy ){
355
-			if(
353
+	public function remove_validation_strategy($validation_strategy_classname) {
354
+		foreach ($this->_validation_strategies as $key => $validation_strategy) {
355
+			if (
356 356
 				$validation_strategy instanceof $validation_strategy_classname
357
-				|| is_subclass_of( $validation_strategy, $validation_strategy_classname )
357
+				|| is_subclass_of($validation_strategy, $validation_strategy_classname)
358 358
 			) {
359
-				unset( $this->_validation_strategies[ $key ] );
359
+				unset($this->_validation_strategies[$key]);
360 360
 			}
361 361
 		}
362 362
 	}
@@ -369,12 +369,12 @@  discard block
 block discarded – undo
369 369
 	 * @param array $validation_strategy_classnames
370 370
 	 * @return bool
371 371
 	 */
372
-	public function has_validation_strategy( $validation_strategy_classnames ) {
373
-		$validation_strategy_classnames = is_array( $validation_strategy_classnames )
372
+	public function has_validation_strategy($validation_strategy_classnames) {
373
+		$validation_strategy_classnames = is_array($validation_strategy_classnames)
374 374
 			? $validation_strategy_classnames
375
-			: array( $validation_strategy_classnames );
376
-		foreach( $this->_validation_strategies as $key => $validation_strategy ){
377
-			if( in_array( $key, $validation_strategy_classnames ) ) {
375
+			: array($validation_strategy_classnames);
376
+		foreach ($this->_validation_strategies as $key => $validation_strategy) {
377
+			if (in_array($key, $validation_strategy_classnames)) {
378 378
 				return true;
379 379
 			}
380 380
 		}
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 	 * Gets the HTML
388 388
 	 * @return string
389 389
 	 */
390
-	public function get_html(){
390
+	public function get_html() {
391 391
 		return $this->_parent_section->get_html_for_input($this);
392 392
 	}
393 393
 
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
 	 * @return string
402 402
 	 * @throws \EE_Error
403 403
 	 */
404
-	public function get_html_for_input(){
404
+	public function get_html_for_input() {
405 405
 		return  $this->_get_display_strategy()->display();
406 406
 	}
407 407
 
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
 	 * @return string
412 412
 	 */
413 413
 	public function html_other_attributes() {
414
-		return ! empty( $this->_html_other_attributes ) ? ' ' . $this->_html_other_attributes : '';
414
+		return ! empty($this->_html_other_attributes) ? ' '.$this->_html_other_attributes : '';
415 415
 	}
416 416
 
417 417
 
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 	/**
420 420
 	 * @param string $html_other_attributes
421 421
 	 */
422
-	public function set_html_other_attributes( $html_other_attributes ) {
422
+	public function set_html_other_attributes($html_other_attributes) {
423 423
 		$this->_html_other_attributes = $html_other_attributes;
424 424
 	}
425 425
 
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 	 * according to the form section's layout strategy
429 429
 	 * @return string
430 430
 	 */
431
-	public function get_html_for_label(){
431
+	public function get_html_for_label() {
432 432
 		return $this->_parent_section->get_layout_strategy()->display_label($this);
433 433
 	}
434 434
 	/**
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 	 * according to the form section's layout strategy
437 437
 	 * @return string
438 438
 	 */
439
-	public function get_html_for_errors(){
439
+	public function get_html_for_errors() {
440 440
 		return $this->_parent_section->get_layout_strategy()->display_errors($this);
441 441
 	}
442 442
 	/**
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 	 * according to the form section's layout strategy
445 445
 	 * @return string
446 446
 	 */
447
-	public function get_html_for_help(){
447
+	public function get_html_for_help() {
448 448
 		return $this->_parent_section->get_layout_strategy()->display_help_text($this);
449 449
 	}
450 450
 	/**
@@ -453,18 +453,18 @@  discard block
 block discarded – undo
453 453
 	 * @return boolean
454 454
 	 */
455 455
 	protected function _validate() {
456
-		foreach($this->_validation_strategies as $validation_strategy){
457
-			if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) {
458
-				try{
456
+		foreach ($this->_validation_strategies as $validation_strategy) {
457
+			if ($validation_strategy instanceof EE_Validation_Strategy_Base) {
458
+				try {
459 459
 					$validation_strategy->validate($this->normalized_value());
460
-				}catch(EE_Validation_Error $e){
460
+				} catch (EE_Validation_Error $e) {
461 461
 					$this->add_validation_error($e);
462 462
 				}
463 463
 			}
464 464
 		}
465
-		if( $this->get_validation_errors()){
465
+		if ($this->get_validation_errors()) {
466 466
 			return false;
467
-		}else{
467
+		} else {
468 468
 			return true;
469 469
 		}
470 470
 	}
@@ -478,8 +478,8 @@  discard block
 block discarded – undo
478 478
 	 * @param string $value
479 479
 	 * @return null|string
480 480
 	 */
481
-	private function _sanitize( $value ) {
482
-		return $value !== null ? stripslashes( html_entity_decode( trim( $value ) ) ) : null;
481
+	private function _sanitize($value) {
482
+		return $value !== null ? stripslashes(html_entity_decode(trim($value))) : null;
483 483
 	}
484 484
 
485 485
 
@@ -493,25 +493,25 @@  discard block
 block discarded – undo
493 493
 	 * @return boolean whether or not there was an error
494 494
 	 * @throws \EE_Error
495 495
 	 */
496
-	protected function _normalize( $req_data ) {
496
+	protected function _normalize($req_data) {
497 497
 		//any existing validation errors don't apply so clear them
498 498
 		$this->_validation_errors = array();
499 499
 		try {
500
-			$raw_input = $this->find_form_data_for_this_section( $req_data );
500
+			$raw_input = $this->find_form_data_for_this_section($req_data);
501 501
 			//super simple sanitization for now
502
-			if ( is_array( $raw_input )) {
502
+			if (is_array($raw_input)) {
503 503
 				$raw_value = array();
504
-				foreach( $raw_input as $key => $value ) {
505
-					$raw_value[ $key ] = $this->_sanitize( $value );
504
+				foreach ($raw_input as $key => $value) {
505
+					$raw_value[$key] = $this->_sanitize($value);
506 506
 				}
507
-				$this->_set_raw_value( $raw_value );
507
+				$this->_set_raw_value($raw_value);
508 508
 			} else {
509
-				$this->_set_raw_value( $this->_sanitize( $raw_input ) );
509
+				$this->_set_raw_value($this->_sanitize($raw_input));
510 510
 			}
511 511
 			//we want to mostly leave the input alone in case we need to re-display it to the user
512
-			$this->_set_normalized_value( $this->_normalization_strategy->normalize( $this->raw_value() ) );
513
-		} catch ( EE_Validation_Error $e ) {
514
-			$this->add_validation_error( $e );
512
+			$this->_set_normalized_value($this->_normalization_strategy->normalize($this->raw_value()));
513
+		} catch (EE_Validation_Error $e) {
514
+			$this->add_validation_error($e);
515 515
 		}
516 516
 	}
517 517
 
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
520 520
 	/**
521 521
 	 * @return string
522 522
 	 */
523
-	public function html_name(){
523
+	public function html_name() {
524 524
 		return $this->_html_name;
525 525
 	}
526 526
 
@@ -529,8 +529,8 @@  discard block
 block discarded – undo
529 529
 	/**
530 530
 	 * @return string
531 531
 	 */
532
-	public function html_label_id(){
533
-		return ! empty( $this->_html_label_id ) ? $this->_html_label_id : $this->_html_id . '-lbl';
532
+	public function html_label_id() {
533
+		return ! empty($this->_html_label_id) ? $this->_html_label_id : $this->_html_id.'-lbl';
534 534
 	}
535 535
 
536 536
 
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
 	/**
539 539
 	 * @return string
540 540
 	 */
541
-	public function html_label_class(){
541
+	public function html_label_class() {
542 542
 		return $this->_html_label_class;
543 543
 	}
544 544
 
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
 	/**
548 548
 	 * @return string
549 549
 	 */
550
-	public function html_label_style(){
550
+	public function html_label_style() {
551 551
 		return $this->_html_label_style;
552 552
 	}
553 553
 
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
 	/**
557 557
 	 * @return string
558 558
 	 */
559
-	public function html_label_text(){
559
+	public function html_label_text() {
560 560
 		return $this->_html_label_text;
561 561
 	}
562 562
 
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
 	/**
566 566
 	 * @return string
567 567
 	 */
568
-	public function html_help_text(){
568
+	public function html_help_text() {
569 569
 		return $this->_html_help_text;
570 570
 	}
571 571
 
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
 	/**
575 575
 	 * @return string
576 576
 	 */
577
-	public function html_help_class(){
577
+	public function html_help_class() {
578 578
 		return $this->_html_help_class;
579 579
 	}
580 580
 
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
 	/**
584 584
 	 * @return string
585 585
 	 */
586
-	public function html_help_style(){
586
+	public function html_help_style() {
587 587
 		return $this->_html_style;
588 588
 	}
589 589
 	/**
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
 	 * in which case, we would have stored the malicious content to our database.
597 597
 	 * @return string
598 598
 	 */
599
-	public function raw_value(){
599
+	public function raw_value() {
600 600
 		return $this->_raw_value;
601 601
 	}
602 602
 	/**
@@ -604,15 +604,15 @@  discard block
 block discarded – undo
604 604
 	 * it escapes all html entities
605 605
 	 * @return string
606 606
 	 */
607
-	public function raw_value_in_form(){
608
-		return htmlentities($this->raw_value(),ENT_QUOTES, 'UTF-8');
607
+	public function raw_value_in_form() {
608
+		return htmlentities($this->raw_value(), ENT_QUOTES, 'UTF-8');
609 609
 	}
610 610
 	/**
611 611
 	 * returns the value after it's been sanitized, and then converted into it's proper type
612 612
 	 * in PHP. Eg, a string, an int, an array,
613 613
 	 * @return mixed
614 614
 	 */
615
-	public function normalized_value(){
615
+	public function normalized_value() {
616 616
 		return $this->_normalized_value;
617 617
 	}
618 618
 
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
 	 * the best thing to display
623 623
 	 * @return string
624 624
 	 */
625
-	public function pretty_value(){
625
+	public function pretty_value() {
626 626
 		return $this->_normalized_value;
627 627
 	}
628 628
 	/**
@@ -641,19 +641,19 @@  discard block
 block discarded – undo
641 641
 		  }</code>
642 642
 	 * @return array
643 643
 	 */
644
-	public function get_jquery_validation_rules(){
644
+	public function get_jquery_validation_rules() {
645 645
 		$jquery_validation_js = array();
646 646
 		$jquery_validation_rules = array();
647
-		foreach($this->get_validation_strategies() as $validation_strategy){
647
+		foreach ($this->get_validation_strategies() as $validation_strategy) {
648 648
 			$jquery_validation_rules = array_replace_recursive(
649 649
 				$jquery_validation_rules,
650 650
 				$validation_strategy->get_jquery_validation_rule_array()
651 651
 			);
652 652
 		}
653 653
 
654
-		if(! empty($jquery_validation_rules)){
655
-			foreach( $this->get_display_strategy()->get_html_input_ids( true ) as $html_id_with_pound_sign ) {
656
-				$jquery_validation_js[ $html_id_with_pound_sign ] = $jquery_validation_rules;
654
+		if ( ! empty($jquery_validation_rules)) {
655
+			foreach ($this->get_display_strategy()->get_html_input_ids(true) as $html_id_with_pound_sign) {
656
+				$jquery_validation_js[$html_id_with_pound_sign] = $jquery_validation_rules;
657 657
 			}
658 658
 		}
659 659
 		return $jquery_validation_js;
@@ -665,16 +665,16 @@  discard block
 block discarded – undo
665 665
 	 * @param mixed $value
666 666
 	 * @return void
667 667
 	 */
668
-	public function set_default($value){
669
-		$this->_set_normalized_value( $value );
670
-		$this->_set_raw_value( $value );
668
+	public function set_default($value) {
669
+		$this->_set_normalized_value($value);
670
+		$this->_set_raw_value($value);
671 671
 	}
672 672
 	
673 673
 	/**
674 674
 	 * Sets the normalized value on this input
675 675
 	 * @param mixed $value
676 676
 	 */
677
-	protected function _set_normalized_value( $value ) {
677
+	protected function _set_normalized_value($value) {
678 678
 		$this->_normalized_value = $value;
679 679
 	}
680 680
 	
@@ -682,8 +682,8 @@  discard block
 block discarded – undo
682 682
 	 * Sets the raw value on this input (ie, exactly as the user submitted it)
683 683
 	 * @param mixed $value
684 684
 	 */
685
-	protected function _set_raw_value( $value ) {
686
-		$this->_raw_value = $this->_normalization_strategy->unnormalize( $value );
685
+	protected function _set_raw_value($value) {
686
+		$this->_raw_value = $this->_normalization_strategy->unnormalize($value);
687 687
 	}
688 688
 
689 689
 	/**
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
 	 * @param string $label
692 692
 	 * @return void
693 693
 	 */
694
-	public function set_html_label_text($label){
694
+	public function set_html_label_text($label) {
695 695
 		$this->_html_label_text = $label;
696 696
 	}
697 697
 
@@ -705,13 +705,13 @@  discard block
 block discarded – undo
705 705
 	 * @param boolean $required boolean
706 706
 	 * @param null    $required_text
707 707
 	 */
708
-	public function set_required($required = true, $required_text = NULL ){
709
-		$required = filter_var( $required, FILTER_VALIDATE_BOOLEAN  );
708
+	public function set_required($required = true, $required_text = NULL) {
709
+		$required = filter_var($required, FILTER_VALIDATE_BOOLEAN);
710 710
 		//whether $required is a string or a boolean, we want to add a required validation strategy
711
-		if ( $required ) {
712
-			$this->_add_validation_strategy( new EE_Required_Validation_Strategy( $required_text ) );
711
+		if ($required) {
712
+			$this->_add_validation_strategy(new EE_Required_Validation_Strategy($required_text));
713 713
 		} else {
714
-			unset( $this->_validation_strategies[ 'EE_Required_Validation_Strategy' ] );
714
+			unset($this->_validation_strategies['EE_Required_Validation_Strategy']);
715 715
 		}
716 716
 		$this->_required = $required;
717 717
 	}
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
 	 * Returns whether or not this field is required
720 720
 	 * @return boolean
721 721
 	 */
722
-	public function required(){
722
+	public function required() {
723 723
 		return $this->_required;
724 724
 	}
725 725
 
@@ -728,7 +728,7 @@  discard block
 block discarded – undo
728 728
 	/**
729 729
 	 * @param string $required_css_class
730 730
 	 */
731
-	public function set_required_css_class( $required_css_class ) {
731
+	public function set_required_css_class($required_css_class) {
732 732
 		$this->_required_css_class = $required_css_class;
733 733
 	}
734 734
 
@@ -747,7 +747,7 @@  discard block
 block discarded – undo
747 747
 	 * Sets the help text, in case
748 748
 	 * @param string $text
749 749
 	 */
750
-	public function set_html_help_text($text){
750
+	public function set_html_help_text($text) {
751 751
 		$this->_html_help_text = $text;
752 752
 	}
753 753
 	/**
@@ -759,9 +759,9 @@  discard block
 block discarded – undo
759 759
 	public function clean_sensitive_data() {
760 760
 		//if we do ANY kind of sensitive data removal on this, then just clear out the raw value
761 761
 		//if we need more logic than this we'll make a strategy for it
762
-		if( $this->_sensitive_data_removal_strategy &&
763
-				! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal ){
764
-			$this->_set_raw_value( null );
762
+		if ($this->_sensitive_data_removal_strategy &&
763
+				! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal) {
764
+			$this->_set_raw_value(null);
765 765
 		}
766 766
 		//and clean the normalized value according to the appropriate strategy
767 767
 		$this->_set_normalized_value(
@@ -778,10 +778,10 @@  discard block
 block discarded – undo
778 778
 	 * @param string $button_size
779 779
 	 * @param string $other_attributes
780 780
 	 */
781
-	public function set_button_css_attributes( $primary = TRUE, $button_size = '', $other_attributes = '' ) {
781
+	public function set_button_css_attributes($primary = TRUE, $button_size = '', $other_attributes = '') {
782 782
 		$button_css_attributes = 'button';
783 783
 		$button_css_attributes .= $primary === TRUE ? ' button-primary' : ' button-secondary';
784
-		switch ( $button_size ) {
784
+		switch ($button_size) {
785 785
 			case 'xs' :
786 786
 			case 'extra-small' :
787 787
 				$button_css_attributes .= ' button-xs';
@@ -802,8 +802,8 @@  discard block
 block discarded – undo
802 802
 			default :
803 803
 				$button_css_attributes .= '';
804 804
 		}
805
-		$this->_button_css_attributes .= ! empty( $other_attributes )
806
-			? $button_css_attributes . ' ' . $other_attributes
805
+		$this->_button_css_attributes .= ! empty($other_attributes)
806
+			? $button_css_attributes.' '.$other_attributes
807 807
 			: $button_css_attributes;
808 808
 	}
809 809
 
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
 	 * @return string
814 814
 	 */
815 815
 	public function button_css_attributes() {
816
-		if ( empty( $this->_button_css_attributes )) {
816
+		if (empty($this->_button_css_attributes)) {
817 817
 			$this->set_button_css_attributes();
818 818
 		}
819 819
 		return $this->_button_css_attributes;
@@ -835,26 +835,26 @@  discard block
 block discarded – undo
835 835
 	 * @return mixed whatever the raw value of this form section is in the request data
836 836
 	 * @throws \EE_Error
837 837
 	 */
838
-	public function find_form_data_for_this_section( $req_data ){
838
+	public function find_form_data_for_this_section($req_data) {
839 839
 		// break up the html name by "[]"
840
-		if ( strpos( $this->html_name(), '[' ) !== FALSE ) {
841
-			$before_any_brackets = substr( $this->html_name(), 0, strpos($this->html_name(), '[') );
840
+		if (strpos($this->html_name(), '[') !== FALSE) {
841
+			$before_any_brackets = substr($this->html_name(), 0, strpos($this->html_name(), '['));
842 842
 		} else {
843 843
 			$before_any_brackets = $this->html_name();
844 844
 		}
845 845
 		// grab all of the segments
846
-		preg_match_all('~\[([^]]*)\]~',$this->html_name(), $matches);
847
-		if( isset( $matches[ 1 ] ) && is_array( $matches[ 1 ] ) ){
848
-			$name_parts = $matches[ 1 ];
846
+		preg_match_all('~\[([^]]*)\]~', $this->html_name(), $matches);
847
+		if (isset($matches[1]) && is_array($matches[1])) {
848
+			$name_parts = $matches[1];
849 849
 			array_unshift($name_parts, $before_any_brackets);
850
-		}else{
851
-			$name_parts = array( $before_any_brackets );
850
+		} else {
851
+			$name_parts = array($before_any_brackets);
852 852
 		}
853 853
 		// now get the value for the input
854 854
 		$value = $this->_find_form_data_for_this_section_using_name_parts($name_parts, $req_data);
855 855
 		// check if this thing's name is at the TOP level of the request data
856
-		if( $value === null && isset( $req_data[ $this->name() ] ) ){
857
-			$value = $req_data[ $this->name() ];
856
+		if ($value === null && isset($req_data[$this->name()])) {
857
+			$value = $req_data[$this->name()];
858 858
 		}
859 859
 		return $value;
860 860
 	}
@@ -867,18 +867,18 @@  discard block
 block discarded – undo
867 867
 	 * @param array $req_data
868 868
 	 * @return array | NULL
869 869
 	 */
870
-	public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data){
871
-		$first_part_to_consider = array_shift( $html_name_parts );
872
-		if( isset( $req_data[ $first_part_to_consider ] ) ){
873
-			if( empty($html_name_parts ) ){
874
-				return $req_data[ $first_part_to_consider ];
875
-			}else{
870
+	public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data) {
871
+		$first_part_to_consider = array_shift($html_name_parts);
872
+		if (isset($req_data[$first_part_to_consider])) {
873
+			if (empty($html_name_parts)) {
874
+				return $req_data[$first_part_to_consider];
875
+			} else {
876 876
 				return $this->_find_form_data_for_this_section_using_name_parts(
877 877
 					$html_name_parts,
878
-					$req_data[ $first_part_to_consider ]
878
+					$req_data[$first_part_to_consider]
879 879
 				);
880 880
 			}
881
-		}else{
881
+		} else {
882 882
 			return NULL;
883 883
 		}
884 884
 	}
@@ -892,14 +892,14 @@  discard block
 block discarded – undo
892 892
 	 * @return boolean
893 893
 	 * @throws \EE_Error
894 894
 	 */
895
-	public function form_data_present_in($req_data = NULL){
896
-		if( $req_data === NULL ){
895
+	public function form_data_present_in($req_data = NULL) {
896
+		if ($req_data === NULL) {
897 897
 			$req_data = $_POST;
898 898
 		}
899
-		$checked_value = $this->find_form_data_for_this_section( $req_data );
900
-		if( $checked_value !== null ){
899
+		$checked_value = $this->find_form_data_for_this_section($req_data);
900
+		if ($checked_value !== null) {
901 901
 			return TRUE;
902
-		}else{
902
+		} else {
903 903
 			return FALSE;
904 904
 		}
905 905
 	}
@@ -910,8 +910,8 @@  discard block
 block discarded – undo
910 910
 	 * @param array $form_other_js_data
911 911
 	 * @return array
912 912
 	 */
913
-	public function get_other_js_data( $form_other_js_data = array() ) {
914
-		$form_other_js_data = $this->get_other_js_data_from_strategies( $form_other_js_data );
913
+	public function get_other_js_data($form_other_js_data = array()) {
914
+		$form_other_js_data = $this->get_other_js_data_from_strategies($form_other_js_data);
915 915
 		return $form_other_js_data;
916 916
 	}
917 917
 
@@ -924,10 +924,10 @@  discard block
 block discarded – undo
924 924
 	 * @param array $form_other_js_data
925 925
 	 * @return array
926 926
 	 */
927
-	public function get_other_js_data_from_strategies( $form_other_js_data = array() ) {
928
-		$form_other_js_data = $this->get_display_strategy()->get_other_js_data( $form_other_js_data );
929
-		foreach( $this->get_validation_strategies() as $validation_strategy ) {
930
-			$form_other_js_data = $validation_strategy->get_other_js_data( $form_other_js_data );
927
+	public function get_other_js_data_from_strategies($form_other_js_data = array()) {
928
+		$form_other_js_data = $this->get_display_strategy()->get_other_js_data($form_other_js_data);
929
+		foreach ($this->get_validation_strategies() as $validation_strategy) {
930
+			$form_other_js_data = $validation_strategy->get_other_js_data($form_other_js_data);
931 931
 		}
932 932
 		return $form_other_js_data;
933 933
 	}
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
 	 * Override parent because we want to give our strategies an opportunity to enqueue some js and css
937 937
 	 * @return void
938 938
 	 */
939
-	public function enqueue_js(){
939
+	public function enqueue_js() {
940 940
 		//ask our display strategy and validation strategies if they have js to enqueue
941 941
 		$this->enqueue_js_from_strategies();
942 942
 	}
@@ -947,7 +947,7 @@  discard block
 block discarded – undo
947 947
 	 */
948 948
 	public function enqueue_js_from_strategies() {
949 949
 		$this->get_display_strategy()->enqueue_js();
950
-		foreach( $this->get_validation_strategies() as $validation_strategy ) {
950
+		foreach ($this->get_validation_strategies() as $validation_strategy) {
951 951
 			$validation_strategy->enqueue_js();
952 952
 		}
953 953
 	}
Please login to merge, or discard this patch.
core/db_models/EEM_Base.model.php 1 patch
Spacing   +975 added lines, -975 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  * @since 				EE4
24 24
  *
25 25
  */
26
-abstract class EEM_Base extends EE_Base{
26
+abstract class EEM_Base extends EE_Base {
27 27
 
28 28
 	//admin posty
29 29
 	//basic -> grants access to mine -> if they don't have it, select none
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 	 * Flag indicating whether this model has a primary key or not
244 244
 	 * @var boolean
245 245
 	 */
246
-	protected $_has_primary_key_field=null;
246
+	protected $_has_primary_key_field = null;
247 247
 
248 248
 	/**
249 249
 	 * Whether or not this model is based off a table in WP core only (CPTs should set
@@ -305,19 +305,19 @@  discard block
 block discarded – undo
305 305
 	 * operators that work like 'BETWEEN'.  Typically used for datetime calculations, i.e. "BETWEEN '12-1-2011' AND '12-31-2012'"
306 306
 	 * @var array
307 307
 	 */
308
-	protected $_between_style_operators = array( 'BETWEEN' );
308
+	protected $_between_style_operators = array('BETWEEN');
309 309
 
310 310
 	/**
311 311
 	 * operators that are used for handling NUll and !NULL queries.  Typically used for when checking if a row exists on a join table.
312 312
 	 * @var array
313 313
 	 */
314
-	protected $_null_style_operators = array( 'IS NOT NULL', 'IS NULL');
314
+	protected $_null_style_operators = array('IS NOT NULL', 'IS NULL');
315 315
 
316 316
 	/**
317 317
 	 * Allowed values for $query_params['order'] for ordering in queries
318 318
 	 * @var array
319 319
 	 */
320
-	protected $_allowed_order_values = array('asc','desc','ASC','DESC');
320
+	protected $_allowed_order_values = array('asc', 'desc', 'ASC', 'DESC');
321 321
 
322 322
 	/**
323 323
 	 * When these are keys in a WHERE or HAVING clause, they are handled much differently
@@ -331,13 +331,13 @@  discard block
 block discarded – undo
331 331
 	 * 'where', but 'where' clauses are so common that we thought we'd omit it
332 332
 	 * @var array
333 333
 	 */
334
-	private $_allowed_query_params = array(0, 'limit','order_by','group_by','having','force_join','order','on_join_limit','default_where_conditions', 'caps');
334
+	private $_allowed_query_params = array(0, 'limit', 'order_by', 'group_by', 'having', 'force_join', 'order', 'on_join_limit', 'default_where_conditions', 'caps');
335 335
 
336 336
 	/**
337 337
 	 * All the data types that can be used in $wpdb->prepare statements.
338 338
 	 * @var array
339 339
 	 */
340
-	private $_valid_wpdb_data_types = array('%d','%s','%f');
340
+	private $_valid_wpdb_data_types = array('%d', '%s', '%f');
341 341
 
342 342
 	/**
343 343
 	 * 	EE_Registry Object
@@ -370,17 +370,17 @@  discard block
 block discarded – undo
370 370
 	/**
371 371
 	 * constant used to show EEM_Base has not yet verified the db on this http request
372 372
 	 */
373
-	const db_verified_none 		= 0;
373
+	const db_verified_none = 0;
374 374
 	/**
375 375
 	 * constant used to show EEM_Base has verified the EE core db on this http request,
376 376
 	 * but not the addons' dbs
377 377
 	 */
378
-	const db_verified_core 		= 1;
378
+	const db_verified_core = 1;
379 379
 	/**
380 380
 	 * constant used to show EEM_Base has verified the addons' dbs (and implicitly
381 381
 	 * the EE core db too)
382 382
 	 */
383
-	const db_verified_addons 	= 2;
383
+	const db_verified_addons = 2;
384 384
 
385 385
 	/**
386 386
 	 * indicates whether an EEM_Base child has already re-verified the DB
@@ -411,13 +411,13 @@  discard block
 block discarded – undo
411 411
 	 * @param null $timezone
412 412
 	 * @throws \EE_Error
413 413
 	 */
414
-	protected function __construct( $timezone = NULL ){
414
+	protected function __construct($timezone = NULL) {
415 415
 		// check that the model has not been loaded too soon
416
-		if ( ! did_action( 'AHEE__EE_System__load_espresso_addons' )) {
417
-			throw new EE_Error (
416
+		if ( ! did_action('AHEE__EE_System__load_espresso_addons')) {
417
+			throw new EE_Error(
418 418
 				sprintf(
419
-					__( 'The %1$s model can not be loaded before the "AHEE__EE_System__load_espresso_addons" hook has been called. This gives other addons a chance to extend this model.', 'event_espresso' ),
420
-					get_class( $this )
419
+					__('The %1$s model can not be loaded before the "AHEE__EE_System__load_espresso_addons" hook has been called. This gives other addons a chance to extend this model.', 'event_espresso'),
420
+					get_class($this)
421 421
 				)
422 422
 			);
423 423
 		}
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
 		/**
426 426
 		 * Set blogid for models to current blog. However we ONLY do this if $_model_query_blog_id is not already set.
427 427
 		 */
428
-		if ( empty( EEM_Base::$_model_query_blog_id ) ) {
428
+		if (empty(EEM_Base::$_model_query_blog_id)) {
429 429
 			EEM_Base::set_model_query_blog_id();
430 430
 		}
431 431
 
@@ -434,11 +434,11 @@  discard block
 block discarded – undo
434 434
 		 * just use EE_Register_Model_Extension
435 435
 		 * @var EE_Table_Base[] $_tables
436 436
 		 */
437
-		$this->_tables = apply_filters( 'FHEE__'.get_class($this).'__construct__tables', $this->_tables );
438
-		foreach($this->_tables as $table_alias => $table_obj){
437
+		$this->_tables = apply_filters('FHEE__'.get_class($this).'__construct__tables', $this->_tables);
438
+		foreach ($this->_tables as $table_alias => $table_obj) {
439 439
 			/** @var $table_obj EE_Table_Base */
440 440
 			$table_obj->_construct_finalize_with_alias($table_alias);
441
-			if( $table_obj instanceof EE_Secondary_Table ){
441
+			if ($table_obj instanceof EE_Secondary_Table) {
442 442
 				/** @var $table_obj EE_Secondary_Table */
443 443
 				$table_obj->_construct_finalize_set_table_to_join_with($this->_get_main_table());
444 444
 			}
@@ -448,54 +448,54 @@  discard block
 block discarded – undo
448 448
 		 * EE_Register_Model_Extension
449 449
 		 * @param EE_Model_Field_Base[] $_fields
450 450
 		 */
451
-		$this->_fields = apply_filters('FHEE__'.get_class($this).'__construct__fields',$this->_fields);
451
+		$this->_fields = apply_filters('FHEE__'.get_class($this).'__construct__fields', $this->_fields);
452 452
 		$this->_invalidate_field_caches();
453
-		foreach($this->_fields as $table_alias => $fields_for_table){
454
-			if ( ! array_key_exists( $table_alias, $this->_tables )){
455
-				throw new EE_Error(sprintf(__("Table alias %s does not exist in EEM_Base child's _tables array. Only tables defined are %s",'event_espresso'),$table_alias,implode(",",$this->_fields)));
453
+		foreach ($this->_fields as $table_alias => $fields_for_table) {
454
+			if ( ! array_key_exists($table_alias, $this->_tables)) {
455
+				throw new EE_Error(sprintf(__("Table alias %s does not exist in EEM_Base child's _tables array. Only tables defined are %s", 'event_espresso'), $table_alias, implode(",", $this->_fields)));
456 456
 			}
457
-			foreach($fields_for_table as $field_name => $field_obj){
457
+			foreach ($fields_for_table as $field_name => $field_obj) {
458 458
 				/** @var $field_obj EE_Model_Field_Base | EE_Primary_Key_Field_Base */
459 459
 				//primary key field base has a slightly different _construct_finalize
460 460
 				/** @var $field_obj EE_Model_Field_Base */
461
-				$field_obj->_construct_finalize( $table_alias, $field_name, $this->get_this_model_name() );
461
+				$field_obj->_construct_finalize($table_alias, $field_name, $this->get_this_model_name());
462 462
 			}
463 463
 		}
464 464
 
465 465
 		// everything is related to Extra_Meta
466
-		if( get_class($this) !== 'EEM_Extra_Meta'){
466
+		if (get_class($this) !== 'EEM_Extra_Meta') {
467 467
 			//make extra meta related to everything, but don't block deleting things just
468 468
 			//because they have related extra meta info. For now just orphan those extra meta
469 469
 			//in the future we should automatically delete them
470
-			$this->_model_relations['Extra_Meta'] = new EE_Has_Many_Any_Relation( FALSE );
470
+			$this->_model_relations['Extra_Meta'] = new EE_Has_Many_Any_Relation(FALSE);
471 471
 		}
472 472
 		//and change logs
473
-		if( get_class( $this) !==  'EEM_Change_Log' ) {
474
-			$this->_model_relations[ 'Change_Log' ] = new EE_Has_Many_Any_Relation( FALSE );
473
+		if (get_class($this) !== 'EEM_Change_Log') {
474
+			$this->_model_relations['Change_Log'] = new EE_Has_Many_Any_Relation(FALSE);
475 475
 		}
476 476
 		/**
477 477
 		 * Filters the list of relations on a model. It is best to NOT use this directly and instead just use
478 478
 		 * EE_Register_Model_Extension
479 479
 		 * @param EE_Model_Relation_Base[] $_model_relations
480 480
 		 */
481
-		$this->_model_relations = apply_filters('FHEE__'.get_class($this).'__construct__model_relations',$this->_model_relations);
482
-		foreach($this->_model_relations as $model_name => $relation_obj){
481
+		$this->_model_relations = apply_filters('FHEE__'.get_class($this).'__construct__model_relations', $this->_model_relations);
482
+		foreach ($this->_model_relations as $model_name => $relation_obj) {
483 483
 			/** @var $relation_obj EE_Model_Relation_Base */
484 484
 			$relation_obj->_construct_finalize_set_models($this->get_this_model_name(), $model_name);
485 485
 		}
486
-		foreach($this->_indexes as $index_name => $index_obj){
486
+		foreach ($this->_indexes as $index_name => $index_obj) {
487 487
 			/** @var $index_obj EE_Index */
488 488
 			$index_obj->_construct_finalize($index_name, $this->get_this_model_name());
489 489
 		}
490 490
 
491 491
 		$this->set_timezone($timezone);
492 492
 		//finalize default where condition strategy, or set default
493
-		if( ! $this->_default_where_conditions_strategy){
493
+		if ( ! $this->_default_where_conditions_strategy) {
494 494
 			//nothing was set during child constructor, so set default
495 495
 			$this->_default_where_conditions_strategy = new EE_Default_Where_Conditions();
496 496
 		}
497 497
 		$this->_default_where_conditions_strategy->_finalize_construct($this);
498
-		if( ! $this->_minimum_where_conditions_strategy){
498
+		if ( ! $this->_minimum_where_conditions_strategy) {
499 499
 			//nothing was set during child constructor, so set default
500 500
 			$this->_minimum_where_conditions_strategy = new EE_Default_Where_Conditions();
501 501
 		}
@@ -503,14 +503,14 @@  discard block
 block discarded – undo
503 503
 
504 504
 		//if the cap slug hasn't been set, and we haven't set it to false on purpose
505 505
 		//to indicate to NOT set it, set it to the logical default
506
-		if( $this->_caps_slug === null ) {
507
-			$this->_caps_slug = EEH_Inflector::pluralize_and_lower( $this->get_this_model_name() );
506
+		if ($this->_caps_slug === null) {
507
+			$this->_caps_slug = EEH_Inflector::pluralize_and_lower($this->get_this_model_name());
508 508
 		}
509 509
 		//initialize the standard cap restriction generators if none were specified by the child constructor
510
-		if( $this->_cap_restriction_generators !== false ){
511
-			foreach( $this->cap_contexts_to_cap_action_map() as $cap_context => $action ){
512
-				if( ! isset( $this->_cap_restriction_generators[ $cap_context ] ) ) {
513
-					$this->_cap_restriction_generators[ $cap_context ] = apply_filters(
510
+		if ($this->_cap_restriction_generators !== false) {
511
+			foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) {
512
+				if ( ! isset($this->_cap_restriction_generators[$cap_context])) {
513
+					$this->_cap_restriction_generators[$cap_context] = apply_filters(
514 514
 						'FHEE__EEM_Base___construct__standard_cap_restriction_generator',
515 515
 						new EE_Restriction_Generator_Protected(),
516 516
 						$cap_context,
@@ -520,23 +520,23 @@  discard block
 block discarded – undo
520 520
 			}
521 521
 		}
522 522
 		//if there are cap restriction generators, use them to make the default cap restrictions
523
-		if( $this->_cap_restriction_generators !== false ){
524
-			foreach( $this->_cap_restriction_generators as $context => $generator_object ) {
525
-				if( ! $generator_object ){
523
+		if ($this->_cap_restriction_generators !== false) {
524
+			foreach ($this->_cap_restriction_generators as $context => $generator_object) {
525
+				if ( ! $generator_object) {
526 526
 					continue;
527 527
 				}
528
-				if( ! $generator_object instanceof EE_Restriction_Generator_Base ){
528
+				if ( ! $generator_object instanceof EE_Restriction_Generator_Base) {
529 529
 					throw new EE_Error(
530 530
 						sprintf(
531
-							__( 'Index "%1$s" in the model %2$s\'s _cap_restriction_generators is not a child of EE_Restriction_Generator_Base. It should be that or NULL.', 'event_espresso' ),
531
+							__('Index "%1$s" in the model %2$s\'s _cap_restriction_generators is not a child of EE_Restriction_Generator_Base. It should be that or NULL.', 'event_espresso'),
532 532
 							$context,
533 533
 							$this->get_this_model_name()
534 534
 						)
535 535
 					);
536 536
 				}
537
-				$action = $this->cap_action_for_context( $context );
538
-				if( ! $generator_object->construction_finalized() ){
539
-					$generator_object->_construct_finalize( $this, $action );
537
+				$action = $this->cap_action_for_context($context);
538
+				if ( ! $generator_object->construction_finalized()) {
539
+					$generator_object->_construct_finalize($this, $action);
540 540
 				}
541 541
 
542 542
 			}
@@ -550,11 +550,11 @@  discard block
 block discarded – undo
550 550
 	 * @param string $context one of EEM_Base::valid_cap_contexts()
551 551
 	 * @return EE_Default_Where_Conditions[]
552 552
 	 */
553
-	protected function _generate_cap_restrictions( $context ){
554
-		if( isset( $this->_cap_restriction_generators[ $context ] ) &&
555
-				$this->_cap_restriction_generators[ $context ] instanceof EE_Restriction_Generator_Base ) {
556
-			return $this->_cap_restriction_generators[ $context ]->generate_restrictions();
557
-		}else{
553
+	protected function _generate_cap_restrictions($context) {
554
+		if (isset($this->_cap_restriction_generators[$context]) &&
555
+				$this->_cap_restriction_generators[$context] instanceof EE_Restriction_Generator_Base) {
556
+			return $this->_cap_restriction_generators[$context]->generate_restrictions();
557
+		} else {
558 558
 			return array();
559 559
 		}
560 560
 	}
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
 	 * @param int $blog_id  If provided then will set the blog_id for the models to this id.  If not provided then the
567 567
 	 *                      value for get_current_blog_id() will be used.
568 568
 	 */
569
-	public static function set_model_query_blog_id( $blog_id = 0 ) {
569
+	public static function set_model_query_blog_id($blog_id = 0) {
570 570
 		EEM_Base::$_model_query_blog_id = $blog_id > 0 ? (int) $blog_id : get_current_blog_id();
571 571
 	}
572 572
 
@@ -591,16 +591,16 @@  discard block
 block discarded – undo
591 591
 	 *		@param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved).  Note this just sends the timezone info to the date time model field objects.  Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option)
592 592
 	 *		@return static (as in the concrete child class)
593 593
 	 */
594
-	public static function instance( $timezone = NULL ){
594
+	public static function instance($timezone = NULL) {
595 595
 
596 596
 		// check if instance of Espresso_model already exists
597 597
 		if ( ! static::$_instance instanceof static) {
598 598
 			// instantiate Espresso_model
599
-			static::$_instance = new static( $timezone );
599
+			static::$_instance = new static($timezone);
600 600
 		}
601 601
 
602 602
 		//we might have a timezone set, let set_timezone decide what to do with it
603
-		static::$_instance->set_timezone( $timezone );
603
+		static::$_instance->set_timezone($timezone);
604 604
 
605 605
 		// Espresso_model object
606 606
 		return static::$_instance;
@@ -613,11 +613,11 @@  discard block
 block discarded – undo
613 613
 	 * @param null | string $timezone
614 614
 	 * @return static
615 615
 	 */
616
-	public static function reset(  $timezone = NULL ){
617
-		if ( ! is_null( static::$_instance ) ) {
616
+	public static function reset($timezone = NULL) {
617
+		if ( ! is_null(static::$_instance)) {
618 618
 			static::$_instance = null;
619 619
 
620
-			return self::instance( $timezone );
620
+			return self::instance($timezone);
621 621
 		}
622 622
 		return null;
623 623
 	}
@@ -631,19 +631,19 @@  discard block
 block discarded – undo
631 631
 	 * @return array
632 632
 	 * @throws \EE_Error
633 633
 	 */
634
-	 public function status_array( $translated = FALSE ) {
635
-		 if ( ! array_key_exists( 'Status', $this->_model_relations ) ) {
634
+	 public function status_array($translated = FALSE) {
635
+		 if ( ! array_key_exists('Status', $this->_model_relations)) {
636 636
 			 return array();
637 637
 		 }
638 638
 		 $model_name = $this->get_this_model_name();
639
-		 $status_type = str_replace( ' ', '_', strtolower( str_replace( '_', ' ', $model_name ) ) );
640
-		 $stati = EEM_Status::instance()->get_all( array( array( 'STS_type' => $status_type ) ) );
639
+		 $status_type = str_replace(' ', '_', strtolower(str_replace('_', ' ', $model_name)));
640
+		 $stati = EEM_Status::instance()->get_all(array(array('STS_type' => $status_type)));
641 641
 		 $status_array = array();
642
-		 foreach ( $stati as $status ) {
643
-			 $status_array[ $status->ID() ] = $status->get( 'STS_code' );
642
+		 foreach ($stati as $status) {
643
+			 $status_array[$status->ID()] = $status->get('STS_code');
644 644
 		 }
645 645
 		 return $translated
646
-			 ? EEM_Status::instance()->localized_status( $status_array, false, 'sentence' )
646
+			 ? EEM_Status::instance()->localized_status($status_array, false, 'sentence')
647 647
 			 : $status_array;
648 648
 	 }
649 649
 
@@ -776,10 +776,10 @@  discard block
 block discarded – undo
776 776
 	 *		));
777 777
 	 * @throws \EE_Error
778 778
 	 */
779
-	public function get_all($query_params = array()){
780
-		if( isset( $query_params[ 'limit' ] )
781
-			&& ! isset( $query_params[ 'group_by' ] ) ) {
782
-			$query_params[ 'group_by' ] = array_keys( $this->get_combined_primary_key_fields() );
779
+	public function get_all($query_params = array()) {
780
+		if (isset($query_params['limit'])
781
+			&& ! isset($query_params['group_by'])) {
782
+			$query_params['group_by'] = array_keys($this->get_combined_primary_key_fields());
783 783
 		}
784 784
 		return $this->_create_objects($this->_get_all_wpdb_results($query_params, ARRAY_A, NULL));
785 785
 	}
@@ -790,10 +790,10 @@  discard block
 block discarded – undo
790 790
 	 * @param array $query_params @see EEM_Base::get_all()
791 791
 	 * @return array like EEM_Base::get_all
792 792
 	 */
793
-	public function alter_query_params_to_only_include_mine( $query_params = array() ) {
793
+	public function alter_query_params_to_only_include_mine($query_params = array()) {
794 794
 		$wp_user_field_name = $this->wp_user_field_name();
795
-		if( $wp_user_field_name ){
796
-			$query_params[0][ $wp_user_field_name ] = get_current_user_id();
795
+		if ($wp_user_field_name) {
796
+			$query_params[0][$wp_user_field_name] = get_current_user_id();
797 797
 		}
798 798
 		return $query_params;
799 799
 	}
@@ -806,19 +806,19 @@  discard block
 block discarded – undo
806 806
 	 * foreign key to the WP_User table
807 807
 	 */
808 808
 	public function wp_user_field_name() {
809
-		try{
810
-			if( ! empty( $this->_model_chain_to_wp_user ) ) {
811
-				$models_to_follow_to_wp_users = explode( '.', $this->_model_chain_to_wp_user );
812
-				$last_model_name = end( $models_to_follow_to_wp_users );
813
-				$model_with_fk_to_wp_users = EE_Registry::instance()->load_model( $last_model_name );
814
-				$model_chain_to_wp_user = $this->_model_chain_to_wp_user . '.';
815
-			}else{
809
+		try {
810
+			if ( ! empty($this->_model_chain_to_wp_user)) {
811
+				$models_to_follow_to_wp_users = explode('.', $this->_model_chain_to_wp_user);
812
+				$last_model_name = end($models_to_follow_to_wp_users);
813
+				$model_with_fk_to_wp_users = EE_Registry::instance()->load_model($last_model_name);
814
+				$model_chain_to_wp_user = $this->_model_chain_to_wp_user.'.';
815
+			} else {
816 816
 				$model_with_fk_to_wp_users = $this;
817 817
 				$model_chain_to_wp_user = '';
818 818
 			}
819
-			$wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to( 'WP_User' );
820
-			return $model_chain_to_wp_user . $wp_user_field->get_name();
821
-		}catch( EE_Error $e ) {
819
+			$wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to('WP_User');
820
+			return $model_chain_to_wp_user.$wp_user_field->get_name();
821
+		} catch (EE_Error $e) {
822 822
 			return false;
823 823
 		}
824 824
 	}
@@ -832,7 +832,7 @@  discard block
 block discarded – undo
832 832
 	 * (or transiently-related model)
833 833
 	 * @return string
834 834
 	 */
835
-	public function model_chain_to_wp_user(){
835
+	public function model_chain_to_wp_user() {
836 836
 		return $this->_model_chain_to_wp_user;
837 837
 	}
838 838
 
@@ -844,13 +844,13 @@  discard block
 block discarded – undo
844 844
 	 * @return boolean
845 845
 	 */
846 846
 	public function is_owned() {
847
-		if( $this->model_chain_to_wp_user() ){
847
+		if ($this->model_chain_to_wp_user()) {
848 848
 			return true;
849
-		}else{
850
-			try{
851
-				$this->get_foreign_key_to( 'WP_User' );
849
+		} else {
850
+			try {
851
+				$this->get_foreign_key_to('WP_User');
852 852
 				return true;
853
-			}catch( EE_Error $e ){
853
+			} catch (EE_Error $e) {
854 854
 				return false;
855 855
 			}
856 856
 		}
@@ -872,17 +872,17 @@  discard block
 block discarded – undo
872 872
 	 * @return array | stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT)
873 873
 	 * @throws \EE_Error
874 874
 	 */
875
-	protected function  _get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){
875
+	protected function  _get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null) {
876 876
 		// remember the custom selections, if any, and type cast as array
877 877
 		// (unless $columns_to_select is an object, then just set as an empty array)
878 878
 		// Note: (array) 'some string' === array( 'some string' )
879
-		$this->_custom_selections = ! is_object( $columns_to_select ) ? (array) $columns_to_select : array();
880
-		$model_query_info = $this->_create_model_query_info_carrier( $query_params );
879
+		$this->_custom_selections = ! is_object($columns_to_select) ? (array) $columns_to_select : array();
880
+		$model_query_info = $this->_create_model_query_info_carrier($query_params);
881 881
 		$select_expressions = $columns_to_select !== null
882
-			? $this->_construct_select_from_input( $columns_to_select )
883
-			: $this->_construct_default_select_sql( $model_query_info );
884
-		$SQL = "SELECT $select_expressions " . $this->_construct_2nd_half_of_select_query( $model_query_info );
885
-		return $this->_do_wpdb_query( 'get_results', array( $SQL, $output ) );
882
+			? $this->_construct_select_from_input($columns_to_select)
883
+			: $this->_construct_default_select_sql($model_query_info);
884
+		$SQL = "SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
885
+		return $this->_do_wpdb_query('get_results', array($SQL, $output));
886 886
 	}
887 887
 
888 888
 	/**
@@ -900,7 +900,7 @@  discard block
 block discarded – undo
900 900
 	 * @return array|stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT)
901 901
 	 * @throws \EE_Error
902 902
 	 */
903
-	public function  get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){
903
+	public function  get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null) {
904 904
 		return $this->_get_all_wpdb_results($query_params, $output, $columns_to_select);
905 905
 	}
906 906
 
@@ -912,12 +912,12 @@  discard block
 block discarded – undo
912 912
 	 * @throws EE_Error
913 913
 	 * @return string
914 914
 	 */
915
-	private function _construct_select_from_input($columns_to_select){
916
-		if(is_array($columns_to_select)){
915
+	private function _construct_select_from_input($columns_to_select) {
916
+		if (is_array($columns_to_select)) {
917 917
 			$select_sql_array = array();
918 918
 
919
-			foreach($columns_to_select as $alias => $selection_and_datatype){
920
-				if( ! is_array($selection_and_datatype) || ! isset($selection_and_datatype[1])){
919
+			foreach ($columns_to_select as $alias => $selection_and_datatype) {
920
+				if ( ! is_array($selection_and_datatype) || ! isset($selection_and_datatype[1])) {
921 921
 					throw new EE_Error(
922 922
 						sprintf(
923 923
 							__(
@@ -929,24 +929,24 @@  discard block
 block discarded – undo
929 929
 						)
930 930
 					);
931 931
 				}
932
-				if( ! in_array( $selection_and_datatype[1],$this->_valid_wpdb_data_types)){
932
+				if ( ! in_array($selection_and_datatype[1], $this->_valid_wpdb_data_types)) {
933 933
 					throw new EE_Error(
934 934
 						sprintf(
935 935
 							__(
936 936
 								"Datatype %s (for selection '%s' and alias '%s') is not a valid wpdb datatype (eg %%s)",
937 937
 								"event_espresso"
938 938
 							),
939
-							$selection_and_datatype[ 1 ],
940
-							$selection_and_datatype[ 0 ],
939
+							$selection_and_datatype[1],
940
+							$selection_and_datatype[0],
941 941
 							$alias,
942
-							implode( ",", $this->_valid_wpdb_data_types )
942
+							implode(",", $this->_valid_wpdb_data_types)
943 943
 						)
944 944
 					);
945 945
 				}
946 946
 				$select_sql_array[] = "{$selection_and_datatype[0]} AS $alias";
947 947
 			}
948
-			$columns_to_select_string = implode(", ",$select_sql_array);
949
-		}else{
948
+			$columns_to_select_string = implode(", ", $select_sql_array);
949
+		} else {
950 950
 			$columns_to_select_string = $columns_to_select;
951 951
 		}
952 952
 		return $columns_to_select_string;
@@ -961,7 +961,7 @@  discard block
 block discarded – undo
961 961
 	 * @return string
962 962
 	 * @throws \EE_Error
963 963
 	 */
964
-	public function primary_key_name(){
964
+	public function primary_key_name() {
965 965
 		return $this->get_primary_key_field()->get_name();
966 966
 	}
967 967
 
@@ -973,14 +973,14 @@  discard block
 block discarded – undo
973 973
 	 * @param mixed $id int or string, depending on the type of the model's primary key
974 974
 	 * @return EE_Base_Class
975 975
 	 */
976
-	public function get_one_by_ID($id){
977
-		if( $this->get_from_entity_map( $id ) ){
978
-			return $this->get_from_entity_map( $id );
976
+	public function get_one_by_ID($id) {
977
+		if ($this->get_from_entity_map($id)) {
978
+			return $this->get_from_entity_map($id);
979 979
 		}
980 980
 		return $this->get_one(
981 981
 			$this->alter_query_params_to_restrict_by_ID(
982 982
 				$id,
983
-				array( 'default_where_conditions' => 'minimum' )
983
+				array('default_where_conditions' => 'minimum')
984 984
 			)
985 985
 		);
986 986
 	}
@@ -996,15 +996,15 @@  discard block
 block discarded – undo
996 996
 	 * @return array of normal query params, @see EEM_Base::get_all
997 997
 	 * @throws \EE_Error
998 998
 	 */
999
-	public function alter_query_params_to_restrict_by_ID( $id, $query_params = array() ) {
1000
-		if( ! isset( $query_params[ 0 ] ) ) {
1001
-			$query_params[ 0 ] = array();
999
+	public function alter_query_params_to_restrict_by_ID($id, $query_params = array()) {
1000
+		if ( ! isset($query_params[0])) {
1001
+			$query_params[0] = array();
1002 1002
 		}
1003
-		if( $this->has_primary_key_field ( ) ) {
1004
-			$query_params[ 0 ][ $this->primary_key_name() ] = $id ;
1005
-		}else{
1003
+		if ($this->has_primary_key_field( )) {
1004
+			$query_params[0][$this->primary_key_name()] = $id;
1005
+		} else {
1006 1006
 			//no primary key, so the $id must be from the get_index_primary_key_string()
1007
-			$query_params[0] = array_replace_recursive( $query_params[ 0 ], $this->parse_index_primary_key_string( $id ) );
1007
+			$query_params[0] = array_replace_recursive($query_params[0], $this->parse_index_primary_key_string($id));
1008 1008
 		}
1009 1009
 		return $query_params;
1010 1010
 	}
@@ -1020,16 +1020,16 @@  discard block
 block discarded – undo
1020 1020
 	 * @return EE_Base_Class|EE_Soft_Delete_Base_Class|NULL
1021 1021
 	 * @throws \EE_Error
1022 1022
 	 */
1023
-	public function get_one($query_params = array()){
1024
-		if( ! is_array( $query_params ) ){
1025
-			EE_Error::doing_it_wrong('EEM_Base::get_one', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
1023
+	public function get_one($query_params = array()) {
1024
+		if ( ! is_array($query_params)) {
1025
+			EE_Error::doing_it_wrong('EEM_Base::get_one', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
1026 1026
 			$query_params = array();
1027 1027
 		}
1028 1028
 		$query_params['limit'] = 1;
1029 1029
 		$items = $this->get_all($query_params);
1030
-		if(empty($items)){
1030
+		if (empty($items)) {
1031 1031
 			return null;
1032
-		}else{
1032
+		} else {
1033 1033
 			return array_shift($items);
1034 1034
 		}
1035 1035
 	}
@@ -1052,8 +1052,8 @@  discard block
 block discarded – undo
1052 1052
 	 * @return EE_Base_Class[]|array
1053 1053
 	 * @throws \EE_Error
1054 1054
 	 */
1055
-	public function next_x( $current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
1056
-		return $this->_get_consecutive( $current_field_value, '>', $field_to_order_by, $limit, $query_params, $columns_to_select );
1055
+	public function next_x($current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
1056
+		return $this->_get_consecutive($current_field_value, '>', $field_to_order_by, $limit, $query_params, $columns_to_select);
1057 1057
 	}
1058 1058
 
1059 1059
 
@@ -1074,8 +1074,8 @@  discard block
 block discarded – undo
1074 1074
 	 * @return EE_Base_Class[]|array
1075 1075
 	 * @throws \EE_Error
1076 1076
 	 */
1077
-	public function previous_x( $current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
1078
-		return $this->_get_consecutive( $current_field_value, '<', $field_to_order_by, $limit, $query_params, $columns_to_select );
1077
+	public function previous_x($current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
1078
+		return $this->_get_consecutive($current_field_value, '<', $field_to_order_by, $limit, $query_params, $columns_to_select);
1079 1079
 	}
1080 1080
 
1081 1081
 
@@ -1096,9 +1096,9 @@  discard block
 block discarded – undo
1096 1096
 	 * @return EE_Base_Class|null|array()
1097 1097
 	 * @throws \EE_Error
1098 1098
 	 */
1099
-	public function next( $current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) {
1100
-		$results = $this->_get_consecutive( $current_field_value, '>', $field_to_order_by, 1, $query_params, $columns_to_select );
1101
-		return empty( $results ) ? null : reset( $results );
1099
+	public function next($current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null) {
1100
+		$results = $this->_get_consecutive($current_field_value, '>', $field_to_order_by, 1, $query_params, $columns_to_select);
1101
+		return empty($results) ? null : reset($results);
1102 1102
 	}
1103 1103
 
1104 1104
 
@@ -1120,9 +1120,9 @@  discard block
 block discarded – undo
1120 1120
  * @return EE_Base_Class|null|array()
1121 1121
 	 * @throws EE_Error
1122 1122
 	 */
1123
-	public function previous( $current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) {
1124
-		$results = $this->_get_consecutive( $current_field_value, '<', $field_to_order_by, 1, $query_params, $columns_to_select );
1125
-		return empty( $results ) ? null : reset( $results );
1123
+	public function previous($current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null) {
1124
+		$results = $this->_get_consecutive($current_field_value, '<', $field_to_order_by, 1, $query_params, $columns_to_select);
1125
+		return empty($results) ? null : reset($results);
1126 1126
 	}
1127 1127
 
1128 1128
 
@@ -1143,42 +1143,42 @@  discard block
 block discarded – undo
1143 1143
 	 * @return EE_Base_Class[]|array
1144 1144
 	 * @throws EE_Error
1145 1145
 	 */
1146
-	protected function _get_consecutive( $current_field_value, $operand = '>', $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
1146
+	protected function _get_consecutive($current_field_value, $operand = '>', $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
1147 1147
 		//if $field_to_order_by is empty then let's assume we're ordering by the primary key.
1148
-		if ( empty( $field_to_order_by ) ) {
1149
-			if ( $this->has_primary_key_field() ) {
1148
+		if (empty($field_to_order_by)) {
1149
+			if ($this->has_primary_key_field()) {
1150 1150
 				$field_to_order_by = $this->get_primary_key_field()->get_name();
1151 1151
 			} else {
1152 1152
 
1153
-				if ( WP_DEBUG ) {
1154
-					throw new EE_Error( __( 'EEM_Base::_get_consecutive() has been called with no $field_to_order_by argument and there is no primary key on the field.  Please provide the field you would like to use as the base for retrieving the next item(s).', 'event_espresso' ) );
1153
+				if (WP_DEBUG) {
1154
+					throw new EE_Error(__('EEM_Base::_get_consecutive() has been called with no $field_to_order_by argument and there is no primary key on the field.  Please provide the field you would like to use as the base for retrieving the next item(s).', 'event_espresso'));
1155 1155
 				}
1156
-				EE_Error::add_error( __('There was an error with the query.', 'event_espresso') );
1156
+				EE_Error::add_error(__('There was an error with the query.', 'event_espresso'));
1157 1157
 				return array();
1158 1158
 			}
1159 1159
 		}
1160 1160
 
1161
-		if( ! is_array( $query_params ) ){
1162
-			EE_Error::doing_it_wrong('EEM_Base::_get_consecutive', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
1161
+		if ( ! is_array($query_params)) {
1162
+			EE_Error::doing_it_wrong('EEM_Base::_get_consecutive', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
1163 1163
 			$query_params = array();
1164 1164
 		}
1165 1165
 
1166 1166
 		//let's add the where query param for consecutive look up.
1167
-		$query_params[0][ $field_to_order_by ] = array( $operand, $current_field_value );
1167
+		$query_params[0][$field_to_order_by] = array($operand, $current_field_value);
1168 1168
 		$query_params['limit'] = $limit;
1169 1169
 
1170 1170
 		//set direction
1171
-		$incoming_orderby = isset( $query_params['order_by'] ) ? (array)$query_params['order_by'] : array();
1171
+		$incoming_orderby = isset($query_params['order_by']) ? (array) $query_params['order_by'] : array();
1172 1172
 		$query_params['order_by'] = $operand === '>'
1173
-			? array( $field_to_order_by => 'ASC' ) + $incoming_orderby
1174
-			: array( $field_to_order_by => 'DESC') + $incoming_orderby;
1173
+			? array($field_to_order_by => 'ASC') + $incoming_orderby
1174
+			: array($field_to_order_by => 'DESC') + $incoming_orderby;
1175 1175
 
1176 1176
 		//if $columns_to_select is empty then that means we're returning EE_Base_Class objects
1177
-		if ( empty( $columns_to_select ) ) {
1178
-			return $this->get_all( $query_params );
1177
+		if (empty($columns_to_select)) {
1178
+			return $this->get_all($query_params);
1179 1179
 		} else {
1180 1180
 			//getting just the fields
1181
-			return $this->_get_all_wpdb_results( $query_params, ARRAY_A, $columns_to_select );
1181
+			return $this->_get_all_wpdb_results($query_params, ARRAY_A, $columns_to_select);
1182 1182
 		}
1183 1183
 	}
1184 1184
 
@@ -1189,18 +1189,18 @@  discard block
 block discarded – undo
1189 1189
 	 * This sets the _timezone property after model object has been instantiated.
1190 1190
 	 * @param null | string $timezone valid PHP DateTimeZone timezone string
1191 1191
 	 */
1192
-	public function set_timezone( $timezone ) {
1193
-		if ( $timezone !== null ) {
1192
+	public function set_timezone($timezone) {
1193
+		if ($timezone !== null) {
1194 1194
 			$this->_timezone = $timezone;
1195 1195
 		}
1196 1196
 		//note we need to loop through relations and set the timezone on those objects as well.
1197
-		foreach ( $this->_model_relations as $relation ) {
1198
-			$relation->set_timezone( $timezone );
1197
+		foreach ($this->_model_relations as $relation) {
1198
+			$relation->set_timezone($timezone);
1199 1199
 		}
1200 1200
 		//and finally we do the same for any datetime fields
1201
-		foreach ( $this->_fields as $field ) {
1202
-			if ( $field instanceof EE_Datetime_Field ) {
1203
-				$field->set_timezone( $timezone );
1201
+		foreach ($this->_fields as $field) {
1202
+			if ($field instanceof EE_Datetime_Field) {
1203
+				$field->set_timezone($timezone);
1204 1204
 			}
1205 1205
 		}
1206 1206
 	}
@@ -1215,9 +1215,9 @@  discard block
 block discarded – undo
1215 1215
 	 */
1216 1216
 	public function get_timezone() {
1217 1217
 		//first validate if timezone is set.  If not, then let's set it be whatever is set on the model fields.
1218
-		if ( empty( $this->_timezone ) ) {
1219
-			foreach( $this->_fields as $field ) {
1220
-				if ( $field instanceof EE_Datetime_Field ) {
1218
+		if (empty($this->_timezone)) {
1219
+			foreach ($this->_fields as $field) {
1220
+				if ($field instanceof EE_Datetime_Field) {
1221 1221
 					$this->set_timezone($field->get_timezone());
1222 1222
 					break;
1223 1223
 				}
@@ -1225,8 +1225,8 @@  discard block
 block discarded – undo
1225 1225
 		}
1226 1226
 
1227 1227
 		//if timezone STILL empty then return the default timezone for the site.
1228
-		if ( empty( $this->_timezone ) ) {
1229
-			$this->set_timezone( EEH_DTT_Helper::get_timezone() );
1228
+		if (empty($this->_timezone)) {
1229
+			$this->set_timezone(EEH_DTT_Helper::get_timezone());
1230 1230
 		}
1231 1231
 		return $this->_timezone;
1232 1232
 	}
@@ -1244,19 +1244,19 @@  discard block
 block discarded – undo
1244 1244
 	 *
1245 1245
 	 * @return array formats in an array with the date format first, and the time format last.
1246 1246
 	 */
1247
-	public function get_formats_for( $field_name, $pretty = false ) {
1248
-		$field_settings = $this->field_settings_for( $field_name );
1247
+	public function get_formats_for($field_name, $pretty = false) {
1248
+		$field_settings = $this->field_settings_for($field_name);
1249 1249
 
1250 1250
 		//if not a valid EE_Datetime_Field then throw error
1251
-		if ( ! $field_settings instanceof EE_Datetime_Field ) {
1252
-			throw new EE_Error( sprintf( __('The field sent into EEM_Base::get_formats_for (%s) is not registered as a EE_Datetime_Field. Please check the spelling and make sure you are submitting the right field name to retrieve date_formats for.', 'event_espresso' ), $field_name ) );
1251
+		if ( ! $field_settings instanceof EE_Datetime_Field) {
1252
+			throw new EE_Error(sprintf(__('The field sent into EEM_Base::get_formats_for (%s) is not registered as a EE_Datetime_Field. Please check the spelling and make sure you are submitting the right field name to retrieve date_formats for.', 'event_espresso'), $field_name));
1253 1253
 		}
1254 1254
 
1255 1255
 		//while we are here, let's make sure the timezone internally in EEM_Base matches what is stored on
1256 1256
 		//the field.
1257 1257
 		$this->_timezone = $field_settings->get_timezone();
1258 1258
 
1259
-		return array( $field_settings->get_date_format( $pretty ), $field_settings->get_time_format( $pretty ) );
1259
+		return array($field_settings->get_date_format($pretty), $field_settings->get_time_format($pretty));
1260 1260
 	}
1261 1261
 
1262 1262
 
@@ -1280,25 +1280,25 @@  discard block
 block discarded – undo
1280 1280
 	 * @return int|string  If the given field_name is not of the EE_Datetime_Field type, then an EE_Error
1281 1281
 	 *                    	     exception is triggered.
1282 1282
 	 */
1283
-	public function current_time_for_query( $field_name, $timestamp = false, $what = 'both' ) {
1284
-		$formats = $this->get_formats_for( $field_name );
1283
+	public function current_time_for_query($field_name, $timestamp = false, $what = 'both') {
1284
+		$formats = $this->get_formats_for($field_name);
1285 1285
 
1286
-		$DateTime = new DateTime( "now", new DateTimeZone( $this->_timezone ) );
1286
+		$DateTime = new DateTime("now", new DateTimeZone($this->_timezone));
1287 1287
 
1288
-		if ( $timestamp ) {
1289
-			return $DateTime->format( 'U' );
1288
+		if ($timestamp) {
1289
+			return $DateTime->format('U');
1290 1290
 		}
1291 1291
 
1292 1292
 		//not returning timestamp, so return formatted string in timezone.
1293
-		switch( $what ) {
1293
+		switch ($what) {
1294 1294
 			case 'time' :
1295
-				return $DateTime->format( $formats[1] );
1295
+				return $DateTime->format($formats[1]);
1296 1296
 				break;
1297 1297
 			case 'date' :
1298
-				return $DateTime->format( $formats[0] );
1298
+				return $DateTime->format($formats[0]);
1299 1299
 				break;
1300 1300
 			default :
1301
-				return $DateTime->format( implode( ' ', $formats ) );
1301
+				return $DateTime->format(implode(' ', $formats));
1302 1302
 				break;
1303 1303
 		}
1304 1304
 	}
@@ -1320,17 +1320,17 @@  discard block
 block discarded – undo
1320 1320
 	 * @return DateTime
1321 1321
 	 * @throws \EE_Error
1322 1322
 	 */
1323
-	public function convert_datetime_for_query( $field_name, $timestring, $incoming_format, $timezone = '' ) {
1323
+	public function convert_datetime_for_query($field_name, $timestring, $incoming_format, $timezone = '') {
1324 1324
 
1325 1325
 		//just using this to ensure the timezone is set correctly internally
1326
-		$this->get_formats_for( $field_name );
1326
+		$this->get_formats_for($field_name);
1327 1327
 
1328 1328
 		//load EEH_DTT_Helper
1329
-		$set_timezone = empty( $timezone ) ? EEH_DTT_Helper::get_timezone() : $timezone;
1329
+		$set_timezone = empty($timezone) ? EEH_DTT_Helper::get_timezone() : $timezone;
1330 1330
 
1331
-		$incomingDateTime = date_create_from_format( $incoming_format, $timestring, new DateTimeZone( $set_timezone ) );
1331
+		$incomingDateTime = date_create_from_format($incoming_format, $timestring, new DateTimeZone($set_timezone));
1332 1332
 
1333
-		return $incomingDateTime->setTimezone( new DateTimeZone( $this->_timezone ) );
1333
+		return $incomingDateTime->setTimezone(new DateTimeZone($this->_timezone));
1334 1334
 	}
1335 1335
 
1336 1336
 
@@ -1340,7 +1340,7 @@  discard block
 block discarded – undo
1340 1340
 	 * Gets all the tables comprising this model. Array keys are the table aliases, and values are EE_Table objects
1341 1341
 	 * @return EE_Table_Base[]
1342 1342
 	 */
1343
-	public function get_tables(){
1343
+	public function get_tables() {
1344 1344
 		return $this->_tables;
1345 1345
 	}
1346 1346
 
@@ -1376,9 +1376,9 @@  discard block
 block discarded – undo
1376 1376
 	 * @return int how many rows got updated or FALSE if something went wrong with the query (wp returns FALSE or num rows affected which *could* include 0 which DOES NOT mean the query was bad)
1377 1377
 	 * @throws \EE_Error
1378 1378
 	 */
1379
-	public function update($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE){
1380
-		if( ! is_array( $query_params ) ){
1381
-			EE_Error::doing_it_wrong('EEM_Base::update', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
1379
+	public function update($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE) {
1380
+		if ( ! is_array($query_params)) {
1381
+			EE_Error::doing_it_wrong('EEM_Base::update', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
1382 1382
 			$query_params = array();
1383 1383
 		}
1384 1384
 		/**
@@ -1388,7 +1388,7 @@  discard block
 block discarded – undo
1388 1388
 		 * @param array $fields_n_values the updated fields and their new values
1389 1389
 		 * @param array $query_params @see EEM_Base::get_all()
1390 1390
 		 */
1391
-		do_action( 'AHEE__EEM_Base__update__begin',$this, $fields_n_values, $query_params );
1391
+		do_action('AHEE__EEM_Base__update__begin', $this, $fields_n_values, $query_params);
1392 1392
 		/**
1393 1393
 		 * Filters the fields about to be updated given the query parameters. You can provide the
1394 1394
 		 * $query_params to $this->get_all() to find exactly which records will be updated
@@ -1396,10 +1396,10 @@  discard block
 block discarded – undo
1396 1396
 		 * @param EEM_Base $model the model being queried
1397 1397
 		 * @param array $query_params see EEM_Base::get_all()
1398 1398
 		 */
1399
-		$fields_n_values = (array)apply_filters( 'FHEE__EEM_Base__update__fields_n_values', $fields_n_values, $this, $query_params );
1399
+		$fields_n_values = (array) apply_filters('FHEE__EEM_Base__update__fields_n_values', $fields_n_values, $this, $query_params);
1400 1400
 		//need to verify that, for any entry we want to update, there are entries in each secondary table.
1401 1401
 		//to do that, for each table, verify that it's PK isn't null.
1402
-		$tables= $this->get_tables();
1402
+		$tables = $this->get_tables();
1403 1403
 
1404 1404
 		//and if the other tables don't have a row for each table-to-be-updated, we'll insert one with whatever values available in the current update query
1405 1405
 		//NOTE: we should make this code more efficient by NOT querying twice
@@ -1409,29 +1409,29 @@  discard block
 block discarded – undo
1409 1409
 			//we want to make sure the default_where strategy is ignored
1410 1410
 			$this->_ignore_where_strategy = TRUE;
1411 1411
 			$wpdb_select_results = $this->_get_all_wpdb_results($query_params);
1412
-			foreach( $wpdb_select_results as $wpdb_result ){
1412
+			foreach ($wpdb_select_results as $wpdb_result) {
1413 1413
 				// type cast stdClass as array
1414
-				$wpdb_result = (array)$wpdb_result;
1414
+				$wpdb_result = (array) $wpdb_result;
1415 1415
 				//get the model object's PK, as we'll want this if we need to insert a row into secondary tables
1416
-				if( $this->has_primary_key_field() ){
1417
-					$main_table_pk_value = $wpdb_result[ $this->get_primary_key_field()->get_qualified_column() ];
1418
-				}else{
1416
+				if ($this->has_primary_key_field()) {
1417
+					$main_table_pk_value = $wpdb_result[$this->get_primary_key_field()->get_qualified_column()];
1418
+				} else {
1419 1419
 					//if there's no primary key, we basically can't support having a 2nd table on the model (we could but it would be lots of work)
1420 1420
 					$main_table_pk_value = null;
1421 1421
 				}
1422 1422
 				//if there are more than 1 tables, we'll want to verify that each table for this model has an entry in the other tables
1423 1423
 				//and if the other tables don't have a row for each table-to-be-updated, we'll insert one with whatever values available in the current update query
1424
-				if(count($tables) > 1){
1424
+				if (count($tables) > 1) {
1425 1425
 					//foreach matching row in the DB, ensure that each table's PK isn't null. If so, there must not be an entry
1426 1426
 					//in that table, and so we'll want to insert one
1427
-					foreach($tables as $table_obj){
1427
+					foreach ($tables as $table_obj) {
1428 1428
 						$this_table_pk_column = $table_obj->get_fully_qualified_pk_column();
1429 1429
 						//if there is no private key for this table on the results, it means there's no entry
1430 1430
 						//in this table, right? so insert a row in the current table, using any fields available
1431
-						if( ! ( array_key_exists( $this_table_pk_column, $wpdb_result) && $wpdb_result[ $this_table_pk_column ] )){
1431
+						if ( ! (array_key_exists($this_table_pk_column, $wpdb_result) && $wpdb_result[$this_table_pk_column])) {
1432 1432
 							$success = $this->_insert_into_specific_table($table_obj, $fields_n_values, $main_table_pk_value);
1433 1433
 							//if we died here, report the error
1434
-							if( ! $success ) {
1434
+							if ( ! $success) {
1435 1435
 								return false;
1436 1436
 							}
1437 1437
 						}
@@ -1451,44 +1451,44 @@  discard block
 block discarded – undo
1451 1451
 		//if this wasn't called from a model object (to update itself)
1452 1452
 		//then we want to make sure we keep all the existing
1453 1453
 		//model objects in sync with the db
1454
-		if( $keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object ){
1455
-			if( $this->has_primary_key_field() ){
1456
-				$model_objs_affected_ids = $this->get_col( $query_params );
1457
-			}else{
1454
+		if ($keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object) {
1455
+			if ($this->has_primary_key_field()) {
1456
+				$model_objs_affected_ids = $this->get_col($query_params);
1457
+			} else {
1458 1458
 				//we need to select a bunch of columns and then combine them into the the "index primary key string"s
1459
-				$models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A );
1459
+				$models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A);
1460 1460
 				$model_objs_affected_ids = array();
1461
-				foreach( $models_affected_key_columns as $row ){
1462
-					$combined_index_key = $this->get_index_primary_key_string( $row );
1463
-					$model_objs_affected_ids[ $combined_index_key ] = $combined_index_key;
1461
+				foreach ($models_affected_key_columns as $row) {
1462
+					$combined_index_key = $this->get_index_primary_key_string($row);
1463
+					$model_objs_affected_ids[$combined_index_key] = $combined_index_key;
1464 1464
 				}
1465 1465
 
1466 1466
 			}
1467 1467
 
1468
-			if( ! $model_objs_affected_ids ){
1468
+			if ( ! $model_objs_affected_ids) {
1469 1469
 				//wait wait wait- if nothing was affected let's stop here
1470 1470
 				return 0;
1471 1471
 			}
1472
-			foreach( $model_objs_affected_ids as $id ){
1473
-				$model_obj_in_entity_map = $this->get_from_entity_map( $id );
1474
-				if( $model_obj_in_entity_map ){
1475
-					foreach( $fields_n_values as $field => $new_value ){
1476
-						$model_obj_in_entity_map->set( $field, $new_value );
1472
+			foreach ($model_objs_affected_ids as $id) {
1473
+				$model_obj_in_entity_map = $this->get_from_entity_map($id);
1474
+				if ($model_obj_in_entity_map) {
1475
+					foreach ($fields_n_values as $field => $new_value) {
1476
+						$model_obj_in_entity_map->set($field, $new_value);
1477 1477
 					}
1478 1478
 				}
1479 1479
 			}
1480 1480
 			//if there is a primary key on this model, we can now do a slight optimization
1481
-			if( $this->has_primary_key_field() ){
1481
+			if ($this->has_primary_key_field()) {
1482 1482
 				//we already know what we want to update. So let's make the query simpler so it's a little more efficient
1483 1483
 				$query_params = array(
1484
-					array( $this->primary_key_name() => array( 'IN', $model_objs_affected_ids ) ),
1485
-					'limit' => count( $model_objs_affected_ids ), 'default_where_conditions' => 'none' );
1484
+					array($this->primary_key_name() => array('IN', $model_objs_affected_ids)),
1485
+					'limit' => count($model_objs_affected_ids), 'default_where_conditions' => 'none' );
1486 1486
 			}
1487 1487
 		}
1488 1488
 
1489
-		$model_query_info = $this->_create_model_query_info_carrier( $query_params );
1490
-		$SQL = "UPDATE ".$model_query_info->get_full_join_sql()." SET ".$this->_construct_update_sql($fields_n_values).$model_query_info->get_where_sql();//note: doesn't use _construct_2nd_half_of_select_query() because doesn't accept LIMIT, ORDER BY, etc.
1491
-		$rows_affected = $this->_do_wpdb_query('query', array( $SQL ) );
1489
+		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1490
+		$SQL = "UPDATE ".$model_query_info->get_full_join_sql()." SET ".$this->_construct_update_sql($fields_n_values).$model_query_info->get_where_sql(); //note: doesn't use _construct_2nd_half_of_select_query() because doesn't accept LIMIT, ORDER BY, etc.
1491
+		$rows_affected = $this->_do_wpdb_query('query', array($SQL));
1492 1492
 		/**
1493 1493
 		 * Action called after a model update call has been made.
1494 1494
 		 *
@@ -1497,8 +1497,8 @@  discard block
 block discarded – undo
1497 1497
 		 * @param array $query_params @see EEM_Base::get_all()
1498 1498
 		 * @param int $rows_affected
1499 1499
 		 */
1500
-		do_action( 'AHEE__EEM_Base__update__end',$this, $fields_n_values, $query_params, $rows_affected );
1501
-		return $rows_affected;//how many supposedly got updated
1500
+		do_action('AHEE__EEM_Base__update__end', $this, $fields_n_values, $query_params, $rows_affected);
1501
+		return $rows_affected; //how many supposedly got updated
1502 1502
 	}
1503 1503
 
1504 1504
 
@@ -1514,22 +1514,22 @@  discard block
 block discarded – undo
1514 1514
 	 * @return array just like $wpdb->get_col()
1515 1515
 	 * @throws \EE_Error
1516 1516
 	 */
1517
-	public function get_col( $query_params  = array(), $field_to_select = NULL ){
1517
+	public function get_col($query_params = array(), $field_to_select = NULL) {
1518 1518
 
1519
-		if( $field_to_select ){
1520
-			$field = $this->field_settings_for( $field_to_select );
1521
-		}elseif( $this->has_primary_key_field ( ) ){
1519
+		if ($field_to_select) {
1520
+			$field = $this->field_settings_for($field_to_select);
1521
+		}elseif ($this->has_primary_key_field( )) {
1522 1522
 			$field = $this->get_primary_key_field();
1523
-		}else{
1523
+		} else {
1524 1524
 			//no primary key, just grab the first column
1525
-			$field = reset( $this->field_settings());
1525
+			$field = reset($this->field_settings());
1526 1526
 		}
1527 1527
 
1528 1528
 
1529 1529
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1530 1530
 		$select_expressions = $field->get_qualified_column();
1531
-		$SQL ="SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
1532
-		return $this->_do_wpdb_query('get_col', array( $SQL ) );
1531
+		$SQL = "SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
1532
+		return $this->_do_wpdb_query('get_col', array($SQL));
1533 1533
 	}
1534 1534
 
1535 1535
 
@@ -1542,12 +1542,12 @@  discard block
 block discarded – undo
1542 1542
 	 * @return string
1543 1543
 	 * @throws \EE_Error
1544 1544
 	 */
1545
-	public function get_var( $query_params = array(), $field_to_select = NULL ) {
1546
-		$query_params[ 'limit' ] = 1;
1547
-		$col = $this->get_col( $query_params, $field_to_select );
1548
-		if( ! empty( $col ) ) {
1549
-			return reset( $col );
1550
-		}else{
1545
+	public function get_var($query_params = array(), $field_to_select = NULL) {
1546
+		$query_params['limit'] = 1;
1547
+		$col = $this->get_col($query_params, $field_to_select);
1548
+		if ( ! empty($col)) {
1549
+			return reset($col);
1550
+		} else {
1551 1551
 			return NULL;
1552 1552
 		}
1553 1553
 	}
@@ -1563,19 +1563,19 @@  discard block
 block discarded – undo
1563 1563
 	 * @return string of SQL
1564 1564
 	 * @throws \EE_Error
1565 1565
 	 */
1566
-	public function _construct_update_sql($fields_n_values){
1566
+	public function _construct_update_sql($fields_n_values) {
1567 1567
 		/** @type WPDB $wpdb */
1568 1568
 		global $wpdb;
1569 1569
 		$cols_n_values = array();
1570
-		foreach($fields_n_values as $field_name => $value){
1570
+		foreach ($fields_n_values as $field_name => $value) {
1571 1571
 			$field_obj = $this->field_settings_for($field_name);
1572 1572
 			//if the value is NULL, we want to assign the value to that.
1573 1573
 			//wpdb->prepare doesn't really handle that properly
1574
-			$prepared_value = $this->_prepare_value_or_use_default( $field_obj, $fields_n_values );
1575
-			$value_sql = $prepared_value===NULL ? 'NULL' : $wpdb->prepare( $field_obj->get_wpdb_data_type(), $prepared_value );
1574
+			$prepared_value = $this->_prepare_value_or_use_default($field_obj, $fields_n_values);
1575
+			$value_sql = $prepared_value === NULL ? 'NULL' : $wpdb->prepare($field_obj->get_wpdb_data_type(), $prepared_value);
1576 1576
 			$cols_n_values[] = $field_obj->get_qualified_column()."=".$value_sql;
1577 1577
 		}
1578
-		return implode(",",$cols_n_values);
1578
+		return implode(",", $cols_n_values);
1579 1579
 
1580 1580
 	}
1581 1581
 
@@ -1591,10 +1591,10 @@  discard block
 block discarded – undo
1591 1591
 	 * @return boolean whether the row got deleted or not
1592 1592
 	 * @throws \EE_Error
1593 1593
 	 */
1594
-	public function delete_permanently_by_ID( $id ) {
1594
+	public function delete_permanently_by_ID($id) {
1595 1595
 		return $this->delete_permanently(
1596 1596
 			array(
1597
-				array( $this->get_primary_key_field()->get_name() => $id ),
1597
+				array($this->get_primary_key_field()->get_name() => $id),
1598 1598
 				'limit' 	=> 1
1599 1599
 			)
1600 1600
 		);
@@ -1610,10 +1610,10 @@  discard block
 block discarded – undo
1610 1610
 	 * @return boolean whether the row got deleted or not
1611 1611
 	 * @throws \EE_Error
1612 1612
 	 */
1613
-	public function delete_by_ID( $id ){
1613
+	public function delete_by_ID($id) {
1614 1614
 		return $this->delete(
1615 1615
 			array(
1616
-				array( $this->get_primary_key_field()->get_name() => $id ),
1616
+				array($this->get_primary_key_field()->get_name() => $id),
1617 1617
 				'limit' 	=> 1
1618 1618
 			)
1619 1619
 		);
@@ -1632,7 +1632,7 @@  discard block
 block discarded – undo
1632 1632
 	 * @return int how many rows got deleted
1633 1633
 	 * @throws \EE_Error
1634 1634
 	 */
1635
-	public function delete($query_params,$allow_blocking = true){
1635
+	public function delete($query_params, $allow_blocking = true) {
1636 1636
 		return $this->delete_permanently($query_params, $allow_blocking);
1637 1637
 	}
1638 1638
 
@@ -1650,7 +1650,7 @@  discard block
 block discarded – undo
1650 1650
 	 * @return int how many rows got deleted
1651 1651
 	 * @throws \EE_Error
1652 1652
 	 */
1653
-	public function delete_permanently($query_params,$allow_blocking = true){
1653
+	public function delete_permanently($query_params, $allow_blocking = true) {
1654 1654
 		/**
1655 1655
 		 * Action called just before performing a real deletion query. You can use the
1656 1656
 		 * model and its $query_params to find exactly which items will be deleted
@@ -1659,31 +1659,31 @@  discard block
 block discarded – undo
1659 1659
 		 * @param boolean $allow_blocking whether or not to allow related model objects
1660 1660
 		 * to block (prevent) this deletion
1661 1661
 		 */
1662
-		do_action( 'AHEE__EEM_Base__delete__begin', $this, $query_params, $allow_blocking );
1662
+		do_action('AHEE__EEM_Base__delete__begin', $this, $query_params, $allow_blocking);
1663 1663
 		//some MySQL databases may be running safe mode, which may restrict
1664 1664
 		//deletion if there is no KEY column used in the WHERE statement of a deletion.
1665 1665
 		//to get around this, we first do a SELECT, get all the IDs, and then run another query
1666 1666
 		//to delete them
1667 1667
 		$items_for_deletion = $this->_get_all_wpdb_results($query_params);
1668
-		$deletion_where = $this->_setup_ids_for_delete( $items_for_deletion, $allow_blocking);
1669
-		if($deletion_where){
1668
+		$deletion_where = $this->_setup_ids_for_delete($items_for_deletion, $allow_blocking);
1669
+		if ($deletion_where) {
1670 1670
 			//echo "objects for deletion:";var_dump($objects_for_deletion);
1671 1671
 			$model_query_info = $this->_create_model_query_info_carrier($query_params);
1672
-			$table_aliases = array_keys( $this->_tables );
1673
-			$SQL = "DELETE ".implode(", ",$table_aliases)." FROM ".$model_query_info->get_full_join_sql()." WHERE ".$deletion_where;
1672
+			$table_aliases = array_keys($this->_tables);
1673
+			$SQL = "DELETE ".implode(", ", $table_aliases)." FROM ".$model_query_info->get_full_join_sql()." WHERE ".$deletion_where;
1674 1674
 
1675 1675
 			//		/echo "delete sql:$SQL";
1676
-			$rows_deleted = $this->_do_wpdb_query( 'query', array( $SQL ) );
1677
-		}else{
1676
+			$rows_deleted = $this->_do_wpdb_query('query', array($SQL));
1677
+		} else {
1678 1678
 			$rows_deleted = 0;
1679 1679
 		}
1680 1680
 
1681 1681
 		//and lastly make sure those items are removed from the entity map; if they could be put into it at all
1682
-		if( $this->has_primary_key_field() ){
1683
-			foreach($items_for_deletion as $item_for_deletion_row ){
1684
-				$pk_value = $item_for_deletion_row[ $this->get_primary_key_field()->get_qualified_column() ];
1685
-				if( isset( $this->_entity_map[ EEM_Base::$_model_query_blog_id ][ $pk_value ] ) ){
1686
-					unset( $this->_entity_map[ EEM_Base::$_model_query_blog_id ][ $pk_value ] );
1682
+		if ($this->has_primary_key_field()) {
1683
+			foreach ($items_for_deletion as $item_for_deletion_row) {
1684
+				$pk_value = $item_for_deletion_row[$this->get_primary_key_field()->get_qualified_column()];
1685
+				if (isset($this->_entity_map[EEM_Base::$_model_query_blog_id][$pk_value])) {
1686
+					unset($this->_entity_map[EEM_Base::$_model_query_blog_id][$pk_value]);
1687 1687
 				}
1688 1688
 			}
1689 1689
 		}
@@ -1695,8 +1695,8 @@  discard block
 block discarded – undo
1695 1695
 		 * @param array $query_params @see EEM_Base::get_all()
1696 1696
 		 * @param int $rows_deleted
1697 1697
 		 */
1698
-		do_action( 'AHEE__EEM_Base__delete__end', $this, $query_params, $rows_deleted );
1699
-		return $rows_deleted;//how many supposedly got deleted
1698
+		do_action('AHEE__EEM_Base__delete__end', $this, $query_params, $rows_deleted);
1699
+		return $rows_deleted; //how many supposedly got deleted
1700 1700
 	}
1701 1701
 
1702 1702
 
@@ -1714,28 +1714,28 @@  discard block
 block discarded – undo
1714 1714
 	 * @return boolean
1715 1715
 	 * @throws \EE_Error
1716 1716
 	 */
1717
-	public function delete_is_blocked_by_related_models($this_model_obj_or_id, $ignore_this_model_obj = null){
1717
+	public function delete_is_blocked_by_related_models($this_model_obj_or_id, $ignore_this_model_obj = null) {
1718 1718
 		//first, if $ignore_this_model_obj was supplied, get its model
1719
-		if($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class){
1719
+		if ($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class) {
1720 1720
 			$ignored_model = $ignore_this_model_obj->get_model();
1721
-		}else{
1721
+		} else {
1722 1722
 			$ignored_model = null;
1723 1723
 		}
1724 1724
 		//now check all the relations of $this_model_obj_or_id and see if there
1725 1725
 		//are any related model objects blocking it?
1726 1726
 		$is_blocked = false;
1727
-		foreach($this->_model_relations as $relation_name => $relation_obj){
1728
-			if( $relation_obj->block_delete_if_related_models_exist()){
1727
+		foreach ($this->_model_relations as $relation_name => $relation_obj) {
1728
+			if ($relation_obj->block_delete_if_related_models_exist()) {
1729 1729
 				//if $ignore_this_model_obj was supplied, then for the query
1730 1730
 				//on that model needs to be told to ignore $ignore_this_model_obj
1731
-				if($ignored_model && $relation_name === $ignored_model->get_this_model_name()){
1732
-					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id,array(
1733
-					array($ignored_model->get_primary_key_field()->get_name() => array('!=',$ignore_this_model_obj->ID()))));
1734
-				}else{
1731
+				if ($ignored_model && $relation_name === $ignored_model->get_this_model_name()) {
1732
+					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id, array(
1733
+					array($ignored_model->get_primary_key_field()->get_name() => array('!=', $ignore_this_model_obj->ID()))));
1734
+				} else {
1735 1735
 					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id);
1736 1736
 				}
1737 1737
 
1738
-				if($related_model_objects){
1738
+				if ($related_model_objects) {
1739 1739
 					EE_Error::add_error($relation_obj->get_deletion_error_message(), __FILE__, __FUNCTION__, __LINE__);
1740 1740
 					$is_blocked = true;
1741 1741
 				}
@@ -1755,75 +1755,75 @@  discard block
 block discarded – undo
1755 1755
 	 * @throws EE_Error
1756 1756
 	 * @return string    everything that comes after the WHERE statement.
1757 1757
 	 */
1758
-	protected function _setup_ids_for_delete( $objects_for_deletion, $allow_blocking = true) {
1759
-		if($this->has_primary_key_field()){
1758
+	protected function _setup_ids_for_delete($objects_for_deletion, $allow_blocking = true) {
1759
+		if ($this->has_primary_key_field()) {
1760 1760
 			$primary_table = $this->_get_main_table();
1761 1761
 			$other_tables = $this->_get_other_tables();
1762 1762
 			$deletes = $query = array();
1763
-			foreach ( $objects_for_deletion as $delete_object ) {
1763
+			foreach ($objects_for_deletion as $delete_object) {
1764 1764
 				//before we mark this object for deletion,
1765 1765
 				//make sure there's no related objects blocking its deletion (if we're checking)
1766 1766
 				if (
1767 1767
 					$allow_blocking
1768 1768
 				    && $this->delete_is_blocked_by_related_models(
1769
-						$delete_object[ $primary_table->get_fully_qualified_pk_column() ]
1769
+						$delete_object[$primary_table->get_fully_qualified_pk_column()]
1770 1770
 					)
1771 1771
 				) {
1772 1772
 					continue;
1773 1773
 				}
1774 1774
 				//primary table deletes
1775
-				if ( isset( $delete_object[ $primary_table->get_fully_qualified_pk_column() ] ) ) {
1776
-					$deletes[ $primary_table->get_fully_qualified_pk_column() ][] = $delete_object[ $primary_table->get_fully_qualified_pk_column() ];
1775
+				if (isset($delete_object[$primary_table->get_fully_qualified_pk_column()])) {
1776
+					$deletes[$primary_table->get_fully_qualified_pk_column()][] = $delete_object[$primary_table->get_fully_qualified_pk_column()];
1777 1777
 				}
1778 1778
 				//other tables
1779
-				if ( ! empty( $other_tables ) ) {
1780
-					foreach ( $other_tables as $ot ) {
1779
+				if ( ! empty($other_tables)) {
1780
+					foreach ($other_tables as $ot) {
1781 1781
 						//first check if we've got the foreign key column here.
1782
-						if ( isset( $delete_object[ $ot->get_fully_qualified_fk_column() ] ) ) {
1783
-							$deletes[ $ot->get_fully_qualified_pk_column() ][] = $delete_object[ $ot->get_fully_qualified_fk_column() ];
1782
+						if (isset($delete_object[$ot->get_fully_qualified_fk_column()])) {
1783
+							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_fk_column()];
1784 1784
 						}
1785 1785
 						// wait! it's entirely possible that we'll have a the primary key
1786 1786
 						// for this table in here, if it's a foreign key for one of the other secondary tables
1787
-						if ( isset( $delete_object[ $ot->get_fully_qualified_pk_column() ] ) ) {
1788
-							$deletes[ $ot->get_fully_qualified_pk_column() ][] = $delete_object[ $ot->get_fully_qualified_pk_column() ];
1787
+						if (isset($delete_object[$ot->get_fully_qualified_pk_column()])) {
1788
+							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1789 1789
 						}
1790 1790
 						// finally, it is possible that the fk for this table is found
1791 1791
 						// in the fully qualified pk column for the fk table, so let's see if that's there!
1792
-						if ( isset( $delete_object[ $ot->get_fully_qualified_pk_on_fk_table() ] ) ) {
1793
-							$deletes[ $ot->get_fully_qualified_pk_column() ][] = $delete_object[ $ot->get_fully_qualified_pk_column() ];
1792
+						if (isset($delete_object[$ot->get_fully_qualified_pk_on_fk_table()])) {
1793
+							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1794 1794
 						}
1795 1795
 					}
1796 1796
 				}
1797 1797
 			}
1798 1798
 
1799 1799
 			//we should have deletes now, so let's just go through and setup the where statement
1800
-			foreach ( $deletes as $column => $values ) {
1800
+			foreach ($deletes as $column => $values) {
1801 1801
 				//make sure we have unique $values;
1802 1802
 				$values = array_unique($values);
1803
-				$query[] = $column . ' IN(' . implode(",",$values) . ')';
1803
+				$query[] = $column.' IN('.implode(",", $values).')';
1804 1804
 			}
1805 1805
 
1806
-			return !empty($query) ? implode(' AND ', $query ) : '';
1807
-		}elseif(count($this->get_combined_primary_key_fields()) > 1){
1806
+			return ! empty($query) ? implode(' AND ', $query) : '';
1807
+		}elseif (count($this->get_combined_primary_key_fields()) > 1) {
1808 1808
 			$ways_to_identify_a_row = array();
1809 1809
 			$fields = $this->get_combined_primary_key_fields();
1810 1810
 			//note: because there' sno primary key, that means nothing else  can be pointing to this model, right?
1811
-			foreach($objects_for_deletion as  $delete_object){
1811
+			foreach ($objects_for_deletion as  $delete_object) {
1812 1812
 				$values_for_each_cpk_for_a_row = array();
1813
-				foreach($fields as $cpk_field){
1814
-					if ( $cpk_field instanceof EE_Model_Field_Base ){
1813
+				foreach ($fields as $cpk_field) {
1814
+					if ($cpk_field instanceof EE_Model_Field_Base) {
1815 1815
 						$values_for_each_cpk_for_a_row[] = $cpk_field->get_qualified_column()
1816 1816
 						                                   . "="
1817
-						                                   . $delete_object[ $cpk_field->get_qualified_column() ];
1817
+						                                   . $delete_object[$cpk_field->get_qualified_column()];
1818 1818
 					}
1819 1819
 				}
1820
-				$ways_to_identify_a_row[] = "(".implode(" AND ",$values_for_each_cpk_for_a_row).")";
1820
+				$ways_to_identify_a_row[] = "(".implode(" AND ", $values_for_each_cpk_for_a_row).")";
1821 1821
 			}
1822
-			return implode(" OR ",$ways_to_identify_a_row);
1823
-		}else{
1822
+			return implode(" OR ", $ways_to_identify_a_row);
1823
+		} else {
1824 1824
 			//so there's no primary key and no combined key...
1825 1825
 			//sorry, can't help you
1826
-			throw new EE_Error(sprintf(__("Cannot delete objects of type %s because there is no primary key NOR combined key", "event_espresso"),get_class($this)));
1826
+			throw new EE_Error(sprintf(__("Cannot delete objects of type %s because there is no primary key NOR combined key", "event_espresso"), get_class($this)));
1827 1827
 		}
1828 1828
 	}
1829 1829
 
@@ -1839,21 +1839,21 @@  discard block
 block discarded – undo
1839 1839
 	 * @return int
1840 1840
 	 * @throws \EE_Error
1841 1841
 	 */
1842
-	public function count($query_params =array(),$field_to_count = NULL, $distinct = FALSE){
1842
+	public function count($query_params = array(), $field_to_count = NULL, $distinct = FALSE) {
1843 1843
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1844
-		if($field_to_count){
1844
+		if ($field_to_count) {
1845 1845
 			$field_obj = $this->field_settings_for($field_to_count);
1846 1846
 			$column_to_count = $field_obj->get_qualified_column();
1847
-		}elseif($this->has_primary_key_field ()){
1847
+		}elseif ($this->has_primary_key_field()) {
1848 1848
 			$pk_field_obj = $this->get_primary_key_field();
1849 1849
 			$column_to_count = $pk_field_obj->get_qualified_column();
1850
-		}else{//there's no primary key
1850
+		} else {//there's no primary key
1851 1851
 			$column_to_count = '*';
1852 1852
 		}
1853 1853
 
1854
-		$column_to_count = $distinct ? "DISTINCT (" . $column_to_count . " )" : $column_to_count;
1855
-		$SQL ="SELECT COUNT(".$column_to_count.")" . $this->_construct_2nd_half_of_select_query($model_query_info);
1856
-		return (int)$this->_do_wpdb_query( 'get_var', array( $SQL) );
1854
+		$column_to_count = $distinct ? "DISTINCT (".$column_to_count." )" : $column_to_count;
1855
+		$SQL = "SELECT COUNT(".$column_to_count.")".$this->_construct_2nd_half_of_select_query($model_query_info);
1856
+		return (int) $this->_do_wpdb_query('get_var', array($SQL));
1857 1857
 	}
1858 1858
 
1859 1859
 
@@ -1866,24 +1866,24 @@  discard block
 block discarded – undo
1866 1866
 	 * @return float
1867 1867
 	 * @throws \EE_Error
1868 1868
 	 */
1869
-	public function sum($query_params, $field_to_sum = NULL){
1869
+	public function sum($query_params, $field_to_sum = NULL) {
1870 1870
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1871 1871
 
1872
-		if($field_to_sum){
1872
+		if ($field_to_sum) {
1873 1873
 			$field_obj = $this->field_settings_for($field_to_sum);
1874 1874
 
1875
-		}else{
1875
+		} else {
1876 1876
 			$field_obj = $this->get_primary_key_field();
1877 1877
 		}
1878 1878
 		$column_to_count = $field_obj->get_qualified_column();
1879 1879
 
1880
-		$SQL ="SELECT SUM(".$column_to_count.")" . $this->_construct_2nd_half_of_select_query($model_query_info);
1881
-		$return_value = $this->_do_wpdb_query('get_var',array( $SQL ) );
1880
+		$SQL = "SELECT SUM(".$column_to_count.")".$this->_construct_2nd_half_of_select_query($model_query_info);
1881
+		$return_value = $this->_do_wpdb_query('get_var', array($SQL));
1882 1882
 		$data_type = $field_obj->get_wpdb_data_type();
1883
-		if( $data_type === '%d' || $data_type === '%s' ){
1884
-			return (float)$return_value;
1885
-		}else{//must be %f
1886
-			return (float)$return_value;
1883
+		if ($data_type === '%d' || $data_type === '%s') {
1884
+			return (float) $return_value;
1885
+		} else {//must be %f
1886
+			return (float) $return_value;
1887 1887
 		}
1888 1888
 	}
1889 1889
 
@@ -1898,37 +1898,37 @@  discard block
 block discarded – undo
1898 1898
 	 * @global wpdb $wpdb
1899 1899
 	 * @return mixed
1900 1900
 	 */
1901
-	protected function _do_wpdb_query( $wpdb_method, $arguments_to_provide ){
1901
+	protected function _do_wpdb_query($wpdb_method, $arguments_to_provide) {
1902 1902
 		//if we're in maintenance mode level 2, DON'T run any queries
1903 1903
 		//because level 2 indicates the database needs updating and
1904 1904
 		//is probably out of sync with the code
1905
-		if( ! EE_Maintenance_Mode::instance()->models_can_query()){
1905
+		if ( ! EE_Maintenance_Mode::instance()->models_can_query()) {
1906 1906
 			throw new EE_Error(sprintf(__("Event Espresso Level 2 Maintenance mode is active. That means EE can not run ANY database queries until the necessary migration scripts have run which will take EE out of maintenance mode level 2. Please inform support of this error.", "event_espresso")));
1907 1907
 		}
1908 1908
 		/** @type WPDB $wpdb */
1909 1909
 		global $wpdb;
1910
-		if( ! method_exists( $wpdb, $wpdb_method ) ){
1911
-			throw new EE_Error( sprintf( __( 'There is no method named "%s" on Wordpress\' $wpdb object','event_espresso' ), $wpdb_method ) );
1910
+		if ( ! method_exists($wpdb, $wpdb_method)) {
1911
+			throw new EE_Error(sprintf(__('There is no method named "%s" on Wordpress\' $wpdb object', 'event_espresso'), $wpdb_method));
1912 1912
 		}
1913
-		if( WP_DEBUG ){
1913
+		if (WP_DEBUG) {
1914 1914
 			$old_show_errors_value = $wpdb->show_errors;
1915
-			$wpdb->show_errors( FALSE );
1916
-		}
1917
-		$result = $this->_process_wpdb_query( $wpdb_method, $arguments_to_provide );
1918
-		$this->show_db_query_if_previously_requested( $wpdb->last_query );
1919
-		if( WP_DEBUG ){
1920
-			$wpdb->show_errors( $old_show_errors_value );
1921
-			if( ! empty( $wpdb->last_error ) ){
1922
-				throw new EE_Error( sprintf( __( 'WPDB Error: "%s"', 'event_espresso' ), $wpdb->last_error ) );
1923
-			}elseif( $result === false ){
1924
-				throw new EE_Error( sprintf( __( 'WPDB Error occurred, but no error message was logged by wpdb! The wpdb method called was "%1$s" and the arguments were "%2$s"', 'event_espresso' ), $wpdb_method, var_export( $arguments_to_provide, true ) ) );
1915
+			$wpdb->show_errors(FALSE);
1916
+		}
1917
+		$result = $this->_process_wpdb_query($wpdb_method, $arguments_to_provide);
1918
+		$this->show_db_query_if_previously_requested($wpdb->last_query);
1919
+		if (WP_DEBUG) {
1920
+			$wpdb->show_errors($old_show_errors_value);
1921
+			if ( ! empty($wpdb->last_error)) {
1922
+				throw new EE_Error(sprintf(__('WPDB Error: "%s"', 'event_espresso'), $wpdb->last_error));
1923
+			}elseif ($result === false) {
1924
+				throw new EE_Error(sprintf(__('WPDB Error occurred, but no error message was logged by wpdb! The wpdb method called was "%1$s" and the arguments were "%2$s"', 'event_espresso'), $wpdb_method, var_export($arguments_to_provide, true)));
1925 1925
 			}
1926
-		}elseif( $result === false ) {
1926
+		}elseif ($result === false) {
1927 1927
 			EE_Error::add_error(
1928 1928
 				sprintf(
1929
-					__( 'A database error has occurred. Turn on WP_DEBUG for more information.||A database error occurred doing wpdb method "%1$s", with arguments "%2$s". The error was "%3$s"', 'event_espresso' ),
1929
+					__('A database error has occurred. Turn on WP_DEBUG for more information.||A database error occurred doing wpdb method "%1$s", with arguments "%2$s". The error was "%3$s"', 'event_espresso'),
1930 1930
 					$wpdb_method,
1931
-					var_export( $arguments_to_provide, true ),
1931
+					var_export($arguments_to_provide, true),
1932 1932
 					$wpdb->last_error
1933 1933
 				),
1934 1934
 				__FILE__,
@@ -1950,26 +1950,26 @@  discard block
 block discarded – undo
1950 1950
 	 * @param array $arguments_to_provide
1951 1951
 	 * @return mixed
1952 1952
 	 */
1953
-	private function _process_wpdb_query( $wpdb_method, $arguments_to_provide ) {
1953
+	private function _process_wpdb_query($wpdb_method, $arguments_to_provide) {
1954 1954
 		/** @type WPDB $wpdb */
1955 1955
 		global $wpdb;
1956 1956
 		$wpdb->last_error = null;
1957
-		$result = call_user_func_array( array( $wpdb, $wpdb_method ), $arguments_to_provide );
1957
+		$result = call_user_func_array(array($wpdb, $wpdb_method), $arguments_to_provide);
1958 1958
 		// was there an error running the query? but we don't care on new activations
1959 1959
 		// (we're going to setup the DB anyway on new activations)
1960
-		if ( ( $result === false || ! empty( $wpdb->last_error ) )
1960
+		if (($result === false || ! empty($wpdb->last_error))
1961 1961
 			&& EE_System::instance()->detect_req_type() !== EE_System::req_type_new_activation
1962 1962
 		) {
1963
-			switch ( EEM_Base::$_db_verification_level ) {
1963
+			switch (EEM_Base::$_db_verification_level) {
1964 1964
 
1965 1965
 				case EEM_Base::db_verified_none :
1966 1966
 					// let's double-check core's DB
1967
-					$error_message = $this->_verify_core_db( $wpdb_method, $arguments_to_provide );
1967
+					$error_message = $this->_verify_core_db($wpdb_method, $arguments_to_provide);
1968 1968
 					break;
1969 1969
 
1970 1970
 				case EEM_Base::db_verified_core :
1971 1971
 					// STILL NO LOVE?? verify all the addons too. Maybe they need to be fixed
1972
-					$error_message = $this->_verify_addons_db( $wpdb_method, $arguments_to_provide );
1972
+					$error_message = $this->_verify_addons_db($wpdb_method, $arguments_to_provide);
1973 1973
 					break;
1974 1974
 
1975 1975
 				case EEM_Base::db_verified_addons :
@@ -1977,11 +1977,11 @@  discard block
 block discarded – undo
1977 1977
 					return $result;
1978 1978
 					break;
1979 1979
 			}
1980
-			if ( ! empty( $error_message ) ) {
1981
-				EE_Log::instance()->log( __FILE__, __FUNCTION__, $error_message, 'error' );
1982
-				trigger_error( $error_message );
1980
+			if ( ! empty($error_message)) {
1981
+				EE_Log::instance()->log(__FILE__, __FUNCTION__, $error_message, 'error');
1982
+				trigger_error($error_message);
1983 1983
 			}
1984
-			return $this->_process_wpdb_query( $wpdb_method, $arguments_to_provide );
1984
+			return $this->_process_wpdb_query($wpdb_method, $arguments_to_provide);
1985 1985
 
1986 1986
 		}
1987 1987
 
@@ -1997,18 +1997,18 @@  discard block
 block discarded – undo
1997 1997
 	 * @param array $arguments_to_provide
1998 1998
 	 * @return string
1999 1999
 	 */
2000
-	private function _verify_core_db( $wpdb_method, $arguments_to_provide ){
2000
+	private function _verify_core_db($wpdb_method, $arguments_to_provide) {
2001 2001
 		/** @type WPDB $wpdb */
2002 2002
 		global $wpdb;
2003 2003
 		//ok remember that we've already attempted fixing the core db, in case the problem persists
2004 2004
 		EEM_Base::$_db_verification_level = EEM_Base::db_verified_core;
2005 2005
 		$error_message = sprintf(
2006
-			__( 'WPDB Error "%1$s" while running wpdb method "%2$s" with arguments %3$s. Automatically attempting to fix EE Core DB', 'event_espresso' ),
2006
+			__('WPDB Error "%1$s" while running wpdb method "%2$s" with arguments %3$s. Automatically attempting to fix EE Core DB', 'event_espresso'),
2007 2007
 			$wpdb->last_error,
2008 2008
 			$wpdb_method,
2009
-			json_encode( $arguments_to_provide )
2009
+			json_encode($arguments_to_provide)
2010 2010
 		);
2011
-		EE_System::instance()->initialize_db_if_no_migrations_required( false, true );
2011
+		EE_System::instance()->initialize_db_if_no_migrations_required(false, true);
2012 2012
 		return $error_message;
2013 2013
 	}
2014 2014
 
@@ -2021,16 +2021,16 @@  discard block
 block discarded – undo
2021 2021
 	 * @param $arguments_to_provide
2022 2022
 	 * @return string
2023 2023
 	 */
2024
-	private function _verify_addons_db( $wpdb_method, $arguments_to_provide ) {
2024
+	private function _verify_addons_db($wpdb_method, $arguments_to_provide) {
2025 2025
 		/** @type WPDB $wpdb */
2026 2026
 		global $wpdb;
2027 2027
 		//ok remember that we've already attempted fixing the addons dbs, in case the problem persists
2028 2028
 		EEM_Base::$_db_verification_level = EEM_Base::db_verified_addons;
2029 2029
 		$error_message = sprintf(
2030
-			__( 'WPDB AGAIN: Error "%1$s" while running the same method and arguments as before. Automatically attempting to fix EE Addons DB', 'event_espresso' ),
2030
+			__('WPDB AGAIN: Error "%1$s" while running the same method and arguments as before. Automatically attempting to fix EE Addons DB', 'event_espresso'),
2031 2031
 			$wpdb->last_error,
2032 2032
 			$wpdb_method,
2033
-			json_encode( $arguments_to_provide )
2033
+			json_encode($arguments_to_provide)
2034 2034
 		);
2035 2035
 		EE_System::instance()->initialize_addons();
2036 2036
 		return $error_message;
@@ -2045,7 +2045,7 @@  discard block
 block discarded – undo
2045 2045
 	 * @param EE_Model_Query_Info_Carrier $model_query_info
2046 2046
 	 * @return string
2047 2047
 	 */
2048
-	private function _construct_2nd_half_of_select_query(EE_Model_Query_Info_Carrier $model_query_info){
2048
+	private function _construct_2nd_half_of_select_query(EE_Model_Query_Info_Carrier $model_query_info) {
2049 2049
 		return " FROM ".$model_query_info->get_full_join_sql().
2050 2050
 				$model_query_info->get_where_sql().
2051 2051
 				$model_query_info->get_group_by_sql().
@@ -2058,7 +2058,7 @@  discard block
 block discarded – undo
2058 2058
 	 * Set to easily debug the next X queries ran from this model.
2059 2059
 	 * @param int $count
2060 2060
 	 */
2061
-	public function show_next_x_db_queries($count = 1){
2061
+	public function show_next_x_db_queries($count = 1) {
2062 2062
 		$this->_show_next_x_db_queries = $count;
2063 2063
 	}
2064 2064
 
@@ -2067,8 +2067,8 @@  discard block
 block discarded – undo
2067 2067
 	/**
2068 2068
 	 * @param $sql_query
2069 2069
 	 */
2070
-	public function show_db_query_if_previously_requested($sql_query){
2071
-		if($this->_show_next_x_db_queries > 0){
2070
+	public function show_db_query_if_previously_requested($sql_query) {
2071
+		if ($this->_show_next_x_db_queries > 0) {
2072 2072
 			echo $sql_query;
2073 2073
 			$this->_show_next_x_db_queries--;
2074 2074
 		}
@@ -2092,9 +2092,9 @@  discard block
 block discarded – undo
2092 2092
 	 * @return EE_Base_Class which was added as a relation. Object referred to by $other_model_id_or_obj
2093 2093
 	 * @throws \EE_Error
2094 2094
 	 */
2095
-	public function add_relationship_to($id_or_obj,$other_model_id_or_obj, $relationName, $extra_join_model_fields_n_values = array()){
2095
+	public function add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $extra_join_model_fields_n_values = array()) {
2096 2096
 		$relation_obj = $this->related_settings_for($relationName);
2097
-		return $relation_obj->add_relation_to( $id_or_obj, $other_model_id_or_obj, $extra_join_model_fields_n_values);
2097
+		return $relation_obj->add_relation_to($id_or_obj, $other_model_id_or_obj, $extra_join_model_fields_n_values);
2098 2098
 	}
2099 2099
 
2100 2100
 
@@ -2113,9 +2113,9 @@  discard block
 block discarded – undo
2113 2113
 	 * @throws \EE_Error
2114 2114
 	 * @param array  $where_query  This allows you to enter further query params for the relation to for relation to methods that allow you to further specify extra columns to join by (such as HABTM).  Keep in mind that the only acceptable query_params is strict "col" => "value" pairs because these will be inserted in any new rows created as well.
2115 2115
 	 */
2116
-	public function remove_relationship_to($id_or_obj,  $other_model_id_or_obj, $relationName, $where_query= array() ){
2116
+	public function remove_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query = array()) {
2117 2117
 		$relation_obj = $this->related_settings_for($relationName);
2118
-		return $relation_obj->remove_relation_to($id_or_obj, $other_model_id_or_obj, $where_query );
2118
+		return $relation_obj->remove_relation_to($id_or_obj, $other_model_id_or_obj, $where_query);
2119 2119
 	}
2120 2120
 
2121 2121
 
@@ -2128,9 +2128,9 @@  discard block
 block discarded – undo
2128 2128
 	 * @return \EE_Base_Class[]
2129 2129
 	 * @throws \EE_Error
2130 2130
 	 */
2131
-	public function remove_relations($id_or_obj,$relationName,$where_query_params = array()){
2131
+	public function remove_relations($id_or_obj, $relationName, $where_query_params = array()) {
2132 2132
 		$relation_obj = $this->related_settings_for($relationName);
2133
-		return $relation_obj->remove_relations($id_or_obj, $where_query_params );
2133
+		return $relation_obj->remove_relations($id_or_obj, $where_query_params);
2134 2134
 	}
2135 2135
 
2136 2136
 
@@ -2146,10 +2146,10 @@  discard block
 block discarded – undo
2146 2146
 	 * @return EE_Base_Class[]
2147 2147
 	 * @throws \EE_Error
2148 2148
 	 */
2149
-	public function get_all_related($id_or_obj, $model_name, $query_params = null){
2149
+	public function get_all_related($id_or_obj, $model_name, $query_params = null) {
2150 2150
 		$model_obj = $this->ensure_is_obj($id_or_obj);
2151 2151
 		$relation_settings = $this->related_settings_for($model_name);
2152
-		return $relation_settings->get_all_related($model_obj,$query_params);
2152
+		return $relation_settings->get_all_related($model_obj, $query_params);
2153 2153
 	}
2154 2154
 
2155 2155
 
@@ -2166,10 +2166,10 @@  discard block
 block discarded – undo
2166 2166
 	 * @return int how many deleted
2167 2167
 	 * @throws \EE_Error
2168 2168
 	 */
2169
-	public function delete_related($id_or_obj,$model_name, $query_params = array()){
2169
+	public function delete_related($id_or_obj, $model_name, $query_params = array()) {
2170 2170
 		$model_obj = $this->ensure_is_obj($id_or_obj);
2171 2171
 		$relation_settings = $this->related_settings_for($model_name);
2172
-		return $relation_settings->delete_all_related($model_obj,$query_params);
2172
+		return $relation_settings->delete_all_related($model_obj, $query_params);
2173 2173
 	}
2174 2174
 
2175 2175
 
@@ -2186,10 +2186,10 @@  discard block
 block discarded – undo
2186 2186
 	 * @return int how many deleted
2187 2187
 	 * @throws \EE_Error
2188 2188
 	 */
2189
-	public function delete_related_permanently($id_or_obj,$model_name, $query_params = array()){
2189
+	public function delete_related_permanently($id_or_obj, $model_name, $query_params = array()) {
2190 2190
 		$model_obj = $this->ensure_is_obj($id_or_obj);
2191 2191
 		$relation_settings = $this->related_settings_for($model_name);
2192
-		return $relation_settings->delete_related_permanently($model_obj,$query_params);
2192
+		return $relation_settings->delete_related_permanently($model_obj, $query_params);
2193 2193
 	}
2194 2194
 
2195 2195
 
@@ -2206,17 +2206,17 @@  discard block
 block discarded – undo
2206 2206
 	 * @return int
2207 2207
 	 * @throws \EE_Error
2208 2208
 	 */
2209
-	public function count_related($id_or_obj,$model_name,$query_params = array(),$field_to_count = null, $distinct = FALSE){
2209
+	public function count_related($id_or_obj, $model_name, $query_params = array(), $field_to_count = null, $distinct = FALSE) {
2210 2210
 		$related_model = $this->get_related_model_obj($model_name);
2211 2211
 		//we're just going to use the query params on the related model's normal get_all query,
2212 2212
 		//except add a condition to say to match the current mod
2213
-		if( ! isset($query_params['default_where_conditions'])){
2214
-			$query_params['default_where_conditions']='none';
2213
+		if ( ! isset($query_params['default_where_conditions'])) {
2214
+			$query_params['default_where_conditions'] = 'none';
2215 2215
 		}
2216 2216
 		$this_model_name = $this->get_this_model_name();
2217 2217
 		$this_pk_field_name = $this->get_primary_key_field()->get_name();
2218
-		$query_params[0][$this_model_name.".".$this_pk_field_name]=$id_or_obj;
2219
-		return $related_model->count($query_params,$field_to_count,$distinct);
2218
+		$query_params[0][$this_model_name.".".$this_pk_field_name] = $id_or_obj;
2219
+		return $related_model->count($query_params, $field_to_count, $distinct);
2220 2220
 	}
2221 2221
 
2222 2222
 
@@ -2232,21 +2232,21 @@  discard block
 block discarded – undo
2232 2232
 	 * @return float
2233 2233
 	 * @throws \EE_Error
2234 2234
 	 */
2235
-	public function sum_related($id_or_obj,$model_name,$query_params,$field_to_sum = null){
2235
+	public function sum_related($id_or_obj, $model_name, $query_params, $field_to_sum = null) {
2236 2236
 		$related_model = $this->get_related_model_obj($model_name);
2237
-		if( ! is_array( $query_params ) ){
2238
-			EE_Error::doing_it_wrong('EEM_Base::sum_related', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
2237
+		if ( ! is_array($query_params)) {
2238
+			EE_Error::doing_it_wrong('EEM_Base::sum_related', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
2239 2239
 			$query_params = array();
2240 2240
 		}
2241 2241
 		//we're just going to use the query params on the related model's normal get_all query,
2242 2242
 		//except add a condition to say to match the current mod
2243
-		if( ! isset($query_params['default_where_conditions'])){
2244
-			$query_params['default_where_conditions']='none';
2243
+		if ( ! isset($query_params['default_where_conditions'])) {
2244
+			$query_params['default_where_conditions'] = 'none';
2245 2245
 		}
2246 2246
 		$this_model_name = $this->get_this_model_name();
2247 2247
 		$this_pk_field_name = $this->get_primary_key_field()->get_name();
2248
-		$query_params[0][$this_model_name.".".$this_pk_field_name]=$id_or_obj;
2249
-		return $related_model->sum($query_params,$field_to_sum);
2248
+		$query_params[0][$this_model_name.".".$this_pk_field_name] = $id_or_obj;
2249
+		return $related_model->sum($query_params, $field_to_sum);
2250 2250
 	}
2251 2251
 
2252 2252
 
@@ -2260,12 +2260,12 @@  discard block
 block discarded – undo
2260 2260
 	 * @return EE_Base_Class
2261 2261
 	 * @throws \EE_Error
2262 2262
 	 */
2263
-	public function get_first_related( EE_Base_Class $id_or_obj, $other_model_name, $query_params ){
2264
-		$query_params['limit']=1;
2265
-		$results = $this->get_all_related($id_or_obj,$other_model_name,$query_params);
2266
-		if( $results ){
2263
+	public function get_first_related(EE_Base_Class $id_or_obj, $other_model_name, $query_params) {
2264
+		$query_params['limit'] = 1;
2265
+		$results = $this->get_all_related($id_or_obj, $other_model_name, $query_params);
2266
+		if ($results) {
2267 2267
 			return array_shift($results);
2268
-		}else{
2268
+		} else {
2269 2269
 			return null;
2270 2270
 		}
2271 2271
 
@@ -2275,8 +2275,8 @@  discard block
 block discarded – undo
2275 2275
 	 * Gets the model's name as it's expected in queries. For example, if this is EEM_Event model, that would be Event
2276 2276
 	 * @return string
2277 2277
 	 */
2278
-	public function get_this_model_name(){
2279
-		return str_replace("EEM_","",get_class($this));
2278
+	public function get_this_model_name() {
2279
+		return str_replace("EEM_", "", get_class($this));
2280 2280
 	}
2281 2281
 
2282 2282
 	/**
@@ -2284,14 +2284,14 @@  discard block
 block discarded – undo
2284 2284
 	 * @return EE_Any_Foreign_Model_Name_Field
2285 2285
 	 * @throws EE_Error
2286 2286
 	 */
2287
-	public function get_field_containing_related_model_name(){
2288
-		foreach($this->field_settings(true) as $field){
2289
-			if($field instanceof EE_Any_Foreign_Model_Name_Field){
2287
+	public function get_field_containing_related_model_name() {
2288
+		foreach ($this->field_settings(true) as $field) {
2289
+			if ($field instanceof EE_Any_Foreign_Model_Name_Field) {
2290 2290
 				$field_with_model_name = $field;
2291 2291
 			}
2292 2292
 		}
2293
-		if( !isset($field_with_model_name) || !$field_with_model_name ){
2294
-			throw new EE_Error(sprintf(__("There is no EE_Any_Foreign_Model_Name field on model %s", "event_espresso"), $this->get_this_model_name() ));
2293
+		if ( ! isset($field_with_model_name) || ! $field_with_model_name) {
2294
+			throw new EE_Error(sprintf(__("There is no EE_Any_Foreign_Model_Name field on model %s", "event_espresso"), $this->get_this_model_name()));
2295 2295
 		}
2296 2296
 		return $field_with_model_name;
2297 2297
 	}
@@ -2312,19 +2312,19 @@  discard block
 block discarded – undo
2312 2312
 	 * @return int new primary key on main table that got inserted
2313 2313
 	 * @throws EE_Error
2314 2314
 	 */
2315
-	public function insert($field_n_values){
2315
+	public function insert($field_n_values) {
2316 2316
 		/**
2317 2317
 		 * Filters the fields and their values before inserting an item using the models
2318 2318
 		 * @param array $fields_n_values keys are the fields and values are their new values
2319 2319
 		 * @param EEM_Base $model the model used
2320 2320
 		 */
2321
-		$field_n_values = (array)apply_filters( 'FHEE__EEM_Base__insert__fields_n_values', $field_n_values, $this );
2322
-		if($this->_satisfies_unique_indexes($field_n_values)){
2321
+		$field_n_values = (array) apply_filters('FHEE__EEM_Base__insert__fields_n_values', $field_n_values, $this);
2322
+		if ($this->_satisfies_unique_indexes($field_n_values)) {
2323 2323
 			$main_table = $this->_get_main_table();
2324 2324
 			$new_id = $this->_insert_into_specific_table($main_table, $field_n_values, false);
2325
-			if( $new_id !== false ) {
2326
-				foreach($this->_get_other_tables() as $other_table){
2327
-					$this->_insert_into_specific_table($other_table, $field_n_values,$new_id);
2325
+			if ($new_id !== false) {
2326
+				foreach ($this->_get_other_tables() as $other_table) {
2327
+					$this->_insert_into_specific_table($other_table, $field_n_values, $new_id);
2328 2328
 				}
2329 2329
 			}
2330 2330
 			/**
@@ -2334,9 +2334,9 @@  discard block
 block discarded – undo
2334 2334
 			 * @param array $fields_n_values fields and their values
2335 2335
 			 * @param int|string the ID of the newly-inserted model object
2336 2336
 			 */
2337
-			do_action( 'AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id );
2337
+			do_action('AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id);
2338 2338
 			return $new_id;
2339
-		}else{
2339
+		} else {
2340 2340
 			return FALSE;
2341 2341
 		}
2342 2342
 	}
@@ -2351,10 +2351,10 @@  discard block
 block discarded – undo
2351 2351
 	 * @return boolean
2352 2352
 	 * @throws \EE_Error
2353 2353
 	 */
2354
-	protected function _satisfies_unique_indexes($field_n_values,$action = 'insert'){
2355
-		foreach($this->unique_indexes() as $index_name => $index){
2354
+	protected function _satisfies_unique_indexes($field_n_values, $action = 'insert') {
2355
+		foreach ($this->unique_indexes() as $index_name => $index) {
2356 2356
 			$uniqueness_where_params = array_intersect_key($field_n_values, $index->fields());
2357
-			if($this->exists(array($uniqueness_where_params))){
2357
+			if ($this->exists(array($uniqueness_where_params))) {
2358 2358
 				EE_Error::add_error(
2359 2359
 					sprintf(
2360 2360
 						__(
@@ -2364,8 +2364,8 @@  discard block
 block discarded – undo
2364 2364
 						$action,
2365 2365
 						$this->_get_class_name(),
2366 2366
 						$index_name,
2367
-						implode( ",", $index->field_names() ),
2368
-						http_build_query( $uniqueness_where_params )
2367
+						implode(",", $index->field_names()),
2368
+						http_build_query($uniqueness_where_params)
2369 2369
 					),
2370 2370
 					__FILE__,
2371 2371
 					__FUNCTION__,
@@ -2395,37 +2395,37 @@  discard block
 block discarded – undo
2395 2395
 	 * @throws EE_Error
2396 2396
 	 * @return EE_Base_Class|array
2397 2397
 	 */
2398
-	public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true ){
2399
-		if($obj_or_fields_array instanceof EE_Base_Class){
2398
+	public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true) {
2399
+		if ($obj_or_fields_array instanceof EE_Base_Class) {
2400 2400
 			$fields_n_values = $obj_or_fields_array->model_field_array();
2401
-		}elseif( is_array($obj_or_fields_array)){
2401
+		}elseif (is_array($obj_or_fields_array)) {
2402 2402
 			$fields_n_values = $obj_or_fields_array;
2403
-		}else{
2403
+		} else {
2404 2404
 			throw new EE_Error(
2405 2405
 				sprintf(
2406 2406
 					__(
2407 2407
 						"%s get_all_conflicting should be called with a model object or an array of field names and values, you provided %d",
2408 2408
 						"event_espresso"
2409 2409
 					),
2410
-					get_class( $this ),
2410
+					get_class($this),
2411 2411
 					$obj_or_fields_array
2412 2412
 				)
2413 2413
 			);
2414 2414
 		}
2415 2415
 		$query_params = array();
2416
-		if( $this->has_primary_key_field() &&
2417
-				( $include_primary_key || $this->get_primary_key_field() instanceof EE_Primary_Key_String_Field) &&
2418
-				isset($fields_n_values[$this->primary_key_name()])){
2416
+		if ($this->has_primary_key_field() &&
2417
+				($include_primary_key || $this->get_primary_key_field() instanceof EE_Primary_Key_String_Field) &&
2418
+				isset($fields_n_values[$this->primary_key_name()])) {
2419 2419
 			$query_params[0]['OR'][$this->primary_key_name()] = $fields_n_values[$this->primary_key_name()];
2420 2420
 		}
2421
-		foreach($this->unique_indexes() as $unique_index_name=>$unique_index){
2421
+		foreach ($this->unique_indexes() as $unique_index_name=>$unique_index) {
2422 2422
 			$uniqueness_where_params = array_intersect_key($fields_n_values, $unique_index->fields());
2423 2423
 			$query_params[0]['OR']['AND*'.$unique_index_name] = $uniqueness_where_params;
2424 2424
 		}
2425 2425
 		//if there is nothing to base this search on, then we shouldn't find anything
2426
-		if( empty( $query_params ) ){
2426
+		if (empty($query_params)) {
2427 2427
 			return array();
2428
-		}else{
2428
+		} else {
2429 2429
 			return $this->get_one($query_params);
2430 2430
 		}
2431 2431
 	}
@@ -2439,7 +2439,7 @@  discard block
 block discarded – undo
2439 2439
 	 * @return boolean
2440 2440
 	 * @throws \EE_Error
2441 2441
 	 */
2442
-	public function exists($query_params){
2442
+	public function exists($query_params) {
2443 2443
 		$query_params['limit'] = 1;
2444 2444
 		return $this->count($query_params) > 0;
2445 2445
 	}
@@ -2453,7 +2453,7 @@  discard block
 block discarded – undo
2453 2453
 	 * @return boolean
2454 2454
 	 * @throws \EE_Error
2455 2455
 	 */
2456
-	public function exists_by_ID($id){
2456
+	public function exists_by_ID($id) {
2457 2457
 		return $this->exists(array('default_where_conditions'=>'none', array($this->primary_key_name() => $id)));
2458 2458
 	}
2459 2459
 
@@ -2473,45 +2473,45 @@  discard block
 block discarded – undo
2473 2473
 	 * @global WPDB $wpdb only used to get the $wpdb->insert_id after performing an insert
2474 2474
 	 * @return int ID of new row inserted, or FALSE on failure
2475 2475
 	 */
2476
-	protected function _insert_into_specific_table(EE_Table_Base $table, $fields_n_values, $new_id = 0 ){
2476
+	protected function _insert_into_specific_table(EE_Table_Base $table, $fields_n_values, $new_id = 0) {
2477 2477
 		global $wpdb;
2478 2478
 		$insertion_col_n_values = array();
2479 2479
 		$format_for_insertion = array();
2480 2480
 		$fields_on_table = $this->_get_fields_for_table($table->get_table_alias());
2481
-		foreach($fields_on_table as $field_name => $field_obj){
2481
+		foreach ($fields_on_table as $field_name => $field_obj) {
2482 2482
 			//check if its an auto-incrementing column, in which case we should just leave it to do its autoincrement thing
2483
-			if($field_obj->is_auto_increment()){
2483
+			if ($field_obj->is_auto_increment()) {
2484 2484
 				continue;
2485 2485
 			}
2486 2486
 			$prepared_value = $this->_prepare_value_or_use_default($field_obj, $fields_n_values);
2487 2487
 			//if the value we want to assign it to is NULL, just don't mention it for the insertion
2488
-			if( $prepared_value !== NULL ){
2489
-				$insertion_col_n_values[ $field_obj->get_table_column() ] = $prepared_value;
2488
+			if ($prepared_value !== NULL) {
2489
+				$insertion_col_n_values[$field_obj->get_table_column()] = $prepared_value;
2490 2490
 				$format_for_insertion[] = $field_obj->get_wpdb_data_type();
2491 2491
 			}
2492 2492
 		}
2493 2493
 
2494
-		if($table instanceof EE_Secondary_Table && $new_id){
2494
+		if ($table instanceof EE_Secondary_Table && $new_id) {
2495 2495
 			//its not the main table, so we should have already saved the main table's PK which we just inserted
2496 2496
 			//so add the fk to the main table as a column
2497 2497
 			$insertion_col_n_values[$table->get_fk_on_table()] = $new_id;
2498
-			$format_for_insertion[]='%d';//yes right now we're only allowing these foreign keys to be INTs
2498
+			$format_for_insertion[] = '%d'; //yes right now we're only allowing these foreign keys to be INTs
2499 2499
 		}
2500 2500
 		//insert the new entry
2501
-		$result = $this->_do_wpdb_query( 'insert', array( $table->get_table_name(), $insertion_col_n_values, $format_for_insertion ) );
2502
-		if( $result === false ) {
2501
+		$result = $this->_do_wpdb_query('insert', array($table->get_table_name(), $insertion_col_n_values, $format_for_insertion));
2502
+		if ($result === false) {
2503 2503
 			return false;
2504 2504
 		}
2505 2505
 		//ok, now what do we return for the ID of the newly-inserted thing?
2506
-		if($this->has_primary_key_field()){
2507
-			if($this->get_primary_key_field()->is_auto_increment()){
2506
+		if ($this->has_primary_key_field()) {
2507
+			if ($this->get_primary_key_field()->is_auto_increment()) {
2508 2508
 				return $wpdb->insert_id;
2509
-			}else{
2509
+			} else {
2510 2510
 				//it's not an auto-increment primary key, so
2511 2511
 				//it must have been supplied
2512 2512
 				return $fields_n_values[$this->get_primary_key_field()->get_name()];
2513 2513
 			}
2514
-		}else{
2514
+		} else {
2515 2515
 			//we can't return a  primary key because there is none. instead return
2516 2516
 			//a unique string indicating this model
2517 2517
 			return $this->get_index_primary_key_string($fields_n_values);
@@ -2530,15 +2530,15 @@  discard block
 block discarded – undo
2530 2530
 	 * @return mixed string|int|float depending on what the table column will be expecting
2531 2531
 	 * @throws \EE_Error
2532 2532
 	 */
2533
-	protected function _prepare_value_or_use_default( $field_obj, $fields_n_values ){
2533
+	protected function _prepare_value_or_use_default($field_obj, $fields_n_values) {
2534 2534
 		//if this field doesn't allow nullable, don't allow it
2535
-		if( ! $field_obj->is_nullable() && (
2536
-				! isset( $fields_n_values[ $field_obj->get_name() ] ) ||
2537
-				$fields_n_values[ $field_obj->get_name() ] === NULL ) ){
2538
-			$fields_n_values[ $field_obj->get_name() ] = $field_obj->get_default_value();
2535
+		if ( ! $field_obj->is_nullable() && (
2536
+				! isset($fields_n_values[$field_obj->get_name()]) ||
2537
+				$fields_n_values[$field_obj->get_name()] === NULL )) {
2538
+			$fields_n_values[$field_obj->get_name()] = $field_obj->get_default_value();
2539 2539
 		}
2540
-		$unprepared_value = isset( $fields_n_values[ $field_obj->get_name() ] ) ? $fields_n_values[ $field_obj->get_name() ] : NULL;
2541
-		return $this->_prepare_value_for_use_in_db( $unprepared_value, $field_obj);
2540
+		$unprepared_value = isset($fields_n_values[$field_obj->get_name()]) ? $fields_n_values[$field_obj->get_name()] : NULL;
2541
+		return $this->_prepare_value_for_use_in_db($unprepared_value, $field_obj);
2542 2542
 	}
2543 2543
 
2544 2544
 
@@ -2550,9 +2550,9 @@  discard block
 block discarded – undo
2550 2550
 	 * @param EE_Model_Field_Base $field field which will be doing the preparing of the value. If null, we assume $value is a custom selection
2551 2551
 	 * @return mixed a value ready for use in the database for insertions, updating, or in a where clause
2552 2552
 	 */
2553
-	private function _prepare_value_for_use_in_db($value, $field){
2554
-		if($field && $field instanceof EE_Model_Field_Base){
2555
-			switch( $this->_values_already_prepared_by_model_object ){
2553
+	private function _prepare_value_for_use_in_db($value, $field) {
2554
+		if ($field && $field instanceof EE_Model_Field_Base) {
2555
+			switch ($this->_values_already_prepared_by_model_object) {
2556 2556
 				/** @noinspection PhpMissingBreakStatementInspection */
2557 2557
 				case self::not_prepared_by_model_object:
2558 2558
 					$value = $field->prepare_for_set($value);
@@ -2563,7 +2563,7 @@  discard block
 block discarded – undo
2563 2563
 					//leave the value alone
2564 2564
 			}
2565 2565
 			return $value;
2566
-		}else{
2566
+		} else {
2567 2567
 			return $value;
2568 2568
 		}
2569 2569
 	}
@@ -2573,13 +2573,13 @@  discard block
 block discarded – undo
2573 2573
 	 * @return EE_Primary_Table
2574 2574
 	 * @throws EE_Error
2575 2575
 	 */
2576
-	protected function _get_main_table(){
2577
-		foreach($this->_tables as $table){
2578
-			if($table instanceof EE_Primary_Table){
2576
+	protected function _get_main_table() {
2577
+		foreach ($this->_tables as $table) {
2578
+			if ($table instanceof EE_Primary_Table) {
2579 2579
 				return $table;
2580 2580
 			}
2581 2581
 		}
2582
-		throw new EE_Error(sprintf(__('There are no main tables on %s. They should be added to _tables array in the constructor','event_espresso'),get_class($this)));
2582
+		throw new EE_Error(sprintf(__('There are no main tables on %s. They should be added to _tables array in the constructor', 'event_espresso'), get_class($this)));
2583 2583
 	}
2584 2584
 
2585 2585
 
@@ -2602,7 +2602,7 @@  discard block
 block discarded – undo
2602 2602
 	 */
2603 2603
 	public function second_table() {
2604 2604
 		// grab second table from tables array
2605
-		$second_table = end( $this->_tables );
2605
+		$second_table = end($this->_tables);
2606 2606
 		return $second_table instanceof EE_Secondary_Table ? $second_table->get_table_name() : NULL;
2607 2607
 	}
2608 2608
 
@@ -2615,8 +2615,8 @@  discard block
 block discarded – undo
2615 2615
 	 * @param string $table_alias
2616 2616
 	 * @return EE_Primary_Table | EE_Secondary_Table
2617 2617
 	 */
2618
-	public function get_table_obj_by_alias( $table_alias = '' ) {
2619
-		return isset( $this->_tables[ $table_alias ] ) ? $this->_tables[ $table_alias ] : NULL;
2618
+	public function get_table_obj_by_alias($table_alias = '') {
2619
+		return isset($this->_tables[$table_alias]) ? $this->_tables[$table_alias] : NULL;
2620 2620
 	}
2621 2621
 
2622 2622
 
@@ -2625,10 +2625,10 @@  discard block
 block discarded – undo
2625 2625
 	 * Gets all the tables of type EE_Other_Table from EEM_CPT_Basel_Model::_tables
2626 2626
 	 * @return EE_Secondary_Table[]
2627 2627
 	 */
2628
-	protected function _get_other_tables(){
2629
-		$other_tables =array();
2630
-		foreach($this->_tables as $table_alias => $table){
2631
-			if($table instanceof EE_Secondary_Table){
2628
+	protected function _get_other_tables() {
2629
+		$other_tables = array();
2630
+		foreach ($this->_tables as $table_alias => $table) {
2631
+			if ($table instanceof EE_Secondary_Table) {
2632 2632
 				$other_tables[$table_alias] = $table;
2633 2633
 			}
2634 2634
 		}
@@ -2640,7 +2640,7 @@  discard block
 block discarded – undo
2640 2640
 	 * @param string $table_alias, array key in EEM_Base::_tables
2641 2641
 	 * @return EE_Model_Field_Base[]
2642 2642
 	 */
2643
-	public function _get_fields_for_table($table_alias){
2643
+	public function _get_fields_for_table($table_alias) {
2644 2644
 		return $this->_fields[$table_alias];
2645 2645
 	}
2646 2646
 
@@ -2656,19 +2656,19 @@  discard block
 block discarded – undo
2656 2656
 	 * @return EE_Model_Query_Info_Carrier
2657 2657
 	 * @throws \EE_Error
2658 2658
 	 */
2659
-	public function _extract_related_models_from_query($query_params){
2659
+	public function _extract_related_models_from_query($query_params) {
2660 2660
 		$query_info_carrier = new EE_Model_Query_Info_Carrier();
2661
-		if ( array_key_exists( 0, $query_params ) ) {
2662
-			$this->_extract_related_models_from_sub_params_array_keys( $query_params[0], $query_info_carrier, 0 );
2661
+		if (array_key_exists(0, $query_params)) {
2662
+			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier, 0);
2663 2663
 		}
2664
-		if ( array_key_exists( 'group_by', $query_params ) ) {
2665
-			if ( is_array( $query_params['group_by'] ) ) {
2664
+		if (array_key_exists('group_by', $query_params)) {
2665
+			if (is_array($query_params['group_by'])) {
2666 2666
 				$this->_extract_related_models_from_sub_params_array_values(
2667 2667
 					$query_params['group_by'],
2668 2668
 					$query_info_carrier,
2669 2669
 					'group_by'
2670 2670
 				);
2671
-			} elseif ( ! empty ( $query_params['group_by'] ) ) {
2671
+			} elseif ( ! empty ($query_params['group_by'])) {
2672 2672
 				$this->_extract_related_model_info_from_query_param(
2673 2673
 					$query_params['group_by'],
2674 2674
 					$query_info_carrier,
@@ -2676,21 +2676,21 @@  discard block
 block discarded – undo
2676 2676
 				);
2677 2677
 			}
2678 2678
 		}
2679
-		if ( array_key_exists( 'having', $query_params ) ) {
2679
+		if (array_key_exists('having', $query_params)) {
2680 2680
 			$this->_extract_related_models_from_sub_params_array_keys(
2681 2681
 				$query_params[0],
2682 2682
 				$query_info_carrier,
2683 2683
 				'having'
2684 2684
 			);
2685 2685
 		}
2686
-		if ( array_key_exists( 'order_by', $query_params ) ) {
2687
-			if ( is_array( $query_params['order_by'] ) ) {
2686
+		if (array_key_exists('order_by', $query_params)) {
2687
+			if (is_array($query_params['order_by'])) {
2688 2688
 				$this->_extract_related_models_from_sub_params_array_keys(
2689 2689
 					$query_params['order_by'],
2690 2690
 					$query_info_carrier,
2691 2691
 					'order_by'
2692 2692
 				);
2693
-			} elseif ( ! empty( $query_params['order_by'] ) ) {
2693
+			} elseif ( ! empty($query_params['order_by'])) {
2694 2694
 				$this->_extract_related_model_info_from_query_param(
2695 2695
 					$query_params['order_by'],
2696 2696
 					$query_info_carrier,
@@ -2698,7 +2698,7 @@  discard block
 block discarded – undo
2698 2698
 				);
2699 2699
 			}
2700 2700
 		}
2701
-		if ( array_key_exists( 'force_join', $query_params ) ) {
2701
+		if (array_key_exists('force_join', $query_params)) {
2702 2702
 			$this->_extract_related_models_from_sub_params_array_values(
2703 2703
 				$query_params['force_join'],
2704 2704
 				$query_info_carrier,
@@ -2716,34 +2716,34 @@  discard block
 block discarded – undo
2716 2716
 	 * @throws EE_Error
2717 2717
 	 * @return \EE_Model_Query_Info_Carrier
2718 2718
 	 */
2719
-	private function _extract_related_models_from_sub_params_array_keys($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier,$query_param_type){
2720
-		if (!empty($sub_query_params)){
2719
+	private function _extract_related_models_from_sub_params_array_keys($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier, $query_param_type) {
2720
+		if ( ! empty($sub_query_params)) {
2721 2721
 			$sub_query_params = (array) $sub_query_params;
2722
-			foreach($sub_query_params as $param => $possibly_array_of_params){
2722
+			foreach ($sub_query_params as $param => $possibly_array_of_params) {
2723 2723
 				//$param could be simply 'EVT_ID', or it could be 'Registrations.REG_ID', or even 'Registrations.Transactions.Payments.PAY_amount'
2724
-				$this->_extract_related_model_info_from_query_param( $param, $model_query_info_carrier,$query_param_type);
2724
+				$this->_extract_related_model_info_from_query_param($param, $model_query_info_carrier, $query_param_type);
2725 2725
 
2726 2726
 				//if $possibly_array_of_params is an array, try recursing into it, searching for keys which
2727 2727
 				//indicate needed joins. Eg, array('NOT'=>array('Registration.TXN_ID'=>23)). In this case, we tried
2728 2728
 				//extracting models out of the 'NOT', which obviously wasn't successful, and then we recurse into the value
2729 2729
 				//of array('Registration.TXN_ID'=>23)
2730 2730
 				$query_param_sans_stars = $this->_remove_stars_and_anything_after_from_condition_query_param_key($param);
2731
-				if(in_array($query_param_sans_stars, $this->_logic_query_param_keys,true)){
2732
-					if (! is_array($possibly_array_of_params)){
2731
+				if (in_array($query_param_sans_stars, $this->_logic_query_param_keys, true)) {
2732
+					if ( ! is_array($possibly_array_of_params)) {
2733 2733
 						throw new EE_Error(sprintf(__("You used a special where query param %s, but the value isn't an array of where query params, it's just %s'. It should be an array, eg array('EVT_ID'=>23,'OR'=>array('Venue.VNU_ID'=>32,'Venue.VNU_name'=>'monkey_land'))", "event_espresso"),
2734
-							$param,$possibly_array_of_params));
2735
-					}else{
2736
-						$this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier,$query_param_type);
2734
+							$param, $possibly_array_of_params));
2735
+					} else {
2736
+						$this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier, $query_param_type);
2737 2737
 					}
2738
-				}elseif($query_param_type === 0 //ie WHERE
2738
+				}elseif ($query_param_type === 0 //ie WHERE
2739 2739
 						&& is_array($possibly_array_of_params)
2740 2740
 						&& isset($possibly_array_of_params[2])
2741
-						&& $possibly_array_of_params[2] == true){
2741
+						&& $possibly_array_of_params[2] == true) {
2742 2742
 					//then $possible_array_of_params looks something like array('<','DTT_sold',true)
2743 2743
 					//indicating that $possible_array_of_params[1] is actually a field name,
2744 2744
 					//from which we should extract query parameters!
2745
-					if( ! isset($possibly_array_of_params[0], $possibly_array_of_params[1] ) ) {
2746
-						throw new EE_Error(sprintf(__("Improperly formed query parameter %s. It should be numerically indexed like array('<','DTT_sold',true); but you provided %s", "event_espresso"),$query_param_type,implode(",",$possibly_array_of_params)));
2745
+					if ( ! isset($possibly_array_of_params[0], $possibly_array_of_params[1])) {
2746
+						throw new EE_Error(sprintf(__("Improperly formed query parameter %s. It should be numerically indexed like array('<','DTT_sold',true); but you provided %s", "event_espresso"), $query_param_type, implode(",", $possibly_array_of_params)));
2747 2747
 					}
2748 2748
 					$this->_extract_related_model_info_from_query_param($possibly_array_of_params[1], $model_query_info_carrier, $query_param_type);
2749 2749
 				}
@@ -2762,14 +2762,14 @@  discard block
 block discarded – undo
2762 2762
 	 * @throws EE_Error
2763 2763
 	 * @return \EE_Model_Query_Info_Carrier
2764 2764
 	 */
2765
-	private function _extract_related_models_from_sub_params_array_values($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier,$query_param_type){
2766
-		if (!empty($sub_query_params)){
2767
-			if(!is_array($sub_query_params)){
2768
-				throw new EE_Error(sprintf(__("Query parameter %s should be an array, but it isn't.", "event_espresso"),$sub_query_params));
2765
+	private function _extract_related_models_from_sub_params_array_values($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier, $query_param_type) {
2766
+		if ( ! empty($sub_query_params)) {
2767
+			if ( ! is_array($sub_query_params)) {
2768
+				throw new EE_Error(sprintf(__("Query parameter %s should be an array, but it isn't.", "event_espresso"), $sub_query_params));
2769 2769
 			}
2770
-			foreach($sub_query_params as $param){
2770
+			foreach ($sub_query_params as $param) {
2771 2771
 				//$param could be simply 'EVT_ID', or it could be 'Registrations.REG_ID', or even 'Registrations.Transactions.Payments.PAY_amount'
2772
-				$this->_extract_related_model_info_from_query_param( $param, $model_query_info_carrier, $query_param_type);
2772
+				$this->_extract_related_model_info_from_query_param($param, $model_query_info_carrier, $query_param_type);
2773 2773
 			}
2774 2774
 		}
2775 2775
 		return $model_query_info_carrier;
@@ -2788,8 +2788,8 @@  discard block
 block discarded – undo
2788 2788
 	 * @throws EE_Error
2789 2789
 	 * @return EE_Model_Query_Info_Carrier
2790 2790
 	 */
2791
-	public function _create_model_query_info_carrier($query_params){
2792
-		if ( ! is_array( $query_params ) ) {
2791
+	public function _create_model_query_info_carrier($query_params) {
2792
+		if ( ! is_array($query_params)) {
2793 2793
 			EE_Error::doing_it_wrong(
2794 2794
 				'EEM_Base::_create_model_query_info_carrier',
2795 2795
 				sprintf(
@@ -2797,16 +2797,16 @@  discard block
 block discarded – undo
2797 2797
 						'$query_params should be an array, you passed a variable of type %s',
2798 2798
 						'event_espresso'
2799 2799
 					),
2800
-					gettype( $query_params )
2800
+					gettype($query_params)
2801 2801
 				),
2802 2802
 				'4.6.0'
2803 2803
 			);
2804 2804
 			$query_params = array();
2805 2805
 		}
2806
-		$where_query_params = isset( $query_params[0] ) ? $query_params[0] : array();
2806
+		$where_query_params = isset($query_params[0]) ? $query_params[0] : array();
2807 2807
 		//first check if we should alter the query to account for caps or not
2808 2808
 		//because the caps might require us to do extra joins
2809
-		if ( isset( $query_params['caps'] ) && $query_params['caps'] !== 'none' ) {
2809
+		if (isset($query_params['caps']) && $query_params['caps'] !== 'none') {
2810 2810
 			$query_params[0] = $where_query_params = array_replace_recursive(
2811 2811
 				$where_query_params,
2812 2812
 				$this->caps_where_conditions(
@@ -2814,10 +2814,10 @@  discard block
 block discarded – undo
2814 2814
 				)
2815 2815
 			);
2816 2816
 		}
2817
-		$query_object = $this->_extract_related_models_from_query( $query_params );
2817
+		$query_object = $this->_extract_related_models_from_query($query_params);
2818 2818
 		//verify where_query_params has NO numeric indexes.... that's simply not how you use it!
2819
-		foreach ( $where_query_params as $key => $value ) {
2820
-			if ( is_int( $key ) ) {
2819
+		foreach ($where_query_params as $key => $value) {
2820
+			if (is_int($key)) {
2821 2821
 				throw new EE_Error(
2822 2822
 					sprintf(
2823 2823
 						__(
@@ -2825,16 +2825,16 @@  discard block
 block discarded – undo
2825 2825
 							"event_espresso"
2826 2826
 						),
2827 2827
 						$key,
2828
-						var_export( $value, true ),
2829
-						var_export( $query_params, true ),
2830
-						get_class( $this )
2828
+						var_export($value, true),
2829
+						var_export($query_params, true),
2830
+						get_class($this)
2831 2831
 					)
2832 2832
 				);
2833 2833
 			}
2834 2834
 		}
2835 2835
 		if (
2836
-			array_key_exists( 'default_where_conditions', $query_params )
2837
-			&& ! empty( $query_params['default_where_conditions'] )
2836
+			array_key_exists('default_where_conditions', $query_params)
2837
+			&& ! empty($query_params['default_where_conditions'])
2838 2838
 		) {
2839 2839
 			$use_default_where_conditions = $query_params['default_where_conditions'];
2840 2840
 		} else {
@@ -2848,13 +2848,13 @@  discard block
 block discarded – undo
2848 2848
 			),
2849 2849
 			$where_query_params
2850 2850
 		);
2851
-		$query_object->set_where_sql( $this->_construct_where_clause( $where_query_params ) );
2851
+		$query_object->set_where_sql($this->_construct_where_clause($where_query_params));
2852 2852
 		// if this is a "on_join_limit" then we are limiting on on a specific table in a multi_table join.
2853 2853
 		// So we need to setup a subquery and use that for the main join.
2854 2854
 		// Note for now this only works on the primary table for the model.
2855 2855
 		// So for instance, you could set the limit array like this:
2856 2856
 		// array( 'on_join_limit' => array('Primary_Table_Alias', array(1,10) ) )
2857
-		if ( array_key_exists( 'on_join_limit', $query_params ) && ! empty( $query_params['on_join_limit'] ) ) {
2857
+		if (array_key_exists('on_join_limit', $query_params) && ! empty($query_params['on_join_limit'])) {
2858 2858
 			$query_object->set_main_model_join_sql(
2859 2859
 				$this->_construct_limit_join_select(
2860 2860
 					$query_params['on_join_limit'][0],
@@ -2863,40 +2863,40 @@  discard block
 block discarded – undo
2863 2863
 			);
2864 2864
 		}
2865 2865
 		//set limit
2866
-		if ( array_key_exists( 'limit', $query_params ) ) {
2867
-			if ( is_array( $query_params['limit'] ) ) {
2868
-				if ( ! isset( $query_params['limit'][0], $query_params['limit'][1] ) ) {
2866
+		if (array_key_exists('limit', $query_params)) {
2867
+			if (is_array($query_params['limit'])) {
2868
+				if ( ! isset($query_params['limit'][0], $query_params['limit'][1])) {
2869 2869
 					$e = sprintf(
2870 2870
 						__(
2871 2871
 							"Invalid DB query. You passed '%s' for the LIMIT, but only the following are valid: an integer, string representing an integer, a string like 'int,int', or an array like array(int,int)",
2872 2872
 							"event_espresso"
2873 2873
 						),
2874
-						http_build_query( $query_params['limit'] )
2874
+						http_build_query($query_params['limit'])
2875 2875
 					);
2876
-					throw new EE_Error( $e . "|" . $e );
2876
+					throw new EE_Error($e."|".$e);
2877 2877
 				}
2878 2878
 				//they passed us an array for the limit. Assume it's like array(50,25), meaning offset by 50, and get 25
2879
-				$query_object->set_limit_sql( " LIMIT " . $query_params['limit'][0] . "," . $query_params['limit'][1] );
2880
-			} elseif ( ! empty ( $query_params['limit'] ) ) {
2881
-				$query_object->set_limit_sql( " LIMIT " . $query_params['limit'] );
2879
+				$query_object->set_limit_sql(" LIMIT ".$query_params['limit'][0].",".$query_params['limit'][1]);
2880
+			} elseif ( ! empty ($query_params['limit'])) {
2881
+				$query_object->set_limit_sql(" LIMIT ".$query_params['limit']);
2882 2882
 			}
2883 2883
 		}
2884 2884
 		//set order by
2885
-		if ( array_key_exists( 'order_by', $query_params ) ) {
2886
-			if ( is_array( $query_params['order_by'] ) ) {
2885
+		if (array_key_exists('order_by', $query_params)) {
2886
+			if (is_array($query_params['order_by'])) {
2887 2887
 				//if they're using 'order_by' as an array, they can't use 'order' (because 'order_by' must
2888 2888
 				//specify whether to ascend or descend on each field. Eg 'order_by'=>array('EVT_ID'=>'ASC'). So
2889 2889
 				//including 'order' wouldn't make any sense if 'order_by' has already specified which way to order!
2890
-				if ( array_key_exists( 'order', $query_params ) ) {
2890
+				if (array_key_exists('order', $query_params)) {
2891 2891
 					throw new EE_Error(
2892 2892
 						sprintf(
2893 2893
 							__(
2894 2894
 								"In querying %s, we are using query parameter 'order_by' as an array (keys:%s,values:%s), and so we can't use query parameter 'order' (value %s). You should just use the 'order_by' parameter ",
2895 2895
 								"event_espresso"
2896 2896
 							),
2897
-							get_class( $this ),
2898
-							implode( ", ", array_keys( $query_params['order_by'] ) ),
2899
-							implode( ", ", $query_params['order_by'] ),
2897
+							get_class($this),
2898
+							implode(", ", array_keys($query_params['order_by'])),
2899
+							implode(", ", $query_params['order_by']),
2900 2900
 							$query_params['order']
2901 2901
 						)
2902 2902
 					);
@@ -2908,57 +2908,57 @@  discard block
 block discarded – undo
2908 2908
 				);
2909 2909
 				//assume it's an array of fields to order by
2910 2910
 				$order_array = array();
2911
-				foreach ( $query_params['order_by'] as $field_name_to_order_by => $order ) {
2912
-					$order = $this->_extract_order( $order );
2913
-					$order_array[] = $this->_deduce_column_name_from_query_param( $field_name_to_order_by ) . SP . $order;
2911
+				foreach ($query_params['order_by'] as $field_name_to_order_by => $order) {
2912
+					$order = $this->_extract_order($order);
2913
+					$order_array[] = $this->_deduce_column_name_from_query_param($field_name_to_order_by).SP.$order;
2914 2914
 				}
2915
-				$query_object->set_order_by_sql( " ORDER BY " . implode( ",", $order_array ) );
2916
-			} elseif ( ! empty ( $query_params['order_by'] ) ) {
2915
+				$query_object->set_order_by_sql(" ORDER BY ".implode(",", $order_array));
2916
+			} elseif ( ! empty ($query_params['order_by'])) {
2917 2917
 				$this->_extract_related_model_info_from_query_param(
2918 2918
 					$query_params['order_by'],
2919 2919
 					$query_object,
2920 2920
 					'order',
2921 2921
 					$query_params['order_by']
2922 2922
 				);
2923
-				$order = isset( $query_params['order'] )
2924
-					? $this->_extract_order( $query_params['order'] )
2923
+				$order = isset($query_params['order'])
2924
+					? $this->_extract_order($query_params['order'])
2925 2925
 					: 'DESC';
2926 2926
 				$query_object->set_order_by_sql(
2927
-					" ORDER BY " . $this->_deduce_column_name_from_query_param( $query_params['order_by'] ) . SP . $order
2927
+					" ORDER BY ".$this->_deduce_column_name_from_query_param($query_params['order_by']).SP.$order
2928 2928
 				);
2929 2929
 			}
2930 2930
 		}
2931 2931
 		//if 'order_by' wasn't set, maybe they are just using 'order' on its own?
2932
-		if ( ! array_key_exists( 'order_by', $query_params )
2933
-		     && array_key_exists( 'order', $query_params )
2934
-		     && ! empty( $query_params['order'] )
2932
+		if ( ! array_key_exists('order_by', $query_params)
2933
+		     && array_key_exists('order', $query_params)
2934
+		     && ! empty($query_params['order'])
2935 2935
 		) {
2936 2936
 			$pk_field = $this->get_primary_key_field();
2937
-			$order = $this->_extract_order( $query_params['order'] );
2938
-			$query_object->set_order_by_sql( " ORDER BY " . $pk_field->get_qualified_column() . SP . $order );
2937
+			$order = $this->_extract_order($query_params['order']);
2938
+			$query_object->set_order_by_sql(" ORDER BY ".$pk_field->get_qualified_column().SP.$order);
2939 2939
 		}
2940 2940
 		//set group by
2941
-		if ( array_key_exists( 'group_by', $query_params ) ) {
2942
-			if ( is_array( $query_params['group_by'] ) ) {
2941
+		if (array_key_exists('group_by', $query_params)) {
2942
+			if (is_array($query_params['group_by'])) {
2943 2943
 				//it's an array, so assume we'll be grouping by a bunch of stuff
2944 2944
 				$group_by_array = array();
2945
-				foreach ( $query_params['group_by'] as $field_name_to_group_by ) {
2946
-					$group_by_array[] = $this->_deduce_column_name_from_query_param( $field_name_to_group_by );
2945
+				foreach ($query_params['group_by'] as $field_name_to_group_by) {
2946
+					$group_by_array[] = $this->_deduce_column_name_from_query_param($field_name_to_group_by);
2947 2947
 				}
2948
-				$query_object->set_group_by_sql( " GROUP BY " . implode( ", ", $group_by_array ) );
2949
-			} elseif ( ! empty ( $query_params['group_by'] ) ) {
2948
+				$query_object->set_group_by_sql(" GROUP BY ".implode(", ", $group_by_array));
2949
+			} elseif ( ! empty ($query_params['group_by'])) {
2950 2950
 				$query_object->set_group_by_sql(
2951
-					" GROUP BY " . $this->_deduce_column_name_from_query_param( $query_params['group_by'] )
2951
+					" GROUP BY ".$this->_deduce_column_name_from_query_param($query_params['group_by'])
2952 2952
 				);
2953 2953
 			}
2954 2954
 		}
2955 2955
 		//set having
2956
-		if ( array_key_exists( 'having', $query_params ) && $query_params['having'] ) {
2957
-			$query_object->set_having_sql( $this->_construct_having_clause( $query_params['having'] ) );
2956
+		if (array_key_exists('having', $query_params) && $query_params['having']) {
2957
+			$query_object->set_having_sql($this->_construct_having_clause($query_params['having']));
2958 2958
 		}
2959 2959
 		//now, just verify they didn't pass anything wack
2960
-		foreach ( $query_params as $query_key => $query_value ) {
2961
-			if ( ! in_array( $query_key, $this->_allowed_query_params, true ) ) {
2960
+		foreach ($query_params as $query_key => $query_value) {
2961
+			if ( ! in_array($query_key, $this->_allowed_query_params, true)) {
2962 2962
 				throw new EE_Error(
2963 2963
 					sprintf(
2964 2964
 						__(
@@ -2966,16 +2966,16 @@  discard block
 block discarded – undo
2966 2966
 							'event_espresso'
2967 2967
 						),
2968 2968
 						$query_key,
2969
-						get_class( $this ),
2969
+						get_class($this),
2970 2970
 //						print_r( $this->_allowed_query_params, TRUE )
2971
-						implode( ',', $this->_allowed_query_params )
2971
+						implode(',', $this->_allowed_query_params)
2972 2972
 					)
2973 2973
 				);
2974 2974
 			}
2975 2975
 		}
2976 2976
 		$main_model_join_sql = $query_object->get_main_model_join_sql();
2977
-		if ( empty( $main_model_join_sql ) ) {
2978
-			$query_object->set_main_model_join_sql( $this->_construct_internal_join() );
2977
+		if (empty($main_model_join_sql)) {
2978
+			$query_object->set_main_model_join_sql($this->_construct_internal_join());
2979 2979
 		}
2980 2980
 		return $query_object;
2981 2981
 	}
@@ -2990,17 +2990,17 @@  discard block
 block discarded – undo
2990 2990
 	 * @return array like EEM_Base::get_all() 's $query_params[0]
2991 2991
 	 * @throws \EE_Error
2992 2992
 	 */
2993
-	public function caps_where_conditions( $context = self::caps_read ) {
2994
-		EEM_Base::verify_is_valid_cap_context( $context );
2993
+	public function caps_where_conditions($context = self::caps_read) {
2994
+		EEM_Base::verify_is_valid_cap_context($context);
2995 2995
 		$cap_where_conditions = array();
2996
-		$cap_restrictions = $this->caps_missing( $context );
2996
+		$cap_restrictions = $this->caps_missing($context);
2997 2997
 		/**
2998 2998
 		 * @var $cap_restrictions EE_Default_Where_Conditions[]
2999 2999
 		 */
3000
-		foreach( $cap_restrictions as $cap => $restriction_if_no_cap ) {
3001
-				$cap_where_conditions = array_replace_recursive( $cap_where_conditions, $restriction_if_no_cap->get_default_where_conditions() );
3000
+		foreach ($cap_restrictions as $cap => $restriction_if_no_cap) {
3001
+				$cap_where_conditions = array_replace_recursive($cap_where_conditions, $restriction_if_no_cap->get_default_where_conditions());
3002 3002
 		}
3003
-		return apply_filters( 'FHEE__EEM_Base__caps_where_conditions__return', $cap_where_conditions, $this, $context, $cap_restrictions );
3003
+		return apply_filters('FHEE__EEM_Base__caps_where_conditions__return', $cap_where_conditions, $this, $context, $cap_restrictions);
3004 3004
 	}
3005 3005
 
3006 3006
 	/**
@@ -3010,11 +3010,11 @@  discard block
 block discarded – undo
3010 3010
 	 * @return string either ASC, asc, DESC or desc
3011 3011
 	 * @throws EE_Error
3012 3012
 	 */
3013
-	private function _extract_order($should_be_order_string){
3014
-		if(in_array($should_be_order_string, $this->_allowed_order_values)){
3013
+	private function _extract_order($should_be_order_string) {
3014
+		if (in_array($should_be_order_string, $this->_allowed_order_values)) {
3015 3015
 			return $should_be_order_string;
3016
-		}else{
3017
-			throw new EE_Error(sprintf(__("While performing a query on '%s', tried to use '%s' as an order parameter. ", "event_espresso"),get_class($this),$should_be_order_string));
3016
+		} else {
3017
+			throw new EE_Error(sprintf(__("While performing a query on '%s', tried to use '%s' as an order parameter. ", "event_espresso"), get_class($this), $should_be_order_string));
3018 3018
 		}
3019 3019
 	}
3020 3020
 
@@ -3032,7 +3032,7 @@  discard block
 block discarded – undo
3032 3032
 	 * @throws EE_Error
3033 3033
 	 * @return array like $query_params[0], see EEM_Base::get_all for documentation
3034 3034
 	 */
3035
-	private function _get_default_where_conditions_for_models_in_query(EE_Model_Query_Info_Carrier $query_info_carrier,$use_default_where_conditions = 'all',$where_query_params = array()){
3035
+	private function _get_default_where_conditions_for_models_in_query(EE_Model_Query_Info_Carrier $query_info_carrier, $use_default_where_conditions = 'all', $where_query_params = array()) {
3036 3036
 		$allowed_used_default_where_conditions_values = array(
3037 3037
 				'all',
3038 3038
 				'this_model_only',
@@ -3040,17 +3040,17 @@  discard block
 block discarded – undo
3040 3040
 				'minimum',
3041 3041
 				'none'
3042 3042
 			);
3043
-		if( ! in_array($use_default_where_conditions,$allowed_used_default_where_conditions_values)){
3044
-			throw new EE_Error(sprintf(__("You passed an invalid value to the query parameter 'default_where_conditions' of '%s'. Allowed values are %s", "event_espresso"),$use_default_where_conditions,implode(", ",$allowed_used_default_where_conditions_values)));
3043
+		if ( ! in_array($use_default_where_conditions, $allowed_used_default_where_conditions_values)) {
3044
+			throw new EE_Error(sprintf(__("You passed an invalid value to the query parameter 'default_where_conditions' of '%s'. Allowed values are %s", "event_espresso"), $use_default_where_conditions, implode(", ", $allowed_used_default_where_conditions_values)));
3045 3045
 		}
3046 3046
 		$universal_query_params = array();
3047
-		if( $use_default_where_conditions === 'all' || $use_default_where_conditions === 'this_model_only' ){
3047
+		if ($use_default_where_conditions === 'all' || $use_default_where_conditions === 'this_model_only') {
3048 3048
 			$universal_query_params = $this->_get_default_where_conditions();
3049
-		} else if( $use_default_where_conditions === 'minimum' ) {
3049
+		} else if ($use_default_where_conditions === 'minimum') {
3050 3050
 			$universal_query_params = $this->_get_minimum_where_conditions();
3051 3051
 		}
3052
-		if(in_array($use_default_where_conditions,array('all','other_models_only'))){
3053
-			foreach($query_info_carrier->get_model_names_included() as $model_relation_path => $model_name){
3052
+		if (in_array($use_default_where_conditions, array('all', 'other_models_only'))) {
3053
+			foreach ($query_info_carrier->get_model_names_included() as $model_relation_path => $model_name) {
3054 3054
 				$related_model = $this->get_related_model_obj($model_name);
3055 3055
 				$related_model_universal_where_params = $related_model->_get_default_where_conditions($model_relation_path);
3056 3056
 				$overrides = $this->_override_defaults_or_make_null_friendly(
@@ -3083,20 +3083,20 @@  discard block
 block discarded – undo
3083 3083
 	 * @return array like EEM_Base::get_all's $query_params[0]
3084 3084
 	 * @throws \EE_Error
3085 3085
 	 */
3086
-	private function _override_defaults_or_make_null_friendly($default_where_conditions,$provided_where_conditions,$model,$model_relation_path){
3086
+	private function _override_defaults_or_make_null_friendly($default_where_conditions, $provided_where_conditions, $model, $model_relation_path) {
3087 3087
 		$null_friendly_where_conditions = array();
3088 3088
 		$none_overridden = true;
3089 3089
 		$or_condition_key_for_defaults = 'OR*'.get_class($model);
3090 3090
 
3091
-		foreach($default_where_conditions as $key => $val){
3092
-			if( isset($provided_where_conditions[$key])){
3091
+		foreach ($default_where_conditions as $key => $val) {
3092
+			if (isset($provided_where_conditions[$key])) {
3093 3093
 				$none_overridden = false;
3094
-			}else{
3094
+			} else {
3095 3095
 				$null_friendly_where_conditions[$or_condition_key_for_defaults]['AND'][$key] = $val;
3096 3096
 			}
3097 3097
 		}
3098
-		if( $none_overridden && $default_where_conditions){
3099
-			if($model->has_primary_key_field()){
3098
+		if ($none_overridden && $default_where_conditions) {
3099
+			if ($model->has_primary_key_field()) {
3100 3100
 				$null_friendly_where_conditions[$or_condition_key_for_defaults][$model_relation_path.".".$model->primary_key_name()] = array('IS NULL');
3101 3101
 			}/*else{
3102 3102
 				//@todo NO PK, use other defaults
@@ -3113,8 +3113,8 @@  discard block
 block discarded – undo
3113 3113
 	 * @param string $model_relation_path eg, path from Event to Payment is "Registration.Transaction.Payment."
3114 3114
 	 * @return array like EEM_Base::get_all's $query_params[0] (where conditions)
3115 3115
 	 */
3116
-	private function _get_default_where_conditions($model_relation_path = null){
3117
-		if ( $this->_ignore_where_strategy ){
3116
+	private function _get_default_where_conditions($model_relation_path = null) {
3117
+		if ($this->_ignore_where_strategy) {
3118 3118
 			return array();
3119 3119
 		}
3120 3120
 		return $this->_default_where_conditions_strategy->get_default_where_conditions($model_relation_path);
@@ -3128,8 +3128,8 @@  discard block
 block discarded – undo
3128 3128
 	 * @param string $model_relation_path eg, path from Event to Payment is "Registration.Transaction.Payment."
3129 3129
 	 * @return array like EEM_Base::get_all's $query_params[0] (where conditions)
3130 3130
 	 */
3131
-	protected function _get_minimum_where_conditions($model_relation_path = null){
3132
-		if ( $this->_ignore_where_strategy ){
3131
+	protected function _get_minimum_where_conditions($model_relation_path = null) {
3132
+		if ($this->_ignore_where_strategy) {
3133 3133
 			return array();
3134 3134
 		}
3135 3135
 		return $this->_minimum_where_conditions_strategy->get_default_where_conditions($model_relation_path);
@@ -3145,16 +3145,16 @@  discard block
 block discarded – undo
3145 3145
 	 * @return string
3146 3146
 	 * @throws \EE_Error
3147 3147
 	 */
3148
-	private function _construct_default_select_sql(EE_Model_Query_Info_Carrier $model_query_info){
3148
+	private function _construct_default_select_sql(EE_Model_Query_Info_Carrier $model_query_info) {
3149 3149
 		$selects = $this->_get_columns_to_select_for_this_model();
3150
-		foreach($model_query_info->get_model_names_included() as $model_relation_chain => $name_of_other_model_included){
3150
+		foreach ($model_query_info->get_model_names_included() as $model_relation_chain => $name_of_other_model_included) {
3151 3151
 			$other_model_included = $this->get_related_model_obj($name_of_other_model_included);
3152
-			$other_model_selects = $other_model_included->_get_columns_to_select_for_this_model( $model_relation_chain );
3153
-			foreach ( $other_model_selects as $key => $value ) {
3152
+			$other_model_selects = $other_model_included->_get_columns_to_select_for_this_model($model_relation_chain);
3153
+			foreach ($other_model_selects as $key => $value) {
3154 3154
 				$selects[] = $value;
3155 3155
 			}
3156 3156
 		}
3157
-		return implode(", ",$selects);
3157
+		return implode(", ", $selects);
3158 3158
 	}
3159 3159
 
3160 3160
 	/**
@@ -3163,19 +3163,19 @@  discard block
 block discarded – undo
3163 3163
 	 * @param string $model_relation_chain like 'Question.Question_Group.Event'
3164 3164
 	 * @return array numerically indexed, values are columns to select and rename, eg "Event.ID AS 'Event.ID'"
3165 3165
 	 */
3166
-	public function _get_columns_to_select_for_this_model($model_relation_chain = ''){
3166
+	public function _get_columns_to_select_for_this_model($model_relation_chain = '') {
3167 3167
 		$fields = $this->field_settings();
3168 3168
 		$selects = array();
3169 3169
 		$table_alias_with_model_relation_chain_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model_name());
3170
-		foreach($fields as $field_obj){
3171
-			$selects[] = $table_alias_with_model_relation_chain_prefix . $field_obj->get_table_alias().".".$field_obj->get_table_column()." AS '".$table_alias_with_model_relation_chain_prefix.$field_obj->get_table_alias().".".$field_obj->get_table_column()."'";
3170
+		foreach ($fields as $field_obj) {
3171
+			$selects[] = $table_alias_with_model_relation_chain_prefix.$field_obj->get_table_alias().".".$field_obj->get_table_column()." AS '".$table_alias_with_model_relation_chain_prefix.$field_obj->get_table_alias().".".$field_obj->get_table_column()."'";
3172 3172
 		}
3173 3173
 		//make sure we are also getting the PKs of each table
3174 3174
 		$tables = $this->get_tables();
3175
-		if(count($tables) > 1){
3176
-			foreach($tables as $table_obj){
3177
-				$qualified_pk_column = $table_alias_with_model_relation_chain_prefix . $table_obj->get_fully_qualified_pk_column();
3178
-				if( ! in_array($qualified_pk_column,$selects)){
3175
+		if (count($tables) > 1) {
3176
+			foreach ($tables as $table_obj) {
3177
+				$qualified_pk_column = $table_alias_with_model_relation_chain_prefix.$table_obj->get_fully_qualified_pk_column();
3178
+				if ( ! in_array($qualified_pk_column, $selects)) {
3179 3179
 					$selects[] = "$qualified_pk_column AS '$qualified_pk_column'";
3180 3180
 				}
3181 3181
 			}
@@ -3205,65 +3205,65 @@  discard block
 block discarded – undo
3205 3205
 		$query_param_type,
3206 3206
 		$original_query_param = null
3207 3207
 	) {
3208
-		if( $original_query_param === null ){
3208
+		if ($original_query_param === null) {
3209 3209
 			$original_query_param = $query_param;
3210 3210
 		}
3211 3211
 		$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param);
3212 3212
 		/** @var $allow_logic_query_params bool whether or not to allow logic_query_params like 'NOT','OR', or 'AND' */
3213
-		$allow_logic_query_params = in_array($query_param_type,array('where','having'));
3214
-		$allow_fields = in_array($query_param_type,array('where','having','order_by','group_by','order'));
3213
+		$allow_logic_query_params = in_array($query_param_type, array('where', 'having'));
3214
+		$allow_fields = in_array($query_param_type, array('where', 'having', 'order_by', 'group_by', 'order'));
3215 3215
 		//check to see if we have a field on this model
3216 3216
 		$this_model_fields = $this->field_settings(true);
3217
-		if(array_key_exists($query_param,$this_model_fields)){
3218
-			if($allow_fields){
3217
+		if (array_key_exists($query_param, $this_model_fields)) {
3218
+			if ($allow_fields) {
3219 3219
 				return;
3220
-			}else{
3220
+			} else {
3221 3221
 				throw new EE_Error(sprintf(__("Using a field name (%s) on model %s is not allowed on this query param type '%s'. Original query param was %s", "event_espresso"),
3222
-						$query_param,get_class($this),$query_param_type,$original_query_param));
3222
+						$query_param, get_class($this), $query_param_type, $original_query_param));
3223 3223
 			}
3224 3224
 		}
3225 3225
 		//check if this is a special logic query param
3226
-		elseif(in_array($query_param, $this->_logic_query_param_keys, TRUE)){
3227
-			if($allow_logic_query_params){
3226
+		elseif (in_array($query_param, $this->_logic_query_param_keys, TRUE)) {
3227
+			if ($allow_logic_query_params) {
3228 3228
 				return;
3229
-			}else{
3229
+			} else {
3230 3230
 				throw new EE_Error(
3231 3231
 					sprintf(
3232
-						__( 'Logic query params ("%1$s") are being used incorrectly with the following query param ("%2$s") on model %3$s. %4$sAdditional Info:%4$s%5$s', 'event_espresso' ),
3233
-						implode( '", "', $this->_logic_query_param_keys ),
3234
-						$query_param ,
3235
-						get_class( $this ),
3232
+						__('Logic query params ("%1$s") are being used incorrectly with the following query param ("%2$s") on model %3$s. %4$sAdditional Info:%4$s%5$s', 'event_espresso'),
3233
+						implode('", "', $this->_logic_query_param_keys),
3234
+						$query_param,
3235
+						get_class($this),
3236 3236
 						'<br />',
3237
-						"\t" . ' $passed_in_query_info = <pre>' . print_r( $passed_in_query_info, TRUE ) . '</pre>' . "\n\t" . ' $query_param_type = ' . $query_param_type . "\n\t" . ' $original_query_param = ' . $original_query_param
3237
+						"\t".' $passed_in_query_info = <pre>'.print_r($passed_in_query_info, TRUE).'</pre>'."\n\t".' $query_param_type = '.$query_param_type."\n\t".' $original_query_param = '.$original_query_param
3238 3238
 					)
3239 3239
 				);
3240 3240
 			}
3241 3241
 		}
3242 3242
 
3243 3243
 		//check if it's a custom selection
3244
-		elseif(array_key_exists($query_param,$this->_custom_selections)){
3244
+		elseif (array_key_exists($query_param, $this->_custom_selections)) {
3245 3245
 			return;
3246 3246
 		}
3247 3247
 
3248 3248
 		//check if has a model name at the beginning
3249 3249
 		//and
3250 3250
 		//check if it's a field on a related model
3251
-		foreach($this->_model_relations as $valid_related_model_name=>$relation_obj){
3252
-			if(strpos($query_param, $valid_related_model_name.".") === 0){
3253
-				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param);
3251
+		foreach ($this->_model_relations as $valid_related_model_name=>$relation_obj) {
3252
+			if (strpos($query_param, $valid_related_model_name.".") === 0) {
3253
+				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info, $original_query_param);
3254 3254
 				$query_param = substr($query_param, strlen($valid_related_model_name."."));
3255
-				if($query_param === ''){
3255
+				if ($query_param === '') {
3256 3256
 					//nothing left to $query_param
3257 3257
 					//we should actually end in a field name, not a model like this!
3258 3258
 					throw new EE_Error(sprintf(__("Query param '%s' (of type %s on model %s) shouldn't end on a period (.) ", "event_espresso"),
3259
-					$query_param,$query_param_type,get_class($this),$valid_related_model_name));
3260
-				}else{
3259
+					$query_param, $query_param_type, get_class($this), $valid_related_model_name));
3260
+				} else {
3261 3261
 					$related_model_obj = $this->get_related_model_obj($valid_related_model_name);
3262 3262
 					$related_model_obj->_extract_related_model_info_from_query_param($query_param, $passed_in_query_info, $query_param_type, $original_query_param);
3263 3263
 					return;
3264 3264
 				}
3265
-			}elseif($query_param === $valid_related_model_name){
3266
-				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param);
3265
+			}elseif ($query_param === $valid_related_model_name) {
3266
+				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info, $original_query_param);
3267 3267
 				return;
3268 3268
 			}
3269 3269
 		}
@@ -3273,7 +3273,7 @@  discard block
 block discarded – undo
3273 3273
 		//and we previously confirmed it wasn't a logic query param or field on the current model
3274 3274
 		//it's wack, that's what it is
3275 3275
 		throw new EE_Error(sprintf(__("There is no model named '%s' related to %s. Query param type is %s and original query param is %s", "event_espresso"),
3276
-				$query_param,get_class($this),$query_param_type,$original_query_param));
3276
+				$query_param, get_class($this), $query_param_type, $original_query_param));
3277 3277
 
3278 3278
 	}
3279 3279
 
@@ -3292,26 +3292,26 @@  discard block
 block discarded – undo
3292 3292
 	 * @return void
3293 3293
 	 * @throws \EE_Error
3294 3294
 	 */
3295
-	private function _add_join_to_model($model_name, EE_Model_Query_Info_Carrier $passed_in_query_info,$original_query_param){
3295
+	private function _add_join_to_model($model_name, EE_Model_Query_Info_Carrier $passed_in_query_info, $original_query_param) {
3296 3296
 		$relation_obj = $this->related_settings_for($model_name);
3297 3297
 
3298 3298
 		$model_relation_chain = EE_Model_Parser::extract_model_relation_chain($model_name, $original_query_param);
3299 3299
 		//check if the relation is HABTM, because then we're essentially doing two joins
3300 3300
 		//If so, join first to the JOIN table, and add its data types, and then continue as normal
3301
-		if($relation_obj instanceof EE_HABTM_Relation){
3301
+		if ($relation_obj instanceof EE_HABTM_Relation) {
3302 3302
 			$join_model_obj = $relation_obj->get_join_model();
3303 3303
 			//replace the model specified with the join model for this relation chain, whi
3304 3304
 			$relation_chain_to_join_model = EE_Model_Parser::replace_model_name_with_join_model_name_in_model_relation_chain($model_name, $join_model_obj->get_this_model_name(), $model_relation_chain);
3305 3305
 			$new_query_info = new EE_Model_Query_Info_Carrier(
3306 3306
 					array($relation_chain_to_join_model => $join_model_obj->get_this_model_name()),
3307 3307
 					$relation_obj->get_join_to_intermediate_model_statement($relation_chain_to_join_model));
3308
-			$passed_in_query_info->merge( $new_query_info  );
3308
+			$passed_in_query_info->merge($new_query_info);
3309 3309
 		}
3310 3310
 		//now just join to the other table pointed to by the relation object, and add its data types
3311 3311
 		$new_query_info = new EE_Model_Query_Info_Carrier(
3312 3312
 				array($model_relation_chain=>$model_name),
3313 3313
 				$relation_obj->get_join_statement($model_relation_chain));
3314
-		$passed_in_query_info->merge( $new_query_info  );
3314
+		$passed_in_query_info->merge($new_query_info);
3315 3315
 	}
3316 3316
 
3317 3317
 
@@ -3323,11 +3323,11 @@  discard block
 block discarded – undo
3323 3323
 	 * @return string of SQL
3324 3324
 	 * @throws \EE_Error
3325 3325
 	 */
3326
-	private function _construct_where_clause($where_params){
3326
+	private function _construct_where_clause($where_params) {
3327 3327
 		$SQL = $this->_construct_condition_clause_recursive($where_params, ' AND ');
3328
-		if($SQL){
3329
-			return " WHERE ". $SQL;
3330
-		}else{
3328
+		if ($SQL) {
3329
+			return " WHERE ".$SQL;
3330
+		} else {
3331 3331
 			return '';
3332 3332
 		}
3333 3333
 	}
@@ -3342,11 +3342,11 @@  discard block
 block discarded – undo
3342 3342
 	 * @return string
3343 3343
 	 * @throws \EE_Error
3344 3344
 	 */
3345
-	private function _construct_having_clause($having_params){
3345
+	private function _construct_having_clause($having_params) {
3346 3346
 		$SQL = $this->_construct_condition_clause_recursive($having_params, ' AND ');
3347
-		if($SQL){
3348
-			return " HAVING ". $SQL;
3349
-		}else{
3347
+		if ($SQL) {
3348
+			return " HAVING ".$SQL;
3349
+		} else {
3350 3350
 			return '';
3351 3351
 		}
3352 3352
 
@@ -3360,16 +3360,16 @@  discard block
 block discarded – undo
3360 3360
 	 * @return EE_Model_Field_Base
3361 3361
 	 * @throws EE_Error
3362 3362
 	 */
3363
-	protected function _get_field_on_model($field_name,$model_name){
3363
+	protected function _get_field_on_model($field_name, $model_name) {
3364 3364
 		$model_class = 'EEM_'.$model_name;
3365 3365
 		$model_filepath = $model_class.".model.php";
3366
-		if ( is_readable($model_filepath)){
3366
+		if (is_readable($model_filepath)) {
3367 3367
 			require_once($model_filepath);
3368
-			$model_instance=call_user_func($model_name."::instance");
3368
+			$model_instance = call_user_func($model_name."::instance");
3369 3369
 			/* @var $model_instance EEM_Base */
3370 3370
 			return $model_instance->field_settings_for($field_name);
3371
-		}else{
3372
-			throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s','event_espresso'),$model_name,$model_class,$model_filepath));
3371
+		} else {
3372
+			throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s', 'event_espresso'), $model_name, $model_class, $model_filepath));
3373 3373
 		}
3374 3374
 	}
3375 3375
 
@@ -3382,41 +3382,41 @@  discard block
 block discarded – undo
3382 3382
 	 * @throws EE_Error
3383 3383
 	 * @return string of SQL
3384 3384
 	 */
3385
-	private function _construct_condition_clause_recursive($where_params, $glue = ' AND'){
3386
-		$where_clauses=array();
3387
-		foreach($where_params as $query_param => $op_and_value_or_sub_condition){
3388
-			$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param);//str_replace("*",'',$query_param);
3389
-			if(in_array($query_param,$this->_logic_query_param_keys)){
3390
-				switch($query_param){
3385
+	private function _construct_condition_clause_recursive($where_params, $glue = ' AND') {
3386
+		$where_clauses = array();
3387
+		foreach ($where_params as $query_param => $op_and_value_or_sub_condition) {
3388
+			$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param); //str_replace("*",'',$query_param);
3389
+			if (in_array($query_param, $this->_logic_query_param_keys)) {
3390
+				switch ($query_param) {
3391 3391
 					case 'not':
3392 3392
 					case 'NOT':
3393
-						$where_clauses[] = "! (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, $glue).")";
3393
+						$where_clauses[] = "! (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, $glue).")";
3394 3394
 						break;
3395 3395
 					case 'and':
3396 3396
 					case 'AND':
3397
-						$where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' AND ') .")";
3397
+						$where_clauses[] = " (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' AND ').")";
3398 3398
 						break;
3399 3399
 					case 'or':
3400 3400
 					case 'OR':
3401
-						$where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ') .")";
3401
+						$where_clauses[] = " (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ').")";
3402 3402
 						break;
3403 3403
 				}
3404
-			}else{
3404
+			} else {
3405 3405
 				$field_obj = $this->_deduce_field_from_query_param($query_param);
3406 3406
 
3407 3407
 				//if it's not a normal field, maybe it's a custom selection?
3408
-				if( ! $field_obj){
3409
-					if(isset( $this->_custom_selections[$query_param][1])){
3408
+				if ( ! $field_obj) {
3409
+					if (isset($this->_custom_selections[$query_param][1])) {
3410 3410
 						$field_obj = $this->_custom_selections[$query_param][1];
3411
-					}else{
3412
-						throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"),$query_param));
3411
+					} else {
3412
+						throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"), $query_param));
3413 3413
 					}
3414 3414
 				}
3415 3415
 				$op_and_value_sql = $this->_construct_op_and_value($op_and_value_or_sub_condition, $field_obj);
3416
-				$where_clauses[]=$this->_deduce_column_name_from_query_param($query_param).SP.$op_and_value_sql;
3416
+				$where_clauses[] = $this->_deduce_column_name_from_query_param($query_param).SP.$op_and_value_sql;
3417 3417
 			}
3418 3418
 		}
3419
-		return $where_clauses ? implode( $glue, $where_clauses ) : '';
3419
+		return $where_clauses ? implode($glue, $where_clauses) : '';
3420 3420
 	}
3421 3421
 
3422 3422
 
@@ -3427,18 +3427,18 @@  discard block
 block discarded – undo
3427 3427
 	 * @throws EE_Error
3428 3428
 	 * @return string table alias and column name for SQL, eg "Transaction.TXN_ID"
3429 3429
 	 */
3430
-	private function _deduce_column_name_from_query_param($query_param){
3430
+	private function _deduce_column_name_from_query_param($query_param) {
3431 3431
 		$field = $this->_deduce_field_from_query_param($query_param);
3432 3432
 
3433
-		if( $field ){
3434
-			$table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param( $field->get_model_name(), $query_param );
3435
-			return $table_alias_prefix . $field->get_qualified_column();
3436
-		}elseif(array_key_exists($query_param,$this->_custom_selections)){
3433
+		if ($field) {
3434
+			$table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param($field->get_model_name(), $query_param);
3435
+			return $table_alias_prefix.$field->get_qualified_column();
3436
+		}elseif (array_key_exists($query_param, $this->_custom_selections)) {
3437 3437
 			//maybe it's custom selection item?
3438 3438
 			//if so, just use it as the "column name"
3439 3439
 			return $query_param;
3440
-		}else{
3441
-			throw new EE_Error(sprintf(__("%s is not a valid field on this model, nor a custom selection (%s)", "event_espresso"),$query_param,implode(",",$this->_custom_selections)));
3440
+		} else {
3441
+			throw new EE_Error(sprintf(__("%s is not a valid field on this model, nor a custom selection (%s)", "event_espresso"), $query_param, implode(",", $this->_custom_selections)));
3442 3442
 		}
3443 3443
 	}
3444 3444
 
@@ -3450,11 +3450,11 @@  discard block
 block discarded – undo
3450 3450
 	 * @param string $condition_query_param_key
3451 3451
 	 * @return string
3452 3452
 	 */
3453
-	private function _remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key){
3453
+	private function _remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key) {
3454 3454
 		$pos_of_star = strpos($condition_query_param_key, '*');
3455
-		if($pos_of_star === FALSE){
3455
+		if ($pos_of_star === FALSE) {
3456 3456
 			return $condition_query_param_key;
3457
-		}else{
3457
+		} else {
3458 3458
 			$condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star);
3459 3459
 			return $condition_query_param_sans_star;
3460 3460
 		}
@@ -3469,12 +3469,12 @@  discard block
 block discarded – undo
3469 3469
 	 * @throws EE_Error
3470 3470
 	 * @return string
3471 3471
 	 */
3472
-	private function _construct_op_and_value($op_and_value, $field_obj){
3473
-		if ( is_array( $op_and_value ) ) {
3474
-			$operator = isset( $op_and_value[0] ) ? $this->_prepare_operator_for_sql( $op_and_value[0] ) : null;
3475
-			if ( ! $operator ) {
3472
+	private function _construct_op_and_value($op_and_value, $field_obj) {
3473
+		if (is_array($op_and_value)) {
3474
+			$operator = isset($op_and_value[0]) ? $this->_prepare_operator_for_sql($op_and_value[0]) : null;
3475
+			if ( ! $operator) {
3476 3476
 				$php_array_like_string = array();
3477
-				foreach ( $op_and_value as $key => $value ) {
3477
+				foreach ($op_and_value as $key => $value) {
3478 3478
 					$php_array_like_string[] = "$key=>$value";
3479 3479
 				}
3480 3480
 				throw new EE_Error(
@@ -3483,27 +3483,27 @@  discard block
 block discarded – undo
3483 3483
 							"You setup a query parameter like you were going to specify an operator, but didn't. You provided '(%s)', but the operator should be at array key index 0 (eg array('>',32))",
3484 3484
 							"event_espresso"
3485 3485
 						),
3486
-						implode( ",", $php_array_like_string )
3486
+						implode(",", $php_array_like_string)
3487 3487
 					)
3488 3488
 				);
3489 3489
 			}
3490
-			$value = isset( $op_and_value[1] ) ? $op_and_value[1] : null;
3490
+			$value = isset($op_and_value[1]) ? $op_and_value[1] : null;
3491 3491
 		} else {
3492 3492
 			$operator = '=';
3493 3493
 			$value = $op_and_value;
3494 3494
 		}
3495 3495
 		//check to see if the value is actually another field
3496
-		if ( is_array( $op_and_value ) && isset( $op_and_value[2] ) && $op_and_value[2] == true ) {
3497
-			return $operator . SP . $this->_deduce_column_name_from_query_param( $value );
3498
-		} elseif ( in_array( $operator, $this->_in_style_operators ) && is_array( $value ) ) {
3496
+		if (is_array($op_and_value) && isset($op_and_value[2]) && $op_and_value[2] == true) {
3497
+			return $operator.SP.$this->_deduce_column_name_from_query_param($value);
3498
+		} elseif (in_array($operator, $this->_in_style_operators) && is_array($value)) {
3499 3499
 			//in this case, the value should be an array, or at least a comma-separated list
3500 3500
 			//it will need to handle a little differently
3501
-			$cleaned_value = $this->_construct_in_value( $value, $field_obj );
3501
+			$cleaned_value = $this->_construct_in_value($value, $field_obj);
3502 3502
 			//note: $cleaned_value has already been run through $wpdb->prepare()
3503
-			return $operator . SP . $cleaned_value;
3504
-		} elseif ( in_array( $operator, $this->_between_style_operators ) && is_array( $value ) ) {
3503
+			return $operator.SP.$cleaned_value;
3504
+		} elseif (in_array($operator, $this->_between_style_operators) && is_array($value)) {
3505 3505
 			//the value should be an array with count of two.
3506
-			if ( count( $value ) !== 2 ) {
3506
+			if (count($value) !== 2) {
3507 3507
 				throw new EE_Error(
3508 3508
 					sprintf(
3509 3509
 						__(
@@ -3514,10 +3514,10 @@  discard block
 block discarded – undo
3514 3514
 					)
3515 3515
 				);
3516 3516
 			}
3517
-			$cleaned_value = $this->_construct_between_value( $value, $field_obj );
3518
-			return $operator . SP . $cleaned_value;
3519
-		} elseif ( in_array( $operator, $this->_null_style_operators ) ) {
3520
-			if ( $value !== null ) {
3517
+			$cleaned_value = $this->_construct_between_value($value, $field_obj);
3518
+			return $operator.SP.$cleaned_value;
3519
+		} elseif (in_array($operator, $this->_null_style_operators)) {
3520
+			if ($value !== null) {
3521 3521
 				throw new EE_Error(
3522 3522
 					sprintf(
3523 3523
 						__(
@@ -3530,13 +3530,13 @@  discard block
 block discarded – undo
3530 3530
 				);
3531 3531
 			}
3532 3532
 			return $operator;
3533
-		} elseif ( $operator === 'LIKE' && ! is_array( $value ) ) {
3533
+		} elseif ($operator === 'LIKE' && ! is_array($value)) {
3534 3534
 			//if the operator is 'LIKE', we want to allow percent signs (%) and not
3535 3535
 			//remove other junk. So just treat it as a string.
3536
-			return $operator . SP . $this->_wpdb_prepare_using_field( $value, '%s' );
3537
-		} elseif ( ! in_array( $operator, $this->_in_style_operators ) && ! is_array( $value ) ) {
3538
-			return $operator . SP . $this->_wpdb_prepare_using_field( $value, $field_obj );
3539
-		} elseif ( in_array( $operator, $this->_in_style_operators ) && ! is_array( $value ) ) {
3536
+			return $operator.SP.$this->_wpdb_prepare_using_field($value, '%s');
3537
+		} elseif ( ! in_array($operator, $this->_in_style_operators) && ! is_array($value)) {
3538
+			return $operator.SP.$this->_wpdb_prepare_using_field($value, $field_obj);
3539
+		} elseif (in_array($operator, $this->_in_style_operators) && ! is_array($value)) {
3540 3540
 			throw new EE_Error(
3541 3541
 				sprintf(
3542 3542
 					__(
@@ -3547,7 +3547,7 @@  discard block
 block discarded – undo
3547 3547
 					$operator
3548 3548
 				)
3549 3549
 			);
3550
-		} elseif ( ! in_array( $operator, $this->_in_style_operators ) && is_array( $value ) ) {
3550
+		} elseif ( ! in_array($operator, $this->_in_style_operators) && is_array($value)) {
3551 3551
 			throw new EE_Error(
3552 3552
 				sprintf(
3553 3553
 					__(
@@ -3565,7 +3565,7 @@  discard block
 block discarded – undo
3565 3565
 						"It appears you've provided some totally invalid query parameters. Operator and value were:'%s', which isn't right at all",
3566 3566
 						"event_espresso"
3567 3567
 					),
3568
-					http_build_query( $op_and_value )
3568
+					http_build_query($op_and_value)
3569 3569
 				)
3570 3570
 			);
3571 3571
 		}
@@ -3581,12 +3581,12 @@  discard block
 block discarded – undo
3581 3581
 	 * @return string
3582 3582
 	 * @throws \EE_Error
3583 3583
 	 */
3584
-	public function _construct_between_value( $values, $field_obj ) {
3584
+	public function _construct_between_value($values, $field_obj) {
3585 3585
 		$cleaned_values = array();
3586
-		foreach ( $values as $value ) {
3587
-			$cleaned_values[] = $this->_wpdb_prepare_using_field($value,$field_obj);
3586
+		foreach ($values as $value) {
3587
+			$cleaned_values[] = $this->_wpdb_prepare_using_field($value, $field_obj);
3588 3588
 		}
3589
-		return  $cleaned_values[0] . " AND " . $cleaned_values[1];
3589
+		return  $cleaned_values[0]." AND ".$cleaned_values[1];
3590 3590
 	}
3591 3591
 
3592 3592
 
@@ -3603,26 +3603,26 @@  discard block
 block discarded – undo
3603 3603
 	 * @return string of SQL to follow an 'IN' or 'NOT IN' operator
3604 3604
 	 * @throws \EE_Error
3605 3605
 	 */
3606
-	public function _construct_in_value($values,  $field_obj){
3606
+	public function _construct_in_value($values, $field_obj) {
3607 3607
 		//check if the value is a CSV list
3608
-		if(is_string($values)){
3608
+		if (is_string($values)) {
3609 3609
 			//in which case, turn it into an array
3610
-			$values = explode(",",$values);
3610
+			$values = explode(",", $values);
3611 3611
 		}
3612 3612
 		$cleaned_values = array();
3613
-		foreach($values as $value){
3614
-			$cleaned_values[] = $this->_wpdb_prepare_using_field($value,$field_obj);
3613
+		foreach ($values as $value) {
3614
+			$cleaned_values[] = $this->_wpdb_prepare_using_field($value, $field_obj);
3615 3615
 		}
3616 3616
 		//we would just LOVE to leave $cleaned_values as an empty array, and return the value as "()",
3617 3617
 		//but unfortunately that's invalid SQL. So instead we return a string which we KNOW will evaluate to be the empty set
3618 3618
 		//which is effectively equivalent to returning "()". We don't return "(0)" because that only works for auto-incrementing columns
3619
-		if(empty($cleaned_values)){
3619
+		if (empty($cleaned_values)) {
3620 3620
 			$all_fields = $this->field_settings();
3621 3621
 			$a_field = array_shift($all_fields);
3622 3622
 			$main_table = $this->_get_main_table();
3623 3623
 			$cleaned_values[] = "SELECT ".$a_field->get_table_column()." FROM ".$main_table->get_table_name()." WHERE FALSE";
3624 3624
 		}
3625
-		return "(".implode(",",$cleaned_values).")";
3625
+		return "(".implode(",", $cleaned_values).")";
3626 3626
 	}
3627 3627
 
3628 3628
 
@@ -3634,16 +3634,16 @@  discard block
 block discarded – undo
3634 3634
 	 * @throws EE_Error
3635 3635
 	 * @return false|null|string
3636 3636
 	 */
3637
-	private function _wpdb_prepare_using_field($value,$field_obj){
3637
+	private function _wpdb_prepare_using_field($value, $field_obj) {
3638 3638
 		/** @type WPDB $wpdb */
3639 3639
 		global $wpdb;
3640
-		if($field_obj instanceof EE_Model_Field_Base){
3641
-			return $wpdb->prepare($field_obj->get_wpdb_data_type(),$this->_prepare_value_for_use_in_db($value, $field_obj));
3642
-		}else{//$field_obj should really just be a data type
3643
-			if( ! in_array($field_obj,$this->_valid_wpdb_data_types)){
3644
-				throw new EE_Error(sprintf(__("%s is not a valid wpdb datatype. Valid ones are %s", "event_espresso"),$field_obj,implode(",",$this->_valid_wpdb_data_types)));
3640
+		if ($field_obj instanceof EE_Model_Field_Base) {
3641
+			return $wpdb->prepare($field_obj->get_wpdb_data_type(), $this->_prepare_value_for_use_in_db($value, $field_obj));
3642
+		} else {//$field_obj should really just be a data type
3643
+			if ( ! in_array($field_obj, $this->_valid_wpdb_data_types)) {
3644
+				throw new EE_Error(sprintf(__("%s is not a valid wpdb datatype. Valid ones are %s", "event_espresso"), $field_obj, implode(",", $this->_valid_wpdb_data_types)));
3645 3645
 			}
3646
-			return $wpdb->prepare($field_obj,$value);
3646
+			return $wpdb->prepare($field_obj, $value);
3647 3647
 		}
3648 3648
 	}
3649 3649
 
@@ -3655,27 +3655,27 @@  discard block
 block discarded – undo
3655 3655
 	 * @throws EE_Error
3656 3656
 	 * @return EE_Model_Field_Base
3657 3657
 	 */
3658
-	protected function _deduce_field_from_query_param($query_param_name){
3658
+	protected function _deduce_field_from_query_param($query_param_name) {
3659 3659
 		//ok, now proceed with deducing which part is the model's name, and which is the field's name
3660 3660
 		//which will help us find the database table and column
3661 3661
 
3662
-		$query_param_parts = explode(".",$query_param_name);
3663
-		if(empty($query_param_parts)){
3664
-			throw new EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s",'event_espresso'),$query_param_name));
3662
+		$query_param_parts = explode(".", $query_param_name);
3663
+		if (empty($query_param_parts)) {
3664
+			throw new EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s", 'event_espresso'), $query_param_name));
3665 3665
 		}
3666 3666
 		$number_of_parts = count($query_param_parts);
3667
-		$last_query_param_part = $query_param_parts[ count($query_param_parts) - 1 ];
3668
-		if($number_of_parts === 1){
3667
+		$last_query_param_part = $query_param_parts[count($query_param_parts) - 1];
3668
+		if ($number_of_parts === 1) {
3669 3669
 			$field_name = $last_query_param_part;
3670 3670
 			$model_obj = $this;
3671
-		}else{// $number_of_parts >= 2
3671
+		} else {// $number_of_parts >= 2
3672 3672
 			//the last part is the column name, and there are only 2parts. therefore...
3673 3673
 			$field_name = $last_query_param_part;
3674
-			$model_obj = $this->get_related_model_obj( $query_param_parts[ $number_of_parts - 2 ]);
3674
+			$model_obj = $this->get_related_model_obj($query_param_parts[$number_of_parts - 2]);
3675 3675
 		}
3676
-		try{
3676
+		try {
3677 3677
 			return $model_obj->field_settings_for($field_name);
3678
-		}catch(EE_Error $e){
3678
+		} catch (EE_Error $e) {
3679 3679
 			return null;
3680 3680
 		}
3681 3681
 	}
@@ -3689,13 +3689,13 @@  discard block
 block discarded – undo
3689 3689
 	 * @throws EE_Error
3690 3690
 	 * @return string
3691 3691
 	 */
3692
-	public function _get_qualified_column_for_field($field_name){
3692
+	public function _get_qualified_column_for_field($field_name) {
3693 3693
 		$all_fields = $this->field_settings();
3694 3694
 		$field = isset($all_fields[$field_name]) ? $all_fields[$field_name] : FALSE;
3695
-		if($field){
3695
+		if ($field) {
3696 3696
 			return $field->get_qualified_column();
3697
-		}else{
3698
-			throw new EE_Error(sprintf(__("There is no field titled %s on model %s. Either the query trying to use it is bad, or you need to add it to the list of fields on the model.",'event_espresso'),$field_name,get_class($this)));
3697
+		} else {
3698
+			throw new EE_Error(sprintf(__("There is no field titled %s on model %s. Either the query trying to use it is bad, or you need to add it to the list of fields on the model.", 'event_espresso'), $field_name, get_class($this)));
3699 3699
 		}
3700 3700
 	}
3701 3701
 
@@ -3709,17 +3709,17 @@  discard block
 block discarded – undo
3709 3709
 	 * @param  mixed|string $limit The limit for this select
3710 3710
 	 * @return string                The final select join element for the query.
3711 3711
 	 */
3712
-	public function _construct_limit_join_select( $table_alias, $limit ) {
3712
+	public function _construct_limit_join_select($table_alias, $limit) {
3713 3713
 		$SQL = '';
3714
-		foreach ( $this->_tables as $table_obj ) {
3715
-			if ( $table_obj instanceof EE_Primary_Table ) {
3714
+		foreach ($this->_tables as $table_obj) {
3715
+			if ($table_obj instanceof EE_Primary_Table) {
3716 3716
 				$SQL .= $table_alias === $table_obj->get_table_alias()
3717
-					? $table_obj->get_select_join_limit( $limit )
3718
-					: SP . $table_obj->get_table_name() . " AS " . $table_obj->get_table_alias() . SP;
3719
-			} elseif ( $table_obj instanceof EE_Secondary_Table ) {
3717
+					? $table_obj->get_select_join_limit($limit)
3718
+					: SP.$table_obj->get_table_name()." AS ".$table_obj->get_table_alias().SP;
3719
+			} elseif ($table_obj instanceof EE_Secondary_Table) {
3720 3720
 				$SQL .= $table_alias === $table_obj->get_table_alias()
3721
-					? $table_obj->get_select_join_limit_join( $limit )
3722
-					: SP . $table_obj->get_join_sql( $table_alias ) . SP;
3721
+					? $table_obj->get_select_join_limit_join($limit)
3722
+					: SP.$table_obj->get_join_sql($table_alias).SP;
3723 3723
 			}
3724 3724
 		}
3725 3725
 		return $SQL;
@@ -3734,7 +3734,7 @@  discard block
 block discarded – undo
3734 3734
 	 * @return string SQL
3735 3735
 	 * @throws \EE_Error
3736 3736
 	 */
3737
-	public function _construct_internal_join(){
3737
+	public function _construct_internal_join() {
3738 3738
 		$SQL = $this->_get_main_table()->get_table_sql();
3739 3739
 		$SQL .= $this->_construct_internal_join_to_table_with_alias($this->_get_main_table()->get_table_alias());
3740 3740
 		return $SQL;
@@ -3755,17 +3755,17 @@  discard block
 block discarded – undo
3755 3755
 	 * @param string $alias_prefixed table alias to join to (this table should already be in the FROM SQL clause)
3756 3756
 	 * @return string
3757 3757
 	 */
3758
-	public function _construct_internal_join_to_table_with_alias($alias_prefixed){
3758
+	public function _construct_internal_join_to_table_with_alias($alias_prefixed) {
3759 3759
 		$SQL = '';
3760 3760
 		$alias_sans_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($alias_prefixed);
3761
-		foreach($this->_tables as $table_obj){
3762
-			if($table_obj instanceof EE_Secondary_Table){//table is secondary table
3763
-				if($alias_sans_prefix === $table_obj->get_table_alias()){
3761
+		foreach ($this->_tables as $table_obj) {
3762
+			if ($table_obj instanceof EE_Secondary_Table) {//table is secondary table
3763
+				if ($alias_sans_prefix === $table_obj->get_table_alias()) {
3764 3764
 					//so we're joining to this table, meaning the table is already in
3765 3765
 					//the FROM statement, BUT the primary table isn't. So we want
3766 3766
 					//to add the inverse join sql
3767 3767
 					$SQL .= $table_obj->get_inverse_join_sql($alias_prefixed);
3768
-				}else{
3768
+				} else {
3769 3769
 					//just add a regular JOIN to this table from the primary table
3770 3770
 					$SQL .= $table_obj->get_join_sql($alias_prefixed);
3771 3771
 				}
@@ -3779,9 +3779,9 @@  discard block
 block discarded – undo
3779 3779
 	 * This should be a growing array of keys being table-columns (eg 'EVT_ID' and 'Event.EVT_ID'), and values being their data type (eg, '%s', '%d', etc)
3780 3780
 	 * @return array
3781 3781
 	 */
3782
-	public function _get_data_types(){
3782
+	public function _get_data_types() {
3783 3783
 		$data_types = array();
3784
-		foreach( $this->field_settings() as $field_obj){
3784
+		foreach ($this->field_settings() as $field_obj) {
3785 3785
 			//$data_types[$field_obj->get_table_column()] = $field_obj->get_wpdb_data_type();
3786 3786
 			/** @var $field_obj EE_Model_Field_Base */
3787 3787
 			$data_types[$field_obj->get_qualified_column()] = $field_obj->get_wpdb_data_type();
@@ -3797,10 +3797,10 @@  discard block
 block discarded – undo
3797 3797
 	 * @throws EE_Error
3798 3798
 	 * @return EEM_Base
3799 3799
 	 */
3800
-	public function get_related_model_obj($model_name){
3800
+	public function get_related_model_obj($model_name) {
3801 3801
 		$model_classname = "EEM_".$model_name;
3802
-		if(!class_exists($model_classname)){
3803
-			throw new EE_Error(sprintf(__("You specified a related model named %s in your query. No such model exists, if it did, it would have the classname %s",'event_espresso'),$model_name,$model_classname));
3802
+		if ( ! class_exists($model_classname)) {
3803
+			throw new EE_Error(sprintf(__("You specified a related model named %s in your query. No such model exists, if it did, it would have the classname %s", 'event_espresso'), $model_name, $model_classname));
3804 3804
 		}
3805 3805
 		return call_user_func($model_classname."::instance");
3806 3806
 	}
@@ -3810,7 +3810,7 @@  discard block
 block discarded – undo
3810 3810
 	 * Returns the array of EE_ModelRelations for this model.
3811 3811
 	 * @return EE_Model_Relation_Base[]
3812 3812
 	 */
3813
-	public function relation_settings(){
3813
+	public function relation_settings() {
3814 3814
 		return $this->_model_relations;
3815 3815
 	}
3816 3816
 
@@ -3820,10 +3820,10 @@  discard block
 block discarded – undo
3820 3820
 	 * (Eg, without an event, datetimes have little purpose.)
3821 3821
 	 * @return EE_Belongs_To_Relation[]
3822 3822
 	 */
3823
-	public function belongs_to_relations(){
3823
+	public function belongs_to_relations() {
3824 3824
 		$belongs_to_relations = array();
3825
-		foreach($this->relation_settings() as $model_name => $relation_obj){
3826
-			if($relation_obj instanceof EE_Belongs_To_Relation){
3825
+		foreach ($this->relation_settings() as $model_name => $relation_obj) {
3826
+			if ($relation_obj instanceof EE_Belongs_To_Relation) {
3827 3827
 				$belongs_to_relations[$model_name] = $relation_obj;
3828 3828
 			}
3829 3829
 		}
@@ -3838,15 +3838,15 @@  discard block
 block discarded – undo
3838 3838
 	 * @throws EE_Error
3839 3839
 	 * @return EE_Model_Relation_Base
3840 3840
 	 */
3841
-	public function related_settings_for($relation_name){
3842
-		$relatedModels=$this->relation_settings();
3843
-		if(!array_key_exists($relation_name,$relatedModels)){
3841
+	public function related_settings_for($relation_name) {
3842
+		$relatedModels = $this->relation_settings();
3843
+		if ( ! array_key_exists($relation_name, $relatedModels)) {
3844 3844
 			throw new EE_Error(
3845 3845
 				sprintf(
3846
-					__('Cannot get %s related to %s. There is no model relation of that type. There is, however, %s...','event_espresso'),
3846
+					__('Cannot get %s related to %s. There is no model relation of that type. There is, however, %s...', 'event_espresso'),
3847 3847
 					$relation_name,
3848 3848
 					$this->_get_class_name(),
3849
-					implode( ', ', array_keys( $relatedModels ))
3849
+					implode(', ', array_keys($relatedModels))
3850 3850
 				)
3851 3851
 			);
3852 3852
 		}
@@ -3861,10 +3861,10 @@  discard block
 block discarded – undo
3861 3861
 	 * @throws EE_Error
3862 3862
 	 * @return EE_Model_Field_Base
3863 3863
 	 */
3864
-	public function field_settings_for($fieldName){
3865
-		$fieldSettings=$this->field_settings(true);
3866
-		if( ! array_key_exists($fieldName,$fieldSettings)){
3867
-			throw new EE_Error(sprintf(__("There is no field/column '%s' on '%s'",'event_espresso'),$fieldName,get_class($this)));
3864
+	public function field_settings_for($fieldName) {
3865
+		$fieldSettings = $this->field_settings(true);
3866
+		if ( ! array_key_exists($fieldName, $fieldSettings)) {
3867
+			throw new EE_Error(sprintf(__("There is no field/column '%s' on '%s'", 'event_espresso'), $fieldName, get_class($this)));
3868 3868
 		}
3869 3869
 		return $fieldSettings[$fieldName];
3870 3870
 	}
@@ -3874,11 +3874,11 @@  discard block
 block discarded – undo
3874 3874
 	 * @param string $fieldName a key in the model's _field_settings array
3875 3875
 	 * @return boolean
3876 3876
 	 */
3877
-	public function has_field($fieldName){
3877
+	public function has_field($fieldName) {
3878 3878
 		$fieldSettings = $this->field_settings(true);
3879
-		if( isset($fieldSettings[$fieldName])){
3879
+		if (isset($fieldSettings[$fieldName])) {
3880 3880
 			return true;
3881
-		}else{
3881
+		} else {
3882 3882
 			return false;
3883 3883
 		}
3884 3884
 	}
@@ -3888,11 +3888,11 @@  discard block
 block discarded – undo
3888 3888
 	 * @param string $relation_name possibly one of the keys in the relation_settings array
3889 3889
 	 * @return boolean
3890 3890
 	 */
3891
-	public function has_relation($relation_name){
3891
+	public function has_relation($relation_name) {
3892 3892
 		$relations = $this->relation_settings();
3893
-		if(isset($relations[$relation_name])){
3893
+		if (isset($relations[$relation_name])) {
3894 3894
 			return true;
3895
-		}else{
3895
+		} else {
3896 3896
 			return false;
3897 3897
 		}
3898 3898
 	}
@@ -3904,7 +3904,7 @@  discard block
 block discarded – undo
3904 3904
 	 * @param $field_obj
3905 3905
 	 * @return boolean
3906 3906
 	 */
3907
-	public function is_primary_key_field( $field_obj ){
3907
+	public function is_primary_key_field($field_obj) {
3908 3908
 		return $field_obj instanceof EE_Primary_Key_Field_Base ? TRUE : FALSE;
3909 3909
 	}
3910 3910
 
@@ -3916,16 +3916,16 @@  discard block
 block discarded – undo
3916 3916
 	 * @return EE_Model_Field_Base
3917 3917
 	 * @throws EE_Error
3918 3918
 	 */
3919
-	public function get_primary_key_field(){
3920
-		if( $this->_primary_key_field === NULL ){
3921
-			foreach( $this->field_settings( TRUE ) as $field_obj ){
3922
-				if( $this->is_primary_key_field( $field_obj )){
3919
+	public function get_primary_key_field() {
3920
+		if ($this->_primary_key_field === NULL) {
3921
+			foreach ($this->field_settings(TRUE) as $field_obj) {
3922
+				if ($this->is_primary_key_field($field_obj)) {
3923 3923
 					$this->_primary_key_field = $field_obj;
3924 3924
 					break;
3925 3925
 				}
3926 3926
 			}
3927
-			if( ! $this->_primary_key_field instanceof EE_Primary_Key_Field_Base ){
3928
-				throw new EE_Error(sprintf(__("There is no Primary Key defined on model %s",'event_espresso'),get_class($this)));
3927
+			if ( ! $this->_primary_key_field instanceof EE_Primary_Key_Field_Base) {
3928
+				throw new EE_Error(sprintf(__("There is no Primary Key defined on model %s", 'event_espresso'), get_class($this)));
3929 3929
 			}
3930 3930
 		}
3931 3931
 		return $this->_primary_key_field;
@@ -3938,12 +3938,12 @@  discard block
 block discarded – undo
3938 3938
 	 * Internally does some caching.
3939 3939
 	 * @return boolean
3940 3940
 	 */
3941
-	public function has_primary_key_field(){
3942
-		if($this->_has_primary_key_field === null){
3943
-			try{
3941
+	public function has_primary_key_field() {
3942
+		if ($this->_has_primary_key_field === null) {
3943
+			try {
3944 3944
 				$this->get_primary_key_field();
3945 3945
 				$this->_has_primary_key_field = true;
3946
-			}catch(EE_Error $e){
3946
+			} catch (EE_Error $e) {
3947 3947
 				$this->_has_primary_key_field = false;
3948 3948
 			}
3949 3949
 		}
@@ -3957,9 +3957,9 @@  discard block
 block discarded – undo
3957 3957
 	 * @param string $field_class_name class name of field that you want to find. Eg, EE_Datetime_Field, EE_Foreign_Key_Field, etc
3958 3958
 	 * @return EE_Model_Field_Base or null if none is found
3959 3959
 	 */
3960
-	public function get_a_field_of_type($field_class_name){
3961
-		foreach($this->field_settings() as $field){
3962
-			if( $field instanceof $field_class_name ){
3960
+	public function get_a_field_of_type($field_class_name) {
3961
+		foreach ($this->field_settings() as $field) {
3962
+			if ($field instanceof $field_class_name) {
3963 3963
 				return $field;
3964 3964
 			}
3965 3965
 		}
@@ -3973,22 +3973,22 @@  discard block
 block discarded – undo
3973 3973
 	 * @return EE_Foreign_Key_Field_Base
3974 3974
 	 * @throws EE_Error
3975 3975
 	 */
3976
-	public function get_foreign_key_to($model_name){
3977
-		if( ! isset( $this->_cache_foreign_key_to_fields[ $model_name ] ) ){
3978
-			foreach($this->field_settings() as $field){
3979
-				if(
3976
+	public function get_foreign_key_to($model_name) {
3977
+		if ( ! isset($this->_cache_foreign_key_to_fields[$model_name])) {
3978
+			foreach ($this->field_settings() as $field) {
3979
+				if (
3980 3980
 					$field instanceof EE_Foreign_Key_Field_Base
3981
-					&& in_array($model_name,$field->get_model_names_pointed_to() )
3981
+					&& in_array($model_name, $field->get_model_names_pointed_to())
3982 3982
 				) {
3983
-					$this->_cache_foreign_key_to_fields[ $model_name ] = $field;
3983
+					$this->_cache_foreign_key_to_fields[$model_name] = $field;
3984 3984
 					break;
3985 3985
 				}
3986 3986
 			}
3987
-			if( ! isset( $this->_cache_foreign_key_to_fields[ $model_name ] ) ){
3988
-				throw new EE_Error(sprintf(__("There is no foreign key field pointing to model %s on model %s",'event_espresso'),$model_name,get_class($this)));
3987
+			if ( ! isset($this->_cache_foreign_key_to_fields[$model_name])) {
3988
+				throw new EE_Error(sprintf(__("There is no foreign key field pointing to model %s on model %s", 'event_espresso'), $model_name, get_class($this)));
3989 3989
 			}
3990 3990
 		}
3991
-		return $this->_cache_foreign_key_to_fields[ $model_name ];
3991
+		return $this->_cache_foreign_key_to_fields[$model_name];
3992 3992
 	}
3993 3993
 
3994 3994
 
@@ -3999,7 +3999,7 @@  discard block
 block discarded – undo
3999 3999
 	 * a table alias with a model chain prefix, like 'Venue__Event_Venue___Event_Meta'. Either one works
4000 4000
 	 * @return EE_Table_Base
4001 4001
 	 */
4002
-	public function get_table_for_alias($table_alias){
4002
+	public function get_table_for_alias($table_alias) {
4003 4003
 		$table_alias_sans_model_relation_chain_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($table_alias);
4004 4004
 		return $this->_tables[$table_alias_sans_model_relation_chain_prefix]->get_table_name();
4005 4005
 	}
@@ -4012,25 +4012,25 @@  discard block
 block discarded – undo
4012 4012
 	 * @param bool $include_db_only_fields flag indicating whether or not to include the db-only fields
4013 4013
 	 * @return EE_Model_Field_Base[] where the keys are the field's name
4014 4014
 	 */
4015
-	public function field_settings($include_db_only_fields = false){
4016
-		if( $include_db_only_fields ){
4017
-			if( $this->_cached_fields === NULL ){
4015
+	public function field_settings($include_db_only_fields = false) {
4016
+		if ($include_db_only_fields) {
4017
+			if ($this->_cached_fields === NULL) {
4018 4018
 				$this->_cached_fields = array();
4019
-				foreach($this->_fields as $fields_corresponding_to_table){
4020
-					foreach($fields_corresponding_to_table as $field_name => $field_obj){
4021
-						$this->_cached_fields[$field_name]=$field_obj;
4019
+				foreach ($this->_fields as $fields_corresponding_to_table) {
4020
+					foreach ($fields_corresponding_to_table as $field_name => $field_obj) {
4021
+						$this->_cached_fields[$field_name] = $field_obj;
4022 4022
 					}
4023 4023
 				}
4024 4024
 			}
4025 4025
 			return $this->_cached_fields;
4026
-		}else{
4027
-			if( $this->_cached_fields_non_db_only === NULL ){
4026
+		} else {
4027
+			if ($this->_cached_fields_non_db_only === NULL) {
4028 4028
 				$this->_cached_fields_non_db_only = array();
4029
-				foreach($this->_fields as $fields_corresponding_to_table){
4030
-					foreach($fields_corresponding_to_table as $field_name => $field_obj){
4029
+				foreach ($this->_fields as $fields_corresponding_to_table) {
4030
+					foreach ($fields_corresponding_to_table as $field_name => $field_obj) {
4031 4031
 						/** @var $field_obj EE_Model_Field_Base */
4032
-						if( ! $field_obj->is_db_only_field() ){
4033
-							$this->_cached_fields_non_db_only[$field_name]=$field_obj;
4032
+						if ( ! $field_obj->is_db_only_field()) {
4033
+							$this->_cached_fields_non_db_only[$field_name] = $field_obj;
4034 4034
 						}
4035 4035
 					}
4036 4036
 				}
@@ -4049,60 +4049,60 @@  discard block
 block discarded – undo
4049 4049
 	 * @return \EE_Base_Class[] array keys are primary keys (if there is a primary key on the model. if not, numerically indexed)
4050 4050
 	 * @throws \EE_Error
4051 4051
 	 */
4052
-	protected function _create_objects( $rows = array() ) {
4053
-		$array_of_objects=array();
4054
-		if(empty($rows)){
4052
+	protected function _create_objects($rows = array()) {
4053
+		$array_of_objects = array();
4054
+		if (empty($rows)) {
4055 4055
 			return array();
4056 4056
 		}
4057 4057
 		$count_if_model_has_no_primary_key = 0;
4058 4058
 		$has_primary_key = $this->has_primary_key_field();
4059 4059
 		$primary_key_field = $has_primary_key ? $this->get_primary_key_field() : null;
4060
-		foreach ( (array)$rows as $row ) {
4061
-			if(empty($row)){
4060
+		foreach ((array) $rows as $row) {
4061
+			if (empty($row)) {
4062 4062
 				//wp did its weird thing where it returns an array like array(0=>null), which is totally not helpful...
4063 4063
 				return array();
4064 4064
 			}
4065 4065
 			//check if we've already set this object in the results array,
4066 4066
 			//in which case there's no need to process it further (again)
4067
-			if( $has_primary_key ) {
4067
+			if ($has_primary_key) {
4068 4068
 				$table_pk_value = $this->_get_column_value_with_table_alias_or_not(
4069 4069
 					$row,
4070 4070
 					$primary_key_field->get_qualified_column(),
4071 4071
 					$primary_key_field->get_table_column()
4072 4072
 				);
4073
-				if( $table_pk_value && isset( $array_of_objects[ $table_pk_value ] ) ) {
4073
+				if ($table_pk_value && isset($array_of_objects[$table_pk_value])) {
4074 4074
 					continue;
4075 4075
 				}
4076 4076
 			}
4077 4077
 			$classInstance = $this->instantiate_class_from_array_or_object($row);
4078
-			if( ! $classInstance ) {
4078
+			if ( ! $classInstance) {
4079 4079
 				throw new EE_Error(
4080 4080
 					sprintf(
4081
-						__( 'Could not create instance of class %s from row %s', 'event_espresso' ),
4081
+						__('Could not create instance of class %s from row %s', 'event_espresso'),
4082 4082
 						$this->get_this_model_name(),
4083
-						http_build_query( $row )
4083
+						http_build_query($row)
4084 4084
 					)
4085 4085
 				);
4086 4086
 			}
4087 4087
 			//set the timezone on the instantiated objects
4088
-			$classInstance->set_timezone( $this->_timezone );
4088
+			$classInstance->set_timezone($this->_timezone);
4089 4089
 			//make sure if there is any timezone setting present that we set the timezone for the object
4090 4090
 			$key = $has_primary_key ? $classInstance->ID() : $count_if_model_has_no_primary_key++;
4091
-			$array_of_objects[ $key ] = $classInstance;
4091
+			$array_of_objects[$key] = $classInstance;
4092 4092
 			//also, for all the relations of type BelongsTo, see if we can cache
4093 4093
 			//those related models
4094 4094
 			//(we could do this for other relations too, but if there are conditions
4095 4095
 			//that filtered out some fo the results, then we'd be caching an incomplete set
4096 4096
 			//so it requires a little more thought than just caching them immediately...)
4097
-			foreach($this->_model_relations as $modelName => $relation_obj){
4098
-				if( $relation_obj instanceof EE_Belongs_To_Relation){
4097
+			foreach ($this->_model_relations as $modelName => $relation_obj) {
4098
+				if ($relation_obj instanceof EE_Belongs_To_Relation) {
4099 4099
 					//check if this model's INFO is present. If so, cache it on the model
4100 4100
 					$other_model = $relation_obj->get_other_model();
4101 4101
 					$other_model_obj_maybe = $other_model->instantiate_class_from_array_or_object($row);
4102 4102
 					//if we managed to make a model object from the results, cache it on the main model object
4103
-					if( $other_model_obj_maybe ){
4103
+					if ($other_model_obj_maybe) {
4104 4104
 						//set timezone on these other model objects if they are present
4105
-						$other_model_obj_maybe->set_timezone( $this->_timezone );
4105
+						$other_model_obj_maybe->set_timezone($this->_timezone);
4106 4106
 						$classInstance->cache($modelName, $other_model_obj_maybe);
4107 4107
 					}
4108 4108
 				}
@@ -4123,12 +4123,12 @@  discard block
 block discarded – undo
4123 4123
 
4124 4124
 		$this_model_fields_and_values = array();
4125 4125
 		//setup the row using default values;
4126
-		foreach ( $this->field_settings() as $field_name => $field_obj ) {
4126
+		foreach ($this->field_settings() as $field_name => $field_obj) {
4127 4127
 			$this_model_fields_and_values[$field_name] = $field_obj->get_default_value();
4128 4128
 		}
4129 4129
 
4130 4130
 		$className = $this->_get_class_name();
4131
-		$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_and_values ), FALSE, FALSE );
4131
+		$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_and_values), FALSE, FALSE);
4132 4132
 
4133 4133
 		return $classInstance;
4134 4134
 	}
@@ -4141,45 +4141,45 @@  discard block
 block discarded – undo
4141 4141
 	 * @return EE_Base_Class
4142 4142
 	 * @throws \EE_Error
4143 4143
 	 */
4144
-	public function instantiate_class_from_array_or_object($cols_n_values){
4145
-		if( ! is_array( $cols_n_values ) && is_object( $cols_n_values )) {
4146
-			$cols_n_values = get_object_vars( $cols_n_values );
4144
+	public function instantiate_class_from_array_or_object($cols_n_values) {
4145
+		if ( ! is_array($cols_n_values) && is_object($cols_n_values)) {
4146
+			$cols_n_values = get_object_vars($cols_n_values);
4147 4147
 		}
4148 4148
 		$primary_key = NULL;
4149 4149
 		//make sure the array only has keys that are fields/columns on this model
4150
-		$this_model_fields_n_values = $this->_deduce_fields_n_values_from_cols_n_values( $cols_n_values );
4151
-		if( $this->has_primary_key_field() && isset( $this_model_fields_n_values[ $this->primary_key_name() ] ) ){
4152
-			$primary_key = $this_model_fields_n_values[ $this->primary_key_name() ];
4150
+		$this_model_fields_n_values = $this->_deduce_fields_n_values_from_cols_n_values($cols_n_values);
4151
+		if ($this->has_primary_key_field() && isset($this_model_fields_n_values[$this->primary_key_name()])) {
4152
+			$primary_key = $this_model_fields_n_values[$this->primary_key_name()];
4153 4153
 		}
4154
-		$className=$this->_get_class_name();
4154
+		$className = $this->_get_class_name();
4155 4155
 
4156 4156
 		//check we actually found results that we can use to build our model object
4157 4157
 		//if not, return null
4158
-		if( $this->has_primary_key_field()){
4159
-			if(empty( $this_model_fields_n_values[$this->primary_key_name()] )){
4158
+		if ($this->has_primary_key_field()) {
4159
+			if (empty($this_model_fields_n_values[$this->primary_key_name()])) {
4160 4160
 				return NULL;
4161 4161
 			}
4162
-		}else if($this->unique_indexes()){
4162
+		} else if ($this->unique_indexes()) {
4163 4163
 			$first_column = reset($this_model_fields_n_values);
4164
-			if(empty($first_column)){
4164
+			if (empty($first_column)) {
4165 4165
 				return NULL;
4166 4166
 			}
4167 4167
 		}
4168 4168
 
4169 4169
 		// if there is no primary key or the object doesn't already exist in the entity map, then create a new instance
4170
-		if ( $primary_key){
4171
-			$classInstance = $this->get_from_entity_map( $primary_key );
4172
-			if( ! $classInstance) {
4173
-				$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE );
4170
+		if ($primary_key) {
4171
+			$classInstance = $this->get_from_entity_map($primary_key);
4172
+			if ( ! $classInstance) {
4173
+				$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_n_values, $this->_timezone), TRUE, FALSE);
4174 4174
 				// add this new object to the entity map
4175
-				$classInstance = $this->add_to_entity_map( $classInstance );
4175
+				$classInstance = $this->add_to_entity_map($classInstance);
4176 4176
 			}
4177
-		}else{
4178
-			$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE );
4177
+		} else {
4178
+			$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_n_values, $this->_timezone), TRUE, FALSE);
4179 4179
 		}
4180 4180
 
4181 4181
 			//it is entirely possible that the instantiated class object has a set timezone_string db field and has set it's internal _timezone property accordingly (see new_instance_from_db in model objects particularly EE_Event for example).  In this case, we want to make sure the model object doesn't have its timezone string overwritten by any timezone property currently set here on the model so, we intentionally override the model _timezone property with the model_object timezone property.
4182
-		$this->set_timezone( $classInstance->get_timezone() );
4182
+		$this->set_timezone($classInstance->get_timezone());
4183 4183
 		return $classInstance;
4184 4184
 	}
4185 4185
 	/**
@@ -4187,8 +4187,8 @@  discard block
 block discarded – undo
4187 4187
 	 * @param int|string $id the ID of the model object
4188 4188
 	 * @return EE_Base_Class
4189 4189
 	 */
4190
-	public function get_from_entity_map( $id ){
4191
-		return isset( $this->_entity_map[ EEM_Base::$_model_query_blog_id ][ $id ] ) ? $this->_entity_map[ EEM_Base::$_model_query_blog_id ][ $id ] : NULL;
4190
+	public function get_from_entity_map($id) {
4191
+		return isset($this->_entity_map[EEM_Base::$_model_query_blog_id][$id]) ? $this->_entity_map[EEM_Base::$_model_query_blog_id][$id] : NULL;
4192 4192
 	}
4193 4193
 
4194 4194
 
@@ -4210,21 +4210,21 @@  discard block
 block discarded – undo
4210 4210
 	 * @throws EE_Error
4211 4211
 	 * @return \EE_Base_Class
4212 4212
 	 */
4213
-	public function add_to_entity_map( EE_Base_Class $object) {
4213
+	public function add_to_entity_map(EE_Base_Class $object) {
4214 4214
 		$className = $this->_get_class_name();
4215
-		if( ! $object instanceof $className ){
4216
-			throw new EE_Error(sprintf(__("You tried adding a %s to a mapping of %ss", "event_espresso"),is_object( $object ) ? get_class( $object ) : $object, $className ) );
4215
+		if ( ! $object instanceof $className) {
4216
+			throw new EE_Error(sprintf(__("You tried adding a %s to a mapping of %ss", "event_espresso"), is_object($object) ? get_class($object) : $object, $className));
4217 4217
 		}
4218 4218
 		/** @var $object EE_Base_Class */
4219
-		if ( ! $object->ID() ){
4220
-			throw new EE_Error(sprintf(__("You tried storing a model object with NO ID in the %s entity mapper.", "event_espresso"),get_class($this)));
4219
+		if ( ! $object->ID()) {
4220
+			throw new EE_Error(sprintf(__("You tried storing a model object with NO ID in the %s entity mapper.", "event_espresso"), get_class($this)));
4221 4221
 		}
4222 4222
 		// double check it's not already there
4223
-		$classInstance = $this->get_from_entity_map( $object->ID() );
4224
-		if ( $classInstance ) {
4223
+		$classInstance = $this->get_from_entity_map($object->ID());
4224
+		if ($classInstance) {
4225 4225
 			return $classInstance;
4226 4226
 		} else {
4227
-			$this->_entity_map[ EEM_Base::$_model_query_blog_id ][ $object->ID() ] = $object;
4227
+			$this->_entity_map[EEM_Base::$_model_query_blog_id][$object->ID()] = $object;
4228 4228
 			return $object;
4229 4229
 		}
4230 4230
 	}
@@ -4238,13 +4238,13 @@  discard block
 block discarded – undo
4238 4238
 	 * @param int|string $id the ID of the model object
4239 4239
 	 * @return boolean
4240 4240
 	 */
4241
-	public function clear_entity_map( $id = null ) {
4242
-		if ( empty( $id ) ) {
4243
-			$this->_entity_map[ EEM_Base::$_model_query_blog_id ] = array();
4241
+	public function clear_entity_map($id = null) {
4242
+		if (empty($id)) {
4243
+			$this->_entity_map[EEM_Base::$_model_query_blog_id] = array();
4244 4244
 			return true;
4245 4245
 		}
4246
-		if ( isset( $this->_entity_map[ EEM_Base::$_model_query_blog_id ][ $id ] ) ) {
4247
-			unset( $this->_entity_map[ EEM_Base::$_model_query_blog_id ][ $id ] );
4246
+		if (isset($this->_entity_map[EEM_Base::$_model_query_blog_id][$id])) {
4247
+			unset($this->_entity_map[EEM_Base::$_model_query_blog_id][$id]);
4248 4248
 			return true;
4249 4249
 		}
4250 4250
 		return false;
@@ -4260,8 +4260,8 @@  discard block
 block discarded – undo
4260 4260
 	 * @param array $cols_n_values
4261 4261
 	 * @return array
4262 4262
 	 */
4263
-	public function deduce_fields_n_values_from_cols_n_values( $cols_n_values ) {
4264
-		return $this->_deduce_fields_n_values_from_cols_n_values( $cols_n_values );
4263
+	public function deduce_fields_n_values_from_cols_n_values($cols_n_values) {
4264
+		return $this->_deduce_fields_n_values_from_cols_n_values($cols_n_values);
4265 4265
 	}
4266 4266
 
4267 4267
 
@@ -4274,23 +4274,23 @@  discard block
 block discarded – undo
4274 4274
 	 * @param string $cols_n_values
4275 4275
 	 * @return array
4276 4276
 	 */
4277
-	protected function _deduce_fields_n_values_from_cols_n_values( $cols_n_values ){
4277
+	protected function _deduce_fields_n_values_from_cols_n_values($cols_n_values) {
4278 4278
 		$this_model_fields_n_values = array();
4279
-		foreach( $this->get_tables() as $table_alias => $table_obj ) {
4280
-			$table_pk_value = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $table_obj->get_fully_qualified_pk_column(), $table_obj->get_pk_column() );
4279
+		foreach ($this->get_tables() as $table_alias => $table_obj) {
4280
+			$table_pk_value = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $table_obj->get_fully_qualified_pk_column(), $table_obj->get_pk_column());
4281 4281
 			//there is a primary key on this table and its not set. Use defaults for all its columns
4282
-			if( $table_pk_value === null && $table_obj->get_pk_column() ){
4283
-				foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) {
4284
-					if( ! $field_obj->is_db_only_field() ){
4282
+			if ($table_pk_value === null && $table_obj->get_pk_column()) {
4283
+				foreach ($this->_get_fields_for_table($table_alias) as $field_name => $field_obj) {
4284
+					if ( ! $field_obj->is_db_only_field()) {
4285 4285
 						//prepare field as if its coming from db
4286
-						$prepared_value = $field_obj->prepare_for_set( $field_obj->get_default_value() );
4287
-						$this_model_fields_n_values[$field_name] = $field_obj->prepare_for_use_in_db( $prepared_value );
4286
+						$prepared_value = $field_obj->prepare_for_set($field_obj->get_default_value());
4287
+						$this_model_fields_n_values[$field_name] = $field_obj->prepare_for_use_in_db($prepared_value);
4288 4288
 					}
4289 4289
 				}
4290
-			}else{
4290
+			} else {
4291 4291
 				//the table's rows existed. Use their values
4292
-				foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) {
4293
-					if( ! $field_obj->is_db_only_field() ){
4292
+				foreach ($this->_get_fields_for_table($table_alias) as $field_name => $field_obj) {
4293
+					if ( ! $field_obj->is_db_only_field()) {
4294 4294
 						$this_model_fields_n_values[$field_name] = $this->_get_column_value_with_table_alias_or_not(
4295 4295
 							$cols_n_values, $field_obj->get_qualified_column(),
4296 4296
 							$field_obj->get_table_column()
@@ -4310,15 +4310,15 @@  discard block
 block discarded – undo
4310 4310
 	 * @param $regular_column
4311 4311
 	 * @return null
4312 4312
 	 */
4313
-	protected function _get_column_value_with_table_alias_or_not( $cols_n_values, $qualified_column, $regular_column ){
4313
+	protected function _get_column_value_with_table_alias_or_not($cols_n_values, $qualified_column, $regular_column) {
4314 4314
 		$value = null;
4315 4315
 		//ask the field what it think it's table_name.column_name should be, and call it the "qualified column"
4316 4316
 		//does the field on the model relate to this column retrieved from the db?
4317 4317
 		//or is it a db-only field? (not relating to the model)
4318
-		if( isset( $cols_n_values[ $qualified_column ] ) ){
4319
-			$value = $cols_n_values[ $qualified_column ];
4320
-		}elseif( isset( $cols_n_values[ $regular_column ] ) ){
4321
-			$value = $cols_n_values[ $regular_column ];
4318
+		if (isset($cols_n_values[$qualified_column])) {
4319
+			$value = $cols_n_values[$qualified_column];
4320
+		}elseif (isset($cols_n_values[$regular_column])) {
4321
+			$value = $cols_n_values[$regular_column];
4322 4322
 		}
4323 4323
 		return $value;
4324 4324
 	}
@@ -4334,25 +4334,25 @@  discard block
 block discarded – undo
4334 4334
 	 * @return EE_Base_Class
4335 4335
 	 * @throws \EE_Error
4336 4336
 	 */
4337
-	public function refresh_entity_map_from_db( $id ){
4338
-		$obj_in_map = $this->get_from_entity_map( $id );
4339
-		if( $obj_in_map ){
4337
+	public function refresh_entity_map_from_db($id) {
4338
+		$obj_in_map = $this->get_from_entity_map($id);
4339
+		if ($obj_in_map) {
4340 4340
 			$wpdb_results = $this->_get_all_wpdb_results(
4341
-				array( array( $this->get_primary_key_field()->get_name() => $id ), 'limit' => 1 )
4341
+				array(array($this->get_primary_key_field()->get_name() => $id), 'limit' => 1)
4342 4342
 			);
4343
-			if( $wpdb_results && is_array( $wpdb_results ) ){
4344
-				$one_row = reset( $wpdb_results );
4345
-				foreach( $this->_deduce_fields_n_values_from_cols_n_values($one_row ) as $field_name => $db_value ) {
4346
-					$obj_in_map->set_from_db( $field_name, $db_value );
4343
+			if ($wpdb_results && is_array($wpdb_results)) {
4344
+				$one_row = reset($wpdb_results);
4345
+				foreach ($this->_deduce_fields_n_values_from_cols_n_values($one_row) as $field_name => $db_value) {
4346
+					$obj_in_map->set_from_db($field_name, $db_value);
4347 4347
 				}
4348 4348
 				//clear the cache of related model objects
4349
-				foreach ( $this->relation_settings() as $relation_name => $relation_obj ){
4350
-					$obj_in_map->clear_cache($relation_name, NULL, TRUE );
4349
+				foreach ($this->relation_settings() as $relation_name => $relation_obj) {
4350
+					$obj_in_map->clear_cache($relation_name, NULL, TRUE);
4351 4351
 				}
4352 4352
 			}
4353 4353
 			return $obj_in_map;
4354
-		}else{
4355
-			return $this->get_one_by_ID( $id );
4354
+		} else {
4355
+			return $this->get_one_by_ID($id);
4356 4356
 		}
4357 4357
 	}
4358 4358
 
@@ -4370,24 +4370,24 @@  discard block
 block discarded – undo
4370 4370
 	 * @return \EE_Base_Class
4371 4371
 	 * @throws \EE_Error
4372 4372
 	 */
4373
-	public function refresh_entity_map_with( $id, $replacing_model_obj ) {
4374
-		$obj_in_map = $this->get_from_entity_map( $id );
4375
-		if( $obj_in_map ){
4376
-			if( $replacing_model_obj instanceof EE_Base_Class ){
4377
-				foreach( $replacing_model_obj->model_field_array() as $field_name => $value ) {
4378
-					$obj_in_map->set( $field_name, $value );
4373
+	public function refresh_entity_map_with($id, $replacing_model_obj) {
4374
+		$obj_in_map = $this->get_from_entity_map($id);
4375
+		if ($obj_in_map) {
4376
+			if ($replacing_model_obj instanceof EE_Base_Class) {
4377
+				foreach ($replacing_model_obj->model_field_array() as $field_name => $value) {
4378
+					$obj_in_map->set($field_name, $value);
4379 4379
 				}
4380 4380
 				//make the model object in the entity map's cache match the $replacing_model_obj
4381
-				foreach ( $this->relation_settings() as $relation_name => $relation_obj ){
4382
-					$obj_in_map->clear_cache($relation_name, NULL, TRUE );
4383
-					foreach( $replacing_model_obj->get_all_from_cache( $relation_name ) as $cache_id => $cached_obj ) {
4384
-						$obj_in_map->cache( $relation_name, $cached_obj, $cache_id );
4381
+				foreach ($this->relation_settings() as $relation_name => $relation_obj) {
4382
+					$obj_in_map->clear_cache($relation_name, NULL, TRUE);
4383
+					foreach ($replacing_model_obj->get_all_from_cache($relation_name) as $cache_id => $cached_obj) {
4384
+						$obj_in_map->cache($relation_name, $cached_obj, $cache_id);
4385 4385
 					}
4386 4386
 				}
4387 4387
 			}
4388 4388
 			return $obj_in_map;
4389
-		}else{
4390
-			$this->add_to_entity_map( $replacing_model_obj );
4389
+		} else {
4390
+			$this->add_to_entity_map($replacing_model_obj);
4391 4391
 			return $replacing_model_obj;
4392 4392
 		}
4393 4393
 	}
@@ -4400,7 +4400,7 @@  discard block
 block discarded – undo
4400 4400
 	 * require_once($this->_getClassName().".class.php");
4401 4401
 	 * @return string
4402 4402
 	 */
4403
-	private function _get_class_name(){
4403
+	private function _get_class_name() {
4404 4404
 		return "EE_".$this->get_this_model_name();
4405 4405
 	}
4406 4406
 
@@ -4413,8 +4413,8 @@  discard block
 block discarded – undo
4413 4413
 	 * @param int $quantity
4414 4414
 	 * @return string
4415 4415
 	 */
4416
-	public function item_name($quantity = 1){
4417
-		return (int)$quantity === 1 ? $this->singular_item : $this->plural_item;
4416
+	public function item_name($quantity = 1) {
4417
+		return (int) $quantity === 1 ? $this->singular_item : $this->plural_item;
4418 4418
 	}
4419 4419
 
4420 4420
 
@@ -4441,13 +4441,13 @@  discard block
 block discarded – undo
4441 4441
 	 * @throws EE_Error
4442 4442
 	 * @return mixed whatever the plugin which calls add_filter decides
4443 4443
 	 */
4444
-	public function __call($methodName,$args){
4445
-		$className=get_class($this);
4446
-		$tagName="FHEE__{$className}__{$methodName}";
4447
-		if(!has_filter($tagName)){
4444
+	public function __call($methodName, $args) {
4445
+		$className = get_class($this);
4446
+		$tagName = "FHEE__{$className}__{$methodName}";
4447
+		if ( ! has_filter($tagName)) {
4448 4448
 			throw new EE_Error(
4449 4449
 				sprintf(
4450
-					__( 'Method %1$s on model %2$s does not exist! You can create one with the following code in functions.php or in a plugin: %4$s function my_callback(%4$s \$previousReturnValue, EEM_Base \$object\ $argsArray=NULL ){%4$s     /*function body*/%4$s      return \$whatever;%4$s }%4$s add_filter( \'%3$s\', \'my_callback\', 10, 3 );', 'event_espresso' ),
4450
+					__('Method %1$s on model %2$s does not exist! You can create one with the following code in functions.php or in a plugin: %4$s function my_callback(%4$s \$previousReturnValue, EEM_Base \$object\ $argsArray=NULL ){%4$s     /*function body*/%4$s      return \$whatever;%4$s }%4$s add_filter( \'%3$s\', \'my_callback\', 10, 3 );', 'event_espresso'),
4451 4451
 					$methodName,
4452 4452
 					$className,
4453 4453
 					$tagName,
@@ -4456,7 +4456,7 @@  discard block
 block discarded – undo
4456 4456
 			);
4457 4457
 		}
4458 4458
 
4459
-		return apply_filters($tagName,null,$this,$args);
4459
+		return apply_filters($tagName, null, $this, $args);
4460 4460
 	}
4461 4461
 
4462 4462
 
@@ -4474,28 +4474,28 @@  discard block
 block discarded – undo
4474 4474
 	 * @throws EE_Error
4475 4475
 	 * @return EE_Base_Class
4476 4476
 	 */
4477
-	public function ensure_is_obj( $base_class_obj_or_id, $ensure_is_in_db = FALSE ){
4477
+	public function ensure_is_obj($base_class_obj_or_id, $ensure_is_in_db = FALSE) {
4478 4478
 		$className = $this->_get_class_name();
4479
-		if ( $base_class_obj_or_id instanceof $className ) {
4479
+		if ($base_class_obj_or_id instanceof $className) {
4480 4480
 			$model_object = $base_class_obj_or_id;
4481 4481
 		} else {
4482 4482
 			$primary_key_field = $this->get_primary_key_field();
4483 4483
 			if (
4484 4484
 				$primary_key_field instanceof EE_Primary_Key_Int_Field
4485 4485
 				&& (
4486
-					is_int( $base_class_obj_or_id )
4487
-					|| is_string( $base_class_obj_or_id )
4486
+					is_int($base_class_obj_or_id)
4487
+					|| is_string($base_class_obj_or_id)
4488 4488
 				)
4489 4489
 			) {
4490 4490
 				// assume it's an ID.
4491 4491
 				// either a proper integer or a string representing an integer (eg "101" instead of 101)
4492
-				$model_object = $this->get_one_by_ID( $base_class_obj_or_id );
4492
+				$model_object = $this->get_one_by_ID($base_class_obj_or_id);
4493 4493
 			} else if (
4494 4494
 				$primary_key_field instanceof EE_Primary_Key_String_Field
4495
-			    && is_string( $base_class_obj_or_id )
4495
+			    && is_string($base_class_obj_or_id)
4496 4496
 			) {
4497 4497
 				// assume its a string representation of the object
4498
-				$model_object = $this->get_one_by_ID( $base_class_obj_or_id );
4498
+				$model_object = $this->get_one_by_ID($base_class_obj_or_id);
4499 4499
 			} else {
4500 4500
 				throw new EE_Error(
4501 4501
 					sprintf(
@@ -4505,12 +4505,12 @@  discard block
 block discarded – undo
4505 4505
 						),
4506 4506
 						$base_class_obj_or_id,
4507 4507
 						$this->_get_class_name(),
4508
-						print_r( $base_class_obj_or_id, true )
4508
+						print_r($base_class_obj_or_id, true)
4509 4509
 					)
4510 4510
 				);
4511 4511
 			}
4512 4512
 		}
4513
-		if ( $ensure_is_in_db && $model_object->ID() !== null ) {
4513
+		if ($ensure_is_in_db && $model_object->ID() !== null) {
4514 4514
 			$model_object->save();
4515 4515
 		}
4516 4516
 		return $model_object;
@@ -4526,19 +4526,19 @@  discard block
 block discarded – undo
4526 4526
 	 * @return int|string depending on the type of this model object's ID
4527 4527
 	 * @throws EE_Error
4528 4528
 	 */
4529
-	public function ensure_is_ID($base_class_obj_or_id){
4529
+	public function ensure_is_ID($base_class_obj_or_id) {
4530 4530
 		$className = $this->_get_class_name();
4531
-		if( $base_class_obj_or_id instanceof $className ){
4531
+		if ($base_class_obj_or_id instanceof $className) {
4532 4532
 			/** @var $base_class_obj_or_id EE_Base_Class */
4533 4533
 			$id = $base_class_obj_or_id->ID();
4534
-		}elseif(is_int($base_class_obj_or_id)){
4534
+		}elseif (is_int($base_class_obj_or_id)) {
4535 4535
 			//assume it's an ID
4536 4536
 			$id = $base_class_obj_or_id;
4537
-		}elseif(is_string($base_class_obj_or_id)){
4537
+		}elseif (is_string($base_class_obj_or_id)) {
4538 4538
 			//assume its a string representation of the object
4539 4539
 			$id = $base_class_obj_or_id;
4540
-		}else{
4541
-			throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'",'event_espresso'),$base_class_obj_or_id,$this->_get_class_name(),print_r($base_class_obj_or_id,true)));
4540
+		} else {
4541
+			throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'", 'event_espresso'), $base_class_obj_or_id, $this->_get_class_name(), print_r($base_class_obj_or_id, true)));
4542 4542
 		}
4543 4543
 		return $id;
4544 4544
 	}
@@ -4561,14 +4561,14 @@  discard block
 block discarded – undo
4561 4561
 	 * @param int $values_already_prepared like one of the constants on EEM_Base
4562 4562
 	 * @return void
4563 4563
 	 */
4564
-	public function assume_values_already_prepared_by_model_object($values_already_prepared = self::not_prepared_by_model_object){
4564
+	public function assume_values_already_prepared_by_model_object($values_already_prepared = self::not_prepared_by_model_object) {
4565 4565
 		$this->_values_already_prepared_by_model_object = $values_already_prepared;
4566 4566
 	}
4567 4567
 	/**
4568 4568
 	 * Read comments for assume_values_already_prepared_by_model_object()
4569 4569
 	 * @return int
4570 4570
 	 */
4571
-	public function get_assumption_concerning_values_already_prepared_by_model_object(){
4571
+	public function get_assumption_concerning_values_already_prepared_by_model_object() {
4572 4572
 		return $this->_values_already_prepared_by_model_object;
4573 4573
 	}
4574 4574
 
@@ -4576,17 +4576,17 @@  discard block
 block discarded – undo
4576 4576
 	 * Gets all the indexes on this model
4577 4577
 	 * @return EE_Index[]
4578 4578
 	 */
4579
-	public function indexes(){
4579
+	public function indexes() {
4580 4580
 		return $this->_indexes;
4581 4581
 	}
4582 4582
 	/**
4583 4583
 	 * Gets all the Unique Indexes on this model
4584 4584
 	 * @return EE_Unique_Index[]
4585 4585
 	 */
4586
-	public function unique_indexes(){
4586
+	public function unique_indexes() {
4587 4587
 		$unique_indexes = array();
4588
-		foreach($this->_indexes as $name => $index){
4589
-			if($index instanceof EE_Unique_Index){
4588
+		foreach ($this->_indexes as $name => $index) {
4589
+			if ($index instanceof EE_Unique_Index) {
4590 4590
 				$unique_indexes [$name] = $index;
4591 4591
 			}
4592 4592
 		}
@@ -4604,13 +4604,13 @@  discard block
 block discarded – undo
4604 4604
 	 * @return EE_Model_Field_Base[] indexed by the field's name
4605 4605
 	 * @throws \EE_Error
4606 4606
 	 */
4607
-	public function get_combined_primary_key_fields(){
4608
-		foreach($this->indexes() as $index){
4609
-			if($index instanceof EE_Primary_Key_Index){
4607
+	public function get_combined_primary_key_fields() {
4608
+		foreach ($this->indexes() as $index) {
4609
+			if ($index instanceof EE_Primary_Key_Index) {
4610 4610
 				return $index->fields();
4611 4611
 			}
4612 4612
 		}
4613
-		return array( $this->primary_key_name() => $this->get_primary_key_field());
4613
+		return array($this->primary_key_name() => $this->get_primary_key_field());
4614 4614
 	}
4615 4615
 
4616 4616
 
@@ -4624,7 +4624,7 @@  discard block
 block discarded – undo
4624 4624
 	 * @return string
4625 4625
 	 * @throws \EE_Error
4626 4626
 	 */
4627
-	public function get_index_primary_key_string($cols_n_values){
4627
+	public function get_index_primary_key_string($cols_n_values) {
4628 4628
 		$cols_n_values_for_primary_key_index = array_intersect_key($cols_n_values, $this->get_combined_primary_key_fields());
4629 4629
 		return http_build_query($cols_n_values_for_primary_key_index);
4630 4630
 	}
@@ -4639,13 +4639,13 @@  discard block
 block discarded – undo
4639 4639
 	 * @return null|array
4640 4640
 	 * @throws \EE_Error
4641 4641
 	 */
4642
-	public function parse_index_primary_key_string( $index_primary_key_string) {
4642
+	public function parse_index_primary_key_string($index_primary_key_string) {
4643 4643
 		$key_fields = $this->get_combined_primary_key_fields();
4644 4644
 		//check all of them are in the $id
4645 4645
 		$key_vals_in_combined_pk = array();
4646
-		parse_str( $index_primary_key_string, $key_vals_in_combined_pk );
4647
-		foreach( $key_fields as $key_field_name => $field_obj ) {
4648
-			if( ! isset( $key_vals_in_combined_pk[ $key_field_name ] ) ){
4646
+		parse_str($index_primary_key_string, $key_vals_in_combined_pk);
4647
+		foreach ($key_fields as $key_field_name => $field_obj) {
4648
+			if ( ! isset($key_vals_in_combined_pk[$key_field_name])) {
4649 4649
 				return NULL;
4650 4650
 			}
4651 4651
 		}
@@ -4662,10 +4662,10 @@  discard block
 block discarded – undo
4662 4662
 	 * @return boolean
4663 4663
 	 * @throws \EE_Error
4664 4664
 	 */
4665
-	public function has_all_combined_primary_key_fields( $key_vals ) {
4666
-		$keys_it_should_have = array_keys( $this->get_combined_primary_key_fields() );
4667
-		foreach( $keys_it_should_have as $key ){
4668
-			if( ! isset( $key_vals[ $key ] ) ){
4665
+	public function has_all_combined_primary_key_fields($key_vals) {
4666
+		$keys_it_should_have = array_keys($this->get_combined_primary_key_fields());
4667
+		foreach ($keys_it_should_have as $key) {
4668
+			if ( ! isset($key_vals[$key])) {
4669 4669
 				return false;
4670 4670
 			}
4671 4671
 		}
@@ -4681,23 +4681,23 @@  discard block
 block discarded – undo
4681 4681
 	 * @throws EE_Error
4682 4682
 	 * @return \EE_Base_Class[] Array keys are object IDs (if there is a primary key on the model. if not, numerically indexed)
4683 4683
 	 */
4684
-	public function get_all_copies($model_object_or_attributes_array, $query_params = array()){
4684
+	public function get_all_copies($model_object_or_attributes_array, $query_params = array()) {
4685 4685
 
4686
-		if($model_object_or_attributes_array instanceof EE_Base_Class){
4686
+		if ($model_object_or_attributes_array instanceof EE_Base_Class) {
4687 4687
 			$attributes_array = $model_object_or_attributes_array->model_field_array();
4688
-		}elseif(is_array($model_object_or_attributes_array)){
4688
+		}elseif (is_array($model_object_or_attributes_array)) {
4689 4689
 			$attributes_array = $model_object_or_attributes_array;
4690
-		}else{
4691
-			throw new EE_Error(sprintf(__("get_all_copies should be provided with either a model object or an array of field-value-pairs, but was given %s", "event_espresso"),$model_object_or_attributes_array));
4690
+		} else {
4691
+			throw new EE_Error(sprintf(__("get_all_copies should be provided with either a model object or an array of field-value-pairs, but was given %s", "event_espresso"), $model_object_or_attributes_array));
4692 4692
 		}
4693 4693
 		//even copies obviously won't have the same ID, so remove the primary key
4694 4694
 		//from the WHERE conditions for finding copies (if there is a primary key, of course)
4695
-		if($this->has_primary_key_field() && isset($attributes_array[$this->primary_key_name()])){
4695
+		if ($this->has_primary_key_field() && isset($attributes_array[$this->primary_key_name()])) {
4696 4696
 			unset($attributes_array[$this->primary_key_name()]);
4697 4697
 		}
4698
-		if(isset($query_params[0])){
4699
-			$query_params[0] = array_merge($attributes_array,$query_params);
4700
-		}else{
4698
+		if (isset($query_params[0])) {
4699
+			$query_params[0] = array_merge($attributes_array, $query_params);
4700
+		} else {
4701 4701
 			$query_params[0] = $attributes_array;
4702 4702
 		}
4703 4703
 		return $this->get_all($query_params);
@@ -4713,16 +4713,16 @@  discard block
 block discarded – undo
4713 4713
 	 * @return EE_Base_Class
4714 4714
 	 * @throws \EE_Error
4715 4715
 	 */
4716
-	public function get_one_copy($model_object_or_attributes_array,$query_params = array()){
4717
-		if( ! is_array( $query_params ) ){
4718
-			EE_Error::doing_it_wrong('EEM_Base::get_one_copy', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
4716
+	public function get_one_copy($model_object_or_attributes_array, $query_params = array()) {
4717
+		if ( ! is_array($query_params)) {
4718
+			EE_Error::doing_it_wrong('EEM_Base::get_one_copy', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
4719 4719
 			$query_params = array();
4720 4720
 		}
4721 4721
 		$query_params['limit'] = 1;
4722
-		$copies = $this->get_all_copies($model_object_or_attributes_array,$query_params);
4723
-		if(is_array($copies)){
4722
+		$copies = $this->get_all_copies($model_object_or_attributes_array, $query_params);
4723
+		if (is_array($copies)) {
4724 4724
 			return array_shift($copies);
4725
-		}else{
4725
+		} else {
4726 4726
 			return null;
4727 4727
 		}
4728 4728
 	}
@@ -4738,10 +4738,10 @@  discard block
 block discarded – undo
4738 4738
 	 * @return int number of rows updated
4739 4739
 	 * @throws \EE_Error
4740 4740
 	 */
4741
-	public function update_by_ID($fields_n_values,$id){
4741
+	public function update_by_ID($fields_n_values, $id) {
4742 4742
 		$query_params = array(0=>array($this->get_primary_key_field()->get_name() => $id),
4743 4743
 			'default_where_conditions'=>'other_models_only',);
4744
-		return $this->update($fields_n_values,$query_params);
4744
+		return $this->update($fields_n_values, $query_params);
4745 4745
 	}
4746 4746
 
4747 4747
 
@@ -4752,12 +4752,12 @@  discard block
 block discarded – undo
4752 4752
 	 * @return string an operator which can be used in SQL
4753 4753
 	 * @throws EE_Error
4754 4754
 	 */
4755
-	private function _prepare_operator_for_sql($operator_supplied){
4755
+	private function _prepare_operator_for_sql($operator_supplied) {
4756 4756
 		$sql_operator = isset($this->_valid_operators[$operator_supplied]) ? $this->_valid_operators[$operator_supplied] : null;
4757
-		if($sql_operator){
4757
+		if ($sql_operator) {
4758 4758
 			return $sql_operator;
4759
-		}else{
4760
-			throw new EE_Error(sprintf(__("The operator '%s' is not in the list of valid operators: %s", "event_espresso"),$operator_supplied,implode(",",array_keys($this->_valid_operators))));
4759
+		} else {
4760
+			throw new EE_Error(sprintf(__("The operator '%s' is not in the list of valid operators: %s", "event_espresso"), $operator_supplied, implode(",", array_keys($this->_valid_operators))));
4761 4761
 		}
4762 4762
 	}
4763 4763
 
@@ -4771,10 +4771,10 @@  discard block
 block discarded – undo
4771 4771
 	 * @return string[]
4772 4772
 	 * @throws \EE_Error
4773 4773
 	 */
4774
-	public function get_all_names($query_params = array()){
4774
+	public function get_all_names($query_params = array()) {
4775 4775
 		$objs = $this->get_all($query_params);
4776 4776
 		$names = array();
4777
-		foreach($objs as $obj){
4777
+		foreach ($objs as $obj) {
4778 4778
 			$names[$obj->ID()] = $obj->name();
4779 4779
 		}
4780 4780
 		return $names;
@@ -4793,11 +4793,11 @@  discard block
 block discarded – undo
4793 4793
 	 * @return array
4794 4794
 	 * @throws \EE_Error
4795 4795
 	 */
4796
-	public function get_IDs( $model_objects, $filter_out_empty_ids = false) {
4797
-		if( ! $this->has_primary_key_field() ) {
4798
-			if( WP_DEBUG ) {
4796
+	public function get_IDs($model_objects, $filter_out_empty_ids = false) {
4797
+		if ( ! $this->has_primary_key_field()) {
4798
+			if (WP_DEBUG) {
4799 4799
 				EE_Error::add_error(
4800
-					__( 'Trying to get IDs from a model than has no primary key', 'event_espresso' ),
4800
+					__('Trying to get IDs from a model than has no primary key', 'event_espresso'),
4801 4801
 					__FILE__,
4802 4802
 					__FUNCTION__,
4803 4803
 					__LINE__
@@ -4805,13 +4805,13 @@  discard block
 block discarded – undo
4805 4805
 			}
4806 4806
 		}
4807 4807
 		$IDs = array();
4808
-		foreach( $model_objects as $model_object ) {
4808
+		foreach ($model_objects as $model_object) {
4809 4809
 			$id = $model_object->ID();
4810
-			if( ! $id ) {
4811
-				if( $filter_out_empty_ids ) {
4810
+			if ( ! $id) {
4811
+				if ($filter_out_empty_ids) {
4812 4812
 					continue;
4813 4813
 				}
4814
-				if ( WP_DEBUG ) {
4814
+				if (WP_DEBUG) {
4815 4815
 					EE_Error::add_error(
4816 4816
 						__(
4817 4817
 							'Called %1$s on a model object that has no ID and so probably hasn\'t been saved to the database',
@@ -4833,8 +4833,8 @@  discard block
 block discarded – undo
4833 4833
 	 * are no capabilities that relate to this model returns false
4834 4834
 	 * @return string|false
4835 4835
 	 */
4836
-	public function cap_slug(){
4837
-		return apply_filters( 'FHEE__EEM_Base__cap_slug', $this->_caps_slug, $this);
4836
+	public function cap_slug() {
4837
+		return apply_filters('FHEE__EEM_Base__cap_slug', $this->_caps_slug, $this);
4838 4838
 	}
4839 4839
 
4840 4840
 
@@ -4849,34 +4849,34 @@  discard block
 block discarded – undo
4849 4849
 	 * @return EE_Default_Where_Conditions[] indexed by associated capability
4850 4850
 	 * @throws \EE_Error
4851 4851
 	 */
4852
-	public function cap_restrictions( $context = EEM_Base::caps_read ) {
4853
-		EEM_Base::verify_is_valid_cap_context( $context );
4852
+	public function cap_restrictions($context = EEM_Base::caps_read) {
4853
+		EEM_Base::verify_is_valid_cap_context($context);
4854 4854
 		//check if we ought to run the restriction generator first
4855
-		if(
4856
-			isset( $this->_cap_restriction_generators[ $context ] )
4857
-			&& $this->_cap_restriction_generators[ $context ] instanceof EE_Restriction_Generator_Base
4858
-			&& ! $this->_cap_restriction_generators[ $context ]->has_generated_cap_restrictions()
4855
+		if (
4856
+			isset($this->_cap_restriction_generators[$context])
4857
+			&& $this->_cap_restriction_generators[$context] instanceof EE_Restriction_Generator_Base
4858
+			&& ! $this->_cap_restriction_generators[$context]->has_generated_cap_restrictions()
4859 4859
 		) {
4860
-			$this->_cap_restrictions[ $context ] = array_merge(
4861
-				$this->_cap_restrictions[ $context ],
4862
-				$this->_cap_restriction_generators[ $context ]->generate_restrictions()
4860
+			$this->_cap_restrictions[$context] = array_merge(
4861
+				$this->_cap_restrictions[$context],
4862
+				$this->_cap_restriction_generators[$context]->generate_restrictions()
4863 4863
 			);
4864 4864
 		}
4865 4865
 		//and make sure we've finalized the construction of each restriction
4866
-		foreach( $this->_cap_restrictions[ $context ] as $where_conditions_obj ) {
4867
-			if ( $where_conditions_obj instanceof EE_Default_Where_Conditions ) {
4868
-				$where_conditions_obj->_finalize_construct( $this );
4866
+		foreach ($this->_cap_restrictions[$context] as $where_conditions_obj) {
4867
+			if ($where_conditions_obj instanceof EE_Default_Where_Conditions) {
4868
+				$where_conditions_obj->_finalize_construct($this);
4869 4869
 			}
4870 4870
 		}
4871 4871
 
4872
-		return $this->_cap_restrictions[ $context ];
4872
+		return $this->_cap_restrictions[$context];
4873 4873
 	}
4874 4874
 
4875 4875
 	/**
4876 4876
 	 * Indicating whether or not this model thinks its a wp core model
4877 4877
 	 * @return boolean
4878 4878
 	 */
4879
-	public function is_wp_core_model(){
4879
+	public function is_wp_core_model() {
4880 4880
 		return $this->_wp_core_model;
4881 4881
 	}
4882 4882
 
@@ -4890,12 +4890,12 @@  discard block
 block discarded – undo
4890 4890
 	 * @return EE_Default_Where_Conditions[] indexed by capability name
4891 4891
 	 * @throws \EE_Error
4892 4892
 	 */
4893
-	public function caps_missing( $context = EEM_Base::caps_read ) {
4893
+	public function caps_missing($context = EEM_Base::caps_read) {
4894 4894
 		$missing_caps = array();
4895
-		$cap_restrictions = $this->cap_restrictions( $context );
4896
-		foreach( $cap_restrictions as $cap => $restriction_if_no_cap ) {
4897
-			if( ! EE_Capabilities::instance()->current_user_can( $cap, $this->get_this_model_name() . '_model_applying_caps') ) {
4898
-				$missing_caps[ $cap ] = $restriction_if_no_cap;
4895
+		$cap_restrictions = $this->cap_restrictions($context);
4896
+		foreach ($cap_restrictions as $cap => $restriction_if_no_cap) {
4897
+			if ( ! EE_Capabilities::instance()->current_user_can($cap, $this->get_this_model_name().'_model_applying_caps')) {
4898
+				$missing_caps[$cap] = $restriction_if_no_cap;
4899 4899
 			}
4900 4900
 		}
4901 4901
 		return $missing_caps;
@@ -4907,7 +4907,7 @@  discard block
 block discarded – undo
4907 4907
 	 * one of 'read', 'edit', or 'delete'
4908 4908
 	 */
4909 4909
 	public function cap_contexts_to_cap_action_map() {
4910
-		return apply_filters( 'FHEE__EEM_Base__cap_contexts_to_cap_action_map', $this->_cap_contexts_to_cap_action_map, $this );
4910
+		return apply_filters('FHEE__EEM_Base__cap_contexts_to_cap_action_map', $this->_cap_contexts_to_cap_action_map, $this);
4911 4911
 	}
4912 4912
 
4913 4913
 
@@ -4918,19 +4918,19 @@  discard block
 block discarded – undo
4918 4918
 	 * @return string one of EEM_Base::cap_contexts_to_cap_action_map() values
4919 4919
 	 * @throws \EE_Error
4920 4920
 	 */
4921
-	public function cap_action_for_context( $context ) {
4921
+	public function cap_action_for_context($context) {
4922 4922
 		$mapping = $this->cap_contexts_to_cap_action_map();
4923
-		if( isset( $mapping[ $context ] ) ) {
4924
-			return $mapping[ $context ];
4923
+		if (isset($mapping[$context])) {
4924
+			return $mapping[$context];
4925 4925
 		}
4926
-		if( $action = apply_filters( 'FHEE__EEM_Base__cap_action_for_context', null, $this, $mapping, $context ) ) {
4926
+		if ($action = apply_filters('FHEE__EEM_Base__cap_action_for_context', null, $this, $mapping, $context)) {
4927 4927
 			return $action;
4928 4928
 		}
4929 4929
 		throw new EE_Error(
4930 4930
 			sprintf(
4931
-				__( 'Cannot find capability restrictions for context "%1$s", allowed values are:%2$s', 'event_espresso' ),
4931
+				__('Cannot find capability restrictions for context "%1$s", allowed values are:%2$s', 'event_espresso'),
4932 4932
 				$context,
4933
-				implode(',', array_keys( $this->cap_contexts_to_cap_action_map() ) )
4933
+				implode(',', array_keys($this->cap_contexts_to_cap_action_map()))
4934 4934
 			)
4935 4935
 		);
4936 4936
 
@@ -4941,7 +4941,7 @@  discard block
 block discarded – undo
4941 4941
 	 * @return array
4942 4942
 	 */
4943 4943
 	static public function valid_cap_contexts() {
4944
-		return apply_filters( 'FHEE__EEM_Base__valid_cap_contexts', array(
4944
+		return apply_filters('FHEE__EEM_Base__valid_cap_contexts', array(
4945 4945
 			self::caps_read,
4946 4946
 			self::caps_read_admin,
4947 4947
 			self::caps_edit,
@@ -4957,17 +4957,17 @@  discard block
 block discarded – undo
4957 4957
 	 * @return bool
4958 4958
 	 * @throws \EE_Error
4959 4959
 	 */
4960
-	static public function verify_is_valid_cap_context( $context ) {
4960
+	static public function verify_is_valid_cap_context($context) {
4961 4961
 		$valid_cap_contexts = EEM_Base::valid_cap_contexts();
4962
-		if( in_array( $context, $valid_cap_contexts ) ) {
4962
+		if (in_array($context, $valid_cap_contexts)) {
4963 4963
 			return true;
4964
-		}else{
4964
+		} else {
4965 4965
 			throw new EE_Error(
4966 4966
 				sprintf(
4967
-					__( 'Context "%1$s" passed into model "%2$s" is not a valid context. They are: %3$s', 'event_espresso' ),
4967
+					__('Context "%1$s" passed into model "%2$s" is not a valid context. They are: %3$s', 'event_espresso'),
4968 4968
 					$context,
4969
-					'EEM_Base' ,
4970
-					implode(',', $valid_cap_contexts )
4969
+					'EEM_Base',
4970
+					implode(',', $valid_cap_contexts)
4971 4971
 				)
4972 4972
 			);
4973 4973
 		}
Please login to merge, or discard this patch.
core/db_models/EEM_Line_Item.model.php 1 patch
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -105,41 +105,41 @@  discard block
 block discarded – undo
105 105
 	 * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved).  Note this just sends the timezone info to the date time model field objects.  Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option)
106 106
 	 * @return \EEM_Line_Item
107 107
 	 */
108
-	protected function __construct( $timezone ) {
109
-		$this->singular_item = __('Line Item','event_espresso');
110
-		$this->plural_item = __('Line Items','event_espresso');
108
+	protected function __construct($timezone) {
109
+		$this->singular_item = __('Line Item', 'event_espresso');
110
+		$this->plural_item = __('Line Items', 'event_espresso');
111 111
 
112 112
 		$this->_tables = array(
113
-			'Line_Item'=>new EE_Primary_Table('esp_line_item','LIN_ID')
113
+			'Line_Item'=>new EE_Primary_Table('esp_line_item', 'LIN_ID')
114 114
 		);
115
-		$line_items_can_be_for = apply_filters( 'FHEE__EEM_Line_Item__line_items_can_be_for', array('Ticket','Price', 'Event' ) );
115
+		$line_items_can_be_for = apply_filters('FHEE__EEM_Line_Item__line_items_can_be_for', array('Ticket', 'Price', 'Event'));
116 116
 		$this->_fields = array(
117 117
 			'Line_Item' => array(
118
-				'LIN_ID' 				=> new EE_Primary_Key_Int_Field( 'LIN_ID', __( "ID", "event_espresso" ) ),
119
-				'LIN_code' 			=> new EE_Slug_Field( 'LIN_code', __( "Code for index into Cart", "event_espresso" ), TRUE ),
120
-				'TXN_ID' 				=> new EE_Foreign_Key_Int_Field( 'TXN_ID', __( "Transaction ID", "event_espresso" ), TRUE, NULL, 'Transaction' ),
121
-				'LIN_name' 			=> new EE_Full_HTML_Field( 'LIN_name', __( "Line Item Name", "event_espresso" ), FALSE, '' ),
122
-				'LIN_desc' 			=> new EE_Full_HTML_Field( 'LIN_desc', __( "Line Item Description", "event_espresso" ), TRUE ),
123
-				'LIN_unit_price' 	=> new EE_Money_Field( 'LIN_unit_price', __( "Unit Price", "event_espresso" ), FALSE, 0 ),
124
-				'LIN_percent' 		=> new EE_Float_Field( 'LIN_percent', __( "Percent", "event_espresso" ), FALSE, 0 ),
125
-				'LIN_is_taxable' 	=> new EE_Boolean_Field( 'LIN_is_taxable', __( "Taxable", "event_espresso" ), FALSE, FALSE ),
126
-				'LIN_order' 			=> new EE_Integer_Field( 'LIN_order', __( "Order of Application towards total of parent", "event_espresso" ), FALSE, 1 ),
127
-				'LIN_total' 			=> new EE_Money_Field( 'LIN_total', __( "Total (unit price x quantity)", "event_espresso" ), FALSE, 0 ),
128
-				'LIN_quantity' 	=> new EE_Integer_Field( 'LIN_quantity', __( "Quantity", "event_espresso" ), TRUE, 1 ),
129
-				'LIN_parent' 		=> new EE_Integer_Field( 'LIN_parent', __( "Parent ID (this item goes towards that Line Item's total)", "event_espresso" ), TRUE, NULL ),
130
-				'LIN_type' 			=> new EE_Enum_Text_Field( 'LIN_type', __( "Type", "event_espresso" ), FALSE, 'line-item', array(
118
+				'LIN_ID' 				=> new EE_Primary_Key_Int_Field('LIN_ID', __("ID", "event_espresso")),
119
+				'LIN_code' 			=> new EE_Slug_Field('LIN_code', __("Code for index into Cart", "event_espresso"), TRUE),
120
+				'TXN_ID' 				=> new EE_Foreign_Key_Int_Field('TXN_ID', __("Transaction ID", "event_espresso"), TRUE, NULL, 'Transaction'),
121
+				'LIN_name' 			=> new EE_Full_HTML_Field('LIN_name', __("Line Item Name", "event_espresso"), FALSE, ''),
122
+				'LIN_desc' 			=> new EE_Full_HTML_Field('LIN_desc', __("Line Item Description", "event_espresso"), TRUE),
123
+				'LIN_unit_price' 	=> new EE_Money_Field('LIN_unit_price', __("Unit Price", "event_espresso"), FALSE, 0),
124
+				'LIN_percent' 		=> new EE_Float_Field('LIN_percent', __("Percent", "event_espresso"), FALSE, 0),
125
+				'LIN_is_taxable' 	=> new EE_Boolean_Field('LIN_is_taxable', __("Taxable", "event_espresso"), FALSE, FALSE),
126
+				'LIN_order' 			=> new EE_Integer_Field('LIN_order', __("Order of Application towards total of parent", "event_espresso"), FALSE, 1),
127
+				'LIN_total' 			=> new EE_Money_Field('LIN_total', __("Total (unit price x quantity)", "event_espresso"), FALSE, 0),
128
+				'LIN_quantity' 	=> new EE_Integer_Field('LIN_quantity', __("Quantity", "event_espresso"), TRUE, 1),
129
+				'LIN_parent' 		=> new EE_Integer_Field('LIN_parent', __("Parent ID (this item goes towards that Line Item's total)", "event_espresso"), TRUE, NULL),
130
+				'LIN_type' 			=> new EE_Enum_Text_Field('LIN_type', __("Type", "event_espresso"), FALSE, 'line-item', array(
131 131
 						self::type_line_item		=>  __("Line Item", "event_espresso"),
132 132
 						self::type_sub_line_item	=>  __("Sub-Item", "event_espresso"),
133 133
 						self::type_sub_total		=>  __("Subtotal", "event_espresso"),
134 134
 						self::type_tax_sub_total 	=> __("Tax Subtotal", "event_espresso"),
135 135
 						self::type_tax					=>  __("Tax", "event_espresso"),
136 136
 						self::type_total				=>  __("Total", "event_espresso"),
137
-						self::type_cancellation	=> __( 'Cancellation', 'event_espresso' )
137
+						self::type_cancellation	=> __('Cancellation', 'event_espresso')
138 138
 					)
139 139
 				),
140
-				'OBJ_ID' 					=> new EE_Foreign_Key_Int_Field( 'OBJ_ID', __( 'ID of Item purchased.', 'event_espresso' ), TRUE, NULL, $line_items_can_be_for ),
141
-				'OBJ_type'				=>new EE_Any_Foreign_Model_Name_Field( 'OBJ_type', __( "Model Name this Line Item is for", "event_espresso" ), TRUE, NULL, $line_items_can_be_for ),
142
-				'LIN_timestamp' => new EE_Datetime_Field('LIN_timestamp', __('When the line item was created','event_espresso'), false, EE_Datetime_Field::now, $timezone ),
140
+				'OBJ_ID' 					=> new EE_Foreign_Key_Int_Field('OBJ_ID', __('ID of Item purchased.', 'event_espresso'), TRUE, NULL, $line_items_can_be_for),
141
+				'OBJ_type'				=>new EE_Any_Foreign_Model_Name_Field('OBJ_type', __("Model Name this Line Item is for", "event_espresso"), TRUE, NULL, $line_items_can_be_for),
142
+				'LIN_timestamp' => new EE_Datetime_Field('LIN_timestamp', __('When the line item was created', 'event_espresso'), false, EE_Datetime_Field::now, $timezone),
143 143
 			)
144 144
 		);
145 145
 		$this->_model_relations = array(
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 		);
151 151
 		$this->_model_chain_to_wp_user = 'Transaction.Registration.Event';
152 152
 		$this->_caps_slug = 'transactions';
153
-		parent::__construct( $timezone );
153
+		parent::__construct($timezone);
154 154
 	}
155 155
 
156 156
 
@@ -161,9 +161,9 @@  discard block
 block discarded – undo
161 161
 	 * @param EE_Transaction|int $transaction
162 162
 	 * @return EE_Line_Item[]
163 163
 	 */
164
-	public function get_all_of_type_for_transaction( $line_item_type, $transaction ){
165
-		$transaction = EEM_Transaction::instance()->ensure_is_ID( $transaction );
166
-		return $this->get_all( array( array(
164
+	public function get_all_of_type_for_transaction($line_item_type, $transaction) {
165
+		$transaction = EEM_Transaction::instance()->ensure_is_ID($transaction);
166
+		return $this->get_all(array(array(
167 167
 			'LIN_type' => $line_item_type,
168 168
 			'TXN_ID' => $transaction
169 169
 		)));
@@ -177,14 +177,14 @@  discard block
 block discarded – undo
177 177
 	 * @param EE_Transaction|int $transaction
178 178
 	 * @return EE_Line_Item[]
179 179
 	 */
180
-	public function get_all_non_ticket_line_items_for_transaction( $transaction ) {
181
-		$transaction = EEM_Transaction::instance()->ensure_is_ID( $transaction );
182
-		return $this->get_all( array( array(
180
+	public function get_all_non_ticket_line_items_for_transaction($transaction) {
181
+		$transaction = EEM_Transaction::instance()->ensure_is_ID($transaction);
182
+		return $this->get_all(array(array(
183 183
 			'LIN_type' => self::type_line_item,
184 184
 			'TXN_ID' => $transaction,
185 185
 			'OR' => array(
186
-				'OBJ_type*notticket' => array( '!=', 'Ticket'),
187
-				'OBJ_type*null' => array( 'IS_NULL' ))
186
+				'OBJ_type*notticket' => array('!=', 'Ticket'),
187
+				'OBJ_type*null' => array('IS_NULL'))
188 188
 		)));
189 189
 	}
190 190
 
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 	 * because if there are spam bots afoot there will be LOTS of line items
195 195
 	 * @return int count of how many deleted
196 196
 	 */
197
-	public function delete_line_items_with_no_transaction(){
197
+	public function delete_line_items_with_no_transaction() {
198 198
 		/** @type WPDB $wpdb */
199 199
 		global $wpdb;
200 200
 		$time_to_leave_alone = apply_filters(
@@ -202,13 +202,13 @@  discard block
 block discarded – undo
202 202
 		);
203 203
 		$query = $wpdb->prepare(
204 204
 				'DELETE li
205
-				FROM ' . $this->table() . ' li
206
-				LEFT JOIN ' . EEM_Transaction::instance()->table(). ' t ON li.TXN_ID = t.TXN_ID
205
+				FROM ' . $this->table().' li
206
+				LEFT JOIN ' . EEM_Transaction::instance()->table().' t ON li.TXN_ID = t.TXN_ID
207 207
 				WHERE t.TXN_ID IS NULL AND li.LIN_timestamp < %s',
208 208
 				// use GMT time because that's what TXN_timestamps are in
209
-				gmdate(  'Y-m-d H:i:s', time() - $time_to_leave_alone )
209
+				gmdate('Y-m-d H:i:s', time() - $time_to_leave_alone)
210 210
 				);
211
-		return $wpdb->query( $query );
211
+		return $wpdb->query($query);
212 212
 	}
213 213
 
214 214
 
@@ -221,10 +221,10 @@  discard block
 block discarded – undo
221 221
 	 * @param \EE_Base_Class $object
222 222
 	 * @return EE_Line_Item[]
223 223
 	 */
224
-	public function get_line_item_for_transaction_object( $TXN_ID, EE_Base_Class $object ){
225
-		return $this->get_all( array( array(
224
+	public function get_line_item_for_transaction_object($TXN_ID, EE_Base_Class $object) {
225
+		return $this->get_all(array(array(
226 226
 			'TXN_ID' 		=> $TXN_ID,
227
-			'OBJ_type' 	=> str_replace( 'EE_', '', get_class( $object )),
227
+			'OBJ_type' 	=> str_replace('EE_', '', get_class($object)),
228 228
 			'OBJ_ID' 		=> $object->ID()
229 229
 		)));
230 230
 	}
@@ -240,16 +240,16 @@  discard block
 block discarded – undo
240 240
 	 * @param array $OBJ_IDs
241 241
 	 * @return EE_Line_Item[]
242 242
 	 */
243
-	public function get_object_line_items_for_transaction( $TXN_ID, $OBJ_type = 'Event', $OBJ_IDs = array() ){
243
+	public function get_object_line_items_for_transaction($TXN_ID, $OBJ_type = 'Event', $OBJ_IDs = array()) {
244 244
 		$query_params = array(
245 245
 			'OBJ_type' 	=> $OBJ_type,
246 246
 			// if incoming $OBJ_IDs is an array, then make sure it is formatted correctly for the query
247
-			'OBJ_ID' 		=> is_array( $OBJ_IDs ) && ! isset( $OBJ_IDs['IN'] ) ? array( 'IN', $OBJ_IDs ) : $OBJ_IDs
247
+			'OBJ_ID' 		=> is_array($OBJ_IDs) && ! isset($OBJ_IDs['IN']) ? array('IN', $OBJ_IDs) : $OBJ_IDs
248 248
 		);
249
-		if ( $TXN_ID ) {
249
+		if ($TXN_ID) {
250 250
 			$query_params['TXN_ID'] = $TXN_ID;
251 251
 		}
252
-		return $this->get_all( array( $query_params ));
252
+		return $this->get_all(array($query_params));
253 253
 	}
254 254
 
255 255
 
@@ -260,13 +260,13 @@  discard block
 block discarded – undo
260 260
 	 * @param EE_Transaction $transaction
261 261
 	 * @return EE_Line_Item[]
262 262
 	 */
263
-	public function get_all_ticket_line_items_for_transaction( EE_Transaction $transaction ) {
264
-		return $this->get_all( array(
263
+	public function get_all_ticket_line_items_for_transaction(EE_Transaction $transaction) {
264
+		return $this->get_all(array(
265 265
 		   array(
266 266
 			   'TXN_ID'   => $transaction->ID(),
267 267
 			   'OBJ_type' => 'Ticket',
268 268
 		   )
269
-	   ) );
269
+	   ));
270 270
 	}
271 271
 
272 272
 
@@ -278,14 +278,14 @@  discard block
 block discarded – undo
278 278
 	 * @param int $TKT_ID
279 279
 	 * @return \EE_Line_Item
280 280
 	 */
281
-	public function get_ticket_line_item_for_transaction( $TXN_ID, $TKT_ID ) {
282
-		return $this->get_one( array(
281
+	public function get_ticket_line_item_for_transaction($TXN_ID, $TKT_ID) {
282
+		return $this->get_one(array(
283 283
 		   array(
284
-			   'TXN_ID'   => EEM_Transaction::instance()->ensure_is_ID( $TXN_ID ),
284
+			   'TXN_ID'   => EEM_Transaction::instance()->ensure_is_ID($TXN_ID),
285 285
 			   'OBJ_ID'   => $TKT_ID,
286 286
 			   'OBJ_type' => 'Ticket',
287 287
 		   )
288
-	   ) );
288
+	   ));
289 289
 	}
290 290
 
291 291
 
@@ -300,8 +300,8 @@  discard block
 block discarded – undo
300 300
 	 * @param EE_Promotion $promotion
301 301
 	 * @return EE_Line_Item
302 302
 	 */
303
-	public function get_existing_promotion_line_item( EE_Line_Item $parent_line_item, EE_Promotion $promotion ) {
304
-		return $this->get_one( array(
303
+	public function get_existing_promotion_line_item(EE_Line_Item $parent_line_item, EE_Promotion $promotion) {
304
+		return $this->get_one(array(
305 305
 			array(
306 306
 				'TXN_ID' 			=> $parent_line_item->TXN_ID(),
307 307
 				'LIN_parent' 	=> $parent_line_item->ID(),
@@ -322,8 +322,8 @@  discard block
 block discarded – undo
322 322
 	 * @param EE_Line_Item $parent_line_item
323 323
 	 * @return EE_Line_Item[]
324 324
 	 */
325
-	public function get_all_promotion_line_items( EE_Line_Item $parent_line_item ) {
326
-		return $this->get_all( array(
325
+	public function get_all_promotion_line_items(EE_Line_Item $parent_line_item) {
326
+		return $this->get_all(array(
327 327
 			array(
328 328
 				'TXN_ID' 			=> $parent_line_item->TXN_ID(),
329 329
 				'LIN_parent' 	=> $parent_line_item->ID(),
@@ -340,8 +340,8 @@  discard block
 block discarded – undo
340 340
 	 * @param EE_Registration $registration
341 341
 	 * @return EE_Line_ITem
342 342
 	 */
343
-	public function get_line_item_for_registration( EE_Registration $registration ) {
344
-		return $this->get_one( $this->line_item_for_registration_query_params( $registration ));
343
+	public function get_line_item_for_registration(EE_Registration $registration) {
344
+		return $this->get_one($this->line_item_for_registration_query_params($registration));
345 345
 	}
346 346
 
347 347
 	/**
@@ -350,14 +350,14 @@  discard block
 block discarded – undo
350 350
 	 * @param array $original_query_params any extra query params you'd like to be merged with
351 351
 	 * @return array like EEM_Base::get_all()'s $query_params
352 352
 	 */
353
-	public function line_item_for_registration_query_params( EE_Registration $registration, $original_query_params = array() ) {
354
-		return array_replace_recursive( $original_query_params, array(
353
+	public function line_item_for_registration_query_params(EE_Registration $registration, $original_query_params = array()) {
354
+		return array_replace_recursive($original_query_params, array(
355 355
 			array(
356 356
 				'OBJ_ID' => $registration->ticket_ID(),
357 357
 				'OBJ_type' => 'Ticket',
358 358
 				'TXN_ID' => $registration->transaction_ID()
359 359
 			)
360
-		) );
360
+		));
361 361
 	}
362 362
 
363 363
 
Please login to merge, or discard this patch.