Completed
Branch BETA-4.9-messages-queue-fixed (941081)
by
unknown
17:38 queued 10s
created
core/helpers/EEH_Export.helper.php 3 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -87,13 +87,13 @@
 block discarded – undo
87 87
 
88 88
 	 /**
89 89
 	  *
90
-	 *	Writes a row to the csv file
91
-	 *	@param array $row - individual row of csv data
92
-	 *	@param string $delimiter - csv delimiter
93
-	 *	@param string $enclosure - csv enclosure
94
-	 *	@param bool $mysql_null - allows php NULL to be overridden with MySQl's insertable NULL value
95
-	 *	@return string of text for teh csv file
96
-	 */
90
+	  *	Writes a row to the csv file
91
+	  *	@param array $row - individual row of csv data
92
+	  *	@param string $delimiter - csv delimiter
93
+	  *	@param string $enclosure - csv enclosure
94
+	  *	@param bool $mysql_null - allows php NULL to be overridden with MySQl's insertable NULL value
95
+	  *	@return string of text for teh csv file
96
+	  */
97 97
 	public static function get_csv_row ( array $row, $delimiter = ',', $enclosure = '"', $mysql_null = false ) {
98 98
 		//Allow user to filter the csv delimiter and enclosure for other countries csv standards
99 99
 		$delimiter = apply_filters( 'FHEE__EE_CSV__fputcsv2__delimiter', $delimiter );
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 * @param EE_Model_Field_Base $field
31 31
 	 * @return string
32 32
 	 */
33
-	public static function get_column_name_for_field(EE_Model_Field_Base $field){
33
+	public static function get_column_name_for_field(EE_Model_Field_Base $field) {
34 34
 		return $field->get_nicename()."[".$field->get_name()."]";
35 35
 	}
36 36
 
@@ -52,32 +52,32 @@  discard block
 block discarded – undo
52 52
 	 * 						we consider that a success (because we wrote everything there was...nothing)
53 53
 	 * @throws EE_Error
54 54
 	 */
55
-	public static function write_data_array_to_csv( $filepath, $data, $write_column_headers = true ){
55
+	public static function write_data_array_to_csv($filepath, $data, $write_column_headers = true) {
56 56
 		EE_Registry::instance()->load_helper('Array');
57 57
 
58 58
 		$new_file_contents = '';
59 59
 		//determine if $data is actually a 2d array
60
-		if ( $data && is_array($data) && is_array(EEH_Array::get_one_item_from_array($data))){
60
+		if ($data && is_array($data) && is_array(EEH_Array::get_one_item_from_array($data))) {
61 61
 			//make sure top level is numerically indexed,
62 62
 
63
-			if( EEH_Array::is_associative_array($data)){
64
-				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))));
63
+			if (EEH_Array::is_associative_array($data)) {
64
+				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))));
65 65
 			}
66 66
 			$item_in_top_level_array = EEH_Array::get_one_item_from_array($data);
67 67
 			//now, is the last item in the top-level array of $data an associative or numeric array?
68
-			if( $write_column_headers &&
69
-					EEH_Array::is_associative_array($item_in_top_level_array)){
68
+			if ($write_column_headers &&
69
+					EEH_Array::is_associative_array($item_in_top_level_array)) {
70 70
 				//its associative, so we want to output its keys as column headers
71 71
 				$keys = array_keys($item_in_top_level_array);
72
-				$new_file_contents .=  EEH_Export::get_csv_row( $keys );
72
+				$new_file_contents .= EEH_Export::get_csv_row($keys);
73 73
 
74 74
 			}
75 75
 			//start writing data
76
-			foreach($data as $data_row){
77
-				$new_file_contents .= EEH_Export::get_csv_row( $data_row);
76
+			foreach ($data as $data_row) {
77
+				$new_file_contents .= EEH_Export::get_csv_row($data_row);
78 78
 			}
79
-			return EEH_File::write_to_file( $filepath, EEH_File::get_file_contents( $filepath ) . $new_file_contents );
80
-		}else{
79
+			return EEH_File::write_to_file($filepath, EEH_File::get_file_contents($filepath).$new_file_contents);
80
+		} else {
81 81
 			//no data TO write... so we can assume that's a success
82 82
 			return true;
83 83
 		}
@@ -94,29 +94,29 @@  discard block
 block discarded – undo
94 94
 	 *	@param bool $mysql_null - allows php NULL to be overridden with MySQl's insertable NULL value
95 95
 	 *	@return string of text for teh csv file
96 96
 	 */
97
-	public static function get_csv_row ( array $row, $delimiter = ',', $enclosure = '"', $mysql_null = false ) {
97
+	public static function get_csv_row(array $row, $delimiter = ',', $enclosure = '"', $mysql_null = false) {
98 98
 		//Allow user to filter the csv delimiter and enclosure for other countries csv standards
99
-		$delimiter = apply_filters( 'FHEE__EE_CSV__fputcsv2__delimiter', $delimiter );
100
-		$enclosure = apply_filters( 'FHEE__EE_CSV__fputcsv2__enclosure', $enclosure );
99
+		$delimiter = apply_filters('FHEE__EE_CSV__fputcsv2__delimiter', $delimiter);
100
+		$enclosure = apply_filters('FHEE__EE_CSV__fputcsv2__enclosure', $enclosure);
101 101
 
102 102
 		$delimiter_esc = preg_quote($delimiter, '/');
103 103
 		$enclosure_esc = preg_quote($enclosure, '/');
104 104
 
105 105
 		$output = array();
106 106
 		foreach ($row as $field_value) {
107
-			if(is_object($field_value) || is_array($field_value)){
107
+			if (is_object($field_value) || is_array($field_value)) {
108 108
 				$field_value = serialize($field_value);
109 109
 			}
110
-			if ($field_value === null && $mysql_null ) {
110
+			if ($field_value === null && $mysql_null) {
111 111
 				$output[] = 'NULL';
112 112
 				continue;
113 113
 			}
114 114
 
115 115
 			$output[] = preg_match("/(?:${delimiter_esc}|${enclosure_esc}|\s)/", $field_value) ?
116
-				( $enclosure . str_replace($enclosure, $enclosure . $enclosure, $field_value) . $enclosure ) : $field_value;
116
+				($enclosure.str_replace($enclosure, $enclosure.$enclosure, $field_value).$enclosure) : $field_value;
117 117
 		}
118 118
 
119
-		return  implode($delimiter, $output) . PHP_EOL;
119
+		return  implode($delimiter, $output).PHP_EOL;
120 120
 	}
121 121
 
122 122
 
@@ -129,19 +129,19 @@  discard block
 block discarded – undo
129 129
 	 * @param boolean|string $pretty_schema true to display pretty, a string to use a specific "Schema", or false to NOT display pretty
130 130
 	 * @return string
131 131
 	 */
132
-	public static function prepare_value_from_db_for_display( $model, $field_name,  $raw_db_value, $pretty_schema = true ) {
133
-		$field_obj = $model->field_settings_for( $field_name );
134
-		$value_on_model_obj = $field_obj->prepare_for_set_from_db( $raw_db_value );
135
-		if( $field_obj instanceof EE_Datetime_Field ) {
136
-			$field_obj->set_date_format( EEH_Export::get_date_format_for_export( $field_obj->get_date_format( $pretty_schema ) ), $pretty_schema );
137
-			$field_obj->set_time_format( EEH_Export::get_time_format_for_export( $field_obj->get_time_format( $pretty_schema ) ), $pretty_schema );
132
+	public static function prepare_value_from_db_for_display($model, $field_name, $raw_db_value, $pretty_schema = true) {
133
+		$field_obj = $model->field_settings_for($field_name);
134
+		$value_on_model_obj = $field_obj->prepare_for_set_from_db($raw_db_value);
135
+		if ($field_obj instanceof EE_Datetime_Field) {
136
+			$field_obj->set_date_format(EEH_Export::get_date_format_for_export($field_obj->get_date_format($pretty_schema)), $pretty_schema);
137
+			$field_obj->set_time_format(EEH_Export::get_time_format_for_export($field_obj->get_time_format($pretty_schema)), $pretty_schema);
138 138
 		}
139
-		if( $pretty_schema === true){
140
-			return $field_obj->prepare_for_pretty_echoing( $value_on_model_obj );
141
-		}elseif( is_string( $pretty_schema ) ) {
142
-			return $field_obj->prepare_for_pretty_echoing($value_on_model_obj, $pretty_schema );
143
-		}else{
144
-			return $field_obj->prepare_for_get( $value_on_model_obj );
139
+		if ($pretty_schema === true) {
140
+			return $field_obj->prepare_for_pretty_echoing($value_on_model_obj);
141
+		}elseif (is_string($pretty_schema)) {
142
+			return $field_obj->prepare_for_pretty_echoing($value_on_model_obj, $pretty_schema);
143
+		} else {
144
+			return $field_obj->prepare_for_get($value_on_model_obj);
145 145
 		}
146 146
 	}
147 147
 
@@ -152,8 +152,8 @@  discard block
 block discarded – undo
152 152
 	 * @param string $current_format
153 153
 	 * @return string
154 154
 	 */
155
-	public static function get_date_format_for_export( $current_format = null ) {
156
-		return apply_filters( 'FHEE__EE_CSV__get_date_format_for_csv__format', 'Y-m-d', $current_format );
155
+	public static function get_date_format_for_export($current_format = null) {
156
+		return apply_filters('FHEE__EE_CSV__get_date_format_for_csv__format', 'Y-m-d', $current_format);
157 157
 	}
158 158
 
159 159
 
@@ -163,8 +163,8 @@  discard block
 block discarded – undo
163 163
 	 * @param string $current_format
164 164
 	 * @return string
165 165
 	 */
166
-	public static function get_time_format_for_export( $current_format = null ) {
167
-		return apply_filters( 'FHEE__EE_CSV__get_time_format_for_csv__format', 'H:i:s', $current_format );
166
+	public static function get_time_format_for_export($current_format = null) {
167
+		return apply_filters('FHEE__EE_CSV__get_time_format_for_csv__format', 'H:i:s', $current_format);
168 168
 	}
169 169
 
170 170
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 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
  * Event Espresso
4 6
  *
@@ -77,7 +79,7 @@  discard block
 block discarded – undo
77 79
 				$new_file_contents .= EEH_Export::get_csv_row( $data_row);
78 80
 			}
79 81
 			return EEH_File::write_to_file( $filepath, EEH_File::get_file_contents( $filepath ) . $new_file_contents );
80
-		}else{
82
+		} else{
81 83
 			//no data TO write... so we can assume that's a success
82 84
 			return true;
83 85
 		}
@@ -138,9 +140,9 @@  discard block
 block discarded – undo
138 140
 		}
139 141
 		if( $pretty_schema === true){
140 142
 			return $field_obj->prepare_for_pretty_echoing( $value_on_model_obj );
141
-		}elseif( is_string( $pretty_schema ) ) {
143
+		} elseif( is_string( $pretty_schema ) ) {
142 144
 			return $field_obj->prepare_for_pretty_echoing($value_on_model_obj, $pretty_schema );
143
-		}else{
145
+		} else{
144 146
 			return $field_obj->prepare_for_get( $value_on_model_obj );
145 147
 		}
146 148
 	}
Please login to merge, or discard this patch.
core/libraries/batch/BatchRequestProcessor.php 2 patches
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -23,8 +23,8 @@  discard block
 block discarded – undo
23 23
 use EventEspressoBatchRequest\Helpers\JobParameters;
24 24
 use EventEspressoBatchRequest\Helpers\JobStepResponse;
25 25
 
26
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
27
-	exit( 'No direct script access allowed' );
26
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
27
+	exit('No direct script access allowed');
28 28
 }
29 29
 
30 30
 
@@ -50,32 +50,32 @@  discard block
 block discarded – undo
50 50
 	 * @param array $request_data to be used by the batch job handler
51 51
 	 * @return JobStepResponse
52 52
 	 */
53
-	public function create_job( $batch_job_handler_class, $request_data ) {
53
+	public function create_job($batch_job_handler_class, $request_data) {
54 54
 		try {
55
-			$this->_job_id = wp_generate_password( 15, false );
56
-			$obj = $this->instantiate_batch_job_handler_from_classname( $batch_job_handler_class );
57
-			$this->_job_parameters = new JobParameters( $this->_job_id, $batch_job_handler_class, $request_data );
58
-			$response = $obj->create_job( $this->_job_parameters );
59
-			if( ! $response instanceof JobStepResponse ) {
55
+			$this->_job_id = wp_generate_password(15, false);
56
+			$obj = $this->instantiate_batch_job_handler_from_classname($batch_job_handler_class);
57
+			$this->_job_parameters = new JobParameters($this->_job_id, $batch_job_handler_class, $request_data);
58
+			$response = $obj->create_job($this->_job_parameters);
59
+			if ( ! $response instanceof JobStepResponse) {
60 60
 				throw new BatchRequestException(
61 61
 					sprintf(
62
-						__( 'The class implementing JobHandlerInterface did not return a JobStepResponse when create_job was called with %1$s. It needs to return one or throw an Exception', 'event_espresso' ),
63
-						wp_json_encode( $request_data )
62
+						__('The class implementing JobHandlerInterface did not return a JobStepResponse when create_job was called with %1$s. It needs to return one or throw an Exception', 'event_espresso'),
63
+						wp_json_encode($request_data)
64 64
 					)
65 65
 				);
66 66
 			}
67
-			$success = $this->_job_parameters->save( true );
68
-			if( ! $success ) {
67
+			$success = $this->_job_parameters->save(true);
68
+			if ( ! $success) {
69 69
 				throw new BatchRequestException(
70 70
 					sprintf(
71 71
 						__('Could not save job %1$s to the Wordpress Options table. These were the arguments used: %2$s', 'event_espresso'),
72 72
 						$this->_job_id,
73
-						wp_json_encode( $request_data )
73
+						wp_json_encode($request_data)
74 74
 					)
75 75
 				);
76 76
 			}
77
-		} catch( \Exception $e ) {
78
-			$response = $this->_get_error_response( $e, 'create_job' );
77
+		} catch (\Exception $e) {
78
+			$response = $this->_get_error_response($e, 'create_job');
79 79
 		}
80 80
 		return $response;
81 81
 	}
@@ -88,26 +88,26 @@  discard block
 block discarded – undo
88 88
 	 * @param int $batch_size
89 89
 	 * @return JobStepResponse
90 90
 	 */
91
-	public function continue_job( $job_id, $batch_size = 50 ) {
91
+	public function continue_job($job_id, $batch_size = 50) {
92 92
 		try {
93 93
 			$this->_job_id = $job_id;
94
-			$batch_size = defined( 'EE_BATCHRUNNER_BATCH_SIZE' ) ? EE_BATCHRUNNER_BATCH_SIZE : $batch_size;
94
+			$batch_size = defined('EE_BATCHRUNNER_BATCH_SIZE') ? EE_BATCHRUNNER_BATCH_SIZE : $batch_size;
95 95
 			//get the corresponding WordPress option for the job
96
-			$this->_job_parameters = JobParameters::load( $this->_job_id );
97
-			$handler_obj = $this->instantiate_batch_job_handler_from_classname( $this->_job_parameters->classname() );
96
+			$this->_job_parameters = JobParameters::load($this->_job_id);
97
+			$handler_obj = $this->instantiate_batch_job_handler_from_classname($this->_job_parameters->classname());
98 98
 			//continue it
99
-			$response = $handler_obj->continue_job( $this->_job_parameters, $batch_size );
100
-			if( ! $response instanceof JobStepResponse ) {
99
+			$response = $handler_obj->continue_job($this->_job_parameters, $batch_size);
100
+			if ( ! $response instanceof JobStepResponse) {
101 101
 				throw new BatchRequestException(
102 102
 					sprintf(
103
-						__( 'The class implementing JobHandlerInterface did not return a JobStepResponse when continue_job was called with job %1$s. It needs to return one or throw an Exception', 'event_espresso' ),
103
+						__('The class implementing JobHandlerInterface did not return a JobStepResponse when continue_job was called with job %1$s. It needs to return one or throw an Exception', 'event_espresso'),
104 104
 						$this->_job_id
105 105
 					)
106 106
 				);
107 107
 			}
108 108
 			$this->_job_parameters->save();
109
-		} catch( \Exception $e ) {
110
-			$response = $this->_get_error_response( $e, 'continue_job' );
109
+		} catch (\Exception $e) {
110
+			$response = $this->_get_error_response($e, 'continue_job');
111 111
 		}
112 112
 		return $response;
113 113
 	}
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
 	 * @return JobHandlerInterface
123 123
 	 * @throws BatchRequestException
124 124
 	 */
125
-	public function instantiate_batch_job_handler_from_classname( $classname ) {
126
-		if( ! class_exists( $classname ) ) {
125
+	public function instantiate_batch_job_handler_from_classname($classname) {
126
+		if ( ! class_exists($classname)) {
127 127
 			throw new BatchRequestException(
128 128
 				sprintf(
129 129
 					__('The class %1$s does not exist, and so could not be used for running a job. It should implement JobHandlerInterface.', 'event_espresso'),
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 			);
133 133
 		}
134 134
 		$obj = new $classname;
135
-		if( ! $obj instanceof JobHandlerInterface ) {
135
+		if ( ! $obj instanceof JobHandlerInterface) {
136 136
 			throw new BatchRequestException(
137 137
 				sprintf(
138 138
 					__('The class %1$s does not implement JobHandlerInterface and so could not be used for running a job', 'event_espresso'),
@@ -152,26 +152,26 @@  discard block
 block discarded – undo
152 152
 	 * @return JobStepResponse
153 153
 	 * @throws BatchRequestException
154 154
 	 */
155
-	public function cleanup_job( $job_id ) {
156
-		try{
155
+	public function cleanup_job($job_id) {
156
+		try {
157 157
 			$this->_job_id = $job_id;
158
-			$job_parameters = JobParameters::load( $this->_job_id );
159
-			$handler_obj = $this->instantiate_batch_job_handler_from_classname( $job_parameters->classname() );
158
+			$job_parameters = JobParameters::load($this->_job_id);
159
+			$handler_obj = $this->instantiate_batch_job_handler_from_classname($job_parameters->classname());
160 160
 			//continue it
161
-			$response = $handler_obj->cleanup_job( $job_parameters );
162
-			if( ! $response instanceof JobStepResponse ) {
161
+			$response = $handler_obj->cleanup_job($job_parameters);
162
+			if ( ! $response instanceof JobStepResponse) {
163 163
 				throw new BatchRequestException(
164 164
 					sprintf(
165
-						__( 'The class implementing JobHandlerInterface did not return a JobStepResponse when cleanup_job was called with job %1$s. It needs to return one or throw an Exception', 'event_espresso' ),
165
+						__('The class implementing JobHandlerInterface did not return a JobStepResponse when cleanup_job was called with job %1$s. It needs to return one or throw an Exception', 'event_espresso'),
166 166
 						$this->_job_id
167 167
 					)
168 168
 				);
169 169
 			}
170
-			$job_parameters->set_status( JobParameters::status_cleaned_up );
170
+			$job_parameters->set_status(JobParameters::status_cleaned_up);
171 171
 			$job_parameters->delete();
172 172
 			return $response;
173
-		} catch( \Exception $e ) {
174
-			$response = $this->_get_error_response( $e, 'cleanup_job' );
173
+		} catch (\Exception $e) {
174
+			$response = $this->_get_error_response($e, 'cleanup_job');
175 175
 		}
176 176
 		return $response;
177 177
 	}
@@ -184,17 +184,17 @@  discard block
 block discarded – undo
184 184
 	 * @param string $method_name
185 185
 	 * @return JobStepResponse
186 186
 	 */
187
-	protected function _get_error_response( \Exception $exception, $method_name ) {
188
-		if( ! $this->_job_parameters instanceof JobParameters ) {
189
-			$this->_job_parameters = new JobParameters( $this->_job_id, __( '__Unknown__', 'event_espresso' ), array() );
187
+	protected function _get_error_response(\Exception $exception, $method_name) {
188
+		if ( ! $this->_job_parameters instanceof JobParameters) {
189
+			$this->_job_parameters = new JobParameters($this->_job_id, __('__Unknown__', 'event_espresso'), array());
190 190
 		}
191
-		$this->_job_parameters->set_status( JobParameters::status_error );
191
+		$this->_job_parameters->set_status(JobParameters::status_error);
192 192
 		return new JobStepResponse(
193 193
 			$this->_job_parameters,
194 194
 			sprintf(
195 195
 				__('An exception of type %1$s occurred while running %2$s. Its message was %3$s and had trace %4$s', 'event_espresso'),
196
-				get_class( $exception ),
197
-				'BatchRunner::' . $method_name . '()',
196
+				get_class($exception),
197
+				'BatchRunner::'.$method_name.'()',
198 198
 				$exception->getMessage(),
199 199
 				$exception->getTraceAsString()
200 200
 			)
Please login to merge, or discard this patch.
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,21 +1,21 @@
 block discarded – undo
1 1
 <?php
2 2
  /**
3
- *
4
- * Class BatchRequetProcessor
3
+  *
4
+  * Class BatchRequetProcessor
5 5
   * 
6
- * Responsible for receiving a request to start a job and assign it a job Id.
7
- * Then when subsequent requests come in to continue that job, dispatches
8
- * the request to the appropriate JobHandler, which processes a step of the batch,
9
- * and then returns the job's new status.
10
- * This class is used by controller code, and the controller code is sent HTTP
11
- * requests from the batch_runner.js library
12
- *
13
- * @package         Event Espresso
14
- * @subpackage    batch
15
- * @author				Mike Nelson
16
- * @since		 	   4.8.26
17
- *
18
- */
6
+  * Responsible for receiving a request to start a job and assign it a job Id.
7
+  * Then when subsequent requests come in to continue that job, dispatches
8
+  * the request to the appropriate JobHandler, which processes a step of the batch,
9
+  * and then returns the job's new status.
10
+  * This class is used by controller code, and the controller code is sent HTTP
11
+  * requests from the batch_runner.js library
12
+  *
13
+  * @package         Event Espresso
14
+  * @subpackage    batch
15
+  * @author				Mike Nelson
16
+  * @since		 	   4.8.26
17
+  *
18
+  */
19 19
 namespace EventEspressoBatchRequest;
20 20
 
21 21
 use EventEspressoBatchRequest\JobHandlerBaseClasses\JobHandlerInterface;
Please login to merge, or discard this patch.
core/libraries/batch/Helpers/BatchRequestException.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
 namespace EventEspressoBatchRequest\Helpers;
16 16
 if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
17 17
 
18
-class BatchRequestException extends \Exception{
18
+class BatchRequestException extends \Exception {
19 19
 	//so far the same as exception
20 20
 }
21 21
 
Please login to merge, or discard this patch.
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,17 +1,17 @@
 block discarded – undo
1 1
 <?php 
2 2
  /**
3
- *
4
- * Class BatchRequestException
5
- *
6
- * Exception class for whenever we have trouble running start, continuing, or finishing
7
- * a batch job.
8
- *
9
- * @package         Event Espresso
10
- * @subpackage    batch
11
- * @author				Mike Nelson
12
- * @since		 	   4.8.26
13
- *
14
- */
3
+  *
4
+  * Class BatchRequestException
5
+  *
6
+  * Exception class for whenever we have trouble running start, continuing, or finishing
7
+  * a batch job.
8
+  *
9
+  * @package         Event Espresso
10
+  * @subpackage    batch
11
+  * @author				Mike Nelson
12
+  * @since		 	   4.8.26
13
+  *
14
+  */
15 15
 namespace EventEspressoBatchRequest\Helpers;
16 16
 if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
17 17
 
Please login to merge, or discard this patch.
core/libraries/batch/Helpers/JobParameters.php 2 patches
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -96,12 +96,12 @@  discard block
 block discarded – undo
96 96
 	 * @param array $request_data
97 97
 	 * @param array $extra_data
98 98
 	 */
99
-	function __construct( $job_id, $classname, $request_data, $extra_data = array() ) {
100
-		$this->set_job_id( $job_id );
101
-		$this->set_classname( $classname );
102
-		$this->set_request_data( $request_data );
103
-		$this->set_extra_data( $extra_data );
104
-		$this->set_status( JobParameters::status_continue );
99
+	function __construct($job_id, $classname, $request_data, $extra_data = array()) {
100
+		$this->set_job_id($job_id);
101
+		$this->set_classname($classname);
102
+		$this->set_request_data($request_data);
103
+		$this->set_extra_data($extra_data);
104
+		$this->set_status(JobParameters::status_continue);
105 105
 	}
106 106
 
107 107
 
@@ -126,12 +126,12 @@  discard block
 block discarded – undo
126 126
 	 * @param boolean $first
127 127
 	 * @return boolean success
128 128
 	 */
129
-	function save( $first = false ) {
130
-		$object_vars = wp_json_encode( get_object_vars( $this ) );
131
-		if( $first ) {
132
-			return add_option( $this->option_name(), $object_vars, null, 'no' );
133
-		} else{
134
-			return update_option( $this->option_name(), $object_vars );
129
+	function save($first = false) {
130
+		$object_vars = wp_json_encode(get_object_vars($this));
131
+		if ($first) {
132
+			return add_option($this->option_name(), $object_vars, null, 'no');
133
+		} else {
134
+			return update_option($this->option_name(), $object_vars);
135 135
 		}
136 136
 	}
137 137
 
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 	 * @return boolean
144 144
 	 */
145 145
 	function delete() {
146
-		return delete_option( $this->option_name() );
146
+		return delete_option($this->option_name());
147 147
 	}
148 148
 
149 149
 
@@ -154,26 +154,26 @@  discard block
 block discarded – undo
154 154
 	 * @return JobParameters
155 155
 	 * @throws BatchRequestException
156 156
 	 */
157
-	static function load( $job_id ) {
158
-		$job_parameter_vars = json_decode( get_option( JobParameters::wp_option_prefix . $job_id ), true );
159
-		if(
160
-			! is_array( $job_parameter_vars ) ||
161
-			! isset( $job_parameter_vars[ '_classname' ] ) ||
162
-			! isset( $job_parameter_vars[ '_request_data' ] )
157
+	static function load($job_id) {
158
+		$job_parameter_vars = json_decode(get_option(JobParameters::wp_option_prefix.$job_id), true);
159
+		if (
160
+			! is_array($job_parameter_vars) ||
161
+			! isset($job_parameter_vars['_classname']) ||
162
+			! isset($job_parameter_vars['_request_data'])
163 163
 		) {
164 164
 			throw new BatchRequestException(
165 165
 				sprintf( 
166 166
 					__('Could not retrieve job %1$s from the Wordpress options table, and so the job could not continue. The wordpress option was %2$s', 'event_espresso'),
167 167
 					$job_id,
168
-					get_option( JobParameters::wp_option_prefix . $job_id )
168
+					get_option(JobParameters::wp_option_prefix.$job_id)
169 169
 				)
170 170
 			);
171 171
 		}
172 172
 		$job_parameters = new JobParameters( 
173 173
 				$job_id, 
174
-				$job_parameter_vars[ '_classname' ], 
175
-				$job_parameter_vars[ '_request_data'] );
176
-		foreach( $job_parameter_vars as $key => $value ) {
174
+				$job_parameter_vars['_classname'], 
175
+				$job_parameter_vars['_request_data'] );
176
+		foreach ($job_parameter_vars as $key => $value) {
177 177
 			$job_parameters->$key = $value;
178 178
 		}
179 179
 		return $job_parameters;
@@ -217,9 +217,9 @@  discard block
 block discarded – undo
217 217
 	 * @param string|array $default
218 218
 	 * @return string|array
219 219
 	 */
220
-	function request_datum( $key, $default = '' ) {
221
-		if( isset( $this->_request_data[ $key ] ) ) {
222
-			return $this->_request_data[ $key ];
220
+	function request_datum($key, $default = '') {
221
+		if (isset($this->_request_data[$key])) {
222
+			return $this->_request_data[$key];
223 223
 		} else {
224 224
 			return $default;
225 225
 		}
@@ -233,9 +233,9 @@  discard block
 block discarded – undo
233 233
 	 * @param string|array $default
234 234
 	 * @return string|array
235 235
 	 */
236
-	function extra_datum( $key, $default = '' ) {
237
-		if( isset( $this->_extra_data[ $key ] ) ) {
238
-			return $this->_extra_data[ $key ];
236
+	function extra_datum($key, $default = '') {
237
+		if (isset($this->_extra_data[$key])) {
238
+			return $this->_extra_data[$key];
239 239
 		} else {
240 240
 			return $default;
241 241
 		}
@@ -248,8 +248,8 @@  discard block
 block discarded – undo
248 248
 	 * @param string $key
249 249
 	 * @param string|int|array|null $value almost any extra data you want to store
250 250
 	 */
251
-	function add_extra_data( $key, $value ) {
252
-		$this->_extra_data[ $key ] = $value;
251
+	function add_extra_data($key, $value) {
252
+		$this->_extra_data[$key] = $value;
253 253
 	}
254 254
 
255 255
 
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 	 * Sets the job size. You decide what units to use
279 279
 	 * @param int $size
280 280
 	 */
281
-	function set_job_size( $size ) {
281
+	function set_job_size($size) {
282 282
 		$this->_job_size = $size;
283 283
 	}
284 284
 
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 	 * @param int $newly_processed
300 300
 	 * @return int updated units processed
301 301
 	 */
302
-	function mark_processed( $newly_processed ) {
302
+	function mark_processed($newly_processed) {
303 303
 		$this->_units_processed += $newly_processed;
304 304
 		return $this->_units_processed;
305 305
 	}
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 	 * Sets the total count of units processed. You might prefer to use mark_processed
311 311
 	 * @param int $total_units_processed
312 312
 	 */
313
-	function set_units_processed( $total_units_processed ) {
313
+	function set_units_processed($total_units_processed) {
314 314
 		$this->_units_processed = $total_units_processed;
315 315
 	}
316 316
 
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 	 * Sets the job's ID
321 321
 	 * @param string $job_id
322 322
 	 */
323
-	function set_job_id( $job_id ) {
323
+	function set_job_id($job_id) {
324 324
 		$this->_job_id = $job_id;
325 325
 	}
326 326
 
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 	 * sets the classname
331 331
 	 * @param string $classname
332 332
 	 */
333
-	function set_classname( $classname ) {
333
+	function set_classname($classname) {
334 334
 		$this->_classname = $classname;
335 335
 	}
336 336
 
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 	 * Sets the request data
341 341
 	 * @param array $request_data
342 342
 	 */
343
-	function set_request_data( $request_data ) {
343
+	function set_request_data($request_data) {
344 344
 		$this->_request_data = $request_data;
345 345
 	}
346 346
 
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 	 * Sets the array of extra data we want to store on this request
351 351
 	 * @param array $extra_data
352 352
 	 */
353
-	function set_extra_data( $extra_data ) {
353
+	function set_extra_data($extra_data) {
354 354
 		$this->_extra_data = $extra_data;
355 355
 	}
356 356
 
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 	 * @return string
362 362
 	 */
363 363
 	function option_name() {
364
-		return JobParameters::wp_option_prefix . $this->job_id();
364
+		return JobParameters::wp_option_prefix.$this->job_id();
365 365
 	}
366 366
 
367 367
 
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 	 *
381 381
 	 * @param string $status on eof JobParameters::valid_stati()
382 382
 	 */
383
-	public function set_status( $status ) {
383
+	public function set_status($status) {
384 384
 		$this->_status = $status;
385 385
 	}
386 386
 
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -214,7 +214,7 @@
 block discarded – undo
214 214
 	/**
215 215
 	 * Gets a single item from the request data
216 216
 	 * @param string $key
217
-	 * @param string|array $default
217
+	 * @param string $default
218 218
 	 * @return string|array
219 219
 	 */
220 220
 	function request_datum( $key, $default = '' ) {
Please login to merge, or discard this patch.
core/libraries/batch/Helpers/JobStepResponse.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -43,10 +43,10 @@
 block discarded – undo
43 43
 	 * @param string $update_text
44 44
 	 * @param array $extra_data
45 45
 	 */
46
-	public function __construct(JobParameters $job_parameters, $update_text, $extra_data = array() ) {
47
-		$this->_job_parameters 	= $job_parameters;
46
+	public function __construct(JobParameters $job_parameters, $update_text, $extra_data = array()) {
47
+		$this->_job_parameters = $job_parameters;
48 48
 		$this->_update_text 	= $update_text;
49
-		$this->_extra_data 		= (array)$extra_data;
49
+		$this->_extra_data 		= (array) $extra_data;
50 50
 	}
51 51
 
52 52
 
Please login to merge, or discard this patch.
core/libraries/batch/JobHandlerBaseClasses/JobHandlerInterface.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
 use EventEspressoBatchRequest\Helpers\JobParameters;
21 21
 use EventEspressoBatchRequest\Helpers\JobStepResponse;
22 22
 
23
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
24
-	exit( 'No direct script access allowed' );
23
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
24
+	exit('No direct script access allowed');
25 25
 }
26 26
 
27 27
 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 * @throws BatchRequestException
36 36
 	 * @return JobStepResponse
37 37
 	 */
38
-	public function create_job( JobParameters $job_parameters );
38
+	public function create_job(JobParameters $job_parameters);
39 39
 
40 40
 	/**
41 41
 	 * Performs another step of the job
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	 * @return JobStepResponse
45 45
 	 * @throws BatchRequestException
46 46
 	 */
47
-	public function continue_job( JobParameters $job_parameters, $batch_size = 50 );
47
+	public function continue_job(JobParameters $job_parameters, $batch_size = 50);
48 48
 
49 49
 	/**
50 50
 	 * Performs any clean-up logic when we know the job is completed
@@ -52,5 +52,5 @@  discard block
 block discarded – undo
52 52
 	 * @return JobStepResponse
53 53
 	 * @throws BatchRequestException
54 54
 	 */
55
-	public function cleanup_job( JobParameters $job_parameters );
55
+	public function cleanup_job(JobParameters $job_parameters);
56 56
 }
Please login to merge, or discard this patch.
core/libraries/batch/JobHandlers/RegistrationsReport.php 3 patches
Braces   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 			if( ! $event_slug ) {
76 76
 				$event_slug = __( 'unknown', 'event_espresso' );
77 77
 			}
78
-		}else{
78
+		} else{
79 79
 			$event_slug = __( 'all', 'event_espresso' );
80 80
 		}
81 81
 		return sprintf( "registrations-for-%s.csv", $event_slug );
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 		);
163 163
 		if( $event_id ){
164 164
 			$query_params[0]['EVT_ID'] =  $event_id;
165
-		}else{
165
+		} else{
166 166
 			$query_params[ 'force_join' ][] = 'Event';
167 167
 		}
168 168
 		$registration_rows = $reg_model->get_all_wpdb_results( $query_params );
@@ -191,11 +191,11 @@  discard block
 block discarded – undo
191 191
 					$field = $reg_model->field_settings_for($field_name);
192 192
 					if($field_name == 'REG_final_price'){
193 193
 						$value = \EEH_Export::prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_final_price'], 'localized_float' );
194
-					}elseif( $field_name == 'REG_count' ){
194
+					} elseif( $field_name == 'REG_count' ){
195 195
 						$value = sprintf( __( '%s of %s', 'event_espresso' ), \EEH_Export::prepare_value_from_db_for_display( $reg_model, 'REG_count', $reg_row['Registration.REG_count'] ), \EEH_Export::prepare_value_from_db_for_display( $reg_model, 'REG_group_size', $reg_row['Registration.REG_group_size' ] ) );
196
-					}elseif( $field_name == 'REG_date' ) {
196
+					} elseif( $field_name == 'REG_date' ) {
197 197
 						$value = \EEH_Export::prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_date'], 'no_html' );
198
-					}else{
198
+					} else{
199 199
 						$value = \EEH_Export::prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ $field->get_qualified_column() ] );
200 200
 					}
201 201
 					$reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = $value;
@@ -267,12 +267,12 @@  discard block
 block discarded – undo
267 267
 					if( $reg_row[ 'Attendee_CPT.ID' ]){
268 268
 						if($att_field_name == 'STA_ID'){
269 269
 							$value = \EEM_State::instance()->get_var( array( array( 'STA_ID' => $reg_row[ 'Attendee_Meta.STA_ID' ] ) ), 'STA_name' );
270
-						}elseif($att_field_name == 'CNT_ISO'){
270
+						} elseif($att_field_name == 'CNT_ISO'){
271 271
 							$value = \EEM_Country::instance()->get_var( array( array( 'CNT_ISO' => $reg_row[ 'Attendee_Meta.CNT_ISO' ] ) ), 'CNT_name' );
272
-						}else{
272
+						} else{
273 273
 							$value = \EEH_Export::prepare_value_from_db_for_display( \EEM_Attendee::instance(), $att_field_name, $reg_row[ $field_obj->get_qualified_column() ] );
274 274
 						}
275
-					}else{
275
+					} else{
276 276
 						$value = '';
277 277
 					}
278 278
 
Please login to merge, or discard this patch.
Spacing   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -19,8 +19,8 @@  discard block
 block discarded – undo
19 19
 use EventEspressoBatchRequest\Helpers\JobParameters;
20 20
 use EventEspressoBatchRequest\Helpers\JobStepResponse;
21 21
 
22
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
23
-	exit( 'No direct script access allowed' );
22
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
23
+	exit('No direct script access allowed');
24 24
 }
25 25
 
26 26
 
@@ -35,36 +35,36 @@  discard block
 block discarded – undo
35 35
 	 * @throws BatchRequestException
36 36
 	 * @return JobStepResponse
37 37
 	 */
38
-	public function create_job( JobParameters $job_parameters ) {
39
-		$event_id = intval( $job_parameters->request_datum( 'EVT_ID', '0' ) );
40
-		if( ! \EE_Capabilities::instance()->current_user_can( 'ee_read_registrations', 'generating_report' ) ) {
38
+	public function create_job(JobParameters $job_parameters) {
39
+		$event_id = intval($job_parameters->request_datum('EVT_ID', '0'));
40
+		if ( ! \EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) {
41 41
 			throw new BatchRequestException(
42
-				__( 'You do not have permission to view registrations', 'event_espresso')
42
+				__('You do not have permission to view registrations', 'event_espresso')
43 43
 			);
44 44
 		}
45 45
 		$filepath = $this->create_file_from_job_with_name(
46 46
 			$job_parameters->job_id(),
47
-			$this->get_filename_from_event( $event_id )
47
+			$this->get_filename_from_event($event_id)
48 48
 		);
49
-		$job_parameters->add_extra_data( 'filepath', $filepath );
50
-		$question_data_for_columns = $this->_get_questions_for_report( $event_id );
51
-		$job_parameters->add_extra_data( 'questions_data', $question_data_for_columns );
52
-		$job_parameters->set_job_size( $this->count_units_to_process( $event_id ) );
49
+		$job_parameters->add_extra_data('filepath', $filepath);
50
+		$question_data_for_columns = $this->_get_questions_for_report($event_id);
51
+		$job_parameters->add_extra_data('questions_data', $question_data_for_columns);
52
+		$job_parameters->set_job_size($this->count_units_to_process($event_id));
53 53
 		//we should also set the header columns
54 54
 		$csv_data_for_row = $this->get_csv_data_for(
55 55
 			$event_id,
56 56
 			0,
57 57
 			1,
58
-			$job_parameters->extra_datum( 'questions_data' ) );
59
-		\EE_Registry::instance()->load_helper( 'Export' );
60
-		\EEH_Export::write_data_array_to_csv( $filepath, $csv_data_for_row, true );
58
+			$job_parameters->extra_datum('questions_data') );
59
+		\EE_Registry::instance()->load_helper('Export');
60
+		\EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true);
61 61
 		//if we actually processed a row there, record it
62
-		if( $job_parameters->job_size() ) {
63
-			$job_parameters->mark_processed( 1 );
62
+		if ($job_parameters->job_size()) {
63
+			$job_parameters->mark_processed(1);
64 64
 		}
65 65
 		return new JobStepResponse(
66 66
 			$job_parameters,
67
-			__( 'Registrations report started successfully...', 'event_espresso' )
67
+			__('Registrations report started successfully...', 'event_espresso')
68 68
 		);
69 69
 	}
70 70
 
@@ -75,16 +75,16 @@  discard block
 block discarded – undo
75 75
 	 * @param int $event_id
76 76
 	 * @return string
77 77
 	 */
78
-	protected function get_filename_from_event( $event_id ) {
79
-		if( $event_id ){
80
-			$event_slug =  \EEM_Event::instance()->get_var( array( array( 'EVT_ID' => $event_id ) ), 'EVT_slug' );
81
-			if( ! $event_slug ) {
82
-				$event_slug = __( 'unknown', 'event_espresso' );
78
+	protected function get_filename_from_event($event_id) {
79
+		if ($event_id) {
80
+			$event_slug = \EEM_Event::instance()->get_var(array(array('EVT_ID' => $event_id)), 'EVT_slug');
81
+			if ( ! $event_slug) {
82
+				$event_slug = __('unknown', 'event_espresso');
83 83
 			}
84
-		}else{
85
-			$event_slug = __( 'all', 'event_espresso' );
84
+		} else {
85
+			$event_slug = __('all', 'event_espresso');
86 86
 		}
87
-		return sprintf( "registrations-for-%s.csv", $event_slug );
87
+		return sprintf("registrations-for-%s.csv", $event_slug);
88 88
 	}
89 89
 
90 90
 	/**
@@ -93,17 +93,17 @@  discard block
 block discarded – undo
93 93
 	 * @param int|null $event_id
94 94
 	 * @return array of wpdb results for questions which are to be used for this report
95 95
 	 */
96
-	protected function _get_questions_for_report( $event_id ) {
96
+	protected function _get_questions_for_report($event_id) {
97 97
 		$question_query_params = array(
98 98
 			array(
99
-				'Answer.ANS_ID' => array( 'IS_NOT_NULL' ),
99
+				'Answer.ANS_ID' => array('IS_NOT_NULL'),
100 100
 			),
101
-			'group_by' => array( 'QST_ID' )
101
+			'group_by' => array('QST_ID')
102 102
 		);
103
-		if( $event_id ) {
103
+		if ($event_id) {
104 104
 			$question_query_params[0]['Answer.Registration.EVT_ID'] = $event_id;
105 105
 		}
106
-		return \EEM_Question::instance()->get_all_wpdb_results( $question_query_params );
106
+		return \EEM_Question::instance()->get_all_wpdb_results($question_query_params);
107 107
 	}
108 108
 
109 109
 
@@ -116,28 +116,28 @@  discard block
 block discarded – undo
116 116
 	 * @return JobStepResponse
117 117
 	 * @throws \EE_Error
118 118
 	 */
119
-	public function continue_job( JobParameters $job_parameters, $batch_size = 50 ) {
119
+	public function continue_job(JobParameters $job_parameters, $batch_size = 50) {
120 120
 		$csv_data = $this->get_csv_data_for(
121
-			$job_parameters->request_datum( 'EVT_ID', '0'),
121
+			$job_parameters->request_datum('EVT_ID', '0'),
122 122
 			$job_parameters->units_processed(),
123 123
 			$batch_size,
124
-			$job_parameters->extra_datum( 'questions_data' ) );
125
-		\EE_Registry::instance()->load_helper( 'Export' );
126
-		\EEH_Export::write_data_array_to_csv( $job_parameters->extra_datum( 'filepath' ), $csv_data, false );
127
-		$units_processed = count( $csv_data );
128
-		$job_parameters->mark_processed( $units_processed );
124
+			$job_parameters->extra_datum('questions_data') );
125
+		\EE_Registry::instance()->load_helper('Export');
126
+		\EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false);
127
+		$units_processed = count($csv_data);
128
+		$job_parameters->mark_processed($units_processed);
129 129
 		$extra_response_data = array(
130 130
 			'file_url' => ''
131 131
 		);
132
-		if( $units_processed < $batch_size ) {
133
-			$job_parameters->set_status( JobParameters::status_complete );
134
-			$extra_response_data[ 'file_url' ] = $this->get_url_to_file( $job_parameters->extra_datum( 'filepath' ) );
132
+		if ($units_processed < $batch_size) {
133
+			$job_parameters->set_status(JobParameters::status_complete);
134
+			$extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath'));
135 135
 		}
136 136
 		return new JobStepResponse(
137 137
 				$job_parameters,
138 138
 				sprintf(
139
-					__( 'Wrote %1$s rows to report CSV file...', 'event_espresso' ),
140
-					count( $csv_data ) ),
139
+					__('Wrote %1$s rows to report CSV file...', 'event_espresso'),
140
+					count($csv_data) ),
141 141
 				$extra_response_data );
142 142
 	}
143 143
 
@@ -150,8 +150,8 @@  discard block
 block discarded – undo
150 150
 	 * @return array top-level keys are numeric, next-level keys are column headers
151 151
 	 *
152 152
 	 */
153
-	function get_csv_data_for( $event_id, $offset, $limit, $questions_for_these_regs_rows ) {
154
-		\EE_Registry::instance()->load_helper( 'Export' );
153
+	function get_csv_data_for($event_id, $offset, $limit, $questions_for_these_regs_rows) {
154
+		\EE_Registry::instance()->load_helper('Export');
155 155
 		$reg_fields_to_include = array(
156 156
 			'TXN_ID',
157 157
 			'ATT_ID',
@@ -182,165 +182,165 @@  discard block
 block discarded – undo
182 182
 				array(
183 183
 					'OR' => array(
184 184
 						//don't include registrations from failed or abandoned transactions...
185
-						'Transaction.STS_ID' => array( 'NOT IN', array( \EEM_Transaction::failed_status_code, \EEM_Transaction::abandoned_status_code ) ),
185
+						'Transaction.STS_ID' => array('NOT IN', array(\EEM_Transaction::failed_status_code, \EEM_Transaction::abandoned_status_code)),
186 186
 						//unless the registration is approved, in which case include it regardless of transaction status
187 187
 						'STS_ID' => \EEM_Registration::status_id_approved
188 188
 						),
189
-					'Ticket.TKT_deleted' => array( 'IN', array( true, false ) )
189
+					'Ticket.TKT_deleted' => array('IN', array(true, false))
190 190
 					),
191
-				'order_by' => array('Transaction.TXN_ID'=>'asc','REG_count'=>'asc'),
192
-				'force_join' => array( 'Transaction', 'Ticket', 'Attendee' ),
193
-				'limit' => array( $offset, $limit ),
191
+				'order_by' => array('Transaction.TXN_ID'=>'asc', 'REG_count'=>'asc'),
192
+				'force_join' => array('Transaction', 'Ticket', 'Attendee'),
193
+				'limit' => array($offset, $limit),
194 194
 			),
195 195
 			$event_id
196 196
 		);
197
-		if( $event_id ){
198
-			$query_params[0]['EVT_ID'] =  $event_id;
199
-		}else{
200
-			$query_params[ 'force_join' ][] = 'Event';
197
+		if ($event_id) {
198
+			$query_params[0]['EVT_ID'] = $event_id;
199
+		} else {
200
+			$query_params['force_join'][] = 'Event';
201 201
 		}
202
-		$registration_rows = $reg_model->get_all_wpdb_results( $query_params );
202
+		$registration_rows = $reg_model->get_all_wpdb_results($query_params);
203 203
 		//get all questions which relate to someone in this group
204 204
 		$registration_ids = array();
205
-		foreach( $registration_rows as $reg_row ) {
206
-			$registration_ids[] = intval( $reg_row[ 'Registration.REG_ID'] );
205
+		foreach ($registration_rows as $reg_row) {
206
+			$registration_ids[] = intval($reg_row['Registration.REG_ID']);
207 207
 		}
208 208
 
209
-		foreach($registration_rows as $reg_row){
210
-			if ( is_array( $reg_row ) ) {
209
+		foreach ($registration_rows as $reg_row) {
210
+			if (is_array($reg_row)) {
211 211
 				$reg_csv_array = array();
212
-				if( ! $event_id ){
212
+				if ( ! $event_id) {
213 213
 					//get the event's name and Id
214
-					$reg_csv_array[ __( 'Event', 'event_espresso' ) ] = sprintf( __( '%1$s (%2$s)', 'event_espresso' ), \EEH_Export::prepare_value_from_db_for_display( \EEM_Event::instance(), 'EVT_name', $reg_row[ 'Event_CPT.post_title'] ), $reg_row[ 'Event_CPT.ID' ] );
214
+					$reg_csv_array[__('Event', 'event_espresso')] = sprintf(__('%1$s (%2$s)', 'event_espresso'), \EEH_Export::prepare_value_from_db_for_display(\EEM_Event::instance(), 'EVT_name', $reg_row['Event_CPT.post_title']), $reg_row['Event_CPT.ID']);
215 215
 				}
216
-				$is_primary_reg = $reg_row[ 'Registration.REG_count' ] == '1' ? true : false;
216
+				$is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false;
217 217
 				/*@var $reg_row EE_Registration */
218
-				foreach($reg_fields_to_include as $field_name){
218
+				foreach ($reg_fields_to_include as $field_name) {
219 219
 					$field = $reg_model->field_settings_for($field_name);
220
-					if($field_name == 'REG_final_price'){
221
-						$value = \EEH_Export::prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_final_price'], 'localized_float' );
222
-					}elseif( $field_name == 'REG_count' ){
223
-						$value = sprintf( __( '%s of %s', 'event_espresso' ), \EEH_Export::prepare_value_from_db_for_display( $reg_model, 'REG_count', $reg_row['Registration.REG_count'] ), \EEH_Export::prepare_value_from_db_for_display( $reg_model, 'REG_group_size', $reg_row['Registration.REG_group_size' ] ) );
224
-					}elseif( $field_name == 'REG_date' ) {
225
-						$value = \EEH_Export::prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_date'], 'no_html' );
226
-					}else{
227
-						$value = \EEH_Export::prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ $field->get_qualified_column() ] );
220
+					if ($field_name == 'REG_final_price') {
221
+						$value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name, $reg_row['Registration.REG_final_price'], 'localized_float');
222
+					}elseif ($field_name == 'REG_count') {
223
+						$value = sprintf(__('%s of %s', 'event_espresso'), \EEH_Export::prepare_value_from_db_for_display($reg_model, 'REG_count', $reg_row['Registration.REG_count']), \EEH_Export::prepare_value_from_db_for_display($reg_model, 'REG_group_size', $reg_row['Registration.REG_group_size']));
224
+					}elseif ($field_name == 'REG_date') {
225
+						$value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name, $reg_row['Registration.REG_date'], 'no_html');
226
+					} else {
227
+						$value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name, $reg_row[$field->get_qualified_column()]);
228 228
 					}
229 229
 					$reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = $value;
230
-					if($field_name == 'REG_final_price'){
230
+					if ($field_name == 'REG_final_price') {
231 231
 						//add a column named Currency after the final price
232 232
 						$reg_csv_array[__("Currency", "event_espresso")] = \EE_Config::instance()->currency->code;
233 233
 					}
234 234
 				}
235 235
 				//get pretty status
236
-				$stati = \EEM_Status::instance()->localized_status( array(
237
-					$reg_row[ 'Registration.STS_ID' ] => __( 'unknown', 'event_espresso' ),
238
-					$reg_row[ 'Transaction.STS_ID' ] => __( 'unknown', 'event_espresso' ) ),
236
+				$stati = \EEM_Status::instance()->localized_status(array(
237
+					$reg_row['Registration.STS_ID'] => __('unknown', 'event_espresso'),
238
+					$reg_row['Transaction.STS_ID'] => __('unknown', 'event_espresso') ),
239 239
 						FALSE,
240
-						'sentence' );
241
-				$reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[ $reg_row[ 'Registration.STS_ID' ] ];
240
+						'sentence');
241
+				$reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[$reg_row['Registration.STS_ID']];
242 242
 				//get pretty transaction status
243
-				$reg_csv_array[__("Transaction Status", 'event_espresso')] = $stati[ $reg_row[ 'Transaction.STS_ID' ] ];
244
-				$reg_csv_array[ __( 'Transaction Amount Due', 'event_espresso' ) ] = $is_primary_reg ? \EEH_Export::prepare_value_from_db_for_display( \EEM_Transaction::instance(), 'TXN_total', $reg_row[ 'Transaction.TXN_total' ], 'localized_float' ) : '0.00';
245
-				$reg_csv_array[ __( 'Amount Paid', 'event_espresso' )] = $is_primary_reg ? \EEH_Export::prepare_value_from_db_for_display( \EEM_Transaction::instance(), 'TXN_paid', $reg_row[ 'Transaction.TXN_paid' ], 'localized_float' ) : '0.00';
243
+				$reg_csv_array[__("Transaction Status", 'event_espresso')] = $stati[$reg_row['Transaction.STS_ID']];
244
+				$reg_csv_array[__('Transaction Amount Due', 'event_espresso')] = $is_primary_reg ? \EEH_Export::prepare_value_from_db_for_display(\EEM_Transaction::instance(), 'TXN_total', $reg_row['Transaction.TXN_total'], 'localized_float') : '0.00';
245
+				$reg_csv_array[__('Amount Paid', 'event_espresso')] = $is_primary_reg ? \EEH_Export::prepare_value_from_db_for_display(\EEM_Transaction::instance(), 'TXN_paid', $reg_row['Transaction.TXN_paid'], 'localized_float') : '0.00';
246 246
 				$payment_methods = array();
247 247
 				$gateway_txn_ids_etc = array();
248 248
 				$payment_times = array();
249
-				if( $is_primary_reg && $reg_row[ 'Transaction.TXN_ID' ] ){
249
+				if ($is_primary_reg && $reg_row['Transaction.TXN_ID']) {
250 250
 					$payments_info = \EEM_Payment::instance()->get_all_wpdb_results(
251 251
 							array(
252 252
 								array(
253
-									'TXN_ID' => $reg_row[ 'Transaction.TXN_ID' ],
253
+									'TXN_ID' => $reg_row['Transaction.TXN_ID'],
254 254
 									'STS_ID' => \EEM_Payment::status_id_approved
255 255
 								),
256
-								'force_join' => array( 'Payment_Method' ),
256
+								'force_join' => array('Payment_Method'),
257 257
 
258 258
 							),
259 259
 							ARRAY_A,
260 260
 							'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time' );
261 261
 
262
-					foreach( $payments_info as $payment_method_and_gateway_txn_id ){
263
-						$payment_methods[] = isset( $payment_method_and_gateway_txn_id[ 'name' ] ) ? $payment_method_and_gateway_txn_id[ 'name' ] : __( 'Unknown', 'event_espresso' );
264
-						$gateway_txn_ids_etc[] = isset( $payment_method_and_gateway_txn_id[ 'gateway_txn_id' ] ) ? $payment_method_and_gateway_txn_id[ 'gateway_txn_id' ] : '';
265
-						$payment_times[] = isset( $payment_method_and_gateway_txn_id[ 'payment_time' ] ) ? $payment_method_and_gateway_txn_id[ 'payment_time' ] : '';
262
+					foreach ($payments_info as $payment_method_and_gateway_txn_id) {
263
+						$payment_methods[] = isset($payment_method_and_gateway_txn_id['name']) ? $payment_method_and_gateway_txn_id['name'] : __('Unknown', 'event_espresso');
264
+						$gateway_txn_ids_etc[] = isset($payment_method_and_gateway_txn_id['gateway_txn_id']) ? $payment_method_and_gateway_txn_id['gateway_txn_id'] : '';
265
+						$payment_times[] = isset($payment_method_and_gateway_txn_id['payment_time']) ? $payment_method_and_gateway_txn_id['payment_time'] : '';
266 266
 					}
267 267
 
268 268
 				}
269
-				$reg_csv_array[ __( 'Payment Date(s)', 'event_espresso' ) ] = implode( ',', $payment_times );
270
-				$reg_csv_array[ __( 'Payment Method(s)', 'event_espresso' ) ] = implode( ",", $payment_methods );
271
-				$reg_csv_array[ __( 'Gateway Transaction ID(s)', 'event_espresso' )] = implode( ',', $gateway_txn_ids_etc );
269
+				$reg_csv_array[__('Payment Date(s)', 'event_espresso')] = implode(',', $payment_times);
270
+				$reg_csv_array[__('Payment Method(s)', 'event_espresso')] = implode(",", $payment_methods);
271
+				$reg_csv_array[__('Gateway Transaction ID(s)', 'event_espresso')] = implode(',', $gateway_txn_ids_etc);
272 272
 
273 273
 				//get whether or not the user has checked in
274
-				$reg_csv_array[__("Check-Ins", "event_espresso")] = $reg_model->count_related( $reg_row[ 'Registration.REG_ID'] , 'Checkin' );
274
+				$reg_csv_array[__("Check-Ins", "event_espresso")] = $reg_model->count_related($reg_row['Registration.REG_ID'], 'Checkin');
275 275
 				//get ticket of registration and its price
276 276
 				$ticket_model = \EE_Registry::instance()->load_model('Ticket');
277
-				if( $reg_row[ 'Ticket.TKT_ID'] ) {
278
-					$ticket_name = \EEH_Export::prepare_value_from_db_for_display( $ticket_model, 'TKT_name', $reg_row[ 'Ticket.TKT_name' ] );
277
+				if ($reg_row['Ticket.TKT_ID']) {
278
+					$ticket_name = \EEH_Export::prepare_value_from_db_for_display($ticket_model, 'TKT_name', $reg_row['Ticket.TKT_name']);
279 279
 					$datetimes_strings = array();
280
-					foreach( \EEM_Datetime::instance()->get_all_wpdb_results( array( array( 'Ticket.TKT_ID' => $reg_row[ 'Ticket.TKT_ID' ] ), 'order_by' => array( 'DTT_EVT_start' => 'ASC' ), 'default_where_conditions' => 'none' ) ) as $datetime){
281
-						$datetimes_strings[] = \EEH_Export::prepare_value_from_db_for_display( \EEM_Datetime::instance(), 'DTT_EVT_start', $datetime[ 'Datetime.DTT_EVT_start'] );
280
+					foreach (\EEM_Datetime::instance()->get_all_wpdb_results(array(array('Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID']), 'order_by' => array('DTT_EVT_start' => 'ASC'), 'default_where_conditions' => 'none')) as $datetime) {
281
+						$datetimes_strings[] = \EEH_Export::prepare_value_from_db_for_display(\EEM_Datetime::instance(), 'DTT_EVT_start', $datetime['Datetime.DTT_EVT_start']);
282 282
 					}
283 283
 
284 284
 				} else {
285
-					$ticket_name = __( 'Unknown', 'event_espresso' );
286
-					$datetimes_strings = array( __( 'Unknown', 'event_espresso' ) );
285
+					$ticket_name = __('Unknown', 'event_espresso');
286
+					$datetimes_strings = array(__('Unknown', 'event_espresso'));
287 287
 				}
288 288
 				$reg_csv_array[$ticket_model->field_settings_for('TKT_name')->get_nicename()] = $ticket_name;
289 289
 				$reg_csv_array[__("Datetimes of Ticket", "event_espresso")] = implode(", ", $datetimes_strings);
290 290
 				//get datetime(s) of registration
291 291
 
292 292
 				//add attendee columns
293
-				foreach($att_fields_to_include as $att_field_name){
293
+				foreach ($att_fields_to_include as $att_field_name) {
294 294
 					$field_obj = \EEM_Attendee::instance()->field_settings_for($att_field_name);
295
-					if( $reg_row[ 'Attendee_CPT.ID' ]){
296
-						if($att_field_name == 'STA_ID'){
297
-							$value = \EEM_State::instance()->get_var( array( array( 'STA_ID' => $reg_row[ 'Attendee_Meta.STA_ID' ] ) ), 'STA_name' );
298
-						}elseif($att_field_name == 'CNT_ISO'){
299
-							$value = \EEM_Country::instance()->get_var( array( array( 'CNT_ISO' => $reg_row[ 'Attendee_Meta.CNT_ISO' ] ) ), 'CNT_name' );
300
-						}else{
301
-							$value = \EEH_Export::prepare_value_from_db_for_display( \EEM_Attendee::instance(), $att_field_name, $reg_row[ $field_obj->get_qualified_column() ] );
295
+					if ($reg_row['Attendee_CPT.ID']) {
296
+						if ($att_field_name == 'STA_ID') {
297
+							$value = \EEM_State::instance()->get_var(array(array('STA_ID' => $reg_row['Attendee_Meta.STA_ID'])), 'STA_name');
298
+						}elseif ($att_field_name == 'CNT_ISO') {
299
+							$value = \EEM_Country::instance()->get_var(array(array('CNT_ISO' => $reg_row['Attendee_Meta.CNT_ISO'])), 'CNT_name');
300
+						} else {
301
+							$value = \EEH_Export::prepare_value_from_db_for_display(\EEM_Attendee::instance(), $att_field_name, $reg_row[$field_obj->get_qualified_column()]);
302 302
 						}
303
-					}else{
303
+					} else {
304 304
 						$value = '';
305 305
 					}
306 306
 
307
-					$reg_csv_array[ \EEH_Export::get_column_name_for_field($field_obj) ] = $value;
307
+					$reg_csv_array[\EEH_Export::get_column_name_for_field($field_obj)] = $value;
308 308
 				}
309 309
 
310 310
 				//make sure each registration has the same questions in the same order
311
-				foreach($questions_for_these_regs_rows as $question_row){
312
-					if( ! isset($reg_csv_array[$question_row[ 'Question.QST_admin_label']])){
313
-						$reg_csv_array[$question_row[ 'Question.QST_admin_label' ] ] = null;
311
+				foreach ($questions_for_these_regs_rows as $question_row) {
312
+					if ( ! isset($reg_csv_array[$question_row['Question.QST_admin_label']])) {
313
+						$reg_csv_array[$question_row['Question.QST_admin_label']] = null;
314 314
 					}
315 315
 				}
316 316
 				$answers = \EEM_Answer::instance()->get_all_wpdb_results(
317 317
 					array(
318
-						array( 'REG_ID' => $reg_row[ 'Registration.REG_ID' ] ),
319
-						'force_join' => array( 'Question' )
318
+						array('REG_ID' => $reg_row['Registration.REG_ID']),
319
+						'force_join' => array('Question')
320 320
 					)
321 321
 				);
322 322
 				//now fill out the questions THEY answered
323
-				foreach( $answers as $answer_row ){
324
-					if( $answer_row[ 'Question.QST_ID' ] ){
323
+				foreach ($answers as $answer_row) {
324
+					if ($answer_row['Question.QST_ID']) {
325 325
 						$question_label = \EEH_Export::prepare_value_from_db_for_display(
326 326
 							\EEM_Question::instance(),
327 327
 							'QST_admin_label',
328
-							$answer_row[ 'Question.QST_admin_label' ]
328
+							$answer_row['Question.QST_admin_label']
329 329
 						);
330 330
 					} else {
331
-						$question_label = sprintf( __( 'Question $s', 'event_espresso' ), $answer_row[ 'Answer.QST_ID' ] );
331
+						$question_label = sprintf(__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']);
332 332
 					}
333
-					if ( isset( $answer_row[ 'Question.QST_type' ] )
334
-						 && $answer_row[ 'Question.QST_type' ] == \EEM_Question::QST_type_state
333
+					if (isset($answer_row['Question.QST_type'])
334
+						 && $answer_row['Question.QST_type'] == \EEM_Question::QST_type_state
335 335
 					) {
336
-						$reg_csv_array[ $question_label ] = \EEM_State::instance()->get_state_name_by_ID(
337
-							$answer_row[ 'Answer.ANS_value' ]
336
+						$reg_csv_array[$question_label] = \EEM_State::instance()->get_state_name_by_ID(
337
+							$answer_row['Answer.ANS_value']
338 338
 						);
339 339
 					} else {
340
-						$reg_csv_array[ $question_label ] = \EEH_Export::prepare_value_from_db_for_display(
340
+						$reg_csv_array[$question_label] = \EEH_Export::prepare_value_from_db_for_display(
341 341
 							\EEM_Answer::instance(),
342 342
 							'ANS_value',
343
-							$answer_row[ 'Answer.ANS_value' ]
343
+							$answer_row['Answer.ANS_value']
344 344
 						);
345 345
 					}
346 346
 				}
@@ -351,17 +351,17 @@  discard block
 block discarded – undo
351 351
 			}
352 352
 		}
353 353
 		//if we couldn't export anything, we want to at least show the column headers
354
-		if ( empty( $registrations_csv_ready_array ) ) {
354
+		if (empty($registrations_csv_ready_array)) {
355 355
 			$reg_csv_array = array();
356 356
 			$model_and_fields_to_include = array(
357 357
 				'Registration' => $reg_fields_to_include,
358 358
 				'Attendee'     => $att_fields_to_include
359 359
 			);
360
-			foreach ( $model_and_fields_to_include as $model_name => $field_list ) {
361
-				$model = \EE_Registry::instance()->load_model( $model_name );
362
-				foreach ( $field_list as $field_name ) {
363
-					$field = $model->field_settings_for( $field_name );
364
-					$reg_csv_array[ \EEH_Export::get_column_name_for_field( $field ) ] = null;
360
+			foreach ($model_and_fields_to_include as $model_name => $field_list) {
361
+				$model = \EE_Registry::instance()->load_model($model_name);
362
+				foreach ($field_list as $field_name) {
363
+					$field = $model->field_settings_for($field_name);
364
+					$reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = null;
365 365
 				}
366 366
 			}
367 367
 			$registrations_csv_ready_array[] = $reg_csv_array;
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
 	 * @param int $event_id
378 378
 	 * @return int
379 379
 	 */
380
-	public function count_units_to_process( $event_id ) {
380
+	public function count_units_to_process($event_id) {
381 381
 		//use the legacy filter
382 382
 		$query_params = apply_filters(
383 383
 			'FHEE__EE_Export__report_registration_for_event',
@@ -385,23 +385,23 @@  discard block
 block discarded – undo
385 385
 				array(
386 386
 					'OR' => array(
387 387
 						//don't include registrations from failed or abandoned transactions...
388
-						'Transaction.STS_ID' => array( 'NOT IN', array( \EEM_Transaction::failed_status_code, \EEM_Transaction::abandoned_status_code ) ),
388
+						'Transaction.STS_ID' => array('NOT IN', array(\EEM_Transaction::failed_status_code, \EEM_Transaction::abandoned_status_code)),
389 389
 						//unless the registration is approved, in which case include it regardless of transaction status
390 390
 						'STS_ID' => \EEM_Registration::status_id_approved
391 391
 						),
392
-					'Ticket.TKT_deleted' => array( 'IN', array( true, false ) )
392
+					'Ticket.TKT_deleted' => array('IN', array(true, false))
393 393
 					),
394
-				'order_by' => array('Transaction.TXN_ID'=>'asc','REG_count'=>'asc'),
395
-				'force_join' => array( 'Transaction', 'Ticket', 'Attendee' )
394
+				'order_by' => array('Transaction.TXN_ID'=>'asc', 'REG_count'=>'asc'),
395
+				'force_join' => array('Transaction', 'Ticket', 'Attendee')
396 396
 			),
397 397
 			$event_id
398 398
 		);
399
-		if( $event_id ){
400
-			$query_params[0]['EVT_ID'] =  $event_id;
399
+		if ($event_id) {
400
+			$query_params[0]['EVT_ID'] = $event_id;
401 401
 		} else {
402
-			$query_params[ 'force_join' ][] = 'Event';
402
+			$query_params['force_join'][] = 'Event';
403 403
 		}
404
-		return \EEM_Registration::instance()->count( $query_params );
404
+		return \EEM_Registration::instance()->count($query_params);
405 405
 	}
406 406
 
407 407
 
@@ -412,13 +412,13 @@  discard block
 block discarded – undo
412 412
 	 * @param JobParameters $job_parameters
413 413
 	 * @return boolean
414 414
 	 */
415
-	public function cleanup_job( JobParameters $job_parameters ){
415
+	public function cleanup_job(JobParameters $job_parameters) {
416 416
 		$this->_file_helper->delete(
417
-			\EEH_File::remove_filename_from_filepath( $job_parameters->extra_datum( 'filepath' ) ),
417
+			\EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')),
418 418
 			true,
419 419
 			'd'
420 420
 		);
421
-		return new JobStepResponse( $job_parameters, __( 'Cleaned up temporary file', 'event_espresso' ) );
421
+		return new JobStepResponse($job_parameters, __('Cleaned up temporary file', 'event_espresso'));
422 422
 	}
423 423
 }
424 424
 
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -410,7 +410,7 @@
 block discarded – undo
410 410
 	 * Performs any clean-up logic when we know the job is completed.
411 411
 	 * In this case, we delete the temporary file
412 412
 	 * @param JobParameters $job_parameters
413
-	 * @return boolean
413
+	 * @return JobStepResponse
414 414
 	 */
415 415
 	public function cleanup_job( JobParameters $job_parameters ){
416 416
 		$this->_file_helper->delete(
Please login to merge, or discard this patch.
caffeinated/admin/extend/events/help_tabs/import_page.help_tab.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -2,18 +2,18 @@
 block discarded – undo
2 2
 <p>
3 3
 <?php _e('The importer can be used to import event information into Event Espresso using a CSV file.', 'event_espresso'); ?>
4 4
 </p>
5
-<h3><?php _e("Importing from other Event Espresso 4 Sites", 'event_espresso');?></h3>
5
+<h3><?php _e("Importing from other Event Espresso 4 Sites", 'event_espresso'); ?></h3>
6 6
 <p>
7 7
 <?php _e('To import Event Espresso data from another Event Espresso 4 install, export a CSV file from the admin Events overview page, or anywhere you can generate a CSV export file from. Then upload that file here (regardless of what type of information was exported).', 'event_espresso'); ?>
8 8
 </p>
9 9
 <p>
10 10
 <?php _e('Note: its possible that data from the other site have the same IDs as data in this site. The importer recognizes that this data is from a different database and inserts new items for each item in the CSV file, regardless of whether its ID matches that of an item in this site\'s database or not. However, the importer also remembers the mapping from the old site\'s database to this site\'s database, and on subsequent CSV importers from that site, the data in this database will be updated instead of re-inserting new items.', 'event_espresso'); ?>
11 11
 </p>
12
-<h3><?php _e("Importing from this Site", 'event_espresso');?></h3>
13
-<p><?php _e("You may want to export data from this site, modify it (or modify the database), and re-import it. When this is done, the importer recognizes that the data is from this site\'s database and updates the records (instead of inserting new items like it would have, had the CSV data been from a different site).", 'event_espresso');?></p>
12
+<h3><?php _e("Importing from this Site", 'event_espresso'); ?></h3>
13
+<p><?php _e("You may want to export data from this site, modify it (or modify the database), and re-import it. When this is done, the importer recognizes that the data is from this site\'s database and updates the records (instead of inserting new items like it would have, had the CSV data been from a different site).", 'event_espresso'); ?></p>
14 14
 
15
-	<h3><?php _e("Notes about Generating your own CSV Import Files", "event_espresso");?></h3>
16
-	<p><?php _e("If you think you could save time entering data into a CSV file, you can use the sample import file below. Note that creating your own CSV file is more complicated than in Event Espresso 3.1 because of the more advanced data structure, and so we recommend creating/editing your events using the normal web-interface.", "event_espresso");?></p>
17
-	<p><?php _e("The export file is just an export of an event, or if you do not have any events in your system, it will only contain column headers. Do not change those column headers. Add as many rows as you like. ", "event_espresso");?></p>
18
-	<p><?php _e("In the ID columns (columns ending in '_ID'), you should enter 'temporary IDs', which are unique numbers/words that identify that item, which can be used later when you want to refer to that item. (For example, if you assign an event's EVT_ID to be a temporary id of 'my-event-1', then use that same phrase 'my-event-1' to refer to that event in the Datetime model's EVT_ID column)", "event_espresso");?></p>
19
-	<p><?php _e("Also note, you do NOT have to enter info in for each model. (You can, for example, only enter in Term_Taxonomies and Term model data)", "event_espresso");?></p>
20 15
\ No newline at end of file
16
+	<h3><?php _e("Notes about Generating your own CSV Import Files", "event_espresso"); ?></h3>
17
+	<p><?php _e("If you think you could save time entering data into a CSV file, you can use the sample import file below. Note that creating your own CSV file is more complicated than in Event Espresso 3.1 because of the more advanced data structure, and so we recommend creating/editing your events using the normal web-interface.", "event_espresso"); ?></p>
18
+	<p><?php _e("The export file is just an export of an event, or if you do not have any events in your system, it will only contain column headers. Do not change those column headers. Add as many rows as you like. ", "event_espresso"); ?></p>
19
+	<p><?php _e("In the ID columns (columns ending in '_ID'), you should enter 'temporary IDs', which are unique numbers/words that identify that item, which can be used later when you want to refer to that item. (For example, if you assign an event's EVT_ID to be a temporary id of 'my-event-1', then use that same phrase 'my-event-1' to refer to that event in the Datetime model's EVT_ID column)", "event_espresso"); ?></p>
20
+	<p><?php _e("Also note, you do NOT have to enter info in for each model. (You can, for example, only enter in Term_Taxonomies and Term model data)", "event_espresso"); ?></p>
21 21
\ No newline at end of file
Please login to merge, or discard this patch.
core/admin/EE_Admin_Hooks.core.php 1 patch
Spacing   +105 added lines, -105 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
 /**
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 	 * constructor
210 210
 	 * @param EE_Admin_Page $admin_page the calling admin_page_object
211 211
 	 */
212
-	public function __construct( EE_Admin_Page $adminpage ) {
212
+	public function __construct(EE_Admin_Page $adminpage) {
213 213
 
214 214
 		$this->_adminpage_obj = $adminpage;
215 215
 		$this->_req_data = array_merge($_GET, $_POST);
@@ -217,11 +217,11 @@  discard block
 block discarded – undo
217 217
 		$this->_set_hooks_properties();
218 218
 
219 219
 		//first let's verify we're on the right page
220
-		if ( !isset( $this->_req_data['page'] ) || ( isset( $this->_req_data['page'] ) && $this->_adminpage_obj->page_slug != $this->_req_data['page'] ) )
220
+		if ( ! isset($this->_req_data['page']) || (isset($this->_req_data['page']) && $this->_adminpage_obj->page_slug != $this->_req_data['page']))
221 221
 			return; //get out nothing more to be done here.
222 222
 
223 223
 		//allow for extends to modify properties
224
-		if ( method_exists( $this, '_extend_properties' ) )
224
+		if (method_exists($this, '_extend_properties'))
225 225
 			$this->_extend_properties();
226 226
 
227 227
 		$this->_set_page_object();
@@ -229,9 +229,9 @@  discard block
 block discarded – undo
229 229
 		$this->_load_custom_methods();
230 230
 		$this->_load_routed_hooks();
231 231
 
232
-		add_action( 'admin_enqueue_scripts', array($this, 'enqueue_scripts_styles' ) );
233
-		add_action( 'admin_enqueue_scripts', array($this, 'add_metaboxes'), 20 );
234
-		add_action( 'admin_enqueue_scripts', array($this, 'remove_metaboxes'), 15 );
232
+		add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts_styles'));
233
+		add_action('admin_enqueue_scripts', array($this, 'add_metaboxes'), 20);
234
+		add_action('admin_enqueue_scripts', array($this, 'remove_metaboxes'), 15);
235 235
 
236 236
 		$this->_ajax_hooks();
237 237
 
@@ -272,15 +272,15 @@  discard block
 block discarded – undo
272 272
 	 */
273 273
 	public function enqueue_scripts_styles() {
274 274
 
275
-		if ( !empty( $this->_scripts_styles ) ) {
275
+		if ( ! empty($this->_scripts_styles)) {
276 276
 			//first let's do all the registrations
277
-			if ( !isset($this->_scripts_styles['registers'] ) ) {
277
+			if ( ! isset($this->_scripts_styles['registers'])) {
278 278
 				$msg[] = __('There is no "registers" index in the <code>$this->_scripts_styles</code> property.', 'event_espresso');
279
-				$msg[] = sprintf ( __('Make sure you read the phpdoc comments above the definition of the $_scripts_styles property in the <code>EE_Admin_Hooks</code> class and modify according in the %s child', 'event_espresso'), '<strong>' . $this->caller . '</strong>' );
280
-				throw new EE_Error( implode( '||', $msg ) );
279
+				$msg[] = sprintf(__('Make sure you read the phpdoc comments above the definition of the $_scripts_styles property in the <code>EE_Admin_Hooks</code> class and modify according in the %s child', 'event_espresso'), '<strong>'.$this->caller.'</strong>');
280
+				throw new EE_Error(implode('||', $msg));
281 281
 			}
282 282
 
283
-			foreach( $this->_scripts_styles['registers'] as $ref => $details ) {
283
+			foreach ($this->_scripts_styles['registers'] as $ref => $details) {
284 284
 				$defaults = array(
285 285
 					'type' => 'js',
286 286
 					'url' => '',
@@ -289,48 +289,48 @@  discard block
 block discarded – undo
289 289
 					'footer' => TRUE
290 290
 					);
291 291
 				$details = wp_parse_args($details, $defaults);
292
-				extract( $details );
292
+				extract($details);
293 293
 
294 294
 				//let's make sure that we set the 'registers' type if it's not set! We need it later to determine whhich enqueu we do
295 295
 				$this->_scripts_styles['registers'][$ref]['type'] = $type;
296 296
 
297 297
 				//let's make sure we're not missing any REQUIRED parameters
298
-				if ( empty($url) ) {
299
-					$msg[] = sprintf( __('Missing the url for the requested %s', 'event_espresso'), $type == 'js' ? 'script' : 'stylesheet' );
300
-					$msg[] = sprintf( __('Doublecheck your <code>$this->_scripts_styles</code> array in %s and make sure that there is a "url" set for the %s ref', 'event_espresso'), '<strong>' . $this->caller . '</strong>', $ref );
301
-					throw new EE_Error( implode( '||', $msg ) );
298
+				if (empty($url)) {
299
+					$msg[] = sprintf(__('Missing the url for the requested %s', 'event_espresso'), $type == 'js' ? 'script' : 'stylesheet');
300
+					$msg[] = sprintf(__('Doublecheck your <code>$this->_scripts_styles</code> array in %s and make sure that there is a "url" set for the %s ref', 'event_espresso'), '<strong>'.$this->caller.'</strong>', $ref);
301
+					throw new EE_Error(implode('||', $msg));
302 302
 				}
303 303
 				//made it here so let's do the appropriate registration
304
-				$type == 'js' ? wp_register_script( $ref, $url, $depends, $version, $footer ) : wp_register_style( $ref, $url, $depends, $version );
304
+				$type == 'js' ? wp_register_script($ref, $url, $depends, $version, $footer) : wp_register_style($ref, $url, $depends, $version);
305 305
 			}
306 306
 
307 307
 			//k now lets do the enqueues
308
-			if( !isset( $this->_scripts_styles['enqueues'] ) )
309
-				return;  //not sure if we should throw an error here or not.
310
-			foreach( $this->_scripts_styles['enqueues'] as $ref => $routes ) {
308
+			if ( ! isset($this->_scripts_styles['enqueues']))
309
+				return; //not sure if we should throw an error here or not.
310
+			foreach ($this->_scripts_styles['enqueues'] as $ref => $routes) {
311 311
 				//make sure $routes is an array
312 312
 				$routes = (array) $routes;
313 313
 
314
-				if ( in_array($this->_current_route, $routes ) ) {
314
+				if (in_array($this->_current_route, $routes)) {
315 315
 					$this->_scripts_styles['registers'][$ref]['type'] == 'js' ? wp_enqueue_script($ref) : wp_enqueue_style($ref);
316 316
 					//if we have a localization for the script let's do that too.
317
-					if ( isset( $this->_scripts_styles['localize'][$ref] ) ) {
318
-						foreach ( $this->_scripts_styles['localize'][$ref] as $object_name => $indexes ) {
319
-							wp_localize_script($ref, $object_name , $this->_scripts_styles['localize'][$ref][$object_name] );
317
+					if (isset($this->_scripts_styles['localize'][$ref])) {
318
+						foreach ($this->_scripts_styles['localize'][$ref] as $object_name => $indexes) {
319
+							wp_localize_script($ref, $object_name, $this->_scripts_styles['localize'][$ref][$object_name]);
320 320
 						}
321 321
 					}
322 322
 				}
323 323
 			}
324 324
 
325 325
 			//let's do the deregisters
326
-			if ( !isset( $this->_scripts_styles['deregisters'] ) )
326
+			if ( ! isset($this->_scripts_styles['deregisters']))
327 327
 				return;
328
-			foreach ( $this->_scripts_styles['deregisters'] as $ref => $details ) {
328
+			foreach ($this->_scripts_styles['deregisters'] as $ref => $details) {
329 329
 				$defaults = array(
330 330
 					'type' => 'js'
331 331
 					);
332
-				$details = wp_parse_args( $details, $defaults );
333
-				extract( $details );
332
+				$details = wp_parse_args($details, $defaults);
333
+				extract($details);
334 334
 
335 335
 				$type == 'js' ? wp_deregister_script($ref) : wp_deregister_style($ref);
336 336
 
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 	 */
350 350
 	private function _set_defaults() {
351 351
 		$this->_ajax_func = $this->_init_func = $this->_metaboxes = $this->_scripts = $this->_styles = $this->_wp_action_filters_priority = array();
352
-		$this->_current_route = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : 'default';
352
+		$this->_current_route = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'default';
353 353
 		$this->caller = get_class($this);
354 354
 		$this->_extend = stripos($this->caller, 'Extend') ? TRUE : FALSE;
355 355
 	}
@@ -364,34 +364,34 @@  discard block
 block discarded – undo
364 364
 	 */
365 365
 	protected function _set_page_object() {
366 366
 		//first make sure $this->_name is set
367
-		if ( empty( $this->_name ) ) {
367
+		if (empty($this->_name)) {
368 368
 			$msg[] = __('We can\'t load the page object', 'event_espresso');
369
-			$msg[] = sprintf( __("This is because the %s child class has not set the '_name' property", 'event_espresso'), $this->caller );
370
-			throw new EE_Error( implode( '||', $msg ) );
369
+			$msg[] = sprintf(__("This is because the %s child class has not set the '_name' property", 'event_espresso'), $this->caller);
370
+			throw new EE_Error(implode('||', $msg));
371 371
 		}
372 372
 
373
-		$ref = str_replace('_' , ' ', $this->_name); //take the_message -> the message
374
-		$ref = str_replace(' ', '_', ucwords($ref) ) . '_Admin_Page'; //take the message -> The_Message
373
+		$ref = str_replace('_', ' ', $this->_name); //take the_message -> the message
374
+		$ref = str_replace(' ', '_', ucwords($ref)).'_Admin_Page'; //take the message -> The_Message
375 375
 
376 376
 		//first default file (if exists)
377
-		$decaf_file = EE_ADMIN_PAGES . $this->_name . DS . $ref . '.core.php';
378
-		if ( is_readable( $decaf_file ) )
379
-		require_once( $decaf_file );
377
+		$decaf_file = EE_ADMIN_PAGES.$this->_name.DS.$ref.'.core.php';
378
+		if (is_readable($decaf_file))
379
+		require_once($decaf_file);
380 380
 
381 381
 		//now we have to do require for extended file (if needed)
382
-		if ( $this->_extend ) {
383
-			require_once( EE_CORE_CAF_ADMIN_EXTEND . $this->_name . DS . 'Extend_' . $ref . '.core.php' );
382
+		if ($this->_extend) {
383
+			require_once(EE_CORE_CAF_ADMIN_EXTEND.$this->_name.DS.'Extend_'.$ref.'.core.php');
384 384
 		}
385 385
 
386 386
 
387 387
 		//if we've got an extended class we use that!
388
-		$ref = $this->_extend ? 'Extend_' . $ref : $ref;
388
+		$ref = $this->_extend ? 'Extend_'.$ref : $ref;
389 389
 
390 390
 		//let's make sure the class exists
391
-		if ( !class_exists( $ref ) ) {
391
+		if ( ! class_exists($ref)) {
392 392
 			$msg[] = __('We can\'t load the page object', 'event_espresso');
393
-			$msg[] = sprintf( __('The class name that was given is %s. Check the spelling and make sure its correct, also there needs to be an autoloader setup for the class', 'event_espresso'), $ref );
394
-			throw new EE_Error( implode( '||', $msg ) );
393
+			$msg[] = sprintf(__('The class name that was given is %s. Check the spelling and make sure its correct, also there needs to be an autoloader setup for the class', 'event_espresso'), $ref);
394
+			throw new EE_Error(implode('||', $msg));
395 395
 		}
396 396
 
397 397
 		$a = new ReflectionClass($ref);
@@ -416,27 +416,27 @@  discard block
 block discarded – undo
416 416
 		$method_callback = $this->_current_route == 'default' ? 'default_callback' : $this->_current_route;
417 417
 
418 418
 		//these run before the Admin_Page route executes.
419
-		if ( method_exists( $this, $method_callback ) ) {
420
-			call_user_func( array( $this, $method_callback) );
419
+		if (method_exists($this, $method_callback)) {
420
+			call_user_func(array($this, $method_callback));
421 421
 		}
422 422
 
423 423
 
424 424
 		//these run via the _redirect_after_action method in EE_Admin_Page which usually happens after non_UI methods in EE_Admin_Page classes.  There are two redirect actions, the first fires before $query_args might be manipulated by "save and close" actions and the seond fires right before the actual redirect happens.
425 425
 		//first the actions
426 426
 		//note that these action hooks will have the $query_args value available.
427
-		$admin_class_name = get_class( $this->_adminpage_obj );
427
+		$admin_class_name = get_class($this->_adminpage_obj);
428 428
 
429
-		if ( method_exists( $this, '_redirect_action_early_' . $this->_current_route ) ) {
430
-			add_action( 'AHEE__' . $admin_class_name . '___redirect_after_action__before_redirect_modification_' . $this->_current_route, array( $this, '_redirect_action_early_' . $this->_current_route ), 10 );
429
+		if (method_exists($this, '_redirect_action_early_'.$this->_current_route)) {
430
+			add_action('AHEE__'.$admin_class_name.'___redirect_after_action__before_redirect_modification_'.$this->_current_route, array($this, '_redirect_action_early_'.$this->_current_route), 10);
431 431
 		}
432 432
 
433
-		if ( method_exists( $this, '_redirect_action_' . $this->_current_route ) ) {
434
-			add_action( 'AHEE_redirect_' . $admin_class_name . $this->_current_route, array( $this, '_redirect_action_' . $this->_current_route ), 10 );
433
+		if (method_exists($this, '_redirect_action_'.$this->_current_route)) {
434
+			add_action('AHEE_redirect_'.$admin_class_name.$this->_current_route, array($this, '_redirect_action_'.$this->_current_route), 10);
435 435
 		}
436 436
 
437 437
 		//let's hook into the _redirect itself and allow for changing where the user goes after redirect.  This will have $query_args and $redirect_url available.
438
-		if ( method_exists( $this, '_redirect_filter_' . $this->_current_route ) ) {
439
-			add_filter( 'FHEE_redirect_' . $admin_class_name . $this->_current_route, array( $this, '_redirect_filter_' . $this->_current_route ), 10, 2 );
438
+		if (method_exists($this, '_redirect_filter_'.$this->_current_route)) {
439
+			add_filter('FHEE_redirect_'.$admin_class_name.$this->_current_route, array($this, '_redirect_filter_'.$this->_current_route), 10, 2);
440 440
 		}
441 441
 
442 442
 	}
@@ -459,12 +459,12 @@  discard block
 block discarded – undo
459 459
 				'argnum' => 1,
460 460
 				'priority' => 10
461 461
 				),
462
-			'FHEE_list_table_views_' . $this->_adminpage_obj->page_slug . '_' . $this->_current_route => array(
462
+			'FHEE_list_table_views_'.$this->_adminpage_obj->page_slug.'_'.$this->_current_route => array(
463 463
 				'type' => 'filter',
464 464
 				'argnum' => 1,
465 465
 				'priority' => 10
466 466
 				),
467
-			'FHEE_list_table_views_' . $this->_adminpage_obj->page_slug => array(
467
+			'FHEE_list_table_views_'.$this->_adminpage_obj->page_slug => array(
468 468
 				'type' => 'filter',
469 469
 				'argnum' => 1,
470 470
 				'priority' => 10
@@ -483,14 +483,14 @@  discard block
 block discarded – undo
483 483
 
484 484
 
485 485
 
486
-		foreach ( $hook_filter_array as $hook => $args ) {
487
-			if ( method_exists( $this, $this->_current_route . '_' . $hook ) ) {
488
-				if ( isset( $this->_wp_action_filters_priority[$hook] ) )
486
+		foreach ($hook_filter_array as $hook => $args) {
487
+			if (method_exists($this, $this->_current_route.'_'.$hook)) {
488
+				if (isset($this->_wp_action_filters_priority[$hook]))
489 489
 					$args['priority'] = $this->_wp_action_filters_priority[$hook];
490
-				if ( $args['type'] == 'action' )
491
-					add_action( $hook, array( $this, $this->_current_route . '_' . $hook ), $args['priority'], $args['argnum'] );
490
+				if ($args['type'] == 'action')
491
+					add_action($hook, array($this, $this->_current_route.'_'.$hook), $args['priority'], $args['argnum']);
492 492
 				else
493
-					add_filter( $hook, array( $this, $this->_current_route . '_' . $hook ), $args['priority'], $args['argnum'] );
493
+					add_filter($hook, array($this, $this->_current_route.'_'.$hook), $args['priority'], $args['argnum']);
494 494
 			}
495 495
 		}
496 496
 
@@ -503,18 +503,18 @@  discard block
 block discarded – undo
503 503
 	 */
504 504
 	private function _ajax_hooks() {
505 505
 
506
-		if ( empty( $this->_ajax_func) )
506
+		if (empty($this->_ajax_func))
507 507
 			return; //get out there's nothing to take care of.
508 508
 
509
-		foreach ( $this->_ajax_func as $action => $method ) {
509
+		foreach ($this->_ajax_func as $action => $method) {
510 510
 			//make sure method exists
511
-			if ( !method_exists($this, $method) ) {
512
-				$msg[] = __('There is no corresponding method for the hook labeled in the _ajax_func array', 'event_espresso') . '<br />';
513
-				$msg[] = sprintf( __('The method name given in the array is %s, check the spelling and make sure it exists in the %s class', 'event_espresso' ), $method, $this->caller );
514
-				throw new EE_Error( implode('||', $msg ) );
511
+			if ( ! method_exists($this, $method)) {
512
+				$msg[] = __('There is no corresponding method for the hook labeled in the _ajax_func array', 'event_espresso').'<br />';
513
+				$msg[] = sprintf(__('The method name given in the array is %s, check the spelling and make sure it exists in the %s class', 'event_espresso'), $method, $this->caller);
514
+				throw new EE_Error(implode('||', $msg));
515 515
 			}
516 516
 
517
-			add_action('wp_ajax_' . $action, array( $this, $method ) );
517
+			add_action('wp_ajax_'.$action, array($this, $method));
518 518
 		}
519 519
 
520 520
 	}
@@ -527,21 +527,21 @@  discard block
 block discarded – undo
527 527
 	 * @return void
528 528
 	 */
529 529
 	protected function _init_hooks() {
530
-		if ( empty( $this->_init_func) )
530
+		if (empty($this->_init_func))
531 531
 			return; //get out there's nothing to take care of.
532 532
 
533 533
 		//We need to determine what page_route we are on!
534
-		$current_route = isset ( $_REQUEST['action'] ) ? $_REQUEST['action'] : 'default';
534
+		$current_route = isset ($_REQUEST['action']) ? $_REQUEST['action'] : 'default';
535 535
 
536
-		foreach ( $this->_init_func as $route => $method ) {
536
+		foreach ($this->_init_func as $route => $method) {
537 537
 			//make sure method exists
538
-			if ( !method_exists($this, $method) ) {
539
-				$msg[] = __('There is no corresponding method for the hook labeled in the _init_func array', 'event_espresso') . '<br />';
540
-				$msg[] = sprintf( __('The method name given in the array is %s, check the spelling and make sure it exists in the %s class', 'event_espresso' ), $method, $this->caller );
541
-				throw new EE_Error( implode('||', $msg ) );
538
+			if ( ! method_exists($this, $method)) {
539
+				$msg[] = __('There is no corresponding method for the hook labeled in the _init_func array', 'event_espresso').'<br />';
540
+				$msg[] = sprintf(__('The method name given in the array is %s, check the spelling and make sure it exists in the %s class', 'event_espresso'), $method, $this->caller);
541
+				throw new EE_Error(implode('||', $msg));
542 542
 			}
543
-			if ( $route == $this->_current_route )
544
-				add_action('admin_init', array( $this, $method ) );
543
+			if ($route == $this->_current_route)
544
+				add_action('admin_init', array($this, $method));
545 545
 		}
546 546
 
547 547
 	}
@@ -556,28 +556,28 @@  discard block
 block discarded – undo
556 556
 	 * @return void
557 557
 	 */
558 558
 	public function add_metaboxes() {
559
-		if ( empty( $this->_metaboxes ) )
559
+		if (empty($this->_metaboxes))
560 560
 			return; //get out we don't have any metaboxes to set for this connection
561 561
 
562
-		$this->_handle_metabox_array( $this->_metaboxes );
562
+		$this->_handle_metabox_array($this->_metaboxes);
563 563
 
564 564
 	}
565 565
 
566 566
 
567 567
 
568
-	private function _handle_metabox_array( $boxes, $add = TRUE ) {
568
+	private function _handle_metabox_array($boxes, $add = TRUE) {
569 569
 
570
-		foreach ( $boxes as $box ) {
571
-			if ( !isset($box['page_route']) )
570
+		foreach ($boxes as $box) {
571
+			if ( ! isset($box['page_route']))
572 572
 				continue; //we dont' have a valid array
573 573
 
574 574
 			//let's make sure $box['page_route'] is an array so the "foreach" will work.
575 575
 			$box['page_route'] = (array) $box['page_route'];
576 576
 
577
-			foreach ( $box['page_route'] as $route ) {
578
-				if ( $route != $this->_current_route )
577
+			foreach ($box['page_route'] as $route) {
578
+				if ($route != $this->_current_route)
579 579
 					continue; //get out we only add metaboxes for set route.
580
-				if ( $add )
580
+				if ($add)
581 581
 					$this->_add_metabox($box);
582 582
 				else
583 583
 					$this->_remove_metabox($box);
@@ -595,10 +595,10 @@  discard block
 block discarded – undo
595 595
 	 */
596 596
 	public function remove_metaboxes() {
597 597
 
598
-		if ( empty( $this->_remove_metaboxes ) )
598
+		if (empty($this->_remove_metaboxes))
599 599
 			return; //get out there are no metaboxes to remove
600 600
 
601
-		$this->_handle_metabox_array( $this->_remove_metaboxes, FALSE );
601
+		$this->_handle_metabox_array($this->_remove_metaboxes, FALSE);
602 602
 	}
603 603
 
604 604
 
@@ -608,53 +608,53 @@  discard block
 block discarded – undo
608 608
 	 * @access private
609 609
 	 * @param array $args an array of args that have been set for this metabox by the child class
610 610
 	 */
611
-	private function _add_metabox( $args ) {
611
+	private function _add_metabox($args) {
612 612
 		$current_screen = get_current_screen();
613
-		$screen_id = is_object( $current_screen ) ? $current_screen->id : NULL;
614
-		$func = isset( $args['func'] ) ? $args['func'] : 'some_invalid_callback';
613
+		$screen_id = is_object($current_screen) ? $current_screen->id : NULL;
614
+		$func = isset($args['func']) ? $args['func'] : 'some_invalid_callback';
615 615
 
616 616
 		//set defaults
617 617
 		$defaults = array(
618 618
 			'func' => $func,
619
-			'id' => $this->caller . '_' . $func . '_metabox',
619
+			'id' => $this->caller.'_'.$func.'_metabox',
620 620
 			'priority' => 'default',
621 621
 			'label' => $this->caller,
622 622
 			'context' => 'advanced',
623 623
 			'callback_args' => array(),
624
-			'page' => isset( $args['page'] ) ? $args['page'] : $screen_id
624
+			'page' => isset($args['page']) ? $args['page'] : $screen_id
625 625
 			);
626 626
 
627
-		$args = wp_parse_args( $args, $defaults );
627
+		$args = wp_parse_args($args, $defaults);
628 628
 		extract($args);
629 629
 
630 630
 
631 631
 		//make sure method exists
632
-		if ( !method_exists($this, $func) ) {
633
-			$msg[] = __('There is no corresponding method to display the metabox content', 'event_espresso') . '<br />';
634
-			$msg[] = sprintf( __('The method name given in the array is %s, check the spelling and make sure it exists in the %s class', 'event_espresso' ), $func, $this->caller );
635
-			throw new EE_Error( implode('||', $msg ) );
632
+		if ( ! method_exists($this, $func)) {
633
+			$msg[] = __('There is no corresponding method to display the metabox content', 'event_espresso').'<br />';
634
+			$msg[] = sprintf(__('The method name given in the array is %s, check the spelling and make sure it exists in the %s class', 'event_espresso'), $func, $this->caller);
635
+			throw new EE_Error(implode('||', $msg));
636 636
 		}
637 637
 
638 638
 		//everything checks out so lets add the metabox
639
-		add_meta_box( $id, $label, array( $this, $func ), $page, $context, $priority, $callback_args);
639
+		add_meta_box($id, $label, array($this, $func), $page, $context, $priority, $callback_args);
640 640
 	}
641 641
 
642 642
 
643 643
 
644
-	private function _remove_metabox( $args ) {
644
+	private function _remove_metabox($args) {
645 645
 		$current_screen = get_current_screen();
646
-		$screen_id = is_object( $current_screen ) ? $current_screen->id : NULL;
647
-		$func = isset( $args['func'] ) ? $args['func'] : 'some_invalid_callback';
646
+		$screen_id = is_object($current_screen) ? $current_screen->id : NULL;
647
+		$func = isset($args['func']) ? $args['func'] : 'some_invalid_callback';
648 648
 
649 649
 		//set defaults
650 650
 		$defaults = array(
651
-			'id' => isset( $args['id'] ) ? $args['id'] : $this->_current_route . '_' . $this->caller . '_' . $func . '_metabox',
651
+			'id' => isset($args['id']) ? $args['id'] : $this->_current_route.'_'.$this->caller.'_'.$func.'_metabox',
652 652
 			'context' => 'default',
653
-			'screen' => isset( $args['screen'] ) ? $args['screen'] : $screen_id
653
+			'screen' => isset($args['screen']) ? $args['screen'] : $screen_id
654 654
 		);
655 655
 
656
-		$args = wp_parse_args( $args, $defaults );
657
-		extract( $args );
656
+		$args = wp_parse_args($args, $defaults);
657
+		extract($args);
658 658
 
659 659
 		//everything checks out so lets remove the box!
660 660
 		remove_meta_box($id, $screen, $context);
Please login to merge, or discard this patch.