Completed
Branch BUG-8866-category-permalink (0af2d2)
by
unknown
35:39 queued 22:52
created
core/libraries/shortcodes/EE_Event_Shortcodes.lib.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION') )
3
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
4 4
 	exit('NO direct script access allowed');
5 5
 
6 6
 /**
@@ -56,34 +56,34 @@  discard block
 block discarded – undo
56 56
 			'[EVENT_NAME]' => __("This also can be used for the name of the event", 'event_espresso'),
57 57
 			'[EVENT_PHONE]' => __('The phone number for the event (usually an info number)', 'event_espresso'),
58 58
 			'[EVENT_DESCRIPTION]' => __('The description of the event', 'event_espresso'),
59
-			'[EVENT_EXCERPT]' => __( 'This gets parsed to the value for the excerpt field in the event or blank if there is no excerpt.', 'event_espresso' ),
59
+			'[EVENT_EXCERPT]' => __('This gets parsed to the value for the excerpt field in the event or blank if there is no excerpt.', 'event_espresso'),
60 60
 			'[EVENT_LINK]' => __('A link associated with the event', 'event_espresso'),
61 61
 			'[EVENT_URL]' => __('A link to the event set up on the host site.', 'event_espresso'),
62 62
 			'[VIRTUAL_URL]' => __('What was used for the "URL of Event" field in the Venue settings', 'event_espresso'),
63 63
 			'[VIRTUAL_PHONE]' => __('An alternate phone number for the event. Typically used as a "call-in" number', 'event_espresso'),
64 64
 			'[EVENT_IMAGE]' => __('This will parse to the Feature image for the event.', 'event_espresso'),
65 65
 			'[EVENT_TOTAL_AVAILABLE_SPACES_*]' => sprintf(
66
-				__( 'This will parse to the total available spaces for an event. Calculating total spaces is approximate because it is dependent on the complexity of limits on your event.  There are two methods of calculation (which can be indicated by the %1$smethod%2$s param on the shortcode).  %1$scurrent%2$s which will do a more accurate calculation of total available spaces based on current sales, and %1$sfull%2$s which will be the maximum total available spaces that is on the event in optimal conditions. The shortcode will default to current.', 'event_espresso' ),
66
+				__('This will parse to the total available spaces for an event. Calculating total spaces is approximate because it is dependent on the complexity of limits on your event.  There are two methods of calculation (which can be indicated by the %1$smethod%2$s param on the shortcode).  %1$scurrent%2$s which will do a more accurate calculation of total available spaces based on current sales, and %1$sfull%2$s which will be the maximum total available spaces that is on the event in optimal conditions. The shortcode will default to current.', 'event_espresso'),
67 67
 				'<code>',
68 68
 				'</code>'
69 69
 				),
70
-			'[EVENT_TOTAL_SPOTS_TAKEN]' => __( 'This shortcode will parse to the output the total approved registrations for this event', 'event_espresso' ),
70
+			'[EVENT_TOTAL_SPOTS_TAKEN]' => __('This shortcode will parse to the output the total approved registrations for this event', 'event_espresso'),
71 71
 			'[EVENT_FACEBOOK_URL]' => __('This will return the Facebook URL for the event if you have it set via custom field in your event, otherwise it will use the Facebook URL set in "Your Organization Settings". To set the facebook url in your event, add a custom field with the key as <code>event_facebook</code> and the value as your facebook url.', 'event_espresso'),
72 72
 			'[EVENT_TWITTER_URL]' => __('This will return the Twitter URL for the event if you have it set via custom field in your event, otherwise it will use the Twitter URL set in "Your Organization Settings". To set the facebook url in your event, add a custom field with the key as <code>event_twitter</code> and the value as your facebook url', 'event_espresso'),
73 73
 			'[EVENT_META_*]' => __('This is a special dynamic shortcode. After the "*", add the exact name for your custom field, if there is a value set for that custom field within the event then it will be output in place of this shortcode.', 'event_espresso'),
74
-			'[REGISTRATION_LIST_TABLE_FOR_EVENT_URL]' => __( 'This parses to the url for the registration list table filtered by registrations for this event.', 'event_espresso' ),
74
+			'[REGISTRATION_LIST_TABLE_FOR_EVENT_URL]' => __('This parses to the url for the registration list table filtered by registrations for this event.', 'event_espresso'),
75 75
 			);
76 76
 	}
77 77
 
78 78
 
79
-	protected function _parser( $shortcode ) {
79
+	protected function _parser($shortcode) {
80 80
 
81
-		EE_Registry::instance()->load_helper( 'Formatter' );
81
+		EE_Registry::instance()->load_helper('Formatter');
82 82
 
83 83
 		$this->_event = $this->_data instanceof EE_Event ? $this->_data : null;
84 84
 
85 85
 		//if no event, then let's see if there is a reg_obj.  If there IS, then we'll try and grab the event from the reg_obj instead.
86
-		if ( empty( $this->_event ) ) {
86
+		if (empty($this->_event)) {
87 87
 			$aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : NULL;
88 88
 			$aee = $this->_extra_data instanceof EE_Messages_Addressee ? $this->_extra_data : $aee;
89 89
 
@@ -92,17 +92,17 @@  discard block
 block discarded – undo
92 92
 
93 93
 
94 94
 		//If there is no event objecdt by now then get out.
95
-		if ( ! $this->_event instanceof EE_Event )
95
+		if ( ! $this->_event instanceof EE_Event)
96 96
 			return '';
97 97
 
98
-		switch ( $shortcode ) {
98
+		switch ($shortcode) {
99 99
 
100 100
 			case '[EVENT_ID]' :
101 101
 				return $this->_event->ID();
102 102
 				break;
103 103
 
104 104
 			case '[EVENT_IDENTIFIER]' :
105
-				return isset($this->_data['line_ref']) ? $this->_data['line_ref']: '';
105
+				return isset($this->_data['line_ref']) ? $this->_data['line_ref'] : '';
106 106
 				break;
107 107
 
108 108
 			case '[EVENT]' :
@@ -132,71 +132,71 @@  discard block
 block discarded – undo
132 132
 
133 133
 			case '[VIRTUAL_URL]' :
134 134
 				$venue = $this->_event->get_first_related('Venue');
135
-				if ( empty( $venue ) )
135
+				if (empty($venue))
136 136
 					return '';
137 137
 				return $venue->get('VNU_virtual_url');
138 138
 
139 139
 			case '[VIRTUAL_PHONE]' :
140 140
 				$venue = $this->_event->get_first_related('Venue');
141
-				if ( empty( $venue ) )
141
+				if (empty($venue))
142 142
 					return '';
143 143
 				return $venue->get('VNU_virtual_phone');
144 144
 				break;
145 145
 
146 146
 			case '[EVENT_IMAGE]' :
147
-				$image = $this->_event->feature_image_url(array(600,300) );
147
+				$image = $this->_event->feature_image_url(array(600, 300));
148 148
 				// @todo: eventually we should make this an attribute shortcode so that em can send along what size they want returned.
149
-				return !empty( $image ) ? '<img src="' . $image . '" alt="' . sprintf( esc_attr__( '%s Feature Image', 'event_espresso'), $this->_event->get('EVT_name') ) . '" />' : '';
149
+				return ! empty($image) ? '<img src="'.$image.'" alt="'.sprintf(esc_attr__('%s Feature Image', 'event_espresso'), $this->_event->get('EVT_name')).'" />' : '';
150 150
 				break;
151 151
 
152 152
 			case '[EVENT_FACEBOOK_URL]' :
153
-				$facebook_url = $this->_event->get_post_meta('event_facebook', true );
154
-				return empty( $facebook_url ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' ) : $facebook_url;
153
+				$facebook_url = $this->_event->get_post_meta('event_facebook', true);
154
+				return empty($facebook_url) ? EE_Registry::instance()->CFG->organization->get_pretty('facebook') : $facebook_url;
155 155
 				break;
156 156
 
157 157
 			case '[EVENT_TWITTER_URL]' :
158 158
 				$twitter_url = $this->_event->get_post_meta('event_twitter', true);
159
-				return empty( $twitter_url ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' ) : $twitter_url;
159
+				return empty($twitter_url) ? EE_Registry::instance()->CFG->organization->get_pretty('twitter') : $twitter_url;
160 160
 				break;
161 161
 
162 162
 			case '[EVENT_AUTHOR_EMAIL]' :
163 163
 				$author_id = $this->_event->get('EVT_wp_user');
164
-				$user_data = get_userdata( (int) $author_id );
164
+				$user_data = get_userdata((int) $author_id);
165 165
 				return $user_data->user_email;
166 166
 				break;
167 167
 
168 168
 			case '[EVENT_TOTAL_SPOTS_TAKEN]' :
169
-				return EEM_Registration::instance()->count( array( array( 'EVT_ID' => $this->_event->ID(), 'STS_ID' => EEM_Registration::status_id_approved ) ), 'REG_ID', true );
169
+				return EEM_Registration::instance()->count(array(array('EVT_ID' => $this->_event->ID(), 'STS_ID' => EEM_Registration::status_id_approved)), 'REG_ID', true);
170 170
 				break;
171 171
 
172 172
 			case '[REGISTRATION_LIST_TABLE_FOR_EVENT_URL]' :
173
-				EE_Registry::instance()->load_helper( 'URL' );
173
+				EE_Registry::instance()->load_helper('URL');
174 174
 				return EEH_URL::add_query_args_and_nonce(
175 175
 					array(
176 176
 						'event_id' => $this->_event->ID(),
177 177
 						'page' => 'espresso_registrations',
178 178
 						'action' => 'default'
179 179
 					),
180
-					admin_url( 'admin.php' ),
180
+					admin_url('admin.php'),
181 181
 					true
182 182
 				);
183 183
 				break;
184 184
 		}
185 185
 
186
-		if ( strpos( $shortcode, '[EVENT_META_*' ) !== false ) {
187
-			$shortcode = str_replace( '[EVENT_META_*', '', $shortcode );
188
-			$shortcode = trim( str_replace( ']', '', $shortcode ) );
186
+		if (strpos($shortcode, '[EVENT_META_*') !== false) {
187
+			$shortcode = str_replace('[EVENT_META_*', '', $shortcode);
188
+			$shortcode = trim(str_replace(']', '', $shortcode));
189 189
 
190 190
 			//pull the meta value from the event post
191
-			$event_meta = $this->_event->get_post_meta( $shortcode, true );
191
+			$event_meta = $this->_event->get_post_meta($shortcode, true);
192 192
 
193
-			return !empty( $event_meta ) ? $this->_event->get_post_meta( $shortcode, true ) : '';
193
+			return ! empty($event_meta) ? $this->_event->get_post_meta($shortcode, true) : '';
194 194
 
195 195
 		}
196 196
 
197
-		if ( strpos( $shortcode, '[EVENT_TOTAL_AVAILABLE_SPACES_*' ) !== false ) {
198
-			$attrs = $this->_get_shortcode_attrs( $shortcode );
199
-			$method = empty( $attrs['method'] ) ? 'current' : $attrs['method'];
197
+		if (strpos($shortcode, '[EVENT_TOTAL_AVAILABLE_SPACES_*') !== false) {
198
+			$attrs = $this->_get_shortcode_attrs($shortcode);
199
+			$method = empty($attrs['method']) ? 'current' : $attrs['method'];
200 200
 			$method = $method === 'current';
201 201
 			$available = $this->_event->total_available_spaces($method);
202 202
 			return $available === EE_INF ? '&infin;' : $available;
@@ -212,10 +212,10 @@  discard block
 block discarded – undo
212 212
 	 * @param  boolean $full_link if TRUE (default) we return the html for the name of the event linked to the event.  Otherwise we just return the url of the event.
213 213
 	 * @return string
214 214
 	 */
215
-	private function _get_event_link( $event, $full_link = TRUE ) {
215
+	private function _get_event_link($event, $full_link = TRUE) {
216 216
 		$url = get_permalink($event->ID());
217 217
 
218
-		return $full_link ? '<a href="' . $url . '">' . $event->get('EVT_name') . '</a>' : $url;
218
+		return $full_link ? '<a href="'.$url.'">'.$event->get('EVT_name').'</a>' : $url;
219 219
 	}
220 220
 
221 221
 
Please login to merge, or discard this patch.
core/db_classes/EE_CSV.class.php 2 patches
Spacing   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
2 2
 /**
3 3
  * CSV Import Export class
4 4
  * 
@@ -45,31 +45,31 @@  discard block
 block discarded – undo
45 45
 		global $wpdb;
46 46
 
47 47
 		$this->_primary_keys = array(
48
-				$wpdb->prefix . 'esp_answer' => array( 'ANS_ID' ),
49
-				$wpdb->prefix . 'esp_attendee' => array( 'ATT_ID' ),
50
-				$wpdb->prefix . 'esp_datetime'	=> array( 'DTT_ID' ),
51
-				$wpdb->prefix . 'esp_event_question_group'	=> array( 'EQG_ID' ),
52
-				$wpdb->prefix . 'esp_message_template'	=> array( 'MTP_ID' ),
53
-				$wpdb->prefix . 'esp_payment'	=> array( 'PAY_ID' ),
54
-				$wpdb->prefix . 'esp_price'	=> array( 'PRC_ID' ),
55
-				$wpdb->prefix . 'esp_price_type'	=> array( 'PRT_ID' ),
56
-				$wpdb->prefix . 'esp_question'	=> array( 'QST_ID' ),
57
-				$wpdb->prefix . 'esp_question_group'	=> array( 'QSG_ID' ),
58
-				$wpdb->prefix . 'esp_question_group_question'	=> array( 'QGQ_ID' ),
59
-				$wpdb->prefix . 'esp_question_option'	=> array( 'QSO_ID' ),
60
-				$wpdb->prefix . 'esp_registration'	=> array( 'REG_ID' ),
61
-				$wpdb->prefix . 'esp_status'	=> array( 'STS_ID' ),
62
-				$wpdb->prefix . 'esp_transaction'	=> array( 'TXN_ID' ),
63
-				$wpdb->prefix . 'esp_transaction'	=> array( 'TXN_ID' ),
64
-				$wpdb->prefix . 'events_detail'	=> array( 'id' ),
65
-				$wpdb->prefix . 'events_category_detail'	=> array( 'id' ),
66
-				$wpdb->prefix . 'events_category_rel'	=> array( 'id' ),
67
-				$wpdb->prefix . 'events_venue'	=> array( 'id' ),
68
-				$wpdb->prefix . 'events_venue_rel' =>  array( 'emeta_id' ),
69
-				$wpdb->prefix . 'events_locale'	=> array( 'id' ),
70
-				$wpdb->prefix . 'events_locale_rel'	=> array( 'id' ),
71
-				$wpdb->prefix . 'events_personnel' =>  array( 'id' ),
72
-				$wpdb->prefix . 'events_personnel_rel' =>  array( 'id' ),
48
+				$wpdb->prefix.'esp_answer' => array('ANS_ID'),
49
+				$wpdb->prefix.'esp_attendee' => array('ATT_ID'),
50
+				$wpdb->prefix.'esp_datetime'	=> array('DTT_ID'),
51
+				$wpdb->prefix.'esp_event_question_group'	=> array('EQG_ID'),
52
+				$wpdb->prefix.'esp_message_template'	=> array('MTP_ID'),
53
+				$wpdb->prefix.'esp_payment'	=> array('PAY_ID'),
54
+				$wpdb->prefix.'esp_price'	=> array('PRC_ID'),
55
+				$wpdb->prefix.'esp_price_type'	=> array('PRT_ID'),
56
+				$wpdb->prefix.'esp_question'	=> array('QST_ID'),
57
+				$wpdb->prefix.'esp_question_group'	=> array('QSG_ID'),
58
+				$wpdb->prefix.'esp_question_group_question'	=> array('QGQ_ID'),
59
+				$wpdb->prefix.'esp_question_option'	=> array('QSO_ID'),
60
+				$wpdb->prefix.'esp_registration'	=> array('REG_ID'),
61
+				$wpdb->prefix.'esp_status'	=> array('STS_ID'),
62
+				$wpdb->prefix.'esp_transaction'	=> array('TXN_ID'),
63
+				$wpdb->prefix.'esp_transaction'	=> array('TXN_ID'),
64
+				$wpdb->prefix.'events_detail'	=> array('id'),
65
+				$wpdb->prefix.'events_category_detail'	=> array('id'),
66
+				$wpdb->prefix.'events_category_rel'	=> array('id'),
67
+				$wpdb->prefix.'events_venue'	=> array('id'),
68
+				$wpdb->prefix.'events_venue_rel' =>  array('emeta_id'),
69
+				$wpdb->prefix.'events_locale'	=> array('id'),
70
+				$wpdb->prefix.'events_locale_rel'	=> array('id'),
71
+				$wpdb->prefix.'events_personnel' =>  array('id'),
72
+				$wpdb->prefix.'events_personnel_rel' =>  array('id'),
73 73
 			);
74 74
 
75 75
 	}
@@ -81,9 +81,9 @@  discard block
 block discarded – undo
81 81
 	 *		@ access public
82 82
 	 *		@return EE_CSV
83 83
 	 */
84
-	public static function instance ( ) {
84
+	public static function instance( ) {
85 85
 		// check if class object is instantiated
86
-		if ( self::$_instance === NULL  or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EE_CSV )) {
86
+		if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EE_CSV)) {
87 87
 			self::$_instance = new self();
88 88
 		}
89 89
 		return self::$_instance;
@@ -95,22 +95,22 @@  discard block
 block discarded – undo
95 95
 	 * @return string
96 96
 	 * @throws EE_Error
97 97
 	 */
98
-	private function read_unicode_file($file_path){
98
+	private function read_unicode_file($file_path) {
99 99
 		$fc = "";
100
-		$fh = fopen($file_path,"rb");
101
-		if( ! $fh ){
102
-			throw new EE_Error( sprintf( __("Cannot open file for read: %s<br>\n", 'event_espresso'), $file_path ) );
100
+		$fh = fopen($file_path, "rb");
101
+		if ( ! $fh) {
102
+			throw new EE_Error(sprintf(__("Cannot open file for read: %s<br>\n", 'event_espresso'), $file_path));
103 103
 		}
104 104
 		$flen = filesize($file_path);
105 105
 		$bc = fread($fh, $flen);
106
-		for ($i=0; $i<$flen; $i++){
107
-			$c = substr($bc,$i,1);
108
-			if ((ord($c) != 0) && (ord($c) != 13)){
109
-			  $fc = $fc . $c;
106
+		for ($i = 0; $i < $flen; $i++) {
107
+			$c = substr($bc, $i, 1);
108
+			if ((ord($c) != 0) && (ord($c) != 13)) {
109
+			  $fc = $fc.$c;
110 110
 			}
111 111
 		}
112
-		if ((ord(substr($fc,0,1)) == 255) && (ord(substr($fc,1,1)) == 254))
113
-		$fc = substr($fc,2);
112
+		if ((ord(substr($fc, 0, 1)) == 255) && (ord(substr($fc, 1, 1)) == 254))
113
+		$fc = substr($fc, 2);
114 114
 		return ($fc);
115 115
 }
116 116
 
@@ -122,15 +122,15 @@  discard block
 block discarded – undo
122 122
 	 * @param string $path_to_file
123 123
 	 * @return array of arrays. Top-level array has rows, second-level array has each item
124 124
 	 */
125
-	public function import_csv_to_multi_dimensional_array($path_to_file){
125
+	public function import_csv_to_multi_dimensional_array($path_to_file) {
126 126
 		// needed to deal with Mac line endings
127
-		ini_set('auto_detect_line_endings',TRUE);
127
+		ini_set('auto_detect_line_endings', TRUE);
128 128
 
129 129
 		// because fgetcsv does not correctly deal with backslashed quotes such as \"
130 130
 		// we'll read the file into a string
131
-		$file_contents = $this->read_unicode_file( $path_to_file );
131
+		$file_contents = $this->read_unicode_file($path_to_file);
132 132
 		// replace backslashed quotes with CSV enclosures
133
-		$file_contents = str_replace ( '\\"', '"""', $file_contents );
133
+		$file_contents = str_replace('\\"', '"""', $file_contents);
134 134
 		// HEY YOU! PUT THAT FILE BACK!!!
135 135
 		file_put_contents($path_to_file, $file_contents);
136 136
 
@@ -140,25 +140,25 @@  discard block
 block discarded – undo
140 140
 			$csvarray = array();
141 141
 
142 142
 			// in PHP 5.3 fgetcsv accepts a 5th parameter, but the pre 5.3 versions of fgetcsv choke if passed more than 4 - is that crazy or what?
143
-			if ( version_compare( PHP_VERSION, '5.3.0' ) < 0 ) {
143
+			if (version_compare(PHP_VERSION, '5.3.0') < 0) {
144 144
 
145 145
 				//  PHP 5.2- version
146 146
 
147 147
 				// loop through each row of the file
148
-				while(($data = fgetcsv($file_handle, 0, ',', '"' )) !== FALSE){
149
-					$csvarray[]= $data;
148
+				while (($data = fgetcsv($file_handle, 0, ',', '"')) !== FALSE) {
149
+					$csvarray[] = $data;
150 150
 				}
151
-			}else{
151
+			} else {
152 152
 				// loop through each row of the file
153
-				while (( $data = fgetcsv( $file_handle, 0, ',', '"', '\\' )) !== FALSE ) {
154
-					$csvarray[]=$data;
153
+				while (($data = fgetcsv($file_handle, 0, ',', '"', '\\')) !== FALSE) {
154
+					$csvarray[] = $data;
155 155
 				}
156 156
 			}
157 157
 			# Close the File.
158 158
 			fclose($file_handle);
159 159
 			return $csvarray;
160
-		}else{
161
-			EE_Error::add_error( sprintf(__("An error occurred - the file: %s could not opened.", "event_espresso"),$path_to_file), __FILE__, __FUNCTION__, __LINE__ );
160
+		} else {
161
+			EE_Error::add_error(sprintf(__("An error occurred - the file: %s could not opened.", "event_espresso"), $path_to_file), __FILE__, __FUNCTION__, __LINE__);
162 162
 			return false;
163 163
 		}
164 164
 	}
@@ -188,9 +188,9 @@  discard block
 block discarded – undo
188 188
 	 *						...
189 189
 	 *						)
190 190
 	 */
191
-	public function import_csv_to_model_data_array( $path_to_file, $model_name = FALSE, $first_row_is_headers = TRUE ) {
191
+	public function import_csv_to_model_data_array($path_to_file, $model_name = FALSE, $first_row_is_headers = TRUE) {
192 192
 		$multi_dimensional_array = $this->import_csv_to_multi_dimensional_array($path_to_file);
193
-		if( ! $multi_dimensional_array ){
193
+		if ( ! $multi_dimensional_array) {
194 194
 			return false;
195 195
 		}
196 196
 		// gotta start somewhere
@@ -199,9 +199,9 @@  discard block
 block discarded – undo
199 199
 		$ee_formatted_data = array();
200 200
 		// array to store headers (column names)
201 201
 		$headers = array();
202
-		foreach($multi_dimensional_array as $data){
202
+		foreach ($multi_dimensional_array as $data) {
203 203
 			// if first cell is MODEL, then second cell is the MODEL name
204
-			if ( $data[0]	== 'MODEL' ) {
204
+			if ($data[0] == 'MODEL') {
205 205
 				$model_name = $data[1];
206 206
 				//don't bother looking for model data in this row. The rest of this
207 207
 				//row should be blank
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 				$headers = array();
212 212
 				continue;
213 213
 			}
214
-			if( strpos( $data[0], EE_CSV::metadata_header ) !==FALSE ){
214
+			if (strpos($data[0], EE_CSV::metadata_header) !== FALSE) {
215 215
 				$model_name = EE_CSV::metadata_header;
216 216
 				//store like model data, we just won't try importing it etc.
217 217
 				$row = 1;
@@ -224,31 +224,31 @@  discard block
 block discarded – undo
224 224
 
225 225
 			$model_entry = array();
226 226
 			// loop through each column
227
-			for ( $i=0; $i < $columns; $i++ ) {
227
+			for ($i = 0; $i < $columns; $i++) {
228 228
 
229 229
 				//replace csv_enclosures with backslashed quotes
230
-				$data[$i] = str_replace ( '"""', '\\"', $data[$i] );
230
+				$data[$i] = str_replace('"""', '\\"', $data[$i]);
231 231
 				// do we need to grab the column names?
232
-				if ( $row === 1){
233
-					if( $first_row_is_headers ) {
232
+				if ($row === 1) {
233
+					if ($first_row_is_headers) {
234 234
 						// store the column names to use for keys
235 235
 						$column_name = $data[$i];
236 236
 						//check it's not blank... sometimes CSV editign programs adda bunch of empty columns onto the end...
237
-						if(!$column_name){continue;}
237
+						if ( ! $column_name) {continue; }
238 238
 						$matches = array();
239
-						if($model_name == EE_CSV::metadata_header){
239
+						if ($model_name == EE_CSV::metadata_header) {
240 240
 							$headers[$i] = $column_name;
241
-						}else{
241
+						} else {
242 242
 							//now get the db table name from it (the part between square brackets)
243
-							$success = preg_match('~(.*)\[(.*)\]~', $column_name,$matches);
244
-							if (!$success){
245
-								EE_Error::add_error( sprintf(__("The column titled %s is invalid for importing. It must be be in the format of 'Nice Name[model_field_name]' in row %s", "event_espresso"),$column_name,implode(",",$data)), __FILE__, __FUNCTION__, __LINE__ );
243
+							$success = preg_match('~(.*)\[(.*)\]~', $column_name, $matches);
244
+							if ( ! $success) {
245
+								EE_Error::add_error(sprintf(__("The column titled %s is invalid for importing. It must be be in the format of 'Nice Name[model_field_name]' in row %s", "event_espresso"), $column_name, implode(",", $data)), __FILE__, __FUNCTION__, __LINE__);
246 246
 								return false;
247 247
 							}
248 248
 							$headers[$i] = $matches[2];
249 249
 						}
250 250
 
251
-					}else{
251
+					} else {
252 252
 						// no column names means our final array will just use counters for keys
253 253
 						$model_entry[$headers[$i]] = $data[$i];
254 254
 						$headers[$i] = $i;
@@ -256,14 +256,14 @@  discard block
 block discarded – undo
256 256
 					// and we need to store csv data
257 257
 				} else {
258 258
 					// this column isn' ta header, store it if there is a header for it
259
-					if(isset($headers[$i])){
259
+					if (isset($headers[$i])) {
260 260
 						$model_entry[$headers[$i]] = $data[$i];
261 261
 					}
262 262
 				}
263 263
 
264 264
 			}
265 265
 			//save the row's data IF it's a non-header-row
266
-			if( ! $first_row_is_headers || ($first_row_is_headers && $row > 1)){
266
+			if ( ! $first_row_is_headers || ($first_row_is_headers && $row > 1)) {
267 267
 				$ee_formatted_data[$model_name][] = $model_entry;
268 268
 			}
269 269
 			// advance to next row
@@ -282,9 +282,9 @@  discard block
 block discarded – undo
282 282
 	}
283 283
 
284 284
 
285
-	public function save_csv_to_db( $csv_data_array, $model_name = FALSE ) {
286
-		EE_Error::doing_it_wrong('save_csv_to_db', __( 'Function moved to EE_Import and renamed to save_csv_data_array_to_db', 'event_espresso' ), '4.6.7' );
287
-		return EE_Import::instance()->save_csv_data_array_to_db( $csv_data_array, $model_name );
285
+	public function save_csv_to_db($csv_data_array, $model_name = FALSE) {
286
+		EE_Error::doing_it_wrong('save_csv_to_db', __('Function moved to EE_Import and renamed to save_csv_data_array_to_db', 'event_espresso'), '4.6.7');
287
+		return EE_Import::instance()->save_csv_data_array_to_db($csv_data_array, $model_name);
288 288
 	}
289 289
 
290 290
 	/**
@@ -294,11 +294,11 @@  discard block
 block discarded – undo
294 294
 	 * @param string $new_filename the name of the file that the user will download
295 295
 	 * @return resource, like the results of fopen(), which can be used for fwrite, fputcsv2, etc.
296 296
 	 */
297
-	public function begin_sending_csv($filename){
297
+	public function begin_sending_csv($filename) {
298 298
 		// grab file extension
299 299
 		$ext = substr(strrchr($filename, '.'), 1);
300
-		if ( $ext == '.csv' or  $ext == '.xls' ) {
301
-			str_replace( $ext, '', $filename );
300
+		if ($ext == '.csv' or $ext == '.xls') {
301
+			str_replace($ext, '', $filename);
302 302
 		}
303 303
 		$filename .= '.csv';
304 304
 
@@ -319,8 +319,8 @@  discard block
 block discarded – undo
319 319
 //		header("Content-Type: application/download");
320 320
 		header('Content-disposition: attachment; filename='.$filename);
321 321
 		header("Content-Type: text/csv; charset=utf-8");
322
-                do_action( 'AHEE__EE_CSV__begin_sending_csv__headers' );
323
-		echo apply_filters('FHEE__EE_CSV__begin_sending_csv__start_writing', "\xEF\xBB\xBF" ); // makes excel open it as UTF-8. UTF-8 BOM, see http://stackoverflow.com/a/4440143/2773835
322
+                do_action('AHEE__EE_CSV__begin_sending_csv__headers');
323
+		echo apply_filters('FHEE__EE_CSV__begin_sending_csv__start_writing', "\xEF\xBB\xBF"); // makes excel open it as UTF-8. UTF-8 BOM, see http://stackoverflow.com/a/4440143/2773835
324 324
 		$fh = fopen('php://output', 'w');
325 325
 		return $fh;
326 326
 	}
@@ -330,12 +330,12 @@  discard block
 block discarded – undo
330 330
 	 * mentioning the version and timezone
331 331
 	 * @param resource $filehandle
332 332
 	 */
333
-	public function write_metadata_to_csv($filehandle){
333
+	public function write_metadata_to_csv($filehandle) {
334 334
 		EE_Registry::instance()->load_helper('DTT_Helper');
335
-		$data_row = array(EE_CSV::metadata_header);//do NOT translate because this exact string is used when importing
335
+		$data_row = array(EE_CSV::metadata_header); //do NOT translate because this exact string is used when importing
336 336
 		$this->fputcsv2($filehandle, $data_row);
337 337
 		EE_Registry::instance()->load_helper('DTT_Helper');
338
-		$meta_data = array( 0=> array(
338
+		$meta_data = array(0=> array(
339 339
 			'version'=>espresso_version(),
340 340
 			'timezone'=>  EEH_DTT_Helper::get_timezone(),
341 341
 			'time_of_export'=>current_time('mysql'),
@@ -353,30 +353,30 @@  discard block
 block discarded – undo
353 353
 	 * then the first row we'd write to the CSV would be "EVT_ID,EVT_name,..."
354 354
 	 * @return boolean if we successfully wrote to the CSV or not. If there's no $data, we consider that a success (because we wrote everything there was...nothing)
355 355
 	 */
356
-	public function write_data_array_to_csv($filehandle, $data){
356
+	public function write_data_array_to_csv($filehandle, $data) {
357 357
 		EE_Registry::instance()->load_helper('Array');
358 358
 
359 359
 
360 360
 		//determine if $data is actually a 2d array
361
-		if ( $data && is_array($data) && is_array(EEH_Array::get_one_item_from_array($data))){
361
+		if ($data && is_array($data) && is_array(EEH_Array::get_one_item_from_array($data))) {
362 362
 			//make sure top level is numerically indexed,
363 363
 
364
-			if( EEH_Array::is_associative_array($data)){
365
-				throw new EE_Error(sprintf(__("top-level array must be numerically indexed. Does these look like numbers to you? %s","event_espresso"),implode(",",array_keys($data))));
364
+			if (EEH_Array::is_associative_array($data)) {
365
+				throw new EE_Error(sprintf(__("top-level array must be numerically indexed. Does these look like numbers to you? %s", "event_espresso"), implode(",", array_keys($data))));
366 366
 			}
367 367
 			$item_in_top_level_array = EEH_Array::get_one_item_from_array($data);
368 368
 			//now, is the last item in the top-level array of $data an associative or numeric array?
369
-			if(EEH_Array::is_associative_array($item_in_top_level_array)){
369
+			if (EEH_Array::is_associative_array($item_in_top_level_array)) {
370 370
 				//its associative, so we want to output its keys as column headers
371 371
 				$keys = array_keys($item_in_top_level_array);
372 372
 				echo $this->fputcsv2($filehandle, $keys);
373 373
 			}
374 374
 			//start writing data
375
-			foreach($data as $data_row){
375
+			foreach ($data as $data_row) {
376 376
 				echo $this->fputcsv2($filehandle, $data_row);
377 377
 			}
378 378
 			return true;
379
-		}else{
379
+		} else {
380 380
 			//no data TO write... so we can assume that's a success
381 381
 			return true;
382 382
 		}
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
 	 * Calls exit to prevent polluting the CSV file with other junk
422 422
 	 * @param resource $fh filehandle where we're writing the CSV to
423 423
 	 */
424
-	public function end_sending_csv($fh){
424
+	public function end_sending_csv($fh) {
425 425
 		fclose($fh);
426 426
 		exit(0);
427 427
 	}
@@ -434,23 +434,23 @@  discard block
 block discarded – undo
434 434
 	 * has all the attributes o fthat model object (eg, the event's id, name, etc)
435 435
 	 * @return boolean success
436 436
 	 */
437
-	public function write_model_data_to_csv($filehandle,$model_data_array){
437
+	public function write_model_data_to_csv($filehandle, $model_data_array) {
438 438
 		$this->write_metadata_to_csv($filehandle);
439
-		foreach($model_data_array as $model_name => $model_instance_arrays){
439
+		foreach ($model_data_array as $model_name => $model_instance_arrays) {
440 440
 			//first: output a special row stating the model
441
-			echo $this->fputcsv2($filehandle,array('MODEL',$model_name));
441
+			echo $this->fputcsv2($filehandle, array('MODEL', $model_name));
442 442
 			//if we have items to put in the CSV, do it normally
443 443
 
444
-			if( ! empty($model_instance_arrays) ){
444
+			if ( ! empty($model_instance_arrays)) {
445 445
 				$this->write_data_array_to_csv($filehandle, $model_instance_arrays);
446
-			}else{
446
+			} else {
447 447
 //				echo "no data to write... so just write the headers";
448 448
 				//so there's actually NO model objects for that model.
449 449
 				//probably still want to show the columns
450 450
 				$model = EE_Registry::instance()->load_model($model_name);
451 451
 				$column_names = array();
452
-				foreach($model->field_settings() as $field){
453
-					$column_names[$field->get_nicename()."[".$field->get_name()."]"] = null ;
452
+				foreach ($model->field_settings() as $field) {
453
+					$column_names[$field->get_nicename()."[".$field->get_name()."]"] = null;
454 454
 				}
455 455
 				$this->write_data_array_to_csv($filehandle, array($column_names));
456 456
 			}
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
 	 * @param array $model_data_array 3d array, as described in EE_CSV::write_model_data_to_csv()
465 465
 	 * @return bool | void writes CSV file to output and dies
466 466
 	 */
467
-	public function export_multiple_model_data_to_csv($filename,$model_data_array){
467
+	public function export_multiple_model_data_to_csv($filename, $model_data_array) {
468 468
 		$filehandle = $this->begin_sending_csv($filename);
469 469
 		$this->write_model_data_to_csv($filehandle, $model_data_array);
470 470
 		$this->end_sending_csv($filehandle);
@@ -476,15 +476,15 @@  discard block
 block discarded – undo
476 476
 	 *			@param string $filename - name for newly created csv file
477 477
 	 *			@return TRUE on success, FALSE on fail
478 478
 	 */
479
-	public function export_array_to_csv( $data = FALSE, $filename = FALSE  ) {
479
+	public function export_array_to_csv($data = FALSE, $filename = FALSE) {
480 480
 
481 481
 		// no data file?? get outta here
482
-		if ( ! $data or ! is_array( $data ) or empty( $data ) ) {
482
+		if ( ! $data or ! is_array($data) or empty($data)) {
483 483
 			return FALSE;
484 484
 		}
485 485
 
486 486
 		// no filename?? get outta here
487
-		if ( ! $filename ) {
487
+		if ( ! $filename) {
488 488
 			return FALSE;
489 489
 		}
490 490
 
@@ -510,11 +510,11 @@  discard block
 block discarded – undo
510 510
 	 *			@param int $percent_of_max - desired percentage of the max upload_mb
511 511
 	 *			@return int KB
512 512
 	 */
513
-	public function get_max_upload_size ( $percent_of_max = FALSE ) {
513
+	public function get_max_upload_size($percent_of_max = FALSE) {
514 514
 
515
-		$max_upload = (int)(ini_get('upload_max_filesize'));
516
-		$max_post = (int)(ini_get('post_max_size'));
517
-		$memory_limit = (int)(ini_get('memory_limit'));
515
+		$max_upload = (int) (ini_get('upload_max_filesize'));
516
+		$max_post = (int) (ini_get('post_max_size'));
517
+		$memory_limit = (int) (ini_get('memory_limit'));
518 518
 
519 519
 		// determine the smallest of the three values from above
520 520
 		$upload_mb = min($max_upload, $max_post, $memory_limit);
@@ -523,9 +523,9 @@  discard block
 block discarded – undo
523 523
 		$upload_mb = $upload_mb * 1024;
524 524
 
525 525
 		// don't want the full monty? then reduce the max uplaod size
526
-		if ( $percent_of_max ) {
526
+		if ($percent_of_max) {
527 527
 			// is percent_of_max like this -> 50 or like this -> 0.50 ?
528
-			if ( $percent_of_max > 1 ) {
528
+			if ($percent_of_max > 1) {
529 529
 				// chnages 50 to 0.50
530 530
 				$percent_of_max = $percent_of_max / 100;
531 531
 			}
@@ -547,17 +547,17 @@  discard block
 block discarded – undo
547 547
 	 *			@param string $mysql_null - allows php NULL to be overridden with MySQl's insertable NULL value
548 548
 	 *			@return void
549 549
 	 */
550
-	private function fputcsv2 ($fh, array $row, $delimiter = ',', $enclosure = '"', $mysql_null = FALSE) {
550
+	private function fputcsv2($fh, array $row, $delimiter = ',', $enclosure = '"', $mysql_null = FALSE) {
551 551
 		//Allow user to filter the csv delimiter and enclosure for other countries csv standards
552
-		$delimiter = apply_filters( 'FHEE__EE_CSV__fputcsv2__delimiter', $delimiter );
553
-		$enclosure = apply_filters( 'FHEE__EE_CSV__fputcsv2__enclosure', $enclosure );
552
+		$delimiter = apply_filters('FHEE__EE_CSV__fputcsv2__delimiter', $delimiter);
553
+		$enclosure = apply_filters('FHEE__EE_CSV__fputcsv2__enclosure', $enclosure);
554 554
 
555 555
 		$delimiter_esc = preg_quote($delimiter, '/');
556 556
 		$enclosure_esc = preg_quote($enclosure, '/');
557 557
 
558 558
 		$output = array();
559 559
 		foreach ($row as $field_value) {
560
-			if(is_object($field_value) || is_array($field_value)){
560
+			if (is_object($field_value) || is_array($field_value)) {
561 561
 				$field_value = serialize($field_value);
562 562
 			}
563 563
 			if ($field_value === null && $mysql_null) {
@@ -566,10 +566,10 @@  discard block
 block discarded – undo
566 566
 			}
567 567
 
568 568
 			$output[] = preg_match("/(?:${delimiter_esc}|${enclosure_esc}|\s)/", $field_value) ?
569
-				( $enclosure . str_replace($enclosure, $enclosure . $enclosure, $field_value) . $enclosure ) : $field_value;
569
+				($enclosure.str_replace($enclosure, $enclosure.$enclosure, $field_value).$enclosure) : $field_value;
570 570
 		}
571 571
 
572
-		fwrite($fh, join($delimiter, $output) . PHP_EOL);
572
+		fwrite($fh, join($delimiter, $output).PHP_EOL);
573 573
 	}
574 574
 
575 575
 
@@ -607,8 +607,8 @@  discard block
 block discarded – undo
607 607
 	 * @param string $current_format
608 608
 	 * @return string
609 609
 	 */
610
-	public function get_date_format_for_csv( $current_format = null ) {
611
-		return apply_filters( 'FHEE__EE_CSV__get_date_format_for_csv__format', 'Y-m-d', $current_format );
610
+	public function get_date_format_for_csv($current_format = null) {
611
+		return apply_filters('FHEE__EE_CSV__get_date_format_for_csv__format', 'Y-m-d', $current_format);
612 612
 	}
613 613
 
614 614
 	/**
@@ -616,8 +616,8 @@  discard block
 block discarded – undo
616 616
 	 * @param string $current_format
617 617
 	 * @return string
618 618
 	 */
619
-	public function get_time_format_for_csv( $current_format = null ) {
620
-		return apply_filters( 'FHEE__EE_CSV__get_time_format_for_csv__format', 'H:i:s', $current_format );
619
+	public function get_time_format_for_csv($current_format = null) {
620
+		return apply_filters('FHEE__EE_CSV__get_time_format_for_csv__format', 'H:i:s', $current_format);
621 621
 	}
622 622
 
623 623
 
Please login to merge, or discard this patch.
Braces   +12 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if (!defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  * CSV Import Export class
4 6
  * 
@@ -109,8 +111,9 @@  discard block
 block discarded – undo
109 111
 			  $fc = $fc . $c;
110 112
 			}
111 113
 		}
112
-		if ((ord(substr($fc,0,1)) == 255) && (ord(substr($fc,1,1)) == 254))
113
-		$fc = substr($fc,2);
114
+		if ((ord(substr($fc,0,1)) == 255) && (ord(substr($fc,1,1)) == 254)) {
115
+				$fc = substr($fc,2);
116
+		}
114 117
 		return ($fc);
115 118
 }
116 119
 
@@ -148,7 +151,7 @@  discard block
 block discarded – undo
148 151
 				while(($data = fgetcsv($file_handle, 0, ',', '"' )) !== FALSE){
149 152
 					$csvarray[]= $data;
150 153
 				}
151
-			}else{
154
+			} else{
152 155
 				// loop through each row of the file
153 156
 				while (( $data = fgetcsv( $file_handle, 0, ',', '"', '\\' )) !== FALSE ) {
154 157
 					$csvarray[]=$data;
@@ -157,7 +160,7 @@  discard block
 block discarded – undo
157 160
 			# Close the File.
158 161
 			fclose($file_handle);
159 162
 			return $csvarray;
160
-		}else{
163
+		} else{
161 164
 			EE_Error::add_error( sprintf(__("An error occurred - the file: %s could not opened.", "event_espresso"),$path_to_file), __FILE__, __FUNCTION__, __LINE__ );
162 165
 			return false;
163 166
 		}
@@ -238,7 +241,7 @@  discard block
 block discarded – undo
238 241
 						$matches = array();
239 242
 						if($model_name == EE_CSV::metadata_header){
240 243
 							$headers[$i] = $column_name;
241
-						}else{
244
+						} else{
242 245
 							//now get the db table name from it (the part between square brackets)
243 246
 							$success = preg_match('~(.*)\[(.*)\]~', $column_name,$matches);
244 247
 							if (!$success){
@@ -248,7 +251,7 @@  discard block
 block discarded – undo
248 251
 							$headers[$i] = $matches[2];
249 252
 						}
250 253
 
251
-					}else{
254
+					} else{
252 255
 						// no column names means our final array will just use counters for keys
253 256
 						$model_entry[$headers[$i]] = $data[$i];
254 257
 						$headers[$i] = $i;
@@ -376,7 +379,7 @@  discard block
 block discarded – undo
376 379
 				echo $this->fputcsv2($filehandle, $data_row);
377 380
 			}
378 381
 			return true;
379
-		}else{
382
+		} else{
380 383
 			//no data TO write... so we can assume that's a success
381 384
 			return true;
382 385
 		}
@@ -443,7 +446,7 @@  discard block
 block discarded – undo
443 446
 
444 447
 			if( ! empty($model_instance_arrays) ){
445 448
 				$this->write_data_array_to_csv($filehandle, $model_instance_arrays);
446
-			}else{
449
+			} else{
447 450
 //				echo "no data to write... so just write the headers";
448 451
 				//so there's actually NO model objects for that model.
449 452
 				//probably still want to show the columns
Please login to merge, or discard this patch.
core/admin/EE_Admin_List_Table.core.php 1 patch
Spacing   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION') )
2
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
3 3
 	exit('NO direct script access allowed');
4 4
 
5 5
 
@@ -31,8 +31,8 @@  discard block
 block discarded – undo
31 31
  * ------------------------------------------------------------------------
32 32
  */
33 33
 
34
-if ( ! class_exists( 'WP_List_Table' )) {
35
-    require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
34
+if ( ! class_exists('WP_List_Table')) {
35
+    require_once(ABSPATH.'wp-admin/includes/class-wp-list-table.php');
36 36
 }
37 37
 
38 38
 abstract class EE_Admin_List_Table extends WP_List_Table {
@@ -243,16 +243,16 @@  discard block
 block discarded – undo
243 243
 	 * constructor
244 244
 	 * @param EE_Admin_Page object $admin_page we use this for obtaining everything we need in the list table.
245 245
 	 */
246
-	public function __construct( EE_Admin_Page $admin_page ) {
246
+	public function __construct(EE_Admin_Page $admin_page) {
247 247
 		$this->_admin_page = $admin_page;
248 248
 		$this->_req_data = $this->_admin_page->get_request_data();
249 249
 		$this->_view = $this->_admin_page->get_view();
250
-		$this->_views = empty( $this->_views ) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views;
250
+		$this->_views = empty($this->_views) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views;
251 251
 		$this->_current_page = $this->get_pagenum();
252
-		$this->_screen = $this->_admin_page->get_current_page() . '_' . $this->_admin_page->get_current_view();
253
-		$this->_yes_no = array(  __('No', 'event_espresso'), __('Yes', 'event_espresso'));
252
+		$this->_screen = $this->_admin_page->get_current_page().'_'.$this->_admin_page->get_current_view();
253
+		$this->_yes_no = array(__('No', 'event_espresso'), __('Yes', 'event_espresso'));
254 254
 
255
-		$this->_per_page = $this->get_items_per_page( $this->_screen . '_per_page', 10 );
255
+		$this->_per_page = $this->get_items_per_page($this->_screen.'_per_page', 10);
256 256
 
257 257
 		$this->_setup_data();
258 258
 		$this->_add_view_counts();
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 		$this->_set_properties();
263 263
 
264 264
 		//set primary column
265
-		add_filter( 'list_table_primary_column', array( $this, 'set_primary_column' ) );
265
+		add_filter('list_table_primary_column', array($this, 'set_primary_column'));
266 266
 
267 267
 		//set parent defaults
268 268
 		parent::__construct($this->_wp_list_args);
@@ -338,17 +338,17 @@  discard block
 block discarded – undo
338 338
 	 * @return html string
339 339
 	 */
340 340
 	protected function _get_hidden_fields() {
341
-		$action = isset( $this->_req_data['route'] ) ? $this->_req_data['route'] : '';
342
-		$action = empty( $action ) && isset( $this->_req_data['action'] ) ? $this->_req_data['action'] : $action;
341
+		$action = isset($this->_req_data['route']) ? $this->_req_data['route'] : '';
342
+		$action = empty($action) && isset($this->_req_data['action']) ? $this->_req_data['action'] : $action;
343 343
 		//if action is STILL empty, then we set it to default
344
-		$action = empty( $action ) ? 'default' : $action;
345
-		$field = '<input type="hidden" name="page" value="' . $this->_req_data['page'] . '" />' . "\n";
346
-		$field .= '<input type="hidden" name="route" value="'. $action .'" />' . "\n";/**/
347
-		$field .= '<input type="hidden" name="perpage" value="' . $this->_per_page . '" />' . "\n";
344
+		$action = empty($action) ? 'default' : $action;
345
+		$field = '<input type="hidden" name="page" value="'.$this->_req_data['page'].'" />'."\n";
346
+		$field .= '<input type="hidden" name="route" value="'.$action.'" />'."\n"; /**/
347
+		$field .= '<input type="hidden" name="perpage" value="'.$this->_per_page.'" />'."\n";
348 348
 
349 349
 		$bulk_actions = $this->_get_bulk_actions();
350
-		foreach ( $bulk_actions as $bulk_action => $label ) {
351
-			$field .= '<input type="hidden" name="' . $bulk_action . '_nonce" value="' . wp_create_nonce  ( $bulk_action . '_nonce' ) . '" />' . "\n";
350
+		foreach ($bulk_actions as $bulk_action => $label) {
351
+			$field .= '<input type="hidden" name="'.$bulk_action.'_nonce" value="'.wp_create_nonce($bulk_action.'_nonce').'" />'."\n";
352 352
 		}
353 353
 
354 354
 		return $field;
@@ -378,15 +378,15 @@  discard block
 block discarded – undo
378 378
 		 *
379 379
 		 * @var array
380 380
 		 */
381
-		$_sortable = apply_filters( "FHEE_manage_{$this->screen->id}_sortable_columns", $_sortable, $this->_screen );
381
+		$_sortable = apply_filters("FHEE_manage_{$this->screen->id}_sortable_columns", $_sortable, $this->_screen);
382 382
 
383 383
 		$sortable = array();
384
-		foreach ( $_sortable as $id => $data ) {
385
-			if ( empty( $data ) )
384
+		foreach ($_sortable as $id => $data) {
385
+			if (empty($data))
386 386
 				continue;
387 387
 
388 388
 			//fix for offset errors with WP_List_Table default get_columninfo()
389
-			if ( is_array($data) ) {
389
+			if (is_array($data)) {
390 390
 				$_data[0] = key($data);
391 391
 				$_data[1] = isset($data[1]) ? $data[1] : false;
392 392
 			} else {
@@ -395,14 +395,14 @@  discard block
 block discarded – undo
395 395
 
396 396
 			$data = (array) $data;
397 397
 
398
-			if ( !isset( $data[1] ) )
398
+			if ( ! isset($data[1]))
399 399
 				$_data[1] = false;
400 400
 
401 401
 
402 402
 			$sortable[$id] = $_data;
403 403
 		}
404 404
 		$primary = $this->get_primary_column_name();
405
-		$this->_column_headers = array( $columns, $hidden, $sortable, $primary );
405
+		$this->_column_headers = array($columns, $hidden, $sortable, $primary);
406 406
 	}
407 407
 
408 408
 
@@ -411,8 +411,8 @@  discard block
 block discarded – undo
411 411
 	 * @return string
412 412
 	 */
413 413
 	protected function get_primary_column_name() {
414
-		foreach( class_parents( $this ) as $parent ) {
415
-			if ( method_exists( $parent, 'get_primary_column_name' ) && $parent == 'WP_List_Table' ) {
414
+		foreach (class_parents($this) as $parent) {
415
+			if (method_exists($parent, 'get_primary_column_name') && $parent == 'WP_List_Table') {
416 416
 				return parent::get_primary_column_name();
417 417
 			}
418 418
 		}
@@ -424,10 +424,10 @@  discard block
 block discarded – undo
424 424
 	 * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
425 425
 	 * @return string
426 426
 	 */
427
-	protected function handle_row_actions( $item, $column_name, $primary ) {
428
-		foreach( class_parents( $this ) as $parent ) {
429
-			if ( method_exists( $parent, 'handle_row_actions' ) && $parent == 'WP_List_Table' ) {
430
-				return parent::handle_row_actions( $item, $column_name, $primary );
427
+	protected function handle_row_actions($item, $column_name, $primary) {
428
+		foreach (class_parents($this) as $parent) {
429
+			if (method_exists($parent, 'handle_row_actions') && $parent == 'WP_List_Table') {
430
+				return parent::handle_row_actions($item, $column_name, $primary);
431 431
 			}
432 432
 		}
433 433
 		return '';
@@ -445,11 +445,11 @@  discard block
 block discarded – undo
445 445
 	protected function _get_bulk_actions() {
446 446
 		$actions = array();
447 447
 		//the _views property should have the bulk_actions, so let's go through and extract them into a properly formatted array for the wp_list_table();
448
-		foreach ( $this->_views as $view => $args) {
449
-			if ( isset( $args['bulk_action']) && is_array($args['bulk_action']) && $this->_view == $view )
448
+		foreach ($this->_views as $view => $args) {
449
+			if (isset($args['bulk_action']) && is_array($args['bulk_action']) && $this->_view == $view)
450 450
 				//each bulk action will correspond with a admin page route, so we can check whatever the capability is for that page route and skip adding the bulk action if no access for the current logged in user.
451
-				foreach ( $args['bulk_action'] as $route =>$label ) {
452
-					if ( $this->_admin_page->check_user_access( $route, true ) ) {
451
+				foreach ($args['bulk_action'] as $route =>$label) {
452
+					if ($this->_admin_page->check_user_access($route, true)) {
453 453
 						$actions[$route] = $label;
454 454
 					}
455 455
 				}
@@ -467,18 +467,18 @@  discard block
 block discarded – undo
467 467
 	 */
468 468
 	private function _filters() {
469 469
 		$classname = get_class($this);
470
-		$filters = apply_filters( "FHEE__{$classname}__filters", (array) $this->_get_table_filters(), $this, $this->_screen );
470
+		$filters = apply_filters("FHEE__{$classname}__filters", (array) $this->_get_table_filters(), $this, $this->_screen);
471 471
 
472
-		if ( empty( $filters )) {
472
+		if (empty($filters)) {
473 473
 			return;
474 474
 		}
475
-		foreach ( $filters as $filter ) {
475
+		foreach ($filters as $filter) {
476 476
 			echo $filter;
477 477
 		}
478 478
 		//add filter button at end
479
-		echo '<input type="submit" class="button-secondary" value="' . __('Filter', 'event_espresso') . '" id="post-query-submit" />';
479
+		echo '<input type="submit" class="button-secondary" value="'.__('Filter', 'event_espresso').'" id="post-query-submit" />';
480 480
 		//add reset filters button at end
481
-		echo '<a class="button button-secondary"  href="' . $this->_admin_page->get_current_page_view_url() . '" style="display:inline-block">' . __('Reset Filters', 'event_espresso') . '</a>';
481
+		echo '<a class="button button-secondary"  href="'.$this->_admin_page->get_current_page_view_url().'" style="display:inline-block">'.__('Reset Filters', 'event_espresso').'</a>';
482 482
 	}
483 483
 
484 484
 
@@ -492,8 +492,8 @@  discard block
 block discarded – undo
492 492
 	 * @param string $column_name
493 493
 	 * @return string
494 494
 	 */
495
-	public function set_primary_column( $column_name ) {
496
-		return ! empty( $this->_primary_column ) ? $this->_primary_column : $column_name;
495
+	public function set_primary_column($column_name) {
496
+		return ! empty($this->_primary_column) ? $this->_primary_column : $column_name;
497 497
 	}
498 498
 
499 499
 
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
 			array(
513 513
 				'total_items' => $total_items,
514 514
 				'per_page' => $this->_per_page,
515
-				'total_pages' => ceil($total_items / $this->_per_page )
515
+				'total_pages' => ceil($total_items / $this->_per_page)
516 516
 			)
517 517
 		);
518 518
 	}
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
 	 *
529 529
 	 * @return string html content for the column
530 530
 	 */
531
-	public function column_default( $item, $column_name ) {
531
+	public function column_default($item, $column_name) {
532 532
 		/**
533 533
 		 * Dynamic hook allowing for adding additional column content in this list table.
534 534
 		 * Note that $this->screen->id is in the format
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
 		 * hook prefix ("event-espresso") will be different.
539 539
 		 *
540 540
 		 */
541
-		do_action( 'AHEE__EE_Admin_List_Table__column_' . $column_name . '__' . $this->screen->id, $item, $this->_screen );
541
+		do_action('AHEE__EE_Admin_List_Table__column_'.$column_name.'__'.$this->screen->id, $item, $this->_screen);
542 542
 	}
543 543
 
544 544
 
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
 		 *
555 555
 		 * @var array
556 556
 		 */
557
-		$columns = apply_filters( 'FHEE_manage_'.$this->screen->id.'_columns', $this->_columns, $this->_screen );
557
+		$columns = apply_filters('FHEE_manage_'.$this->screen->id.'_columns', $this->_columns, $this->_screen);
558 558
 		return $columns;
559 559
 	}
560 560
 
@@ -566,18 +566,18 @@  discard block
 block discarded – undo
566 566
 		$views = $this->get_views();
567 567
 		$assembled_views = '';
568 568
 
569
-		if ( empty( $views )) {
569
+		if (empty($views)) {
570 570
 			return;
571 571
 		}
572 572
 		echo "<ul class='subsubsub'>\n";
573
-		foreach ( $views as $view ) {
574
-			$count = isset($view['count'] ) && !empty($view['count']) ? absint( $view['count'] )  : 0;
575
-			if ( isset( $view['slug'] ) && isset( $view['class'] ) && isset( $view['url'] ) && isset( $view['label']) ) {
576
-				$assembled_views[ $view['slug'] ] = "\t<li class='" . $view['class'] . "'>" . '<a href="' . $view['url'] . '">' . $view['label'] . '</a> <span class="count">(' . $count . ')</span>';
573
+		foreach ($views as $view) {
574
+			$count = isset($view['count']) && ! empty($view['count']) ? absint($view['count']) : 0;
575
+			if (isset($view['slug']) && isset($view['class']) && isset($view['url']) && isset($view['label'])) {
576
+				$assembled_views[$view['slug']] = "\t<li class='".$view['class']."'>".'<a href="'.$view['url'].'">'.$view['label'].'</a> <span class="count">('.$count.')</span>';
577 577
 			}
578 578
 		}
579 579
 
580
-		echo is_array( $assembled_views) && ! empty( $assembled_views ) ? implode( " |</li>\n", $assembled_views ) . "</li>\n" : '';
580
+		echo is_array($assembled_views) && ! empty($assembled_views) ? implode(" |</li>\n", $assembled_views)."</li>\n" : '';
581 581
 		echo "</ul>";
582 582
 	}
583 583
 
@@ -590,10 +590,10 @@  discard block
 block discarded – undo
590 590
 	 *
591 591
 	 * @param object $item The current item
592 592
 	 */
593
-	public function single_row( $item ) {
594
-		$row_class = $this->_get_row_class( $item );
595
-		echo '<tr class="' . esc_attr( $row_class ) . '">';
596
-		$this->single_row_columns( $item );
593
+	public function single_row($item) {
594
+		$row_class = $this->_get_row_class($item);
595
+		echo '<tr class="'.esc_attr($row_class).'">';
596
+		$this->single_row_columns($item);
597 597
 		echo '</tr>';
598 598
 	}
599 599
 
@@ -604,13 +604,13 @@  discard block
 block discarded – undo
604 604
 	 * @param  object $item the current item
605 605
 	 * @return string
606 606
 	 */
607
-	protected function _get_row_class( $item ) {
607
+	protected function _get_row_class($item) {
608 608
 		static $row_class = '';
609
-		$row_class = ( $row_class == '' ? 'alternate' : '' );
609
+		$row_class = ($row_class == '' ? 'alternate' : '');
610 610
 
611 611
 		$new_row_class = $row_class;
612 612
 
613
-		if ( !empty($this->_ajax_sorting_callback) ) {
613
+		if ( ! empty($this->_ajax_sorting_callback)) {
614 614
 			$new_row_class .= ' rowsortable';
615 615
 		}
616 616
 
@@ -629,13 +629,13 @@  discard block
 block discarded – undo
629 629
 
630 630
 	public function get_hidden_columns() {
631 631
 		$user_id = get_current_user_id();
632
-		$has_default = get_user_option('default'. $this->screen->id . 'columnshidden', $user_id);
633
-		if ( empty( $has_default ) && !empty($this->_hidden_columns ) ) {
634
-			update_user_option($user_id, 'default'.$this->screen->id . 'columnshidden', TRUE);
635
-			update_user_option($user_id, 'manage' . $this->screen->id . 'columnshidden', $this->_hidden_columns, TRUE );
632
+		$has_default = get_user_option('default'.$this->screen->id.'columnshidden', $user_id);
633
+		if (empty($has_default) && ! empty($this->_hidden_columns)) {
634
+			update_user_option($user_id, 'default'.$this->screen->id.'columnshidden', TRUE);
635
+			update_user_option($user_id, 'manage'.$this->screen->id.'columnshidden', $this->_hidden_columns, TRUE);
636 636
 		}
637
-		$ref = 'manage' . $this->screen->id . 'columnshidden';
638
-		$saved_columns = (array) get_user_option( $ref, $user_id );
637
+		$ref = 'manage'.$this->screen->id.'columnshidden';
638
+		$saved_columns = (array) get_user_option($ref, $user_id);
639 639
 		return $saved_columns;
640 640
 	}
641 641
 
@@ -650,47 +650,47 @@  discard block
 block discarded – undo
650 650
 	 *
651 651
 	 * @param object $item The current item
652 652
 	 */
653
-	public function single_row_columns( $item ) {
654
-		list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
653
+	public function single_row_columns($item) {
654
+		list($columns, $hidden, $sortable, $primary) = $this->get_column_info();
655 655
 
656 656
 		global $wp_version;
657
-		$use_hidden_class = version_compare( $wp_version, '4.3-RC', '>=' );
657
+		$use_hidden_class = version_compare($wp_version, '4.3-RC', '>=');
658 658
 
659
-		foreach ( $columns as $column_name => $column_display_name ) {
659
+		foreach ($columns as $column_name => $column_display_name) {
660 660
 
661 661
 			/**
662 662
 			 * With WordPress version 4.3.RC+ WordPress started using the hidden css class to control whether columns are
663 663
 			 * hidden or not instead of using "display:none;".  This bit of code provides backward compat.
664 664
 			 */
665
-			$hidden_class = $use_hidden_class && in_array( $column_name, $hidden ) ? ' hidden' : '';
666
-			$style = ! $use_hidden_class && in_array( $column_name, $hidden ) ? ' style="display:none;"' : '';
665
+			$hidden_class = $use_hidden_class && in_array($column_name, $hidden) ? ' hidden' : '';
666
+			$style = ! $use_hidden_class && in_array($column_name, $hidden) ? ' style="display:none;"' : '';
667 667
 
668
-			$classes = $column_name . ' column-' . $column_name.$hidden_class;
669
-			if ( $primary == $column_name ) {
668
+			$classes = $column_name.' column-'.$column_name.$hidden_class;
669
+			if ($primary == $column_name) {
670 670
 				$classes .= ' has-row-actions column-primary';
671 671
 			}
672 672
 
673
-			$data = ' data-colname="' . wp_strip_all_tags( $column_display_name ) . '"';
673
+			$data = ' data-colname="'.wp_strip_all_tags($column_display_name).'"';
674 674
 
675 675
 			$class = "class='$classes'";
676 676
 
677 677
 			$attributes = "$class$style$data";
678 678
 
679
-			if ( 'cb' === $column_name ) {
679
+			if ('cb' === $column_name) {
680 680
 				echo '<th scope="row" class="check-column">';
681
-				echo apply_filters( 'FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content', $this->column_cb( $item ), $item, $this );
681
+				echo apply_filters('FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content', $this->column_cb($item), $item, $this);
682 682
 				echo '</th>';
683 683
 			}
684
-			elseif ( method_exists( $this, 'column_' . $column_name ) ) {
684
+			elseif (method_exists($this, 'column_'.$column_name)) {
685 685
 				echo "<td $attributes>";
686
-				echo apply_filters( 'FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content', call_user_func( array( $this, 'column_' . $column_name ), $item ), $item, $this );
687
-				echo $this->handle_row_actions( $item, $column_name, $primary );
686
+				echo apply_filters('FHEE__EE_Admin_List_Table__single_row_columns__column_'.$column_name.'__column_content', call_user_func(array($this, 'column_'.$column_name), $item), $item, $this);
687
+				echo $this->handle_row_actions($item, $column_name, $primary);
688 688
 				echo "</td>";
689 689
 			}
690 690
 			else {
691 691
 				echo "<td $attributes>";
692
-				echo apply_filters( 'FHEE__EE_Admin_List_Table__single_row_columns__column_default__column_content', $this->column_default( $item, $column_name ), $item, $column_name, $this );
693
-				echo $this->handle_row_actions( $item, $column_name, $primary );
692
+				echo apply_filters('FHEE__EE_Admin_List_Table__single_row_columns__column_default__column_content', $this->column_default($item, $column_name), $item, $column_name, $this);
693
+				echo $this->handle_row_actions($item, $column_name, $primary);
694 694
 				echo "</td>";
695 695
 			}
696 696
 		}
@@ -698,19 +698,19 @@  discard block
 block discarded – undo
698 698
 
699 699
 
700 700
 
701
-	public function extra_tablenav( $which ) {
702
-		if ( $which == 'top' ) {
701
+	public function extra_tablenav($which) {
702
+		if ($which == 'top') {
703 703
 			$this->_filters();
704 704
 			echo $this->_get_hidden_fields();
705 705
 			echo '<br class="clear">';
706
-		}else{
706
+		} else {
707 707
 			echo '<div class="list-table-bottom-buttons alignleft actions">';
708
-			foreach($this->_bottom_buttons as $type => $action){
709
-				$route = isset( $action['route'] ) ? $action['route'] : '';
710
-				$extra_request = isset( $action['extra_request'] ) ? $action['extra_request'] : '';
708
+			foreach ($this->_bottom_buttons as $type => $action) {
709
+				$route = isset($action['route']) ? $action['route'] : '';
710
+				$extra_request = isset($action['extra_request']) ? $action['extra_request'] : '';
711 711
 				echo $this->_admin_page->get_action_link_or_button($route, $type, $extra_request);
712 712
 			}
713
-			do_action( 'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', $this, $this->_screen );
713
+			do_action('AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', $this, $this->_screen);
714 714
 			echo '</div>';
715 715
 		}
716 716
 		//echo $this->_entries_per_page_dropdown;
@@ -760,13 +760,13 @@  discard block
 block discarded – undo
760 760
 	 *
761 761
 	 * @return string The assembled action elements container.
762 762
 	 */
763
-	protected function _action_string( $action_items, $item, $action_container = 'ul', $action_class = '', $action_id = '' ) {
763
+	protected function _action_string($action_items, $item, $action_container = 'ul', $action_class = '', $action_id = '') {
764 764
 		$content = '';
765
-		$action_class = ! empty( $action_class ) ? ' class="' . $action_class . '"' : '';
766
-		$action_id = ! empty( $action_id ) ? ' id="' . $action_id . '"' : '';
767
-		$content .= ! empty( $action_container ) ? '<' . $action_container . $action_class . $action_id . '>' : '';
768
-		$content .= apply_filters( 'FHEE__EE_Admin_List_Table___action_string__action_items', $action_items, $item, $this );
769
-		$content .= ! empty( $container ) ? '</' . $container . '>' : '';
765
+		$action_class = ! empty($action_class) ? ' class="'.$action_class.'"' : '';
766
+		$action_id = ! empty($action_id) ? ' id="'.$action_id.'"' : '';
767
+		$content .= ! empty($action_container) ? '<'.$action_container.$action_class.$action_id.'>' : '';
768
+		$content .= apply_filters('FHEE__EE_Admin_List_Table___action_string__action_items', $action_items, $item, $this);
769
+		$content .= ! empty($container) ? '</'.$container.'>' : '';
770 770
 		return $content;
771 771
 	}
772 772
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Status.model.php 2 patches
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	public function localized_status(  $statuses, $plural = FALSE, $schema = 'upper' ) {
84 84
 		//note these are all in lower case because ucwords() on upper case will NOT convert.
85 85
 		$translation_array = array(
86
-	     	EEM_Registration::status_id_pending_payment => array(
86
+		 	EEM_Registration::status_id_pending_payment => array(
87 87
 				__('pending payment', 'event_espresso'), //singular
88 88
 				__('pending payments', 'event_espresso') //plural
89 89
 			),
@@ -232,37 +232,37 @@  discard block
 block discarded – undo
232 232
 	  			__('trashed', 'event_espresso'),
233 233
 	  			__('trashed', 'event_espresso')
234 234
   			),
235
-	    );
235
+		);
236 236
 
237 237
 		$translation_array = apply_filters( 'FHEE__EEM_Status__localized_status__translation_array', $translation_array );
238 238
 
239 239
 		if ( !is_array($statuses) )
240 240
 			throw new EE_Error( __('The incoming statuses argument must be an array with keys as the $status_id and values as the $status_code', 'event_espresso') );
241 241
 
242
-	    $translation = array();
242
+		$translation = array();
243 243
 
244
-	    foreach ( $statuses as $id => $code ) {
245
-	    	if ( isset( $translation_array[$id] ) ) {
246
-	    		$translation[$id] = $plural ? $translation_array[$id][1] : $translation_array[$id][0];
247
-	    	} else {
248
-	    		$translation[$id] = $code;
249
-	    	}
244
+		foreach ( $statuses as $id => $code ) {
245
+			if ( isset( $translation_array[$id] ) ) {
246
+				$translation[$id] = $plural ? $translation_array[$id][1] : $translation_array[$id][0];
247
+			} else {
248
+				$translation[$id] = $code;
249
+			}
250 250
 
251
-	    	//schema
252
-	    	switch ( $schema ) {
253
-	    		case 'lower' :
254
-	    			$translation[$id] = strtolower( $translation[$id] ); //even though these start in lower case, this will catch any statuses added via filter.
255
-	    			break;
256
-	    		case 'sentence' :
257
-	    			$translation[$id] = ucwords( $translation[$id] );
258
-	    			break;
259
-	    		case 'upper' :
260
-	    			$translation[$id] = strtoupper( $translation[$id] );
261
-	    			break;
262
-	    	}
263
-	    }
251
+			//schema
252
+			switch ( $schema ) {
253
+				case 'lower' :
254
+					$translation[$id] = strtolower( $translation[$id] ); //even though these start in lower case, this will catch any statuses added via filter.
255
+					break;
256
+				case 'sentence' :
257
+					$translation[$id] = ucwords( $translation[$id] );
258
+					break;
259
+				case 'upper' :
260
+					$translation[$id] = strtoupper( $translation[$id] );
261
+					break;
262
+			}
263
+		}
264 264
 
265
-	    return $translation;
265
+		return $translation;
266 266
 	}
267 267
 
268 268
 
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  *
14 14
  * ------------------------------------------------------------------------
15 15
  */
16
-require_once ( EE_MODELS . 'EEM_Base.model.php' );
16
+require_once (EE_MODELS.'EEM_Base.model.php');
17 17
 /**
18 18
  *
19 19
  * Class EEM_Status
@@ -32,32 +32,32 @@  discard block
 block discarded – undo
32 32
 	/**
33 33
 	 * @return EEM_Status
34 34
 	 */
35
-	protected function __construct( $timezone = NULL ) {
36
-		$this->singular_item = __('Status','event_espresso');
37
-		$this->plural_item = __('Stati','event_espresso');
35
+	protected function __construct($timezone = NULL) {
36
+		$this->singular_item = __('Status', 'event_espresso');
37
+		$this->plural_item = __('Stati', 'event_espresso');
38 38
 		$this->_tables = array(
39 39
 			'Status'=> new EE_Primary_Table('esp_status', 'STS_ID')
40 40
 		);
41 41
 		$this->_fields = array(
42 42
 			'Status'=>array(
43
-				'STS_ID'=> new EE_Primary_Key_String_Field('STS_ID', __('Status ID','event_espresso')),
44
-				'STS_code'=>new EE_Plain_Text_Field('STS_code',__('Status Code','event_espresso'),false, ''),
43
+				'STS_ID'=> new EE_Primary_Key_String_Field('STS_ID', __('Status ID', 'event_espresso')),
44
+				'STS_code'=>new EE_Plain_Text_Field('STS_code', __('Status Code', 'event_espresso'), false, ''),
45 45
 				'STS_type'=>new EE_Enum_Text_Field(
46 46
 					'STS_type',
47 47
 					__("Type", "event_espresso"),
48 48
 					false,
49 49
 					'event',
50 50
 					array(
51
-						'event'=> __("Event", "event_espresso"),//deprecated
51
+						'event'=> __("Event", "event_espresso"), //deprecated
52 52
 						'registration'=>  __("Registration", "event_espresso"),
53 53
 						'transaction'=>  __("Transaction", "event_espresso"),
54 54
 						'payment'=>  __("Payment", "event_espresso"),
55 55
 						'email'=>  __("Email", "event_espresso")
56 56
 					)
57 57
 				),
58
-				'STS_can_edit'=>new EE_Boolean_Field('STS_can_edit', __('Editable?','event_espresso'), false),
58
+				'STS_can_edit'=>new EE_Boolean_Field('STS_can_edit', __('Editable?', 'event_espresso'), false),
59 59
 				'STS_desc'=>new EE_Simple_HTML_Field('STS_desc', __("Description", "event_espresso"), false, ''),
60
-				'STS_open'=>new EE_Boolean_Field('STS_open', __("Open?", "event_espresso"), false,false)
60
+				'STS_open'=>new EE_Boolean_Field('STS_open', __("Open?", "event_espresso"), false, false)
61 61
 			));
62 62
 		$this->_model_relations = array(
63 63
 			'Registration'=>new EE_Has_Many_Relation(),
@@ -65,9 +65,9 @@  discard block
 block discarded – undo
65 65
 			'Payment'=>new EE_Has_Many_Relation()
66 66
 		);
67 67
 		//this model is generally available for reading
68
-		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
68
+		$this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
69 69
 
70
-		parent::__construct( $timezone );
70
+		parent::__construct($timezone);
71 71
 	}
72 72
 
73 73
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	 * @throws EE_Error
81 81
 	 * @return array             an array of translated strings for the incoming status id.
82 82
 	 */
83
-	public function localized_status(  $statuses, $plural = FALSE, $schema = 'upper' ) {
83
+	public function localized_status($statuses, $plural = FALSE, $schema = 'upper') {
84 84
 		//note these are all in lower case because ucwords() on upper case will NOT convert.
85 85
 		$translation_array = array(
86 86
 	     	EEM_Registration::status_id_pending_payment => array(
@@ -234,30 +234,30 @@  discard block
 block discarded – undo
234 234
   			),
235 235
 	    );
236 236
 
237
-		$translation_array = apply_filters( 'FHEE__EEM_Status__localized_status__translation_array', $translation_array );
237
+		$translation_array = apply_filters('FHEE__EEM_Status__localized_status__translation_array', $translation_array);
238 238
 
239
-		if ( !is_array($statuses) )
240
-			throw new EE_Error( __('The incoming statuses argument must be an array with keys as the $status_id and values as the $status_code', 'event_espresso') );
239
+		if ( ! is_array($statuses))
240
+			throw new EE_Error(__('The incoming statuses argument must be an array with keys as the $status_id and values as the $status_code', 'event_espresso'));
241 241
 
242 242
 	    $translation = array();
243 243
 
244
-	    foreach ( $statuses as $id => $code ) {
245
-	    	if ( isset( $translation_array[$id] ) ) {
244
+	    foreach ($statuses as $id => $code) {
245
+	    	if (isset($translation_array[$id])) {
246 246
 	    		$translation[$id] = $plural ? $translation_array[$id][1] : $translation_array[$id][0];
247 247
 	    	} else {
248 248
 	    		$translation[$id] = $code;
249 249
 	    	}
250 250
 
251 251
 	    	//schema
252
-	    	switch ( $schema ) {
252
+	    	switch ($schema) {
253 253
 	    		case 'lower' :
254
-	    			$translation[$id] = strtolower( $translation[$id] ); //even though these start in lower case, this will catch any statuses added via filter.
254
+	    			$translation[$id] = strtolower($translation[$id]); //even though these start in lower case, this will catch any statuses added via filter.
255 255
 	    			break;
256 256
 	    		case 'sentence' :
257
-	    			$translation[$id] = ucwords( $translation[$id] );
257
+	    			$translation[$id] = ucwords($translation[$id]);
258 258
 	    			break;
259 259
 	    		case 'upper' :
260
-	    			$translation[$id] = strtoupper( $translation[$id] );
260
+	    			$translation[$id] = strtoupper($translation[$id]);
261 261
 	    			break;
262 262
 	    	}
263 263
 	    }
Please login to merge, or discard this patch.
caffeinated/payment_methods/Aim/EEG_Aim.gateway.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION'))
3
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
4 4
 	exit('No direct script access allowed');
5 5
 
6 6
 /**
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  *
26 26
  * ------------------------------------------------------------------------
27 27
  */
28
-class EEG_Aim extends EE_Onsite_Gateway{
28
+class EEG_Aim extends EE_Onsite_Gateway {
29 29
 	protected $_login_id;
30 30
 	protected $_transaction_key;
31 31
 	protected $_currencies_supported = array(
@@ -98,17 +98,17 @@  discard block
 block discarded – undo
98 98
 			$primary_registrant = $transaction->primary_registration();
99 99
 			//if we're are charging for the full amount, show the normal line items
100 100
 			//and the itemized total adds up properly
101
-			if( $this->_can_easily_itemize_transaction_for( $payment ) ){
101
+			if ($this->_can_easily_itemize_transaction_for($payment)) {
102 102
 				$total_line_item = $transaction->total_line_item();
103 103
 				foreach ($total_line_item->get_items() as $line_item) {
104 104
 					$this->addLineItem($item_num++, $line_item->name(), $line_item->desc(), $line_item->quantity(), $line_item->unit_price(), 'N');
105 105
 					$order_description .= $line_item->desc().', ';
106 106
 				}
107
-				foreach($total_line_item->tax_descendants() as $tax_line_item){
107
+				foreach ($total_line_item->tax_descendants() as $tax_line_item) {
108 108
 					$this->addLineItem($item_num++, $tax_line_item->name(), $tax_line_item->desc(), 1, $tax_line_item->total(), 'N');
109 109
 				}
110
-			}else{//partial payment
111
-				$order_description = sprintf(__("Payment of %s for %s", "event_espresso"),$payment->amount(),$primary_registrant->reg_code());
110
+			} else {//partial payment
111
+				$order_description = sprintf(__("Payment of %s for %s", "event_espresso"), $payment->amount(), $primary_registrant->reg_code());
112 112
 			}
113 113
 
114 114
 
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 
117 117
 			//start transaction
118 118
 			$this->setField('amount', $this->format_currency($payment->amount()));
119
-			$this->setField('description',substr(rtrim($order_description, ', '), 0, 255));
119
+			$this->setField('description', substr(rtrim($order_description, ', '), 0, 255));
120 120
 			$this->setField('card_num', $billing_info['credit_card']);
121 121
 			$this->setField('exp_date', $billing_info['exp_month'].$billing_info['exp_year']);
122 122
 			$this->setField('card_code', $billing_info['cvv']);
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
 			$this->setField('company', $billing_info['company']);
127 127
 			$this->setField('address', $billing_info['address'].' '.$billing_info['address2']);
128 128
 			$this->setField('city', $billing_info['city']);
129
-			$this->setField('state', $billing_info['state'] );
130
-			$this->setField('country', $billing_info['country'] );
129
+			$this->setField('state', $billing_info['state']);
130
+			$this->setField('country', $billing_info['country']);
131 131
 			$this->setField('zip', $billing_info['zip']);
132 132
 			$this->setField('fax', $billing_info['fax']);
133 133
 			$this->setField('cust_id', $primary_registrant->ID());
@@ -135,9 +135,9 @@  discard block
 block discarded – undo
135 135
 			//invoice_num would be nice to have itbe unique per SPCO page-load, taht way if users
136 136
 			//press back, they don't submit a duplicate. However, we may be keepin gthe user on teh same spco page
137 137
 			//in which case, we need to generate teh invoice num per request right here...
138
-			$this->setField('invoice_num', wp_generate_password(12,false));//$billing_info['_reg-page-billing-invoice-'.$this->_gateway_name]['value']);
138
+			$this->setField('invoice_num', wp_generate_password(12, false)); //$billing_info['_reg-page-billing-invoice-'.$this->_gateway_name]['value']);
139 139
 			//tell AIM that any duplicates sent in the next 5 minutes are to be ignored
140
-            $this->setField('duplicate_window', 5 * MINUTE_IN_SECONDS );
140
+            $this->setField('duplicate_window', 5 * MINUTE_IN_SECONDS);
141 141
 
142 142
 
143 143
 			if ($this->_test_transactions) {
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 			//Capture response
148 148
 			$this->type = "AUTH_CAPTURE";
149 149
 			$response = $this->_sendRequest($payment);
150
-			if (!empty($response)){
150
+			if ( ! empty($response)) {
151 151
 				if ($this->_debug_mode) {
152 152
 					$txn_id = $response->invoice_number;
153 153
 				} else {
@@ -156,15 +156,15 @@  discard block
 block discarded – undo
156 156
 				$payment_status = $response->approved ? $this->_pay_model->approved_status() : $this->_pay_model->declined_status();
157 157
 				$payment->set_status($payment_status);
158 158
 				//make sure we interpret the AMT as a float, not an international string (where periods are thousand seperators)
159
-				$payment->set_amount( floatval( $response->amount ) );
160
-				$payment->set_gateway_response(sprintf("%s (code: %s)",$response->response_reason_text,$response->response_reason_code));
161
-				$payment->set_txn_id_chq_nmbr( $txn_id );
159
+				$payment->set_amount(floatval($response->amount));
160
+				$payment->set_gateway_response(sprintf("%s (code: %s)", $response->response_reason_text, $response->response_reason_code));
161
+				$payment->set_txn_id_chq_nmbr($txn_id);
162 162
 				$payment->set_extra_accntng($primary_registrant->reg_code());
163
-				$payment->set_details(print_r($response,true));
163
+				$payment->set_details(print_r($response, true));
164 164
 			} else {
165 165
 				$payment->set_status($this->_pay_model->failed_status());
166 166
 				$payment->set_gateway_response(__("There was no response from Authorize.net", 'event_espresso'));
167
-				$payment->set_details(print_r($response,true));
167
+				$payment->set_details(print_r($response, true));
168 168
 			}
169 169
 		return $payment;
170 170
 	}
@@ -215,22 +215,22 @@  discard block
 block discarded – undo
215 215
 		$this->_x_post_fields['tran_key'] = $this->_transaction_key;
216 216
 		$x_keys = array();
217 217
 		foreach ($this->_x_post_fields as $key => $value) {
218
-			$x_keys[] = "x_$key=" . urlencode($value);
218
+			$x_keys[] = "x_$key=".urlencode($value);
219 219
 		}
220 220
 		// Add line items
221 221
 		foreach ($this->_additional_line_items as $key => $value) {
222
-			$x_keys[] =  "x_line_item=" . urlencode($value);
222
+			$x_keys[] = "x_line_item=".urlencode($value);
223 223
 		}
224 224
 		$this->_log_clean_request($x_keys, $payment);
225 225
 		$post_url = ($this->_debug_mode ? self::SANDBOX_URL : self::LIVE_URL);
226 226
 		$curl_request = curl_init($post_url);
227
-		curl_setopt($curl_request, CURLOPT_POSTFIELDS, implode("&",$x_keys));
227
+		curl_setopt($curl_request, CURLOPT_POSTFIELDS, implode("&", $x_keys));
228 228
 		curl_setopt($curl_request, CURLOPT_HEADER, 0);
229 229
 		curl_setopt($curl_request, CURLOPT_TIMEOUT, 45);
230 230
 		curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1);
231 231
 		curl_setopt($curl_request, CURLOPT_SSL_VERIFYHOST, 2);
232 232
 		if ($this->VERIFY_PEER) {
233
-			curl_setopt($curl_request, CURLOPT_CAINFO, dirname(dirname(__FILE__)) . '/ssl/cert.pem');
233
+			curl_setopt($curl_request, CURLOPT_CAINFO, dirname(dirname(__FILE__)).'/ssl/cert.pem');
234 234
 		} else {
235 235
 			curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, false);
236 236
 		}
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 		$response = curl_exec($curl_request);
243 243
 
244 244
 		curl_close($curl_request);
245
-		$response_obj =  new EE_AuthorizeNetAIM_Response($response);
245
+		$response_obj = new EE_AuthorizeNetAIM_Response($response);
246 246
 
247 247
 		return $this->_log_and_clean_response($response_obj, $payment);
248 248
 	}
@@ -251,18 +251,18 @@  discard block
 block discarded – undo
251 251
 	 * @param array $request_array
252 252
 	 * @param EEI_Payment $payment
253 253
 	 */
254
-	private function _log_clean_request($request_array,$payment){
255
-		$keys_to_filter_out = array( 'x_card_num', 'x_card_code', 'x_exp_date' );
256
-		foreach($request_array as $index => $keyvaltogether ) {
257
-			foreach( $keys_to_filter_out as $key ) {
258
-				if( strpos( $keyvaltogether, $key ) === 0 ){
254
+	private function _log_clean_request($request_array, $payment) {
255
+		$keys_to_filter_out = array('x_card_num', 'x_card_code', 'x_exp_date');
256
+		foreach ($request_array as $index => $keyvaltogether) {
257
+			foreach ($keys_to_filter_out as $key) {
258
+				if (strpos($keyvaltogether, $key) === 0) {
259 259
 					//found it at the first character
260 260
 					//so its one of them
261
-					unset( $request_array[ $index ] );
261
+					unset($request_array[$index]);
262 262
 				}
263 263
 			}
264 264
 		}
265
-		$this->log(array('AIM Request sent:'=>$request_array),$payment);
265
+		$this->log(array('AIM Request sent:'=>$request_array), $payment);
266 266
 	}
267 267
 
268 268
 	/**
@@ -270,9 +270,9 @@  discard block
 block discarded – undo
270 270
 	 * @param EE_AuthorizeNetAIM_Response $response_obj
271 271
 	 * @param EE_Payment $payment
272 272
 	 */
273
-	private function _log_and_clean_response($response_obj,$payment){
273
+	private function _log_and_clean_response($response_obj, $payment) {
274 274
 		$response_obj->account_number = '';
275
-		$this->log(array('AIM Response received:'=>$response_obj),$payment);
275
+		$this->log(array('AIM Response received:'=>$response_obj), $payment);
276 276
 		return $response_obj;
277 277
 	}
278 278
 
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 			// Split Array
369 369
 			$this->response = $response;
370 370
 			if ($encap_char) {
371
-				$this->_response_array = explode($encap_char . $delimiter . $encap_char, substr($response, 1, -1));
371
+				$this->_response_array = explode($encap_char.$delimiter.$encap_char, substr($response, 1, -1));
372 372
 			} else {
373 373
 				$this->_response_array = explode($delimiter, $response);
374 374
 			}
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
 			$this->held = ($this->response_code == self::HELD);
439 439
 
440 440
 			if ($this->error || $this->declined || $this->held) {
441
-				$this->error_message = '<p><strong class="credit_card_failure">Attention: your transaction was declined for the following reason(s):</strong><br />' . $this->response_reason_text . '<br /><span class="response_code">Response Code: ' . $this->response_code . '<br /></span><span class="response_subcode">Response Subcode: ' . $this->response_subcode . '</span></p><p>To try again, <a href="#payment_options">please click here</a>.</p> ';
441
+				$this->error_message = '<p><strong class="credit_card_failure">Attention: your transaction was declined for the following reason(s):</strong><br />'.$this->response_reason_text.'<br /><span class="response_code">Response Code: '.$this->response_code.'<br /></span><span class="response_subcode">Response Subcode: '.$this->response_subcode.'</span></p><p>To try again, <a href="#payment_options">please click here</a>.</p> ';
442 442
 
443 443
 
444 444
 				/* $this->error_message = "AuthorizeNet Error:
Please login to merge, or discard this patch.
core/db_models/EEM_Event.model.php 1 patch
Spacing   +161 added lines, -161 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
2
-require_once( EE_MODELS . 'EEM_CPT_Base.model.php');
2
+require_once(EE_MODELS.'EEM_CPT_Base.model.php');
3 3
 /**
4 4
  *
5 5
  * EEM_Event Model
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  * @author				Michael Nelson, Brent Christensen
12 12
  *
13 13
  */
14
-class EEM_Event  extends EEM_CPT_Base{
14
+class EEM_Event  extends EEM_CPT_Base {
15 15
 
16 16
 	/**
17 17
 	 * constant used by status(), indicating that no more tickets can be purchased for any of the datetimes for the event
@@ -51,15 +51,15 @@  discard block
 block discarded – undo
51 51
 	 * @param string $timezone
52 52
 	 * @return EEM_Event
53 53
 	 */
54
-	public static function instance( $timezone = NULL ){
54
+	public static function instance($timezone = NULL) {
55 55
 
56 56
 		// check if instance of EEM_Event already exists
57
-		if ( ! self::$_instance instanceof EEM_Event ) {
57
+		if ( ! self::$_instance instanceof EEM_Event) {
58 58
 			// instantiate Espresso_model
59
-			self::$_instance = new self( $timezone );
59
+			self::$_instance = new self($timezone);
60 60
 		}
61 61
 		//we might have a timezone set, let set_timezone decide what to do with it
62
-		self::$_instance->set_timezone( $timezone );
62
+		self::$_instance->set_timezone($timezone);
63 63
 		// EEM_Event object
64 64
 		return self::$_instance;
65 65
 	}
@@ -70,12 +70,12 @@  discard block
 block discarded – undo
70 70
 	 * @param string $timezone
71 71
 	 * @return EEM_Event
72 72
 	 */
73
-	protected function __construct($timezone = null){
73
+	protected function __construct($timezone = null) {
74 74
 
75
-		EE_Registry::instance()->load_model( 'Registration' );
75
+		EE_Registry::instance()->load_model('Registration');
76 76
 
77
-		$this->singular_item = __('Event','event_espresso');
78
-		$this->plural_item = __('Events','event_espresso');
77
+		$this->singular_item = __('Event', 'event_espresso');
78
+		$this->plural_item = __('Events', 'event_espresso');
79 79
 
80 80
 		// to remove Cancelled events from the frontend, copy the following filter to your functions.php file
81 81
 		// add_filter( 'AFEE__EEM_Event__construct___custom_stati__cancelled__Public', '__return_false' );
@@ -89,57 +89,57 @@  discard block
 block discarded – undo
89 89
 			array(
90 90
 				EEM_Event::cancelled => array(
91 91
 					'label' => __('Cancelled', 'event_espresso'),
92
-					'public' => apply_filters( 'AFEE__EEM_Event__construct___custom_stati__cancelled__Public', TRUE )
92
+					'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__cancelled__Public', TRUE)
93 93
 				),
94 94
 				EEM_Event::postponed => array(
95 95
 					'label' => __('Postponed', 'event_espresso'),
96
-					'public' => apply_filters( 'AFEE__EEM_Event__construct___custom_stati__postponed__Public', TRUE )
96
+					'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__postponed__Public', TRUE)
97 97
 				),
98 98
 				EEM_Event::sold_out => array(
99 99
 					'label' => __('Sold Out', 'event_espresso'),
100
-					'public' => apply_filters( 'AFEE__EEM_Event__construct___custom_stati__sold_out__Public', TRUE )
100
+					'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__sold_out__Public', TRUE)
101 101
 				)
102 102
 			)
103 103
 		);
104 104
 
105
-		self::$_default_reg_status = empty( self::$_default_reg_status ) ? EEM_Registration::status_id_pending_payment : self::$_default_reg_status;
105
+		self::$_default_reg_status = empty(self::$_default_reg_status) ? EEM_Registration::status_id_pending_payment : self::$_default_reg_status;
106 106
 
107 107
 		$this->_tables = array(
108
-			'Event_CPT'=>new EE_Primary_Table( 'posts','ID' ),
109
-			'Event_Meta'=> new EE_Secondary_Table( 'esp_event_meta', 'EVTM_ID', 'EVT_ID' )
108
+			'Event_CPT'=>new EE_Primary_Table('posts', 'ID'),
109
+			'Event_Meta'=> new EE_Secondary_Table('esp_event_meta', 'EVTM_ID', 'EVT_ID')
110 110
 		);
111 111
 
112 112
 		$this->_fields = array(
113 113
 			'Event_CPT'=>array(
114
-				'EVT_ID'=>new EE_Primary_Key_Int_Field( 'ID', __( 'Post ID for Event','event_espresso' )),
115
-				'EVT_name'=>new EE_Plain_Text_Field( 'post_title', __( 'Event Name','event_espresso' ), FALSE, '' ),
116
-				'EVT_desc'=>new EE_Post_Content_Field( 'post_content', __( 'Event Description', 'event_espresso' ), FALSE, '' ),
117
-				'EVT_slug'=>new EE_Slug_Field( 'post_name', __( 'Event Slug', 'event_espresso' ), FALSE, '' ),
118
-				'EVT_created'=>new EE_Datetime_Field( 'post_date', __( 'Date/Time Event Created', 'event_espresso' ), FALSE, time()),
119
-				'EVT_short_desc'=>new EE_Simple_HTML_Field( 'post_excerpt', __( 'Event Short Description', 'event_espresso' ), FALSE,'' ),
120
-				'EVT_modified'=>new EE_Datetime_Field( 'post_modified', __( 'Date/Time Event Modified', 'event_espresso' ), FALSE, time()),
121
-				'EVT_wp_user'=>new EE_WP_User_Field( 'post_author', __( 'Event Creator ID', 'event_espresso'), FALSE),
122
-				'parent'=>new EE_Integer_Field( 'post_parent', __( 'Event Parent ID', 'event_espresso' ), FALSE, 0 ),
123
-				'EVT_order'=>new EE_Integer_Field( 'menu_order', __( 'Event Menu Order', 'event_espresso' ), FALSE, 1 ),
124
-				'post_type'=>new EE_WP_Post_Type_Field('espresso_events'),// EE_Plain_Text_Field( 'post_type', __( 'Event Post Type', 'event_espresso' ), FALSE, 'espresso_events' ),
125
-				'status' => new EE_WP_Post_Status_Field( 'post_status', __( 'Event Status', 'event_espresso' ), FALSE, 'draft', $this->_custom_stati )
114
+				'EVT_ID'=>new EE_Primary_Key_Int_Field('ID', __('Post ID for Event', 'event_espresso')),
115
+				'EVT_name'=>new EE_Plain_Text_Field('post_title', __('Event Name', 'event_espresso'), FALSE, ''),
116
+				'EVT_desc'=>new EE_Post_Content_Field('post_content', __('Event Description', 'event_espresso'), FALSE, ''),
117
+				'EVT_slug'=>new EE_Slug_Field('post_name', __('Event Slug', 'event_espresso'), FALSE, ''),
118
+				'EVT_created'=>new EE_Datetime_Field('post_date', __('Date/Time Event Created', 'event_espresso'), FALSE, time()),
119
+				'EVT_short_desc'=>new EE_Simple_HTML_Field('post_excerpt', __('Event Short Description', 'event_espresso'), FALSE, ''),
120
+				'EVT_modified'=>new EE_Datetime_Field('post_modified', __('Date/Time Event Modified', 'event_espresso'), FALSE, time()),
121
+				'EVT_wp_user'=>new EE_WP_User_Field('post_author', __('Event Creator ID', 'event_espresso'), FALSE),
122
+				'parent'=>new EE_Integer_Field('post_parent', __('Event Parent ID', 'event_espresso'), FALSE, 0),
123
+				'EVT_order'=>new EE_Integer_Field('menu_order', __('Event Menu Order', 'event_espresso'), FALSE, 1),
124
+				'post_type'=>new EE_WP_Post_Type_Field('espresso_events'), // EE_Plain_Text_Field( 'post_type', __( 'Event Post Type', 'event_espresso' ), FALSE, 'espresso_events' ),
125
+				'status' => new EE_WP_Post_Status_Field('post_status', __('Event Status', 'event_espresso'), FALSE, 'draft', $this->_custom_stati)
126 126
 			),
127 127
 			'Event_Meta'=>array(
128
-				'EVTM_ID'=> new EE_DB_Only_Float_Field( 'EVTM_ID', __( 'Event Meta Row ID','event_espresso' ), FALSE ),
129
-				'EVT_ID_fk'=>new EE_DB_Only_Int_Field( 'EVT_ID', __( 'Foreign key to Event ID from Event Meta table', 'event_espresso' ), FALSE ),
130
-				'EVT_display_desc'=>new EE_Boolean_Field( 'EVT_display_desc', __( 'Display Description Flag', 'event_espresso' ), FALSE, 1 ),
131
-				'EVT_display_ticket_selector'=>new EE_Boolean_Field( 'EVT_display_ticket_selector', __( 'Display Ticket Selector Flag', 'event_espresso' ), FALSE, 1 ),
132
-				'EVT_visible_on'=>new EE_Datetime_Field( 'EVT_visible_on', __( 'Event Visible Date', 'event_espresso' ), TRUE, time()),
133
-				'EVT_additional_limit'=>new EE_Integer_Field( 'EVT_additional_limit', __( 'Limit of Additional Registrations on Same Transaction', 'event_espresso' ), TRUE, 10 ),
128
+				'EVTM_ID'=> new EE_DB_Only_Float_Field('EVTM_ID', __('Event Meta Row ID', 'event_espresso'), FALSE),
129
+				'EVT_ID_fk'=>new EE_DB_Only_Int_Field('EVT_ID', __('Foreign key to Event ID from Event Meta table', 'event_espresso'), FALSE),
130
+				'EVT_display_desc'=>new EE_Boolean_Field('EVT_display_desc', __('Display Description Flag', 'event_espresso'), FALSE, 1),
131
+				'EVT_display_ticket_selector'=>new EE_Boolean_Field('EVT_display_ticket_selector', __('Display Ticket Selector Flag', 'event_espresso'), FALSE, 1),
132
+				'EVT_visible_on'=>new EE_Datetime_Field('EVT_visible_on', __('Event Visible Date', 'event_espresso'), TRUE, time()),
133
+				'EVT_additional_limit'=>new EE_Integer_Field('EVT_additional_limit', __('Limit of Additional Registrations on Same Transaction', 'event_espresso'), TRUE, 10),
134 134
 				'EVT_default_registration_status'=>new EE_Enum_Text_Field(
135
-					'EVT_default_registration_status', __( 'Default Registration Status on this Event', 'event_espresso' ), FALSE, EEM_Event::$_default_reg_status, EEM_Registration::reg_status_array()
135
+					'EVT_default_registration_status', __('Default Registration Status on this Event', 'event_espresso'), FALSE, EEM_Event::$_default_reg_status, EEM_Registration::reg_status_array()
136 136
 				),
137
-				'EVT_member_only'=>new EE_Boolean_Field( 'EVT_member_only', __( 'Member-Only Event Flag', 'event_espresso' ), FALSE, FALSE ),
138
-				'EVT_phone'=> new EE_Plain_Text_Field('EVT_phone', __( 'Event Phone Number', 'event_espresso' ), FALSE ),
139
-				'EVT_allow_overflow'=>new EE_Boolean_Field(  'EVT_allow_overflow', __( 'Allow Overflow on Event', 'event_espresso' ), FALSE, FALSE ),
140
-				'EVT_timezone_string'=>new EE_Plain_Text_Field( 'EVT_timezone_string', __( 'Timezone (name) for Event times', 'event_espresso' ), FALSE ),
141
-				'EVT_external_URL'=>new EE_Plain_Text_Field( 'EVT_external_URL', __( 'URL of Event Page if hosted elsewhere', 'event_espresso' ), TRUE ),
142
-				'EVT_donations'=>new EE_Boolean_Field( 'EVT_donations', __( 'Accept Donations?', 'event_espresso' ), FALSE, FALSE )
137
+				'EVT_member_only'=>new EE_Boolean_Field('EVT_member_only', __('Member-Only Event Flag', 'event_espresso'), FALSE, FALSE),
138
+				'EVT_phone'=> new EE_Plain_Text_Field('EVT_phone', __('Event Phone Number', 'event_espresso'), FALSE),
139
+				'EVT_allow_overflow'=>new EE_Boolean_Field('EVT_allow_overflow', __('Allow Overflow on Event', 'event_espresso'), FALSE, FALSE),
140
+				'EVT_timezone_string'=>new EE_Plain_Text_Field('EVT_timezone_string', __('Timezone (name) for Event times', 'event_espresso'), FALSE),
141
+				'EVT_external_URL'=>new EE_Plain_Text_Field('EVT_external_URL', __('URL of Event Page if hosted elsewhere', 'event_espresso'), TRUE),
142
+				'EVT_donations'=>new EE_Boolean_Field('EVT_donations', __('Accept Donations?', 'event_espresso'), FALSE, FALSE)
143 143
 
144 144
 			));
145 145
 
@@ -154,8 +154,8 @@  discard block
 block discarded – undo
154 154
 			'WP_User' => new EE_Belongs_To_Relation(),
155 155
 		);
156 156
 		//this model is generally available for reading
157
-		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
158
-		parent::__construct( $timezone );
157
+		$this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
158
+		parent::__construct($timezone);
159 159
 	}
160 160
 
161 161
 
@@ -163,14 +163,14 @@  discard block
 block discarded – undo
163 163
 	/**
164 164
 	 * @param string $default_reg_status
165 165
 	 */
166
-	public static function set_default_reg_status( $default_reg_status ) {
166
+	public static function set_default_reg_status($default_reg_status) {
167 167
 		self::$_default_reg_status = $default_reg_status;
168 168
 		//if EEM_Event has already been instantiated, then we need to reset the `EVT_default_reg_status` field to use the new default.
169
-		if ( self::$_instance instanceof EEM_Event ) {
169
+		if (self::$_instance instanceof EEM_Event) {
170 170
 			self::$_instance->_fields['Event_Meta']['EVT_default_registration_status'] = new EE_Enum_Text_Field(
171
-				'EVT_default_registration_status', __( 'Default Registration Status on this Event', 'event_espresso' ), false, $default_reg_status, EEM_Registration::reg_status_array()
171
+				'EVT_default_registration_status', __('Default Registration Status on this Event', 'event_espresso'), false, $default_reg_status, EEM_Registration::reg_status_array()
172 172
 			);
173
-			self::$_instance->_fields['Event_Meta']['EVT_default_registration_status']->_construct_finalize( 'Event_Meta', 'EVT_default_registration_status', 'EEM_Event' );
173
+			self::$_instance->_fields['Event_Meta']['EVT_default_registration_status']->_construct_finalize('Event_Meta', 'EVT_default_registration_status', 'EEM_Event');
174 174
 		}
175 175
 	}
176 176
 
@@ -183,9 +183,9 @@  discard block
 block discarded – undo
183 183
 	*		@return 		array
184 184
 	*/
185 185
 	public function get_all_question_groups() {
186
-		return EE_Registry::instance()->load_model( 'Question_Group' )->get_all( array(
187
-			array( 'QSG_deleted' => FALSE ),
188
-			'order_by' => array( 'QSG_order' => 'ASC' )
186
+		return EE_Registry::instance()->load_model('Question_Group')->get_all(array(
187
+			array('QSG_deleted' => FALSE),
188
+			'order_by' => array('QSG_order' => 'ASC')
189 189
 		));
190 190
 	}
191 191
 
@@ -201,13 +201,13 @@  discard block
 block discarded – undo
201 201
 	* 		@param		int $EVT_ID
202 202
 	*		@return 		array
203 203
 	*/
204
-	public function get_all_event_question_groups( $EVT_ID = 0 ) {
205
-		if ( ! isset( $EVT_ID) || ! absint( $EVT_ID )) {
206
-			EE_Error::add_error( __( 'An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
204
+	public function get_all_event_question_groups($EVT_ID = 0) {
205
+		if ( ! isset($EVT_ID) || ! absint($EVT_ID)) {
206
+			EE_Error::add_error(__('An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
207 207
 			return FALSE;
208 208
 		}
209
-		return EE_Registry::instance()->load_model( 'Event_Question_Group' )->get_all( array(
210
-			array( 'EVT_ID' => $EVT_ID )
209
+		return EE_Registry::instance()->load_model('Event_Question_Group')->get_all(array(
210
+			array('EVT_ID' => $EVT_ID)
211 211
 		));
212 212
 	}
213 213
 
@@ -223,13 +223,13 @@  discard block
 block discarded – undo
223 223
 	* 		@param		boolean	$for_primary_attendee
224 224
 	*		@return 		array
225 225
 	*/
226
-	public function get_event_question_groups( $EVT_ID = 0, $for_primary_attendee = TRUE ) {
227
-		if ( ! isset( $EVT_ID) || ! absint( $EVT_ID )) {
228
-			EE_Error::add_error( __( 'An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
226
+	public function get_event_question_groups($EVT_ID = 0, $for_primary_attendee = TRUE) {
227
+		if ( ! isset($EVT_ID) || ! absint($EVT_ID)) {
228
+			EE_Error::add_error(__('An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
229 229
 			return FALSE;
230 230
 		}
231
-		return EE_Registry::instance()->load_model( 'Event_Question_Group' )->get_all( array(
232
-			array( 'EVT_ID' => $EVT_ID, 'EQG_primary' => $for_primary_attendee )
231
+		return EE_Registry::instance()->load_model('Event_Question_Group')->get_all(array(
232
+			array('EVT_ID' => $EVT_ID, 'EQG_primary' => $for_primary_attendee)
233 233
 		));
234 234
 	}
235 235
 
@@ -246,10 +246,10 @@  discard block
 block discarded – undo
246 246
 	* 		@param		EE_Registration 	$registration
247 247
 	*		@return 		array
248 248
 	*/
249
-	public function get_question_groups_for_event( $EVT_ID = 0, EE_Registration $registration ) {
249
+	public function get_question_groups_for_event($EVT_ID = 0, EE_Registration $registration) {
250 250
 
251
-		if ( ! isset( $EVT_ID) || ! absint( $EVT_ID )) {
252
-			EE_Error::add_error( __( 'An error occurred. No Question Groups could be retrieved because an Event ID was not received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
251
+		if ( ! isset($EVT_ID) || ! absint($EVT_ID)) {
252
+			EE_Error::add_error(__('An error occurred. No Question Groups could be retrieved because an Event ID was not received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
253 253
 			return FALSE;
254 254
 		}
255 255
 
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 			'QSG_deleted' => FALSE
260 260
 		);
261 261
 
262
-		return EE_Registry::instance()->load_model( 'Question_Group' )->get_all( array(
262
+		return EE_Registry::instance()->load_model('Question_Group')->get_all(array(
263 263
 			$where_params,
264 264
 			'order_by' => array('QSG_order' => 'ASC')
265 265
 		));
@@ -279,16 +279,16 @@  discard block
 block discarded – undo
279 279
 	* 		@param		string		$QSG_IDs  csv list of $QSG IDs
280 280
 	*		@return 		array
281 281
 	*/
282
-	public function get_questions_in_groups( $QSG_IDs = '' ) {
282
+	public function get_questions_in_groups($QSG_IDs = '') {
283 283
 
284
-		if ( empty( $QSG_IDs )) {
285
-			EE_Error::add_error( __( 'An error occurred. No Question Group IDs were received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
284
+		if (empty($QSG_IDs)) {
285
+			EE_Error::add_error(__('An error occurred. No Question Group IDs were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
286 286
 			return FALSE;
287 287
 		}
288 288
 
289
-		return EE_Registry::instance()->load_model( 'Question' )->get_all( array(
289
+		return EE_Registry::instance()->load_model('Question')->get_all(array(
290 290
 			array(
291
-				'Question_Group.QSG_ID' => array( 'IN', $QSG_IDs ),
291
+				'Question_Group.QSG_ID' => array('IN', $QSG_IDs),
292 292
 				'QST_deleted' => FALSE,
293 293
 				'QST_admin_only' => is_admin()
294 294
 			),
@@ -310,16 +310,16 @@  discard block
 block discarded – undo
310 310
 	* 		@param		string		$QST_IDs  csv list of $QST IDs
311 311
 	*		@return 		array
312 312
 	*/
313
-	public function get_options_for_question( $QST_IDs ) {
313
+	public function get_options_for_question($QST_IDs) {
314 314
 
315
-		if ( empty( $QST_IDs )) {
316
-			EE_Error::add_error( __( 'An error occurred. No Question IDs were received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
315
+		if (empty($QST_IDs)) {
316
+			EE_Error::add_error(__('An error occurred. No Question IDs were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
317 317
 			return FALSE;
318 318
 		}
319 319
 
320
-		return EE_Registry::instance()->load_model( 'Question_Option' )->get_all( array(
320
+		return EE_Registry::instance()->load_model('Question_Option')->get_all(array(
321 321
 			array(
322
-				'Question.QST_ID' => array( 'IN', $QST_IDs ),
322
+				'Question.QST_ID' => array('IN', $QST_IDs),
323 323
 				'QSO_deleted' => FALSE
324 324
 			),
325 325
 			'order_by' => 'QSO_ID'
@@ -338,45 +338,45 @@  discard block
 block discarded – undo
338 338
 	 * @throws EE_Error
339 339
 	 * @return 	array
340 340
 	 */
341
-	public function assemble_array_of_groups_questions_and_options( EE_Registration $registration, $EVT_ID = 0 ) {
341
+	public function assemble_array_of_groups_questions_and_options(EE_Registration $registration, $EVT_ID = 0) {
342 342
 
343
-		if ( empty( $EVT_ID ) ) {
344
-			throw new EE_Error( __( 'An error occurred. No EVT_ID is included.  Needed to know which question groups to retrieve.', 'event_espresso' ) );
343
+		if (empty($EVT_ID)) {
344
+			throw new EE_Error(__('An error occurred. No EVT_ID is included.  Needed to know which question groups to retrieve.', 'event_espresso'));
345 345
 		}
346 346
 
347 347
 		$questions = array();
348 348
 
349 349
 		// get all question groups for event
350
-		$qgs = $this->get_question_groups_for_event( $EVT_ID, $registration );
351
-		if ( !empty( $qgs ) ) {
352
-			foreach ( $qgs as $qg ) {
350
+		$qgs = $this->get_question_groups_for_event($EVT_ID, $registration);
351
+		if ( ! empty($qgs)) {
352
+			foreach ($qgs as $qg) {
353 353
 			 	$qsts = $qg->questions();
354
-			 	$questions[ $qg->ID() ] = $qg->model_field_array();
355
-			 	$questions[ $qg->ID() ]['QSG_questions'] = array();
356
-			 	foreach ( $qsts as $qst ) {
357
-			 		if ( $qst->is_system_question() )
354
+			 	$questions[$qg->ID()] = $qg->model_field_array();
355
+			 	$questions[$qg->ID()]['QSG_questions'] = array();
356
+			 	foreach ($qsts as $qst) {
357
+			 		if ($qst->is_system_question())
358 358
 			 			continue;
359
-			 		$answer = EEM_Answer::instance()->get_one( array( array( 'QST_ID' => $qst->ID(), 'REG_ID' => $registration->ID() ) ) );
359
+			 		$answer = EEM_Answer::instance()->get_one(array(array('QST_ID' => $qst->ID(), 'REG_ID' => $registration->ID())));
360 360
 			 		$answer = $answer instanceof EE_Answer ? $answer : EEM_Answer::instance()->create_default_object();
361 361
 			 		$qst_name = $qstn_id = $qst->ID();
362 362
 			 		$ans_id = $answer->ID();
363
-			 		$qst_name = !empty( $ans_id ) ?  '[' . $qst_name . '][' . $ans_id . ']' : '[' . $qst_name . ']';
363
+			 		$qst_name = ! empty($ans_id) ? '['.$qst_name.']['.$ans_id.']' : '['.$qst_name.']';
364 364
 			 		$input_name = '';
365
-			 		$input_id = sanitize_key( $qst->display_text() );
365
+			 		$input_id = sanitize_key($qst->display_text());
366 366
 			 		$input_class = '';
367 367
 			 		$questions[$qg->ID()]['QSG_questions'][$qst->ID()] = $qst->model_field_array();
368
-		 			$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_input_name'] = 'qstn' . $input_name . $qst_name;
369
-					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_input_id'] = $input_id . '-' . $qstn_id;
370
-					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_input_class'] = $input_class;
371
-					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_options'] = array();
372
-					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['qst_obj'] = $qst;
373
-					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['ans_obj'] = $answer;
374
-
375
-					if ( $qst->type() == 'RADIO_BTN' || $qst->type() == 'CHECKBOX' || $qst->type() == 'DROPDOWN' ) {
376
-						$QSOs = $qst->options(TRUE,$answer->value());
377
-						if ( is_array( $QSOs ) ) {
378
-							foreach ( $QSOs as $QSO_ID => $QSO ) {
379
-								$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_options'][ $QSO_ID ] = $QSO->model_field_array();
368
+		 			$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_name'] = 'qstn'.$input_name.$qst_name;
369
+					$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_id'] = $input_id.'-'.$qstn_id;
370
+					$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_class'] = $input_class;
371
+					$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_options'] = array();
372
+					$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['qst_obj'] = $qst;
373
+					$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['ans_obj'] = $answer;
374
+
375
+					if ($qst->type() == 'RADIO_BTN' || $qst->type() == 'CHECKBOX' || $qst->type() == 'DROPDOWN') {
376
+						$QSOs = $qst->options(TRUE, $answer->value());
377
+						if (is_array($QSOs)) {
378
+							foreach ($QSOs as $QSO_ID => $QSO) {
379
+								$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_options'][$QSO_ID] = $QSO->model_field_array();
380 380
 							}
381 381
 						}
382 382
 					}
@@ -400,9 +400,9 @@  discard block
 block discarded – undo
400 400
 	* 		@param		$QST
401 401
 	*		@return 		string		string
402 402
 	*/
403
-	private function _generate_question_input_name( $QST ) {
403
+	private function _generate_question_input_name($QST) {
404 404
 
405
-		if ( $QST->QST_system ) {
405
+		if ($QST->QST_system) {
406 406
 			$qst_name = $QST->QST_system;
407 407
 /*			switch( $QST->QST_system ) {
408 408
 
@@ -469,36 +469,36 @@  discard block
 block discarded – undo
469 469
 	 * @param bool    $count whether to return the count or not (default FALSE)
470 470
 	 * @return array 	EE_Event objects
471 471
 	 */
472
-	public function get_active_events( $query_params, $count = FALSE ) {
473
-		if ( array_key_exists( 0, $query_params ) ) {
472
+	public function get_active_events($query_params, $count = FALSE) {
473
+		if (array_key_exists(0, $query_params)) {
474 474
 			$where_params = $query_params[0];
475
-			unset( $query_params[0] );
475
+			unset($query_params[0]);
476 476
 		} else {
477 477
 			$where_params = array();
478 478
 		}
479 479
 
480 480
 		//if we have count make sure we don't include group by
481
-		if ( $count && isset( $query_params['group_by'] ) ) {
482
-			unset( $query_params['group_by'] );
481
+		if ($count && isset($query_params['group_by'])) {
482
+			unset($query_params['group_by']);
483 483
 		}
484 484
 
485 485
 		//let's add specific query_params for active_events - keep in mind this will override any sent status in the query AND any date queries.
486 486
 		$where_params['status'] = 'publish';
487 487
 		//if already have where params for DTT_EVT_start or DTT_EVT_end then append these conditions
488
-		if ( isset( $where_params['Datetime.DTT_EVT_start'] ) ) {
489
-			$where_params['Datetime.DTT_EVT_start******'] = array('<',  EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_start' ) );
488
+		if (isset($where_params['Datetime.DTT_EVT_start'])) {
489
+			$where_params['Datetime.DTT_EVT_start******'] = array('<', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'));
490 490
 		} else {
491
-			$where_params['Datetime.DTT_EVT_start'] = array('<',  EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_start' ) );
491
+			$where_params['Datetime.DTT_EVT_start'] = array('<', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'));
492 492
 		}
493 493
 
494
-		if ( isset( $where_params['Datetime.DTT_EVT_end'] ) ) {
495
-			$where_params['Datetime.DTT_EVT_end*****'] = array('>', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_end' ) );
494
+		if (isset($where_params['Datetime.DTT_EVT_end'])) {
495
+			$where_params['Datetime.DTT_EVT_end*****'] = array('>', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'));
496 496
 		} else {
497
-			$where_params['Datetime.DTT_EVT_end'] = array('>', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_end' ) );
497
+			$where_params['Datetime.DTT_EVT_end'] = array('>', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'));
498 498
 		}
499 499
 		$query_params[0] = $where_params;
500 500
 		// don't use $query_params with count() because we don't want to include additional query clauses like "GROUP BY" 
501
-		return $count ? $this->count( array( $where_params ), 'EVT_ID', true ) : $this->get_all( $query_params );
501
+		return $count ? $this->count(array($where_params), 'EVT_ID', true) : $this->get_all($query_params);
502 502
 	}
503 503
 
504 504
 
@@ -513,30 +513,30 @@  discard block
 block discarded – undo
513 513
 	 * @param bool    $count whether to return the count or not (default FALSE)
514 514
 	 * @return array               EE_Event objects
515 515
 	 */
516
-	public function get_upcoming_events( $query_params, $count = FALSE ) {
517
-		if ( array_key_exists( 0, $query_params ) ) {
516
+	public function get_upcoming_events($query_params, $count = FALSE) {
517
+		if (array_key_exists(0, $query_params)) {
518 518
 			$where_params = $query_params[0];
519
-			unset( $query_params[0] );
519
+			unset($query_params[0]);
520 520
 		} else {
521 521
 			$where_params = array();
522 522
 		}
523 523
 
524 524
 		//if we have count make sure we don't include group by
525
-		if ( $count && isset( $query_params['group_by'] ) ) {
526
-			unset( $query_params['group_by'] );
525
+		if ($count && isset($query_params['group_by'])) {
526
+			unset($query_params['group_by']);
527 527
 		}
528 528
 
529 529
 		//let's add specific query_params for active_events - keep in mind this will override any sent status in the query AND any date queries.
530 530
 		$where_params['status'] = 'publish';
531 531
 		//if there are already query_params matching DTT_EVT_start then we need to modify that to add them.
532
-		if ( isset( $where_params['Datetime.DTT_EVT_start'] ) ) {
533
-			$where_params['Datetime.DTT_EVT_start*****'] = array('>', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_start' ) );
532
+		if (isset($where_params['Datetime.DTT_EVT_start'])) {
533
+			$where_params['Datetime.DTT_EVT_start*****'] = array('>', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'));
534 534
 		} else {
535
-			$where_params['Datetime.DTT_EVT_start'] = array('>', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_start' ) );
535
+			$where_params['Datetime.DTT_EVT_start'] = array('>', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'));
536 536
 		}
537 537
 		$query_params[0] = $where_params;
538 538
 		// don't use $query_params with count() because we don't want to include additional query clauses like "GROUP BY" 
539
-		return $count ? $this->count( array( $where_params ), 'EVT_ID', true ) : $this->get_all( $query_params );
539
+		return $count ? $this->count(array($where_params), 'EVT_ID', true) : $this->get_all($query_params);
540 540
 	}
541 541
 
542 542
 
@@ -548,56 +548,56 @@  discard block
 block discarded – undo
548 548
 	 * @param bool    $count whether to return the count or not (default FALSE)
549 549
 	 * @return array 	EE_Event objects
550 550
 	 */
551
-	public function get_expired_events( $query_params, $count = FALSE ) {
551
+	public function get_expired_events($query_params, $count = FALSE) {
552 552
 
553
-		$where_params = isset( $query_params[0] ) ? $query_params[0] : array();
553
+		$where_params = isset($query_params[0]) ? $query_params[0] : array();
554 554
 
555 555
 		//if we have count make sure we don't include group by
556
-		if ( $count && isset( $query_params['group_by'] ) ) {
557
-			unset( $query_params['group_by'] );
556
+		if ($count && isset($query_params['group_by'])) {
557
+			unset($query_params['group_by']);
558 558
 		}
559 559
 
560 560
 		//let's add specific query_params for active_events - keep in mind this will override any sent status in the query AND any date queries.
561
-		if ( isset( $where_params['status'] ) ) {
562
-			unset( $where_params['status'] );
561
+		if (isset($where_params['status'])) {
562
+			unset($where_params['status']);
563 563
 		}
564 564
 		$exclude_query = $query_params;
565
-		if ( isset( $exclude_query[0] ) ) {
566
-			unset( $exclude_query[0] );
565
+		if (isset($exclude_query[0])) {
566
+			unset($exclude_query[0]);
567 567
 		}
568
-		$exclude_query[0] = array( 'Datetime.DTT_EVT_end' => array( '>', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_end' ) ) );
568
+		$exclude_query[0] = array('Datetime.DTT_EVT_end' => array('>', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end')));
569 569
 		//first get all events that have datetimes where its not expired.
570
-		$event_ids = $this->_get_all_wpdb_results( $exclude_query, OBJECT_K, 'Event_CPT.ID' );
571
-		$event_ids = array_keys( $event_ids );
570
+		$event_ids = $this->_get_all_wpdb_results($exclude_query, OBJECT_K, 'Event_CPT.ID');
571
+		$event_ids = array_keys($event_ids);
572 572
 
573 573
 		//if we have any additional query_params, let's add them to the 'AND' condition
574 574
 		$and_condition = array(
575
-			'Datetime.DTT_EVT_end' => array( '<', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_end' ) ),
576
-			'EVT_ID' =>  array( 'NOT IN', $event_ids )
575
+			'Datetime.DTT_EVT_end' => array('<', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end')),
576
+			'EVT_ID' =>  array('NOT IN', $event_ids)
577 577
 			);
578 578
 
579
-		if ( isset( $where_params['OR'] ) ) {
579
+		if (isset($where_params['OR'])) {
580 580
 			$and_condition['OR'] = $where_params['OR'];
581
-			unset( $where_params['OR'] );
581
+			unset($where_params['OR']);
582 582
 		}
583 583
 
584
-		if ( isset( $where_params['Datetime.DTT_EVT_end'] ) ) {
584
+		if (isset($where_params['Datetime.DTT_EVT_end'])) {
585 585
 			$and_condition['Datetime.DTT_EVT_end****'] = $where_params['Datetime.DTT_EVT_end'];
586
-			unset( $where_params['Datetime.DTT_EVT_end'] );
586
+			unset($where_params['Datetime.DTT_EVT_end']);
587 587
 		}
588 588
 
589
-		if ( isset( $where_params['Datetime.DTT_EVT_start'] ) ) {
589
+		if (isset($where_params['Datetime.DTT_EVT_start'])) {
590 590
 			$and_condition['Datetime.DTT_EVT_start'] = $where_params['Datetime.DTT_EVT_start'];
591
-			unset( $where_params['Datetime.DTT_EVT_start'] );
591
+			unset($where_params['Datetime.DTT_EVT_start']);
592 592
 		}
593 593
 
594 594
 		//merge remaining $where params with the and conditions.
595
-		$and_condtion = array_merge( $and_condition, $where_params );
595
+		$and_condtion = array_merge($and_condition, $where_params);
596 596
 
597 597
 		$where_params['AND'] = $and_condition;
598 598
 		$query_params[0] = $where_params;
599 599
 		// don't use $query_params with count() because we don't want to include additional query clauses like "GROUP BY" 
600
-		return $count ? $this->count( array( $where_params ), 'EVT_ID', true ) : $this->get_all( $query_params );
600
+		return $count ? $this->count(array($where_params), 'EVT_ID', true) : $this->get_all($query_params);
601 601
 	}
602 602
 
603 603
 
@@ -608,40 +608,40 @@  discard block
 block discarded – undo
608 608
 	 * @param  boolean $count        whether to return the count or not (default FALSE)
609 609
 	 * @return EE_Event[]            array of EE_Event objects
610 610
 	 */
611
-	public function get_inactive_events( $query_params, $count = FALSE ) {
612
-		$where_params = isset( $query_params[0] ) ? $query_params[0] : array();
611
+	public function get_inactive_events($query_params, $count = FALSE) {
612
+		$where_params = isset($query_params[0]) ? $query_params[0] : array();
613 613
 
614 614
 		//let's add in specific query_params for inactive events.
615
-		if ( isset( $where_params['status'] ) ) {
616
-			unset( $where_params['status'] );
615
+		if (isset($where_params['status'])) {
616
+			unset($where_params['status']);
617 617
 		}
618 618
 
619 619
 		//if we have count make sure we don't include group by
620
-		if ( $count && isset( $query_params['group_by'] ) ) {
621
-			unset( $query_params['group_by'] );
620
+		if ($count && isset($query_params['group_by'])) {
621
+			unset($query_params['group_by']);
622 622
 		}
623 623
 
624 624
 		//if we have any additional query_params, let's add them to the 'AND' condition
625
-		$where_params['AND']['status'] = array( '!=', 'publish' );
625
+		$where_params['AND']['status'] = array('!=', 'publish');
626 626
 
627
-		if ( isset( $where_params['OR'] ) ) {
627
+		if (isset($where_params['OR'])) {
628 628
 			$where_params['AND']['OR'] = $where_params['OR'];
629
-			unset( $where_params['OR'] );
629
+			unset($where_params['OR']);
630 630
 		}
631 631
 
632
-		if ( isset( $where_params['Datetime.DTT_EVT_end'] ) ) {
632
+		if (isset($where_params['Datetime.DTT_EVT_end'])) {
633 633
 			$where_params['AND']['Datetime.DTT_EVT_end****'] = $where_params['Datetime.DTT_EVT_end'];
634
-			unset( $where_params['Datetime.DTT_EVT_end'] );
634
+			unset($where_params['Datetime.DTT_EVT_end']);
635 635
 		}
636 636
 
637
-		if ( isset( $where_params['Datetime.DTT_EVT_start'] ) ) {
637
+		if (isset($where_params['Datetime.DTT_EVT_start'])) {
638 638
 			$where_params['AND']['Datetime.DTT_EVT_start'] = $where_params['Datetime.DTT_EVT_start'];
639
-			unset( $where_params['Datetime.DTT_EVT_start'] );
639
+			unset($where_params['Datetime.DTT_EVT_start']);
640 640
 		}
641 641
 
642 642
 		$query_params[0] = $where_params;
643 643
 		// don't use $query_params with count() because we don't want to include additional query clauses like "GROUP BY" 
644
-		return $count ? $this->count( array( $where_params ), 'EVT_ID', true ) : $this->get_all( $query_params );
644
+		return $count ? $this->count(array($where_params), 'EVT_ID', true) : $this->get_all($query_params);
645 645
 	}
646 646
 
647 647
 
@@ -649,13 +649,13 @@  discard block
 block discarded – undo
649 649
 	 * This is just injecting into the parent add_relationship_to so we do special handling on price relationships because we don't want to override any existing global default prices but instead insert NEW prices that get attached to the event.
650 650
 	 * See parent for param descriptions
651 651
 	 */
652
-	public function add_relationship_to($id_or_obj,$other_model_id_or_obj, $relationName, $where_query = array()){
652
+	public function add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query = array()) {
653 653
 
654
-		if ( $relationName == 'Price' ) {
654
+		if ($relationName == 'Price') {
655 655
 			//let's get the PRC object for the given ID to make sure that we aren't dealing with a default
656 656
 			$prc_chk = $this->get_related_model_obj($relationName)->ensure_is_obj($other_model_id_or_obj);
657 657
 			//if EVT_ID = 0, then this is a default
658
-			if ( $prc_chk->get('EVT_ID') == 0 ) {
658
+			if ($prc_chk->get('EVT_ID') == 0) {
659 659
 				//let's set the prc_id as 0 so we force an insert on the add_relation_to carried out by relation
660 660
 				$prc_chk->set('PRC_ID', 0);
661 661
 			}
@@ -665,7 +665,7 @@  discard block
 block discarded – undo
665 665
 		}
666 666
 
667 667
 		//otherwise carry on as normal
668
-		return parent::add_relationship_to($id_or_obj,$other_model_id_or_obj, $relationName, $where_query);
668
+		return parent::add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query);
669 669
 	}
670 670
 
671 671
 
Please login to merge, or discard this patch.
core/helpers/EEH_Activation.helper.php 1 patch
Spacing   +367 added lines, -367 removed lines patch added patch discarded remove patch
@@ -57,9 +57,9 @@  discard block
 block discarded – undo
57 57
 	 * @param $table_name
58 58
 	 * @return string
59 59
 	 */
60
-	public static function ensure_table_name_has_prefix( $table_name ) {
60
+	public static function ensure_table_name_has_prefix($table_name) {
61 61
 		global $wpdb;
62
-		return strpos( $table_name, $wpdb->prefix ) === 0 ? $table_name : $wpdb->prefix . $table_name;
62
+		return strpos($table_name, $wpdb->prefix) === 0 ? $table_name : $wpdb->prefix.$table_name;
63 63
 	}
64 64
 
65 65
 
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	 * be called on plugin activation and reactivation
86 86
 	 * @return boolean success, whether the database and folders are setup properly
87 87
 	 */
88
-	public static function initialize_db_and_folders(){
88
+	public static function initialize_db_and_folders() {
89 89
 		$good_filesystem = EEH_Activation::create_upload_directories();
90 90
 		$good_db = EEH_Activation::create_database_tables();
91 91
 		return $good_filesystem && $good_db;
@@ -99,9 +99,9 @@  discard block
 block discarded – undo
99 99
 	 * upon activation of a new plugin, reactivation, and at the end
100 100
 	 * of running migration scripts
101 101
 	 */
102
-	public static function initialize_db_content(){
102
+	public static function initialize_db_content() {
103 103
 		//let's avoid doing all this logic repeatedly, especially when addons are requesting it
104
-		if( EEH_Activation::$_initialized_db_content_already_in_this_request ) {
104
+		if (EEH_Activation::$_initialized_db_content_already_in_this_request) {
105 105
 			return;
106 106
 		}
107 107
 		EEH_Activation::$_initialized_db_content_already_in_this_request = true;
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 		EEH_Activation::remove_cron_tasks();
119 119
 		EEH_Activation::create_cron_tasks();
120 120
 		//also, check for CAF default db content
121
-		do_action( 'AHEE__EEH_Activation__initialize_db_content' );
121
+		do_action('AHEE__EEH_Activation__initialize_db_content');
122 122
 		//also: EEM_Gateways::load_all_gateways() outputs a lot of success messages
123 123
 		//which users really won't care about on initial activation
124 124
 		EE_Error::overwrite_success();
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 	 * @return array
138 138
 	 * @throws \EE_Error
139 139
 	 */
140
-	public static function get_cron_tasks( $which_to_include ) {
140
+	public static function get_cron_tasks($which_to_include) {
141 141
 		$cron_tasks = apply_filters(
142 142
 			'FHEE__EEH_Activation__get_cron_tasks',
143 143
 			array(
@@ -146,17 +146,17 @@  discard block
 block discarded – undo
146 146
 				'AHEE__EE_Cron_Tasks__update_transaction_with_payment' => EEH_Activation::cron_task_no_longer_in_use, //there may have been a bug which prevented from these cron tasks from getting unscheduled, so we might want to remove these for a few updates
147 147
 			)
148 148
 		);
149
-		if( $which_to_include === 'all' ) {
149
+		if ($which_to_include === 'all') {
150 150
 			//leave as-is
151
-		}elseif( $which_to_include === 'old' ) {
152
-			$cron_tasks = array_filter( $cron_tasks, function ( $value ) {
151
+		}elseif ($which_to_include === 'old') {
152
+			$cron_tasks = array_filter($cron_tasks, function($value) {
153 153
 				return $value === EEH_Activation::cron_task_no_longer_in_use;
154 154
 			});
155
-		}elseif( $which_to_include === 'current' ) {
156
-			$cron_tasks = array_filter( $cron_tasks );
157
-		}elseif( WP_DEBUG ) {
158
-			throw new EE_Error( sprintf( __( 'Invalidate argument of "%1$s" passed to EEH_Activation::get_cron_tasks. Valid values are "all", "old" and "current".', 'event_espresso' ), $which_to_include ) );
159
-		}else{
155
+		}elseif ($which_to_include === 'current') {
156
+			$cron_tasks = array_filter($cron_tasks);
157
+		}elseif (WP_DEBUG) {
158
+			throw new EE_Error(sprintf(__('Invalidate argument of "%1$s" passed to EEH_Activation::get_cron_tasks. Valid values are "all", "old" and "current".', 'event_espresso'), $which_to_include));
159
+		} else {
160 160
 			//leave as-is
161 161
 		}
162 162
 		return $cron_tasks;
@@ -167,9 +167,9 @@  discard block
 block discarded – undo
167 167
 	 */
168 168
 	public static function create_cron_tasks() {
169 169
 
170
-		foreach( EEH_Activation::get_cron_tasks( 'current' ) as $hook_name => $frequency ) {
171
-			if( ! wp_next_scheduled( $hook_name ) ) {
172
-				wp_schedule_event( time(), $frequency, $hook_name );
170
+		foreach (EEH_Activation::get_cron_tasks('current') as $hook_name => $frequency) {
171
+			if ( ! wp_next_scheduled($hook_name)) {
172
+				wp_schedule_event(time(), $frequency, $hook_name);
173 173
 			}
174 174
 		}
175 175
 
@@ -179,10 +179,10 @@  discard block
 block discarded – undo
179 179
 	 * Remove the currently-existing and now-removed cron tasks.
180 180
 	 * @param boolean $remove_all whether to only remove the old ones, or remove absolutely ALL the EE ones
181 181
 	 */
182
-	public static function remove_cron_tasks( $remove_all = true ) {
182
+	public static function remove_cron_tasks($remove_all = true) {
183 183
 		$cron_tasks_to_remove = $remove_all ? 'all' : 'old';
184 184
 		$crons = _get_cron_array();
185
-		$crons = is_array( $crons ) ? $crons : array();
185
+		$crons = is_array($crons) ? $crons : array();
186 186
 		/* reminder that $crons looks like: top-level keys are timestamps,
187 187
 		 * and their values are arrays.
188 188
 		 * The 2nd level arrays have keys with each of the cron task hooknames to run at that time
@@ -200,14 +200,14 @@  discard block
 block discarded – undo
200 200
 		 *					...
201 201
 		 *      ...
202 202
 		 */
203
-		foreach( EEH_Activation::get_cron_tasks( $cron_tasks_to_remove ) as $hook_name => $frequency ) {
204
-			foreach( $crons as $timestamp => $hooks_to_fire_at_time ) {
205
-				if ( array_key_exists( $hook_name, $hooks_to_fire_at_time ) )  {
206
-					unset( $crons[ $timestamp ][ $hook_name ] );
203
+		foreach (EEH_Activation::get_cron_tasks($cron_tasks_to_remove) as $hook_name => $frequency) {
204
+			foreach ($crons as $timestamp => $hooks_to_fire_at_time) {
205
+				if (array_key_exists($hook_name, $hooks_to_fire_at_time)) {
206
+					unset($crons[$timestamp][$hook_name]);
207 207
 				}
208 208
 			}
209 209
 		}
210
-		_set_cron_array( $crons );
210
+		_set_cron_array($crons);
211 211
 	}
212 212
 
213 213
 
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 	 */
223 223
 	public static function CPT_initialization() {
224 224
 		// register Custom Post Types
225
-		EE_Registry::instance()->load_core( 'Register_CPTs' );
225
+		EE_Registry::instance()->load_core('Register_CPTs');
226 226
 		flush_rewrite_rules();
227 227
 	}
228 228
 
@@ -240,8 +240,8 @@  discard block
 block discarded – undo
240 240
 	 * 	@return void
241 241
 	 */
242 242
 	public static function reset_and_update_config() {
243
-		do_action( 'AHEE__EE_Config___load_core_config__start', array( 'EEH_Activation', 'load_calendar_config' ) );
244
-		add_filter( 'FHEE__EE_Config___load_core_config__config_settings', array( 'EEH_Activation', 'migrate_old_config_data' ), 10, 3 );
243
+		do_action('AHEE__EE_Config___load_core_config__start', array('EEH_Activation', 'load_calendar_config'));
244
+		add_filter('FHEE__EE_Config___load_core_config__config_settings', array('EEH_Activation', 'migrate_old_config_data'), 10, 3);
245 245
 		//EE_Config::reset();
246 246
 	}
247 247
 
@@ -254,23 +254,23 @@  discard block
 block discarded – undo
254 254
 	 */
255 255
 	public static function load_calendar_config() {
256 256
 		// grab array of all plugin folders and loop thru it
257
-		$plugins = glob( WP_PLUGIN_DIR . DS . '*', GLOB_ONLYDIR );
258
-		if ( empty( $plugins ) ) {
257
+		$plugins = glob(WP_PLUGIN_DIR.DS.'*', GLOB_ONLYDIR);
258
+		if (empty($plugins)) {
259 259
 			return;
260 260
 		}
261
-		foreach ( $plugins as $plugin_path ) {
261
+		foreach ($plugins as $plugin_path) {
262 262
 			// grab plugin folder name from path
263
-			$plugin = basename( $plugin_path );
263
+			$plugin = basename($plugin_path);
264 264
 			// drill down to Espresso plugins
265
-			if ( strpos( $plugin, 'espresso' ) !== FALSE || strpos( $plugin, 'Espresso' ) !== FALSE || strpos( $plugin, 'ee4' ) !== FALSE || strpos( $plugin, 'EE4' ) !== FALSE ) {
265
+			if (strpos($plugin, 'espresso') !== FALSE || strpos($plugin, 'Espresso') !== FALSE || strpos($plugin, 'ee4') !== FALSE || strpos($plugin, 'EE4') !== FALSE) {
266 266
 				// then to calendar related plugins
267
-				if ( strpos( $plugin, 'calendar' ) !== FALSE ) {
267
+				if (strpos($plugin, 'calendar') !== FALSE) {
268 268
 					// this is what we are looking for
269
-					$calendar_config = $plugin_path . DS . 'EE_Calendar_Config.php';
269
+					$calendar_config = $plugin_path.DS.'EE_Calendar_Config.php';
270 270
 					// does it exist in this folder ?
271
-					if ( is_readable( $calendar_config )) {
271
+					if (is_readable($calendar_config)) {
272 272
 						// YEAH! let's load it
273
-						require_once( $calendar_config );
273
+						require_once($calendar_config);
274 274
 					}
275 275
 				}
276 276
 			}
@@ -287,21 +287,21 @@  discard block
 block discarded – undo
287 287
 	 * @param \EE_Config $EE_Config
288 288
 	 * @return \stdClass
289 289
 	 */
290
-	public static function migrate_old_config_data( $settings = array(), $config = '', EE_Config $EE_Config ) {
291
-		$convert_from_array = array( 'addons' );
290
+	public static function migrate_old_config_data($settings = array(), $config = '', EE_Config $EE_Config) {
291
+		$convert_from_array = array('addons');
292 292
 		// in case old settings were saved as an array
293
-		if ( is_array( $settings ) && in_array( $config, $convert_from_array )) {
293
+		if (is_array($settings) && in_array($config, $convert_from_array)) {
294 294
 			// convert existing settings to an object
295 295
 			$config_array = $settings;
296 296
 			$settings = new stdClass();
297
-			foreach ( $config_array as $key => $value ){
298
-				if ( $key == 'calendar' && class_exists( 'EE_Calendar_Config' )) {
299
-					$EE_Config->set_config( 'addons', 'EE_Calendar', 'EE_Calendar_Config', $value );
297
+			foreach ($config_array as $key => $value) {
298
+				if ($key == 'calendar' && class_exists('EE_Calendar_Config')) {
299
+					$EE_Config->set_config('addons', 'EE_Calendar', 'EE_Calendar_Config', $value);
300 300
 				} else {
301 301
 					$settings->$key = $value;
302 302
 				}
303 303
 			}
304
-			add_filter( 'FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true' );
304
+			add_filter('FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true');
305 305
 		}
306 306
 		return $settings;
307 307
 	}
@@ -317,8 +317,8 @@  discard block
 block discarded – undo
317 317
 	 */
318 318
 	public static function deactivate_event_espresso() {
319 319
 		// check permissions
320
-		if ( current_user_can( 'activate_plugins' )) {
321
-			deactivate_plugins( EE_PLUGIN_BASENAME, TRUE );
320
+		if (current_user_can('activate_plugins')) {
321
+			deactivate_plugins(EE_PLUGIN_BASENAME, TRUE);
322 322
 		}
323 323
 	}
324 324
 
@@ -340,79 +340,79 @@  discard block
 block discarded – undo
340 340
 		$critical_pages = array(
341 341
 			array(
342 342
 				'id' =>'reg_page_id',
343
-				'name' => __( 'Registration Checkout', 'event_espresso' ),
343
+				'name' => __('Registration Checkout', 'event_espresso'),
344 344
 				'post' => NULL,
345 345
 				'code' => 'ESPRESSO_CHECKOUT'
346 346
 			),
347 347
 			array(
348 348
 				'id' => 'txn_page_id',
349
-				'name' => __( 'Transactions', 'event_espresso' ),
349
+				'name' => __('Transactions', 'event_espresso'),
350 350
 				'post' => NULL,
351 351
 				'code' => 'ESPRESSO_TXN_PAGE'
352 352
 			),
353 353
 			array(
354 354
 				'id' => 'thank_you_page_id',
355
-				'name' => __( 'Thank You', 'event_espresso' ),
355
+				'name' => __('Thank You', 'event_espresso'),
356 356
 				'post' => NULL,
357 357
 				'code' => 'ESPRESSO_THANK_YOU'
358 358
 			),
359 359
 			array(
360 360
 				'id' => 'cancel_page_id',
361
-				'name' => __( 'Registration Cancelled', 'event_espresso' ),
361
+				'name' => __('Registration Cancelled', 'event_espresso'),
362 362
 				'post' => NULL,
363 363
 				'code' => 'ESPRESSO_CANCELLED'
364 364
 			),
365 365
 		);
366 366
 
367
-		foreach ( $critical_pages as $critical_page ) {
367
+		foreach ($critical_pages as $critical_page) {
368 368
 			// is critical page ID set in config ?
369
-			if ( EE_Registry::instance()->CFG->core->$critical_page['id'] !== FALSE ) {
369
+			if (EE_Registry::instance()->CFG->core->$critical_page['id'] !== FALSE) {
370 370
 				// attempt to find post by ID
371
-				$critical_page['post'] = get_post( EE_Registry::instance()->CFG->core->$critical_page['id'] );
371
+				$critical_page['post'] = get_post(EE_Registry::instance()->CFG->core->$critical_page['id']);
372 372
 			}
373 373
 			// no dice?
374
-			if ( $critical_page['post'] == NULL ) {
374
+			if ($critical_page['post'] == NULL) {
375 375
 				// attempt to find post by title
376
-				$critical_page['post'] = self::get_page_by_ee_shortcode( $critical_page['code'] );
376
+				$critical_page['post'] = self::get_page_by_ee_shortcode($critical_page['code']);
377 377
 				// still nothing?
378
-				if ( $critical_page['post'] == NULL ) {
379
-					$critical_page = EEH_Activation::create_critical_page( $critical_page );
378
+				if ($critical_page['post'] == NULL) {
379
+					$critical_page = EEH_Activation::create_critical_page($critical_page);
380 380
 					// REALLY? Still nothing ??!?!?
381
-					if ( $critical_page['post'] == NULL ) {
382
-						$msg = __( 'The Event Espresso critical page configuration settings could not be updated.', 'event_espresso' );
383
-						EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
381
+					if ($critical_page['post'] == NULL) {
382
+						$msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso');
383
+						EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
384 384
 						break;
385 385
 					}
386 386
 				}
387 387
 			}
388 388
 			// track post_shortcodes
389
-			if ( $critical_page['post'] ) {
390
-				EEH_Activation::_track_critical_page_post_shortcodes( $critical_page );
389
+			if ($critical_page['post']) {
390
+				EEH_Activation::_track_critical_page_post_shortcodes($critical_page);
391 391
 			}
392 392
 			// check that Post ID matches critical page ID in config
393
-			if ( isset( $critical_page['post']->ID ) && $critical_page['post']->ID != EE_Registry::instance()->CFG->core->$critical_page['id'] ) {
393
+			if (isset($critical_page['post']->ID) && $critical_page['post']->ID != EE_Registry::instance()->CFG->core->$critical_page['id']) {
394 394
 				//update Config with post ID
395 395
 				EE_Registry::instance()->CFG->core->$critical_page['id'] = $critical_page['post']->ID;
396
-				if ( ! EE_Config::instance()->update_espresso_config( FALSE, FALSE ) ) {
397
-					$msg = __( 'The Event Espresso critical page configuration settings could not be updated.', 'event_espresso' );
398
-					EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
396
+				if ( ! EE_Config::instance()->update_espresso_config(FALSE, FALSE)) {
397
+					$msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso');
398
+					EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
399 399
 				}
400 400
 			}
401 401
 
402
-			$critical_page_problem =  ! isset( $critical_page['post']->post_status ) || $critical_page['post']->post_status != 'publish' || strpos( $critical_page['post']->post_content, $critical_page['code'] ) === FALSE ? TRUE : $critical_page_problem;
402
+			$critical_page_problem = ! isset($critical_page['post']->post_status) || $critical_page['post']->post_status != 'publish' || strpos($critical_page['post']->post_content, $critical_page['code']) === FALSE ? TRUE : $critical_page_problem;
403 403
 
404 404
 		}
405 405
 
406
-		if ( $critical_page_problem ) {
406
+		if ($critical_page_problem) {
407 407
 			$msg = sprintf(
408
-				__('A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', 'event_espresso' ),
409
-				'<a href="' . admin_url('admin.php?page=espresso_general_settings&action=critical_pages') . '">' . __('Event Espresso Critical Pages Settings', 'event_espresso') . '</a>'
408
+				__('A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', 'event_espresso'),
409
+				'<a href="'.admin_url('admin.php?page=espresso_general_settings&action=critical_pages').'">'.__('Event Espresso Critical Pages Settings', 'event_espresso').'</a>'
410 410
 			);
411
-			EE_Error::add_persistent_admin_notice( 'critical_page_problem', $msg );
411
+			EE_Error::add_persistent_admin_notice('critical_page_problem', $msg);
412 412
 		}
413 413
 
414
-		if ( EE_Error::has_notices() ) {
415
-			EE_Error::get_notices( FALSE, TRUE, TRUE );
414
+		if (EE_Error::has_notices()) {
415
+			EE_Error::get_notices(FALSE, TRUE, TRUE);
416 416
 		}
417 417
 
418 418
 	}
@@ -425,13 +425,13 @@  discard block
 block discarded – undo
425 425
 	 * parameter to the shortcode
426 426
 	 * @return WP_Post or NULl
427 427
 	 */
428
-	public static function get_page_by_ee_shortcode($ee_shortcode){
428
+	public static function get_page_by_ee_shortcode($ee_shortcode) {
429 429
 		global $wpdb;
430 430
 		$shortcode_and_opening_bracket = '['.$ee_shortcode;
431 431
 		$post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1");
432
-		if($post_id){
432
+		if ($post_id) {
433 433
 			return get_post($post_id);
434
-		}else{
434
+		} else {
435 435
 			return NULL;
436 436
 		}
437 437
 
@@ -448,32 +448,32 @@  discard block
 block discarded – undo
448 448
 	 * @param array $critical_page
449 449
 	 * @return array
450 450
 	 */
451
-	public static function create_critical_page( $critical_page ) {
451
+	public static function create_critical_page($critical_page) {
452 452
 
453 453
 		$post_args = array(
454 454
 			'post_title' => $critical_page['name'],
455 455
 			'post_status' => 'publish',
456 456
 			'post_type' => 'page',
457 457
 			'comment_status' => 'closed',
458
-			'post_content' => '[' . $critical_page['code'] . ']'
458
+			'post_content' => '['.$critical_page['code'].']'
459 459
 		);
460 460
 
461
-		$post_id = wp_insert_post( $post_args );
462
-		if ( ! $post_id ) {
461
+		$post_id = wp_insert_post($post_args);
462
+		if ( ! $post_id) {
463 463
 			$msg = sprintf(
464
-				__( 'The Event Espresso  critical page entitled "%s" could not be created.', 'event_espresso' ),
464
+				__('The Event Espresso  critical page entitled "%s" could not be created.', 'event_espresso'),
465 465
 				$critical_page['name']
466 466
 			);
467
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
467
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
468 468
 			return $critical_page;
469 469
 		}
470 470
 		// get newly created post's details
471
-		if ( ! $critical_page['post'] = get_post( $post_id )) {
471
+		if ( ! $critical_page['post'] = get_post($post_id)) {
472 472
 			$msg = sprintf(
473
-				__( 'The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso' ),
473
+				__('The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso'),
474 474
 				$critical_page['name']
475 475
 			);
476
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
476
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
477 477
 		}
478 478
 
479 479
 		return $critical_page;
@@ -492,34 +492,34 @@  discard block
 block discarded – undo
492 492
 	 * @param array $critical_page
493 493
 	 * @return void
494 494
 	 */
495
-	private static function _track_critical_page_post_shortcodes( $critical_page = array() ) {
495
+	private static function _track_critical_page_post_shortcodes($critical_page = array()) {
496 496
 		// check the goods
497
-		if ( ! $critical_page['post'] instanceof WP_Post ) {
497
+		if ( ! $critical_page['post'] instanceof WP_Post) {
498 498
 			$msg = sprintf(
499
-				__( 'The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.', 'event_espresso' ),
499
+				__('The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.', 'event_espresso'),
500 500
 				$critical_page['name']
501 501
 			);
502
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
502
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
503 503
 			return;
504 504
 		}
505 505
 		// map shortcode to post
506
-		EE_Registry::instance()->CFG->core->post_shortcodes[ $critical_page['post']->post_name ][ $critical_page['code'] ] = $critical_page['post']->ID;
506
+		EE_Registry::instance()->CFG->core->post_shortcodes[$critical_page['post']->post_name][$critical_page['code']] = $critical_page['post']->ID;
507 507
 		// and make sure it's NOT added to the WP "Posts Page"
508 508
 		// name of the WP Posts Page
509 509
 		$posts_page = EE_Registry::instance()->CFG->get_page_for_posts();
510
-		if ( isset( EE_Registry::instance()->CFG->core->post_shortcodes[ $posts_page ] )) {
511
-			unset( EE_Registry::instance()->CFG->core->post_shortcodes[ $posts_page ][ $critical_page['code'] ] );
510
+		if (isset(EE_Registry::instance()->CFG->core->post_shortcodes[$posts_page])) {
511
+			unset(EE_Registry::instance()->CFG->core->post_shortcodes[$posts_page][$critical_page['code']]);
512 512
 		}
513
-		if ( $posts_page != 'posts' && isset( EE_Registry::instance()->CFG->core->post_shortcodes['posts'] )) {
514
-			unset( EE_Registry::instance()->CFG->core->post_shortcodes['posts'][ $critical_page['code'] ] );
513
+		if ($posts_page != 'posts' && isset(EE_Registry::instance()->CFG->core->post_shortcodes['posts'])) {
514
+			unset(EE_Registry::instance()->CFG->core->post_shortcodes['posts'][$critical_page['code']]);
515 515
 		}
516 516
 		// update post_shortcode CFG
517
-		if ( ! EE_Config::instance()->update_espresso_config( FALSE, FALSE )) {
517
+		if ( ! EE_Config::instance()->update_espresso_config(FALSE, FALSE)) {
518 518
 			$msg = sprintf(
519
-				__( 'The Event Espresso critical page shortcode for the %s page could not be configured properly.', 'event_espresso' ),
519
+				__('The Event Espresso critical page shortcode for the %s page could not be configured properly.', 'event_espresso'),
520 520
 				$critical_page['name']
521 521
 			);
522
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
522
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
523 523
 		}
524 524
 	}
525 525
 
@@ -537,24 +537,24 @@  discard block
 block discarded – undo
537 537
 	public static function get_default_creator_id() {
538 538
 		global $wpdb;
539 539
 
540
-		if ( ! empty( self::$_default_creator_id ) ) {
540
+		if ( ! empty(self::$_default_creator_id)) {
541 541
 			return self::$_default_creator_id;
542 542
 		}/**/
543 543
 
544
-		$role_to_check = apply_filters( 'FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator' );
544
+		$role_to_check = apply_filters('FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator');
545 545
 
546 546
 		//let's allow pre_filtering for early exits by alternative methods for getting id.  We check for truthy result and if so then exit early.
547
-		$pre_filtered_id = apply_filters( 'FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', false, $role_to_check );
548
-		if ( $pre_filtered_id !== false ) {
547
+		$pre_filtered_id = apply_filters('FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', false, $role_to_check);
548
+		if ($pre_filtered_id !== false) {
549 549
 			return (int) $pre_filtered_id;
550 550
 		}
551 551
 
552
-		$capabilities_key = EEH_Activation::ensure_table_name_has_prefix( 'capabilities' );
553
-		$query = $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", '%' . $role_to_check . '%' );
554
-		$user_id = $wpdb->get_var( $query );
555
-		 $user_id = apply_filters( 'FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id );
556
-		 if ( $user_id && intval( $user_id ) ) {
557
-		 	self::$_default_creator_id =  intval( $user_id );
552
+		$capabilities_key = EEH_Activation::ensure_table_name_has_prefix('capabilities');
553
+		$query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", '%'.$role_to_check.'%');
554
+		$user_id = $wpdb->get_var($query);
555
+		 $user_id = apply_filters('FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id);
556
+		 if ($user_id && intval($user_id)) {
557
+		 	self::$_default_creator_id = intval($user_id);
558 558
 		 	return self::$_default_creator_id;
559 559
 		 } else {
560 560
 		 	return NULL;
@@ -581,29 +581,29 @@  discard block
 block discarded – undo
581 581
 	 * 	@return void
582 582
 	 * @throws EE_Error if there are database errors
583 583
 	 */
584
-	public static function create_table( $table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false ) {
585
-		if( apply_filters( 'FHEE__EEH_Activation__create_table__short_circuit', FALSE, $table_name, $sql ) ){
584
+	public static function create_table($table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false) {
585
+		if (apply_filters('FHEE__EEH_Activation__create_table__short_circuit', FALSE, $table_name, $sql)) {
586 586
 			return;
587 587
 		}
588
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
589
-		if ( ! function_exists( 'dbDelta' )) {
590
-			require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
588
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
589
+		if ( ! function_exists('dbDelta')) {
590
+			require_once(ABSPATH.'wp-admin/includes/upgrade.php');
591 591
 		}
592 592
 		/** @var WPDB $wpdb */
593 593
 		global $wpdb;
594
-		$wp_table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name );
594
+		$wp_table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
595 595
 		// do we need to first delete an existing version of this table ?
596
-		if ( $drop_pre_existing_table && EEH_Activation::table_exists( $wp_table_name ) ){
596
+		if ($drop_pre_existing_table && EEH_Activation::table_exists($wp_table_name)) {
597 597
 			// ok, delete the table... but ONLY if it's empty
598
-			$deleted_safely = EEH_Activation::delete_db_table_if_empty( $wp_table_name );
598
+			$deleted_safely = EEH_Activation::delete_db_table_if_empty($wp_table_name);
599 599
 			// table is NOT empty, are you SURE you want to delete this table ???
600
-			if ( ! $deleted_safely && defined( 'EE_DROP_BAD_TABLES' ) && EE_DROP_BAD_TABLES ){
601
-				EEH_Activation::delete_unused_db_table( $wp_table_name );
602
-			} else if ( ! $deleted_safely ) {
600
+			if ( ! $deleted_safely && defined('EE_DROP_BAD_TABLES') && EE_DROP_BAD_TABLES) {
601
+				EEH_Activation::delete_unused_db_table($wp_table_name);
602
+			} else if ( ! $deleted_safely) {
603 603
 				// so we should be more cautious rather than just dropping tables so easily
604 604
 				EE_Error::add_persistent_admin_notice(
605
-						'bad_table_' . $wp_table_name . '_detected',
606
-						sprintf( __( 'Database table %1$s exists when it shouldn\'t, and may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend adding %2$s to your %3$s file then restore to that backup again. This will clear out the invalid data from %1$s. Afterwards you should undo that change from your %3$s file. %4$sIf you cannot edit %3$s, you should remove the data from %1$s manually then restore to the backup again.', 'event_espresso' ),
605
+						'bad_table_'.$wp_table_name.'_detected',
606
+						sprintf(__('Database table %1$s exists when it shouldn\'t, and may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend adding %2$s to your %3$s file then restore to that backup again. This will clear out the invalid data from %1$s. Afterwards you should undo that change from your %3$s file. %4$sIf you cannot edit %3$s, you should remove the data from %1$s manually then restore to the backup again.', 'event_espresso'),
607 607
 								$wp_table_name,
608 608
 								"<pre>define( 'EE_DROP_BAD_TABLES', TRUE );</pre>",
609 609
 								'<b>wp-config.php</b>',
@@ -612,25 +612,25 @@  discard block
 block discarded – undo
612 612
 			}
613 613
 		}
614 614
 		// does $sql contain valid column information? ( LPT: https://regex101.com/ is great for working out regex patterns )
615
-		if ( preg_match( '((((.*?))(,\s))+)', $sql, $valid_column_data ) ) {
615
+		if (preg_match('((((.*?))(,\s))+)', $sql, $valid_column_data)) {
616 616
 			$SQL = "CREATE TABLE $wp_table_name ( $sql ) $engine DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;";
617 617
 			//get $wpdb to echo errors, but buffer them. This way at least WE know an error
618 618
 			//happened. And then we can choose to tell the end user
619
-			$old_show_errors_policy = $wpdb->show_errors( TRUE );
620
-			$old_error_suppression_policy = $wpdb->suppress_errors( FALSE );
619
+			$old_show_errors_policy = $wpdb->show_errors(TRUE);
620
+			$old_error_suppression_policy = $wpdb->suppress_errors(FALSE);
621 621
 			ob_start();
622
-			dbDelta( $SQL );
622
+			dbDelta($SQL);
623 623
 			$output = ob_get_contents();
624 624
 			ob_end_clean();
625
-			$wpdb->show_errors( $old_show_errors_policy );
626
-			$wpdb->suppress_errors( $old_error_suppression_policy );
627
-			if( ! empty( $output ) ){
628
-				throw new EE_Error( $output	);
625
+			$wpdb->show_errors($old_show_errors_policy);
626
+			$wpdb->suppress_errors($old_error_suppression_policy);
627
+			if ( ! empty($output)) {
628
+				throw new EE_Error($output);
629 629
 			}
630 630
 		} else {
631 631
 			throw new EE_Error(
632 632
 				sprintf(
633
-					__( 'The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', 'event_espresso' ),
633
+					__('The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', 'event_espresso'),
634 634
 					'<br />',
635 635
 					$sql
636 636
 				)
@@ -652,15 +652,15 @@  discard block
 block discarded – undo
652 652
 	 * @param string $column_info if your SQL were 'ALTER TABLE table_name ADD price VARCHAR(10)', this would be 'VARCHAR(10)'
653 653
 	 * @return bool|int
654 654
 	 */
655
-	public static function add_column_if_it_doesnt_exist($table_name,$column_name,$column_info='INT UNSIGNED NOT NULL'){
656
-		if( apply_filters( 'FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', FALSE ) ){
655
+	public static function add_column_if_it_doesnt_exist($table_name, $column_name, $column_info = 'INT UNSIGNED NOT NULL') {
656
+		if (apply_filters('FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', FALSE)) {
657 657
 			return FALSE;
658 658
 		}
659 659
 		global $wpdb;
660
-		$full_table_name= EEH_Activation::ensure_table_name_has_prefix( $table_name );
660
+		$full_table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
661 661
 		$fields = self::get_fields_on_table($table_name);
662
-		if (!in_array($column_name, $fields)){
663
-			$alter_query="ALTER TABLE $full_table_name ADD $column_name $column_info";
662
+		if ( ! in_array($column_name, $fields)) {
663
+			$alter_query = "ALTER TABLE $full_table_name ADD $column_name $column_info";
664 664
 			//echo "alter query:$alter_query";
665 665
 			return $wpdb->query($alter_query);
666 666
 		}
@@ -679,15 +679,15 @@  discard block
 block discarded – undo
679 679
 	 * 	@param string $table_name, without prefixed $wpdb->prefix
680 680
 	 * 	@return array of database column names
681 681
 	 */
682
-	public static function get_fields_on_table( $table_name = NULL ) {
682
+	public static function get_fields_on_table($table_name = NULL) {
683 683
 		global $wpdb;
684
-		$table_name= EEH_Activation::ensure_table_name_has_prefix( $table_name );
685
-		if ( ! empty( $table_name )) {
684
+		$table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
685
+		if ( ! empty($table_name)) {
686 686
 			$columns = $wpdb->get_results("SHOW COLUMNS FROM $table_name ");
687 687
 			if ($columns !== FALSE) {
688 688
 				$field_array = array();
689
-				foreach($columns as $column ){
690
-					$field_array[] = $column->Field;;
689
+				foreach ($columns as $column) {
690
+					$field_array[] = $column->Field; ;
691 691
 				}
692 692
 				return $field_array;
693 693
 			}
@@ -705,12 +705,12 @@  discard block
 block discarded – undo
705 705
 	 * @param string $table_name
706 706
 	 * @return bool
707 707
 	 */
708
-	public static function db_table_is_empty( $table_name ) {
708
+	public static function db_table_is_empty($table_name) {
709 709
 		global $wpdb;
710
-		$table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name );
711
-		if ( EEH_Activation::table_exists( $table_name ) ) {
712
-			$count = $wpdb->get_var( "SELECT COUNT(*) FROM $table_name" );
713
-			return absint( $count ) === 0 ? true : false;
710
+		$table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
711
+		if (EEH_Activation::table_exists($table_name)) {
712
+			$count = $wpdb->get_var("SELECT COUNT(*) FROM $table_name");
713
+			return absint($count) === 0 ? true : false;
714 714
 		}
715 715
 		return false;
716 716
 	}
@@ -725,9 +725,9 @@  discard block
 block discarded – undo
725 725
 	 * @param string $table_name
726 726
 	 * @return bool | int
727 727
 	 */
728
-	public static function delete_db_table_if_empty( $table_name ) {
729
-		if ( EEH_Activation::db_table_is_empty( $table_name ) ) {
730
-			return EEH_Activation::delete_unused_db_table( $table_name );
728
+	public static function delete_db_table_if_empty($table_name) {
729
+		if (EEH_Activation::db_table_is_empty($table_name)) {
730
+			return EEH_Activation::delete_unused_db_table($table_name);
731 731
 		}
732 732
 		return false;
733 733
 	}
@@ -742,11 +742,11 @@  discard block
 block discarded – undo
742 742
 	 * @param string $table_name
743 743
 	 * @return bool | int
744 744
 	 */
745
-	public static function delete_unused_db_table( $table_name ) {
745
+	public static function delete_unused_db_table($table_name) {
746 746
 		global $wpdb;
747
-		if ( EEH_Activation::table_exists( $table_name ) ) {
748
-			$table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name );
749
-			return $wpdb->query( "DROP TABLE IF EXISTS $table_name" );
747
+		if (EEH_Activation::table_exists($table_name)) {
748
+			$table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
749
+			return $wpdb->query("DROP TABLE IF EXISTS $table_name");
750 750
 		}
751 751
 		return false;
752 752
 	}
@@ -762,18 +762,18 @@  discard block
 block discarded – undo
762 762
 	 * @param string $index_name
763 763
 	 * @return bool | int
764 764
 	 */
765
-	public static function drop_index( $table_name, $index_name ) {
766
-		if( apply_filters( 'FHEE__EEH_Activation__drop_index__short_circuit', FALSE ) ){
765
+	public static function drop_index($table_name, $index_name) {
766
+		if (apply_filters('FHEE__EEH_Activation__drop_index__short_circuit', FALSE)) {
767 767
 			return FALSE;
768 768
 		}
769 769
 		global $wpdb;
770
-		$table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name );
770
+		$table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
771 771
 		$index_exists_query = "SHOW INDEX FROM $table_name WHERE Key_name = '$index_name'";
772 772
 		if (
773
-			$wpdb->get_var( "SHOW TABLES LIKE '$table_name'" ) == $table_name
774
-			&& $wpdb->get_var( $index_exists_query ) == $table_name //using get_var with the $index_exists_query returns the table's name
773
+			$wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name
774
+			&& $wpdb->get_var($index_exists_query) == $table_name //using get_var with the $index_exists_query returns the table's name
775 775
 		) {
776
-			return $wpdb->query( "ALTER TABLE $table_name DROP INDEX $index_name" );
776
+			return $wpdb->query("ALTER TABLE $table_name DROP INDEX $index_name");
777 777
 		}
778 778
 		return TRUE;
779 779
 	}
@@ -789,27 +789,27 @@  discard block
 block discarded – undo
789 789
 	 * @return boolean success (whether database is setup properly or not)
790 790
 	 */
791 791
 	public static function create_database_tables() {
792
-		EE_Registry::instance()->load_core( 'Data_Migration_Manager' );
792
+		EE_Registry::instance()->load_core('Data_Migration_Manager');
793 793
 		//find the migration script that sets the database to be compatible with the code
794 794
 		$dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms();
795
-		if( $dms_name ){
796
-			$current_data_migration_script = EE_Registry::instance()->load_dms( $dms_name );
797
-			$current_data_migration_script->set_migrating( false );
795
+		if ($dms_name) {
796
+			$current_data_migration_script = EE_Registry::instance()->load_dms($dms_name);
797
+			$current_data_migration_script->set_migrating(false);
798 798
 			$current_data_migration_script->schema_changes_before_migration();
799 799
 			$current_data_migration_script->schema_changes_after_migration();
800
-			if( $current_data_migration_script->get_errors() ){
801
-				if( WP_DEBUG ){
802
-					foreach( $current_data_migration_script->get_errors() as $error ){
803
-						EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__ );
800
+			if ($current_data_migration_script->get_errors()) {
801
+				if (WP_DEBUG) {
802
+					foreach ($current_data_migration_script->get_errors() as $error) {
803
+						EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
804 804
 					}
805
-				}else{
806
-					EE_Error::add_error( __( 'There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', 'event_espresso' ) );
805
+				} else {
806
+					EE_Error::add_error(__('There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', 'event_espresso'));
807 807
 				}
808 808
 				return false;
809 809
 			}
810 810
 			EE_Data_Migration_Manager::instance()->update_current_database_state_to();
811
-		}else{
812
-			EE_Error::add_error( __( 'Could not determine most up-to-date data migration script from which to pull database schema structure. So database is probably not setup properly', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__);
811
+		} else {
812
+			EE_Error::add_error(__('Could not determine most up-to-date data migration script from which to pull database schema structure. So database is probably not setup properly', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
813 813
 			return false;
814 814
 		}
815 815
 		return true;
@@ -829,27 +829,27 @@  discard block
 block discarded – undo
829 829
 	public static function initialize_system_questions() {
830 830
 		// QUESTION GROUPS
831 831
 		global $wpdb;
832
-		$table_name = EEH_Activation::ensure_table_name_has_prefix( 'esp_question_group' );
832
+		$table_name = EEH_Activation::ensure_table_name_has_prefix('esp_question_group');
833 833
 		$SQL = "SELECT QSG_system FROM $table_name WHERE QSG_system != 0";
834 834
 		// what we have
835
-		$question_groups = $wpdb->get_col( $SQL );
835
+		$question_groups = $wpdb->get_col($SQL);
836 836
 		// check the response
837
-		$question_groups = is_array( $question_groups ) ? $question_groups : array();
837
+		$question_groups = is_array($question_groups) ? $question_groups : array();
838 838
 		// what we should have
839
-		$QSG_systems = array( 1, 2 );
839
+		$QSG_systems = array(1, 2);
840 840
 		// loop thru what we should have and compare to what we have
841
-		foreach ( $QSG_systems as $QSG_system ) {
841
+		foreach ($QSG_systems as $QSG_system) {
842 842
 			// reset values array
843 843
 			$QSG_values = array();
844 844
 			// if we don't have what we should have (but use $QST_system as as string because that's what we got from the db)
845
-			if ( ! in_array( "$QSG_system", $question_groups )) {
845
+			if ( ! in_array("$QSG_system", $question_groups)) {
846 846
 				// add it
847
-				switch ( $QSG_system ) {
847
+				switch ($QSG_system) {
848 848
 
849 849
 					case 1:
850 850
 							$QSG_values = array(
851
-									'QSG_name' => __( 'Personal Information', 'event_espresso' ),
852
-									'QSG_identifier' => 'personal-information-' . time(),
851
+									'QSG_name' => __('Personal Information', 'event_espresso'),
852
+									'QSG_identifier' => 'personal-information-'.time(),
853 853
 									'QSG_desc' => '',
854 854
 									'QSG_order' => 1,
855 855
 									'QSG_show_group_name' => 1,
@@ -861,8 +861,8 @@  discard block
 block discarded – undo
861 861
 
862 862
 					case 2:
863 863
 							$QSG_values = array(
864
-									'QSG_name' => __( 'Address Information','event_espresso' ),
865
-									'QSG_identifier' => 'address-information-' . time(),
864
+									'QSG_name' => __('Address Information', 'event_espresso'),
865
+									'QSG_identifier' => 'address-information-'.time(),
866 866
 									'QSG_desc' => '',
867 867
 									'QSG_order' => 2,
868 868
 									'QSG_show_group_name' => 1,
@@ -874,14 +874,14 @@  discard block
 block discarded – undo
874 874
 
875 875
 				}
876 876
 				// make sure we have some values before inserting them
877
-				if ( ! empty( $QSG_values )) {
877
+				if ( ! empty($QSG_values)) {
878 878
 					// insert system question
879 879
 					$wpdb->insert(
880 880
 						$table_name,
881 881
 						$QSG_values,
882
-						array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d' )
882
+						array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d')
883 883
 					);
884
-					$QSG_IDs[ $QSG_system ] = $wpdb->insert_id;
884
+					$QSG_IDs[$QSG_system] = $wpdb->insert_id;
885 885
 				}
886 886
 			}
887 887
 		}
@@ -890,10 +890,10 @@  discard block
 block discarded – undo
890 890
 
891 891
 		// QUESTIONS
892 892
 		global $wpdb;
893
-		$table_name = EEH_Activation::ensure_table_name_has_prefix( 'esp_question' );
893
+		$table_name = EEH_Activation::ensure_table_name_has_prefix('esp_question');
894 894
 		$SQL = "SELECT QST_system FROM $table_name WHERE QST_system != ''";
895 895
 		// what we have
896
-		$questions = $wpdb->get_col( $SQL );
896
+		$questions = $wpdb->get_col($SQL);
897 897
 		// what we should have
898 898
 		$QST_systems = array(
899 899
 			'fname',
@@ -910,25 +910,25 @@  discard block
 block discarded – undo
910 910
 		$order_for_group_1 = 1;
911 911
 		$order_for_group_2 = 1;
912 912
 		// loop thru what we should have and compare to what we have
913
-		foreach ( $QST_systems as $QST_system ) {
913
+		foreach ($QST_systems as $QST_system) {
914 914
 			// reset values array
915 915
 			$QST_values = array();
916 916
 			// if we don't have what we should have
917
-			if ( ! in_array( $QST_system, $questions )) {
917
+			if ( ! in_array($QST_system, $questions)) {
918 918
 				// add it
919
-				switch ( $QST_system ) {
919
+				switch ($QST_system) {
920 920
 
921 921
 					case 'fname':
922 922
 							$QST_values = array(
923
-									'QST_display_text' => __( 'First Name', 'event_espresso' ),
924
-									'QST_admin_label' => __( 'First Name - System Question', 'event_espresso' ),
923
+									'QST_display_text' => __('First Name', 'event_espresso'),
924
+									'QST_admin_label' => __('First Name - System Question', 'event_espresso'),
925 925
 									'QST_system' => 'fname',
926 926
 									'QST_type' => 'TEXT',
927 927
 									'QST_required' => 1,
928
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
928
+									'QST_required_text' => __('This field is required', 'event_espresso'),
929 929
 									'QST_order' => 1,
930 930
 									'QST_admin_only' => 0,
931
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
931
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
932 932
 									'QST_wp_user' => self::get_default_creator_id(),
933 933
 									'QST_deleted' => 0
934 934
 								);
@@ -936,15 +936,15 @@  discard block
 block discarded – undo
936 936
 
937 937
 					case 'lname':
938 938
 							$QST_values = array(
939
-									'QST_display_text' => __( 'Last Name', 'event_espresso' ),
940
-									'QST_admin_label' => __( 'Last Name - System Question', 'event_espresso' ),
939
+									'QST_display_text' => __('Last Name', 'event_espresso'),
940
+									'QST_admin_label' => __('Last Name - System Question', 'event_espresso'),
941 941
 									'QST_system' => 'lname',
942 942
 									'QST_type' => 'TEXT',
943 943
 									'QST_required' => 1,
944
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
944
+									'QST_required_text' => __('This field is required', 'event_espresso'),
945 945
 									'QST_order' => 2,
946 946
 									'QST_admin_only' => 0,
947
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
947
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
948 948
 									'QST_wp_user' => self::get_default_creator_id(),
949 949
 									'QST_deleted' => 0
950 950
 								);
@@ -952,15 +952,15 @@  discard block
 block discarded – undo
952 952
 
953 953
 					case 'email':
954 954
 							$QST_values = array(
955
-									'QST_display_text' => __( 'Email Address', 'event_espresso' ),
956
-									'QST_admin_label' => __( 'Email Address - System Question', 'event_espresso' ),
955
+									'QST_display_text' => __('Email Address', 'event_espresso'),
956
+									'QST_admin_label' => __('Email Address - System Question', 'event_espresso'),
957 957
 									'QST_system' => 'email',
958 958
 									'QST_type' => 'TEXT',
959 959
 									'QST_required' => 1,
960
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
960
+									'QST_required_text' => __('This field is required', 'event_espresso'),
961 961
 									'QST_order' => 3,
962 962
 									'QST_admin_only' => 0,
963
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
963
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
964 964
 									'QST_wp_user' => self::get_default_creator_id(),
965 965
 									'QST_deleted' => 0
966 966
 								);
@@ -968,15 +968,15 @@  discard block
 block discarded – undo
968 968
 
969 969
 					case 'address':
970 970
 							$QST_values = array(
971
-									'QST_display_text' => __( 'Address', 'event_espresso' ),
972
-									'QST_admin_label' => __( 'Address - System Question', 'event_espresso' ),
971
+									'QST_display_text' => __('Address', 'event_espresso'),
972
+									'QST_admin_label' => __('Address - System Question', 'event_espresso'),
973 973
 									'QST_system' => 'address',
974 974
 									'QST_type' => 'TEXT',
975 975
 									'QST_required' => 0,
976
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
976
+									'QST_required_text' => __('This field is required', 'event_espresso'),
977 977
 									'QST_order' => 4,
978 978
 									'QST_admin_only' => 0,
979
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
979
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
980 980
 									'QST_wp_user' => self::get_default_creator_id(),
981 981
 									'QST_deleted' => 0
982 982
 								);
@@ -984,15 +984,15 @@  discard block
 block discarded – undo
984 984
 
985 985
 					case 'address2':
986 986
 							$QST_values = array(
987
-									'QST_display_text' => __( 'Address2', 'event_espresso' ),
988
-									'QST_admin_label' => __( 'Address2 - System Question', 'event_espresso' ),
987
+									'QST_display_text' => __('Address2', 'event_espresso'),
988
+									'QST_admin_label' => __('Address2 - System Question', 'event_espresso'),
989 989
 									'QST_system' => 'address2',
990 990
 									'QST_type' => 'TEXT',
991 991
 									'QST_required' => 0,
992
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
992
+									'QST_required_text' => __('This field is required', 'event_espresso'),
993 993
 									'QST_order' => 5,
994 994
 									'QST_admin_only' => 0,
995
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
995
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
996 996
 									'QST_wp_user' => self::get_default_creator_id(),
997 997
 									'QST_deleted' => 0
998 998
 								);
@@ -1000,15 +1000,15 @@  discard block
 block discarded – undo
1000 1000
 
1001 1001
 					case 'city':
1002 1002
 							$QST_values = array(
1003
-									'QST_display_text' => __( 'City', 'event_espresso' ),
1004
-									'QST_admin_label' => __( 'City - System Question', 'event_espresso' ),
1003
+									'QST_display_text' => __('City', 'event_espresso'),
1004
+									'QST_admin_label' => __('City - System Question', 'event_espresso'),
1005 1005
 									'QST_system' => 'city',
1006 1006
 									'QST_type' => 'TEXT',
1007 1007
 									'QST_required' => 0,
1008
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
1008
+									'QST_required_text' => __('This field is required', 'event_espresso'),
1009 1009
 									'QST_order' => 6,
1010 1010
 									'QST_admin_only' => 0,
1011
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
1011
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1012 1012
 									'QST_wp_user' => self::get_default_creator_id(),
1013 1013
 									'QST_deleted' => 0
1014 1014
 								);
@@ -1016,12 +1016,12 @@  discard block
 block discarded – undo
1016 1016
 
1017 1017
 					case 'state':
1018 1018
 							$QST_values = array(
1019
-									'QST_display_text' => __( 'State/Province', 'event_espresso' ),
1020
-									'QST_admin_label' => __( 'State/Province - System Question', 'event_espresso' ),
1019
+									'QST_display_text' => __('State/Province', 'event_espresso'),
1020
+									'QST_admin_label' => __('State/Province - System Question', 'event_espresso'),
1021 1021
 									'QST_system' => 'state',
1022 1022
 									'QST_type' => 'STATE',
1023 1023
 									'QST_required' => 0,
1024
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
1024
+									'QST_required_text' => __('This field is required', 'event_espresso'),
1025 1025
 									'QST_order' => 7,
1026 1026
 									'QST_admin_only' => 0,
1027 1027
 									'QST_wp_user' => self::get_default_creator_id(),
@@ -1031,12 +1031,12 @@  discard block
 block discarded – undo
1031 1031
 
1032 1032
 					case 'country' :
1033 1033
 							$QST_values = array(
1034
-									'QST_display_text' => __( 'Country', 'event_espresso' ),
1035
-									'QST_admin_label' => __( 'Country - System Question', 'event_espresso' ),
1034
+									'QST_display_text' => __('Country', 'event_espresso'),
1035
+									'QST_admin_label' => __('Country - System Question', 'event_espresso'),
1036 1036
 									'QST_system' => 'country',
1037 1037
 									'QST_type' => 'COUNTRY',
1038 1038
 									'QST_required' => 0,
1039
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
1039
+									'QST_required_text' => __('This field is required', 'event_espresso'),
1040 1040
 									'QST_order' => 8,
1041 1041
 									'QST_admin_only' => 0,
1042 1042
 									'QST_wp_user' => self::get_default_creator_id(),
@@ -1046,15 +1046,15 @@  discard block
 block discarded – undo
1046 1046
 
1047 1047
 					case 'zip':
1048 1048
 							$QST_values = array(
1049
-									'QST_display_text' => __( 'Zip/Postal Code', 'event_espresso' ),
1050
-									'QST_admin_label' => __( 'Zip/Postal Code - System Question', 'event_espresso' ),
1049
+									'QST_display_text' => __('Zip/Postal Code', 'event_espresso'),
1050
+									'QST_admin_label' => __('Zip/Postal Code - System Question', 'event_espresso'),
1051 1051
 									'QST_system' => 'zip',
1052 1052
 									'QST_type' => 'TEXT',
1053 1053
 									'QST_required' => 0,
1054
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
1054
+									'QST_required_text' => __('This field is required', 'event_espresso'),
1055 1055
 									'QST_order' => 9,
1056 1056
 									'QST_admin_only' => 0,
1057
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
1057
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1058 1058
 									'QST_wp_user' => self::get_default_creator_id(),
1059 1059
 									'QST_deleted' => 0
1060 1060
 								);
@@ -1062,49 +1062,49 @@  discard block
 block discarded – undo
1062 1062
 
1063 1063
 					case 'phone':
1064 1064
 							$QST_values = array(
1065
-									'QST_display_text' => __( 'Phone Number', 'event_espresso' ),
1066
-									'QST_admin_label' => __( 'Phone Number - System Question', 'event_espresso' ),
1065
+									'QST_display_text' => __('Phone Number', 'event_espresso'),
1066
+									'QST_admin_label' => __('Phone Number - System Question', 'event_espresso'),
1067 1067
 									'QST_system' => 'phone',
1068 1068
 									'QST_type' => 'TEXT',
1069 1069
 									'QST_required' => 0,
1070
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
1070
+									'QST_required_text' => __('This field is required', 'event_espresso'),
1071 1071
 									'QST_order' => 10,
1072 1072
 									'QST_admin_only' => 0,
1073
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
1073
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1074 1074
 									'QST_wp_user' => self::get_default_creator_id(),
1075 1075
 									'QST_deleted' => 0
1076 1076
 								);
1077 1077
 						break;
1078 1078
 
1079 1079
 				}
1080
-				if ( ! empty( $QST_values )) {
1080
+				if ( ! empty($QST_values)) {
1081 1081
 					// insert system question
1082 1082
 					$wpdb->insert(
1083 1083
 						$table_name,
1084 1084
 						$QST_values,
1085
-						array( '%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d' )
1085
+						array('%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d')
1086 1086
 					);
1087 1087
 					$QST_ID = $wpdb->insert_id;
1088 1088
 
1089 1089
 					// QUESTION GROUP QUESTIONS
1090
-					if(  in_array( $QST_system, array( 'fname', 'lname', 'email' ) ) ) {
1090
+					if (in_array($QST_system, array('fname', 'lname', 'email'))) {
1091 1091
 						$system_question_we_want = EEM_Question_Group::system_personal;
1092 1092
 					} else {
1093 1093
 						$system_question_we_want = EEM_Question_Group::system_address;
1094 1094
 					}
1095
-					if( isset( $QSG_IDs[ $system_question_we_want ] ) ) {
1096
-						$QSG_ID = $QSG_IDs[ $system_question_we_want ];
1095
+					if (isset($QSG_IDs[$system_question_we_want])) {
1096
+						$QSG_ID = $QSG_IDs[$system_question_we_want];
1097 1097
 					} else {
1098
-						$id_col = EEM_Question_Group::instance()->get_col( array( array( 'QSG_system' => $system_question_we_want ) ) );
1099
-						if( is_array( $id_col ) ) {
1100
-							$QSG_ID = reset( $id_col );
1098
+						$id_col = EEM_Question_Group::instance()->get_col(array(array('QSG_system' => $system_question_we_want)));
1099
+						if (is_array($id_col)) {
1100
+							$QSG_ID = reset($id_col);
1101 1101
 						} else {
1102 1102
 							//ok so we didn't find it in the db either?? that's weird because we should have inserted it at the start of this method
1103 1103
                                                         EE_Log::instance()->log( 
1104 1104
                                                                 __FILE__, 
1105 1105
                                                                 __FUNCTION__, 
1106 1106
                                                                 sprintf( 
1107
-                                                                        __( 'Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), 
1107
+                                                                        __('Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), 
1108 1108
                                                                         $QST_ID ), 
1109 1109
                                                                 'error' );
1110 1110
                                                         continue;
@@ -1113,9 +1113,9 @@  discard block
 block discarded – undo
1113 1113
                                         
1114 1114
 					// add system questions to groups
1115 1115
 					$wpdb->insert(
1116
-						EEH_Activation::ensure_table_name_has_prefix( 'esp_question_group_question' ),
1117
-						array( 'QSG_ID' => $QSG_ID , 'QST_ID' => $QST_ID, 'QGQ_order'=>($QSG_ID==1)? $order_for_group_1++ : $order_for_group_2++ ),
1118
-						array( '%d', '%d','%d' )
1116
+						EEH_Activation::ensure_table_name_has_prefix('esp_question_group_question'),
1117
+						array('QSG_ID' => $QSG_ID, 'QST_ID' => $QST_ID, 'QGQ_order'=>($QSG_ID == 1) ? $order_for_group_1++ : $order_for_group_2++),
1118
+						array('%d', '%d', '%d')
1119 1119
 					);
1120 1120
 				}
1121 1121
 			}
@@ -1127,11 +1127,11 @@  discard block
 block discarded – undo
1127 1127
 	 * Makes sure the default payment method (Invoice) is active.
1128 1128
 	 * This used to be done automatically as part of constructing the old gateways config
1129 1129
 	 */
1130
-	public static function insert_default_payment_methods(){
1131
-		if( ! EEM_Payment_Method::instance()->count_active( EEM_Payment_Method::scope_cart ) ){
1132
-			EE_Registry::instance()->load_lib( 'Payment_Method_Manager' );
1133
-			EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( 'Invoice' );
1134
-		}else{
1130
+	public static function insert_default_payment_methods() {
1131
+		if ( ! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) {
1132
+			EE_Registry::instance()->load_lib('Payment_Method_Manager');
1133
+			EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice');
1134
+		} else {
1135 1135
 			EEM_Payment_Method::instance()->verify_button_urls();
1136 1136
 		}
1137 1137
 	}
@@ -1147,7 +1147,7 @@  discard block
 block discarded – undo
1147 1147
 
1148 1148
 		global $wpdb;
1149 1149
 
1150
-		if ( EEH_Activation::table_exists( EEM_Status::instance()->table() ) ) {
1150
+		if (EEH_Activation::table_exists(EEM_Status::instance()->table())) {
1151 1151
 
1152 1152
 			$table_name = EEM_Status::instance()->table();
1153 1153
 
@@ -1213,38 +1213,38 @@  discard block
 block discarded – undo
1213 1213
 	 * 	@return boolean success of verifying upload directories exist
1214 1214
 	 */
1215 1215
 	public static function create_upload_directories() {
1216
-		EE_Registry::instance()->load_helper( 'File' );
1216
+		EE_Registry::instance()->load_helper('File');
1217 1217
 		// Create the required folders
1218 1218
 		$folders = array(
1219 1219
 				EVENT_ESPRESSO_TEMPLATE_DIR,
1220 1220
 				EVENT_ESPRESSO_GATEWAY_DIR,
1221
-				EVENT_ESPRESSO_UPLOAD_DIR . 'logs/',
1222
-				EVENT_ESPRESSO_UPLOAD_DIR . 'css/',
1223
-				EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/'
1221
+				EVENT_ESPRESSO_UPLOAD_DIR.'logs/',
1222
+				EVENT_ESPRESSO_UPLOAD_DIR.'css/',
1223
+				EVENT_ESPRESSO_UPLOAD_DIR.'tickets/'
1224 1224
 		);
1225
-		foreach ( $folders as $folder ) {
1225
+		foreach ($folders as $folder) {
1226 1226
 			try {
1227
-				EEH_File::ensure_folder_exists_and_is_writable( $folder );
1228
-				@ chmod( $folder, 0755 );
1229
-			} catch( EE_Error $e ){
1227
+				EEH_File::ensure_folder_exists_and_is_writable($folder);
1228
+				@ chmod($folder, 0755);
1229
+			} catch (EE_Error $e) {
1230 1230
 				EE_Error::add_error(
1231 1231
 					sprintf(
1232
-						__(  'Could not create the folder at "%1$s" because: %2$s', 'event_espresso' ),
1232
+						__('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'),
1233 1233
 						$folder,
1234
-						'<br />' . $e->getMessage()
1234
+						'<br />'.$e->getMessage()
1235 1235
 					),
1236 1236
 					__FILE__, __FUNCTION__, __LINE__
1237 1237
 				);
1238 1238
 				//indicate we'll need to fix this later
1239
-				update_option( EEH_Activation::upload_directories_incomplete_option_name, true );
1239
+				update_option(EEH_Activation::upload_directories_incomplete_option_name, true);
1240 1240
 				return FALSE;
1241 1241
 			}
1242 1242
 		}
1243 1243
 		//just add the .htaccess file to the logs directory to begin with. Even if logging
1244 1244
 		//is disabled, there might be activation errors recorded in there
1245
-		EEH_File::add_htaccess_deny_from_all( EVENT_ESPRESSO_UPLOAD_DIR . 'logs/' );
1245
+		EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR.'logs/');
1246 1246
 		//remember EE's folders are all good
1247
-		delete_option( EEH_Activation::upload_directories_incomplete_option_name );
1247
+		delete_option(EEH_Activation::upload_directories_incomplete_option_name);
1248 1248
 		return TRUE;
1249 1249
 	}
1250 1250
 	
@@ -1257,7 +1257,7 @@  discard block
 block discarded – undo
1257 1257
 	 * @return boolean
1258 1258
 	 */
1259 1259
 	public static function upload_directories_incomplete() {
1260
-		return get_option( EEH_Activation::upload_directories_incomplete_option_name, false );
1260
+		return get_option(EEH_Activation::upload_directories_incomplete_option_name, false);
1261 1261
 	}
1262 1262
 
1263 1263
 
@@ -1276,16 +1276,16 @@  discard block
 block discarded – undo
1276 1276
 		$installed_messengers = $default_messengers = array();
1277 1277
 
1278 1278
 		//include our helper
1279
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
1279
+		EE_Registry::instance()->load_helper('MSG_Template');
1280 1280
 
1281 1281
 		//get all installed messenger objects
1282 1282
 		$installed = EEH_MSG_Template::get_installed_message_objects();
1283 1283
 
1284 1284
 		//let's setup the $installed messengers in an array AND the messengers that are set to be activated on install.
1285
-		foreach ( $installed['messengers'] as $msgr ) {
1286
-			if ( $msgr instanceof EE_messenger ) {
1285
+		foreach ($installed['messengers'] as $msgr) {
1286
+			if ($msgr instanceof EE_messenger) {
1287 1287
 				$installed_messengers[$msgr->name] = $msgr;
1288
-				if ( $msgr->activate_on_install ) {
1288
+				if ($msgr->activate_on_install) {
1289 1289
 					$default_messengers[] = $msgr->name;
1290 1290
 				}
1291 1291
 			}
@@ -1295,36 +1295,36 @@  discard block
 block discarded – undo
1295 1295
 		$active_messengers = EEH_MSG_Template::get_active_messengers_in_db();
1296 1296
 
1297 1297
 		//things that have already been activated before
1298
-		$has_activated = get_option( 'ee_has_activated_messenger' );
1298
+		$has_activated = get_option('ee_has_activated_messenger');
1299 1299
 
1300 1300
 		//do an initial loop to determine if we need to continue
1301 1301
 		$def_ms = array();
1302
-		foreach ( $default_messengers as $msgr ) {
1303
-			if ( isset($active_messengers[$msgr] ) || isset( $has_activated[$msgr] ) ) continue;
1302
+		foreach ($default_messengers as $msgr) {
1303
+			if (isset($active_messengers[$msgr]) || isset($has_activated[$msgr])) continue;
1304 1304
 			$def_ms[] = $msgr;
1305 1305
 		}
1306 1306
 
1307 1307
 		//setup the $installed_mts in an array
1308
-		foreach ( $installed['message_types'] as $imt ) {
1309
-			if ( $imt instanceof EE_message_type ) {
1308
+		foreach ($installed['message_types'] as $imt) {
1309
+			if ($imt instanceof EE_message_type) {
1310 1310
 				$installed_mts[$imt->name] = $imt;
1311 1311
 			}
1312 1312
 		}
1313 1313
 
1314 1314
 		//loop through default array for default messengers (if present)
1315
-		if ( ! empty( $def_ms ) ) {
1316
-			foreach ( $def_ms as $messenger ) {
1315
+		if ( ! empty($def_ms)) {
1316
+			foreach ($def_ms as $messenger) {
1317 1317
 				//all is good so let's setup the default stuff. We need to use the given messenger object (if exists) to get the default message type for the messenger.
1318
-				if ( ! isset( $installed_messengers[$messenger] )) {
1318
+				if ( ! isset($installed_messengers[$messenger])) {
1319 1319
 					continue;
1320 1320
 				}
1321 1321
 				/** @var EE_messenger[] $installed_messengers  */
1322 1322
 				$default_mts = $installed_messengers[$messenger]->get_default_message_types();
1323 1323
 				$active_messengers[$messenger]['obj'] = $installed_messengers[$messenger];
1324
-				foreach ( $default_mts as $index => $mt ) {
1324
+				foreach ($default_mts as $index => $mt) {
1325 1325
 					//is there an installed_mt matching the default string?  If not then nothing to do here.
1326
-					if ( ! isset( $installed_mts[$mt] ) ) {
1327
-						unset( $default_mts[$index] );
1326
+					if ( ! isset($installed_mts[$mt])) {
1327
+						unset($default_mts[$index]);
1328 1328
 						continue;
1329 1329
 					}
1330 1330
 
@@ -1333,41 +1333,41 @@  discard block
 block discarded – undo
1333 1333
 					/** @var EE_message_type[] $installed_mts */
1334 1334
 					$settings_fields = $installed_mts[$mt]->get_admin_settings_fields();
1335 1335
 					$settings = array();
1336
-					if ( is_array( $settings_fields ) ) {
1337
-						foreach ( $settings_fields as $field => $values ) {
1338
-							if ( isset( $values['default'] ) ) {
1336
+					if (is_array($settings_fields)) {
1337
+						foreach ($settings_fields as $field => $values) {
1338
+							if (isset($values['default'])) {
1339 1339
 								$settings[$field] = $values['default'];
1340 1340
 							}
1341 1341
 						}
1342 1342
 					}
1343 1343
 
1344
-					$active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt]['settings'] = $settings;
1344
+					$active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt]['settings'] = $settings;
1345 1345
 					$has_activated[$messenger][] = $mt;
1346 1346
 				}
1347 1347
 
1348 1348
 				//setup any initial settings for the messenger
1349 1349
 				$msgr_settings = $installed_messengers[$messenger]->get_admin_settings_fields();
1350 1350
 
1351
-				if ( !empty( $msgr_settings ) ) {
1352
-					foreach ( $msgr_settings as $field => $value ) {
1351
+				if ( ! empty($msgr_settings)) {
1352
+					foreach ($msgr_settings as $field => $value) {
1353 1353
 						$active_messengers[$messenger]['settings'][$field] = $value;
1354 1354
 					}
1355 1355
 				}
1356 1356
 
1357 1357
 				//now let's save the settings for this messenger! Must do now because the validator checks the db for active messengers to validate.
1358
-				EEH_MSG_Template::update_active_messengers_in_db( $active_messengers );
1358
+				EEH_MSG_Template::update_active_messengers_in_db($active_messengers);
1359 1359
 
1360 1360
 				//let's generate all the templates but only if the messenger has default_mts (otherwise its just activated).
1361
-				if ( !empty( $default_mts ) ) {
1362
-					$success = EEH_MSG_Template::generate_new_templates( $messenger, $default_mts, '', TRUE );
1361
+				if ( ! empty($default_mts)) {
1362
+					$success = EEH_MSG_Template::generate_new_templates($messenger, $default_mts, '', TRUE);
1363 1363
 				}
1364 1364
 			}
1365 1365
 		} //end check for empty( $def_ms )
1366 1366
 
1367 1367
 		//still need to see if there are any message types to activate for active messengers
1368
-		foreach ( $active_messengers as $messenger => $settings ) {
1368
+		foreach ($active_messengers as $messenger => $settings) {
1369 1369
 			$msg_obj = $settings['obj'];
1370
-			if ( ! $msg_obj instanceof EE_messenger ) {
1370
+			if ( ! $msg_obj instanceof EE_messenger) {
1371 1371
 				continue;
1372 1372
 			}
1373 1373
 
@@ -1375,45 +1375,45 @@  discard block
 block discarded – undo
1375 1375
 			$new_default_mts = array();
1376 1376
 
1377 1377
 			//loop through each default mt reported by the messenger and make sure its set in its active db entry.
1378
-			foreach( $all_default_mts as $index => $mt ) {
1378
+			foreach ($all_default_mts as $index => $mt) {
1379 1379
 				//already active? already has generated templates? || has already been activated before (we dont' want to reactivate things users intentionally deactivated).
1380
-				if ( ( isset( $has_activated[$messenger] ) && in_array($mt, $has_activated[$messenger]) ) || isset( $active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt] ) ||  EEH_MSG_Template::already_generated( $messenger, $mt, 0, FALSE ) ) {
1380
+				if ((isset($has_activated[$messenger]) && in_array($mt, $has_activated[$messenger])) || isset($active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt]) || EEH_MSG_Template::already_generated($messenger, $mt, 0, FALSE)) {
1381 1381
 					continue;
1382 1382
 				}
1383 1383
 
1384 1384
 				//is there an installed_mt matching the default string?  If not then nothing to do here.
1385
-				if ( ! isset( $installed_mts[$mt] ) ) {
1386
-					unset( $all_default_mts[$mt] );
1385
+				if ( ! isset($installed_mts[$mt])) {
1386
+					unset($all_default_mts[$mt]);
1387 1387
 					continue;
1388 1388
 				}
1389 1389
 
1390 1390
 				$settings_fields = $installed_mts[$mt]->get_admin_settings_fields();
1391 1391
 				$settings = array();
1392
-				if ( is_array( $settings_fields ) ) {
1393
-					foreach ( $settings_fields as $field => $values ) {
1394
-						if ( isset( $values['default'] ) ) {
1392
+				if (is_array($settings_fields)) {
1393
+					foreach ($settings_fields as $field => $values) {
1394
+						if (isset($values['default'])) {
1395 1395
 							$settings[$field] = $values['default'];
1396 1396
 						}
1397 1397
 					}
1398 1398
 				}
1399 1399
 
1400
-				$active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt]['settings'] = $settings;
1400
+				$active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt]['settings'] = $settings;
1401 1401
 				$new_default_mts[] = $mt;
1402 1402
 				$has_activated[$messenger][] = $mt;
1403 1403
 			}
1404 1404
 
1405 1405
 
1406
-			if ( ! empty( $new_default_mts ) ) {
1407
-				$success = EEH_MSG_Template::generate_new_templates( $messenger, $new_default_mts, '', TRUE );
1406
+			if ( ! empty($new_default_mts)) {
1407
+				$success = EEH_MSG_Template::generate_new_templates($messenger, $new_default_mts, '', TRUE);
1408 1408
 			}
1409 1409
 
1410 1410
 		}
1411 1411
 
1412 1412
 		//now let's save the settings for this messenger!
1413
-		EEH_MSG_Template::update_active_messengers_in_db( $active_messengers );
1413
+		EEH_MSG_Template::update_active_messengers_in_db($active_messengers);
1414 1414
 
1415 1415
 		//update $has_activated record
1416
-		update_option( 'ee_has_activated_messenger', $has_activated );
1416
+		update_option('ee_has_activated_messenger', $has_activated);
1417 1417
 
1418 1418
 		//that's it!
1419 1419
 		return $success;
@@ -1433,47 +1433,47 @@  discard block
 block discarded – undo
1433 1433
 	 */
1434 1434
 	public static function validate_messages_system() {
1435 1435
 		//include our helper
1436
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
1436
+		EE_Registry::instance()->load_helper('MSG_Template');
1437 1437
 
1438 1438
 		//get active and installed  messengers/message types.
1439 1439
 		$active_messengers = EEH_MSG_Template::get_active_messengers_in_db();
1440 1440
 		$installed = EEH_MSG_Template::get_installed_message_objects();
1441 1441
 		$installed_messengers = $installed_mts = array();
1442 1442
 		//set up the arrays so they can be handled easier.
1443
-		foreach( $installed['messengers'] as $im ) {
1444
-			if ( $im instanceof EE_messenger ) {
1443
+		foreach ($installed['messengers'] as $im) {
1444
+			if ($im instanceof EE_messenger) {
1445 1445
 				$installed_messengers[$im->name] = $im;
1446 1446
 			}
1447 1447
 		}
1448
-		foreach( $installed['message_types'] as $imt ) {
1449
-			if ( $imt instanceof EE_message_type ) {
1448
+		foreach ($installed['message_types'] as $imt) {
1449
+			if ($imt instanceof EE_message_type) {
1450 1450
 				$installed_mts[$imt->name] = $imt;
1451 1451
 			}
1452 1452
 		}
1453 1453
 
1454 1454
 		//now let's loop through the active array and validate
1455
-		foreach( $active_messengers as $messenger => $active_details ) {
1455
+		foreach ($active_messengers as $messenger => $active_details) {
1456 1456
 			//first let's see if this messenger is installed.
1457
-			if ( ! isset( $installed_messengers[$messenger] ) ) {
1457
+			if ( ! isset($installed_messengers[$messenger])) {
1458 1458
 				//not set so let's just remove from actives and make sure templates are inactive.
1459
-				unset( $active_messengers[$messenger] );
1460
-				EEH_MSG_Template::update_to_inactive( $messenger );
1459
+				unset($active_messengers[$messenger]);
1460
+				EEH_MSG_Template::update_to_inactive($messenger);
1461 1461
 				continue;
1462 1462
 			}
1463 1463
 
1464 1464
 			//messenger is active, so let's just make sure that any active message types not installed are deactivated.
1465
-			$mts = ! empty( $active_details['settings'][$messenger . '-message_types'] ) ? $active_details['settings'][$messenger . '-message_types'] : array();
1466
-			foreach ( $mts as $mt_name => $mt ) {
1467
-				if ( ! isset( $installed_mts[$mt_name] )  ) {
1468
-					unset( $active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt_name] );
1469
-					EEH_MSG_Template::update_to_inactive( $messenger, $mt_name );
1465
+			$mts = ! empty($active_details['settings'][$messenger.'-message_types']) ? $active_details['settings'][$messenger.'-message_types'] : array();
1466
+			foreach ($mts as $mt_name => $mt) {
1467
+				if ( ! isset($installed_mts[$mt_name])) {
1468
+					unset($active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt_name]);
1469
+					EEH_MSG_Template::update_to_inactive($messenger, $mt_name);
1470 1470
 				}
1471 1471
 			}
1472 1472
 		}
1473 1473
 
1474 1474
 		//all done! let's update the active_messengers.
1475
-		EEH_MSG_Template::update_active_messengers_in_db( $active_messengers );
1476
-		do_action( 'AHEE__EEH_Activation__validate_messages_system' );
1475
+		EEH_MSG_Template::update_active_messengers_in_db($active_messengers);
1476
+		do_action('AHEE__EEH_Activation__validate_messages_system');
1477 1477
 		return;
1478 1478
 	}
1479 1479
 
@@ -1487,12 +1487,12 @@  discard block
 block discarded – undo
1487 1487
 	 * 	@static
1488 1488
 	 * 	@return void
1489 1489
 	 */
1490
-	public static function create_no_ticket_prices_array(){
1490
+	public static function create_no_ticket_prices_array() {
1491 1491
 		// this creates an array for tracking events that have no active ticket prices created
1492 1492
 		// this allows us to warn admins of the situation so that it can be corrected
1493
-		$espresso_no_ticket_prices = get_option( 'ee_no_ticket_prices', FALSE );
1494
-		if ( ! $espresso_no_ticket_prices ) {
1495
-			add_option( 'ee_no_ticket_prices', array(), '', FALSE );
1493
+		$espresso_no_ticket_prices = get_option('ee_no_ticket_prices', FALSE);
1494
+		if ( ! $espresso_no_ticket_prices) {
1495
+			add_option('ee_no_ticket_prices', array(), '', FALSE);
1496 1496
 		}
1497 1497
 	}
1498 1498
 
@@ -1514,24 +1514,24 @@  discard block
 block discarded – undo
1514 1514
 	 * Finds all our EE4 custom post types, and deletes them and their associated data (like post meta or term relations)/
1515 1515
 	 * @global wpdb $wpdb
1516 1516
 	 */
1517
-	public static function delete_all_espresso_cpt_data(){
1517
+	public static function delete_all_espresso_cpt_data() {
1518 1518
 		global $wpdb;
1519 1519
 		//get all the CPT post_types
1520 1520
 		$ee_post_types = array();
1521
-		foreach(EE_Registry::instance()->non_abstract_db_models as $model_name){
1522
-			if ( method_exists( $model_name, 'instance' )) {
1523
-				$model_obj = call_user_func( array( $model_name, 'instance' ));
1524
-				if ( $model_obj instanceof EEM_CPT_Base ) {
1525
-					$ee_post_types[] = $wpdb->prepare("%s",$model_obj->post_type());
1521
+		foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
1522
+			if (method_exists($model_name, 'instance')) {
1523
+				$model_obj = call_user_func(array($model_name, 'instance'));
1524
+				if ($model_obj instanceof EEM_CPT_Base) {
1525
+					$ee_post_types[] = $wpdb->prepare("%s", $model_obj->post_type());
1526 1526
 				}
1527 1527
 			}
1528 1528
 		}
1529 1529
 		//get all our CPTs
1530
-		$query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",",$ee_post_types).")";
1530
+		$query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",", $ee_post_types).")";
1531 1531
 		$cpt_ids = $wpdb->get_col($query);
1532 1532
 		//delete each post meta and term relations too
1533
-		foreach($cpt_ids as $post_id){
1534
-			wp_delete_post($post_id,true);
1533
+		foreach ($cpt_ids as $post_id) {
1534
+			wp_delete_post($post_id, true);
1535 1535
 		}
1536 1536
 	}
1537 1537
 
@@ -1545,18 +1545,18 @@  discard block
 block discarded – undo
1545 1545
 	 * @param bool $remove_all
1546 1546
 	 * @return void
1547 1547
 	 */
1548
-	public static function delete_all_espresso_tables_and_data( $remove_all = true ) {
1548
+	public static function delete_all_espresso_tables_and_data($remove_all = true) {
1549 1549
 		global $wpdb;
1550 1550
 		$undeleted_tables = array();
1551 1551
 
1552 1552
 		// load registry
1553
-		foreach( EE_Registry::instance()->non_abstract_db_models as $model_name ){
1554
-			if ( method_exists( $model_name, 'instance' )) {
1555
-				$model_obj = call_user_func( array( $model_name, 'instance' ));
1556
-				if ( $model_obj instanceof EEM_Base ) {
1557
-					foreach ( $model_obj->get_tables() as $table ) {
1558
-						if ( strpos( $table->get_table_name(), 'esp_' )) {
1559
-							switch ( EEH_Activation::delete_unused_db_table( $table->get_table_name() )) {
1553
+		foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
1554
+			if (method_exists($model_name, 'instance')) {
1555
+				$model_obj = call_user_func(array($model_name, 'instance'));
1556
+				if ($model_obj instanceof EEM_Base) {
1557
+					foreach ($model_obj->get_tables() as $table) {
1558
+						if (strpos($table->get_table_name(), 'esp_')) {
1559
+							switch (EEH_Activation::delete_unused_db_table($table->get_table_name())) {
1560 1560
 								case false :
1561 1561
 									$undeleted_tables[] = $table->get_table_name();
1562 1562
 								break;
@@ -1581,8 +1581,8 @@  discard block
 block discarded – undo
1581 1581
 			'esp_promotion_rule',
1582 1582
 			'esp_rule'
1583 1583
 		);
1584
-		foreach( $tables_without_models as $table ){
1585
-			EEH_Activation::delete_db_table_if_empty( $table );
1584
+		foreach ($tables_without_models as $table) {
1585
+			EEH_Activation::delete_db_table_if_empty($table);
1586 1586
 		}
1587 1587
 
1588 1588
 
@@ -1620,58 +1620,58 @@  discard block
 block discarded – undo
1620 1620
 			'ee_job_parameters_' => false,
1621 1621
 			'ee_upload_directories_incomplete' => true,
1622 1622
 		);
1623
-		if( is_main_site() ) {
1624
-			$wp_options_to_delete[ 'ee_network_config' ] = true;
1623
+		if (is_main_site()) {
1624
+			$wp_options_to_delete['ee_network_config'] = true;
1625 1625
 		}
1626 1626
 
1627 1627
 		$undeleted_options = array();
1628
-		foreach ( $wp_options_to_delete as $option_name => $no_wildcard ) {
1628
+		foreach ($wp_options_to_delete as $option_name => $no_wildcard) {
1629 1629
 
1630
-			if( $no_wildcard ){
1631
-				if( ! delete_option( $option_name ) ){
1630
+			if ($no_wildcard) {
1631
+				if ( ! delete_option($option_name)) {
1632 1632
 					$undeleted_options[] = $option_name;
1633 1633
 				}
1634
-			}else{
1635
-				$option_names_to_delete_from_wildcard = $wpdb->get_col( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'" );
1636
-				foreach($option_names_to_delete_from_wildcard as $option_name_from_wildcard ){
1637
-					if( ! delete_option( $option_name_from_wildcard ) ){
1634
+			} else {
1635
+				$option_names_to_delete_from_wildcard = $wpdb->get_col("SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'");
1636
+				foreach ($option_names_to_delete_from_wildcard as $option_name_from_wildcard) {
1637
+					if ( ! delete_option($option_name_from_wildcard)) {
1638 1638
 						$undeleted_options[] = $option_name_from_wildcard;
1639 1639
 					}
1640 1640
 				}
1641 1641
 			}
1642 1642
 		}
1643 1643
                 //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it
1644
-                remove_action( 'shutdown', array( EE_Config::instance(), 'shutdown' ), 10 );
1644
+                remove_action('shutdown', array(EE_Config::instance(), 'shutdown'), 10);
1645 1645
 
1646
-		if ( $remove_all && $espresso_db_update = get_option( 'espresso_db_update' )) {
1646
+		if ($remove_all && $espresso_db_update = get_option('espresso_db_update')) {
1647 1647
 			$db_update_sans_ee4 = array();
1648
-			foreach($espresso_db_update as $version => $times_activated){
1649
-				if( $version[0] =='3'){//if its NON EE4
1648
+			foreach ($espresso_db_update as $version => $times_activated) {
1649
+				if ($version[0] == '3') {//if its NON EE4
1650 1650
 					$db_update_sans_ee4[$version] = $times_activated;
1651 1651
 				}
1652 1652
 			}
1653
-			update_option( 'espresso_db_update', $db_update_sans_ee4 );
1653
+			update_option('espresso_db_update', $db_update_sans_ee4);
1654 1654
 		}
1655 1655
 
1656 1656
 		$errors = '';
1657
-		if ( ! empty( $undeleted_tables )) {
1657
+		if ( ! empty($undeleted_tables)) {
1658 1658
 			$errors .= sprintf(
1659
-				__( 'The following tables could not be deleted: %s%s', 'event_espresso' ),
1659
+				__('The following tables could not be deleted: %s%s', 'event_espresso'),
1660 1660
 				'<br/>',
1661
-				implode( ',<br/>', $undeleted_tables )
1661
+				implode(',<br/>', $undeleted_tables)
1662 1662
 			);
1663 1663
 		}
1664
-		if ( ! empty( $undeleted_options )) {
1665
-			$errors .= ! empty( $undeleted_tables ) ? '<br/>' : '';
1664
+		if ( ! empty($undeleted_options)) {
1665
+			$errors .= ! empty($undeleted_tables) ? '<br/>' : '';
1666 1666
 			$errors .= sprintf(
1667
-				__( 'The following wp-options could not be deleted: %s%s', 'event_espresso' ),
1667
+				__('The following wp-options could not be deleted: %s%s', 'event_espresso'),
1668 1668
 				'<br/>',
1669
-				implode( ',<br/>', $undeleted_options )
1669
+				implode(',<br/>', $undeleted_options)
1670 1670
 			);
1671 1671
 
1672 1672
 		}
1673
-		if ( $errors != '' ) {
1674
-			EE_Error::add_attention( $errors, __FILE__, __FUNCTION__, __LINE__ );
1673
+		if ($errors != '') {
1674
+			EE_Error::add_attention($errors, __FILE__, __FUNCTION__, __LINE__);
1675 1675
 		}
1676 1676
 	}
1677 1677
 
@@ -1681,23 +1681,23 @@  discard block
 block discarded – undo
1681 1681
 	 * @param string $table_name with or without $wpdb->prefix
1682 1682
 	 * @return boolean
1683 1683
 	 */
1684
-	public static function table_exists( $table_name ){
1684
+	public static function table_exists($table_name) {
1685 1685
 		global $wpdb, $EZSQL_ERROR;
1686
-		$table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name );
1686
+		$table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
1687 1687
 		//ignore if this causes an sql error
1688 1688
 		$old_error = $wpdb->last_error;
1689 1689
 		$old_suppress_errors = $wpdb->suppress_errors();
1690
-		$old_show_errors_value = $wpdb->show_errors( FALSE );
1690
+		$old_show_errors_value = $wpdb->show_errors(FALSE);
1691 1691
 		$ezsql_error_cache = $EZSQL_ERROR;
1692
-		$wpdb->get_results( "SELECT * from $table_name LIMIT 1");
1693
-		$wpdb->show_errors( $old_show_errors_value );
1694
-		$wpdb->suppress_errors( $old_suppress_errors );
1692
+		$wpdb->get_results("SELECT * from $table_name LIMIT 1");
1693
+		$wpdb->show_errors($old_show_errors_value);
1694
+		$wpdb->suppress_errors($old_suppress_errors);
1695 1695
 		$new_error = $wpdb->last_error;
1696 1696
 		$wpdb->last_error = $old_error;
1697 1697
 		$EZSQL_ERROR = $ezsql_error_cache;
1698
-		if( empty( $new_error ) ){
1698
+		if (empty($new_error)) {
1699 1699
 			return TRUE;
1700
-		}else{
1700
+		} else {
1701 1701
 			return FALSE;
1702 1702
 		}
1703 1703
 	}
@@ -1705,7 +1705,7 @@  discard block
 block discarded – undo
1705 1705
 	/**
1706 1706
 	 * Resets the cache on EEH_Activation
1707 1707
 	 */
1708
-	public static function reset(){
1708
+	public static function reset() {
1709 1709
 		self::$_default_creator_id = NULL;
1710 1710
 		self::$_initialized_db_content_already_in_this_request = false;
1711 1711
 	}
Please login to merge, or discard this patch.