Completed
Branch FET-9576-iframes (7043fb)
by
unknown
486:30 queued 469:44
created
core/services/address/formatters/NullAddressFormatter.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace EventEspresso\core\services\address\formatters;
3 3
 
4
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
5
-	exit( 'No direct script access allowed' );
4
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 * @param string $CNT_ISO
29 29
 	 * @return string
30 30
 	 */
31
-	public function format( $address, $address2, $city, $state, $zip, $country, $CNT_ISO ) {
31
+	public function format($address, $address2, $city, $state, $zip, $country, $CNT_ISO) {
32 32
 		return null;
33 33
 	}
34 34
 
Please login to merge, or discard this patch.
core/services/address/formatters/AddressFormatter.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace EventEspresso\core\services\address\formatters;
3 3
 
4
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
5
-	exit( 'No direct script access allowed' );
4
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 
@@ -41,14 +41,14 @@  discard block
 block discarded – undo
41 41
 		// swap address part placeholders for the real text
42 42
 		$formatted_address = str_replace(
43 43
 		// find
44
-			array( '{address}', '{address2}', '{city}', '{state}', '{zip}', '{country}' ),
44
+			array('{address}', '{address2}', '{city}', '{state}', '{zip}', '{country}'),
45 45
 			// replace
46
-			array( $address, $address2, $city, $state, $zip, $country ),
46
+			array($address, $address2, $city, $state, $zip, $country),
47 47
 			// string
48 48
 			$formatted_address
49 49
 		);
50 50
 		// remove placeholder from start and end, reduce repeating placeholders to singles, then replace with HTML line breaks
51
-		return preg_replace( '/%+/', $sub, trim( $formatted_address, '%' ) );
51
+		return preg_replace('/%+/', $sub, trim($formatted_address, '%'));
52 52
 	}
53 53
 
54 54
 
Please login to merge, or discard this patch.
core/services/address/formatters/InlineAddressFormatter.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace EventEspresso\core\services\address\formatters;
3 3
 
4
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
5
-	exit( 'No direct script access allowed' );
4
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 * @param string $CNT_ISO
29 29
 	 * @return string
30 30
 	 */
31
-	public function format( $address, $address2, $city, $state, $zip, $country, $CNT_ISO ) {
31
+	public function format($address, $address2, $city, $state, $zip, $country, $CNT_ISO) {
32 32
 		$address_formats = apply_filters(
33 33
 			'FHEE__EE_Inline_Address_Formatter__address_formats',
34 34
 			array(
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 			)
40 40
 		);
41 41
 		// if the incoming country has a set format, use that, else use the default
42
-		$formatted_address = isset( $address_formats[ $CNT_ISO ] ) ? $address_formats[ $CNT_ISO ]
42
+		$formatted_address = isset($address_formats[$CNT_ISO]) ? $address_formats[$CNT_ISO]
43 43
 			: $address_formats['ZZZ'];
44 44
 		return $this->parse_formatted_address(
45 45
 			$address,
Please login to merge, or discard this patch.
core/EE_Log.core.php 1 patch
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
2 2
 /**
3 3
  *
4 4
  * Class EE_Log
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	 * @return EE_Log
63 63
 	 */
64 64
 	public static function instance() {
65
-		if ( ! self::$_instance instanceof EE_Log ) {
65
+		if ( ! self::$_instance instanceof EE_Log) {
66 66
 			self::$_instance = new self();
67 67
 		}
68 68
 		return self::$_instance;
@@ -74,11 +74,11 @@  discard block
 block discarded – undo
74 74
 	 */
75 75
 	private function __construct() {
76 76
 
77
-		if ( ! EE_Registry::instance()->CFG->admin->use_full_logging && ! EE_Registry::instance()->CFG->admin->use_remote_logging ) {
77
+		if ( ! EE_Registry::instance()->CFG->admin->use_full_logging && ! EE_Registry::instance()->CFG->admin->use_remote_logging) {
78 78
 			return;
79 79
 		}
80 80
 
81
-		$this->_logs_folder = EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS;
81
+		$this->_logs_folder = EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS;
82 82
 		$this->_log_file = EE_Registry::instance()->CFG->admin->log_file_name();
83 83
 		$this->_log = '';
84 84
 		$this->_debug_file = EE_Registry::instance()->CFG->admin->debug_file_name();
@@ -86,15 +86,15 @@  discard block
 block discarded – undo
86 86
 		$this->_remote_logging_url = EE_Registry::instance()->CFG->admin->remote_logging_url;
87 87
 		$this->_remote_log = '';
88 88
 
89
-		add_action( 'admin_init', array( $this, 'verify_filesystem' ), -10 );
90
-		add_action( 'AHEE_log', array( $this, 'log' ), 10, 4 );
91
-		if ( EE_Registry::instance()->CFG->admin->use_full_logging ) {
92
-			add_action( 'shutdown', array( $this, 'write_log' ), 9999 );
89
+		add_action('admin_init', array($this, 'verify_filesystem'), -10);
90
+		add_action('AHEE_log', array($this, 'log'), 10, 4);
91
+		if (EE_Registry::instance()->CFG->admin->use_full_logging) {
92
+			add_action('shutdown', array($this, 'write_log'), 9999);
93 93
 			// if WP_DEBUG
94
-			add_action( 'shutdown', array( $this, 'write_debug' ), 9999 );
94
+			add_action('shutdown', array($this, 'write_debug'), 9999);
95 95
 		}
96
-		if ( EE_Registry::instance()->CFG->admin->use_remote_logging ) {
97
-			add_action( 'shutdown', array( $this, 'send_log' ), 9999 );
96
+		if (EE_Registry::instance()->CFG->admin->use_remote_logging) {
97
+			add_action('shutdown', array($this, 'send_log'), 9999);
98 98
 		}
99 99
 
100 100
 	}
@@ -108,11 +108,11 @@  discard block
 block discarded – undo
108 108
 	 */
109 109
 	public function verify_filesystem() {
110 110
 		try {
111
-			EEH_File::ensure_file_exists_and_is_writable( $this->_logs_folder . $this->_log_file );
112
-			EEH_File::ensure_file_exists_and_is_writable( $this->_logs_folder . $this->_debug_file );
113
-			EEH_File::add_htaccess_deny_from_all( $this->_logs_folder );
114
-		} catch( EE_Error $e ){
115
-			EE_Error::add_error( sprintf( __(  'Event Espresso logging could not be setup because: %s', 'event_espresso' ), ' &nbsp; &nbsp; ' . $e->getMessage() ), __FILE__, __FUNCTION__, __LINE__ );
111
+			EEH_File::ensure_file_exists_and_is_writable($this->_logs_folder.$this->_log_file);
112
+			EEH_File::ensure_file_exists_and_is_writable($this->_logs_folder.$this->_debug_file);
113
+			EEH_File::add_htaccess_deny_from_all($this->_logs_folder);
114
+		} catch (EE_Error $e) {
115
+			EE_Error::add_error(sprintf(__('Event Espresso logging could not be setup because: %s', 'event_espresso'), ' &nbsp; &nbsp; '.$e->getMessage()), __FILE__, __FUNCTION__, __LINE__);
116 116
 			return;
117 117
 		}
118 118
 	}
@@ -129,15 +129,15 @@  discard block
 block discarded – undo
129 129
 	 * @param string $type
130 130
 	 * @return string
131 131
 	 */
132
-	private function _format_message( $file = '', $function = '', $message = '', $type = '' ) {
133
-		$msg = '----------------------------------------------------------------------------------------' . PHP_EOL;
134
-		$msg .= '[' . current_time( 'mysql' ) . '] ';
135
-		$msg .= ! empty( $file ) ? basename( $file ) : '';
136
-		$msg .= ! empty( $file ) && ! empty( $function ) ? ' -> ' : '';
137
-		$msg .= ! empty( $function ) ? $function . '()' : '';
132
+	private function _format_message($file = '', $function = '', $message = '', $type = '') {
133
+		$msg = '----------------------------------------------------------------------------------------'.PHP_EOL;
134
+		$msg .= '['.current_time('mysql').'] ';
135
+		$msg .= ! empty($file) ? basename($file) : '';
136
+		$msg .= ! empty($file) && ! empty($function) ? ' -> ' : '';
137
+		$msg .= ! empty($function) ? $function.'()' : '';
138 138
 		$msg .= PHP_EOL;
139
-		$type = ! empty( $type ) ? $type : 'log message';
140
-		$msg .= ! empty( $message ) ? "\t" . '[' . $type . '] ' . $message . PHP_EOL : '';
139
+		$type = ! empty($type) ? $type : 'log message';
140
+		$msg .= ! empty($message) ? "\t".'['.$type.'] '.$message.PHP_EOL : '';
141 141
 		return $msg;
142 142
 	}
143 143
 
@@ -152,8 +152,8 @@  discard block
 block discarded – undo
152 152
 	 * @param string $message
153 153
 	 * @param string $type
154 154
 	 */
155
-	public function log( $file = '', $function = '', $message = '', $type = '' ) {
156
-		$this->_log .= $this->_format_message( $file, $function, $message, $type );
155
+	public function log($file = '', $function = '', $message = '', $type = '') {
156
+		$this->_log .= $this->_format_message($file, $function, $message, $type);
157 157
 	}
158 158
 
159 159
 
@@ -165,10 +165,10 @@  discard block
 block discarded – undo
165 165
 	public function write_log() {
166 166
 		try {
167 167
 			//get existing log file and append new log info
168
-			$this->_log = EEH_File::get_file_contents( $this->_logs_folder . $this->_log_file ) . $this->_log;
169
-			EEH_File::write_to_file( $this->_logs_folder . $this->_log_file, $this->_log, 'Event Espresso Log' );
170
-		} catch( EE_Error $e ){
171
-			EE_Error::add_error( sprintf( __(  'Could not write to the Event Espresso log file because: %s', 'event_espresso' ), ' &nbsp; &nbsp; ' . $e->getMessage() ), __FILE__, __FUNCTION__, __LINE__ );
168
+			$this->_log = EEH_File::get_file_contents($this->_logs_folder.$this->_log_file).$this->_log;
169
+			EEH_File::write_to_file($this->_logs_folder.$this->_log_file, $this->_log, 'Event Espresso Log');
170
+		} catch (EE_Error $e) {
171
+			EE_Error::add_error(sprintf(__('Could not write to the Event Espresso log file because: %s', 'event_espresso'), ' &nbsp; &nbsp; '.$e->getMessage()), __FILE__, __FUNCTION__, __LINE__);
172 172
 			return;
173 173
 		}
174 174
 	}
@@ -181,31 +181,31 @@  discard block
 block discarded – undo
181 181
 	 */
182 182
 	public function send_log() {
183 183
 
184
-		if ( empty( $this->_remote_logging_url )) {
184
+		if (empty($this->_remote_logging_url)) {
185 185
 			return;
186 186
 		}
187 187
 
188
-		$data = 'domain=' . $_SERVER['HTTP_HOST'];
189
-		$data .= '&ip=' . $_SERVER['SERVER_ADDR'];
190
-		$data .= '&server_type=' . $_SERVER['SERVER_SOFTWARE'];
191
-		$data .= '&time=' . time();
192
-		$data .= '&remote_log=' . $this->_log;
193
-		$data .= '&request_array=' . json_encode( $_REQUEST );
188
+		$data = 'domain='.$_SERVER['HTTP_HOST'];
189
+		$data .= '&ip='.$_SERVER['SERVER_ADDR'];
190
+		$data .= '&server_type='.$_SERVER['SERVER_SOFTWARE'];
191
+		$data .= '&time='.time();
192
+		$data .= '&remote_log='.$this->_log;
193
+		$data .= '&request_array='.json_encode($_REQUEST);
194 194
 		$data .= '&action=save';
195 195
 
196
-		if ( defined( 'EELOGGING_PASS' )) {
197
-			$data .= '&pass=' . EELOGGING_PASS;
196
+		if (defined('EELOGGING_PASS')) {
197
+			$data .= '&pass='.EELOGGING_PASS;
198 198
 		}
199
-		if ( defined( 'EELOGGING_KEY' )) {
200
-			$data .= '&key=' . EELOGGING_KEY;
199
+		if (defined('EELOGGING_KEY')) {
200
+			$data .= '&key='.EELOGGING_KEY;
201 201
 		}
202 202
 
203
-		$c = curl_init( $this->_remote_logging_url );
204
-		curl_setopt( $c, CURLOPT_POST, TRUE );
205
-		curl_setopt( $c, CURLOPT_POSTFIELDS, $data );
206
-		curl_setopt( $c, CURLOPT_RETURNTRANSFER, TRUE );
207
-		curl_exec( $c );
208
-		curl_close( $c );
203
+		$c = curl_init($this->_remote_logging_url);
204
+		curl_setopt($c, CURLOPT_POST, TRUE);
205
+		curl_setopt($c, CURLOPT_POSTFIELDS, $data);
206
+		curl_setopt($c, CURLOPT_RETURNTRANSFER, TRUE);
207
+		curl_exec($c);
208
+		curl_close($c);
209 209
 	}
210 210
 
211 211
 
@@ -216,18 +216,18 @@  discard block
 block discarded – undo
216 216
 	 * previous entries are overwritten
217 217
 	 */
218 218
 	public function write_debug() {
219
-		if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
219
+		if (defined('WP_DEBUG') && WP_DEBUG) {
220 220
 			$this->_debug_log = '';
221
-			foreach ( $_GET as $key => $value ) {
222
-				$this->_debug_log .= '$_GET["' . $key . '"] = "' . serialize($value) . '"' . PHP_EOL;
221
+			foreach ($_GET as $key => $value) {
222
+				$this->_debug_log .= '$_GET["'.$key.'"] = "'.serialize($value).'"'.PHP_EOL;
223 223
 			}
224
-			foreach ( $_POST as $key => $value ) {
225
-				$this->_debug_log .= '$_POST["' . $key . '"] = "' . serialize($value) . '"' . PHP_EOL;
224
+			foreach ($_POST as $key => $value) {
225
+				$this->_debug_log .= '$_POST["'.$key.'"] = "'.serialize($value).'"'.PHP_EOL;
226 226
 			}
227 227
 			try {
228
-				EEH_File::write_to_file( $this->_logs_folder . $this->_debug_file, $this->_debug_log, 'Event Espresso Debug Log' );
229
-			} catch( EE_Error $e ){
230
-				EE_Error::add_error( sprintf( __(  'Could not write to the Event Espresso debug log file because: %s', 'event_espresso' ), ' &nbsp; &nbsp; ' . $e->getMessage() ), __FILE__, __FUNCTION__, __LINE__ );
228
+				EEH_File::write_to_file($this->_logs_folder.$this->_debug_file, $this->_debug_log, 'Event Espresso Debug Log');
229
+			} catch (EE_Error $e) {
230
+				EE_Error::add_error(sprintf(__('Could not write to the Event Espresso debug log file because: %s', 'event_espresso'), ' &nbsp; &nbsp; '.$e->getMessage()), __FILE__, __FUNCTION__, __LINE__);
231 231
 				return;
232 232
 			}
233 233
 		}
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 	 * __clone
240 240
 	 */
241 241
 	public function __clone() {
242
-		trigger_error( __( 'Clone is not allowed.', 'event_espresso' ), E_USER_ERROR );
242
+		trigger_error(__('Clone is not allowed.', 'event_espresso'), E_USER_ERROR);
243 243
 	}
244 244
 
245 245
 
Please login to merge, or discard this patch.
core/business/EE_Processor_Base.class.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -32,8 +32,8 @@  discard block
 block discarded – undo
32 32
 	/**
33 33
 	 * @param boolean $IPN
34 34
 	 */
35
-	public static function set_IPN( $IPN ) {
36
-		self::$IPN = filter_var( $IPN, FILTER_VALIDATE_BOOLEAN );
35
+	public static function set_IPN($IPN) {
36
+		self::$IPN = filter_var($IPN, FILTER_VALIDATE_BOOLEAN);
37 37
 	}
38 38
 
39 39
 
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
44 44
 	 * @param bool $revisit
45 45
 	 * @return void
46 46
 	 */
47
-	public function set_revisit( $revisit = false ) {
48
-		$this->_revisit = filter_var( $revisit, FILTER_VALIDATE_BOOLEAN );
47
+	public function set_revisit($revisit = false) {
48
+		$this->_revisit = filter_var($revisit, FILTER_VALIDATE_BOOLEAN);
49 49
 	}
50 50
 
51 51
 
@@ -60,16 +60,16 @@  discard block
 block discarded – undo
60 60
 	 * @param array $info
61 61
 	 * @param bool $display_request
62 62
 	 */
63
-	protected function log( $class = '', $func = '', $line = '', EE_Transaction $transaction, $info = array(), $display_request = false ) {
64
-		if ( WP_DEBUG && false ) {
65
-			if ( $transaction instanceof EE_Transaction ) {
63
+	protected function log($class = '', $func = '', $line = '', EE_Transaction $transaction, $info = array(), $display_request = false) {
64
+		if (WP_DEBUG && false) {
65
+			if ($transaction instanceof EE_Transaction) {
66 66
 				// don't serialize objects
67
-				$info = EEH_Debug_Tools::strip_objects( $info );
68
-				if ( $transaction->ID() ) {
69
-					$info[ 'TXN_status' ] = $transaction->status_ID();
70
-					$info[ 'TXN_reg_steps' ] = $transaction->reg_steps();
71
-					$index = 'EE_Transaction: ' . $transaction->ID();
72
-					EEH_Debug_Tools::log( $class, $func, $line, $info, $display_request, $index );
67
+				$info = EEH_Debug_Tools::strip_objects($info);
68
+				if ($transaction->ID()) {
69
+					$info['TXN_status'] = $transaction->status_ID();
70
+					$info['TXN_reg_steps'] = $transaction->reg_steps();
71
+					$index = 'EE_Transaction: '.$transaction->ID();
72
+					EEH_Debug_Tools::log($class, $func, $line, $info, $display_request, $index);
73 73
 				}
74 74
 			}
75 75
 		}
Please login to merge, or discard this patch.
core/business/EE_Registration_Processor.class.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 if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
2
-EE_Registry::instance()->load_class( 'Processor_Base' );
2
+EE_Registry::instance()->load_class('Processor_Base');
3 3
 
4 4
 /**
5 5
  * Class EE_Registration_Processor
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	 */
61 61
 	public static function instance() {
62 62
 		// check if class object is instantiated
63
-		if ( ! self::$_instance instanceof EE_Registration_Processor ) {
63
+		if ( ! self::$_instance instanceof EE_Registration_Processor) {
64 64
 			self::$_instance = new self();
65 65
 		}
66 66
 		return self::$_instance;
@@ -96,37 +96,37 @@  discard block
 block discarded – undo
96 96
 	 * @return \EE_Registration | null
97 97
 	 * @throws \EE_Error
98 98
 	 */
99
-	public function generate_ONE_registration_from_line_item( EE_Line_Item $line_item, EE_Transaction $transaction, $att_nmbr = 1, $total_ticket_count = 1 ) {
99
+	public function generate_ONE_registration_from_line_item(EE_Line_Item $line_item, EE_Transaction $transaction, $att_nmbr = 1, $total_ticket_count = 1) {
100 100
 		// grab the related ticket object for this line_item
101 101
 		$ticket = $line_item->ticket();
102
-		if ( ! $ticket instanceof EE_Ticket ) {
103
-			EE_Error::add_error( sprintf( __( "Line item %s did not contain a valid ticket", "event_espresso" ), $line_item->ID() ), __FILE__, __FUNCTION__, __LINE__ );
102
+		if ( ! $ticket instanceof EE_Ticket) {
103
+			EE_Error::add_error(sprintf(__("Line item %s did not contain a valid ticket", "event_espresso"), $line_item->ID()), __FILE__, __FUNCTION__, __LINE__);
104 104
 			return null;
105 105
 		}
106
-		$first_datetime = $ticket->get_first_related( 'Datetime' );
107
-		if ( ! $first_datetime instanceof EE_Datetime ) {
108
-			EE_Error::add_error( sprintf( __( "The ticket (%s) is not associated with any valid datetimes.", "event_espresso" ), $ticket->name() ), __FILE__, __FUNCTION__, __LINE__ );
106
+		$first_datetime = $ticket->get_first_related('Datetime');
107
+		if ( ! $first_datetime instanceof EE_Datetime) {
108
+			EE_Error::add_error(sprintf(__("The ticket (%s) is not associated with any valid datetimes.", "event_espresso"), $ticket->name()), __FILE__, __FUNCTION__, __LINE__);
109 109
 			return null;
110 110
 		}
111
-		$event = $first_datetime->get_first_related( 'Event' );
112
-		if ( ! $event instanceof EE_Event ) {
113
-			EE_Error::add_error( sprintf( __( "The ticket (%s) is not associated with a valid event.", "event_espresso" ), $ticket->name() ), __FILE__, __FUNCTION__, __LINE__ );
111
+		$event = $first_datetime->get_first_related('Event');
112
+		if ( ! $event instanceof EE_Event) {
113
+			EE_Error::add_error(sprintf(__("The ticket (%s) is not associated with a valid event.", "event_espresso"), $ticket->name()), __FILE__, __FUNCTION__, __LINE__);
114 114
 			return null;
115 115
 		}
116
-		$reg_url_link = $this->generate_reg_url_link( $att_nmbr, $line_item );
116
+		$reg_url_link = $this->generate_reg_url_link($att_nmbr, $line_item);
117 117
 
118
-		if( $this->_reg_final_price_per_tkt_line_item === null ) {
119
-			$this->_reg_final_price_per_tkt_line_item = EEH_Line_Item::calculate_reg_final_prices_per_line_item( $transaction->total_line_item() );
118
+		if ($this->_reg_final_price_per_tkt_line_item === null) {
119
+			$this->_reg_final_price_per_tkt_line_item = EEH_Line_Item::calculate_reg_final_prices_per_line_item($transaction->total_line_item());
120 120
 		}
121 121
 		//ok now find this new registration's final price
122
-		if( isset( $this->_reg_final_price_per_tkt_line_item[ $line_item->ID() ] ) ) {
123
-			$final_price = $this->_reg_final_price_per_tkt_line_item[ $line_item->ID() ] ;
124
-		}else{
125
-			$message = sprintf( __( 'The ticket line item (ID:%1$d) had no entry in the reg_final_price_per_tkt_line_item array.', 'event_espresso' ), $line_item->ID() );
126
-			if( WP_DEBUG ){
127
-				throw new EE_Error( $message );
128
-			}else{
129
-				EE_Log::instance()->log(__CLASS__, __FUNCTION__, $message );
122
+		if (isset($this->_reg_final_price_per_tkt_line_item[$line_item->ID()])) {
123
+			$final_price = $this->_reg_final_price_per_tkt_line_item[$line_item->ID()];
124
+		} else {
125
+			$message = sprintf(__('The ticket line item (ID:%1$d) had no entry in the reg_final_price_per_tkt_line_item array.', 'event_espresso'), $line_item->ID());
126
+			if (WP_DEBUG) {
127
+				throw new EE_Error($message);
128
+			} else {
129
+				EE_Log::instance()->log(__CLASS__, __FUNCTION__, $message);
130 130
 			}
131 131
 			$final_price = $ticket->get_ticket_total_with_taxes();
132 132
 
@@ -146,11 +146,11 @@  discard block
 block discarded – undo
146 146
 				'REG_url_link'    => $reg_url_link
147 147
 			)
148 148
 		);
149
-		$registration->set_reg_code( $this->generate_reg_code( $registration ) );
149
+		$registration->set_reg_code($this->generate_reg_code($registration));
150 150
 		$registration->save();
151
-		$registration->_add_relation_to( $event, 'Event', array(), $event->ID() );
152
-		$registration->_add_relation_to( $line_item->ticket(), 'Ticket', array(), $line_item->ticket()->ID() );
153
-		$transaction->_add_relation_to( $registration, 'Registration' );
151
+		$registration->_add_relation_to($event, 'Event', array(), $event->ID());
152
+		$registration->_add_relation_to($line_item->ticket(), 'Ticket', array(), $line_item->ticket()->ID());
153
+		$transaction->_add_relation_to($registration, 'Registration');
154 154
 		return $registration;
155 155
 	}
156 156
 
@@ -163,9 +163,9 @@  discard block
 block discarded – undo
163 163
 	 * @param EE_Line_Item | string $item
164 164
 	 * @return string
165 165
 	 */
166
-	public function generate_reg_url_link( $att_nmbr, $item ) {
166
+	public function generate_reg_url_link($att_nmbr, $item) {
167 167
 		$reg_url_link = $item instanceof EE_Line_Item ? $item->code() : $item;
168
-		$reg_url_link = $att_nmbr . '-' . md5( $reg_url_link . microtime() );
168
+		$reg_url_link = $att_nmbr.'-'.md5($reg_url_link.microtime());
169 169
 		return $reg_url_link;
170 170
 	}
171 171
 
@@ -177,18 +177,18 @@  discard block
 block discarded – undo
177 177
 	 * @param \EE_Registration $registration
178 178
 	 * @return string
179 179
 	 */
180
-	public function generate_reg_code( EE_Registration $registration ) {
180
+	public function generate_reg_code(EE_Registration $registration) {
181 181
 	// figure out where to start parsing the reg code
182
-		$chars = strpos( $registration->reg_url_link(), '-' ) + 5;
182
+		$chars = strpos($registration->reg_url_link(), '-') + 5;
183 183
 		// TXN_ID + TKT_ID + first 3 and last 3 chars of reg_url_link
184 184
 		$new_reg_code = array(
185 185
 			$registration->transaction_ID(),
186 186
 			$registration->ticket_ID(),
187
-			substr( $registration->reg_url_link(), 0, $chars )
187
+			substr($registration->reg_url_link(), 0, $chars)
188 188
 		);
189 189
 		// now put it all together
190
-		$new_reg_code = implode( '-', $new_reg_code );
191
-		return apply_filters( 'FHEE__EE_Registration_Processor___generate_reg_code__new_reg_code', $new_reg_code, $registration );
190
+		$new_reg_code = implode('-', $new_reg_code);
191
+		return apply_filters('FHEE__EE_Registration_Processor___generate_reg_code__new_reg_code', $new_reg_code, $registration);
192 192
 	}
193 193
 
194 194
 
@@ -197,8 +197,8 @@  discard block
 block discarded – undo
197 197
 	 * @param int $REG_ID
198 198
 	 * @return string
199 199
 	 */
200
-	public function old_reg_status( $REG_ID ) {
201
-		return isset( $this->_old_reg_status[ $REG_ID ] ) ? $this->_old_reg_status[ $REG_ID ] : null;
200
+	public function old_reg_status($REG_ID) {
201
+		return isset($this->_old_reg_status[$REG_ID]) ? $this->_old_reg_status[$REG_ID] : null;
202 202
 	}
203 203
 
204 204
 
@@ -207,10 +207,10 @@  discard block
 block discarded – undo
207 207
 	 * @param int $REG_ID
208 208
 	 * @param string $old_reg_status
209 209
 	 */
210
-	public function set_old_reg_status( $REG_ID, $old_reg_status ) {
210
+	public function set_old_reg_status($REG_ID, $old_reg_status) {
211 211
 		// only set the first time
212
-		if ( ! isset( $this->_old_reg_status[ $REG_ID ] ) ) {
213
-			$this->_old_reg_status[ $REG_ID ] = $old_reg_status;
212
+		if ( ! isset($this->_old_reg_status[$REG_ID])) {
213
+			$this->_old_reg_status[$REG_ID] = $old_reg_status;
214 214
 		}
215 215
 	}
216 216
 
@@ -220,8 +220,8 @@  discard block
 block discarded – undo
220 220
 	 * @param int $REG_ID
221 221
 	 * @return string
222 222
 	 */
223
-	public function new_reg_status( $REG_ID ) {
224
-		return isset( $this->_new_reg_status[ $REG_ID ] ) ? $this->_new_reg_status[ $REG_ID ] : null;
223
+	public function new_reg_status($REG_ID) {
224
+		return isset($this->_new_reg_status[$REG_ID]) ? $this->_new_reg_status[$REG_ID] : null;
225 225
 	}
226 226
 
227 227
 
@@ -230,8 +230,8 @@  discard block
 block discarded – undo
230 230
 	 * @param int $REG_ID
231 231
 	 * @param string $new_reg_status
232 232
 	 */
233
-	public function set_new_reg_status( $REG_ID, $new_reg_status ) {
234
-		$this->_new_reg_status[ $REG_ID ] = $new_reg_status;
233
+	public function set_new_reg_status($REG_ID, $new_reg_status) {
234
+		$this->_new_reg_status[$REG_ID] = $new_reg_status;
235 235
 	}
236 236
 
237 237
 
@@ -242,8 +242,8 @@  discard block
 block discarded – undo
242 242
 	 * @param int $REG_ID
243 243
 	 * @return bool
244 244
 	 */
245
-	public function reg_status_updated( $REG_ID ) {
246
-		return $this->new_reg_status( $REG_ID ) !== $this->old_reg_status( $REG_ID ) ? true : false;
245
+	public function reg_status_updated($REG_ID) {
246
+		return $this->new_reg_status($REG_ID) !== $this->old_reg_status($REG_ID) ? true : false;
247 247
 	}
248 248
 
249 249
 
@@ -257,19 +257,19 @@  discard block
 block discarded – undo
257 257
 	 * @param bool 	$save TRUE will save the registration if the status is updated, FALSE will leave that up to client code
258 258
 	 * 	@return boolean
259 259
 	 */
260
-	public function manually_update_registration_status( EE_Registration $registration, $new_reg_status = '', $save = true ) {
260
+	public function manually_update_registration_status(EE_Registration $registration, $new_reg_status = '', $save = true) {
261 261
 		// set initial REG_Status
262
-		$this->set_old_reg_status( $registration->ID(), $registration->status_ID() );
262
+		$this->set_old_reg_status($registration->ID(), $registration->status_ID());
263 263
 		// set incoming REG_Status
264
-		$this->set_new_reg_status( $registration->ID(), $new_reg_status );
264
+		$this->set_new_reg_status($registration->ID(), $new_reg_status);
265 265
 		// toggle reg status but only if it has changed and the user can do so
266 266
 		if (
267
-			$this->reg_status_updated( $registration->ID() ) &&
268
-			EE_Registry::instance()->CAP->current_user_can( 'ee_edit_registration', 'toggle_registration_status', $registration->ID() )
267
+			$this->reg_status_updated($registration->ID()) &&
268
+			EE_Registry::instance()->CAP->current_user_can('ee_edit_registration', 'toggle_registration_status', $registration->ID())
269 269
 		) {
270 270
 			// change status to new value
271
-			if ( $registration->set_status( $this->new_reg_status( $registration->ID() ) )) {
272
-				if ( $save ) {
271
+			if ($registration->set_status($this->new_reg_status($registration->ID()))) {
272
+				if ($save) {
273 273
 					$registration->save();
274 274
 				}
275 275
 			}
@@ -290,30 +290,30 @@  discard block
 block discarded – undo
290 290
 	 * @return void
291 291
 	 * @throws \EE_Error
292 292
 	 */
293
-	public function toggle_incomplete_registration_status_to_default( EE_Registration $registration, $save = TRUE ) {
293
+	public function toggle_incomplete_registration_status_to_default(EE_Registration $registration, $save = TRUE) {
294 294
 		$existing_reg_status = $registration->status_ID();
295 295
 		// set initial REG_Status
296
-		$this->set_old_reg_status( $registration->ID(), $existing_reg_status );
296
+		$this->set_old_reg_status($registration->ID(), $existing_reg_status);
297 297
 		// is the registration currently incomplete ?
298
-		if ( $registration->status_ID() === EEM_Registration::status_id_incomplete ) {
298
+		if ($registration->status_ID() === EEM_Registration::status_id_incomplete) {
299 299
 			// grab default reg status for the event, if set
300 300
 			$event_default_registration_status = $registration->event()->default_registration_status();
301 301
 			// if no default reg status is set for the event, then use the global value
302
-			$STS_ID = ! empty( $event_default_registration_status )
302
+			$STS_ID = ! empty($event_default_registration_status)
303 303
 				? $event_default_registration_status
304 304
 				: EE_Registry::instance()->CFG->registration->default_STS_ID;
305 305
 			// if the event default reg status is approved, then downgrade temporarily to payment pending to ensure that payments are triggered
306 306
 			$STS_ID = $STS_ID === EEM_Registration::status_id_approved ? EEM_Registration::status_id_pending_payment : $STS_ID;
307 307
 			// set incoming REG_Status
308
-			$this->set_new_reg_status( $registration->ID(), $STS_ID );
309
-			$registration->set_status( $STS_ID );
310
-			if ( $save ) {
308
+			$this->set_new_reg_status($registration->ID(), $STS_ID);
309
+			$registration->set_status($STS_ID);
310
+			if ($save) {
311 311
 				$registration->save();
312 312
 			}
313 313
 			// don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor
314
-			if ( ! EE_Processor_Base::$IPN ) {
314
+			if ( ! EE_Processor_Base::$IPN) {
315 315
 				// otherwise, send out notifications
316
-				add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 );
316
+				add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10);
317 317
 			}
318 318
 			// DEBUG LOG
319 319
 			//$this->log(
@@ -337,25 +337,25 @@  discard block
 block discarded – undo
337 337
 	 * @param bool 	$save TRUE will save the registration if the status is updated, FALSE will leave that up to client code
338 338
 	 * @return boolean
339 339
 	 */
340
-	public function toggle_registration_status_for_default_approved_events( EE_Registration $registration, $save = TRUE ) {
340
+	public function toggle_registration_status_for_default_approved_events(EE_Registration $registration, $save = TRUE) {
341 341
 		// set initial REG_Status
342
-		$this->set_old_reg_status( $registration->ID(), $registration->status_ID() );
342
+		$this->set_old_reg_status($registration->ID(), $registration->status_ID());
343 343
 		// if not already, toggle reg status to approved IF the event default reg status is approved
344 344
 		if (
345 345
 			$registration->status_ID() !== EEM_Registration::status_id_approved &&
346 346
 			$registration->event()->default_registration_status() == EEM_Registration::status_id_approved
347 347
 		) {
348 348
 			// set incoming REG_Status
349
-			$this->set_new_reg_status( $registration->ID(), EEM_Registration::status_id_approved );
349
+			$this->set_new_reg_status($registration->ID(), EEM_Registration::status_id_approved);
350 350
 			// toggle status to approved
351
-			$registration->set_status( EEM_Registration::status_id_approved );
352
-			if ( $save ) {
351
+			$registration->set_status(EEM_Registration::status_id_approved);
352
+			if ($save) {
353 353
 				$registration->save();
354 354
 			}
355 355
 			// don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor
356
-			if ( ! EE_Processor_Base::$IPN ) {
356
+			if ( ! EE_Processor_Base::$IPN) {
357 357
 				// otherwise, send out notifications
358
-				add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 );
358
+				add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10);
359 359
 			}
360 360
 			// DEBUG LOG
361 361
 			//$this->log(
@@ -383,19 +383,19 @@  discard block
 block discarded – undo
383 383
 	 * @return bool
384 384
 	 * @throws \EE_Error
385 385
 	 */
386
-	public function toggle_registration_status_if_no_monies_owing( EE_Registration $registration, $save = TRUE, $additional_details = array() ) {
386
+	public function toggle_registration_status_if_no_monies_owing(EE_Registration $registration, $save = TRUE, $additional_details = array()) {
387 387
 		// set initial REG_Status
388
-		$this->set_old_reg_status( $registration->ID(), $registration->status_ID() );
388
+		$this->set_old_reg_status($registration->ID(), $registration->status_ID());
389 389
 		//EEH_Debug_Tools::printr( $additional_details, '$additional_details', __FILE__, __LINE__ );
390 390
 		// was a payment just made ?
391 391
 		if (
392
-			isset( $additional_details[ 'payment_updates' ], $additional_details[ 'last_payment' ] ) &&
393
-			$additional_details[ 'payment_updates' ] &&
394
-			$additional_details[ 'last_payment' ] instanceof EE_Payment
392
+			isset($additional_details['payment_updates'], $additional_details['last_payment']) &&
393
+			$additional_details['payment_updates'] &&
394
+			$additional_details['last_payment'] instanceof EE_Payment
395 395
 		) {
396
-			$payment = $additional_details[ 'last_payment' ];
396
+			$payment = $additional_details['last_payment'];
397 397
 			$total_paid = 0;
398
-			foreach ( self::$_amount_paid as $reg => $amount_paid ) {
398
+			foreach (self::$_amount_paid as $reg => $amount_paid) {
399 399
 				$total_paid += $amount_paid;
400 400
 			}
401 401
 		} else {
@@ -419,30 +419,30 @@  discard block
 block discarded – undo
419 419
 					$registration->transaction()->is_completed() ||
420 420
 					$registration->transaction()->is_overpaid() ||
421 421
 					$registration->transaction()->is_free() ||
422
-					apply_filters( 'FHEE__EE_Registration_Processor__toggle_registration_status_if_no_monies_owing', false, $registration )
422
+					apply_filters('FHEE__EE_Registration_Processor__toggle_registration_status_if_no_monies_owing', false, $registration)
423 423
 				) || (
424 424
 					$payment instanceof EE_Payment &&
425 425
 					$payment->is_approved() &&
426 426
 					// this specific registration has not yet been paid for
427
-					! isset( self::$_amount_paid[ $registration->ID() ] ) &&
427
+					! isset(self::$_amount_paid[$registration->ID()]) &&
428 428
 					// payment amount, less what we have already attributed to other registrations, is greater than this reg's final price
429 429
 					$payment->amount() - $total_paid >= $registration->final_price()
430 430
 				)
431 431
 			)
432 432
 		) {
433 433
 			// mark as paid
434
-			self::$_amount_paid[ $registration->ID() ] = $registration->final_price();
434
+			self::$_amount_paid[$registration->ID()] = $registration->final_price();
435 435
 			// track new REG_Status
436
-			$this->set_new_reg_status( $registration->ID(), EEM_Registration::status_id_approved );
436
+			$this->set_new_reg_status($registration->ID(), EEM_Registration::status_id_approved);
437 437
 			// toggle status to approved
438
-			$registration->set_status( EEM_Registration::status_id_approved );
439
-			if ( $save ) {
438
+			$registration->set_status(EEM_Registration::status_id_approved);
439
+			if ($save) {
440 440
 				$registration->save();
441 441
 			}
442 442
 			// don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor
443
-			if ( ! EE_Processor_Base::$IPN ) {
443
+			if ( ! EE_Processor_Base::$IPN) {
444 444
 				// otherwise, send out notifications
445
-				add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 );
445
+				add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10);
446 446
 			}
447 447
 			// DEBUG LOG
448 448
 			//$this->log(
@@ -468,19 +468,19 @@  discard block
 block discarded – undo
468 468
 	 * @param array 	$additional_details
469 469
 	 * @return void
470 470
 	 */
471
-	public function trigger_registration_update_notifications( $registration, $additional_details = array() ) {
471
+	public function trigger_registration_update_notifications($registration, $additional_details = array()) {
472 472
 		try {
473
-			if ( ! $registration instanceof EE_Registration ) {
474
-				throw new EE_Error( __( 'An invalid registration was received.', 'event_espresso' ) );
473
+			if ( ! $registration instanceof EE_Registration) {
474
+				throw new EE_Error(__('An invalid registration was received.', 'event_espresso'));
475 475
 			}
476
-			EEH_Debug_Tools::log( __CLASS__, __FUNCTION__, __LINE__, array( $registration->transaction(), $additional_details ), false, 'EE_Transaction: ' . $registration->transaction()->ID() );
476
+			EEH_Debug_Tools::log(__CLASS__, __FUNCTION__, __LINE__, array($registration->transaction(), $additional_details), false, 'EE_Transaction: '.$registration->transaction()->ID());
477 477
 			do_action(
478 478
 				'AHEE__EE_Registration_Processor__trigger_registration_update_notifications',
479 479
 				$registration,
480 480
 				$additional_details
481 481
 			);
482
-		} catch( Exception $e ) {
483
-			EE_Error::add_error( $e->getMessage(), $e->getFile(), 'unknown_function_from_exception', $e->getLine() );
482
+		} catch (Exception $e) {
483
+			EE_Error::add_error($e->getMessage(), $e->getFile(), 'unknown_function_from_exception', $e->getLine());
484 484
 		}
485 485
 	}
486 486
 
@@ -493,18 +493,18 @@  discard block
 block discarded – undo
493 493
 	 * @param array 	$additional_details
494 494
 	 * @return bool
495 495
 	 */
496
-	public function update_registration_after_checkout_or_payment(  EE_Registration $registration, $additional_details = array() ) {
496
+	public function update_registration_after_checkout_or_payment(EE_Registration $registration, $additional_details = array()) {
497 497
 		// set initial REG_Status
498
-		$this->set_old_reg_status( $registration->ID(), $registration->status_ID() );
498
+		$this->set_old_reg_status($registration->ID(), $registration->status_ID());
499 499
 
500 500
 		// if the registration status gets updated, then save the registration
501
-		if ( $this->toggle_registration_status_for_default_approved_events( $registration, false ) || $this->toggle_registration_status_if_no_monies_owing( $registration, false, $additional_details )) {
501
+		if ($this->toggle_registration_status_for_default_approved_events($registration, false) || $this->toggle_registration_status_if_no_monies_owing($registration, false, $additional_details)) {
502 502
 			$registration->save();
503 503
 		}
504 504
 
505 505
 		// set new  REG_Status
506
-		$this->set_new_reg_status( $registration->ID(), $registration->status_ID() );
507
-		return $this->reg_status_updated( $registration->ID() ) && $this->new_reg_status( $registration->ID() ) == EEM_Registration::status_id_approved ? true : false;
506
+		$this->set_new_reg_status($registration->ID(), $registration->status_ID());
507
+		return $this->reg_status_updated($registration->ID()) && $this->new_reg_status($registration->ID()) == EEM_Registration::status_id_approved ? true : false;
508 508
 	}
509 509
 
510 510
 	/**
@@ -514,19 +514,19 @@  discard block
 block discarded – undo
514 514
 	 * @param boolean $save_regs whether to immediately save registrations in this function or not
515 515
 	 * @return void
516 516
 	 */
517
-	public function update_registration_final_prices( $transaction, $save_regs = true ) {
518
-		$reg_final_price_per_ticket_line_item = EEH_Line_Item::calculate_reg_final_prices_per_line_item( $transaction->total_line_item() );
519
-		foreach( $transaction->registrations() as $registration ) {
520
-			$line_item = EEM_Line_Item::instance()->get_line_item_for_registration( $registration );
521
-			if( isset( $reg_final_price_per_ticket_line_item[ $line_item->ID() ] ) ) {
522
-				$registration->set_final_price( $reg_final_price_per_ticket_line_item[ $line_item->ID() ] );
523
-				if( $save_regs ) {
517
+	public function update_registration_final_prices($transaction, $save_regs = true) {
518
+		$reg_final_price_per_ticket_line_item = EEH_Line_Item::calculate_reg_final_prices_per_line_item($transaction->total_line_item());
519
+		foreach ($transaction->registrations() as $registration) {
520
+			$line_item = EEM_Line_Item::instance()->get_line_item_for_registration($registration);
521
+			if (isset($reg_final_price_per_ticket_line_item[$line_item->ID()])) {
522
+				$registration->set_final_price($reg_final_price_per_ticket_line_item[$line_item->ID()]);
523
+				if ($save_regs) {
524 524
 					$registration->save();
525 525
 				}
526 526
 			}
527 527
 		}
528 528
 		//and make sure there's no rounding problem
529
-		$this->fix_reg_final_price_rounding_issue( $transaction );
529
+		$this->fix_reg_final_price_rounding_issue($transaction);
530 530
 	}
531 531
 
532 532
 	/**
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
 	 * @param EE_Transaction $transaction
543 543
 	 * @return boolean success verifying that there is NO difference after this method is done
544 544
 	 */
545
-	public function fix_reg_final_price_rounding_issue( $transaction ) {
545
+	public function fix_reg_final_price_rounding_issue($transaction) {
546 546
 		$reg_final_price_sum = EEM_Registration::instance()->sum(
547 547
 			array(
548 548
 				array(
@@ -551,9 +551,9 @@  discard block
 block discarded – undo
551 551
 			),
552 552
 			'REG_final_price'
553 553
 		);
554
-		$diff =  $transaction->total() - floatval( $reg_final_price_sum );
554
+		$diff = $transaction->total() - floatval($reg_final_price_sum);
555 555
 		//ok then, just grab one of the registrations
556
-		if( $diff != 0 ) {
556
+		if ($diff != 0) {
557 557
 			$a_reg = EEM_Registration::instance()->get_one(
558 558
 					array(
559 559
 						array(
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
 					));
563 563
 			$success = $a_reg instanceof EE_Registration ? $a_reg->save(
564 564
 				array(
565
-					'REG_final_price' => ( $a_reg->final_price() + $diff )
565
+					'REG_final_price' => ($a_reg->final_price() + $diff)
566 566
 				)
567 567
 			) : false;
568 568
 			return $success ? true : false;
Please login to merge, or discard this patch.
core/EE_Load_Textdomain.core.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -39,12 +39,12 @@  discard block
 block discarded – undo
39 39
 	public static function load_textdomain() {
40 40
 		self::_maybe_get_langfile();
41 41
 		//now load the textdomain
42
-		if ( ! empty( self::$_lang ) && is_readable( EE_LANGUAGES_SAFE_DIR . 'event_espresso-' . self::$_lang . '.mo' ) ) {
42
+		if ( ! empty(self::$_lang) && is_readable(EE_LANGUAGES_SAFE_DIR.'event_espresso-'.self::$_lang.'.mo')) {
43 43
 			load_plugin_textdomain('event_espresso', FALSE, EE_LANGUAGES_SAFE_LOC);
44
-		} else if ( ! empty( self::$_lang ) && is_readable( EE_LANGUAGES_SAFE_DIR . 'event-espresso-4-' . self::$_lang . '.mo' ) ) {
45
-			load_textdomain( 'event_espresso', EE_LANGUAGES_SAFE_DIR . 'event-espresso-4-' . self::$_lang . '.mo'  );
44
+		} else if ( ! empty(self::$_lang) && is_readable(EE_LANGUAGES_SAFE_DIR.'event-espresso-4-'.self::$_lang.'.mo')) {
45
+			load_textdomain('event_espresso', EE_LANGUAGES_SAFE_DIR.'event-espresso-4-'.self::$_lang.'.mo');
46 46
 		} else {
47
-			load_plugin_textdomain( 'event_espresso', FALSE, dirname( EE_PLUGIN_BASENAME ) . '/languages/');
47
+			load_plugin_textdomain('event_espresso', FALSE, dirname(EE_PLUGIN_BASENAME).'/languages/');
48 48
 		}
49 49
 	}
50 50
 
@@ -59,24 +59,24 @@  discard block
 block discarded – undo
59 59
 	 */
60 60
 	private static function _maybe_get_langfile() {
61 61
 		self::$_lang = get_locale();
62
-		if ( $has_check = get_option( 'ee_lang_check_' . self::$_lang . '_' . EVENT_ESPRESSO_VERSION ) || empty( self::$_lang ) )
62
+		if ($has_check = get_option('ee_lang_check_'.self::$_lang.'_'.EVENT_ESPRESSO_VERSION) || empty(self::$_lang))
63 63
 			return;
64 64
 
65 65
 		//if lang is en_US or empty then lets just get out.  (Event Espresso core is en_US)
66
-		if ( empty( self::$_lang ) || self::$_lang == 'en_US' )
66
+		if (empty(self::$_lang) || self::$_lang == 'en_US')
67 67
 			return;
68 68
 
69 69
 		//made it here so let's get the file from the github repo
70 70
 		$sideloader_args = array(
71
-			'_upload_to' => EE_PLUGIN_DIR_PATH . 'languages/',
72
-			'_upload_from' => 'https://github.com/eventespresso/languages-ee4/blob/master/event_espresso-' . self::$_lang . '.mo?raw=true',
73
-			'_new_file_name' => 'event_espresso-' . self::$_lang . '.mo'
71
+			'_upload_to' => EE_PLUGIN_DIR_PATH.'languages/',
72
+			'_upload_from' => 'https://github.com/eventespresso/languages-ee4/blob/master/event_espresso-'.self::$_lang.'.mo?raw=true',
73
+			'_new_file_name' => 'event_espresso-'.self::$_lang.'.mo'
74 74
 			);
75 75
 
76 76
 
77
-		$sideloader = EE_Registry::instance()->load_helper('Sideloader', $sideloader_args, FALSE );
77
+		$sideloader = EE_Registry::instance()->load_helper('Sideloader', $sideloader_args, FALSE);
78 78
 
79 79
 		$sideloader->sideload();
80
-		update_option( 'ee_lang_check_' . self::$_lang . '_' . EVENT_ESPRESSO_VERSION, 1 );
80
+		update_option('ee_lang_check_'.self::$_lang.'_'.EVENT_ESPRESSO_VERSION, 1);
81 81
 	}
82 82
 } //end EE_Load_Textdomain
Please login to merge, or discard this patch.
modules/gateways/Invoice/lib/Invoice.class.php 1 patch
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -21,23 +21,23 @@  discard block
 block discarded – undo
21 21
 	private $EE;
22 22
 	public function __construct($url_link = 0) {
23 23
 
24
-		if ( $this->registration = EE_Registry::instance()->load_model( 'Registration' )->get_registration_for_reg_url_link( $url_link)) {
24
+		if ($this->registration = EE_Registry::instance()->load_model('Registration')->get_registration_for_reg_url_link($url_link)) {
25 25
 			$this->transaction = $this->registration->transaction();
26 26
 
27
-			$payment_settings = EE_Config::instance()->gateway->payment_settings;//get_user_meta(EE_Registry::instance()->CFG->wp_user, 'payment_settings', TRUE);
28
-			$this->invoice_payment_method = EEM_Payment_Method::instance()->get_one_of_type( 'Invoice' );
27
+			$payment_settings = EE_Config::instance()->gateway->payment_settings; //get_user_meta(EE_Registry::instance()->CFG->wp_user, 'payment_settings', TRUE);
28
+			$this->invoice_payment_method = EEM_Payment_Method::instance()->get_one_of_type('Invoice');
29 29
 		} else {
30
-			EE_Error::add_error( __( 'Your request appears to be missing some required data, and no information for your transaction could be retrieved.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
30
+			EE_Error::add_error(__('Your request appears to be missing some required data, and no information for your transaction could be retrieved.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
31 31
 		}
32 32
 
33 33
 	}
34 34
 
35
-	public function send_invoice( $download = FALSE ) {
35
+	public function send_invoice($download = FALSE) {
36 36
 		$template_args = array();
37 37
 		$EE = EE_Registry::instance();
38 38
 
39 39
 		//allow the request to override the default theme defined in the invoice settings
40
-		$theme_requested = ( isset( $_REQUEST['theme'] ) && $_REQUEST['theme'] > 0 && $_REQUEST['theme'] < 8 ) ? absint( $_REQUEST['theme'] ) : null;
40
+		$theme_requested = (isset($_REQUEST['theme']) && $_REQUEST['theme'] > 0 && $_REQUEST['theme'] < 8) ? absint($_REQUEST['theme']) : null;
41 41
 		$themes = array(
42 42
 										1 => "simple.css",
43 43
 										2 => "bauhaus.css",
@@ -48,26 +48,26 @@  discard block
 block discarded – undo
48 48
 										7 => "union.css"
49 49
 									);
50 50
 		//Get the CSS file
51
-		if( isset( $themes[ $theme_requested ] ) ) {
52
-			$template_args['invoice_css'] = $themes[ $theme_requested ];
53
-		}else{
54
-			$template_args['invoice_css'] = $this->invoice_payment_method->get_extra_meta( 'legacy_invoice_css', TRUE, 'simple.css' );
51
+		if (isset($themes[$theme_requested])) {
52
+			$template_args['invoice_css'] = $themes[$theme_requested];
53
+		} else {
54
+			$template_args['invoice_css'] = $this->invoice_payment_method->get_extra_meta('legacy_invoice_css', TRUE, 'simple.css');
55 55
 		}
56 56
 
57
-		if (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) {
58
-			$template_args['base_url'] = EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/';
57
+		if (is_dir(EVENT_ESPRESSO_GATEWAY_DIR.'/invoice')) {
58
+			$template_args['base_url'] = EVENT_ESPRESSO_GATEWAY_URL.'Invoice/lib/templates/';
59 59
 		} else {
60
-			$template_args['base_url'] = EE_GATEWAYS . '/Invoice/lib/templates/';
60
+			$template_args['base_url'] = EE_GATEWAYS.'/Invoice/lib/templates/';
61 61
 		}
62 62
 		$primary_attendee = $this->transaction->primary_registration()->attendee();
63 63
 
64
-		$template_args['organization'] = $EE->CFG->organization->get_pretty( 'name' );
65
-		$template_args['street'] = empty( $EE->CFG->organization->address_2 ) ? $EE->CFG->organization->get_pretty( 'address_1' ) : $EE->CFG->organization->get_pretty( 'address_1' ) . '<br>' . $EE->CFG->organization->get_pretty( 'address_2' );
66
-		$template_args['city'] = $EE->CFG->organization->get_pretty( 'city' );
67
-		$template_args['state'] = EE_Registry::instance()->load_model( 'State' )->get_one_by_ID( $EE->CFG->organization->STA_ID );
68
-		$template_args['country'] = EE_Registry::instance()->load_model( 'Country' )->get_one_by_ID( $EE->CFG->organization->CNT_ISO );
69
-		$template_args['zip'] = $EE->CFG->organization->get_pretty( 'zip' );
70
-		$template_args['email'] = $EE->CFG->organization->get_pretty( 'email' );
64
+		$template_args['organization'] = $EE->CFG->organization->get_pretty('name');
65
+		$template_args['street'] = empty($EE->CFG->organization->address_2) ? $EE->CFG->organization->get_pretty('address_1') : $EE->CFG->organization->get_pretty('address_1').'<br>'.$EE->CFG->organization->get_pretty('address_2');
66
+		$template_args['city'] = $EE->CFG->organization->get_pretty('city');
67
+		$template_args['state'] = EE_Registry::instance()->load_model('State')->get_one_by_ID($EE->CFG->organization->STA_ID);
68
+		$template_args['country'] = EE_Registry::instance()->load_model('Country')->get_one_by_ID($EE->CFG->organization->CNT_ISO);
69
+		$template_args['zip'] = $EE->CFG->organization->get_pretty('zip');
70
+		$template_args['email'] = $EE->CFG->organization->get_pretty('email');
71 71
 
72 72
 		$template_args['registration_code'] = $this->registration->reg_code();
73 73
 		$template_args['registration_date'] = $this->registration->date();
@@ -76,9 +76,9 @@  discard block
 block discarded – undo
76 76
 		$template_args['attendee_address2'] = $primary_attendee->address2();
77 77
 		$template_args['attendee_city'] = $primary_attendee->city();
78 78
 		$attendee_state = $primary_attendee->state_obj();
79
-		if($attendee_state){
79
+		if ($attendee_state) {
80 80
 			$attendee_state_name = $attendee_state->name();
81
-		}else{
81
+		} else {
82 82
 			$attendee_state_name = '';
83 83
 		}
84 84
 		$template_args['attendee_state'] = $attendee_state_name;
@@ -102,9 +102,9 @@  discard block
 block discarded – undo
102 102
 		if ($template_args['amount_pd'] != $template_args['total_cost']) {
103 103
 			//$template_args['net_total'] = $this->espressoInvoiceTotals( __('SubTotal', 'event_espresso'), $this->transaction->total());//$this->session_data['cart']['REG']['sub_total']);
104 104
 			$tax_items = $this->transaction->tax_items();
105
-			if(!empty($tax_items) ){
105
+			if ( ! empty($tax_items)) {
106 106
 				foreach ($tax_items as $tax) {
107
-					$template_args['net_total'] .= $this->espressoInvoiceTotals( $tax->name(), $tax->total());
107
+					$template_args['net_total'] .= $this->espressoInvoiceTotals($tax->name(), $tax->total());
108 108
 				}
109 109
 			}
110 110
 
@@ -114,30 +114,30 @@  discard block
 block discarded – undo
114 114
 			} else {
115 115
 				$text = __('Extra', 'event_espresso');
116 116
 			}
117
-			$template_args['discount'] = $this->espressoInvoiceTotals( $text, $difference );
117
+			$template_args['discount'] = $this->espressoInvoiceTotals($text, $difference);
118 118
 		}
119 119
 
120 120
 		$template_args['currency_symbol'] = $EE->CFG->currency->sign;
121
-		$template_args['template_payment_instructions'] = wpautop(stripslashes_deep(html_entity_decode($this->invoice_payment_method->get_extra_meta( 'pdf_instructions', TRUE ), ENT_QUOTES)));
122
-		$template_args['shameless_plug'] = apply_filters( 'FHEE_Invoice__send_invoice__shameless_plug',true );
123
-		if(isset($_GET['receipt'])){
121
+		$template_args['template_payment_instructions'] = wpautop(stripslashes_deep(html_entity_decode($this->invoice_payment_method->get_extra_meta('pdf_instructions', TRUE), ENT_QUOTES)));
122
+		$template_args['shameless_plug'] = apply_filters('FHEE_Invoice__send_invoice__shameless_plug', true);
123
+		if (isset($_GET['receipt'])) {
124 124
 			//receipt-specific stuff
125 125
 			$events_for_txn = EEM_Event::instance()->get_all(array(array('Registration.TXN_ID'=>$this->transaction->ID())));
126 126
 			$ticket_line_items_per_event = array();
127 127
 			$registrations_per_line_item = array();
128 128
 			$venues_for_events = array();
129
-			foreach($events_for_txn as $event_id => $event){
130
-				$line_items_for_this_event = EEM_Line_Item::instance()->get_all(array(array('Ticket.Datetime.EVT_ID'=>$event_id,'TXN_ID'=>$this->transaction->ID())));
129
+			foreach ($events_for_txn as $event_id => $event) {
130
+				$line_items_for_this_event = EEM_Line_Item::instance()->get_all(array(array('Ticket.Datetime.EVT_ID'=>$event_id, 'TXN_ID'=>$this->transaction->ID())));
131 131
 				$ticket_line_items_per_event[$event_id] = $line_items_for_this_event;
132
-				foreach($line_items_for_this_event as $line_item_id => $line_item){
132
+				foreach ($line_items_for_this_event as $line_item_id => $line_item) {
133 133
 					$ticket = $line_item->ticket();
134
-					$registrations_for_this_ticket = EEM_Registration::instance()->get_all(array(array('TKT_ID'=>$ticket->ID(),'TXN_ID'=>$this->transaction->ID())));
134
+					$registrations_for_this_ticket = EEM_Registration::instance()->get_all(array(array('TKT_ID'=>$ticket->ID(), 'TXN_ID'=>$this->transaction->ID())));
135 135
 					$registrations_per_line_item[$line_item_id] = $registrations_for_this_ticket;
136 136
 				}
137 137
 				$venues_for_events = array_merge($venues_for_events, $event->venues());
138 138
 			}
139
-			$tax_total_line_item = EEM_Line_Item::instance()->get_one(array(array('TXN_ID'=>$this->transaction->ID(),'LIN_type'=>  EEM_Line_Item::type_tax_sub_total)));
140
-			$questions_to_skip = array(EEM_Attendee::system_question_fname,EEM_Attendee::system_question_lname,  EEM_Attendee::system_question_email);
139
+			$tax_total_line_item = EEM_Line_Item::instance()->get_one(array(array('TXN_ID'=>$this->transaction->ID(), 'LIN_type'=>  EEM_Line_Item::type_tax_sub_total)));
140
+			$questions_to_skip = array(EEM_Attendee::system_question_fname, EEM_Attendee::system_question_lname, EEM_Attendee::system_question_email);
141 141
 
142 142
 
143 143
 			$template_args['events_for_txn'] = $events_for_txn;
@@ -148,53 +148,53 @@  discard block
 block discarded – undo
148 148
 			$template_args['questions_to_skip'] = $questions_to_skip;
149 149
 //			d($template_args);
150 150
 			$template_args['download_link'] = $this->registration->receipt_url('download');
151
-		}else{
151
+		} else {
152 152
 			//it's just an invoice we're accessing
153 153
 			$template_args['download_link'] = $this->registration->invoice_url('download');
154 154
 		}
155 155
 
156 156
 		//Get the HTML as an object
157 157
 		$templates_relative_path = 'modules/gateways/Invoice/lib/templates/';
158
-		$template_header = EEH_Template::locate_template( $templates_relative_path . 'invoice_header.template.php', $template_args, TRUE, TRUE );
159
-		if(isset($_GET['receipt'])){
160
-			$template_body = EEH_Template::locate_template( $templates_relative_path . 'receipt_body.template.php', $template_args, TRUE, TRUE );
161
-		}else{
162
-			$template_body = EEH_Template::locate_template( $templates_relative_path . 'invoice_body.template.php', $template_args, TRUE, TRUE );
158
+		$template_header = EEH_Template::locate_template($templates_relative_path.'invoice_header.template.php', $template_args, TRUE, TRUE);
159
+		if (isset($_GET['receipt'])) {
160
+			$template_body = EEH_Template::locate_template($templates_relative_path.'receipt_body.template.php', $template_args, TRUE, TRUE);
161
+		} else {
162
+			$template_body = EEH_Template::locate_template($templates_relative_path.'invoice_body.template.php', $template_args, TRUE, TRUE);
163 163
 		}
164 164
 
165 165
 
166
-		$template_footer = EEH_Template::locate_template( $templates_relative_path . 'invoice_footer.template.php', $template_args, TRUE, TRUE );
166
+		$template_footer = EEH_Template::locate_template($templates_relative_path.'invoice_footer.template.php', $template_args, TRUE, TRUE);
167 167
 
168
-		$copies =  ! empty( $_REQUEST['copies'] ) ? $_REQUEST['copies'] : 1;
168
+		$copies = ! empty($_REQUEST['copies']) ? $_REQUEST['copies'] : 1;
169 169
 
170 170
 		$content = $this->espresso_replace_invoice_shortcodes($template_header);
171
-		for( $x = 1; $x <= $copies; $x++ ) {
171
+		for ($x = 1; $x <= $copies; $x++) {
172 172
 			$content .= $this->espresso_replace_invoice_shortcodes($template_body);
173 173
 		}
174 174
 		$content .= $this->espresso_replace_invoice_shortcodes($template_footer);
175 175
 
176 176
 		//Check if debugging or mobile is set
177
-		if (!empty($_REQUEST['html'])) {
177
+		if ( ! empty($_REQUEST['html'])) {
178 178
 			echo $content;
179 179
 			exit(0);
180 180
 		}
181
-		$invoice_name = $template_args['organization'] . ' ' . __('Invoice #', 'event_espresso') . $template_args['registration_code'] . __(' for ', 'event_espresso') . $template_args['name'];
182
-		$invoice_name = str_replace( ' ', '_', $invoice_name );
181
+		$invoice_name = $template_args['organization'].' '.__('Invoice #', 'event_espresso').$template_args['registration_code'].__(' for ', 'event_espresso').$template_args['name'];
182
+		$invoice_name = str_replace(' ', '_', $invoice_name);
183 183
 		//Create the PDF
184
-		if(array_key_exists('html',$_GET)){
184
+		if (array_key_exists('html', $_GET)) {
185 185
 			echo $content;
186
-		}else{
186
+		} else {
187 187
 			//only load dompdf if nobody else has yet...
188
-			if( ! defined('DOMPDF_DIR')){
188
+			if ( ! defined('DOMPDF_DIR')) {
189 189
 				define('DOMPDF_ENABLE_REMOTE', TRUE);
190 190
 				define('DOMPDF_ENABLE_JAVASCRIPT', FALSE);
191 191
 				define('DOMPDF_ENABLE_CSS_FLOAT', TRUE);
192
-				require_once(EE_THIRD_PARTY . 'dompdf/dompdf_config.inc.php');
192
+				require_once(EE_THIRD_PARTY.'dompdf/dompdf_config.inc.php');
193 193
 			}
194 194
 			$dompdf = new DOMPDF();
195 195
 			$dompdf->load_html($content);
196 196
 			$dompdf->render();
197
-			$dompdf->stream($invoice_name . ".pdf", array( 'Attachment' => $download ));
197
+			$dompdf->stream($invoice_name.".pdf", array('Attachment' => $download));
198 198
 		}
199 199
 		exit(0);
200 200
 	}
@@ -204,12 +204,12 @@  discard block
 block discarded – undo
204 204
 	 * @param EE_Line_Item $line_item
205 205
 	 * @return boolean
206 206
 	 */
207
-	function check_if_any_line_items_have_a_description(EE_Line_Item $line_item){
208
-		if($line_item->desc()){
207
+	function check_if_any_line_items_have_a_description(EE_Line_Item $line_item) {
208
+		if ($line_item->desc()) {
209 209
 			return true;
210
-		}else{
211
-			foreach($line_item->children() as $child_line_item){
212
-				if($this->check_if_any_line_items_have_a_description($child_line_item)){
210
+		} else {
211
+			foreach ($line_item->children() as $child_line_item) {
212
+				if ($this->check_if_any_line_items_have_a_description($child_line_item)) {
213 213
 					return true;
214 214
 				}
215 215
 			}
@@ -219,14 +219,14 @@  discard block
 block discarded – undo
219 219
 	}
220 220
 
221 221
 //Perform the shortcode replacement
222
-	function espresso_replace_invoice_shortcodes( $content ) {
222
+	function espresso_replace_invoice_shortcodes($content) {
223 223
 
224 224
 		$EE = EE_Registry::instance();
225 225
 		//Create the logo
226
-		$invoice_logo_url = $this->invoice_payment_method->get_extra_meta('pdf_logo_image', TRUE,  $EE->CFG->organization->logo_url );
227
-		if (!empty($invoice_logo_url)) {
226
+		$invoice_logo_url = $this->invoice_payment_method->get_extra_meta('pdf_logo_image', TRUE, $EE->CFG->organization->logo_url);
227
+		if ( ! empty($invoice_logo_url)) {
228 228
 			$image_size = getimagesize($invoice_logo_url);
229
-			$invoice_logo_image = '<img class="logo screen" src="' . $invoice_logo_url . '" ' . $image_size[3] . ' alt="logo" /> ';
229
+			$invoice_logo_image = '<img class="logo screen" src="'.$invoice_logo_url.'" '.$image_size[3].' alt="logo" /> ';
230 230
 		} else {
231 231
 			$invoice_logo_image = '';
232 232
 		}
@@ -248,28 +248,28 @@  discard block
 block discarded – undo
248 248
 				"[instructions]",
249 249
 		);
250 250
 		$primary_attendee = $this->transaction->primary_registration()->attendee();
251
-		$org_state = EE_Registry::instance()->load_model( 'State' )->get_one_by_ID( $EE->CFG->organization->STA_ID );
252
-		if($org_state){
251
+		$org_state = EE_Registry::instance()->load_model('State')->get_one_by_ID($EE->CFG->organization->STA_ID);
252
+		if ($org_state) {
253 253
 			$org_state_name = $org_state->name();
254
-		}else{
254
+		} else {
255 255
 			$org_state_name = '';
256 256
 		}
257 257
 		$ReplaceValues = array(
258
-				$EE->CFG->organization->get_pretty( 'name' ),
258
+				$EE->CFG->organization->get_pretty('name'),
259 259
 				$this->registration->reg_code(),
260 260
 				$this->transaction->ID(),
261 261
 				$primary_attendee->full_name(),
262
-				(is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) ? EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/' : EE_GATEWAYS_URL . 'Invoice/lib/templates/',
263
-				$this->registration->invoice_url(),//home_url() . '/?download_invoice=true&amp;id=' . $this->registration->reg_url_link(),
262
+				(is_dir(EVENT_ESPRESSO_GATEWAY_DIR.'/invoice')) ? EVENT_ESPRESSO_GATEWAY_URL.'Invoice/lib/templates/' : EE_GATEWAYS_URL.'Invoice/lib/templates/',
263
+				$this->registration->invoice_url(), //home_url() . '/?download_invoice=true&amp;id=' . $this->registration->reg_url_link(),
264 264
 				$invoice_logo_image,
265
-				empty( $EE->CFG->organization->address_2 ) ? $EE->CFG->organization->get_pretty( 'address_1' ) : $EE->CFG->organization->get_pretty( 'address_1' ) . '<br>' . $EE->CFG->organization->get_pretty( 'address_2' ),
266
-				$EE->CFG->organization->get_pretty( 'city' ),
265
+				empty($EE->CFG->organization->address_2) ? $EE->CFG->organization->get_pretty('address_1') : $EE->CFG->organization->get_pretty('address_1').'<br>'.$EE->CFG->organization->get_pretty('address_2'),
266
+				$EE->CFG->organization->get_pretty('city'),
267 267
 				$org_state_name,
268
-				$EE->CFG->organization->get_pretty( 'zip' ),
269
-				$EE->CFG->organization->get_pretty( 'email' ),
268
+				$EE->CFG->organization->get_pretty('zip'),
269
+				$EE->CFG->organization->get_pretty('email'),
270 270
 				$EE->CFG->organization->vat,
271
-				$this->registration->get_i18n_datetime( 'REG_date', get_option( 'date_format' ) ),
272
-				$this->invoice_payment_method->get_extra_meta( 'pdf_instructions', TRUE ),
271
+				$this->registration->get_i18n_datetime('REG_date', get_option('date_format')),
272
+				$this->invoice_payment_method->get_extra_meta('pdf_instructions', TRUE),
273 273
 		);
274 274
 
275 275
 		return str_replace($SearchValues, $ReplaceValues, $content);
@@ -292,12 +292,12 @@  discard block
 block discarded – undo
292 292
 		if ($total_cost < 0) {
293 293
 			$total_cost = (-1) * $total_cost;
294 294
 		}
295
-		$find = array( ' ' );
296
-		$replace = array( '-' );
297
-		$row_id = strtolower( str_replace( $find, $replace, $text ));
295
+		$find = array(' ');
296
+		$replace = array('-');
297
+		$row_id = strtolower(str_replace($find, $replace, $text));
298 298
 		$html .= '<tr id="'.$row_id.'-tr"><td colspan="4">&nbsp;</td>';
299
-		$html .= '<td class="item_r">' . $text . '</td>';
300
-		$html .= '<td class="item_r">' . $total_cost . '</td>';
299
+		$html .= '<td class="item_r">'.$text.'</td>';
300
+		$html .= '<td class="item_r">'.$total_cost.'</td>';
301 301
 		$html .= '</tr>';
302 302
 		return $html;
303 303
 	}
Please login to merge, or discard this patch.
modules/ical/EED_Ical.module.php 1 patch
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 * @return EED_Ical
33 33
 	 */
34 34
 	public static function instance() {
35
-		return parent::get_instance( __CLASS__ );
35
+		return parent::get_instance(__CLASS__);
36 36
 	}
37 37
 
38 38
 
@@ -45,9 +45,9 @@  discard block
 block discarded – undo
45 45
 	 */
46 46
 	public static function set_hooks() {
47 47
 		// create download buttons
48
-		add_filter( 'FHEE__espresso_list_of_event_dates__datetime_html', array( 'EED_Ical', 'generate_add_to_iCal_button' ), 10, 2 );
48
+		add_filter('FHEE__espresso_list_of_event_dates__datetime_html', array('EED_Ical', 'generate_add_to_iCal_button'), 10, 2);
49 49
 		 // process ics download request
50
-		EE_Config::register_route( 'download_ics_file', 'EED_Ical', 'download_ics_file' );
50
+		EE_Config::register_route('download_ics_file', 'EED_Ical', 'download_ics_file');
51 51
 	}
52 52
 
53 53
 
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 	 * @param    WP $WP
71 71
 	 * @return    void
72 72
 	 */
73
-	public function run( $WP ) {}
73
+	public function run($WP) {}
74 74
 
75 75
 
76 76
 
@@ -82,30 +82,30 @@  discard block
 block discarded – undo
82 82
 	 * @param $datetime
83 83
 	 * @return    string
84 84
 	 */
85
-	public static function generate_add_to_iCal_button( $html, $datetime ) {
85
+	public static function generate_add_to_iCal_button($html, $datetime) {
86 86
 		// first verify a proper datetime object has been received
87
-		if ( $datetime instanceof EE_Datetime ) {
87
+		if ($datetime instanceof EE_Datetime) {
88 88
 			// set whether a link or submit button is shown
89
-			$iCal_type = apply_filters( 'FHEE__EED_Ical__generate_add_to_iCal_button__iCal_type', 'submit' );
89
+			$iCal_type = apply_filters('FHEE__EED_Ical__generate_add_to_iCal_button__iCal_type', 'submit');
90 90
 			// generate a link to the route we registered in set_hooks()
91
-			$URL = add_query_arg( array( 'ee' => 'download_ics_file', 'ics_id' => $datetime->ID() ), site_url() );
91
+			$URL = add_query_arg(array('ee' => 'download_ics_file', 'ics_id' => $datetime->ID()), site_url());
92 92
 			// what type ?
93
-			switch ( $iCal_type ) {
93
+			switch ($iCal_type) {
94 94
 				// submit buttons appear as buttons and are very compatible with a theme's style
95 95
 				case 'submit' :
96
-					$html .= '<form id="download-iCal-frm-' . $datetime->ID() . '" class="download-iCal-frm" action="' . $URL . '" method="post" >';
97
-					$html .= '<input type="submit" class="ee-ical-sbmt" value="&#xf145;" title="' . __( 'Add to iCal Calendar', 'event_espresso' ) . '"/>';
96
+					$html .= '<form id="download-iCal-frm-'.$datetime->ID().'" class="download-iCal-frm" action="'.$URL.'" method="post" >';
97
+					$html .= '<input type="submit" class="ee-ical-sbmt" value="&#xf145;" title="'.__('Add to iCal Calendar', 'event_espresso').'"/>';
98 98
 					$html .= '</form>';
99 99
 					break;
100 100
 				// buttons are just links that have been styled to appear as buttons, but may not be blend with a theme as well as submit buttons
101 101
 				case 'button' :
102
-					$html .= '<a class="ee-ical-btn small ee-button ee-roundish" href="' . $URL . '" title="' . __( 'Add to iCal Calendar', 'event_espresso' ) . '">';
102
+					$html .= '<a class="ee-ical-btn small ee-button ee-roundish" href="'.$URL.'" title="'.__('Add to iCal Calendar', 'event_espresso').'">';
103 103
 					$html .= ' <span class="dashicons dashicons-calendar"></span>';
104 104
 					$html .= '</a>';
105 105
 					break;
106 106
 				// links are just links that use the calendar dashicon
107 107
 				case 'icon' :
108
-					$html .= '<a class="ee-ical-lnk" href="' . $URL . '" title="' . __( 'Add to iCal Calendar', 'event_espresso' ) . '">';
108
+					$html .= '<a class="ee-ical-lnk" href="'.$URL.'" title="'.__('Add to iCal Calendar', 'event_espresso').'">';
109 109
 					$html .= ' <span class="dashicons dashicons-calendar"></span>';
110 110
 					$html .= '</a>';
111 111
 					break;
@@ -123,72 +123,72 @@  discard block
 block discarded – undo
123 123
 	 *  @return 	void
124 124
 	 */
125 125
 	public static function download_ics_file() {
126
-		if ( EE_Registry::instance()->REQ->is_set( 'ics_id' )) {
127
-			$DTT_ID = absint( EE_Registry::instance()->REQ->get( 'ics_id' ));
128
-			$datetime = EE_Registry::instance()->load_model( 'Datetime' )->get_one_by_ID( $DTT_ID );
129
-			if ( $datetime instanceof EE_Datetime ) {
126
+		if (EE_Registry::instance()->REQ->is_set('ics_id')) {
127
+			$DTT_ID = absint(EE_Registry::instance()->REQ->get('ics_id'));
128
+			$datetime = EE_Registry::instance()->load_model('Datetime')->get_one_by_ID($DTT_ID);
129
+			if ($datetime instanceof EE_Datetime) {
130 130
 				// get related event, venues, and event categories
131 131
 				$event = $datetime->event();
132 132
 				// get related category Term object and it's name
133 133
 				$category = $event->first_event_category();
134
-				if ( $category instanceof EE_Term ) {
134
+				if ($category instanceof EE_Term) {
135 135
 					$category = $category->name();
136 136
 				}
137 137
 				$location = '';
138 138
 				// get first related venue and convert to CSV string
139
-				$venue = $event->venues(array( 'limit'=>1 ));
140
-				if ( is_array( $venue ) && ! empty( $venue )) {
141
-					$venue = array_shift( $venue );
142
-					if ( $venue instanceof EE_Venue ) {
143
-						$location = espresso_venue_raw_address( 'inline', $venue->ID(), FALSE );
139
+				$venue = $event->venues(array('limit'=>1));
140
+				if (is_array($venue) && ! empty($venue)) {
141
+					$venue = array_shift($venue);
142
+					if ($venue instanceof EE_Venue) {
143
+						$location = espresso_venue_raw_address('inline', $venue->ID(), FALSE);
144 144
 					}
145 145
 				}
146 146
 				// set variables, escape strings, convert timestamps to ics format, etc
147
-				$filename = $event->slug() . '-' . $datetime->start_date( 'Y-m-d' ) . '.ics';
148
-				$organizer = EED_Ical::_escape_ICal_data( EE_Registry::instance()->CFG->organization->name );
149
-				$UID = EED_Ical::_escape_ICal_data( md5( $event->name() . $event->ID() . $datetime->ID() ));
150
-				$org_email = EED_Ical::_escape_ICal_data( $datetime->ID() );
151
-				$timestamp = date( EED_Ical::iCal_datetime_format );
152
-				$location = EED_Ical::_escape_ICal_data( $location );
153
-				$summary = EED_Ical::_escape_ICal_data( $event->name() );
154
-				$description = EED_Ical::_escape_ICal_description( wp_strip_all_tags( $event->description() ));
147
+				$filename = $event->slug().'-'.$datetime->start_date('Y-m-d').'.ics';
148
+				$organizer = EED_Ical::_escape_ICal_data(EE_Registry::instance()->CFG->organization->name);
149
+				$UID = EED_Ical::_escape_ICal_data(md5($event->name().$event->ID().$datetime->ID()));
150
+				$org_email = EED_Ical::_escape_ICal_data($datetime->ID());
151
+				$timestamp = date(EED_Ical::iCal_datetime_format);
152
+				$location = EED_Ical::_escape_ICal_data($location);
153
+				$summary = EED_Ical::_escape_ICal_data($event->name());
154
+				$description = EED_Ical::_escape_ICal_description(wp_strip_all_tags($event->description()));
155 155
 				$status = $datetime->get_active_status();
156 156
 				$status = $status == EE_Datetime::cancelled ? 'Cancelled' : 'Confirmed';
157
-				$status = EED_Ical::_escape_ICal_data( $status );
158
-				$categories = EED_Ical::_escape_ICal_data( $category );
159
-				$url = EED_Ical::_escape_ICal_data( get_permalink( $event->ID() ));
160
-				$dtt_start = EED_Ical::_escape_ICal_data( date( EED_Ical::iCal_datetime_format, $datetime->start() ));
161
-				$dtt_end = EED_Ical::_escape_ICal_data( date( EED_Ical::iCal_datetime_format, $datetime->end() ));
157
+				$status = EED_Ical::_escape_ICal_data($status);
158
+				$categories = EED_Ical::_escape_ICal_data($category);
159
+				$url = EED_Ical::_escape_ICal_data(get_permalink($event->ID()));
160
+				$dtt_start = EED_Ical::_escape_ICal_data(date(EED_Ical::iCal_datetime_format, $datetime->start()));
161
+				$dtt_end = EED_Ical::_escape_ICal_data(date(EED_Ical::iCal_datetime_format, $datetime->end()));
162 162
 				// set headers
163
-				header( 'Content-type: text/calendar; charset=utf-8' );
164
-				header( 'Content-Disposition: attachment; filename="' . $filename . '"' );
165
-				header( 'Cache-Control: private, max-age=0, must-revalidate' );
166
-				header( 'Pragma: public' );
167
-				header( 'Content-Type: application/octet-stream' );
168
-				header( 'Content-Type: application/force-download' );
169
-				header( 'Cache-Control: no-cache, must-revalidate' );
170
-				header( 'Content-Transfer-Encoding: binary' );
171
-				header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' ); // past date
172
-				ini_set( 'zlib.output_compression', '0' );
163
+				header('Content-type: text/calendar; charset=utf-8');
164
+				header('Content-Disposition: attachment; filename="'.$filename.'"');
165
+				header('Cache-Control: private, max-age=0, must-revalidate');
166
+				header('Pragma: public');
167
+				header('Content-Type: application/octet-stream');
168
+				header('Content-Type: application/force-download');
169
+				header('Cache-Control: no-cache, must-revalidate');
170
+				header('Content-Transfer-Encoding: binary');
171
+				header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // past date
172
+				ini_set('zlib.output_compression', '0');
173 173
 				// echo the output
174
-				echo "BEGIN:VCALENDAR" . PHP_EOL;
175
-				echo "VERSION:2.0" . PHP_EOL;
176
-				echo "PRODID:-//{$organizer}//NONSGML PDA Calendar Version 1.0//EN" . PHP_EOL;
177
-				echo "CALSCALE:GREGORIAN" . PHP_EOL;
178
-				echo "BEGIN:VEVENT" . PHP_EOL;
179
-				echo "UID:{$UID}" . PHP_EOL;
180
-				echo "ORGANIZER:MAILTO:{$org_email}" . PHP_EOL;
181
-				echo "DTSTAMP:{$timestamp}" . PHP_EOL;
182
-				echo "LOCATION:{$location}" . PHP_EOL;
183
-				echo "SUMMARY:{$summary}" . PHP_EOL;
184
-				echo "DESCRIPTION:{$description}" . PHP_EOL;
185
-				echo "STATUS:{$status}" . PHP_EOL;
186
-				echo "CATEGORIES:{$categories}" . PHP_EOL;
187
-				echo "URL;VALUE=URI:{$url}" . PHP_EOL;
188
-				echo "DTSTART:{$dtt_start}" . PHP_EOL;
189
-				echo "DTEND:{$dtt_end}" . PHP_EOL;
190
-				echo "END:VEVENT" . PHP_EOL;
191
-				echo "END:VCALENDAR" . PHP_EOL;
174
+				echo "BEGIN:VCALENDAR".PHP_EOL;
175
+				echo "VERSION:2.0".PHP_EOL;
176
+				echo "PRODID:-//{$organizer}//NONSGML PDA Calendar Version 1.0//EN".PHP_EOL;
177
+				echo "CALSCALE:GREGORIAN".PHP_EOL;
178
+				echo "BEGIN:VEVENT".PHP_EOL;
179
+				echo "UID:{$UID}".PHP_EOL;
180
+				echo "ORGANIZER:MAILTO:{$org_email}".PHP_EOL;
181
+				echo "DTSTAMP:{$timestamp}".PHP_EOL;
182
+				echo "LOCATION:{$location}".PHP_EOL;
183
+				echo "SUMMARY:{$summary}".PHP_EOL;
184
+				echo "DESCRIPTION:{$description}".PHP_EOL;
185
+				echo "STATUS:{$status}".PHP_EOL;
186
+				echo "CATEGORIES:{$categories}".PHP_EOL;
187
+				echo "URL;VALUE=URI:{$url}".PHP_EOL;
188
+				echo "DTSTART:{$dtt_start}".PHP_EOL;
189
+				echo "DTEND:{$dtt_end}".PHP_EOL;
190
+				echo "END:VEVENT".PHP_EOL;
191
+				echo "END:VCALENDAR".PHP_EOL;
192 192
 			}
193 193
 		}
194 194
 		die();
@@ -203,8 +203,8 @@  discard block
 block discarded – undo
203 203
 	 *  	@param	string $string
204 204
 	 *  	@return	string
205 205
 	 */
206
-	private static function _escape_ICal_data( $string = '' ) {
207
-		return preg_replace( '/([\,;])/', '\\\$1', $string );
206
+	private static function _escape_ICal_data($string = '') {
207
+		return preg_replace('/([\,;])/', '\\\$1', $string);
208 208
 	}
209 209
 
210 210
 	/**
@@ -214,13 +214,13 @@  discard block
 block discarded – undo
214 214
 	 *  	@param	string $description
215 215
 	 *  	@return	string
216 216
 	 */
217
-	private static function _escape_ICal_description( $description = '' ) {
217
+	private static function _escape_ICal_description($description = '') {
218 218
 			
219 219
 			//Escape spcial chars within the decription
220
-			$description = EED_Ical::_escape_ICal_data( $description );
220
+			$description = EED_Ical::_escape_ICal_data($description);
221 221
 
222 222
 		    //Remove line breaks and output in iCal format
223
-		    $description = str_replace( array( "\r\n", "\n"), '\n', $description );
223
+		    $description = str_replace(array("\r\n", "\n"), '\n', $description);
224 224
 
225 225
 		return $description;
226 226
 	}
Please login to merge, or discard this patch.