Completed
Branch BUG-8698-ticket-sellouts+8511 (0d128a)
by
unknown
33:55 queued 17:36
created
admin/extend/messages/Custom_Messages_Template_List_Table.class.php 2 patches
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION') )
2
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
3 3
 	exit('NO direct script access allowed');
4 4
 
5 5
 /**
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 class Custom_Messages_Template_List_Table extends EE_Admin_List_Table {
31 31
 
32 32
 
33
-	public function __construct( $admin_page ) {
33
+	public function __construct($admin_page) {
34 34
 		//Set parent defaults
35 35
 		parent::__construct($admin_page);
36 36
 	}
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
 
50 50
 
51 51
 	protected function _setup_data() {
52
-		$this->_data = $this->get_admin_page()->get_message_templates( $this->_per_page, $this->_view, FALSE, FALSE, FALSE );
53
-		$this->_all_data_count = $this->get_admin_page()->get_message_templates( $this->_per_page, $this->_view, TRUE, TRUE, FALSE );
52
+		$this->_data = $this->get_admin_page()->get_message_templates($this->_per_page, $this->_view, FALSE, FALSE, FALSE);
53
+		$this->_all_data_count = $this->get_admin_page()->get_message_templates($this->_per_page, $this->_view, TRUE, TRUE, FALSE);
54 54
 	}
55 55
 
56 56
 
@@ -59,8 +59,8 @@  discard block
 block discarded – undo
59 59
 
60 60
 	protected function _set_properties() {
61 61
 		$this->_wp_list_args = array(
62
-			'singular' => __('Message Template Group', 'event_espresso' ),
63
-			'plural' => __('Message Template', 'event_espresso' ),
62
+			'singular' => __('Message Template Group', 'event_espresso'),
63
+			'plural' => __('Message Template', 'event_espresso'),
64 64
 			'ajax' => TRUE, //for now,
65 65
 			'screen' => $this->get_admin_page()->get_current_screen()->id
66 66
 			);
@@ -69,15 +69,15 @@  discard block
 block discarded – undo
69 69
 			'cb' => '<input type="checkbox" />',
70 70
 			'name' => __('Template Name', 'event_espresso'),
71 71
 			'message_type' => __('Message Type', 'event_espresso'),
72
-			'messenger' => __( 'Messenger', 'event_espresso'),
73
-			'description' => __( 'Description', 'event_espresso' ),
74
-			'events' => __( 'Events', 'event_espresso'), //count of events using this template.
72
+			'messenger' => __('Messenger', 'event_espresso'),
73
+			'description' => __('Description', 'event_espresso'),
74
+			'events' => __('Events', 'event_espresso'), //count of events using this template.
75 75
 			'actions' => ''
76 76
 			//'messages_sent' => __( 'Total Sent', 'event_espresso' ) //todo this will come later when we've got message tracking in place.
77 77
 			);
78 78
 
79 79
 		$this->_sortable_columns = array(
80
-			'messenger' => array( 'MTP_messenger' => TRUE ),
80
+			'messenger' => array('MTP_messenger' => TRUE),
81 81
 			//'message_type' => array( 'MTP_message_type' => FALSE )
82 82
 			);
83 83
 
@@ -96,16 +96,16 @@  discard block
 block discarded – undo
96 96
 	 *
97 97
 	 * @return string
98 98
 	 */
99
-	public function single_row( $item ) {
99
+	public function single_row($item) {
100 100
 		$message_type = $item->message_type_obj();
101 101
 		$messenger = $item->messenger_obj();
102 102
 
103
-		if ( ! $message_type instanceof EE_message_type || ! $messenger instanceof EE_messenger ) {
103
+		if ( ! $message_type instanceof EE_message_type || ! $messenger instanceof EE_messenger) {
104 104
 			echo '';
105 105
 			return;
106 106
 		}
107 107
 
108
-		parent::single_row( $item );
108
+		parent::single_row($item);
109 109
 	}
110 110
 
111 111
 
@@ -123,8 +123,8 @@  discard block
 block discarded – undo
123 123
 		);
124 124
 
125 125
 		//set filters to select inputs if they aren't empty
126
-		foreach ( $select_inputs as $select_input ) {
127
-			if ( $select_input ) {
126
+		foreach ($select_inputs as $select_input) {
127
+			if ($select_input) {
128 128
 				$filters[] = $select_input;
129 129
 			}
130 130
 		}
@@ -135,14 +135,14 @@  discard block
 block discarded – undo
135 135
 	 * we're just removing the search box for message templates, not needed.
136 136
 	 * @return string (empty);
137 137
 	 */
138
-	function search_box( $text, $input_id ) {
138
+	function search_box($text, $input_id) {
139 139
 		return '';
140 140
 	}
141 141
 
142 142
 
143 143
 	protected function _add_view_counts() {
144
-		foreach ( $this->_views as $view => $args )  {
145
-			$this->_views[$view]['count'] = $this->get_admin_page()->get_message_templates( $this->_per_page, $view, TRUE, TRUE, FALSE );
144
+		foreach ($this->_views as $view => $args) {
145
+			$this->_views[$view]['count'] = $this->get_admin_page()->get_message_templates($this->_per_page, $view, TRUE, TRUE, FALSE);
146 146
 		}
147 147
 	}
148 148
 
@@ -156,16 +156,16 @@  discard block
 block discarded – undo
156 156
 	 * @return string
157 157
 	 */
158 158
 	public function no_items() {
159
-		if ( $this->_view !== 'trashed' )
160
-			printf( __('%sNo Custom Templates found.%s To create your first custom message template, go to the "Default Message Templates" tab and click the "Create Custom" button next to the template you want to use as a base for the new one.', 'event_espresso'), '<strong>', '</strong>' );
159
+		if ($this->_view !== 'trashed')
160
+			printf(__('%sNo Custom Templates found.%s To create your first custom message template, go to the "Default Message Templates" tab and click the "Create Custom" button next to the template you want to use as a base for the new one.', 'event_espresso'), '<strong>', '</strong>');
161 161
 		else
162 162
 			parent::no_items();
163 163
 	}
164 164
 
165 165
 
166 166
 
167
-	public function column_cb( $item ) {
168
-		return sprintf( '<input type="checkbox" name="checkbox[%s] value="1" />', $item->GRP_ID() );
167
+	public function column_cb($item) {
168
+		return sprintf('<input type="checkbox" name="checkbox[%s] value="1" />', $item->GRP_ID());
169 169
 	}
170 170
 
171 171
 
@@ -173,29 +173,29 @@  discard block
 block discarded – undo
173 173
 
174 174
 
175 175
 
176
-	function column_name( $item ) {
177
-		return '<p>' . $item->name() . '</p>';
176
+	function column_name($item) {
177
+		return '<p>'.$item->name().'</p>';
178 178
 	}
179 179
 
180 180
 
181 181
 
182 182
 
183
-	function column_description( $item ) {
184
-		return '<p>' . $item->description() . '</p>';
183
+	function column_description($item) {
184
+		return '<p>'.$item->description().'</p>';
185 185
 	}
186 186
 
187 187
 
188 188
 
189
-	function column_actions( $item ) {
190
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_edit_messages', 'espresso_messages_add_new_message_template' ) ) {
189
+	function column_actions($item) {
190
+		if (EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'espresso_messages_add_new_message_template')) {
191 191
 			$create_args = array(
192 192
 				'GRP_ID' => $item->ID(),
193 193
 				'messenger' => $item->messenger(),
194 194
 				'message_type' => $item->message_type(),
195 195
 				'action' => 'add_new_message_template'
196 196
 				);
197
-			$create_link = EE_Admin_Page::add_query_args_and_nonce( $create_args, EE_MSG_ADMIN_URL );
198
-			return sprintf( '<p><a href="%s" class="button button-small">%s</a></p>', $create_link, __('Create Custom', 'event_espresso') );
197
+			$create_link = EE_Admin_Page::add_query_args_and_nonce($create_args, EE_MSG_ADMIN_URL);
198
+			return sprintf('<p><a href="%s" class="button button-small">%s</a></p>', $create_link, __('Create Custom', 'event_espresso'));
199 199
 		}
200 200
 		return '';
201 201
 	}
@@ -212,27 +212,27 @@  discard block
 block discarded – undo
212 212
 		$actions = array();
213 213
 
214 214
 		// edit link but only if item isn't trashed.
215
-		if ( !$item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $item->ID() ) ) {
216
-			$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'edit_message_template', 'id'=>$item->GRP_ID() ), EE_MSG_ADMIN_URL );
217
-			$actions['edit'] = '<a href="'.$edit_lnk_url.'" title="' . esc_attr__( 'Edit Template', 'event_espresso' ) . '">' . __( 'Edit', 'event_espresso' ) . '</a>';
215
+		if ( ! $item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $item->ID())) {
216
+			$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'edit_message_template', 'id'=>$item->GRP_ID()), EE_MSG_ADMIN_URL);
217
+			$actions['edit'] = '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('Edit Template', 'event_espresso').'">'.__('Edit', 'event_espresso').'</a>';
218 218
 		}
219 219
 
220
-		$name_link = ! $item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $item->ID() )? '<a href="'.$edit_lnk_url.'" title="' . esc_attr__( 'Edit Template', 'event_espresso' ) . '">' . ucwords( $item->messenger_obj()->label['singular'] ) . '</a>' : ucwords( $item->messenger_obj()->label['singular'] );
221
-		$trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'trash_message_template', 'id'=>$item->GRP_ID(), 'noheader' => TRUE ), EE_MSG_ADMIN_URL );
220
+		$name_link = ! $item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $item->ID()) ? '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('Edit Template', 'event_espresso').'">'.ucwords($item->messenger_obj()->label['singular']).'</a>' : ucwords($item->messenger_obj()->label['singular']);
221
+		$trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'trash_message_template', 'id'=>$item->GRP_ID(), 'noheader' => TRUE), EE_MSG_ADMIN_URL);
222 222
 		// restore link
223
-		$restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'restore_message_template', 'id'=>$item->GRP_ID(), 'noheader' => TRUE ), EE_MSG_ADMIN_URL );
223
+		$restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'restore_message_template', 'id'=>$item->GRP_ID(), 'noheader' => TRUE), EE_MSG_ADMIN_URL);
224 224
 		// delete price link
225
-		$delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'delete_message_template', 'id'=>$item->GRP_ID(), 'noheader' => TRUE ), EE_MSG_ADMIN_URL );
225
+		$delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'delete_message_template', 'id'=>$item->GRP_ID(), 'noheader' => TRUE), EE_MSG_ADMIN_URL);
226 226
 
227
-		if ( !$item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can( 'ee_delete_message', 'espresso_messages_trash_message_template', $item->ID() ) ) {
228
-			$actions['trash'] = '<a href="'.$trash_lnk_url.'" title="' . esc_attr__( 'Move Template Group to Trash', 'event_espresso' ) . '">' . __( 'Move to Trash', 'event_espresso' ) . '</a>';
227
+		if ( ! $item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can('ee_delete_message', 'espresso_messages_trash_message_template', $item->ID())) {
228
+			$actions['trash'] = '<a href="'.$trash_lnk_url.'" title="'.esc_attr__('Move Template Group to Trash', 'event_espresso').'">'.__('Move to Trash', 'event_espresso').'</a>';
229 229
 		} else {
230
-			if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_message', 'espresso_messages_restore_message_template', $item->ID() ) ) {
231
-				$actions['restore'] = '<a href="'.$restore_lnk_url.'" title="' . esc_attr__( 'Restore Message Template', 'event_espresso' ) . '">' . __( 'Restore', 'event_espresso' ) . '</a>';
230
+			if (EE_Registry::instance()->CAP->current_user_can('ee_delete_message', 'espresso_messages_restore_message_template', $item->ID())) {
231
+				$actions['restore'] = '<a href="'.$restore_lnk_url.'" title="'.esc_attr__('Restore Message Template', 'event_espresso').'">'.__('Restore', 'event_espresso').'</a>';
232 232
 			}
233 233
 
234
-			if ( $this->_view == 'trashed' && EE_Registry::instance()->CAP->current_user_can( 'ee_delete_message', 'espresso_messages_delete_message_template', $item->ID() ) ) {
235
-				$actions['delete'] = '<a href="'.$delete_lnk_url.'" title="' . esc_attr__( 'Delete Template Group Permanently', 'event_espresso' ) . '">' . __( 'Delete Permanently', 'event_espresso' ) . '</a>';
234
+			if ($this->_view == 'trashed' && EE_Registry::instance()->CAP->current_user_can('ee_delete_message', 'espresso_messages_delete_message_template', $item->ID())) {
235
+				$actions['delete'] = '<a href="'.$delete_lnk_url.'" title="'.esc_attr__('Delete Template Group Permanently', 'event_espresso').'">'.__('Delete Permanently', 'event_espresso').'</a>';
236 236
 			}
237 237
 		}
238 238
 
@@ -241,15 +241,15 @@  discard block
 block discarded – undo
241 241
 		$c_configs = $item->contexts_config();
242 242
 		$ctxt = array();
243 243
 		$context_templates = $item->context_templates();
244
-		foreach ( $context_templates as $context => $template_fields ) {
245
-			$mtp_to = !empty( $context_templates[$context]['to'] ) && $context_templates[$context]['to'] instanceof EE_Message_Template ? $context_templates[$context]['to']->get('MTP_content') : NULL;
246
-			$inactive = empty( $mtp_to ) && !empty( $context_templates[$context]['to'] ) ? ' class="mtp-inactive"' : '';
244
+		foreach ($context_templates as $context => $template_fields) {
245
+			$mtp_to = ! empty($context_templates[$context]['to']) && $context_templates[$context]['to'] instanceof EE_Message_Template ? $context_templates[$context]['to']->get('MTP_content') : NULL;
246
+			$inactive = empty($mtp_to) && ! empty($context_templates[$context]['to']) ? ' class="mtp-inactive"' : '';
247 247
 			$context_title = ucwords($c_configs[$context]['label']);
248
-			$edit_link = EE_Admin_Page::add_query_args_and_nonce( array('action'=>'edit_message_template', 'id'=>$item->GRP_ID(), 'context' => $context), EE_MSG_ADMIN_URL );
249
-			$ctxt[] = EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $item->ID() ) ? '<a' . $inactive . ' href="'. $edit_link . '" title="' . esc_attr__('Edit Context', 'event_espresso') . '">' . $context_title . '</a>' : $context_title;
248
+			$edit_link = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'edit_message_template', 'id'=>$item->GRP_ID(), 'context' => $context), EE_MSG_ADMIN_URL);
249
+			$ctxt[] = EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $item->ID()) ? '<a'.$inactive.' href="'.$edit_link.'" title="'.esc_attr__('Edit Context', 'event_espresso').'">'.$context_title.'</a>' : $context_title;
250 250
 		}
251 251
 
252
-		$ctx_content = !$item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $item->ID() ) ? sprintf( __('<strong>%s:</strong> ', 'event_espresso'), ucwords($c_label['plural']) ) . implode(' | ', $ctxt) : '';
252
+		$ctx_content = ! $item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $item->ID()) ? sprintf(__('<strong>%s:</strong> ', 'event_espresso'), ucwords($c_label['plural'])).implode(' | ', $ctxt) : '';
253 253
 
254 254
 
255 255
 		//Return the name contents
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 										/* $1%s */ $name_link,
258 258
 										/* $2%s */ $item->GRP_ID(),
259 259
 										/* %4$s */ $ctx_content,
260
-										/* $3%s */ $this->row_actions( $actions )
260
+										/* $3%s */ $this->row_actions($actions)
261 261
 		);
262 262
 	}
263 263
 
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 	 * @return string       message_type name
279 279
 	 */
280 280
 	function column_message_type($item) {
281
-		return ucwords($item->message_type_obj()->label['singular'] );
281
+		return ucwords($item->message_type_obj()->label['singular']);
282 282
 	}
283 283
 
284 284
 
@@ -305,16 +305,16 @@  discard block
 block discarded – undo
305 305
 			)
306 306
 		);
307 307
 
308
-		foreach ( $active_message_template_groups_grouped_by_messenger as $active_message_template_group ) {
309
-			if ( $active_message_template_group instanceof EE_Message_Template_Group ) {
308
+		foreach ($active_message_template_groups_grouped_by_messenger as $active_message_template_group) {
309
+			if ($active_message_template_group instanceof EE_Message_Template_Group) {
310 310
 				$messenger = $active_message_template_group->messenger_obj();
311 311
 				$messenger_label = $messenger instanceof EE_messenger
312 312
 					? $messenger->label['singular']
313 313
 					: $active_message_template_group->messenger();
314
-				$messenger_options[ $active_message_template_group->messenger() ] = ucwords( $messenger_label );
314
+				$messenger_options[$active_message_template_group->messenger()] = ucwords($messenger_label);
315 315
 			}
316 316
 		}
317
-		return $this->get_admin_page()->get_messengers_select_input( $messenger_options );
317
+		return $this->get_admin_page()->get_messengers_select_input($messenger_options);
318 318
 	}
319 319
 
320 320
 
@@ -334,16 +334,16 @@  discard block
 block discarded – undo
334 334
 			)
335 335
 		);
336 336
 
337
-		foreach ( $active_message_template_groups_grouped_by_message_type as $active_message_template_group ) {
338
-			if ( $active_message_template_group instanceof EE_Message_Template_Group ) {
337
+		foreach ($active_message_template_groups_grouped_by_message_type as $active_message_template_group) {
338
+			if ($active_message_template_group instanceof EE_Message_Template_Group) {
339 339
 				$message_type = $active_message_template_group->message_type_obj();
340 340
 				$message_type_label = $message_type instanceof EE_message_type
341 341
 					? $message_type->label['singular']
342 342
 					: $active_message_template_group->message_type();
343
-				$message_type_options[ $active_message_template_group->message_type() ] = ucwords( $message_type_label );
343
+				$message_type_options[$active_message_template_group->message_type()] = ucwords($message_type_label);
344 344
 			}
345 345
 		}
346
-		return $this->get_admin_page()->get_message_types_select_input( $message_type_options );
346
+		return $this->get_admin_page()->get_message_types_select_input($message_type_options);
347 347
 	}
348 348
 
349 349
 }
Please login to merge, or discard this patch.
Braces   +7 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,6 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION') )
2
+if (!defined('EVENT_ESPRESSO_VERSION') ) {
3 3
 	exit('NO direct script access allowed');
4
+}
4 5
 
5 6
 /**
6 7
  * Event Espresso
@@ -156,10 +157,11 @@  discard block
 block discarded – undo
156 157
 	 * @return string
157 158
 	 */
158 159
 	public function no_items() {
159
-		if ( $this->_view !== 'trashed' )
160
-			printf( __('%sNo Custom Templates found.%s To create your first custom message template, go to the "Default Message Templates" tab and click the "Create Custom" button next to the template you want to use as a base for the new one.', 'event_espresso'), '<strong>', '</strong>' );
161
-		else
162
-			parent::no_items();
160
+		if ( $this->_view !== 'trashed' ) {
161
+					printf( __('%sNo Custom Templates found.%s To create your first custom message template, go to the "Default Message Templates" tab and click the "Create Custom" button next to the template you want to use as a base for the new one.', 'event_espresso'), '<strong>', '</strong>' );
162
+		} else {
163
+					parent::no_items();
164
+		}
163 165
 	}
164 166
 
165 167
 
Please login to merge, or discard this patch.
admin_pages/messages/Messages_Admin_Page.core.php 2 patches
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 *
102 102
 	 *
103 103
 	 * @throws EE_Error
104
-	*/
104
+	 */
105 105
 	protected function _load_message_resource_manager() {
106 106
 		$this->_message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' );
107 107
 	}
@@ -202,8 +202,8 @@  discard block
 block discarded – undo
202 202
 	public function get_messengers_select_input( $messenger_options ) {
203 203
 		//if empty or just one value then just return an empty string
204 204
 		if ( empty( $messenger_options )
205
-		     || ! is_array( $messenger_options )
206
-		     ||  count( $messenger_options ) === 1
205
+			 || ! is_array( $messenger_options )
206
+			 ||  count( $messenger_options ) === 1
207 207
 		) {
208 208
 			return '';
209 209
 		}
@@ -333,9 +333,9 @@  discard block
 block discarded – undo
333 333
 
334 334
 	/**
335 335
 	 * 		an array for storing key => value pairs of request actions and their corresponding methods
336
-	*		@access protected
337
-	*		@return void
338
-	*/
336
+	 *		@access protected
337
+	 *		@return void
338
+	 */
339 339
 	protected function _set_page_routes() {
340 340
 		$grp_id = ! empty( $this->_req_data['GRP_ID'] ) && ! is_array( $this->_req_data['GRP_ID'] )
341 341
 			? $this->_req_data['GRP_ID']
@@ -644,8 +644,8 @@  discard block
 block discarded – undo
644 644
 	protected function _add_screen_options_global_mtps() {
645 645
 		/**
646 646
 		 * Note: the reason for the value swap here on $this->_admin_page_title is because $this->_per_page_screen_options
647
-         * uses the $_admin_page_title property and we want different outputs in the different spots.
648
-         */
647
+		 * uses the $_admin_page_title property and we want different outputs in the different spots.
648
+		 */
649 649
 		$page_title = $this->_admin_page_title;
650 650
 		$this->_admin_page_title = __('Global Message Templates', 'event_espresso');
651 651
 		$this->_per_page_screen_option();
@@ -848,9 +848,9 @@  discard block
 block discarded – undo
848 848
 		$common_bulk_actions = EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'message_list_table_bulk_actions' )
849 849
 			? array(
850 850
 				'generate_now' => __( 'Generate Now', 'event_espresso' ),
851
-		        'generate_and_send_now' => __( 'Generate and Send Now', 'event_espresso' ),
852
-		        'queue_for_resending' => __( 'Queue for Resending', 'event_espresso' ),
853
-		        'send_now' => __( 'Send Now', 'event_espresso' )
851
+				'generate_and_send_now' => __( 'Generate and Send Now', 'event_espresso' ),
852
+				'queue_for_resending' => __( 'Queue for Resending', 'event_espresso' ),
853
+				'send_now' => __( 'Send Now', 'event_espresso' )
854 854
 				)
855 855
 			: array();
856 856
 
@@ -861,10 +861,10 @@  discard block
 block discarded – undo
861 861
 
862 862
 		$this->_views = array(
863 863
 			 'all' => array(
864
-			    'slug' => 'all',
865
-			    'label' => __( 'All', 'event_espresso' ),
866
-			    'count' => 0,
867
-			    'bulk_action' => array_merge( $common_bulk_actions, $delete_bulk_action )
864
+				'slug' => 'all',
865
+				'label' => __( 'All', 'event_espresso' ),
866
+				'count' => 0,
867
+				'bulk_action' => array_merge( $common_bulk_actions, $delete_bulk_action )
868 868
 			 )
869 869
 		);
870 870
 
@@ -1254,9 +1254,9 @@  discard block
 block discarded – undo
1254 1254
 																			&& in_array($extra_field, $v_fields)
1255 1255
 																			&&
1256 1256
 																			(
1257
-								                                                is_array($validators[$extra_field] )
1257
+																				is_array($validators[$extra_field] )
1258 1258
 																				&& isset( $validators[$extra_field]['msg'] )
1259
-							                                                )
1259
+																			)
1260 1260
 								? 'validate-error ' . $css_class
1261 1261
 								: $css_class;
1262 1262
 
@@ -1541,8 +1541,8 @@  discard block
 block discarded – undo
1541 1541
 			 $GRP_ID,
1542 1542
 			 false,
1543 1543
 			 add_query_arg(
1544
-			    array( 'action' => 'global_mtps' ),
1545
-			    $this->_admin_base_url
1544
+				array( 'action' => 'global_mtps' ),
1545
+				$this->_admin_base_url
1546 1546
 			 )
1547 1547
 		);
1548 1548
 
@@ -2017,14 +2017,14 @@  discard block
 block discarded – undo
2017 2017
 
2018 2018
 
2019 2019
 	/**
2020
-     * This returns the shortcode selector skeleton for a given context and field.
2021
-     *
2022
-     * @since 4.9.rc.000
2023
-     *
2020
+	 * This returns the shortcode selector skeleton for a given context and field.
2021
+	 *
2022
+	 * @since 4.9.rc.000
2023
+	 *
2024 2024
 	 * @param string $field  The name of the field retrieving shortcodes for.
2025
-     * @param string $linked_input_id The css id of the input that the shortcodes get added to.
2026
-     * @return string
2027
-    */
2025
+	 * @param string $linked_input_id The css id of the input that the shortcodes get added to.
2026
+	 * @return string
2027
+	 */
2028 2028
 	protected function _get_shortcode_selector( $field, $linked_input_id ) {
2029 2029
 		$template_args = array(
2030 2030
 			'shortcodes' => $this->_get_shortcodes( array( $field ), true ),
@@ -2622,9 +2622,9 @@  discard block
 block discarded – undo
2622 2622
 
2623 2623
 	/**
2624 2624
 	 * 	_learn_more_about_message_templates_link
2625
-	*	@access protected
2626
-	*	@return string
2627
-	*/
2625
+	 *	@access protected
2626
+	 *	@return string
2627
+	 */
2628 2628
 	protected function _learn_more_about_message_templates_link() {
2629 2629
 		return '<a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >' . __('learn more about how message templates works', 'event_espresso') . '</a>';
2630 2630
 	}
@@ -3268,7 +3268,7 @@  discard block
 block discarded – undo
3268 3268
 			/** @var EE_message_type $message_type */
3269 3269
 			$message_type = $this->_message_resource_manager->get_message_type( $message_type_name );
3270 3270
 			if ( $this->_message_resource_manager->is_message_type_active_for_messenger( $messenger_name, $message_type_name )
3271
-			     && $message_type instanceof EE_message_type
3271
+				 && $message_type instanceof EE_message_type
3272 3272
 			) {
3273 3273
 				$this->_template_args['data']['active_mts'][] = $message_type_name;
3274 3274
 				if ( $message_type->get_admin_settings_fields() ) {
@@ -3604,10 +3604,10 @@  discard block
 block discarded – undo
3604 3604
 
3605 3605
 	/**
3606 3606
 	 * This immediately generates any EE_Message ID's that are selected that are EEM_Message::status_incomplete
3607
-     * However, this does not send immediately, it just queues for sending.
3608
-     *
3609
-     * @since 4.9.0
3610
-     */
3607
+	 * However, this does not send immediately, it just queues for sending.
3608
+	 *
3609
+	 * @since 4.9.0
3610
+	 */
3611 3611
 	protected function _generate_now() {
3612 3612
 		$msg_ids = $this->_get_msg_ids_from_request();
3613 3613
 		EED_Messages::generate_now( $msg_ids );
@@ -3618,11 +3618,11 @@  discard block
 block discarded – undo
3618 3618
 
3619 3619
 	/**
3620 3620
 	 * This immediately generates AND sends any EE_Message's selected that are EEM_Message::status_incomplete or that are
3621
-     * EEM_Message::status_resend or EEM_Message::status_idle
3622
-     *
3623
-     * @since 4.9.0
3624
-     *
3625
-     */
3621
+	 * EEM_Message::status_resend or EEM_Message::status_idle
3622
+	 *
3623
+	 * @since 4.9.0
3624
+	 *
3625
+	 */
3626 3626
 	protected function _generate_and_send_now() {
3627 3627
 		$this->_generate_now();
3628 3628
 		$this->_send_now();
@@ -3635,9 +3635,9 @@  discard block
 block discarded – undo
3635 3635
 
3636 3636
 	/**
3637 3637
 	 * This queues any EEM_Message::status_sent EE_Message ids in the request for resending.
3638
-     *
3639
-     * @since 4.9.0
3640
-     */
3638
+	 *
3639
+	 * @since 4.9.0
3640
+	 */
3641 3641
 	protected function _queue_for_resending() {
3642 3642
 		$msg_ids = $this->_get_msg_ids_from_request();
3643 3643
 		EED_Messages::queue_for_resending( $msg_ids );
@@ -3649,9 +3649,9 @@  discard block
 block discarded – undo
3649 3649
 
3650 3650
 	/**
3651 3651
 	 *  This sends immediately any EEM_Message::status_idle or EEM_Message::status_resend messages in the queue
3652
-     *
3653
-     *  @since 4.9.0
3654
-     */
3652
+	 *
3653
+	 *  @since 4.9.0
3654
+	 */
3655 3655
 	protected function _send_now() {
3656 3656
 		$msg_ids = $this->_get_msg_ids_from_request();
3657 3657
 		EED_Messages::send_now( $msg_ids );
@@ -3663,9 +3663,9 @@  discard block
 block discarded – undo
3663 3663
 
3664 3664
 	/**
3665 3665
 	 * Deletes EE_messages for IDs in the request.
3666
-     *
3667
-     * @since 4.9.0
3668
-     */
3666
+	 *
3667
+	 * @since 4.9.0
3668
+	 */
3669 3669
 	protected function _delete_ee_messages() {
3670 3670
 		$msg_ids = $this->_get_msg_ids_from_request();
3671 3671
 		$deleted_count = 0;
@@ -3694,9 +3694,9 @@  discard block
 block discarded – undo
3694 3694
 
3695 3695
 	/**
3696 3696
 	 *  This looks for 'MSG_ID' key in the request and returns an array of MSG_ID's if present.
3697
-     *  @since 4.9.0
3698
-     *  @return array
3699
-     */
3697
+	 *  @since 4.9.0
3698
+	 *  @return array
3699
+	 */
3700 3700
 	protected function _get_msg_ids_from_request() {
3701 3701
 		if ( ! isset( $this->_req_data['MSG_ID'] ) ) {
3702 3702
 			return array();
Please login to merge, or discard this patch.
Spacing   +655 added lines, -655 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if (!defined('EVENT_ESPRESSO_VERSION') )
2
-	{exit('NO direct script access allowed');}
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION'))
2
+	{exit('NO direct script access allowed'); }
3 3
 
4 4
 /**
5 5
  *
@@ -74,10 +74,10 @@  discard block
 block discarded – undo
74 74
 	/**
75 75
 	 * @param bool $routing
76 76
 	 */
77
-	public function __construct( $routing = true ) {
77
+	public function __construct($routing = true) {
78 78
 		//make sure messages autoloader is running
79 79
 		EED_Messages::set_autoloaders();
80
-		parent::__construct( $routing );
80
+		parent::__construct($routing);
81 81
 	}
82 82
 
83 83
 
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 
92 92
 		$this->_activate_state = isset($this->_req_data['activate_state']) ? (array) $this->_req_data['activate_state'] : array();
93 93
 
94
-		$this->_active_messenger = isset( $this->_req_data['messenger'] ) ? $this->_req_data['messenger'] : null;
94
+		$this->_active_messenger = isset($this->_req_data['messenger']) ? $this->_req_data['messenger'] : null;
95 95
 		$this->_load_message_resource_manager();
96 96
 	}
97 97
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	 * @throws EE_Error
106 106
 	*/
107 107
 	protected function _load_message_resource_manager() {
108
-		$this->_message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' );
108
+		$this->_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
109 109
 	}
110 110
 
111 111
 
@@ -116,21 +116,21 @@  discard block
 block discarded – undo
116 116
 	public function get_messengers_for_list_table() {
117 117
 		EE_Error::doing_it_wrong(
118 118
 			__METHOD__,
119
-			__( 'This method is no longer in use.  There is no replacement for it. The method was used to generate a set of
119
+			__('This method is no longer in use.  There is no replacement for it. The method was used to generate a set of
120 120
 			values for use in creating a messenger filter dropdown which is now generated differently via
121
-			 Messages_Admin_Page::get_messengers_select_input', 'event_espresso' ),
121
+			 Messages_Admin_Page::get_messengers_select_input', 'event_espresso'),
122 122
 			'4.9.9.rc.014'
123 123
 		);
124 124
 
125 125
 		$m_values = array();
126
-		$active_messengers = EEM_Message::instance()->get_all( array( 'group_by' => 'MSG_messenger' ) );
126
+		$active_messengers = EEM_Message::instance()->get_all(array('group_by' => 'MSG_messenger'));
127 127
 		//setup messengers for selects
128 128
 		$i = 1;
129
-		foreach ( $active_messengers as $active_messenger ) {
130
-			if ( $active_messenger instanceof EE_Message ) {
131
-				$m_values[ $i ]['id']   = $active_messenger->messenger();
132
-				$m_values[ $i ]['text'] = ucwords( $active_messenger->messenger_label() );
133
-				$i ++;
129
+		foreach ($active_messengers as $active_messenger) {
130
+			if ($active_messenger instanceof EE_Message) {
131
+				$m_values[$i]['id']   = $active_messenger->messenger();
132
+				$m_values[$i]['text'] = ucwords($active_messenger->messenger_label());
133
+				$i++;
134 134
 			}
135 135
 		}
136 136
 		return $m_values;
@@ -144,20 +144,20 @@  discard block
 block discarded – undo
144 144
 	public function get_message_types_for_list_table() {
145 145
 		EE_Error::doing_it_wrong(
146 146
 			__METHOD__,
147
-			__( 'This method is no longer in use.  There is no replacement for it. The method was used to generate a set of
147
+			__('This method is no longer in use.  There is no replacement for it. The method was used to generate a set of
148 148
 			values for use in creating a message type filter dropdown which is now generated differently via
149
-			 Messages_Admin_Page::get_message_types_select_input', 'event_espresso' ),
149
+			 Messages_Admin_Page::get_message_types_select_input', 'event_espresso'),
150 150
 			'4.9.9.rc.014'
151 151
 		);
152 152
 
153 153
 		$mt_values = array();
154
-		$active_messages = EEM_Message::instance()->get_all( array( 'group_by' => 'MSG_message_type' ) );
154
+		$active_messages = EEM_Message::instance()->get_all(array('group_by' => 'MSG_message_type'));
155 155
 		$i = 1;
156
-		foreach ( $active_messages as $active_message ) {
157
-			if ( $active_message instanceof EE_Message ) {
158
-				$mt_values[ $i ]['id']   = $active_message->message_type();
159
-				$mt_values[ $i ]['text'] = ucwords( $active_message->message_type_label() );
160
-				$i ++;
156
+		foreach ($active_messages as $active_message) {
157
+			if ($active_message instanceof EE_Message) {
158
+				$mt_values[$i]['id']   = $active_message->message_type();
159
+				$mt_values[$i]['text'] = ucwords($active_message->message_type_label());
160
+				$i++;
161 161
 			}
162 162
 		}
163 163
 		return $mt_values;
@@ -171,21 +171,21 @@  discard block
 block discarded – undo
171 171
 	public function get_contexts_for_message_types_for_list_table() {
172 172
 		EE_Error::doing_it_wrong(
173 173
 			__METHOD__,
174
-			__( 'This method is no longer in use.  There is no replacement for it. The method was used to generate a set of
174
+			__('This method is no longer in use.  There is no replacement for it. The method was used to generate a set of
175 175
 			values for use in creating a message type context filter dropdown which is now generated differently via
176
-			 Messages_Admin_Page::get_contexts_for_message_types_select_input', 'event_espresso' ),
176
+			 Messages_Admin_Page::get_contexts_for_message_types_select_input', 'event_espresso'),
177 177
 			'4.9.9.rc.014'
178 178
 		);
179 179
 
180 180
 		$contexts = array();
181
-		$active_message_contexts = EEM_Message::instance()->get_all( array( 'group_by' => 'MSG_context' ) );
182
-		foreach ( $active_message_contexts as $active_message ) {
183
-			if ( $active_message instanceof EE_Message ) {
181
+		$active_message_contexts = EEM_Message::instance()->get_all(array('group_by' => 'MSG_context'));
182
+		foreach ($active_message_contexts as $active_message) {
183
+			if ($active_message instanceof EE_Message) {
184 184
 				$message_type = $active_message->message_type_object();
185
-				if ( $message_type instanceof EE_message_type ) {
185
+				if ($message_type instanceof EE_message_type) {
186 186
 					$message_type_contexts = $message_type->get_contexts();
187
-					foreach ( $message_type_contexts as $context => $context_details ) {
188
-						$contexts[ $context ] = $context_details['label'];
187
+					foreach ($message_type_contexts as $context => $context_details) {
188
+						$contexts[$context] = $context_details['label'];
189 189
 					}
190 190
 				}
191 191
 			}
@@ -201,17 +201,17 @@  discard block
 block discarded – undo
201 201
 	 *
202 202
 	 * @return string
203 203
 	 */
204
-	public function get_messengers_select_input( $messenger_options ) {
204
+	public function get_messengers_select_input($messenger_options) {
205 205
 		//if empty or just one value then just return an empty string
206
-		if ( empty( $messenger_options )
207
-		     || ! is_array( $messenger_options )
208
-		     ||  count( $messenger_options ) === 1
206
+		if (empty($messenger_options)
207
+		     || ! is_array($messenger_options)
208
+		     ||  count($messenger_options) === 1
209 209
 		) {
210 210
 			return '';
211 211
 		}
212 212
 		//merge in default
213 213
 		$messenger_options = array_merge(
214
-			array( 'none_selected' => __( 'Show All Messengers', 'event_espresso' ) ),
214
+			array('none_selected' => __('Show All Messengers', 'event_espresso')),
215 215
 			$messenger_options
216 216
 		);
217 217
 		$input = new EE_Select_Input(
@@ -220,8 +220,8 @@  discard block
 block discarded – undo
220 220
 				'html_name'  => 'ee_messenger_filter_by',
221 221
 				'html_id'    => 'ee_messenger_filter_by',
222 222
 				'html_class' => 'wide',
223
-				'default'    => isset( $this->_req_data['ee_messenger_filter_by'] )
224
-					? sanitize_title( $this->_req_data['ee_messenger_filter_by'] )
223
+				'default'    => isset($this->_req_data['ee_messenger_filter_by'])
224
+					? sanitize_title($this->_req_data['ee_messenger_filter_by'])
225 225
 					: 'none_selected'
226 226
 			)
227 227
 		);
@@ -237,17 +237,17 @@  discard block
 block discarded – undo
237 237
 	 *
238 238
 	 * @return string
239 239
 	 */
240
-	public function get_message_types_select_input( $message_type_options ) {
240
+	public function get_message_types_select_input($message_type_options) {
241 241
 		//if empty or count of options is 1 then just return an empty string
242
-		if ( empty( $message_type_options )
243
-			|| ! is_array( $message_type_options )
244
-			|| count( $message_type_options ) === 1
242
+		if (empty($message_type_options)
243
+			|| ! is_array($message_type_options)
244
+			|| count($message_type_options) === 1
245 245
 		) {
246 246
 			return '';
247 247
 		}
248 248
 		//merge in default
249 249
 		$message_type_options = array_merge(
250
-			array( 'none_selected' => __( 'Show All Message Types', 'event_espresso' ) ),
250
+			array('none_selected' => __('Show All Message Types', 'event_espresso')),
251 251
 			$message_type_options
252 252
 		);
253 253
 		$input = new EE_Select_Input(
@@ -256,8 +256,8 @@  discard block
 block discarded – undo
256 256
 				'html_name'  => 'ee_message_type_filter_by',
257 257
 				'html_id'    => 'ee_message_type_filter_by',
258 258
 				'html_class' => 'wide',
259
-				'default'    => isset( $this->_req_data['ee_message_type_filter_by'] )
260
-					? sanitize_title( $this->_req_data['ee_message_type_filter_by'] )
259
+				'default'    => isset($this->_req_data['ee_message_type_filter_by'])
260
+					? sanitize_title($this->_req_data['ee_message_type_filter_by'])
261 261
 					: 'none_selected',
262 262
 			)
263 263
 		);
@@ -273,17 +273,17 @@  discard block
 block discarded – undo
273 273
 	 *
274 274
 	 * @return string
275 275
 	 */
276
-	public function get_contexts_for_message_types_select_input( $context_options ) {
276
+	public function get_contexts_for_message_types_select_input($context_options) {
277 277
 		//if empty or count of options is one then just return empty string
278
-		if ( empty( $context_options )
279
-			|| ! is_array( $context_options )
280
-			|| count( $context_options ) === 1
278
+		if (empty($context_options)
279
+			|| ! is_array($context_options)
280
+			|| count($context_options) === 1
281 281
 		) {
282 282
 			return '';
283 283
 		}
284 284
 		//merge in default
285 285
 		$context_options = array_merge(
286
-			array( 'none_selected' => __( 'Show all Contexts', 'event_espresso' ) ),
286
+			array('none_selected' => __('Show all Contexts', 'event_espresso')),
287 287
 			$context_options
288 288
 		);
289 289
 		$input = new EE_Select_Input(
@@ -292,8 +292,8 @@  discard block
 block discarded – undo
292 292
 				'html_name'  => 'ee_context_filter_by',
293 293
 				'html_id'    => 'ee_context_filter_by',
294 294
 				'html_class' => 'wide',
295
-				'default'    => isset( $this->_req_data['ee_context_filter_by'] )
296
-					? sanitize_title( $this->_req_data['ee_context_filter_by'] )
295
+				'default'    => isset($this->_req_data['ee_context_filter_by'])
296
+					? sanitize_title($this->_req_data['ee_context_filter_by'])
297 297
 					: 'none_selected',
298 298
 			)
299 299
 		);
@@ -303,11 +303,11 @@  discard block
 block discarded – undo
303 303
 
304 304
 
305 305
 	protected function _ajax_hooks() {
306
-		add_action('wp_ajax_activate_messenger', array($this, 'activate_messenger_toggle' ) );
307
-		add_action('wp_ajax_activate_mt', array( $this, 'activate_mt_toggle') );
308
-		add_action('wp_ajax_ee_msgs_save_settings', array( $this, 'save_settings') );
309
-		add_action('wp_ajax_ee_msgs_update_mt_form', array( $this, 'update_mt_form' ) );
310
-		add_action('wp_ajax_switch_template_pack', array( $this, 'switch_template_pack' ) );
306
+		add_action('wp_ajax_activate_messenger', array($this, 'activate_messenger_toggle'));
307
+		add_action('wp_ajax_activate_mt', array($this, 'activate_mt_toggle'));
308
+		add_action('wp_ajax_ee_msgs_save_settings', array($this, 'save_settings'));
309
+		add_action('wp_ajax_ee_msgs_update_mt_form', array($this, 'update_mt_form'));
310
+		add_action('wp_ajax_switch_template_pack', array($this, 'switch_template_pack'));
311 311
 	}
312 312
 
313 313
 
@@ -339,13 +339,13 @@  discard block
 block discarded – undo
339 339
 	*		@return void
340 340
 	*/
341 341
 	protected function _set_page_routes() {
342
-		$grp_id = ! empty( $this->_req_data['GRP_ID'] ) && ! is_array( $this->_req_data['GRP_ID'] )
342
+		$grp_id = ! empty($this->_req_data['GRP_ID']) && ! is_array($this->_req_data['GRP_ID'])
343 343
 			? $this->_req_data['GRP_ID']
344 344
 			: 0;
345
-		$grp_id = empty( $grp_id ) && !empty( $this->_req_data['id'] )
345
+		$grp_id = empty($grp_id) && ! empty($this->_req_data['id'])
346 346
 			? $this->_req_data['id']
347 347
 			: $grp_id;
348
-		$msg_id = ! empty( $this->_req_data['MSG_ID'] ) && ! is_array( $this->_req_data['MSG_ID'] )
348
+		$msg_id = ! empty($this->_req_data['MSG_ID']) && ! is_array($this->_req_data['MSG_ID'])
349 349
 			? $this->_req_data['MSG_ID']
350 350
 			: 0;
351 351
 
@@ -387,35 +387,35 @@  discard block
 block discarded – undo
387 387
 			'insert_message_template' => array(
388 388
 				'func' => '_insert_or_update_message_template',
389 389
 				'capability' => 'ee_edit_messages',
390
-				'args' => array( 'new_template' => true ),
390
+				'args' => array('new_template' => true),
391 391
 				'noheader' => true
392 392
 			 ),
393 393
 			'update_message_template' => array(
394 394
 				'func' => '_insert_or_update_message_template',
395 395
 				'capability' => 'ee_edit_message',
396 396
 				'obj_id' => $grp_id,
397
-				'args' => array( 'new_template' => false ),
397
+				'args' => array('new_template' => false),
398 398
 				'noheader' => true
399 399
 			),
400 400
 			'trash_message_template' => array(
401 401
 				'func' => '_trash_or_restore_message_template',
402 402
 				'capability' => 'ee_delete_message',
403 403
 				'obj_id' => $grp_id,
404
-				'args' => array( 'trash' => true, 'all' => true ),
404
+				'args' => array('trash' => true, 'all' => true),
405 405
 				'noheader' => true
406 406
 			),
407 407
 			'trash_message_template_context' => array(
408 408
 				'func' => '_trash_or_restore_message_template',
409 409
 				'capability' => 'ee_delete_message',
410 410
 				'obj_id' => $grp_id,
411
-				'args' => array( 'trash' => true ),
411
+				'args' => array('trash' => true),
412 412
 				'noheader' => true
413 413
 			),
414 414
 			'restore_message_template' => array(
415 415
 				'func' => '_trash_or_restore_message_template',
416 416
 				'capability' => 'ee_delete_message',
417 417
 				'obj_id' => $grp_id,
418
-				'args' => array( 'trash' => false, 'all' => true ),
418
+				'args' => array('trash' => false, 'all' => true),
419 419
 				'noheader' => true
420 420
 			),
421 421
 			'restore_message_template_context' => array(
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
 						'filename' => 'messages_overview_other',
535 535
 					),
536 536
 				),
537
-				'help_tour' => array( 'Messages_Overview_Help_Tour' ),
537
+				'help_tour' => array('Messages_Overview_Help_Tour'),
538 538
 				'require_nonce' => false
539 539
 			),
540 540
 			'custom_mtps' => array(
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
 				),
570 570
 				'metaboxes' => array('_publish_post_box', '_register_edit_meta_boxes'),
571 571
 				'has_metaboxes' => true,
572
-				'help_tour' => array( 'Message_Templates_Edit_Help_Tour' ),
572
+				'help_tour' => array('Message_Templates_Edit_Help_Tour'),
573 573
 				'help_tabs' => array(
574 574
 					'edit_message_template' => array(
575 575
 						'title' => __('Message Template Editor', 'event_espresso'),
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
 						'filename' => 'messages_settings_messengers'
626 626
 					),
627 627
 				),
628
-				'help_tour' => array( 'Messages_Settings_Help_Tour' ),
628
+				'help_tour' => array('Messages_Settings_Help_Tour'),
629 629
 				'require_nonce' => false
630 630
 			)
631 631
 		);
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
 
659 659
 
660 660
 	protected function _add_screen_options_default() {
661
-		$this->_admin_page_title = __( 'Message Activity', 'event_espresso' );
661
+		$this->_admin_page_title = __('Message Activity', 'event_espresso');
662 662
 		$this->_per_page_screen_option();
663 663
 	}
664 664
 
@@ -680,37 +680,37 @@  discard block
 block discarded – undo
680 680
 
681 681
 
682 682
 	public function messages_help_tab() {
683
-		EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_help_tab.template.php' );
683
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_help_tab.template.php');
684 684
 	}
685 685
 
686 686
 
687 687
 	public function messengers_help_tab() {
688
-		EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messenger_help_tab.template.php' );
688
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messenger_help_tab.template.php');
689 689
 	}
690 690
 
691 691
 
692 692
 	public function message_types_help_tab() {
693
-		EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_message_type_help_tab.template.php' );
693
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_message_type_help_tab.template.php');
694 694
 	}
695 695
 
696 696
 
697 697
 	public function messages_overview_help_tab() {
698
-		EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_overview_help_tab.template.php' );
698
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_overview_help_tab.template.php');
699 699
 	}
700 700
 
701 701
 
702 702
 	public function message_templates_help_tab() {
703
-		EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_message_templates_help_tab.template.php' );
703
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_message_templates_help_tab.template.php');
704 704
 	}
705 705
 
706 706
 
707 707
 	public function edit_message_template_help_tab() {
708
-		$args['img1'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/editor.png' . '" alt="' . esc_attr__('Editor Title', 'event_espresso') . '" />';
709
-		$args['img2'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/switch-context.png' . '" alt="' . esc_attr__('Context Switcher and Preview', 'event_espresso') . '" />';
710
-		$args['img3'] = '<img class="left" src="' . EE_MSG_ASSETS_URL . 'images/form-fields.png' . '" alt="' . esc_attr__('Message Template Form Fields', 'event_espresso') . '" />';
711
-		$args['img4'] = '<img class="right" src="' . EE_MSG_ASSETS_URL . 'images/shortcodes-metabox.png' . '" alt="' . esc_attr__('Shortcodes Metabox', 'event_espresso') . '" />';
712
-		$args['img5'] = '<img class="right" src="' . EE_MSG_ASSETS_URL . 'images/publish-meta-box.png' . '" alt="' . esc_attr__('Publish Metabox', 'event_espresso') . '" />';
713
-		EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_templates_editor_help_tab.template.php', $args);
708
+		$args['img1'] = '<img src="'.EE_MSG_ASSETS_URL.'images/editor.png'.'" alt="'.esc_attr__('Editor Title', 'event_espresso').'" />';
709
+		$args['img2'] = '<img src="'.EE_MSG_ASSETS_URL.'images/switch-context.png'.'" alt="'.esc_attr__('Context Switcher and Preview', 'event_espresso').'" />';
710
+		$args['img3'] = '<img class="left" src="'.EE_MSG_ASSETS_URL.'images/form-fields.png'.'" alt="'.esc_attr__('Message Template Form Fields', 'event_espresso').'" />';
711
+		$args['img4'] = '<img class="right" src="'.EE_MSG_ASSETS_URL.'images/shortcodes-metabox.png'.'" alt="'.esc_attr__('Shortcodes Metabox', 'event_espresso').'" />';
712
+		$args['img5'] = '<img class="right" src="'.EE_MSG_ASSETS_URL.'images/publish-meta-box.png'.'" alt="'.esc_attr__('Publish Metabox', 'event_espresso').'" />';
713
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_templates_editor_help_tab.template.php', $args);
714 714
 	}
715 715
 
716 716
 
@@ -718,22 +718,22 @@  discard block
 block discarded – undo
718 718
 	public function message_template_shortcodes_help_tab() {
719 719
 		$this->_set_shortcodes();
720 720
 		$args['shortcodes'] = $this->_shortcodes;
721
-		EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_shortcodes_help_tab.template.php', $args );
721
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_shortcodes_help_tab.template.php', $args);
722 722
 	}
723 723
 
724 724
 
725 725
 
726 726
 	public function preview_message_help_tab() {
727
-		EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_preview_help_tab.template.php' );
727
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_preview_help_tab.template.php');
728 728
 	}
729 729
 
730 730
 
731 731
 	public function settings_help_tab() {
732
-		$args['img1'] = '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-active.png' . '" alt="' . esc_attr__('Active Email Tab', 'event_espresso') . '" />';
733
-		$args['img2'] = '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-inactive.png' . '" alt="' . esc_attr__('Inactive Email Tab', 'event_espresso') . '" />';
732
+		$args['img1'] = '<img class="inline-text" src="'.EE_MSG_ASSETS_URL.'images/email-tab-active.png'.'" alt="'.esc_attr__('Active Email Tab', 'event_espresso').'" />';
733
+		$args['img2'] = '<img class="inline-text" src="'.EE_MSG_ASSETS_URL.'images/email-tab-inactive.png'.'" alt="'.esc_attr__('Inactive Email Tab', 'event_espresso').'" />';
734 734
 		$args['img3'] = '<div class="switch"><input id="ee-on-off-toggle-on" class="ee-on-off-toggle ee-toggle-round-flat" type="checkbox" checked="checked"><label for="ee-on-off-toggle-on"></label>';
735 735
 		$args['img4'] = '<div class="switch"><input id="ee-on-off-toggle-on" class="ee-on-off-toggle ee-toggle-round-flat" type="checkbox"><label for="ee-on-off-toggle-on"></label>';
736
-		EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_settings_help_tab.template.php', $args);
736
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_settings_help_tab.template.php', $args);
737 737
 	}
738 738
 
739 739
 
@@ -741,31 +741,31 @@  discard block
 block discarded – undo
741 741
 
742 742
 
743 743
 	public function load_scripts_styles() {
744
-		wp_register_style('espresso_ee_msg', EE_MSG_ASSETS_URL . 'ee_message_admin.css', EVENT_ESPRESSO_VERSION );
744
+		wp_register_style('espresso_ee_msg', EE_MSG_ASSETS_URL.'ee_message_admin.css', EVENT_ESPRESSO_VERSION);
745 745
 		wp_enqueue_style('espresso_ee_msg');
746 746
 
747
-		wp_register_script('ee-messages-settings', EE_MSG_ASSETS_URL . 'ee-messages-settings.js', array('jquery-ui-droppable', 'ee-serialize-full-array'), EVENT_ESPRESSO_VERSION, true );
748
-		wp_register_script( 'ee-msg-list-table-js', EE_MSG_ASSETS_URL. 'ee_message_admin_list_table.js', array( 'ee-dialog' ), EVENT_ESPRESSO_VERSION );
747
+		wp_register_script('ee-messages-settings', EE_MSG_ASSETS_URL.'ee-messages-settings.js', array('jquery-ui-droppable', 'ee-serialize-full-array'), EVENT_ESPRESSO_VERSION, true);
748
+		wp_register_script('ee-msg-list-table-js', EE_MSG_ASSETS_URL.'ee_message_admin_list_table.js', array('ee-dialog'), EVENT_ESPRESSO_VERSION);
749 749
 	}
750 750
 
751 751
 
752 752
 
753 753
 	public function load_scripts_styles_default() {
754
-		wp_enqueue_script( 'ee-msg-list-table-js' );
754
+		wp_enqueue_script('ee-msg-list-table-js');
755 755
 	}
756 756
 
757 757
 
758 758
 
759 759
 
760 760
 
761
-	public function wp_editor_css( $mce_css ) {
761
+	public function wp_editor_css($mce_css) {
762 762
 		//if we're on the edit_message_template route
763
-		if ( $this->_req_action == 'edit_message_template' && $this->_active_messenger instanceof EE_messenger  ) {
763
+		if ($this->_req_action == 'edit_message_template' && $this->_active_messenger instanceof EE_messenger) {
764 764
 			$message_type_name = $this->_active_message_type_name;
765 765
 
766 766
 			//we're going to REPLACE the existing mce css
767 767
 			//we need to get the css file location from the active messenger
768
-			$mce_css = $this->_active_messenger->get_variation($this->_template_pack, $message_type_name, true, 'wpeditor', $this->_variation );
768
+			$mce_css = $this->_active_messenger->get_variation($this->_template_pack, $message_type_name, true, 'wpeditor', $this->_variation);
769 769
 		}
770 770
 
771 771
 		return $mce_css;
@@ -783,15 +783,15 @@  discard block
 block discarded – undo
783 783
 			$this->_message_template_group->messenger_obj()->label['singular'],
784 784
 			$this->_message_template_group->message_type_obj()->label['singular']
785 785
 		);
786
-		EE_Registry::$i18n_js_strings['confirm_switch_template_pack'] = __('Switching the template pack for a messages template will reset the content for the template so the new layout is loaded.  Any custom content in the existing template will be lost. Are you sure you wish to do this?', 'event_espresso' );
786
+		EE_Registry::$i18n_js_strings['confirm_switch_template_pack'] = __('Switching the template pack for a messages template will reset the content for the template so the new layout is loaded.  Any custom content in the existing template will be lost. Are you sure you wish to do this?', 'event_espresso');
787 787
 
788
-		wp_register_script('ee_msgs_edit_js', EE_MSG_ASSETS_URL . 'ee_message_editor.js', array('jquery'), EVENT_ESPRESSO_VERSION );
788
+		wp_register_script('ee_msgs_edit_js', EE_MSG_ASSETS_URL.'ee_message_editor.js', array('jquery'), EVENT_ESPRESSO_VERSION);
789 789
 
790 790
 		wp_enqueue_script('ee_admin_js');
791 791
 		wp_enqueue_script('ee_msgs_edit_js');
792 792
 
793 793
 		//add in special css for tiny_mce
794
-		add_filter( 'mce_css', array( $this, 'wp_editor_css' ) );
794
+		add_filter('mce_css', array($this, 'wp_editor_css'));
795 795
 	}
796 796
 
797 797
 
@@ -800,22 +800,22 @@  discard block
 block discarded – undo
800 800
 
801 801
 		$this->_set_message_template_group();
802 802
 
803
-		if ( isset( $this->_req_data['messenger'] ) ) {
804
-			$this->_active_messenger = $this->_message_resource_manager->get_active_messenger( $this->_req_data['messenger'] );
803
+		if (isset($this->_req_data['messenger'])) {
804
+			$this->_active_messenger = $this->_message_resource_manager->get_active_messenger($this->_req_data['messenger']);
805 805
 		}
806 806
 
807
-		$message_type_name = isset( $this->_req_data['message_type'] ) ? $this->_req_data['message_type'] : '';
807
+		$message_type_name = isset($this->_req_data['message_type']) ? $this->_req_data['message_type'] : '';
808 808
 
809 809
 
810
-		wp_enqueue_style('espresso_preview_css', $this->_active_messenger->get_variation( $this->_template_pack, $message_type_name, true, 'preview', $this->_variation ) );
810
+		wp_enqueue_style('espresso_preview_css', $this->_active_messenger->get_variation($this->_template_pack, $message_type_name, true, 'preview', $this->_variation));
811 811
 	}
812 812
 
813 813
 
814 814
 
815 815
 	public function load_scripts_styles_settings() {
816
-		wp_register_style( 'ee-message-settings', EE_MSG_ASSETS_URL . 'ee_message_settings.css', array(), EVENT_ESPRESSO_VERSION );
817
-		wp_enqueue_style( 'ee-text-links' );
818
-		wp_enqueue_style( 'ee-message-settings' );
816
+		wp_register_style('ee-message-settings', EE_MSG_ASSETS_URL.'ee_message_settings.css', array(), EVENT_ESPRESSO_VERSION);
817
+		wp_enqueue_style('ee-text-links');
818
+		wp_enqueue_style('ee-message-settings');
819 819
 
820 820
 		wp_enqueue_script('ee-messages-settings');
821 821
 	}
@@ -845,40 +845,40 @@  discard block
 block discarded – undo
845 845
 	 * set views array for message queue list table
846 846
 	 */
847 847
 	public function _set_list_table_views_default() {
848
-		EE_Registry::instance()->load_helper( 'Template' );
848
+		EE_Registry::instance()->load_helper('Template');
849 849
 
850
-		$common_bulk_actions = EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'message_list_table_bulk_actions' )
850
+		$common_bulk_actions = EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'message_list_table_bulk_actions')
851 851
 			? array(
852
-				'generate_now' => __( 'Generate Now', 'event_espresso' ),
853
-		        'generate_and_send_now' => __( 'Generate and Send Now', 'event_espresso' ),
854
-		        'queue_for_resending' => __( 'Queue for Resending', 'event_espresso' ),
855
-		        'send_now' => __( 'Send Now', 'event_espresso' )
852
+				'generate_now' => __('Generate Now', 'event_espresso'),
853
+		        'generate_and_send_now' => __('Generate and Send Now', 'event_espresso'),
854
+		        'queue_for_resending' => __('Queue for Resending', 'event_espresso'),
855
+		        'send_now' => __('Send Now', 'event_espresso')
856 856
 				)
857 857
 			: array();
858 858
 
859
-		$delete_bulk_action = EE_Registry::instance()->CAP->current_user_can( 'ee_delete_messages', 'message_list_table_bulk_actions' )
860
-			? array( 'delete_ee_messages' => __( 'Delete Messages', 'event_espresso' ) )
859
+		$delete_bulk_action = EE_Registry::instance()->CAP->current_user_can('ee_delete_messages', 'message_list_table_bulk_actions')
860
+			? array('delete_ee_messages' => __('Delete Messages', 'event_espresso'))
861 861
 			: array();
862 862
 
863 863
 
864 864
 		$this->_views = array(
865 865
 			 'all' => array(
866 866
 			    'slug' => 'all',
867
-			    'label' => __( 'All', 'event_espresso' ),
867
+			    'label' => __('All', 'event_espresso'),
868 868
 			    'count' => 0,
869
-			    'bulk_action' => array_merge( $common_bulk_actions, $delete_bulk_action )
869
+			    'bulk_action' => array_merge($common_bulk_actions, $delete_bulk_action)
870 870
 			 )
871 871
 		);
872 872
 
873 873
 
874
-		foreach ( EEM_Message::instance()->all_statuses() as $status ) {
875
-			if ( $status === EEM_Message::status_debug_only && ! EEM_Message::debug() ) {
874
+		foreach (EEM_Message::instance()->all_statuses() as $status) {
875
+			if ($status === EEM_Message::status_debug_only && ! EEM_Message::debug()) {
876 876
 				continue;
877 877
 			}
878 878
 			$status_bulk_actions = $common_bulk_actions;
879 879
 			//unset bulk actions not applying to status
880
-			if ( ! empty( $status_bulk_actions ) ) {
881
-				switch ( $status ) {
880
+			if ( ! empty($status_bulk_actions)) {
881
+				switch ($status) {
882 882
 					case EEM_Message::status_idle :
883 883
 					case EEM_Message::status_resend :
884 884
 						$status_bulk_actions['send_now'] = $common_bulk_actions['send_now'];
@@ -890,21 +890,21 @@  discard block
 block discarded – undo
890 890
 						break;
891 891
 
892 892
 					case EEM_Message::status_incomplete :
893
-						unset( $status_bulk_actions['queue_for_resending'], $status_bulk_actions['send_now'] );
893
+						unset($status_bulk_actions['queue_for_resending'], $status_bulk_actions['send_now']);
894 894
 						break;
895 895
 
896 896
 					case EEM_Message::status_retry :
897 897
 					case EEM_Message::status_sent :
898
-						unset( $status_bulk_actions['generate_now'], $status_bulk_actions['generate_and_send_now'] );
898
+						unset($status_bulk_actions['generate_now'], $status_bulk_actions['generate_and_send_now']);
899 899
 						break;
900 900
 				}
901 901
 			}
902 902
 
903
-			$this->_views[ strtolower( $status ) ] = array(
904
-				'slug' => strtolower( $status ),
905
-				'label' => EEH_Template::pretty_status( $status, false, 'sentence' ),
903
+			$this->_views[strtolower($status)] = array(
904
+				'slug' => strtolower($status),
905
+				'label' => EEH_Template::pretty_status($status, false, 'sentence'),
906 906
 				'count' => 0,
907
-				'bulk_action' => array_merge( $status_bulk_actions, $delete_bulk_action )
907
+				'bulk_action' => array_merge($status_bulk_actions, $delete_bulk_action)
908 908
 			);
909 909
 		}
910 910
 	}
@@ -923,8 +923,8 @@  discard block
 block discarded – undo
923 923
 	protected function _message_queue_list_table() {
924 924
 		$this->_search_btn_label = __('Message Activity', 'event_espresso');
925 925
 		$this->_template_args['per_column'] = 6;
926
-		$this->_template_args['after_list_table'] = $this->_display_legend( $this->_message_legend_items() );
927
-		$this->_template_args['before_list_table'] = '<h3>' . EEM_Message::instance()->get_pretty_label_for_results() . '</h3>';
926
+		$this->_template_args['after_list_table'] = $this->_display_legend($this->_message_legend_items());
927
+		$this->_template_args['before_list_table'] = '<h3>'.EEM_Message::instance()->get_pretty_label_for_results().'</h3>';
928 928
 		$this->display_admin_list_table_page_with_no_sidebar();
929 929
 	}
930 930
 
@@ -937,8 +937,8 @@  discard block
 block discarded – undo
937 937
 		$action_css_classes = EEH_MSG_Template::get_message_action_icons();
938 938
 		$action_items = array();
939 939
 
940
-		foreach( $action_css_classes as $action_item => $action_details ) {
941
-			if ( $action_item === 'see_notifications_for' ) {
940
+		foreach ($action_css_classes as $action_item => $action_details) {
941
+			if ($action_item === 'see_notifications_for') {
942 942
 				continue;
943 943
 			}
944 944
 			$action_items[$action_item] = array(
@@ -950,37 +950,37 @@  discard block
 block discarded – undo
950 950
 		/** @type array $status_items status legend setup*/
951 951
 		$status_items = array(
952 952
 			'sent_status' => array(
953
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_sent,
954
-				'desc' => EEH_Template::pretty_status( EEM_Message::status_sent, false, 'sentence' )
953
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_sent,
954
+				'desc' => EEH_Template::pretty_status(EEM_Message::status_sent, false, 'sentence')
955 955
 				),
956 956
 			'idle_status' => array(
957
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_idle,
958
-				'desc' => EEH_Template::pretty_status( EEM_Message::status_idle, false, 'sentence' )
957
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_idle,
958
+				'desc' => EEH_Template::pretty_status(EEM_Message::status_idle, false, 'sentence')
959 959
 				),
960 960
 			'failed_status' => array(
961
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_failed,
962
-				'desc' => EEH_Template::pretty_status( EEM_Message::status_failed, false, 'sentence' )
961
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_failed,
962
+				'desc' => EEH_Template::pretty_status(EEM_Message::status_failed, false, 'sentence')
963 963
 			),
964 964
 			'resend_status' => array(
965
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_resend,
966
-				'desc' => EEH_Template::pretty_status( EEM_Message::status_resend, false, 'sentence' )
965
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_resend,
966
+				'desc' => EEH_Template::pretty_status(EEM_Message::status_resend, false, 'sentence')
967 967
 				),
968 968
 			'incomplete_status' => array(
969
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_incomplete,
970
-				'desc' => EEH_Template::pretty_status( EEM_Message::status_incomplete, false, 'sentence' )
969
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_incomplete,
970
+				'desc' => EEH_Template::pretty_status(EEM_Message::status_incomplete, false, 'sentence')
971 971
 				),
972 972
 			'retry_status' => array(
973
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_retry,
974
-				'desc' => EEH_Template::pretty_status( EEM_Message::status_retry, false, 'sentence' )
973
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_retry,
974
+				'desc' => EEH_Template::pretty_status(EEM_Message::status_retry, false, 'sentence')
975 975
 				)
976 976
 		);
977
-		if ( EEM_Message::debug() ) {
977
+		if (EEM_Message::debug()) {
978 978
 			$status_items['debug_only_status'] = array(
979
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_debug_only,
980
-				'desc' => EEH_Template::pretty_status( EEM_Message::status_debug_only, false, 'sentence' )
979
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_debug_only,
980
+				'desc' => EEH_Template::pretty_status(EEM_Message::status_debug_only, false, 'sentence')
981 981
 			);
982 982
 		}
983
-		return array_merge( $action_items, $status_items );
983
+		return array_merge($action_items, $status_items);
984 984
 	}
985 985
 
986 986
 
@@ -990,9 +990,9 @@  discard block
 block discarded – undo
990 990
 
991 991
 	protected function _custom_mtps_preview() {
992 992
 		$this->_admin_page_title = __('Custom Message Templates (Preview)', 'event_espresso');
993
-		$this->_template_args['preview_img'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/custom_mtps_preview.png" alt="' . esc_attr__('Preview Custom Message Templates screenshot', 'event_espresso' ) . '" />';
993
+		$this->_template_args['preview_img'] = '<img src="'.EE_MSG_ASSETS_URL.'images/custom_mtps_preview.png" alt="'.esc_attr__('Preview Custom Message Templates screenshot', 'event_espresso').'" />';
994 994
 		$this->_template_args['preview_text'] = '<strong>'.__('Custom Message Templates is a feature that is only available in the caffeinated version of Event Espresso.  With the Custom Message Templates feature, you are able to create custom templates and set them per event.', 'event_espresso').'</strong>';
995
-		$this->display_admin_caf_preview_page( 'custom_message_types', false );
995
+		$this->display_admin_caf_preview_page('custom_message_types', false);
996 996
 	}
997 997
 
998 998
 
@@ -1016,31 +1016,31 @@  discard block
 block discarded – undo
1016 1016
 	 *
1017 1017
 	 * @return array
1018 1018
 	 */
1019
-	public function get_message_templates( $perpage = 10, $type = 'in_use', $count = false, $all = false, $global = true ) {
1019
+	public function get_message_templates($perpage = 10, $type = 'in_use', $count = false, $all = false, $global = true) {
1020 1020
 
1021 1021
 		$MTP = EEM_Message_Template_Group::instance();
1022 1022
 
1023 1023
 		$this->_req_data['orderby'] = empty($this->_req_data['orderby']) ? 'GRP_ID' : $this->_req_data['orderby'];
1024 1024
 		$orderby = $this->_req_data['orderby'];
1025 1025
 
1026
-		$order = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] ) ) ? $this->_req_data['order'] : 'ASC';
1026
+		$order = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC';
1027 1027
 
1028
-		$current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1;
1029
-		$per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $perpage;
1028
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1;
1029
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $perpage;
1030 1030
 
1031
-		$offset = ($current_page-1)*$per_page;
1032
-		$limit = $all ? null : array( $offset, $per_page );
1031
+		$offset = ($current_page - 1) * $per_page;
1032
+		$limit = $all ? null : array($offset, $per_page);
1033 1033
 
1034 1034
 
1035 1035
 		//options will match what is in the _views array property
1036
-		switch( $type ) {
1036
+		switch ($type) {
1037 1037
 
1038 1038
 			case 'in_use':
1039
-				$templates = $MTP->get_all_active_message_templates($orderby, $order, $limit, $count, $global, true );
1039
+				$templates = $MTP->get_all_active_message_templates($orderby, $order, $limit, $count, $global, true);
1040 1040
 				break;
1041 1041
 
1042 1042
 			default:
1043
-				$templates = $MTP->get_all_trashed_grouped_message_templates($orderby, $order, $limit, $count, $global );
1043
+				$templates = $MTP->get_all_trashed_grouped_message_templates($orderby, $order, $limit, $count, $global);
1044 1044
 
1045 1045
 		}
1046 1046
 
@@ -1059,8 +1059,8 @@  discard block
 block discarded – undo
1059 1059
 		$installed_message_types = $this->_message_resource_manager->installed_message_types();
1060 1060
 		$installed = array();
1061 1061
 
1062
-		foreach ( $installed_message_types as $message_type ) {
1063
-			$installed[ $message_type->name ] = $message_type;
1062
+		foreach ($installed_message_types as $message_type) {
1063
+			$installed[$message_type->name] = $message_type;
1064 1064
 		}
1065 1065
 
1066 1066
 		return $installed;
@@ -1079,24 +1079,24 @@  discard block
 block discarded – undo
1079 1079
 	 *
1080 1080
 	 * @throws EE_error
1081 1081
 	 */
1082
-	protected function _add_message_template(  $message_type = '', $messenger='', $GRP_ID = '' ) {
1082
+	protected function _add_message_template($message_type = '', $messenger = '', $GRP_ID = '') {
1083 1083
 		//set values override any request data
1084
-		$message_type = !empty( $message_type ) ? $message_type : '';
1085
-		$message_type = empty( $message_type ) && !empty( $this->_req_data['message_type'] ) ? $this->_req_data['message_type'] : $message_type;
1084
+		$message_type = ! empty($message_type) ? $message_type : '';
1085
+		$message_type = empty($message_type) && ! empty($this->_req_data['message_type']) ? $this->_req_data['message_type'] : $message_type;
1086 1086
 
1087
-		$messenger = !empty( $messenger ) ? $messenger : '';
1088
-		$messenger = empty( $messenger ) && !empty( $this->_req_data['messenger'] ) ? $this->_req_data['messenger'] : $messenger;
1087
+		$messenger = ! empty($messenger) ? $messenger : '';
1088
+		$messenger = empty($messenger) && ! empty($this->_req_data['messenger']) ? $this->_req_data['messenger'] : $messenger;
1089 1089
 
1090
-		$GRP_ID = !empty( $GRP_ID ) ? $GRP_ID : '';
1091
-		$GRP_ID = empty( $GRP_ID ) && !empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : $GRP_ID;
1090
+		$GRP_ID = ! empty($GRP_ID) ? $GRP_ID : '';
1091
+		$GRP_ID = empty($GRP_ID) && ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : $GRP_ID;
1092 1092
 
1093 1093
 		//we need messenger and message type.  They should be coming from the event editor. If not here then return error
1094
-		if ( empty( $message_type ) || empty( $messenger )  )
1095
-			{throw new EE_error(__('Sorry, but we can\'t create new templates because we\'re missing the messenger or message type', 'event_espresso'));}
1094
+		if (empty($message_type) || empty($messenger))
1095
+			{throw new EE_error(__('Sorry, but we can\'t create new templates because we\'re missing the messenger or message type', 'event_espresso')); }
1096 1096
 
1097 1097
 		//we need the GRP_ID for the template being used as the base for the new template
1098
-		if ( empty( $GRP_ID ) )
1099
-			{throw new EE_Error( __('In order to create a custom message template the GRP_ID of the template being used as a base is needed', 'event_espresso' ) );}
1098
+		if (empty($GRP_ID))
1099
+			{throw new EE_Error(__('In order to create a custom message template the GRP_ID of the template being used as a base is needed', 'event_espresso')); }
1100 1100
 
1101 1101
 		//let's just make sure the template gets generated!
1102 1102
 
@@ -1117,8 +1117,8 @@  discard block
 block discarded – undo
1117 1117
 	 * @param int      $GRP_ID         GRP_ID for the related message template group this new template will be based
1118 1118
 	 *                                 off of.
1119 1119
 	 */
1120
-	public function add_message_template( $message_type, $messenger, $GRP_ID ) {
1121
-		$this->_add_message_template( $message_type, $messenger, $GRP_ID );
1120
+	public function add_message_template($message_type, $messenger, $GRP_ID) {
1121
+		$this->_add_message_template($message_type, $messenger, $GRP_ID);
1122 1122
 	}
1123 1123
 
1124 1124
 
@@ -1129,14 +1129,14 @@  discard block
 block discarded – undo
1129 1129
 	 * @return void
1130 1130
 	 */
1131 1131
 	protected function _edit_message_template() {
1132
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '');
1132
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1133 1133
 		$template_fields = '';
1134 1134
 		$sidebar_fields = '';
1135 1135
 		//we filter the tinyMCE settings to remove the validation since message templates by their nature will not have valid html in the templates.
1136
-		add_filter( 'tiny_mce_before_init', array( $this, 'filter_tinymce_init'), 10, 2 );
1136
+		add_filter('tiny_mce_before_init', array($this, 'filter_tinymce_init'), 10, 2);
1137 1137
 
1138
-		$GRP_ID = isset( $this->_req_data['id'] ) && !empty( $this->_req_data['id'] )
1139
-			? absint( $this->_req_data['id'] )
1138
+		$GRP_ID = isset($this->_req_data['id']) && ! empty($this->_req_data['id'])
1139
+			? absint($this->_req_data['id'])
1140 1140
 			: false;
1141 1141
 
1142 1142
 		$this->_set_shortcodes(); //this also sets the _message_template property.
@@ -1144,20 +1144,20 @@  discard block
 block discarded – undo
1144 1144
 		$c_label = $message_template_group->context_label();
1145 1145
 		$c_config = $message_template_group->contexts_config();
1146 1146
 
1147
-		reset( $c_config );
1148
-		$context = isset( $this->_req_data['context']) && !empty($this->_req_data['context'] )
1147
+		reset($c_config);
1148
+		$context = isset($this->_req_data['context']) && ! empty($this->_req_data['context'])
1149 1149
 			? strtolower($this->_req_data['context'])
1150 1150
 			: key($c_config);
1151 1151
 
1152 1152
 
1153
-		if ( empty($GRP_ID) ) {
1153
+		if (empty($GRP_ID)) {
1154 1154
 			$action = 'insert_message_template';
1155 1155
 			//$button_both = false;
1156 1156
 			//$button_text = array( __( 'Save','event_espresso') );
1157 1157
 			//$button_actions = array('something_different');
1158 1158
 			//$referrer = false;
1159 1159
 			$edit_message_template_form_url = add_query_arg(
1160
-				array( 'action' => $action, 'noheader' => true ),
1160
+				array('action' => $action, 'noheader' => true),
1161 1161
 				EE_MSG_ADMIN_URL
1162 1162
 			);
1163 1163
 		} else {
@@ -1167,7 +1167,7 @@  discard block
 block discarded – undo
1167 1167
 			//$button_actions = array();
1168 1168
 			//$referrer = $this->_admin_base_url;
1169 1169
 			$edit_message_template_form_url = add_query_arg(
1170
-				array( 'action' => $action, 'noheader' => true ),
1170
+				array('action' => $action, 'noheader' => true),
1171 1171
 				EE_MSG_ADMIN_URL
1172 1172
 			);
1173 1173
 		}
@@ -1181,14 +1181,14 @@  discard block
 block discarded – undo
1181 1181
 
1182 1182
 		//Do we have any validation errors?
1183 1183
 		$validators = $this->_get_transient();
1184
-		$v_fields = !empty($validators) ? array_keys($validators) : array();
1184
+		$v_fields = ! empty($validators) ? array_keys($validators) : array();
1185 1185
 
1186 1186
 
1187 1187
 		//we need to assemble the title from Various details
1188 1188
 		$context_label = sprintf(
1189 1189
 			__('(%s %s)', 'event_espresso'),
1190 1190
 			$c_config[$context]['label'],
1191
-			ucwords($c_label['label'] )
1191
+			ucwords($c_label['label'])
1192 1192
 		);
1193 1193
 
1194 1194
 		$title = sprintf(
@@ -1209,7 +1209,7 @@  discard block
 block discarded – undo
1209 1209
 			$message_template_group->message_type()
1210 1210
 		);
1211 1211
 
1212
-		if ( !$template_field_structure ) {
1212
+		if ( ! $template_field_structure) {
1213 1213
 			$template_field_structure = false;
1214 1214
 			$template_fields = __('There was an error in assembling the fields for this display (you should see an error message)', 'event_espresso');
1215 1215
 		}
@@ -1219,51 +1219,51 @@  discard block
 block discarded – undo
1219 1219
 
1220 1220
 
1221 1221
 		//if we have the extra key.. then we need to remove the content index from the template_field_structure as it will get handled in the "extra" array.
1222
-		if ( is_array($template_field_structure[$context]) && isset( $template_field_structure[$context]['extra']) ) {
1223
-			foreach ( $template_field_structure[$context]['extra'] as $reference_field => $new_fields ) {
1224
-				unset( $template_field_structure[$context][$reference_field] );
1222
+		if (is_array($template_field_structure[$context]) && isset($template_field_structure[$context]['extra'])) {
1223
+			foreach ($template_field_structure[$context]['extra'] as $reference_field => $new_fields) {
1224
+				unset($template_field_structure[$context][$reference_field]);
1225 1225
 			}
1226 1226
 		}
1227 1227
 
1228 1228
 		//let's loop through the template_field_structure and actually assemble the input fields!
1229
-		if ( !empty($template_field_structure) ) {
1230
-			foreach ( $template_field_structure[$context] as $template_field => $field_setup_array ) {
1229
+		if ( ! empty($template_field_structure)) {
1230
+			foreach ($template_field_structure[$context] as $template_field => $field_setup_array) {
1231 1231
 				//if this is an 'extra' template field then we need to remove any existing fields that are keyed up in the extra array and reset them.
1232
-				if ( $template_field == 'extra' ) {
1232
+				if ($template_field == 'extra') {
1233 1233
 					$this->_template_args['is_extra_fields'] = true;
1234
-					foreach ( $field_setup_array as $reference_field => $new_fields_array ) {
1235
-						$message_template = $message_templates[ $context ][ $reference_field ];
1234
+					foreach ($field_setup_array as $reference_field => $new_fields_array) {
1235
+						$message_template = $message_templates[$context][$reference_field];
1236 1236
 						$content = $message_template instanceof EE_Message_Template
1237
-							? $message_template->get( 'MTP_content' )
1237
+							? $message_template->get('MTP_content')
1238 1238
 							: '';
1239
-						foreach ( $new_fields_array as $extra_field =>  $extra_array ) {
1239
+						foreach ($new_fields_array as $extra_field =>  $extra_array) {
1240 1240
 							//let's verify if we need this extra field via the shortcodes parameter.
1241 1241
 							$continue = false;
1242
-							if ( isset( $extra_array['shortcodes_required'] ) ) {
1243
-								foreach ( (array) $extra_array['shortcodes_required'] as $shortcode ) {
1244
-									if ( !array_key_exists( $shortcode, $this->_shortcodes ) )
1245
-										{$continue = true;}
1242
+							if (isset($extra_array['shortcodes_required'])) {
1243
+								foreach ((array) $extra_array['shortcodes_required'] as $shortcode) {
1244
+									if ( ! array_key_exists($shortcode, $this->_shortcodes))
1245
+										{$continue = true; }
1246 1246
 								}
1247
-								if ( $continue ) {continue;}
1247
+								if ($continue) {continue; }
1248 1248
 							}
1249 1249
 
1250
-							$field_id = $reference_field . '-' . $extra_field . '-content';
1250
+							$field_id = $reference_field.'-'.$extra_field.'-content';
1251 1251
 							$template_form_fields[$field_id] = $extra_array;
1252
-							$template_form_fields[$field_id]['name'] = 'MTP_template_fields[' . $reference_field . '][content][' . $extra_field . ']';
1253
-							$css_class = isset( $extra_array['css_class'] ) ? $extra_array['css_class'] : '';
1252
+							$template_form_fields[$field_id]['name'] = 'MTP_template_fields['.$reference_field.'][content]['.$extra_field.']';
1253
+							$css_class = isset($extra_array['css_class']) ? $extra_array['css_class'] : '';
1254 1254
 
1255
-							$template_form_fields[$field_id]['css_class'] = ! empty( $v_fields )
1255
+							$template_form_fields[$field_id]['css_class'] = ! empty($v_fields)
1256 1256
 																			&& in_array($extra_field, $v_fields)
1257 1257
 																			&&
1258 1258
 																			(
1259
-								                                                is_array($validators[$extra_field] )
1260
-																				&& isset( $validators[$extra_field]['msg'] )
1259
+								                                                is_array($validators[$extra_field])
1260
+																				&& isset($validators[$extra_field]['msg'])
1261 1261
 							                                                )
1262
-								? 'validate-error ' . $css_class
1262
+								? 'validate-error '.$css_class
1263 1263
 								: $css_class;
1264 1264
 
1265
-							$template_form_fields[$field_id]['value'] = !empty($message_templates) && isset($content[$extra_field])
1266
-								? stripslashes( html_entity_decode( $content[$extra_field], ENT_QUOTES, "UTF-8") )
1265
+							$template_form_fields[$field_id]['value'] = ! empty($message_templates) && isset($content[$extra_field])
1266
+								? stripslashes(html_entity_decode($content[$extra_field], ENT_QUOTES, "UTF-8"))
1267 1267
 								: '';
1268 1268
 
1269 1269
 							//do we have a validation error?  if we do then let's use that value instead
@@ -1279,32 +1279,32 @@  discard block
 block discarded – undo
1279 1279
 								$field_id
1280 1280
 							);
1281 1281
 
1282
-							if ( isset( $extra_array['input'] ) && $extra_array['input'] == 'wp_editor' ) {
1282
+							if (isset($extra_array['input']) && $extra_array['input'] == 'wp_editor') {
1283 1283
 								//we want to decode the entities
1284 1284
 								$template_form_fields[$field_id]['value'] = stripslashes(
1285
-									html_entity_decode( $template_form_fields[$field_id]['value'], ENT_QUOTES, "UTF-8")
1285
+									html_entity_decode($template_form_fields[$field_id]['value'], ENT_QUOTES, "UTF-8")
1286 1286
 								);
1287 1287
 
1288 1288
 							}/**/
1289 1289
 						}
1290
-						$templatefield_MTP_id = $reference_field . '-MTP_ID';
1291
-						$templatefield_templatename_id = $reference_field . '-name';
1290
+						$templatefield_MTP_id = $reference_field.'-MTP_ID';
1291
+						$templatefield_templatename_id = $reference_field.'-name';
1292 1292
 
1293 1293
 						$template_form_fields[$templatefield_MTP_id] = array(
1294
-							'name' => 'MTP_template_fields[' . $reference_field . '][MTP_ID]',
1294
+							'name' => 'MTP_template_fields['.$reference_field.'][MTP_ID]',
1295 1295
 							'label' => null,
1296 1296
 							'input' => 'hidden',
1297 1297
 							'type' => 'int',
1298 1298
 							'required' => false,
1299 1299
 							'validation' => false,
1300
-							'value' => !empty($message_templates) ? $message_template->ID() : '',
1300
+							'value' => ! empty($message_templates) ? $message_template->ID() : '',
1301 1301
 							'css_class' => '',
1302 1302
 							'format' => '%d',
1303 1303
 							'db-col' => 'MTP_ID'
1304 1304
 						);
1305 1305
 
1306 1306
 						$template_form_fields[$templatefield_templatename_id] = array(
1307
-							'name' => 'MTP_template_fields[' . $reference_field . '][name]',
1307
+							'name' => 'MTP_template_fields['.$reference_field.'][name]',
1308 1308
 							'label' => null,
1309 1309
 							'input' => 'hidden',
1310 1310
 							'type' => 'string',
@@ -1318,14 +1318,14 @@  discard block
 block discarded – undo
1318 1318
 					}
1319 1319
 					continue; //skip the next stuff, we got the necessary fields here for this dataset.
1320 1320
 				} else {
1321
-					$field_id = $template_field . '-content';
1321
+					$field_id = $template_field.'-content';
1322 1322
 					$template_form_fields[$field_id] = $field_setup_array;
1323
-					$template_form_fields[$field_id]['name'] = 'MTP_template_fields[' . $template_field . '][content]';
1324
-					$message_template = isset( $message_templates[ $context ][ $template_field ] )
1325
-						? $message_templates[ $context ][ $template_field ]
1323
+					$template_form_fields[$field_id]['name'] = 'MTP_template_fields['.$template_field.'][content]';
1324
+					$message_template = isset($message_templates[$context][$template_field])
1325
+						? $message_templates[$context][$template_field]
1326 1326
 						: null;
1327
-					$template_form_fields[$field_id]['value'] = ! empty( $message_templates )
1328
-																&& is_array( $message_templates[$context] )
1327
+					$template_form_fields[$field_id]['value'] = ! empty($message_templates)
1328
+																&& is_array($message_templates[$context])
1329 1329
 																&& $message_template instanceof EE_Message_Template
1330 1330
 						? $message_template->get('MTP_content')
1331 1331
 						: '';
@@ -1338,10 +1338,10 @@  discard block
 block discarded – undo
1338 1338
 
1339 1339
 					$template_form_fields[$field_id]['db-col'] = 'MTP_content';
1340 1340
 					$css_class = isset($field_setup_array['css_class']) ? $field_setup_array['css_class'] : '';
1341
-					$template_form_fields[$field_id]['css_class'] =  ! empty( $v_fields )
1342
-																	 && in_array( $template_field, $v_fields )
1343
-																	 && isset( $validators[$template_field]['msg'] )
1344
-						? 'validate-error ' . $css_class
1341
+					$template_form_fields[$field_id]['css_class'] = ! empty($v_fields)
1342
+																	 && in_array($template_field, $v_fields)
1343
+																	 && isset($validators[$template_field]['msg'])
1344
+						? 'validate-error '.$css_class
1345 1345
 						: $css_class;
1346 1346
 
1347 1347
 					//shortcode selector
@@ -1352,12 +1352,12 @@  discard block
 block discarded – undo
1352 1352
 
1353 1353
 				//k took care of content field(s) now let's take care of others.
1354 1354
 
1355
-				$templatefield_MTP_id = $template_field . '-MTP_ID';
1356
-				$templatefield_field_templatename_id = $template_field . '-name';
1355
+				$templatefield_MTP_id = $template_field.'-MTP_ID';
1356
+				$templatefield_field_templatename_id = $template_field.'-name';
1357 1357
 
1358 1358
 				//foreach template field there are actually two form fields created
1359 1359
 				$template_form_fields[$templatefield_MTP_id] = array(
1360
-					'name' => 'MTP_template_fields[' . $template_field . '][MTP_ID]',
1360
+					'name' => 'MTP_template_fields['.$template_field.'][MTP_ID]',
1361 1361
 					'label' => null,
1362 1362
 					'input' => 'hidden',
1363 1363
 					'type' => 'int',
@@ -1370,7 +1370,7 @@  discard block
 block discarded – undo
1370 1370
 				);
1371 1371
 
1372 1372
 				$template_form_fields[$templatefield_field_templatename_id] = array(
1373
-					'name' => 'MTP_template_fields[' . $template_field . '][name]',
1373
+					'name' => 'MTP_template_fields['.$template_field.'][name]',
1374 1374
 					'label' => null,
1375 1375
 					'input' => 'hidden',
1376 1376
 					'type' => 'string',
@@ -1514,13 +1514,13 @@  discard block
 block discarded – undo
1514 1514
 				'value' => $GRP_ID
1515 1515
 				);
1516 1516
 			$sidebar_form_fields['ee-msg-evt-nonce'] = array(
1517
-				'name' => $action . '_nonce',
1517
+				'name' => $action.'_nonce',
1518 1518
 				'input' => 'hidden',
1519 1519
 				'type' => 'string',
1520
-				'value' => wp_create_nonce( $action . '_nonce')
1520
+				'value' => wp_create_nonce($action.'_nonce')
1521 1521
 				);
1522 1522
 
1523
-			if ( isset($this->_req_data['template_switch']) && $this->_req_data['template_switch'] ) {
1523
+			if (isset($this->_req_data['template_switch']) && $this->_req_data['template_switch']) {
1524 1524
 				$sidebar_form_fields['ee-msg-template-switch'] = array(
1525 1525
 					'name' => 'template_switch',
1526 1526
 					'input' => 'hidden',
@@ -1530,8 +1530,8 @@  discard block
 block discarded – undo
1530 1530
 			}
1531 1531
 
1532 1532
 
1533
-			$template_fields = $this->_generate_admin_form_fields( $template_form_fields );
1534
-			$sidebar_fields = $this->_generate_admin_form_fields( $sidebar_form_fields );
1533
+			$template_fields = $this->_generate_admin_form_fields($template_form_fields);
1534
+			$sidebar_fields = $this->_generate_admin_form_fields($sidebar_form_fields);
1535 1535
 
1536 1536
 
1537 1537
 		} //end if ( !empty($template_field_structure) )
@@ -1543,7 +1543,7 @@  discard block
 block discarded – undo
1543 1543
 			 $GRP_ID,
1544 1544
 			 false,
1545 1545
 			 add_query_arg(
1546
-			    array( 'action' => 'global_mtps' ),
1546
+			    array('action' => 'global_mtps'),
1547 1547
 			    $this->_admin_base_url
1548 1548
 			 )
1549 1549
 		);
@@ -1559,7 +1559,7 @@  discard block
 block discarded – undo
1559 1559
 			),
1560 1560
 			$this->_admin_base_url
1561 1561
 		);
1562
-		$preview_button = '<a href="' . $preview_url . '" class="button-secondary messages-preview-button">' . __('Preview', 'event_espresso') . '</a>';
1562
+		$preview_button = '<a href="'.$preview_url.'" class="button-secondary messages-preview-button">'.__('Preview', 'event_espresso').'</a>';
1563 1563
 
1564 1564
 
1565 1565
 		//setup context switcher
@@ -1587,17 +1587,17 @@  discard block
 block discarded – undo
1587 1587
 		$this->_template_args['after_admin_page_content'] = $this->_add_form_element_after();
1588 1588
 
1589 1589
 		$this->_template_path = $this->_template_args['GRP_ID']
1590
-			? EE_MSG_TEMPLATE_PATH . 'ee_msg_details_main_edit_meta_box.template.php'
1591
-			: EE_MSG_TEMPLATE_PATH . 'ee_msg_details_main_add_meta_box.template.php';
1590
+			? EE_MSG_TEMPLATE_PATH.'ee_msg_details_main_edit_meta_box.template.php'
1591
+			: EE_MSG_TEMPLATE_PATH.'ee_msg_details_main_add_meta_box.template.php';
1592 1592
 
1593 1593
 		//send along EE_Message_Template_Group object for further template use.
1594 1594
 		$this->_template_args['MTP'] = $message_template_group;
1595 1595
 
1596
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( $this->_template_path, $this->_template_args, true );
1596
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, $this->_template_args, true);
1597 1597
 
1598 1598
 
1599 1599
 		//finally, let's set the admin_page title
1600
-		$this->_admin_page_title = sprintf( __('Editing %s', 'event_espresso'), $title );
1600
+		$this->_admin_page_title = sprintf(__('Editing %s', 'event_espresso'), $title);
1601 1601
 
1602 1602
 
1603 1603
 		//we need to take care of setting the shortcodes property for use elsewhere.
@@ -1610,7 +1610,7 @@  discard block
 block discarded – undo
1610 1610
 	}
1611 1611
 
1612 1612
 
1613
-	public function filter_tinymce_init( $mceInit, $editor_id ) {
1613
+	public function filter_tinymce_init($mceInit, $editor_id) {
1614 1614
 		return $mceInit;
1615 1615
 	}
1616 1616
 
@@ -1621,7 +1621,7 @@  discard block
 block discarded – undo
1621 1621
 	}
1622 1622
 
1623 1623
 	public function _add_form_element_before() {
1624
-		return '<form method="post" action="' . $this->_template_args["edit_message_template_form_url"] . '" id="ee-msg-edit-frm">';
1624
+		return '<form method="post" action="'.$this->_template_args["edit_message_template_form_url"].'" id="ee-msg-edit-frm">';
1625 1625
 	}
1626 1626
 
1627 1627
 	public function _add_form_element_after() {
@@ -1638,25 +1638,25 @@  discard block
 block discarded – undo
1638 1638
 	 *
1639 1639
 	 */
1640 1640
 	public function switch_template_pack() {
1641
-		$GRP_ID = ! empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : 0;
1642
-		$template_pack = ! empty( $this->_req_data['template_pack'] ) ? $this->_req_data['template_pack'] : '';
1641
+		$GRP_ID = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0;
1642
+		$template_pack = ! empty($this->_req_data['template_pack']) ? $this->_req_data['template_pack'] : '';
1643 1643
 
1644 1644
 		//verify we have needed values.
1645
-		if ( empty( $GRP_ID ) || empty( $template_pack ) ) {
1645
+		if (empty($GRP_ID) || empty($template_pack)) {
1646 1646
 			$this->_template_args['error'] = true;
1647
-			EE_Error::add_error( __('The required date for switching templates is not available.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__  );
1647
+			EE_Error::add_error(__('The required date for switching templates is not available.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1648 1648
 		} else {
1649 1649
 			//get template, set the new template_pack and then reset to default
1650 1650
 			/** @type EE_Message_Template_Group $message_template_group */
1651
-			$message_template_group = EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID );
1651
+			$message_template_group = EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID);
1652 1652
 
1653
-			$message_template_group->set_template_pack_name( $template_pack );
1653
+			$message_template_group->set_template_pack_name($template_pack);
1654 1654
 			$this->_req_data['msgr'] = $message_template_group->messenger();
1655 1655
 			$this->_req_data['mt'] = $message_template_group->message_type();
1656 1656
 
1657 1657
 			$query_args = $this->_reset_to_default_template();
1658 1658
 
1659
-			if ( empty( $query_args['id'] ) ) {
1659
+			if (empty($query_args['id'])) {
1660 1660
 				EE_Error::add_error(
1661 1661
 					__(
1662 1662
 						'Something went wrong with switching the template pack. Please try again or contact EE support',
@@ -1666,7 +1666,7 @@  discard block
 block discarded – undo
1666 1666
 				);
1667 1667
 				$this->_template_args['error'] = true;
1668 1668
 			} else {
1669
-				$template_label =$message_template_group->get_template_pack()->label;
1669
+				$template_label = $message_template_group->get_template_pack()->label;
1670 1670
 				$template_pack_labels = $message_template_group->messenger_obj()->get_supports_labels();
1671 1671
 				EE_Error::add_success(
1672 1672
 					sprintf(
@@ -1679,7 +1679,7 @@  discard block
 block discarded – undo
1679 1679
 					)
1680 1680
 				);
1681 1681
 				//generate the redirect url for js.
1682
-				$url = self::add_query_args_and_nonce( $query_args, $this->_admin_base_url );
1682
+				$url = self::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1683 1683
 				$this->_template_args['data']['redirect_url'] = $url;
1684 1684
 				$this->_template_args['success'] = true;
1685 1685
 			}
@@ -1701,9 +1701,9 @@  discard block
 block discarded – undo
1701 1701
 	protected function _reset_to_default_template() {
1702 1702
 
1703 1703
 		$templates = array();
1704
-		$GRP_ID = !empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : 0;
1704
+		$GRP_ID = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0;
1705 1705
 		//we need to make sure we've got the info we need.
1706
-		if ( ! isset( $this->_req_data['msgr'], $this->_req_data['mt'], $this->_req_data['GRP_ID'] ) ) {
1706
+		if ( ! isset($this->_req_data['msgr'], $this->_req_data['mt'], $this->_req_data['GRP_ID'])) {
1707 1707
 			EE_Error::add_error(
1708 1708
 				__(
1709 1709
 					'In order to reset the template to its default we require the messenger, message type, and message template GRP_ID to know what is being reset.  At least one of these is missing.',
@@ -1715,9 +1715,9 @@  discard block
 block discarded – undo
1715 1715
 
1716 1716
 		// all templates will be reset to whatever the defaults are
1717 1717
 		// for the global template matching the messenger and message type.
1718
-		$success = !empty( $GRP_ID ) ? true : false;
1718
+		$success = ! empty($GRP_ID) ? true : false;
1719 1719
 
1720
-		if ( $success ) {
1720
+		if ($success) {
1721 1721
 
1722 1722
 			//let's first determine if the incoming template is a global template,
1723 1723
 			// if it isn't then we need to get the global template matching messenger and message type.
@@ -1725,9 +1725,9 @@  discard block
 block discarded – undo
1725 1725
 
1726 1726
 
1727 1727
 			//note this is ONLY deleting the template fields (Message Template rows) NOT the message template group.
1728
-			$success = $this->_delete_mtp_permanently( $GRP_ID, false );
1728
+			$success = $this->_delete_mtp_permanently($GRP_ID, false);
1729 1729
 
1730
-			if ( $success ) {
1730
+			if ($success) {
1731 1731
 				// if successfully deleted, lets generate the new ones.
1732 1732
 				// Note. We set GLOBAL to true, because resets on ANY template
1733 1733
 				// will use the related global template defaults for regeneration.
@@ -1745,32 +1745,32 @@  discard block
 block discarded – undo
1745 1745
 		}
1746 1746
 
1747 1747
 		//any error messages?
1748
-		if ( !$success ) {
1748
+		if ( ! $success) {
1749 1749
 			EE_Error::add_error(
1750
-				__( 'Something went wrong with deleting existing templates. Unable to reset to default', 'event_espresso' ),
1750
+				__('Something went wrong with deleting existing templates. Unable to reset to default', 'event_espresso'),
1751 1751
 				__FILE__, __FUNCTION__, __LINE__
1752 1752
 			);
1753 1753
 		}
1754 1754
 
1755 1755
 		//all good, let's add a success message!
1756
-		if ( $success && ! empty( $templates ) ) {
1756
+		if ($success && ! empty($templates)) {
1757 1757
 			$templates = $templates[0]; //the info for the template we generated is the first element in the returned array.
1758 1758
 			EE_Error::overwrite_success();
1759
-			EE_Error::add_success( __('Templates have been reset to defaults.', 'event_espresso') );
1759
+			EE_Error::add_success(__('Templates have been reset to defaults.', 'event_espresso'));
1760 1760
 		}
1761 1761
 
1762 1762
 
1763 1763
 		$query_args = array(
1764
-			'id' => isset( $templates['GRP_ID'] ) ? $templates['GRP_ID'] : null,
1765
-			'context' => isset( $templates['MTP_context'] ) ? $templates['MTP_context'] : null,
1766
-			'action' => isset( $templates['GRP_ID'] ) ? 'edit_message_template' : 'global_mtps'
1764
+			'id' => isset($templates['GRP_ID']) ? $templates['GRP_ID'] : null,
1765
+			'context' => isset($templates['MTP_context']) ? $templates['MTP_context'] : null,
1766
+			'action' => isset($templates['GRP_ID']) ? 'edit_message_template' : 'global_mtps'
1767 1767
 			);
1768 1768
 
1769 1769
 		//if called via ajax then we return query args otherwise redirect
1770
-		if ( defined('DOING_AJAX') && DOING_AJAX ) {
1770
+		if (defined('DOING_AJAX') && DOING_AJAX) {
1771 1771
 			return $query_args;
1772 1772
 		} else {
1773
-			$this->_redirect_after_action( false, '', '', $query_args, true );
1773
+			$this->_redirect_after_action(false, '', '', $query_args, true);
1774 1774
 			return null;
1775 1775
 		}
1776 1776
 	}
@@ -1783,7 +1783,7 @@  discard block
 block discarded – undo
1783 1783
 	 * @param bool $send if TRUE then we are doing an actual TEST send with the results of the preview.
1784 1784
 	 * @return string
1785 1785
 	 */
1786
-	public function _preview_message( $send = false ) {
1786
+	public function _preview_message($send = false) {
1787 1787
 		//first make sure we've got the necessary parameters
1788 1788
 		if (
1789 1789
 			! isset(
@@ -1799,13 +1799,13 @@  discard block
 block discarded – undo
1799 1799
 			);
1800 1800
 		}
1801 1801
 
1802
-		EE_Registry::instance()->REQ->set( 'GRP_ID', $this->_req_data['GRP_ID'] );
1802
+		EE_Registry::instance()->REQ->set('GRP_ID', $this->_req_data['GRP_ID']);
1803 1803
 
1804 1804
 
1805 1805
 		//get the preview!
1806
-		$preview = EED_Messages::preview_message( $this->_req_data['message_type'], $this->_req_data['context'], $this->_req_data['messenger'], $send );
1806
+		$preview = EED_Messages::preview_message($this->_req_data['message_type'], $this->_req_data['context'], $this->_req_data['messenger'], $send);
1807 1807
 
1808
-		if ( $send ) {
1808
+		if ($send) {
1809 1809
 			return $preview;
1810 1810
 		}
1811 1811
 
@@ -1815,22 +1815,22 @@  discard block
 block discarded – undo
1815 1815
 			'context' => $this->_req_data['context'],
1816 1816
 			'action' => 'edit_message_template'
1817 1817
 			);
1818
-		$go_back_url = parent::add_query_args_and_nonce( $query_args, $this->_admin_base_url );
1819
-		$preview_button = '<a href="' . $go_back_url . '" class="button-secondary messages-preview-go-back-button">' . __('Go Back to Edit', 'event_espresso') . '</a>';
1818
+		$go_back_url = parent::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1819
+		$preview_button = '<a href="'.$go_back_url.'" class="button-secondary messages-preview-go-back-button">'.__('Go Back to Edit', 'event_espresso').'</a>';
1820 1820
 		$message_types = $this->get_installed_message_types();
1821
-		$active_messenger = $this->_message_resource_manager->get_active_messenger( $this->_req_data['messenger'] );
1821
+		$active_messenger = $this->_message_resource_manager->get_active_messenger($this->_req_data['messenger']);
1822 1822
 		$active_messenger_label = $active_messenger instanceof EE_messenger
1823
-			? ucwords( $active_messenger->label['singular'] )
1824
-			: esc_html__( 'Unknown Messenger', 'event_espresso' );
1823
+			? ucwords($active_messenger->label['singular'])
1824
+			: esc_html__('Unknown Messenger', 'event_espresso');
1825 1825
 		//let's provide a helpful title for context
1826 1826
 		$preview_title = sprintf(
1827
-			__( 'Viewing Preview for %s %s Message Template', 'event_espresso' ),
1827
+			__('Viewing Preview for %s %s Message Template', 'event_espresso'),
1828 1828
 			$active_messenger_label,
1829
-			ucwords( $message_types[ $this->_req_data[ 'message_type' ] ]->label[ 'singular' ] )
1829
+			ucwords($message_types[$this->_req_data['message_type']]->label['singular'])
1830 1830
 		);
1831 1831
 		//setup display of preview.
1832 1832
 		$this->_admin_page_title = $preview_title;
1833
-		$this->_template_args['admin_page_content'] = $preview_button . '<br />' .stripslashes($preview);
1833
+		$this->_template_args['admin_page_content'] = $preview_button.'<br />'.stripslashes($preview);
1834 1834
 		$this->_template_args['data']['force_json'] = true;
1835 1835
 		return '';
1836 1836
 	}
@@ -1860,9 +1860,9 @@  discard block
 block discarded – undo
1860 1860
 	 * @return void
1861 1861
 	 */
1862 1862
 	protected function _register_edit_meta_boxes() {
1863
-		add_meta_box( 'mtp_valid_shortcodes', __('Valid Shortcodes', 'event_espresso'), array( $this, 'shortcode_meta_box' ), $this->_current_screen->id, 'side', 'default' );
1864
-		add_meta_box( 'mtp_extra_actions', __('Extra Actions', 'event_espresso'), array( $this, 'extra_actions_meta_box' ), $this->_current_screen->id, 'side', 'high' );
1865
-		add_meta_box( 'mtp_templates', __('Template Styles', 'event_espresso'), array( $this, 'template_pack_meta_box' ), $this->_current_screen->id, 'side', 'high' );
1863
+		add_meta_box('mtp_valid_shortcodes', __('Valid Shortcodes', 'event_espresso'), array($this, 'shortcode_meta_box'), $this->_current_screen->id, 'side', 'default');
1864
+		add_meta_box('mtp_extra_actions', __('Extra Actions', 'event_espresso'), array($this, 'extra_actions_meta_box'), $this->_current_screen->id, 'side', 'high');
1865
+		add_meta_box('mtp_templates', __('Template Styles', 'event_espresso'), array($this, 'template_pack_meta_box'), $this->_current_screen->id, 'side', 'high');
1866 1866
 	}
1867 1867
 
1868 1868
 
@@ -1881,14 +1881,14 @@  discard block
 block discarded – undo
1881 1881
 
1882 1882
 		$tp_select_values = array();
1883 1883
 
1884
-		foreach ( $tp_collection as $tp ) {
1884
+		foreach ($tp_collection as $tp) {
1885 1885
 			//only include template packs that support this messenger and message type!
1886 1886
 			$supports = $tp->get_supports();
1887 1887
 			if (
1888
-				! isset( $supports[ $this->_message_template_group->messenger() ] )
1888
+				! isset($supports[$this->_message_template_group->messenger()])
1889 1889
 				|| ! in_array(
1890 1890
 					$this->_message_template_group->message_type(),
1891
-					$supports[ $this->_message_template_group->messenger() ]
1891
+					$supports[$this->_message_template_group->messenger()]
1892 1892
 				)
1893 1893
 			) {
1894 1894
 				//not supported
@@ -1902,7 +1902,7 @@  discard block
 block discarded – undo
1902 1902
 		}
1903 1903
 
1904 1904
 		//if empty $tp_select_values then we make sure default is set because EVERY message type should be supported by the default template pack.  This still allows for the odd template pack to override.
1905
-		if ( empty( $tp_select_values ) ) {
1905
+		if (empty($tp_select_values)) {
1906 1906
 			$tp_select_values[] = array(
1907 1907
 				'text' => __('Default', 'event_espresso'),
1908 1908
 				'id' => 'default'
@@ -1915,14 +1915,14 @@  discard block
 block discarded – undo
1915 1915
 			$this->_message_template_group->message_type()
1916 1916
 		);
1917 1917
 		$variations_select_values = array();
1918
-		foreach ( $variations as $variation => $label ) {
1918
+		foreach ($variations as $variation => $label) {
1919 1919
 			$variations_select_values[] = array(
1920 1920
 				'text' => $label,
1921 1921
 				'id' => $variation
1922 1922
 			);
1923 1923
 		}
1924 1924
 
1925
-		$template_pack_labels= $this->_message_template_group->messenger_obj()->get_supports_labels();
1925
+		$template_pack_labels = $this->_message_template_group->messenger_obj()->get_supports_labels();
1926 1926
 
1927 1927
 		$template_args['template_packs_selector'] = EEH_Form_Fields::select_input(
1928 1928
 			'MTP_template_pack',
@@ -1939,9 +1939,9 @@  discard block
 block discarded – undo
1939 1939
 		$template_args['template_pack_description'] = $template_pack_labels->template_pack_description;
1940 1940
 		$template_args['template_variation_description'] = $template_pack_labels->template_variation_description;
1941 1941
 
1942
-		$template = EE_MSG_TEMPLATE_PATH . 'template_pack_and_variations_metabox.template.php';
1942
+		$template = EE_MSG_TEMPLATE_PATH.'template_pack_and_variations_metabox.template.php';
1943 1943
 
1944
-		EEH_Template::display_template( $template, $template_args );
1944
+		EEH_Template::display_template($template, $template_args);
1945 1945
 	}
1946 1946
 
1947 1947
 
@@ -1965,46 +1965,46 @@  discard block
 block discarded – undo
1965 1965
 		//first we need to see if there are any fields
1966 1966
 		$fields = $this->_message_template_group->messenger_obj()->get_test_settings_fields();
1967 1967
 
1968
-		if ( !empty( $fields ) ) {
1968
+		if ( ! empty($fields)) {
1969 1969
 			//yup there be fields
1970
-			foreach ( $fields as $field => $config ) {
1971
-				$field_id = $this->_message_template_group->messenger() . '_' . $field;
1970
+			foreach ($fields as $field => $config) {
1971
+				$field_id = $this->_message_template_group->messenger().'_'.$field;
1972 1972
 				$existing = $this->_message_template_group->messenger_obj()->get_existing_test_settings();
1973
-				$default = isset( $config['default'] ) ? $config['default'] : '';
1974
-				$default = isset( $config['value'] ) ? $config['value'] : $default;
1973
+				$default = isset($config['default']) ? $config['default'] : '';
1974
+				$default = isset($config['value']) ? $config['value'] : $default;
1975 1975
 
1976 1976
 				// if type is hidden and the value is empty
1977 1977
 				// something may have gone wrong so let's correct with the defaults
1978 1978
 				$fix = $config['input'] === 'hidden' && isset($existing[$field]) && empty($existing[$field])
1979 1979
 					? $default
1980 1980
 					: '';
1981
-				$existing[$field] = isset( $existing[$field] ) && empty( $fix )
1981
+				$existing[$field] = isset($existing[$field]) && empty($fix)
1982 1982
 					? $existing[$field]
1983 1983
 					: $fix;
1984 1984
 
1985 1985
 				$template_form_fields[$field_id] = array(
1986
-					'name'       => 'test_settings_fld[' . $field . ']',
1986
+					'name'       => 'test_settings_fld['.$field.']',
1987 1987
 					'label'      => $config['label'],
1988 1988
 					'input'      => $config['input'],
1989 1989
 					'type'       => $config['type'],
1990 1990
 					'required'   => $config['required'],
1991 1991
 					'validation' => $config['validation'],
1992
-					'value'      => isset( $existing[ $field ] ) ? $existing[ $field ] : $default,
1992
+					'value'      => isset($existing[$field]) ? $existing[$field] : $default,
1993 1993
 					'css_class'  => $config['css_class'],
1994
-					'options'    => isset( $config['options'] ) ? $config['options'] : array(),
1994
+					'options'    => isset($config['options']) ? $config['options'] : array(),
1995 1995
 					'default'    => $default,
1996 1996
 					'format'     => $config['format']
1997 1997
 				);
1998 1998
 			}
1999 1999
 		}
2000 2000
 
2001
-		$test_settings_fields = !empty( $template_form_fields)
2002
-			? $this->_generate_admin_form_fields( $template_form_fields, 'string', 'ee_tst_settings_flds' )
2001
+		$test_settings_fields = ! empty($template_form_fields)
2002
+			? $this->_generate_admin_form_fields($template_form_fields, 'string', 'ee_tst_settings_flds')
2003 2003
 			: '';
2004 2004
 
2005 2005
 		$test_settings_html = '';
2006 2006
 		//print out $test_settings_fields
2007
-		if ( !empty( $test_settings_fields ) ) {
2007
+		if ( ! empty($test_settings_fields)) {
2008 2008
 			echo $test_settings_fields;
2009 2009
 			$test_settings_html = '<input type="submit" class="button-primary mtp-test-button alignright" ';
2010 2010
 			$test_settings_html .= 'name="test_button" value="';
@@ -2013,7 +2013,7 @@  discard block
 block discarded – undo
2013 2013
 		}
2014 2014
 
2015 2015
 		//and button
2016
-		$test_settings_html .= '<p>' . __('Need to reset this message type and start over?', 'event_espresso') . '</p>';
2016
+		$test_settings_html .= '<p>'.__('Need to reset this message type and start over?', 'event_espresso').'</p>';
2017 2017
 		$test_settings_html .= '<div class="publishing-action alignright resetbutton">';
2018 2018
 		$test_settings_html .= $this->get_action_link_or_button(
2019 2019
 			'reset_to_default',
@@ -2037,13 +2037,13 @@  discard block
 block discarded – undo
2037 2037
      * @param string $linked_input_id The css id of the input that the shortcodes get added to.
2038 2038
      * @return string
2039 2039
     */
2040
-	protected function _get_shortcode_selector( $field, $linked_input_id ) {
2040
+	protected function _get_shortcode_selector($field, $linked_input_id) {
2041 2041
 		$template_args = array(
2042
-			'shortcodes' => $this->_get_shortcodes( array( $field ), true ),
2042
+			'shortcodes' => $this->_get_shortcodes(array($field), true),
2043 2043
 			'fieldname' => $field,
2044 2044
 			'linked_input_id' => $linked_input_id
2045 2045
 		);
2046
-		return EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'shortcode_selector_skeleton.template.php', $template_args, true );
2046
+		return EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'shortcode_selector_skeleton.template.php', $template_args, true);
2047 2047
 	}
2048 2048
 
2049 2049
 
@@ -2058,13 +2058,13 @@  discard block
 block discarded – undo
2058 2058
 		$shortcodes = $this->_get_shortcodes(array(), false); //just make sure shortcodes property is set
2059 2059
 		//$messenger = $this->_message_template_group->messenger_obj();
2060 2060
 		//now let's set the content depending on the status of the shortcodes array
2061
-		if ( empty( $shortcodes ) ) {
2062
-			$content = '<p>' . __('There are no valid shortcodes available', 'event_espresso') . '</p>';
2061
+		if (empty($shortcodes)) {
2062
+			$content = '<p>'.__('There are no valid shortcodes available', 'event_espresso').'</p>';
2063 2063
 			echo $content;
2064 2064
 		} else {
2065 2065
 			//$alt = 0;
2066 2066
 			?>
2067
-			<div style="float:right; margin-top:10px"><?php echo $this->_get_help_tab_link('message_template_shortcodes'); ?></div><p class="small-text"><?php printf( __('You can view the shortcodes usable in your template by clicking the %s icon next to each field.', 'event_espresso' ), '<span class="dashicons dashicons-menu"></span>' ); ?></p>
2067
+			<div style="float:right; margin-top:10px"><?php echo $this->_get_help_tab_link('message_template_shortcodes'); ?></div><p class="small-text"><?php printf(__('You can view the shortcodes usable in your template by clicking the %s icon next to each field.', 'event_espresso'), '<span class="dashicons dashicons-menu"></span>'); ?></p>
2068 2068
 			<?php
2069 2069
 		}
2070 2070
 
@@ -2081,7 +2081,7 @@  discard block
 block discarded – undo
2081 2081
 	protected function _set_shortcodes() {
2082 2082
 
2083 2083
 		//no need to run this if the property is already set
2084
-		if ( !empty($this->_shortcodes ) ) {return;}
2084
+		if ( ! empty($this->_shortcodes)) {return; }
2085 2085
 
2086 2086
 		$this->_shortcodes = $this->_get_shortcodes();
2087 2087
 	}
@@ -2103,14 +2103,14 @@  discard block
 block discarded – undo
2103 2103
 	 * @return array          Shortcodes indexed by fieldname and the an array of shortcode/label pairs OR if merged is true
2104 2104
 	 *                       just an array of shortcode/label pairs.
2105 2105
 	 */
2106
-	protected function _get_shortcodes( $fields = array(), $merged = true ) {
2106
+	protected function _get_shortcodes($fields = array(), $merged = true) {
2107 2107
 		$this->_set_message_template_group();
2108 2108
 
2109 2109
 		//we need the messenger and message template to retrieve the valid shortcodes array.
2110
-		$GRP_ID = isset( $this->_req_data['id'] ) && !empty( $this->_req_data['id'] ) ? absint( $this->_req_data['id'] ) : false;
2111
-		$context = isset( $this->_req_data['context'] ) ? $this->_req_data['context'] : key( $this->_message_template_group->contexts_config() );
2110
+		$GRP_ID = isset($this->_req_data['id']) && ! empty($this->_req_data['id']) ? absint($this->_req_data['id']) : false;
2111
+		$context = isset($this->_req_data['context']) ? $this->_req_data['context'] : key($this->_message_template_group->contexts_config());
2112 2112
 
2113
-		return !empty($GRP_ID) ? $this->_message_template_group->get_shortcodes( $context, $fields, $merged ) : array();
2113
+		return ! empty($GRP_ID) ? $this->_message_template_group->get_shortcodes($context, $fields, $merged) : array();
2114 2114
 	}
2115 2115
 
2116 2116
 
@@ -2123,19 +2123,19 @@  discard block
 block discarded – undo
2123 2123
 	 */
2124 2124
 	protected function _set_message_template_group() {
2125 2125
 
2126
-		if ( !empty( $this->_message_template_group ) )
2127
-			{return;} //get out if this is already set.
2126
+		if ( ! empty($this->_message_template_group))
2127
+			{return; } //get out if this is already set.
2128 2128
 
2129
-		$GRP_ID =  ! empty( $this->_req_data['GRP_ID'] ) ? absint( $this->_req_data['GRP_ID'] ) : false;
2130
-		$GRP_ID = empty( $GRP_ID ) && ! empty( $this->_req_data['id'] ) ? $this->_req_data['id'] : $GRP_ID;
2129
+		$GRP_ID = ! empty($this->_req_data['GRP_ID']) ? absint($this->_req_data['GRP_ID']) : false;
2130
+		$GRP_ID = empty($GRP_ID) && ! empty($this->_req_data['id']) ? $this->_req_data['id'] : $GRP_ID;
2131 2131
 
2132 2132
 		//let's get the message templates
2133 2133
 		$MTP = EEM_Message_Template_Group::instance();
2134 2134
 
2135
-		if ( empty($GRP_ID) )
2136
-			{$this->_message_template_group = $MTP->create_default_object();}
2135
+		if (empty($GRP_ID))
2136
+			{$this->_message_template_group = $MTP->create_default_object(); }
2137 2137
 		else
2138
-			{$this->_message_template_group = $MTP->get_one_by_ID( $GRP_ID );}
2138
+			{$this->_message_template_group = $MTP->get_one_by_ID($GRP_ID); }
2139 2139
 
2140 2140
 		$this->_template_pack = $this->_message_template_group->get_template_pack();
2141 2141
 		$this->_variation = $this->_message_template_group->get_template_pack_variation();
@@ -2154,7 +2154,7 @@  discard block
 block discarded – undo
2154 2154
 	 * @param array $args various things the context switcher needs.
2155 2155
 	 *
2156 2156
 	 */
2157
-	protected function _set_context_switcher( EE_Message_Template_Group $template_group_object, $args) {
2157
+	protected function _set_context_switcher(EE_Message_Template_Group $template_group_object, $args) {
2158 2158
 		$context_details = $template_group_object->contexts_config();
2159 2159
 		$context_label = $template_group_object->context_label();
2160 2160
 		ob_start();
@@ -2162,20 +2162,20 @@  discard block
 block discarded – undo
2162 2162
 		<div class="ee-msg-switcher-container">
2163 2163
 			<form method="get" action="<?php echo EE_MSG_ADMIN_URL; ?>" id="ee-msg-context-switcher-frm">
2164 2164
 				<?php
2165
-					foreach ( $args as $name => $value ) {
2166
-						if ( $name == 'context' || empty($value) || $name == 'extra' ) {continue;}
2165
+					foreach ($args as $name => $value) {
2166
+						if ($name == 'context' || empty($value) || $name == 'extra') {continue; }
2167 2167
 						?>
2168 2168
 						<input type="hidden" name="<?php echo $name; ?>" value = "<?php echo $value; ?>" />
2169 2169
 						<?php
2170 2170
 					}
2171 2171
 					//setup nonce_url
2172
-					wp_nonce_field($args['action'] . '_nonce', $args['action'] . '_nonce', false);
2172
+					wp_nonce_field($args['action'].'_nonce', $args['action'].'_nonce', false);
2173 2173
 				?>
2174 2174
 				<select name="context">
2175 2175
 					<?php
2176 2176
 					$context_templates = $template_group_object->context_templates();
2177
-					if ( is_array($context_templates) ) :
2178
-							foreach ( $context_templates as $context => $template_fields ) :
2177
+					if (is_array($context_templates)) :
2178
+							foreach ($context_templates as $context => $template_fields) :
2179 2179
 								$checked = ($context == $args['context']) ? 'selected="selected"' : '';
2180 2180
 					?>
2181 2181
 					<option value="<?php echo $context; ?>" <?php echo $checked; ?>>
@@ -2183,7 +2183,7 @@  discard block
 block discarded – undo
2183 2183
 					</option>
2184 2184
 					<?php endforeach; endif; ?>
2185 2185
 				</select>
2186
-				<?php $button_text = sprintf( __('Switch %s', 'event_espresso'), ucwords($context_label['label']) ); ?>
2186
+				<?php $button_text = sprintf(__('Switch %s', 'event_espresso'), ucwords($context_label['label'])); ?>
2187 2187
 				<input id="submit-msg-context-switcher-sbmt" class="button-secondary" type="submit" value="<?php echo $button_text; ?>">
2188 2188
 			</form>
2189 2189
 			<?php echo $args['extra']; ?>
@@ -2210,8 +2210,8 @@  discard block
 block discarded – undo
2210 2210
 	 * @return array
2211 2211
 	 */
2212 2212
 	protected function _set_message_template_column_values($index) {
2213
-		if ( is_array($this->_req_data['MTP_template_fields'][$index]['content'] ) ) {
2214
-			foreach ( $this->_req_data['MTP_template_fields'][$index]['content'] as $field => $value ) {
2213
+		if (is_array($this->_req_data['MTP_template_fields'][$index]['content'])) {
2214
+			foreach ($this->_req_data['MTP_template_fields'][$index]['content'] as $field => $value) {
2215 2215
 				$this->_req_data['MTP_template_fields'][$index]['content'][$field] = $value;
2216 2216
 			}
2217 2217
 		} /*else {
@@ -2220,22 +2220,22 @@  discard block
 block discarded – undo
2220 2220
 
2221 2221
 
2222 2222
 		$set_column_values = array(
2223
-			'MTP_ID'             => absint( $this->_req_data[ 'MTP_template_fields' ][ $index ][ 'MTP_ID' ] ),
2224
-			'GRP_ID'             => absint( $this->_req_data[ 'GRP_ID' ] ),
2225
-			'MTP_user_id'        => absint( $this->_req_data[ 'MTP_user_id' ] ),
2226
-			'MTP_messenger'      => strtolower( $this->_req_data[ 'MTP_messenger' ] ),
2227
-			'MTP_message_type'   => strtolower( $this->_req_data[ 'MTP_message_type' ] ),
2228
-			'MTP_template_field' => strtolower( $this->_req_data[ 'MTP_template_fields' ][ $index ][ 'name' ] ),
2229
-			'MTP_context'        => strtolower( $this->_req_data[ 'MTP_context' ] ),
2230
-			'MTP_content'        => $this->_req_data[ 'MTP_template_fields' ][ $index ][ 'content' ],
2231
-			'MTP_is_global'      => isset( $this->_req_data[ 'MTP_is_global' ] )
2232
-				? absint( $this->_req_data[ 'MTP_is_global' ] )
2223
+			'MTP_ID'             => absint($this->_req_data['MTP_template_fields'][$index]['MTP_ID']),
2224
+			'GRP_ID'             => absint($this->_req_data['GRP_ID']),
2225
+			'MTP_user_id'        => absint($this->_req_data['MTP_user_id']),
2226
+			'MTP_messenger'      => strtolower($this->_req_data['MTP_messenger']),
2227
+			'MTP_message_type'   => strtolower($this->_req_data['MTP_message_type']),
2228
+			'MTP_template_field' => strtolower($this->_req_data['MTP_template_fields'][$index]['name']),
2229
+			'MTP_context'        => strtolower($this->_req_data['MTP_context']),
2230
+			'MTP_content'        => $this->_req_data['MTP_template_fields'][$index]['content'],
2231
+			'MTP_is_global'      => isset($this->_req_data['MTP_is_global'])
2232
+				? absint($this->_req_data['MTP_is_global'])
2233 2233
 				: 0,
2234
-			'MTP_is_override'    => isset( $this->_req_data[ 'MTP_is_override' ] )
2235
-				? absint( $this->_req_data[ 'MTP_is_override' ] )
2234
+			'MTP_is_override'    => isset($this->_req_data['MTP_is_override'])
2235
+				? absint($this->_req_data['MTP_is_override'])
2236 2236
 				: 0,
2237
-			'MTP_deleted'        => absint( $this->_req_data[ 'MTP_deleted' ] ),
2238
-			'MTP_is_active'      => absint( $this->_req_data[ 'MTP_is_active' ] )
2237
+			'MTP_deleted'        => absint($this->_req_data['MTP_deleted']),
2238
+			'MTP_is_active'      => absint($this->_req_data['MTP_is_active'])
2239 2239
 		);
2240 2240
 
2241 2241
 
@@ -2247,36 +2247,36 @@  discard block
 block discarded – undo
2247 2247
 
2248 2248
 
2249 2249
 
2250
-	protected function _insert_or_update_message_template($new = false ) {
2250
+	protected function _insert_or_update_message_template($new = false) {
2251 2251
 
2252
-		do_action ( 'AHEE_log', __FILE__, __FUNCTION__, '');
2252
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2253 2253
 		$success = 0;
2254 2254
 		$override = false;
2255 2255
 
2256 2256
 		//setup notices description
2257
-		$messenger = ! empty( $this->_req_data['MTP_messenger'] )
2258
-			? ucwords( str_replace( '_', ' ', $this->_req_data['MTP_messenger'] ) )
2257
+		$messenger = ! empty($this->_req_data['MTP_messenger'])
2258
+			? ucwords(str_replace('_', ' ', $this->_req_data['MTP_messenger']))
2259 2259
 			: false;
2260 2260
 
2261
-		$message_type = ! empty( $this->_req_data['MTP_message_type'] )
2262
-			? ucwords( str_replace( '_', ' ', $this->_req_data['MTP_message_type'] ) )
2261
+		$message_type = ! empty($this->_req_data['MTP_message_type'])
2262
+			? ucwords(str_replace('_', ' ', $this->_req_data['MTP_message_type']))
2263 2263
 			: false;
2264 2264
 
2265
-		$context = ! empty( $this->_req_data['MTP_context'] )
2266
-			? ucwords( str_replace( '_', ' ', $this->_req_data['MTP_context'] ) )
2265
+		$context = ! empty($this->_req_data['MTP_context'])
2266
+			? ucwords(str_replace('_', ' ', $this->_req_data['MTP_context']))
2267 2267
 			: false;
2268 2268
 
2269
-		$item_desc = $messenger ? $messenger . ' ' . $message_type . ' ' . $context . ' ' : '';
2269
+		$item_desc = $messenger ? $messenger.' '.$message_type.' '.$context.' ' : '';
2270 2270
 		$item_desc .= 'Message Template';
2271 2271
 		$query_args = array();
2272 2272
 		$edit_array = array();
2273 2273
 		$action_desc = '';
2274 2274
 
2275 2275
 		//if this is "new" then we need to generate the default contexts for the selected messenger/message_type for user to edit.
2276
-		if ( $new ) {
2277
-			$GRP_ID = !empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : 0;
2278
-			if ( $edit_array = $this->_generate_new_templates($messenger, $message_type, $GRP_ID ) ) {
2279
-				if ( empty($edit_array) ) {
2276
+		if ($new) {
2277
+			$GRP_ID = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0;
2278
+			if ($edit_array = $this->_generate_new_templates($messenger, $message_type, $GRP_ID)) {
2279
+				if (empty($edit_array)) {
2280 2280
 					$success = 0;
2281 2281
 				} else {
2282 2282
 					$success = 1;
@@ -2295,7 +2295,7 @@  discard block
 block discarded – undo
2295 2295
 
2296 2296
 
2297 2297
 			//run update for each template field in displayed context
2298
-			if ( !isset($this->_req_data['MTP_template_fields']) && empty($this->_req_data['MTP_template_fields'] ) ) {
2298
+			if ( ! isset($this->_req_data['MTP_template_fields']) && empty($this->_req_data['MTP_template_fields'])) {
2299 2299
 				EE_Error::add_error(
2300 2300
 					__('There was a problem saving the template fields from the form because I didn\'t receive any actual template field data.', 'event_espresso'),
2301 2301
 					__FILE__, __FUNCTION__, __LINE__
@@ -2304,25 +2304,25 @@  discard block
 block discarded – undo
2304 2304
 
2305 2305
 			} else {
2306 2306
 				//first validate all fields!
2307
-				$validates = $MTPG->validate($this->_req_data['MTP_template_fields'], $this->_req_data['MTP_context'],  $this->_req_data['MTP_messenger'], $this->_req_data['MTP_message_type']);
2307
+				$validates = $MTPG->validate($this->_req_data['MTP_template_fields'], $this->_req_data['MTP_context'], $this->_req_data['MTP_messenger'], $this->_req_data['MTP_message_type']);
2308 2308
 
2309 2309
 				//if $validate returned error messages (i.e. is_array()) then we need to process them and setup an appropriate response. HMM, dang this isn't correct, $validates will ALWAYS be an array.  WE need to make sure there is no actual error messages in validates.
2310
-				if ( is_array($validates) && !empty($validates) ) {
2310
+				if (is_array($validates) && ! empty($validates)) {
2311 2311
 					//add the transient so when the form loads we know which fields to highlight
2312
-					$this->_add_transient( 'edit_message_template', $validates );
2312
+					$this->_add_transient('edit_message_template', $validates);
2313 2313
 
2314 2314
 					$success = 0;
2315 2315
 
2316 2316
 					//setup notices
2317
-					foreach ( $validates as $field => $error ) {
2318
-						if ( isset($error['msg'] ) ) {
2319
-							EE_Error::add_error( $error['msg'], __FILE__, __FUNCTION__, __LINE__ );
2317
+					foreach ($validates as $field => $error) {
2318
+						if (isset($error['msg'])) {
2319
+							EE_Error::add_error($error['msg'], __FILE__, __FUNCTION__, __LINE__);
2320 2320
 						}
2321 2321
 					}
2322 2322
 
2323 2323
 				} else {
2324 2324
 					$set_column_values = array();
2325
-					foreach ( $this->_req_data['MTP_template_fields'] as $template_field => $content ) {
2325
+					foreach ($this->_req_data['MTP_template_fields'] as $template_field => $content) {
2326 2326
 						$set_column_values = $this->_set_message_template_column_values($template_field);
2327 2327
 
2328 2328
 						$where_cols_n_values = array(
@@ -2335,11 +2335,11 @@  discard block
 block discarded – undo
2335 2335
 							'MTP_context' => $set_column_values['MTP_context'],
2336 2336
 							'MTP_content' => $set_column_values['MTP_content']
2337 2337
 						);
2338
-						if ( $updated = $MTP->update( $message_template_fields, array( $where_cols_n_values ) ) ) {
2339
-							if ( $updated === false ) {
2338
+						if ($updated = $MTP->update($message_template_fields, array($where_cols_n_values))) {
2339
+							if ($updated === false) {
2340 2340
 								EE_Error::add_error(
2341 2341
 									sprintf(
2342
-										__( '%s field was NOT updated for some reason', 'event_espresso' ),
2342
+										__('%s field was NOT updated for some reason', 'event_espresso'),
2343 2343
 										$template_field
2344 2344
 									),
2345 2345
 									__FILE__, __FUNCTION__, __LINE__
@@ -2353,46 +2353,46 @@  discard block
 block discarded – undo
2353 2353
 
2354 2354
 					//we can use the last set_column_values for the MTPG update (because its the same for all of these specific MTPs)
2355 2355
 					$mtpg_fields = array(
2356
-						'MTP_user_id'      => $set_column_values[ 'MTP_user_id' ],
2357
-						'MTP_messenger'    => $set_column_values[ 'MTP_messenger' ],
2358
-						'MTP_message_type' => $set_column_values[ 'MTP_message_type' ],
2359
-						'MTP_is_global'    => $set_column_values[ 'MTP_is_global' ],
2360
-						'MTP_is_override'  => $set_column_values[ 'MTP_is_override' ],
2361
-						'MTP_deleted'      => $set_column_values[ 'MTP_deleted' ],
2362
-						'MTP_is_active'    => $set_column_values[ 'MTP_is_active' ],
2363
-						'MTP_name'         => ! empty( $this->_req_data[ 'ee_msg_non_global_fields' ][ 'MTP_name' ] )
2364
-							? $this->_req_data[ 'ee_msg_non_global_fields' ][ 'MTP_name' ]
2356
+						'MTP_user_id'      => $set_column_values['MTP_user_id'],
2357
+						'MTP_messenger'    => $set_column_values['MTP_messenger'],
2358
+						'MTP_message_type' => $set_column_values['MTP_message_type'],
2359
+						'MTP_is_global'    => $set_column_values['MTP_is_global'],
2360
+						'MTP_is_override'  => $set_column_values['MTP_is_override'],
2361
+						'MTP_deleted'      => $set_column_values['MTP_deleted'],
2362
+						'MTP_is_active'    => $set_column_values['MTP_is_active'],
2363
+						'MTP_name'         => ! empty($this->_req_data['ee_msg_non_global_fields']['MTP_name'])
2364
+							? $this->_req_data['ee_msg_non_global_fields']['MTP_name']
2365 2365
 							: '',
2366
-						'MTP_description'  => ! empty( $this->_req_data[ 'ee_msg_non_global_fields' ][ 'MTP_description' ] )
2367
-							? $this->_req_data[ 'ee_msg_non_global_fields' ][ 'MTP_description' ]
2366
+						'MTP_description'  => ! empty($this->_req_data['ee_msg_non_global_fields']['MTP_description'])
2367
+							? $this->_req_data['ee_msg_non_global_fields']['MTP_description']
2368 2368
 							: ''
2369 2369
 					);
2370 2370
 
2371
-					$mtpg_where = array('GRP_ID' => $set_column_values['GRP_ID'] );
2372
-					$updated = $MTPG->update( $mtpg_fields, array($mtpg_where) );
2371
+					$mtpg_where = array('GRP_ID' => $set_column_values['GRP_ID']);
2372
+					$updated = $MTPG->update($mtpg_fields, array($mtpg_where));
2373 2373
 
2374
-					if ( $updated === false ) {
2374
+					if ($updated === false) {
2375 2375
 						EE_Error::add_error(
2376 2376
 							sprintf(
2377
-								__( 'The Message Template Group (%d) was NOT updated for some reason', 'event_espresso' ),
2378
-								$set_column_values[ 'GRP_ID' ]
2377
+								__('The Message Template Group (%d) was NOT updated for some reason', 'event_espresso'),
2378
+								$set_column_values['GRP_ID']
2379 2379
 							),
2380 2380
 							__FILE__, __FUNCTION__, __LINE__
2381 2381
 						);
2382 2382
 					} else {
2383 2383
 						//k now we need to ensure the template_pack and template_variation fields are set.
2384
-						$template_pack = ! empty( $this->_req_data['MTP_template_pack' ] )
2384
+						$template_pack = ! empty($this->_req_data['MTP_template_pack'])
2385 2385
 							? $this->_req_data['MTP_template_pack']
2386 2386
 							: 'default';
2387 2387
 
2388
-						$template_variation = ! empty( $this->_req_data['MTP_template_variation'] )
2388
+						$template_variation = ! empty($this->_req_data['MTP_template_variation'])
2389 2389
 							? $this->_req_data['MTP_template_variation']
2390 2390
 							: 'default';
2391 2391
 
2392
-						$mtpg_obj = $MTPG->get_one_by_ID( $set_column_values['GRP_ID'] );
2393
-						if ( $mtpg_obj instanceof EE_Message_Template_Group ) {
2394
-							$mtpg_obj->set_template_pack_name( $template_pack );
2395
-							$mtpg_obj->set_template_pack_variation( $template_variation );
2392
+						$mtpg_obj = $MTPG->get_one_by_ID($set_column_values['GRP_ID']);
2393
+						if ($mtpg_obj instanceof EE_Message_Template_Group) {
2394
+							$mtpg_obj->set_template_pack_name($template_pack);
2395
+							$mtpg_obj->set_template_pack_variation($template_variation);
2396 2396
 						}
2397 2397
 						$success = 1;
2398 2398
 					}
@@ -2402,7 +2402,7 @@  discard block
 block discarded – undo
2402 2402
 		}
2403 2403
 
2404 2404
 		//we return things differently if doing ajax
2405
-		if ( defined('DOING_AJAX') && DOING_AJAX ) {
2405
+		if (defined('DOING_AJAX') && DOING_AJAX) {
2406 2406
 			$this->_template_args['success'] = $success;
2407 2407
 			$this->_template_args['error'] = ! $success ? true : false;
2408 2408
 			$this->_template_args['content'] = '';
@@ -2410,9 +2410,9 @@  discard block
 block discarded – undo
2410 2410
 				'grpID' => $edit_array['GRP_ID'],
2411 2411
 				'templateName' => $edit_array['template_name']
2412 2412
 				);
2413
-			if ( $success ) {
2413
+			if ($success) {
2414 2414
 				EE_Error::overwrite_success();
2415
-				EE_Error::add_success( __('The new template has been created and automatically selected for this event.  You can edit the new template by clicking the edit button.  Note before this template is assigned to this event, the event must be saved.', 'event_espresso') );
2415
+				EE_Error::add_success(__('The new template has been created and automatically selected for this event.  You can edit the new template by clicking the edit button.  Note before this template is assigned to this event, the event must be saved.', 'event_espresso'));
2416 2416
 			}
2417 2417
 
2418 2418
 			$this->_return_json();
@@ -2420,13 +2420,13 @@  discard block
 block discarded – undo
2420 2420
 
2421 2421
 
2422 2422
 		//was a test send triggered?
2423
-		if ( isset( $this->_req_data['test_button'] ) ) {
2423
+		if (isset($this->_req_data['test_button'])) {
2424 2424
 			EE_Error::overwrite_success();
2425
-			$this->_do_test_send( $this->_req_data['MTP_context'],  $this->_req_data['MTP_messenger'], $this->_req_data['MTP_message_type'] );
2425
+			$this->_do_test_send($this->_req_data['MTP_context'], $this->_req_data['MTP_messenger'], $this->_req_data['MTP_message_type']);
2426 2426
 			$override = true;
2427 2427
 		}
2428 2428
 
2429
-		if ( empty( $query_args ) ) {
2429
+		if (empty($query_args)) {
2430 2430
 			$query_args = array(
2431 2431
 				'id' => $this->_req_data['GRP_ID'],
2432 2432
 				'context' => $this->_req_data['MTP_context'],
@@ -2434,7 +2434,7 @@  discard block
 block discarded – undo
2434 2434
 				);
2435 2435
 		}
2436 2436
 
2437
-		$this->_redirect_after_action( $success, $item_desc, $action_desc, $query_args, $override );
2437
+		$this->_redirect_after_action($success, $item_desc, $action_desc, $query_args, $override);
2438 2438
 	}
2439 2439
 
2440 2440
 
@@ -2448,28 +2448,28 @@  discard block
 block discarded – undo
2448 2448
 	 * @param  string $message_type message type being tested
2449 2449
 	 *
2450 2450
 	 */
2451
-	protected function _do_test_send( $context, $messenger, $message_type ) {
2451
+	protected function _do_test_send($context, $messenger, $message_type) {
2452 2452
 		//set things up for preview
2453 2453
 		$this->_req_data['messenger'] = $messenger;
2454 2454
 		$this->_req_data['message_type'] = $message_type;
2455 2455
 		$this->_req_data['context'] = $context;
2456
-		$this->_req_data['GRP_ID'] = isset($this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : '';
2457
-		$active_messenger = $this->_message_resource_manager->get_active_messenger( $messenger );
2456
+		$this->_req_data['GRP_ID'] = isset($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : '';
2457
+		$active_messenger = $this->_message_resource_manager->get_active_messenger($messenger);
2458 2458
 
2459 2459
 		//let's save any existing fields that might be required by the messenger
2460 2460
 		if (
2461
-			isset( $this->_req_data['test_settings_fld'] )
2461
+			isset($this->_req_data['test_settings_fld'])
2462 2462
 			&& $active_messenger instanceof EE_messenger
2463 2463
 		) {
2464
-			$active_messenger->set_existing_test_settings( $this->_req_data['test_settings_fld'] );
2464
+			$active_messenger->set_existing_test_settings($this->_req_data['test_settings_fld']);
2465 2465
 		}
2466 2466
 
2467 2467
 		$success = $this->_preview_message(true);
2468 2468
 
2469
-		if ( $success ) {
2470
-			EE_Error::add_success( __('Test message sent', 'event_espresso') );
2469
+		if ($success) {
2470
+			EE_Error::add_success(__('Test message sent', 'event_espresso'));
2471 2471
 		} else {
2472
-			EE_Error::add_error( __('The test message was not sent', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
2472
+			EE_Error::add_error(__('The test message was not sent', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
2473 2473
 		}
2474 2474
 	}
2475 2475
 
@@ -2495,11 +2495,11 @@  discard block
 block discarded – undo
2495 2495
 	protected function _generate_new_templates($messenger, $message_types, $GRP_ID = 0, $global = false) {
2496 2496
 
2497 2497
 		//if no $message_types are given then that's okay... this may be a messenger that just adds shortcodes, so we just don't generate any templates.
2498
-		if ( empty( $message_types ) ) {
2498
+		if (empty($message_types)) {
2499 2499
 			return true;
2500 2500
 		}
2501 2501
 
2502
-		return EEH_MSG_Template::generate_new_templates( $messenger, $message_types, $GRP_ID, $global );
2502
+		return EEH_MSG_Template::generate_new_templates($messenger, $message_types, $GRP_ID, $global);
2503 2503
 	}
2504 2504
 
2505 2505
 
@@ -2515,33 +2515,33 @@  discard block
 block discarded – undo
2515 2515
 	 *
2516 2516
 	 * @return void
2517 2517
 	 */
2518
-	protected function _trash_or_restore_message_template($trash = true, $all = false ) {
2519
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
2518
+	protected function _trash_or_restore_message_template($trash = true, $all = false) {
2519
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2520 2520
 		$MTP = EEM_Message_Template_Group::instance();
2521 2521
 
2522 2522
 		$success = 1;
2523 2523
 
2524 2524
 		//incoming GRP_IDs
2525
-		if ( $all ) {
2525
+		if ($all) {
2526 2526
 			//Checkboxes
2527
-			if ( !empty( $this->_req_data['checkbox'] ) && is_array($this->_req_data['checkbox'] ) ) {
2527
+			if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
2528 2528
 				//if array has more than one element then success message should be plural.
2529 2529
 				//todo: what about nonce?
2530
-				$success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1;
2530
+				$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
2531 2531
 
2532 2532
 				//cycle through checkboxes
2533
-				while ( list( $GRP_ID, $value ) = each ($this->_req_data['checkbox']) ) {
2534
-					$trashed_or_restored = $trash ? $MTP->delete_by_ID( $GRP_ID ) : $MTP->restore_by_ID( $GRP_ID );
2535
-					if ( ! $trashed_or_restored ) {
2533
+				while (list($GRP_ID, $value) = each($this->_req_data['checkbox'])) {
2534
+					$trashed_or_restored = $trash ? $MTP->delete_by_ID($GRP_ID) : $MTP->restore_by_ID($GRP_ID);
2535
+					if ( ! $trashed_or_restored) {
2536 2536
 						$success = 0;
2537 2537
 					}
2538 2538
 				}
2539 2539
 			} else {
2540 2540
 				//grab single GRP_ID and handle
2541
-				$GRP_ID = isset( $this->_req_data['id'] ) ? absint($this->_req_data['id']) : 0;
2542
-				if ( ! empty( $GRP_ID ) ) {
2543
-					$trashed_or_restored = $trash ? $MTP->delete_by_ID( $GRP_ID ) : $MTP->restore_by_ID( $GRP_ID );
2544
-					if ( ! $trashed_or_restored ) {
2541
+				$GRP_ID = isset($this->_req_data['id']) ? absint($this->_req_data['id']) : 0;
2542
+				if ( ! empty($GRP_ID)) {
2543
+					$trashed_or_restored = $trash ? $MTP->delete_by_ID($GRP_ID) : $MTP->restore_by_ID($GRP_ID);
2544
+					if ( ! $trashed_or_restored) {
2545 2545
 						$success = 0;
2546 2546
 					}
2547 2547
 				} else {
@@ -2553,13 +2553,13 @@  discard block
 block discarded – undo
2553 2553
 
2554 2554
 		$action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso');
2555 2555
 
2556
-		$action_desc = !empty( $this->_req_data['template_switch'] ) ? __('switched') : $action_desc;
2556
+		$action_desc = ! empty($this->_req_data['template_switch']) ? __('switched') : $action_desc;
2557 2557
 
2558 2558
 		$item_desc = $all ? _n('Message Template Group', 'Message Template Groups', $success, 'event_espresso') : _n('Message Template Context', 'Message Template Contexts', $success, 'event_espresso');
2559 2559
 
2560
-		$item_desc = !empty( $this->_req_data['template_switch'] ) ? _n('template', 'templates', $success, 'event_espresso') : $item_desc;
2560
+		$item_desc = ! empty($this->_req_data['template_switch']) ? _n('template', 'templates', $success, 'event_espresso') : $item_desc;
2561 2561
 
2562
-		$this->_redirect_after_action( $success, $item_desc, $action_desc, array() );
2562
+		$this->_redirect_after_action($success, $item_desc, $action_desc, array());
2563 2563
 
2564 2564
 	}
2565 2565
 
@@ -2575,24 +2575,24 @@  discard block
 block discarded – undo
2575 2575
 	 * @return void
2576 2576
 	 */
2577 2577
 	protected function _delete_message_template() {
2578
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
2578
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2579 2579
 
2580 2580
 		//checkboxes
2581
-		if ( !empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'] ) ) {
2581
+		if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
2582 2582
 			//if array has more than one element then success message should be plural
2583
-			$success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1;
2583
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
2584 2584
 
2585 2585
 			//cycle through bulk action checkboxes
2586
-			while ( list( $GRP_ID, $value ) = each($this->_req_data['checkbox'] ) ) {
2587
-				$success = $this->_delete_mtp_permanently( $GRP_ID );
2586
+			while (list($GRP_ID, $value) = each($this->_req_data['checkbox'])) {
2587
+				$success = $this->_delete_mtp_permanently($GRP_ID);
2588 2588
 			}
2589 2589
 		} else {
2590 2590
 			//grab single grp_id and delete
2591
-			$GRP_ID = absint($this->_req_data['id'] );
2592
-			$success = $this->_delete_mtp_permanently( $GRP_ID );
2591
+			$GRP_ID = absint($this->_req_data['id']);
2592
+			$success = $this->_delete_mtp_permanently($GRP_ID);
2593 2593
 		}
2594 2594
 
2595
-		$this->_redirect_after_action( $success, 'Message Templates', 'deleted', array() );
2595
+		$this->_redirect_after_action($success, 'Message Templates', 'deleted', array());
2596 2596
 
2597 2597
 	}
2598 2598
 
@@ -2607,20 +2607,20 @@  discard block
 block discarded – undo
2607 2607
 	 *
2608 2608
 	 * @return bool        boolean to indicate the success of the deletes or not.
2609 2609
 	 */
2610
-	private function _delete_mtp_permanently( $GRP_ID, $include_group = true ) {
2610
+	private function _delete_mtp_permanently($GRP_ID, $include_group = true) {
2611 2611
 		$success = 1;
2612 2612
 		$MTPG = EEM_Message_Template_Group::instance();
2613 2613
 		//first let's GET this group
2614
-		$MTG = $MTPG->get_one_by_ID( $GRP_ID );
2614
+		$MTG = $MTPG->get_one_by_ID($GRP_ID);
2615 2615
 		//then delete permanently all the related Message Templates
2616
-		$deleted = $MTG->delete_related_permanently( 'Message_Template' );
2616
+		$deleted = $MTG->delete_related_permanently('Message_Template');
2617 2617
 
2618
-		if ( $deleted === 0 )
2619
-			{$success = 0;}
2618
+		if ($deleted === 0)
2619
+			{$success = 0; }
2620 2620
 
2621 2621
 		//now delete permanently this particular group
2622 2622
 
2623
-		if ( $include_group && ! $MTG->delete_permanently() ) {
2623
+		if ($include_group && ! $MTG->delete_permanently()) {
2624 2624
 			$success = 0;
2625 2625
 		}
2626 2626
 		return $success;
@@ -2638,7 +2638,7 @@  discard block
 block discarded – undo
2638 2638
 	*	@return string
2639 2639
 	*/
2640 2640
 	protected function _learn_more_about_message_templates_link() {
2641
-		return '<a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >' . __('learn more about how message templates works', 'event_espresso') . '</a>';
2641
+		return '<a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >'.__('learn more about how message templates works', 'event_espresso').'</a>';
2642 2642
 	}
2643 2643
 
2644 2644
 
@@ -2656,10 +2656,10 @@  discard block
 block discarded – undo
2656 2656
 
2657 2657
 		$this->_set_m_mt_settings();
2658 2658
 
2659
-		$selected_messenger = isset( $this->_req_data['selected_messenger'] ) ? $this->_req_data['selected_messenger'] : 'email';
2659
+		$selected_messenger = isset($this->_req_data['selected_messenger']) ? $this->_req_data['selected_messenger'] : 'email';
2660 2660
 
2661 2661
 		//let's setup the messenger tabs
2662
-		$this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links( $this->_m_mt_settings['messenger_tabs'], 'messenger_links', '|', $selected_messenger );
2662
+		$this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links($this->_m_mt_settings['messenger_tabs'], 'messenger_links', '|', $selected_messenger);
2663 2663
 		$this->_template_args['before_admin_page_content'] = '<div class="ui-widget ui-helper-clearfix">';
2664 2664
 		$this->_template_args['after_admin_page_content'] = '</div><!-- end .ui-widget -->';
2665 2665
 
@@ -2678,7 +2678,7 @@  discard block
 block discarded – undo
2678 2678
 	 */
2679 2679
 	protected function _set_m_mt_settings() {
2680 2680
 		//first if this is already set then lets get out no need to regenerate data.
2681
-		if ( !empty($this->_m_mt_settings) ) {
2681
+		if ( ! empty($this->_m_mt_settings)) {
2682 2682
 			return;
2683 2683
 		}
2684 2684
 
@@ -2693,10 +2693,10 @@  discard block
 block discarded – undo
2693 2693
 
2694 2694
 		//assemble the array for the _tab_text_links helper
2695 2695
 
2696
-		foreach ( $messengers as $messenger ) {
2696
+		foreach ($messengers as $messenger) {
2697 2697
 			$this->_m_mt_settings['messenger_tabs'][$messenger->name] = array(
2698 2698
 				'label' => ucwords($messenger->label['singular']),
2699
-				'class' => $this->_message_resource_manager->is_messenger_active( $messenger->name ) ? 'messenger-active' : '',
2699
+				'class' => $this->_message_resource_manager->is_messenger_active($messenger->name) ? 'messenger-active' : '',
2700 2700
 				'href' => $messenger->name,
2701 2701
 				'title' => __('Modify this Messenger', 'event_espresso'),
2702 2702
 				'slug' => $messenger->name,
@@ -2706,26 +2706,26 @@  discard block
 block discarded – undo
2706 2706
 
2707 2707
 			$message_types_for_messenger = $messenger->get_valid_message_types();
2708 2708
 
2709
-			foreach ( $message_types as $message_type ) {
2709
+			foreach ($message_types as $message_type) {
2710 2710
 				//first we need to verify that this message type is valid with this messenger. Cause if it isn't then it shouldn't show in either the inactive OR active metabox.
2711
-				if ( ! in_array( $message_type->name, $message_types_for_messenger ) ) {
2711
+				if ( ! in_array($message_type->name, $message_types_for_messenger)) {
2712 2712
 					continue;
2713 2713
 				}
2714 2714
 
2715
-				$a_or_i = $this->_message_resource_manager->is_message_type_active_for_messenger( $messenger->name, $message_type->name ) ? 'active' : 'inactive';
2715
+				$a_or_i = $this->_message_resource_manager->is_message_type_active_for_messenger($messenger->name, $message_type->name) ? 'active' : 'inactive';
2716 2716
 
2717 2717
 				$this->_m_mt_settings['message_type_tabs'][$messenger->name][$a_or_i][$message_type->name] = array(
2718
-					'label'    => ucwords( $message_type->label[ 'singular' ] ),
2719
-					'class'    => 'message-type-' . $a_or_i,
2720
-					'slug_id'  => $message_type->name . '-messagetype-' . $messenger->name,
2721
-					'mt_nonce' => wp_create_nonce( $message_type->name . '_nonce' ),
2722
-					'href'     => 'espresso_' . $message_type->name . '_message_type_settings',
2718
+					'label'    => ucwords($message_type->label['singular']),
2719
+					'class'    => 'message-type-'.$a_or_i,
2720
+					'slug_id'  => $message_type->name.'-messagetype-'.$messenger->name,
2721
+					'mt_nonce' => wp_create_nonce($message_type->name.'_nonce'),
2722
+					'href'     => 'espresso_'.$message_type->name.'_message_type_settings',
2723 2723
 					'title'    => $a_or_i == 'active'
2724
-						? __( 'Drag this message type to the Inactive window to deactivate', 'event_espresso' )
2725
-						: __( 'Drag this message type to the messenger to activate', 'event_espresso' ),
2724
+						? __('Drag this message type to the Inactive window to deactivate', 'event_espresso')
2725
+						: __('Drag this message type to the messenger to activate', 'event_espresso'),
2726 2726
 					'content'  => $a_or_i == 'active'
2727
-						? $this->_message_type_settings_content( $message_type, $messenger, true )
2728
-						: $this->_message_type_settings_content( $message_type, $messenger ),
2727
+						? $this->_message_type_settings_content($message_type, $messenger, true)
2728
+						: $this->_message_type_settings_content($message_type, $messenger),
2729 2729
 					'slug'     => $message_type->name,
2730 2730
 					'active'   => $a_or_i == 'active' ? true : false,
2731 2731
 					'obj'      => $message_type
@@ -2744,34 +2744,34 @@  discard block
 block discarded – undo
2744 2744
 	 *
2745 2745
 	 * @return string                html output for the content
2746 2746
 	 */
2747
-	protected function _message_type_settings_content( $message_type, $messenger, $active = false ) {
2747
+	protected function _message_type_settings_content($message_type, $messenger, $active = false) {
2748 2748
 		//get message type fields
2749 2749
 		$fields = $message_type->get_admin_settings_fields();
2750
-		$settings_template_args['template_form_fields']= '';
2750
+		$settings_template_args['template_form_fields'] = '';
2751 2751
 
2752
-		if ( !empty( $fields ) && $active ) {
2752
+		if ( ! empty($fields) && $active) {
2753 2753
 
2754
-			$existing_settings = $message_type->get_existing_admin_settings( $messenger->name );
2754
+			$existing_settings = $message_type->get_existing_admin_settings($messenger->name);
2755 2755
 
2756
-			foreach( $fields as $fldname => $fldprops ) {
2757
-				$field_id = $messenger->name . '-' . $message_type->name . '-' . $fldname;
2756
+			foreach ($fields as $fldname => $fldprops) {
2757
+				$field_id = $messenger->name.'-'.$message_type->name.'-'.$fldname;
2758 2758
 				$template_form_field[$field_id] = array(
2759
-					'name' => 'message_type_settings[' . $fldname . ']',
2759
+					'name' => 'message_type_settings['.$fldname.']',
2760 2760
 					'label' => $fldprops['label'],
2761 2761
 					'input' => $fldprops['field_type'],
2762 2762
 					'type' => $fldprops['value_type'],
2763 2763
 					'required' => $fldprops['required'],
2764 2764
 					'validation' => $fldprops['validation'],
2765
-					'value' => isset( $existing_settings[$fldname]) ? $existing_settings[$fldname] : $fldprops['default'],
2766
-					'options' => isset( $fldprops['options'] ) ? $fldprops['options'] : array(),
2767
-					'default' => isset( $existing_settings[$fldname] ) ? $existing_settings[$fldname] : $fldprops['default'],
2765
+					'value' => isset($existing_settings[$fldname]) ? $existing_settings[$fldname] : $fldprops['default'],
2766
+					'options' => isset($fldprops['options']) ? $fldprops['options'] : array(),
2767
+					'default' => isset($existing_settings[$fldname]) ? $existing_settings[$fldname] : $fldprops['default'],
2768 2768
 					'css_class' => 'no-drag',
2769 2769
 					'format' => $fldprops['format']
2770 2770
 				);
2771 2771
 			}
2772 2772
 
2773 2773
 
2774
-			$settings_template_args['template_form_fields'] = !empty($template_form_field) ? $this->_generate_admin_form_fields( $template_form_field, 'string', 'ee_mt_activate_form' ) : '';
2774
+			$settings_template_args['template_form_fields'] = ! empty($template_form_field) ? $this->_generate_admin_form_fields($template_form_field, 'string', 'ee_mt_activate_form') : '';
2775 2775
 		}
2776 2776
 
2777 2777
 		$settings_template_args['description'] = $message_type->description;
@@ -2791,13 +2791,13 @@  discard block
 block discarded – undo
2791 2791
 					)
2792 2792
 				);
2793 2793
 
2794
-		$settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields( $settings_template_args['hidden_fields'], 'array' );
2795
-		$settings_template_args['show_form'] = empty( $settings_template_args['template_form_fields'] ) ? ' hidden' : '';
2794
+		$settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields($settings_template_args['hidden_fields'], 'array');
2795
+		$settings_template_args['show_form'] = empty($settings_template_args['template_form_fields']) ? ' hidden' : '';
2796 2796
 
2797 2797
 
2798 2798
 
2799
-		$template = EE_MSG_TEMPLATE_PATH . 'ee_msg_mt_settings_content.template.php';
2800
-		$content = EEH_Template::display_template( $template, $settings_template_args, true );
2799
+		$template = EE_MSG_TEMPLATE_PATH.'ee_msg_mt_settings_content.template.php';
2800
+		$content = EEH_Template::display_template($template, $settings_template_args, true);
2801 2801
 		return $content;
2802 2802
 	}
2803 2803
 
@@ -2814,27 +2814,27 @@  discard block
 block discarded – undo
2814 2814
 		$m_boxes = $mt_boxes = array();
2815 2815
 		$m_template_args = $mt_template_args = array();
2816 2816
 
2817
-		$selected_messenger = isset( $this->_req_data['selected_messenger'] ) ? $this->_req_data['selected_messenger'] : 'email';
2817
+		$selected_messenger = isset($this->_req_data['selected_messenger']) ? $this->_req_data['selected_messenger'] : 'email';
2818 2818
 
2819
-		if ( isset( $this->_m_mt_settings[ 'messenger_tabs' ] ) ) {
2820
-			foreach ( $this->_m_mt_settings[ 'messenger_tabs' ] as $messenger => $tab_array ) {
2821
-				$hide_on_message = $this->_message_resource_manager->is_messenger_active( $messenger ) ? '' : 'hidden';
2822
-				$hide_off_message = $this->_message_resource_manager->is_messenger_active( $messenger ) ? 'hidden' : '';
2819
+		if (isset($this->_m_mt_settings['messenger_tabs'])) {
2820
+			foreach ($this->_m_mt_settings['messenger_tabs'] as $messenger => $tab_array) {
2821
+				$hide_on_message = $this->_message_resource_manager->is_messenger_active($messenger) ? '' : 'hidden';
2822
+				$hide_off_message = $this->_message_resource_manager->is_messenger_active($messenger) ? 'hidden' : '';
2823 2823
 				//messenger meta boxes
2824 2824
 				$active = $selected_messenger == $messenger ? true : false;
2825
-				$active_mt_tabs = isset( $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'active' ] )
2826
-				? $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'active' ]
2825
+				$active_mt_tabs = isset($this->_m_mt_settings['message_type_tabs'][$messenger]['active'])
2826
+				? $this->_m_mt_settings['message_type_tabs'][$messenger]['active']
2827 2827
 				: '';
2828
-				$m_boxes[ $messenger . '_a_box' ] = sprintf(
2829
-				__( '%s Settings', 'event_espresso' ),
2830
-				$tab_array[ 'label' ]
2828
+				$m_boxes[$messenger.'_a_box'] = sprintf(
2829
+				__('%s Settings', 'event_espresso'),
2830
+				$tab_array['label']
2831 2831
 				);
2832
-				$m_template_args[ $messenger . '_a_box' ] = array(
2833
-				'active_message_types'   => ! empty( $active_mt_tabs ) ? $this->_get_mt_tabs( $active_mt_tabs ) : '',
2834
-				'inactive_message_types' => isset( $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'inactive' ] )
2835
-				? $this->_get_mt_tabs( $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'inactive' ] )
2832
+				$m_template_args[$messenger.'_a_box'] = array(
2833
+				'active_message_types'   => ! empty($active_mt_tabs) ? $this->_get_mt_tabs($active_mt_tabs) : '',
2834
+				'inactive_message_types' => isset($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'])
2835
+				? $this->_get_mt_tabs($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'])
2836 2836
 				: '',
2837
-				'content'                => $this->_get_messenger_box_content( $tab_array[ 'obj' ] ),
2837
+				'content'                => $this->_get_messenger_box_content($tab_array['obj']),
2838 2838
 				'hidden'                 => $active ? '' : ' hidden',
2839 2839
 				'hide_on_message'        => $hide_on_message,
2840 2840
 				'messenger'              => $messenger,
@@ -2843,11 +2843,11 @@  discard block
 block discarded – undo
2843 2843
 				// message type meta boxes
2844 2844
 				// (which is really just the inactive container for each messenger
2845 2845
 				// showing inactive message types for that messenger)
2846
-				$mt_boxes[ $messenger . '_i_box' ] = __( 'Inactive Message Types', 'event_espresso' );
2847
-				$mt_template_args[ $messenger . '_i_box' ] = array(
2848
-				'active_message_types'   => ! empty( $active_mt_tabs ) ? $this->_get_mt_tabs( $active_mt_tabs ) : '',
2849
-				'inactive_message_types' => isset( $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'inactive' ] )
2850
-				? $this->_get_mt_tabs( $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'inactive' ] )
2846
+				$mt_boxes[$messenger.'_i_box'] = __('Inactive Message Types', 'event_espresso');
2847
+				$mt_template_args[$messenger.'_i_box'] = array(
2848
+				'active_message_types'   => ! empty($active_mt_tabs) ? $this->_get_mt_tabs($active_mt_tabs) : '',
2849
+				'inactive_message_types' => isset($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'])
2850
+				? $this->_get_mt_tabs($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'])
2851 2851
 				: '',
2852 2852
 				'hidden'                 => $active ? '' : ' hidden',
2853 2853
 				'hide_on_message'        => $hide_on_message,
@@ -2860,15 +2860,15 @@  discard block
 block discarded – undo
2860 2860
 
2861 2861
 
2862 2862
 		//register messenger metaboxes
2863
-		$m_template_path = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_messenger_mt_meta_box.template.php';
2864
-		foreach ( $m_boxes as $box => $label ) {
2865
-			$callback_args = array( 'template_path' => $m_template_path, 'template_args' => $m_template_args[$box] );
2866
-			$msgr = str_replace( '_a_box', '', $box );
2863
+		$m_template_path = EE_MSG_TEMPLATE_PATH.'ee_msg_details_messenger_mt_meta_box.template.php';
2864
+		foreach ($m_boxes as $box => $label) {
2865
+			$callback_args = array('template_path' => $m_template_path, 'template_args' => $m_template_args[$box]);
2866
+			$msgr = str_replace('_a_box', '', $box);
2867 2867
 			add_meta_box(
2868
-				'espresso_' . $msgr . '_settings',
2868
+				'espresso_'.$msgr.'_settings',
2869 2869
 				$label,
2870
-				function( $post, $metabox ) {
2871
-					echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );
2870
+				function($post, $metabox) {
2871
+					echo EEH_Template::display_template($metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE);
2872 2872
 				},
2873 2873
 				$this->_current_screen->id,
2874 2874
 				'normal',
@@ -2878,17 +2878,17 @@  discard block
 block discarded – undo
2878 2878
 		}
2879 2879
 
2880 2880
 		//register message type metaboxes
2881
-		$mt_template_path = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_messenger_meta_box.template.php';
2882
-		foreach ( $mt_boxes as $box => $label ) {
2881
+		$mt_template_path = EE_MSG_TEMPLATE_PATH.'ee_msg_details_messenger_meta_box.template.php';
2882
+		foreach ($mt_boxes as $box => $label) {
2883 2883
 			$callback_args = array(
2884
-				'template_path' => $mt_template_path, 'template_args' => $mt_template_args[ $box ]
2884
+				'template_path' => $mt_template_path, 'template_args' => $mt_template_args[$box]
2885 2885
 			);
2886
-			$mt = str_replace( '_i_box', '', $box );
2886
+			$mt = str_replace('_i_box', '', $box);
2887 2887
 			add_meta_box(
2888
-				'espresso_' . $mt . '_inactive_mts',
2888
+				'espresso_'.$mt.'_inactive_mts',
2889 2889
 				$label,
2890
-				function( $post, $metabox ) {
2891
-					echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );
2890
+				function($post, $metabox) {
2891
+					echo EEH_Template::display_template($metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE);
2892 2892
 				},
2893 2893
 				$this->_current_screen->id,
2894 2894
 				'side',
@@ -2899,11 +2899,11 @@  discard block
 block discarded – undo
2899 2899
 
2900 2900
 		//register metabox for global messages settings but only when on the main site.  On single site installs this will
2901 2901
 		//always result in the metabox showing, on multisite installs the metabox will only show on the main site.
2902
-		if ( is_main_site() ) {
2902
+		if (is_main_site()) {
2903 2903
 			add_meta_box(
2904 2904
 				'espresso_global_message_settings',
2905
-				__( 'Global Message Settings', 'event_espresso' ),
2906
-				array( $this, 'global_messages_settings_metabox_content' ),
2905
+				__('Global Message Settings', 'event_espresso'),
2906
+				array($this, 'global_messages_settings_metabox_content'),
2907 2907
 				$this->_current_screen->id,
2908 2908
 				'normal',
2909 2909
 				'low',
@@ -2923,7 +2923,7 @@  discard block
 block discarded – undo
2923 2923
 	public function global_messages_settings_metabox_content() {
2924 2924
 		$form = $this->_generate_global_settings_form();
2925 2925
 		echo $form->form_open(
2926
-			$this->add_query_args_and_nonce( array( 'action' => 'update_global_settings' ), EE_MSG_ADMIN_URL ),
2926
+			$this->add_query_args_and_nonce(array('action' => 'update_global_settings'), EE_MSG_ADMIN_URL),
2927 2927
 			'POST'
2928 2928
 		)
2929 2929
 		. $form->get_html()
@@ -2936,7 +2936,7 @@  discard block
 block discarded – undo
2936 2936
 	 * @return EE_Form_Section_Proper
2937 2937
 	 */
2938 2938
 	protected function _generate_global_settings_form() {
2939
-		EE_Registry::instance()->load_helper( 'HTML' );
2939
+		EE_Registry::instance()->load_helper('HTML');
2940 2940
 		/** @var EE_Network_Core_Config $network_config */
2941 2941
 		$network_config = EE_Registry::instance()->NET_CFG->core;
2942 2942
 		return new EE_Form_Section_Proper(
@@ -2955,13 +2955,13 @@  discard block
 block discarded – undo
2955 2955
 							),
2956 2956
 							array(
2957 2957
 								'default' => $network_config->do_messages_on_same_request,
2958
-								'html_label_text' => __( 'Generate and send all messages:', 'event_espresso' ),
2959
-								'html_help_text' => __( 'By default the messages system uses a more efficient means of processing messages on separate requests and utilizes the wp-cron scheduling system.  This makes things execute faster for people registering for your events.  However, if the wp-cron system is disabled on your site and there is no alternative in place, then you can change this so messages are always executed on the same request.', 'event_espresso' ),
2958
+								'html_label_text' => __('Generate and send all messages:', 'event_espresso'),
2959
+								'html_help_text' => __('By default the messages system uses a more efficient means of processing messages on separate requests and utilizes the wp-cron scheduling system.  This makes things execute faster for people registering for your events.  However, if the wp-cron system is disabled on your site and there is no alternative in place, then you can change this so messages are always executed on the same request.', 'event_espresso'),
2960 2960
 							)
2961 2961
 						),
2962 2962
 						'update_settings' => new EE_Submit_Input(
2963 2963
 							array(
2964
-								'default' => __( 'Update', 'event_espresso' ),
2964
+								'default' => __('Update', 'event_espresso'),
2965 2965
 								'html_label_text' => '&nbsp'
2966 2966
 							)
2967 2967
 						)
@@ -2980,28 +2980,28 @@  discard block
 block discarded – undo
2980 2980
 		/** @var EE_Network_Core_Config $network_config */
2981 2981
 		$network_config = EE_Registry::instance()->NET_CFG->core;
2982 2982
 		$form = $this->_generate_global_settings_form();
2983
-		if ( $form->was_submitted() ) {
2983
+		if ($form->was_submitted()) {
2984 2984
 			$form->receive_form_submission();
2985
-			if ( $form->is_valid() ) {
2985
+			if ($form->is_valid()) {
2986 2986
 				$valid_data = $form->valid_data();
2987
-				foreach( $valid_data as $property => $value ) {
2988
-					$setter = 'set_' . $property;
2989
-					if ( method_exists( $network_config, $setter ) ) {
2990
-						$network_config->{$setter}( $value );
2987
+				foreach ($valid_data as $property => $value) {
2988
+					$setter = 'set_'.$property;
2989
+					if (method_exists($network_config, $setter)) {
2990
+						$network_config->{$setter}($value);
2991 2991
 					} else if (
2992
-						property_exists( $network_config, $property )
2992
+						property_exists($network_config, $property)
2993 2993
 						&& $network_config->{$property} !== $value
2994 2994
 					) {
2995 2995
 						$network_config->{$property} = $value;
2996 2996
 					}
2997 2997
 				}
2998 2998
 				//only update if the form submission was valid!
2999
-				EE_Registry::instance()->NET_CFG->update_config( true, false );
2999
+				EE_Registry::instance()->NET_CFG->update_config(true, false);
3000 3000
 				EE_Error::overwrite_success();
3001
-				EE_Error::add_success( __( 'Global message settings were updated', 'event_espresso' ) );
3001
+				EE_Error::add_success(__('Global message settings were updated', 'event_espresso'));
3002 3002
 			}
3003 3003
 		}
3004
-		$this->_redirect_after_action( 0, '', '', array( 'action' => 'settings' ), true );
3004
+		$this->_redirect_after_action(0, '', '', array('action' => 'settings'), true);
3005 3005
 	}
3006 3006
 
3007 3007
 
@@ -3012,13 +3012,13 @@  discard block
 block discarded – undo
3012 3012
 	 *
3013 3013
 	 * @return string            html formatted tabs
3014 3014
 	 */
3015
-	protected function _get_mt_tabs( $tab_array ) {
3015
+	protected function _get_mt_tabs($tab_array) {
3016 3016
 		$tab_array = (array) $tab_array;
3017
-		$template = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_mt_settings_tab_item.template.php';
3017
+		$template = EE_MSG_TEMPLATE_PATH.'ee_msg_details_mt_settings_tab_item.template.php';
3018 3018
 		$tabs = '';
3019 3019
 
3020
-		foreach ( $tab_array as $tab ) {
3021
-			$tabs .=  EEH_Template::display_template( $template, $tab, true );
3020
+		foreach ($tab_array as $tab) {
3021
+			$tabs .= EEH_Template::display_template($template, $tab, true);
3022 3022
 		}
3023 3023
 
3024 3024
 		return $tabs;
@@ -3034,29 +3034,29 @@  discard block
 block discarded – undo
3034 3034
 	 *
3035 3035
 	 * @return string            html formatted content
3036 3036
 	 */
3037
-	protected function _get_messenger_box_content( EE_messenger $messenger ) {
3037
+	protected function _get_messenger_box_content(EE_messenger $messenger) {
3038 3038
 
3039 3039
 		$fields = $messenger->get_admin_settings_fields();
3040 3040
 		$settings_template_args['template_form_fields'] = '';
3041 3041
 
3042 3042
 		//is $messenger active?
3043
-		$settings_template_args['active'] = $this->_message_resource_manager->is_messenger_active( $messenger->name );
3043
+		$settings_template_args['active'] = $this->_message_resource_manager->is_messenger_active($messenger->name);
3044 3044
 
3045 3045
 
3046
-		if ( ! empty( $fields ) ) {
3046
+		if ( ! empty($fields)) {
3047 3047
 
3048 3048
 			$existing_settings = $messenger->get_existing_admin_settings();
3049 3049
 
3050
-			foreach( $fields as $fldname => $fldprops ) {
3051
-				$field_id = $messenger->name . '-' . $fldname;
3050
+			foreach ($fields as $fldname => $fldprops) {
3051
+				$field_id = $messenger->name.'-'.$fldname;
3052 3052
 				$template_form_field[$field_id] = array(
3053
-					'name' => 'messenger_settings[' . $field_id . ']',
3053
+					'name' => 'messenger_settings['.$field_id.']',
3054 3054
 					'label' => $fldprops['label'],
3055 3055
 					'input' => $fldprops['field_type'],
3056 3056
 					'type' => $fldprops['value_type'],
3057 3057
 					'required' => $fldprops['required'],
3058 3058
 					'validation' => $fldprops['validation'],
3059
-					'value' => isset( $existing_settings[$field_id])
3059
+					'value' => isset($existing_settings[$field_id])
3060 3060
 						? $existing_settings[$field_id]
3061 3061
 						: $fldprops['default'],
3062 3062
 					'css_class' => '',
@@ -3065,8 +3065,8 @@  discard block
 block discarded – undo
3065 3065
 			}
3066 3066
 
3067 3067
 
3068
-			$settings_template_args['template_form_fields'] = !empty($template_form_field)
3069
-				? $this->_generate_admin_form_fields( $template_form_field, 'string', 'ee_m_activate_form' )
3068
+			$settings_template_args['template_form_fields'] = ! empty($template_form_field)
3069
+				? $this->_generate_admin_form_fields($template_form_field, 'string', 'ee_m_activate_form')
3070 3070
 				: '';
3071 3071
 		}
3072 3072
 
@@ -3083,39 +3083,39 @@  discard block
 block discarded – undo
3083 3083
 			);
3084 3084
 
3085 3085
 		//make sure any active message types that are existing are included in the hidden fields
3086
-		if ( isset( $this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'] ) ) {
3087
-			foreach ( $this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'] as $mt => $values ) {
3086
+		if (isset($this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'])) {
3087
+			foreach ($this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'] as $mt => $values) {
3088 3088
 				$settings_template_args['hidden_fields']['messenger_settings[message_types]['.$mt.']'] = array(
3089 3089
 						'type' => 'hidden',
3090 3090
 						'value' => $mt
3091 3091
 					);
3092 3092
 			}
3093 3093
 		}
3094
-		$settings_template_args[ 'hidden_fields' ] = $this->_generate_admin_form_fields(
3095
-			$settings_template_args[ 'hidden_fields' ],
3094
+		$settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields(
3095
+			$settings_template_args['hidden_fields'],
3096 3096
 			'array'
3097 3097
 		);
3098
-		$active = $this->_message_resource_manager->is_messenger_active( $messenger->name );
3098
+		$active = $this->_message_resource_manager->is_messenger_active($messenger->name);
3099 3099
 
3100 3100
 		$settings_template_args['messenger'] = $messenger->name;
3101 3101
 		$settings_template_args['description'] = $messenger->description;
3102 3102
 		$settings_template_args['show_hide_edit_form'] = $active ? '' : ' hidden';
3103 3103
 
3104 3104
 
3105
-		$settings_template_args['show_hide_edit_form'] = $this->_message_resource_manager->is_messenger_active( $messenger->name )
3105
+		$settings_template_args['show_hide_edit_form'] = $this->_message_resource_manager->is_messenger_active($messenger->name)
3106 3106
 			? $settings_template_args['show_hide_edit_form']
3107 3107
 			: ' hidden';
3108 3108
 
3109
-		$settings_template_args['show_hide_edit_form'] = empty( $settings_template_args['template_form_fields'] )
3109
+		$settings_template_args['show_hide_edit_form'] = empty($settings_template_args['template_form_fields'])
3110 3110
 			? ' hidden'
3111 3111
 			: $settings_template_args['show_hide_edit_form'];
3112 3112
 
3113 3113
 
3114 3114
 		$settings_template_args['on_off_action'] = $active ? 'messenger-off' : 'messenger-on';
3115
-		$settings_template_args['nonce'] = wp_create_nonce('activate_' . $messenger->name . '_toggle_nonce');
3115
+		$settings_template_args['nonce'] = wp_create_nonce('activate_'.$messenger->name.'_toggle_nonce');
3116 3116
 		$settings_template_args['on_off_status'] = $active ? true : false;
3117
-		$template = EE_MSG_TEMPLATE_PATH . 'ee_msg_m_settings_content.template.php';
3118
-		$content = EEH_Template::display_template( $template, $settings_template_args, true);
3117
+		$template = EE_MSG_TEMPLATE_PATH.'ee_msg_m_settings_content.template.php';
3118
+		$content = EEH_Template::display_template($template, $settings_template_args, true);
3119 3119
 		return $content;
3120 3120
 	}
3121 3121
 
@@ -3129,9 +3129,9 @@  discard block
 block discarded – undo
3129 3129
 		$success = true;
3130 3130
 		$this->_prep_default_response_for_messenger_or_message_type_toggle();
3131 3131
 		//let's check that we have required data
3132
-		if ( !isset( $this->_req_data[ 'messenger' ] ) ) {
3132
+		if ( ! isset($this->_req_data['messenger'])) {
3133 3133
 			EE_Error::add_error(
3134
-				__( 'Messenger name needed to toggle activation. None given', 'event_espresso' ),
3134
+				__('Messenger name needed to toggle activation. None given', 'event_espresso'),
3135 3135
 				__FILE__,
3136 3136
 				__FUNCTION__,
3137 3137
 				__LINE__
@@ -3140,14 +3140,14 @@  discard block
 block discarded – undo
3140 3140
 		}
3141 3141
 
3142 3142
 		//do a nonce check here since we're not arriving via a normal route
3143
-		$nonce = isset($this->_req_data[ 'activate_nonce' ]) ? sanitize_text_field( $this->_req_data[ 'activate_nonce'] ) : '';
3144
-		$nonce_ref = 'activate_' . $this->_req_data['messenger'] . '_toggle_nonce';
3143
+		$nonce = isset($this->_req_data['activate_nonce']) ? sanitize_text_field($this->_req_data['activate_nonce']) : '';
3144
+		$nonce_ref = 'activate_'.$this->_req_data['messenger'].'_toggle_nonce';
3145 3145
 
3146
-		$this->_verify_nonce( $nonce, $nonce_ref );
3146
+		$this->_verify_nonce($nonce, $nonce_ref);
3147 3147
 
3148 3148
 
3149 3149
 
3150
-		if ( !isset( $this->_req_data[ 'status' ])) {
3150
+		if ( ! isset($this->_req_data['status'])) {
3151 3151
 			EE_Error::add_error(
3152 3152
 				__(
3153 3153
 					'Messenger status needed to know whether activation or deactivation is happening. No status is given',
@@ -3163,11 +3163,11 @@  discard block
 block discarded – undo
3163 3163
 		//do check to verify we have a valid status.
3164 3164
 		$status = $this->_req_data['status'];
3165 3165
 
3166
-		if ( $status != 'off' && $status != 'on' ) {
3166
+		if ($status != 'off' && $status != 'on') {
3167 3167
 			EE_Error::add_error(
3168 3168
 				sprintf(
3169
-					__( 'The given status (%s) is not valid. Must be "off" or "on"', 'event_espresso' ),
3170
-					$this->_req_data[ 'status' ]
3169
+					__('The given status (%s) is not valid. Must be "off" or "on"', 'event_espresso'),
3170
+					$this->_req_data['status']
3171 3171
 				),
3172 3172
 				__FILE__,
3173 3173
 				__FUNCTION__,
@@ -3176,11 +3176,11 @@  discard block
 block discarded – undo
3176 3176
 			$success = false;
3177 3177
 		}
3178 3178
 
3179
-		if ( $success ) {
3179
+		if ($success) {
3180 3180
 			//made it here?  Stop dawdling then!!
3181 3181
 			$success = $status == 'off'
3182
-				? $this->_deactivate_messenger( $this->_req_data['messenger'] )
3183
-				: $this->_activate_messenger( $this->_req_data['messenger'] );
3182
+				? $this->_deactivate_messenger($this->_req_data['messenger'])
3183
+				: $this->_activate_messenger($this->_req_data['messenger']);
3184 3184
 		}
3185 3185
 
3186 3186
 		$this->_template_args['success'] = $success;
@@ -3203,7 +3203,7 @@  discard block
 block discarded – undo
3203 3203
 		$this->_prep_default_response_for_messenger_or_message_type_toggle();
3204 3204
 
3205 3205
 		//let's make sure we have the necessary data
3206
-		if ( ! isset( $this->_req_data[ 'message_type' ] ) ) {
3206
+		if ( ! isset($this->_req_data['message_type'])) {
3207 3207
 			EE_Error::add_error(
3208 3208
 				__('Message Type name needed to toggle activation. None given', 'event_espresso'),
3209 3209
 				__FILE__, __FUNCTION__, __LINE__
@@ -3211,7 +3211,7 @@  discard block
 block discarded – undo
3211 3211
 			$success = false;
3212 3212
 		}
3213 3213
 
3214
-		if ( ! isset( $this->_req_data[ 'messenger' ] ) ) {
3214
+		if ( ! isset($this->_req_data['messenger'])) {
3215 3215
 			EE_Error::add_error(
3216 3216
 				__('Messenger name needed to toggle activation. None given', 'event_espresso'),
3217 3217
 				__FILE__, __FUNCTION__, __LINE__
@@ -3219,7 +3219,7 @@  discard block
 block discarded – undo
3219 3219
 			$success = false;
3220 3220
 		}
3221 3221
 
3222
-		if ( ! isset( $this->_req_data[ 'status' ])) {
3222
+		if ( ! isset($this->_req_data['status'])) {
3223 3223
 			EE_Error::add_error(
3224 3224
 				__('Messenger status needed to know whether activation or deactivation is happening. No status is given', 'event_espresso'),
3225 3225
 				__FILE__, __FUNCTION__, __LINE__
@@ -3231,7 +3231,7 @@  discard block
 block discarded – undo
3231 3231
 		//do check to verify we have a valid status.
3232 3232
 		$status = $this->_req_data['status'];
3233 3233
 
3234
-		if ( $status != 'activate' && $status != 'deactivate' ) {
3234
+		if ($status != 'activate' && $status != 'deactivate') {
3235 3235
 			EE_Error::add_error(
3236 3236
 				sprintf(
3237 3237
 					__('The given status (%s) is not valid. Must be "active" or "inactive"', 'event_espresso'),
@@ -3244,16 +3244,16 @@  discard block
 block discarded – undo
3244 3244
 
3245 3245
 
3246 3246
 		//do a nonce check here since we're not arriving via a normal route
3247
-		$nonce = isset( $this->_req_data['mt_nonce'] ) ? sanitize_text_field( $this->_req_data['mt_nonce'] ) : '';
3248
-		$nonce_ref = $this->_req_data['message_type'] . '_nonce';
3247
+		$nonce = isset($this->_req_data['mt_nonce']) ? sanitize_text_field($this->_req_data['mt_nonce']) : '';
3248
+		$nonce_ref = $this->_req_data['message_type'].'_nonce';
3249 3249
 
3250
-		$this->_verify_nonce( $nonce, $nonce_ref );
3250
+		$this->_verify_nonce($nonce, $nonce_ref);
3251 3251
 
3252
-		if ( $success ) {
3252
+		if ($success) {
3253 3253
 			//made it here? um, what are you waiting for then?
3254 3254
 			$success = $status == 'deactivate'
3255
-				? $this->_deactivate_message_type_for_messenger( $this->_req_data['messenger'], $this->_req_data['message_type'] )
3256
-				: $this->_activate_message_type_for_messenger( $this->_req_data['messenger'], $this->_req_data['message_type'] );
3255
+				? $this->_deactivate_message_type_for_messenger($this->_req_data['messenger'], $this->_req_data['message_type'])
3256
+				: $this->_activate_message_type_for_messenger($this->_req_data['messenger'], $this->_req_data['message_type']);
3257 3257
 		}
3258 3258
 
3259 3259
 		$this->_template_args['success'] = $success;
@@ -3267,30 +3267,30 @@  discard block
 block discarded – undo
3267 3267
 	 * @param string $messenger_name The name of the messenger being activated
3268 3268
 	 * @return bool
3269 3269
 	 */
3270
-	protected function _activate_messenger( $messenger_name ) {
3270
+	protected function _activate_messenger($messenger_name) {
3271 3271
 		/** @var EE_messenger $active_messenger  This will be present because it can't be toggled if it isn't*/
3272
-		$active_messenger = $this->_message_resource_manager->get_messenger( $messenger_name );
3272
+		$active_messenger = $this->_message_resource_manager->get_messenger($messenger_name);
3273 3273
 		$message_types_to_activate = $active_messenger instanceof EE_Messenger ? $active_messenger->get_default_message_types() : array();
3274 3274
 
3275 3275
 		//ensure is active
3276
-		$this->_message_resource_manager->activate_messenger( $messenger_name, $message_types_to_activate );
3276
+		$this->_message_resource_manager->activate_messenger($messenger_name, $message_types_to_activate);
3277 3277
 
3278 3278
 		//set response_data for reload
3279
-		foreach( $message_types_to_activate as $message_type_name ) {
3279
+		foreach ($message_types_to_activate as $message_type_name) {
3280 3280
 			/** @var EE_message_type $message_type */
3281
-			$message_type = $this->_message_resource_manager->get_message_type( $message_type_name );
3282
-			if ( $this->_message_resource_manager->is_message_type_active_for_messenger( $messenger_name, $message_type_name )
3281
+			$message_type = $this->_message_resource_manager->get_message_type($message_type_name);
3282
+			if ($this->_message_resource_manager->is_message_type_active_for_messenger($messenger_name, $message_type_name)
3283 3283
 			     && $message_type instanceof EE_message_type
3284 3284
 			) {
3285 3285
 				$this->_template_args['data']['active_mts'][] = $message_type_name;
3286
-				if ( $message_type->get_admin_settings_fields() ) {
3286
+				if ($message_type->get_admin_settings_fields()) {
3287 3287
 					$this->_template_args['data']['mt_reload'][] = $message_type_name;
3288 3288
 				}
3289 3289
 			}
3290 3290
 		}
3291 3291
 
3292 3292
 		//add success message for activating messenger
3293
-		return $this->_setup_response_message_for_activating_messenger_with_message_types( $active_messenger );
3293
+		return $this->_setup_response_message_for_activating_messenger_with_message_types($active_messenger);
3294 3294
 
3295 3295
 	}
3296 3296
 
@@ -3301,11 +3301,11 @@  discard block
 block discarded – undo
3301 3301
 	 * @param string $messenger_name The name of the messenger being activated
3302 3302
 	 * @return bool
3303 3303
 	 */
3304
-	protected function _deactivate_messenger( $messenger_name ) {
3304
+	protected function _deactivate_messenger($messenger_name) {
3305 3305
 		/** @var EE_messenger $active_messenger  This will be present because it can't be toggled if it isn't*/
3306
-		$active_messenger = $this->_message_resource_manager->get_messenger( $messenger_name );
3307
-		$this->_message_resource_manager->deactivate_messenger( $messenger_name );
3308
-		return $this->_setup_response_message_for_deactivating_messenger_with_message_types( $active_messenger );
3306
+		$active_messenger = $this->_message_resource_manager->get_messenger($messenger_name);
3307
+		$this->_message_resource_manager->deactivate_messenger($messenger_name);
3308
+		return $this->_setup_response_message_for_deactivating_messenger_with_message_types($active_messenger);
3309 3309
 	}
3310 3310
 
3311 3311
 
@@ -3316,23 +3316,23 @@  discard block
 block discarded – undo
3316 3316
 	 * @param string $message_type_name  The name of the message type being activated for the messenger
3317 3317
 	 * @return bool
3318 3318
 	 */
3319
-	protected function _activate_message_type_for_messenger( $messenger_name, $message_type_name ) {
3319
+	protected function _activate_message_type_for_messenger($messenger_name, $message_type_name) {
3320 3320
 		/** @var EE_messenger $active_messenger  This will be present because it can't be toggled if it isn't*/
3321
-		$active_messenger = $this->_message_resource_manager->get_messenger( $messenger_name );
3321
+		$active_messenger = $this->_message_resource_manager->get_messenger($messenger_name);
3322 3322
 		/** @var EE_message_type $message_type_to_activate This will be present because it can't be toggled if it isn't*/
3323
-		$message_type_to_activate = $this->_message_resource_manager->get_message_type( $message_type_name );
3323
+		$message_type_to_activate = $this->_message_resource_manager->get_message_type($message_type_name);
3324 3324
 
3325 3325
 		//ensure is active
3326
-		$this->_message_resource_manager->activate_messenger( $messenger_name, $message_type_name );
3326
+		$this->_message_resource_manager->activate_messenger($messenger_name, $message_type_name);
3327 3327
 
3328 3328
 		//set response for load
3329
-		if ( $this->_message_resource_manager->is_message_type_active_for_messenger( $messenger_name, $message_type_name ) ) {
3329
+		if ($this->_message_resource_manager->is_message_type_active_for_messenger($messenger_name, $message_type_name)) {
3330 3330
 			$this->_template_args['data']['active_mts'][] = $message_type_name;
3331
-			if ( $message_type_to_activate->get_admin_settings_fields() ) {
3331
+			if ($message_type_to_activate->get_admin_settings_fields()) {
3332 3332
 				$this->_template_args['data']['mt_reload'][] = $message_type_name;
3333 3333
 			}
3334 3334
 		}
3335
-		return $this->_setup_response_message_for_activating_messenger_with_message_types( $active_messenger, $message_type_to_activate );
3335
+		return $this->_setup_response_message_for_activating_messenger_with_message_types($active_messenger, $message_type_to_activate);
3336 3336
 	}
3337 3337
 
3338 3338
 
@@ -3344,13 +3344,13 @@  discard block
 block discarded – undo
3344 3344
 	 * @param string $message_type_name  The name of the message type being deactivated for the messenger
3345 3345
 	 * @return bool
3346 3346
 	 */
3347
-	protected function _deactivate_message_type_for_messenger( $messenger_name, $message_type_name ) {
3347
+	protected function _deactivate_message_type_for_messenger($messenger_name, $message_type_name) {
3348 3348
 		/** @var EE_messenger $active_messenger  This will be present because it can't be toggled if it isn't*/
3349
-		$active_messenger = $this->_message_resource_manager->get_messenger( $messenger_name );
3349
+		$active_messenger = $this->_message_resource_manager->get_messenger($messenger_name);
3350 3350
 		/** @var EE_message_type $message_type_to_activate This will be present because it can't be toggled if it isn't*/
3351
-		$message_type_to_deactivate = $this->_message_resource_manager->get_message_type( $message_type_name );
3352
-		$this->_message_resource_manager->deactivate_message_type_for_messenger( $message_type_name, $messenger_name );
3353
-		return $this->_setup_response_message_for_deactivating_messenger_with_message_types( $active_messenger, $message_type_to_deactivate );
3351
+		$message_type_to_deactivate = $this->_message_resource_manager->get_message_type($message_type_name);
3352
+		$this->_message_resource_manager->deactivate_message_type_for_messenger($message_type_name, $messenger_name);
3353
+		return $this->_setup_response_message_for_deactivating_messenger_with_message_types($active_messenger, $message_type_to_deactivate);
3354 3354
 	}
3355 3355
 
3356 3356
 
@@ -3381,9 +3381,9 @@  discard block
 block discarded – undo
3381 3381
 		EE_Message_Type $message_type = null
3382 3382
 	) {
3383 3383
 		//if $messenger isn't a valid messenger object then get out.
3384
-		if ( ! $messenger instanceof EE_Messenger ) {
3384
+		if ( ! $messenger instanceof EE_Messenger) {
3385 3385
 			EE_Error::add_error(
3386
-				__( 'The messenger being activated is not a valid messenger', 'event_espresso' ),
3386
+				__('The messenger being activated is not a valid messenger', 'event_espresso'),
3387 3387
 				__FILE__,
3388 3388
 				__FUNCTION__,
3389 3389
 				__LINE__
@@ -3391,32 +3391,32 @@  discard block
 block discarded – undo
3391 3391
 			return false;
3392 3392
 		}
3393 3393
 		//activated
3394
-		if ( $this->_template_args['data']['active_mts'] ) {
3394
+		if ($this->_template_args['data']['active_mts']) {
3395 3395
 			EE_Error::overwrite_success();
3396 3396
 			//activated a message type with the messenger
3397
-			if ( $message_type instanceof EE_message_type ) {
3397
+			if ($message_type instanceof EE_message_type) {
3398 3398
 				EE_Error::add_success(
3399 3399
 					sprintf(
3400 3400
 						__('%s message type has been successfully activated with the %s messenger', 'event_espresso'),
3401
-						ucwords( $message_type->label['singular'] ),
3402
-						ucwords( $messenger->label['singular'] )
3401
+						ucwords($message_type->label['singular']),
3402
+						ucwords($messenger->label['singular'])
3403 3403
 					)
3404 3404
 				);
3405 3405
 
3406 3406
 				//if message type was invoice then let's make sure we activate the invoice payment method.
3407
-				if ( $message_type->name == 'invoice' ) {
3408
-					EE_Registry::instance()->load_lib( 'Payment_Method_Manager' );
3409
-					$pm = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( 'Invoice' );
3410
-					if ( $pm instanceof EE_Payment_Method ) {
3411
-						EE_Error::add_attention( __('Activating the invoice message type also automatically activates the invoice payment method.  If you do not wish the invoice payment method to be active, or to change its settings, visit the payment method admin page.', 'event_espresso' ) );
3407
+				if ($message_type->name == 'invoice') {
3408
+					EE_Registry::instance()->load_lib('Payment_Method_Manager');
3409
+					$pm = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice');
3410
+					if ($pm instanceof EE_Payment_Method) {
3411
+						EE_Error::add_attention(__('Activating the invoice message type also automatically activates the invoice payment method.  If you do not wish the invoice payment method to be active, or to change its settings, visit the payment method admin page.', 'event_espresso'));
3412 3412
 					}
3413 3413
 				}
3414 3414
 			//just toggles the entire messenger
3415 3415
 			} else {
3416 3416
 				EE_Error::add_success(
3417 3417
 					sprintf(
3418
-						__( '%s messenger has been successfully activated', 'event_espresso' ),
3419
-						ucwords( $messenger->label[ 'singular' ] )
3418
+						__('%s messenger has been successfully activated', 'event_espresso'),
3419
+						ucwords($messenger->label['singular'])
3420 3420
 					)
3421 3421
 				);
3422 3422
 			}
@@ -3426,12 +3426,12 @@  discard block
 block discarded – undo
3426 3426
 		//message types after the activation process.  However its possible some messengers don't HAVE any default_message_types
3427 3427
 		//in which case we just give a success message for the messenger being successfully activated.
3428 3428
 		} else {
3429
-			if ( ! $messenger->get_default_message_types() ) {
3429
+			if ( ! $messenger->get_default_message_types()) {
3430 3430
 				//messenger doesn't have any default message types so still a success.
3431 3431
 				EE_Error::add_success(
3432 3432
 					sprintf(
3433
-						__('%s messenger was successfully activated.', 'event_espresso' ),
3434
-						ucwords( $messenger->label['singular'] )
3433
+						__('%s messenger was successfully activated.', 'event_espresso'),
3434
+						ucwords($messenger->label['singular'])
3435 3435
 						)
3436 3436
 				);
3437 3437
 				return true;
@@ -3439,13 +3439,13 @@  discard block
 block discarded – undo
3439 3439
 				EE_Error::add_error(
3440 3440
 					$message_type instanceof EE_message_type
3441 3441
 						? sprintf(
3442
-						__( '%s message type was not successfully activated with the %s messenger', 'event_espresso' ),
3443
-						ucwords( $message_type->label['singular'] ),
3444
-						ucwords( $messenger->label['singular'] )
3442
+						__('%s message type was not successfully activated with the %s messenger', 'event_espresso'),
3443
+						ucwords($message_type->label['singular']),
3444
+						ucwords($messenger->label['singular'])
3445 3445
 					)
3446 3446
 						: sprintf(
3447
-						__( '%s messenger was not successfully activated', 'event_espresso' ),
3448
-						ucwords( $messenger->label['singular'] )
3447
+						__('%s messenger was not successfully activated', 'event_espresso'),
3448
+						ucwords($messenger->label['singular'])
3449 3449
 					),
3450 3450
 					__FILE__,
3451 3451
 					__FUNCTION__,
@@ -3473,9 +3473,9 @@  discard block
 block discarded – undo
3473 3473
 		EE_Error::overwrite_success();
3474 3474
 
3475 3475
 		//if $messenger isn't a valid messenger object then get out.
3476
-		if ( ! $messenger instanceof EE_Messenger ) {
3476
+		if ( ! $messenger instanceof EE_Messenger) {
3477 3477
 			EE_Error::add_error(
3478
-				__( 'The messenger being deactivated is not a valid messenger', 'event_espresso' ),
3478
+				__('The messenger being deactivated is not a valid messenger', 'event_espresso'),
3479 3479
 				__FILE__,
3480 3480
 				__FUNCTION__,
3481 3481
 				__LINE__
@@ -3483,13 +3483,13 @@  discard block
 block discarded – undo
3483 3483
 			return false;
3484 3484
 		}
3485 3485
 
3486
-		if ( $message_type instanceof EE_message_type ) {
3486
+		if ($message_type instanceof EE_message_type) {
3487 3487
 			$message_type_name = $message_type->name;
3488 3488
 			EE_Error::add_success(
3489 3489
 				sprintf(
3490 3490
 					__('%s message type has been successfully deactivated for the %s messenger.', 'event_espresso'),
3491
-					ucwords( $message_type->label['singular'] ),
3492
-					ucwords ( $messenger->label['singular'] )
3491
+					ucwords($message_type->label['singular']),
3492
+					ucwords($messenger->label['singular'])
3493 3493
 				)
3494 3494
 			);
3495 3495
 		} else {
@@ -3497,20 +3497,20 @@  discard block
 block discarded – undo
3497 3497
 			EE_Error::add_success(
3498 3498
 				sprintf(
3499 3499
 					__('%s messenger has been successfully deactivated.', 'event_espresso'),
3500
-					ucwords( $messenger->label['singular'] )
3500
+					ucwords($messenger->label['singular'])
3501 3501
 				)
3502 3502
 			);
3503 3503
 		}
3504 3504
 
3505 3505
 		//if messenger was html or message type was invoice then let's make sure we deactivate invoice payment method.
3506
-		if ( $messenger->name == 'html'  || $message_type_name == 'invoice') {
3507
-			EE_Registry::instance()->load_lib( 'Payment_Method_Manager' );
3508
-			$count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method( 'invoice' );
3509
-			if ( $count_updated > 0 ) {
3506
+		if ($messenger->name == 'html' || $message_type_name == 'invoice') {
3507
+			EE_Registry::instance()->load_lib('Payment_Method_Manager');
3508
+			$count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method('invoice');
3509
+			if ($count_updated > 0) {
3510 3510
 				$msg = $message_type_name == 'invoice'
3511
-					? __('Deactivating the invoice message type also automatically deactivates the invoice payment method. In order for invoices to be generated the invoice message type must be active. If you completed this action by mistake, simply reactivate the invoice message type and then visit the payment methods admin page to reactivate the invoice payment method.', 'event_espresso' )
3512
-					: __('Deactivating the html messenger also automatically deactivates the invoice payment method.  In order for invoices to be generated the html messenger must be be active.  If you completed this action by mistake, simply reactivate the html messenger, then visit the payment methods admin page to reactivate the invoice payment method.', 'event_espresso' );
3513
-				EE_Error::add_attention( $msg );
3511
+					? __('Deactivating the invoice message type also automatically deactivates the invoice payment method. In order for invoices to be generated the invoice message type must be active. If you completed this action by mistake, simply reactivate the invoice message type and then visit the payment methods admin page to reactivate the invoice payment method.', 'event_espresso')
3512
+					: __('Deactivating the html messenger also automatically deactivates the invoice payment method.  In order for invoices to be generated the html messenger must be be active.  If you completed this action by mistake, simply reactivate the html messenger, then visit the payment methods admin page to reactivate the invoice payment method.', 'event_espresso');
3513
+				EE_Error::add_attention($msg);
3514 3514
 			}
3515 3515
 		}
3516 3516
 		return true;
@@ -3521,17 +3521,17 @@  discard block
 block discarded – undo
3521 3521
 	 * handles updating a message type form on messenger activation IF the message type has settings fields. (via ajax)
3522 3522
 	 */
3523 3523
 	public function update_mt_form() {
3524
-		if ( !isset( $this->_req_data['messenger'] ) || !isset( $this->_req_data['message_type'] ) ) {
3525
-			EE_Error::add_error( __('Require message type or messenger to send an updated form'), __FILE__, __FUNCTION__, __LINE__ );
3524
+		if ( ! isset($this->_req_data['messenger']) || ! isset($this->_req_data['message_type'])) {
3525
+			EE_Error::add_error(__('Require message type or messenger to send an updated form'), __FILE__, __FUNCTION__, __LINE__);
3526 3526
 			$this->_return_json();
3527 3527
 		}
3528 3528
 
3529 3529
 		$message_types = $this->get_installed_message_types();
3530 3530
 
3531
-		$message_type = $message_types[ $this->_req_data['message_type'] ];
3532
-		$messenger = $this->_message_resource_manager->get_active_messenger( $this->_req_data['messenger'] );
3531
+		$message_type = $message_types[$this->_req_data['message_type']];
3532
+		$messenger = $this->_message_resource_manager->get_active_messenger($this->_req_data['messenger']);
3533 3533
 
3534
-		$content = $this->_message_type_settings_content ( $message_type, $messenger, true );
3534
+		$content = $this->_message_type_settings_content($message_type, $messenger, true);
3535 3535
 		$this->_template_args['success'] = true;
3536 3536
 		$this->_template_args['content'] = $content;
3537 3537
 		$this->_return_json();
@@ -3545,45 +3545,45 @@  discard block
 block discarded – undo
3545 3545
 	 *
3546 3546
 	 */
3547 3547
 	public function save_settings() {
3548
-		if ( !isset( $this->_req_data['type'] ) ) {
3549
-			EE_Error::add_error(__('Cannot save settings because type is unknown (messenger settings or messsage type settings?)', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
3548
+		if ( ! isset($this->_req_data['type'])) {
3549
+			EE_Error::add_error(__('Cannot save settings because type is unknown (messenger settings or messsage type settings?)', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
3550 3550
 			$this->_template_args['error'] = true;
3551 3551
 			$this->_return_json();
3552 3552
 		}
3553 3553
 
3554 3554
 
3555
-		if ( $this->_req_data['type'] == 'messenger' ) {
3555
+		if ($this->_req_data['type'] == 'messenger') {
3556 3556
 			$settings = $this->_req_data['messenger_settings']; //this should be an array.
3557 3557
 			$messenger = $settings['messenger'];
3558 3558
 			//let's setup the settings data
3559
-			foreach ( $settings as $key => $value ) {
3560
-				switch ( $key ) {
3559
+			foreach ($settings as $key => $value) {
3560
+				switch ($key) {
3561 3561
 					case 'messenger' :
3562
-						unset( $settings['messenger'] );
3562
+						unset($settings['messenger']);
3563 3563
 						break;
3564 3564
 					case 'message_types' :
3565
-						unset( $settings['message_types'] );
3565
+						unset($settings['message_types']);
3566 3566
 						break;
3567 3567
 					default :
3568 3568
 						$settings[$key] = $value;
3569 3569
 						break;
3570 3570
 				}
3571 3571
 			}
3572
-			$this->_message_resource_manager->add_settings_for_messenger( $messenger, $settings );
3572
+			$this->_message_resource_manager->add_settings_for_messenger($messenger, $settings);
3573 3573
 		}
3574 3574
 
3575
-		else if ( $this->_req_data['type'] == 'message_type' ) {
3575
+		else if ($this->_req_data['type'] == 'message_type') {
3576 3576
 			$settings = $this->_req_data['message_type_settings'];
3577 3577
 			$messenger = $settings['messenger'];
3578 3578
 			$message_type = $settings['message_type'];
3579 3579
 
3580
-			foreach ( $settings as $key => $value ) {
3581
-				switch ( $key ) {
3580
+			foreach ($settings as $key => $value) {
3581
+				switch ($key) {
3582 3582
 					case 'messenger' :
3583
-						unset( $settings['messenger'] );
3583
+						unset($settings['messenger']);
3584 3584
 						break;
3585 3585
 					case 'message_type' :
3586
-						unset( $settings['message_type'] );
3586
+						unset($settings['message_type']);
3587 3587
 						break;
3588 3588
 					default :
3589 3589
 						$settings[$key] = $value;
@@ -3591,16 +3591,16 @@  discard block
 block discarded – undo
3591 3591
 				}
3592 3592
 			}
3593 3593
 
3594
-			$this->_message_resource_manager->add_settings_for_message_type( $messenger, $message_type, $settings );
3594
+			$this->_message_resource_manager->add_settings_for_message_type($messenger, $message_type, $settings);
3595 3595
 		}
3596 3596
 
3597 3597
 		//okay we should have the data all setup.  Now we just update!
3598 3598
 		$success = $this->_message_resource_manager->update_active_messengers_option();
3599 3599
 
3600
-		if ( $success ) {
3601
-			EE_Error::add_success( __('Settings updated', 'event_espresso') );
3600
+		if ($success) {
3601
+			EE_Error::add_success(__('Settings updated', 'event_espresso'));
3602 3602
 		} else {
3603
-			EE_Error::add_error( __('Settings did not get updated', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
3603
+			EE_Error::add_error(__('Settings did not get updated', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
3604 3604
 		}
3605 3605
 
3606 3606
 		$this->_template_args['success'] = $success;
@@ -3622,8 +3622,8 @@  discard block
 block discarded – undo
3622 3622
      */
3623 3623
 	protected function _generate_now() {
3624 3624
 		$msg_ids = $this->_get_msg_ids_from_request();
3625
-		EED_Messages::generate_now( $msg_ids );
3626
-		$this->_redirect_after_action( false, '', '', array(), true );
3625
+		EED_Messages::generate_now($msg_ids);
3626
+		$this->_redirect_after_action(false, '', '', array(), true);
3627 3627
 	}
3628 3628
 
3629 3629
 
@@ -3638,7 +3638,7 @@  discard block
 block discarded – undo
3638 3638
 	protected function _generate_and_send_now() {
3639 3639
 		$this->_generate_now();
3640 3640
 		$this->_send_now();
3641
-		$this->_redirect_after_action( false, '', '', array(), true );
3641
+		$this->_redirect_after_action(false, '', '', array(), true);
3642 3642
 	}
3643 3643
 
3644 3644
 
@@ -3652,8 +3652,8 @@  discard block
 block discarded – undo
3652 3652
      */
3653 3653
 	protected function _queue_for_resending() {
3654 3654
 		$msg_ids = $this->_get_msg_ids_from_request();
3655
-		EED_Messages::queue_for_resending( $msg_ids );
3656
-		$this->_redirect_after_action( false, '', '', array(), true );
3655
+		EED_Messages::queue_for_resending($msg_ids);
3656
+		$this->_redirect_after_action(false, '', '', array(), true);
3657 3657
 	}
3658 3658
 
3659 3659
 
@@ -3666,8 +3666,8 @@  discard block
 block discarded – undo
3666 3666
      */
3667 3667
 	protected function _send_now() {
3668 3668
 		$msg_ids = $this->_get_msg_ids_from_request();
3669
-		EED_Messages::send_now( $msg_ids );
3670
-		$this->_redirect_after_action( false, '', '', array(), true );
3669
+		EED_Messages::send_now($msg_ids);
3670
+		$this->_redirect_after_action(false, '', '', array(), true);
3671 3671
 	}
3672 3672
 
3673 3673
 
@@ -3681,23 +3681,23 @@  discard block
 block discarded – undo
3681 3681
 	protected function _delete_ee_messages() {
3682 3682
 		$msg_ids = $this->_get_msg_ids_from_request();
3683 3683
 		$deleted_count = 0;
3684
-		foreach ( $msg_ids as $msg_id ) {
3685
-			if ( EEM_Message::instance()->delete_by_ID( $msg_id ) ) {
3684
+		foreach ($msg_ids as $msg_id) {
3685
+			if (EEM_Message::instance()->delete_by_ID($msg_id)) {
3686 3686
 				$deleted_count++;
3687 3687
 			}
3688 3688
 		}
3689
-		if ( $deleted_count ) {
3689
+		if ($deleted_count) {
3690 3690
 			$this->_redirect_after_action(
3691 3691
 				true,
3692
-				_n( 'message', 'messages', $deleted_count, 'event_espresso' ),
3692
+				_n('message', 'messages', $deleted_count, 'event_espresso'),
3693 3693
 				__('deleted', 'event_espresso')
3694 3694
 			);
3695 3695
 		} else {
3696 3696
 			EE_Error::add_error(
3697
-				_n( 'The message was not deleted.', 'The messages were not deleted', count( $msg_ids ), 'event_espresso' ),
3697
+				_n('The message was not deleted.', 'The messages were not deleted', count($msg_ids), 'event_espresso'),
3698 3698
 				__FILE__, __FUNCTION__, __LINE__
3699 3699
 			);
3700
-			$this->_redirect_after_action( false, '', '', array(), true );
3700
+			$this->_redirect_after_action(false, '', '', array(), true);
3701 3701
 		}
3702 3702
 	}
3703 3703
 
@@ -3710,10 +3710,10 @@  discard block
 block discarded – undo
3710 3710
      *  @return array
3711 3711
      */
3712 3712
 	protected function _get_msg_ids_from_request() {
3713
-		if ( ! isset( $this->_req_data['MSG_ID'] ) ) {
3713
+		if ( ! isset($this->_req_data['MSG_ID'])) {
3714 3714
 			return array();
3715 3715
 		}
3716
-		return is_array( $this->_req_data['MSG_ID'] ) ? array_keys( $this->_req_data['MSG_ID'] ) : array( $this->_req_data['MSG_ID'] );
3716
+		return is_array($this->_req_data['MSG_ID']) ? array_keys($this->_req_data['MSG_ID']) : array($this->_req_data['MSG_ID']);
3717 3717
 	}
3718 3718
 
3719 3719
 
Please login to merge, or discard this patch.
admin_pages/messages/Messages_Template_List_Table.class.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION') )
2
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
3 3
 	exit('NO direct script access allowed');
4 4
 
5 5
 /**
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
 
42 42
 
43 43
 	protected function _setup_data() {
44
-		$this->_data = $this->get_admin_page()->get_message_templates( $this->_per_page, $this->_view, FALSE);
45
-		$this->_all_data_count = $this->get_admin_page()->get_message_templates( $this->_per_page, $this->_view, TRUE, TRUE );
44
+		$this->_data = $this->get_admin_page()->get_message_templates($this->_per_page, $this->_view, FALSE);
45
+		$this->_all_data_count = $this->get_admin_page()->get_message_templates($this->_per_page, $this->_view, TRUE, TRUE);
46 46
 	}
47 47
 
48 48
 
@@ -51,21 +51,21 @@  discard block
 block discarded – undo
51 51
 
52 52
 	protected function _set_properties() {
53 53
 		$this->_wp_list_args = array(
54
-			'singular' => __('Message Template Group', 'event_espresso' ),
55
-			'plural' => __('Message Template', 'event_espresso' ),
54
+			'singular' => __('Message Template Group', 'event_espresso'),
55
+			'plural' => __('Message Template', 'event_espresso'),
56 56
 			'ajax' => TRUE, //for now,
57 57
 			'screen' => $this->get_admin_page()->get_current_screen()->id
58 58
 			);
59 59
 		$this->_columns = array(
60 60
 			//'cb' => '<input type="checkbox" />', //no deleting default (global) templates!
61 61
 			'message_type' => __('Message Type', 'event_espresso'),
62
-			'messenger' => __( 'Messenger', 'event_espresso'),
63
-			'description' => __( 'Description', 'event_espresso' ),
62
+			'messenger' => __('Messenger', 'event_espresso'),
63
+			'description' => __('Description', 'event_espresso'),
64 64
 			//'messages_sent' => __( 'Total Sent', 'event_espresso' ) //todo this will come later when we've got message tracking in place.
65 65
 			);
66 66
 
67 67
 		$this->_sortable_columns = array(
68
-			'messenger' => array( 'MTP_messenger' => TRUE ),
68
+			'messenger' => array('MTP_messenger' => TRUE),
69 69
 			//'message_type' => array( 'MTP_message_type' => FALSE )
70 70
 			);
71 71
 
@@ -84,16 +84,16 @@  discard block
 block discarded – undo
84 84
 	 *
85 85
 	 * @return string
86 86
 	 */
87
-	public function single_row( $item ) {
87
+	public function single_row($item) {
88 88
 		$message_type = $item->message_type_obj();
89 89
 		$messenger = $item->messenger_obj();
90 90
 
91
-		if ( ! $message_type instanceof EE_message_type || ! $messenger instanceof EE_messenger ) {
91
+		if ( ! $message_type instanceof EE_message_type || ! $messenger instanceof EE_messenger) {
92 92
 			echo '';
93 93
 			return;
94 94
 		}
95 95
 
96
-		parent::single_row( $item );
96
+		parent::single_row($item);
97 97
 	}
98 98
 
99 99
 
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
 		);
112 112
 
113 113
 		//set filters to select inputs if they aren't empty
114
-		foreach ( $select_inputs as $select_input ) {
115
-			if ( $select_input ) {
114
+		foreach ($select_inputs as $select_input) {
115
+			if ($select_input) {
116 116
 				$filters[] = $select_input;
117 117
 			}
118 118
 		}
@@ -123,20 +123,20 @@  discard block
 block discarded – undo
123 123
 	 * we're just removing the search box for message templates, not needed.
124 124
 	 * @return string (empty);
125 125
 	 */
126
-	function search_box( $text, $input_id ) {
126
+	function search_box($text, $input_id) {
127 127
 		return '';
128 128
 	}
129 129
 
130 130
 
131 131
 	protected function _add_view_counts() {
132
-		foreach ( $this->_views as $view => $args )  {
133
-			$this->_views[$view]['count'] = $this->get_admin_page()->get_message_templates( $this->_per_page, $view, TRUE, TRUE );
132
+		foreach ($this->_views as $view => $args) {
133
+			$this->_views[$view]['count'] = $this->get_admin_page()->get_message_templates($this->_per_page, $view, TRUE, TRUE);
134 134
 		}
135 135
 	}
136 136
 
137 137
 
138 138
 
139
-	public function column_cb( $item ) {
139
+	public function column_cb($item) {
140 140
 		return '';
141 141
 	}
142 142
 
@@ -144,8 +144,8 @@  discard block
 block discarded – undo
144 144
 
145 145
 
146 146
 
147
-	function column_description( $item ) {
148
-		return '<p>' . $item->message_type_obj()->description . '</p>';
147
+	function column_description($item) {
148
+		return '<p>'.$item->message_type_obj()->description.'</p>';
149 149
 	}
150 150
 
151 151
 
@@ -160,27 +160,27 @@  discard block
 block discarded – undo
160 160
 		$actions = array();
161 161
 
162 162
 		// edit link but only if item isn't trashed.
163
-		if ( !$item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $item->ID() ) ) {
164
-			$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'edit_message_template', 'id'=>$item->GRP_ID() ), EE_MSG_ADMIN_URL );
165
-			$actions['edit'] = '<a href="'.$edit_lnk_url.'" title="' . esc_attr__( 'Edit Template Group', 'event_espresso' ) . '">' . __( 'Edit', 'event_espresso' ) . '</a>';
163
+		if ( ! $item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $item->ID())) {
164
+			$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'edit_message_template', 'id'=>$item->GRP_ID()), EE_MSG_ADMIN_URL);
165
+			$actions['edit'] = '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('Edit Template Group', 'event_espresso').'">'.__('Edit', 'event_espresso').'</a>';
166 166
 		}
167 167
 
168
-		$name_link = ! $item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $item->ID() ) ? '<a href="'.$edit_lnk_url.'" title="' . esc_attr__( 'Edit Template Group', 'event_espresso' ) . '">' . ucwords( $item->messenger_obj()->label['singular'] ) . '</a>' : ucwords( $item->messenger_obj()->label['singular'] );
168
+		$name_link = ! $item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $item->ID()) ? '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('Edit Template Group', 'event_espresso').'">'.ucwords($item->messenger_obj()->label['singular']).'</a>' : ucwords($item->messenger_obj()->label['singular']);
169 169
 
170 170
 		//we want to display the contexts in here so we need to set them up
171 171
 		$c_label = $item->context_label();
172 172
 		$c_configs = $item->contexts_config();
173 173
 		$ctxt = array();
174 174
 		$context_templates = $item->context_templates();
175
-		foreach ( $context_templates as $context => $template_fields ) {
176
-			$mtp_to = !empty( $context_templates[$context]['to'] ) && $context_templates[$context]['to'] instanceof EE_Message_Template ? $context_templates[$context]['to']->get('MTP_content') : NULL;
177
-			$inactive = empty( $mtp_to ) && !empty( $context_templates[$context]['to'] ) ? ' class="mtp-inactive"' : '';
175
+		foreach ($context_templates as $context => $template_fields) {
176
+			$mtp_to = ! empty($context_templates[$context]['to']) && $context_templates[$context]['to'] instanceof EE_Message_Template ? $context_templates[$context]['to']->get('MTP_content') : NULL;
177
+			$inactive = empty($mtp_to) && ! empty($context_templates[$context]['to']) ? ' class="mtp-inactive"' : '';
178 178
 			$context_title = ucwords($c_configs[$context]['label']);
179
-			$edit_link = EE_Admin_Page::add_query_args_and_nonce( array('action'=>'edit_message_template', 'id'=>$item->GRP_ID(), 'context' => $context), EE_MSG_ADMIN_URL );
180
-			$ctxt[] = EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $item->ID() ) ? '<a' . $inactive . ' href="'. $edit_link . '" title="' . esc_attr__('Edit Context', 'event_espresso') . '">' . $context_title . '</a>' : $context_title;
179
+			$edit_link = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'edit_message_template', 'id'=>$item->GRP_ID(), 'context' => $context), EE_MSG_ADMIN_URL);
180
+			$ctxt[] = EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $item->ID()) ? '<a'.$inactive.' href="'.$edit_link.'" title="'.esc_attr__('Edit Context', 'event_espresso').'">'.$context_title.'</a>' : $context_title;
181 181
 		}
182 182
 
183
-		$ctx_content = !$item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $item->ID() ) ? sprintf( __('<strong>%s:</strong> ', 'event_espresso'), ucwords($c_label['plural']) ) . implode(' | ', $ctxt) : '';
183
+		$ctx_content = ! $item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $item->ID()) ? sprintf(__('<strong>%s:</strong> ', 'event_espresso'), ucwords($c_label['plural'])).implode(' | ', $ctxt) : '';
184 184
 
185 185
 
186 186
 		//Return the name contents
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 										/* $1%s */ $name_link,
189 189
 										/* $2%s */ $item->GRP_ID(),
190 190
 										/* %4$s */ $ctx_content,
191
-										/* $3%s */ $this->row_actions( $actions )
191
+										/* $3%s */ $this->row_actions($actions)
192 192
 		);
193 193
 	}
194 194
 
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 	 * @return string       message_type name
199 199
 	 */
200 200
 	function column_message_type($item) {
201
-		return ucwords($item->message_type_obj()->label['singular'] );
201
+		return ucwords($item->message_type_obj()->label['singular']);
202 202
 	}
203 203
 
204 204
 
@@ -225,16 +225,16 @@  discard block
 block discarded – undo
225 225
 			)
226 226
 		);
227 227
 
228
-		foreach ( $active_message_template_groups_grouped_by_messenger as $active_message_template_group ) {
229
-			if ( $active_message_template_group instanceof EE_Message_Template_Group ) {
228
+		foreach ($active_message_template_groups_grouped_by_messenger as $active_message_template_group) {
229
+			if ($active_message_template_group instanceof EE_Message_Template_Group) {
230 230
 				$messenger = $active_message_template_group->messenger_obj();
231 231
 				$messenger_label = $messenger instanceof EE_messenger
232 232
 					? $messenger->label['singular']
233 233
 					: $active_message_template_group->messenger();
234
-				$messenger_options[ $active_message_template_group->messenger() ] = ucwords( $messenger_label );
234
+				$messenger_options[$active_message_template_group->messenger()] = ucwords($messenger_label);
235 235
 			}
236 236
 		}
237
-		return $this->get_admin_page()->get_messengers_select_input( $messenger_options );
237
+		return $this->get_admin_page()->get_messengers_select_input($messenger_options);
238 238
 	}
239 239
 
240 240
 
@@ -254,16 +254,16 @@  discard block
 block discarded – undo
254 254
 			)
255 255
 		);
256 256
 
257
-		foreach ( $active_message_template_groups_grouped_by_message_type as $active_message_template_group ) {
258
-			if ( $active_message_template_group instanceof EE_Message_Template_Group ) {
257
+		foreach ($active_message_template_groups_grouped_by_message_type as $active_message_template_group) {
258
+			if ($active_message_template_group instanceof EE_Message_Template_Group) {
259 259
 				$message_type = $active_message_template_group->message_type_obj();
260 260
 				$message_type_label = $message_type instanceof EE_message_type
261 261
 					? $message_type->label['singular']
262 262
 					: $active_message_template_group->message_type();
263
-				$message_type_options[ $active_message_template_group->message_type() ] = ucwords( $message_type_label );
263
+				$message_type_options[$active_message_template_group->message_type()] = ucwords($message_type_label);
264 264
 			}
265 265
 		}
266
-		return $this->get_admin_page()->get_message_types_select_input( $message_type_options );
266
+		return $this->get_admin_page()->get_message_types_select_input($message_type_options);
267 267
 	}
268 268
 
269 269
 }
Please login to merge, or discard this patch.
admin_pages/messages/EE_Message_List_Table.class.php 1 patch
Spacing   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION') ){
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3 3
 	exit('NO direct script access allowed');
4 4
 }
5 5
 /**
@@ -26,8 +26,8 @@  discard block
 block discarded – undo
26 26
 
27 27
 
28 28
 	protected function _setup_data() {
29
-		$this->_data = $this->_get_messages( $this->_per_page, $this->_view );
30
-		$this->_all_data_count = $this->_get_messages( $this->_per_page, $this->_view, true );
29
+		$this->_data = $this->_get_messages($this->_per_page, $this->_view);
30
+		$this->_all_data_count = $this->_get_messages($this->_per_page, $this->_view, true);
31 31
 	}
32 32
 
33 33
 
@@ -35,32 +35,32 @@  discard block
 block discarded – undo
35 35
 
36 36
 	protected function _set_properties() {
37 37
 		$this->_wp_list_args = array(
38
-			'singular' => __( 'Message', 'event_espresso' ),
39
-			'plural' => __( 'Messages', 'event_espresso' ),
38
+			'singular' => __('Message', 'event_espresso'),
39
+			'plural' => __('Messages', 'event_espresso'),
40 40
 			'ajax' => true,
41 41
 			'screen' => $this->get_admin_page()->get_current_screen()->id
42 42
 		);
43 43
 
44 44
 		$this->_columns = array(
45 45
 			'cb' => '<input type="checkbox" />',
46
-			'to' => __( 'To', 'event_espresso' ),
47
-			'from' => __( 'From', 'event_espresso' ),
48
-			'messenger' => __( 'Messenger', 'event_espresso' ),
49
-			'message_type' => __( 'Message Type', 'event_espresso' ),
50
-			'context' => __( 'Context', 'event_espresso' ),
51
-			'modified' => __( 'Modified', 'event_espresso' ),
52
-			'action' => __( 'Actions', 'event_espresso' ),
53
-			'msg_id' => __( 'ID', 'event_espresso' ),
46
+			'to' => __('To', 'event_espresso'),
47
+			'from' => __('From', 'event_espresso'),
48
+			'messenger' => __('Messenger', 'event_espresso'),
49
+			'message_type' => __('Message Type', 'event_espresso'),
50
+			'context' => __('Context', 'event_espresso'),
51
+			'modified' => __('Modified', 'event_espresso'),
52
+			'action' => __('Actions', 'event_espresso'),
53
+			'msg_id' => __('ID', 'event_espresso'),
54 54
 		);
55 55
 
56 56
 		$this->_sortable_columns = array(
57
-			'modified' => array( 'MSG_modified' => true ),
58
-			'message_type' => array( 'MSG_message_type' => false ),
59
-			'messenger' => array( 'MSG_messenger' => false ),
60
-			'to' => array( 'MSG_to' => false ),
61
-			'from' => array( 'MSG_from' => false ),
62
-			'context' => array( 'MSG_context' => false ),
63
-			'msg_id' => array( 'MSG_ID', false ),
57
+			'modified' => array('MSG_modified' => true),
58
+			'message_type' => array('MSG_message_type' => false),
59
+			'messenger' => array('MSG_messenger' => false),
60
+			'to' => array('MSG_to' => false),
61
+			'from' => array('MSG_from' => false),
62
+			'context' => array('MSG_context' => false),
63
+			'msg_id' => array('MSG_ID', false),
64 64
 		);
65 65
 
66 66
 		$this->_primary_column = 'to';
@@ -78,11 +78,11 @@  discard block
 block discarded – undo
78 78
 	 * @param  object $item the current item
79 79
 	 * @return string
80 80
 	 */
81
-	protected function _get_row_class( $item ) {
82
-		$class = parent::_get_row_class( $item );
81
+	protected function _get_row_class($item) {
82
+		$class = parent::_get_row_class($item);
83 83
 		//add status class
84
-		$class .= ' ee-status-strip msg-status-' . $item->STS_ID();
85
-		if ( $this->_has_checkbox_column ) {
84
+		$class .= ' ee-status-strip msg-status-'.$item->STS_ID();
85
+		if ($this->_has_checkbox_column) {
86 86
 			$class .= ' has-checkbox-column';
87 87
 		}
88 88
 		return $class;
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
 		);
111 111
 
112 112
 		//set filters to select inputs if they aren't empty
113
-		foreach ( $select_inputs as $select_input ) {
114
-			if ( $select_input ) {
113
+		foreach ($select_inputs as $select_input) {
114
+			if ($select_input) {
115 115
 				$filters[] = $select_input;
116 116
 			}
117 117
 		}
@@ -121,8 +121,8 @@  discard block
 block discarded – undo
121 121
 
122 122
 
123 123
 	protected function _add_view_counts() {
124
-		foreach ( $this->_views as $view => $args ) {
125
-			$this->_views[ $view ]['count'] = $this->_get_messages( $this->_per_page, $view, true, true );
124
+		foreach ($this->_views as $view => $args) {
125
+			$this->_views[$view]['count'] = $this->_get_messages($this->_per_page, $view, true, true);
126 126
 		}
127 127
 	}
128 128
 
@@ -133,8 +133,8 @@  discard block
 block discarded – undo
133 133
 	 * @return string   checkbox
134 134
 	 * @throws \EE_Error
135 135
 	 */
136
-	public function column_cb( $message ) {
137
-		return sprintf( '<input type="checkbox" name="MSG_ID[%s]" value="1" />', $message->ID() );
136
+	public function column_cb($message) {
137
+		return sprintf('<input type="checkbox" name="MSG_ID[%s]" value="1" />', $message->ID());
138 138
 	}
139 139
 
140 140
 
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	 * @return string
145 145
 	 * @throws \EE_Error
146 146
 	 */
147
-	public function column_msg_id( EE_Message $message ) {
147
+	public function column_msg_id(EE_Message $message) {
148 148
 		return $message->ID();
149 149
 	}
150 150
 
@@ -155,8 +155,8 @@  discard block
 block discarded – undo
155 155
 	 * @return string    The recipient of the message
156 156
 	 * @throws \EE_Error
157 157
 	 */
158
-	public function column_to( EE_Message $message ) {
159
-		EE_Registry::instance()->load_helper( 'URL' );
158
+	public function column_to(EE_Message $message) {
159
+		EE_Registry::instance()->load_helper('URL');
160 160
 		$actions = array();
161 161
 		$actions['delete'] = '<a href="'
162 162
 			. EEH_URL::add_query_args_and_nonce(
@@ -165,10 +165,10 @@  discard block
 block discarded – undo
165 165
 					'action' => 'delete_ee_message',
166 166
 					'MSG_ID' => $message->ID()
167 167
 				),
168
-				admin_url( 'admin.php' )
168
+				admin_url('admin.php')
169 169
 			)
170
-			. '">' . __( 'Delete', 'event_espresso' ) . '</a>';
171
-		return $message->to() . $this->row_actions( $actions );
170
+			. '">'.__('Delete', 'event_espresso').'</a>';
171
+		return $message->to().$this->row_actions($actions);
172 172
 	}
173 173
 
174 174
 
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 	 * @param EE_Message $message
177 177
 	 * @return string   The sender of the message
178 178
 	 */
179
-	public function column_from( EE_Message $message ) {
179
+	public function column_from(EE_Message $message) {
180 180
 		return $message->from();
181 181
 	}
182 182
 
@@ -186,8 +186,8 @@  discard block
 block discarded – undo
186 186
 	 * @param EE_Message $message
187 187
 	 * @return string  The messenger used to send the message.
188 188
 	 */
189
-	public function column_messenger( EE_Message $message ) {
190
-		return ucwords( $message->messenger_label() );
189
+	public function column_messenger(EE_Message $message) {
190
+		return ucwords($message->messenger_label());
191 191
 	}
192 192
 
193 193
 
@@ -195,8 +195,8 @@  discard block
 block discarded – undo
195 195
 	 * @param EE_Message $message
196 196
 	 * @return string  The message type used to generate the message.
197 197
 	 */
198
-	public function column_message_type( EE_Message $message ) {
199
-		return ucwords( $message->message_type_label() );
198
+	public function column_message_type(EE_Message $message) {
199
+		return ucwords($message->message_type_label());
200 200
 	}
201 201
 
202 202
 
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 	 * @param EE_Message $message
205 205
 	 * @return string  The context the message was generated for.
206 206
 	 */
207
-	public function column_context( EE_Message $message ) {
207
+	public function column_context(EE_Message $message) {
208 208
 		return $message->context_label();
209 209
 	}
210 210
 
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 	 * @param EE_Message $message
214 214
 	 * @return string    The timestamp when this message was last modified.
215 215
 	 */
216
-	public function column_modified( EE_Message $message ) {
216
+	public function column_modified(EE_Message $message) {
217 217
 		return $message->modified();
218 218
 	}
219 219
 
@@ -222,36 +222,36 @@  discard block
 block discarded – undo
222 222
 	 * @param EE_Message $message
223 223
 	 * @return string   Actions that can be done on the current message.
224 224
 	 */
225
-	public function column_action( EE_Message $message ) {
226
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
225
+	public function column_action(EE_Message $message) {
226
+		EE_Registry::instance()->load_helper('MSG_Template');
227 227
 		$action_links = array(
228
-			'view' => EEH_MSG_Template::get_message_action_link( 'view', $message ),
229
-			'error' => EEH_MSG_Template::get_message_action_link( 'error', $message ),
230
-			'generate_now' => EEH_MSG_Template::get_message_action_link( 'generate_now', $message ),
231
-			'send_now' => EEH_MSG_Template::get_message_action_link( 'send_now', $message ),
232
-			'queue_for_resending' => EEH_MSG_Template::get_message_action_link( 'queue_for_resending', $message ),
233
-			'view_transaction' => EEH_MSG_Template::get_message_action_link( 'view_transaction', $message ),
228
+			'view' => EEH_MSG_Template::get_message_action_link('view', $message),
229
+			'error' => EEH_MSG_Template::get_message_action_link('error', $message),
230
+			'generate_now' => EEH_MSG_Template::get_message_action_link('generate_now', $message),
231
+			'send_now' => EEH_MSG_Template::get_message_action_link('send_now', $message),
232
+			'queue_for_resending' => EEH_MSG_Template::get_message_action_link('queue_for_resending', $message),
233
+			'view_transaction' => EEH_MSG_Template::get_message_action_link('view_transaction', $message),
234 234
 		);
235 235
 		$content = '';
236
-		switch ( $message->STS_ID() ) {
236
+		switch ($message->STS_ID()) {
237 237
 			case EEM_Message::status_sent :
238
-				$content = $action_links['view'] . $action_links['queue_for_resending'] . $action_links['view_transaction'];
238
+				$content = $action_links['view'].$action_links['queue_for_resending'].$action_links['view_transaction'];
239 239
 				break;
240 240
 			case EEM_Message::status_resend :
241
-				$content = $action_links['view'] . $action_links['send_now'] . $action_links['view_transaction'];
241
+				$content = $action_links['view'].$action_links['send_now'].$action_links['view_transaction'];
242 242
 				break;
243 243
 			case EEM_Message::status_retry :
244
-				$content = $action_links['view'] . $action_links['send_now'] . $action_links['error'] . $action_links['view_transaction'];
244
+				$content = $action_links['view'].$action_links['send_now'].$action_links['error'].$action_links['view_transaction'];
245 245
 				break;
246 246
 			case EEM_Message::status_failed :
247 247
 			case EEM_Message::status_debug_only :
248
-				$content = $action_links['error'] . $action_links['view_transaction'];
248
+				$content = $action_links['error'].$action_links['view_transaction'];
249 249
 				break;
250 250
 			case EEM_Message::status_idle :
251
-				$content = $action_links['view'] . $action_links['send_now'] . $action_links['view_transaction'];
251
+				$content = $action_links['view'].$action_links['send_now'].$action_links['view_transaction'];
252 252
 				break;
253 253
 			case EEM_Message::status_incomplete;
254
-				$content = $action_links['generate_now'] . $action_links['view_transaction'];
254
+				$content = $action_links['generate_now'].$action_links['view_transaction'];
255 255
 				break;
256 256
 		}
257 257
 		return $content;
@@ -269,54 +269,54 @@  discard block
 block discarded – undo
269 269
 	 * @return int | EE_Message[]
270 270
 	 * @throws \EE_Error
271 271
 	 */
272
-	protected function _get_messages( $perpage = 10, $view = 'all', $count = false, $all = false ) {
272
+	protected function _get_messages($perpage = 10, $view = 'all', $count = false, $all = false) {
273 273
 
274
-		$current_page = isset( $this->_req_data['paged'] ) && ! empty( $this->_req_data['paged'] )
274
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
275 275
 			? $this->_req_data['paged']
276 276
 			: 1;
277 277
 
278
-		$per_page = isset( $this->_req_data['perpage'] ) && ! empty( $this->_req_data['perpage'] )
278
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
279 279
 			? $this->_req_data['perpage']
280 280
 			: $perpage;
281 281
 
282
-		$offset = ( $current_page - 1 ) * $per_page;
283
-		$limit = $all || $count ? null : array( $offset, $per_page );
282
+		$offset = ($current_page - 1) * $per_page;
283
+		$limit = $all || $count ? null : array($offset, $per_page);
284 284
 		$query_params = array(
285
-			'order_by' => empty( $this->_req_data[ 'orderby' ] ) ? 'MSG_modified' : $this->_req_data[ 'orderby' ],
286
-			'order'    => empty( $this->_req_data[ 'order' ] ) ? 'DESC' : $this->_req_data[ 'order' ],
285
+			'order_by' => empty($this->_req_data['orderby']) ? 'MSG_modified' : $this->_req_data['orderby'],
286
+			'order'    => empty($this->_req_data['order']) ? 'DESC' : $this->_req_data['order'],
287 287
 			'limit'    => $limit,
288 288
 		);
289 289
 
290 290
 		/**
291 291
 		 * Any filters coming in from other routes?
292 292
 		 */
293
-		if ( isset( $this->_req_data['filterby'] ) ) {
294
-			$query_params = array_merge( $query_params, EEM_Message::instance()->filter_by_query_params() );
295
-			if ( ! $count ) {
293
+		if (isset($this->_req_data['filterby'])) {
294
+			$query_params = array_merge($query_params, EEM_Message::instance()->filter_by_query_params());
295
+			if ( ! $count) {
296 296
 				$query_params['group_by'] = 'MSG_ID';
297 297
 			}
298 298
 		}
299 299
 
300 300
 		//view conditionals
301
-		if ( $view !== 'all' && $count && $all ) {
301
+		if ($view !== 'all' && $count && $all) {
302 302
 			$query_params[0]['AND*view_conditional'] = array(
303
-				'STS_ID' => strtoupper( $view ),
303
+				'STS_ID' => strtoupper($view),
304 304
 			);
305 305
 		}
306 306
 
307
-		if ( ! $all && ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] !== 'all' ) {
307
+		if ( ! $all && ! empty($this->_req_data['status']) && $this->_req_data['status'] !== 'all') {
308 308
 			$query_params[0]['AND*view_conditional'] = array(
309
-				'STS_ID' => strtoupper( $this->_req_data['status'] ),
309
+				'STS_ID' => strtoupper($this->_req_data['status']),
310 310
 			);
311 311
 		}
312 312
 
313
-		if ( ! $all && ! empty( $this->_req_data['s'] ) ) {
314
-			$search_string = '%' . $this->_req_data['s'] . '%';
313
+		if ( ! $all && ! empty($this->_req_data['s'])) {
314
+			$search_string = '%'.$this->_req_data['s'].'%';
315 315
 			$query_params[0]['OR'] = array(
316
-				'MSG_to' => array( 'LIKE', $search_string ),
317
-				'MSG_from' => array( 'LIKE', $search_string ),
318
-				'MSG_subject' => array( 'LIKE', $search_string ),
319
-				'MSG_content' => array( 'LIKE', $search_string ),
316
+				'MSG_to' => array('LIKE', $search_string),
317
+				'MSG_from' => array('LIKE', $search_string),
318
+				'MSG_subject' => array('LIKE', $search_string),
319
+				'MSG_content' => array('LIKE', $search_string),
320 320
 			);
321 321
 		}
322 322
 
@@ -324,16 +324,16 @@  discard block
 block discarded – undo
324 324
 		//the messages system is in debug mode.
325 325
 		//Note: for backward compat with previous iterations, this is necessary because there may be EEM_Message::status_debug_only
326 326
 		//messages in the database.
327
-		if ( ! EEM_Message::debug() ) {
327
+		if ( ! EEM_Message::debug()) {
328 328
 			$query_params[0]['AND*debug_only_conditional'] = array(
329
-				'STS_ID' => array( '!=', EEM_Message::status_debug_only )
329
+				'STS_ID' => array('!=', EEM_Message::status_debug_only)
330 330
 			);
331 331
 		}
332 332
 
333 333
 		//account for filters
334 334
 		if (
335 335
 			! $all
336
-			&& isset( $this->_req_data['ee_messenger_filter_by'] )
336
+			&& isset($this->_req_data['ee_messenger_filter_by'])
337 337
 			&& $this->_req_data['ee_messenger_filter_by'] !== 'none_selected'
338 338
 		) {
339 339
 			$query_params[0]['AND*messenger_filter'] = array(
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 		}
343 343
 		if (
344 344
 			! $all
345
-			&& ! empty( $this->_req_data['ee_message_type_filter_by'] )
345
+			&& ! empty($this->_req_data['ee_message_type_filter_by'])
346 346
 			&& $this->_req_data['ee_message_type_filter_by'] !== 'none_selected'
347 347
 		) {
348 348
 			$query_params[0]['AND*message_type_filter'] = array(
@@ -352,17 +352,17 @@  discard block
 block discarded – undo
352 352
 
353 353
 		if (
354 354
 			! $all
355
-			&& ! empty( $this->_req_data['ee_context_filter_by'] )
355
+			&& ! empty($this->_req_data['ee_context_filter_by'])
356 356
 			&& $this->_req_data['ee_context_filter_by'] !== 'none_selected'
357 357
 		) {
358 358
 			$query_params[0]['AND*context_filter'] = array(
359
-				'MSG_context' => array( 'IN', explode( ',', $this->_req_data['ee_context_filter_by'] ) )
359
+				'MSG_context' => array('IN', explode(',', $this->_req_data['ee_context_filter_by']))
360 360
 			);
361 361
 		}
362 362
 
363 363
 		return $count
364
-			? EEM_Message::instance()->count( $query_params, null, true )
365
-			: EEM_Message::instance()->get_all( $query_params );
364
+			? EEM_Message::instance()->count($query_params, null, true)
365
+			: EEM_Message::instance()->get_all($query_params);
366 366
 	}
367 367
 
368 368
 
@@ -372,15 +372,15 @@  discard block
 block discarded – undo
372 372
 	 */
373 373
 	protected function _get_messengers_dropdown_filter() {
374 374
 		$messenger_options = array();
375
-		$active_messages_grouped_by_messenger = EEM_Message::instance()->get_all( array( 'group_by' => 'MSG_messenger' ) );
375
+		$active_messages_grouped_by_messenger = EEM_Message::instance()->get_all(array('group_by' => 'MSG_messenger'));
376 376
 
377 377
 		//setup array of messenger options
378
-		foreach ( $active_messages_grouped_by_messenger as $active_message ) {
379
-			if ( $active_message instanceof EE_Message ) {
380
-				$messenger_options[ $active_message->messenger() ] = ucwords( $active_message->messenger_label() );
378
+		foreach ($active_messages_grouped_by_messenger as $active_message) {
379
+			if ($active_message instanceof EE_Message) {
380
+				$messenger_options[$active_message->messenger()] = ucwords($active_message->messenger_label());
381 381
 			}
382 382
 		}
383
-		return $this->get_admin_page()->get_messengers_select_input( $messenger_options );
383
+		return $this->get_admin_page()->get_messengers_select_input($messenger_options);
384 384
 	}
385 385
 
386 386
 
@@ -391,15 +391,15 @@  discard block
 block discarded – undo
391 391
 	 */
392 392
 	protected function _get_message_types_dropdown_filter() {
393 393
 		$message_type_options = array();
394
-		$active_messages_grouped_by_message_type = EEM_Message::instance()->get_all( array( 'group_by' => 'MSG_message_type' ) );
394
+		$active_messages_grouped_by_message_type = EEM_Message::instance()->get_all(array('group_by' => 'MSG_message_type'));
395 395
 
396 396
 		//setup array of message type options
397
-		foreach ( $active_messages_grouped_by_message_type as $active_message ) {
398
-			if ( $active_message instanceof EE_Message ) {
399
-				$message_type_options[ $active_message->message_type() ] = ucwords( $active_message->message_type_label() );
397
+		foreach ($active_messages_grouped_by_message_type as $active_message) {
398
+			if ($active_message instanceof EE_Message) {
399
+				$message_type_options[$active_message->message_type()] = ucwords($active_message->message_type_label());
400 400
 			}
401 401
 		}
402
-		return $this->get_admin_page()->get_message_types_select_input( $message_type_options );
402
+		return $this->get_admin_page()->get_message_types_select_input($message_type_options);
403 403
 	}
404 404
 
405 405
 
@@ -409,21 +409,21 @@  discard block
 block discarded – undo
409 409
 	 */
410 410
 	protected function _get_contexts_for_message_types_dropdown_filter() {
411 411
 		$context_options = array();
412
-		$active_messages_grouped_by_context = EEM_Message::instance()->get_all( array( 'group_by' => 'MSG_context' ) );
412
+		$active_messages_grouped_by_context = EEM_Message::instance()->get_all(array('group_by' => 'MSG_context'));
413 413
 
414 414
 		//setup array of context options
415
-		foreach ( $active_messages_grouped_by_context as $active_message ) {
416
-			if ( $active_message instanceof EE_Message ) {
415
+		foreach ($active_messages_grouped_by_context as $active_message) {
416
+			if ($active_message instanceof EE_Message) {
417 417
 				$message_type = $active_message->message_type_object();
418
-				if ( $message_type instanceof EE_message_type ) {
419
-					foreach ( $message_type->get_contexts() as $context => $context_details ) {
420
-						if ( isset( $context_details['label'] ) ) {
421
-							$context_options[ $context ] = $context_details['label'];
418
+				if ($message_type instanceof EE_message_type) {
419
+					foreach ($message_type->get_contexts() as $context => $context_details) {
420
+						if (isset($context_details['label'])) {
421
+							$context_options[$context] = $context_details['label'];
422 422
 						}
423 423
 					}
424 424
 				}
425 425
 			}
426 426
 		}
427
-		return $this->get_admin_page()->get_contexts_for_message_types_select_input( $context_options );
427
+		return $this->get_admin_page()->get_contexts_for_message_types_select_input($context_options);
428 428
 	}
429 429
 } //end EE_Message_List_Table class
430 430
\ No newline at end of file
Please login to merge, or discard this patch.
espresso.php 1 patch
Spacing   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined( 'ABSPATH' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('ABSPATH')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /*
5 5
   Plugin Name:		Event Espresso
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
  *
43 43
  */
44 44
 
45
-if ( function_exists( 'espresso_version' ) ) {
45
+if (function_exists('espresso_version')) {
46 46
 
47 47
 	/**
48 48
 	 *    espresso_duplicate_plugin_error
@@ -51,12 +51,12 @@  discard block
 block discarded – undo
51 51
 	function espresso_duplicate_plugin_error() {
52 52
 		?>
53 53
 		<div class="error">
54
-			<p><?php _e( 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', 'event_espresso' ); ?></p>
54
+			<p><?php _e('Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', 'event_espresso'); ?></p>
55 55
 		</div>
56 56
 		<?php
57
-		espresso_deactivate_plugin( plugin_basename( __FILE__ ) );
57
+		espresso_deactivate_plugin(plugin_basename(__FILE__));
58 58
 	}
59
-	add_action( 'admin_notices', 'espresso_duplicate_plugin_error', 1 );
59
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
60 60
 
61 61
 } else {
62 62
 
@@ -67,103 +67,103 @@  discard block
 block discarded – undo
67 67
 	 * @return string
68 68
 	 */
69 69
 	function espresso_version() {
70
-		return apply_filters( 'FHEE__espresso__espresso_version', '4.9.10.rc.001' );
70
+		return apply_filters('FHEE__espresso__espresso_version', '4.9.10.rc.001');
71 71
 	}
72 72
 
73 73
 	// define versions
74
-	define( 'EVENT_ESPRESSO_VERSION', espresso_version() );
75
-	define( 'EE_MIN_WP_VER_REQUIRED', '4.1' );
76
-	define( 'EE_MIN_WP_VER_RECOMMENDED', '4.4.2' );
77
-	define( 'EE_MIN_PHP_VER_REQUIRED', '5.3.0' );
78
-	define( 'EE_MIN_PHP_VER_RECOMMENDED', '5.4.44' );
79
-	define( 'EVENT_ESPRESSO_POWERED_BY', 'Event Espresso - ' . EVENT_ESPRESSO_VERSION );
80
-	define( 'EVENT_ESPRESSO_MAIN_FILE', __FILE__ );
74
+	define('EVENT_ESPRESSO_VERSION', espresso_version());
75
+	define('EE_MIN_WP_VER_REQUIRED', '4.1');
76
+	define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2');
77
+	define('EE_MIN_PHP_VER_REQUIRED', '5.3.0');
78
+	define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44');
79
+	define('EVENT_ESPRESSO_POWERED_BY', 'Event Espresso - '.EVENT_ESPRESSO_VERSION);
80
+	define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
81 81
 	//used to be DIRECTORY_SEPARATOR, but that caused issues on windows
82
-	if ( ! defined( 'DS' ) ) {
83
-		define( 'DS', '/' );
82
+	if ( ! defined('DS')) {
83
+		define('DS', '/');
84 84
 	}
85
-	if ( ! defined( 'PS' ) ) {
86
-		define( 'PS', PATH_SEPARATOR );
85
+	if ( ! defined('PS')) {
86
+		define('PS', PATH_SEPARATOR);
87 87
 	}
88
-	if ( ! defined( 'SP' ) ) {
89
-		define( 'SP', ' ' );
88
+	if ( ! defined('SP')) {
89
+		define('SP', ' ');
90 90
 	}
91
-	if ( ! defined( 'EENL' ) ) {
92
-		define( 'EENL', "\n" );
91
+	if ( ! defined('EENL')) {
92
+		define('EENL', "\n");
93 93
 	}
94
-	define( 'EE_SUPPORT_EMAIL', '[email protected]' );
94
+	define('EE_SUPPORT_EMAIL', '[email protected]');
95 95
 	// define the plugin directory and URL
96
-	define( 'EE_PLUGIN_BASENAME', plugin_basename( EVENT_ESPRESSO_MAIN_FILE ) );
97
-	define( 'EE_PLUGIN_DIR_PATH', plugin_dir_path( EVENT_ESPRESSO_MAIN_FILE ) );
98
-	define( 'EE_PLUGIN_DIR_URL', plugin_dir_url( EVENT_ESPRESSO_MAIN_FILE ) );
96
+	define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
97
+	define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE));
98
+	define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE));
99 99
 	// main root folder paths
100
-	define( 'EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS );
101
-	define( 'EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS );
102
-	define( 'EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS );
103
-	define( 'EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS );
104
-	define( 'EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS );
105
-	define( 'EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS );
106
-	define( 'EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS );
107
-	define( 'EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS );
100
+	define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH.'admin_pages'.DS);
101
+	define('EE_CORE', EE_PLUGIN_DIR_PATH.'core'.DS);
102
+	define('EE_MODULES', EE_PLUGIN_DIR_PATH.'modules'.DS);
103
+	define('EE_PUBLIC', EE_PLUGIN_DIR_PATH.'public'.DS);
104
+	define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH.'shortcodes'.DS);
105
+	define('EE_WIDGETS', EE_PLUGIN_DIR_PATH.'widgets'.DS);
106
+	define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH.'payment_methods'.DS);
107
+	define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH.'caffeinated'.DS);
108 108
 	// core system paths
109
-	define( 'EE_ADMIN', EE_CORE . 'admin' . DS );
110
-	define( 'EE_CPTS', EE_CORE . 'CPTs' . DS );
111
-	define( 'EE_CLASSES', EE_CORE . 'db_classes' . DS );
112
-	define( 'EE_INTERFACES', EE_CORE . 'interfaces' . DS );
113
-	define( 'EE_BUSINESS', EE_CORE . 'business' . DS );
114
-	define( 'EE_MODELS', EE_CORE . 'db_models' . DS );
115
-	define( 'EE_HELPERS', EE_CORE . 'helpers' . DS );
116
-	define( 'EE_LIBRARIES', EE_CORE . 'libraries' . DS );
117
-	define( 'EE_TEMPLATES', EE_CORE . 'templates' . DS );
118
-	define( 'EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS );
119
-	define( 'EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS );
120
-	define( 'EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS );
109
+	define('EE_ADMIN', EE_CORE.'admin'.DS);
110
+	define('EE_CPTS', EE_CORE.'CPTs'.DS);
111
+	define('EE_CLASSES', EE_CORE.'db_classes'.DS);
112
+	define('EE_INTERFACES', EE_CORE.'interfaces'.DS);
113
+	define('EE_BUSINESS', EE_CORE.'business'.DS);
114
+	define('EE_MODELS', EE_CORE.'db_models'.DS);
115
+	define('EE_HELPERS', EE_CORE.'helpers'.DS);
116
+	define('EE_LIBRARIES', EE_CORE.'libraries'.DS);
117
+	define('EE_TEMPLATES', EE_CORE.'templates'.DS);
118
+	define('EE_THIRD_PARTY', EE_CORE.'third_party_libs'.DS);
119
+	define('EE_GLOBAL_ASSETS', EE_TEMPLATES.'global_assets'.DS);
120
+	define('EE_FORM_SECTIONS', EE_LIBRARIES.'form_sections'.DS);
121 121
 	// gateways
122
-	define( 'EE_GATEWAYS', EE_MODULES . 'gateways' . DS );
123
-	define( 'EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS );
122
+	define('EE_GATEWAYS', EE_MODULES.'gateways'.DS);
123
+	define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL.'modules'.DS.'gateways'.DS);
124 124
 	// asset URL paths
125
-	define( 'EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS );
126
-	define( 'EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS );
127
-	define( 'EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS );
128
-	define( 'EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS );
129
-	define( 'EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/' );
130
-	define( 'EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/' );
125
+	define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL.'core'.DS.'templates'.DS);
126
+	define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL.'global_assets'.DS);
127
+	define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL.'images'.DS);
128
+	define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL.'core'.DS.'third_party_libs'.DS);
129
+	define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL.'core/helpers/assets/');
130
+	define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL.'core/libraries/');
131 131
 	// define upload paths
132 132
 	$uploads = wp_upload_dir();
133 133
 	// define the uploads directory and URL
134
-	define( 'EVENT_ESPRESSO_UPLOAD_DIR', $uploads[ 'basedir' ] . DS . 'espresso' . DS );
135
-	define( 'EVENT_ESPRESSO_UPLOAD_URL', $uploads[ 'baseurl' ] . DS . 'espresso' . DS );
134
+	define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'].DS.'espresso'.DS);
135
+	define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'].DS.'espresso'.DS);
136 136
 	// define the templates directory and URL
137
-	define( 'EVENT_ESPRESSO_TEMPLATE_DIR', $uploads[ 'basedir' ] . DS . 'espresso' . DS . 'templates' . DS );
138
-	define( 'EVENT_ESPRESSO_TEMPLATE_URL', $uploads[ 'baseurl' ] . DS . 'espresso' . DS . 'templates' . DS );
137
+	define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'].DS.'espresso'.DS.'templates'.DS);
138
+	define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'].DS.'espresso'.DS.'templates'.DS);
139 139
 	// define the gateway directory and URL
140
-	define( 'EVENT_ESPRESSO_GATEWAY_DIR', $uploads[ 'basedir' ] . DS . 'espresso' . DS . 'gateways' . DS );
141
-	define( 'EVENT_ESPRESSO_GATEWAY_URL', $uploads[ 'baseurl' ] . DS . 'espresso' . DS . 'gateways' . DS );
140
+	define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'].DS.'espresso'.DS.'gateways'.DS);
141
+	define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'].DS.'espresso'.DS.'gateways'.DS);
142 142
 	// languages folder/path
143
-	define( 'EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS );
144
-	define( 'EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS );
143
+	define('EE_LANGUAGES_SAFE_LOC', '..'.DS.'uploads'.DS.'espresso'.DS.'languages'.DS);
144
+	define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'languages'.DS);
145 145
 	//check for dompdf fonts in uploads
146
-	if ( file_exists( EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS ) ) {
147
-		define( 'DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS );
146
+	if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS)) {
147
+		define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS);
148 148
 	}
149 149
 	//ajax constants
150
-	define( 'EE_FRONT_AJAX', isset( $_REQUEST[ 'ee_front_ajax' ] ) || isset( $_REQUEST[ 'data' ][ 'ee_front_ajax' ] ) ? true : false );
151
-	define( 'EE_ADMIN_AJAX', isset( $_REQUEST[ 'ee_admin_ajax' ] ) || isset( $_REQUEST[ 'data' ][ 'ee_admin_ajax' ] ) ? true : false );
150
+	define('EE_FRONT_AJAX', isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false);
151
+	define('EE_ADMIN_AJAX', isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false);
152 152
 	//just a handy constant occasionally needed for finding values representing infinity in the DB
153 153
 	//you're better to use this than its straight value (currently -1) in case you ever
154 154
 	//want to change its default value! or find when -1 means infinity
155
-	define( 'EE_INF_IN_DB', -1 );
156
-	define( 'EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX );
157
-	define( 'EE_DEBUG', false );
155
+	define('EE_INF_IN_DB', -1);
156
+	define('EE_INF', INF > (float) PHP_INT_MAX ? INF : PHP_INT_MAX);
157
+	define('EE_DEBUG', false);
158 158
 
159 159
 	/**
160 160
 	 *    espresso_plugin_activation
161 161
 	 *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
162 162
 	 */
163 163
 	function espresso_plugin_activation() {
164
-		update_option( 'ee_espresso_activation', true );
164
+		update_option('ee_espresso_activation', true);
165 165
 	}
166
-	register_activation_hook( EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation' );
166
+	register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
167 167
 
168 168
 
169 169
 
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 		//	}
178 178
 		//
179 179
 	}
180
-	register_deactivation_hook( EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation' );
180
+	register_deactivation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation');
181 181
 
182 182
 
183 183
 
@@ -187,15 +187,15 @@  discard block
 block discarded – undo
187 187
 	 */
188 188
 	function espresso_load_error_handling() {
189 189
 		// load debugging tools
190
-		if ( WP_DEBUG === true && is_readable( EE_HELPERS . 'EEH_Debug_Tools.helper.php' ) ) {
191
-			require_once( EE_HELPERS . 'EEH_Debug_Tools.helper.php' );
190
+		if (WP_DEBUG === true && is_readable(EE_HELPERS.'EEH_Debug_Tools.helper.php')) {
191
+			require_once(EE_HELPERS.'EEH_Debug_Tools.helper.php');
192 192
 			EEH_Debug_Tools::instance();
193 193
 		}
194 194
 		// load error handling
195
-		if ( is_readable( EE_CORE . 'EE_Error.core.php' ) ) {
196
-			require_once( EE_CORE . 'EE_Error.core.php' );
195
+		if (is_readable(EE_CORE.'EE_Error.core.php')) {
196
+			require_once(EE_CORE.'EE_Error.core.php');
197 197
 		} else {
198
-			wp_die( __( 'The EE_Error core class could not be loaded.', 'event_espresso' ) );
198
+			wp_die(__('The EE_Error core class could not be loaded.', 'event_espresso'));
199 199
 		}
200 200
 	}
201 201
 
@@ -209,25 +209,25 @@  discard block
 block discarded – undo
209 209
 	 * @param    string $full_path_to_file
210 210
 	 * @throws    EE_Error
211 211
 	 */
212
-	function espresso_load_required( $classname, $full_path_to_file ) {
212
+	function espresso_load_required($classname, $full_path_to_file) {
213 213
 		static $error_handling_loaded = false;
214
-		if ( ! $error_handling_loaded ) {
214
+		if ( ! $error_handling_loaded) {
215 215
 			espresso_load_error_handling();
216 216
 			$error_handling_loaded = true;
217 217
 		}
218
-		if ( is_readable( $full_path_to_file ) ) {
219
-			require_once( $full_path_to_file );
218
+		if (is_readable($full_path_to_file)) {
219
+			require_once($full_path_to_file);
220 220
 		} else {
221
-			throw new EE_Error ( sprintf(
222
-				__( 'The %s class file could not be located or is not readable due to file permissions.', 'event_espresso' ),
221
+			throw new EE_Error(sprintf(
222
+				__('The %s class file could not be located or is not readable due to file permissions.', 'event_espresso'),
223 223
 				$classname
224
-			) );
224
+			));
225 225
 		}
226 226
 	}
227 227
 
228
-	espresso_load_required( 'EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php' );
229
-	espresso_load_required( 'EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php' );
230
-	espresso_load_required( 'EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php' );
228
+	espresso_load_required('EEH_Base', EE_CORE.'helpers'.DS.'EEH_Base.helper.php');
229
+	espresso_load_required('EEH_File', EE_CORE.'helpers'.DS.'EEH_File.helper.php');
230
+	espresso_load_required('EE_Bootstrap', EE_CORE.'EE_Bootstrap.core.php');
231 231
 	new EE_Bootstrap();
232 232
 
233 233
 
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 
237 237
 
238 238
 
239
-if ( ! function_exists( 'espresso_deactivate_plugin' ) ) {
239
+if ( ! function_exists('espresso_deactivate_plugin')) {
240 240
 	/**
241 241
 	*    deactivate_plugin
242 242
 	* usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
@@ -245,11 +245,11 @@  discard block
 block discarded – undo
245 245
 	* @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
246 246
 	* @return    void
247 247
 	*/
248
-	function espresso_deactivate_plugin( $plugin_basename = '' ) {
249
-		if ( ! function_exists( 'deactivate_plugins' ) ) {
250
-			require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
248
+	function espresso_deactivate_plugin($plugin_basename = '') {
249
+		if ( ! function_exists('deactivate_plugins')) {
250
+			require_once(ABSPATH.'wp-admin/includes/plugin.php');
251 251
 		}
252
-		unset( $_GET[ 'activate' ], $_REQUEST[ 'activate' ] );
253
-		deactivate_plugins( $plugin_basename );
252
+		unset($_GET['activate'], $_REQUEST['activate']);
253
+		deactivate_plugins($plugin_basename);
254 254
 	}
255 255
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Base.model.php 1 patch
Spacing   +969 added lines, -969 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
 	}
@@ -1019,16 +1019,16 @@  discard block
 block discarded – undo
1019 1019
 	 * @return EE_Base_Class | NULL
1020 1020
 	 * @throws \EE_Error
1021 1021
 	 */
1022
-	public function get_one($query_params = array()){
1023
-		if( ! is_array( $query_params ) ){
1024
-			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' );
1022
+	public function get_one($query_params = array()) {
1023
+		if ( ! is_array($query_params)) {
1024
+			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');
1025 1025
 			$query_params = array();
1026 1026
 		}
1027 1027
 		$query_params['limit'] = 1;
1028 1028
 		$items = $this->get_all($query_params);
1029
-		if(empty($items)){
1029
+		if (empty($items)) {
1030 1030
 			return null;
1031
-		}else{
1031
+		} else {
1032 1032
 			return array_shift($items);
1033 1033
 		}
1034 1034
 	}
@@ -1051,8 +1051,8 @@  discard block
 block discarded – undo
1051 1051
 	 * @return EE_Base_Class[]|array
1052 1052
 	 * @throws \EE_Error
1053 1053
 	 */
1054
-	public function next_x( $current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
1055
-		return $this->_get_consecutive( $current_field_value, '>', $field_to_order_by, $limit, $query_params, $columns_to_select );
1054
+	public function next_x($current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
1055
+		return $this->_get_consecutive($current_field_value, '>', $field_to_order_by, $limit, $query_params, $columns_to_select);
1056 1056
 	}
1057 1057
 
1058 1058
 
@@ -1073,8 +1073,8 @@  discard block
 block discarded – undo
1073 1073
 	 * @return EE_Base_Class[]|array
1074 1074
 	 * @throws \EE_Error
1075 1075
 	 */
1076
-	public function previous_x( $current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
1077
-		return $this->_get_consecutive( $current_field_value, '<', $field_to_order_by, $limit, $query_params, $columns_to_select );
1076
+	public function previous_x($current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
1077
+		return $this->_get_consecutive($current_field_value, '<', $field_to_order_by, $limit, $query_params, $columns_to_select);
1078 1078
 	}
1079 1079
 
1080 1080
 
@@ -1095,9 +1095,9 @@  discard block
 block discarded – undo
1095 1095
 	 * @return EE_Base_Class|null|array()
1096 1096
 	 * @throws \EE_Error
1097 1097
 	 */
1098
-	public function next( $current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) {
1099
-		$results = $this->_get_consecutive( $current_field_value, '>', $field_to_order_by, 1, $query_params, $columns_to_select );
1100
-		return empty( $results ) ? null : reset( $results );
1098
+	public function next($current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null) {
1099
+		$results = $this->_get_consecutive($current_field_value, '>', $field_to_order_by, 1, $query_params, $columns_to_select);
1100
+		return empty($results) ? null : reset($results);
1101 1101
 	}
1102 1102
 
1103 1103
 
@@ -1119,9 +1119,9 @@  discard block
 block discarded – undo
1119 1119
  * @return EE_Base_Class|null|array()
1120 1120
 	 * @throws EE_Error
1121 1121
 	 */
1122
-	public function previous( $current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) {
1123
-		$results = $this->_get_consecutive( $current_field_value, '<', $field_to_order_by, 1, $query_params, $columns_to_select );
1124
-		return empty( $results ) ? null : reset( $results );
1122
+	public function previous($current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null) {
1123
+		$results = $this->_get_consecutive($current_field_value, '<', $field_to_order_by, 1, $query_params, $columns_to_select);
1124
+		return empty($results) ? null : reset($results);
1125 1125
 	}
1126 1126
 
1127 1127
 
@@ -1142,42 +1142,42 @@  discard block
 block discarded – undo
1142 1142
 	 * @return EE_Base_Class[]|array
1143 1143
 	 * @throws EE_Error
1144 1144
 	 */
1145
-	protected function _get_consecutive( $current_field_value, $operand = '>', $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
1145
+	protected function _get_consecutive($current_field_value, $operand = '>', $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
1146 1146
 		//if $field_to_order_by is empty then let's assume we're ordering by the primary key.
1147
-		if ( empty( $field_to_order_by ) ) {
1148
-			if ( $this->has_primary_key_field() ) {
1147
+		if (empty($field_to_order_by)) {
1148
+			if ($this->has_primary_key_field()) {
1149 1149
 				$field_to_order_by = $this->get_primary_key_field()->get_name();
1150 1150
 			} else {
1151 1151
 
1152
-				if ( WP_DEBUG ) {
1153
-					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' ) );
1152
+				if (WP_DEBUG) {
1153
+					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'));
1154 1154
 				}
1155
-				EE_Error::add_error( __('There was an error with the query.', 'event_espresso') );
1155
+				EE_Error::add_error(__('There was an error with the query.', 'event_espresso'));
1156 1156
 				return array();
1157 1157
 			}
1158 1158
 		}
1159 1159
 
1160
-		if( ! is_array( $query_params ) ){
1161
-			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' );
1160
+		if ( ! is_array($query_params)) {
1161
+			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');
1162 1162
 			$query_params = array();
1163 1163
 		}
1164 1164
 
1165 1165
 		//let's add the where query param for consecutive look up.
1166
-		$query_params[0][ $field_to_order_by ] = array( $operand, $current_field_value );
1166
+		$query_params[0][$field_to_order_by] = array($operand, $current_field_value);
1167 1167
 		$query_params['limit'] = $limit;
1168 1168
 
1169 1169
 		//set direction
1170
-		$incoming_orderby = isset( $query_params['order_by'] ) ? (array)$query_params['order_by'] : array();
1170
+		$incoming_orderby = isset($query_params['order_by']) ? (array) $query_params['order_by'] : array();
1171 1171
 		$query_params['order_by'] = $operand === '>'
1172
-			? array( $field_to_order_by => 'ASC' ) + $incoming_orderby
1173
-			: array( $field_to_order_by => 'DESC') + $incoming_orderby;
1172
+			? array($field_to_order_by => 'ASC') + $incoming_orderby
1173
+			: array($field_to_order_by => 'DESC') + $incoming_orderby;
1174 1174
 
1175 1175
 		//if $columns_to_select is empty then that means we're returning EE_Base_Class objects
1176
-		if ( empty( $columns_to_select ) ) {
1177
-			return $this->get_all( $query_params );
1176
+		if (empty($columns_to_select)) {
1177
+			return $this->get_all($query_params);
1178 1178
 		} else {
1179 1179
 			//getting just the fields
1180
-			return $this->_get_all_wpdb_results( $query_params, ARRAY_A, $columns_to_select );
1180
+			return $this->_get_all_wpdb_results($query_params, ARRAY_A, $columns_to_select);
1181 1181
 		}
1182 1182
 	}
1183 1183
 
@@ -1188,18 +1188,18 @@  discard block
 block discarded – undo
1188 1188
 	 * This sets the _timezone property after model object has been instantiated.
1189 1189
 	 * @param null | string $timezone valid PHP DateTimeZone timezone string
1190 1190
 	 */
1191
-	public function set_timezone( $timezone ) {
1192
-		if ( $timezone !== null ) {
1191
+	public function set_timezone($timezone) {
1192
+		if ($timezone !== null) {
1193 1193
 			$this->_timezone = $timezone;
1194 1194
 		}
1195 1195
 		//note we need to loop through relations and set the timezone on those objects as well.
1196
-		foreach ( $this->_model_relations as $relation ) {
1197
-			$relation->set_timezone( $timezone );
1196
+		foreach ($this->_model_relations as $relation) {
1197
+			$relation->set_timezone($timezone);
1198 1198
 		}
1199 1199
 		//and finally we do the same for any datetime fields
1200
-		foreach ( $this->_fields as $field ) {
1201
-			if ( $field instanceof EE_Datetime_Field ) {
1202
-				$field->set_timezone( $timezone );
1200
+		foreach ($this->_fields as $field) {
1201
+			if ($field instanceof EE_Datetime_Field) {
1202
+				$field->set_timezone($timezone);
1203 1203
 			}
1204 1204
 		}
1205 1205
 	}
@@ -1214,9 +1214,9 @@  discard block
 block discarded – undo
1214 1214
 	 */
1215 1215
 	public function get_timezone() {
1216 1216
 		//first validate if timezone is set.  If not, then let's set it be whatever is set on the model fields.
1217
-		if ( empty( $this->_timezone ) ) {
1218
-			foreach( $this->_fields as $field ) {
1219
-				if ( $field instanceof EE_Datetime_Field ) {
1217
+		if (empty($this->_timezone)) {
1218
+			foreach ($this->_fields as $field) {
1219
+				if ($field instanceof EE_Datetime_Field) {
1220 1220
 					$this->set_timezone($field->get_timezone());
1221 1221
 					break;
1222 1222
 				}
@@ -1224,8 +1224,8 @@  discard block
 block discarded – undo
1224 1224
 		}
1225 1225
 
1226 1226
 		//if timezone STILL empty then return the default timezone for the site.
1227
-		if ( empty( $this->_timezone ) ) {
1228
-			$this->set_timezone( EEH_DTT_Helper::get_timezone() );
1227
+		if (empty($this->_timezone)) {
1228
+			$this->set_timezone(EEH_DTT_Helper::get_timezone());
1229 1229
 		}
1230 1230
 		return $this->_timezone;
1231 1231
 	}
@@ -1243,19 +1243,19 @@  discard block
 block discarded – undo
1243 1243
 	 *
1244 1244
 	 * @return array formats in an array with the date format first, and the time format last.
1245 1245
 	 */
1246
-	public function get_formats_for( $field_name, $pretty = false ) {
1247
-		$field_settings = $this->field_settings_for( $field_name );
1246
+	public function get_formats_for($field_name, $pretty = false) {
1247
+		$field_settings = $this->field_settings_for($field_name);
1248 1248
 
1249 1249
 		//if not a valid EE_Datetime_Field then throw error
1250
-		if ( ! $field_settings instanceof EE_Datetime_Field ) {
1251
-			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 ) );
1250
+		if ( ! $field_settings instanceof EE_Datetime_Field) {
1251
+			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));
1252 1252
 		}
1253 1253
 
1254 1254
 		//while we are here, let's make sure the timezone internally in EEM_Base matches what is stored on
1255 1255
 		//the field.
1256 1256
 		$this->_timezone = $field_settings->get_timezone();
1257 1257
 
1258
-		return array( $field_settings->get_date_format( $pretty ), $field_settings->get_time_format( $pretty ) );
1258
+		return array($field_settings->get_date_format($pretty), $field_settings->get_time_format($pretty));
1259 1259
 	}
1260 1260
 
1261 1261
 
@@ -1279,25 +1279,25 @@  discard block
 block discarded – undo
1279 1279
 	 * @return int|string  If the given field_name is not of the EE_Datetime_Field type, then an EE_Error
1280 1280
 	 *                    	     exception is triggered.
1281 1281
 	 */
1282
-	public function current_time_for_query( $field_name, $timestamp = false, $what = 'both' ) {
1283
-		$formats = $this->get_formats_for( $field_name );
1282
+	public function current_time_for_query($field_name, $timestamp = false, $what = 'both') {
1283
+		$formats = $this->get_formats_for($field_name);
1284 1284
 
1285
-		$DateTime = new DateTime( "now", new DateTimeZone( $this->_timezone ) );
1285
+		$DateTime = new DateTime("now", new DateTimeZone($this->_timezone));
1286 1286
 
1287
-		if ( $timestamp ) {
1288
-			return $DateTime->format( 'U' );
1287
+		if ($timestamp) {
1288
+			return $DateTime->format('U');
1289 1289
 		}
1290 1290
 
1291 1291
 		//not returning timestamp, so return formatted string in timezone.
1292
-		switch( $what ) {
1292
+		switch ($what) {
1293 1293
 			case 'time' :
1294
-				return $DateTime->format( $formats[1] );
1294
+				return $DateTime->format($formats[1]);
1295 1295
 				break;
1296 1296
 			case 'date' :
1297
-				return $DateTime->format( $formats[0] );
1297
+				return $DateTime->format($formats[0]);
1298 1298
 				break;
1299 1299
 			default :
1300
-				return $DateTime->format( implode( ' ', $formats ) );
1300
+				return $DateTime->format(implode(' ', $formats));
1301 1301
 				break;
1302 1302
 		}
1303 1303
 	}
@@ -1319,17 +1319,17 @@  discard block
 block discarded – undo
1319 1319
 	 * @return DateTime
1320 1320
 	 * @throws \EE_Error
1321 1321
 	 */
1322
-	public function convert_datetime_for_query( $field_name, $timestring, $incoming_format, $timezone = '' ) {
1322
+	public function convert_datetime_for_query($field_name, $timestring, $incoming_format, $timezone = '') {
1323 1323
 
1324 1324
 		//just using this to ensure the timezone is set correctly internally
1325
-		$this->get_formats_for( $field_name );
1325
+		$this->get_formats_for($field_name);
1326 1326
 
1327 1327
 		//load EEH_DTT_Helper
1328
-		$set_timezone = empty( $timezone ) ? EEH_DTT_Helper::get_timezone() : $timezone;
1328
+		$set_timezone = empty($timezone) ? EEH_DTT_Helper::get_timezone() : $timezone;
1329 1329
 
1330
-		$incomingDateTime = date_create_from_format( $incoming_format, $timestring, new DateTimeZone( $set_timezone ) );
1330
+		$incomingDateTime = date_create_from_format($incoming_format, $timestring, new DateTimeZone($set_timezone));
1331 1331
 
1332
-		return $incomingDateTime->setTimezone( new DateTimeZone( $this->_timezone ) );
1332
+		return $incomingDateTime->setTimezone(new DateTimeZone($this->_timezone));
1333 1333
 	}
1334 1334
 
1335 1335
 
@@ -1339,7 +1339,7 @@  discard block
 block discarded – undo
1339 1339
 	 * Gets all the tables comprising this model. Array keys are the table aliases, and values are EE_Table objects
1340 1340
 	 * @return EE_Table_Base[]
1341 1341
 	 */
1342
-	public function get_tables(){
1342
+	public function get_tables() {
1343 1343
 		return $this->_tables;
1344 1344
 	}
1345 1345
 
@@ -1375,9 +1375,9 @@  discard block
 block discarded – undo
1375 1375
 	 * @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)
1376 1376
 	 * @throws \EE_Error
1377 1377
 	 */
1378
-	public function update($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE){
1379
-		if( ! is_array( $query_params ) ){
1380
-			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' );
1378
+	public function update($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE) {
1379
+		if ( ! is_array($query_params)) {
1380
+			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');
1381 1381
 			$query_params = array();
1382 1382
 		}
1383 1383
 		/**
@@ -1387,7 +1387,7 @@  discard block
 block discarded – undo
1387 1387
 		 * @param array $fields_n_values the updated fields and their new values
1388 1388
 		 * @param array $query_params @see EEM_Base::get_all()
1389 1389
 		 */
1390
-		do_action( 'AHEE__EEM_Base__update__begin',$this, $fields_n_values, $query_params );
1390
+		do_action('AHEE__EEM_Base__update__begin', $this, $fields_n_values, $query_params);
1391 1391
 		/**
1392 1392
 		 * Filters the fields about to be updated given the query parameters. You can provide the
1393 1393
 		 * $query_params to $this->get_all() to find exactly which records will be updated
@@ -1395,10 +1395,10 @@  discard block
 block discarded – undo
1395 1395
 		 * @param EEM_Base $model the model being queried
1396 1396
 		 * @param array $query_params see EEM_Base::get_all()
1397 1397
 		 */
1398
-		$fields_n_values = (array)apply_filters( 'FHEE__EEM_Base__update__fields_n_values', $fields_n_values, $this, $query_params );
1398
+		$fields_n_values = (array) apply_filters('FHEE__EEM_Base__update__fields_n_values', $fields_n_values, $this, $query_params);
1399 1399
 		//need to verify that, for any entry we want to update, there are entries in each secondary table.
1400 1400
 		//to do that, for each table, verify that it's PK isn't null.
1401
-		$tables= $this->get_tables();
1401
+		$tables = $this->get_tables();
1402 1402
 
1403 1403
 		//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
1404 1404
 		//NOTE: we should make this code more efficient by NOT querying twice
@@ -1408,29 +1408,29 @@  discard block
 block discarded – undo
1408 1408
 			//we want to make sure the default_where strategy is ignored
1409 1409
 			$this->_ignore_where_strategy = TRUE;
1410 1410
 			$wpdb_select_results = $this->_get_all_wpdb_results($query_params);
1411
-			foreach( $wpdb_select_results as $wpdb_result ){
1411
+			foreach ($wpdb_select_results as $wpdb_result) {
1412 1412
 				// type cast stdClass as array
1413
-				$wpdb_result = (array)$wpdb_result;
1413
+				$wpdb_result = (array) $wpdb_result;
1414 1414
 				//get the model object's PK, as we'll want this if we need to insert a row into secondary tables
1415
-				if( $this->has_primary_key_field() ){
1416
-					$main_table_pk_value = $wpdb_result[ $this->get_primary_key_field()->get_qualified_column() ];
1417
-				}else{
1415
+				if ($this->has_primary_key_field()) {
1416
+					$main_table_pk_value = $wpdb_result[$this->get_primary_key_field()->get_qualified_column()];
1417
+				} else {
1418 1418
 					//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)
1419 1419
 					$main_table_pk_value = null;
1420 1420
 				}
1421 1421
 				//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
1422 1422
 				//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
1423
-				if(count($tables) > 1){
1423
+				if (count($tables) > 1) {
1424 1424
 					//foreach matching row in the DB, ensure that each table's PK isn't null. If so, there must not be an entry
1425 1425
 					//in that table, and so we'll want to insert one
1426
-					foreach($tables as $table_obj){
1426
+					foreach ($tables as $table_obj) {
1427 1427
 						$this_table_pk_column = $table_obj->get_fully_qualified_pk_column();
1428 1428
 						//if there is no private key for this table on the results, it means there's no entry
1429 1429
 						//in this table, right? so insert a row in the current table, using any fields available
1430
-						if( ! ( array_key_exists( $this_table_pk_column, $wpdb_result) && $wpdb_result[ $this_table_pk_column ] )){
1430
+						if ( ! (array_key_exists($this_table_pk_column, $wpdb_result) && $wpdb_result[$this_table_pk_column])) {
1431 1431
 							$success = $this->_insert_into_specific_table($table_obj, $fields_n_values, $main_table_pk_value);
1432 1432
 							//if we died here, report the error
1433
-							if( ! $success ) {
1433
+							if ( ! $success) {
1434 1434
 								return false;
1435 1435
 							}
1436 1436
 						}
@@ -1450,44 +1450,44 @@  discard block
 block discarded – undo
1450 1450
 		//if this wasn't called from a model object (to update itself)
1451 1451
 		//then we want to make sure we keep all the existing
1452 1452
 		//model objects in sync with the db
1453
-		if( $keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object ){
1454
-			if( $this->has_primary_key_field() ){
1455
-				$model_objs_affected_ids = $this->get_col( $query_params );
1456
-			}else{
1453
+		if ($keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object) {
1454
+			if ($this->has_primary_key_field()) {
1455
+				$model_objs_affected_ids = $this->get_col($query_params);
1456
+			} else {
1457 1457
 				//we need to select a bunch of columns and then combine them into the the "index primary key string"s
1458
-				$models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A );
1458
+				$models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A);
1459 1459
 				$model_objs_affected_ids = array();
1460
-				foreach( $models_affected_key_columns as $row ){
1461
-					$combined_index_key = $this->get_index_primary_key_string( $row );
1462
-					$model_objs_affected_ids[ $combined_index_key ] = $combined_index_key;
1460
+				foreach ($models_affected_key_columns as $row) {
1461
+					$combined_index_key = $this->get_index_primary_key_string($row);
1462
+					$model_objs_affected_ids[$combined_index_key] = $combined_index_key;
1463 1463
 				}
1464 1464
 
1465 1465
 			}
1466 1466
 
1467
-			if( ! $model_objs_affected_ids ){
1467
+			if ( ! $model_objs_affected_ids) {
1468 1468
 				//wait wait wait- if nothing was affected let's stop here
1469 1469
 				return 0;
1470 1470
 			}
1471
-			foreach( $model_objs_affected_ids as $id ){
1472
-				$model_obj_in_entity_map = $this->get_from_entity_map( $id );
1473
-				if( $model_obj_in_entity_map ){
1474
-					foreach( $fields_n_values as $field => $new_value ){
1475
-						$model_obj_in_entity_map->set( $field, $new_value );
1471
+			foreach ($model_objs_affected_ids as $id) {
1472
+				$model_obj_in_entity_map = $this->get_from_entity_map($id);
1473
+				if ($model_obj_in_entity_map) {
1474
+					foreach ($fields_n_values as $field => $new_value) {
1475
+						$model_obj_in_entity_map->set($field, $new_value);
1476 1476
 					}
1477 1477
 				}
1478 1478
 			}
1479 1479
 			//if there is a primary key on this model, we can now do a slight optimization
1480
-			if( $this->has_primary_key_field() ){
1480
+			if ($this->has_primary_key_field()) {
1481 1481
 				//we already know what we want to update. So let's make the query simpler so it's a little more efficient
1482 1482
 				$query_params = array(
1483
-					array( $this->primary_key_name() => array( 'IN', $model_objs_affected_ids ) ),
1484
-					'limit' => count( $model_objs_affected_ids ), 'default_where_conditions' => 'none' );
1483
+					array($this->primary_key_name() => array('IN', $model_objs_affected_ids)),
1484
+					'limit' => count($model_objs_affected_ids), 'default_where_conditions' => 'none' );
1485 1485
 			}
1486 1486
 		}
1487 1487
 
1488
-		$model_query_info = $this->_create_model_query_info_carrier( $query_params );
1489
-		$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.
1490
-		$rows_affected = $this->_do_wpdb_query('query', array( $SQL ) );
1488
+		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1489
+		$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.
1490
+		$rows_affected = $this->_do_wpdb_query('query', array($SQL));
1491 1491
 		/**
1492 1492
 		 * Action called after a model update call has been made.
1493 1493
 		 *
@@ -1496,8 +1496,8 @@  discard block
 block discarded – undo
1496 1496
 		 * @param array $query_params @see EEM_Base::get_all()
1497 1497
 		 * @param int $rows_affected
1498 1498
 		 */
1499
-		do_action( 'AHEE__EEM_Base__update__end',$this, $fields_n_values, $query_params, $rows_affected );
1500
-		return $rows_affected;//how many supposedly got updated
1499
+		do_action('AHEE__EEM_Base__update__end', $this, $fields_n_values, $query_params, $rows_affected);
1500
+		return $rows_affected; //how many supposedly got updated
1501 1501
 	}
1502 1502
 
1503 1503
 
@@ -1513,22 +1513,22 @@  discard block
 block discarded – undo
1513 1513
 	 * @return array just like $wpdb->get_col()
1514 1514
 	 * @throws \EE_Error
1515 1515
 	 */
1516
-	public function get_col( $query_params  = array(), $field_to_select = NULL ){
1516
+	public function get_col($query_params = array(), $field_to_select = NULL) {
1517 1517
 
1518
-		if( $field_to_select ){
1519
-			$field = $this->field_settings_for( $field_to_select );
1520
-		}elseif( $this->has_primary_key_field ( ) ){
1518
+		if ($field_to_select) {
1519
+			$field = $this->field_settings_for($field_to_select);
1520
+		}elseif ($this->has_primary_key_field( )) {
1521 1521
 			$field = $this->get_primary_key_field();
1522
-		}else{
1522
+		} else {
1523 1523
 			//no primary key, just grab the first column
1524
-			$field = reset( $this->field_settings());
1524
+			$field = reset($this->field_settings());
1525 1525
 		}
1526 1526
 
1527 1527
 
1528 1528
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1529 1529
 		$select_expressions = $field->get_qualified_column();
1530
-		$SQL ="SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
1531
-		return $this->_do_wpdb_query('get_col', array( $SQL ) );
1530
+		$SQL = "SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
1531
+		return $this->_do_wpdb_query('get_col', array($SQL));
1532 1532
 	}
1533 1533
 
1534 1534
 
@@ -1541,12 +1541,12 @@  discard block
 block discarded – undo
1541 1541
 	 * @return string
1542 1542
 	 * @throws \EE_Error
1543 1543
 	 */
1544
-	public function get_var( $query_params = array(), $field_to_select = NULL ) {
1545
-		$query_params[ 'limit' ] = 1;
1546
-		$col = $this->get_col( $query_params, $field_to_select );
1547
-		if( ! empty( $col ) ) {
1548
-			return reset( $col );
1549
-		}else{
1544
+	public function get_var($query_params = array(), $field_to_select = NULL) {
1545
+		$query_params['limit'] = 1;
1546
+		$col = $this->get_col($query_params, $field_to_select);
1547
+		if ( ! empty($col)) {
1548
+			return reset($col);
1549
+		} else {
1550 1550
 			return NULL;
1551 1551
 		}
1552 1552
 	}
@@ -1562,19 +1562,19 @@  discard block
 block discarded – undo
1562 1562
 	 * @return string of SQL
1563 1563
 	 * @throws \EE_Error
1564 1564
 	 */
1565
-	public function _construct_update_sql($fields_n_values){
1565
+	public function _construct_update_sql($fields_n_values) {
1566 1566
 		/** @type WPDB $wpdb */
1567 1567
 		global $wpdb;
1568 1568
 		$cols_n_values = array();
1569
-		foreach($fields_n_values as $field_name => $value){
1569
+		foreach ($fields_n_values as $field_name => $value) {
1570 1570
 			$field_obj = $this->field_settings_for($field_name);
1571 1571
 			//if the value is NULL, we want to assign the value to that.
1572 1572
 			//wpdb->prepare doesn't really handle that properly
1573
-			$prepared_value = $this->_prepare_value_or_use_default( $field_obj, $fields_n_values );
1574
-			$value_sql = $prepared_value===NULL ? 'NULL' : $wpdb->prepare( $field_obj->get_wpdb_data_type(), $prepared_value );
1573
+			$prepared_value = $this->_prepare_value_or_use_default($field_obj, $fields_n_values);
1574
+			$value_sql = $prepared_value === NULL ? 'NULL' : $wpdb->prepare($field_obj->get_wpdb_data_type(), $prepared_value);
1575 1575
 			$cols_n_values[] = $field_obj->get_qualified_column()."=".$value_sql;
1576 1576
 		}
1577
-		return implode(",",$cols_n_values);
1577
+		return implode(",", $cols_n_values);
1578 1578
 
1579 1579
 	}
1580 1580
 
@@ -1590,10 +1590,10 @@  discard block
 block discarded – undo
1590 1590
 	 * @return boolean whether the row got deleted or not
1591 1591
 	 * @throws \EE_Error
1592 1592
 	 */
1593
-	public function delete_permanently_by_ID( $id ) {
1593
+	public function delete_permanently_by_ID($id) {
1594 1594
 		return $this->delete_permanently(
1595 1595
 			array(
1596
-				array( $this->get_primary_key_field()->get_name() => $id ),
1596
+				array($this->get_primary_key_field()->get_name() => $id),
1597 1597
 				'limit' 	=> 1
1598 1598
 			)
1599 1599
 		);
@@ -1609,10 +1609,10 @@  discard block
 block discarded – undo
1609 1609
 	 * @return boolean whether the row got deleted or not
1610 1610
 	 * @throws \EE_Error
1611 1611
 	 */
1612
-	public function delete_by_ID( $id ){
1612
+	public function delete_by_ID($id) {
1613 1613
 		return $this->delete(
1614 1614
 			array(
1615
-				array( $this->get_primary_key_field()->get_name() => $id ),
1615
+				array($this->get_primary_key_field()->get_name() => $id),
1616 1616
 				'limit' 	=> 1
1617 1617
 			)
1618 1618
 		);
@@ -1631,7 +1631,7 @@  discard block
 block discarded – undo
1631 1631
 	 * @return int how many rows got deleted
1632 1632
 	 * @throws \EE_Error
1633 1633
 	 */
1634
-	public function delete($query_params,$allow_blocking = true){
1634
+	public function delete($query_params, $allow_blocking = true) {
1635 1635
 		return $this->delete_permanently($query_params, $allow_blocking);
1636 1636
 	}
1637 1637
 
@@ -1649,7 +1649,7 @@  discard block
 block discarded – undo
1649 1649
 	 * @return int how many rows got deleted
1650 1650
 	 * @throws \EE_Error
1651 1651
 	 */
1652
-	public function delete_permanently($query_params,$allow_blocking = true){
1652
+	public function delete_permanently($query_params, $allow_blocking = true) {
1653 1653
 		/**
1654 1654
 		 * Action called just before performing a real deletion query. You can use the
1655 1655
 		 * model and its $query_params to find exactly which items will be deleted
@@ -1658,31 +1658,31 @@  discard block
 block discarded – undo
1658 1658
 		 * @param boolean $allow_blocking whether or not to allow related model objects
1659 1659
 		 * to block (prevent) this deletion
1660 1660
 		 */
1661
-		do_action( 'AHEE__EEM_Base__delete__begin', $this, $query_params, $allow_blocking );
1661
+		do_action('AHEE__EEM_Base__delete__begin', $this, $query_params, $allow_blocking);
1662 1662
 		//some MySQL databases may be running safe mode, which may restrict
1663 1663
 		//deletion if there is no KEY column used in the WHERE statement of a deletion.
1664 1664
 		//to get around this, we first do a SELECT, get all the IDs, and then run another query
1665 1665
 		//to delete them
1666 1666
 		$items_for_deletion = $this->_get_all_wpdb_results($query_params);
1667
-		$deletion_where = $this->_setup_ids_for_delete( $items_for_deletion, $allow_blocking);
1668
-		if($deletion_where){
1667
+		$deletion_where = $this->_setup_ids_for_delete($items_for_deletion, $allow_blocking);
1668
+		if ($deletion_where) {
1669 1669
 			//echo "objects for deletion:";var_dump($objects_for_deletion);
1670 1670
 			$model_query_info = $this->_create_model_query_info_carrier($query_params);
1671
-			$table_aliases = array_keys( $this->_tables );
1672
-			$SQL = "DELETE ".implode(", ",$table_aliases)." FROM ".$model_query_info->get_full_join_sql()." WHERE ".$deletion_where;
1671
+			$table_aliases = array_keys($this->_tables);
1672
+			$SQL = "DELETE ".implode(", ", $table_aliases)." FROM ".$model_query_info->get_full_join_sql()." WHERE ".$deletion_where;
1673 1673
 
1674 1674
 			//		/echo "delete sql:$SQL";
1675
-			$rows_deleted = $this->_do_wpdb_query( 'query', array( $SQL ) );
1676
-		}else{
1675
+			$rows_deleted = $this->_do_wpdb_query('query', array($SQL));
1676
+		} else {
1677 1677
 			$rows_deleted = 0;
1678 1678
 		}
1679 1679
 
1680 1680
 		//and lastly make sure those items are removed from the entity map; if they could be put into it at all
1681
-		if( $this->has_primary_key_field() ){
1682
-			foreach($items_for_deletion as $item_for_deletion_row ){
1683
-				$pk_value = $item_for_deletion_row[ $this->get_primary_key_field()->get_qualified_column() ];
1684
-				if( isset( $this->_entity_map[ EEM_Base::$_model_query_blog_id ][ $pk_value ] ) ){
1685
-					unset( $this->_entity_map[ EEM_Base::$_model_query_blog_id ][ $pk_value ] );
1681
+		if ($this->has_primary_key_field()) {
1682
+			foreach ($items_for_deletion as $item_for_deletion_row) {
1683
+				$pk_value = $item_for_deletion_row[$this->get_primary_key_field()->get_qualified_column()];
1684
+				if (isset($this->_entity_map[EEM_Base::$_model_query_blog_id][$pk_value])) {
1685
+					unset($this->_entity_map[EEM_Base::$_model_query_blog_id][$pk_value]);
1686 1686
 				}
1687 1687
 			}
1688 1688
 		}
@@ -1694,8 +1694,8 @@  discard block
 block discarded – undo
1694 1694
 		 * @param array $query_params @see EEM_Base::get_all()
1695 1695
 		 * @param int $rows_deleted
1696 1696
 		 */
1697
-		do_action( 'AHEE__EEM_Base__delete__end', $this, $query_params, $rows_deleted );
1698
-		return $rows_deleted;//how many supposedly got deleted
1697
+		do_action('AHEE__EEM_Base__delete__end', $this, $query_params, $rows_deleted);
1698
+		return $rows_deleted; //how many supposedly got deleted
1699 1699
 	}
1700 1700
 
1701 1701
 
@@ -1713,28 +1713,28 @@  discard block
 block discarded – undo
1713 1713
 	 * @return boolean
1714 1714
 	 * @throws \EE_Error
1715 1715
 	 */
1716
-	public function delete_is_blocked_by_related_models($this_model_obj_or_id, $ignore_this_model_obj = null){
1716
+	public function delete_is_blocked_by_related_models($this_model_obj_or_id, $ignore_this_model_obj = null) {
1717 1717
 		//first, if $ignore_this_model_obj was supplied, get its model
1718
-		if($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class){
1718
+		if ($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class) {
1719 1719
 			$ignored_model = $ignore_this_model_obj->get_model();
1720
-		}else{
1720
+		} else {
1721 1721
 			$ignored_model = null;
1722 1722
 		}
1723 1723
 		//now check all the relations of $this_model_obj_or_id and see if there
1724 1724
 		//are any related model objects blocking it?
1725 1725
 		$is_blocked = false;
1726
-		foreach($this->_model_relations as $relation_name => $relation_obj){
1727
-			if( $relation_obj->block_delete_if_related_models_exist()){
1726
+		foreach ($this->_model_relations as $relation_name => $relation_obj) {
1727
+			if ($relation_obj->block_delete_if_related_models_exist()) {
1728 1728
 				//if $ignore_this_model_obj was supplied, then for the query
1729 1729
 				//on that model needs to be told to ignore $ignore_this_model_obj
1730
-				if($ignored_model && $relation_name === $ignored_model->get_this_model_name()){
1731
-					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id,array(
1732
-					array($ignored_model->get_primary_key_field()->get_name() => array('!=',$ignore_this_model_obj->ID()))));
1733
-				}else{
1730
+				if ($ignored_model && $relation_name === $ignored_model->get_this_model_name()) {
1731
+					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id, array(
1732
+					array($ignored_model->get_primary_key_field()->get_name() => array('!=', $ignore_this_model_obj->ID()))));
1733
+				} else {
1734 1734
 					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id);
1735 1735
 				}
1736 1736
 
1737
-				if($related_model_objects){
1737
+				if ($related_model_objects) {
1738 1738
 					EE_Error::add_error($relation_obj->get_deletion_error_message(), __FILE__, __FUNCTION__, __LINE__);
1739 1739
 					$is_blocked = true;
1740 1740
 				}
@@ -1754,71 +1754,71 @@  discard block
 block discarded – undo
1754 1754
 	 * @throws EE_Error
1755 1755
 	 * @return string    everything that comes after the WHERE statement.
1756 1756
 	 */
1757
-	protected function _setup_ids_for_delete( $objects_for_deletion, $allow_blocking = true) {
1758
-		if($this->has_primary_key_field()){
1757
+	protected function _setup_ids_for_delete($objects_for_deletion, $allow_blocking = true) {
1758
+		if ($this->has_primary_key_field()) {
1759 1759
 			$primary_table = $this->_get_main_table();
1760 1760
 			$other_tables = $this->_get_other_tables();
1761 1761
 			$deletes = $query = array();
1762
-			foreach ( $objects_for_deletion as $delete_object ) {
1762
+			foreach ($objects_for_deletion as $delete_object) {
1763 1763
 				//before we mark this object for deletion,
1764 1764
 				//make sure there's no related objects blocking its deletion (if we're checking)
1765 1765
 				if (
1766 1766
 					$allow_blocking
1767 1767
 				    && $this->delete_is_blocked_by_related_models(
1768
-						$delete_object[ $primary_table->get_fully_qualified_pk_column() ]
1768
+						$delete_object[$primary_table->get_fully_qualified_pk_column()]
1769 1769
 					)
1770 1770
 				) {
1771 1771
 					continue;
1772 1772
 				}
1773 1773
 				//primary table deletes
1774
-				if ( isset( $delete_object[ $primary_table->get_fully_qualified_pk_column() ] ) ) {
1775
-					$deletes[ $primary_table->get_fully_qualified_pk_column() ][] = $delete_object[ $primary_table->get_fully_qualified_pk_column() ];
1774
+				if (isset($delete_object[$primary_table->get_fully_qualified_pk_column()])) {
1775
+					$deletes[$primary_table->get_fully_qualified_pk_column()][] = $delete_object[$primary_table->get_fully_qualified_pk_column()];
1776 1776
 				}
1777 1777
 				//other tables
1778
-				if ( ! empty( $other_tables ) ) {
1779
-					foreach ( $other_tables as $ot ) {
1778
+				if ( ! empty($other_tables)) {
1779
+					foreach ($other_tables as $ot) {
1780 1780
 						//first check if we've got the foreign key column here.
1781
-						if ( isset( $delete_object[ $ot->get_fully_qualified_fk_column() ] ) ) {
1782
-							$deletes[ $ot->get_fully_qualified_pk_column() ][] = $delete_object[ $ot->get_fully_qualified_fk_column() ];
1781
+						if (isset($delete_object[$ot->get_fully_qualified_fk_column()])) {
1782
+							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_fk_column()];
1783 1783
 						}
1784 1784
 						// wait! it's entirely possible that we'll have a the primary key
1785 1785
 						// for this table in here, if it's a foreign key for one of the other secondary tables
1786
-						if ( isset( $delete_object[ $ot->get_fully_qualified_pk_column() ] ) ) {
1787
-							$deletes[ $ot->get_fully_qualified_pk_column() ][] = $delete_object[ $ot->get_fully_qualified_pk_column() ];
1786
+						if (isset($delete_object[$ot->get_fully_qualified_pk_column()])) {
1787
+							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1788 1788
 						}
1789 1789
 						// finally, it is possible that the fk for this table is found
1790 1790
 						// in the fully qualified pk column for the fk table, so let's see if that's there!
1791
-						if ( isset( $delete_object[ $ot->get_fully_qualified_pk_on_fk_table() ] ) ) {
1792
-							$deletes[ $ot->get_fully_qualified_pk_column() ][] = $delete_object[ $ot->get_fully_qualified_pk_column() ];
1791
+						if (isset($delete_object[$ot->get_fully_qualified_pk_on_fk_table()])) {
1792
+							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1793 1793
 						}
1794 1794
 					}
1795 1795
 				}
1796 1796
 			}
1797 1797
 
1798 1798
 			//we should have deletes now, so let's just go through and setup the where statement
1799
-			foreach ( $deletes as $column => $values ) {
1799
+			foreach ($deletes as $column => $values) {
1800 1800
 				//make sure we have unique $values;
1801 1801
 				$values = array_unique($values);
1802
-				$query[] = $column . ' IN(' . implode(",",$values) . ')';
1802
+				$query[] = $column.' IN('.implode(",", $values).')';
1803 1803
 			}
1804 1804
 
1805
-			return !empty($query) ? implode(' AND ', $query ) : '';
1806
-		}elseif(count($this->get_combined_primary_key_fields()) > 1){
1805
+			return ! empty($query) ? implode(' AND ', $query) : '';
1806
+		}elseif (count($this->get_combined_primary_key_fields()) > 1) {
1807 1807
 			$ways_to_identify_a_row = array();
1808 1808
 			$fields = $this->get_combined_primary_key_fields();
1809 1809
 			//note: because there' sno primary key, that means nothing else  can be pointing to this model, right?
1810
-			foreach($objects_for_deletion as  $delete_object){
1810
+			foreach ($objects_for_deletion as  $delete_object) {
1811 1811
 				$values_for_each_cpk_for_a_row = array();
1812
-				foreach($fields as $cpk_field){
1812
+				foreach ($fields as $cpk_field) {
1813 1813
 					$values_for_each_cpk_for_a_row[] = $cpk_field->get_qualified_column()."=".$delete_object[$cpk_field->get_qualified_column()];
1814 1814
 				}
1815
-				$ways_to_identify_a_row[] = "(".implode(" AND ",$values_for_each_cpk_for_a_row).")";
1815
+				$ways_to_identify_a_row[] = "(".implode(" AND ", $values_for_each_cpk_for_a_row).")";
1816 1816
 			}
1817
-			return implode(" OR ",$ways_to_identify_a_row);
1818
-		}else{
1817
+			return implode(" OR ", $ways_to_identify_a_row);
1818
+		} else {
1819 1819
 			//so there's no primary key and no combined key...
1820 1820
 			//sorry, can't help you
1821
-			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)));
1821
+			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)));
1822 1822
 		}
1823 1823
 	}
1824 1824
 
@@ -1834,21 +1834,21 @@  discard block
 block discarded – undo
1834 1834
 	 * @return int
1835 1835
 	 * @throws \EE_Error
1836 1836
 	 */
1837
-	public function count($query_params =array(),$field_to_count = NULL, $distinct = FALSE){
1837
+	public function count($query_params = array(), $field_to_count = NULL, $distinct = FALSE) {
1838 1838
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1839
-		if($field_to_count){
1839
+		if ($field_to_count) {
1840 1840
 			$field_obj = $this->field_settings_for($field_to_count);
1841 1841
 			$column_to_count = $field_obj->get_qualified_column();
1842
-		}elseif($this->has_primary_key_field ()){
1842
+		}elseif ($this->has_primary_key_field()) {
1843 1843
 			$pk_field_obj = $this->get_primary_key_field();
1844 1844
 			$column_to_count = $pk_field_obj->get_qualified_column();
1845
-		}else{//there's no primary key
1845
+		} else {//there's no primary key
1846 1846
 			$column_to_count = '*';
1847 1847
 		}
1848 1848
 
1849
-		$column_to_count = $distinct ? "DISTINCT (" . $column_to_count . " )" : $column_to_count;
1850
-		$SQL ="SELECT COUNT(".$column_to_count.")" . $this->_construct_2nd_half_of_select_query($model_query_info);
1851
-		return (int)$this->_do_wpdb_query( 'get_var', array( $SQL) );
1849
+		$column_to_count = $distinct ? "DISTINCT (".$column_to_count." )" : $column_to_count;
1850
+		$SQL = "SELECT COUNT(".$column_to_count.")".$this->_construct_2nd_half_of_select_query($model_query_info);
1851
+		return (int) $this->_do_wpdb_query('get_var', array($SQL));
1852 1852
 	}
1853 1853
 
1854 1854
 
@@ -1861,24 +1861,24 @@  discard block
 block discarded – undo
1861 1861
 	 * @return float
1862 1862
 	 * @throws \EE_Error
1863 1863
 	 */
1864
-	public function sum($query_params, $field_to_sum = NULL){
1864
+	public function sum($query_params, $field_to_sum = NULL) {
1865 1865
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1866 1866
 
1867
-		if($field_to_sum){
1867
+		if ($field_to_sum) {
1868 1868
 			$field_obj = $this->field_settings_for($field_to_sum);
1869 1869
 
1870
-		}else{
1870
+		} else {
1871 1871
 			$field_obj = $this->get_primary_key_field();
1872 1872
 		}
1873 1873
 		$column_to_count = $field_obj->get_qualified_column();
1874 1874
 
1875
-		$SQL ="SELECT SUM(".$column_to_count.")" . $this->_construct_2nd_half_of_select_query($model_query_info);
1876
-		$return_value = $this->_do_wpdb_query('get_var',array( $SQL ) );
1875
+		$SQL = "SELECT SUM(".$column_to_count.")".$this->_construct_2nd_half_of_select_query($model_query_info);
1876
+		$return_value = $this->_do_wpdb_query('get_var', array($SQL));
1877 1877
 		$data_type = $field_obj->get_wpdb_data_type();
1878
-		if( $data_type === '%d' || $data_type === '%s' ){
1879
-			return (float)$return_value;
1880
-		}else{//must be %f
1881
-			return (float)$return_value;
1878
+		if ($data_type === '%d' || $data_type === '%s') {
1879
+			return (float) $return_value;
1880
+		} else {//must be %f
1881
+			return (float) $return_value;
1882 1882
 		}
1883 1883
 	}
1884 1884
 
@@ -1893,37 +1893,37 @@  discard block
 block discarded – undo
1893 1893
 	 * @global wpdb $wpdb
1894 1894
 	 * @return mixed
1895 1895
 	 */
1896
-	protected function _do_wpdb_query( $wpdb_method, $arguments_to_provide ){
1896
+	protected function _do_wpdb_query($wpdb_method, $arguments_to_provide) {
1897 1897
 		//if we're in maintenance mode level 2, DON'T run any queries
1898 1898
 		//because level 2 indicates the database needs updating and
1899 1899
 		//is probably out of sync with the code
1900
-		if( ! EE_Maintenance_Mode::instance()->models_can_query()){
1900
+		if ( ! EE_Maintenance_Mode::instance()->models_can_query()) {
1901 1901
 			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")));
1902 1902
 		}
1903 1903
 		/** @type WPDB $wpdb */
1904 1904
 		global $wpdb;
1905
-		if( ! method_exists( $wpdb, $wpdb_method ) ){
1906
-			throw new EE_Error( sprintf( __( 'There is no method named "%s" on Wordpress\' $wpdb object','event_espresso' ), $wpdb_method ) );
1905
+		if ( ! method_exists($wpdb, $wpdb_method)) {
1906
+			throw new EE_Error(sprintf(__('There is no method named "%s" on Wordpress\' $wpdb object', 'event_espresso'), $wpdb_method));
1907 1907
 		}
1908
-		if( WP_DEBUG ){
1908
+		if (WP_DEBUG) {
1909 1909
 			$old_show_errors_value = $wpdb->show_errors;
1910
-			$wpdb->show_errors( FALSE );
1911
-		}
1912
-		$result = $this->_process_wpdb_query( $wpdb_method, $arguments_to_provide );
1913
-		$this->show_db_query_if_previously_requested( $wpdb->last_query );
1914
-		if( WP_DEBUG ){
1915
-			$wpdb->show_errors( $old_show_errors_value );
1916
-			if( ! empty( $wpdb->last_error ) ){
1917
-				throw new EE_Error( sprintf( __( 'WPDB Error: "%s"', 'event_espresso' ), $wpdb->last_error ) );
1918
-			}elseif( $result === false ){
1919
-				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 ) ) );
1910
+			$wpdb->show_errors(FALSE);
1911
+		}
1912
+		$result = $this->_process_wpdb_query($wpdb_method, $arguments_to_provide);
1913
+		$this->show_db_query_if_previously_requested($wpdb->last_query);
1914
+		if (WP_DEBUG) {
1915
+			$wpdb->show_errors($old_show_errors_value);
1916
+			if ( ! empty($wpdb->last_error)) {
1917
+				throw new EE_Error(sprintf(__('WPDB Error: "%s"', 'event_espresso'), $wpdb->last_error));
1918
+			}elseif ($result === false) {
1919
+				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)));
1920 1920
 			}
1921
-		}elseif( $result === false ) {
1921
+		}elseif ($result === false) {
1922 1922
 			EE_Error::add_error(
1923 1923
 				sprintf(
1924
-					__( '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' ),
1924
+					__('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'),
1925 1925
 					$wpdb_method,
1926
-					var_export( $arguments_to_provide, true ),
1926
+					var_export($arguments_to_provide, true),
1927 1927
 					$wpdb->last_error
1928 1928
 				),
1929 1929
 				__FILE__,
@@ -1945,26 +1945,26 @@  discard block
 block discarded – undo
1945 1945
 	 * @param array $arguments_to_provide
1946 1946
 	 * @return mixed
1947 1947
 	 */
1948
-	private function _process_wpdb_query( $wpdb_method, $arguments_to_provide ) {
1948
+	private function _process_wpdb_query($wpdb_method, $arguments_to_provide) {
1949 1949
 		/** @type WPDB $wpdb */
1950 1950
 		global $wpdb;
1951 1951
 		$wpdb->last_error = null;
1952
-		$result = call_user_func_array( array( $wpdb, $wpdb_method ), $arguments_to_provide );
1952
+		$result = call_user_func_array(array($wpdb, $wpdb_method), $arguments_to_provide);
1953 1953
 		// was there an error running the query? but we don't care on new activations
1954 1954
 		// (we're going to setup the DB anyway on new activations)
1955
-		if ( ( $result === false || ! empty( $wpdb->last_error ) )
1955
+		if (($result === false || ! empty($wpdb->last_error))
1956 1956
 			&& EE_System::instance()->detect_req_type() !== EE_System::req_type_new_activation
1957 1957
 		) {
1958
-			switch ( EEM_Base::$_db_verification_level ) {
1958
+			switch (EEM_Base::$_db_verification_level) {
1959 1959
 
1960 1960
 				case EEM_Base::db_verified_none :
1961 1961
 					// let's double-check core's DB
1962
-					$error_message = $this->_verify_core_db( $wpdb_method, $arguments_to_provide );
1962
+					$error_message = $this->_verify_core_db($wpdb_method, $arguments_to_provide);
1963 1963
 					break;
1964 1964
 
1965 1965
 				case EEM_Base::db_verified_core :
1966 1966
 					// STILL NO LOVE?? verify all the addons too. Maybe they need to be fixed
1967
-					$error_message = $this->_verify_addons_db( $wpdb_method, $arguments_to_provide );
1967
+					$error_message = $this->_verify_addons_db($wpdb_method, $arguments_to_provide);
1968 1968
 					break;
1969 1969
 
1970 1970
 				case EEM_Base::db_verified_addons :
@@ -1972,11 +1972,11 @@  discard block
 block discarded – undo
1972 1972
 					return $result;
1973 1973
 					break;
1974 1974
 			}
1975
-			if ( ! empty( $error_message ) ) {
1976
-				EE_Log::instance()->log( __FILE__, __FUNCTION__, $error_message, 'error' );
1977
-				trigger_error( $error_message );
1975
+			if ( ! empty($error_message)) {
1976
+				EE_Log::instance()->log(__FILE__, __FUNCTION__, $error_message, 'error');
1977
+				trigger_error($error_message);
1978 1978
 			}
1979
-			return $this->_process_wpdb_query( $wpdb_method, $arguments_to_provide );
1979
+			return $this->_process_wpdb_query($wpdb_method, $arguments_to_provide);
1980 1980
 
1981 1981
 		}
1982 1982
 
@@ -1992,18 +1992,18 @@  discard block
 block discarded – undo
1992 1992
 	 * @param array $arguments_to_provide
1993 1993
 	 * @return string
1994 1994
 	 */
1995
-	private function _verify_core_db( $wpdb_method, $arguments_to_provide ){
1995
+	private function _verify_core_db($wpdb_method, $arguments_to_provide) {
1996 1996
 		/** @type WPDB $wpdb */
1997 1997
 		global $wpdb;
1998 1998
 		//ok remember that we've already attempted fixing the core db, in case the problem persists
1999 1999
 		EEM_Base::$_db_verification_level = EEM_Base::db_verified_core;
2000 2000
 		$error_message = sprintf(
2001
-			__( 'WPDB Error "%1$s" while running wpdb method "%2$s" with arguments %3$s. Automatically attempting to fix EE Core DB', 'event_espresso' ),
2001
+			__('WPDB Error "%1$s" while running wpdb method "%2$s" with arguments %3$s. Automatically attempting to fix EE Core DB', 'event_espresso'),
2002 2002
 			$wpdb->last_error,
2003 2003
 			$wpdb_method,
2004
-			json_encode( $arguments_to_provide )
2004
+			json_encode($arguments_to_provide)
2005 2005
 		);
2006
-		EE_System::instance()->initialize_db_if_no_migrations_required( false, true );
2006
+		EE_System::instance()->initialize_db_if_no_migrations_required(false, true);
2007 2007
 		return $error_message;
2008 2008
 	}
2009 2009
 
@@ -2016,16 +2016,16 @@  discard block
 block discarded – undo
2016 2016
 	 * @param $arguments_to_provide
2017 2017
 	 * @return string
2018 2018
 	 */
2019
-	private function _verify_addons_db( $wpdb_method, $arguments_to_provide ) {
2019
+	private function _verify_addons_db($wpdb_method, $arguments_to_provide) {
2020 2020
 		/** @type WPDB $wpdb */
2021 2021
 		global $wpdb;
2022 2022
 		//ok remember that we've already attempted fixing the addons dbs, in case the problem persists
2023 2023
 		EEM_Base::$_db_verification_level = EEM_Base::db_verified_addons;
2024 2024
 		$error_message = sprintf(
2025
-			__( 'WPDB AGAIN: Error "%1$s" while running the same method and arguments as before. Automatically attempting to fix EE Addons DB', 'event_espresso' ),
2025
+			__('WPDB AGAIN: Error "%1$s" while running the same method and arguments as before. Automatically attempting to fix EE Addons DB', 'event_espresso'),
2026 2026
 			$wpdb->last_error,
2027 2027
 			$wpdb_method,
2028
-			json_encode( $arguments_to_provide )
2028
+			json_encode($arguments_to_provide)
2029 2029
 		);
2030 2030
 		EE_System::instance()->initialize_addons();
2031 2031
 		return $error_message;
@@ -2040,7 +2040,7 @@  discard block
 block discarded – undo
2040 2040
 	 * @param EE_Model_Query_Info_Carrier $model_query_info
2041 2041
 	 * @return string
2042 2042
 	 */
2043
-	private function _construct_2nd_half_of_select_query(EE_Model_Query_Info_Carrier $model_query_info){
2043
+	private function _construct_2nd_half_of_select_query(EE_Model_Query_Info_Carrier $model_query_info) {
2044 2044
 		return " FROM ".$model_query_info->get_full_join_sql().
2045 2045
 				$model_query_info->get_where_sql().
2046 2046
 				$model_query_info->get_group_by_sql().
@@ -2053,7 +2053,7 @@  discard block
 block discarded – undo
2053 2053
 	 * Set to easily debug the next X queries ran from this model.
2054 2054
 	 * @param int $count
2055 2055
 	 */
2056
-	public function show_next_x_db_queries($count = 1){
2056
+	public function show_next_x_db_queries($count = 1) {
2057 2057
 		$this->_show_next_x_db_queries = $count;
2058 2058
 	}
2059 2059
 
@@ -2062,8 +2062,8 @@  discard block
 block discarded – undo
2062 2062
 	/**
2063 2063
 	 * @param $sql_query
2064 2064
 	 */
2065
-	public function show_db_query_if_previously_requested($sql_query){
2066
-		if($this->_show_next_x_db_queries > 0){
2065
+	public function show_db_query_if_previously_requested($sql_query) {
2066
+		if ($this->_show_next_x_db_queries > 0) {
2067 2067
 			echo $sql_query;
2068 2068
 			$this->_show_next_x_db_queries--;
2069 2069
 		}
@@ -2087,9 +2087,9 @@  discard block
 block discarded – undo
2087 2087
 	 * @return EE_Base_Class which was added as a relation. Object referred to by $other_model_id_or_obj
2088 2088
 	 * @throws \EE_Error
2089 2089
 	 */
2090
-	public function add_relationship_to($id_or_obj,$other_model_id_or_obj, $relationName, $extra_join_model_fields_n_values = array()){
2090
+	public function add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $extra_join_model_fields_n_values = array()) {
2091 2091
 		$relation_obj = $this->related_settings_for($relationName);
2092
-		return $relation_obj->add_relation_to( $id_or_obj, $other_model_id_or_obj, $extra_join_model_fields_n_values);
2092
+		return $relation_obj->add_relation_to($id_or_obj, $other_model_id_or_obj, $extra_join_model_fields_n_values);
2093 2093
 	}
2094 2094
 
2095 2095
 
@@ -2108,9 +2108,9 @@  discard block
 block discarded – undo
2108 2108
 	 * @throws \EE_Error
2109 2109
 	 * @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.
2110 2110
 	 */
2111
-	public function remove_relationship_to($id_or_obj,  $other_model_id_or_obj, $relationName, $where_query= array() ){
2111
+	public function remove_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query = array()) {
2112 2112
 		$relation_obj = $this->related_settings_for($relationName);
2113
-		return $relation_obj->remove_relation_to($id_or_obj, $other_model_id_or_obj, $where_query );
2113
+		return $relation_obj->remove_relation_to($id_or_obj, $other_model_id_or_obj, $where_query);
2114 2114
 	}
2115 2115
 
2116 2116
 
@@ -2123,9 +2123,9 @@  discard block
 block discarded – undo
2123 2123
 	 * @return \EE_Base_Class[]
2124 2124
 	 * @throws \EE_Error
2125 2125
 	 */
2126
-	public function remove_relations($id_or_obj,$relationName,$where_query_params = array()){
2126
+	public function remove_relations($id_or_obj, $relationName, $where_query_params = array()) {
2127 2127
 		$relation_obj = $this->related_settings_for($relationName);
2128
-		return $relation_obj->remove_relations($id_or_obj, $where_query_params );
2128
+		return $relation_obj->remove_relations($id_or_obj, $where_query_params);
2129 2129
 	}
2130 2130
 
2131 2131
 
@@ -2141,10 +2141,10 @@  discard block
 block discarded – undo
2141 2141
 	 * @return EE_Base_Class[]
2142 2142
 	 * @throws \EE_Error
2143 2143
 	 */
2144
-	public function get_all_related($id_or_obj, $model_name, $query_params = null){
2144
+	public function get_all_related($id_or_obj, $model_name, $query_params = null) {
2145 2145
 		$model_obj = $this->ensure_is_obj($id_or_obj);
2146 2146
 		$relation_settings = $this->related_settings_for($model_name);
2147
-		return $relation_settings->get_all_related($model_obj,$query_params);
2147
+		return $relation_settings->get_all_related($model_obj, $query_params);
2148 2148
 	}
2149 2149
 
2150 2150
 
@@ -2161,10 +2161,10 @@  discard block
 block discarded – undo
2161 2161
 	 * @return int how many deleted
2162 2162
 	 * @throws \EE_Error
2163 2163
 	 */
2164
-	public function delete_related($id_or_obj,$model_name, $query_params = array()){
2164
+	public function delete_related($id_or_obj, $model_name, $query_params = array()) {
2165 2165
 		$model_obj = $this->ensure_is_obj($id_or_obj);
2166 2166
 		$relation_settings = $this->related_settings_for($model_name);
2167
-		return $relation_settings->delete_all_related($model_obj,$query_params);
2167
+		return $relation_settings->delete_all_related($model_obj, $query_params);
2168 2168
 	}
2169 2169
 
2170 2170
 
@@ -2181,10 +2181,10 @@  discard block
 block discarded – undo
2181 2181
 	 * @return int how many deleted
2182 2182
 	 * @throws \EE_Error
2183 2183
 	 */
2184
-	public function delete_related_permanently($id_or_obj,$model_name, $query_params = array()){
2184
+	public function delete_related_permanently($id_or_obj, $model_name, $query_params = array()) {
2185 2185
 		$model_obj = $this->ensure_is_obj($id_or_obj);
2186 2186
 		$relation_settings = $this->related_settings_for($model_name);
2187
-		return $relation_settings->delete_related_permanently($model_obj,$query_params);
2187
+		return $relation_settings->delete_related_permanently($model_obj, $query_params);
2188 2188
 	}
2189 2189
 
2190 2190
 
@@ -2201,17 +2201,17 @@  discard block
 block discarded – undo
2201 2201
 	 * @return int
2202 2202
 	 * @throws \EE_Error
2203 2203
 	 */
2204
-	public function count_related($id_or_obj,$model_name,$query_params = array(),$field_to_count = null, $distinct = FALSE){
2204
+	public function count_related($id_or_obj, $model_name, $query_params = array(), $field_to_count = null, $distinct = FALSE) {
2205 2205
 		$related_model = $this->get_related_model_obj($model_name);
2206 2206
 		//we're just going to use the query params on the related model's normal get_all query,
2207 2207
 		//except add a condition to say to match the current mod
2208
-		if( ! isset($query_params['default_where_conditions'])){
2209
-			$query_params['default_where_conditions']='none';
2208
+		if ( ! isset($query_params['default_where_conditions'])) {
2209
+			$query_params['default_where_conditions'] = 'none';
2210 2210
 		}
2211 2211
 		$this_model_name = $this->get_this_model_name();
2212 2212
 		$this_pk_field_name = $this->get_primary_key_field()->get_name();
2213
-		$query_params[0][$this_model_name.".".$this_pk_field_name]=$id_or_obj;
2214
-		return $related_model->count($query_params,$field_to_count,$distinct);
2213
+		$query_params[0][$this_model_name.".".$this_pk_field_name] = $id_or_obj;
2214
+		return $related_model->count($query_params, $field_to_count, $distinct);
2215 2215
 	}
2216 2216
 
2217 2217
 
@@ -2227,21 +2227,21 @@  discard block
 block discarded – undo
2227 2227
 	 * @return float
2228 2228
 	 * @throws \EE_Error
2229 2229
 	 */
2230
-	public function sum_related($id_or_obj,$model_name,$query_params,$field_to_sum = null){
2230
+	public function sum_related($id_or_obj, $model_name, $query_params, $field_to_sum = null) {
2231 2231
 		$related_model = $this->get_related_model_obj($model_name);
2232
-		if( ! is_array( $query_params ) ){
2233
-			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' );
2232
+		if ( ! is_array($query_params)) {
2233
+			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');
2234 2234
 			$query_params = array();
2235 2235
 		}
2236 2236
 		//we're just going to use the query params on the related model's normal get_all query,
2237 2237
 		//except add a condition to say to match the current mod
2238
-		if( ! isset($query_params['default_where_conditions'])){
2239
-			$query_params['default_where_conditions']='none';
2238
+		if ( ! isset($query_params['default_where_conditions'])) {
2239
+			$query_params['default_where_conditions'] = 'none';
2240 2240
 		}
2241 2241
 		$this_model_name = $this->get_this_model_name();
2242 2242
 		$this_pk_field_name = $this->get_primary_key_field()->get_name();
2243
-		$query_params[0][$this_model_name.".".$this_pk_field_name]=$id_or_obj;
2244
-		return $related_model->sum($query_params,$field_to_sum);
2243
+		$query_params[0][$this_model_name.".".$this_pk_field_name] = $id_or_obj;
2244
+		return $related_model->sum($query_params, $field_to_sum);
2245 2245
 	}
2246 2246
 
2247 2247
 
@@ -2255,12 +2255,12 @@  discard block
 block discarded – undo
2255 2255
 	 * @return EE_Base_Class
2256 2256
 	 * @throws \EE_Error
2257 2257
 	 */
2258
-	public function get_first_related( EE_Base_Class $id_or_obj, $other_model_name, $query_params ){
2259
-		$query_params['limit']=1;
2260
-		$results = $this->get_all_related($id_or_obj,$other_model_name,$query_params);
2261
-		if( $results ){
2258
+	public function get_first_related(EE_Base_Class $id_or_obj, $other_model_name, $query_params) {
2259
+		$query_params['limit'] = 1;
2260
+		$results = $this->get_all_related($id_or_obj, $other_model_name, $query_params);
2261
+		if ($results) {
2262 2262
 			return array_shift($results);
2263
-		}else{
2263
+		} else {
2264 2264
 			return null;
2265 2265
 		}
2266 2266
 
@@ -2270,8 +2270,8 @@  discard block
 block discarded – undo
2270 2270
 	 * Gets the model's name as it's expected in queries. For example, if this is EEM_Event model, that would be Event
2271 2271
 	 * @return string
2272 2272
 	 */
2273
-	public function get_this_model_name(){
2274
-		return str_replace("EEM_","",get_class($this));
2273
+	public function get_this_model_name() {
2274
+		return str_replace("EEM_", "", get_class($this));
2275 2275
 	}
2276 2276
 
2277 2277
 	/**
@@ -2279,14 +2279,14 @@  discard block
 block discarded – undo
2279 2279
 	 * @return EE_Any_Foreign_Model_Name_Field
2280 2280
 	 * @throws EE_Error
2281 2281
 	 */
2282
-	public function get_field_containing_related_model_name(){
2283
-		foreach($this->field_settings(true) as $field){
2284
-			if($field instanceof EE_Any_Foreign_Model_Name_Field){
2282
+	public function get_field_containing_related_model_name() {
2283
+		foreach ($this->field_settings(true) as $field) {
2284
+			if ($field instanceof EE_Any_Foreign_Model_Name_Field) {
2285 2285
 				$field_with_model_name = $field;
2286 2286
 			}
2287 2287
 		}
2288
-		if( !isset($field_with_model_name) || !$field_with_model_name ){
2289
-			throw new EE_Error(sprintf(__("There is no EE_Any_Foreign_Model_Name field on model %s", "event_espresso"), $this->get_this_model_name() ));
2288
+		if ( ! isset($field_with_model_name) || ! $field_with_model_name) {
2289
+			throw new EE_Error(sprintf(__("There is no EE_Any_Foreign_Model_Name field on model %s", "event_espresso"), $this->get_this_model_name()));
2290 2290
 		}
2291 2291
 		return $field_with_model_name;
2292 2292
 	}
@@ -2307,19 +2307,19 @@  discard block
 block discarded – undo
2307 2307
 	 * @return int new primary key on main table that got inserted
2308 2308
 	 * @throws EE_Error
2309 2309
 	 */
2310
-	public function insert($field_n_values){
2310
+	public function insert($field_n_values) {
2311 2311
 		/**
2312 2312
 		 * Filters the fields and their values before inserting an item using the models
2313 2313
 		 * @param array $fields_n_values keys are the fields and values are their new values
2314 2314
 		 * @param EEM_Base $model the model used
2315 2315
 		 */
2316
-		$field_n_values = (array)apply_filters( 'FHEE__EEM_Base__insert__fields_n_values', $field_n_values, $this );
2317
-		if($this->_satisfies_unique_indexes($field_n_values)){
2316
+		$field_n_values = (array) apply_filters('FHEE__EEM_Base__insert__fields_n_values', $field_n_values, $this);
2317
+		if ($this->_satisfies_unique_indexes($field_n_values)) {
2318 2318
 			$main_table = $this->_get_main_table();
2319 2319
 			$new_id = $this->_insert_into_specific_table($main_table, $field_n_values, false);
2320
-			if( $new_id !== false ) {
2321
-				foreach($this->_get_other_tables() as $other_table){
2322
-					$this->_insert_into_specific_table($other_table, $field_n_values,$new_id);
2320
+			if ($new_id !== false) {
2321
+				foreach ($this->_get_other_tables() as $other_table) {
2322
+					$this->_insert_into_specific_table($other_table, $field_n_values, $new_id);
2323 2323
 				}
2324 2324
 			}
2325 2325
 			/**
@@ -2329,9 +2329,9 @@  discard block
 block discarded – undo
2329 2329
 			 * @param array $fields_n_values fields and their values
2330 2330
 			 * @param int|string the ID of the newly-inserted model object
2331 2331
 			 */
2332
-			do_action( 'AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id );
2332
+			do_action('AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id);
2333 2333
 			return $new_id;
2334
-		}else{
2334
+		} else {
2335 2335
 			return FALSE;
2336 2336
 		}
2337 2337
 	}
@@ -2346,10 +2346,10 @@  discard block
 block discarded – undo
2346 2346
 	 * @return boolean
2347 2347
 	 * @throws \EE_Error
2348 2348
 	 */
2349
-	protected function _satisfies_unique_indexes($field_n_values,$action = 'insert'){
2350
-		foreach($this->unique_indexes() as $index_name => $index){
2349
+	protected function _satisfies_unique_indexes($field_n_values, $action = 'insert') {
2350
+		foreach ($this->unique_indexes() as $index_name => $index) {
2351 2351
 			$uniqueness_where_params = array_intersect_key($field_n_values, $index->fields());
2352
-			if($this->exists(array($uniqueness_where_params))){
2352
+			if ($this->exists(array($uniqueness_where_params))) {
2353 2353
 				EE_Error::add_error(
2354 2354
 					sprintf(
2355 2355
 						__(
@@ -2359,8 +2359,8 @@  discard block
 block discarded – undo
2359 2359
 						$action,
2360 2360
 						$this->_get_class_name(),
2361 2361
 						$index_name,
2362
-						implode( ",", $index->field_names() ),
2363
-						http_build_query( $uniqueness_where_params )
2362
+						implode(",", $index->field_names()),
2363
+						http_build_query($uniqueness_where_params)
2364 2364
 					),
2365 2365
 					__FILE__,
2366 2366
 					__FUNCTION__,
@@ -2386,37 +2386,37 @@  discard block
 block discarded – undo
2386 2386
 	 * @throws EE_Error
2387 2387
 	 * @return EE_Base_Class
2388 2388
 	 */
2389
-	public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true ){
2390
-		if($obj_or_fields_array instanceof EE_Base_Class){
2389
+	public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true) {
2390
+		if ($obj_or_fields_array instanceof EE_Base_Class) {
2391 2391
 			$fields_n_values = $obj_or_fields_array->model_field_array();
2392
-		}elseif( is_array($obj_or_fields_array)){
2392
+		}elseif (is_array($obj_or_fields_array)) {
2393 2393
 			$fields_n_values = $obj_or_fields_array;
2394
-		}else{
2394
+		} else {
2395 2395
 			throw new EE_Error(
2396 2396
 				sprintf(
2397 2397
 					__(
2398 2398
 						"%s get_all_conflicting should be called with a model object or an array of field names and values, you provided %d",
2399 2399
 						"event_espresso"
2400 2400
 					),
2401
-					get_class( $this ),
2401
+					get_class($this),
2402 2402
 					$obj_or_fields_array
2403 2403
 				)
2404 2404
 			);
2405 2405
 		}
2406 2406
 		$query_params = array();
2407
-		if( $this->has_primary_key_field() &&
2408
-				( $include_primary_key || $this->get_primary_key_field() instanceof EE_Primary_Key_String_Field) &&
2409
-				isset($fields_n_values[$this->primary_key_name()])){
2407
+		if ($this->has_primary_key_field() &&
2408
+				($include_primary_key || $this->get_primary_key_field() instanceof EE_Primary_Key_String_Field) &&
2409
+				isset($fields_n_values[$this->primary_key_name()])) {
2410 2410
 			$query_params[0]['OR'][$this->primary_key_name()] = $fields_n_values[$this->primary_key_name()];
2411 2411
 		}
2412
-		foreach($this->unique_indexes() as $unique_index_name=>$unique_index){
2412
+		foreach ($this->unique_indexes() as $unique_index_name=>$unique_index) {
2413 2413
 			$uniqueness_where_params = array_intersect_key($fields_n_values, $unique_index->fields());
2414 2414
 			$query_params[0]['OR']['AND*'.$unique_index_name] = $uniqueness_where_params;
2415 2415
 		}
2416 2416
 		//if there is nothing to base this search on, then we shouldn't find anything
2417
-		if( empty( $query_params ) ){
2417
+		if (empty($query_params)) {
2418 2418
 			return array();
2419
-		}else{
2419
+		} else {
2420 2420
 			return $this->get_one($query_params);
2421 2421
 		}
2422 2422
 	}
@@ -2430,7 +2430,7 @@  discard block
 block discarded – undo
2430 2430
 	 * @return boolean
2431 2431
 	 * @throws \EE_Error
2432 2432
 	 */
2433
-	public function exists($query_params){
2433
+	public function exists($query_params) {
2434 2434
 		$query_params['limit'] = 1;
2435 2435
 		return $this->count($query_params) > 0;
2436 2436
 	}
@@ -2444,7 +2444,7 @@  discard block
 block discarded – undo
2444 2444
 	 * @return boolean
2445 2445
 	 * @throws \EE_Error
2446 2446
 	 */
2447
-	public function exists_by_ID($id){
2447
+	public function exists_by_ID($id) {
2448 2448
 		return $this->exists(array('default_where_conditions'=>'none', array($this->primary_key_name() => $id)));
2449 2449
 	}
2450 2450
 
@@ -2464,45 +2464,45 @@  discard block
 block discarded – undo
2464 2464
 	 * @global WPDB $wpdb only used to get the $wpdb->insert_id after performing an insert
2465 2465
 	 * @return int ID of new row inserted, or FALSE on failure
2466 2466
 	 */
2467
-	protected function _insert_into_specific_table(EE_Table_Base $table, $fields_n_values, $new_id = 0 ){
2467
+	protected function _insert_into_specific_table(EE_Table_Base $table, $fields_n_values, $new_id = 0) {
2468 2468
 		global $wpdb;
2469 2469
 		$insertion_col_n_values = array();
2470 2470
 		$format_for_insertion = array();
2471 2471
 		$fields_on_table = $this->_get_fields_for_table($table->get_table_alias());
2472
-		foreach($fields_on_table as $field_name => $field_obj){
2472
+		foreach ($fields_on_table as $field_name => $field_obj) {
2473 2473
 			//check if its an auto-incrementing column, in which case we should just leave it to do its autoincrement thing
2474
-			if($field_obj->is_auto_increment()){
2474
+			if ($field_obj->is_auto_increment()) {
2475 2475
 				continue;
2476 2476
 			}
2477 2477
 			$prepared_value = $this->_prepare_value_or_use_default($field_obj, $fields_n_values);
2478 2478
 			//if the value we want to assign it to is NULL, just don't mention it for the insertion
2479
-			if( $prepared_value !== NULL ){
2480
-				$insertion_col_n_values[ $field_obj->get_table_column() ] = $prepared_value;
2479
+			if ($prepared_value !== NULL) {
2480
+				$insertion_col_n_values[$field_obj->get_table_column()] = $prepared_value;
2481 2481
 				$format_for_insertion[] = $field_obj->get_wpdb_data_type();
2482 2482
 			}
2483 2483
 		}
2484 2484
 
2485
-		if($table instanceof EE_Secondary_Table && $new_id){
2485
+		if ($table instanceof EE_Secondary_Table && $new_id) {
2486 2486
 			//its not the main table, so we should have already saved the main table's PK which we just inserted
2487 2487
 			//so add the fk to the main table as a column
2488 2488
 			$insertion_col_n_values[$table->get_fk_on_table()] = $new_id;
2489
-			$format_for_insertion[]='%d';//yes right now we're only allowing these foreign keys to be INTs
2489
+			$format_for_insertion[] = '%d'; //yes right now we're only allowing these foreign keys to be INTs
2490 2490
 		}
2491 2491
 		//insert the new entry
2492
-		$result = $this->_do_wpdb_query( 'insert', array( $table->get_table_name(), $insertion_col_n_values, $format_for_insertion ) );
2493
-		if( $result === false ) {
2492
+		$result = $this->_do_wpdb_query('insert', array($table->get_table_name(), $insertion_col_n_values, $format_for_insertion));
2493
+		if ($result === false) {
2494 2494
 			return false;
2495 2495
 		}
2496 2496
 		//ok, now what do we return for the ID of the newly-inserted thing?
2497
-		if($this->has_primary_key_field()){
2498
-			if($this->get_primary_key_field()->is_auto_increment()){
2497
+		if ($this->has_primary_key_field()) {
2498
+			if ($this->get_primary_key_field()->is_auto_increment()) {
2499 2499
 				return $wpdb->insert_id;
2500
-			}else{
2500
+			} else {
2501 2501
 				//it's not an auto-increment primary key, so
2502 2502
 				//it must have been supplied
2503 2503
 				return $fields_n_values[$this->get_primary_key_field()->get_name()];
2504 2504
 			}
2505
-		}else{
2505
+		} else {
2506 2506
 			//we can't return a  primary key because there is none. instead return
2507 2507
 			//a unique string indicating this model
2508 2508
 			return $this->get_index_primary_key_string($fields_n_values);
@@ -2521,15 +2521,15 @@  discard block
 block discarded – undo
2521 2521
 	 * @return mixed string|int|float depending on what the table column will be expecting
2522 2522
 	 * @throws \EE_Error
2523 2523
 	 */
2524
-	protected function _prepare_value_or_use_default( $field_obj, $fields_n_values ){
2524
+	protected function _prepare_value_or_use_default($field_obj, $fields_n_values) {
2525 2525
 		//if this field doesn't allow nullable, don't allow it
2526
-		if( ! $field_obj->is_nullable() && (
2527
-				! isset( $fields_n_values[ $field_obj->get_name() ] ) ||
2528
-				$fields_n_values[ $field_obj->get_name() ] === NULL ) ){
2529
-			$fields_n_values[ $field_obj->get_name() ] = $field_obj->get_default_value();
2526
+		if ( ! $field_obj->is_nullable() && (
2527
+				! isset($fields_n_values[$field_obj->get_name()]) ||
2528
+				$fields_n_values[$field_obj->get_name()] === NULL )) {
2529
+			$fields_n_values[$field_obj->get_name()] = $field_obj->get_default_value();
2530 2530
 		}
2531
-		$unprepared_value = isset( $fields_n_values[ $field_obj->get_name() ] ) ? $fields_n_values[ $field_obj->get_name() ] : NULL;
2532
-		return $this->_prepare_value_for_use_in_db( $unprepared_value, $field_obj);
2531
+		$unprepared_value = isset($fields_n_values[$field_obj->get_name()]) ? $fields_n_values[$field_obj->get_name()] : NULL;
2532
+		return $this->_prepare_value_for_use_in_db($unprepared_value, $field_obj);
2533 2533
 	}
2534 2534
 
2535 2535
 
@@ -2541,9 +2541,9 @@  discard block
 block discarded – undo
2541 2541
 	 * @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
2542 2542
 	 * @return mixed a value ready for use in the database for insertions, updating, or in a where clause
2543 2543
 	 */
2544
-	private function _prepare_value_for_use_in_db($value, $field){
2545
-		if($field && $field instanceof EE_Model_Field_Base){
2546
-			switch( $this->_values_already_prepared_by_model_object ){
2544
+	private function _prepare_value_for_use_in_db($value, $field) {
2545
+		if ($field && $field instanceof EE_Model_Field_Base) {
2546
+			switch ($this->_values_already_prepared_by_model_object) {
2547 2547
 				/** @noinspection PhpMissingBreakStatementInspection */
2548 2548
 				case self::not_prepared_by_model_object:
2549 2549
 					$value = $field->prepare_for_set($value);
@@ -2554,7 +2554,7 @@  discard block
 block discarded – undo
2554 2554
 					//leave the value alone
2555 2555
 			}
2556 2556
 			return $value;
2557
-		}else{
2557
+		} else {
2558 2558
 			return $value;
2559 2559
 		}
2560 2560
 	}
@@ -2564,13 +2564,13 @@  discard block
 block discarded – undo
2564 2564
 	 * @return EE_Primary_Table
2565 2565
 	 * @throws EE_Error
2566 2566
 	 */
2567
-	protected function _get_main_table(){
2568
-		foreach($this->_tables as $table){
2569
-			if($table instanceof EE_Primary_Table){
2567
+	protected function _get_main_table() {
2568
+		foreach ($this->_tables as $table) {
2569
+			if ($table instanceof EE_Primary_Table) {
2570 2570
 				return $table;
2571 2571
 			}
2572 2572
 		}
2573
-		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)));
2573
+		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)));
2574 2574
 	}
2575 2575
 
2576 2576
 
@@ -2593,7 +2593,7 @@  discard block
 block discarded – undo
2593 2593
 	 */
2594 2594
 	public function second_table() {
2595 2595
 		// grab second table from tables array
2596
-		$second_table = end( $this->_tables );
2596
+		$second_table = end($this->_tables);
2597 2597
 		return $second_table instanceof EE_Secondary_Table ? $second_table->get_table_name() : NULL;
2598 2598
 	}
2599 2599
 
@@ -2606,8 +2606,8 @@  discard block
 block discarded – undo
2606 2606
 	 * @param string $table_alias
2607 2607
 	 * @return EE_Primary_Table | EE_Secondary_Table
2608 2608
 	 */
2609
-	public function get_table_obj_by_alias( $table_alias = '' ) {
2610
-		return isset( $this->_tables[ $table_alias ] ) ? $this->_tables[ $table_alias ] : NULL;
2609
+	public function get_table_obj_by_alias($table_alias = '') {
2610
+		return isset($this->_tables[$table_alias]) ? $this->_tables[$table_alias] : NULL;
2611 2611
 	}
2612 2612
 
2613 2613
 
@@ -2616,10 +2616,10 @@  discard block
 block discarded – undo
2616 2616
 	 * Gets all the tables of type EE_Other_Table from EEM_CPT_Basel_Model::_tables
2617 2617
 	 * @return EE_Secondary_Table[]
2618 2618
 	 */
2619
-	protected function _get_other_tables(){
2620
-		$other_tables =array();
2621
-		foreach($this->_tables as $table_alias => $table){
2622
-			if($table instanceof EE_Secondary_Table){
2619
+	protected function _get_other_tables() {
2620
+		$other_tables = array();
2621
+		foreach ($this->_tables as $table_alias => $table) {
2622
+			if ($table instanceof EE_Secondary_Table) {
2623 2623
 				$other_tables[$table_alias] = $table;
2624 2624
 			}
2625 2625
 		}
@@ -2631,7 +2631,7 @@  discard block
 block discarded – undo
2631 2631
 	 * @param string $table_alias, array key in EEM_Base::_tables
2632 2632
 	 * @return EE_Model_Field_Base[]
2633 2633
 	 */
2634
-	public function _get_fields_for_table($table_alias){
2634
+	public function _get_fields_for_table($table_alias) {
2635 2635
 		return $this->_fields[$table_alias];
2636 2636
 	}
2637 2637
 
@@ -2647,19 +2647,19 @@  discard block
 block discarded – undo
2647 2647
 	 * @return EE_Model_Query_Info_Carrier
2648 2648
 	 * @throws \EE_Error
2649 2649
 	 */
2650
-	public function _extract_related_models_from_query($query_params){
2650
+	public function _extract_related_models_from_query($query_params) {
2651 2651
 		$query_info_carrier = new EE_Model_Query_Info_Carrier();
2652
-		if ( array_key_exists( 0, $query_params ) ) {
2653
-			$this->_extract_related_models_from_sub_params_array_keys( $query_params[0], $query_info_carrier, 0 );
2652
+		if (array_key_exists(0, $query_params)) {
2653
+			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier, 0);
2654 2654
 		}
2655
-		if ( array_key_exists( 'group_by', $query_params ) ) {
2656
-			if ( is_array( $query_params['group_by'] ) ) {
2655
+		if (array_key_exists('group_by', $query_params)) {
2656
+			if (is_array($query_params['group_by'])) {
2657 2657
 				$this->_extract_related_models_from_sub_params_array_values(
2658 2658
 					$query_params['group_by'],
2659 2659
 					$query_info_carrier,
2660 2660
 					'group_by'
2661 2661
 				);
2662
-			} elseif ( ! empty ( $query_params['group_by'] ) ) {
2662
+			} elseif ( ! empty ($query_params['group_by'])) {
2663 2663
 				$this->_extract_related_model_info_from_query_param(
2664 2664
 					$query_params['group_by'],
2665 2665
 					$query_info_carrier,
@@ -2667,21 +2667,21 @@  discard block
 block discarded – undo
2667 2667
 				);
2668 2668
 			}
2669 2669
 		}
2670
-		if ( array_key_exists( 'having', $query_params ) ) {
2670
+		if (array_key_exists('having', $query_params)) {
2671 2671
 			$this->_extract_related_models_from_sub_params_array_keys(
2672 2672
 				$query_params[0],
2673 2673
 				$query_info_carrier,
2674 2674
 				'having'
2675 2675
 			);
2676 2676
 		}
2677
-		if ( array_key_exists( 'order_by', $query_params ) ) {
2678
-			if ( is_array( $query_params['order_by'] ) ) {
2677
+		if (array_key_exists('order_by', $query_params)) {
2678
+			if (is_array($query_params['order_by'])) {
2679 2679
 				$this->_extract_related_models_from_sub_params_array_keys(
2680 2680
 					$query_params['order_by'],
2681 2681
 					$query_info_carrier,
2682 2682
 					'order_by'
2683 2683
 				);
2684
-			} elseif ( ! empty( $query_params['order_by'] ) ) {
2684
+			} elseif ( ! empty($query_params['order_by'])) {
2685 2685
 				$this->_extract_related_model_info_from_query_param(
2686 2686
 					$query_params['order_by'],
2687 2687
 					$query_info_carrier,
@@ -2689,7 +2689,7 @@  discard block
 block discarded – undo
2689 2689
 				);
2690 2690
 			}
2691 2691
 		}
2692
-		if ( array_key_exists( 'force_join', $query_params ) ) {
2692
+		if (array_key_exists('force_join', $query_params)) {
2693 2693
 			$this->_extract_related_models_from_sub_params_array_values(
2694 2694
 				$query_params['force_join'],
2695 2695
 				$query_info_carrier,
@@ -2707,34 +2707,34 @@  discard block
 block discarded – undo
2707 2707
 	 * @throws EE_Error
2708 2708
 	 * @return \EE_Model_Query_Info_Carrier
2709 2709
 	 */
2710
-	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){
2711
-		if (!empty($sub_query_params)){
2710
+	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) {
2711
+		if ( ! empty($sub_query_params)) {
2712 2712
 			$sub_query_params = (array) $sub_query_params;
2713
-			foreach($sub_query_params as $param => $possibly_array_of_params){
2713
+			foreach ($sub_query_params as $param => $possibly_array_of_params) {
2714 2714
 				//$param could be simply 'EVT_ID', or it could be 'Registrations.REG_ID', or even 'Registrations.Transactions.Payments.PAY_amount'
2715
-				$this->_extract_related_model_info_from_query_param( $param, $model_query_info_carrier,$query_param_type);
2715
+				$this->_extract_related_model_info_from_query_param($param, $model_query_info_carrier, $query_param_type);
2716 2716
 
2717 2717
 				//if $possibly_array_of_params is an array, try recursing into it, searching for keys which
2718 2718
 				//indicate needed joins. Eg, array('NOT'=>array('Registration.TXN_ID'=>23)). In this case, we tried
2719 2719
 				//extracting models out of the 'NOT', which obviously wasn't successful, and then we recurse into the value
2720 2720
 				//of array('Registration.TXN_ID'=>23)
2721 2721
 				$query_param_sans_stars = $this->_remove_stars_and_anything_after_from_condition_query_param_key($param);
2722
-				if(in_array($query_param_sans_stars, $this->_logic_query_param_keys,true)){
2723
-					if (! is_array($possibly_array_of_params)){
2722
+				if (in_array($query_param_sans_stars, $this->_logic_query_param_keys, true)) {
2723
+					if ( ! is_array($possibly_array_of_params)) {
2724 2724
 						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"),
2725
-							$param,$possibly_array_of_params));
2726
-					}else{
2727
-						$this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier,$query_param_type);
2725
+							$param, $possibly_array_of_params));
2726
+					} else {
2727
+						$this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier, $query_param_type);
2728 2728
 					}
2729
-				}elseif($query_param_type === 0 //ie WHERE
2729
+				}elseif ($query_param_type === 0 //ie WHERE
2730 2730
 						&& is_array($possibly_array_of_params)
2731 2731
 						&& isset($possibly_array_of_params[2])
2732
-						&& $possibly_array_of_params[2] == true){
2732
+						&& $possibly_array_of_params[2] == true) {
2733 2733
 					//then $possible_array_of_params looks something like array('<','DTT_sold',true)
2734 2734
 					//indicating that $possible_array_of_params[1] is actually a field name,
2735 2735
 					//from which we should extract query parameters!
2736
-					if( ! isset($possibly_array_of_params[0], $possibly_array_of_params[1] ) ) {
2737
-						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)));
2736
+					if ( ! isset($possibly_array_of_params[0], $possibly_array_of_params[1])) {
2737
+						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)));
2738 2738
 					}
2739 2739
 					$this->_extract_related_model_info_from_query_param($possibly_array_of_params[1], $model_query_info_carrier, $query_param_type);
2740 2740
 				}
@@ -2753,14 +2753,14 @@  discard block
 block discarded – undo
2753 2753
 	 * @throws EE_Error
2754 2754
 	 * @return \EE_Model_Query_Info_Carrier
2755 2755
 	 */
2756
-	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){
2757
-		if (!empty($sub_query_params)){
2758
-			if(!is_array($sub_query_params)){
2759
-				throw new EE_Error(sprintf(__("Query parameter %s should be an array, but it isn't.", "event_espresso"),$sub_query_params));
2756
+	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) {
2757
+		if ( ! empty($sub_query_params)) {
2758
+			if ( ! is_array($sub_query_params)) {
2759
+				throw new EE_Error(sprintf(__("Query parameter %s should be an array, but it isn't.", "event_espresso"), $sub_query_params));
2760 2760
 			}
2761
-			foreach($sub_query_params as $param){
2761
+			foreach ($sub_query_params as $param) {
2762 2762
 				//$param could be simply 'EVT_ID', or it could be 'Registrations.REG_ID', or even 'Registrations.Transactions.Payments.PAY_amount'
2763
-				$this->_extract_related_model_info_from_query_param( $param, $model_query_info_carrier, $query_param_type);
2763
+				$this->_extract_related_model_info_from_query_param($param, $model_query_info_carrier, $query_param_type);
2764 2764
 			}
2765 2765
 		}
2766 2766
 		return $model_query_info_carrier;
@@ -2779,8 +2779,8 @@  discard block
 block discarded – undo
2779 2779
 	 * @throws EE_Error
2780 2780
 	 * @return EE_Model_Query_Info_Carrier
2781 2781
 	 */
2782
-	public function _create_model_query_info_carrier($query_params){
2783
-		if ( ! is_array( $query_params ) ) {
2782
+	public function _create_model_query_info_carrier($query_params) {
2783
+		if ( ! is_array($query_params)) {
2784 2784
 			EE_Error::doing_it_wrong(
2785 2785
 				'EEM_Base::_create_model_query_info_carrier',
2786 2786
 				sprintf(
@@ -2788,16 +2788,16 @@  discard block
 block discarded – undo
2788 2788
 						'$query_params should be an array, you passed a variable of type %s',
2789 2789
 						'event_espresso'
2790 2790
 					),
2791
-					gettype( $query_params )
2791
+					gettype($query_params)
2792 2792
 				),
2793 2793
 				'4.6.0'
2794 2794
 			);
2795 2795
 			$query_params = array();
2796 2796
 		}
2797
-		$where_query_params = isset( $query_params[0] ) ? $query_params[0] : array();
2797
+		$where_query_params = isset($query_params[0]) ? $query_params[0] : array();
2798 2798
 		//first check if we should alter the query to account for caps or not
2799 2799
 		//because the caps might require us to do extra joins
2800
-		if ( isset( $query_params['caps'] ) && $query_params['caps'] !== 'none' ) {
2800
+		if (isset($query_params['caps']) && $query_params['caps'] !== 'none') {
2801 2801
 			$query_params[0] = $where_query_params = array_replace_recursive(
2802 2802
 				$where_query_params,
2803 2803
 				$this->caps_where_conditions(
@@ -2805,10 +2805,10 @@  discard block
 block discarded – undo
2805 2805
 				)
2806 2806
 			);
2807 2807
 		}
2808
-		$query_object = $this->_extract_related_models_from_query( $query_params );
2808
+		$query_object = $this->_extract_related_models_from_query($query_params);
2809 2809
 		//verify where_query_params has NO numeric indexes.... that's simply not how you use it!
2810
-		foreach ( $where_query_params as $key => $value ) {
2811
-			if ( is_int( $key ) ) {
2810
+		foreach ($where_query_params as $key => $value) {
2811
+			if (is_int($key)) {
2812 2812
 				throw new EE_Error(
2813 2813
 					sprintf(
2814 2814
 						__(
@@ -2816,16 +2816,16 @@  discard block
 block discarded – undo
2816 2816
 							"event_espresso"
2817 2817
 						),
2818 2818
 						$key,
2819
-						var_export( $value, true ),
2820
-						var_export( $query_params, true ),
2821
-						get_class( $this )
2819
+						var_export($value, true),
2820
+						var_export($query_params, true),
2821
+						get_class($this)
2822 2822
 					)
2823 2823
 				);
2824 2824
 			}
2825 2825
 		}
2826 2826
 		if (
2827
-			array_key_exists( 'default_where_conditions', $query_params )
2828
-			&& ! empty( $query_params['default_where_conditions'] )
2827
+			array_key_exists('default_where_conditions', $query_params)
2828
+			&& ! empty($query_params['default_where_conditions'])
2829 2829
 		) {
2830 2830
 			$use_default_where_conditions = $query_params['default_where_conditions'];
2831 2831
 		} else {
@@ -2839,13 +2839,13 @@  discard block
 block discarded – undo
2839 2839
 			),
2840 2840
 			$where_query_params
2841 2841
 		);
2842
-		$query_object->set_where_sql( $this->_construct_where_clause( $where_query_params ) );
2842
+		$query_object->set_where_sql($this->_construct_where_clause($where_query_params));
2843 2843
 		// if this is a "on_join_limit" then we are limiting on on a specific table in a multi_table join.
2844 2844
 		// So we need to setup a subquery and use that for the main join.
2845 2845
 		// Note for now this only works on the primary table for the model.
2846 2846
 		// So for instance, you could set the limit array like this:
2847 2847
 		// array( 'on_join_limit' => array('Primary_Table_Alias', array(1,10) ) )
2848
-		if ( array_key_exists( 'on_join_limit', $query_params ) && ! empty( $query_params['on_join_limit'] ) ) {
2848
+		if (array_key_exists('on_join_limit', $query_params) && ! empty($query_params['on_join_limit'])) {
2849 2849
 			$query_object->set_main_model_join_sql(
2850 2850
 				$this->_construct_limit_join_select(
2851 2851
 					$query_params['on_join_limit'][0],
@@ -2854,40 +2854,40 @@  discard block
 block discarded – undo
2854 2854
 			);
2855 2855
 		}
2856 2856
 		//set limit
2857
-		if ( array_key_exists( 'limit', $query_params ) ) {
2858
-			if ( is_array( $query_params['limit'] ) ) {
2859
-				if ( ! isset( $query_params['limit'][0], $query_params['limit'][1] ) ) {
2857
+		if (array_key_exists('limit', $query_params)) {
2858
+			if (is_array($query_params['limit'])) {
2859
+				if ( ! isset($query_params['limit'][0], $query_params['limit'][1])) {
2860 2860
 					$e = sprintf(
2861 2861
 						__(
2862 2862
 							"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)",
2863 2863
 							"event_espresso"
2864 2864
 						),
2865
-						http_build_query( $query_params['limit'] )
2865
+						http_build_query($query_params['limit'])
2866 2866
 					);
2867
-					throw new EE_Error( $e . "|" . $e );
2867
+					throw new EE_Error($e."|".$e);
2868 2868
 				}
2869 2869
 				//they passed us an array for the limit. Assume it's like array(50,25), meaning offset by 50, and get 25
2870
-				$query_object->set_limit_sql( " LIMIT " . $query_params['limit'][0] . "," . $query_params['limit'][1] );
2871
-			} elseif ( ! empty ( $query_params['limit'] ) ) {
2872
-				$query_object->set_limit_sql( " LIMIT " . $query_params['limit'] );
2870
+				$query_object->set_limit_sql(" LIMIT ".$query_params['limit'][0].",".$query_params['limit'][1]);
2871
+			} elseif ( ! empty ($query_params['limit'])) {
2872
+				$query_object->set_limit_sql(" LIMIT ".$query_params['limit']);
2873 2873
 			}
2874 2874
 		}
2875 2875
 		//set order by
2876
-		if ( array_key_exists( 'order_by', $query_params ) ) {
2877
-			if ( is_array( $query_params['order_by'] ) ) {
2876
+		if (array_key_exists('order_by', $query_params)) {
2877
+			if (is_array($query_params['order_by'])) {
2878 2878
 				//if they're using 'order_by' as an array, they can't use 'order' (because 'order_by' must
2879 2879
 				//specify whether to ascend or descend on each field. Eg 'order_by'=>array('EVT_ID'=>'ASC'). So
2880 2880
 				//including 'order' wouldn't make any sense if 'order_by' has already specified which way to order!
2881
-				if ( array_key_exists( 'order', $query_params ) ) {
2881
+				if (array_key_exists('order', $query_params)) {
2882 2882
 					throw new EE_Error(
2883 2883
 						sprintf(
2884 2884
 							__(
2885 2885
 								"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 ",
2886 2886
 								"event_espresso"
2887 2887
 							),
2888
-							get_class( $this ),
2889
-							implode( ", ", array_keys( $query_params['order_by'] ) ),
2890
-							implode( ", ", $query_params['order_by'] ),
2888
+							get_class($this),
2889
+							implode(", ", array_keys($query_params['order_by'])),
2890
+							implode(", ", $query_params['order_by']),
2891 2891
 							$query_params['order']
2892 2892
 						)
2893 2893
 					);
@@ -2899,57 +2899,57 @@  discard block
 block discarded – undo
2899 2899
 				);
2900 2900
 				//assume it's an array of fields to order by
2901 2901
 				$order_array = array();
2902
-				foreach ( $query_params['order_by'] as $field_name_to_order_by => $order ) {
2903
-					$order = $this->_extract_order( $order );
2904
-					$order_array[] = $this->_deduce_column_name_from_query_param( $field_name_to_order_by ) . SP . $order;
2902
+				foreach ($query_params['order_by'] as $field_name_to_order_by => $order) {
2903
+					$order = $this->_extract_order($order);
2904
+					$order_array[] = $this->_deduce_column_name_from_query_param($field_name_to_order_by).SP.$order;
2905 2905
 				}
2906
-				$query_object->set_order_by_sql( " ORDER BY " . implode( ",", $order_array ) );
2907
-			} elseif ( ! empty ( $query_params['order_by'] ) ) {
2906
+				$query_object->set_order_by_sql(" ORDER BY ".implode(",", $order_array));
2907
+			} elseif ( ! empty ($query_params['order_by'])) {
2908 2908
 				$this->_extract_related_model_info_from_query_param(
2909 2909
 					$query_params['order_by'],
2910 2910
 					$query_object,
2911 2911
 					'order',
2912 2912
 					$query_params['order_by']
2913 2913
 				);
2914
-				$order = isset( $query_params['order'] )
2915
-					? $this->_extract_order( $query_params['order'] )
2914
+				$order = isset($query_params['order'])
2915
+					? $this->_extract_order($query_params['order'])
2916 2916
 					: 'DESC';
2917 2917
 				$query_object->set_order_by_sql(
2918
-					" ORDER BY " . $this->_deduce_column_name_from_query_param( $query_params['order_by'] ) . SP . $order
2918
+					" ORDER BY ".$this->_deduce_column_name_from_query_param($query_params['order_by']).SP.$order
2919 2919
 				);
2920 2920
 			}
2921 2921
 		}
2922 2922
 		//if 'order_by' wasn't set, maybe they are just using 'order' on its own?
2923
-		if ( ! array_key_exists( 'order_by', $query_params )
2924
-		     && array_key_exists( 'order', $query_params )
2925
-		     && ! empty( $query_params['order'] )
2923
+		if ( ! array_key_exists('order_by', $query_params)
2924
+		     && array_key_exists('order', $query_params)
2925
+		     && ! empty($query_params['order'])
2926 2926
 		) {
2927 2927
 			$pk_field = $this->get_primary_key_field();
2928
-			$order = $this->_extract_order( $query_params['order'] );
2929
-			$query_object->set_order_by_sql( " ORDER BY " . $pk_field->get_qualified_column() . SP . $order );
2928
+			$order = $this->_extract_order($query_params['order']);
2929
+			$query_object->set_order_by_sql(" ORDER BY ".$pk_field->get_qualified_column().SP.$order);
2930 2930
 		}
2931 2931
 		//set group by
2932
-		if ( array_key_exists( 'group_by', $query_params ) ) {
2933
-			if ( is_array( $query_params['group_by'] ) ) {
2932
+		if (array_key_exists('group_by', $query_params)) {
2933
+			if (is_array($query_params['group_by'])) {
2934 2934
 				//it's an array, so assume we'll be grouping by a bunch of stuff
2935 2935
 				$group_by_array = array();
2936
-				foreach ( $query_params['group_by'] as $field_name_to_group_by ) {
2937
-					$group_by_array[] = $this->_deduce_column_name_from_query_param( $field_name_to_group_by );
2936
+				foreach ($query_params['group_by'] as $field_name_to_group_by) {
2937
+					$group_by_array[] = $this->_deduce_column_name_from_query_param($field_name_to_group_by);
2938 2938
 				}
2939
-				$query_object->set_group_by_sql( " GROUP BY " . implode( ", ", $group_by_array ) );
2940
-			} elseif ( ! empty ( $query_params['group_by'] ) ) {
2939
+				$query_object->set_group_by_sql(" GROUP BY ".implode(", ", $group_by_array));
2940
+			} elseif ( ! empty ($query_params['group_by'])) {
2941 2941
 				$query_object->set_group_by_sql(
2942
-					" GROUP BY " . $this->_deduce_column_name_from_query_param( $query_params['group_by'] )
2942
+					" GROUP BY ".$this->_deduce_column_name_from_query_param($query_params['group_by'])
2943 2943
 				);
2944 2944
 			}
2945 2945
 		}
2946 2946
 		//set having
2947
-		if ( array_key_exists( 'having', $query_params ) && $query_params['having'] ) {
2948
-			$query_object->set_having_sql( $this->_construct_having_clause( $query_params['having'] ) );
2947
+		if (array_key_exists('having', $query_params) && $query_params['having']) {
2948
+			$query_object->set_having_sql($this->_construct_having_clause($query_params['having']));
2949 2949
 		}
2950 2950
 		//now, just verify they didn't pass anything wack
2951
-		foreach ( $query_params as $query_key => $query_value ) {
2952
-			if ( ! in_array( $query_key, $this->_allowed_query_params, true ) ) {
2951
+		foreach ($query_params as $query_key => $query_value) {
2952
+			if ( ! in_array($query_key, $this->_allowed_query_params, true)) {
2953 2953
 				throw new EE_Error(
2954 2954
 					sprintf(
2955 2955
 						__(
@@ -2957,16 +2957,16 @@  discard block
 block discarded – undo
2957 2957
 							'event_espresso'
2958 2958
 						),
2959 2959
 						$query_key,
2960
-						get_class( $this ),
2960
+						get_class($this),
2961 2961
 //						print_r( $this->_allowed_query_params, TRUE )
2962
-						implode( ',', $this->_allowed_query_params )
2962
+						implode(',', $this->_allowed_query_params)
2963 2963
 					)
2964 2964
 				);
2965 2965
 			}
2966 2966
 		}
2967 2967
 		$main_model_join_sql = $query_object->get_main_model_join_sql();
2968
-		if ( empty( $main_model_join_sql ) ) {
2969
-			$query_object->set_main_model_join_sql( $this->_construct_internal_join() );
2968
+		if (empty($main_model_join_sql)) {
2969
+			$query_object->set_main_model_join_sql($this->_construct_internal_join());
2970 2970
 		}
2971 2971
 		return $query_object;
2972 2972
 	}
@@ -2981,17 +2981,17 @@  discard block
 block discarded – undo
2981 2981
 	 * @return array like EEM_Base::get_all() 's $query_params[0]
2982 2982
 	 * @throws \EE_Error
2983 2983
 	 */
2984
-	public function caps_where_conditions( $context = self::caps_read ) {
2985
-		EEM_Base::verify_is_valid_cap_context( $context );
2984
+	public function caps_where_conditions($context = self::caps_read) {
2985
+		EEM_Base::verify_is_valid_cap_context($context);
2986 2986
 		$cap_where_conditions = array();
2987
-		$cap_restrictions = $this->caps_missing( $context );
2987
+		$cap_restrictions = $this->caps_missing($context);
2988 2988
 		/**
2989 2989
 		 * @var $cap_restrictions EE_Default_Where_Conditions[]
2990 2990
 		 */
2991
-		foreach( $cap_restrictions as $cap => $restriction_if_no_cap ) {
2992
-				$cap_where_conditions = array_replace_recursive( $cap_where_conditions, $restriction_if_no_cap->get_default_where_conditions() );
2991
+		foreach ($cap_restrictions as $cap => $restriction_if_no_cap) {
2992
+				$cap_where_conditions = array_replace_recursive($cap_where_conditions, $restriction_if_no_cap->get_default_where_conditions());
2993 2993
 		}
2994
-		return apply_filters( 'FHEE__EEM_Base__caps_where_conditions__return', $cap_where_conditions, $this, $context, $cap_restrictions );
2994
+		return apply_filters('FHEE__EEM_Base__caps_where_conditions__return', $cap_where_conditions, $this, $context, $cap_restrictions);
2995 2995
 	}
2996 2996
 
2997 2997
 	/**
@@ -3001,11 +3001,11 @@  discard block
 block discarded – undo
3001 3001
 	 * @return string either ASC, asc, DESC or desc
3002 3002
 	 * @throws EE_Error
3003 3003
 	 */
3004
-	private function _extract_order($should_be_order_string){
3005
-		if(in_array($should_be_order_string, $this->_allowed_order_values)){
3004
+	private function _extract_order($should_be_order_string) {
3005
+		if (in_array($should_be_order_string, $this->_allowed_order_values)) {
3006 3006
 			return $should_be_order_string;
3007
-		}else{
3008
-			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));
3007
+		} else {
3008
+			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));
3009 3009
 		}
3010 3010
 	}
3011 3011
 
@@ -3023,7 +3023,7 @@  discard block
 block discarded – undo
3023 3023
 	 * @throws EE_Error
3024 3024
 	 * @return array like $query_params[0], see EEM_Base::get_all for documentation
3025 3025
 	 */
3026
-	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()){
3026
+	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()) {
3027 3027
 		$allowed_used_default_where_conditions_values = array(
3028 3028
 				'all',
3029 3029
 				'this_model_only',
@@ -3031,17 +3031,17 @@  discard block
 block discarded – undo
3031 3031
 				'minimum',
3032 3032
 				'none'
3033 3033
 			);
3034
-		if( ! in_array($use_default_where_conditions,$allowed_used_default_where_conditions_values)){
3035
-			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)));
3034
+		if ( ! in_array($use_default_where_conditions, $allowed_used_default_where_conditions_values)) {
3035
+			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)));
3036 3036
 		}
3037 3037
 		$universal_query_params = array();
3038
-		if( $use_default_where_conditions === 'all' || $use_default_where_conditions === 'this_model_only' ){
3038
+		if ($use_default_where_conditions === 'all' || $use_default_where_conditions === 'this_model_only') {
3039 3039
 			$universal_query_params = $this->_get_default_where_conditions();
3040
-		} else if( $use_default_where_conditions === 'minimum' ) {
3040
+		} else if ($use_default_where_conditions === 'minimum') {
3041 3041
 			$universal_query_params = $this->_get_minimum_where_conditions();
3042 3042
 		}
3043
-		if(in_array($use_default_where_conditions,array('all','other_models_only'))){
3044
-			foreach($query_info_carrier->get_model_names_included() as $model_relation_path => $model_name){
3043
+		if (in_array($use_default_where_conditions, array('all', 'other_models_only'))) {
3044
+			foreach ($query_info_carrier->get_model_names_included() as $model_relation_path => $model_name) {
3045 3045
 				$related_model = $this->get_related_model_obj($model_name);
3046 3046
 				$related_model_universal_where_params = $related_model->_get_default_where_conditions($model_relation_path);
3047 3047
 				$overrides = $this->_override_defaults_or_make_null_friendly(
@@ -3074,20 +3074,20 @@  discard block
 block discarded – undo
3074 3074
 	 * @return array like EEM_Base::get_all's $query_params[0]
3075 3075
 	 * @throws \EE_Error
3076 3076
 	 */
3077
-	private function _override_defaults_or_make_null_friendly($default_where_conditions,$provided_where_conditions,$model,$model_relation_path){
3077
+	private function _override_defaults_or_make_null_friendly($default_where_conditions, $provided_where_conditions, $model, $model_relation_path) {
3078 3078
 		$null_friendly_where_conditions = array();
3079 3079
 		$none_overridden = true;
3080 3080
 		$or_condition_key_for_defaults = 'OR*'.get_class($model);
3081 3081
 
3082
-		foreach($default_where_conditions as $key => $val){
3083
-			if( isset($provided_where_conditions[$key])){
3082
+		foreach ($default_where_conditions as $key => $val) {
3083
+			if (isset($provided_where_conditions[$key])) {
3084 3084
 				$none_overridden = false;
3085
-			}else{
3085
+			} else {
3086 3086
 				$null_friendly_where_conditions[$or_condition_key_for_defaults]['AND'][$key] = $val;
3087 3087
 			}
3088 3088
 		}
3089
-		if( $none_overridden && $default_where_conditions){
3090
-			if($model->has_primary_key_field()){
3089
+		if ($none_overridden && $default_where_conditions) {
3090
+			if ($model->has_primary_key_field()) {
3091 3091
 				$null_friendly_where_conditions[$or_condition_key_for_defaults][$model_relation_path.".".$model->primary_key_name()] = array('IS NULL');
3092 3092
 			}/*else{
3093 3093
 				//@todo NO PK, use other defaults
@@ -3104,8 +3104,8 @@  discard block
 block discarded – undo
3104 3104
 	 * @param string $model_relation_path eg, path from Event to Payment is "Registration.Transaction.Payment."
3105 3105
 	 * @return array like EEM_Base::get_all's $query_params[0] (where conditions)
3106 3106
 	 */
3107
-	private function _get_default_where_conditions($model_relation_path = null){
3108
-		if ( $this->_ignore_where_strategy ){
3107
+	private function _get_default_where_conditions($model_relation_path = null) {
3108
+		if ($this->_ignore_where_strategy) {
3109 3109
 			return array();
3110 3110
 		}
3111 3111
 		return $this->_default_where_conditions_strategy->get_default_where_conditions($model_relation_path);
@@ -3119,8 +3119,8 @@  discard block
 block discarded – undo
3119 3119
 	 * @param string $model_relation_path eg, path from Event to Payment is "Registration.Transaction.Payment."
3120 3120
 	 * @return array like EEM_Base::get_all's $query_params[0] (where conditions)
3121 3121
 	 */
3122
-	protected function _get_minimum_where_conditions($model_relation_path = null){
3123
-		if ( $this->_ignore_where_strategy ){
3122
+	protected function _get_minimum_where_conditions($model_relation_path = null) {
3123
+		if ($this->_ignore_where_strategy) {
3124 3124
 			return array();
3125 3125
 		}
3126 3126
 		return $this->_minimum_where_conditions_strategy->get_default_where_conditions($model_relation_path);
@@ -3136,16 +3136,16 @@  discard block
 block discarded – undo
3136 3136
 	 * @return string
3137 3137
 	 * @throws \EE_Error
3138 3138
 	 */
3139
-	private function _construct_default_select_sql(EE_Model_Query_Info_Carrier $model_query_info){
3139
+	private function _construct_default_select_sql(EE_Model_Query_Info_Carrier $model_query_info) {
3140 3140
 		$selects = $this->_get_columns_to_select_for_this_model();
3141
-		foreach($model_query_info->get_model_names_included() as $model_relation_chain => $name_of_other_model_included){
3141
+		foreach ($model_query_info->get_model_names_included() as $model_relation_chain => $name_of_other_model_included) {
3142 3142
 			$other_model_included = $this->get_related_model_obj($name_of_other_model_included);
3143
-			$other_model_selects = $other_model_included->_get_columns_to_select_for_this_model( $model_relation_chain );
3144
-			foreach ( $other_model_selects as $key => $value ) {
3143
+			$other_model_selects = $other_model_included->_get_columns_to_select_for_this_model($model_relation_chain);
3144
+			foreach ($other_model_selects as $key => $value) {
3145 3145
 				$selects[] = $value;
3146 3146
 			}
3147 3147
 		}
3148
-		return implode(", ",$selects);
3148
+		return implode(", ", $selects);
3149 3149
 	}
3150 3150
 
3151 3151
 	/**
@@ -3154,19 +3154,19 @@  discard block
 block discarded – undo
3154 3154
 	 * @param string $model_relation_chain like 'Question.Question_Group.Event'
3155 3155
 	 * @return array numerically indexed, values are columns to select and rename, eg "Event.ID AS 'Event.ID'"
3156 3156
 	 */
3157
-	public function _get_columns_to_select_for_this_model($model_relation_chain = ''){
3157
+	public function _get_columns_to_select_for_this_model($model_relation_chain = '') {
3158 3158
 		$fields = $this->field_settings();
3159 3159
 		$selects = array();
3160 3160
 		$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());
3161
-		foreach($fields as $field_obj){
3162
-			$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()."'";
3161
+		foreach ($fields as $field_obj) {
3162
+			$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()."'";
3163 3163
 		}
3164 3164
 		//make sure we are also getting the PKs of each table
3165 3165
 		$tables = $this->get_tables();
3166
-		if(count($tables) > 1){
3167
-			foreach($tables as $table_obj){
3168
-				$qualified_pk_column = $table_alias_with_model_relation_chain_prefix . $table_obj->get_fully_qualified_pk_column();
3169
-				if( ! in_array($qualified_pk_column,$selects)){
3166
+		if (count($tables) > 1) {
3167
+			foreach ($tables as $table_obj) {
3168
+				$qualified_pk_column = $table_alias_with_model_relation_chain_prefix.$table_obj->get_fully_qualified_pk_column();
3169
+				if ( ! in_array($qualified_pk_column, $selects)) {
3170 3170
 					$selects[] = "$qualified_pk_column AS '$qualified_pk_column'";
3171 3171
 				}
3172 3172
 			}
@@ -3196,65 +3196,65 @@  discard block
 block discarded – undo
3196 3196
 		$query_param_type,
3197 3197
 		$original_query_param = null
3198 3198
 	) {
3199
-		if( $original_query_param === null ){
3199
+		if ($original_query_param === null) {
3200 3200
 			$original_query_param = $query_param;
3201 3201
 		}
3202 3202
 		$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param);
3203 3203
 		/** @var $allow_logic_query_params bool whether or not to allow logic_query_params like 'NOT','OR', or 'AND' */
3204
-		$allow_logic_query_params = in_array($query_param_type,array('where','having'));
3205
-		$allow_fields = in_array($query_param_type,array('where','having','order_by','group_by','order'));
3204
+		$allow_logic_query_params = in_array($query_param_type, array('where', 'having'));
3205
+		$allow_fields = in_array($query_param_type, array('where', 'having', 'order_by', 'group_by', 'order'));
3206 3206
 		//check to see if we have a field on this model
3207 3207
 		$this_model_fields = $this->field_settings(true);
3208
-		if(array_key_exists($query_param,$this_model_fields)){
3209
-			if($allow_fields){
3208
+		if (array_key_exists($query_param, $this_model_fields)) {
3209
+			if ($allow_fields) {
3210 3210
 				return;
3211
-			}else{
3211
+			} else {
3212 3212
 				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"),
3213
-						$query_param,get_class($this),$query_param_type,$original_query_param));
3213
+						$query_param, get_class($this), $query_param_type, $original_query_param));
3214 3214
 			}
3215 3215
 		}
3216 3216
 		//check if this is a special logic query param
3217
-		elseif(in_array($query_param, $this->_logic_query_param_keys, TRUE)){
3218
-			if($allow_logic_query_params){
3217
+		elseif (in_array($query_param, $this->_logic_query_param_keys, TRUE)) {
3218
+			if ($allow_logic_query_params) {
3219 3219
 				return;
3220
-			}else{
3220
+			} else {
3221 3221
 				throw new EE_Error(
3222 3222
 					sprintf(
3223
-						__( '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' ),
3224
-						implode( '", "', $this->_logic_query_param_keys ),
3225
-						$query_param ,
3226
-						get_class( $this ),
3223
+						__('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'),
3224
+						implode('", "', $this->_logic_query_param_keys),
3225
+						$query_param,
3226
+						get_class($this),
3227 3227
 						'<br />',
3228
-						"\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
3228
+						"\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
3229 3229
 					)
3230 3230
 				);
3231 3231
 			}
3232 3232
 		}
3233 3233
 
3234 3234
 		//check if it's a custom selection
3235
-		elseif(array_key_exists($query_param,$this->_custom_selections)){
3235
+		elseif (array_key_exists($query_param, $this->_custom_selections)) {
3236 3236
 			return;
3237 3237
 		}
3238 3238
 
3239 3239
 		//check if has a model name at the beginning
3240 3240
 		//and
3241 3241
 		//check if it's a field on a related model
3242
-		foreach($this->_model_relations as $valid_related_model_name=>$relation_obj){
3243
-			if(strpos($query_param, $valid_related_model_name.".") === 0){
3244
-				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param);
3242
+		foreach ($this->_model_relations as $valid_related_model_name=>$relation_obj) {
3243
+			if (strpos($query_param, $valid_related_model_name.".") === 0) {
3244
+				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info, $original_query_param);
3245 3245
 				$query_param = substr($query_param, strlen($valid_related_model_name."."));
3246
-				if($query_param === ''){
3246
+				if ($query_param === '') {
3247 3247
 					//nothing left to $query_param
3248 3248
 					//we should actually end in a field name, not a model like this!
3249 3249
 					throw new EE_Error(sprintf(__("Query param '%s' (of type %s on model %s) shouldn't end on a period (.) ", "event_espresso"),
3250
-					$query_param,$query_param_type,get_class($this),$valid_related_model_name));
3251
-				}else{
3250
+					$query_param, $query_param_type, get_class($this), $valid_related_model_name));
3251
+				} else {
3252 3252
 					$related_model_obj = $this->get_related_model_obj($valid_related_model_name);
3253 3253
 					$related_model_obj->_extract_related_model_info_from_query_param($query_param, $passed_in_query_info, $query_param_type, $original_query_param);
3254 3254
 					return;
3255 3255
 				}
3256
-			}elseif($query_param === $valid_related_model_name){
3257
-				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param);
3256
+			}elseif ($query_param === $valid_related_model_name) {
3257
+				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info, $original_query_param);
3258 3258
 				return;
3259 3259
 			}
3260 3260
 		}
@@ -3264,7 +3264,7 @@  discard block
 block discarded – undo
3264 3264
 		//and we previously confirmed it wasn't a logic query param or field on the current model
3265 3265
 		//it's wack, that's what it is
3266 3266
 		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"),
3267
-				$query_param,get_class($this),$query_param_type,$original_query_param));
3267
+				$query_param, get_class($this), $query_param_type, $original_query_param));
3268 3268
 
3269 3269
 	}
3270 3270
 
@@ -3283,26 +3283,26 @@  discard block
 block discarded – undo
3283 3283
 	 * @return void
3284 3284
 	 * @throws \EE_Error
3285 3285
 	 */
3286
-	private function _add_join_to_model($model_name, EE_Model_Query_Info_Carrier $passed_in_query_info,$original_query_param){
3286
+	private function _add_join_to_model($model_name, EE_Model_Query_Info_Carrier $passed_in_query_info, $original_query_param) {
3287 3287
 		$relation_obj = $this->related_settings_for($model_name);
3288 3288
 
3289 3289
 		$model_relation_chain = EE_Model_Parser::extract_model_relation_chain($model_name, $original_query_param);
3290 3290
 		//check if the relation is HABTM, because then we're essentially doing two joins
3291 3291
 		//If so, join first to the JOIN table, and add its data types, and then continue as normal
3292
-		if($relation_obj instanceof EE_HABTM_Relation){
3292
+		if ($relation_obj instanceof EE_HABTM_Relation) {
3293 3293
 			$join_model_obj = $relation_obj->get_join_model();
3294 3294
 			//replace the model specified with the join model for this relation chain, whi
3295 3295
 			$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);
3296 3296
 			$new_query_info = new EE_Model_Query_Info_Carrier(
3297 3297
 					array($relation_chain_to_join_model => $join_model_obj->get_this_model_name()),
3298 3298
 					$relation_obj->get_join_to_intermediate_model_statement($relation_chain_to_join_model));
3299
-			$passed_in_query_info->merge( $new_query_info  );
3299
+			$passed_in_query_info->merge($new_query_info);
3300 3300
 		}
3301 3301
 		//now just join to the other table pointed to by the relation object, and add its data types
3302 3302
 		$new_query_info = new EE_Model_Query_Info_Carrier(
3303 3303
 				array($model_relation_chain=>$model_name),
3304 3304
 				$relation_obj->get_join_statement($model_relation_chain));
3305
-		$passed_in_query_info->merge( $new_query_info  );
3305
+		$passed_in_query_info->merge($new_query_info);
3306 3306
 	}
3307 3307
 
3308 3308
 
@@ -3314,11 +3314,11 @@  discard block
 block discarded – undo
3314 3314
 	 * @return string of SQL
3315 3315
 	 * @throws \EE_Error
3316 3316
 	 */
3317
-	private function _construct_where_clause($where_params){
3317
+	private function _construct_where_clause($where_params) {
3318 3318
 		$SQL = $this->_construct_condition_clause_recursive($where_params, ' AND ');
3319
-		if($SQL){
3320
-			return " WHERE ". $SQL;
3321
-		}else{
3319
+		if ($SQL) {
3320
+			return " WHERE ".$SQL;
3321
+		} else {
3322 3322
 			return '';
3323 3323
 		}
3324 3324
 	}
@@ -3333,11 +3333,11 @@  discard block
 block discarded – undo
3333 3333
 	 * @return string
3334 3334
 	 * @throws \EE_Error
3335 3335
 	 */
3336
-	private function _construct_having_clause($having_params){
3336
+	private function _construct_having_clause($having_params) {
3337 3337
 		$SQL = $this->_construct_condition_clause_recursive($having_params, ' AND ');
3338
-		if($SQL){
3339
-			return " HAVING ". $SQL;
3340
-		}else{
3338
+		if ($SQL) {
3339
+			return " HAVING ".$SQL;
3340
+		} else {
3341 3341
 			return '';
3342 3342
 		}
3343 3343
 
@@ -3351,16 +3351,16 @@  discard block
 block discarded – undo
3351 3351
 	 * @return EE_Model_Field_Base
3352 3352
 	 * @throws EE_Error
3353 3353
 	 */
3354
-	protected function _get_field_on_model($field_name,$model_name){
3354
+	protected function _get_field_on_model($field_name, $model_name) {
3355 3355
 		$model_class = 'EEM_'.$model_name;
3356 3356
 		$model_filepath = $model_class.".model.php";
3357
-		if ( is_readable($model_filepath)){
3357
+		if (is_readable($model_filepath)) {
3358 3358
 			require_once($model_filepath);
3359
-			$model_instance=call_user_func($model_name."::instance");
3359
+			$model_instance = call_user_func($model_name."::instance");
3360 3360
 			/* @var $model_instance EEM_Base */
3361 3361
 			return $model_instance->field_settings_for($field_name);
3362
-		}else{
3363
-			throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s','event_espresso'),$model_name,$model_class,$model_filepath));
3362
+		} else {
3363
+			throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s', 'event_espresso'), $model_name, $model_class, $model_filepath));
3364 3364
 		}
3365 3365
 	}
3366 3366
 
@@ -3373,41 +3373,41 @@  discard block
 block discarded – undo
3373 3373
 	 * @throws EE_Error
3374 3374
 	 * @return string of SQL
3375 3375
 	 */
3376
-	private function _construct_condition_clause_recursive($where_params, $glue = ' AND'){
3377
-		$where_clauses=array();
3378
-		foreach($where_params as $query_param => $op_and_value_or_sub_condition){
3379
-			$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param);//str_replace("*",'',$query_param);
3380
-			if(in_array($query_param,$this->_logic_query_param_keys)){
3381
-				switch($query_param){
3376
+	private function _construct_condition_clause_recursive($where_params, $glue = ' AND') {
3377
+		$where_clauses = array();
3378
+		foreach ($where_params as $query_param => $op_and_value_or_sub_condition) {
3379
+			$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param); //str_replace("*",'',$query_param);
3380
+			if (in_array($query_param, $this->_logic_query_param_keys)) {
3381
+				switch ($query_param) {
3382 3382
 					case 'not':
3383 3383
 					case 'NOT':
3384
-						$where_clauses[] = "! (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, $glue).")";
3384
+						$where_clauses[] = "! (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, $glue).")";
3385 3385
 						break;
3386 3386
 					case 'and':
3387 3387
 					case 'AND':
3388
-						$where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' AND ') .")";
3388
+						$where_clauses[] = " (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' AND ').")";
3389 3389
 						break;
3390 3390
 					case 'or':
3391 3391
 					case 'OR':
3392
-						$where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ') .")";
3392
+						$where_clauses[] = " (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ').")";
3393 3393
 						break;
3394 3394
 				}
3395
-			}else{
3395
+			} else {
3396 3396
 				$field_obj = $this->_deduce_field_from_query_param($query_param);
3397 3397
 
3398 3398
 				//if it's not a normal field, maybe it's a custom selection?
3399
-				if( ! $field_obj){
3400
-					if(isset( $this->_custom_selections[$query_param][1])){
3399
+				if ( ! $field_obj) {
3400
+					if (isset($this->_custom_selections[$query_param][1])) {
3401 3401
 						$field_obj = $this->_custom_selections[$query_param][1];
3402
-					}else{
3403
-						throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"),$query_param));
3402
+					} else {
3403
+						throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"), $query_param));
3404 3404
 					}
3405 3405
 				}
3406 3406
 				$op_and_value_sql = $this->_construct_op_and_value($op_and_value_or_sub_condition, $field_obj);
3407
-				$where_clauses[]=$this->_deduce_column_name_from_query_param($query_param).SP.$op_and_value_sql;
3407
+				$where_clauses[] = $this->_deduce_column_name_from_query_param($query_param).SP.$op_and_value_sql;
3408 3408
 			}
3409 3409
 		}
3410
-		return $where_clauses ? implode( $glue, $where_clauses ) : '';
3410
+		return $where_clauses ? implode($glue, $where_clauses) : '';
3411 3411
 	}
3412 3412
 
3413 3413
 
@@ -3418,18 +3418,18 @@  discard block
 block discarded – undo
3418 3418
 	 * @throws EE_Error
3419 3419
 	 * @return string table alias and column name for SQL, eg "Transaction.TXN_ID"
3420 3420
 	 */
3421
-	private function _deduce_column_name_from_query_param($query_param){
3421
+	private function _deduce_column_name_from_query_param($query_param) {
3422 3422
 		$field = $this->_deduce_field_from_query_param($query_param);
3423 3423
 
3424
-		if( $field ){
3425
-			$table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param( $field->get_model_name(), $query_param );
3426
-			return $table_alias_prefix . $field->get_qualified_column();
3427
-		}elseif(array_key_exists($query_param,$this->_custom_selections)){
3424
+		if ($field) {
3425
+			$table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param($field->get_model_name(), $query_param);
3426
+			return $table_alias_prefix.$field->get_qualified_column();
3427
+		}elseif (array_key_exists($query_param, $this->_custom_selections)) {
3428 3428
 			//maybe it's custom selection item?
3429 3429
 			//if so, just use it as the "column name"
3430 3430
 			return $query_param;
3431
-		}else{
3432
-			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)));
3431
+		} else {
3432
+			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)));
3433 3433
 		}
3434 3434
 	}
3435 3435
 
@@ -3441,11 +3441,11 @@  discard block
 block discarded – undo
3441 3441
 	 * @param string $condition_query_param_key
3442 3442
 	 * @return string
3443 3443
 	 */
3444
-	private function _remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key){
3444
+	private function _remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key) {
3445 3445
 		$pos_of_star = strpos($condition_query_param_key, '*');
3446
-		if($pos_of_star === FALSE){
3446
+		if ($pos_of_star === FALSE) {
3447 3447
 			return $condition_query_param_key;
3448
-		}else{
3448
+		} else {
3449 3449
 			$condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star);
3450 3450
 			return $condition_query_param_sans_star;
3451 3451
 		}
@@ -3460,12 +3460,12 @@  discard block
 block discarded – undo
3460 3460
 	 * @throws EE_Error
3461 3461
 	 * @return string
3462 3462
 	 */
3463
-	private function _construct_op_and_value($op_and_value, $field_obj){
3464
-		if ( is_array( $op_and_value ) ) {
3465
-			$operator = isset( $op_and_value[0] ) ? $this->_prepare_operator_for_sql( $op_and_value[0] ) : null;
3466
-			if ( ! $operator ) {
3463
+	private function _construct_op_and_value($op_and_value, $field_obj) {
3464
+		if (is_array($op_and_value)) {
3465
+			$operator = isset($op_and_value[0]) ? $this->_prepare_operator_for_sql($op_and_value[0]) : null;
3466
+			if ( ! $operator) {
3467 3467
 				$php_array_like_string = array();
3468
-				foreach ( $op_and_value as $key => $value ) {
3468
+				foreach ($op_and_value as $key => $value) {
3469 3469
 					$php_array_like_string[] = "$key=>$value";
3470 3470
 				}
3471 3471
 				throw new EE_Error(
@@ -3474,27 +3474,27 @@  discard block
 block discarded – undo
3474 3474
 							"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))",
3475 3475
 							"event_espresso"
3476 3476
 						),
3477
-						implode( ",", $php_array_like_string )
3477
+						implode(",", $php_array_like_string)
3478 3478
 					)
3479 3479
 				);
3480 3480
 			}
3481
-			$value = isset( $op_and_value[1] ) ? $op_and_value[1] : null;
3481
+			$value = isset($op_and_value[1]) ? $op_and_value[1] : null;
3482 3482
 		} else {
3483 3483
 			$operator = '=';
3484 3484
 			$value = $op_and_value;
3485 3485
 		}
3486 3486
 		//check to see if the value is actually another field
3487
-		if ( is_array( $op_and_value ) && isset( $op_and_value[2] ) && $op_and_value[2] == true ) {
3488
-			return $operator . SP . $this->_deduce_column_name_from_query_param( $value );
3489
-		} elseif ( in_array( $operator, $this->_in_style_operators ) && is_array( $value ) ) {
3487
+		if (is_array($op_and_value) && isset($op_and_value[2]) && $op_and_value[2] == true) {
3488
+			return $operator.SP.$this->_deduce_column_name_from_query_param($value);
3489
+		} elseif (in_array($operator, $this->_in_style_operators) && is_array($value)) {
3490 3490
 			//in this case, the value should be an array, or at least a comma-separated list
3491 3491
 			//it will need to handle a little differently
3492
-			$cleaned_value = $this->_construct_in_value( $value, $field_obj );
3492
+			$cleaned_value = $this->_construct_in_value($value, $field_obj);
3493 3493
 			//note: $cleaned_value has already been run through $wpdb->prepare()
3494
-			return $operator . SP . $cleaned_value;
3495
-		} elseif ( in_array( $operator, $this->_between_style_operators ) && is_array( $value ) ) {
3494
+			return $operator.SP.$cleaned_value;
3495
+		} elseif (in_array($operator, $this->_between_style_operators) && is_array($value)) {
3496 3496
 			//the value should be an array with count of two.
3497
-			if ( count( $value ) !== 2 ) {
3497
+			if (count($value) !== 2) {
3498 3498
 				throw new EE_Error(
3499 3499
 					sprintf(
3500 3500
 						__(
@@ -3505,10 +3505,10 @@  discard block
 block discarded – undo
3505 3505
 					)
3506 3506
 				);
3507 3507
 			}
3508
-			$cleaned_value = $this->_construct_between_value( $value, $field_obj );
3509
-			return $operator . SP . $cleaned_value;
3510
-		} elseif ( in_array( $operator, $this->_null_style_operators ) ) {
3511
-			if ( $value !== null ) {
3508
+			$cleaned_value = $this->_construct_between_value($value, $field_obj);
3509
+			return $operator.SP.$cleaned_value;
3510
+		} elseif (in_array($operator, $this->_null_style_operators)) {
3511
+			if ($value !== null) {
3512 3512
 				throw new EE_Error(
3513 3513
 					sprintf(
3514 3514
 						__(
@@ -3521,13 +3521,13 @@  discard block
 block discarded – undo
3521 3521
 				);
3522 3522
 			}
3523 3523
 			return $operator;
3524
-		} elseif ( $operator === 'LIKE' && ! is_array( $value ) ) {
3524
+		} elseif ($operator === 'LIKE' && ! is_array($value)) {
3525 3525
 			//if the operator is 'LIKE', we want to allow percent signs (%) and not
3526 3526
 			//remove other junk. So just treat it as a string.
3527
-			return $operator . SP . $this->_wpdb_prepare_using_field( $value, '%s' );
3528
-		} elseif ( ! in_array( $operator, $this->_in_style_operators ) && ! is_array( $value ) ) {
3529
-			return $operator . SP . $this->_wpdb_prepare_using_field( $value, $field_obj );
3530
-		} elseif ( in_array( $operator, $this->_in_style_operators ) && ! is_array( $value ) ) {
3527
+			return $operator.SP.$this->_wpdb_prepare_using_field($value, '%s');
3528
+		} elseif ( ! in_array($operator, $this->_in_style_operators) && ! is_array($value)) {
3529
+			return $operator.SP.$this->_wpdb_prepare_using_field($value, $field_obj);
3530
+		} elseif (in_array($operator, $this->_in_style_operators) && ! is_array($value)) {
3531 3531
 			throw new EE_Error(
3532 3532
 				sprintf(
3533 3533
 					__(
@@ -3538,7 +3538,7 @@  discard block
 block discarded – undo
3538 3538
 					$operator
3539 3539
 				)
3540 3540
 			);
3541
-		} elseif ( ! in_array( $operator, $this->_in_style_operators ) && is_array( $value ) ) {
3541
+		} elseif ( ! in_array($operator, $this->_in_style_operators) && is_array($value)) {
3542 3542
 			throw new EE_Error(
3543 3543
 				sprintf(
3544 3544
 					__(
@@ -3556,7 +3556,7 @@  discard block
 block discarded – undo
3556 3556
 						"It appears you've provided some totally invalid query parameters. Operator and value were:'%s', which isn't right at all",
3557 3557
 						"event_espresso"
3558 3558
 					),
3559
-					http_build_query( $op_and_value )
3559
+					http_build_query($op_and_value)
3560 3560
 				)
3561 3561
 			);
3562 3562
 		}
@@ -3572,12 +3572,12 @@  discard block
 block discarded – undo
3572 3572
 	 * @return string
3573 3573
 	 * @throws \EE_Error
3574 3574
 	 */
3575
-	public function _construct_between_value( $values, $field_obj ) {
3575
+	public function _construct_between_value($values, $field_obj) {
3576 3576
 		$cleaned_values = array();
3577
-		foreach ( $values as $value ) {
3578
-			$cleaned_values[] = $this->_wpdb_prepare_using_field($value,$field_obj);
3577
+		foreach ($values as $value) {
3578
+			$cleaned_values[] = $this->_wpdb_prepare_using_field($value, $field_obj);
3579 3579
 		}
3580
-		return  $cleaned_values[0] . " AND " . $cleaned_values[1];
3580
+		return  $cleaned_values[0]." AND ".$cleaned_values[1];
3581 3581
 	}
3582 3582
 
3583 3583
 
@@ -3594,26 +3594,26 @@  discard block
 block discarded – undo
3594 3594
 	 * @return string of SQL to follow an 'IN' or 'NOT IN' operator
3595 3595
 	 * @throws \EE_Error
3596 3596
 	 */
3597
-	public function _construct_in_value($values,  $field_obj){
3597
+	public function _construct_in_value($values, $field_obj) {
3598 3598
 		//check if the value is a CSV list
3599
-		if(is_string($values)){
3599
+		if (is_string($values)) {
3600 3600
 			//in which case, turn it into an array
3601
-			$values = explode(",",$values);
3601
+			$values = explode(",", $values);
3602 3602
 		}
3603 3603
 		$cleaned_values = array();
3604
-		foreach($values as $value){
3605
-			$cleaned_values[] = $this->_wpdb_prepare_using_field($value,$field_obj);
3604
+		foreach ($values as $value) {
3605
+			$cleaned_values[] = $this->_wpdb_prepare_using_field($value, $field_obj);
3606 3606
 		}
3607 3607
 		//we would just LOVE to leave $cleaned_values as an empty array, and return the value as "()",
3608 3608
 		//but unfortunately that's invalid SQL. So instead we return a string which we KNOW will evaluate to be the empty set
3609 3609
 		//which is effectively equivalent to returning "()". We don't return "(0)" because that only works for auto-incrementing columns
3610
-		if(empty($cleaned_values)){
3610
+		if (empty($cleaned_values)) {
3611 3611
 			$all_fields = $this->field_settings();
3612 3612
 			$a_field = array_shift($all_fields);
3613 3613
 			$main_table = $this->_get_main_table();
3614 3614
 			$cleaned_values[] = "SELECT ".$a_field->get_table_column()." FROM ".$main_table->get_table_name()." WHERE FALSE";
3615 3615
 		}
3616
-		return "(".implode(",",$cleaned_values).")";
3616
+		return "(".implode(",", $cleaned_values).")";
3617 3617
 	}
3618 3618
 
3619 3619
 
@@ -3625,16 +3625,16 @@  discard block
 block discarded – undo
3625 3625
 	 * @throws EE_Error
3626 3626
 	 * @return false|null|string
3627 3627
 	 */
3628
-	private function _wpdb_prepare_using_field($value,$field_obj){
3628
+	private function _wpdb_prepare_using_field($value, $field_obj) {
3629 3629
 		/** @type WPDB $wpdb */
3630 3630
 		global $wpdb;
3631
-		if($field_obj instanceof EE_Model_Field_Base){
3632
-			return $wpdb->prepare($field_obj->get_wpdb_data_type(),$this->_prepare_value_for_use_in_db($value, $field_obj));
3633
-		}else{//$field_obj should really just be a data type
3634
-			if( ! in_array($field_obj,$this->_valid_wpdb_data_types)){
3635
-				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)));
3631
+		if ($field_obj instanceof EE_Model_Field_Base) {
3632
+			return $wpdb->prepare($field_obj->get_wpdb_data_type(), $this->_prepare_value_for_use_in_db($value, $field_obj));
3633
+		} else {//$field_obj should really just be a data type
3634
+			if ( ! in_array($field_obj, $this->_valid_wpdb_data_types)) {
3635
+				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)));
3636 3636
 			}
3637
-			return $wpdb->prepare($field_obj,$value);
3637
+			return $wpdb->prepare($field_obj, $value);
3638 3638
 		}
3639 3639
 	}
3640 3640
 
@@ -3646,27 +3646,27 @@  discard block
 block discarded – undo
3646 3646
 	 * @throws EE_Error
3647 3647
 	 * @return EE_Model_Field_Base
3648 3648
 	 */
3649
-	protected function _deduce_field_from_query_param($query_param_name){
3649
+	protected function _deduce_field_from_query_param($query_param_name) {
3650 3650
 		//ok, now proceed with deducing which part is the model's name, and which is the field's name
3651 3651
 		//which will help us find the database table and column
3652 3652
 
3653
-		$query_param_parts = explode(".",$query_param_name);
3654
-		if(empty($query_param_parts)){
3655
-			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));
3653
+		$query_param_parts = explode(".", $query_param_name);
3654
+		if (empty($query_param_parts)) {
3655
+			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));
3656 3656
 		}
3657 3657
 		$number_of_parts = count($query_param_parts);
3658
-		$last_query_param_part = $query_param_parts[ count($query_param_parts) - 1 ];
3659
-		if($number_of_parts === 1){
3658
+		$last_query_param_part = $query_param_parts[count($query_param_parts) - 1];
3659
+		if ($number_of_parts === 1) {
3660 3660
 			$field_name = $last_query_param_part;
3661 3661
 			$model_obj = $this;
3662
-		}else{// $number_of_parts >= 2
3662
+		} else {// $number_of_parts >= 2
3663 3663
 			//the last part is the column name, and there are only 2parts. therefore...
3664 3664
 			$field_name = $last_query_param_part;
3665
-			$model_obj = $this->get_related_model_obj( $query_param_parts[ $number_of_parts - 2 ]);
3665
+			$model_obj = $this->get_related_model_obj($query_param_parts[$number_of_parts - 2]);
3666 3666
 		}
3667
-		try{
3667
+		try {
3668 3668
 			return $model_obj->field_settings_for($field_name);
3669
-		}catch(EE_Error $e){
3669
+		} catch (EE_Error $e) {
3670 3670
 			return null;
3671 3671
 		}
3672 3672
 	}
@@ -3680,13 +3680,13 @@  discard block
 block discarded – undo
3680 3680
 	 * @throws EE_Error
3681 3681
 	 * @return string
3682 3682
 	 */
3683
-	public function _get_qualified_column_for_field($field_name){
3683
+	public function _get_qualified_column_for_field($field_name) {
3684 3684
 		$all_fields = $this->field_settings();
3685 3685
 		$field = isset($all_fields[$field_name]) ? $all_fields[$field_name] : FALSE;
3686
-		if($field){
3686
+		if ($field) {
3687 3687
 			return $field->get_qualified_column();
3688
-		}else{
3689
-			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)));
3688
+		} else {
3689
+			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)));
3690 3690
 		}
3691 3691
 	}
3692 3692
 
@@ -3700,17 +3700,17 @@  discard block
 block discarded – undo
3700 3700
 	 * @param  mixed|string $limit The limit for this select
3701 3701
 	 * @return string                The final select join element for the query.
3702 3702
 	 */
3703
-	public function _construct_limit_join_select( $table_alias, $limit ) {
3703
+	public function _construct_limit_join_select($table_alias, $limit) {
3704 3704
 		$SQL = '';
3705
-		foreach ( $this->_tables as $table_obj ) {
3706
-			if ( $table_obj instanceof EE_Primary_Table ) {
3705
+		foreach ($this->_tables as $table_obj) {
3706
+			if ($table_obj instanceof EE_Primary_Table) {
3707 3707
 				$SQL .= $table_alias === $table_obj->get_table_alias()
3708
-					? $table_obj->get_select_join_limit( $limit )
3709
-					: SP . $table_obj->get_table_name() . " AS " . $table_obj->get_table_alias() . SP;
3710
-			} elseif ( $table_obj instanceof EE_Secondary_Table ) {
3708
+					? $table_obj->get_select_join_limit($limit)
3709
+					: SP.$table_obj->get_table_name()." AS ".$table_obj->get_table_alias().SP;
3710
+			} elseif ($table_obj instanceof EE_Secondary_Table) {
3711 3711
 				$SQL .= $table_alias === $table_obj->get_table_alias()
3712
-					? $table_obj->get_select_join_limit_join( $limit )
3713
-					: SP . $table_obj->get_join_sql( $table_alias ) . SP;
3712
+					? $table_obj->get_select_join_limit_join($limit)
3713
+					: SP.$table_obj->get_join_sql($table_alias).SP;
3714 3714
 			}
3715 3715
 		}
3716 3716
 		return $SQL;
@@ -3725,7 +3725,7 @@  discard block
 block discarded – undo
3725 3725
 	 * @return string SQL
3726 3726
 	 * @throws \EE_Error
3727 3727
 	 */
3728
-	public function _construct_internal_join(){
3728
+	public function _construct_internal_join() {
3729 3729
 		$SQL = $this->_get_main_table()->get_table_sql();
3730 3730
 		$SQL .= $this->_construct_internal_join_to_table_with_alias($this->_get_main_table()->get_table_alias());
3731 3731
 		return $SQL;
@@ -3746,17 +3746,17 @@  discard block
 block discarded – undo
3746 3746
 	 * @param string $alias_prefixed table alias to join to (this table should already be in the FROM SQL clause)
3747 3747
 	 * @return string
3748 3748
 	 */
3749
-	public function _construct_internal_join_to_table_with_alias($alias_prefixed){
3749
+	public function _construct_internal_join_to_table_with_alias($alias_prefixed) {
3750 3750
 		$SQL = '';
3751 3751
 		$alias_sans_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($alias_prefixed);
3752
-		foreach($this->_tables as $table_obj){
3753
-			if($table_obj instanceof EE_Secondary_Table){//table is secondary table
3754
-				if($alias_sans_prefix === $table_obj->get_table_alias()){
3752
+		foreach ($this->_tables as $table_obj) {
3753
+			if ($table_obj instanceof EE_Secondary_Table) {//table is secondary table
3754
+				if ($alias_sans_prefix === $table_obj->get_table_alias()) {
3755 3755
 					//so we're joining to this table, meaning the table is already in
3756 3756
 					//the FROM statement, BUT the primary table isn't. So we want
3757 3757
 					//to add the inverse join sql
3758 3758
 					$SQL .= $table_obj->get_inverse_join_sql($alias_prefixed);
3759
-				}else{
3759
+				} else {
3760 3760
 					//just add a regular JOIN to this table from the primary table
3761 3761
 					$SQL .= $table_obj->get_join_sql($alias_prefixed);
3762 3762
 				}
@@ -3770,9 +3770,9 @@  discard block
 block discarded – undo
3770 3770
 	 * 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)
3771 3771
 	 * @return array
3772 3772
 	 */
3773
-	public function _get_data_types(){
3773
+	public function _get_data_types() {
3774 3774
 		$data_types = array();
3775
-		foreach( $this->field_settings() as $field_obj){
3775
+		foreach ($this->field_settings() as $field_obj) {
3776 3776
 			//$data_types[$field_obj->get_table_column()] = $field_obj->get_wpdb_data_type();
3777 3777
 			/** @var $field_obj EE_Model_Field_Base */
3778 3778
 			$data_types[$field_obj->get_qualified_column()] = $field_obj->get_wpdb_data_type();
@@ -3788,10 +3788,10 @@  discard block
 block discarded – undo
3788 3788
 	 * @throws EE_Error
3789 3789
 	 * @return EEM_Base
3790 3790
 	 */
3791
-	public function get_related_model_obj($model_name){
3791
+	public function get_related_model_obj($model_name) {
3792 3792
 		$model_classname = "EEM_".$model_name;
3793
-		if(!class_exists($model_classname)){
3794
-			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));
3793
+		if ( ! class_exists($model_classname)) {
3794
+			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));
3795 3795
 		}
3796 3796
 		return call_user_func($model_classname."::instance");
3797 3797
 	}
@@ -3801,7 +3801,7 @@  discard block
 block discarded – undo
3801 3801
 	 * Returns the array of EE_ModelRelations for this model.
3802 3802
 	 * @return EE_Model_Relation_Base[]
3803 3803
 	 */
3804
-	public function relation_settings(){
3804
+	public function relation_settings() {
3805 3805
 		return $this->_model_relations;
3806 3806
 	}
3807 3807
 
@@ -3811,10 +3811,10 @@  discard block
 block discarded – undo
3811 3811
 	 * (Eg, without an event, datetimes have little purpose.)
3812 3812
 	 * @return EE_Belongs_To_Relation[]
3813 3813
 	 */
3814
-	public function belongs_to_relations(){
3814
+	public function belongs_to_relations() {
3815 3815
 		$belongs_to_relations = array();
3816
-		foreach($this->relation_settings() as $model_name => $relation_obj){
3817
-			if($relation_obj instanceof EE_Belongs_To_Relation){
3816
+		foreach ($this->relation_settings() as $model_name => $relation_obj) {
3817
+			if ($relation_obj instanceof EE_Belongs_To_Relation) {
3818 3818
 				$belongs_to_relations[$model_name] = $relation_obj;
3819 3819
 			}
3820 3820
 		}
@@ -3829,15 +3829,15 @@  discard block
 block discarded – undo
3829 3829
 	 * @throws EE_Error
3830 3830
 	 * @return EE_Model_Relation_Base
3831 3831
 	 */
3832
-	public function related_settings_for($relation_name){
3833
-		$relatedModels=$this->relation_settings();
3834
-		if(!array_key_exists($relation_name,$relatedModels)){
3832
+	public function related_settings_for($relation_name) {
3833
+		$relatedModels = $this->relation_settings();
3834
+		if ( ! array_key_exists($relation_name, $relatedModels)) {
3835 3835
 			throw new EE_Error(
3836 3836
 				sprintf(
3837
-					__('Cannot get %s related to %s. There is no model relation of that type. There is, however, %s...','event_espresso'),
3837
+					__('Cannot get %s related to %s. There is no model relation of that type. There is, however, %s...', 'event_espresso'),
3838 3838
 					$relation_name,
3839 3839
 					$this->_get_class_name(),
3840
-					implode( ', ', array_keys( $relatedModels ))
3840
+					implode(', ', array_keys($relatedModels))
3841 3841
 				)
3842 3842
 			);
3843 3843
 		}
@@ -3852,10 +3852,10 @@  discard block
 block discarded – undo
3852 3852
 	 * @throws EE_Error
3853 3853
 	 * @return EE_Model_Field_Base
3854 3854
 	 */
3855
-	public function field_settings_for($fieldName){
3856
-		$fieldSettings=$this->field_settings(true);
3857
-		if( ! array_key_exists($fieldName,$fieldSettings)){
3858
-			throw new EE_Error(sprintf(__("There is no field/column '%s' on '%s'",'event_espresso'),$fieldName,get_class($this)));
3855
+	public function field_settings_for($fieldName) {
3856
+		$fieldSettings = $this->field_settings(true);
3857
+		if ( ! array_key_exists($fieldName, $fieldSettings)) {
3858
+			throw new EE_Error(sprintf(__("There is no field/column '%s' on '%s'", 'event_espresso'), $fieldName, get_class($this)));
3859 3859
 		}
3860 3860
 		return $fieldSettings[$fieldName];
3861 3861
 	}
@@ -3865,11 +3865,11 @@  discard block
 block discarded – undo
3865 3865
 	 * @param string $fieldName a key in the model's _field_settings array
3866 3866
 	 * @return boolean
3867 3867
 	 */
3868
-	public function has_field($fieldName){
3868
+	public function has_field($fieldName) {
3869 3869
 		$fieldSettings = $this->field_settings(true);
3870
-		if( isset($fieldSettings[$fieldName])){
3870
+		if (isset($fieldSettings[$fieldName])) {
3871 3871
 			return true;
3872
-		}else{
3872
+		} else {
3873 3873
 			return false;
3874 3874
 		}
3875 3875
 	}
@@ -3879,11 +3879,11 @@  discard block
 block discarded – undo
3879 3879
 	 * @param string $relation_name possibly one of the keys in the relation_settings array
3880 3880
 	 * @return boolean
3881 3881
 	 */
3882
-	public function has_relation($relation_name){
3882
+	public function has_relation($relation_name) {
3883 3883
 		$relations = $this->relation_settings();
3884
-		if(isset($relations[$relation_name])){
3884
+		if (isset($relations[$relation_name])) {
3885 3885
 			return true;
3886
-		}else{
3886
+		} else {
3887 3887
 			return false;
3888 3888
 		}
3889 3889
 	}
@@ -3895,7 +3895,7 @@  discard block
 block discarded – undo
3895 3895
 	 * @param $field_obj
3896 3896
 	 * @return EE_Model_Field_Base
3897 3897
 	 */
3898
-	public function is_primary_key_field( $field_obj ){
3898
+	public function is_primary_key_field($field_obj) {
3899 3899
 		return $field_obj instanceof EE_Primary_Key_Field_Base ? TRUE : FALSE;
3900 3900
 	}
3901 3901
 
@@ -3907,16 +3907,16 @@  discard block
 block discarded – undo
3907 3907
 	 * @return EE_Model_Field_Base
3908 3908
 	 * @throws EE_Error
3909 3909
 	 */
3910
-	public function get_primary_key_field(){
3911
-		if( $this->_primary_key_field === NULL ){
3912
-			foreach( $this->field_settings( TRUE ) as $field_obj ){
3913
-				if( $this->is_primary_key_field( $field_obj )){
3910
+	public function get_primary_key_field() {
3911
+		if ($this->_primary_key_field === NULL) {
3912
+			foreach ($this->field_settings(TRUE) as $field_obj) {
3913
+				if ($this->is_primary_key_field($field_obj)) {
3914 3914
 					$this->_primary_key_field = $field_obj;
3915 3915
 					break;
3916 3916
 				}
3917 3917
 			}
3918
-			if( ! $this->_primary_key_field instanceof EE_Primary_Key_Field_Base ){
3919
-				throw new EE_Error(sprintf(__("There is no Primary Key defined on model %s",'event_espresso'),get_class($this)));
3918
+			if ( ! $this->_primary_key_field instanceof EE_Primary_Key_Field_Base) {
3919
+				throw new EE_Error(sprintf(__("There is no Primary Key defined on model %s", 'event_espresso'), get_class($this)));
3920 3920
 			}
3921 3921
 		}
3922 3922
 		return $this->_primary_key_field;
@@ -3929,12 +3929,12 @@  discard block
 block discarded – undo
3929 3929
 	 * Internally does some caching.
3930 3930
 	 * @return boolean
3931 3931
 	 */
3932
-	public function has_primary_key_field(){
3933
-		if($this->_has_primary_key_field === null){
3934
-			try{
3932
+	public function has_primary_key_field() {
3933
+		if ($this->_has_primary_key_field === null) {
3934
+			try {
3935 3935
 				$this->get_primary_key_field();
3936 3936
 				$this->_has_primary_key_field = true;
3937
-			}catch(EE_Error $e){
3937
+			} catch (EE_Error $e) {
3938 3938
 				$this->_has_primary_key_field = false;
3939 3939
 			}
3940 3940
 		}
@@ -3948,9 +3948,9 @@  discard block
 block discarded – undo
3948 3948
 	 * @param string $field_class_name class name of field that you want to find. Eg, EE_Datetime_Field, EE_Foreign_Key_Field, etc
3949 3949
 	 * @return EE_Model_Field_Base or null if none is found
3950 3950
 	 */
3951
-	public function get_a_field_of_type($field_class_name){
3952
-		foreach($this->field_settings() as $field){
3953
-			if( $field instanceof $field_class_name ){
3951
+	public function get_a_field_of_type($field_class_name) {
3952
+		foreach ($this->field_settings() as $field) {
3953
+			if ($field instanceof $field_class_name) {
3954 3954
 				return $field;
3955 3955
 			}
3956 3956
 		}
@@ -3964,22 +3964,22 @@  discard block
 block discarded – undo
3964 3964
 	 * @return EE_Foreign_Key_Field_Base
3965 3965
 	 * @throws EE_Error
3966 3966
 	 */
3967
-	public function get_foreign_key_to($model_name){
3968
-		if( ! isset( $this->_cache_foreign_key_to_fields[ $model_name ] ) ){
3969
-			foreach($this->field_settings() as $field){
3970
-				if(
3967
+	public function get_foreign_key_to($model_name) {
3968
+		if ( ! isset($this->_cache_foreign_key_to_fields[$model_name])) {
3969
+			foreach ($this->field_settings() as $field) {
3970
+				if (
3971 3971
 					$field instanceof EE_Foreign_Key_Field_Base
3972
-					&& in_array($model_name,$field->get_model_names_pointed_to() )
3972
+					&& in_array($model_name, $field->get_model_names_pointed_to())
3973 3973
 				) {
3974
-					$this->_cache_foreign_key_to_fields[ $model_name ] = $field;
3974
+					$this->_cache_foreign_key_to_fields[$model_name] = $field;
3975 3975
 					break;
3976 3976
 				}
3977 3977
 			}
3978
-			if( ! isset( $this->_cache_foreign_key_to_fields[ $model_name ] ) ){
3979
-				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)));
3978
+			if ( ! isset($this->_cache_foreign_key_to_fields[$model_name])) {
3979
+				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)));
3980 3980
 			}
3981 3981
 		}
3982
-		return $this->_cache_foreign_key_to_fields[ $model_name ];
3982
+		return $this->_cache_foreign_key_to_fields[$model_name];
3983 3983
 	}
3984 3984
 
3985 3985
 
@@ -3990,7 +3990,7 @@  discard block
 block discarded – undo
3990 3990
 	 * a table alias with a model chain prefix, like 'Venue__Event_Venue___Event_Meta'. Either one works
3991 3991
 	 * @return EE_Table_Base
3992 3992
 	 */
3993
-	public function get_table_for_alias($table_alias){
3993
+	public function get_table_for_alias($table_alias) {
3994 3994
 		$table_alias_sans_model_relation_chain_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($table_alias);
3995 3995
 		return $this->_tables[$table_alias_sans_model_relation_chain_prefix]->get_table_name();
3996 3996
 	}
@@ -4003,25 +4003,25 @@  discard block
 block discarded – undo
4003 4003
 	 * @param bool $include_db_only_fields flag indicating whether or not to include the db-only fields
4004 4004
 	 * @return EE_Model_Field_Base[] where the keys are the field's name
4005 4005
 	 */
4006
-	public function field_settings($include_db_only_fields = false){
4007
-		if( $include_db_only_fields ){
4008
-			if( $this->_cached_fields === NULL ){
4006
+	public function field_settings($include_db_only_fields = false) {
4007
+		if ($include_db_only_fields) {
4008
+			if ($this->_cached_fields === NULL) {
4009 4009
 				$this->_cached_fields = array();
4010
-				foreach($this->_fields as $fields_corresponding_to_table){
4011
-					foreach($fields_corresponding_to_table as $field_name => $field_obj){
4012
-						$this->_cached_fields[$field_name]=$field_obj;
4010
+				foreach ($this->_fields as $fields_corresponding_to_table) {
4011
+					foreach ($fields_corresponding_to_table as $field_name => $field_obj) {
4012
+						$this->_cached_fields[$field_name] = $field_obj;
4013 4013
 					}
4014 4014
 				}
4015 4015
 			}
4016 4016
 			return $this->_cached_fields;
4017
-		}else{
4018
-			if( $this->_cached_fields_non_db_only === NULL ){
4017
+		} else {
4018
+			if ($this->_cached_fields_non_db_only === NULL) {
4019 4019
 				$this->_cached_fields_non_db_only = array();
4020
-				foreach($this->_fields as $fields_corresponding_to_table){
4021
-					foreach($fields_corresponding_to_table as $field_name => $field_obj){
4020
+				foreach ($this->_fields as $fields_corresponding_to_table) {
4021
+					foreach ($fields_corresponding_to_table as $field_name => $field_obj) {
4022 4022
 						/** @var $field_obj EE_Model_Field_Base */
4023
-						if( ! $field_obj->is_db_only_field() ){
4024
-							$this->_cached_fields_non_db_only[$field_name]=$field_obj;
4023
+						if ( ! $field_obj->is_db_only_field()) {
4024
+							$this->_cached_fields_non_db_only[$field_name] = $field_obj;
4025 4025
 						}
4026 4026
 					}
4027 4027
 				}
@@ -4040,60 +4040,60 @@  discard block
 block discarded – undo
4040 4040
 	 * @return \EE_Base_Class[] array keys are primary keys (if there is a primary key on the model. if not, numerically indexed)
4041 4041
 	 * @throws \EE_Error
4042 4042
 	 */
4043
-	protected function _create_objects( $rows = array() ) {
4044
-		$array_of_objects=array();
4045
-		if(empty($rows)){
4043
+	protected function _create_objects($rows = array()) {
4044
+		$array_of_objects = array();
4045
+		if (empty($rows)) {
4046 4046
 			return array();
4047 4047
 		}
4048 4048
 		$count_if_model_has_no_primary_key = 0;
4049 4049
 		$has_primary_key = $this->has_primary_key_field();
4050 4050
 		$primary_key_field = $has_primary_key ? $this->get_primary_key_field() : null;
4051
-		foreach ( (array)$rows as $row ) {
4052
-			if(empty($row)){
4051
+		foreach ((array) $rows as $row) {
4052
+			if (empty($row)) {
4053 4053
 				//wp did its weird thing where it returns an array like array(0=>null), which is totally not helpful...
4054 4054
 				return array();
4055 4055
 			}
4056 4056
 			//check if we've already set this object in the results array,
4057 4057
 			//in which case there's no need to process it further (again)
4058
-			if( $has_primary_key ) {
4058
+			if ($has_primary_key) {
4059 4059
 				$table_pk_value = $this->_get_column_value_with_table_alias_or_not(
4060 4060
 					$row,
4061 4061
 					$primary_key_field->get_qualified_column(),
4062 4062
 					$primary_key_field->get_table_column()
4063 4063
 				);
4064
-				if( $table_pk_value && isset( $array_of_objects[ $table_pk_value ] ) ) {
4064
+				if ($table_pk_value && isset($array_of_objects[$table_pk_value])) {
4065 4065
 					continue;
4066 4066
 				}
4067 4067
 			}
4068 4068
 			$classInstance = $this->instantiate_class_from_array_or_object($row);
4069
-			if( ! $classInstance ) {
4069
+			if ( ! $classInstance) {
4070 4070
 				throw new EE_Error(
4071 4071
 					sprintf(
4072
-						__( 'Could not create instance of class %s from row %s', 'event_espresso' ),
4072
+						__('Could not create instance of class %s from row %s', 'event_espresso'),
4073 4073
 						$this->get_this_model_name(),
4074
-						http_build_query( $row )
4074
+						http_build_query($row)
4075 4075
 					)
4076 4076
 				);
4077 4077
 			}
4078 4078
 			//set the timezone on the instantiated objects
4079
-			$classInstance->set_timezone( $this->_timezone );
4079
+			$classInstance->set_timezone($this->_timezone);
4080 4080
 			//make sure if there is any timezone setting present that we set the timezone for the object
4081 4081
 			$key = $has_primary_key ? $classInstance->ID() : $count_if_model_has_no_primary_key++;
4082
-			$array_of_objects[ $key ] = $classInstance;
4082
+			$array_of_objects[$key] = $classInstance;
4083 4083
 			//also, for all the relations of type BelongsTo, see if we can cache
4084 4084
 			//those related models
4085 4085
 			//(we could do this for other relations too, but if there are conditions
4086 4086
 			//that filtered out some fo the results, then we'd be caching an incomplete set
4087 4087
 			//so it requires a little more thought than just caching them immediately...)
4088
-			foreach($this->_model_relations as $modelName => $relation_obj){
4089
-				if( $relation_obj instanceof EE_Belongs_To_Relation){
4088
+			foreach ($this->_model_relations as $modelName => $relation_obj) {
4089
+				if ($relation_obj instanceof EE_Belongs_To_Relation) {
4090 4090
 					//check if this model's INFO is present. If so, cache it on the model
4091 4091
 					$other_model = $relation_obj->get_other_model();
4092 4092
 					$other_model_obj_maybe = $other_model->instantiate_class_from_array_or_object($row);
4093 4093
 					//if we managed to make a model object from the results, cache it on the main model object
4094
-					if( $other_model_obj_maybe ){
4094
+					if ($other_model_obj_maybe) {
4095 4095
 						//set timezone on these other model objects if they are present
4096
-						$other_model_obj_maybe->set_timezone( $this->_timezone );
4096
+						$other_model_obj_maybe->set_timezone($this->_timezone);
4097 4097
 						$classInstance->cache($modelName, $other_model_obj_maybe);
4098 4098
 					}
4099 4099
 				}
@@ -4114,12 +4114,12 @@  discard block
 block discarded – undo
4114 4114
 
4115 4115
 		$this_model_fields_and_values = array();
4116 4116
 		//setup the row using default values;
4117
-		foreach ( $this->field_settings() as $field_name => $field_obj ) {
4117
+		foreach ($this->field_settings() as $field_name => $field_obj) {
4118 4118
 			$this_model_fields_and_values[$field_name] = $field_obj->get_default_value();
4119 4119
 		}
4120 4120
 
4121 4121
 		$className = $this->_get_class_name();
4122
-		$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_and_values ), FALSE, FALSE );
4122
+		$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_and_values), FALSE, FALSE);
4123 4123
 
4124 4124
 		return $classInstance;
4125 4125
 	}
@@ -4132,45 +4132,45 @@  discard block
 block discarded – undo
4132 4132
 	 * @return EE_Base_Class
4133 4133
 	 * @throws \EE_Error
4134 4134
 	 */
4135
-	public function instantiate_class_from_array_or_object($cols_n_values){
4136
-		if( ! is_array( $cols_n_values ) && is_object( $cols_n_values )) {
4137
-			$cols_n_values = get_object_vars( $cols_n_values );
4135
+	public function instantiate_class_from_array_or_object($cols_n_values) {
4136
+		if ( ! is_array($cols_n_values) && is_object($cols_n_values)) {
4137
+			$cols_n_values = get_object_vars($cols_n_values);
4138 4138
 		}
4139 4139
 		$primary_key = NULL;
4140 4140
 		//make sure the array only has keys that are fields/columns on this model
4141
-		$this_model_fields_n_values = $this->_deduce_fields_n_values_from_cols_n_values( $cols_n_values );
4142
-		if( $this->has_primary_key_field() && isset( $this_model_fields_n_values[ $this->primary_key_name() ] ) ){
4143
-			$primary_key = $this_model_fields_n_values[ $this->primary_key_name() ];
4141
+		$this_model_fields_n_values = $this->_deduce_fields_n_values_from_cols_n_values($cols_n_values);
4142
+		if ($this->has_primary_key_field() && isset($this_model_fields_n_values[$this->primary_key_name()])) {
4143
+			$primary_key = $this_model_fields_n_values[$this->primary_key_name()];
4144 4144
 		}
4145
-		$className=$this->_get_class_name();
4145
+		$className = $this->_get_class_name();
4146 4146
 
4147 4147
 		//check we actually found results that we can use to build our model object
4148 4148
 		//if not, return null
4149
-		if( $this->has_primary_key_field()){
4150
-			if(empty( $this_model_fields_n_values[$this->primary_key_name()] )){
4149
+		if ($this->has_primary_key_field()) {
4150
+			if (empty($this_model_fields_n_values[$this->primary_key_name()])) {
4151 4151
 				return NULL;
4152 4152
 			}
4153
-		}else if($this->unique_indexes()){
4153
+		} else if ($this->unique_indexes()) {
4154 4154
 			$first_column = reset($this_model_fields_n_values);
4155
-			if(empty($first_column)){
4155
+			if (empty($first_column)) {
4156 4156
 				return NULL;
4157 4157
 			}
4158 4158
 		}
4159 4159
 
4160 4160
 		// if there is no primary key or the object doesn't already exist in the entity map, then create a new instance
4161
-		if ( $primary_key){
4162
-			$classInstance = $this->get_from_entity_map( $primary_key );
4163
-			if( ! $classInstance) {
4164
-				$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE );
4161
+		if ($primary_key) {
4162
+			$classInstance = $this->get_from_entity_map($primary_key);
4163
+			if ( ! $classInstance) {
4164
+				$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_n_values, $this->_timezone), TRUE, FALSE);
4165 4165
 				// add this new object to the entity map
4166
-				$classInstance = $this->add_to_entity_map( $classInstance );
4166
+				$classInstance = $this->add_to_entity_map($classInstance);
4167 4167
 			}
4168
-		}else{
4169
-			$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE );
4168
+		} else {
4169
+			$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_n_values, $this->_timezone), TRUE, FALSE);
4170 4170
 		}
4171 4171
 
4172 4172
 			//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.
4173
-		$this->set_timezone( $classInstance->get_timezone() );
4173
+		$this->set_timezone($classInstance->get_timezone());
4174 4174
 		return $classInstance;
4175 4175
 	}
4176 4176
 	/**
@@ -4178,8 +4178,8 @@  discard block
 block discarded – undo
4178 4178
 	 * @param int|string $id the ID of the model object
4179 4179
 	 * @return EE_Base_Class
4180 4180
 	 */
4181
-	public function get_from_entity_map( $id ){
4182
-		return isset( $this->_entity_map[ EEM_Base::$_model_query_blog_id ][ $id ] ) ? $this->_entity_map[ EEM_Base::$_model_query_blog_id ][ $id ] : NULL;
4181
+	public function get_from_entity_map($id) {
4182
+		return isset($this->_entity_map[EEM_Base::$_model_query_blog_id][$id]) ? $this->_entity_map[EEM_Base::$_model_query_blog_id][$id] : NULL;
4183 4183
 	}
4184 4184
 
4185 4185
 
@@ -4201,21 +4201,21 @@  discard block
 block discarded – undo
4201 4201
 	 * @throws EE_Error
4202 4202
 	 * @return \EE_Base_Class
4203 4203
 	 */
4204
-	public function add_to_entity_map( EE_Base_Class $object) {
4204
+	public function add_to_entity_map(EE_Base_Class $object) {
4205 4205
 		$className = $this->_get_class_name();
4206
-		if( ! $object instanceof $className ){
4207
-			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 ) );
4206
+		if ( ! $object instanceof $className) {
4207
+			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));
4208 4208
 		}
4209 4209
 		/** @var $object EE_Base_Class */
4210
-		if ( ! $object->ID() ){
4211
-			throw new EE_Error(sprintf(__("You tried storing a model object with NO ID in the %s entity mapper.", "event_espresso"),get_class($this)));
4210
+		if ( ! $object->ID()) {
4211
+			throw new EE_Error(sprintf(__("You tried storing a model object with NO ID in the %s entity mapper.", "event_espresso"), get_class($this)));
4212 4212
 		}
4213 4213
 		// double check it's not already there
4214
-		$classInstance = $this->get_from_entity_map( $object->ID() );
4215
-		if ( $classInstance ) {
4214
+		$classInstance = $this->get_from_entity_map($object->ID());
4215
+		if ($classInstance) {
4216 4216
 			return $classInstance;
4217 4217
 		} else {
4218
-			$this->_entity_map[ EEM_Base::$_model_query_blog_id ][ $object->ID() ] = $object;
4218
+			$this->_entity_map[EEM_Base::$_model_query_blog_id][$object->ID()] = $object;
4219 4219
 			return $object;
4220 4220
 		}
4221 4221
 	}
@@ -4228,8 +4228,8 @@  discard block
 block discarded – undo
4228 4228
 	 * @param array $cols_n_values
4229 4229
 	 * @return array
4230 4230
 	 */
4231
-	public function deduce_fields_n_values_from_cols_n_values( $cols_n_values ) {
4232
-		return $this->_deduce_fields_n_values_from_cols_n_values( $cols_n_values );
4231
+	public function deduce_fields_n_values_from_cols_n_values($cols_n_values) {
4232
+		return $this->_deduce_fields_n_values_from_cols_n_values($cols_n_values);
4233 4233
 	}
4234 4234
 
4235 4235
 
@@ -4242,23 +4242,23 @@  discard block
 block discarded – undo
4242 4242
 	 * @param string $cols_n_values
4243 4243
 	 * @return array
4244 4244
 	 */
4245
-	protected function _deduce_fields_n_values_from_cols_n_values( $cols_n_values ){
4245
+	protected function _deduce_fields_n_values_from_cols_n_values($cols_n_values) {
4246 4246
 		$this_model_fields_n_values = array();
4247
-		foreach( $this->get_tables() as $table_alias => $table_obj ) {
4248
-			$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() );
4247
+		foreach ($this->get_tables() as $table_alias => $table_obj) {
4248
+			$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());
4249 4249
 			//there is a primary key on this table and its not set. Use defaults for all its columns
4250
-			if( $table_pk_value === null && $table_obj->get_pk_column() ){
4251
-				foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) {
4252
-					if( ! $field_obj->is_db_only_field() ){
4250
+			if ($table_pk_value === null && $table_obj->get_pk_column()) {
4251
+				foreach ($this->_get_fields_for_table($table_alias) as $field_name => $field_obj) {
4252
+					if ( ! $field_obj->is_db_only_field()) {
4253 4253
 						//prepare field as if its coming from db
4254
-						$prepared_value = $field_obj->prepare_for_set( $field_obj->get_default_value() );
4255
-						$this_model_fields_n_values[$field_name] = $field_obj->prepare_for_use_in_db( $prepared_value );
4254
+						$prepared_value = $field_obj->prepare_for_set($field_obj->get_default_value());
4255
+						$this_model_fields_n_values[$field_name] = $field_obj->prepare_for_use_in_db($prepared_value);
4256 4256
 					}
4257 4257
 				}
4258
-			}else{
4258
+			} else {
4259 4259
 				//the table's rows existed. Use their values
4260
-				foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) {
4261
-					if( ! $field_obj->is_db_only_field() ){
4260
+				foreach ($this->_get_fields_for_table($table_alias) as $field_name => $field_obj) {
4261
+					if ( ! $field_obj->is_db_only_field()) {
4262 4262
 						$this_model_fields_n_values[$field_name] = $this->_get_column_value_with_table_alias_or_not(
4263 4263
 							$cols_n_values, $field_obj->get_qualified_column(),
4264 4264
 							$field_obj->get_table_column()
@@ -4278,15 +4278,15 @@  discard block
 block discarded – undo
4278 4278
 	 * @param $regular_column
4279 4279
 	 * @return null
4280 4280
 	 */
4281
-	protected function _get_column_value_with_table_alias_or_not( $cols_n_values, $qualified_column, $regular_column ){
4281
+	protected function _get_column_value_with_table_alias_or_not($cols_n_values, $qualified_column, $regular_column) {
4282 4282
 		$value = null;
4283 4283
 		//ask the field what it think it's table_name.column_name should be, and call it the "qualified column"
4284 4284
 		//does the field on the model relate to this column retrieved from the db?
4285 4285
 		//or is it a db-only field? (not relating to the model)
4286
-		if( isset( $cols_n_values[ $qualified_column ] ) ){
4287
-			$value = $cols_n_values[ $qualified_column ];
4288
-		}elseif( isset( $cols_n_values[ $regular_column ] ) ){
4289
-			$value = $cols_n_values[ $regular_column ];
4286
+		if (isset($cols_n_values[$qualified_column])) {
4287
+			$value = $cols_n_values[$qualified_column];
4288
+		}elseif (isset($cols_n_values[$regular_column])) {
4289
+			$value = $cols_n_values[$regular_column];
4290 4290
 		}
4291 4291
 		return $value;
4292 4292
 	}
@@ -4302,26 +4302,26 @@  discard block
 block discarded – undo
4302 4302
 	 * @return EE_Base_Class
4303 4303
 	 * @throws \EE_Error
4304 4304
 	 */
4305
-	public function refresh_entity_map_from_db( $id ){
4306
-		$obj_in_map = $this->get_from_entity_map( $id );
4307
-		if( $obj_in_map ){
4305
+	public function refresh_entity_map_from_db($id) {
4306
+		$obj_in_map = $this->get_from_entity_map($id);
4307
+		if ($obj_in_map) {
4308 4308
 			$wpdb_results = $this->_get_all_wpdb_results(
4309
-				array( array( $this->get_primary_key_field()->get_name() => $id ), 'limit' => 1 )
4309
+				array(array($this->get_primary_key_field()->get_name() => $id), 'limit' => 1)
4310 4310
 			);
4311
-			if( $wpdb_results && is_array( $wpdb_results ) ){
4312
-				$one_row = reset( $wpdb_results );
4313
-				foreach( $this->_deduce_fields_n_values_from_cols_n_values($one_row ) as $field_name => $db_value ) {
4314
-					$obj_in_map->set_from_db( $field_name, $db_value );
4311
+			if ($wpdb_results && is_array($wpdb_results)) {
4312
+				$one_row = reset($wpdb_results);
4313
+				foreach ($this->_deduce_fields_n_values_from_cols_n_values($one_row) as $field_name => $db_value) {
4314
+					$obj_in_map->set_from_db($field_name, $db_value);
4315 4315
 				}
4316 4316
 				//clear the cache of related model objects
4317
-				foreach ( $this->relation_settings() as $relation_name => $relation_obj ){
4318
-					$obj_in_map->clear_cache($relation_name, NULL, TRUE );
4317
+				foreach ($this->relation_settings() as $relation_name => $relation_obj) {
4318
+					$obj_in_map->clear_cache($relation_name, NULL, TRUE);
4319 4319
 				}
4320 4320
 			}
4321
-			$this->_entity_map[ EEM_Base::$_model_query_blog_id ][ $id ] = $obj_in_map;
4321
+			$this->_entity_map[EEM_Base::$_model_query_blog_id][$id] = $obj_in_map;
4322 4322
 			return $obj_in_map;
4323
-		}else{
4324
-			return $this->get_one_by_ID( $id );
4323
+		} else {
4324
+			return $this->get_one_by_ID($id);
4325 4325
 		}
4326 4326
 	}
4327 4327
 
@@ -4339,24 +4339,24 @@  discard block
 block discarded – undo
4339 4339
 	 * @return \EE_Base_Class
4340 4340
 	 * @throws \EE_Error
4341 4341
 	 */
4342
-	public function refresh_entity_map_with( $id, $replacing_model_obj ) {
4343
-		$obj_in_map = $this->get_from_entity_map( $id );
4344
-		if( $obj_in_map ){
4345
-			if( $replacing_model_obj instanceof EE_Base_Class ){
4346
-				foreach( $replacing_model_obj->model_field_array() as $field_name => $value ) {
4347
-					$obj_in_map->set( $field_name, $value );
4342
+	public function refresh_entity_map_with($id, $replacing_model_obj) {
4343
+		$obj_in_map = $this->get_from_entity_map($id);
4344
+		if ($obj_in_map) {
4345
+			if ($replacing_model_obj instanceof EE_Base_Class) {
4346
+				foreach ($replacing_model_obj->model_field_array() as $field_name => $value) {
4347
+					$obj_in_map->set($field_name, $value);
4348 4348
 				}
4349 4349
 				//make the model object in the entity map's cache match the $replacing_model_obj
4350
-				foreach ( $this->relation_settings() as $relation_name => $relation_obj ){
4351
-					$obj_in_map->clear_cache($relation_name, NULL, TRUE );
4352
-					foreach( $replacing_model_obj->get_all_from_cache( $relation_name ) as $cache_id => $cached_obj ) {
4353
-						$obj_in_map->cache( $relation_name, $cached_obj, $cache_id );
4350
+				foreach ($this->relation_settings() as $relation_name => $relation_obj) {
4351
+					$obj_in_map->clear_cache($relation_name, NULL, TRUE);
4352
+					foreach ($replacing_model_obj->get_all_from_cache($relation_name) as $cache_id => $cached_obj) {
4353
+						$obj_in_map->cache($relation_name, $cached_obj, $cache_id);
4354 4354
 					}
4355 4355
 				}
4356 4356
 			}
4357 4357
 			return $obj_in_map;
4358
-		}else{
4359
-			$this->add_to_entity_map( $replacing_model_obj );
4358
+		} else {
4359
+			$this->add_to_entity_map($replacing_model_obj);
4360 4360
 			return $replacing_model_obj;
4361 4361
 		}
4362 4362
 	}
@@ -4369,7 +4369,7 @@  discard block
 block discarded – undo
4369 4369
 	 * require_once($this->_getClassName().".class.php");
4370 4370
 	 * @return string
4371 4371
 	 */
4372
-	private function _get_class_name(){
4372
+	private function _get_class_name() {
4373 4373
 		return "EE_".$this->get_this_model_name();
4374 4374
 	}
4375 4375
 
@@ -4382,8 +4382,8 @@  discard block
 block discarded – undo
4382 4382
 	 * @param int $quantity
4383 4383
 	 * @return string
4384 4384
 	 */
4385
-	public function item_name($quantity = 1){
4386
-		return (int)$quantity === 1 ? $this->singular_item : $this->plural_item;
4385
+	public function item_name($quantity = 1) {
4386
+		return (int) $quantity === 1 ? $this->singular_item : $this->plural_item;
4387 4387
 	}
4388 4388
 
4389 4389
 
@@ -4410,13 +4410,13 @@  discard block
 block discarded – undo
4410 4410
 	 * @throws EE_Error
4411 4411
 	 * @return mixed whatever the plugin which calls add_filter decides
4412 4412
 	 */
4413
-	public function __call($methodName,$args){
4414
-		$className=get_class($this);
4415
-		$tagName="FHEE__{$className}__{$methodName}";
4416
-		if(!has_filter($tagName)){
4413
+	public function __call($methodName, $args) {
4414
+		$className = get_class($this);
4415
+		$tagName = "FHEE__{$className}__{$methodName}";
4416
+		if ( ! has_filter($tagName)) {
4417 4417
 			throw new EE_Error(
4418 4418
 				sprintf(
4419
-					__( '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' ),
4419
+					__('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'),
4420 4420
 					$methodName,
4421 4421
 					$className,
4422 4422
 					$tagName,
@@ -4425,7 +4425,7 @@  discard block
 block discarded – undo
4425 4425
 			);
4426 4426
 		}
4427 4427
 
4428
-		return apply_filters($tagName,null,$this,$args);
4428
+		return apply_filters($tagName, null, $this, $args);
4429 4429
 	}
4430 4430
 
4431 4431
 
@@ -4443,28 +4443,28 @@  discard block
 block discarded – undo
4443 4443
 	 * @throws EE_Error
4444 4444
 	 * @return EE_Base_Class
4445 4445
 	 */
4446
-	public function ensure_is_obj( $base_class_obj_or_id, $ensure_is_in_db = FALSE ){
4446
+	public function ensure_is_obj($base_class_obj_or_id, $ensure_is_in_db = FALSE) {
4447 4447
 		$className = $this->_get_class_name();
4448
-		if ( $base_class_obj_or_id instanceof $className ) {
4448
+		if ($base_class_obj_or_id instanceof $className) {
4449 4449
 			$model_object = $base_class_obj_or_id;
4450 4450
 		} else {
4451 4451
 			$primary_key_field = $this->get_primary_key_field();
4452 4452
 			if (
4453 4453
 				$primary_key_field instanceof EE_Primary_Key_Int_Field
4454 4454
 				&& (
4455
-					is_int( $base_class_obj_or_id )
4456
-					|| is_string( $base_class_obj_or_id )
4455
+					is_int($base_class_obj_or_id)
4456
+					|| is_string($base_class_obj_or_id)
4457 4457
 				)
4458 4458
 			) {
4459 4459
 				// assume it's an ID.
4460 4460
 				// either a proper integer or a string representing an integer (eg "101" instead of 101)
4461
-				$model_object = $this->get_one_by_ID( $base_class_obj_or_id );
4461
+				$model_object = $this->get_one_by_ID($base_class_obj_or_id);
4462 4462
 			} else if (
4463 4463
 				$primary_key_field instanceof EE_Primary_Key_String_Field
4464
-			    && is_string( $base_class_obj_or_id )
4464
+			    && is_string($base_class_obj_or_id)
4465 4465
 			) {
4466 4466
 				// assume its a string representation of the object
4467
-				$model_object = $this->get_one_by_ID( $base_class_obj_or_id );
4467
+				$model_object = $this->get_one_by_ID($base_class_obj_or_id);
4468 4468
 			} else {
4469 4469
 				throw new EE_Error(
4470 4470
 					sprintf(
@@ -4474,12 +4474,12 @@  discard block
 block discarded – undo
4474 4474
 						),
4475 4475
 						$base_class_obj_or_id,
4476 4476
 						$this->_get_class_name(),
4477
-						print_r( $base_class_obj_or_id, true )
4477
+						print_r($base_class_obj_or_id, true)
4478 4478
 					)
4479 4479
 				);
4480 4480
 			}
4481 4481
 		}
4482
-		if ( $ensure_is_in_db && $model_object->ID() !== null ) {
4482
+		if ($ensure_is_in_db && $model_object->ID() !== null) {
4483 4483
 			$model_object->save();
4484 4484
 		}
4485 4485
 		return $model_object;
@@ -4495,19 +4495,19 @@  discard block
 block discarded – undo
4495 4495
 	 * @return int|string depending on the type of this model object's ID
4496 4496
 	 * @throws EE_Error
4497 4497
 	 */
4498
-	public function ensure_is_ID($base_class_obj_or_id){
4498
+	public function ensure_is_ID($base_class_obj_or_id) {
4499 4499
 		$className = $this->_get_class_name();
4500
-		if( $base_class_obj_or_id instanceof $className ){
4500
+		if ($base_class_obj_or_id instanceof $className) {
4501 4501
 			/** @var $base_class_obj_or_id EE_Base_Class */
4502 4502
 			$id = $base_class_obj_or_id->ID();
4503
-		}elseif(is_int($base_class_obj_or_id)){
4503
+		}elseif (is_int($base_class_obj_or_id)) {
4504 4504
 			//assume it's an ID
4505 4505
 			$id = $base_class_obj_or_id;
4506
-		}elseif(is_string($base_class_obj_or_id)){
4506
+		}elseif (is_string($base_class_obj_or_id)) {
4507 4507
 			//assume its a string representation of the object
4508 4508
 			$id = $base_class_obj_or_id;
4509
-		}else{
4510
-			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)));
4509
+		} else {
4510
+			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)));
4511 4511
 		}
4512 4512
 		return $id;
4513 4513
 	}
@@ -4530,14 +4530,14 @@  discard block
 block discarded – undo
4530 4530
 	 * @param int $values_already_prepared like one of the constants on EEM_Base
4531 4531
 	 * @return void
4532 4532
 	 */
4533
-	public function assume_values_already_prepared_by_model_object($values_already_prepared = self::not_prepared_by_model_object){
4533
+	public function assume_values_already_prepared_by_model_object($values_already_prepared = self::not_prepared_by_model_object) {
4534 4534
 		$this->_values_already_prepared_by_model_object = $values_already_prepared;
4535 4535
 	}
4536 4536
 	/**
4537 4537
 	 * Read comments for assume_values_already_prepared_by_model_object()
4538 4538
 	 * @return int
4539 4539
 	 */
4540
-	public function get_assumption_concerning_values_already_prepared_by_model_object(){
4540
+	public function get_assumption_concerning_values_already_prepared_by_model_object() {
4541 4541
 		return $this->_values_already_prepared_by_model_object;
4542 4542
 	}
4543 4543
 
@@ -4545,17 +4545,17 @@  discard block
 block discarded – undo
4545 4545
 	 * Gets all the indexes on this model
4546 4546
 	 * @return EE_Index[]
4547 4547
 	 */
4548
-	public function indexes(){
4548
+	public function indexes() {
4549 4549
 		return $this->_indexes;
4550 4550
 	}
4551 4551
 	/**
4552 4552
 	 * Gets all the Unique Indexes on this model
4553 4553
 	 * @return EE_Unique_Index[]
4554 4554
 	 */
4555
-	public function unique_indexes(){
4555
+	public function unique_indexes() {
4556 4556
 		$unique_indexes = array();
4557
-		foreach($this->_indexes as $name => $index){
4558
-			if($index instanceof EE_Unique_Index){
4557
+		foreach ($this->_indexes as $name => $index) {
4558
+			if ($index instanceof EE_Unique_Index) {
4559 4559
 				$unique_indexes [$name] = $index;
4560 4560
 			}
4561 4561
 		}
@@ -4573,13 +4573,13 @@  discard block
 block discarded – undo
4573 4573
 	 * @return EE_Model_Field_Base[] indexed by the field's name
4574 4574
 	 * @throws \EE_Error
4575 4575
 	 */
4576
-	public function get_combined_primary_key_fields(){
4577
-		foreach($this->indexes() as $index){
4578
-			if($index instanceof EE_Primary_Key_Index){
4576
+	public function get_combined_primary_key_fields() {
4577
+		foreach ($this->indexes() as $index) {
4578
+			if ($index instanceof EE_Primary_Key_Index) {
4579 4579
 				return $index->fields();
4580 4580
 			}
4581 4581
 		}
4582
-		return array( $this->primary_key_name() => $this->get_primary_key_field());
4582
+		return array($this->primary_key_name() => $this->get_primary_key_field());
4583 4583
 	}
4584 4584
 
4585 4585
 
@@ -4593,7 +4593,7 @@  discard block
 block discarded – undo
4593 4593
 	 * @return string
4594 4594
 	 * @throws \EE_Error
4595 4595
 	 */
4596
-	public function get_index_primary_key_string($cols_n_values){
4596
+	public function get_index_primary_key_string($cols_n_values) {
4597 4597
 		$cols_n_values_for_primary_key_index = array_intersect_key($cols_n_values, $this->get_combined_primary_key_fields());
4598 4598
 		return http_build_query($cols_n_values_for_primary_key_index);
4599 4599
 	}
@@ -4608,13 +4608,13 @@  discard block
 block discarded – undo
4608 4608
 	 * @return null|array
4609 4609
 	 * @throws \EE_Error
4610 4610
 	 */
4611
-	public function parse_index_primary_key_string( $index_primary_key_string) {
4611
+	public function parse_index_primary_key_string($index_primary_key_string) {
4612 4612
 		$key_fields = $this->get_combined_primary_key_fields();
4613 4613
 		//check all of them are in the $id
4614 4614
 		$key_vals_in_combined_pk = array();
4615
-		parse_str( $index_primary_key_string, $key_vals_in_combined_pk );
4616
-		foreach( $key_fields as $key_field_name => $field_obj ) {
4617
-			if( ! isset( $key_vals_in_combined_pk[ $key_field_name ] ) ){
4615
+		parse_str($index_primary_key_string, $key_vals_in_combined_pk);
4616
+		foreach ($key_fields as $key_field_name => $field_obj) {
4617
+			if ( ! isset($key_vals_in_combined_pk[$key_field_name])) {
4618 4618
 				return NULL;
4619 4619
 			}
4620 4620
 		}
@@ -4631,10 +4631,10 @@  discard block
 block discarded – undo
4631 4631
 	 * @return boolean
4632 4632
 	 * @throws \EE_Error
4633 4633
 	 */
4634
-	public function has_all_combined_primary_key_fields( $key_vals ) {
4635
-		$keys_it_should_have = array_keys( $this->get_combined_primary_key_fields() );
4636
-		foreach( $keys_it_should_have as $key ){
4637
-			if( ! isset( $key_vals[ $key ] ) ){
4634
+	public function has_all_combined_primary_key_fields($key_vals) {
4635
+		$keys_it_should_have = array_keys($this->get_combined_primary_key_fields());
4636
+		foreach ($keys_it_should_have as $key) {
4637
+			if ( ! isset($key_vals[$key])) {
4638 4638
 				return false;
4639 4639
 			}
4640 4640
 		}
@@ -4650,23 +4650,23 @@  discard block
 block discarded – undo
4650 4650
 	 * @throws EE_Error
4651 4651
 	 * @return \EE_Base_Class[] Array keys are object IDs (if there is a primary key on the model. if not, numerically indexed)
4652 4652
 	 */
4653
-	public function get_all_copies($model_object_or_attributes_array, $query_params = array()){
4653
+	public function get_all_copies($model_object_or_attributes_array, $query_params = array()) {
4654 4654
 
4655
-		if($model_object_or_attributes_array instanceof EE_Base_Class){
4655
+		if ($model_object_or_attributes_array instanceof EE_Base_Class) {
4656 4656
 			$attributes_array = $model_object_or_attributes_array->model_field_array();
4657
-		}elseif(is_array($model_object_or_attributes_array)){
4657
+		}elseif (is_array($model_object_or_attributes_array)) {
4658 4658
 			$attributes_array = $model_object_or_attributes_array;
4659
-		}else{
4660
-			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));
4659
+		} else {
4660
+			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));
4661 4661
 		}
4662 4662
 		//even copies obviously won't have the same ID, so remove the primary key
4663 4663
 		//from the WHERE conditions for finding copies (if there is a primary key, of course)
4664
-		if($this->has_primary_key_field() && isset($attributes_array[$this->primary_key_name()])){
4664
+		if ($this->has_primary_key_field() && isset($attributes_array[$this->primary_key_name()])) {
4665 4665
 			unset($attributes_array[$this->primary_key_name()]);
4666 4666
 		}
4667
-		if(isset($query_params[0])){
4668
-			$query_params[0] = array_merge($attributes_array,$query_params);
4669
-		}else{
4667
+		if (isset($query_params[0])) {
4668
+			$query_params[0] = array_merge($attributes_array, $query_params);
4669
+		} else {
4670 4670
 			$query_params[0] = $attributes_array;
4671 4671
 		}
4672 4672
 		return $this->get_all($query_params);
@@ -4682,16 +4682,16 @@  discard block
 block discarded – undo
4682 4682
 	 * @return EE_Base_Class
4683 4683
 	 * @throws \EE_Error
4684 4684
 	 */
4685
-	public function get_one_copy($model_object_or_attributes_array,$query_params = array()){
4686
-		if( ! is_array( $query_params ) ){
4687
-			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' );
4685
+	public function get_one_copy($model_object_or_attributes_array, $query_params = array()) {
4686
+		if ( ! is_array($query_params)) {
4687
+			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');
4688 4688
 			$query_params = array();
4689 4689
 		}
4690 4690
 		$query_params['limit'] = 1;
4691
-		$copies = $this->get_all_copies($model_object_or_attributes_array,$query_params);
4692
-		if(is_array($copies)){
4691
+		$copies = $this->get_all_copies($model_object_or_attributes_array, $query_params);
4692
+		if (is_array($copies)) {
4693 4693
 			return array_shift($copies);
4694
-		}else{
4694
+		} else {
4695 4695
 			return null;
4696 4696
 		}
4697 4697
 	}
@@ -4707,10 +4707,10 @@  discard block
 block discarded – undo
4707 4707
 	 * @return int number of rows updated
4708 4708
 	 * @throws \EE_Error
4709 4709
 	 */
4710
-	public function update_by_ID($fields_n_values,$id){
4710
+	public function update_by_ID($fields_n_values, $id) {
4711 4711
 		$query_params = array(0=>array($this->get_primary_key_field()->get_name() => $id),
4712 4712
 			'default_where_conditions'=>'other_models_only',);
4713
-		return $this->update($fields_n_values,$query_params);
4713
+		return $this->update($fields_n_values, $query_params);
4714 4714
 	}
4715 4715
 
4716 4716
 
@@ -4721,12 +4721,12 @@  discard block
 block discarded – undo
4721 4721
 	 * @return string an operator which can be used in SQL
4722 4722
 	 * @throws EE_Error
4723 4723
 	 */
4724
-	private function _prepare_operator_for_sql($operator_supplied){
4724
+	private function _prepare_operator_for_sql($operator_supplied) {
4725 4725
 		$sql_operator = isset($this->_valid_operators[$operator_supplied]) ? $this->_valid_operators[$operator_supplied] : null;
4726
-		if($sql_operator){
4726
+		if ($sql_operator) {
4727 4727
 			return $sql_operator;
4728
-		}else{
4729
-			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))));
4728
+		} else {
4729
+			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))));
4730 4730
 		}
4731 4731
 	}
4732 4732
 
@@ -4740,10 +4740,10 @@  discard block
 block discarded – undo
4740 4740
 	 * @return string[]
4741 4741
 	 * @throws \EE_Error
4742 4742
 	 */
4743
-	public function get_all_names($query_params = array()){
4743
+	public function get_all_names($query_params = array()) {
4744 4744
 		$objs = $this->get_all($query_params);
4745 4745
 		$names = array();
4746
-		foreach($objs as $obj){
4746
+		foreach ($objs as $obj) {
4747 4747
 			$names[$obj->ID()] = $obj->name();
4748 4748
 		}
4749 4749
 		return $names;
@@ -4762,11 +4762,11 @@  discard block
 block discarded – undo
4762 4762
 	 * @return array
4763 4763
 	 * @throws \EE_Error
4764 4764
 	 */
4765
-	public function get_IDs( $model_objects, $filter_out_empty_ids = false) {
4766
-		if( ! $this->has_primary_key_field() ) {
4767
-			if( WP_DEBUG ) {
4765
+	public function get_IDs($model_objects, $filter_out_empty_ids = false) {
4766
+		if ( ! $this->has_primary_key_field()) {
4767
+			if (WP_DEBUG) {
4768 4768
 				EE_Error::add_error(
4769
-					__( 'Trying to get IDs from a model than has no primary key', 'event_espresso' ),
4769
+					__('Trying to get IDs from a model than has no primary key', 'event_espresso'),
4770 4770
 					__FILE__,
4771 4771
 					__FUNCTION__,
4772 4772
 					__LINE__
@@ -4774,13 +4774,13 @@  discard block
 block discarded – undo
4774 4774
 			}
4775 4775
 		}
4776 4776
 		$IDs = array();
4777
-		foreach( $model_objects as $model_object ) {
4777
+		foreach ($model_objects as $model_object) {
4778 4778
 			$id = $model_object->ID();
4779
-			if( ! $id ) {
4780
-				if( $filter_out_empty_ids ) {
4779
+			if ( ! $id) {
4780
+				if ($filter_out_empty_ids) {
4781 4781
 					continue;
4782 4782
 				}
4783
-				if ( WP_DEBUG ) {
4783
+				if (WP_DEBUG) {
4784 4784
 					EE_Error::add_error(
4785 4785
 						__(
4786 4786
 							'Called %1$s on a model object that has no ID and so probably hasn\'t been saved to the database',
@@ -4802,8 +4802,8 @@  discard block
 block discarded – undo
4802 4802
 	 * are no capabilities that relate to this model returns false
4803 4803
 	 * @return string|false
4804 4804
 	 */
4805
-	public function cap_slug(){
4806
-		return apply_filters( 'FHEE__EEM_Base__cap_slug', $this->_caps_slug, $this);
4805
+	public function cap_slug() {
4806
+		return apply_filters('FHEE__EEM_Base__cap_slug', $this->_caps_slug, $this);
4807 4807
 	}
4808 4808
 
4809 4809
 
@@ -4818,34 +4818,34 @@  discard block
 block discarded – undo
4818 4818
 	 * @return EE_Default_Where_Conditions[] indexed by associated capability
4819 4819
 	 * @throws \EE_Error
4820 4820
 	 */
4821
-	public function cap_restrictions( $context = EEM_Base::caps_read ) {
4822
-		EEM_Base::verify_is_valid_cap_context( $context );
4821
+	public function cap_restrictions($context = EEM_Base::caps_read) {
4822
+		EEM_Base::verify_is_valid_cap_context($context);
4823 4823
 		//check if we ought to run the restriction generator first
4824
-		if(
4825
-			isset( $this->_cap_restriction_generators[ $context ] )
4826
-			&& $this->_cap_restriction_generators[ $context ] instanceof EE_Restriction_Generator_Base
4827
-			&& ! $this->_cap_restriction_generators[ $context ]->has_generated_cap_restrictions()
4824
+		if (
4825
+			isset($this->_cap_restriction_generators[$context])
4826
+			&& $this->_cap_restriction_generators[$context] instanceof EE_Restriction_Generator_Base
4827
+			&& ! $this->_cap_restriction_generators[$context]->has_generated_cap_restrictions()
4828 4828
 		) {
4829
-			$this->_cap_restrictions[ $context ] = array_merge(
4830
-				$this->_cap_restrictions[ $context ],
4831
-				$this->_cap_restriction_generators[ $context ]->generate_restrictions()
4829
+			$this->_cap_restrictions[$context] = array_merge(
4830
+				$this->_cap_restrictions[$context],
4831
+				$this->_cap_restriction_generators[$context]->generate_restrictions()
4832 4832
 			);
4833 4833
 		}
4834 4834
 		//and make sure we've finalized the construction of each restriction
4835
-		foreach( $this->_cap_restrictions[ $context ] as $where_conditions_obj ) {
4836
-			if ( $where_conditions_obj instanceof EE_Default_Where_Conditions ) {
4837
-				$where_conditions_obj->_finalize_construct( $this );
4835
+		foreach ($this->_cap_restrictions[$context] as $where_conditions_obj) {
4836
+			if ($where_conditions_obj instanceof EE_Default_Where_Conditions) {
4837
+				$where_conditions_obj->_finalize_construct($this);
4838 4838
 			}
4839 4839
 		}
4840 4840
 
4841
-		return $this->_cap_restrictions[ $context ];
4841
+		return $this->_cap_restrictions[$context];
4842 4842
 	}
4843 4843
 
4844 4844
 	/**
4845 4845
 	 * Indicating whether or not this model thinks its a wp core model
4846 4846
 	 * @return boolean
4847 4847
 	 */
4848
-	public function is_wp_core_model(){
4848
+	public function is_wp_core_model() {
4849 4849
 		return $this->_wp_core_model;
4850 4850
 	}
4851 4851
 
@@ -4859,12 +4859,12 @@  discard block
 block discarded – undo
4859 4859
 	 * @return EE_Default_Where_Conditions[] indexed by capability name
4860 4860
 	 * @throws \EE_Error
4861 4861
 	 */
4862
-	public function caps_missing( $context = EEM_Base::caps_read ) {
4862
+	public function caps_missing($context = EEM_Base::caps_read) {
4863 4863
 		$missing_caps = array();
4864
-		$cap_restrictions = $this->cap_restrictions( $context );
4865
-		foreach( $cap_restrictions as $cap => $restriction_if_no_cap ) {
4866
-			if( ! EE_Capabilities::instance()->current_user_can( $cap, $this->get_this_model_name() . '_model_applying_caps') ) {
4867
-				$missing_caps[ $cap ] = $restriction_if_no_cap;
4864
+		$cap_restrictions = $this->cap_restrictions($context);
4865
+		foreach ($cap_restrictions as $cap => $restriction_if_no_cap) {
4866
+			if ( ! EE_Capabilities::instance()->current_user_can($cap, $this->get_this_model_name().'_model_applying_caps')) {
4867
+				$missing_caps[$cap] = $restriction_if_no_cap;
4868 4868
 			}
4869 4869
 		}
4870 4870
 		return $missing_caps;
@@ -4876,7 +4876,7 @@  discard block
 block discarded – undo
4876 4876
 	 * one of 'read', 'edit', or 'delete'
4877 4877
 	 */
4878 4878
 	public function cap_contexts_to_cap_action_map() {
4879
-		return apply_filters( 'FHEE__EEM_Base__cap_contexts_to_cap_action_map', $this->_cap_contexts_to_cap_action_map, $this );
4879
+		return apply_filters('FHEE__EEM_Base__cap_contexts_to_cap_action_map', $this->_cap_contexts_to_cap_action_map, $this);
4880 4880
 	}
4881 4881
 
4882 4882
 
@@ -4887,19 +4887,19 @@  discard block
 block discarded – undo
4887 4887
 	 * @return string one of EEM_Base::cap_contexts_to_cap_action_map() values
4888 4888
 	 * @throws \EE_Error
4889 4889
 	 */
4890
-	public function cap_action_for_context( $context ) {
4890
+	public function cap_action_for_context($context) {
4891 4891
 		$mapping = $this->cap_contexts_to_cap_action_map();
4892
-		if( isset( $mapping[ $context ] ) ) {
4893
-			return $mapping[ $context ];
4892
+		if (isset($mapping[$context])) {
4893
+			return $mapping[$context];
4894 4894
 		}
4895
-		if( $action = apply_filters( 'FHEE__EEM_Base__cap_action_for_context', null, $this, $mapping, $context ) ) {
4895
+		if ($action = apply_filters('FHEE__EEM_Base__cap_action_for_context', null, $this, $mapping, $context)) {
4896 4896
 			return $action;
4897 4897
 		}
4898 4898
 		throw new EE_Error(
4899 4899
 			sprintf(
4900
-				__( 'Cannot find capability restrictions for context "%1$s", allowed values are:%2$s', 'event_espresso' ),
4900
+				__('Cannot find capability restrictions for context "%1$s", allowed values are:%2$s', 'event_espresso'),
4901 4901
 				$context,
4902
-				implode(',', array_keys( $this->cap_contexts_to_cap_action_map() ) )
4902
+				implode(',', array_keys($this->cap_contexts_to_cap_action_map()))
4903 4903
 			)
4904 4904
 		);
4905 4905
 
@@ -4910,7 +4910,7 @@  discard block
 block discarded – undo
4910 4910
 	 * @return array
4911 4911
 	 */
4912 4912
 	static public function valid_cap_contexts() {
4913
-		return apply_filters( 'FHEE__EEM_Base__valid_cap_contexts', array(
4913
+		return apply_filters('FHEE__EEM_Base__valid_cap_contexts', array(
4914 4914
 			self::caps_read,
4915 4915
 			self::caps_read_admin,
4916 4916
 			self::caps_edit,
@@ -4926,17 +4926,17 @@  discard block
 block discarded – undo
4926 4926
 	 * @return bool
4927 4927
 	 * @throws \EE_Error
4928 4928
 	 */
4929
-	static public function verify_is_valid_cap_context( $context ) {
4929
+	static public function verify_is_valid_cap_context($context) {
4930 4930
 		$valid_cap_contexts = EEM_Base::valid_cap_contexts();
4931
-		if( in_array( $context, $valid_cap_contexts ) ) {
4931
+		if (in_array($context, $valid_cap_contexts)) {
4932 4932
 			return true;
4933
-		}else{
4933
+		} else {
4934 4934
 			throw new EE_Error(
4935 4935
 				sprintf(
4936
-					__( 'Context "%1$s" passed into model "%2$s" is not a valid context. They are: %3$s', 'event_espresso' ),
4936
+					__('Context "%1$s" passed into model "%2$s" is not a valid context. They are: %3$s', 'event_espresso'),
4937 4937
 					$context,
4938
-					'EEM_Base' ,
4939
-					implode(',', $valid_cap_contexts )
4938
+					'EEM_Base',
4939
+					implode(',', $valid_cap_contexts)
4940 4940
 				)
4941 4941
 			);
4942 4942
 		}
Please login to merge, or discard this patch.