Completed
Branch BUG-9548-transaction-completio... (b1c41e)
by
unknown
519:42 queued 503:28
created
espresso_event_attendees/EES_Espresso_Event_Attendees.shortcode.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 	 * @param       WP $WP
20 20
 	 * @return    void
21 21
 	 */
22
-	public function run( WP $WP ) {}
22
+	public function run(WP $WP) {}
23 23
 
24 24
 
25 25
 	/**
@@ -69,10 +69,10 @@  discard block
 block discarded – undo
69 69
 	 *  @param 	    array 	$attributes
70 70
 	 *  @return 	string
71 71
 	 */
72
-	public function process_shortcode( $attributes = array() ) {
72
+	public function process_shortcode($attributes = array()) {
73 73
 
74 74
 		// merge in any attributes passed via fallback shortcode processor
75
-		$attributes = array_merge( (array) $attributes, (array) $this->_attributes );
75
+		$attributes = array_merge((array) $attributes, (array) $this->_attributes);
76 76
 
77 77
 		//set default attributes
78 78
 		$default_shortcode_attributes = array(
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
 		);
85 85
 
86 86
 		// allow the defaults to be filtered
87
-		$default_shortcode_attributes = apply_filters( 'EES_Espresso_Event_Attendees__process_shortcode__default_shortcode_atts', $default_shortcode_attributes );
87
+		$default_shortcode_attributes = apply_filters('EES_Espresso_Event_Attendees__process_shortcode__default_shortcode_atts', $default_shortcode_attributes);
88 88
 		// grab attributes and merge with defaults, then extract
89
-		$attributes = array_merge( $default_shortcode_attributes, $attributes );
89
+		$attributes = array_merge($default_shortcode_attributes, $attributes);
90 90
 
91 91
 		$template_args = array(
92 92
 			'contacts'      => array(),
@@ -102,31 +102,31 @@  discard block
 block discarded – undo
102 102
 		$error = false;
103 103
 
104 104
 		//what event?
105
-		if ( empty( $attributes['event_id'] ) && empty( $attributes['datetime_id'] ) && empty( $attributes['ticket_id'] ) ) {
105
+		if (empty($attributes['event_id']) && empty($attributes['datetime_id']) && empty($attributes['ticket_id'])) {
106 106
 			//seems like is_espresso_event_single() isn't working as expected. So using alternate method.
107
-			if ( is_single() && is_espresso_event() ) {
107
+			if (is_single() && is_espresso_event()) {
108 108
 				$event = EEH_Event_View::get_event();
109
-				if ( $event instanceof EE_Event ) {
109
+				if ($event instanceof EE_Event) {
110 110
 					$template_args['event']          = $event;
111 111
 					$query[0]['Registration.EVT_ID'] = $event->ID();
112 112
 				}
113 113
 			} else {
114 114
 				//try getting the earliest active event if none then get the
115
-				$events = EEM_Event::instance()->get_active_events( array( 'limit'    => 1,
116
-				                                                          'order_by' => array( 'Datetime.DTT_EVT_start' => 'ASC' )
117
-				) );
118
-				$events = empty( $events ) ? EEM_Event::instance()->get_upcoming_events( array( 'limit'    => 1,
119
-				                                                                              'order_by' => array( 'Datetime.DTT_EVT_start' => 'ASC' )
120
-				) ) : $events;
121
-				$event = reset( $events );
122
-				if ( $event instanceof EE_Event ) {
115
+				$events = EEM_Event::instance()->get_active_events(array('limit'    => 1,
116
+				                                                          'order_by' => array('Datetime.DTT_EVT_start' => 'ASC')
117
+				));
118
+				$events = empty($events) ? EEM_Event::instance()->get_upcoming_events(array('limit'    => 1,
119
+				                                                                              'order_by' => array('Datetime.DTT_EVT_start' => 'ASC')
120
+				)) : $events;
121
+				$event = reset($events);
122
+				if ($event instanceof EE_Event) {
123 123
 					$query[0]['Registration.EVT_ID'] = $event->ID();
124 124
 					$template_args['event']          = $event;
125 125
 				}
126 126
 			}
127
-		} elseif ( ! empty( $attributes['event_id'] ) ) {
128
-			$event = EEM_Event::instance()->get_one_by_ID( $attributes['event_id'] );
129
-			if ( $event instanceof EE_Event ) {
127
+		} elseif ( ! empty($attributes['event_id'])) {
128
+			$event = EEM_Event::instance()->get_one_by_ID($attributes['event_id']);
129
+			if ($event instanceof EE_Event) {
130 130
 				$query[0]['Registration.EVT_ID'] = $attributes['event_id'];
131 131
 				$template_args['event']          = $event;
132 132
 			} else {
@@ -135,9 +135,9 @@  discard block
 block discarded – undo
135 135
 		}
136 136
 
137 137
 		//datetime?
138
-		if ( ! empty( $attributes['datetime_id'] ) && empty( $attributes['event_id'] ) ) {
139
-			$datetime = EEM_Datetime::instance()->get_one_by_ID( $attributes['datetime_id'] );
140
-			if ( $datetime instanceof EE_Datetime ) {
138
+		if ( ! empty($attributes['datetime_id']) && empty($attributes['event_id'])) {
139
+			$datetime = EEM_Datetime::instance()->get_one_by_ID($attributes['datetime_id']);
140
+			if ($datetime instanceof EE_Datetime) {
141 141
 				$query[0]['Registration.Ticket.Datetime.DTT_ID'] = $attributes['datetime_id'];
142 142
 				$query['default_where_conditions'] = 'this_model_only';
143 143
 				$template_args['datetime']                      = $datetime;
@@ -148,9 +148,9 @@  discard block
 block discarded – undo
148 148
 		}
149 149
 
150 150
 		//ticket?just
151
-		if ( ! empty( $attributes['ticket_id'] ) && empty( $attributes['event_id'] ) && empty( $attributes['datetime_id'] ) ) {
152
-			$ticket = EEM_Ticket::instance()->get_one_by_ID( $attributes['ticket_id'] );
153
-			if ( $ticket instanceof EE_Ticket ) {
151
+		if ( ! empty($attributes['ticket_id']) && empty($attributes['event_id']) && empty($attributes['datetime_id'])) {
152
+			$ticket = EEM_Ticket::instance()->get_one_by_ID($attributes['ticket_id']);
153
+			if ($ticket instanceof EE_Ticket) {
154 154
 				$query[0]['Registration.TKT_ID'] = $attributes['ticket_id'];
155 155
 				$template_args['ticket']         = $ticket;
156 156
 				$template_args['event']          = $ticket->first_datetime() instanceof EE_Datetime ? $ticket->first_datetime()->event() : null;
@@ -161,17 +161,17 @@  discard block
 block discarded – undo
161 161
 
162 162
 		//status
163 163
 		$reg_status_array = EEM_Registration::reg_status_array();
164
-		if ( $attributes['status'] != 'all' && isset( $reg_status_array[$attributes['status']] ) ) {
164
+		if ($attributes['status'] != 'all' && isset($reg_status_array[$attributes['status']])) {
165 165
 			$query[0]['Registration.STS_ID'] = $attributes['status'];
166 166
 		}
167
-		$query['group_by'] = array( 'ATT_ID' );
168
-		$query['order_by'] = apply_filters( 'FHEE__EES_Espresso_Event_Attendees__process_shortcode__order_by', array( 'ATT_lname' => 'ASC', 'ATT_fname' => 'ASC' ) );
167
+		$query['group_by'] = array('ATT_ID');
168
+		$query['order_by'] = apply_filters('FHEE__EES_Espresso_Event_Attendees__process_shortcode__order_by', array('ATT_lname' => 'ASC', 'ATT_fname' => 'ASC'));
169 169
 
170 170
 		//if we have NO query where conditions, then there was an invalid parameter or the shortcode was used incorrectly
171 171
 		//so when WP_DEBUG is set and true, we'll show a message, otherwise we'll just return an empty string.
172
-		if ( ( ! isset( $query[0] ) || ! is_array( $query[0] ) ) || $error ) {
173
-			if ( WP_DEBUG ) {
174
-				return '<div class="important-notice ee-attention">' . __( 'The [ESPRESSO_EVENT_ATTENDEES] shortcode has been used incorrectly.  Please double check the arguments you used for any typos.  In the case of ID type arguments, its possible the given ID does not correspond to existing data in the database.', 'event_espresso' ) . '</div>';
172
+		if (( ! isset($query[0]) || ! is_array($query[0])) || $error) {
173
+			if (WP_DEBUG) {
174
+				return '<div class="important-notice ee-attention">'.__('The [ESPRESSO_EVENT_ATTENDEES] shortcode has been used incorrectly.  Please double check the arguments you used for any typos.  In the case of ID type arguments, its possible the given ID does not correspond to existing data in the database.', 'event_espresso').'</div>';
175 175
 			} else {
176 176
 				return '';
177 177
 			}
@@ -179,11 +179,11 @@  discard block
 block discarded – undo
179 179
 
180 180
 
181 181
 		//get contacts!
182
-		$template_args['contacts'] = EEM_Attendee::instance()->get_all( $query );
182
+		$template_args['contacts'] = EEM_Attendee::instance()->get_all($query);
183 183
 
184 184
 
185 185
 		//all set let's load up the template and return.
186
-		return EEH_Template::locate_template( 'loop-espresso_event_attendees.php', $template_args, true, true );
186
+		return EEH_Template::locate_template('loop-espresso_event_attendees.php', $template_args, true, true);
187 187
 
188 188
 	}
189 189
 
Please login to merge, or discard this patch.
shortcodes/espresso_events/EES_Espresso_Events.shortcode.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -50,14 +50,14 @@  discard block
 block discarded – undo
50 50
 	 * @param WP $WP
51 51
 	 * @return    void
52 52
 	 */
53
-	public function run( WP $WP ) {
54
-		if ( did_action( 'pre_get_posts' ) && did_action( 'send_headers' ) ) {
53
+	public function run(WP $WP) {
54
+		if (did_action('pre_get_posts') && did_action('send_headers')) {
55 55
 			EED_Events_Archive::instance()->event_list();
56 56
 		} else {
57 57
 			// this will trigger the EED_Events_Archive module's event_list() method during the pre_get_posts hook point,
58 58
 			// this allows us to initialize things, enqueue assets, etc,
59 59
 			// as well, this saves an instantiation of the module in an array using 'espresso_events' as the key, so that we can retrieve it
60
-			add_action( 'pre_get_posts', array( EED_Events_Archive::instance(), 'event_list' ) );
60
+			add_action('pre_get_posts', array(EED_Events_Archive::instance(), 'event_list'));
61 61
 		}
62 62
 	}
63 63
 
@@ -79,13 +79,13 @@  discard block
 block discarded – undo
79 79
 	 *  @param 	array 	$attributes
80 80
 	 *  @return 	string
81 81
 	 */
82
-	public function process_shortcode( $attributes = array() ) {
82
+	public function process_shortcode($attributes = array()) {
83 83
 		// make sure EED_Events_Archive is setup properly
84
-		if ( apply_filters( 'FHEE__fallback_shortcode_processor__EES_Espresso_Events', FALSE )) {
84
+		if (apply_filters('FHEE__fallback_shortcode_processor__EES_Espresso_Events', FALSE)) {
85 85
 			EED_Events_Archive::instance()->event_list();
86 86
 		}
87 87
 		// merge in any attributes passed via fallback shortcode processor
88
-		$attributes = array_merge( (array)$attributes, (array)$this->_attributes );
88
+		$attributes = array_merge((array) $attributes, (array) $this->_attributes);
89 89
 		//set default attributes
90 90
 		$default_espresso_events_shortcode_atts = array(
91 91
 			'title' => NULL,
@@ -99,26 +99,26 @@  discard block
 block discarded – undo
99 99
 			'fallback_shortcode_processor' => FALSE
100 100
 		);
101 101
 		// allow the defaults to be filtered
102
-		$default_espresso_events_shortcode_atts = apply_filters( 'EES_Espresso_Events__process_shortcode__default_espresso_events_shortcode_atts', $default_espresso_events_shortcode_atts );
102
+		$default_espresso_events_shortcode_atts = apply_filters('EES_Espresso_Events__process_shortcode__default_espresso_events_shortcode_atts', $default_espresso_events_shortcode_atts);
103 103
 		// grab attributes and merge with defaults, then extract
104
-		$attributes = array_merge( $default_espresso_events_shortcode_atts, $attributes );
104
+		$attributes = array_merge($default_espresso_events_shortcode_atts, $attributes);
105 105
 		// make sure we use the_excerpt()
106
-		add_filter( 'FHEE__EES_Espresso_Events__process_shortcode__true', '__return_true' );
106
+		add_filter('FHEE__EES_Espresso_Events__process_shortcode__true', '__return_true');
107 107
 		// apply query filters
108
-		add_filter( 'FHEE__EEH_Event_Query__apply_query_filters', '__return_true' );
108
+		add_filter('FHEE__EEH_Event_Query__apply_query_filters', '__return_true');
109 109
 		// run the query
110 110
 		global $wp_query;
111
-		$wp_query = new EE_Event_List_Query( $attributes );
111
+		$wp_query = new EE_Event_List_Query($attributes);
112 112
 		// check what template is loaded and load filters accordingly
113
-		EED_Events_Archive::instance()->template_include( 'loop-espresso_events.php' );
113
+		EED_Events_Archive::instance()->template_include('loop-espresso_events.php');
114 114
 		// load our template
115
-		$event_list = EEH_Template::locate_template( 'loop-espresso_events.php', array(), TRUE, TRUE );
115
+		$event_list = EEH_Template::locate_template('loop-espresso_events.php', array(), TRUE, TRUE);
116 116
 		// now reset the query and postdata
117 117
 		wp_reset_query();
118 118
 		wp_reset_postdata();
119 119
 		EED_Events_Archive::remove_all_events_archive_filters();
120 120
 		// remove query filters
121
-		remove_filter( 'FHEE__EEH_Event_Query__apply_query_filters', '__return_true' );
121
+		remove_filter('FHEE__EEH_Event_Query__apply_query_filters', '__return_true');
122 122
 		// pull our content from the output buffer and return it
123 123
 		return $event_list;
124 124
 	}
@@ -163,44 +163,44 @@  discard block
 block discarded – undo
163 163
 	 * @param array $args
164 164
 	 * @return \EE_Event_List_Query
165 165
 	 */
166
-	function __construct( $args = array() ) {
166
+	function __construct($args = array()) {
167 167
 //		EEH_Debug_Tools::printr( $args, '$args  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
168 168
 		// incoming args could be a mix of WP query args + EE shortcode args
169
-		foreach ( $args as $key =>$value ) {
170
-			$property = '_' . $key;
169
+		foreach ($args as $key =>$value) {
170
+			$property = '_'.$key;
171 171
 			// if the arg is a property of this class, then it's an EE shortcode arg
172
-			if ( property_exists( $this, $property )) {
172
+			if (property_exists($this, $property)) {
173 173
 				// set the property value
174 174
 				$this->{$property} = $value;
175 175
 				// then remove it from the array of args that will later be passed to WP_Query()
176
-				unset( $args[ $key ] );
176
+				unset($args[$key]);
177 177
 			}
178 178
 		}
179 179
 		//add query filters
180 180
 		EEH_Event_Query::add_query_filters();
181 181
 		// set params that will get used by the filters
182
-		EEH_Event_Query::set_query_params( $this->_month, $this->_category_slug, $this->_show_expired, $this->_order_by, $this->_sort );
182
+		EEH_Event_Query::set_query_params($this->_month, $this->_category_slug, $this->_show_expired, $this->_order_by, $this->_sort);
183 183
 		// first off, let's remove any filters from previous queries
184
-		remove_filter( 'FHEE__archive_espresso_events_template__upcoming_events_h1', array( $this, 'event_list_title' ));
185
-		remove_all_filters( 'FHEE__content_espresso_events__event_class' );
184
+		remove_filter('FHEE__archive_espresso_events_template__upcoming_events_h1', array($this, 'event_list_title'));
185
+		remove_all_filters('FHEE__content_espresso_events__event_class');
186 186
 		// Event List Title ?
187
-		add_filter( 'FHEE__archive_espresso_events_template__upcoming_events_h1', array( $this, 'event_list_title' ), 10, 1 );
187
+		add_filter('FHEE__archive_espresso_events_template__upcoming_events_h1', array($this, 'event_list_title'), 10, 1);
188 188
 		// add the css class
189
-		add_filter( 'FHEE__content_espresso_events__event_class', array( $this, 'event_list_css' ), 10, 1 );
189
+		add_filter('FHEE__content_espresso_events__event_class', array($this, 'event_list_css'), 10, 1);
190 190
 		// the current "page" we are viewing
191
-		$paged = max( 1, get_query_var( 'paged' ));
191
+		$paged = max(1, get_query_var('paged'));
192 192
 		// Force these args
193
-		$args = array_merge( $args, array(
193
+		$args = array_merge($args, array(
194 194
 			'post_type' => 'espresso_events',
195 195
 			'posts_per_page' => $this->_limit,
196 196
 			'update_post_term_cache' => FALSE,
197 197
 			'update_post_meta_cache' => FALSE,
198 198
 			'paged' => $paged,
199
-			'offset' => ( $paged - 1 ) * $this->_limit
199
+			'offset' => ($paged - 1) * $this->_limit
200 200
 		));
201 201
 
202 202
 		// run the query
203
-		parent::__construct( $args );
203
+		parent::__construct($args);
204 204
 	}
205 205
 
206 206
 
@@ -213,8 +213,8 @@  discard block
 block discarded – undo
213 213
 	 * @param string $event_list_title
214 214
 	 * @return    string
215 215
 	 */
216
-	public function event_list_title( $event_list_title = '' ) {
217
-		if ( ! empty( $this->_title )) {
216
+	public function event_list_title($event_list_title = '') {
217
+		if ( ! empty($this->_title)) {
218 218
 			return $this->_title;
219 219
 		}
220 220
 		return $event_list_title;
@@ -229,11 +229,11 @@  discard block
 block discarded – undo
229 229
 	 * @param string $event_list_css
230 230
 	 * @return    array
231 231
 	 */
232
-	public function event_list_css( $event_list_css = '' ) {
233
-		$event_list_css .=  ! empty( $event_list_css ) ? ' ' : '';
234
-		$event_list_css .=  ! empty( $this->_css_class ) ? $this->_css_class : '';
235
-		$event_list_css .=  ! empty( $event_list_css ) ? ' ' : '';
236
-		$event_list_css .=  ! empty( $this->_category_slug ) ? $this->_category_slug : '';
232
+	public function event_list_css($event_list_css = '') {
233
+		$event_list_css .= ! empty($event_list_css) ? ' ' : '';
234
+		$event_list_css .= ! empty($this->_css_class) ? $this->_css_class : '';
235
+		$event_list_css .= ! empty($event_list_css) ? ' ' : '';
236
+		$event_list_css .= ! empty($this->_category_slug) ? $this->_category_slug : '';
237 237
 		return $event_list_css;
238 238
 	}
239 239
 
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_Data_Migration_Script_Base.core.php 1 patch
Spacing   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
 	 * All children of this must call parent::__construct() at the end of their constructor or suffer the consequences!
118 118
 	 */
119 119
 	public function __construct() {
120
-		$this->_migration_stages = apply_filters('FHEE__'.get_class($this).'__construct__migration_stages',$this->_migration_stages);
121
-		foreach($this->_migration_stages as $migration_stage){
122
-			if ( $migration_stage instanceof EE_Data_Migration_Script_Stage ) {
120
+		$this->_migration_stages = apply_filters('FHEE__'.get_class($this).'__construct__migration_stages', $this->_migration_stages);
121
+		foreach ($this->_migration_stages as $migration_stage) {
122
+			if ($migration_stage instanceof EE_Data_Migration_Script_Stage) {
123 123
 				$migration_stage->_construct_finalize($this);
124 124
 			}
125 125
 		}
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 	 * Place to add hooks and filters for tweaking the migrations page, in order
133 133
 	 * to customize it
134 134
 	 */
135
-	public function migration_page_hooks(){
135
+	public function migration_page_hooks() {
136 136
 		//by default none are added because we normally like the default look of the migration page
137 137
 	}
138 138
 
@@ -147,9 +147,9 @@  discard block
 block discarded – undo
147 147
 	 * @param int|string $new_pk eg posts.ID
148 148
 	 * @return void
149 149
 	 */
150
-	public function set_mapping($old_table,$old_pk,$new_table,$new_pk){
150
+	public function set_mapping($old_table, $old_pk, $new_table, $new_pk) {
151 151
 		//make sure it has the needed keys
152
-		if( ! isset($this->_mappings[$old_table]) || ! isset($this->_mappings[$old_table][$new_table])){
152
+		if ( ! isset($this->_mappings[$old_table]) || ! isset($this->_mappings[$old_table][$new_table])) {
153 153
 			$this->_mappings[$old_table][$new_table] = $this->_get_mapping_option($old_table, $new_table);
154 154
 		}
155 155
 		$this->_mappings[$old_table][$new_table][$old_pk] = $new_pk;
@@ -165,9 +165,9 @@  discard block
 block discarded – undo
165 165
 	 * @param string $new_table with wpdb prefix (wp_). Eg: wp_posts
166 166
 	 * @return mixed the primary key on the new table
167 167
 	 */
168
-	public function get_mapping_new_pk($old_table,$old_pk,$new_table){
169
-		if( ! isset($this->_mappings[$old_table]) ||
170
-			! isset($this->_mappings[$old_table][$new_table])){
168
+	public function get_mapping_new_pk($old_table, $old_pk, $new_table) {
169
+		if ( ! isset($this->_mappings[$old_table]) ||
170
+			! isset($this->_mappings[$old_table][$new_table])) {
171 171
 			//try fetching the option
172 172
 			$this->_mappings[$old_table][$new_table] = $this->_get_mapping_option($old_table, $new_table);
173 173
 		}
@@ -184,15 +184,15 @@  discard block
 block discarded – undo
184 184
 	 * @param mixed $new_pk
185 185
 	 * @return mixed
186 186
 	 */
187
-	public function get_mapping_old_pk($old_table,$new_table,$new_pk){
188
-		if( ! isset($this->_mappings[$old_table]) ||
189
-			! isset($this->_mappings[$old_table][$new_table])){
187
+	public function get_mapping_old_pk($old_table, $new_table, $new_pk) {
188
+		if ( ! isset($this->_mappings[$old_table]) ||
189
+			! isset($this->_mappings[$old_table][$new_table])) {
190 190
 			//try fetching the option
191 191
 			$this->_mappings[$old_table][$new_table] = $this->_get_mapping_option($old_table, $new_table);
192 192
 		}
193
-		if(isset($this->_mappings[$old_table][$new_table])){
193
+		if (isset($this->_mappings[$old_table][$new_table])) {
194 194
 			$new_pk_to_old_pk = array_flip($this->_mappings[$old_table][$new_table]);
195
-			if(isset($new_pk_to_old_pk[$new_pk])){
195
+			if (isset($new_pk_to_old_pk[$new_pk])) {
196 196
 				return $new_pk_to_old_pk[$new_pk];
197 197
 			}
198 198
 		}
@@ -207,8 +207,8 @@  discard block
 block discarded – undo
207 207
 	 * @param string $new_table_name
208 208
 	 * @return array
209 209
 	 */
210
-	protected function _get_mapping_option($old_table_name,$new_table_name){
211
-		$option =  get_option($this->_get_mapping_option_name($old_table_name, $new_table_name),array());
210
+	protected function _get_mapping_option($old_table_name, $new_table_name) {
211
+		$option = get_option($this->_get_mapping_option_name($old_table_name, $new_table_name), array());
212 212
 		return $option;
213 213
 	}
214 214
 
@@ -221,9 +221,9 @@  discard block
 block discarded – undo
221 221
 	 * @param array $mapping_array
222 222
 	 * @return boolean success of updating option
223 223
 	 */
224
-	protected function _set_mapping_option($old_table_name,$new_table_name,$mapping_array){
224
+	protected function _set_mapping_option($old_table_name, $new_table_name, $mapping_array) {
225 225
 //		echo "set mapping for $old_table_name $new_table_name".count($mapping_array)."<br>";
226
-		$success =  update_option($this->_get_mapping_option_name($old_table_name, $new_table_name),$mapping_array);
226
+		$success = update_option($this->_get_mapping_option_name($old_table_name, $new_table_name), $mapping_array);
227 227
 		return $success;
228 228
 	}
229 229
 
@@ -235,12 +235,12 @@  discard block
 block discarded – undo
235 235
 	 * @param string $new_table_name
236 236
 	 * @return string
237 237
 	 */
238
-	protected function _get_mapping_option_name($old_table_name,$new_table_name){
238
+	protected function _get_mapping_option_name($old_table_name, $new_table_name) {
239 239
 		global $wpdb;
240
-		$old_table_name_sans_wp = str_replace($wpdb->prefix,"",$old_table_name);
241
-		$new_table_name_sans_wp = str_replace($wpdb->prefix,"",$new_table_name);
240
+		$old_table_name_sans_wp = str_replace($wpdb->prefix, "", $old_table_name);
241
+		$new_table_name_sans_wp = str_replace($wpdb->prefix, "", $new_table_name);
242 242
 		$migrates_to = EE_Data_Migration_Manager::instance()->script_migrates_to_version(get_class($this));
243
-		return substr( EE_Data_Migration_Manager::data_migration_script_mapping_option_prefix . $migrates_to [ 'slug' ] . '_' . $migrates_to[ 'version' ] . '_' . $old_table_name_sans_wp . '_' . $new_table_name_sans_wp, 0, 64 );
243
+		return substr(EE_Data_Migration_Manager::data_migration_script_mapping_option_prefix.$migrates_to ['slug'].'_'.$migrates_to['version'].'_'.$old_table_name_sans_wp.'_'.$new_table_name_sans_wp, 0, 64);
244 244
 	}
245 245
 
246 246
 
@@ -257,10 +257,10 @@  discard block
 block discarded – undo
257 257
 	 * 99% until the function "migration_step" returns EE_Data_Migration_Script_Base::status_complete.
258 258
 	 * @return int
259 259
 	 */
260
-	protected function _count_records_to_migrate(){
260
+	protected function _count_records_to_migrate() {
261 261
 		$count = 0;
262
-		foreach($this->stages() as $stage){
263
-			$count+= $stage->count_records_to_migrate();
262
+		foreach ($this->stages() as $stage) {
263
+			$count += $stage->count_records_to_migrate();
264 264
 		}
265 265
 		return $count;
266 266
 	}
@@ -272,10 +272,10 @@  discard block
 block discarded – undo
272 272
 	 * by just setting a transient and updating it after each migration_step
273 273
 	 * @return int
274 274
 	 */
275
-	public function count_records_migrated(){
275
+	public function count_records_migrated() {
276 276
 		$count = 0;
277
-		foreach($this->stages() as $stage){
278
-			$count+= $stage->count_records_migrated();
277
+		foreach ($this->stages() as $stage) {
278
+			$count += $stage->count_records_migrated();
279 279
 		}
280 280
 		$this->_records_migrated = $count;
281 281
 		return $count;
@@ -289,24 +289,24 @@  discard block
 block discarded – undo
289 289
 	 * @throws EE_Error
290 290
 	 * @throws Exception
291 291
 	 */
292
-	public function migration_step($num_records_to_migrate_limit){
292
+	public function migration_step($num_records_to_migrate_limit) {
293 293
 		//reset the feedback message
294 294
 		$this->_feedback_message = '';
295 295
 		//if we haven't yet done the 1st schema changes, do them now. buffer any output
296 296
 		$this->_maybe_do_schema_changes(true);
297 297
 
298
-		$num_records_actually_migrated =0;
298
+		$num_records_actually_migrated = 0;
299 299
 		$records_migrated_per_stage = array();
300 300
 		//setup the 'stage' variable, which should hold the last run stage of the migration  (or none at all if nothing runs)
301 301
 		$stage = null;
302 302
 		//get the next stage that isn't complete
303
-		foreach($this->stages() as $stage){
304
-			if( $stage->get_status() == EE_Data_Migration_Manager::status_continue){
305
-				try{
303
+		foreach ($this->stages() as $stage) {
304
+			if ($stage->get_status() == EE_Data_Migration_Manager::status_continue) {
305
+				try {
306 306
 					$records_migrated_during_stage = $stage->migration_step($num_records_to_migrate_limit - $num_records_actually_migrated);
307 307
 					$num_records_actually_migrated += $records_migrated_during_stage;
308 308
 					$records_migrated_per_stage[$stage->pretty_name()] = $records_migrated_during_stage;
309
-				}catch(Exception $e){
309
+				} catch (Exception $e) {
310 310
 					//yes if we catch an exception here, we consider that migration stage borked.
311 311
 					$stage->set_status(EE_Data_Migration_Manager::status_fatal_error);
312 312
 					$this->set_status(EE_Data_Migration_Manager::status_fatal_error);
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 					throw $e;
315 315
 				}
316 316
 				//check that the migration stage didn't mark itself as having a fatal error
317
-				if($stage->is_broken()){
317
+				if ($stage->is_broken()) {
318 318
 					$this->set_broken();
319 319
 					throw new EE_Error($stage->get_last_error());
320 320
 				}
@@ -322,24 +322,24 @@  discard block
 block discarded – undo
322 322
 			//once we've migrated all the number we intended to (possibly from different stages), stop migrating
323 323
 			//or if we had a fatal error
324 324
 			//or if the current script stopped early- its not done, but it's done all it thinks we should do on this step
325
-			if ($num_records_actually_migrated >= $num_records_to_migrate_limit || $stage->is_broken() || $stage->has_more_to_do()){
325
+			if ($num_records_actually_migrated >= $num_records_to_migrate_limit || $stage->is_broken() || $stage->has_more_to_do()) {
326 326
 				break;
327 327
 			}
328 328
 		}
329 329
 		//check if we're all done this data migration...
330 330
 		//which is indicated by being done early AND the last stage claims to be done
331
-		if($stage == NULL){
331
+		if ($stage == NULL) {
332 332
 			//this migration script apparently has NO stages... which is super weird, but whatever
333 333
 			$this->set_completed();
334 334
 			$this->_maybe_do_schema_changes(false);
335
-		}else if( $num_records_actually_migrated < $num_records_to_migrate_limit && ! $stage->has_more_to_do()){
335
+		} else if ($num_records_actually_migrated < $num_records_to_migrate_limit && ! $stage->has_more_to_do()) {
336 336
 			//apparently we're done, because we couldn't migrate the number we intended to
337 337
 			$this->set_completed();
338 338
 			$this->_update_feedback_message(array_reverse($records_migrated_per_stage));
339 339
 			//do schema changes for after the migration now
340 340
 			//first double-check we haven't already done this
341 341
 			$this->_maybe_do_schema_changes(false);
342
-		}else{
342
+		} else {
343 343
 			//update feedback message, keeping in mind that we show them with the most recent at the top
344 344
 			$this->_update_feedback_message(array_reverse($records_migrated_per_stage));
345 345
 		}
@@ -353,12 +353,12 @@  discard block
 block discarded – undo
353 353
 	 * @param array $records_migrated_per_stage KEYS are pretty names for each stage; values are the count of records migrated from that stage
354 354
 	 * @return void
355 355
 	 */
356
-	private function _update_feedback_message($records_migrated_per_stage){
356
+	private function _update_feedback_message($records_migrated_per_stage) {
357 357
 		$feedback_message_array = array();
358
-		foreach($records_migrated_per_stage as $migration_stage_name => $num_records_migrated){
359
-			$feedback_message_array[] = sprintf(__("Migrated %d records successfully during %s", "event_espresso"),$num_records_migrated,$migration_stage_name) ;
358
+		foreach ($records_migrated_per_stage as $migration_stage_name => $num_records_migrated) {
359
+			$feedback_message_array[] = sprintf(__("Migrated %d records successfully during %s", "event_espresso"), $num_records_migrated, $migration_stage_name);
360 360
 		}
361
-		$this->_feedback_message .= implode("<br>",$feedback_message_array);
361
+		$this->_feedback_message .= implode("<br>", $feedback_message_array);
362 362
 	}
363 363
 
364 364
 
@@ -370,27 +370,27 @@  discard block
 block discarded – undo
370 370
 	 * @throws Exception
371 371
 	 * @return void
372 372
 	 */
373
-	private function _maybe_do_schema_changes($before = true){
373
+	private function _maybe_do_schema_changes($before = true) {
374 374
 		//so this property will be either _schema_changes_after_migration_ran or _schema_changes_before_migration_ran
375
-		$property_name = '_schema_changes_'. ($before ? 'before' : 'after').'_migration_ran';
376
-		if ( ! $this->{$property_name} ){
377
-			try{
375
+		$property_name = '_schema_changes_'.($before ? 'before' : 'after').'_migration_ran';
376
+		if ( ! $this->{$property_name} ) {
377
+			try {
378 378
 				ob_start();
379
-				if($before){
379
+				if ($before) {
380 380
 					$this->schema_changes_before_migration();
381
-				}else{
381
+				} else {
382 382
 					$this->schema_changes_after_migration();
383 383
 				}
384 384
 				$output = ob_get_contents();
385 385
 				ob_end_clean();
386
-			}catch(Exception $e){
386
+			} catch (Exception $e) {
387 387
 				$this->set_status(EE_Data_Migration_Manager::status_fatal_error);
388 388
 				throw $e;
389 389
 			}
390 390
 			//record that we've done these schema changes
391 391
 			$this->{$property_name} = true;
392 392
 			//if there were any warnings etc, record them as non-fatal errors
393
-			if( $output ){
393
+			if ($output) {
394 394
 				//there were some warnings
395 395
 				$this->_errors[] = $output;
396 396
 			}
@@ -417,9 +417,9 @@  discard block
 block discarded – undo
417 417
 	 * @param string $table_definition_sql
418 418
 	 * @param string $engine_string
419 419
 	 */
420
-	protected function _table_is_new_in_this_version($table_name,$table_definition_sql,$engine_string='ENGINE=InnoDB '){
420
+	protected function _table_is_new_in_this_version($table_name, $table_definition_sql, $engine_string = 'ENGINE=InnoDB ') {
421 421
 //		EEH_Debug_Tools::instance()->start_timer( '_table_is_new_in_this_version_' . $table_name );
422
-		$this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped(  true ) );
422
+		$this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped(true));
423 423
 //		EEH_Debug_Tools::instance()->stop_timer( '_table_is_new_in_this_version_' . $table_name  );
424 424
 	}
425 425
 
@@ -433,9 +433,9 @@  discard block
 block discarded – undo
433 433
 	 * @param string $table_definition_sql
434 434
 	 * @param string $engine_string
435 435
 	 */
436
-	protected function _table_is_changed_in_this_version($table_name,$table_definition_sql,$engine_string = 'ENGINE=MyISAM'){
436
+	protected function _table_is_changed_in_this_version($table_name, $table_definition_sql, $engine_string = 'ENGINE=MyISAM') {
437 437
 //		EEH_Debug_Tools::instance()->start_timer( '_table_is_changed_in_this_version' . $table_name );
438
-		$this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped(  false ) );
438
+		$this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped(false));
439 439
 //		EEH_Debug_Tools::instance()->stop_timer( '_table_is_changed_in_this_version' . $table_name  );
440 440
 	}
441 441
 
@@ -446,8 +446,8 @@  discard block
 block discarded – undo
446 446
 	 * @param string $table_name
447 447
 	 * @return boolean
448 448
 	 */
449
-	protected function _old_table_exists( $table_name ) {
450
-		return EEH_Activation::table_exists( $table_name );
449
+	protected function _old_table_exists($table_name) {
450
+		return EEH_Activation::table_exists($table_name);
451 451
 	}
452 452
 
453 453
 
@@ -457,8 +457,8 @@  discard block
 block discarded – undo
457 457
 	 * @param string $table_name
458 458
 	 * @return boolean
459 459
 	 */
460
-	protected function _delete_table_if_empty( $table_name ) {
461
-		return EEH_Activation::delete_db_table_if_empty( $table_name );
460
+	protected function _delete_table_if_empty($table_name) {
461
+		return EEH_Activation::delete_db_table_if_empty($table_name);
462 462
 	}
463 463
 
464 464
 
@@ -477,9 +477,9 @@  discard block
 block discarded – undo
477 477
 	 * @param string $table_definition_sql
478 478
 	 * @param string $engine_string
479 479
 	 */
480
-	protected function _table_should_exist_previously($table_name,$table_definition_sql,$engine_string = 'ENGINE=MyISAM'){
480
+	protected function _table_should_exist_previously($table_name, $table_definition_sql, $engine_string = 'ENGINE=MyISAM') {
481 481
 //		EEH_Debug_Tools::instance()->start_timer( '_table_should_exist_previously' . $table_name );
482
-		$this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped(  false ) );
482
+		$this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped(false));
483 483
 //		EEH_Debug_Tools::instance()->stop_timer( '_table_should_exist_previously' . $table_name );
484 484
 	}
485 485
 
@@ -494,13 +494,13 @@  discard block
 block discarded – undo
494 494
 	 * @param string $table_definition_sql
495 495
 	 * @param string $engine_string
496 496
 	 */
497
-	protected function _table_has_not_changed_since_previous( $table_name,$table_definition_sql,$engine_string = 'ENGINE=MyISAM'){
498
-		if( $this->_currently_migrating() ) {
497
+	protected function _table_has_not_changed_since_previous($table_name, $table_definition_sql, $engine_string = 'ENGINE=MyISAM') {
498
+		if ($this->_currently_migrating()) {
499 499
 			//if we're doing a migration, and this table apparently already exists, then we don't need do anything right?
500 500
 //			EEH_Debug_Tools::instance()->stop_timer( '_table_should_exist_previously' . $table_name );
501 501
 			return;
502 502
 		}
503
-		$this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped(  false ) );
503
+		$this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped(false));
504 504
 	}
505 505
 
506 506
 	/**
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
 	protected function _currently_migrating() {
511 511
 		//we want to know if we are currently performing a migration. We could just believe what was set on the _migrating property, but let's double-check (ie the script should apply and we should be in MM)
512 512
 		return $this->_migrating &&
513
-					$this->can_migrate_from_version( EE_Data_Migration_Manager::instance()->ensure_current_database_state_is_set() ) &&
513
+					$this->can_migrate_from_version(EE_Data_Migration_Manager::instance()->ensure_current_database_state_is_set()) &&
514 514
 					EE_Maintenance_Mode::instance()->real_level() == EE_Maintenance_Mode::level_2_complete_maintenance;
515 515
 	}
516 516
 
@@ -521,17 +521,17 @@  discard block
 block discarded – undo
521 521
 	 * @param boolean $table_is_new
522 522
 	 * @return boolean
523 523
 	 */
524
-	protected function _pre_existing_table_should_be_dropped( $table_is_new ) {
525
-		if( $table_is_new ) {
526
-			if( $this->_get_req_type_for_plugin_corresponding_to_this_dms() == EE_System::req_type_new_activation  || $this->_currently_migrating() ){
524
+	protected function _pre_existing_table_should_be_dropped($table_is_new) {
525
+		if ($table_is_new) {
526
+			if ($this->_get_req_type_for_plugin_corresponding_to_this_dms() == EE_System::req_type_new_activation || $this->_currently_migrating()) {
527 527
 				return true;
528
-			}else{
528
+			} else {
529 529
 				return false;
530 530
 			}
531
-		}else{
532
-			if(in_array($this->_get_req_type_for_plugin_corresponding_to_this_dms(),array(EE_System::req_type_new_activation))){
531
+		} else {
532
+			if (in_array($this->_get_req_type_for_plugin_corresponding_to_this_dms(), array(EE_System::req_type_new_activation))) {
533 533
 				return true;
534
-			}else{
534
+			} else {
535 535
 				return false;
536 536
 			}
537 537
 		}
@@ -544,12 +544,12 @@  discard block
 block discarded – undo
544 544
 	 * @param string $engine_string
545 545
 	 * @param boolean $drop_pre_existing_tables
546 546
 	 */
547
-	private function _create_table_and_catch_errors( $table_name, $table_definition_sql, $engine_string = 'ENGINE=MyISAM', $drop_pre_existing_tables = FALSE ){
548
-		try{
549
-			EEH_Activation::create_table($table_name,$table_definition_sql, $engine_string, $drop_pre_existing_tables);
550
-		}catch( EE_Error $e ) {
551
-			$message = $e->getMessage() . '<br>Stack Trace:' . $e->getTraceAsString();
552
-			$this->add_error( $message  );
547
+	private function _create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string = 'ENGINE=MyISAM', $drop_pre_existing_tables = FALSE) {
548
+		try {
549
+			EEH_Activation::create_table($table_name, $table_definition_sql, $engine_string, $drop_pre_existing_tables);
550
+		} catch (EE_Error $e) {
551
+			$message = $e->getMessage().'<br>Stack Trace:'.$e->getTraceAsString();
552
+			$this->add_error($message);
553 553
 			$this->_feedback_message .= $message;
554 554
 		}
555 555
 	}
@@ -561,15 +561,15 @@  discard block
 block discarded – undo
561 561
 	 * @return int one of EE_System::_req_type_* constants
562 562
 	 * @throws EE_Error
563 563
 	 */
564
-	private function _get_req_type_for_plugin_corresponding_to_this_dms(){
565
-		if($this->slug() == 'Core'){
564
+	private function _get_req_type_for_plugin_corresponding_to_this_dms() {
565
+		if ($this->slug() == 'Core') {
566 566
 			return EE_System::instance()->detect_req_type();
567
-		}else{//it must be for an addon
567
+		} else {//it must be for an addon
568 568
 			$addon_name = $this->slug();
569
-			if( EE_Registry::instance()->get_addon_by_name($addon_name)){
569
+			if (EE_Registry::instance()->get_addon_by_name($addon_name)) {
570 570
 				return EE_Registry::instance()->get_addon_by_name($addon_name)->detect_req_type();
571
-			}else{
572
-				throw new EE_Error(sprintf(__("The DMS slug '%s' should correspond to the addon's name, which should also be '%s', but no such addon was registered. These are the registered addons' names: %s", "event_espresso"),$this->slug(),$addon_name,implode(",",array_keys( EE_Registry::instance()->get_addons_by_name() ) ) ) ) ;
571
+			} else {
572
+				throw new EE_Error(sprintf(__("The DMS slug '%s' should correspond to the addon's name, which should also be '%s', but no such addon was registered. These are the registered addons' names: %s", "event_espresso"), $this->slug(), $addon_name, implode(",", array_keys(EE_Registry::instance()->get_addons_by_name()))));
573 573
 			}
574 574
 		}
575 575
 	}
@@ -580,13 +580,13 @@  discard block
 block discarded – undo
580 580
 	 * returns an array of strings describing errors by all the script's stages
581 581
 	 * @return array
582 582
 	 */
583
-	public function get_errors(){
583
+	public function get_errors() {
584 584
 		$all_errors = $this->_errors;
585
-		if( ! is_array($all_errors)){
585
+		if ( ! is_array($all_errors)) {
586 586
 			$all_errors = array();
587 587
 		}
588
-		foreach($this->stages() as $stage){
589
-			$all_errors = array_merge($stage->get_errors(),$all_errors);
588
+		foreach ($this->stages() as $stage) {
589
+			$all_errors = array_merge($stage->get_errors(), $all_errors);
590 590
 		}
591 591
 		return $all_errors;
592 592
 	}
@@ -597,8 +597,8 @@  discard block
 block discarded – undo
597 597
 	 * Indicates whether or not this migration script should continue
598 598
 	 * @return boolean
599 599
 	 */
600
-	public function can_continue(){
601
-		return in_array($this->get_status(),  EE_Data_Migration_Manager::instance()->stati_that_indicate_to_continue_single_migration_script);
600
+	public function can_continue() {
601
+		return in_array($this->get_status(), EE_Data_Migration_Manager::instance()->stati_that_indicate_to_continue_single_migration_script);
602 602
 	}
603 603
 
604 604
 
@@ -610,8 +610,8 @@  discard block
 block discarded – undo
610 610
 	 * get ordered by the indexes
611 611
 	 * @return EE_Data_Migration_Script_Stage[]
612 612
 	 */
613
-	protected function stages(){
614
-		$stages = apply_filters( 'FHEE__'.get_class($this).'__stages',$this->_migration_stages );
613
+	protected function stages() {
614
+		$stages = apply_filters('FHEE__'.get_class($this).'__stages', $this->_migration_stages);
615 615
 		ksort($stages);
616 616
 		return $stages;
617 617
 	}
@@ -623,7 +623,7 @@  discard block
 block discarded – undo
623 623
 	 * can be displayed to the user
624 624
 	 * @return string
625 625
 	 */
626
-	public function get_feedback_message(){
626
+	public function get_feedback_message() {
627 627
 		return $this->_feedback_message;
628 628
 	}
629 629
 
@@ -635,16 +635,16 @@  discard block
 block discarded – undo
635 635
 	 * possible that this class is defined when it goes to sleep, but NOT available when it
636 636
 	 * awakes (eg, this class is part of an addon that is deactivated at some point).
637 637
 	 */
638
-	public function properties_as_array(){
638
+	public function properties_as_array() {
639 639
 		$properties = parent::properties_as_array();
640 640
 		$properties['_migration_stages'] = array();
641
-		foreach($this->_migration_stages as $migration_stage_priority => $migration_stage_class){
641
+		foreach ($this->_migration_stages as $migration_stage_priority => $migration_stage_class) {
642 642
 			$properties['_migration_stages'][$migration_stage_priority] = $migration_stage_class->properties_as_array();
643 643
 		}
644 644
 		unset($properties['_mappings']);
645 645
 
646
-		foreach($this->_mappings as $old_table_name => $mapping_to_new_table){
647
-			foreach($mapping_to_new_table as $new_table_name => $mapping){
646
+		foreach ($this->_mappings as $old_table_name => $mapping_to_new_table) {
647
+			foreach ($mapping_to_new_table as $new_table_name => $mapping) {
648 648
 				$this->_set_mapping_option($old_table_name, $new_table_name, $mapping);
649 649
 			}
650 650
 		}
@@ -659,19 +659,19 @@  discard block
 block discarded – undo
659 659
 	 * @param array $array_of_properties like what's produced from properties_as_array() method
660 660
 	 * @return void
661 661
 	 */
662
-	public function instantiate_from_array_of_properties($array_of_properties){
662
+	public function instantiate_from_array_of_properties($array_of_properties) {
663 663
 		$stages_properties_arrays = $array_of_properties['_migration_stages'];
664 664
 		unset($array_of_properties['_migration_stages']);
665 665
 		unset($array_of_properties['class']);
666
-		foreach($array_of_properties as $property_name => $property_value){
666
+		foreach ($array_of_properties as $property_name => $property_value) {
667 667
 			$this->{$property_name} = $property_value;
668 668
 		}
669 669
 		//_migration_stages are already instantiated, but have only default data
670
-		foreach($this->_migration_stages as $stage){
671
-			$stage_data = $this->_find_migration_stage_data_with_classname(get_class($stage),$stages_properties_arrays);
670
+		foreach ($this->_migration_stages as $stage) {
671
+			$stage_data = $this->_find_migration_stage_data_with_classname(get_class($stage), $stages_properties_arrays);
672 672
 			//SO, if we found the stage data that was saved, use it. Otherwise, I guess the stage is new? (maybe added by
673 673
 			//an addon? Unlikely... not sure why it wouldn't exist, but if it doesn't just treat it like it was never started yet)
674
-			if($stage_data){
674
+			if ($stage_data) {
675 675
 				$stage->instantiate_from_array_of_properties($stage_data);
676 676
 			}
677 677
 		}
@@ -687,9 +687,9 @@  discard block
 block discarded – undo
687 687
 	 * @param array $migration_stage_data_arrays
688 688
 	 * @return null
689 689
 	 */
690
-	private function _find_migration_stage_data_with_classname($classname,$migration_stage_data_arrays){
691
-		foreach($migration_stage_data_arrays as $migration_stage_data_array){
692
-			if(isset($migration_stage_data_array['class']) && $migration_stage_data_array['class'] == $classname){
690
+	private function _find_migration_stage_data_with_classname($classname, $migration_stage_data_arrays) {
691
+		foreach ($migration_stage_data_arrays as $migration_stage_data_array) {
692
+			if (isset($migration_stage_data_array['class']) && $migration_stage_data_array['class'] == $classname) {
693 693
 				return $migration_stage_data_array;
694 694
 			}
695 695
 		}
@@ -705,8 +705,8 @@  discard block
 block discarded – undo
705 705
 	 * @return array where the first key is the plugin's slug, the 2nd is the version of that plugin
706 706
 	 * that will be updated to. Eg array('Core','4.1.0')
707 707
 	 */
708
-	public final function migrates_to_version(){
709
-		return EE_Data_Migration_Manager::instance()->script_migrates_to_version( get_class( $this ) );
708
+	public final function migrates_to_version() {
709
+		return EE_Data_Migration_Manager::instance()->script_migrates_to_version(get_class($this));
710 710
 	}
711 711
 
712 712
 
@@ -718,10 +718,10 @@  discard block
 block discarded – undo
718 718
 	 * Or 'Core' for core (non-addon).
719 719
 	 * @return string
720 720
 	 */
721
-	public function slug(){
721
+	public function slug() {
722 722
 		$migrates_to_version_info = $this->migrates_to_version();
723 723
 		//the slug is the first part of the array
724
-		return $migrates_to_version_info[ 'slug' ];
724
+		return $migrates_to_version_info['slug'];
725 725
 	}
726 726
 
727 727
 
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
 	 * the database up so it can run), then you can set "A" to priority 3 or something.
736 736
 	 * @return int
737 737
 	 */
738
-	public function priority(){
738
+	public function priority() {
739 739
 		return $this->_priority;
740 740
 	}
741 741
 
@@ -748,18 +748,18 @@  discard block
 block discarded – undo
748 748
 	 * @param boolean $migrating
749 749
 	 * @return void
750 750
 	 */
751
-	public function set_migrating( $migrating = TRUE ){
751
+	public function set_migrating($migrating = TRUE) {
752 752
 		$this->_migrating = $migrating;
753 753
 	}
754 754
 
755 755
 	/**
756 756
 	 * Marks that we think this migration class can continue to migrate
757 757
 	 */
758
-	public function reattempt(){
758
+	public function reattempt() {
759 759
 		parent::reattempt();
760 760
 		//also, we want to reattempt any stages that were marked as borked
761
-		foreach( $this->stages() as $stage ) {
762
-			if( $stage->is_broken() ) {
761
+		foreach ($this->stages() as $stage) {
762
+			if ($stage->is_broken()) {
763 763
 				$stage->reattempt();
764 764
 			}
765 765
 		}
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_DMS_Core_4_7_0.dms.php 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -14,13 +14,13 @@  discard block
 block discarded – undo
14 14
 // (all other times it gets resurrected from a wordpress option)
15 15
 $stages = glob(EE_CORE.'data_migration_scripts/4_7_0_stages/*');
16 16
 $class_to_filepath = array();
17
-foreach($stages as $filepath){
17
+foreach ($stages as $filepath) {
18 18
 	$matches = array();
19
-	preg_match('~4_7_0_stages/(.*).dmsstage.php~',$filepath,$matches);
19
+	preg_match('~4_7_0_stages/(.*).dmsstage.php~', $filepath, $matches);
20 20
 	$class_to_filepath[$matches[1]] = $filepath;
21 21
 }
22 22
 //give addons a chance to autoload their stages too
23
-$class_to_filepath = apply_filters('FHEE__EE_DMS_4_7_0__autoloaded_stages',$class_to_filepath);
23
+$class_to_filepath = apply_filters('FHEE__EE_DMS_4_7_0__autoloaded_stages', $class_to_filepath);
24 24
 EEH_Autoloader::register_autoloader($class_to_filepath);
25 25
 
26 26
 
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
  * @since                4.7.0
37 37
  *
38 38
  */
39
-class EE_DMS_Core_4_7_0 extends EE_Data_Migration_Script_Base{
39
+class EE_DMS_Core_4_7_0 extends EE_Data_Migration_Script_Base {
40 40
 
41 41
 	/**
42 42
 	 * return EE_DMS_Core_4_7_0
@@ -60,15 +60,15 @@  discard block
 block discarded – undo
60 60
 	public function can_migrate_from_version($version_array) {
61 61
 		$version_string = $version_array['Core'];
62 62
 		if (
63
-			( $version_string <= '4.7.0' && $version_string >= '4.6.0' )
63
+			($version_string <= '4.7.0' && $version_string >= '4.6.0')
64 64
 			||
65
-			( $version_string >= '4.7.0' &&
66
-					! EEH_Activation::table_exists( 'esp_registration_payment' ) &&
67
-					EEH_Activation::table_exists( 'esp_registration' ) ) ) {
65
+			($version_string >= '4.7.0' &&
66
+					! EEH_Activation::table_exists('esp_registration_payment') &&
67
+					EEH_Activation::table_exists('esp_registration')) ) {
68 68
 			return true;
69
-		} elseif ( ! $version_string ) {
69
+		} elseif ( ! $version_string) {
70 70
 			//no version string provided... this must be pre 4.3
71
-			return false;//changed mind. dont want people thinking they should migrate yet because they cant
71
+			return false; //changed mind. dont want people thinking they should migrate yet because they cant
72 72
 		} else {
73 73
 			return false;
74 74
 		}
@@ -90,16 +90,16 @@  discard block
 block discarded – undo
90 90
 	 */
91 91
 	public function schema_changes_before_migration() {
92 92
 		//relies on 4.1's EEH_Activation::create_table
93
-		require_once( EE_HELPERS . 'EEH_Activation.helper.php' );
94
-		$table_name='esp_answer';
95
-		$sql=" ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
93
+		require_once(EE_HELPERS.'EEH_Activation.helper.php');
94
+		$table_name = 'esp_answer';
95
+		$sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
96 96
 					REG_ID INT UNSIGNED NOT NULL,
97 97
 					QST_ID INT UNSIGNED NOT NULL,
98 98
 					ANS_value TEXT NOT NULL,
99 99
 					PRIMARY KEY  (ANS_ID),
100 100
 					KEY REG_ID (REG_ID),
101 101
 					KEY QST_ID (QST_ID)";
102
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
102
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
103 103
 
104 104
 		$table_name = 'esp_attendee_meta';
105 105
 		$sql = "ATTM_ID INT(10) UNSIGNED NOT	NULL AUTO_INCREMENT,
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 					  CNT_is_EU TINYINT(1) DEFAULT '0',
140 140
 					  CNT_active TINYINT(1) DEFAULT '0',
141 141
 					  PRIMARY KEY  (CNT_ISO)";
142
-		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB' );
142
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
143 143
 
144 144
 		$table_name = 'esp_currency';
145 145
 		$sql = "CUR_code VARCHAR(6) COLLATE utf8_bin NOT NULL,
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 				CUR_dec_plc VARCHAR(1) COLLATE utf8_bin NOT NULL DEFAULT '2',
150 150
 				CUR_active TINYINT(1) DEFAULT '0',
151 151
 				PRIMARY KEY  (CUR_code)";
152
-		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB' );
152
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
153 153
 
154 154
 
155 155
 		$table_name = 'esp_currency_payment_method';
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 						KEY EVT_ID (EVT_ID),
180 180
 						KEY DTT_is_primary (DTT_is_primary)";
181 181
 
182
-		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB' );
182
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
183 183
 
184 184
 		$table_name = 'esp_event_meta';
185 185
 		$sql = "
@@ -198,44 +198,44 @@  discard block
 block discarded – undo
198 198
 			EVT_donations TINYINT(1) NULL,
199 199
 			PRIMARY KEY  (EVTM_ID),
200 200
 			KEY EVT_ID (EVT_ID)";
201
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
201
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
202 202
 
203 203
 
204 204
 
205
-		$table_name='esp_event_question_group';
206
-		$sql="EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
205
+		$table_name = 'esp_event_question_group';
206
+		$sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
207 207
 					EVT_ID BIGINT(20) UNSIGNED NOT NULL,
208 208
 					QSG_ID INT UNSIGNED NOT NULL,
209 209
 					EQG_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
210 210
 					PRIMARY KEY  (EQG_ID),
211 211
 					KEY EVT_ID (EVT_ID),
212 212
 					KEY QSG_ID (QSG_ID)";
213
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
213
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
214 214
 
215 215
 
216 216
 
217
-		$table_name='esp_event_venue';
218
-		$sql="EVV_ID INT(11) NOT NULL AUTO_INCREMENT,
217
+		$table_name = 'esp_event_venue';
218
+		$sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT,
219 219
 				EVT_ID BIGINT(20) UNSIGNED NOT NULL,
220 220
 				VNU_ID BIGINT(20) UNSIGNED NOT NULL,
221 221
 				EVV_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
222 222
 				PRIMARY KEY  (EVV_ID)";
223
-		$this->_table_has_not_changed_since_previous($table_name,$sql, 'ENGINE=InnoDB');
223
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
224 224
 
225 225
 
226 226
 
227
-		$table_name='esp_extra_meta';
228
-		$sql="EXM_ID INT(11) NOT NULL AUTO_INCREMENT,
227
+		$table_name = 'esp_extra_meta';
228
+		$sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT,
229 229
 				OBJ_ID INT(11) DEFAULT NULL,
230 230
 				EXM_type VARCHAR(45) DEFAULT NULL,
231 231
 				EXM_key VARCHAR(45) DEFAULT NULL,
232 232
 				EXM_value TEXT,
233 233
 				PRIMARY KEY  (EXM_ID),
234 234
 				KEY EXM_type (EXM_type, OBJ_ID, EXM_key(45))";
235
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
235
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
236 236
 
237
-		$table_name='esp_line_item';
238
-		$sql="LIN_ID INT(11) NOT NULL AUTO_INCREMENT,
237
+		$table_name = 'esp_line_item';
238
+		$sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT,
239 239
 				LIN_code VARCHAR(245) NOT NULL DEFAULT '',
240 240
 				TXN_ID INT(11) DEFAULT NULL,
241 241
 				LIN_name VARCHAR(245) NOT NULL DEFAULT '',
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 				PRIMARY KEY  (LIN_ID),
254 254
 				KEY LIN_code (LIN_code(191)),
255 255
 				KEY TXN_ID (TXN_ID)";
256
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB' );
256
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
257 257
 
258 258
 		$table_name = 'esp_log';
259 259
 		$sql = "LOG_ID INT(11) NOT NULL AUTO_INCREMENT,
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 					MTP_is_active TINYINT(1) NOT NULL DEFAULT '1',
294 294
 					PRIMARY KEY  (GRP_ID),
295 295
 					KEY MTP_user_id (MTP_user_id)";
296
-		$this->_table_has_not_changed_since_previous( $table_name, $sql, 'ENGINE=InnoDB');
296
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
297 297
 
298 298
 		$table_name = 'esp_event_message_template';
299 299
 		$sql = "EMT_ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 					PRIMARY KEY  (EMT_ID),
303 303
 					KEY EVT_ID (EVT_ID),
304 304
 					KEY GRP_ID (GRP_ID)";
305
-		$this->_table_has_not_changed_since_previous( $table_name, $sql, 'ENGINE=InnoDB');
305
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
306 306
 
307 307
 
308 308
 		$table_name = 'esp_payment';
@@ -375,8 +375,8 @@  discard block
 block discarded – undo
375 375
 					  PRIMARY KEY  (TTM_ID)";
376 376
 		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
377 377
 
378
-		$table_name='esp_question';
379
-		$sql='QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
378
+		$table_name = 'esp_question';
379
+		$sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
380 380
 					QST_display_text TEXT NOT NULL,
381 381
 					QST_admin_label VARCHAR(255) NOT NULL,
382 382
 					QST_system VARCHAR(25) DEFAULT NULL,
@@ -389,22 +389,22 @@  discard block
 block discarded – undo
389 389
 					QST_deleted TINYINT UNSIGNED NOT NULL DEFAULT 0,
390 390
 					PRIMARY KEY  (QST_ID),
391 391
 					KEY QST_order (QST_order)';
392
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
392
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
393 393
 
394
-		$table_name='esp_question_group_question';
395
-		$sql="QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
394
+		$table_name = 'esp_question_group_question';
395
+		$sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
396 396
 					QSG_ID INT UNSIGNED NOT NULL,
397 397
 					QST_ID INT UNSIGNED NOT NULL,
398 398
 					QGQ_order INT UNSIGNED NOT NULL DEFAULT 0,
399 399
 					PRIMARY KEY  (QGQ_ID),
400 400
 					KEY QST_ID (QST_ID),
401 401
 					KEY QSG_ID_order (QSG_ID, QGQ_order)";
402
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
402
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
403 403
 
404 404
 
405 405
 
406
-		$table_name='esp_question_option';
407
-		$sql="QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
406
+		$table_name = 'esp_question_option';
407
+		$sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
408 408
 					QSO_value VARCHAR(255) NOT NULL,
409 409
 					QSO_desc TEXT NOT NULL,
410 410
 					QST_ID INT UNSIGNED NOT NULL,
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
 					PRIMARY KEY  (QSO_ID),
414 414
 					KEY QST_ID (QST_ID),
415 415
 					KEY QSO_order (QSO_order)";
416
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
416
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
417 417
 
418 418
 
419 419
 
@@ -459,8 +459,8 @@  discard block
 block discarded – undo
459 459
 
460 460
 
461 461
 
462
-		$table_name='esp_checkin';
463
-		$sql="CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
462
+		$table_name = 'esp_checkin';
463
+		$sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
464 464
 					REG_ID INT(10) UNSIGNED NOT NULL,
465 465
 					DTT_ID INT(10) UNSIGNED NOT NULL,
466 466
 					CHK_in TINYINT(1) UNSIGNED NOT NULL DEFAULT 1,
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
 					  PRC_parent INT(10) UNSIGNED DEFAULT 0,
556 556
 					  PRIMARY KEY  (PRC_ID),
557 557
 					  KEY PRT_ID (PRT_ID)";
558
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
558
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
559 559
 
560 560
 		$table_name = "esp_price_type";
561 561
 		$sql = "PRT_ID TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT,
@@ -593,10 +593,10 @@  discard block
 block discarded – undo
593 593
 					  TKT_deleted TINYINT(1) NOT NULL DEFAULT '0',
594 594
 					  PRIMARY KEY  (TKT_ID),
595 595
 					  KEY TKT_start_date (TKT_start_date)";
596
-		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB' );
596
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
597 597
 
598 598
 		$table_name = 'esp_question_group';
599
-		$sql='QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
599
+		$sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
600 600
 					QSG_name VARCHAR(255) NOT NULL,
601 601
 					QSG_identifier VARCHAR(100) NOT NULL,
602 602
 					QSG_desc TEXT NULL,
@@ -609,7 +609,7 @@  discard block
 block discarded – undo
609 609
 					PRIMARY KEY  (QSG_ID),
610 610
 					UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier),
611 611
 					KEY QSG_order (QSG_order)';
612
-		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB' );
612
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
613 613
 
614 614
 		/** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */
615 615
 		$script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
@@ -641,7 +641,7 @@  discard block
 block discarded – undo
641 641
 		return true;
642 642
 	}
643 643
 
644
-	public function migration_page_hooks(){
644
+	public function migration_page_hooks() {
645 645
 
646 646
 	}
647 647
 }
Please login to merge, or discard this patch.
4_5_0_stages/EE_DMS_4_5_0_invoice_settings.dmsstage.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 * Just initializes the status of the migration
30 30
 	 */
31 31
 	public function __construct() {
32
-		$this->_pretty_name = __( 'Update Invoice Gateway Settings', 'event_espresso' );
32
+		$this->_pretty_name = __('Update Invoice Gateway Settings', 'event_espresso');
33 33
 		parent::__construct();
34 34
 	}
35 35
 
@@ -56,39 +56,39 @@  discard block
 block discarded – undo
56 56
 	 * @throws EE_Error
57 57
 	 * @return int number of items ACTUALLY migrated
58 58
 	 */
59
-	protected function _migration_step( $num_items = 1 ){
59
+	protected function _migration_step($num_items = 1) {
60 60
 		// if this isn't set then something is really wrong
61
-		if ( ! EE_Config::instance()->gateway instanceof EE_Gateway_Config ) {
62
-			throw new EE_Error( __( 'It appears the Event Espresso Core Configuration is not setup correctly.', 'event_espresso' ));
61
+		if ( ! EE_Config::instance()->gateway instanceof EE_Gateway_Config) {
62
+			throw new EE_Error(__('It appears the Event Espresso Core Configuration is not setup correctly.', 'event_espresso'));
63 63
 		}
64
-		$invoice_settings = isset( EE_Config::instance()->gateway->payment_settings[ 'Invoice' ] ) ? EE_Config::instance()->gateway->payment_settings[ 'Invoice' ] : NULL;
65
-		if( ! $invoice_settings ){
66
-			$this->add_error( __( 'Could not migrate EE4.4 invoice settings to EE4.5 because they didnt exist', 'event_espresso' ) );
67
-		}else{
68
-			$invoice_settings[ 'template_payment_instructions' ] = $invoice_settings[ 'pdf_instructions' ];
69
-			$invoice_settings[ 'template_invoice_payee_name' ] = $invoice_settings[ 'payable_to' ];
70
-			$invoice_settings[ 'template_invoice_address' ] = $invoice_settings[ 'payment_address' ];
71
-			$invoice_settings[ 'template_invoice_email' ] = '';
72
-			$invoice_settings[ 'template_invoice_tax_number' ] = '';
73
-			unset( $invoice_settings[ 'pdf_instructions' ] );
74
-			unset( $invoice_settings[ 'payable_to' ] );
75
-			unset( $invoice_settings[ 'payment_address' ] );
76
-			EE_Config::instance()->gateway->payment_settings[ 'Invoice' ] = $invoice_settings;
77
-			EE_Config::instance()->update_espresso_config(false,false);
64
+		$invoice_settings = isset(EE_Config::instance()->gateway->payment_settings['Invoice']) ? EE_Config::instance()->gateway->payment_settings['Invoice'] : NULL;
65
+		if ( ! $invoice_settings) {
66
+			$this->add_error(__('Could not migrate EE4.4 invoice settings to EE4.5 because they didnt exist', 'event_espresso'));
67
+		} else {
68
+			$invoice_settings['template_payment_instructions'] = $invoice_settings['pdf_instructions'];
69
+			$invoice_settings['template_invoice_payee_name'] = $invoice_settings['payable_to'];
70
+			$invoice_settings['template_invoice_address'] = $invoice_settings['payment_address'];
71
+			$invoice_settings['template_invoice_email'] = '';
72
+			$invoice_settings['template_invoice_tax_number'] = '';
73
+			unset($invoice_settings['pdf_instructions']);
74
+			unset($invoice_settings['payable_to']);
75
+			unset($invoice_settings['payment_address']);
76
+			EE_Config::instance()->gateway->payment_settings['Invoice'] = $invoice_settings;
77
+			EE_Config::instance()->update_espresso_config(false, false);
78 78
 
79 79
 			//@todo: check 'invoice_css' too because we can't easily affect that so we might need to set a persistent notice
80 80
 			//(why is it tough to change? because we want to update the receipt and invoice message template, but
81 81
 			//message templates are only initialized AFTER migrations and those two are new in 4.5. So if we wanted to
82 82
 			//update them from a DMS, we'd need to have the DMS create the message templates which is quite a lot of code;
83 83
 			//also we don't want to build a dependency on the messages code because it is likely to change soon
84
-			if( ! in_array( $invoice_settings[ 'invoice_css' ], array( '', 'simple.css' ) ) ){
85
-				EE_Error::add_persistent_admin_notice( 'invoice_css_not_updated', sprintf( __( 'You had previously set your Invoice Payment Method\'s stylesheet to be %1$s, but that setting has moved. PDF and HTML Invoices and Receipts are now Messages, which means you can easily modify them from your Wordpress Dashboard instead of using filters or uploading template files. Please visit Messages -> Receipt and Messages -> Invoice to change their stylesheets.', 'event_espresso'), $invoice_settings[ 'invoice_css' ] ), FALSE );
84
+			if ( ! in_array($invoice_settings['invoice_css'], array('', 'simple.css'))) {
85
+				EE_Error::add_persistent_admin_notice('invoice_css_not_updated', sprintf(__('You had previously set your Invoice Payment Method\'s stylesheet to be %1$s, but that setting has moved. PDF and HTML Invoices and Receipts are now Messages, which means you can easily modify them from your Wordpress Dashboard instead of using filters or uploading template files. Please visit Messages -> Receipt and Messages -> Invoice to change their stylesheets.', 'event_espresso'), $invoice_settings['invoice_css']), FALSE);
86 86
 			}
87 87
 			$templates_relative_path = 'modules/gateways/Invoice/lib/templates/';
88
-			$overridden_invoice_body = EEH_Template::locate_template( $templates_relative_path . 'invoice_body.template.php', NULL, FALSE, FALSE, TRUE );
89
-			$overridden_receipt_body= EEH_Template::locate_template( $templates_relative_path . 'receipt_body.template.php', NULL, FALSE, FALSE, TRUE );
90
-			if( $overridden_invoice_body || $overridden_receipt_body ) {
91
-				EE_Error::add_persistent_admin_notice( 'invoice_overriding_templates', sprintf( __( 'Note: in this version of Event Espresso, PDF and HTML Invoices and Receipts are now Messages and can be changed just like any other messages; however we noticed you had previously overriden the old default Invoice/Receipt templates. Because of this, your old Invoice/Receipt templates will continue to be used INSTEAD of the new Invoice/Receipt message equivalents. We recommend deleting your old Invoice/Receipt templates and modifying the new Invoice and Receipt messages\'s content in Messages -> Invoice and Messages -> Receipt.')), TRUE );
88
+			$overridden_invoice_body = EEH_Template::locate_template($templates_relative_path.'invoice_body.template.php', NULL, FALSE, FALSE, TRUE);
89
+			$overridden_receipt_body = EEH_Template::locate_template($templates_relative_path.'receipt_body.template.php', NULL, FALSE, FALSE, TRUE);
90
+			if ($overridden_invoice_body || $overridden_receipt_body) {
91
+				EE_Error::add_persistent_admin_notice('invoice_overriding_templates', sprintf(__('Note: in this version of Event Espresso, PDF and HTML Invoices and Receipts are now Messages and can be changed just like any other messages; however we noticed you had previously overriden the old default Invoice/Receipt templates. Because of this, your old Invoice/Receipt templates will continue to be used INSTEAD of the new Invoice/Receipt message equivalents. We recommend deleting your old Invoice/Receipt templates and modifying the new Invoice and Receipt messages\'s content in Messages -> Invoice and Messages -> Receipt.')), TRUE);
92 92
 			}
93 93
 
94 94
 		}
Please login to merge, or discard this patch.
4_6_0_stages/EE_DMS_4_6_0_invoice_settings.dmsstage.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	 * Just initializes the status of the migration
28 28
 	 */
29 29
 	public function __construct() {
30
-		$this->_pretty_name = __( 'Update Invoice Settings', 'event_espresso' );
30
+		$this->_pretty_name = __('Update Invoice Settings', 'event_espresso');
31 31
 		parent::__construct();
32 32
 	}
33 33
 
@@ -54,13 +54,13 @@  discard block
 block discarded – undo
54 54
 	 * @throws EE_Error
55 55
 	 * @return int number of items ACTUALLY migrated
56 56
 	 */
57
-	protected function _migration_step( $num_items = 1 ){
57
+	protected function _migration_step($num_items = 1) {
58 58
 
59 59
 		$templates_relative_path = 'modules/gateways/Invoice/lib/templates/';
60
-		$overridden_invoice_body = EEH_Template::locate_template( $templates_relative_path . 'invoice_body.template.php', NULL, FALSE, FALSE, TRUE );
61
-		$overridden_receipt_body= EEH_Template::locate_template( $templates_relative_path . 'receipt_body.template.php', NULL, FALSE, FALSE, TRUE );
62
-		if( $overridden_invoice_body || $overridden_receipt_body ) {
63
-			EE_Error::add_persistent_admin_notice( 'invoice_overriding_templates', sprintf( __( 'Note: in this version of Event Espresso, PDF and HTML Invoices and Receipts are now Messages and can be changed just like any other messages; however we noticed you had previously overriden the old default Invoice/Receipt templates. Because of this, your old Invoice/Receipt templates will continue to be used INSTEAD of the new Invoice/Receipt message equivalents (but this will be removed in an upcoming version). We recommend deleting your old Invoice/Receipt templates and using the new messages system. Then modify the new Invoice and Receipt messages\'s content in Messages -> Invoice and Messages -> Receipt.')), TRUE );
60
+		$overridden_invoice_body = EEH_Template::locate_template($templates_relative_path.'invoice_body.template.php', NULL, FALSE, FALSE, TRUE);
61
+		$overridden_receipt_body = EEH_Template::locate_template($templates_relative_path.'receipt_body.template.php', NULL, FALSE, FALSE, TRUE);
62
+		if ($overridden_invoice_body || $overridden_receipt_body) {
63
+			EE_Error::add_persistent_admin_notice('invoice_overriding_templates', sprintf(__('Note: in this version of Event Espresso, PDF and HTML Invoices and Receipts are now Messages and can be changed just like any other messages; however we noticed you had previously overriden the old default Invoice/Receipt templates. Because of this, your old Invoice/Receipt templates will continue to be used INSTEAD of the new Invoice/Receipt message equivalents (but this will be removed in an upcoming version). We recommend deleting your old Invoice/Receipt templates and using the new messages system. Then modify the new Invoice and Receipt messages\'s content in Messages -> Invoice and Messages -> Receipt.')), TRUE);
64 64
 		}
65 65
 
66 66
 		//regardless of whether it worked or not, we ought to continue the migration
Please login to merge, or discard this patch.
core/EE_Deprecated.core.php 1 patch
Spacing   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -15,9 +15,9 @@  discard block
 block discarded – undo
15 15
  * @return boolean
16 16
  */
17 17
 function ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() {
18
-	$in_use =  has_filter( 'FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns' )
19
-			|| has_action( 'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save' );
20
-	if( $in_use ) {
18
+	$in_use = has_filter('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns')
19
+			|| has_action('AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save');
20
+	if ($in_use) {
21 21
 		$msg = __(
22 22
 			'We detected you are using the filter FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns or AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save.'
23 23
 			. 'Both of these have been deprecated and should not be used anymore. You should instead use FHEE__EE_Form_Section_Proper___construct__options_array to customize the contents of the form,'
@@ -26,18 +26,18 @@  discard block
 block discarded – undo
26 26
 			'event_espresso' )
27 27
 		;
28 28
 		EE_Error::doing_it_wrong(
29
-			__CLASS__ . '::' . __FUNCTION__,
29
+			__CLASS__.'::'.__FUNCTION__,
30 30
 			$msg,
31 31
 			'4.8.32.rc.000'
32 32
 		);
33 33
 		//it seems the doing_it_wrong messages get output during some hidden html tags, so add an error to make sure this gets noticed
34
-		if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
35
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
34
+		if (is_admin() && ! defined('DOING_AJAX')) {
35
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
36 36
 		}
37 37
 	}
38 38
 	return $in_use;
39 39
 }
40
-add_action( 'AHEE__Registrations_Admin_Page___registration_details_metabox__start', 'ee_deprecated_using_old_registration_admin_custom_questions_form_hooks' );
40
+add_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', 'ee_deprecated_using_old_registration_admin_custom_questions_form_hooks');
41 41
 
42 42
 /**
43 43
  * @deprecated since 4.8.32.rc.000 because it has issues on https://events.codebasehq.com/projects/event-espresso/tickets/9165
@@ -46,34 +46,34 @@  discard block
 block discarded – undo
46 46
  * @param EE_Admin_Page $admin_page
47 47
  * @return void
48 48
  */
49
-function ee_deprecated_update_attendee_registration_form_old( $admin_page ) {
49
+function ee_deprecated_update_attendee_registration_form_old($admin_page) {
50 50
 	//check if the old hooks are in use. If not, do the default
51
-	if( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
52
-		|| ! $admin_page instanceof EE_Admin_Page ) {
51
+	if ( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
52
+		|| ! $admin_page instanceof EE_Admin_Page) {
53 53
 		return;
54 54
 	}
55 55
 	$req_data = $admin_page->get_request_data();
56
-	$qstns = isset( $req_data['qstn'] ) ? $req_data['qstn'] : FALSE;
57
-	$REG_ID = isset( $req_data['_REG_ID'] ) ? absint( $req_data['_REG_ID'] ) : FALSE;
58
-	$qstns = apply_filters( 'FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns );
59
-	if ( ! $REG_ID || ! $qstns ) {
60
-		EE_Error::add_error( __('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
56
+	$qstns = isset($req_data['qstn']) ? $req_data['qstn'] : FALSE;
57
+	$REG_ID = isset($req_data['_REG_ID']) ? absint($req_data['_REG_ID']) : FALSE;
58
+	$qstns = apply_filters('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns);
59
+	if ( ! $REG_ID || ! $qstns) {
60
+		EE_Error::add_error(__('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
61 61
 	}
62 62
 	$success = TRUE;
63 63
 
64 64
 	// allow others to get in on this awesome fun   :D
65
-	do_action( 'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save', $REG_ID, $qstns );
65
+	do_action('AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save', $REG_ID, $qstns);
66 66
 	// loop thru questions... FINALLY!!!
67 67
 
68
-	foreach ( $qstns as $QST_ID => $qstn ) {
68
+	foreach ($qstns as $QST_ID => $qstn) {
69 69
 		//if $qstn isn't an array then it doesn't already have an answer, so let's create the answer
70
-		if ( !is_array($qstn) ) {
71
-			$success = $this->_save_new_answer( $REG_ID, $QST_ID, $qstn);
70
+		if ( ! is_array($qstn)) {
71
+			$success = $this->_save_new_answer($REG_ID, $QST_ID, $qstn);
72 72
 			continue;
73 73
 		}
74 74
 
75 75
 
76
-		foreach ( $qstn as $ANS_ID => $ANS_value ) {
76
+		foreach ($qstn as $ANS_ID => $ANS_value) {
77 77
 			//get answer
78 78
 			$query_params = array(
79 79
 				0 => array(
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 				);
85 85
 			$answer = EEM_Answer::instance()->get_one($query_params);
86 86
 			//this MAY be an array but NOT have an answer because its multi select.  If so then we need to create the answer
87
-			if ( ! $answer instanceof EE_Answer ) {
87
+			if ( ! $answer instanceof EE_Answer) {
88 88
 				$set_values = array(
89 89
 					'QST_ID' => $QST_ID,
90 90
 					'REG_ID' => $REG_ID,
@@ -99,11 +99,11 @@  discard block
 block discarded – undo
99 99
 		}
100 100
 	}
101 101
 	$what = __('Registration Form', 'event_espresso');
102
-	$route = $REG_ID ? array( 'action' => 'view_registration', '_REG_ID' => $REG_ID ) : array( 'action' => 'default' );
103
-	$admin_page->redirect_after_action( $success, $what, __('updated', 'event_espresso'), $route );
102
+	$route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) : array('action' => 'default');
103
+	$admin_page->redirect_after_action($success, $what, __('updated', 'event_espresso'), $route);
104 104
 	exit;
105 105
 }
106
-add_action( 'AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', 'ee_deprecated_update_attendee_registration_form_old', 10, 1 );
106
+add_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', 'ee_deprecated_update_attendee_registration_form_old', 10, 1);
107 107
 /**
108 108
  * Render the registration admin page's custom questions area in the old fashion
109 109
  * and firing the old hooks. When this method is removed, we can probably also
@@ -116,30 +116,30 @@  discard block
 block discarded – undo
116 116
  * @return bool
117 117
  * @throws \EE_Error
118 118
  */
119
-function ee_deprecated_reg_questions_meta_box_old( $do_default_action, $admin_page, $registration ) {
119
+function ee_deprecated_reg_questions_meta_box_old($do_default_action, $admin_page, $registration) {
120 120
 	//check if the old hooks are in use. If not, do the default
121
-	if( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
122
-		|| ! $admin_page instanceof EE_Admin_Page ) {
121
+	if ( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
122
+		|| ! $admin_page instanceof EE_Admin_Page) {
123 123
 		return $do_default_action;
124 124
 	}
125
-	add_filter( 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', array( $admin_page, 'form_before_question_group' ), 10, 1 );
126
-	add_filter( 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', array( $admin_page, 'form_after_question_group' ), 10, 1 );
127
-	add_filter( 'FHEE__EEH_Form_Fields__label_html', array( $admin_page, 'form_form_field_label_wrap' ), 10, 1 );
128
-	add_filter( 'FHEE__EEH_Form_Fields__input_html', array( $admin_page, 'form_form_field_input__wrap' ), 10, 1 );
125
+	add_filter('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', array($admin_page, 'form_before_question_group'), 10, 1);
126
+	add_filter('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', array($admin_page, 'form_after_question_group'), 10, 1);
127
+	add_filter('FHEE__EEH_Form_Fields__label_html', array($admin_page, 'form_form_field_label_wrap'), 10, 1);
128
+	add_filter('FHEE__EEH_Form_Fields__input_html', array($admin_page, 'form_form_field_input__wrap'), 10, 1);
129 129
 
130
-	$question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options( $registration, $registration->get('EVT_ID') );
130
+	$question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options($registration, $registration->get('EVT_ID'));
131 131
 
132 132
 	$template_args = array(
133
-		'att_questions' => EEH_Form_Fields::generate_question_groups_html( $question_groups ),
133
+		'att_questions' => EEH_Form_Fields::generate_question_groups_html($question_groups),
134 134
 		'reg_questions_form_action' => 'edit_registration',
135 135
 		'REG_ID' => $registration->ID()
136 136
 	);
137
-	$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
138
-	echo EEH_Template::display_template( $template_path, $template_args, TRUE );
137
+	$template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_questions.template.php';
138
+	echo EEH_Template::display_template($template_path, $template_args, TRUE);
139 139
 	//indicate that we should not do the default admin page code
140 140
 	return false;
141 141
 }
142
-add_action( 'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', 'ee_deprecated_reg_questions_meta_box_old', 10, 3 );
142
+add_action('FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', 'ee_deprecated_reg_questions_meta_box_old', 10, 3);
143 143
 
144 144
 /**
145 145
  * ee_deprecated__registration_checkout__button_text
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
  * @param \EE_Checkout $checkout
149 149
  * @return string
150 150
  */
151
-function ee_deprecated__registration_checkout__button_text( $submit_button_text, EE_Checkout $checkout ) {
151
+function ee_deprecated__registration_checkout__button_text($submit_button_text, EE_Checkout $checkout) {
152 152
 	// list of old filters
153 153
 	$deprecated_filters = array(
154 154
 		'update_registration_details' => true,
@@ -158,16 +158,16 @@  discard block
 block discarded – undo
158 158
 		'proceed_to' => true,
159 159
 	);
160 160
 	// loop thru and call doing_it_wrong() or remove any that aren't being used
161
-	foreach ( $deprecated_filters as $deprecated_filter => $on ) {
161
+	foreach ($deprecated_filters as $deprecated_filter => $on) {
162 162
 		// was this filter called ?
163
-		if ( has_action( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter )) {
163
+		if (has_action('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter)) {
164 164
 			// only display doing_it_wrong() notice to Event Admins during non-AJAX requests
165
-			if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_ee', 'hide_doing_it_wrong_for_deprecated_SPCO_filter' ) && ! defined( 'DOING_AJAX' ) ) {
165
+			if (EE_Registry::instance()->CAP->current_user_can('ee_read_ee', 'hide_doing_it_wrong_for_deprecated_SPCO_filter') && ! defined('DOING_AJAX')) {
166 166
 				EE_Error::doing_it_wrong(
167
-					'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter,
167
+					'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter,
168 168
 					sprintf(
169
-						__( 'The %1$s filter is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"', 'event_espresso' ),
170
-						'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter,
169
+						__('The %1$s filter is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"', 'event_espresso'),
170
+						'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter,
171 171
 						'<br />',
172 172
 						'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text',
173 173
 						'/modules/single_page_checkout/inc/EE_SPCO_Reg_Step.class.php'
@@ -177,24 +177,24 @@  discard block
 block discarded – undo
177 177
 				);
178 178
 			}
179 179
 		} else {
180
-			unset( $deprecated_filters[ $deprecated_filter ] );
180
+			unset($deprecated_filters[$deprecated_filter]);
181 181
 		}
182 182
 	}
183
-	if ( ! empty( $deprecated_filters )) {
184
-
185
-		if ( $checkout->current_step->slug() == 'attendee_information' && $checkout->revisit && isset( $deprecated_filters[ 'update_registration_details' ] )) {
186
-			$submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__update_registration_details', $submit_button_text );
187
-		} else if ( $checkout->current_step->slug() == 'payment_options' && $checkout->revisit && isset( $deprecated_filters[ 'process_payment' ] ) ) {
188
-			$submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__process_payment', $submit_button_text );
189
-		} else if ( $checkout->next_step instanceof EE_SPCO_Reg_Step && $checkout->next_step->slug() == 'finalize_registration' && isset( $deprecated_filters[ 'finalize_registration' ] ) ) {
190
-			$submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__finalize_registration', $submit_button_text );
183
+	if ( ! empty($deprecated_filters)) {
184
+
185
+		if ($checkout->current_step->slug() == 'attendee_information' && $checkout->revisit && isset($deprecated_filters['update_registration_details'])) {
186
+			$submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__update_registration_details', $submit_button_text);
187
+		} else if ($checkout->current_step->slug() == 'payment_options' && $checkout->revisit && isset($deprecated_filters['process_payment'])) {
188
+			$submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__process_payment', $submit_button_text);
189
+		} else if ($checkout->next_step instanceof EE_SPCO_Reg_Step && $checkout->next_step->slug() == 'finalize_registration' && isset($deprecated_filters['finalize_registration'])) {
190
+			$submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__finalize_registration', $submit_button_text);
191 191
 		}
192
-		if ( $checkout->next_step instanceof EE_SPCO_Reg_Step ) {
193
-			if ( $checkout->payment_required() && $checkout->next_step->slug() == 'payment_options' && isset( $deprecated_filters[ 'and_proceed_to_payment' ] ) ) {
194
-				$submit_button_text .= apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__and_proceed_to_payment', $submit_button_text );
192
+		if ($checkout->next_step instanceof EE_SPCO_Reg_Step) {
193
+			if ($checkout->payment_required() && $checkout->next_step->slug() == 'payment_options' && isset($deprecated_filters['and_proceed_to_payment'])) {
194
+				$submit_button_text .= apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__and_proceed_to_payment', $submit_button_text);
195 195
 			}
196
-			if ( $checkout->next_step->slug() != 'finalize_registration' && ! $checkout->revisit && isset( $deprecated_filters[ 'proceed_to' ] ) ) {
197
-				$submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to', $submit_button_text ) . $checkout->next_step->name();
196
+			if ($checkout->next_step->slug() != 'finalize_registration' && ! $checkout->revisit && isset($deprecated_filters['proceed_to'])) {
197
+				$submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to', $submit_button_text).$checkout->next_step->name();
198 198
 			}
199 199
 		}
200 200
 
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 	return $submit_button_text;
203 203
 
204 204
 }
205
-add_filter( 'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', 'ee_deprecated__registration_checkout__button_text', 10, 2 );
205
+add_filter('FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', 'ee_deprecated__registration_checkout__button_text', 10, 2);
206 206
 
207 207
 
208 208
 
@@ -213,16 +213,16 @@  discard block
 block discarded – undo
213 213
  * @param \EE_Checkout $checkout
214 214
  * @param boolean $status_updates
215 215
  */
216
-function ee_deprecated_finalize_transaction( EE_Checkout $checkout, $status_updates ) {
216
+function ee_deprecated_finalize_transaction(EE_Checkout $checkout, $status_updates) {
217 217
 	$action_ref = NULL;
218
-	$action_ref = has_action( 'AHEE__EE_Transaction__finalize__new_transaction' ) ? 'AHEE__EE_Transaction__finalize__new_transaction' : $action_ref;
219
-	$action_ref = has_action( 'AHEE__EE_Transaction__finalize__all_transaction' ) ? 'AHEE__EE_Transaction__finalize__all_transaction' : $action_ref;
220
-	if ( $action_ref ) {
218
+	$action_ref = has_action('AHEE__EE_Transaction__finalize__new_transaction') ? 'AHEE__EE_Transaction__finalize__new_transaction' : $action_ref;
219
+	$action_ref = has_action('AHEE__EE_Transaction__finalize__all_transaction') ? 'AHEE__EE_Transaction__finalize__all_transaction' : $action_ref;
220
+	if ($action_ref) {
221 221
 
222 222
 		EE_Error::doing_it_wrong(
223 223
 			$action_ref,
224 224
 			sprintf(
225
-				__( 'This action is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use one of the following new actions: %1$s"%3$s" found in "%2$s" %1$s"%4$s" found in "%2$s" %1$s"%5$s" found in "%2$s" %1$s"%6$s" found in "%2$s"', 'event_espresso' ),
225
+				__('This action is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use one of the following new actions: %1$s"%3$s" found in "%2$s" %1$s"%4$s" found in "%2$s" %1$s"%5$s" found in "%2$s" %1$s"%6$s" found in "%2$s"', 'event_espresso'),
226 226
 				'<br />',
227 227
 				'/core/business/EE_Transaction_Processor.class.php',
228 228
 				'AHEE__EE_Transaction_Processor__finalize',
@@ -233,29 +233,29 @@  discard block
 block discarded – undo
233 233
 			'4.6.0',
234 234
 			E_USER_DEPRECATED
235 235
 		);
236
-		switch ( $action_ref ) {
236
+		switch ($action_ref) {
237 237
 			case 'AHEE__EE_Transaction__finalize__new_transaction' :
238
-				do_action( 'AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, $checkout->admin_request );
238
+				do_action('AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, $checkout->admin_request);
239 239
 				break;
240 240
 			case 'AHEE__EE_Transaction__finalize__all_transaction' :
241
-				do_action( 'AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, array( 'new_reg' => ! $checkout->revisit, 'to_approved' => $status_updates ), $checkout->admin_request );
241
+				do_action('AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, array('new_reg' => ! $checkout->revisit, 'to_approved' => $status_updates), $checkout->admin_request);
242 242
 				break;
243 243
 		}
244 244
 	}
245 245
 }
246
-add_action( 'AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed', 'ee_deprecated_finalize_transaction', 10, 2 );
246
+add_action('AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed', 'ee_deprecated_finalize_transaction', 10, 2);
247 247
 /**
248 248
  * ee_deprecated_finalize_registration
249 249
  *
250 250
  * @param EE_Registration $registration
251 251
  */
252
-function ee_deprecated_finalize_registration( EE_Registration $registration ) {
253
-	$action_ref = has_action( 'AHEE__EE_Registration__finalize__update_and_new_reg' ) ? 'AHEE__EE_Registration__finalize__update_and_new_reg' : NULL;
254
-	if ( $action_ref ) {
252
+function ee_deprecated_finalize_registration(EE_Registration $registration) {
253
+	$action_ref = has_action('AHEE__EE_Registration__finalize__update_and_new_reg') ? 'AHEE__EE_Registration__finalize__update_and_new_reg' : NULL;
254
+	if ($action_ref) {
255 255
 		EE_Error::doing_it_wrong(
256 256
 			$action_ref,
257 257
 			sprintf(
258
-				__( 'This action is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new action: %1$s"%3$s" found in "%2$s"', 'event_espresso' ),
258
+				__('This action is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new action: %1$s"%3$s" found in "%2$s"', 'event_espresso'),
259 259
 				'<br />',
260 260
 				'/core/business/EE_Registration_Processor.class.php',
261 261
 				'AHEE__EE_Registration_Processor__trigger_registration_status_changed_hook'
@@ -263,10 +263,10 @@  discard block
 block discarded – undo
263 263
 			'4.6.0',
264 264
 			E_USER_DEPRECATED
265 265
 		);
266
-		do_action( 'AHEE__EE_Registration__finalize__update_and_new_reg', $registration, ( is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX )));
266
+		do_action('AHEE__EE_Registration__finalize__update_and_new_reg', $registration, (is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX)));
267 267
 	}
268 268
 }
269
-add_action( 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', 'ee_deprecated_finalize_registration', 10, 1 );
269
+add_action('AHEE__EE_Registration_Processor__trigger_registration_update_notifications', 'ee_deprecated_finalize_registration', 10, 1);
270 270
 
271 271
 
272 272
 
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
  *
288 288
  * @return array
289 289
  */
290
-function ee_deprecated_get_templates( $templates, EE_messenger $messenger, EE_message_type $message_type, EE_Messages_Template_Pack $template_pack ) {
290
+function ee_deprecated_get_templates($templates, EE_messenger $messenger, EE_message_type $message_type, EE_Messages_Template_Pack $template_pack) {
291 291
 	$old_default_classnames = array(
292 292
 		'EE_Messages_Email_Cancelled_Registration_Defaults',
293 293
 		'EE_Messages_Email_Declined_Registration_Defaults',
@@ -303,23 +303,23 @@  discard block
 block discarded – undo
303 303
 
304 304
 	$old_class_instance = new stdClass();
305 305
 
306
-	foreach ( $old_default_classnames as $classname ) {
307
-		$filter_ref = 'FHEE__' . $classname . '___create_new_templates___templates';
308
-		if ( has_filter( $filter_ref ) ) {
309
-			EE_Error::doing_it_wrong( $filter_ref, __('This filter is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the new filter provided which is "FHEE__EE_Template_Pack___get_templates__templates" found in the EE_Messages_Template_Pack class.', 'event_espresso'), '4.5.0', E_USER_DEPRECATED );
306
+	foreach ($old_default_classnames as $classname) {
307
+		$filter_ref = 'FHEE__'.$classname.'___create_new_templates___templates';
308
+		if (has_filter($filter_ref)) {
309
+			EE_Error::doing_it_wrong($filter_ref, __('This filter is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the new filter provided which is "FHEE__EE_Template_Pack___get_templates__templates" found in the EE_Messages_Template_Pack class.', 'event_espresso'), '4.5.0', E_USER_DEPRECATED);
310 310
 		}
311
-		$templates = apply_filters( $filter_ref, $templates, $old_class_instance );
311
+		$templates = apply_filters($filter_ref, $templates, $old_class_instance);
312 312
 	}
313 313
 
314 314
 	return $templates;
315 315
 }
316
-add_filter( 'FHEE__EE_Template_Pack___get_templates__templates', 'ee_deprecated_get_templates', 10, 4 );
316
+add_filter('FHEE__EE_Template_Pack___get_templates__templates', 'ee_deprecated_get_templates', 10, 4);
317 317
 
318 318
 /**
319 319
  * Called after EED_Module::set_hooks() and EED_Module::set_admin_hooks() was called.
320 320
  * Checks if any deprecated hooks were hooked-into and provide doing_it_wrong messages appropriately.
321 321
  */
322
-function ee_deprecated_hooks(){
322
+function ee_deprecated_hooks() {
323 323
 	/**
324 324
 	 * @var $hooks array where keys are hook names, and their values are array{
325 325
 	 *			@type string $version  when deprecated
@@ -330,26 +330,26 @@  discard block
 block discarded – undo
330 330
 	$hooks = array(
331 331
 		'AHEE__EE_System___do_setup_validations' => array(
332 332
 			'version' => '4.6.0',
333
-			'alternative' => __( 'Instead use "AHEE__EEH_Activation__validate_messages_system" which is called after validating messages (done on every new install, upgrade, reactivation, and downgrade)', 'event_espresso' ),
333
+			'alternative' => __('Instead use "AHEE__EEH_Activation__validate_messages_system" which is called after validating messages (done on every new install, upgrade, reactivation, and downgrade)', 'event_espresso'),
334 334
 			'still_works' => FALSE
335 335
 		)
336 336
 	);
337
-	foreach( $hooks as $name => $deprecation_info ){
338
-		if( has_action( $name ) ){
337
+	foreach ($hooks as $name => $deprecation_info) {
338
+		if (has_action($name)) {
339 339
 			EE_Error::doing_it_wrong(
340 340
 				$name,
341 341
 				sprintf(
342
-					__('This filter is deprecated. %1$s%2$s','event_espresso'),
343
-					$deprecation_info[ 'still_works' ] ?  __('It *may* work as an attempt to build in backwards compatibility.', 'event_espresso') : __( 'It has been completely removed.', 'event_espresso' ),
344
-					isset( $deprecation_info[ 'alternative' ] ) ? $deprecation_info[ 'alternative' ] : __( 'Please read the current EE4 documentation further or contact Support.', 'event_espresso' )
342
+					__('This filter is deprecated. %1$s%2$s', 'event_espresso'),
343
+					$deprecation_info['still_works'] ? __('It *may* work as an attempt to build in backwards compatibility.', 'event_espresso') : __('It has been completely removed.', 'event_espresso'),
344
+					isset($deprecation_info['alternative']) ? $deprecation_info['alternative'] : __('Please read the current EE4 documentation further or contact Support.', 'event_espresso')
345 345
 				),
346
-				isset( $deprecation_info[ 'version' ] ) ? $deprecation_info[ 'version' ] : __( 'recently', 'event_espresso' ),
346
+				isset($deprecation_info['version']) ? $deprecation_info['version'] : __('recently', 'event_espresso'),
347 347
 				E_USER_DEPRECATED
348 348
 			);
349 349
 		}
350 350
 	}
351 351
 }
352
-add_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', 'ee_deprecated_hooks' );
352
+add_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', 'ee_deprecated_hooks');
353 353
 
354 354
 
355 355
 
@@ -372,25 +372,25 @@  discard block
 block discarded – undo
372 372
  *
373 373
  * @return string                    The default contents for the messenger, message type, context and field.
374 374
  */
375
-function ee_deprecated_get_default_field_content( $contents, $actual_path, EE_messenger $messenger, EE_message_type $message_type, $field, $context, EE_Messages_Template_Pack $template_pack ) {
375
+function ee_deprecated_get_default_field_content($contents, $actual_path, EE_messenger $messenger, EE_message_type $message_type, $field, $context, EE_Messages_Template_Pack $template_pack) {
376 376
 
377 377
 	$classnames_to_try = array(
378
-		get_class( $messenger ) => $messenger,
379
-		get_class( $message_type ) => $message_type,
378
+		get_class($messenger) => $messenger,
379
+		get_class($message_type) => $message_type,
380 380
 		'EE_Messages_Base' => $message_type
381 381
 		);
382 382
 
383
-	foreach ( $classnames_to_try as $classname => $obj ) {
384
-		$filter_ref = 'FHEE__' . $classname . '__get_default_field_content';
385
-		if ( has_filter( $filter_ref ) ) {
386
-			EE_Error::doing_it_wrong( $filter_ref, __('This filter is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the new filter provided which is "FHEE__EE_Messages_Template_Pack__get_specific_template__contents" found in the EE_Messages_Template_Pack class.', 'event_espresso'), '4.5.0', E_USER_DEPRECATED );
383
+	foreach ($classnames_to_try as $classname => $obj) {
384
+		$filter_ref = 'FHEE__'.$classname.'__get_default_field_content';
385
+		if (has_filter($filter_ref)) {
386
+			EE_Error::doing_it_wrong($filter_ref, __('This filter is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the new filter provided which is "FHEE__EE_Messages_Template_Pack__get_specific_template__contents" found in the EE_Messages_Template_Pack class.', 'event_espresso'), '4.5.0', E_USER_DEPRECATED);
387 387
 		}
388
-		$contents = apply_filters( $filter_ref, $contents, $obj );
388
+		$contents = apply_filters($filter_ref, $contents, $obj);
389 389
 	}
390 390
 
391 391
 	return $contents;
392 392
 }
393
-add_filter( 'FHEE__EE_Messages_Template_Pack__get_specific_template__contents', 'ee_deprecated_get_default_field_content', 10, 7 );
393
+add_filter('FHEE__EE_Messages_Template_Pack__get_specific_template__contents', 'ee_deprecated_get_default_field_content', 10, 7);
394 394
 
395 395
 
396 396
 
@@ -418,23 +418,23 @@  discard block
 block discarded – undo
418 418
  *
419 419
  * @return string                    The path to the file being used.
420 420
  */
421
-function ee_deprecated_get_inline_css_template_filters( $variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url,  EE_Messages_Template_Pack $template_pack ) {
421
+function ee_deprecated_get_inline_css_template_filters($variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url, EE_Messages_Template_Pack $template_pack) {
422 422
 
423
-	if ( $messenger == 'email' ) {
423
+	if ($messenger == 'email') {
424 424
 		$filter_ref = $url ? 'FHEE__EE_Email_Messenger__get_inline_css_template__css_url' : 'FHEE__EE_Email_Messenger__get_inline_css_template__css_path';
425
-	} elseif ( $messenger == 'html' ) {
425
+	} elseif ($messenger == 'html') {
426 426
 		$filter_ref = $url ? 'FHEE__EE_Html_messenger__get_inline_css_template__css_url' : 'FHEE__EE_Html_messenger__get_inline_css_template__css_path';
427 427
 	} else {
428 428
 		return $variation_path;
429 429
 	}
430 430
 
431
-	if ( has_filter( $filter_ref ) ) {
432
-		EE_Error::doing_it_wrong( $filter_ref, __('This filter is deprecated.  It is recommended to use the new filter provided which is "FHEE__EE_Messages_Template_Pack__get_variation" found in the EE_Messages_Template_Pack class.', 'event_espresso'), '4.5.0', E_USER_DEPRECATED );
431
+	if (has_filter($filter_ref)) {
432
+		EE_Error::doing_it_wrong($filter_ref, __('This filter is deprecated.  It is recommended to use the new filter provided which is "FHEE__EE_Messages_Template_Pack__get_variation" found in the EE_Messages_Template_Pack class.', 'event_espresso'), '4.5.0', E_USER_DEPRECATED);
433 433
 	}
434 434
 
435
-	return apply_filters( $filter_ref, $variation_path, $url, $type );
435
+	return apply_filters($filter_ref, $variation_path, $url, $type);
436 436
 }
437
-add_filter( 'FHEE__EE_Messages_Template_Pack__get_variation', 'ee_deprecated_get_inline_css_template_filters', 10, 8 );
437
+add_filter('FHEE__EE_Messages_Template_Pack__get_variation', 'ee_deprecated_get_inline_css_template_filters', 10, 8);
438 438
 
439 439
 
440 440
 
@@ -450,78 +450,78 @@  discard block
 block discarded – undo
450 450
 class EE_Messages_Init extends EE_Base {
451 451
 
452 452
 	public function __construct() {
453
-		self::doing_it_wrong_call( __METHOD__ );
453
+		self::doing_it_wrong_call(__METHOD__);
454 454
 	}
455 455
 
456 456
 	/**
457 457
 	 * @param $method_name
458 458
 	 */
459
-	public static function doing_it_wrong_call( $method_name ) {
460
-		EE_Error::doing_it_wrong( __CLASS__, sprintf( __('The %s in this class is deprecated as of EE4.5.0.  All functionality formerly in this class is now in the EED_Messages module.', 'event_espresso'), $method_name ), '4.5.0', E_USER_DEPRECATED );
459
+	public static function doing_it_wrong_call($method_name) {
460
+		EE_Error::doing_it_wrong(__CLASS__, sprintf(__('The %s in this class is deprecated as of EE4.5.0.  All functionality formerly in this class is now in the EED_Messages module.', 'event_espresso'), $method_name), '4.5.0', E_USER_DEPRECATED);
461 461
 	}
462 462
 
463 463
 	/**
464 464
 	 * @deprecated 4.5.0
465 465
 	 */
466 466
 	public static function set_autoloaders() {
467
-		self::doing_it_wrong_call( __METHOD__ );
467
+		self::doing_it_wrong_call(__METHOD__);
468 468
 		EED_Messages::set_autoloaders();
469 469
 	}
470 470
 
471 471
 	/**
472 472
 	 * @deprecated 4.5.0
473 473
 	 */
474
-	public function payment_reminder( $transaction ) {
475
-		self::doing_it_wrong_call( __METHOD__ );
476
-		EED_Messages::payment_reminder( $transaction );
474
+	public function payment_reminder($transaction) {
475
+		self::doing_it_wrong_call(__METHOD__);
476
+		EED_Messages::payment_reminder($transaction);
477 477
 	}
478 478
 
479 479
 	/**
480 480
 	 * @deprecated 4.5.0
481 481
 	 */
482
-	public function payment( $transaction, $payment ) {
483
-		self::doing_it_wrong_call( __METHOD__ );
484
-		EED_Messages::payment( $transaction, $payment );
482
+	public function payment($transaction, $payment) {
483
+		self::doing_it_wrong_call(__METHOD__);
484
+		EED_Messages::payment($transaction, $payment);
485 485
 	}
486 486
 
487 487
 	/**
488 488
 	 * @deprecated 4.5.0
489 489
 	 */
490
-	public function cancelled_registration( $transaction ) {
491
-		self::doing_it_wrong_call( __METHOD__ );
492
-		EED_Messages::cancelled_registration( $transaction );
490
+	public function cancelled_registration($transaction) {
491
+		self::doing_it_wrong_call(__METHOD__);
492
+		EED_Messages::cancelled_registration($transaction);
493 493
 	}
494 494
 
495 495
 	/**
496 496
 	 * @deprecated 4.5.0
497 497
 	 */
498
-	public function maybe_registration( $transaction, $reg_msg, $from_admin ) {
499
-		self::doing_it_wrong_call( __METHOD__ );
500
-		EED_Messages::maybe_registration( $transaction, $reg_msg, $from_admin );
498
+	public function maybe_registration($transaction, $reg_msg, $from_admin) {
499
+		self::doing_it_wrong_call(__METHOD__);
500
+		EED_Messages::maybe_registration($transaction, $reg_msg, $from_admin);
501 501
 	}
502 502
 
503 503
 	/**
504 504
 	 * @deprecated 4.5.0
505 505
 	 */
506
-	public function process_resend( $success, $req_data ) {
507
-		self::doing_it_wrong_call( __METHOD__ );
508
-		EED_Messages::process_resend( $req_data );
506
+	public function process_resend($success, $req_data) {
507
+		self::doing_it_wrong_call(__METHOD__);
508
+		EED_Messages::process_resend($req_data);
509 509
 	}
510 510
 
511 511
 	/**
512 512
 	 * @deprecated 4.5.0
513 513
 	 */
514
-	public function process_admin_payment( $success, $payment ) {
515
-		self::doing_it_wrong_call( __METHOD__ );
516
-		EED_Messages::process_admin_payment( $success, $payment );
514
+	public function process_admin_payment($success, $payment) {
515
+		self::doing_it_wrong_call(__METHOD__);
516
+		EED_Messages::process_admin_payment($success, $payment);
517 517
 	}
518 518
 
519 519
 	/**
520 520
 	 * @deprecated 4.5.0
521 521
 	 */
522
-	public function send_newsletter_message( $contacts, $grp_id ) {
523
-		self::doing_it_wrong_call( __METHOD__ );
524
-		EED_Messages::send_newsletter_message( $contacts, $grp_id );
522
+	public function send_newsletter_message($contacts, $grp_id) {
523
+		self::doing_it_wrong_call(__METHOD__);
524
+		EED_Messages::send_newsletter_message($contacts, $grp_id);
525 525
 	}
526 526
 
527 527
 
@@ -542,13 +542,13 @@  discard block
 block discarded – undo
542 542
  *
543 543
  * @return array additional cpts.
544 544
  */
545
-function ee_deprecated_get_cpts( $cpts ) {
546
-	if ( has_filter( 'FHEE__EE_Register_CPTs__construct__CPTs' ) ) {
547
-		EE_Error::doing_it_wrong( 'FHEE__EE_Register_CPTs__construct__CPTs', __('This filter is deprecated. It will still work for the time being.  However, it is recommended to use the new filter provided which is "FHEE__EE_Register_CPTs__get_CPTs__cpts" found in EE_Register_CPTs::get_CPTs()', 'event_espresso'), '4.5.0', E_USER_DEPRECATED );
545
+function ee_deprecated_get_cpts($cpts) {
546
+	if (has_filter('FHEE__EE_Register_CPTs__construct__CPTs')) {
547
+		EE_Error::doing_it_wrong('FHEE__EE_Register_CPTs__construct__CPTs', __('This filter is deprecated. It will still work for the time being.  However, it is recommended to use the new filter provided which is "FHEE__EE_Register_CPTs__get_CPTs__cpts" found in EE_Register_CPTs::get_CPTs()', 'event_espresso'), '4.5.0', E_USER_DEPRECATED);
548 548
 	}
549
-	return apply_filters( 'FHEE__EE_Register_CPTs__construct__CPTs', $cpts );
549
+	return apply_filters('FHEE__EE_Register_CPTs__construct__CPTs', $cpts);
550 550
 }
551
-add_filter( 'FHEE__EE_Register_CPTs__get_CPTs__cpts', 'ee_deprecated_get_cpts', 10 );
551
+add_filter('FHEE__EE_Register_CPTs__get_CPTs__cpts', 'ee_deprecated_get_cpts', 10);
552 552
 
553 553
 
554 554
 
@@ -562,10 +562,10 @@  discard block
 block discarded – undo
562 562
  *
563 563
  * @return array additional custom taxonomies.
564 564
  */
565
-function ee_deprecated_get_taxonomies( $cts ) {
566
-	if ( has_filter( 'FHEE__EE_Register_CPTs__construct__taxonomies' ) ) {
567
-		EE_Error::doing_it_wrong( 'FHEE__EE_Register_CPTs__construct__taxonomies', __('This filter is deprecated. It will still work for the time being.  However, it is recommended to use the new filter provided which is "FHEE__EE_Register_CPTs__get_taxonomies__taxonomies" found in EE_Register_CPTs::get_taxonomies()', 'event_espresso'), '4.5.0', E_USER_DEPRECATED );
565
+function ee_deprecated_get_taxonomies($cts) {
566
+	if (has_filter('FHEE__EE_Register_CPTs__construct__taxonomies')) {
567
+		EE_Error::doing_it_wrong('FHEE__EE_Register_CPTs__construct__taxonomies', __('This filter is deprecated. It will still work for the time being.  However, it is recommended to use the new filter provided which is "FHEE__EE_Register_CPTs__get_taxonomies__taxonomies" found in EE_Register_CPTs::get_taxonomies()', 'event_espresso'), '4.5.0', E_USER_DEPRECATED);
568 568
 	}
569
-	return apply_filters( 'FHEE__EE_Register_CPTs__construct__taxonomies', $cts );
569
+	return apply_filters('FHEE__EE_Register_CPTs__construct__taxonomies', $cts);
570 570
 }
571
-add_filter( 'FHEE__EE_Register_CPTs__get_taxonomies__taxonomies', 'ee_deprecated_get_taxonomies', 10 );
571
+add_filter('FHEE__EE_Register_CPTs__get_taxonomies__taxonomies', 'ee_deprecated_get_taxonomies', 10);
Please login to merge, or discard this patch.
core/admin/EE_Admin.core.php 1 patch
Spacing   +173 added lines, -173 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	 */
48 48
 	public static function instance() {
49 49
 		// check if class object is instantiated
50
-		if (  ! self::$_instance instanceof EE_Admin ) {
50
+		if ( ! self::$_instance instanceof EE_Admin) {
51 51
 			self::$_instance = new self();
52 52
 		}
53 53
 		return self::$_instance;
@@ -62,25 +62,25 @@  discard block
 block discarded – undo
62 62
 		// define global EE_Admin constants
63 63
 		$this->_define_all_constants();
64 64
 		// set autoloaders for our admin page classes based on included path information
65
-		EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder( EE_ADMIN );
65
+		EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_ADMIN);
66 66
 		// admin hooks
67
-		add_filter( 'plugin_action_links', array( $this, 'filter_plugin_actions' ), 10, 2 );
67
+		add_filter('plugin_action_links', array($this, 'filter_plugin_actions'), 10, 2);
68 68
 		// load EE_Request_Handler early
69
-		add_action( 'AHEE__EE_System__core_loaded_and_ready', array( $this, 'get_request' ));
70
-		add_action( 'AHEE__EE_System__initialize_last', array( $this, 'init' ));
71
-		add_action( 'AHEE__EE_Admin_Page__route_admin_request', array( $this, 'route_admin_request' ), 100, 2 );
72
-		add_action( 'wp_loaded', array( $this, 'wp_loaded' ), 100 );
73
-		add_action( 'admin_init', array( $this, 'admin_init' ), 100 );
74
-		add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ), 20 );
75
-		add_action( 'admin_notices', array( $this, 'display_admin_notices' ), 10 );
76
-		add_action( 'network_admin_notices', array( $this, 'display_admin_notices' ), 10 );
77
-		add_filter( 'pre_update_option', array( $this, 'check_for_invalid_datetime_formats' ), 100, 2 );
78
-		add_filter('admin_footer_text', array( $this, 'espresso_admin_footer' ));
69
+		add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'get_request'));
70
+		add_action('AHEE__EE_System__initialize_last', array($this, 'init'));
71
+		add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'route_admin_request'), 100, 2);
72
+		add_action('wp_loaded', array($this, 'wp_loaded'), 100);
73
+		add_action('admin_init', array($this, 'admin_init'), 100);
74
+		add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'), 20);
75
+		add_action('admin_notices', array($this, 'display_admin_notices'), 10);
76
+		add_action('network_admin_notices', array($this, 'display_admin_notices'), 10);
77
+		add_filter('pre_update_option', array($this, 'check_for_invalid_datetime_formats'), 100, 2);
78
+		add_filter('admin_footer_text', array($this, 'espresso_admin_footer'));
79 79
 
80 80
 		//reset Environment config (we only do this on admin page loads);
81 81
 		EE_Registry::instance()->CFG->environment->recheck_values();
82 82
 
83
-		do_action( 'AHEE__EE_Admin__loaded' );
83
+		do_action('AHEE__EE_Admin__loaded');
84 84
 	}
85 85
 
86 86
 
@@ -95,11 +95,11 @@  discard block
 block discarded – undo
95 95
 	 * @return void
96 96
 	 */
97 97
 	private function _define_all_constants() {
98
-		define( 'EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/' );
99
-		define( 'EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/' );
100
-		define( 'EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates' . DS );
101
-		define( 'WP_ADMIN_PATH', ABSPATH . 'wp-admin/' );
102
-		define( 'WP_AJAX_URL', admin_url( 'admin-ajax.php' ));
98
+		define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL.'core/admin/');
99
+		define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL.'admin_pages/');
100
+		define('EE_ADMIN_TEMPLATE', EE_ADMIN.'templates'.DS);
101
+		define('WP_ADMIN_PATH', ABSPATH.'wp-admin/');
102
+		define('WP_AJAX_URL', admin_url('admin-ajax.php'));
103 103
 	}
104 104
 
105 105
 
@@ -112,23 +112,23 @@  discard block
 block discarded – undo
112 112
 	 * @param 	string 	$plugin
113 113
 	 * @return 	array
114 114
 	 */
115
-	public function filter_plugin_actions( $links, $plugin ) {
115
+	public function filter_plugin_actions($links, $plugin) {
116 116
 		// set $main_file in stone
117 117
 		static $main_file;
118 118
 		// if $main_file is not set yet
119
-		if ( ! $main_file ) {
120
-			$main_file = plugin_basename( EVENT_ESPRESSO_MAIN_FILE );
119
+		if ( ! $main_file) {
120
+			$main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE);
121 121
 		}
122
-		 if ( $plugin == $main_file ) {
122
+		 if ($plugin == $main_file) {
123 123
 		 	// compare current plugin to this one
124
-			if ( EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance ) {
125
-				$maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings" title="Event Espresso is in maintenance mode.  Click this link to learn why.">' . __('Maintenance Mode Active', 'event_espresso' ) . '</a>';
126
-				array_unshift( $links, $maintenance_link );
124
+			if (EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance) {
125
+				$maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings" title="Event Espresso is in maintenance mode.  Click this link to learn why.">'.__('Maintenance Mode Active', 'event_espresso').'</a>';
126
+				array_unshift($links, $maintenance_link);
127 127
 			} else {
128
-				$org_settings_link = '<a href="admin.php?page=espresso_general_settings">' . __( 'Settings', 'event_espresso' ) . '</a>';
129
-				$events_link = '<a href="admin.php?page=espresso_events">' . __( 'Events', 'event_espresso' ) . '</a>';
128
+				$org_settings_link = '<a href="admin.php?page=espresso_general_settings">'.__('Settings', 'event_espresso').'</a>';
129
+				$events_link = '<a href="admin.php?page=espresso_events">'.__('Events', 'event_espresso').'</a>';
130 130
 				// add before other links
131
-				array_unshift( $links, $org_settings_link, $events_link );
131
+				array_unshift($links, $org_settings_link, $events_link);
132 132
 			}
133 133
 		}
134 134
 		return $links;
@@ -143,8 +143,8 @@  discard block
 block discarded – undo
143 143
 	 *	@return void
144 144
 	 */
145 145
 	public function get_request() {
146
-		EE_Registry::instance()->load_core( 'Request_Handler' );
147
-		EE_Registry::instance()->load_core( 'CPT_Strategy' );
146
+		EE_Registry::instance()->load_core('Request_Handler');
147
+		EE_Registry::instance()->load_core('CPT_Strategy');
148 148
 	}
149 149
 
150 150
 
@@ -156,11 +156,11 @@  discard block
 block discarded – undo
156 156
 	 * @param array $admin_page_folder_names
157 157
 	 * @return array
158 158
 	 */
159
-	public function hide_admin_pages_except_maintenance_mode( $admin_page_folder_names = array() ){
159
+	public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array()) {
160 160
 		return array(
161
-			'maintenance' => EE_ADMIN_PAGES . 'maintenance' . DS,
162
-			'about' => EE_ADMIN_PAGES . 'about' . DS,
163
-			'support' => EE_ADMIN_PAGES . 'support' . DS
161
+			'maintenance' => EE_ADMIN_PAGES.'maintenance'.DS,
162
+			'about' => EE_ADMIN_PAGES.'about'.DS,
163
+			'support' => EE_ADMIN_PAGES.'support'.DS
164 164
 		);
165 165
 	}
166 166
 
@@ -175,36 +175,36 @@  discard block
 block discarded – undo
175 175
 	public function init() {
176 176
 
177 177
 		//only enable most of the EE_Admin IF we're not in full maintenance mode
178
-		if ( EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance ){
178
+		if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) {
179 179
 			//ok so we want to enable the entire admin
180
-			add_action( 'wp_ajax_dismiss_ee_nag_notice', array( $this, 'dismiss_ee_nag_notice_callback' ));
181
-			add_action( 'save_post', array( 'EE_Admin', 'parse_post_content_on_save' ), 100, 2 );
182
-			add_action( 'update_option', array( $this, 'reset_page_for_posts_on_change' ), 100, 3 );
183
-			add_filter( 'content_save_pre', array( $this, 'its_eSpresso' ), 10, 1 );
184
-			add_action( 'admin_notices', array( $this, 'get_persistent_admin_notices' ), 9 );
185
-			add_action( 'network_admin_notices', array( $this, 'get_persistent_admin_notices' ), 9 );
180
+			add_action('wp_ajax_dismiss_ee_nag_notice', array($this, 'dismiss_ee_nag_notice_callback'));
181
+			add_action('save_post', array('EE_Admin', 'parse_post_content_on_save'), 100, 2);
182
+			add_action('update_option', array($this, 'reset_page_for_posts_on_change'), 100, 3);
183
+			add_filter('content_save_pre', array($this, 'its_eSpresso'), 10, 1);
184
+			add_action('admin_notices', array($this, 'get_persistent_admin_notices'), 9);
185
+			add_action('network_admin_notices', array($this, 'get_persistent_admin_notices'), 9);
186 186
 			//at a glance dashboard widget
187
-			add_filter( 'dashboard_glance_items', array( $this, 'dashboard_glance_items'), 10 );
187
+			add_filter('dashboard_glance_items', array($this, 'dashboard_glance_items'), 10);
188 188
 			//filter for get_edit_post_link used on comments for custom post types
189
-			add_filter('get_edit_post_link', array( $this, 'modify_edit_post_link' ), 10, 3 );
189
+			add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 3);
190 190
 		}
191 191
 
192 192
 		// run the admin page factory but ONLY if we are doing an ee admin ajax request
193
-		if ( !defined('DOING_AJAX') || EE_ADMIN_AJAX ) {
193
+		if ( ! defined('DOING_AJAX') || EE_ADMIN_AJAX) {
194 194
 			try {
195 195
 				//this loads the controller for the admin pages which will setup routing etc
196
-				EE_Registry::instance()->load_core( 'Admin_Page_Loader' );
197
-			} catch ( EE_Error $e ) {
196
+				EE_Registry::instance()->load_core('Admin_Page_Loader');
197
+			} catch (EE_Error $e) {
198 198
 				$e->get_error();
199 199
 			}
200 200
 		}
201 201
 
202 202
 		//make sure our CPTs and custom taxonomy metaboxes get shown for first time users
203
-		add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes' ), 10 );
204
-		add_action('admin_head', array( $this, 'register_custom_nav_menu_boxes' ), 10 );
203
+		add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes'), 10);
204
+		add_action('admin_head', array($this, 'register_custom_nav_menu_boxes'), 10);
205 205
 
206 206
 		//exclude EE critical pages from all nav menus and wp_list_pages
207
-		add_filter('nav_menu_meta_box_object', array( $this, 'remove_pages_from_nav_menu'), 10 );
207
+		add_filter('nav_menu_meta_box_object', array($this, 'remove_pages_from_nav_menu'), 10);
208 208
 	}
209 209
 
210 210
 
@@ -217,9 +217,9 @@  discard block
 block discarded – undo
217 217
 	 * @param  object $post_type WP post type object
218 218
 	 * @return object            WP post type object
219 219
 	 */
220
-	public function remove_pages_from_nav_menu( $post_type ) {
220
+	public function remove_pages_from_nav_menu($post_type) {
221 221
 		//if this isn't the "pages" post type let's get out
222
-		if ( $post_type->name !== 'page' )
222
+		if ($post_type->name !== 'page')
223 223
 			return $post_type;
224 224
 
225 225
 		$critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();
@@ -239,28 +239,28 @@  discard block
 block discarded – undo
239 239
 	 */
240 240
 	public function enable_hidden_ee_nav_menu_metaboxes() {
241 241
 		global $wp_meta_boxes, $pagenow;
242
-		if ( ! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php' ) {
242
+		if ( ! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') {
243 243
 			return;
244 244
 		}
245 245
 		$user = wp_get_current_user();
246 246
 		//has this been done yet?
247
-		if ( get_user_option( 'ee_nav_menu_initialized', $user->ID ) ) {
247
+		if (get_user_option('ee_nav_menu_initialized', $user->ID)) {
248 248
 			return;
249 249
 		}
250 250
 
251
-		$hidden_meta_boxes = get_user_option( 'metaboxhidden_nav-menus', $user->ID );
252
-		$initial_meta_boxes = apply_filters( 'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes', array( 'nav-menu-theme-locations', 'add-page', 'add-custom-links', 'add-category', 'add-espresso_events', 'add-espresso_venues', 'add-espresso_event_categories', 'add-espresso_venue_categories', 'add-post-type-post', 'add-post-type-page' ) );
251
+		$hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus', $user->ID);
252
+		$initial_meta_boxes = apply_filters('FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes', array('nav-menu-theme-locations', 'add-page', 'add-custom-links', 'add-category', 'add-espresso_events', 'add-espresso_venues', 'add-espresso_event_categories', 'add-espresso_venue_categories', 'add-post-type-post', 'add-post-type-page'));
253 253
 
254
-		if ( is_array( $hidden_meta_boxes ) ) {
255
-			foreach ( $hidden_meta_boxes as $key => $meta_box_id ) {
256
-				if ( in_array( $meta_box_id, $initial_meta_boxes ) ) {
257
-					unset( $hidden_meta_boxes[ $key ] );
254
+		if (is_array($hidden_meta_boxes)) {
255
+			foreach ($hidden_meta_boxes as $key => $meta_box_id) {
256
+				if (in_array($meta_box_id, $initial_meta_boxes)) {
257
+					unset($hidden_meta_boxes[$key]);
258 258
 				}
259 259
 			}
260 260
 		}
261 261
 
262
-		update_user_option( $user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true );
263
-		update_user_option( $user->ID, 'ee_nav_menu_initialized', 1, true );
262
+		update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true);
263
+		update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true);
264 264
 	}
265 265
 
266 266
 
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 	 * @return void
280 280
 	 */
281 281
 	public function register_custom_nav_menu_boxes() {
282
-		add_meta_box( 'add-extra-nav-menu-pages', __('Event Espresso Pages', 'event_espresso'), array( $this, 'ee_cpt_archive_pages' ), 'nav-menus', 'side', 'core' );
282
+		add_meta_box('add-extra-nav-menu-pages', __('Event Espresso Pages', 'event_espresso'), array($this, 'ee_cpt_archive_pages'), 'nav-menus', 'side', 'core');
283 283
 	}
284 284
 
285 285
 
@@ -296,16 +296,16 @@  discard block
 block discarded – undo
296 296
 	 *
297 297
 	 * @return string  the (maybe) modified link
298 298
 	 */
299
-	public function modify_edit_post_link( $link, $id, $context ) {
300
-		if ( ! $post = get_post( $id ) )
299
+	public function modify_edit_post_link($link, $id, $context) {
300
+		if ( ! $post = get_post($id))
301 301
 			return $link;
302 302
 
303
-		if ( $post->post_type == 'espresso_attendees' ) {
303
+		if ($post->post_type == 'espresso_attendees') {
304 304
 			$query_args = array(
305 305
 				'action' => 'edit_attendee',
306 306
 				'post' => $id
307 307
 				);
308
-			return EEH_URL::add_query_args_and_nonce( $query_args, admin_url('admin.php?page=espresso_registrations') );
308
+			return EEH_URL::add_query_args_and_nonce($query_args, admin_url('admin.php?page=espresso_registrations'));
309 309
 		}
310 310
 		return $link;
311 311
 	}
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 		global $nav_menu_selected_id;
318 318
 
319 319
 		$db_fields = false;
320
-		$walker = new Walker_Nav_Menu_Checklist( $db_fields );
320
+		$walker = new Walker_Nav_Menu_Checklist($db_fields);
321 321
 		$current_tab = 'event-archives';
322 322
 
323 323
 		/*if ( ! empty( $_REQUEST['quick-search-posttype-' . $post_type_name] ) ) {
@@ -336,9 +336,9 @@  discard block
 block discarded – undo
336 336
 		?>
337 337
 		<div id="posttype-extra-nav-menu-pages" class="posttypediv">
338 338
 			<ul id="posttype-extra-nav-menu-pages-tabs" class="posttype-tabs add-menu-item-tabs">
339
-				<li <?php echo ( 'event-archives' == $current_tab ? ' class="tabs"' : '' ); ?>>
340
-					<a class="nav-tab-link" data-type="tabs-panel-posttype-extra-nav-menu-pages-event-archives" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg('extra-nav-menu-pages-tab', 'event-archives', remove_query_arg($removed_args))); ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives">
341
-						<?php _e( 'Event Archive Pages', 'event_espresso' ); ?>
339
+				<li <?php echo ('event-archives' == $current_tab ? ' class="tabs"' : ''); ?>>
340
+					<a class="nav-tab-link" data-type="tabs-panel-posttype-extra-nav-menu-pages-event-archives" href="<?php if ($nav_menu_selected_id) echo esc_url(add_query_arg('extra-nav-menu-pages-tab', 'event-archives', remove_query_arg($removed_args))); ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives">
341
+						<?php _e('Event Archive Pages', 'event_espresso'); ?>
342 342
 					</a>
343 343
 				</li>
344 344
 			<?php /* // temporarily removing but leaving skeleton in place in case we ever decide to add more tabs.
@@ -356,13 +356,13 @@  discard block
 block discarded – undo
356 356
  			<?php */ ?>
357 357
 
358 358
 			<div id="tabs-panel-posttype-extra-nav-menu-pages-event-archives" class="tabs-panel <?php
359
-			echo ( 'event-archives' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
359
+			echo ('event-archives' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive');
360 360
 			?>">
361 361
 				<ul id="extra-nav-menu-pageschecklist-event-archives" class="categorychecklist form-no-clear">
362 362
 					<?php
363 363
 					$pages = $this->_get_extra_nav_menu_pages_items();
364 364
 					$args['walker'] = $walker;
365
-					echo walk_nav_menu_tree( array_map( array( $this, '_setup_extra_nav_menu_pages_items' ), $pages), 0, (object) $args );
365
+					echo walk_nav_menu_tree(array_map(array($this, '_setup_extra_nav_menu_pages_items'), $pages), 0, (object) $args);
366 366
 					?>
367 367
 				</ul>
368 368
 			</div><!-- /.tabs-panel -->
@@ -370,18 +370,18 @@  discard block
 block discarded – undo
370 370
 			<p class="button-controls">
371 371
 				<span class="list-controls">
372 372
 					<a href="<?php
373
-						echo esc_url( add_query_arg(
373
+						echo esc_url(add_query_arg(
374 374
 							array(
375 375
 								'extra-nav-menu-pages-tab' => 'event-archives',
376 376
 								'selectall' => 1,
377 377
 							),
378
-							remove_query_arg( $removed_args )
378
+							remove_query_arg($removed_args)
379 379
 						));
380 380
 					?>#posttype-extra-nav-menu-pages>" class="select-all"><?php _e('Select All'); ?></a>
381 381
 				</span>
382 382
 
383 383
 				<span class="add-to-menu">
384
-					<input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( __( 'Add to Menu' ) ); ?>" name="add-post-type-menu-item" id="<?php esc_attr_e( 'submit-posttype-extra-nav-menu-pages' ); ?>" />
384
+					<input type="submit"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e(__('Add to Menu')); ?>" name="add-post-type-menu-item" id="<?php esc_attr_e('submit-posttype-extra-nav-menu-pages'); ?>" />
385 385
 					<span class="spinner"></span>
386 386
 				</span>
387 387
 			</p>
@@ -402,10 +402,10 @@  discard block
 block discarded – undo
402 402
 	private function _get_extra_nav_menu_pages_items() {
403 403
 		$menuitems[] = array(
404 404
 			'title' => __('Event List', 'event_espresso'),
405
-			'url' => get_post_type_archive_link( 'espresso_events' ),
405
+			'url' => get_post_type_archive_link('espresso_events'),
406 406
 			'description' => __('Archive page for all events.', 'event_espresso')
407 407
 		);
408
-		return apply_filters( 'FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems );
408
+		return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems);
409 409
 	}
410 410
 
411 411
 
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
 	 * @param $menu_item_values
418 418
 	 * @return stdClass
419 419
 	 */
420
-	private function _setup_extra_nav_menu_pages_items( $menu_item_values ) {
420
+	private function _setup_extra_nav_menu_pages_items($menu_item_values) {
421 421
 		$menu_item = new stdClass();
422 422
 		$keys = array(
423 423
 			'ID' => 0,
@@ -437,8 +437,8 @@  discard block
 block discarded – undo
437 437
 			'xfn' => ''
438 438
 		);
439 439
 
440
-		foreach ( $keys as $key => $value) {
441
-			$menu_item->{$key} = isset( $menu_item_values[ $key]) ? $menu_item_values[ $key] : $value;
440
+		foreach ($keys as $key => $value) {
441
+			$menu_item->{$key} = isset($menu_item_values[$key]) ? $menu_item_values[$key] : $value;
442 442
 		}
443 443
 		return $menu_item;
444 444
 	}
@@ -477,10 +477,10 @@  discard block
 block discarded – undo
477 477
 		 * - check if doing post processing of one of EE CPTs
478 478
 		 * - instantiate the corresponding EE CPT model for the post_type being processed.
479 479
 		 */
480
-		if ( isset( $_POST['action'] ) && $_POST['action'] == 'editpost' ) {
481
-			if ( isset( $_POST['post_type'] ) ) {
482
-				EE_Registry::instance()->load_core( 'Register_CPTs' );
483
-				EE_Register_CPTs::instantiate_cpt_models( $_POST['post_type'] );
480
+		if (isset($_POST['action']) && $_POST['action'] == 'editpost') {
481
+			if (isset($_POST['post_type'])) {
482
+				EE_Registry::instance()->load_core('Register_CPTs');
483
+				EE_Register_CPTs::instantiate_cpt_models($_POST['post_type']);
484 484
 			}
485 485
 		}
486 486
 
@@ -490,8 +490,8 @@  discard block
 block discarded – undo
490 490
 		 * 'options-reading.php' core WordPress admin settings page.  This is for user-proofing.
491 491
 		 */
492 492
 		global $pagenow;
493
-		if ( $pagenow == 'options-reading.php' ) {
494
-			add_filter( 'wp_dropdown_pages', array( $this, 'modify_dropdown_pages' ) );
493
+		if ($pagenow == 'options-reading.php') {
494
+			add_filter('wp_dropdown_pages', array($this, 'modify_dropdown_pages'));
495 495
 		}
496 496
 
497 497
 	}
@@ -503,25 +503,25 @@  discard block
 block discarded – undo
503 503
 	 * @param string $output  Current output.
504 504
 	 * @return string
505 505
 	 */
506
-	public function modify_dropdown_pages( $output ) {
506
+	public function modify_dropdown_pages($output) {
507 507
 		//get critical pages
508 508
 		$critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();
509 509
 
510 510
 		//split current output by line break for easier parsing.
511
-		$split_output = explode( "\n", $output );
511
+		$split_output = explode("\n", $output);
512 512
 
513 513
 		//loop through to remove any critical pages from the array.
514
-		foreach ( $critical_pages as $page_id ) {
515
-			$needle = 'value="' . $page_id . '"';
516
-			foreach( $split_output as $key => $haystack ) {
517
-				if( strpos( $haystack, $needle ) !== false ) {
518
-					unset( $split_output[$key] );
514
+		foreach ($critical_pages as $page_id) {
515
+			$needle = 'value="'.$page_id.'"';
516
+			foreach ($split_output as $key => $haystack) {
517
+				if (strpos($haystack, $needle) !== false) {
518
+					unset($split_output[$key]);
519 519
 				}
520 520
 			}
521 521
 		}
522 522
 
523 523
 		//replace output with the new contents
524
-		$output = implode( "\n", $split_output );
524
+		$output = implode("\n", $split_output);
525 525
 
526 526
 		return $output;
527 527
 	}
@@ -537,36 +537,36 @@  discard block
 block discarded – undo
537 537
 	public function enqueue_admin_scripts() {
538 538
 		// this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js.
539 539
 		// Note: the intention of this script is to only do TARGETED injections.  I.E, only injecting on certain script calls.
540
-		wp_enqueue_script('ee-inject-wp', EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE);
540
+		wp_enqueue_script('ee-inject-wp', EE_ADMIN_URL.'assets/ee-cpt-wp-injects.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE);
541 541
 		// register cookie script for future dependencies
542
-		wp_register_script('jquery-cookie', EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js', array('jquery'), '2.1', TRUE );
542
+		wp_register_script('jquery-cookie', EE_THIRD_PARTY_URL.'joyride/jquery.cookie.js', array('jquery'), '2.1', TRUE);
543 543
 		// jquery_validate loading is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again via:  add_filter( 'FHEE_load_jquery_validate', '__return_true' );
544
-		if ( apply_filters( 'FHEE_load_jquery_validate', FALSE ) ) {
544
+		if (apply_filters('FHEE_load_jquery_validate', FALSE)) {
545 545
 			// register jQuery Validate
546
-			wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', array('jquery'), '1.15.0', TRUE);
546
+			wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js', array('jquery'), '1.15.0', TRUE);
547 547
 		}
548 548
 		//joyride is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again vai: add_filter('FHEE_load_joyride', '__return_true' );
549
-		if ( apply_filters( 'FHEE_load_joyride', FALSE ) ) {
549
+		if (apply_filters('FHEE_load_joyride', FALSE)) {
550 550
 			//joyride style
551
-			wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1');
552
-			wp_register_style('ee-joyride-css', EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css', array('joyride-css'), EVENT_ESPRESSO_VERSION );
553
-			wp_register_script('joyride-modernizr', EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js', array(), '2.1', TRUE );
551
+			wp_register_style('joyride-css', EE_THIRD_PARTY_URL.'joyride/joyride-2.1.css', array(), '2.1');
552
+			wp_register_style('ee-joyride-css', EE_GLOBAL_ASSETS_URL.'css/ee-joyride-styles.css', array('joyride-css'), EVENT_ESPRESSO_VERSION);
553
+			wp_register_script('joyride-modernizr', EE_THIRD_PARTY_URL.'joyride/modernizr.mq.js', array(), '2.1', TRUE);
554 554
 			//joyride JS
555
-			wp_register_script('jquery-joyride', EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js', array('jquery-cookie', 'joyride-modernizr'), '2.1', TRUE );
555
+			wp_register_script('jquery-joyride', EE_THIRD_PARTY_URL.'joyride/jquery.joyride-2.1.js', array('jquery-cookie', 'joyride-modernizr'), '2.1', TRUE);
556 556
 			// wanna go for a joyride?
557 557
 			wp_enqueue_style('ee-joyride-css');
558 558
 			wp_enqueue_script('jquery-joyride');
559 559
 		}
560 560
 		//qtip is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again via: add_filter('FHEE_load_qtips', '__return_true' );
561
-		if ( apply_filters( 'FHEE_load_qtip', FALSE ) ) {
561
+		if (apply_filters('FHEE_load_qtip', FALSE)) {
562 562
 			EEH_Qtip_Loader::instance()->register_and_enqueue();
563 563
 		}
564 564
 		//accounting.js library
565 565
 		// @link http://josscrowcroft.github.io/accounting.js/
566
-		if ( apply_filters( 'FHEE_load_accounting_js', FALSE ) ) {
567
-			wp_register_script( 'ee-accounting', EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', array('ee-accounting-core'), EVENT_ESPRESSO_VERSION, TRUE );
568
-			wp_register_script( 'ee-accounting-core', EE_THIRD_PARTY_URL . 'accounting/accounting.js', array('underscore'), '0.3.2', TRUE );
569
-			wp_enqueue_script( 'ee-accounting' );
566
+		if (apply_filters('FHEE_load_accounting_js', FALSE)) {
567
+			wp_register_script('ee-accounting', EE_GLOBAL_ASSETS_URL.'scripts/ee-accounting-config.js', array('ee-accounting-core'), EVENT_ESPRESSO_VERSION, TRUE);
568
+			wp_register_script('ee-accounting-core', EE_THIRD_PARTY_URL.'accounting/accounting.js', array('underscore'), '0.3.2', TRUE);
569
+			wp_enqueue_script('ee-accounting');
570 570
 			// array of settings to get converted to JSON array via wp_localize_script
571 571
 			$currency_config = array(
572 572
 				'currency' => array(
@@ -613,11 +613,11 @@  discard block
 block discarded – undo
613 613
 	public function get_persistent_admin_notices() {
614 614
 		// http://www.example.com/wp-admin/admin.php?page=espresso_general_settings&action=critical_pages&critical_pages_nonce=2831ce0f30
615 615
 		$args = array(
616
-			'page' => EE_Registry::instance()->REQ->is_set( 'page' ) ? EE_Registry::instance()->REQ->get( 'page' ) : '',
617
-			'action' => EE_Registry::instance()->REQ->is_set( 'action' ) ? EE_Registry::instance()->REQ->get( 'action' ) : '',
616
+			'page' => EE_Registry::instance()->REQ->is_set('page') ? EE_Registry::instance()->REQ->get('page') : '',
617
+			'action' => EE_Registry::instance()->REQ->is_set('action') ? EE_Registry::instance()->REQ->get('action') : '',
618 618
 		);
619
-		$return_url = EE_Admin_Page::add_query_args_and_nonce( $args, EE_ADMIN_URL );
620
-		echo EE_Error::get_persistent_admin_notices( $return_url );
619
+		$return_url = EE_Admin_Page::add_query_args_and_nonce($args, EE_ADMIN_URL);
620
+		echo EE_Error::get_persistent_admin_notices($return_url);
621 621
 	}
622 622
 
623 623
 
@@ -638,26 +638,26 @@  discard block
 block discarded – undo
638 638
 	 * @param $elements
639 639
 	 * @return array
640 640
 	 */
641
-	public function dashboard_glance_items( $elements ) {
641
+	public function dashboard_glance_items($elements) {
642 642
 		$events = EEM_Event::instance()->count();
643
-		$items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce( array('page' => 'espresso_events'), admin_url('admin.php') );
644
-		$items['events']['text'] = sprintf( _n( '%s Event', '%s Events', $events ), number_format_i18n( $events ) );
643
+		$items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce(array('page' => 'espresso_events'), admin_url('admin.php'));
644
+		$items['events']['text'] = sprintf(_n('%s Event', '%s Events', $events), number_format_i18n($events));
645 645
 		$items['events']['title'] = __('Click to view all Events', 'event_espresso');
646 646
 		$registrations = EEM_Registration::instance()->count(
647 647
 			array(
648 648
 				array(
649
-					'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete )
649
+					'STS_ID' => array('!=', EEM_Registration::status_id_incomplete)
650 650
 				)
651 651
 			)
652 652
 		);
653
-		$items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce( array('page' => 'espresso_registrations' ), admin_url('admin.php') );
654
-		$items['registrations']['text'] = sprintf( _n( '%s Registration', '%s Registrations', $registrations ), number_format_i18n($registrations) );
653
+		$items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce(array('page' => 'espresso_registrations'), admin_url('admin.php'));
654
+		$items['registrations']['text'] = sprintf(_n('%s Registration', '%s Registrations', $registrations), number_format_i18n($registrations));
655 655
 		$items['registrations']['title'] = __('Click to view all registrations', 'event_espresso');
656 656
 
657
-		$items = apply_filters( 'FHEE__EE_Admin__dashboard_glance_items__items', $items );
657
+		$items = apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items);
658 658
 
659
-		foreach ( $items as $type => $item_properties ) {
660
-			$elements[] = sprintf( '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>', $item_properties['url'], $item_properties['title'], $item_properties['text'] );
659
+		foreach ($items as $type => $item_properties) {
660
+			$elements[] = sprintf('<a class="ee-dashboard-link-'.$type.'" href="%s" title="%s">%s</a>', $item_properties['url'], $item_properties['title'], $item_properties['text']);
661 661
 		}
662 662
 		return $elements;
663 663
 	}
@@ -676,63 +676,63 @@  discard block
 block discarded – undo
676 676
 	 * @param $post
677 677
 	 * @return    void
678 678
 	 */
679
-	public static function parse_post_content_on_save( $post_ID, $post ) {
679
+	public static function parse_post_content_on_save($post_ID, $post) {
680 680
 		// default post types
681
-		$post_types = array( 'post' => 0, 'page' => 1 );
681
+		$post_types = array('post' => 0, 'page' => 1);
682 682
 		// add CPTs
683 683
 		$CPTs = EE_Register_CPTs::get_CPTs();
684
-		$post_types = array_merge( $post_types, $CPTs );
684
+		$post_types = array_merge($post_types, $CPTs);
685 685
 		// for default or CPT posts...
686
-		if ( isset( $post_types[ $post->post_type ] )) {
686
+		if (isset($post_types[$post->post_type])) {
687 687
 			// post on frontpage ?
688 688
 			$page_for_posts = EE_Config::get_page_for_posts();
689 689
 			$maybe_remove_from_posts = array();
690 690
 			// critical page shortcodes that we do NOT want added to the Posts page (blog)
691 691
 			$critical_shortcodes = EE_Registry::instance()->CFG->core->get_critical_pages_shortcodes_array();
692 692
 			// array of shortcodes indexed by post name
693
-			EE_Registry::instance()->CFG->core->post_shortcodes = isset( EE_Registry::instance()->CFG->core->post_shortcodes ) ? EE_Registry::instance()->CFG->core->post_shortcodes : array();
693
+			EE_Registry::instance()->CFG->core->post_shortcodes = isset(EE_Registry::instance()->CFG->core->post_shortcodes) ? EE_Registry::instance()->CFG->core->post_shortcodes : array();
694 694
 			// whether to proceed with update, if an entry already exists for this post, then we want to update
695
-			$update_post_shortcodes = isset( EE_Registry::instance()->CFG->core->post_shortcodes[ $post->post_name ] ) ? true : false;
695
+			$update_post_shortcodes = isset(EE_Registry::instance()->CFG->core->post_shortcodes[$post->post_name]) ? true : false;
696 696
 			// empty both arrays
697
-			EE_Registry::instance()->CFG->core->post_shortcodes[ $post->post_name ] = array();
697
+			EE_Registry::instance()->CFG->core->post_shortcodes[$post->post_name] = array();
698 698
 			// check that posts page is already being tracked
699
-			if ( ! isset( EE_Registry::instance()->CFG->core->post_shortcodes[ $page_for_posts ] ) ) {
699
+			if ( ! isset(EE_Registry::instance()->CFG->core->post_shortcodes[$page_for_posts])) {
700 700
 				// if not, then ensure that it is properly added
701
-				EE_Registry::instance()->CFG->core->post_shortcodes[ $page_for_posts ] = array();
701
+				EE_Registry::instance()->CFG->core->post_shortcodes[$page_for_posts] = array();
702 702
 			}
703 703
 			// loop thru shortcodes
704
-			foreach ( EE_Registry::instance()->shortcodes as $EES_Shortcode => $shortcode_dir ) {
704
+			foreach (EE_Registry::instance()->shortcodes as $EES_Shortcode => $shortcode_dir) {
705 705
 				// convert to UPPERCASE to get actual shortcode
706
-				$EES_Shortcode = strtoupper( $EES_Shortcode );
706
+				$EES_Shortcode = strtoupper($EES_Shortcode);
707 707
 				// is the shortcode in the post_content ?
708
-				if ( strpos( $post->post_content, $EES_Shortcode ) !== FALSE ) {
708
+				if (strpos($post->post_content, $EES_Shortcode) !== FALSE) {
709 709
 					// map shortcode to post names and post IDs
710
-					EE_Registry::instance()->CFG->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] = $post_ID;
710
+					EE_Registry::instance()->CFG->core->post_shortcodes[$post->post_name][$EES_Shortcode] = $post_ID;
711 711
 					// if the shortcode is NOT one of the critical page shortcodes like ESPRESSO_TXN_PAGE
712
-					if ( ! in_array( $EES_Shortcode, $critical_shortcodes )) {
712
+					if ( ! in_array($EES_Shortcode, $critical_shortcodes)) {
713 713
 						// add shortcode to "Posts page" tracking
714
-						EE_Registry::instance()->CFG->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] = $post_ID;
714
+						EE_Registry::instance()->CFG->core->post_shortcodes[$page_for_posts][$EES_Shortcode] = $post_ID;
715 715
 					}
716 716
 					$update_post_shortcodes = TRUE;
717
-					unset( $maybe_remove_from_posts[ $EES_Shortcode ] );
717
+					unset($maybe_remove_from_posts[$EES_Shortcode]);
718 718
 				} else {
719
-					$maybe_remove_from_posts[ $EES_Shortcode ] = $post_ID;
719
+					$maybe_remove_from_posts[$EES_Shortcode] = $post_ID;
720 720
 				}
721 721
 			}
722
-			if ( $update_post_shortcodes ) {
722
+			if ($update_post_shortcodes) {
723 723
 				// remove shortcodes from $maybe_remove_from_posts that are still being used
724
-				foreach ( EE_Registry::instance()->CFG->core->post_shortcodes as $post_name => $shortcodes ) {
725
-					if ( $post_name == $page_for_posts ) {
724
+				foreach (EE_Registry::instance()->CFG->core->post_shortcodes as $post_name => $shortcodes) {
725
+					if ($post_name == $page_for_posts) {
726 726
 						continue;
727 727
 					}
728 728
 					// compute difference between active post_shortcodes array and $maybe_remove_from_posts array
729
-					$maybe_remove_from_posts = array_diff_key( $maybe_remove_from_posts, $shortcodes );
729
+					$maybe_remove_from_posts = array_diff_key($maybe_remove_from_posts, $shortcodes);
730 730
 				}
731 731
 				// now unset unused shortcodes from the $page_for_posts post_shortcodes
732
-				foreach ( $maybe_remove_from_posts as $shortcode => $post_ID ) {
733
-					unset( EE_Registry::instance()->CFG->core->post_shortcodes[ $page_for_posts ][ $shortcode ] );
732
+				foreach ($maybe_remove_from_posts as $shortcode => $post_ID) {
733
+					unset(EE_Registry::instance()->CFG->core->post_shortcodes[$page_for_posts][$shortcode]);
734 734
 				}
735
-				EE_Registry::instance()->CFG->update_post_shortcodes( $page_for_posts );
735
+				EE_Registry::instance()->CFG->update_post_shortcodes($page_for_posts);
736 736
 			}
737 737
 		}
738 738
 	}
@@ -750,31 +750,31 @@  discard block
 block discarded – undo
750 750
 	 * @throws EE_Error
751 751
 	 * @return    string
752 752
 	 */
753
-	public function check_for_invalid_datetime_formats( $value, $option ) {
753
+	public function check_for_invalid_datetime_formats($value, $option) {
754 754
 		// check for date_format or time_format
755
-		switch ( $option ) {
755
+		switch ($option) {
756 756
 			case 'date_format' :
757
-				$date_time_format = $value . ' ' . get_option('time_format');
757
+				$date_time_format = $value.' '.get_option('time_format');
758 758
 				break;
759 759
 			case 'time_format' :
760
-				$date_time_format = get_option('date_format') . ' ' . $value;
760
+				$date_time_format = get_option('date_format').' '.$value;
761 761
 				break;
762 762
 			default :
763 763
 				$date_time_format = FALSE;
764 764
 		}
765 765
 		// do we have a date_time format to check ?
766
-		if ( $date_time_format ) {
767
-			$error_msg = EEH_DTT_Helper::validate_format_string( $date_time_format );
766
+		if ($date_time_format) {
767
+			$error_msg = EEH_DTT_Helper::validate_format_string($date_time_format);
768 768
 
769
-			if ( is_array( $error_msg ) ) {
770
-				$msg = '<p>' . sprintf( __( 'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:', 'event_espresso' ), date( $date_time_format ) , $date_time_format  ) . '</p><p><ul>';
769
+			if (is_array($error_msg)) {
770
+				$msg = '<p>'.sprintf(__('The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:', 'event_espresso'), date($date_time_format), $date_time_format).'</p><p><ul>';
771 771
 
772 772
 
773
-				foreach ( $error_msg as $error ) {
774
-					$msg .= '<li>' . $error . '</li>';
773
+				foreach ($error_msg as $error) {
774
+					$msg .= '<li>'.$error.'</li>';
775 775
 				}
776 776
 
777
-				$msg .= '</ul></p><p>' . sprintf( __( '%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s', 'event_espresso' ), '<span style="color:#D54E21;">', '</span>' ) . '</p>';
777
+				$msg .= '</ul></p><p>'.sprintf(__('%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s', 'event_espresso'), '<span style="color:#D54E21;">', '</span>').'</p>';
778 778
 
779 779
 				// trigger WP settings error
780 780
 				add_settings_error(
@@ -784,7 +784,7 @@  discard block
 block discarded – undo
784 784
 				);
785 785
 
786 786
 				// set format to something valid
787
-				switch ( $option ) {
787
+				switch ($option) {
788 788
 					case 'date_format' :
789 789
 						$value = 'F j, Y';
790 790
 						break;
@@ -810,14 +810,14 @@  discard block
 block discarded – undo
810 810
 	 * @param 	$value
811 811
 	 * @return 	void
812 812
 	 */
813
-	public function reset_page_for_posts_on_change( $option, $old_value, $value ) {
814
-		if ( $option == 'page_for_posts' ) {
813
+	public function reset_page_for_posts_on_change($option, $old_value, $value) {
814
+		if ($option == 'page_for_posts') {
815 815
 			global $wpdb;
816
-			$SQL = 'SELECT post_name from ' . $wpdb->posts . ' WHERE post_type="posts" OR post_type="page" AND post_status="publish" AND ID=%s';
817
-			$old_page_for_posts = $old_value ? $wpdb->get_var( $wpdb->prepare( $SQL, $old_value )) : 'posts';
818
-			$new_page_for_posts = $value ? $wpdb->get_var( $wpdb->prepare( $SQL, $value )) : 'posts';
819
-			EE_Registry::instance()->CFG->core->post_shortcodes[ $new_page_for_posts ] = EE_Registry::instance()->CFG->core->post_shortcodes[ $old_page_for_posts ];
820
-			EE_Registry::instance()->CFG->update_post_shortcodes( $new_page_for_posts );
816
+			$SQL = 'SELECT post_name from '.$wpdb->posts.' WHERE post_type="posts" OR post_type="page" AND post_status="publish" AND ID=%s';
817
+			$old_page_for_posts = $old_value ? $wpdb->get_var($wpdb->prepare($SQL, $old_value)) : 'posts';
818
+			$new_page_for_posts = $value ? $wpdb->get_var($wpdb->prepare($SQL, $value)) : 'posts';
819
+			EE_Registry::instance()->CFG->core->post_shortcodes[$new_page_for_posts] = EE_Registry::instance()->CFG->core->post_shortcodes[$old_page_for_posts];
820
+			EE_Registry::instance()->CFG->update_post_shortcodes($new_page_for_posts);
821 821
 		}
822 822
 	}
823 823
 
@@ -830,8 +830,8 @@  discard block
 block discarded – undo
830 830
 	 * @param $content
831 831
 	 * @return    string
832 832
 	 */
833
-	public function its_eSpresso( $content ) {
834
-		return str_replace( '[EXPRESSO_', '[ESPRESSO_', $content );
833
+	public function its_eSpresso($content) {
834
+		return str_replace('[EXPRESSO_', '[ESPRESSO_', $content);
835 835
 	}
836 836
 
837 837
 
@@ -844,9 +844,9 @@  discard block
 block discarded – undo
844 844
 	 */
845 845
 	public function espresso_admin_footer() {
846 846
 		return sprintf(
847
-			__( 'Event Registration and Ticketing Powered by %sEvent Registration Powered by Event Espresso%s', 'event_espresso' ),
847
+			__('Event Registration and Ticketing Powered by %sEvent Registration Powered by Event Espresso%s', 'event_espresso'),
848 848
 			'<a href="https://eventespresso.com/" title="',
849
-			'">' . EVENT_ESPRESSO_POWERED_BY . '</a>'
849
+			'">'.EVENT_ESPRESSO_POWERED_BY.'</a>'
850 850
 		);
851 851
 	}
852 852
 
@@ -866,11 +866,11 @@  discard block
 block discarded – undo
866 866
 	 * @param array $config
867 867
 	 * @return void
868 868
 	 */
869
-	public static function register_ee_admin_page( $page_basename, $page_path, $config = array() ) {
870
-		EE_Error::doing_it_wrong( __METHOD__, sprintf( __('Usage is deprecated.  Use EE_Register_Admin_Page::register() for registering the %s admin page.', 'event_espresso'), $page_basename), '4.3' );
871
-		if ( class_exists( 'EE_Register_Admin_Page' ) )
869
+	public static function register_ee_admin_page($page_basename, $page_path, $config = array()) {
870
+		EE_Error::doing_it_wrong(__METHOD__, sprintf(__('Usage is deprecated.  Use EE_Register_Admin_Page::register() for registering the %s admin page.', 'event_espresso'), $page_basename), '4.3');
871
+		if (class_exists('EE_Register_Admin_Page'))
872 872
 			$config['page_path'] = $page_path;
873
-			EE_Register_Admin_Page::register( $page_basename, $config );
873
+			EE_Register_Admin_Page::register($page_basename, $config);
874 874
 	}
875 875
 
876 876
 
Please login to merge, or discard this patch.
core/db_models/EEM_Base.model.php 1 patch
Spacing   +961 added lines, -961 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
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 	 * Flag indicating whether this model has a primary key or not
237 237
 	 * @var boolean
238 238
 	 */
239
-	protected $_has_primary_key_field=null;
239
+	protected $_has_primary_key_field = null;
240 240
 
241 241
 	/**
242 242
 	 * Whether or not this model is based off a table in WP core only (CPTs should set
@@ -298,19 +298,19 @@  discard block
 block discarded – undo
298 298
 	 * operators that work like 'BETWEEN'.  Typically used for datetime calculations, i.e. "BETWEEN '12-1-2011' AND '12-31-2012'"
299 299
 	 * @var array
300 300
 	 */
301
-	protected $_between_style_operators = array( 'BETWEEN' );
301
+	protected $_between_style_operators = array('BETWEEN');
302 302
 
303 303
 	/**
304 304
 	 * operators that are used for handling NUll and !NULL queries.  Typically used for when checking if a row exists on a join table.
305 305
 	 * @var array
306 306
 	 */
307
-	protected $_null_style_operators = array( 'IS NOT NULL', 'IS NULL');
307
+	protected $_null_style_operators = array('IS NOT NULL', 'IS NULL');
308 308
 
309 309
 	/**
310 310
 	 * Allowed values for $query_params['order'] for ordering in queries
311 311
 	 * @var array
312 312
 	 */
313
-	protected $_allowed_order_values = array('asc','desc','ASC','DESC');
313
+	protected $_allowed_order_values = array('asc', 'desc', 'ASC', 'DESC');
314 314
 
315 315
 	/**
316 316
 	 * When these are keys in a WHERE or HAVING clause, they are handled much differently
@@ -324,13 +324,13 @@  discard block
 block discarded – undo
324 324
 	 * 'where', but 'where' clauses are so common that we thought we'd omit it
325 325
 	 * @var array
326 326
 	 */
327
-	private $_allowed_query_params = array(0, 'limit','order_by','group_by','having','force_join','order','on_join_limit','default_where_conditions', 'caps');
327
+	private $_allowed_query_params = array(0, 'limit', 'order_by', 'group_by', 'having', 'force_join', 'order', 'on_join_limit', 'default_where_conditions', 'caps');
328 328
 
329 329
 	/**
330 330
 	 * All the data types that can be used in $wpdb->prepare statements.
331 331
 	 * @var array
332 332
 	 */
333
-	private $_valid_wpdb_data_types = array('%d','%s','%f');
333
+	private $_valid_wpdb_data_types = array('%d', '%s', '%f');
334 334
 
335 335
 	/**
336 336
 	 * 	EE_Registry Object
@@ -363,17 +363,17 @@  discard block
 block discarded – undo
363 363
 	/**
364 364
 	 * constant used to show EEM_Base has not yet verified the db on this http request
365 365
 	 */
366
-	const db_verified_none 		= 0;
366
+	const db_verified_none = 0;
367 367
 	/**
368 368
 	 * constant used to show EEM_Base has verified the EE core db on this http request,
369 369
 	 * but not the addons' dbs
370 370
 	 */
371
-	const db_verified_core 		= 1;
371
+	const db_verified_core = 1;
372 372
 	/**
373 373
 	 * constant used to show EEM_Base has verified the addons' dbs (and implicitly
374 374
 	 * the EE core db too)
375 375
 	 */
376
-	const db_verified_addons 	= 2;
376
+	const db_verified_addons = 2;
377 377
 
378 378
 	/**
379 379
 	 * indicates whether an EEM_Base child has already re-verified the DB
@@ -404,13 +404,13 @@  discard block
 block discarded – undo
404 404
 	 * @param null $timezone
405 405
 	 * @throws \EE_Error
406 406
 	 */
407
-	protected function __construct( $timezone = NULL ){
407
+	protected function __construct($timezone = NULL) {
408 408
 		// check that the model has not been loaded too soon
409
-		if ( ! did_action( 'AHEE__EE_System__load_espresso_addons' )) {
410
-			throw new EE_Error (
409
+		if ( ! did_action('AHEE__EE_System__load_espresso_addons')) {
410
+			throw new EE_Error(
411 411
 				sprintf(
412
-					__( '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' ),
413
-					get_class( $this )
412
+					__('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'),
413
+					get_class($this)
414 414
 				)
415 415
 			);
416 416
 		}
@@ -420,11 +420,11 @@  discard block
 block discarded – undo
420 420
 		 * just use EE_Register_Model_Extension
421 421
 		 * @var EE_Table_Base[] $_tables
422 422
 		 */
423
-		$this->_tables = apply_filters( 'FHEE__'.get_class($this).'__construct__tables', $this->_tables );
424
-		foreach($this->_tables as $table_alias => $table_obj){
423
+		$this->_tables = apply_filters('FHEE__'.get_class($this).'__construct__tables', $this->_tables);
424
+		foreach ($this->_tables as $table_alias => $table_obj) {
425 425
 			/** @var $table_obj EE_Table_Base */
426 426
 			$table_obj->_construct_finalize_with_alias($table_alias);
427
-			if( $table_obj instanceof EE_Secondary_Table ){
427
+			if ($table_obj instanceof EE_Secondary_Table) {
428 428
 				/** @var $table_obj EE_Secondary_Table */
429 429
 				$table_obj->_construct_finalize_set_table_to_join_with($this->_get_main_table());
430 430
 			}
@@ -434,54 +434,54 @@  discard block
 block discarded – undo
434 434
 		 * EE_Register_Model_Extension
435 435
 		 * @param EE_Model_Field_Base[] $_fields
436 436
 		 */
437
-		$this->_fields = apply_filters('FHEE__'.get_class($this).'__construct__fields',$this->_fields);
437
+		$this->_fields = apply_filters('FHEE__'.get_class($this).'__construct__fields', $this->_fields);
438 438
 		$this->_invalidate_field_caches();
439
-		foreach($this->_fields as $table_alias => $fields_for_table){
440
-			if ( ! array_key_exists( $table_alias, $this->_tables )){
441
-				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)));
439
+		foreach ($this->_fields as $table_alias => $fields_for_table) {
440
+			if ( ! array_key_exists($table_alias, $this->_tables)) {
441
+				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)));
442 442
 			}
443
-			foreach($fields_for_table as $field_name => $field_obj){
443
+			foreach ($fields_for_table as $field_name => $field_obj) {
444 444
 				/** @var $field_obj EE_Model_Field_Base | EE_Primary_Key_Field_Base */
445 445
 				//primary key field base has a slightly different _construct_finalize
446 446
 				/** @var $field_obj EE_Model_Field_Base */
447
-				$field_obj->_construct_finalize( $table_alias, $field_name, $this->get_this_model_name() );
447
+				$field_obj->_construct_finalize($table_alias, $field_name, $this->get_this_model_name());
448 448
 			}
449 449
 		}
450 450
 
451 451
 		// everything is related to Extra_Meta
452
-		if( get_class($this) !== 'EEM_Extra_Meta'){
452
+		if (get_class($this) !== 'EEM_Extra_Meta') {
453 453
 			//make extra meta related to everything, but don't block deleting things just
454 454
 			//because they have related extra meta info. For now just orphan those extra meta
455 455
 			//in the future we should automatically delete them
456
-			$this->_model_relations['Extra_Meta'] = new EE_Has_Many_Any_Relation( FALSE );
456
+			$this->_model_relations['Extra_Meta'] = new EE_Has_Many_Any_Relation(FALSE);
457 457
 		}
458 458
 		//and change logs
459
-		if( get_class( $this) !==  'EEM_Change_Log' ) {
460
-			$this->_model_relations[ 'Change_Log' ] = new EE_Has_Many_Any_Relation( FALSE );
459
+		if (get_class($this) !== 'EEM_Change_Log') {
460
+			$this->_model_relations['Change_Log'] = new EE_Has_Many_Any_Relation(FALSE);
461 461
 		}
462 462
 		/**
463 463
 		 * Filters the list of relations on a model. It is best to NOT use this directly and instead just use
464 464
 		 * EE_Register_Model_Extension
465 465
 		 * @param EE_Model_Relation_Base[] $_model_relations
466 466
 		 */
467
-		$this->_model_relations = apply_filters('FHEE__'.get_class($this).'__construct__model_relations',$this->_model_relations);
468
-		foreach($this->_model_relations as $model_name => $relation_obj){
467
+		$this->_model_relations = apply_filters('FHEE__'.get_class($this).'__construct__model_relations', $this->_model_relations);
468
+		foreach ($this->_model_relations as $model_name => $relation_obj) {
469 469
 			/** @var $relation_obj EE_Model_Relation_Base */
470 470
 			$relation_obj->_construct_finalize_set_models($this->get_this_model_name(), $model_name);
471 471
 		}
472
-		foreach($this->_indexes as $index_name => $index_obj){
472
+		foreach ($this->_indexes as $index_name => $index_obj) {
473 473
 			/** @var $index_obj EE_Index */
474 474
 			$index_obj->_construct_finalize($index_name, $this->get_this_model_name());
475 475
 		}
476 476
 
477 477
 		$this->set_timezone($timezone);
478 478
 		//finalize default where condition strategy, or set default
479
-		if( ! $this->_default_where_conditions_strategy){
479
+		if ( ! $this->_default_where_conditions_strategy) {
480 480
 			//nothing was set during child constructor, so set default
481 481
 			$this->_default_where_conditions_strategy = new EE_Default_Where_Conditions();
482 482
 		}
483 483
 		$this->_default_where_conditions_strategy->_finalize_construct($this);
484
-		if( ! $this->_minimum_where_conditions_strategy){
484
+		if ( ! $this->_minimum_where_conditions_strategy) {
485 485
 			//nothing was set during child constructor, so set default
486 486
 			$this->_minimum_where_conditions_strategy = new EE_Default_Where_Conditions();
487 487
 		}
@@ -489,14 +489,14 @@  discard block
 block discarded – undo
489 489
 
490 490
 		//if the cap slug hasn't been set, and we haven't set it to false on purpose
491 491
 		//to indicate to NOT set it, set it to the logical default
492
-		if( $this->_caps_slug === null ) {
493
-			$this->_caps_slug = EEH_Inflector::pluralize_and_lower( $this->get_this_model_name() );
492
+		if ($this->_caps_slug === null) {
493
+			$this->_caps_slug = EEH_Inflector::pluralize_and_lower($this->get_this_model_name());
494 494
 		}
495 495
 		//initialize the standard cap restriction generators if none were specified by the child constructor
496
-		if( $this->_cap_restriction_generators !== false ){
497
-			foreach( $this->cap_contexts_to_cap_action_map() as $cap_context => $action ){
498
-				if( ! isset( $this->_cap_restriction_generators[ $cap_context ] ) ) {
499
-					$this->_cap_restriction_generators[ $cap_context ] = apply_filters(
496
+		if ($this->_cap_restriction_generators !== false) {
497
+			foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) {
498
+				if ( ! isset($this->_cap_restriction_generators[$cap_context])) {
499
+					$this->_cap_restriction_generators[$cap_context] = apply_filters(
500 500
 						'FHEE__EEM_Base___construct__standard_cap_restriction_generator',
501 501
 						new EE_Restriction_Generator_Protected(),
502 502
 						$cap_context,
@@ -506,23 +506,23 @@  discard block
 block discarded – undo
506 506
 			}
507 507
 		}
508 508
 		//if there are cap restriction generators, use them to make the default cap restrictions
509
-		if( $this->_cap_restriction_generators !== false ){
510
-			foreach( $this->_cap_restriction_generators as $context => $generator_object ) {
511
-				if( ! $generator_object ){
509
+		if ($this->_cap_restriction_generators !== false) {
510
+			foreach ($this->_cap_restriction_generators as $context => $generator_object) {
511
+				if ( ! $generator_object) {
512 512
 					continue;
513 513
 				}
514
-				if( ! $generator_object instanceof EE_Restriction_Generator_Base ){
514
+				if ( ! $generator_object instanceof EE_Restriction_Generator_Base) {
515 515
 					throw new EE_Error(
516 516
 						sprintf(
517
-							__( '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' ),
517
+							__('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'),
518 518
 							$context,
519 519
 							$this->get_this_model_name()
520 520
 						)
521 521
 					);
522 522
 				}
523
-				$action = $this->cap_action_for_context( $context );
524
-				if( ! $generator_object->construction_finalized() ){
525
-					$generator_object->_construct_finalize( $this, $action );
523
+				$action = $this->cap_action_for_context($context);
524
+				if ( ! $generator_object->construction_finalized()) {
525
+					$generator_object->_construct_finalize($this, $action);
526 526
 				}
527 527
 
528 528
 			}
@@ -536,11 +536,11 @@  discard block
 block discarded – undo
536 536
 	 * @param string $context one of EEM_Base::valid_cap_contexts()
537 537
 	 * @return EE_Default_Where_Conditions[]
538 538
 	 */
539
-	protected function _generate_cap_restrictions( $context ){
540
-		if( isset( $this->_cap_restriction_generators[ $context ] ) &&
541
-				$this->_cap_restriction_generators[ $context ] instanceof EE_Restriction_Generator_Base ) {
542
-			return $this->_cap_restriction_generators[ $context ]->generate_restrictions();
543
-		}else{
539
+	protected function _generate_cap_restrictions($context) {
540
+		if (isset($this->_cap_restriction_generators[$context]) &&
541
+				$this->_cap_restriction_generators[$context] instanceof EE_Restriction_Generator_Base) {
542
+			return $this->_cap_restriction_generators[$context]->generate_restrictions();
543
+		} else {
544 544
 			return array();
545 545
 		}
546 546
 }
@@ -553,16 +553,16 @@  discard block
 block discarded – undo
553 553
 	 *		@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)
554 554
 	 *		@return static (as in the concrete child class)
555 555
 	 */
556
-	public static function instance( $timezone = NULL ){
556
+	public static function instance($timezone = NULL) {
557 557
 
558 558
 		// check if instance of Espresso_model already exists
559 559
 		if ( ! static::$_instance instanceof static) {
560 560
 			// instantiate Espresso_model
561
-			static::$_instance = new static( $timezone );
561
+			static::$_instance = new static($timezone);
562 562
 		}
563 563
 
564 564
 		//we might have a timezone set, let set_timezone decide what to do with it
565
-		static::$_instance->set_timezone( $timezone );
565
+		static::$_instance->set_timezone($timezone);
566 566
 
567 567
 		// Espresso_model object
568 568
 		return static::$_instance;
@@ -575,11 +575,11 @@  discard block
 block discarded – undo
575 575
 	 * @param null | string $timezone
576 576
 	 * @return static
577 577
 	 */
578
-	public static function reset(  $timezone = NULL ){
579
-		if ( ! is_null( static::$_instance ) ) {
578
+	public static function reset($timezone = NULL) {
579
+		if ( ! is_null(static::$_instance)) {
580 580
 			static::$_instance = null;
581 581
 
582
-			return self::instance( $timezone );
582
+			return self::instance($timezone);
583 583
 		}
584 584
 		return null;
585 585
 	}
@@ -593,19 +593,19 @@  discard block
 block discarded – undo
593 593
 	 * @return array
594 594
 	 * @throws \EE_Error
595 595
 	 */
596
-	 public function status_array( $translated = FALSE ) {
597
-		 if ( ! array_key_exists( 'Status', $this->_model_relations ) ) {
596
+	 public function status_array($translated = FALSE) {
597
+		 if ( ! array_key_exists('Status', $this->_model_relations)) {
598 598
 			 return array();
599 599
 		 }
600 600
 		 $model_name = $this->get_this_model_name();
601
-		 $status_type = str_replace( ' ', '_', strtolower( str_replace( '_', ' ', $model_name ) ) );
602
-		 $stati = EEM_Status::instance()->get_all( array( array( 'STS_type' => $status_type ) ) );
601
+		 $status_type = str_replace(' ', '_', strtolower(str_replace('_', ' ', $model_name)));
602
+		 $stati = EEM_Status::instance()->get_all(array(array('STS_type' => $status_type)));
603 603
 		 $status_array = array();
604
-		 foreach ( $stati as $status ) {
605
-			 $status_array[ $status->ID() ] = $status->get( 'STS_code' );
604
+		 foreach ($stati as $status) {
605
+			 $status_array[$status->ID()] = $status->get('STS_code');
606 606
 		 }
607 607
 		 return $translated
608
-			 ? EEM_Status::instance()->localized_status( $status_array, false, 'sentence' )
608
+			 ? EEM_Status::instance()->localized_status($status_array, false, 'sentence')
609 609
 			 : $status_array;
610 610
 	 }
611 611
 
@@ -733,7 +733,7 @@  discard block
 block discarded – undo
733 733
 	 *		));
734 734
 	 * @throws \EE_Error
735 735
 	 */
736
-	public function get_all($query_params = array()){
736
+	public function get_all($query_params = array()) {
737 737
 		return $this->_create_objects($this->_get_all_wpdb_results($query_params, ARRAY_A, NULL));
738 738
 	}
739 739
 
@@ -743,10 +743,10 @@  discard block
 block discarded – undo
743 743
 	 * @param array $query_params @see EEM_Base::get_all()
744 744
 	 * @return array like EEM_Base::get_all
745 745
 	 */
746
-	public function alter_query_params_to_only_include_mine( $query_params = array() ) {
746
+	public function alter_query_params_to_only_include_mine($query_params = array()) {
747 747
 		$wp_user_field_name = $this->wp_user_field_name();
748
-		if( $wp_user_field_name ){
749
-			$query_params[0][ $wp_user_field_name ] = get_current_user_id();
748
+		if ($wp_user_field_name) {
749
+			$query_params[0][$wp_user_field_name] = get_current_user_id();
750 750
 		}
751 751
 		return $query_params;
752 752
 	}
@@ -759,19 +759,19 @@  discard block
 block discarded – undo
759 759
 	 * foreign key to the WP_User table
760 760
 	 */
761 761
 	public function wp_user_field_name() {
762
-		try{
763
-			if( ! empty( $this->_model_chain_to_wp_user ) ) {
764
-				$models_to_follow_to_wp_users = explode( '.', $this->_model_chain_to_wp_user );
765
-				$last_model_name = end( $models_to_follow_to_wp_users );
766
-				$model_with_fk_to_wp_users = EE_Registry::instance()->load_model( $last_model_name );
767
-				$model_chain_to_wp_user = $this->_model_chain_to_wp_user . '.';
768
-			}else{
762
+		try {
763
+			if ( ! empty($this->_model_chain_to_wp_user)) {
764
+				$models_to_follow_to_wp_users = explode('.', $this->_model_chain_to_wp_user);
765
+				$last_model_name = end($models_to_follow_to_wp_users);
766
+				$model_with_fk_to_wp_users = EE_Registry::instance()->load_model($last_model_name);
767
+				$model_chain_to_wp_user = $this->_model_chain_to_wp_user.'.';
768
+			} else {
769 769
 				$model_with_fk_to_wp_users = $this;
770 770
 				$model_chain_to_wp_user = '';
771 771
 			}
772
-			$wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to( 'WP_User' );
773
-			return $model_chain_to_wp_user . $wp_user_field->get_name();
774
-		}catch( EE_Error $e ) {
772
+			$wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to('WP_User');
773
+			return $model_chain_to_wp_user.$wp_user_field->get_name();
774
+		} catch (EE_Error $e) {
775 775
 			return false;
776 776
 		}
777 777
 	}
@@ -785,7 +785,7 @@  discard block
 block discarded – undo
785 785
 	 * (or transiently-related model)
786 786
 	 * @return string
787 787
 	 */
788
-	public function model_chain_to_wp_user(){
788
+	public function model_chain_to_wp_user() {
789 789
 		return $this->_model_chain_to_wp_user;
790 790
 	}
791 791
 
@@ -797,13 +797,13 @@  discard block
 block discarded – undo
797 797
 	 * @return boolean
798 798
 	 */
799 799
 	public function is_owned() {
800
-		if( $this->model_chain_to_wp_user() ){
800
+		if ($this->model_chain_to_wp_user()) {
801 801
 			return true;
802
-		}else{
803
-			try{
804
-				$this->get_foreign_key_to( 'WP_User' );
802
+		} else {
803
+			try {
804
+				$this->get_foreign_key_to('WP_User');
805 805
 				return true;
806
-			}catch( EE_Error $e ){
806
+			} catch (EE_Error $e) {
807 807
 				return false;
808 808
 			}
809 809
 		}
@@ -825,17 +825,17 @@  discard block
 block discarded – undo
825 825
 	 * @return array | stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT)
826 826
 	 * @throws \EE_Error
827 827
 	 */
828
-	protected function  _get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){
828
+	protected function  _get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null) {
829 829
 		// remember the custom selections, if any, and type cast as array
830 830
 		// (unless $columns_to_select is an object, then just set as an empty array)
831 831
 		// Note: (array) 'some string' === array( 'some string' )
832
-		$this->_custom_selections = ! is_object( $columns_to_select ) ? (array) $columns_to_select : array();
833
-		$model_query_info = $this->_create_model_query_info_carrier( $query_params );
832
+		$this->_custom_selections = ! is_object($columns_to_select) ? (array) $columns_to_select : array();
833
+		$model_query_info = $this->_create_model_query_info_carrier($query_params);
834 834
 		$select_expressions = $columns_to_select !== null
835
-			? $this->_construct_select_from_input( $columns_to_select )
836
-			: $this->_construct_default_select_sql( $model_query_info );
837
-		$SQL = "SELECT $select_expressions " . $this->_construct_2nd_half_of_select_query( $model_query_info );
838
-		return $this->_do_wpdb_query( 'get_results', array( $SQL, $output ) );
835
+			? $this->_construct_select_from_input($columns_to_select)
836
+			: $this->_construct_default_select_sql($model_query_info);
837
+		$SQL = "SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
838
+		return $this->_do_wpdb_query('get_results', array($SQL, $output));
839 839
 	}
840 840
 
841 841
 	/**
@@ -853,7 +853,7 @@  discard block
 block discarded – undo
853 853
 	 * @return array|stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT)
854 854
 	 * @throws \EE_Error
855 855
 	 */
856
-	public function  get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){
856
+	public function  get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null) {
857 857
 		return $this->_get_all_wpdb_results($query_params, $output, $columns_to_select);
858 858
 	}
859 859
 
@@ -865,12 +865,12 @@  discard block
 block discarded – undo
865 865
 	 * @throws EE_Error
866 866
 	 * @return string
867 867
 	 */
868
-	private function _construct_select_from_input($columns_to_select){
869
-		if(is_array($columns_to_select)){
868
+	private function _construct_select_from_input($columns_to_select) {
869
+		if (is_array($columns_to_select)) {
870 870
 			$select_sql_array = array();
871 871
 
872
-			foreach($columns_to_select as $alias => $selection_and_datatype){
873
-				if( ! is_array($selection_and_datatype) || ! isset($selection_and_datatype[1])){
872
+			foreach ($columns_to_select as $alias => $selection_and_datatype) {
873
+				if ( ! is_array($selection_and_datatype) || ! isset($selection_and_datatype[1])) {
874 874
 					throw new EE_Error(
875 875
 						sprintf(
876 876
 							__(
@@ -882,24 +882,24 @@  discard block
 block discarded – undo
882 882
 						)
883 883
 					);
884 884
 				}
885
-				if( ! in_array( $selection_and_datatype[1],$this->_valid_wpdb_data_types)){
885
+				if ( ! in_array($selection_and_datatype[1], $this->_valid_wpdb_data_types)) {
886 886
 					throw new EE_Error(
887 887
 						sprintf(
888 888
 							__(
889 889
 								"Datatype %s (for selection '%s' and alias '%s') is not a valid wpdb datatype (eg %%s)",
890 890
 								"event_espresso"
891 891
 							),
892
-							$selection_and_datatype[ 1 ],
893
-							$selection_and_datatype[ 0 ],
892
+							$selection_and_datatype[1],
893
+							$selection_and_datatype[0],
894 894
 							$alias,
895
-							implode( ",", $this->_valid_wpdb_data_types )
895
+							implode(",", $this->_valid_wpdb_data_types)
896 896
 						)
897 897
 					);
898 898
 				}
899 899
 				$select_sql_array[] = "{$selection_and_datatype[0]} AS $alias";
900 900
 			}
901
-			$columns_to_select_string = implode(", ",$select_sql_array);
902
-		}else{
901
+			$columns_to_select_string = implode(", ", $select_sql_array);
902
+		} else {
903 903
 			$columns_to_select_string = $columns_to_select;
904 904
 		}
905 905
 		return $columns_to_select_string;
@@ -914,7 +914,7 @@  discard block
 block discarded – undo
914 914
 	 * @return string
915 915
 	 * @throws \EE_Error
916 916
 	 */
917
-	public function primary_key_name(){
917
+	public function primary_key_name() {
918 918
 		return $this->get_primary_key_field()->get_name();
919 919
 	}
920 920
 
@@ -926,14 +926,14 @@  discard block
 block discarded – undo
926 926
 	 * @param mixed $id int or string, depending on the type of the model's primary key
927 927
 	 * @return EE_Base_Class
928 928
 	 */
929
-	public function get_one_by_ID($id){
930
-		if( $this->get_from_entity_map( $id ) ){
931
-			return $this->get_from_entity_map( $id );
929
+	public function get_one_by_ID($id) {
930
+		if ($this->get_from_entity_map($id)) {
931
+			return $this->get_from_entity_map($id);
932 932
 		}
933 933
 		return $this->get_one(
934 934
 			$this->alter_query_params_to_restrict_by_ID(
935 935
 				$id,
936
-				array( 'default_where_conditions' => 'minimum' )
936
+				array('default_where_conditions' => 'minimum')
937 937
 			)
938 938
 		);
939 939
 	}
@@ -949,15 +949,15 @@  discard block
 block discarded – undo
949 949
 	 * @return array of normal query params, @see EEM_Base::get_all
950 950
 	 * @throws \EE_Error
951 951
 	 */
952
-	public function alter_query_params_to_restrict_by_ID( $id, $query_params = array() ) {
953
-		if( ! isset( $query_params[ 0 ] ) ) {
954
-			$query_params[ 0 ] = array();
952
+	public function alter_query_params_to_restrict_by_ID($id, $query_params = array()) {
953
+		if ( ! isset($query_params[0])) {
954
+			$query_params[0] = array();
955 955
 		}
956
-		if( $this->has_primary_key_field ( ) ) {
957
-			$query_params[ 0 ][ $this->primary_key_name() ] = $id ;
958
-		}else{
956
+		if ($this->has_primary_key_field( )) {
957
+			$query_params[0][$this->primary_key_name()] = $id;
958
+		} else {
959 959
 			//no primary key, so the $id must be from the get_index_primary_key_string()
960
-			$query_params[0] = array_replace_recursive( $query_params[ 0 ], $this->parse_index_primary_key_string( $id ) );
960
+			$query_params[0] = array_replace_recursive($query_params[0], $this->parse_index_primary_key_string($id));
961 961
 		}
962 962
 		return $query_params;
963 963
 	}
@@ -972,16 +972,16 @@  discard block
 block discarded – undo
972 972
 	 * @return EE_Base_Class | NULL
973 973
 	 * @throws \EE_Error
974 974
 	 */
975
-	public function get_one($query_params = array()){
976
-		if( ! is_array( $query_params ) ){
977
-			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' );
975
+	public function get_one($query_params = array()) {
976
+		if ( ! is_array($query_params)) {
977
+			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');
978 978
 			$query_params = array();
979 979
 		}
980 980
 		$query_params['limit'] = 1;
981 981
 		$items = $this->get_all($query_params);
982
-		if(empty($items)){
982
+		if (empty($items)) {
983 983
 			return null;
984
-		}else{
984
+		} else {
985 985
 			return array_shift($items);
986 986
 		}
987 987
 	}
@@ -1004,8 +1004,8 @@  discard block
 block discarded – undo
1004 1004
 	 * @return EE_Base_Class[]|array
1005 1005
 	 * @throws \EE_Error
1006 1006
 	 */
1007
-	public function next_x( $current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
1008
-		return $this->_get_consecutive( $current_field_value, '>', $field_to_order_by, $limit, $query_params, $columns_to_select );
1007
+	public function next_x($current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
1008
+		return $this->_get_consecutive($current_field_value, '>', $field_to_order_by, $limit, $query_params, $columns_to_select);
1009 1009
 	}
1010 1010
 
1011 1011
 
@@ -1026,8 +1026,8 @@  discard block
 block discarded – undo
1026 1026
 	 * @return EE_Base_Class[]|array
1027 1027
 	 * @throws \EE_Error
1028 1028
 	 */
1029
-	public function previous_x( $current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
1030
-		return $this->_get_consecutive( $current_field_value, '<', $field_to_order_by, $limit, $query_params, $columns_to_select );
1029
+	public function previous_x($current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
1030
+		return $this->_get_consecutive($current_field_value, '<', $field_to_order_by, $limit, $query_params, $columns_to_select);
1031 1031
 	}
1032 1032
 
1033 1033
 
@@ -1048,9 +1048,9 @@  discard block
 block discarded – undo
1048 1048
 	 * @return EE_Base_Class|null|array()
1049 1049
 	 * @throws \EE_Error
1050 1050
 	 */
1051
-	public function next( $current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) {
1052
-		$results = $this->_get_consecutive( $current_field_value, '>', $field_to_order_by, 1, $query_params, $columns_to_select );
1053
-		return empty( $results ) ? null : reset( $results );
1051
+	public function next($current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null) {
1052
+		$results = $this->_get_consecutive($current_field_value, '>', $field_to_order_by, 1, $query_params, $columns_to_select);
1053
+		return empty($results) ? null : reset($results);
1054 1054
 	}
1055 1055
 
1056 1056
 
@@ -1072,9 +1072,9 @@  discard block
 block discarded – undo
1072 1072
  * @return EE_Base_Class|null|array()
1073 1073
 	 * @throws EE_Error
1074 1074
 	 */
1075
-	public function previous( $current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) {
1076
-		$results = $this->_get_consecutive( $current_field_value, '<', $field_to_order_by, 1, $query_params, $columns_to_select );
1077
-		return empty( $results ) ? null : reset( $results );
1075
+	public function previous($current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null) {
1076
+		$results = $this->_get_consecutive($current_field_value, '<', $field_to_order_by, 1, $query_params, $columns_to_select);
1077
+		return empty($results) ? null : reset($results);
1078 1078
 	}
1079 1079
 
1080 1080
 
@@ -1095,42 +1095,42 @@  discard block
 block discarded – undo
1095 1095
 	 * @return EE_Base_Class[]|array
1096 1096
 	 * @throws EE_Error
1097 1097
 	 */
1098
-	protected function _get_consecutive( $current_field_value, $operand = '>', $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
1098
+	protected function _get_consecutive($current_field_value, $operand = '>', $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
1099 1099
 		//if $field_to_order_by is empty then let's assume we're ordering by the primary key.
1100
-		if ( empty( $field_to_order_by ) ) {
1101
-			if ( $this->has_primary_key_field() ) {
1100
+		if (empty($field_to_order_by)) {
1101
+			if ($this->has_primary_key_field()) {
1102 1102
 				$field_to_order_by = $this->get_primary_key_field()->get_name();
1103 1103
 			} else {
1104 1104
 
1105
-				if ( WP_DEBUG ) {
1106
-					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' ) );
1105
+				if (WP_DEBUG) {
1106
+					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'));
1107 1107
 				}
1108
-				EE_Error::add_error( __('There was an error with the query.', 'event_espresso') );
1108
+				EE_Error::add_error(__('There was an error with the query.', 'event_espresso'));
1109 1109
 				return array();
1110 1110
 			}
1111 1111
 		}
1112 1112
 
1113
-		if( ! is_array( $query_params ) ){
1114
-			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' );
1113
+		if ( ! is_array($query_params)) {
1114
+			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');
1115 1115
 			$query_params = array();
1116 1116
 		}
1117 1117
 
1118 1118
 		//let's add the where query param for consecutive look up.
1119
-		$query_params[0][ $field_to_order_by ] = array( $operand, $current_field_value );
1119
+		$query_params[0][$field_to_order_by] = array($operand, $current_field_value);
1120 1120
 		$query_params['limit'] = $limit;
1121 1121
 
1122 1122
 		//set direction
1123
-		$incoming_orderby = isset( $query_params['order_by'] ) ? (array)$query_params['order_by'] : array();
1123
+		$incoming_orderby = isset($query_params['order_by']) ? (array) $query_params['order_by'] : array();
1124 1124
 		$query_params['order_by'] = $operand === '>'
1125
-			? array( $field_to_order_by => 'ASC' ) + $incoming_orderby
1126
-			: array( $field_to_order_by => 'DESC') + $incoming_orderby;
1125
+			? array($field_to_order_by => 'ASC') + $incoming_orderby
1126
+			: array($field_to_order_by => 'DESC') + $incoming_orderby;
1127 1127
 
1128 1128
 		//if $columns_to_select is empty then that means we're returning EE_Base_Class objects
1129
-		if ( empty( $columns_to_select ) ) {
1130
-			return $this->get_all( $query_params );
1129
+		if (empty($columns_to_select)) {
1130
+			return $this->get_all($query_params);
1131 1131
 		} else {
1132 1132
 			//getting just the fields
1133
-			return $this->_get_all_wpdb_results( $query_params, ARRAY_A, $columns_to_select );
1133
+			return $this->_get_all_wpdb_results($query_params, ARRAY_A, $columns_to_select);
1134 1134
 		}
1135 1135
 	}
1136 1136
 
@@ -1141,18 +1141,18 @@  discard block
 block discarded – undo
1141 1141
 	 * This sets the _timezone property after model object has been instantiated.
1142 1142
 	 * @param null | string $timezone valid PHP DateTimeZone timezone string
1143 1143
 	 */
1144
-	public function set_timezone( $timezone ) {
1145
-		if ( $timezone !== null ) {
1144
+	public function set_timezone($timezone) {
1145
+		if ($timezone !== null) {
1146 1146
 			$this->_timezone = $timezone;
1147 1147
 		}
1148 1148
 		//note we need to loop through relations and set the timezone on those objects as well.
1149
-		foreach ( $this->_model_relations as $relation ) {
1150
-			$relation->set_timezone( $timezone );
1149
+		foreach ($this->_model_relations as $relation) {
1150
+			$relation->set_timezone($timezone);
1151 1151
 		}
1152 1152
 		//and finally we do the same for any datetime fields
1153
-		foreach ( $this->_fields as $field ) {
1154
-			if ( $field instanceof EE_Datetime_Field ) {
1155
-				$field->set_timezone( $timezone );
1153
+		foreach ($this->_fields as $field) {
1154
+			if ($field instanceof EE_Datetime_Field) {
1155
+				$field->set_timezone($timezone);
1156 1156
 			}
1157 1157
 		}
1158 1158
 	}
@@ -1167,9 +1167,9 @@  discard block
 block discarded – undo
1167 1167
 	 */
1168 1168
 	public function get_timezone() {
1169 1169
 		//first validate if timezone is set.  If not, then let's set it be whatever is set on the model fields.
1170
-		if ( empty( $this->_timezone ) ) {
1171
-			foreach( $this->_fields as $field ) {
1172
-				if ( $field instanceof EE_Datetime_Field ) {
1170
+		if (empty($this->_timezone)) {
1171
+			foreach ($this->_fields as $field) {
1172
+				if ($field instanceof EE_Datetime_Field) {
1173 1173
 					$this->set_timezone($field->get_timezone());
1174 1174
 					break;
1175 1175
 				}
@@ -1177,8 +1177,8 @@  discard block
 block discarded – undo
1177 1177
 		}
1178 1178
 
1179 1179
 		//if timezone STILL empty then return the default timezone for the site.
1180
-		if ( empty( $this->_timezone ) ) {
1181
-			$this->set_timezone( EEH_DTT_Helper::get_timezone() );
1180
+		if (empty($this->_timezone)) {
1181
+			$this->set_timezone(EEH_DTT_Helper::get_timezone());
1182 1182
 		}
1183 1183
 		return $this->_timezone;
1184 1184
 	}
@@ -1196,19 +1196,19 @@  discard block
 block discarded – undo
1196 1196
 	 *
1197 1197
 	 * @return array formats in an array with the date format first, and the time format last.
1198 1198
 	 */
1199
-	public function get_formats_for( $field_name, $pretty = false ) {
1200
-		$field_settings = $this->field_settings_for( $field_name );
1199
+	public function get_formats_for($field_name, $pretty = false) {
1200
+		$field_settings = $this->field_settings_for($field_name);
1201 1201
 
1202 1202
 		//if not a valid EE_Datetime_Field then throw error
1203
-		if ( ! $field_settings instanceof EE_Datetime_Field ) {
1204
-			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 ) );
1203
+		if ( ! $field_settings instanceof EE_Datetime_Field) {
1204
+			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));
1205 1205
 		}
1206 1206
 
1207 1207
 		//while we are here, let's make sure the timezone internally in EEM_Base matches what is stored on
1208 1208
 		//the field.
1209 1209
 		$this->_timezone = $field_settings->get_timezone();
1210 1210
 
1211
-		return array( $field_settings->get_date_format( $pretty ), $field_settings->get_time_format( $pretty ) );
1211
+		return array($field_settings->get_date_format($pretty), $field_settings->get_time_format($pretty));
1212 1212
 	}
1213 1213
 
1214 1214
 
@@ -1232,25 +1232,25 @@  discard block
 block discarded – undo
1232 1232
 	 * @return int|string  If the given field_name is not of the EE_Datetime_Field type, then an EE_Error
1233 1233
 	 *                    	     exception is triggered.
1234 1234
 	 */
1235
-	public function current_time_for_query( $field_name, $timestamp = false, $what = 'both' ) {
1236
-		$formats = $this->get_formats_for( $field_name );
1235
+	public function current_time_for_query($field_name, $timestamp = false, $what = 'both') {
1236
+		$formats = $this->get_formats_for($field_name);
1237 1237
 
1238
-		$DateTime = new DateTime( "now", new DateTimeZone( $this->_timezone ) );
1238
+		$DateTime = new DateTime("now", new DateTimeZone($this->_timezone));
1239 1239
 
1240
-		if ( $timestamp ) {
1241
-			return $DateTime->format( 'U' );
1240
+		if ($timestamp) {
1241
+			return $DateTime->format('U');
1242 1242
 		}
1243 1243
 
1244 1244
 		//not returning timestamp, so return formatted string in timezone.
1245
-		switch( $what ) {
1245
+		switch ($what) {
1246 1246
 			case 'time' :
1247
-				return $DateTime->format( $formats[1] );
1247
+				return $DateTime->format($formats[1]);
1248 1248
 				break;
1249 1249
 			case 'date' :
1250
-				return $DateTime->format( $formats[0] );
1250
+				return $DateTime->format($formats[0]);
1251 1251
 				break;
1252 1252
 			default :
1253
-				return $DateTime->format( implode( ' ', $formats ) );
1253
+				return $DateTime->format(implode(' ', $formats));
1254 1254
 				break;
1255 1255
 		}
1256 1256
 	}
@@ -1272,17 +1272,17 @@  discard block
 block discarded – undo
1272 1272
 	 * @return DateTime
1273 1273
 	 * @throws \EE_Error
1274 1274
 	 */
1275
-	public function convert_datetime_for_query( $field_name, $timestring, $incoming_format, $timezone = '' ) {
1275
+	public function convert_datetime_for_query($field_name, $timestring, $incoming_format, $timezone = '') {
1276 1276
 
1277 1277
 		//just using this to ensure the timezone is set correctly internally
1278
-		$this->get_formats_for( $field_name );
1278
+		$this->get_formats_for($field_name);
1279 1279
 
1280 1280
 		//load EEH_DTT_Helper
1281
-		$set_timezone = empty( $timezone ) ? EEH_DTT_Helper::get_timezone() : $timezone;
1281
+		$set_timezone = empty($timezone) ? EEH_DTT_Helper::get_timezone() : $timezone;
1282 1282
 
1283
-		$incomingDateTime = date_create_from_format( $incoming_format, $timestring, new DateTimeZone( $set_timezone ) );
1283
+		$incomingDateTime = date_create_from_format($incoming_format, $timestring, new DateTimeZone($set_timezone));
1284 1284
 
1285
-		return $incomingDateTime->setTimezone( new DateTimeZone( $this->_timezone ) );
1285
+		return $incomingDateTime->setTimezone(new DateTimeZone($this->_timezone));
1286 1286
 	}
1287 1287
 
1288 1288
 
@@ -1292,7 +1292,7 @@  discard block
 block discarded – undo
1292 1292
 	 * Gets all the tables comprising this model. Array keys are the table aliases, and values are EE_Table objects
1293 1293
 	 * @return EE_Table_Base[]
1294 1294
 	 */
1295
-	public function get_tables(){
1295
+	public function get_tables() {
1296 1296
 		return $this->_tables;
1297 1297
 	}
1298 1298
 
@@ -1328,9 +1328,9 @@  discard block
 block discarded – undo
1328 1328
 	 * @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)
1329 1329
 	 * @throws \EE_Error
1330 1330
 	 */
1331
-	public function update($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE){
1332
-		if( ! is_array( $query_params ) ){
1333
-			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' );
1331
+	public function update($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE) {
1332
+		if ( ! is_array($query_params)) {
1333
+			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');
1334 1334
 			$query_params = array();
1335 1335
 		}
1336 1336
 		/**
@@ -1340,7 +1340,7 @@  discard block
 block discarded – undo
1340 1340
 		 * @param array $fields_n_values the updated fields and their new values
1341 1341
 		 * @param array $query_params @see EEM_Base::get_all()
1342 1342
 		 */
1343
-		do_action( 'AHEE__EEM_Base__update__begin',$this, $fields_n_values, $query_params );
1343
+		do_action('AHEE__EEM_Base__update__begin', $this, $fields_n_values, $query_params);
1344 1344
 		/**
1345 1345
 		 * Filters the fields about to be updated given the query parameters. You can provide the
1346 1346
 		 * $query_params to $this->get_all() to find exactly which records will be updated
@@ -1348,10 +1348,10 @@  discard block
 block discarded – undo
1348 1348
 		 * @param EEM_Base $model the model being queried
1349 1349
 		 * @param array $query_params see EEM_Base::get_all()
1350 1350
 		 */
1351
-		$fields_n_values = (array)apply_filters( 'FHEE__EEM_Base__update__fields_n_values', $fields_n_values, $this, $query_params );
1351
+		$fields_n_values = (array) apply_filters('FHEE__EEM_Base__update__fields_n_values', $fields_n_values, $this, $query_params);
1352 1352
 		//need to verify that, for any entry we want to update, there are entries in each secondary table.
1353 1353
 		//to do that, for each table, verify that it's PK isn't null.
1354
-		$tables= $this->get_tables();
1354
+		$tables = $this->get_tables();
1355 1355
 
1356 1356
 		//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
1357 1357
 		//NOTE: we should make this code more efficient by NOT querying twice
@@ -1361,29 +1361,29 @@  discard block
 block discarded – undo
1361 1361
 			//we want to make sure the default_where strategy is ignored
1362 1362
 			$this->_ignore_where_strategy = TRUE;
1363 1363
 			$wpdb_select_results = $this->_get_all_wpdb_results($query_params);
1364
-			foreach( $wpdb_select_results as $wpdb_result ){
1364
+			foreach ($wpdb_select_results as $wpdb_result) {
1365 1365
 				// type cast stdClass as array
1366
-				$wpdb_result = (array)$wpdb_result;
1366
+				$wpdb_result = (array) $wpdb_result;
1367 1367
 				//get the model object's PK, as we'll want this if we need to insert a row into secondary tables
1368
-				if( $this->has_primary_key_field() ){
1369
-					$main_table_pk_value = $wpdb_result[ $this->get_primary_key_field()->get_qualified_column() ];
1370
-				}else{
1368
+				if ($this->has_primary_key_field()) {
1369
+					$main_table_pk_value = $wpdb_result[$this->get_primary_key_field()->get_qualified_column()];
1370
+				} else {
1371 1371
 					//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)
1372 1372
 					$main_table_pk_value = null;
1373 1373
 				}
1374 1374
 				//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
1375 1375
 				//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
1376
-				if(count($tables) > 1){
1376
+				if (count($tables) > 1) {
1377 1377
 					//foreach matching row in the DB, ensure that each table's PK isn't null. If so, there must not be an entry
1378 1378
 					//in that table, and so we'll want to insert one
1379
-					foreach($tables as $table_obj){
1379
+					foreach ($tables as $table_obj) {
1380 1380
 						$this_table_pk_column = $table_obj->get_fully_qualified_pk_column();
1381 1381
 						//if there is no private key for this table on the results, it means there's no entry
1382 1382
 						//in this table, right? so insert a row in the current table, using any fields available
1383
-						if( ! ( array_key_exists( $this_table_pk_column, $wpdb_result) && $wpdb_result[ $this_table_pk_column ] )){
1383
+						if ( ! (array_key_exists($this_table_pk_column, $wpdb_result) && $wpdb_result[$this_table_pk_column])) {
1384 1384
 							$success = $this->_insert_into_specific_table($table_obj, $fields_n_values, $main_table_pk_value);
1385 1385
 							//if we died here, report the error
1386
-							if( ! $success ) {
1386
+							if ( ! $success) {
1387 1387
 								return false;
1388 1388
 							}
1389 1389
 						}
@@ -1403,44 +1403,44 @@  discard block
 block discarded – undo
1403 1403
 		//if this wasn't called from a model object (to update itself)
1404 1404
 		//then we want to make sure we keep all the existing
1405 1405
 		//model objects in sync with the db
1406
-		if( $keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object ){
1407
-			if( $this->has_primary_key_field() ){
1408
-				$model_objs_affected_ids = $this->get_col( $query_params );
1409
-			}else{
1406
+		if ($keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object) {
1407
+			if ($this->has_primary_key_field()) {
1408
+				$model_objs_affected_ids = $this->get_col($query_params);
1409
+			} else {
1410 1410
 				//we need to select a bunch of columns and then combine them into the the "index primary key string"s
1411
-				$models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A );
1411
+				$models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A);
1412 1412
 				$model_objs_affected_ids = array();
1413
-				foreach( $models_affected_key_columns as $row ){
1414
-					$combined_index_key = $this->get_index_primary_key_string( $row );
1415
-					$model_objs_affected_ids[ $combined_index_key ] = $combined_index_key;
1413
+				foreach ($models_affected_key_columns as $row) {
1414
+					$combined_index_key = $this->get_index_primary_key_string($row);
1415
+					$model_objs_affected_ids[$combined_index_key] = $combined_index_key;
1416 1416
 				}
1417 1417
 
1418 1418
 			}
1419 1419
 
1420
-			if( ! $model_objs_affected_ids ){
1420
+			if ( ! $model_objs_affected_ids) {
1421 1421
 				//wait wait wait- if nothing was affected let's stop here
1422 1422
 				return 0;
1423 1423
 			}
1424
-			foreach( $model_objs_affected_ids as $id ){
1425
-				$model_obj_in_entity_map = $this->get_from_entity_map( $id );
1426
-				if( $model_obj_in_entity_map ){
1427
-					foreach( $fields_n_values as $field => $new_value ){
1428
-						$model_obj_in_entity_map->set( $field, $new_value );
1424
+			foreach ($model_objs_affected_ids as $id) {
1425
+				$model_obj_in_entity_map = $this->get_from_entity_map($id);
1426
+				if ($model_obj_in_entity_map) {
1427
+					foreach ($fields_n_values as $field => $new_value) {
1428
+						$model_obj_in_entity_map->set($field, $new_value);
1429 1429
 					}
1430 1430
 				}
1431 1431
 			}
1432 1432
 			//if there is a primary key on this model, we can now do a slight optimization
1433
-			if( $this->has_primary_key_field() ){
1433
+			if ($this->has_primary_key_field()) {
1434 1434
 				//we already know what we want to update. So let's make the query simpler so it's a little more efficient
1435 1435
 				$query_params = array(
1436
-					array( $this->primary_key_name() => array( 'IN', $model_objs_affected_ids ) ),
1437
-					'limit' => count( $model_objs_affected_ids ), 'default_where_conditions' => 'none' );
1436
+					array($this->primary_key_name() => array('IN', $model_objs_affected_ids)),
1437
+					'limit' => count($model_objs_affected_ids), 'default_where_conditions' => 'none' );
1438 1438
 			}
1439 1439
 		}
1440 1440
 
1441
-		$model_query_info = $this->_create_model_query_info_carrier( $query_params );
1442
-		$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.
1443
-		$rows_affected = $this->_do_wpdb_query('query', array( $SQL ) );
1441
+		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1442
+		$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.
1443
+		$rows_affected = $this->_do_wpdb_query('query', array($SQL));
1444 1444
 		/**
1445 1445
 		 * Action called after a model update call has been made.
1446 1446
 		 *
@@ -1449,8 +1449,8 @@  discard block
 block discarded – undo
1449 1449
 		 * @param array $query_params @see EEM_Base::get_all()
1450 1450
 		 * @param int $rows_affected
1451 1451
 		 */
1452
-		do_action( 'AHEE__EEM_Base__update__end',$this, $fields_n_values, $query_params, $rows_affected );
1453
-		return $rows_affected;//how many supposedly got updated
1452
+		do_action('AHEE__EEM_Base__update__end', $this, $fields_n_values, $query_params, $rows_affected);
1453
+		return $rows_affected; //how many supposedly got updated
1454 1454
 	}
1455 1455
 
1456 1456
 
@@ -1466,22 +1466,22 @@  discard block
 block discarded – undo
1466 1466
 	 * @return array just like $wpdb->get_col()
1467 1467
 	 * @throws \EE_Error
1468 1468
 	 */
1469
-	public function get_col( $query_params  = array(), $field_to_select = NULL ){
1469
+	public function get_col($query_params = array(), $field_to_select = NULL) {
1470 1470
 
1471
-		if( $field_to_select ){
1472
-			$field = $this->field_settings_for( $field_to_select );
1473
-		}elseif( $this->has_primary_key_field ( ) ){
1471
+		if ($field_to_select) {
1472
+			$field = $this->field_settings_for($field_to_select);
1473
+		}elseif ($this->has_primary_key_field( )) {
1474 1474
 			$field = $this->get_primary_key_field();
1475
-		}else{
1475
+		} else {
1476 1476
 			//no primary key, just grab the first column
1477
-			$field = reset( $this->field_settings());
1477
+			$field = reset($this->field_settings());
1478 1478
 		}
1479 1479
 
1480 1480
 
1481 1481
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1482 1482
 		$select_expressions = $field->get_qualified_column();
1483
-		$SQL ="SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
1484
-		return $this->_do_wpdb_query('get_col', array( $SQL ) );
1483
+		$SQL = "SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
1484
+		return $this->_do_wpdb_query('get_col', array($SQL));
1485 1485
 	}
1486 1486
 
1487 1487
 
@@ -1494,12 +1494,12 @@  discard block
 block discarded – undo
1494 1494
 	 * @return string
1495 1495
 	 * @throws \EE_Error
1496 1496
 	 */
1497
-	public function get_var( $query_params = array(), $field_to_select = NULL ) {
1498
-		$query_params[ 'limit' ] = 1;
1499
-		$col = $this->get_col( $query_params, $field_to_select );
1500
-		if( ! empty( $col ) ) {
1501
-			return reset( $col );
1502
-		}else{
1497
+	public function get_var($query_params = array(), $field_to_select = NULL) {
1498
+		$query_params['limit'] = 1;
1499
+		$col = $this->get_col($query_params, $field_to_select);
1500
+		if ( ! empty($col)) {
1501
+			return reset($col);
1502
+		} else {
1503 1503
 			return NULL;
1504 1504
 		}
1505 1505
 	}
@@ -1515,19 +1515,19 @@  discard block
 block discarded – undo
1515 1515
 	 * @return string of SQL
1516 1516
 	 * @throws \EE_Error
1517 1517
 	 */
1518
-	public function _construct_update_sql($fields_n_values){
1518
+	public function _construct_update_sql($fields_n_values) {
1519 1519
 		/** @type WPDB $wpdb */
1520 1520
 		global $wpdb;
1521 1521
 		$cols_n_values = array();
1522
-		foreach($fields_n_values as $field_name => $value){
1522
+		foreach ($fields_n_values as $field_name => $value) {
1523 1523
 			$field_obj = $this->field_settings_for($field_name);
1524 1524
 			//if the value is NULL, we want to assign the value to that.
1525 1525
 			//wpdb->prepare doesn't really handle that properly
1526
-			$prepared_value = $this->_prepare_value_or_use_default( $field_obj, $fields_n_values );
1527
-			$value_sql = $prepared_value===NULL ? 'NULL' : $wpdb->prepare( $field_obj->get_wpdb_data_type(), $prepared_value );
1526
+			$prepared_value = $this->_prepare_value_or_use_default($field_obj, $fields_n_values);
1527
+			$value_sql = $prepared_value === NULL ? 'NULL' : $wpdb->prepare($field_obj->get_wpdb_data_type(), $prepared_value);
1528 1528
 			$cols_n_values[] = $field_obj->get_qualified_column()."=".$value_sql;
1529 1529
 		}
1530
-		return implode(",",$cols_n_values);
1530
+		return implode(",", $cols_n_values);
1531 1531
 
1532 1532
 	}
1533 1533
 
@@ -1543,10 +1543,10 @@  discard block
 block discarded – undo
1543 1543
 	 * @return boolean whether the row got deleted or not
1544 1544
 	 * @throws \EE_Error
1545 1545
 	 */
1546
-	public function delete_permanently_by_ID( $id ) {
1546
+	public function delete_permanently_by_ID($id) {
1547 1547
 		return $this->delete_permanently(
1548 1548
 			array(
1549
-				array( $this->get_primary_key_field()->get_name() => $id ),
1549
+				array($this->get_primary_key_field()->get_name() => $id),
1550 1550
 				'limit' 	=> 1
1551 1551
 			)
1552 1552
 		);
@@ -1562,10 +1562,10 @@  discard block
 block discarded – undo
1562 1562
 	 * @return boolean whether the row got deleted or not
1563 1563
 	 * @throws \EE_Error
1564 1564
 	 */
1565
-	public function delete_by_ID( $id ){
1565
+	public function delete_by_ID($id) {
1566 1566
 		return $this->delete(
1567 1567
 			array(
1568
-				array( $this->get_primary_key_field()->get_name() => $id ),
1568
+				array($this->get_primary_key_field()->get_name() => $id),
1569 1569
 				'limit' 	=> 1
1570 1570
 			)
1571 1571
 		);
@@ -1584,7 +1584,7 @@  discard block
 block discarded – undo
1584 1584
 	 * @return int how many rows got deleted
1585 1585
 	 * @throws \EE_Error
1586 1586
 	 */
1587
-	public function delete($query_params,$allow_blocking = true){
1587
+	public function delete($query_params, $allow_blocking = true) {
1588 1588
 		return $this->delete_permanently($query_params, $allow_blocking);
1589 1589
 	}
1590 1590
 
@@ -1602,7 +1602,7 @@  discard block
 block discarded – undo
1602 1602
 	 * @return int how many rows got deleted
1603 1603
 	 * @throws \EE_Error
1604 1604
 	 */
1605
-	public function delete_permanently($query_params,$allow_blocking = true){
1605
+	public function delete_permanently($query_params, $allow_blocking = true) {
1606 1606
 		/**
1607 1607
 		 * Action called just before performing a real deletion query. You can use the
1608 1608
 		 * model and its $query_params to find exactly which items will be deleted
@@ -1611,31 +1611,31 @@  discard block
 block discarded – undo
1611 1611
 		 * @param boolean $allow_blocking whether or not to allow related model objects
1612 1612
 		 * to block (prevent) this deletion
1613 1613
 		 */
1614
-		do_action( 'AHEE__EEM_Base__delete__begin', $this, $query_params, $allow_blocking );
1614
+		do_action('AHEE__EEM_Base__delete__begin', $this, $query_params, $allow_blocking);
1615 1615
 		//some MySQL databases may be running safe mode, which may restrict
1616 1616
 		//deletion if there is no KEY column used in the WHERE statement of a deletion.
1617 1617
 		//to get around this, we first do a SELECT, get all the IDs, and then run another query
1618 1618
 		//to delete them
1619 1619
 		$items_for_deletion = $this->_get_all_wpdb_results($query_params);
1620
-		$deletion_where = $this->_setup_ids_for_delete( $items_for_deletion, $allow_blocking);
1621
-		if($deletion_where){
1620
+		$deletion_where = $this->_setup_ids_for_delete($items_for_deletion, $allow_blocking);
1621
+		if ($deletion_where) {
1622 1622
 			//echo "objects for deletion:";var_dump($objects_for_deletion);
1623 1623
 			$model_query_info = $this->_create_model_query_info_carrier($query_params);
1624
-			$table_aliases = array_keys( $this->_tables );
1625
-			$SQL = "DELETE ".implode(", ",$table_aliases)." FROM ".$model_query_info->get_full_join_sql()." WHERE ".$deletion_where;
1624
+			$table_aliases = array_keys($this->_tables);
1625
+			$SQL = "DELETE ".implode(", ", $table_aliases)." FROM ".$model_query_info->get_full_join_sql()." WHERE ".$deletion_where;
1626 1626
 
1627 1627
 			//		/echo "delete sql:$SQL";
1628
-			$rows_deleted = $this->_do_wpdb_query( 'query', array( $SQL ) );
1629
-		}else{
1628
+			$rows_deleted = $this->_do_wpdb_query('query', array($SQL));
1629
+		} else {
1630 1630
 			$rows_deleted = 0;
1631 1631
 		}
1632 1632
 
1633 1633
 		//and lastly make sure those items are removed from the entity map; if they could be put into it at all
1634
-		if( $this->has_primary_key_field() ){
1635
-			foreach($items_for_deletion as $item_for_deletion_row ){
1636
-				$pk_value = $item_for_deletion_row[ $this->get_primary_key_field()->get_qualified_column() ];
1637
-				if( isset( $this->_entity_map[ $pk_value ] ) ){
1638
-					unset( $this->_entity_map[ $pk_value ] );
1634
+		if ($this->has_primary_key_field()) {
1635
+			foreach ($items_for_deletion as $item_for_deletion_row) {
1636
+				$pk_value = $item_for_deletion_row[$this->get_primary_key_field()->get_qualified_column()];
1637
+				if (isset($this->_entity_map[$pk_value])) {
1638
+					unset($this->_entity_map[$pk_value]);
1639 1639
 				}
1640 1640
 			}
1641 1641
 		}
@@ -1647,8 +1647,8 @@  discard block
 block discarded – undo
1647 1647
 		 * @param array $query_params @see EEM_Base::get_all()
1648 1648
 		 * @param int $rows_deleted
1649 1649
 		 */
1650
-		do_action( 'AHEE__EEM_Base__delete__end', $this, $query_params, $rows_deleted );
1651
-		return $rows_deleted;//how many supposedly got deleted
1650
+		do_action('AHEE__EEM_Base__delete__end', $this, $query_params, $rows_deleted);
1651
+		return $rows_deleted; //how many supposedly got deleted
1652 1652
 	}
1653 1653
 
1654 1654
 
@@ -1666,28 +1666,28 @@  discard block
 block discarded – undo
1666 1666
 	 * @return boolean
1667 1667
 	 * @throws \EE_Error
1668 1668
 	 */
1669
-	public function delete_is_blocked_by_related_models($this_model_obj_or_id, $ignore_this_model_obj = null){
1669
+	public function delete_is_blocked_by_related_models($this_model_obj_or_id, $ignore_this_model_obj = null) {
1670 1670
 		//first, if $ignore_this_model_obj was supplied, get its model
1671
-		if($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class){
1671
+		if ($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class) {
1672 1672
 			$ignored_model = $ignore_this_model_obj->get_model();
1673
-		}else{
1673
+		} else {
1674 1674
 			$ignored_model = null;
1675 1675
 		}
1676 1676
 		//now check all the relations of $this_model_obj_or_id and see if there
1677 1677
 		//are any related model objects blocking it?
1678 1678
 		$is_blocked = false;
1679
-		foreach($this->_model_relations as $relation_name => $relation_obj){
1680
-			if( $relation_obj->block_delete_if_related_models_exist()){
1679
+		foreach ($this->_model_relations as $relation_name => $relation_obj) {
1680
+			if ($relation_obj->block_delete_if_related_models_exist()) {
1681 1681
 				//if $ignore_this_model_obj was supplied, then for the query
1682 1682
 				//on that model needs to be told to ignore $ignore_this_model_obj
1683
-				if($ignored_model && $relation_name === $ignored_model->get_this_model_name()){
1684
-					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id,array(
1685
-					array($ignored_model->get_primary_key_field()->get_name() => array('!=',$ignore_this_model_obj->ID()))));
1686
-				}else{
1683
+				if ($ignored_model && $relation_name === $ignored_model->get_this_model_name()) {
1684
+					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id, array(
1685
+					array($ignored_model->get_primary_key_field()->get_name() => array('!=', $ignore_this_model_obj->ID()))));
1686
+				} else {
1687 1687
 					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id);
1688 1688
 				}
1689 1689
 
1690
-				if($related_model_objects){
1690
+				if ($related_model_objects) {
1691 1691
 					EE_Error::add_error($relation_obj->get_deletion_error_message(), __FILE__, __FUNCTION__, __LINE__);
1692 1692
 					$is_blocked = true;
1693 1693
 				}
@@ -1707,71 +1707,71 @@  discard block
 block discarded – undo
1707 1707
 	 * @throws EE_Error
1708 1708
 	 * @return string    everything that comes after the WHERE statement.
1709 1709
 	 */
1710
-	protected function _setup_ids_for_delete( $objects_for_deletion, $allow_blocking = true) {
1711
-		if($this->has_primary_key_field()){
1710
+	protected function _setup_ids_for_delete($objects_for_deletion, $allow_blocking = true) {
1711
+		if ($this->has_primary_key_field()) {
1712 1712
 			$primary_table = $this->_get_main_table();
1713 1713
 			$other_tables = $this->_get_other_tables();
1714 1714
 			$deletes = $query = array();
1715
-			foreach ( $objects_for_deletion as $delete_object ) {
1715
+			foreach ($objects_for_deletion as $delete_object) {
1716 1716
 				//before we mark this object for deletion,
1717 1717
 				//make sure there's no related objects blocking its deletion (if we're checking)
1718 1718
 				if (
1719 1719
 					$allow_blocking
1720 1720
 				    && $this->delete_is_blocked_by_related_models(
1721
-						$delete_object[ $primary_table->get_fully_qualified_pk_column() ]
1721
+						$delete_object[$primary_table->get_fully_qualified_pk_column()]
1722 1722
 					)
1723 1723
 				) {
1724 1724
 					continue;
1725 1725
 				}
1726 1726
 				//primary table deletes
1727
-				if ( isset( $delete_object[ $primary_table->get_fully_qualified_pk_column() ] ) ) {
1728
-					$deletes[ $primary_table->get_fully_qualified_pk_column() ][] = $delete_object[ $primary_table->get_fully_qualified_pk_column() ];
1727
+				if (isset($delete_object[$primary_table->get_fully_qualified_pk_column()])) {
1728
+					$deletes[$primary_table->get_fully_qualified_pk_column()][] = $delete_object[$primary_table->get_fully_qualified_pk_column()];
1729 1729
 				}
1730 1730
 				//other tables
1731
-				if ( ! empty( $other_tables ) ) {
1732
-					foreach ( $other_tables as $ot ) {
1731
+				if ( ! empty($other_tables)) {
1732
+					foreach ($other_tables as $ot) {
1733 1733
 						//first check if we've got the foreign key column here.
1734
-						if ( isset( $delete_object[ $ot->get_fully_qualified_fk_column() ] ) ) {
1735
-							$deletes[ $ot->get_fully_qualified_pk_column() ][] = $delete_object[ $ot->get_fully_qualified_fk_column() ];
1734
+						if (isset($delete_object[$ot->get_fully_qualified_fk_column()])) {
1735
+							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_fk_column()];
1736 1736
 						}
1737 1737
 						// wait! it's entirely possible that we'll have a the primary key
1738 1738
 						// for this table in here, if it's a foreign key for one of the other secondary tables
1739
-						if ( isset( $delete_object[ $ot->get_fully_qualified_pk_column() ] ) ) {
1740
-							$deletes[ $ot->get_fully_qualified_pk_column() ][] = $delete_object[ $ot->get_fully_qualified_pk_column() ];
1739
+						if (isset($delete_object[$ot->get_fully_qualified_pk_column()])) {
1740
+							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1741 1741
 						}
1742 1742
 						// finally, it is possible that the fk for this table is found
1743 1743
 						// in the fully qualified pk column for the fk table, so let's see if that's there!
1744
-						if ( isset( $delete_object[ $ot->get_fully_qualified_pk_on_fk_table() ] ) ) {
1745
-							$deletes[ $ot->get_fully_qualified_pk_column() ][] = $delete_object[ $ot->get_fully_qualified_pk_column() ];
1744
+						if (isset($delete_object[$ot->get_fully_qualified_pk_on_fk_table()])) {
1745
+							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1746 1746
 						}
1747 1747
 					}
1748 1748
 				}
1749 1749
 			}
1750 1750
 
1751 1751
 			//we should have deletes now, so let's just go through and setup the where statement
1752
-			foreach ( $deletes as $column => $values ) {
1752
+			foreach ($deletes as $column => $values) {
1753 1753
 				//make sure we have unique $values;
1754 1754
 				$values = array_unique($values);
1755
-				$query[] = $column . ' IN(' . implode(",",$values) . ')';
1755
+				$query[] = $column.' IN('.implode(",", $values).')';
1756 1756
 			}
1757 1757
 
1758
-			return !empty($query) ? implode(' AND ', $query ) : '';
1759
-		}elseif(count($this->get_combined_primary_key_fields()) > 1){
1758
+			return ! empty($query) ? implode(' AND ', $query) : '';
1759
+		}elseif (count($this->get_combined_primary_key_fields()) > 1) {
1760 1760
 			$ways_to_identify_a_row = array();
1761 1761
 			$fields = $this->get_combined_primary_key_fields();
1762 1762
 			//note: because there' sno primary key, that means nothing else  can be pointing to this model, right?
1763
-			foreach($objects_for_deletion as  $delete_object){
1763
+			foreach ($objects_for_deletion as  $delete_object) {
1764 1764
 				$values_for_each_cpk_for_a_row = array();
1765
-				foreach($fields as $cpk_field){
1765
+				foreach ($fields as $cpk_field) {
1766 1766
 					$values_for_each_cpk_for_a_row[] = $cpk_field->get_qualified_column()."=".$delete_object[$cpk_field->get_qualified_column()];
1767 1767
 				}
1768
-				$ways_to_identify_a_row[] = "(".implode(" AND ",$values_for_each_cpk_for_a_row).")";
1768
+				$ways_to_identify_a_row[] = "(".implode(" AND ", $values_for_each_cpk_for_a_row).")";
1769 1769
 			}
1770
-			return implode(" OR ",$ways_to_identify_a_row);
1771
-		}else{
1770
+			return implode(" OR ", $ways_to_identify_a_row);
1771
+		} else {
1772 1772
 			//so there's no primary key and no combined key...
1773 1773
 			//sorry, can't help you
1774
-			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)));
1774
+			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)));
1775 1775
 		}
1776 1776
 	}
1777 1777
 
@@ -1787,21 +1787,21 @@  discard block
 block discarded – undo
1787 1787
 	 * @return int
1788 1788
 	 * @throws \EE_Error
1789 1789
 	 */
1790
-	public function count($query_params =array(),$field_to_count = NULL, $distinct = FALSE){
1790
+	public function count($query_params = array(), $field_to_count = NULL, $distinct = FALSE) {
1791 1791
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1792
-		if($field_to_count){
1792
+		if ($field_to_count) {
1793 1793
 			$field_obj = $this->field_settings_for($field_to_count);
1794 1794
 			$column_to_count = $field_obj->get_qualified_column();
1795
-		}elseif($this->has_primary_key_field ()){
1795
+		}elseif ($this->has_primary_key_field()) {
1796 1796
 			$pk_field_obj = $this->get_primary_key_field();
1797 1797
 			$column_to_count = $pk_field_obj->get_qualified_column();
1798
-		}else{//there's no primary key
1798
+		} else {//there's no primary key
1799 1799
 			$column_to_count = '*';
1800 1800
 		}
1801 1801
 
1802
-		$column_to_count = $distinct ? "DISTINCT (" . $column_to_count . " )" : $column_to_count;
1803
-		$SQL ="SELECT COUNT(".$column_to_count.")" . $this->_construct_2nd_half_of_select_query($model_query_info);
1804
-		return (int)$this->_do_wpdb_query( 'get_var', array( $SQL) );
1802
+		$column_to_count = $distinct ? "DISTINCT (".$column_to_count." )" : $column_to_count;
1803
+		$SQL = "SELECT COUNT(".$column_to_count.")".$this->_construct_2nd_half_of_select_query($model_query_info);
1804
+		return (int) $this->_do_wpdb_query('get_var', array($SQL));
1805 1805
 	}
1806 1806
 
1807 1807
 
@@ -1814,24 +1814,24 @@  discard block
 block discarded – undo
1814 1814
 	 * @return float
1815 1815
 	 * @throws \EE_Error
1816 1816
 	 */
1817
-	public function sum($query_params, $field_to_sum = NULL){
1817
+	public function sum($query_params, $field_to_sum = NULL) {
1818 1818
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1819 1819
 
1820
-		if($field_to_sum){
1820
+		if ($field_to_sum) {
1821 1821
 			$field_obj = $this->field_settings_for($field_to_sum);
1822 1822
 
1823
-		}else{
1823
+		} else {
1824 1824
 			$field_obj = $this->get_primary_key_field();
1825 1825
 		}
1826 1826
 		$column_to_count = $field_obj->get_qualified_column();
1827 1827
 
1828
-		$SQL ="SELECT SUM(".$column_to_count.")" . $this->_construct_2nd_half_of_select_query($model_query_info);
1829
-		$return_value = $this->_do_wpdb_query('get_var',array( $SQL ) );
1828
+		$SQL = "SELECT SUM(".$column_to_count.")".$this->_construct_2nd_half_of_select_query($model_query_info);
1829
+		$return_value = $this->_do_wpdb_query('get_var', array($SQL));
1830 1830
 		$data_type = $field_obj->get_wpdb_data_type();
1831
-		if( $data_type === '%d' || $data_type === '%s' ){
1832
-			return (float)$return_value;
1833
-		}else{//must be %f
1834
-			return (float)$return_value;
1831
+		if ($data_type === '%d' || $data_type === '%s') {
1832
+			return (float) $return_value;
1833
+		} else {//must be %f
1834
+			return (float) $return_value;
1835 1835
 		}
1836 1836
 	}
1837 1837
 
@@ -1846,33 +1846,33 @@  discard block
 block discarded – undo
1846 1846
 	 * @global wpdb $wpdb
1847 1847
 	 * @return mixed
1848 1848
 	 */
1849
-	protected function _do_wpdb_query( $wpdb_method, $arguments_to_provide ){
1849
+	protected function _do_wpdb_query($wpdb_method, $arguments_to_provide) {
1850 1850
 		//if we're in maintenance mode level 2, DON'T run any queries
1851 1851
 		//because level 2 indicates the database needs updating and
1852 1852
 		//is probably out of sync with the code
1853
-		if( ! EE_Maintenance_Mode::instance()->models_can_query()){
1853
+		if ( ! EE_Maintenance_Mode::instance()->models_can_query()) {
1854 1854
 			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")));
1855 1855
 		}
1856 1856
 		/** @type WPDB $wpdb */
1857 1857
 		global $wpdb;
1858
-		if( ! method_exists( $wpdb, $wpdb_method ) ){
1859
-			throw new EE_Error( sprintf( __( 'There is no method named "%s" on Wordpress\' $wpdb object','event_espresso' ), $wpdb_method ) );
1858
+		if ( ! method_exists($wpdb, $wpdb_method)) {
1859
+			throw new EE_Error(sprintf(__('There is no method named "%s" on Wordpress\' $wpdb object', 'event_espresso'), $wpdb_method));
1860 1860
 		}
1861
-		if( WP_DEBUG ){
1861
+		if (WP_DEBUG) {
1862 1862
 			$old_show_errors_value = $wpdb->show_errors;
1863
-			$wpdb->show_errors( FALSE );
1864
-		}
1865
-		$result = $this->_process_wpdb_query( $wpdb_method, $arguments_to_provide );
1866
-		$this->show_db_query_if_previously_requested( $wpdb->last_query );
1867
-		if( WP_DEBUG ){
1868
-			$wpdb->show_errors( $old_show_errors_value );
1869
-			if( ! empty( $wpdb->last_error ) ){
1870
-				throw new EE_Error( sprintf( __( 'WPDB Error: "%s"', 'event_espresso' ), $wpdb->last_error ) );
1871
-			}elseif( $result === false ){
1872
-				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 ) ) );
1863
+			$wpdb->show_errors(FALSE);
1864
+		}
1865
+		$result = $this->_process_wpdb_query($wpdb_method, $arguments_to_provide);
1866
+		$this->show_db_query_if_previously_requested($wpdb->last_query);
1867
+		if (WP_DEBUG) {
1868
+			$wpdb->show_errors($old_show_errors_value);
1869
+			if ( ! empty($wpdb->last_error)) {
1870
+				throw new EE_Error(sprintf(__('WPDB Error: "%s"', 'event_espresso'), $wpdb->last_error));
1871
+			}elseif ($result === false) {
1872
+				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)));
1873 1873
 			}
1874
-		}elseif( $result === false ) {
1875
-			EE_Error::add_error( sprintf( __( 'A database error has occurred. Turn on WP_DEBUG for more information.', 'event_espresso' )), __FILE__, __FUNCTION__, __LINE__);
1874
+		}elseif ($result === false) {
1875
+			EE_Error::add_error(sprintf(__('A database error has occurred. Turn on WP_DEBUG for more information.', 'event_espresso')), __FILE__, __FUNCTION__, __LINE__);
1876 1876
 		}
1877 1877
 		return $result;
1878 1878
 	}
@@ -1888,26 +1888,26 @@  discard block
 block discarded – undo
1888 1888
 	 * @param array $arguments_to_provide
1889 1889
 	 * @return mixed
1890 1890
 	 */
1891
-	private function _process_wpdb_query( $wpdb_method, $arguments_to_provide ) {
1891
+	private function _process_wpdb_query($wpdb_method, $arguments_to_provide) {
1892 1892
 		/** @type WPDB $wpdb */
1893 1893
 		global $wpdb;
1894 1894
 		$wpdb->last_error = null;
1895
-		$result = call_user_func_array( array( $wpdb, $wpdb_method ), $arguments_to_provide );
1895
+		$result = call_user_func_array(array($wpdb, $wpdb_method), $arguments_to_provide);
1896 1896
 		// was there an error running the query? but we don't care on new activations
1897 1897
 		// (we're going to setup the DB anyway on new activations)
1898
-		if ( ( $result === false || ! empty( $wpdb->last_error ) )
1898
+		if (($result === false || ! empty($wpdb->last_error))
1899 1899
 			&& EE_System::instance()->detect_req_type() !== EE_System::req_type_new_activation
1900 1900
 		) {
1901
-			switch ( EEM_Base::$_db_verification_level ) {
1901
+			switch (EEM_Base::$_db_verification_level) {
1902 1902
 
1903 1903
 				case EEM_Base::db_verified_none :
1904 1904
 					// let's double-check core's DB
1905
-					$error_message = $this->_verify_core_db( $wpdb_method, $arguments_to_provide );
1905
+					$error_message = $this->_verify_core_db($wpdb_method, $arguments_to_provide);
1906 1906
 					break;
1907 1907
 
1908 1908
 				case EEM_Base::db_verified_core :
1909 1909
 					// STILL NO LOVE?? verify all the addons too. Maybe they need to be fixed
1910
-					$error_message = $this->_verify_addons_db( $wpdb_method, $arguments_to_provide );
1910
+					$error_message = $this->_verify_addons_db($wpdb_method, $arguments_to_provide);
1911 1911
 					break;
1912 1912
 
1913 1913
 				case EEM_Base::db_verified_addons :
@@ -1915,11 +1915,11 @@  discard block
 block discarded – undo
1915 1915
 					return $result;
1916 1916
 					break;
1917 1917
 			}
1918
-			if ( ! empty( $error_message ) ) {
1919
-				EE_Log::instance()->log( __FILE__, __FUNCTION__, $error_message, 'error' );
1920
-				trigger_error( $error_message );
1918
+			if ( ! empty($error_message)) {
1919
+				EE_Log::instance()->log(__FILE__, __FUNCTION__, $error_message, 'error');
1920
+				trigger_error($error_message);
1921 1921
 			}
1922
-			return $this->_process_wpdb_query( $wpdb_method, $arguments_to_provide );
1922
+			return $this->_process_wpdb_query($wpdb_method, $arguments_to_provide);
1923 1923
 
1924 1924
 		}
1925 1925
 
@@ -1935,18 +1935,18 @@  discard block
 block discarded – undo
1935 1935
 	 * @param array $arguments_to_provide
1936 1936
 	 * @return string
1937 1937
 	 */
1938
-	private function _verify_core_db( $wpdb_method, $arguments_to_provide ){
1938
+	private function _verify_core_db($wpdb_method, $arguments_to_provide) {
1939 1939
 		/** @type WPDB $wpdb */
1940 1940
 		global $wpdb;
1941 1941
 		//ok remember that we've already attempted fixing the core db, in case the problem persists
1942 1942
 		EEM_Base::$_db_verification_level = EEM_Base::db_verified_core;
1943 1943
 		$error_message = sprintf(
1944
-			__( 'WPDB Error "%1$s" while running wpdb method "%2$s" with arguments %3$s. Automatically attempting to fix EE Core DB', 'event_espresso' ),
1944
+			__('WPDB Error "%1$s" while running wpdb method "%2$s" with arguments %3$s. Automatically attempting to fix EE Core DB', 'event_espresso'),
1945 1945
 			$wpdb->last_error,
1946 1946
 			$wpdb_method,
1947
-			json_encode( $arguments_to_provide )
1947
+			json_encode($arguments_to_provide)
1948 1948
 		);
1949
-		EE_System::instance()->initialize_db_if_no_migrations_required( false, true );
1949
+		EE_System::instance()->initialize_db_if_no_migrations_required(false, true);
1950 1950
 		return $error_message;
1951 1951
 	}
1952 1952
 
@@ -1959,16 +1959,16 @@  discard block
 block discarded – undo
1959 1959
 	 * @param $arguments_to_provide
1960 1960
 	 * @return string
1961 1961
 	 */
1962
-	private function _verify_addons_db( $wpdb_method, $arguments_to_provide ) {
1962
+	private function _verify_addons_db($wpdb_method, $arguments_to_provide) {
1963 1963
 		/** @type WPDB $wpdb */
1964 1964
 		global $wpdb;
1965 1965
 		//ok remember that we've already attempted fixing the addons dbs, in case the problem persists
1966 1966
 		EEM_Base::$_db_verification_level = EEM_Base::db_verified_addons;
1967 1967
 		$error_message = sprintf(
1968
-			__( 'WPDB AGAIN: Error "%1$s" while running the same method and arguments as before. Automatically attempting to fix EE Addons DB', 'event_espresso' ),
1968
+			__('WPDB AGAIN: Error "%1$s" while running the same method and arguments as before. Automatically attempting to fix EE Addons DB', 'event_espresso'),
1969 1969
 			$wpdb->last_error,
1970 1970
 			$wpdb_method,
1971
-			json_encode( $arguments_to_provide )
1971
+			json_encode($arguments_to_provide)
1972 1972
 		);
1973 1973
 		EE_System::instance()->initialize_addons();
1974 1974
 		return $error_message;
@@ -1983,7 +1983,7 @@  discard block
 block discarded – undo
1983 1983
 	 * @param EE_Model_Query_Info_Carrier $model_query_info
1984 1984
 	 * @return string
1985 1985
 	 */
1986
-	private function _construct_2nd_half_of_select_query(EE_Model_Query_Info_Carrier $model_query_info){
1986
+	private function _construct_2nd_half_of_select_query(EE_Model_Query_Info_Carrier $model_query_info) {
1987 1987
 		return " FROM ".$model_query_info->get_full_join_sql().
1988 1988
 				$model_query_info->get_where_sql().
1989 1989
 				$model_query_info->get_group_by_sql().
@@ -1996,7 +1996,7 @@  discard block
 block discarded – undo
1996 1996
 	 * Set to easily debug the next X queries ran from this model.
1997 1997
 	 * @param int $count
1998 1998
 	 */
1999
-	public function show_next_x_db_queries($count = 1){
1999
+	public function show_next_x_db_queries($count = 1) {
2000 2000
 		$this->_show_next_x_db_queries = $count;
2001 2001
 	}
2002 2002
 
@@ -2005,8 +2005,8 @@  discard block
 block discarded – undo
2005 2005
 	/**
2006 2006
 	 * @param $sql_query
2007 2007
 	 */
2008
-	public function show_db_query_if_previously_requested($sql_query){
2009
-		if($this->_show_next_x_db_queries > 0){
2008
+	public function show_db_query_if_previously_requested($sql_query) {
2009
+		if ($this->_show_next_x_db_queries > 0) {
2010 2010
 			echo $sql_query;
2011 2011
 			$this->_show_next_x_db_queries--;
2012 2012
 		}
@@ -2030,9 +2030,9 @@  discard block
 block discarded – undo
2030 2030
 	 * @return EE_Base_Class which was added as a relation. Object referred to by $other_model_id_or_obj
2031 2031
 	 * @throws \EE_Error
2032 2032
 	 */
2033
-	public function add_relationship_to($id_or_obj,$other_model_id_or_obj, $relationName, $extra_join_model_fields_n_values = array()){
2033
+	public function add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $extra_join_model_fields_n_values = array()) {
2034 2034
 		$relation_obj = $this->related_settings_for($relationName);
2035
-		return $relation_obj->add_relation_to( $id_or_obj, $other_model_id_or_obj, $extra_join_model_fields_n_values);
2035
+		return $relation_obj->add_relation_to($id_or_obj, $other_model_id_or_obj, $extra_join_model_fields_n_values);
2036 2036
 	}
2037 2037
 
2038 2038
 
@@ -2051,9 +2051,9 @@  discard block
 block discarded – undo
2051 2051
 	 * @throws \EE_Error
2052 2052
 	 * @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.
2053 2053
 	 */
2054
-	public function remove_relationship_to($id_or_obj,  $other_model_id_or_obj, $relationName, $where_query= array() ){
2054
+	public function remove_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query = array()) {
2055 2055
 		$relation_obj = $this->related_settings_for($relationName);
2056
-		return $relation_obj->remove_relation_to($id_or_obj, $other_model_id_or_obj, $where_query );
2056
+		return $relation_obj->remove_relation_to($id_or_obj, $other_model_id_or_obj, $where_query);
2057 2057
 	}
2058 2058
 
2059 2059
 
@@ -2066,9 +2066,9 @@  discard block
 block discarded – undo
2066 2066
 	 * @return \EE_Base_Class[]
2067 2067
 	 * @throws \EE_Error
2068 2068
 	 */
2069
-	public function remove_relations($id_or_obj,$relationName,$where_query_params = array()){
2069
+	public function remove_relations($id_or_obj, $relationName, $where_query_params = array()) {
2070 2070
 		$relation_obj = $this->related_settings_for($relationName);
2071
-		return $relation_obj->remove_relations($id_or_obj, $where_query_params );
2071
+		return $relation_obj->remove_relations($id_or_obj, $where_query_params);
2072 2072
 	}
2073 2073
 
2074 2074
 
@@ -2084,10 +2084,10 @@  discard block
 block discarded – undo
2084 2084
 	 * @return EE_Base_Class[]
2085 2085
 	 * @throws \EE_Error
2086 2086
 	 */
2087
-	public function get_all_related($id_or_obj, $model_name, $query_params = null){
2087
+	public function get_all_related($id_or_obj, $model_name, $query_params = null) {
2088 2088
 		$model_obj = $this->ensure_is_obj($id_or_obj);
2089 2089
 		$relation_settings = $this->related_settings_for($model_name);
2090
-		return $relation_settings->get_all_related($model_obj,$query_params);
2090
+		return $relation_settings->get_all_related($model_obj, $query_params);
2091 2091
 	}
2092 2092
 
2093 2093
 
@@ -2104,10 +2104,10 @@  discard block
 block discarded – undo
2104 2104
 	 * @return int how many deleted
2105 2105
 	 * @throws \EE_Error
2106 2106
 	 */
2107
-	public function delete_related($id_or_obj,$model_name, $query_params = array()){
2107
+	public function delete_related($id_or_obj, $model_name, $query_params = array()) {
2108 2108
 		$model_obj = $this->ensure_is_obj($id_or_obj);
2109 2109
 		$relation_settings = $this->related_settings_for($model_name);
2110
-		return $relation_settings->delete_all_related($model_obj,$query_params);
2110
+		return $relation_settings->delete_all_related($model_obj, $query_params);
2111 2111
 	}
2112 2112
 
2113 2113
 
@@ -2124,10 +2124,10 @@  discard block
 block discarded – undo
2124 2124
 	 * @return int how many deleted
2125 2125
 	 * @throws \EE_Error
2126 2126
 	 */
2127
-	public function delete_related_permanently($id_or_obj,$model_name, $query_params = array()){
2127
+	public function delete_related_permanently($id_or_obj, $model_name, $query_params = array()) {
2128 2128
 		$model_obj = $this->ensure_is_obj($id_or_obj);
2129 2129
 		$relation_settings = $this->related_settings_for($model_name);
2130
-		return $relation_settings->delete_related_permanently($model_obj,$query_params);
2130
+		return $relation_settings->delete_related_permanently($model_obj, $query_params);
2131 2131
 	}
2132 2132
 
2133 2133
 
@@ -2144,17 +2144,17 @@  discard block
 block discarded – undo
2144 2144
 	 * @return int
2145 2145
 	 * @throws \EE_Error
2146 2146
 	 */
2147
-	public function count_related($id_or_obj,$model_name,$query_params = array(),$field_to_count = null, $distinct = FALSE){
2147
+	public function count_related($id_or_obj, $model_name, $query_params = array(), $field_to_count = null, $distinct = FALSE) {
2148 2148
 		$related_model = $this->get_related_model_obj($model_name);
2149 2149
 		//we're just going to use the query params on the related model's normal get_all query,
2150 2150
 		//except add a condition to say to match the current mod
2151
-		if( ! isset($query_params['default_where_conditions'])){
2152
-			$query_params['default_where_conditions']='none';
2151
+		if ( ! isset($query_params['default_where_conditions'])) {
2152
+			$query_params['default_where_conditions'] = 'none';
2153 2153
 		}
2154 2154
 		$this_model_name = $this->get_this_model_name();
2155 2155
 		$this_pk_field_name = $this->get_primary_key_field()->get_name();
2156
-		$query_params[0][$this_model_name.".".$this_pk_field_name]=$id_or_obj;
2157
-		return $related_model->count($query_params,$field_to_count,$distinct);
2156
+		$query_params[0][$this_model_name.".".$this_pk_field_name] = $id_or_obj;
2157
+		return $related_model->count($query_params, $field_to_count, $distinct);
2158 2158
 	}
2159 2159
 
2160 2160
 
@@ -2170,21 +2170,21 @@  discard block
 block discarded – undo
2170 2170
 	 * @return float
2171 2171
 	 * @throws \EE_Error
2172 2172
 	 */
2173
-	public function sum_related($id_or_obj,$model_name,$query_params,$field_to_sum = null){
2173
+	public function sum_related($id_or_obj, $model_name, $query_params, $field_to_sum = null) {
2174 2174
 		$related_model = $this->get_related_model_obj($model_name);
2175
-		if( ! is_array( $query_params ) ){
2176
-			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' );
2175
+		if ( ! is_array($query_params)) {
2176
+			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');
2177 2177
 			$query_params = array();
2178 2178
 		}
2179 2179
 		//we're just going to use the query params on the related model's normal get_all query,
2180 2180
 		//except add a condition to say to match the current mod
2181
-		if( ! isset($query_params['default_where_conditions'])){
2182
-			$query_params['default_where_conditions']='none';
2181
+		if ( ! isset($query_params['default_where_conditions'])) {
2182
+			$query_params['default_where_conditions'] = 'none';
2183 2183
 		}
2184 2184
 		$this_model_name = $this->get_this_model_name();
2185 2185
 		$this_pk_field_name = $this->get_primary_key_field()->get_name();
2186
-		$query_params[0][$this_model_name.".".$this_pk_field_name]=$id_or_obj;
2187
-		return $related_model->sum($query_params,$field_to_sum);
2186
+		$query_params[0][$this_model_name.".".$this_pk_field_name] = $id_or_obj;
2187
+		return $related_model->sum($query_params, $field_to_sum);
2188 2188
 	}
2189 2189
 
2190 2190
 
@@ -2198,12 +2198,12 @@  discard block
 block discarded – undo
2198 2198
 	 * @return EE_Base_Class
2199 2199
 	 * @throws \EE_Error
2200 2200
 	 */
2201
-	public function get_first_related( EE_Base_Class $id_or_obj, $other_model_name, $query_params ){
2202
-		$query_params['limit']=1;
2203
-		$results = $this->get_all_related($id_or_obj,$other_model_name,$query_params);
2204
-		if( $results ){
2201
+	public function get_first_related(EE_Base_Class $id_or_obj, $other_model_name, $query_params) {
2202
+		$query_params['limit'] = 1;
2203
+		$results = $this->get_all_related($id_or_obj, $other_model_name, $query_params);
2204
+		if ($results) {
2205 2205
 			return array_shift($results);
2206
-		}else{
2206
+		} else {
2207 2207
 			return null;
2208 2208
 		}
2209 2209
 
@@ -2213,8 +2213,8 @@  discard block
 block discarded – undo
2213 2213
 	 * Gets the model's name as it's expected in queries. For example, if this is EEM_Event model, that would be Event
2214 2214
 	 * @return string
2215 2215
 	 */
2216
-	public function get_this_model_name(){
2217
-		return str_replace("EEM_","",get_class($this));
2216
+	public function get_this_model_name() {
2217
+		return str_replace("EEM_", "", get_class($this));
2218 2218
 	}
2219 2219
 
2220 2220
 	/**
@@ -2222,14 +2222,14 @@  discard block
 block discarded – undo
2222 2222
 	 * @return EE_Any_Foreign_Model_Name_Field
2223 2223
 	 * @throws EE_Error
2224 2224
 	 */
2225
-	public function get_field_containing_related_model_name(){
2226
-		foreach($this->field_settings(true) as $field){
2227
-			if($field instanceof EE_Any_Foreign_Model_Name_Field){
2225
+	public function get_field_containing_related_model_name() {
2226
+		foreach ($this->field_settings(true) as $field) {
2227
+			if ($field instanceof EE_Any_Foreign_Model_Name_Field) {
2228 2228
 				$field_with_model_name = $field;
2229 2229
 			}
2230 2230
 		}
2231
-		if( !isset($field_with_model_name) || !$field_with_model_name ){
2232
-			throw new EE_Error(sprintf(__("There is no EE_Any_Foreign_Model_Name field on model %s", "event_espresso"), $this->get_this_model_name() ));
2231
+		if ( ! isset($field_with_model_name) || ! $field_with_model_name) {
2232
+			throw new EE_Error(sprintf(__("There is no EE_Any_Foreign_Model_Name field on model %s", "event_espresso"), $this->get_this_model_name()));
2233 2233
 		}
2234 2234
 		return $field_with_model_name;
2235 2235
 	}
@@ -2250,19 +2250,19 @@  discard block
 block discarded – undo
2250 2250
 	 * @return int new primary key on main table that got inserted
2251 2251
 	 * @throws EE_Error
2252 2252
 	 */
2253
-	public function insert($field_n_values){
2253
+	public function insert($field_n_values) {
2254 2254
 		/**
2255 2255
 		 * Filters the fields and their values before inserting an item using the models
2256 2256
 		 * @param array $fields_n_values keys are the fields and values are their new values
2257 2257
 		 * @param EEM_Base $model the model used
2258 2258
 		 */
2259
-		$field_n_values = (array)apply_filters( 'FHEE__EEM_Base__insert__fields_n_values', $field_n_values, $this );
2260
-		if($this->_satisfies_unique_indexes($field_n_values)){
2259
+		$field_n_values = (array) apply_filters('FHEE__EEM_Base__insert__fields_n_values', $field_n_values, $this);
2260
+		if ($this->_satisfies_unique_indexes($field_n_values)) {
2261 2261
 			$main_table = $this->_get_main_table();
2262 2262
 			$new_id = $this->_insert_into_specific_table($main_table, $field_n_values, false);
2263
-			if( $new_id !== false ) {
2264
-				foreach($this->_get_other_tables() as $other_table){
2265
-					$this->_insert_into_specific_table($other_table, $field_n_values,$new_id);
2263
+			if ($new_id !== false) {
2264
+				foreach ($this->_get_other_tables() as $other_table) {
2265
+					$this->_insert_into_specific_table($other_table, $field_n_values, $new_id);
2266 2266
 				}
2267 2267
 			}
2268 2268
 			/**
@@ -2272,9 +2272,9 @@  discard block
 block discarded – undo
2272 2272
 			 * @param array $fields_n_values fields and their values
2273 2273
 			 * @param int|string the ID of the newly-inserted model object
2274 2274
 			 */
2275
-			do_action( 'AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id );
2275
+			do_action('AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id);
2276 2276
 			return $new_id;
2277
-		}else{
2277
+		} else {
2278 2278
 			return FALSE;
2279 2279
 		}
2280 2280
 	}
@@ -2289,10 +2289,10 @@  discard block
 block discarded – undo
2289 2289
 	 * @return boolean
2290 2290
 	 * @throws \EE_Error
2291 2291
 	 */
2292
-	protected function _satisfies_unique_indexes($field_n_values,$action = 'insert'){
2293
-		foreach($this->unique_indexes() as $index_name => $index){
2292
+	protected function _satisfies_unique_indexes($field_n_values, $action = 'insert') {
2293
+		foreach ($this->unique_indexes() as $index_name => $index) {
2294 2294
 			$uniqueness_where_params = array_intersect_key($field_n_values, $index->fields());
2295
-			if($this->exists(array($uniqueness_where_params))){
2295
+			if ($this->exists(array($uniqueness_where_params))) {
2296 2296
 				EE_Error::add_error(
2297 2297
 					sprintf(
2298 2298
 						__(
@@ -2302,8 +2302,8 @@  discard block
 block discarded – undo
2302 2302
 						$action,
2303 2303
 						$this->_get_class_name(),
2304 2304
 						$index_name,
2305
-						implode( ",", $index->field_names() ),
2306
-						http_build_query( $uniqueness_where_params )
2305
+						implode(",", $index->field_names()),
2306
+						http_build_query($uniqueness_where_params)
2307 2307
 					),
2308 2308
 					__FILE__,
2309 2309
 					__FUNCTION__,
@@ -2329,37 +2329,37 @@  discard block
 block discarded – undo
2329 2329
 	 * @throws EE_Error
2330 2330
 	 * @return EE_Base_Class
2331 2331
 	 */
2332
-	public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true ){
2333
-		if($obj_or_fields_array instanceof EE_Base_Class){
2332
+	public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true) {
2333
+		if ($obj_or_fields_array instanceof EE_Base_Class) {
2334 2334
 			$fields_n_values = $obj_or_fields_array->model_field_array();
2335
-		}elseif( is_array($obj_or_fields_array)){
2335
+		}elseif (is_array($obj_or_fields_array)) {
2336 2336
 			$fields_n_values = $obj_or_fields_array;
2337
-		}else{
2337
+		} else {
2338 2338
 			throw new EE_Error(
2339 2339
 				sprintf(
2340 2340
 					__(
2341 2341
 						"%s get_all_conflicting should be called with a model object or an array of field names and values, you provided %d",
2342 2342
 						"event_espresso"
2343 2343
 					),
2344
-					get_class( $this ),
2344
+					get_class($this),
2345 2345
 					$obj_or_fields_array
2346 2346
 				)
2347 2347
 			);
2348 2348
 		}
2349 2349
 		$query_params = array();
2350
-		if( $this->has_primary_key_field() &&
2351
-				( $include_primary_key || $this->get_primary_key_field() instanceof EE_Primary_Key_String_Field) &&
2352
-				isset($fields_n_values[$this->primary_key_name()])){
2350
+		if ($this->has_primary_key_field() &&
2351
+				($include_primary_key || $this->get_primary_key_field() instanceof EE_Primary_Key_String_Field) &&
2352
+				isset($fields_n_values[$this->primary_key_name()])) {
2353 2353
 			$query_params[0]['OR'][$this->primary_key_name()] = $fields_n_values[$this->primary_key_name()];
2354 2354
 		}
2355
-		foreach($this->unique_indexes() as $unique_index_name=>$unique_index){
2355
+		foreach ($this->unique_indexes() as $unique_index_name=>$unique_index) {
2356 2356
 			$uniqueness_where_params = array_intersect_key($fields_n_values, $unique_index->fields());
2357 2357
 			$query_params[0]['OR']['AND*'.$unique_index_name] = $uniqueness_where_params;
2358 2358
 		}
2359 2359
 		//if there is nothing to base this search on, then we shouldn't find anything
2360
-		if( empty( $query_params ) ){
2360
+		if (empty($query_params)) {
2361 2361
 			return array();
2362
-		}else{
2362
+		} else {
2363 2363
 			return $this->get_one($query_params);
2364 2364
 		}
2365 2365
 	}
@@ -2373,7 +2373,7 @@  discard block
 block discarded – undo
2373 2373
 	 * @return boolean
2374 2374
 	 * @throws \EE_Error
2375 2375
 	 */
2376
-	public function exists($query_params){
2376
+	public function exists($query_params) {
2377 2377
 		$query_params['limit'] = 1;
2378 2378
 		return $this->count($query_params) > 0;
2379 2379
 	}
@@ -2387,7 +2387,7 @@  discard block
 block discarded – undo
2387 2387
 	 * @return boolean
2388 2388
 	 * @throws \EE_Error
2389 2389
 	 */
2390
-	public function exists_by_ID($id){
2390
+	public function exists_by_ID($id) {
2391 2391
 		return $this->exists(array('default_where_conditions'=>'none', array($this->primary_key_name() => $id)));
2392 2392
 	}
2393 2393
 
@@ -2407,45 +2407,45 @@  discard block
 block discarded – undo
2407 2407
 	 * @global WPDB $wpdb only used to get the $wpdb->insert_id after performing an insert
2408 2408
 	 * @return int ID of new row inserted, or FALSE on failure
2409 2409
 	 */
2410
-	protected function _insert_into_specific_table(EE_Table_Base $table, $fields_n_values, $new_id = 0 ){
2410
+	protected function _insert_into_specific_table(EE_Table_Base $table, $fields_n_values, $new_id = 0) {
2411 2411
 		global $wpdb;
2412 2412
 		$insertion_col_n_values = array();
2413 2413
 		$format_for_insertion = array();
2414 2414
 		$fields_on_table = $this->_get_fields_for_table($table->get_table_alias());
2415
-		foreach($fields_on_table as $field_name => $field_obj){
2415
+		foreach ($fields_on_table as $field_name => $field_obj) {
2416 2416
 			//check if its an auto-incrementing column, in which case we should just leave it to do its autoincrement thing
2417
-			if($field_obj->is_auto_increment()){
2417
+			if ($field_obj->is_auto_increment()) {
2418 2418
 				continue;
2419 2419
 			}
2420 2420
 			$prepared_value = $this->_prepare_value_or_use_default($field_obj, $fields_n_values);
2421 2421
 			//if the value we want to assign it to is NULL, just don't mention it for the insertion
2422
-			if( $prepared_value !== NULL ){
2423
-				$insertion_col_n_values[ $field_obj->get_table_column() ] = $prepared_value;
2422
+			if ($prepared_value !== NULL) {
2423
+				$insertion_col_n_values[$field_obj->get_table_column()] = $prepared_value;
2424 2424
 				$format_for_insertion[] = $field_obj->get_wpdb_data_type();
2425 2425
 			}
2426 2426
 		}
2427 2427
 
2428
-		if($table instanceof EE_Secondary_Table && $new_id){
2428
+		if ($table instanceof EE_Secondary_Table && $new_id) {
2429 2429
 			//its not the main table, so we should have already saved the main table's PK which we just inserted
2430 2430
 			//so add the fk to the main table as a column
2431 2431
 			$insertion_col_n_values[$table->get_fk_on_table()] = $new_id;
2432
-			$format_for_insertion[]='%d';//yes right now we're only allowing these foreign keys to be INTs
2432
+			$format_for_insertion[] = '%d'; //yes right now we're only allowing these foreign keys to be INTs
2433 2433
 		}
2434 2434
 		//insert the new entry
2435
-		$result = $this->_do_wpdb_query( 'insert', array( $table->get_table_name(), $insertion_col_n_values, $format_for_insertion ) );
2436
-		if( $result === false ) {
2435
+		$result = $this->_do_wpdb_query('insert', array($table->get_table_name(), $insertion_col_n_values, $format_for_insertion));
2436
+		if ($result === false) {
2437 2437
 			return false;
2438 2438
 		}
2439 2439
 		//ok, now what do we return for the ID of the newly-inserted thing?
2440
-		if($this->has_primary_key_field()){
2441
-			if($this->get_primary_key_field()->is_auto_increment()){
2440
+		if ($this->has_primary_key_field()) {
2441
+			if ($this->get_primary_key_field()->is_auto_increment()) {
2442 2442
 				return $wpdb->insert_id;
2443
-			}else{
2443
+			} else {
2444 2444
 				//it's not an auto-increment primary key, so
2445 2445
 				//it must have been supplied
2446 2446
 				return $fields_n_values[$this->get_primary_key_field()->get_name()];
2447 2447
 			}
2448
-		}else{
2448
+		} else {
2449 2449
 			//we can't return a  primary key because there is none. instead return
2450 2450
 			//a unique string indicating this model
2451 2451
 			return $this->get_index_primary_key_string($fields_n_values);
@@ -2464,15 +2464,15 @@  discard block
 block discarded – undo
2464 2464
 	 * @return mixed string|int|float depending on what the table column will be expecting
2465 2465
 	 * @throws \EE_Error
2466 2466
 	 */
2467
-	protected function _prepare_value_or_use_default( $field_obj, $fields_n_values ){
2467
+	protected function _prepare_value_or_use_default($field_obj, $fields_n_values) {
2468 2468
 		//if this field doesn't allow nullable, don't allow it
2469
-		if( ! $field_obj->is_nullable() && (
2470
-				! isset( $fields_n_values[ $field_obj->get_name() ] ) ||
2471
-				$fields_n_values[ $field_obj->get_name() ] === NULL ) ){
2472
-			$fields_n_values[ $field_obj->get_name() ] = $field_obj->get_default_value();
2469
+		if ( ! $field_obj->is_nullable() && (
2470
+				! isset($fields_n_values[$field_obj->get_name()]) ||
2471
+				$fields_n_values[$field_obj->get_name()] === NULL )) {
2472
+			$fields_n_values[$field_obj->get_name()] = $field_obj->get_default_value();
2473 2473
 		}
2474
-		$unprepared_value = isset( $fields_n_values[ $field_obj->get_name() ] ) ? $fields_n_values[ $field_obj->get_name() ] : NULL;
2475
-		return $this->_prepare_value_for_use_in_db( $unprepared_value, $field_obj);
2474
+		$unprepared_value = isset($fields_n_values[$field_obj->get_name()]) ? $fields_n_values[$field_obj->get_name()] : NULL;
2475
+		return $this->_prepare_value_for_use_in_db($unprepared_value, $field_obj);
2476 2476
 	}
2477 2477
 
2478 2478
 
@@ -2484,9 +2484,9 @@  discard block
 block discarded – undo
2484 2484
 	 * @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
2485 2485
 	 * @return mixed a value ready for use in the database for insertions, updating, or in a where clause
2486 2486
 	 */
2487
-	private function _prepare_value_for_use_in_db($value, $field){
2488
-		if($field && $field instanceof EE_Model_Field_Base){
2489
-			switch( $this->_values_already_prepared_by_model_object ){
2487
+	private function _prepare_value_for_use_in_db($value, $field) {
2488
+		if ($field && $field instanceof EE_Model_Field_Base) {
2489
+			switch ($this->_values_already_prepared_by_model_object) {
2490 2490
 				/** @noinspection PhpMissingBreakStatementInspection */
2491 2491
 				case self::not_prepared_by_model_object:
2492 2492
 					$value = $field->prepare_for_set($value);
@@ -2497,7 +2497,7 @@  discard block
 block discarded – undo
2497 2497
 					//leave the value alone
2498 2498
 			}
2499 2499
 			return $value;
2500
-		}else{
2500
+		} else {
2501 2501
 			return $value;
2502 2502
 		}
2503 2503
 	}
@@ -2507,13 +2507,13 @@  discard block
 block discarded – undo
2507 2507
 	 * @return EE_Primary_Table
2508 2508
 	 * @throws EE_Error
2509 2509
 	 */
2510
-	protected function _get_main_table(){
2511
-		foreach($this->_tables as $table){
2512
-			if($table instanceof EE_Primary_Table){
2510
+	protected function _get_main_table() {
2511
+		foreach ($this->_tables as $table) {
2512
+			if ($table instanceof EE_Primary_Table) {
2513 2513
 				return $table;
2514 2514
 			}
2515 2515
 		}
2516
-		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)));
2516
+		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)));
2517 2517
 	}
2518 2518
 
2519 2519
 
@@ -2536,7 +2536,7 @@  discard block
 block discarded – undo
2536 2536
 	 */
2537 2537
 	public function second_table() {
2538 2538
 		// grab second table from tables array
2539
-		$second_table = end( $this->_tables );
2539
+		$second_table = end($this->_tables);
2540 2540
 		return $second_table instanceof EE_Secondary_Table ? $second_table->get_table_name() : NULL;
2541 2541
 	}
2542 2542
 
@@ -2549,8 +2549,8 @@  discard block
 block discarded – undo
2549 2549
 	 * @param string $table_alias
2550 2550
 	 * @return EE_Primary_Table | EE_Secondary_Table
2551 2551
 	 */
2552
-	public function get_table_obj_by_alias( $table_alias = '' ) {
2553
-		return isset( $this->_tables[ $table_alias ] ) ? $this->_tables[ $table_alias ] : NULL;
2552
+	public function get_table_obj_by_alias($table_alias = '') {
2553
+		return isset($this->_tables[$table_alias]) ? $this->_tables[$table_alias] : NULL;
2554 2554
 	}
2555 2555
 
2556 2556
 
@@ -2559,10 +2559,10 @@  discard block
 block discarded – undo
2559 2559
 	 * Gets all the tables of type EE_Other_Table from EEM_CPT_Basel_Model::_tables
2560 2560
 	 * @return EE_Secondary_Table[]
2561 2561
 	 */
2562
-	protected function _get_other_tables(){
2563
-		$other_tables =array();
2564
-		foreach($this->_tables as $table_alias => $table){
2565
-			if($table instanceof EE_Secondary_Table){
2562
+	protected function _get_other_tables() {
2563
+		$other_tables = array();
2564
+		foreach ($this->_tables as $table_alias => $table) {
2565
+			if ($table instanceof EE_Secondary_Table) {
2566 2566
 				$other_tables[$table_alias] = $table;
2567 2567
 			}
2568 2568
 		}
@@ -2574,7 +2574,7 @@  discard block
 block discarded – undo
2574 2574
 	 * @param string $table_alias, array key in EEM_Base::_tables
2575 2575
 	 * @return EE_Model_Field_Base[]
2576 2576
 	 */
2577
-	public function _get_fields_for_table($table_alias){
2577
+	public function _get_fields_for_table($table_alias) {
2578 2578
 		return $this->_fields[$table_alias];
2579 2579
 	}
2580 2580
 
@@ -2590,19 +2590,19 @@  discard block
 block discarded – undo
2590 2590
 	 * @return EE_Model_Query_Info_Carrier
2591 2591
 	 * @throws \EE_Error
2592 2592
 	 */
2593
-	public function _extract_related_models_from_query($query_params){
2593
+	public function _extract_related_models_from_query($query_params) {
2594 2594
 		$query_info_carrier = new EE_Model_Query_Info_Carrier();
2595
-		if ( array_key_exists( 0, $query_params ) ) {
2596
-			$this->_extract_related_models_from_sub_params_array_keys( $query_params[0], $query_info_carrier, 0 );
2595
+		if (array_key_exists(0, $query_params)) {
2596
+			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier, 0);
2597 2597
 		}
2598
-		if ( array_key_exists( 'group_by', $query_params ) ) {
2599
-			if ( is_array( $query_params['group_by'] ) ) {
2598
+		if (array_key_exists('group_by', $query_params)) {
2599
+			if (is_array($query_params['group_by'])) {
2600 2600
 				$this->_extract_related_models_from_sub_params_array_values(
2601 2601
 					$query_params['group_by'],
2602 2602
 					$query_info_carrier,
2603 2603
 					'group_by'
2604 2604
 				);
2605
-			} elseif ( ! empty ( $query_params['group_by'] ) ) {
2605
+			} elseif ( ! empty ($query_params['group_by'])) {
2606 2606
 				$this->_extract_related_model_info_from_query_param(
2607 2607
 					$query_params['group_by'],
2608 2608
 					$query_info_carrier,
@@ -2610,21 +2610,21 @@  discard block
 block discarded – undo
2610 2610
 				);
2611 2611
 			}
2612 2612
 		}
2613
-		if ( array_key_exists( 'having', $query_params ) ) {
2613
+		if (array_key_exists('having', $query_params)) {
2614 2614
 			$this->_extract_related_models_from_sub_params_array_keys(
2615 2615
 				$query_params[0],
2616 2616
 				$query_info_carrier,
2617 2617
 				'having'
2618 2618
 			);
2619 2619
 		}
2620
-		if ( array_key_exists( 'order_by', $query_params ) ) {
2621
-			if ( is_array( $query_params['order_by'] ) ) {
2620
+		if (array_key_exists('order_by', $query_params)) {
2621
+			if (is_array($query_params['order_by'])) {
2622 2622
 				$this->_extract_related_models_from_sub_params_array_keys(
2623 2623
 					$query_params['order_by'],
2624 2624
 					$query_info_carrier,
2625 2625
 					'order_by'
2626 2626
 				);
2627
-			} elseif ( ! empty( $query_params['order_by'] ) ) {
2627
+			} elseif ( ! empty($query_params['order_by'])) {
2628 2628
 				$this->_extract_related_model_info_from_query_param(
2629 2629
 					$query_params['order_by'],
2630 2630
 					$query_info_carrier,
@@ -2632,7 +2632,7 @@  discard block
 block discarded – undo
2632 2632
 				);
2633 2633
 			}
2634 2634
 		}
2635
-		if ( array_key_exists( 'force_join', $query_params ) ) {
2635
+		if (array_key_exists('force_join', $query_params)) {
2636 2636
 			$this->_extract_related_models_from_sub_params_array_values(
2637 2637
 				$query_params['force_join'],
2638 2638
 				$query_info_carrier,
@@ -2650,34 +2650,34 @@  discard block
 block discarded – undo
2650 2650
 	 * @throws EE_Error
2651 2651
 	 * @return \EE_Model_Query_Info_Carrier
2652 2652
 	 */
2653
-	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){
2654
-		if (!empty($sub_query_params)){
2653
+	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) {
2654
+		if ( ! empty($sub_query_params)) {
2655 2655
 			$sub_query_params = (array) $sub_query_params;
2656
-			foreach($sub_query_params as $param => $possibly_array_of_params){
2656
+			foreach ($sub_query_params as $param => $possibly_array_of_params) {
2657 2657
 				//$param could be simply 'EVT_ID', or it could be 'Registrations.REG_ID', or even 'Registrations.Transactions.Payments.PAY_amount'
2658
-				$this->_extract_related_model_info_from_query_param( $param, $model_query_info_carrier,$query_param_type);
2658
+				$this->_extract_related_model_info_from_query_param($param, $model_query_info_carrier, $query_param_type);
2659 2659
 
2660 2660
 				//if $possibly_array_of_params is an array, try recursing into it, searching for keys which
2661 2661
 				//indicate needed joins. Eg, array('NOT'=>array('Registration.TXN_ID'=>23)). In this case, we tried
2662 2662
 				//extracting models out of the 'NOT', which obviously wasn't successful, and then we recurse into the value
2663 2663
 				//of array('Registration.TXN_ID'=>23)
2664 2664
 				$query_param_sans_stars = $this->_remove_stars_and_anything_after_from_condition_query_param_key($param);
2665
-				if(in_array($query_param_sans_stars, $this->_logic_query_param_keys,true)){
2666
-					if (! is_array($possibly_array_of_params)){
2665
+				if (in_array($query_param_sans_stars, $this->_logic_query_param_keys, true)) {
2666
+					if ( ! is_array($possibly_array_of_params)) {
2667 2667
 						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"),
2668
-							$param,$possibly_array_of_params));
2669
-					}else{
2670
-						$this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier,$query_param_type);
2668
+							$param, $possibly_array_of_params));
2669
+					} else {
2670
+						$this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier, $query_param_type);
2671 2671
 					}
2672
-				}elseif($query_param_type === 0 //ie WHERE
2672
+				}elseif ($query_param_type === 0 //ie WHERE
2673 2673
 						&& is_array($possibly_array_of_params)
2674 2674
 						&& isset($possibly_array_of_params[2])
2675
-						&& $possibly_array_of_params[2] == true){
2675
+						&& $possibly_array_of_params[2] == true) {
2676 2676
 					//then $possible_array_of_params looks something like array('<','DTT_sold',true)
2677 2677
 					//indicating that $possible_array_of_params[1] is actually a field name,
2678 2678
 					//from which we should extract query parameters!
2679
-					if( ! isset($possibly_array_of_params[0], $possibly_array_of_params[1] ) ) {
2680
-						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)));
2679
+					if ( ! isset($possibly_array_of_params[0], $possibly_array_of_params[1])) {
2680
+						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)));
2681 2681
 					}
2682 2682
 					$this->_extract_related_model_info_from_query_param($possibly_array_of_params[1], $model_query_info_carrier, $query_param_type);
2683 2683
 				}
@@ -2696,14 +2696,14 @@  discard block
 block discarded – undo
2696 2696
 	 * @throws EE_Error
2697 2697
 	 * @return \EE_Model_Query_Info_Carrier
2698 2698
 	 */
2699
-	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){
2700
-		if (!empty($sub_query_params)){
2701
-			if(!is_array($sub_query_params)){
2702
-				throw new EE_Error(sprintf(__("Query parameter %s should be an array, but it isn't.", "event_espresso"),$sub_query_params));
2699
+	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) {
2700
+		if ( ! empty($sub_query_params)) {
2701
+			if ( ! is_array($sub_query_params)) {
2702
+				throw new EE_Error(sprintf(__("Query parameter %s should be an array, but it isn't.", "event_espresso"), $sub_query_params));
2703 2703
 			}
2704
-			foreach($sub_query_params as $param){
2704
+			foreach ($sub_query_params as $param) {
2705 2705
 				//$param could be simply 'EVT_ID', or it could be 'Registrations.REG_ID', or even 'Registrations.Transactions.Payments.PAY_amount'
2706
-				$this->_extract_related_model_info_from_query_param( $param, $model_query_info_carrier, $query_param_type);
2706
+				$this->_extract_related_model_info_from_query_param($param, $model_query_info_carrier, $query_param_type);
2707 2707
 			}
2708 2708
 		}
2709 2709
 		return $model_query_info_carrier;
@@ -2722,8 +2722,8 @@  discard block
 block discarded – undo
2722 2722
 	 * @throws EE_Error
2723 2723
 	 * @return EE_Model_Query_Info_Carrier
2724 2724
 	 */
2725
-	public function _create_model_query_info_carrier($query_params){
2726
-		if ( ! is_array( $query_params ) ) {
2725
+	public function _create_model_query_info_carrier($query_params) {
2726
+		if ( ! is_array($query_params)) {
2727 2727
 			EE_Error::doing_it_wrong(
2728 2728
 				'EEM_Base::_create_model_query_info_carrier',
2729 2729
 				sprintf(
@@ -2731,16 +2731,16 @@  discard block
 block discarded – undo
2731 2731
 						'$query_params should be an array, you passed a variable of type %s',
2732 2732
 						'event_espresso'
2733 2733
 					),
2734
-					gettype( $query_params )
2734
+					gettype($query_params)
2735 2735
 				),
2736 2736
 				'4.6.0'
2737 2737
 			);
2738 2738
 			$query_params = array();
2739 2739
 		}
2740
-		$where_query_params = isset( $query_params[0] ) ? $query_params[0] : array();
2740
+		$where_query_params = isset($query_params[0]) ? $query_params[0] : array();
2741 2741
 		//first check if we should alter the query to account for caps or not
2742 2742
 		//because the caps might require us to do extra joins
2743
-		if ( isset( $query_params['caps'] ) && $query_params['caps'] !== 'none' ) {
2743
+		if (isset($query_params['caps']) && $query_params['caps'] !== 'none') {
2744 2744
 			$query_params[0] = $where_query_params = array_replace_recursive(
2745 2745
 				$where_query_params,
2746 2746
 				$this->caps_where_conditions(
@@ -2748,10 +2748,10 @@  discard block
 block discarded – undo
2748 2748
 				)
2749 2749
 			);
2750 2750
 		}
2751
-		$query_object = $this->_extract_related_models_from_query( $query_params );
2751
+		$query_object = $this->_extract_related_models_from_query($query_params);
2752 2752
 		//verify where_query_params has NO numeric indexes.... that's simply not how you use it!
2753
-		foreach ( $where_query_params as $key => $value ) {
2754
-			if ( is_int( $key ) ) {
2753
+		foreach ($where_query_params as $key => $value) {
2754
+			if (is_int($key)) {
2755 2755
 				throw new EE_Error(
2756 2756
 					sprintf(
2757 2757
 						__(
@@ -2759,16 +2759,16 @@  discard block
 block discarded – undo
2759 2759
 							"event_espresso"
2760 2760
 						),
2761 2761
 						$key,
2762
-						var_export( $value, true ),
2763
-						var_export( $query_params, true ),
2764
-						get_class( $this )
2762
+						var_export($value, true),
2763
+						var_export($query_params, true),
2764
+						get_class($this)
2765 2765
 					)
2766 2766
 				);
2767 2767
 			}
2768 2768
 		}
2769 2769
 		if (
2770
-			array_key_exists( 'default_where_conditions', $query_params )
2771
-			&& ! empty( $query_params['default_where_conditions'] )
2770
+			array_key_exists('default_where_conditions', $query_params)
2771
+			&& ! empty($query_params['default_where_conditions'])
2772 2772
 		) {
2773 2773
 			$use_default_where_conditions = $query_params['default_where_conditions'];
2774 2774
 		} else {
@@ -2782,13 +2782,13 @@  discard block
 block discarded – undo
2782 2782
 			),
2783 2783
 			$where_query_params
2784 2784
 		);
2785
-		$query_object->set_where_sql( $this->_construct_where_clause( $where_query_params ) );
2785
+		$query_object->set_where_sql($this->_construct_where_clause($where_query_params));
2786 2786
 		// if this is a "on_join_limit" then we are limiting on on a specific table in a multi_table join.
2787 2787
 		// So we need to setup a subquery and use that for the main join.
2788 2788
 		// Note for now this only works on the primary table for the model.
2789 2789
 		// So for instance, you could set the limit array like this:
2790 2790
 		// array( 'on_join_limit' => array('Primary_Table_Alias', array(1,10) ) )
2791
-		if ( array_key_exists( 'on_join_limit', $query_params ) && ! empty( $query_params['on_join_limit'] ) ) {
2791
+		if (array_key_exists('on_join_limit', $query_params) && ! empty($query_params['on_join_limit'])) {
2792 2792
 			$query_object->set_main_model_join_sql(
2793 2793
 				$this->_construct_limit_join_select(
2794 2794
 					$query_params['on_join_limit'][0],
@@ -2797,40 +2797,40 @@  discard block
 block discarded – undo
2797 2797
 			);
2798 2798
 		}
2799 2799
 		//set limit
2800
-		if ( array_key_exists( 'limit', $query_params ) ) {
2801
-			if ( is_array( $query_params['limit'] ) ) {
2802
-				if ( ! isset( $query_params['limit'][0], $query_params['limit'][1] ) ) {
2800
+		if (array_key_exists('limit', $query_params)) {
2801
+			if (is_array($query_params['limit'])) {
2802
+				if ( ! isset($query_params['limit'][0], $query_params['limit'][1])) {
2803 2803
 					$e = sprintf(
2804 2804
 						__(
2805 2805
 							"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)",
2806 2806
 							"event_espresso"
2807 2807
 						),
2808
-						http_build_query( $query_params['limit'] )
2808
+						http_build_query($query_params['limit'])
2809 2809
 					);
2810
-					throw new EE_Error( $e . "|" . $e );
2810
+					throw new EE_Error($e."|".$e);
2811 2811
 				}
2812 2812
 				//they passed us an array for the limit. Assume it's like array(50,25), meaning offset by 50, and get 25
2813
-				$query_object->set_limit_sql( " LIMIT " . $query_params['limit'][0] . "," . $query_params['limit'][1] );
2814
-			} elseif ( ! empty ( $query_params['limit'] ) ) {
2815
-				$query_object->set_limit_sql( " LIMIT " . $query_params['limit'] );
2813
+				$query_object->set_limit_sql(" LIMIT ".$query_params['limit'][0].",".$query_params['limit'][1]);
2814
+			} elseif ( ! empty ($query_params['limit'])) {
2815
+				$query_object->set_limit_sql(" LIMIT ".$query_params['limit']);
2816 2816
 			}
2817 2817
 		}
2818 2818
 		//set order by
2819
-		if ( array_key_exists( 'order_by', $query_params ) ) {
2820
-			if ( is_array( $query_params['order_by'] ) ) {
2819
+		if (array_key_exists('order_by', $query_params)) {
2820
+			if (is_array($query_params['order_by'])) {
2821 2821
 				//if they're using 'order_by' as an array, they can't use 'order' (because 'order_by' must
2822 2822
 				//specify whether to ascend or descend on each field. Eg 'order_by'=>array('EVT_ID'=>'ASC'). So
2823 2823
 				//including 'order' wouldn't make any sense if 'order_by' has already specified which way to order!
2824
-				if ( array_key_exists( 'order', $query_params ) ) {
2824
+				if (array_key_exists('order', $query_params)) {
2825 2825
 					throw new EE_Error(
2826 2826
 						sprintf(
2827 2827
 							__(
2828 2828
 								"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 ",
2829 2829
 								"event_espresso"
2830 2830
 							),
2831
-							get_class( $this ),
2832
-							implode( ", ", array_keys( $query_params['order_by'] ) ),
2833
-							implode( ", ", $query_params['order_by'] ),
2831
+							get_class($this),
2832
+							implode(", ", array_keys($query_params['order_by'])),
2833
+							implode(", ", $query_params['order_by']),
2834 2834
 							$query_params['order']
2835 2835
 						)
2836 2836
 					);
@@ -2842,57 +2842,57 @@  discard block
 block discarded – undo
2842 2842
 				);
2843 2843
 				//assume it's an array of fields to order by
2844 2844
 				$order_array = array();
2845
-				foreach ( $query_params['order_by'] as $field_name_to_order_by => $order ) {
2846
-					$order = $this->_extract_order( $order );
2847
-					$order_array[] = $this->_deduce_column_name_from_query_param( $field_name_to_order_by ) . SP . $order;
2845
+				foreach ($query_params['order_by'] as $field_name_to_order_by => $order) {
2846
+					$order = $this->_extract_order($order);
2847
+					$order_array[] = $this->_deduce_column_name_from_query_param($field_name_to_order_by).SP.$order;
2848 2848
 				}
2849
-				$query_object->set_order_by_sql( " ORDER BY " . implode( ",", $order_array ) );
2850
-			} elseif ( ! empty ( $query_params['order_by'] ) ) {
2849
+				$query_object->set_order_by_sql(" ORDER BY ".implode(",", $order_array));
2850
+			} elseif ( ! empty ($query_params['order_by'])) {
2851 2851
 				$this->_extract_related_model_info_from_query_param(
2852 2852
 					$query_params['order_by'],
2853 2853
 					$query_object,
2854 2854
 					'order',
2855 2855
 					$query_params['order_by']
2856 2856
 				);
2857
-				$order = isset( $query_params['order'] )
2858
-					? $this->_extract_order( $query_params['order'] )
2857
+				$order = isset($query_params['order'])
2858
+					? $this->_extract_order($query_params['order'])
2859 2859
 					: 'DESC';
2860 2860
 				$query_object->set_order_by_sql(
2861
-					" ORDER BY " . $this->_deduce_column_name_from_query_param( $query_params['order_by'] ) . SP . $order
2861
+					" ORDER BY ".$this->_deduce_column_name_from_query_param($query_params['order_by']).SP.$order
2862 2862
 				);
2863 2863
 			}
2864 2864
 		}
2865 2865
 		//if 'order_by' wasn't set, maybe they are just using 'order' on its own?
2866
-		if ( ! array_key_exists( 'order_by', $query_params )
2867
-		     && array_key_exists( 'order', $query_params )
2868
-		     && ! empty( $query_params['order'] )
2866
+		if ( ! array_key_exists('order_by', $query_params)
2867
+		     && array_key_exists('order', $query_params)
2868
+		     && ! empty($query_params['order'])
2869 2869
 		) {
2870 2870
 			$pk_field = $this->get_primary_key_field();
2871
-			$order = $this->_extract_order( $query_params['order'] );
2872
-			$query_object->set_order_by_sql( " ORDER BY " . $pk_field->get_qualified_column() . SP . $order );
2871
+			$order = $this->_extract_order($query_params['order']);
2872
+			$query_object->set_order_by_sql(" ORDER BY ".$pk_field->get_qualified_column().SP.$order);
2873 2873
 		}
2874 2874
 		//set group by
2875
-		if ( array_key_exists( 'group_by', $query_params ) ) {
2876
-			if ( is_array( $query_params['group_by'] ) ) {
2875
+		if (array_key_exists('group_by', $query_params)) {
2876
+			if (is_array($query_params['group_by'])) {
2877 2877
 				//it's an array, so assume we'll be grouping by a bunch of stuff
2878 2878
 				$group_by_array = array();
2879
-				foreach ( $query_params['group_by'] as $field_name_to_group_by ) {
2880
-					$group_by_array[] = $this->_deduce_column_name_from_query_param( $field_name_to_group_by );
2879
+				foreach ($query_params['group_by'] as $field_name_to_group_by) {
2880
+					$group_by_array[] = $this->_deduce_column_name_from_query_param($field_name_to_group_by);
2881 2881
 				}
2882
-				$query_object->set_group_by_sql( " GROUP BY " . implode( ", ", $group_by_array ) );
2883
-			} elseif ( ! empty ( $query_params['group_by'] ) ) {
2882
+				$query_object->set_group_by_sql(" GROUP BY ".implode(", ", $group_by_array));
2883
+			} elseif ( ! empty ($query_params['group_by'])) {
2884 2884
 				$query_object->set_group_by_sql(
2885
-					" GROUP BY " . $this->_deduce_column_name_from_query_param( $query_params['group_by'] )
2885
+					" GROUP BY ".$this->_deduce_column_name_from_query_param($query_params['group_by'])
2886 2886
 				);
2887 2887
 			}
2888 2888
 		}
2889 2889
 		//set having
2890
-		if ( array_key_exists( 'having', $query_params ) && $query_params['having'] ) {
2891
-			$query_object->set_having_sql( $this->_construct_having_clause( $query_params['having'] ) );
2890
+		if (array_key_exists('having', $query_params) && $query_params['having']) {
2891
+			$query_object->set_having_sql($this->_construct_having_clause($query_params['having']));
2892 2892
 		}
2893 2893
 		//now, just verify they didn't pass anything wack
2894
-		foreach ( $query_params as $query_key => $query_value ) {
2895
-			if ( ! in_array( $query_key, $this->_allowed_query_params, true ) ) {
2894
+		foreach ($query_params as $query_key => $query_value) {
2895
+			if ( ! in_array($query_key, $this->_allowed_query_params, true)) {
2896 2896
 				throw new EE_Error(
2897 2897
 					sprintf(
2898 2898
 						__(
@@ -2900,16 +2900,16 @@  discard block
 block discarded – undo
2900 2900
 							'event_espresso'
2901 2901
 						),
2902 2902
 						$query_key,
2903
-						get_class( $this ),
2903
+						get_class($this),
2904 2904
 //						print_r( $this->_allowed_query_params, TRUE )
2905
-						implode( ',', $this->_allowed_query_params )
2905
+						implode(',', $this->_allowed_query_params)
2906 2906
 					)
2907 2907
 				);
2908 2908
 			}
2909 2909
 		}
2910 2910
 		$main_model_join_sql = $query_object->get_main_model_join_sql();
2911
-		if ( empty( $main_model_join_sql ) ) {
2912
-			$query_object->set_main_model_join_sql( $this->_construct_internal_join() );
2911
+		if (empty($main_model_join_sql)) {
2912
+			$query_object->set_main_model_join_sql($this->_construct_internal_join());
2913 2913
 		}
2914 2914
 		return $query_object;
2915 2915
 	}
@@ -2924,17 +2924,17 @@  discard block
 block discarded – undo
2924 2924
 	 * @return array like EEM_Base::get_all() 's $query_params[0]
2925 2925
 	 * @throws \EE_Error
2926 2926
 	 */
2927
-	public function caps_where_conditions( $context = self::caps_read ) {
2928
-		EEM_Base::verify_is_valid_cap_context( $context );
2927
+	public function caps_where_conditions($context = self::caps_read) {
2928
+		EEM_Base::verify_is_valid_cap_context($context);
2929 2929
 		$cap_where_conditions = array();
2930
-		$cap_restrictions = $this->caps_missing( $context );
2930
+		$cap_restrictions = $this->caps_missing($context);
2931 2931
 		/**
2932 2932
 		 * @var $cap_restrictions EE_Default_Where_Conditions[]
2933 2933
 		 */
2934
-		foreach( $cap_restrictions as $cap => $restriction_if_no_cap ) {
2935
-				$cap_where_conditions = array_replace_recursive( $cap_where_conditions, $restriction_if_no_cap->get_default_where_conditions() );
2934
+		foreach ($cap_restrictions as $cap => $restriction_if_no_cap) {
2935
+				$cap_where_conditions = array_replace_recursive($cap_where_conditions, $restriction_if_no_cap->get_default_where_conditions());
2936 2936
 		}
2937
-		return apply_filters( 'FHEE__EEM_Base__caps_where_conditions__return', $cap_where_conditions, $this, $context, $cap_restrictions );
2937
+		return apply_filters('FHEE__EEM_Base__caps_where_conditions__return', $cap_where_conditions, $this, $context, $cap_restrictions);
2938 2938
 	}
2939 2939
 
2940 2940
 	/**
@@ -2944,11 +2944,11 @@  discard block
 block discarded – undo
2944 2944
 	 * @return string either ASC, asc, DESC or desc
2945 2945
 	 * @throws EE_Error
2946 2946
 	 */
2947
-	private function _extract_order($should_be_order_string){
2948
-		if(in_array($should_be_order_string, $this->_allowed_order_values)){
2947
+	private function _extract_order($should_be_order_string) {
2948
+		if (in_array($should_be_order_string, $this->_allowed_order_values)) {
2949 2949
 			return $should_be_order_string;
2950
-		}else{
2951
-			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));
2950
+		} else {
2951
+			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));
2952 2952
 		}
2953 2953
 	}
2954 2954
 
@@ -2966,7 +2966,7 @@  discard block
 block discarded – undo
2966 2966
 	 * @throws EE_Error
2967 2967
 	 * @return array like $query_params[0], see EEM_Base::get_all for documentation
2968 2968
 	 */
2969
-	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()){
2969
+	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()) {
2970 2970
 		$allowed_used_default_where_conditions_values = array(
2971 2971
 				'all',
2972 2972
 				'this_model_only',
@@ -2974,17 +2974,17 @@  discard block
 block discarded – undo
2974 2974
 				'minimum',
2975 2975
 				'none'
2976 2976
 			);
2977
-		if( ! in_array($use_default_where_conditions,$allowed_used_default_where_conditions_values)){
2978
-			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)));
2977
+		if ( ! in_array($use_default_where_conditions, $allowed_used_default_where_conditions_values)) {
2978
+			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)));
2979 2979
 		}
2980 2980
 		$universal_query_params = array();
2981
-		if( $use_default_where_conditions === 'all' || $use_default_where_conditions === 'this_model_only' ){
2981
+		if ($use_default_where_conditions === 'all' || $use_default_where_conditions === 'this_model_only') {
2982 2982
 			$universal_query_params = $this->_get_default_where_conditions();
2983
-		} else if( $use_default_where_conditions === 'minimum' ) {
2983
+		} else if ($use_default_where_conditions === 'minimum') {
2984 2984
 			$universal_query_params = $this->_get_minimum_where_conditions();
2985 2985
 		}
2986
-		if(in_array($use_default_where_conditions,array('all','other_models_only'))){
2987
-			foreach($query_info_carrier->get_model_names_included() as $model_relation_path => $model_name){
2986
+		if (in_array($use_default_where_conditions, array('all', 'other_models_only'))) {
2987
+			foreach ($query_info_carrier->get_model_names_included() as $model_relation_path => $model_name) {
2988 2988
 				$related_model = $this->get_related_model_obj($model_name);
2989 2989
 				$related_model_universal_where_params = $related_model->_get_default_where_conditions($model_relation_path);
2990 2990
 				$overrides = $this->_override_defaults_or_make_null_friendly(
@@ -3017,20 +3017,20 @@  discard block
 block discarded – undo
3017 3017
 	 * @return array like EEM_Base::get_all's $query_params[0]
3018 3018
 	 * @throws \EE_Error
3019 3019
 	 */
3020
-	private function _override_defaults_or_make_null_friendly($default_where_conditions,$provided_where_conditions,$model,$model_relation_path){
3020
+	private function _override_defaults_or_make_null_friendly($default_where_conditions, $provided_where_conditions, $model, $model_relation_path) {
3021 3021
 		$null_friendly_where_conditions = array();
3022 3022
 		$none_overridden = true;
3023 3023
 		$or_condition_key_for_defaults = 'OR*'.get_class($model);
3024 3024
 
3025
-		foreach($default_where_conditions as $key => $val){
3026
-			if( isset($provided_where_conditions[$key])){
3025
+		foreach ($default_where_conditions as $key => $val) {
3026
+			if (isset($provided_where_conditions[$key])) {
3027 3027
 				$none_overridden = false;
3028
-			}else{
3028
+			} else {
3029 3029
 				$null_friendly_where_conditions[$or_condition_key_for_defaults]['AND'][$key] = $val;
3030 3030
 			}
3031 3031
 		}
3032
-		if( $none_overridden && $default_where_conditions){
3033
-			if($model->has_primary_key_field()){
3032
+		if ($none_overridden && $default_where_conditions) {
3033
+			if ($model->has_primary_key_field()) {
3034 3034
 				$null_friendly_where_conditions[$or_condition_key_for_defaults][$model_relation_path.".".$model->primary_key_name()] = array('IS NULL');
3035 3035
 			}/*else{
3036 3036
 				//@todo NO PK, use other defaults
@@ -3047,8 +3047,8 @@  discard block
 block discarded – undo
3047 3047
 	 * @param string $model_relation_path eg, path from Event to Payment is "Registration.Transaction.Payment."
3048 3048
 	 * @return array like EEM_Base::get_all's $query_params[0] (where conditions)
3049 3049
 	 */
3050
-	private function _get_default_where_conditions($model_relation_path = null){
3051
-		if ( $this->_ignore_where_strategy ){
3050
+	private function _get_default_where_conditions($model_relation_path = null) {
3051
+		if ($this->_ignore_where_strategy) {
3052 3052
 			return array();
3053 3053
 		}
3054 3054
 		return $this->_default_where_conditions_strategy->get_default_where_conditions($model_relation_path);
@@ -3062,8 +3062,8 @@  discard block
 block discarded – undo
3062 3062
 	 * @param string $model_relation_path eg, path from Event to Payment is "Registration.Transaction.Payment."
3063 3063
 	 * @return array like EEM_Base::get_all's $query_params[0] (where conditions)
3064 3064
 	 */
3065
-	protected function _get_minimum_where_conditions($model_relation_path = null){
3066
-		if ( $this->_ignore_where_strategy ){
3065
+	protected function _get_minimum_where_conditions($model_relation_path = null) {
3066
+		if ($this->_ignore_where_strategy) {
3067 3067
 			return array();
3068 3068
 		}
3069 3069
 		return $this->_minimum_where_conditions_strategy->get_default_where_conditions($model_relation_path);
@@ -3079,16 +3079,16 @@  discard block
 block discarded – undo
3079 3079
 	 * @return string
3080 3080
 	 * @throws \EE_Error
3081 3081
 	 */
3082
-	private function _construct_default_select_sql(EE_Model_Query_Info_Carrier $model_query_info){
3082
+	private function _construct_default_select_sql(EE_Model_Query_Info_Carrier $model_query_info) {
3083 3083
 		$selects = $this->_get_columns_to_select_for_this_model();
3084
-		foreach($model_query_info->get_model_names_included() as $model_relation_chain => $name_of_other_model_included){
3084
+		foreach ($model_query_info->get_model_names_included() as $model_relation_chain => $name_of_other_model_included) {
3085 3085
 			$other_model_included = $this->get_related_model_obj($name_of_other_model_included);
3086
-			$other_model_selects = $other_model_included->_get_columns_to_select_for_this_model( $model_relation_chain );
3087
-			foreach ( $other_model_selects as $key => $value ) {
3086
+			$other_model_selects = $other_model_included->_get_columns_to_select_for_this_model($model_relation_chain);
3087
+			foreach ($other_model_selects as $key => $value) {
3088 3088
 				$selects[] = $value;
3089 3089
 			}
3090 3090
 		}
3091
-		return implode(", ",$selects);
3091
+		return implode(", ", $selects);
3092 3092
 	}
3093 3093
 
3094 3094
 	/**
@@ -3097,19 +3097,19 @@  discard block
 block discarded – undo
3097 3097
 	 * @param string $model_relation_chain like 'Question.Question_Group.Event'
3098 3098
 	 * @return array numerically indexed, values are columns to select and rename, eg "Event.ID AS 'Event.ID'"
3099 3099
 	 */
3100
-	public function _get_columns_to_select_for_this_model($model_relation_chain = ''){
3100
+	public function _get_columns_to_select_for_this_model($model_relation_chain = '') {
3101 3101
 		$fields = $this->field_settings();
3102 3102
 		$selects = array();
3103 3103
 		$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());
3104
-		foreach($fields as $field_obj){
3105
-			$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()."'";
3104
+		foreach ($fields as $field_obj) {
3105
+			$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()."'";
3106 3106
 		}
3107 3107
 		//make sure we are also getting the PKs of each table
3108 3108
 		$tables = $this->get_tables();
3109
-		if(count($tables) > 1){
3110
-			foreach($tables as $table_obj){
3111
-				$qualified_pk_column = $table_alias_with_model_relation_chain_prefix . $table_obj->get_fully_qualified_pk_column();
3112
-				if( ! in_array($qualified_pk_column,$selects)){
3109
+		if (count($tables) > 1) {
3110
+			foreach ($tables as $table_obj) {
3111
+				$qualified_pk_column = $table_alias_with_model_relation_chain_prefix.$table_obj->get_fully_qualified_pk_column();
3112
+				if ( ! in_array($qualified_pk_column, $selects)) {
3113 3113
 					$selects[] = "$qualified_pk_column AS '$qualified_pk_column'";
3114 3114
 				}
3115 3115
 			}
@@ -3139,65 +3139,65 @@  discard block
 block discarded – undo
3139 3139
 		$query_param_type,
3140 3140
 		$original_query_param = null
3141 3141
 	) {
3142
-		if( $original_query_param === null ){
3142
+		if ($original_query_param === null) {
3143 3143
 			$original_query_param = $query_param;
3144 3144
 		}
3145 3145
 		$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param);
3146 3146
 		/** @var $allow_logic_query_params bool whether or not to allow logic_query_params like 'NOT','OR', or 'AND' */
3147
-		$allow_logic_query_params = in_array($query_param_type,array('where','having'));
3148
-		$allow_fields = in_array($query_param_type,array('where','having','order_by','group_by','order'));
3147
+		$allow_logic_query_params = in_array($query_param_type, array('where', 'having'));
3148
+		$allow_fields = in_array($query_param_type, array('where', 'having', 'order_by', 'group_by', 'order'));
3149 3149
 		//check to see if we have a field on this model
3150 3150
 		$this_model_fields = $this->field_settings(true);
3151
-		if(array_key_exists($query_param,$this_model_fields)){
3152
-			if($allow_fields){
3151
+		if (array_key_exists($query_param, $this_model_fields)) {
3152
+			if ($allow_fields) {
3153 3153
 				return;
3154
-			}else{
3154
+			} else {
3155 3155
 				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"),
3156
-						$query_param,get_class($this),$query_param_type,$original_query_param));
3156
+						$query_param, get_class($this), $query_param_type, $original_query_param));
3157 3157
 			}
3158 3158
 		}
3159 3159
 		//check if this is a special logic query param
3160
-		elseif(in_array($query_param, $this->_logic_query_param_keys, TRUE)){
3161
-			if($allow_logic_query_params){
3160
+		elseif (in_array($query_param, $this->_logic_query_param_keys, TRUE)) {
3161
+			if ($allow_logic_query_params) {
3162 3162
 				return;
3163
-			}else{
3163
+			} else {
3164 3164
 				throw new EE_Error(
3165 3165
 					sprintf(
3166
-						__( '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' ),
3167
-						implode( '", "', $this->_logic_query_param_keys ),
3168
-						$query_param ,
3169
-						get_class( $this ),
3166
+						__('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'),
3167
+						implode('", "', $this->_logic_query_param_keys),
3168
+						$query_param,
3169
+						get_class($this),
3170 3170
 						'<br />',
3171
-						"\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
3171
+						"\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
3172 3172
 					)
3173 3173
 				);
3174 3174
 			}
3175 3175
 		}
3176 3176
 
3177 3177
 		//check if it's a custom selection
3178
-		elseif(array_key_exists($query_param,$this->_custom_selections)){
3178
+		elseif (array_key_exists($query_param, $this->_custom_selections)) {
3179 3179
 			return;
3180 3180
 		}
3181 3181
 
3182 3182
 		//check if has a model name at the beginning
3183 3183
 		//and
3184 3184
 		//check if it's a field on a related model
3185
-		foreach($this->_model_relations as $valid_related_model_name=>$relation_obj){
3186
-			if(strpos($query_param, $valid_related_model_name.".") === 0){
3187
-				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param);
3185
+		foreach ($this->_model_relations as $valid_related_model_name=>$relation_obj) {
3186
+			if (strpos($query_param, $valid_related_model_name.".") === 0) {
3187
+				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info, $original_query_param);
3188 3188
 				$query_param = substr($query_param, strlen($valid_related_model_name."."));
3189
-				if($query_param === ''){
3189
+				if ($query_param === '') {
3190 3190
 					//nothing left to $query_param
3191 3191
 					//we should actually end in a field name, not a model like this!
3192 3192
 					throw new EE_Error(sprintf(__("Query param '%s' (of type %s on model %s) shouldn't end on a period (.) ", "event_espresso"),
3193
-					$query_param,$query_param_type,get_class($this),$valid_related_model_name));
3194
-				}else{
3193
+					$query_param, $query_param_type, get_class($this), $valid_related_model_name));
3194
+				} else {
3195 3195
 					$related_model_obj = $this->get_related_model_obj($valid_related_model_name);
3196 3196
 					$related_model_obj->_extract_related_model_info_from_query_param($query_param, $passed_in_query_info, $query_param_type, $original_query_param);
3197 3197
 					return;
3198 3198
 				}
3199
-			}elseif($query_param === $valid_related_model_name){
3200
-				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param);
3199
+			}elseif ($query_param === $valid_related_model_name) {
3200
+				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info, $original_query_param);
3201 3201
 				return;
3202 3202
 			}
3203 3203
 		}
@@ -3207,7 +3207,7 @@  discard block
 block discarded – undo
3207 3207
 		//and we previously confirmed it wasn't a logic query param or field on the current model
3208 3208
 		//it's wack, that's what it is
3209 3209
 		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"),
3210
-				$query_param,get_class($this),$query_param_type,$original_query_param));
3210
+				$query_param, get_class($this), $query_param_type, $original_query_param));
3211 3211
 
3212 3212
 	}
3213 3213
 
@@ -3226,26 +3226,26 @@  discard block
 block discarded – undo
3226 3226
 	 * @return void
3227 3227
 	 * @throws \EE_Error
3228 3228
 	 */
3229
-	private function _add_join_to_model($model_name, EE_Model_Query_Info_Carrier $passed_in_query_info,$original_query_param){
3229
+	private function _add_join_to_model($model_name, EE_Model_Query_Info_Carrier $passed_in_query_info, $original_query_param) {
3230 3230
 		$relation_obj = $this->related_settings_for($model_name);
3231 3231
 
3232 3232
 		$model_relation_chain = EE_Model_Parser::extract_model_relation_chain($model_name, $original_query_param);
3233 3233
 		//check if the relation is HABTM, because then we're essentially doing two joins
3234 3234
 		//If so, join first to the JOIN table, and add its data types, and then continue as normal
3235
-		if($relation_obj instanceof EE_HABTM_Relation){
3235
+		if ($relation_obj instanceof EE_HABTM_Relation) {
3236 3236
 			$join_model_obj = $relation_obj->get_join_model();
3237 3237
 			//replace the model specified with the join model for this relation chain, whi
3238 3238
 			$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);
3239 3239
 			$new_query_info = new EE_Model_Query_Info_Carrier(
3240 3240
 					array($relation_chain_to_join_model => $join_model_obj->get_this_model_name()),
3241 3241
 					$relation_obj->get_join_to_intermediate_model_statement($relation_chain_to_join_model));
3242
-			$passed_in_query_info->merge( $new_query_info  );
3242
+			$passed_in_query_info->merge($new_query_info);
3243 3243
 		}
3244 3244
 		//now just join to the other table pointed to by the relation object, and add its data types
3245 3245
 		$new_query_info = new EE_Model_Query_Info_Carrier(
3246 3246
 				array($model_relation_chain=>$model_name),
3247 3247
 				$relation_obj->get_join_statement($model_relation_chain));
3248
-		$passed_in_query_info->merge( $new_query_info  );
3248
+		$passed_in_query_info->merge($new_query_info);
3249 3249
 	}
3250 3250
 
3251 3251
 
@@ -3257,11 +3257,11 @@  discard block
 block discarded – undo
3257 3257
 	 * @return string of SQL
3258 3258
 	 * @throws \EE_Error
3259 3259
 	 */
3260
-	private function _construct_where_clause($where_params){
3260
+	private function _construct_where_clause($where_params) {
3261 3261
 		$SQL = $this->_construct_condition_clause_recursive($where_params, ' AND ');
3262
-		if($SQL){
3263
-			return " WHERE ". $SQL;
3264
-		}else{
3262
+		if ($SQL) {
3263
+			return " WHERE ".$SQL;
3264
+		} else {
3265 3265
 			return '';
3266 3266
 		}
3267 3267
 	}
@@ -3276,11 +3276,11 @@  discard block
 block discarded – undo
3276 3276
 	 * @return string
3277 3277
 	 * @throws \EE_Error
3278 3278
 	 */
3279
-	private function _construct_having_clause($having_params){
3279
+	private function _construct_having_clause($having_params) {
3280 3280
 		$SQL = $this->_construct_condition_clause_recursive($having_params, ' AND ');
3281
-		if($SQL){
3282
-			return " HAVING ". $SQL;
3283
-		}else{
3281
+		if ($SQL) {
3282
+			return " HAVING ".$SQL;
3283
+		} else {
3284 3284
 			return '';
3285 3285
 		}
3286 3286
 
@@ -3294,16 +3294,16 @@  discard block
 block discarded – undo
3294 3294
 	 * @return EE_Model_Field_Base
3295 3295
 	 * @throws EE_Error
3296 3296
 	 */
3297
-	protected function _get_field_on_model($field_name,$model_name){
3297
+	protected function _get_field_on_model($field_name, $model_name) {
3298 3298
 		$model_class = 'EEM_'.$model_name;
3299 3299
 		$model_filepath = $model_class.".model.php";
3300
-		if ( is_readable($model_filepath)){
3300
+		if (is_readable($model_filepath)) {
3301 3301
 			require_once($model_filepath);
3302
-			$model_instance=call_user_func($model_name."::instance");
3302
+			$model_instance = call_user_func($model_name."::instance");
3303 3303
 			/* @var $model_instance EEM_Base */
3304 3304
 			return $model_instance->field_settings_for($field_name);
3305
-		}else{
3306
-			throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s','event_espresso'),$model_name,$model_class,$model_filepath));
3305
+		} else {
3306
+			throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s', 'event_espresso'), $model_name, $model_class, $model_filepath));
3307 3307
 		}
3308 3308
 	}
3309 3309
 
@@ -3316,41 +3316,41 @@  discard block
 block discarded – undo
3316 3316
 	 * @throws EE_Error
3317 3317
 	 * @return string of SQL
3318 3318
 	 */
3319
-	private function _construct_condition_clause_recursive($where_params, $glue = ' AND'){
3320
-		$where_clauses=array();
3321
-		foreach($where_params as $query_param => $op_and_value_or_sub_condition){
3322
-			$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param);//str_replace("*",'',$query_param);
3323
-			if(in_array($query_param,$this->_logic_query_param_keys)){
3324
-				switch($query_param){
3319
+	private function _construct_condition_clause_recursive($where_params, $glue = ' AND') {
3320
+		$where_clauses = array();
3321
+		foreach ($where_params as $query_param => $op_and_value_or_sub_condition) {
3322
+			$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param); //str_replace("*",'',$query_param);
3323
+			if (in_array($query_param, $this->_logic_query_param_keys)) {
3324
+				switch ($query_param) {
3325 3325
 					case 'not':
3326 3326
 					case 'NOT':
3327
-						$where_clauses[] = "! (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, $glue).")";
3327
+						$where_clauses[] = "! (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, $glue).")";
3328 3328
 						break;
3329 3329
 					case 'and':
3330 3330
 					case 'AND':
3331
-						$where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' AND ') .")";
3331
+						$where_clauses[] = " (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' AND ').")";
3332 3332
 						break;
3333 3333
 					case 'or':
3334 3334
 					case 'OR':
3335
-						$where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ') .")";
3335
+						$where_clauses[] = " (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ').")";
3336 3336
 						break;
3337 3337
 				}
3338
-			}else{
3338
+			} else {
3339 3339
 				$field_obj = $this->_deduce_field_from_query_param($query_param);
3340 3340
 
3341 3341
 				//if it's not a normal field, maybe it's a custom selection?
3342
-				if( ! $field_obj){
3343
-					if(isset( $this->_custom_selections[$query_param][1])){
3342
+				if ( ! $field_obj) {
3343
+					if (isset($this->_custom_selections[$query_param][1])) {
3344 3344
 						$field_obj = $this->_custom_selections[$query_param][1];
3345
-					}else{
3346
-						throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"),$query_param));
3345
+					} else {
3346
+						throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"), $query_param));
3347 3347
 					}
3348 3348
 				}
3349 3349
 				$op_and_value_sql = $this->_construct_op_and_value($op_and_value_or_sub_condition, $field_obj);
3350
-				$where_clauses[]=$this->_deduce_column_name_from_query_param($query_param).SP.$op_and_value_sql;
3350
+				$where_clauses[] = $this->_deduce_column_name_from_query_param($query_param).SP.$op_and_value_sql;
3351 3351
 			}
3352 3352
 		}
3353
-		return $where_clauses ? implode( $glue, $where_clauses ) : '';
3353
+		return $where_clauses ? implode($glue, $where_clauses) : '';
3354 3354
 	}
3355 3355
 
3356 3356
 
@@ -3361,18 +3361,18 @@  discard block
 block discarded – undo
3361 3361
 	 * @throws EE_Error
3362 3362
 	 * @return string table alias and column name for SQL, eg "Transaction.TXN_ID"
3363 3363
 	 */
3364
-	private function _deduce_column_name_from_query_param($query_param){
3364
+	private function _deduce_column_name_from_query_param($query_param) {
3365 3365
 		$field = $this->_deduce_field_from_query_param($query_param);
3366 3366
 
3367
-		if( $field ){
3368
-			$table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param( $field->get_model_name(), $query_param );
3369
-			return $table_alias_prefix . $field->get_qualified_column();
3370
-		}elseif(array_key_exists($query_param,$this->_custom_selections)){
3367
+		if ($field) {
3368
+			$table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param($field->get_model_name(), $query_param);
3369
+			return $table_alias_prefix.$field->get_qualified_column();
3370
+		}elseif (array_key_exists($query_param, $this->_custom_selections)) {
3371 3371
 			//maybe it's custom selection item?
3372 3372
 			//if so, just use it as the "column name"
3373 3373
 			return $query_param;
3374
-		}else{
3375
-			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)));
3374
+		} else {
3375
+			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)));
3376 3376
 		}
3377 3377
 	}
3378 3378
 
@@ -3384,11 +3384,11 @@  discard block
 block discarded – undo
3384 3384
 	 * @param string $condition_query_param_key
3385 3385
 	 * @return string
3386 3386
 	 */
3387
-	private function _remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key){
3387
+	private function _remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key) {
3388 3388
 		$pos_of_star = strpos($condition_query_param_key, '*');
3389
-		if($pos_of_star === FALSE){
3389
+		if ($pos_of_star === FALSE) {
3390 3390
 			return $condition_query_param_key;
3391
-		}else{
3391
+		} else {
3392 3392
 			$condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star);
3393 3393
 			return $condition_query_param_sans_star;
3394 3394
 		}
@@ -3403,12 +3403,12 @@  discard block
 block discarded – undo
3403 3403
 	 * @throws EE_Error
3404 3404
 	 * @return string
3405 3405
 	 */
3406
-	private function _construct_op_and_value($op_and_value, $field_obj){
3407
-		if ( is_array( $op_and_value ) ) {
3408
-			$operator = isset( $op_and_value[0] ) ? $this->_prepare_operator_for_sql( $op_and_value[0] ) : null;
3409
-			if ( ! $operator ) {
3406
+	private function _construct_op_and_value($op_and_value, $field_obj) {
3407
+		if (is_array($op_and_value)) {
3408
+			$operator = isset($op_and_value[0]) ? $this->_prepare_operator_for_sql($op_and_value[0]) : null;
3409
+			if ( ! $operator) {
3410 3410
 				$php_array_like_string = array();
3411
-				foreach ( $op_and_value as $key => $value ) {
3411
+				foreach ($op_and_value as $key => $value) {
3412 3412
 					$php_array_like_string[] = "$key=>$value";
3413 3413
 				}
3414 3414
 				throw new EE_Error(
@@ -3417,27 +3417,27 @@  discard block
 block discarded – undo
3417 3417
 							"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))",
3418 3418
 							"event_espresso"
3419 3419
 						),
3420
-						implode( ",", $php_array_like_string )
3420
+						implode(",", $php_array_like_string)
3421 3421
 					)
3422 3422
 				);
3423 3423
 			}
3424
-			$value = isset( $op_and_value[1] ) ? $op_and_value[1] : null;
3424
+			$value = isset($op_and_value[1]) ? $op_and_value[1] : null;
3425 3425
 		} else {
3426 3426
 			$operator = '=';
3427 3427
 			$value = $op_and_value;
3428 3428
 		}
3429 3429
 		//check to see if the value is actually another field
3430
-		if ( is_array( $op_and_value ) && isset( $op_and_value[2] ) && $op_and_value[2] == true ) {
3431
-			return $operator . SP . $this->_deduce_column_name_from_query_param( $value );
3432
-		} elseif ( in_array( $operator, $this->_in_style_operators ) && is_array( $value ) ) {
3430
+		if (is_array($op_and_value) && isset($op_and_value[2]) && $op_and_value[2] == true) {
3431
+			return $operator.SP.$this->_deduce_column_name_from_query_param($value);
3432
+		} elseif (in_array($operator, $this->_in_style_operators) && is_array($value)) {
3433 3433
 			//in this case, the value should be an array, or at least a comma-separated list
3434 3434
 			//it will need to handle a little differently
3435
-			$cleaned_value = $this->_construct_in_value( $value, $field_obj );
3435
+			$cleaned_value = $this->_construct_in_value($value, $field_obj);
3436 3436
 			//note: $cleaned_value has already been run through $wpdb->prepare()
3437
-			return $operator . SP . $cleaned_value;
3438
-		} elseif ( in_array( $operator, $this->_between_style_operators ) && is_array( $value ) ) {
3437
+			return $operator.SP.$cleaned_value;
3438
+		} elseif (in_array($operator, $this->_between_style_operators) && is_array($value)) {
3439 3439
 			//the value should be an array with count of two.
3440
-			if ( count( $value ) !== 2 ) {
3440
+			if (count($value) !== 2) {
3441 3441
 				throw new EE_Error(
3442 3442
 					sprintf(
3443 3443
 						__(
@@ -3448,10 +3448,10 @@  discard block
 block discarded – undo
3448 3448
 					)
3449 3449
 				);
3450 3450
 			}
3451
-			$cleaned_value = $this->_construct_between_value( $value, $field_obj );
3452
-			return $operator . SP . $cleaned_value;
3453
-		} elseif ( in_array( $operator, $this->_null_style_operators ) ) {
3454
-			if ( $value !== null ) {
3451
+			$cleaned_value = $this->_construct_between_value($value, $field_obj);
3452
+			return $operator.SP.$cleaned_value;
3453
+		} elseif (in_array($operator, $this->_null_style_operators)) {
3454
+			if ($value !== null) {
3455 3455
 				throw new EE_Error(
3456 3456
 					sprintf(
3457 3457
 						__(
@@ -3464,13 +3464,13 @@  discard block
 block discarded – undo
3464 3464
 				);
3465 3465
 			}
3466 3466
 			return $operator;
3467
-		} elseif ( $operator === 'LIKE' && ! is_array( $value ) ) {
3467
+		} elseif ($operator === 'LIKE' && ! is_array($value)) {
3468 3468
 			//if the operator is 'LIKE', we want to allow percent signs (%) and not
3469 3469
 			//remove other junk. So just treat it as a string.
3470
-			return $operator . SP . $this->_wpdb_prepare_using_field( $value, '%s' );
3471
-		} elseif ( ! in_array( $operator, $this->_in_style_operators ) && ! is_array( $value ) ) {
3472
-			return $operator . SP . $this->_wpdb_prepare_using_field( $value, $field_obj );
3473
-		} elseif ( in_array( $operator, $this->_in_style_operators ) && ! is_array( $value ) ) {
3470
+			return $operator.SP.$this->_wpdb_prepare_using_field($value, '%s');
3471
+		} elseif ( ! in_array($operator, $this->_in_style_operators) && ! is_array($value)) {
3472
+			return $operator.SP.$this->_wpdb_prepare_using_field($value, $field_obj);
3473
+		} elseif (in_array($operator, $this->_in_style_operators) && ! is_array($value)) {
3474 3474
 			throw new EE_Error(
3475 3475
 				sprintf(
3476 3476
 					__(
@@ -3481,7 +3481,7 @@  discard block
 block discarded – undo
3481 3481
 					$operator
3482 3482
 				)
3483 3483
 			);
3484
-		} elseif ( ! in_array( $operator, $this->_in_style_operators ) && is_array( $value ) ) {
3484
+		} elseif ( ! in_array($operator, $this->_in_style_operators) && is_array($value)) {
3485 3485
 			throw new EE_Error(
3486 3486
 				sprintf(
3487 3487
 					__(
@@ -3499,7 +3499,7 @@  discard block
 block discarded – undo
3499 3499
 						"It appears you've provided some totally invalid query parameters. Operator and value were:'%s', which isn't right at all",
3500 3500
 						"event_espresso"
3501 3501
 					),
3502
-					http_build_query( $op_and_value )
3502
+					http_build_query($op_and_value)
3503 3503
 				)
3504 3504
 			);
3505 3505
 		}
@@ -3515,12 +3515,12 @@  discard block
 block discarded – undo
3515 3515
 	 * @return string
3516 3516
 	 * @throws \EE_Error
3517 3517
 	 */
3518
-	public function _construct_between_value( $values, $field_obj ) {
3518
+	public function _construct_between_value($values, $field_obj) {
3519 3519
 		$cleaned_values = array();
3520
-		foreach ( $values as $value ) {
3521
-			$cleaned_values[] = $this->_wpdb_prepare_using_field($value,$field_obj);
3520
+		foreach ($values as $value) {
3521
+			$cleaned_values[] = $this->_wpdb_prepare_using_field($value, $field_obj);
3522 3522
 		}
3523
-		return  $cleaned_values[0] . " AND " . $cleaned_values[1];
3523
+		return  $cleaned_values[0]." AND ".$cleaned_values[1];
3524 3524
 	}
3525 3525
 
3526 3526
 
@@ -3537,26 +3537,26 @@  discard block
 block discarded – undo
3537 3537
 	 * @return string of SQL to follow an 'IN' or 'NOT IN' operator
3538 3538
 	 * @throws \EE_Error
3539 3539
 	 */
3540
-	public function _construct_in_value($values,  $field_obj){
3540
+	public function _construct_in_value($values, $field_obj) {
3541 3541
 		//check if the value is a CSV list
3542
-		if(is_string($values)){
3542
+		if (is_string($values)) {
3543 3543
 			//in which case, turn it into an array
3544
-			$values = explode(",",$values);
3544
+			$values = explode(",", $values);
3545 3545
 		}
3546 3546
 		$cleaned_values = array();
3547
-		foreach($values as $value){
3548
-			$cleaned_values[] = $this->_wpdb_prepare_using_field($value,$field_obj);
3547
+		foreach ($values as $value) {
3548
+			$cleaned_values[] = $this->_wpdb_prepare_using_field($value, $field_obj);
3549 3549
 		}
3550 3550
 		//we would just LOVE to leave $cleaned_values as an empty array, and return the value as "()",
3551 3551
 		//but unfortunately that's invalid SQL. So instead we return a string which we KNOW will evaluate to be the empty set
3552 3552
 		//which is effectively equivalent to returning "()". We don't return "(0)" because that only works for auto-incrementing columns
3553
-		if(empty($cleaned_values)){
3553
+		if (empty($cleaned_values)) {
3554 3554
 			$all_fields = $this->field_settings();
3555 3555
 			$a_field = array_shift($all_fields);
3556 3556
 			$main_table = $this->_get_main_table();
3557 3557
 			$cleaned_values[] = "SELECT ".$a_field->get_table_column()." FROM ".$main_table->get_table_name()." WHERE FALSE";
3558 3558
 		}
3559
-		return "(".implode(",",$cleaned_values).")";
3559
+		return "(".implode(",", $cleaned_values).")";
3560 3560
 	}
3561 3561
 
3562 3562
 
@@ -3568,16 +3568,16 @@  discard block
 block discarded – undo
3568 3568
 	 * @throws EE_Error
3569 3569
 	 * @return false|null|string
3570 3570
 	 */
3571
-	private function _wpdb_prepare_using_field($value,$field_obj){
3571
+	private function _wpdb_prepare_using_field($value, $field_obj) {
3572 3572
 		/** @type WPDB $wpdb */
3573 3573
 		global $wpdb;
3574
-		if($field_obj instanceof EE_Model_Field_Base){
3575
-			return $wpdb->prepare($field_obj->get_wpdb_data_type(),$this->_prepare_value_for_use_in_db($value, $field_obj));
3576
-		}else{//$field_obj should really just be a data type
3577
-			if( ! in_array($field_obj,$this->_valid_wpdb_data_types)){
3578
-				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)));
3574
+		if ($field_obj instanceof EE_Model_Field_Base) {
3575
+			return $wpdb->prepare($field_obj->get_wpdb_data_type(), $this->_prepare_value_for_use_in_db($value, $field_obj));
3576
+		} else {//$field_obj should really just be a data type
3577
+			if ( ! in_array($field_obj, $this->_valid_wpdb_data_types)) {
3578
+				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)));
3579 3579
 			}
3580
-			return $wpdb->prepare($field_obj,$value);
3580
+			return $wpdb->prepare($field_obj, $value);
3581 3581
 		}
3582 3582
 	}
3583 3583
 
@@ -3589,27 +3589,27 @@  discard block
 block discarded – undo
3589 3589
 	 * @throws EE_Error
3590 3590
 	 * @return EE_Model_Field_Base
3591 3591
 	 */
3592
-	protected function _deduce_field_from_query_param($query_param_name){
3592
+	protected function _deduce_field_from_query_param($query_param_name) {
3593 3593
 		//ok, now proceed with deducing which part is the model's name, and which is the field's name
3594 3594
 		//which will help us find the database table and column
3595 3595
 
3596
-		$query_param_parts = explode(".",$query_param_name);
3597
-		if(empty($query_param_parts)){
3598
-			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));
3596
+		$query_param_parts = explode(".", $query_param_name);
3597
+		if (empty($query_param_parts)) {
3598
+			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));
3599 3599
 		}
3600 3600
 		$number_of_parts = count($query_param_parts);
3601
-		$last_query_param_part = $query_param_parts[ count($query_param_parts) - 1 ];
3602
-		if($number_of_parts === 1){
3601
+		$last_query_param_part = $query_param_parts[count($query_param_parts) - 1];
3602
+		if ($number_of_parts === 1) {
3603 3603
 			$field_name = $last_query_param_part;
3604 3604
 			$model_obj = $this;
3605
-		}else{// $number_of_parts >= 2
3605
+		} else {// $number_of_parts >= 2
3606 3606
 			//the last part is the column name, and there are only 2parts. therefore...
3607 3607
 			$field_name = $last_query_param_part;
3608
-			$model_obj = $this->get_related_model_obj( $query_param_parts[ $number_of_parts - 2 ]);
3608
+			$model_obj = $this->get_related_model_obj($query_param_parts[$number_of_parts - 2]);
3609 3609
 		}
3610
-		try{
3610
+		try {
3611 3611
 			return $model_obj->field_settings_for($field_name);
3612
-		}catch(EE_Error $e){
3612
+		} catch (EE_Error $e) {
3613 3613
 			return null;
3614 3614
 		}
3615 3615
 	}
@@ -3623,13 +3623,13 @@  discard block
 block discarded – undo
3623 3623
 	 * @throws EE_Error
3624 3624
 	 * @return string
3625 3625
 	 */
3626
-	public function _get_qualified_column_for_field($field_name){
3626
+	public function _get_qualified_column_for_field($field_name) {
3627 3627
 		$all_fields = $this->field_settings();
3628 3628
 		$field = isset($all_fields[$field_name]) ? $all_fields[$field_name] : FALSE;
3629
-		if($field){
3629
+		if ($field) {
3630 3630
 			return $field->get_qualified_column();
3631
-		}else{
3632
-			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)));
3631
+		} else {
3632
+			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)));
3633 3633
 		}
3634 3634
 	}
3635 3635
 
@@ -3643,17 +3643,17 @@  discard block
 block discarded – undo
3643 3643
 	 * @param  mixed|string $limit The limit for this select
3644 3644
 	 * @return string                The final select join element for the query.
3645 3645
 	 */
3646
-	public function _construct_limit_join_select( $table_alias, $limit ) {
3646
+	public function _construct_limit_join_select($table_alias, $limit) {
3647 3647
 		$SQL = '';
3648
-		foreach ( $this->_tables as $table_obj ) {
3649
-			if ( $table_obj instanceof EE_Primary_Table ) {
3648
+		foreach ($this->_tables as $table_obj) {
3649
+			if ($table_obj instanceof EE_Primary_Table) {
3650 3650
 				$SQL .= $table_alias === $table_obj->get_table_alias()
3651
-					? $table_obj->get_select_join_limit( $limit )
3652
-					: SP . $table_obj->get_table_name() . " AS " . $table_obj->get_table_alias() . SP;
3653
-			} elseif ( $table_obj instanceof EE_Secondary_Table ) {
3651
+					? $table_obj->get_select_join_limit($limit)
3652
+					: SP.$table_obj->get_table_name()." AS ".$table_obj->get_table_alias().SP;
3653
+			} elseif ($table_obj instanceof EE_Secondary_Table) {
3654 3654
 				$SQL .= $table_alias === $table_obj->get_table_alias()
3655
-					? $table_obj->get_select_join_limit_join( $limit )
3656
-					: SP . $table_obj->get_join_sql( $table_alias ) . SP;
3655
+					? $table_obj->get_select_join_limit_join($limit)
3656
+					: SP.$table_obj->get_join_sql($table_alias).SP;
3657 3657
 			}
3658 3658
 		}
3659 3659
 		return $SQL;
@@ -3668,7 +3668,7 @@  discard block
 block discarded – undo
3668 3668
 	 * @return string SQL
3669 3669
 	 * @throws \EE_Error
3670 3670
 	 */
3671
-	public function _construct_internal_join(){
3671
+	public function _construct_internal_join() {
3672 3672
 		$SQL = $this->_get_main_table()->get_table_sql();
3673 3673
 		$SQL .= $this->_construct_internal_join_to_table_with_alias($this->_get_main_table()->get_table_alias());
3674 3674
 		return $SQL;
@@ -3689,17 +3689,17 @@  discard block
 block discarded – undo
3689 3689
 	 * @param string $alias_prefixed table alias to join to (this table should already be in the FROM SQL clause)
3690 3690
 	 * @return string
3691 3691
 	 */
3692
-	public function _construct_internal_join_to_table_with_alias($alias_prefixed){
3692
+	public function _construct_internal_join_to_table_with_alias($alias_prefixed) {
3693 3693
 		$SQL = '';
3694 3694
 		$alias_sans_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($alias_prefixed);
3695
-		foreach($this->_tables as $table_obj){
3696
-			if($table_obj instanceof EE_Secondary_Table){//table is secondary table
3697
-				if($alias_sans_prefix === $table_obj->get_table_alias()){
3695
+		foreach ($this->_tables as $table_obj) {
3696
+			if ($table_obj instanceof EE_Secondary_Table) {//table is secondary table
3697
+				if ($alias_sans_prefix === $table_obj->get_table_alias()) {
3698 3698
 					//so we're joining to this table, meaning the table is already in
3699 3699
 					//the FROM statement, BUT the primary table isn't. So we want
3700 3700
 					//to add the inverse join sql
3701 3701
 					$SQL .= $table_obj->get_inverse_join_sql($alias_prefixed);
3702
-				}else{
3702
+				} else {
3703 3703
 					//just add a regular JOIN to this table from the primary table
3704 3704
 					$SQL .= $table_obj->get_join_sql($alias_prefixed);
3705 3705
 				}
@@ -3713,9 +3713,9 @@  discard block
 block discarded – undo
3713 3713
 	 * 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)
3714 3714
 	 * @return array
3715 3715
 	 */
3716
-	public function _get_data_types(){
3716
+	public function _get_data_types() {
3717 3717
 		$data_types = array();
3718
-		foreach( $this->field_settings() as $field_obj){
3718
+		foreach ($this->field_settings() as $field_obj) {
3719 3719
 			//$data_types[$field_obj->get_table_column()] = $field_obj->get_wpdb_data_type();
3720 3720
 			/** @var $field_obj EE_Model_Field_Base */
3721 3721
 			$data_types[$field_obj->get_qualified_column()] = $field_obj->get_wpdb_data_type();
@@ -3731,10 +3731,10 @@  discard block
 block discarded – undo
3731 3731
 	 * @throws EE_Error
3732 3732
 	 * @return EEM_Base
3733 3733
 	 */
3734
-	public function get_related_model_obj($model_name){
3734
+	public function get_related_model_obj($model_name) {
3735 3735
 		$model_classname = "EEM_".$model_name;
3736
-		if(!class_exists($model_classname)){
3737
-			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));
3736
+		if ( ! class_exists($model_classname)) {
3737
+			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));
3738 3738
 		}
3739 3739
 		return call_user_func($model_classname."::instance");
3740 3740
 	}
@@ -3744,7 +3744,7 @@  discard block
 block discarded – undo
3744 3744
 	 * Returns the array of EE_ModelRelations for this model.
3745 3745
 	 * @return EE_Model_Relation_Base[]
3746 3746
 	 */
3747
-	public function relation_settings(){
3747
+	public function relation_settings() {
3748 3748
 		return $this->_model_relations;
3749 3749
 	}
3750 3750
 
@@ -3754,10 +3754,10 @@  discard block
 block discarded – undo
3754 3754
 	 * (Eg, without an event, datetimes have little purpose.)
3755 3755
 	 * @return EE_Belongs_To_Relation[]
3756 3756
 	 */
3757
-	public function belongs_to_relations(){
3757
+	public function belongs_to_relations() {
3758 3758
 		$belongs_to_relations = array();
3759
-		foreach($this->relation_settings() as $model_name => $relation_obj){
3760
-			if($relation_obj instanceof EE_Belongs_To_Relation){
3759
+		foreach ($this->relation_settings() as $model_name => $relation_obj) {
3760
+			if ($relation_obj instanceof EE_Belongs_To_Relation) {
3761 3761
 				$belongs_to_relations[$model_name] = $relation_obj;
3762 3762
 			}
3763 3763
 		}
@@ -3772,15 +3772,15 @@  discard block
 block discarded – undo
3772 3772
 	 * @throws EE_Error
3773 3773
 	 * @return EE_Model_Relation_Base
3774 3774
 	 */
3775
-	public function related_settings_for($relation_name){
3776
-		$relatedModels=$this->relation_settings();
3777
-		if(!array_key_exists($relation_name,$relatedModels)){
3775
+	public function related_settings_for($relation_name) {
3776
+		$relatedModels = $this->relation_settings();
3777
+		if ( ! array_key_exists($relation_name, $relatedModels)) {
3778 3778
 			throw new EE_Error(
3779 3779
 				sprintf(
3780
-					__('Cannot get %s related to %s. There is no model relation of that type. There is, however, %s...','event_espresso'),
3780
+					__('Cannot get %s related to %s. There is no model relation of that type. There is, however, %s...', 'event_espresso'),
3781 3781
 					$relation_name,
3782 3782
 					$this->_get_class_name(),
3783
-					implode( ', ', array_keys( $relatedModels ))
3783
+					implode(', ', array_keys($relatedModels))
3784 3784
 				)
3785 3785
 			);
3786 3786
 		}
@@ -3795,10 +3795,10 @@  discard block
 block discarded – undo
3795 3795
 	 * @throws EE_Error
3796 3796
 	 * @return EE_Model_Field_Base
3797 3797
 	 */
3798
-	public function field_settings_for($fieldName){
3799
-		$fieldSettings=$this->field_settings(true);
3800
-		if( ! array_key_exists($fieldName,$fieldSettings)){
3801
-			throw new EE_Error(sprintf(__("There is no field/column '%s' on '%s'",'event_espresso'),$fieldName,get_class($this)));
3798
+	public function field_settings_for($fieldName) {
3799
+		$fieldSettings = $this->field_settings(true);
3800
+		if ( ! array_key_exists($fieldName, $fieldSettings)) {
3801
+			throw new EE_Error(sprintf(__("There is no field/column '%s' on '%s'", 'event_espresso'), $fieldName, get_class($this)));
3802 3802
 		}
3803 3803
 		return $fieldSettings[$fieldName];
3804 3804
 	}
@@ -3808,11 +3808,11 @@  discard block
 block discarded – undo
3808 3808
 	 * @param string $fieldName a key in the model's _field_settings array
3809 3809
 	 * @return boolean
3810 3810
 	 */
3811
-	public function has_field($fieldName){
3811
+	public function has_field($fieldName) {
3812 3812
 		$fieldSettings = $this->field_settings(true);
3813
-		if( isset($fieldSettings[$fieldName])){
3813
+		if (isset($fieldSettings[$fieldName])) {
3814 3814
 			return true;
3815
-		}else{
3815
+		} else {
3816 3816
 			return false;
3817 3817
 		}
3818 3818
 	}
@@ -3822,11 +3822,11 @@  discard block
 block discarded – undo
3822 3822
 	 * @param string $relation_name possibly one of the keys in the relation_settings array
3823 3823
 	 * @return boolean
3824 3824
 	 */
3825
-	public function has_relation($relation_name){
3825
+	public function has_relation($relation_name) {
3826 3826
 		$relations = $this->relation_settings();
3827
-		if(isset($relations[$relation_name])){
3827
+		if (isset($relations[$relation_name])) {
3828 3828
 			return true;
3829
-		}else{
3829
+		} else {
3830 3830
 			return false;
3831 3831
 		}
3832 3832
 	}
@@ -3838,7 +3838,7 @@  discard block
 block discarded – undo
3838 3838
 	 * @param $field_obj
3839 3839
 	 * @return EE_Model_Field_Base
3840 3840
 	 */
3841
-	public function is_primary_key_field( $field_obj ){
3841
+	public function is_primary_key_field($field_obj) {
3842 3842
 		return $field_obj instanceof EE_Primary_Key_Field_Base ? TRUE : FALSE;
3843 3843
 	}
3844 3844
 
@@ -3850,16 +3850,16 @@  discard block
 block discarded – undo
3850 3850
 	 * @return EE_Model_Field_Base
3851 3851
 	 * @throws EE_Error
3852 3852
 	 */
3853
-	public function get_primary_key_field(){
3854
-		if( $this->_primary_key_field === NULL ){
3855
-			foreach( $this->field_settings( TRUE ) as $field_obj ){
3856
-				if( $this->is_primary_key_field( $field_obj )){
3853
+	public function get_primary_key_field() {
3854
+		if ($this->_primary_key_field === NULL) {
3855
+			foreach ($this->field_settings(TRUE) as $field_obj) {
3856
+				if ($this->is_primary_key_field($field_obj)) {
3857 3857
 					$this->_primary_key_field = $field_obj;
3858 3858
 					break;
3859 3859
 				}
3860 3860
 			}
3861
-			if( ! $this->_primary_key_field instanceof EE_Primary_Key_Field_Base ){
3862
-				throw new EE_Error(sprintf(__("There is no Primary Key defined on model %s",'event_espresso'),get_class($this)));
3861
+			if ( ! $this->_primary_key_field instanceof EE_Primary_Key_Field_Base) {
3862
+				throw new EE_Error(sprintf(__("There is no Primary Key defined on model %s", 'event_espresso'), get_class($this)));
3863 3863
 			}
3864 3864
 		}
3865 3865
 		return $this->_primary_key_field;
@@ -3872,12 +3872,12 @@  discard block
 block discarded – undo
3872 3872
 	 * Internally does some caching.
3873 3873
 	 * @return boolean
3874 3874
 	 */
3875
-	public function has_primary_key_field(){
3876
-		if($this->_has_primary_key_field === null){
3877
-			try{
3875
+	public function has_primary_key_field() {
3876
+		if ($this->_has_primary_key_field === null) {
3877
+			try {
3878 3878
 				$this->get_primary_key_field();
3879 3879
 				$this->_has_primary_key_field = true;
3880
-			}catch(EE_Error $e){
3880
+			} catch (EE_Error $e) {
3881 3881
 				$this->_has_primary_key_field = false;
3882 3882
 			}
3883 3883
 		}
@@ -3891,9 +3891,9 @@  discard block
 block discarded – undo
3891 3891
 	 * @param string $field_class_name class name of field that you want to find. Eg, EE_Datetime_Field, EE_Foreign_Key_Field, etc
3892 3892
 	 * @return EE_Model_Field_Base or null if none is found
3893 3893
 	 */
3894
-	public function get_a_field_of_type($field_class_name){
3895
-		foreach($this->field_settings() as $field){
3896
-			if( $field instanceof $field_class_name ){
3894
+	public function get_a_field_of_type($field_class_name) {
3895
+		foreach ($this->field_settings() as $field) {
3896
+			if ($field instanceof $field_class_name) {
3897 3897
 				return $field;
3898 3898
 			}
3899 3899
 		}
@@ -3907,21 +3907,21 @@  discard block
 block discarded – undo
3907 3907
 	 * @return EE_Foreign_Key_Field_Base
3908 3908
 	 * @throws EE_Error
3909 3909
 	 */
3910
-	public function get_foreign_key_to($model_name){
3911
-		if( ! isset( $this->_cache_foreign_key_to_fields[ $model_name ] ) ){
3912
-			foreach($this->field_settings() as $field){
3913
-				if(
3910
+	public function get_foreign_key_to($model_name) {
3911
+		if ( ! isset($this->_cache_foreign_key_to_fields[$model_name])) {
3912
+			foreach ($this->field_settings() as $field) {
3913
+				if (
3914 3914
 					$field instanceof EE_Foreign_Key_Field_Base
3915
-					&& in_array($model_name,$field->get_model_names_pointed_to() )
3915
+					&& in_array($model_name, $field->get_model_names_pointed_to())
3916 3916
 				) {
3917
-					$this->_cache_foreign_key_to_fields[ $model_name ] = $field;
3917
+					$this->_cache_foreign_key_to_fields[$model_name] = $field;
3918 3918
 				}
3919 3919
 			}
3920
-			if( ! isset( $this->_cache_foreign_key_to_fields[ $model_name ] ) ){
3921
-				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)));
3920
+			if ( ! isset($this->_cache_foreign_key_to_fields[$model_name])) {
3921
+				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)));
3922 3922
 			}
3923 3923
 		}
3924
-		return $this->_cache_foreign_key_to_fields[ $model_name ];
3924
+		return $this->_cache_foreign_key_to_fields[$model_name];
3925 3925
 	}
3926 3926
 
3927 3927
 
@@ -3932,7 +3932,7 @@  discard block
 block discarded – undo
3932 3932
 	 * a table alias with a model chain prefix, like 'Venue__Event_Venue___Event_Meta'. Either one works
3933 3933
 	 * @return EE_Table_Base
3934 3934
 	 */
3935
-	public function get_table_for_alias($table_alias){
3935
+	public function get_table_for_alias($table_alias) {
3936 3936
 		$table_alias_sans_model_relation_chain_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($table_alias);
3937 3937
 		return $this->_tables[$table_alias_sans_model_relation_chain_prefix]->get_table_name();
3938 3938
 	}
@@ -3945,25 +3945,25 @@  discard block
 block discarded – undo
3945 3945
 	 * @param bool $include_db_only_fields flag indicating whether or not to include the db-only fields
3946 3946
 	 * @return EE_Model_Field_Base[] where the keys are the field's name
3947 3947
 	 */
3948
-	public function field_settings($include_db_only_fields = false){
3949
-		if( $include_db_only_fields ){
3950
-			if( $this->_cached_fields === NULL ){
3948
+	public function field_settings($include_db_only_fields = false) {
3949
+		if ($include_db_only_fields) {
3950
+			if ($this->_cached_fields === NULL) {
3951 3951
 				$this->_cached_fields = array();
3952
-				foreach($this->_fields as $fields_corresponding_to_table){
3953
-					foreach($fields_corresponding_to_table as $field_name => $field_obj){
3954
-						$this->_cached_fields[$field_name]=$field_obj;
3952
+				foreach ($this->_fields as $fields_corresponding_to_table) {
3953
+					foreach ($fields_corresponding_to_table as $field_name => $field_obj) {
3954
+						$this->_cached_fields[$field_name] = $field_obj;
3955 3955
 					}
3956 3956
 				}
3957 3957
 			}
3958 3958
 			return $this->_cached_fields;
3959
-		}else{
3960
-			if( $this->_cached_fields_non_db_only === NULL ){
3959
+		} else {
3960
+			if ($this->_cached_fields_non_db_only === NULL) {
3961 3961
 				$this->_cached_fields_non_db_only = array();
3962
-				foreach($this->_fields as $fields_corresponding_to_table){
3963
-					foreach($fields_corresponding_to_table as $field_name => $field_obj){
3962
+				foreach ($this->_fields as $fields_corresponding_to_table) {
3963
+					foreach ($fields_corresponding_to_table as $field_name => $field_obj) {
3964 3964
 						/** @var $field_obj EE_Model_Field_Base */
3965
-						if( ! $field_obj->is_db_only_field() ){
3966
-							$this->_cached_fields_non_db_only[$field_name]=$field_obj;
3965
+						if ( ! $field_obj->is_db_only_field()) {
3966
+							$this->_cached_fields_non_db_only[$field_name] = $field_obj;
3967 3967
 						}
3968 3968
 					}
3969 3969
 				}
@@ -3982,60 +3982,60 @@  discard block
 block discarded – undo
3982 3982
 	 * @return \EE_Base_Class[] array keys are primary keys (if there is a primary key on the model. if not, numerically indexed)
3983 3983
 	 * @throws \EE_Error
3984 3984
 	 */
3985
-	protected function _create_objects( $rows = array() ) {
3986
-		$array_of_objects=array();
3987
-		if(empty($rows)){
3985
+	protected function _create_objects($rows = array()) {
3986
+		$array_of_objects = array();
3987
+		if (empty($rows)) {
3988 3988
 			return array();
3989 3989
 		}
3990 3990
 		$count_if_model_has_no_primary_key = 0;
3991 3991
 		$has_primary_key = $this->has_primary_key_field();
3992 3992
 		$primary_key_field = $has_primary_key ? $this->get_primary_key_field() : null;
3993
-		foreach ( (array)$rows as $row ) {
3994
-			if(empty($row)){
3993
+		foreach ((array) $rows as $row) {
3994
+			if (empty($row)) {
3995 3995
 				//wp did its weird thing where it returns an array like array(0=>null), which is totally not helpful...
3996 3996
 				return array();
3997 3997
 			}
3998 3998
 			//check if we've already set this object in the results array,
3999 3999
 			//in which case there's no need to process it further (again)
4000
-			if( $has_primary_key ) {
4000
+			if ($has_primary_key) {
4001 4001
 				$table_pk_value = $this->_get_column_value_with_table_alias_or_not(
4002 4002
 					$row,
4003 4003
 					$primary_key_field->get_qualified_column(),
4004 4004
 					$primary_key_field->get_table_column()
4005 4005
 				);
4006
-				if( $table_pk_value && isset( $array_of_objects[ $table_pk_value ] ) ) {
4006
+				if ($table_pk_value && isset($array_of_objects[$table_pk_value])) {
4007 4007
 					continue;
4008 4008
 				}
4009 4009
 			}
4010 4010
 			$classInstance = $this->instantiate_class_from_array_or_object($row);
4011
-			if( ! $classInstance ) {
4011
+			if ( ! $classInstance) {
4012 4012
 				throw new EE_Error(
4013 4013
 					sprintf(
4014
-						__( 'Could not create instance of class %s from row %s', 'event_espresso' ),
4014
+						__('Could not create instance of class %s from row %s', 'event_espresso'),
4015 4015
 						$this->get_this_model_name(),
4016
-						http_build_query( $row )
4016
+						http_build_query($row)
4017 4017
 					)
4018 4018
 				);
4019 4019
 			}
4020 4020
 			//set the timezone on the instantiated objects
4021
-			$classInstance->set_timezone( $this->_timezone );
4021
+			$classInstance->set_timezone($this->_timezone);
4022 4022
 			//make sure if there is any timezone setting present that we set the timezone for the object
4023 4023
 			$key = $has_primary_key ? $classInstance->ID() : $count_if_model_has_no_primary_key++;
4024
-			$array_of_objects[ $key ] = $classInstance;
4024
+			$array_of_objects[$key] = $classInstance;
4025 4025
 			//also, for all the relations of type BelongsTo, see if we can cache
4026 4026
 			//those related models
4027 4027
 			//(we could do this for other relations too, but if there are conditions
4028 4028
 			//that filtered out some fo the results, then we'd be caching an incomplete set
4029 4029
 			//so it requires a little more thought than just caching them immediately...)
4030
-			foreach($this->_model_relations as $modelName => $relation_obj){
4031
-				if( $relation_obj instanceof EE_Belongs_To_Relation){
4030
+			foreach ($this->_model_relations as $modelName => $relation_obj) {
4031
+				if ($relation_obj instanceof EE_Belongs_To_Relation) {
4032 4032
 					//check if this model's INFO is present. If so, cache it on the model
4033 4033
 					$other_model = $relation_obj->get_other_model();
4034 4034
 					$other_model_obj_maybe = $other_model->instantiate_class_from_array_or_object($row);
4035 4035
 					//if we managed to make a model object from the results, cache it on the main model object
4036
-					if( $other_model_obj_maybe ){
4036
+					if ($other_model_obj_maybe) {
4037 4037
 						//set timezone on these other model objects if they are present
4038
-						$other_model_obj_maybe->set_timezone( $this->_timezone );
4038
+						$other_model_obj_maybe->set_timezone($this->_timezone);
4039 4039
 						$classInstance->cache($modelName, $other_model_obj_maybe);
4040 4040
 					}
4041 4041
 				}
@@ -4056,12 +4056,12 @@  discard block
 block discarded – undo
4056 4056
 
4057 4057
 		$this_model_fields_and_values = array();
4058 4058
 		//setup the row using default values;
4059
-		foreach ( $this->field_settings() as $field_name => $field_obj ) {
4059
+		foreach ($this->field_settings() as $field_name => $field_obj) {
4060 4060
 			$this_model_fields_and_values[$field_name] = $field_obj->get_default_value();
4061 4061
 		}
4062 4062
 
4063 4063
 		$className = $this->_get_class_name();
4064
-		$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_and_values ), FALSE, FALSE );
4064
+		$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_and_values), FALSE, FALSE);
4065 4065
 
4066 4066
 		return $classInstance;
4067 4067
 	}
@@ -4074,45 +4074,45 @@  discard block
 block discarded – undo
4074 4074
 	 * @return EE_Base_Class
4075 4075
 	 * @throws \EE_Error
4076 4076
 	 */
4077
-	public function instantiate_class_from_array_or_object($cols_n_values){
4078
-		if( ! is_array( $cols_n_values ) && is_object( $cols_n_values )) {
4079
-			$cols_n_values = get_object_vars( $cols_n_values );
4077
+	public function instantiate_class_from_array_or_object($cols_n_values) {
4078
+		if ( ! is_array($cols_n_values) && is_object($cols_n_values)) {
4079
+			$cols_n_values = get_object_vars($cols_n_values);
4080 4080
 		}
4081 4081
 		$primary_key = NULL;
4082 4082
 		//make sure the array only has keys that are fields/columns on this model
4083
-		$this_model_fields_n_values = $this->_deduce_fields_n_values_from_cols_n_values( $cols_n_values );
4084
-		if( $this->has_primary_key_field() && isset( $this_model_fields_n_values[ $this->primary_key_name() ] ) ){
4085
-			$primary_key = $this_model_fields_n_values[ $this->primary_key_name() ];
4083
+		$this_model_fields_n_values = $this->_deduce_fields_n_values_from_cols_n_values($cols_n_values);
4084
+		if ($this->has_primary_key_field() && isset($this_model_fields_n_values[$this->primary_key_name()])) {
4085
+			$primary_key = $this_model_fields_n_values[$this->primary_key_name()];
4086 4086
 		}
4087
-		$className=$this->_get_class_name();
4087
+		$className = $this->_get_class_name();
4088 4088
 
4089 4089
 		//check we actually found results that we can use to build our model object
4090 4090
 		//if not, return null
4091
-		if( $this->has_primary_key_field()){
4092
-			if(empty( $this_model_fields_n_values[$this->primary_key_name()] )){
4091
+		if ($this->has_primary_key_field()) {
4092
+			if (empty($this_model_fields_n_values[$this->primary_key_name()])) {
4093 4093
 				return NULL;
4094 4094
 			}
4095
-		}else if($this->unique_indexes()){
4095
+		} else if ($this->unique_indexes()) {
4096 4096
 			$first_column = reset($this_model_fields_n_values);
4097
-			if(empty($first_column)){
4097
+			if (empty($first_column)) {
4098 4098
 				return NULL;
4099 4099
 			}
4100 4100
 		}
4101 4101
 
4102 4102
 		// if there is no primary key or the object doesn't already exist in the entity map, then create a new instance
4103
-		if ( $primary_key){
4104
-			$classInstance = $this->get_from_entity_map( $primary_key );
4105
-			if( ! $classInstance) {
4106
-				$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE );
4103
+		if ($primary_key) {
4104
+			$classInstance = $this->get_from_entity_map($primary_key);
4105
+			if ( ! $classInstance) {
4106
+				$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_n_values, $this->_timezone), TRUE, FALSE);
4107 4107
 				// add this new object to the entity map
4108
-				$classInstance = $this->add_to_entity_map( $classInstance );
4108
+				$classInstance = $this->add_to_entity_map($classInstance);
4109 4109
 			}
4110
-		}else{
4111
-			$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE );
4110
+		} else {
4111
+			$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_n_values, $this->_timezone), TRUE, FALSE);
4112 4112
 		}
4113 4113
 
4114 4114
 			//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.
4115
-		$this->set_timezone( $classInstance->get_timezone() );
4115
+		$this->set_timezone($classInstance->get_timezone());
4116 4116
 		return $classInstance;
4117 4117
 	}
4118 4118
 	/**
@@ -4120,8 +4120,8 @@  discard block
 block discarded – undo
4120 4120
 	 * @param int|string $id the ID of the model object
4121 4121
 	 * @return EE_Base_Class
4122 4122
 	 */
4123
-	public function get_from_entity_map( $id ){
4124
-		return isset( $this->_entity_map[ $id ] ) ? $this->_entity_map[ $id ] : NULL;
4123
+	public function get_from_entity_map($id) {
4124
+		return isset($this->_entity_map[$id]) ? $this->_entity_map[$id] : NULL;
4125 4125
 	}
4126 4126
 
4127 4127
 
@@ -4140,21 +4140,21 @@  discard block
 block discarded – undo
4140 4140
 	 * @throws EE_Error
4141 4141
 	 * @return \EE_Base_Class
4142 4142
 	 */
4143
-	public function add_to_entity_map( EE_Base_Class $object) {
4143
+	public function add_to_entity_map(EE_Base_Class $object) {
4144 4144
 		$className = $this->_get_class_name();
4145
-		if( ! $object instanceof $className ){
4146
-			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 ) );
4145
+		if ( ! $object instanceof $className) {
4146
+			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));
4147 4147
 		}
4148 4148
 		/** @var $object EE_Base_Class */
4149
-		if ( ! $object->ID() ){
4150
-			throw new EE_Error(sprintf(__("You tried storing a model object with NO ID in the %s entity mapper.", "event_espresso"),get_class($this)));
4149
+		if ( ! $object->ID()) {
4150
+			throw new EE_Error(sprintf(__("You tried storing a model object with NO ID in the %s entity mapper.", "event_espresso"), get_class($this)));
4151 4151
 		}
4152 4152
 		// double check it's not already there
4153
-		$classInstance = $this->get_from_entity_map( $object->ID() );
4154
-		if ( $classInstance ) {
4153
+		$classInstance = $this->get_from_entity_map($object->ID());
4154
+		if ($classInstance) {
4155 4155
 			return $classInstance;
4156 4156
 		} else {
4157
-			$this->_entity_map[ $object->ID() ] = $object;
4157
+			$this->_entity_map[$object->ID()] = $object;
4158 4158
 			return $object;
4159 4159
 		}
4160 4160
 	}
@@ -4167,8 +4167,8 @@  discard block
 block discarded – undo
4167 4167
 	 * @param array $cols_n_values
4168 4168
 	 * @return array
4169 4169
 	 */
4170
-	public function deduce_fields_n_values_from_cols_n_values( $cols_n_values ) {
4171
-		return $this->_deduce_fields_n_values_from_cols_n_values( $cols_n_values );
4170
+	public function deduce_fields_n_values_from_cols_n_values($cols_n_values) {
4171
+		return $this->_deduce_fields_n_values_from_cols_n_values($cols_n_values);
4172 4172
 	}
4173 4173
 
4174 4174
 
@@ -4181,23 +4181,23 @@  discard block
 block discarded – undo
4181 4181
 	 * @param string $cols_n_values
4182 4182
 	 * @return array
4183 4183
 	 */
4184
-	protected function _deduce_fields_n_values_from_cols_n_values( $cols_n_values ){
4184
+	protected function _deduce_fields_n_values_from_cols_n_values($cols_n_values) {
4185 4185
 		$this_model_fields_n_values = array();
4186
-		foreach( $this->get_tables() as $table_alias => $table_obj ) {
4187
-			$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() );
4186
+		foreach ($this->get_tables() as $table_alias => $table_obj) {
4187
+			$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());
4188 4188
 			//there is a primary key on this table and its not set. Use defaults for all its columns
4189
-			if( $table_pk_value === null && $table_obj->get_pk_column() ){
4190
-				foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) {
4191
-					if( ! $field_obj->is_db_only_field() ){
4189
+			if ($table_pk_value === null && $table_obj->get_pk_column()) {
4190
+				foreach ($this->_get_fields_for_table($table_alias) as $field_name => $field_obj) {
4191
+					if ( ! $field_obj->is_db_only_field()) {
4192 4192
 						//prepare field as if its coming from db
4193
-						$prepared_value = $field_obj->prepare_for_set( $field_obj->get_default_value() );
4194
-						$this_model_fields_n_values[$field_name] = $field_obj->prepare_for_use_in_db( $prepared_value );
4193
+						$prepared_value = $field_obj->prepare_for_set($field_obj->get_default_value());
4194
+						$this_model_fields_n_values[$field_name] = $field_obj->prepare_for_use_in_db($prepared_value);
4195 4195
 					}
4196 4196
 				}
4197
-			}else{
4197
+			} else {
4198 4198
 				//the table's rows existed. Use their values
4199
-				foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) {
4200
-					if( ! $field_obj->is_db_only_field() ){
4199
+				foreach ($this->_get_fields_for_table($table_alias) as $field_name => $field_obj) {
4200
+					if ( ! $field_obj->is_db_only_field()) {
4201 4201
 						$this_model_fields_n_values[$field_name] = $this->_get_column_value_with_table_alias_or_not(
4202 4202
 							$cols_n_values, $field_obj->get_qualified_column(),
4203 4203
 							$field_obj->get_table_column()
@@ -4217,15 +4217,15 @@  discard block
 block discarded – undo
4217 4217
 	 * @param $regular_column
4218 4218
 	 * @return null
4219 4219
 	 */
4220
-	protected function _get_column_value_with_table_alias_or_not( $cols_n_values, $qualified_column, $regular_column ){
4220
+	protected function _get_column_value_with_table_alias_or_not($cols_n_values, $qualified_column, $regular_column) {
4221 4221
 		$value = null;
4222 4222
 		//ask the field what it think it's table_name.column_name should be, and call it the "qualified column"
4223 4223
 		//does the field on the model relate to this column retrieved from the db?
4224 4224
 		//or is it a db-only field? (not relating to the model)
4225
-		if( isset( $cols_n_values[ $qualified_column ] ) ){
4226
-			$value = $cols_n_values[ $qualified_column ];
4227
-		}elseif( isset( $cols_n_values[ $regular_column ] ) ){
4228
-			$value = $cols_n_values[ $regular_column ];
4225
+		if (isset($cols_n_values[$qualified_column])) {
4226
+			$value = $cols_n_values[$qualified_column];
4227
+		}elseif (isset($cols_n_values[$regular_column])) {
4228
+			$value = $cols_n_values[$regular_column];
4229 4229
 		}
4230 4230
 		return $value;
4231 4231
 	}
@@ -4241,25 +4241,25 @@  discard block
 block discarded – undo
4241 4241
 	 * @return EE_Base_Class
4242 4242
 	 * @throws \EE_Error
4243 4243
 	 */
4244
-	public function refresh_entity_map_from_db( $id ){
4245
-		$obj_in_map = $this->get_from_entity_map( $id );
4246
-		if( $obj_in_map ){
4244
+	public function refresh_entity_map_from_db($id) {
4245
+		$obj_in_map = $this->get_from_entity_map($id);
4246
+		if ($obj_in_map) {
4247 4247
 			$wpdb_results = $this->_get_all_wpdb_results(
4248
-				array( array( $this->get_primary_key_field()->get_name() => $id ), 'limit' => 1 )
4248
+				array(array($this->get_primary_key_field()->get_name() => $id), 'limit' => 1)
4249 4249
 			);
4250
-			if( $wpdb_results && is_array( $wpdb_results ) ){
4251
-				$one_row = reset( $wpdb_results );
4252
-				foreach( $this->_deduce_fields_n_values_from_cols_n_values($one_row ) as $field_name => $db_value ) {
4253
-					$obj_in_map->set_from_db( $field_name, $db_value );
4250
+			if ($wpdb_results && is_array($wpdb_results)) {
4251
+				$one_row = reset($wpdb_results);
4252
+				foreach ($this->_deduce_fields_n_values_from_cols_n_values($one_row) as $field_name => $db_value) {
4253
+					$obj_in_map->set_from_db($field_name, $db_value);
4254 4254
 				}
4255 4255
 				//clear the cache of related model objects
4256
-				foreach ( $this->relation_settings() as $relation_name => $relation_obj ){
4257
-					$obj_in_map->clear_cache($relation_name, NULL, TRUE );
4256
+				foreach ($this->relation_settings() as $relation_name => $relation_obj) {
4257
+					$obj_in_map->clear_cache($relation_name, NULL, TRUE);
4258 4258
 				}
4259 4259
 			}
4260 4260
 			return $obj_in_map;
4261
-		}else{
4262
-			return $this->get_one_by_ID( $id );
4261
+		} else {
4262
+			return $this->get_one_by_ID($id);
4263 4263
 		}
4264 4264
 	}
4265 4265
 
@@ -4277,24 +4277,24 @@  discard block
 block discarded – undo
4277 4277
 	 * @return \EE_Base_Class
4278 4278
 	 * @throws \EE_Error
4279 4279
 	 */
4280
-	public function refresh_entity_map_with( $id, $replacing_model_obj ) {
4281
-		$obj_in_map = $this->get_from_entity_map( $id );
4282
-		if( $obj_in_map ){
4283
-			if( $replacing_model_obj instanceof EE_Base_Class ){
4284
-				foreach( $replacing_model_obj->model_field_array() as $field_name => $value ) {
4285
-					$obj_in_map->set( $field_name, $value );
4280
+	public function refresh_entity_map_with($id, $replacing_model_obj) {
4281
+		$obj_in_map = $this->get_from_entity_map($id);
4282
+		if ($obj_in_map) {
4283
+			if ($replacing_model_obj instanceof EE_Base_Class) {
4284
+				foreach ($replacing_model_obj->model_field_array() as $field_name => $value) {
4285
+					$obj_in_map->set($field_name, $value);
4286 4286
 				}
4287 4287
 				//make the model object in the entity map's cache match the $replacing_model_obj
4288
-				foreach ( $this->relation_settings() as $relation_name => $relation_obj ){
4289
-					$obj_in_map->clear_cache($relation_name, NULL, TRUE );
4290
-					foreach( $replacing_model_obj->get_all_from_cache( $relation_name ) as $cache_id => $cached_obj ) {
4291
-						$obj_in_map->cache( $relation_name, $cached_obj, $cache_id );
4288
+				foreach ($this->relation_settings() as $relation_name => $relation_obj) {
4289
+					$obj_in_map->clear_cache($relation_name, NULL, TRUE);
4290
+					foreach ($replacing_model_obj->get_all_from_cache($relation_name) as $cache_id => $cached_obj) {
4291
+						$obj_in_map->cache($relation_name, $cached_obj, $cache_id);
4292 4292
 					}
4293 4293
 				}
4294 4294
 			}
4295 4295
 			return $obj_in_map;
4296
-		}else{
4297
-			$this->add_to_entity_map( $replacing_model_obj );
4296
+		} else {
4297
+			$this->add_to_entity_map($replacing_model_obj);
4298 4298
 			return $replacing_model_obj;
4299 4299
 		}
4300 4300
 	}
@@ -4307,7 +4307,7 @@  discard block
 block discarded – undo
4307 4307
 	 * require_once($this->_getClassName().".class.php");
4308 4308
 	 * @return string
4309 4309
 	 */
4310
-	private function _get_class_name(){
4310
+	private function _get_class_name() {
4311 4311
 		return "EE_".$this->get_this_model_name();
4312 4312
 	}
4313 4313
 
@@ -4320,8 +4320,8 @@  discard block
 block discarded – undo
4320 4320
 	 * @param int $quantity
4321 4321
 	 * @return string
4322 4322
 	 */
4323
-	public function item_name($quantity = 1){
4324
-		return (int)$quantity === 1 ? $this->singular_item : $this->plural_item;
4323
+	public function item_name($quantity = 1) {
4324
+		return (int) $quantity === 1 ? $this->singular_item : $this->plural_item;
4325 4325
 	}
4326 4326
 
4327 4327
 
@@ -4348,13 +4348,13 @@  discard block
 block discarded – undo
4348 4348
 	 * @throws EE_Error
4349 4349
 	 * @return mixed whatever the plugin which calls add_filter decides
4350 4350
 	 */
4351
-	public function __call($methodName,$args){
4352
-		$className=get_class($this);
4353
-		$tagName="FHEE__{$className}__{$methodName}";
4354
-		if(!has_filter($tagName)){
4351
+	public function __call($methodName, $args) {
4352
+		$className = get_class($this);
4353
+		$tagName = "FHEE__{$className}__{$methodName}";
4354
+		if ( ! has_filter($tagName)) {
4355 4355
 			throw new EE_Error(
4356 4356
 				sprintf(
4357
-					__( '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' ),
4357
+					__('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'),
4358 4358
 					$methodName,
4359 4359
 					$className,
4360 4360
 					$tagName,
@@ -4363,7 +4363,7 @@  discard block
 block discarded – undo
4363 4363
 			);
4364 4364
 		}
4365 4365
 
4366
-		return apply_filters($tagName,null,$this,$args);
4366
+		return apply_filters($tagName, null, $this, $args);
4367 4367
 	}
4368 4368
 
4369 4369
 
@@ -4381,28 +4381,28 @@  discard block
 block discarded – undo
4381 4381
 	 * @throws EE_Error
4382 4382
 	 * @return EE_Base_Class
4383 4383
 	 */
4384
-	public function ensure_is_obj( $base_class_obj_or_id, $ensure_is_in_db = FALSE ){
4384
+	public function ensure_is_obj($base_class_obj_or_id, $ensure_is_in_db = FALSE) {
4385 4385
 		$className = $this->_get_class_name();
4386
-		if ( $base_class_obj_or_id instanceof $className ) {
4386
+		if ($base_class_obj_or_id instanceof $className) {
4387 4387
 			$model_object = $base_class_obj_or_id;
4388 4388
 		} else {
4389 4389
 			$primary_key_field = $this->get_primary_key_field();
4390 4390
 			if (
4391 4391
 				$primary_key_field instanceof EE_Primary_Key_Int_Field
4392 4392
 				&& (
4393
-					is_int( $base_class_obj_or_id )
4394
-					|| is_string( $base_class_obj_or_id )
4393
+					is_int($base_class_obj_or_id)
4394
+					|| is_string($base_class_obj_or_id)
4395 4395
 				)
4396 4396
 			) {
4397 4397
 				// assume it's an ID.
4398 4398
 				// either a proper integer or a string representing an integer (eg "101" instead of 101)
4399
-				$model_object = $this->get_one_by_ID( $base_class_obj_or_id );
4399
+				$model_object = $this->get_one_by_ID($base_class_obj_or_id);
4400 4400
 			} else if (
4401 4401
 				$primary_key_field instanceof EE_Primary_Key_String_Field
4402
-			    && is_string( $base_class_obj_or_id )
4402
+			    && is_string($base_class_obj_or_id)
4403 4403
 			) {
4404 4404
 				// assume its a string representation of the object
4405
-				$model_object = $this->get_one_by_ID( $base_class_obj_or_id );
4405
+				$model_object = $this->get_one_by_ID($base_class_obj_or_id);
4406 4406
 			} else {
4407 4407
 				throw new EE_Error(
4408 4408
 					sprintf(
@@ -4412,12 +4412,12 @@  discard block
 block discarded – undo
4412 4412
 						),
4413 4413
 						$base_class_obj_or_id,
4414 4414
 						$this->_get_class_name(),
4415
-						print_r( $base_class_obj_or_id, true )
4415
+						print_r($base_class_obj_or_id, true)
4416 4416
 					)
4417 4417
 				);
4418 4418
 			}
4419 4419
 		}
4420
-		if ( $ensure_is_in_db && $model_object->ID() !== null ) {
4420
+		if ($ensure_is_in_db && $model_object->ID() !== null) {
4421 4421
 			$model_object->save();
4422 4422
 		}
4423 4423
 		return $model_object;
@@ -4433,19 +4433,19 @@  discard block
 block discarded – undo
4433 4433
 	 * @return int|string depending on the type of this model object's ID
4434 4434
 	 * @throws EE_Error
4435 4435
 	 */
4436
-	public function ensure_is_ID($base_class_obj_or_id){
4436
+	public function ensure_is_ID($base_class_obj_or_id) {
4437 4437
 		$className = $this->_get_class_name();
4438
-		if( $base_class_obj_or_id instanceof $className ){
4438
+		if ($base_class_obj_or_id instanceof $className) {
4439 4439
 			/** @var $base_class_obj_or_id EE_Base_Class */
4440 4440
 			$id = $base_class_obj_or_id->ID();
4441
-		}elseif(is_int($base_class_obj_or_id)){
4441
+		}elseif (is_int($base_class_obj_or_id)) {
4442 4442
 			//assume it's an ID
4443 4443
 			$id = $base_class_obj_or_id;
4444
-		}elseif(is_string($base_class_obj_or_id)){
4444
+		}elseif (is_string($base_class_obj_or_id)) {
4445 4445
 			//assume its a string representation of the object
4446 4446
 			$id = $base_class_obj_or_id;
4447
-		}else{
4448
-			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)));
4447
+		} else {
4448
+			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)));
4449 4449
 		}
4450 4450
 		return $id;
4451 4451
 	}
@@ -4468,14 +4468,14 @@  discard block
 block discarded – undo
4468 4468
 	 * @param int $values_already_prepared like one of the constants on EEM_Base
4469 4469
 	 * @return void
4470 4470
 	 */
4471
-	public function assume_values_already_prepared_by_model_object($values_already_prepared = self::not_prepared_by_model_object){
4471
+	public function assume_values_already_prepared_by_model_object($values_already_prepared = self::not_prepared_by_model_object) {
4472 4472
 		$this->_values_already_prepared_by_model_object = $values_already_prepared;
4473 4473
 	}
4474 4474
 	/**
4475 4475
 	 * Read comments for assume_values_already_prepared_by_model_object()
4476 4476
 	 * @return int
4477 4477
 	 */
4478
-	public function get_assumption_concerning_values_already_prepared_by_model_object(){
4478
+	public function get_assumption_concerning_values_already_prepared_by_model_object() {
4479 4479
 		return $this->_values_already_prepared_by_model_object;
4480 4480
 	}
4481 4481
 
@@ -4483,17 +4483,17 @@  discard block
 block discarded – undo
4483 4483
 	 * Gets all the indexes on this model
4484 4484
 	 * @return EE_Index[]
4485 4485
 	 */
4486
-	public function indexes(){
4486
+	public function indexes() {
4487 4487
 		return $this->_indexes;
4488 4488
 	}
4489 4489
 	/**
4490 4490
 	 * Gets all the Unique Indexes on this model
4491 4491
 	 * @return EE_Unique_Index[]
4492 4492
 	 */
4493
-	public function unique_indexes(){
4493
+	public function unique_indexes() {
4494 4494
 		$unique_indexes = array();
4495
-		foreach($this->_indexes as $name => $index){
4496
-			if($index instanceof EE_Unique_Index){
4495
+		foreach ($this->_indexes as $name => $index) {
4496
+			if ($index instanceof EE_Unique_Index) {
4497 4497
 				$unique_indexes [$name] = $index;
4498 4498
 			}
4499 4499
 		}
@@ -4511,9 +4511,9 @@  discard block
 block discarded – undo
4511 4511
 	 * @return EE_Model_Field_Base[]
4512 4512
 	 * @throws \EE_Error
4513 4513
 	 */
4514
-	public function get_combined_primary_key_fields(){
4515
-		foreach($this->indexes() as $index){
4516
-			if($index instanceof EE_Primary_Key_Index){
4514
+	public function get_combined_primary_key_fields() {
4515
+		foreach ($this->indexes() as $index) {
4516
+			if ($index instanceof EE_Primary_Key_Index) {
4517 4517
 				return $index->fields();
4518 4518
 			}
4519 4519
 		}
@@ -4530,7 +4530,7 @@  discard block
 block discarded – undo
4530 4530
 	 * @return string
4531 4531
 	 * @throws \EE_Error
4532 4532
 	 */
4533
-	public function get_index_primary_key_string($cols_n_values){
4533
+	public function get_index_primary_key_string($cols_n_values) {
4534 4534
 		$cols_n_values_for_primary_key_index = array_intersect_key($cols_n_values, $this->get_combined_primary_key_fields());
4535 4535
 		return http_build_query($cols_n_values_for_primary_key_index);
4536 4536
 	}
@@ -4545,13 +4545,13 @@  discard block
 block discarded – undo
4545 4545
 	 * @return null|array
4546 4546
 	 * @throws \EE_Error
4547 4547
 	 */
4548
-	public function parse_index_primary_key_string( $index_primary_key_string) {
4548
+	public function parse_index_primary_key_string($index_primary_key_string) {
4549 4549
 		$key_fields = $this->get_combined_primary_key_fields();
4550 4550
 		//check all of them are in the $id
4551 4551
 		$key_vals_in_combined_pk = array();
4552
-		parse_str( $index_primary_key_string, $key_vals_in_combined_pk );
4553
-		foreach( $key_fields as $key_field_name => $field_obj ) {
4554
-			if( ! isset( $key_vals_in_combined_pk[ $key_field_name ] ) ){
4552
+		parse_str($index_primary_key_string, $key_vals_in_combined_pk);
4553
+		foreach ($key_fields as $key_field_name => $field_obj) {
4554
+			if ( ! isset($key_vals_in_combined_pk[$key_field_name])) {
4555 4555
 				return NULL;
4556 4556
 			}
4557 4557
 		}
@@ -4568,10 +4568,10 @@  discard block
 block discarded – undo
4568 4568
 	 * @return boolean
4569 4569
 	 * @throws \EE_Error
4570 4570
 	 */
4571
-	public function has_all_combined_primary_key_fields( $key_vals ) {
4572
-		$keys_it_should_have = array_keys( $this->get_combined_primary_key_fields() );
4573
-		foreach( $keys_it_should_have as $key ){
4574
-			if( ! isset( $key_vals[ $key ] ) ){
4571
+	public function has_all_combined_primary_key_fields($key_vals) {
4572
+		$keys_it_should_have = array_keys($this->get_combined_primary_key_fields());
4573
+		foreach ($keys_it_should_have as $key) {
4574
+			if ( ! isset($key_vals[$key])) {
4575 4575
 				return false;
4576 4576
 			}
4577 4577
 		}
@@ -4587,23 +4587,23 @@  discard block
 block discarded – undo
4587 4587
 	 * @throws EE_Error
4588 4588
 	 * @return \EE_Base_Class[] Array keys are object IDs (if there is a primary key on the model. if not, numerically indexed)
4589 4589
 	 */
4590
-	public function get_all_copies($model_object_or_attributes_array, $query_params = array()){
4590
+	public function get_all_copies($model_object_or_attributes_array, $query_params = array()) {
4591 4591
 
4592
-		if($model_object_or_attributes_array instanceof EE_Base_Class){
4592
+		if ($model_object_or_attributes_array instanceof EE_Base_Class) {
4593 4593
 			$attributes_array = $model_object_or_attributes_array->model_field_array();
4594
-		}elseif(is_array($model_object_or_attributes_array)){
4594
+		}elseif (is_array($model_object_or_attributes_array)) {
4595 4595
 			$attributes_array = $model_object_or_attributes_array;
4596
-		}else{
4597
-			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));
4596
+		} else {
4597
+			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));
4598 4598
 		}
4599 4599
 		//even copies obviously won't have the same ID, so remove the primary key
4600 4600
 		//from the WHERE conditions for finding copies (if there is a primary key, of course)
4601
-		if($this->has_primary_key_field() && isset($attributes_array[$this->primary_key_name()])){
4601
+		if ($this->has_primary_key_field() && isset($attributes_array[$this->primary_key_name()])) {
4602 4602
 			unset($attributes_array[$this->primary_key_name()]);
4603 4603
 		}
4604
-		if(isset($query_params[0])){
4605
-			$query_params[0] = array_merge($attributes_array,$query_params);
4606
-		}else{
4604
+		if (isset($query_params[0])) {
4605
+			$query_params[0] = array_merge($attributes_array, $query_params);
4606
+		} else {
4607 4607
 			$query_params[0] = $attributes_array;
4608 4608
 		}
4609 4609
 		return $this->get_all($query_params);
@@ -4619,16 +4619,16 @@  discard block
 block discarded – undo
4619 4619
 	 * @return EE_Base_Class
4620 4620
 	 * @throws \EE_Error
4621 4621
 	 */
4622
-	public function get_one_copy($model_object_or_attributes_array,$query_params = array()){
4623
-		if( ! is_array( $query_params ) ){
4624
-			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' );
4622
+	public function get_one_copy($model_object_or_attributes_array, $query_params = array()) {
4623
+		if ( ! is_array($query_params)) {
4624
+			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');
4625 4625
 			$query_params = array();
4626 4626
 		}
4627 4627
 		$query_params['limit'] = 1;
4628
-		$copies = $this->get_all_copies($model_object_or_attributes_array,$query_params);
4629
-		if(is_array($copies)){
4628
+		$copies = $this->get_all_copies($model_object_or_attributes_array, $query_params);
4629
+		if (is_array($copies)) {
4630 4630
 			return array_shift($copies);
4631
-		}else{
4631
+		} else {
4632 4632
 			return null;
4633 4633
 		}
4634 4634
 	}
@@ -4644,10 +4644,10 @@  discard block
 block discarded – undo
4644 4644
 	 * @return int number of rows updated
4645 4645
 	 * @throws \EE_Error
4646 4646
 	 */
4647
-	public function update_by_ID($fields_n_values,$id){
4647
+	public function update_by_ID($fields_n_values, $id) {
4648 4648
 		$query_params = array(0=>array($this->get_primary_key_field()->get_name() => $id),
4649 4649
 			'default_where_conditions'=>'other_models_only',);
4650
-		return $this->update($fields_n_values,$query_params);
4650
+		return $this->update($fields_n_values, $query_params);
4651 4651
 	}
4652 4652
 
4653 4653
 
@@ -4658,12 +4658,12 @@  discard block
 block discarded – undo
4658 4658
 	 * @return string an operator which can be used in SQL
4659 4659
 	 * @throws EE_Error
4660 4660
 	 */
4661
-	private function _prepare_operator_for_sql($operator_supplied){
4661
+	private function _prepare_operator_for_sql($operator_supplied) {
4662 4662
 		$sql_operator = isset($this->_valid_operators[$operator_supplied]) ? $this->_valid_operators[$operator_supplied] : null;
4663
-		if($sql_operator){
4663
+		if ($sql_operator) {
4664 4664
 			return $sql_operator;
4665
-		}else{
4666
-			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))));
4665
+		} else {
4666
+			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))));
4667 4667
 		}
4668 4668
 	}
4669 4669
 
@@ -4677,10 +4677,10 @@  discard block
 block discarded – undo
4677 4677
 	 * @return string[]
4678 4678
 	 * @throws \EE_Error
4679 4679
 	 */
4680
-	public function get_all_names($query_params = array()){
4680
+	public function get_all_names($query_params = array()) {
4681 4681
 		$objs = $this->get_all($query_params);
4682 4682
 		$names = array();
4683
-		foreach($objs as $obj){
4683
+		foreach ($objs as $obj) {
4684 4684
 			$names[$obj->ID()] = $obj->name();
4685 4685
 		}
4686 4686
 		return $names;
@@ -4699,11 +4699,11 @@  discard block
 block discarded – undo
4699 4699
 	 * @return array
4700 4700
 	 * @throws \EE_Error
4701 4701
 	 */
4702
-	public function get_IDs( $model_objects, $filter_out_empty_ids = false) {
4703
-		if( ! $this->has_primary_key_field() ) {
4704
-			if( WP_DEBUG ) {
4702
+	public function get_IDs($model_objects, $filter_out_empty_ids = false) {
4703
+		if ( ! $this->has_primary_key_field()) {
4704
+			if (WP_DEBUG) {
4705 4705
 				EE_Error::add_error(
4706
-					__( 'Trying to get IDs from a model than has no primary key', 'event_espresso' ),
4706
+					__('Trying to get IDs from a model than has no primary key', 'event_espresso'),
4707 4707
 					__FILE__,
4708 4708
 					__FUNCTION__,
4709 4709
 					__LINE__
@@ -4711,13 +4711,13 @@  discard block
 block discarded – undo
4711 4711
 			}
4712 4712
 		}
4713 4713
 		$IDs = array();
4714
-		foreach( $model_objects as $model_object ) {
4714
+		foreach ($model_objects as $model_object) {
4715 4715
 			$id = $model_object->ID();
4716
-			if( ! $id ) {
4717
-				if( $filter_out_empty_ids ) {
4716
+			if ( ! $id) {
4717
+				if ($filter_out_empty_ids) {
4718 4718
 					continue;
4719 4719
 				}
4720
-				if ( WP_DEBUG ) {
4720
+				if (WP_DEBUG) {
4721 4721
 					EE_Error::add_error(
4722 4722
 						__(
4723 4723
 							'Called %1$s on a model object that has no ID and so probably hasn\'t been saved to the database',
@@ -4739,8 +4739,8 @@  discard block
 block discarded – undo
4739 4739
 	 * are no capabilities that relate to this model returns false
4740 4740
 	 * @return string|false
4741 4741
 	 */
4742
-	public function cap_slug(){
4743
-		return apply_filters( 'FHEE__EEM_Base__cap_slug', $this->_caps_slug, $this);
4742
+	public function cap_slug() {
4743
+		return apply_filters('FHEE__EEM_Base__cap_slug', $this->_caps_slug, $this);
4744 4744
 	}
4745 4745
 
4746 4746
 
@@ -4755,34 +4755,34 @@  discard block
 block discarded – undo
4755 4755
 	 * @return EE_Default_Where_Conditions[] indexed by associated capability
4756 4756
 	 * @throws \EE_Error
4757 4757
 	 */
4758
-	public function cap_restrictions( $context = EEM_Base::caps_read ) {
4759
-		EEM_Base::verify_is_valid_cap_context( $context );
4758
+	public function cap_restrictions($context = EEM_Base::caps_read) {
4759
+		EEM_Base::verify_is_valid_cap_context($context);
4760 4760
 		//check if we ought to run the restriction generator first
4761
-		if(
4762
-			isset( $this->_cap_restriction_generators[ $context ] )
4763
-			&& $this->_cap_restriction_generators[ $context ] instanceof EE_Restriction_Generator_Base
4764
-			&& ! $this->_cap_restriction_generators[ $context ]->has_generated_cap_restrictions()
4761
+		if (
4762
+			isset($this->_cap_restriction_generators[$context])
4763
+			&& $this->_cap_restriction_generators[$context] instanceof EE_Restriction_Generator_Base
4764
+			&& ! $this->_cap_restriction_generators[$context]->has_generated_cap_restrictions()
4765 4765
 		) {
4766
-			$this->_cap_restrictions[ $context ] = array_merge(
4767
-				$this->_cap_restrictions[ $context ],
4768
-				$this->_cap_restriction_generators[ $context ]->generate_restrictions()
4766
+			$this->_cap_restrictions[$context] = array_merge(
4767
+				$this->_cap_restrictions[$context],
4768
+				$this->_cap_restriction_generators[$context]->generate_restrictions()
4769 4769
 			);
4770 4770
 		}
4771 4771
 		//and make sure we've finalized the construction of each restriction
4772
-		foreach( $this->_cap_restrictions[ $context ] as $where_conditions_obj ) {
4773
-			if ( $where_conditions_obj instanceof EE_Default_Where_Conditions ) {
4774
-				$where_conditions_obj->_finalize_construct( $this );
4772
+		foreach ($this->_cap_restrictions[$context] as $where_conditions_obj) {
4773
+			if ($where_conditions_obj instanceof EE_Default_Where_Conditions) {
4774
+				$where_conditions_obj->_finalize_construct($this);
4775 4775
 			}
4776 4776
 		}
4777 4777
 
4778
-		return $this->_cap_restrictions[ $context ];
4778
+		return $this->_cap_restrictions[$context];
4779 4779
 	}
4780 4780
 
4781 4781
 	/**
4782 4782
 	 * Indicating whether or not this model thinks its a wp core model
4783 4783
 	 * @return boolean
4784 4784
 	 */
4785
-	public function is_wp_core_model(){
4785
+	public function is_wp_core_model() {
4786 4786
 		return $this->_wp_core_model;
4787 4787
 	}
4788 4788
 
@@ -4796,12 +4796,12 @@  discard block
 block discarded – undo
4796 4796
 	 * @return EE_Default_Where_Conditions[] indexed by capability name
4797 4797
 	 * @throws \EE_Error
4798 4798
 	 */
4799
-	public function caps_missing( $context = EEM_Base::caps_read ) {
4799
+	public function caps_missing($context = EEM_Base::caps_read) {
4800 4800
 		$missing_caps = array();
4801
-		$cap_restrictions = $this->cap_restrictions( $context );
4802
-		foreach( $cap_restrictions as $cap => $restriction_if_no_cap ) {
4803
-			if( ! EE_Capabilities::instance()->current_user_can( $cap, $this->get_this_model_name() . '_model_applying_caps') ) {
4804
-				$missing_caps[ $cap ] = $restriction_if_no_cap;
4801
+		$cap_restrictions = $this->cap_restrictions($context);
4802
+		foreach ($cap_restrictions as $cap => $restriction_if_no_cap) {
4803
+			if ( ! EE_Capabilities::instance()->current_user_can($cap, $this->get_this_model_name().'_model_applying_caps')) {
4804
+				$missing_caps[$cap] = $restriction_if_no_cap;
4805 4805
 			}
4806 4806
 		}
4807 4807
 		return $missing_caps;
@@ -4813,7 +4813,7 @@  discard block
 block discarded – undo
4813 4813
 	 * one of 'read', 'edit', or 'delete'
4814 4814
 	 */
4815 4815
 	public function cap_contexts_to_cap_action_map() {
4816
-		return apply_filters( 'FHEE__EEM_Base__cap_contexts_to_cap_action_map', $this->_cap_contexts_to_cap_action_map, $this );
4816
+		return apply_filters('FHEE__EEM_Base__cap_contexts_to_cap_action_map', $this->_cap_contexts_to_cap_action_map, $this);
4817 4817
 	}
4818 4818
 
4819 4819
 
@@ -4824,19 +4824,19 @@  discard block
 block discarded – undo
4824 4824
 	 * @return string one of EEM_Base::cap_contexts_to_cap_action_map() values
4825 4825
 	 * @throws \EE_Error
4826 4826
 	 */
4827
-	public function cap_action_for_context( $context ) {
4827
+	public function cap_action_for_context($context) {
4828 4828
 		$mapping = $this->cap_contexts_to_cap_action_map();
4829
-		if( isset( $mapping[ $context ] ) ) {
4830
-			return $mapping[ $context ];
4829
+		if (isset($mapping[$context])) {
4830
+			return $mapping[$context];
4831 4831
 		}
4832
-		if( $action = apply_filters( 'FHEE__EEM_Base__cap_action_for_context', null, $this, $mapping, $context ) ) {
4832
+		if ($action = apply_filters('FHEE__EEM_Base__cap_action_for_context', null, $this, $mapping, $context)) {
4833 4833
 			return $action;
4834 4834
 		}
4835 4835
 		throw new EE_Error(
4836 4836
 			sprintf(
4837
-				__( 'Cannot find capability restrictions for context "%1$s", allowed values are:%2$s', 'event_espresso' ),
4837
+				__('Cannot find capability restrictions for context "%1$s", allowed values are:%2$s', 'event_espresso'),
4838 4838
 				$context,
4839
-				implode(',', array_keys( $this->cap_contexts_to_cap_action_map() ) )
4839
+				implode(',', array_keys($this->cap_contexts_to_cap_action_map()))
4840 4840
 			)
4841 4841
 		);
4842 4842
 
@@ -4847,7 +4847,7 @@  discard block
 block discarded – undo
4847 4847
 	 * @return array
4848 4848
 	 */
4849 4849
 	static public function valid_cap_contexts() {
4850
-		return apply_filters( 'FHEE__EEM_Base__valid_cap_contexts', array(
4850
+		return apply_filters('FHEE__EEM_Base__valid_cap_contexts', array(
4851 4851
 			self::caps_read,
4852 4852
 			self::caps_read_admin,
4853 4853
 			self::caps_edit,
@@ -4863,17 +4863,17 @@  discard block
 block discarded – undo
4863 4863
 	 * @return bool
4864 4864
 	 * @throws \EE_Error
4865 4865
 	 */
4866
-	static public function verify_is_valid_cap_context( $context ) {
4866
+	static public function verify_is_valid_cap_context($context) {
4867 4867
 		$valid_cap_contexts = EEM_Base::valid_cap_contexts();
4868
-		if( in_array( $context, $valid_cap_contexts ) ) {
4868
+		if (in_array($context, $valid_cap_contexts)) {
4869 4869
 			return true;
4870
-		}else{
4870
+		} else {
4871 4871
 			throw new EE_Error(
4872 4872
 				sprintf(
4873
-					__( 'Context "%1$s" passed into model "%2$s" is not a valid context. They are: %3$s', 'event_espresso' ),
4873
+					__('Context "%1$s" passed into model "%2$s" is not a valid context. They are: %3$s', 'event_espresso'),
4874 4874
 					$context,
4875
-					'EEM_Base' ,
4876
-					implode(',', $valid_cap_contexts )
4875
+					'EEM_Base',
4876
+					implode(',', $valid_cap_contexts)
4877 4877
 				)
4878 4878
 			);
4879 4879
 		}
Please login to merge, or discard this patch.