@@ -1,14 +1,14 @@ |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2 | 2 | require_once ( EE_MODELS . 'EEM_Base.model.php' ); |
3 | 3 | /** |
4 | - * |
|
5 | - * Transaction Model |
|
6 | - * |
|
7 | - * @package Event Espresso |
|
8 | - * @subpackage includes/models/ |
|
9 | - * @author Brent Christensen |
|
10 | - * |
|
11 | - */ |
|
4 | + * |
|
5 | + * Transaction Model |
|
6 | + * |
|
7 | + * @package Event Espresso |
|
8 | + * @subpackage includes/models/ |
|
9 | + * @author Brent Christensen |
|
10 | + * |
|
11 | + */ |
|
12 | 12 | class EEM_Transaction extends EEM_Base { |
13 | 13 | |
14 | 14 | // private instance of the Transaction object |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2 | -require_once ( EE_MODELS . 'EEM_Base.model.php' ); |
|
2 | +require_once (EE_MODELS.'EEM_Base.model.php'); |
|
3 | 3 | /** |
4 | 4 | * |
5 | 5 | * Transaction Model |
@@ -68,36 +68,36 @@ discard block |
||
68 | 68 | * Note this just sends the timezone info to the date time model field objects. Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option) |
69 | 69 | * @return EEM_Transaction |
70 | 70 | */ |
71 | - protected function __construct( $timezone ) { |
|
72 | - $this->singular_item = __('Transaction','event_espresso'); |
|
73 | - $this->plural_item = __('Transactions','event_espresso'); |
|
71 | + protected function __construct($timezone) { |
|
72 | + $this->singular_item = __('Transaction', 'event_espresso'); |
|
73 | + $this->plural_item = __('Transactions', 'event_espresso'); |
|
74 | 74 | |
75 | 75 | $this->_tables = array( |
76 | - 'Transaction'=>new EE_Primary_Table('esp_transaction','TXN_ID') |
|
76 | + 'Transaction'=>new EE_Primary_Table('esp_transaction', 'TXN_ID') |
|
77 | 77 | ); |
78 | 78 | $this->_fields = array( |
79 | 79 | 'Transaction'=>array( |
80 | - 'TXN_ID'=>new EE_Primary_Key_Int_Field('TXN_ID', __('Transaction ID','event_espresso')), |
|
81 | - 'TXN_timestamp'=>new EE_Datetime_Field('TXN_timestamp', __('date when transaction was created','event_espresso'), false, time(), $timezone ), |
|
82 | - 'TXN_total'=>new EE_Money_Field('TXN_total', __('Total value of Transaction','event_espresso'), false, 0), |
|
83 | - 'TXN_paid'=>new EE_Money_Field('TXN_paid', __('Amount paid towards transaction to date','event_espresso'), false, 0), |
|
84 | - 'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID','event_espresso'), false, EEM_Transaction::failed_status_code, 'Status'), |
|
85 | - 'TXN_session_data'=>new EE_Serialized_Text_Field('TXN_session_data', __('Serialized session data','event_espresso'), true, ''), |
|
86 | - 'TXN_hash_salt'=>new EE_Plain_Text_Field('TXN_hash_salt', __('Transaction Hash Salt','event_espresso'), true, ''), |
|
80 | + 'TXN_ID'=>new EE_Primary_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso')), |
|
81 | + 'TXN_timestamp'=>new EE_Datetime_Field('TXN_timestamp', __('date when transaction was created', 'event_espresso'), false, time(), $timezone), |
|
82 | + 'TXN_total'=>new EE_Money_Field('TXN_total', __('Total value of Transaction', 'event_espresso'), false, 0), |
|
83 | + 'TXN_paid'=>new EE_Money_Field('TXN_paid', __('Amount paid towards transaction to date', 'event_espresso'), false, 0), |
|
84 | + 'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'), false, EEM_Transaction::failed_status_code, 'Status'), |
|
85 | + 'TXN_session_data'=>new EE_Serialized_Text_Field('TXN_session_data', __('Serialized session data', 'event_espresso'), true, ''), |
|
86 | + 'TXN_hash_salt'=>new EE_Plain_Text_Field('TXN_hash_salt', __('Transaction Hash Salt', 'event_espresso'), true, ''), |
|
87 | 87 | 'PMD_ID'=>new EE_Foreign_Key_Int_Field('PMD_ID', __("Last Used Payment Method", 'event_espresso'), true, NULL, 'Payment_Method'), |
88 | - 'TXN_reg_steps' => new EE_Serialized_Text_Field( 'TXN_reg_steps', __( 'Registration Steps', 'event_espresso' ), FALSE, array() ), |
|
88 | + 'TXN_reg_steps' => new EE_Serialized_Text_Field('TXN_reg_steps', __('Registration Steps', 'event_espresso'), FALSE, array()), |
|
89 | 89 | ) |
90 | 90 | ); |
91 | 91 | $this->_model_relations = array( |
92 | 92 | 'Registration'=>new EE_Has_Many_Relation(), |
93 | 93 | 'Payment'=>new EE_Has_Many_Relation(), |
94 | 94 | 'Status'=>new EE_Belongs_To_Relation(), |
95 | - 'Line_Item'=>new EE_Has_Many_Relation(false),//you can delete a transaction without needing to delete its line items |
|
95 | + 'Line_Item'=>new EE_Has_Many_Relation(false), //you can delete a transaction without needing to delete its line items |
|
96 | 96 | 'Payment_Method'=>new EE_Belongs_To_Relation(), |
97 | 97 | 'Message' => new EE_Has_Many_Relation() |
98 | 98 | ); |
99 | 99 | $this->_model_chain_to_wp_user = 'Registration.Event'; |
100 | - parent::__construct( $timezone ); |
|
100 | + parent::__construct($timezone); |
|
101 | 101 | |
102 | 102 | } |
103 | 103 | |
@@ -108,23 +108,23 @@ discard block |
||
108 | 108 | * @param string $period |
109 | 109 | * @return \stdClass[] |
110 | 110 | */ |
111 | - public function get_revenue_per_day_report( $period = '-1 month' ) { |
|
112 | - $sql_date = $this->convert_datetime_for_query( 'TXN_timestamp', date( 'Y-m-d H:i:s', strtotime( $period ) ), 'Y-m-d H:i:s', 'UTC' ); |
|
111 | + public function get_revenue_per_day_report($period = '-1 month') { |
|
112 | + $sql_date = $this->convert_datetime_for_query('TXN_timestamp', date('Y-m-d H:i:s', strtotime($period)), 'Y-m-d H:i:s', 'UTC'); |
|
113 | 113 | |
114 | - EE_Registry::instance()->load_helper( 'DTT_Helper' ); |
|
115 | - $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset( $this->get_timezone(), 'TXN_timestamp' ); |
|
114 | + EE_Registry::instance()->load_helper('DTT_Helper'); |
|
115 | + $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'TXN_timestamp'); |
|
116 | 116 | |
117 | 117 | $results = $this->_get_all_wpdb_results( |
118 | 118 | array( |
119 | 119 | array( |
120 | - 'TXN_timestamp' => array( '>=', $sql_date ) ), |
|
120 | + 'TXN_timestamp' => array('>=', $sql_date) ), |
|
121 | 121 | 'group_by' => 'txnDate', |
122 | - 'order_by' => array( 'TXN_timestamp' => 'ASC' ) |
|
122 | + 'order_by' => array('TXN_timestamp' => 'ASC') |
|
123 | 123 | ), |
124 | 124 | OBJECT, |
125 | 125 | array( |
126 | - 'txnDate' => array( 'DATE(' . $query_interval . ')', '%s' ), |
|
127 | - 'revenue' => array( 'SUM(Transaction.TXN_paid)', '%d' ) |
|
126 | + 'txnDate' => array('DATE('.$query_interval.')', '%s'), |
|
127 | + 'revenue' => array('SUM(Transaction.TXN_paid)', '%d') |
|
128 | 128 | ) |
129 | 129 | ); |
130 | 130 | return $results; |
@@ -140,17 +140,17 @@ discard block |
||
140 | 140 | * @throws \EE_Error |
141 | 141 | * @return mixed |
142 | 142 | */ |
143 | - public function get_revenue_per_event_report( $period = '-1 month' ) { |
|
143 | + public function get_revenue_per_event_report($period = '-1 month') { |
|
144 | 144 | global $wpdb; |
145 | - $transaction_table = $wpdb->prefix . 'esp_transaction'; |
|
146 | - $registration_table = $wpdb->prefix . 'esp_registration'; |
|
145 | + $transaction_table = $wpdb->prefix.'esp_transaction'; |
|
146 | + $registration_table = $wpdb->prefix.'esp_registration'; |
|
147 | 147 | $event_table = $wpdb->posts; |
148 | - $payment_table = $wpdb->prefix . 'esp_payment'; |
|
149 | - $sql_date = date( 'Y-m-d H:i:s', strtotime( $period ) ); |
|
148 | + $payment_table = $wpdb->prefix.'esp_payment'; |
|
149 | + $sql_date = date('Y-m-d H:i:s', strtotime($period)); |
|
150 | 150 | $extra_event_on_join = ''; |
151 | 151 | //exclude events not authored by user if permissions in effect |
152 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_registrations', 'reg_per_event_report' ) ) { |
|
153 | - $extra_event_on_join = ' AND Event.post_author = ' . get_current_user_id(); |
|
152 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
153 | + $extra_event_on_join = ' AND Event.post_author = '.get_current_user_id(); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | $approved_payment_status = EEM_Payment::status_id_approved; |
@@ -196,10 +196,10 @@ discard block |
||
196 | 196 | * @param string $reg_url_link |
197 | 197 | * @return EE_Transaction |
198 | 198 | */ |
199 | - public function get_transaction_from_reg_url_link( $reg_url_link = '' ){ |
|
200 | - return $this->get_one( array( |
|
199 | + public function get_transaction_from_reg_url_link($reg_url_link = '') { |
|
200 | + return $this->get_one(array( |
|
201 | 201 | array( |
202 | - 'Registration.REG_url_link' => ! empty( $reg_url_link ) ? $reg_url_link : EE_Registry::instance()->REQ->get( 'e_reg_url_link', '' ) |
|
202 | + 'Registration.REG_url_link' => ! empty($reg_url_link) ? $reg_url_link : EE_Registry::instance()->REQ->get('e_reg_url_link', '') |
|
203 | 203 | ) |
204 | 204 | )); |
205 | 205 | } |
@@ -219,15 +219,15 @@ discard block |
||
219 | 219 | * @param boolean $save_txn whether or not to save the transaction during this function call |
220 | 220 | * @return boolean |
221 | 221 | */ |
222 | - public function update_based_on_payments( $transaction_obj_or_id, $save_txn = TRUE ){ |
|
222 | + public function update_based_on_payments($transaction_obj_or_id, $save_txn = TRUE) { |
|
223 | 223 | EE_Error::doing_it_wrong( |
224 | - __CLASS__ . '::' . __FUNCTION__, |
|
225 | - sprintf( __( 'This method is deprecated. Please use "%s" instead', 'event_espresso' ), 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()' ), |
|
224 | + __CLASS__.'::'.__FUNCTION__, |
|
225 | + sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'), 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()'), |
|
226 | 226 | '4.6.0' |
227 | 227 | ); |
228 | 228 | /** @type EE_Transaction_Processor $transaction_processor */ |
229 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
230 | - return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( $this->ensure_is_obj( $transaction_obj_or_id )); |
|
229 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
230 | + return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment($this->ensure_is_obj($transaction_obj_or_id)); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | array( |
259 | 259 | 0 => array( |
260 | 260 | 'STS_ID' => EEM_Transaction::failed_status_code, |
261 | - 'TXN_timestamp' => array( '<', time() - $time_to_leave_alone ) |
|
261 | + 'TXN_timestamp' => array('<', time() - $time_to_leave_alone) |
|
262 | 262 | ) |
263 | 263 | ), |
264 | 264 | $time_to_leave_alone |
@@ -271,26 +271,26 @@ discard block |
||
271 | 271 | */ |
272 | 272 | $txn_ids = apply_filters( |
273 | 273 | 'FHEE__EEM_Transaction__delete_junk_transactions__transaction_ids_to_delete', |
274 | - EEM_Transaction::instance()->get_col( $ids_query, 'TXN_ID' ), |
|
274 | + EEM_Transaction::instance()->get_col($ids_query, 'TXN_ID'), |
|
275 | 275 | $time_to_leave_alone |
276 | 276 | ); |
277 | 277 | |
278 | 278 | //now that we have the ids to delete, let's get deletin' |
279 | 279 | //Why no wpdb->prepare? Because the data is trusted. We got the ids from the original query to get them FROM |
280 | 280 | //the db (which is sanitized) so no need to prepare them again. |
281 | - if ( $txn_ids ) { |
|
282 | - $query = ' |
|
281 | + if ($txn_ids) { |
|
282 | + $query = ' |
|
283 | 283 | DELETE |
284 | - FROM ' . $this->table() . ' |
|
284 | + FROM ' . $this->table().' |
|
285 | 285 | WHERE |
286 | - TXN_ID IN ( ' . implode( ",", $txn_ids ) . ')'; |
|
287 | - $deleted = $wpdb->query( $query ); |
|
286 | + TXN_ID IN ( ' . implode(",", $txn_ids).')'; |
|
287 | + $deleted = $wpdb->query($query); |
|
288 | 288 | } |
289 | - if ( $deleted ) { |
|
289 | + if ($deleted) { |
|
290 | 290 | /** |
291 | 291 | * Allows code to do something after the transactions have been deleted. |
292 | 292 | */ |
293 | - do_action( 'AHEE__EEM_Transaction__delete_junk_transactions__successful_deletion', $txn_ids ); |
|
293 | + do_action('AHEE__EEM_Transaction__delete_junk_transactions__successful_deletion', $txn_ids); |
|
294 | 294 | } |
295 | 295 | return $deleted; |
296 | 296 | } |
@@ -1,13 +1,13 @@ |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
2 | 2 | /** |
3 | - * EE_Form_Input_Base |
|
4 | - * For representing a single form input. Extends EE_Form_Section_Base because |
|
5 | - * it is a part of a form and shares a surprisingly large amount of functionality |
|
6 | - * |
|
7 | - * @package Event Espresso |
|
8 | - * @subpackage |
|
9 | - * @author Mike Nelson |
|
10 | - */ |
|
3 | + * EE_Form_Input_Base |
|
4 | + * For representing a single form input. Extends EE_Form_Section_Base because |
|
5 | + * it is a part of a form and shares a surprisingly large amount of functionality |
|
6 | + * |
|
7 | + * @package Event Espresso |
|
8 | + * @subpackage |
|
9 | + * @author Mike Nelson |
|
10 | + */ |
|
11 | 11 | abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable{ |
12 | 12 | |
13 | 13 | /** |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @subpackage |
9 | 9 | * @author Mike Nelson |
10 | 10 | */ |
11 | -abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable{ |
|
11 | +abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * the input's name attribute |
@@ -141,66 +141,66 @@ discard block |
||
141 | 141 | * @type EE_Validation_Strategy_Base[] $validation_strategies |
142 | 142 | * } |
143 | 143 | */ |
144 | - public function __construct( $input_args = array() ){ |
|
145 | - $input_args = apply_filters( 'FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this ); |
|
144 | + public function __construct($input_args = array()) { |
|
145 | + $input_args = apply_filters('FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this); |
|
146 | 146 | // the following properties must be cast as arrays |
147 | 147 | $set_as_array = array( |
148 | 148 | 'validation_strategies' => true |
149 | 149 | ); |
150 | 150 | // loop thru incoming options |
151 | - foreach( $input_args as $key => $value ) { |
|
151 | + foreach ($input_args as $key => $value) { |
|
152 | 152 | // add underscore to $key to match property names |
153 | - $_key = '_' . $key; |
|
154 | - if ( property_exists( $this, $_key )) { |
|
153 | + $_key = '_'.$key; |
|
154 | + if (property_exists($this, $_key)) { |
|
155 | 155 | // first check if this property needs to be set as an array |
156 | - if ( isset( $set_as_array[ $key ] )) { |
|
156 | + if (isset($set_as_array[$key])) { |
|
157 | 157 | // ensure value is an array |
158 | - $value = is_array( $value ) ? $value : array( get_class( $value ), $value ); |
|
158 | + $value = is_array($value) ? $value : array(get_class($value), $value); |
|
159 | 159 | // and merge with existing values |
160 | - $this->{$_key} = array_merge( $this->{$_key}, $value ); |
|
160 | + $this->{$_key} = array_merge($this->{$_key}, $value); |
|
161 | 161 | } else { |
162 | 162 | $this->{$_key} = $value; |
163 | 163 | } |
164 | 164 | } |
165 | 165 | } |
166 | 166 | // ensure that "required" is set correctly |
167 | - $this->set_required( $this->_required, isset( $input_args[ 'required_validation_error_message' ] ) ? $input_args[ 'required_validation_error_message' ] : NULL ); |
|
167 | + $this->set_required($this->_required, isset($input_args['required_validation_error_message']) ? $input_args['required_validation_error_message'] : NULL); |
|
168 | 168 | |
169 | 169 | //$this->_html_name_specified = isset( $input_args['html_name'] ) ? TRUE : FALSE; |
170 | 170 | |
171 | 171 | $this->_display_strategy->_construct_finalize($this); |
172 | - if ( $this->_validation_strategies ){ |
|
173 | - foreach( $this->_validation_strategies as $validation_strategy ){ |
|
172 | + if ($this->_validation_strategies) { |
|
173 | + foreach ($this->_validation_strategies as $validation_strategy) { |
|
174 | 174 | $validation_strategy->_construct_finalize($this); |
175 | 175 | } |
176 | 176 | } |
177 | 177 | |
178 | - if( ! $this->_normalization_strategy){ |
|
178 | + if ( ! $this->_normalization_strategy) { |
|
179 | 179 | $this->_normalization_strategy = new EE_Text_Normalization(); |
180 | 180 | } |
181 | 181 | $this->_normalization_strategy->_construct_finalize($this); |
182 | 182 | |
183 | 183 | //at least we can use the normalization strategy to populate the default |
184 | - if( isset( $input_args[ 'default' ] ) ) { |
|
185 | - $this->set_default( $input_args[ 'default' ] ); |
|
184 | + if (isset($input_args['default'])) { |
|
185 | + $this->set_default($input_args['default']); |
|
186 | 186 | } |
187 | 187 | |
188 | - if( ! $this->_sensitive_data_removal_strategy){ |
|
188 | + if ( ! $this->_sensitive_data_removal_strategy) { |
|
189 | 189 | $this->_sensitive_data_removal_strategy = new EE_No_Sensitive_Data_Removal(); |
190 | 190 | } |
191 | 191 | $this->_sensitive_data_removal_strategy->_construct_finalize($this); |
192 | - parent::__construct( $input_args ); |
|
192 | + parent::__construct($input_args); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
196 | 196 | * Sets the html_name to its default value, if none was specified in teh constructor. |
197 | 197 | * Calculation involves using the name and the parent's html_name |
198 | 198 | */ |
199 | - protected function _set_default_html_name_if_empty(){ |
|
200 | - if( ! $this->_html_name){ |
|
201 | - if( $this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper){ |
|
202 | - $this->_html_name = $this->_parent_section->html_name_prefix() . "[{$this->name()}]"; |
|
203 | - }else{ |
|
199 | + protected function _set_default_html_name_if_empty() { |
|
200 | + if ( ! $this->_html_name) { |
|
201 | + if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) { |
|
202 | + $this->_html_name = $this->_parent_section->html_name_prefix()."[{$this->name()}]"; |
|
203 | + } else { |
|
204 | 204 | $this->_html_name = $this->name(); |
205 | 205 | } |
206 | 206 | } |
@@ -215,12 +215,12 @@ discard block |
||
215 | 215 | function _construct_finalize($parent_form_section, $name) { |
216 | 216 | parent::_construct_finalize($parent_form_section, $name); |
217 | 217 | $this->_set_default_html_name_if_empty(); |
218 | - if( ! $this->_html_label ){ |
|
219 | - if( ! $this->_html_label_text){ |
|
220 | - $this->_html_label_text = ucwords( str_replace("_"," ",$name)); |
|
218 | + if ( ! $this->_html_label) { |
|
219 | + if ( ! $this->_html_label_text) { |
|
220 | + $this->_html_label_text = ucwords(str_replace("_", " ", $name)); |
|
221 | 221 | } |
222 | 222 | } |
223 | - do_action( 'AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name ); |
|
223 | + do_action('AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | /** |
@@ -228,10 +228,10 @@ discard block |
||
228 | 228 | * @return EE_Display_Strategy_Base |
229 | 229 | * @throws EE_Error |
230 | 230 | */ |
231 | - protected function _get_display_strategy(){ |
|
232 | - if( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base){ |
|
233 | - throw new EE_Error(sprintf(__("Cannot get display strategy for form input with name %s and id %s, because it has not been set in the constructor", "event_espresso"),$this->html_name(),$this->html_id())); |
|
234 | - }else{ |
|
231 | + protected function _get_display_strategy() { |
|
232 | + if ( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base) { |
|
233 | + throw new EE_Error(sprintf(__("Cannot get display strategy for form input with name %s and id %s, because it has not been set in the constructor", "event_espresso"), $this->html_name(), $this->html_id())); |
|
234 | + } else { |
|
235 | 235 | return $this->_display_strategy; |
236 | 236 | } |
237 | 237 | } |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | * Sets the display strategy. |
240 | 240 | * @param EE_Display_Strategy_Base $strategy |
241 | 241 | */ |
242 | - protected function _set_display_strategy(EE_Display_Strategy_Base $strategy){ |
|
242 | + protected function _set_display_strategy(EE_Display_Strategy_Base $strategy) { |
|
243 | 243 | $this->_display_strategy = $strategy; |
244 | 244 | } |
245 | 245 | |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | * Sets the sanitization strategy |
248 | 248 | * @param EE_Normalization_Strategy_Base $strategy |
249 | 249 | */ |
250 | - protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy){ |
|
250 | + protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy) { |
|
251 | 251 | $this->_normalization_strategy = $strategy; |
252 | 252 | } |
253 | 253 | |
@@ -273,14 +273,14 @@ discard block |
||
273 | 273 | * Gets the display strategy for this input |
274 | 274 | * @return EE_Display_Strategy_Base |
275 | 275 | */ |
276 | - public function get_display_strategy(){ |
|
276 | + public function get_display_strategy() { |
|
277 | 277 | return $this->_display_strategy; |
278 | 278 | } |
279 | 279 | /** |
280 | 280 | * Overwrites the display strategy |
281 | 281 | * @param EE_Display_Strategy_Base $display_strategy |
282 | 282 | */ |
283 | - public function set_display_strategy($display_strategy){ |
|
283 | + public function set_display_strategy($display_strategy) { |
|
284 | 284 | $this->_display_strategy = $display_strategy; |
285 | 285 | $this->_display_strategy->_construct_finalize($this); |
286 | 286 | } |
@@ -288,14 +288,14 @@ discard block |
||
288 | 288 | * Gets the normalization strategy set on this input |
289 | 289 | * @return EE_Normalization_Strategy_Base |
290 | 290 | */ |
291 | - public function get_normalization_strategy(){ |
|
291 | + public function get_normalization_strategy() { |
|
292 | 292 | return $this->_normalization_strategy; |
293 | 293 | } |
294 | 294 | /** |
295 | 295 | * Overwrites the normalization strategy |
296 | 296 | * @param EE_Normalization_Strategy_Base $normalization_strategy |
297 | 297 | */ |
298 | - public function set_normalization_strategy($normalization_strategy){ |
|
298 | + public function set_normalization_strategy($normalization_strategy) { |
|
299 | 299 | $this->_normalization_strategy = $normalization_strategy; |
300 | 300 | $this->_normalization_strategy->_construct_finalize($this); |
301 | 301 | } |
@@ -304,10 +304,10 @@ discard block |
||
304 | 304 | * Returns all teh validation strategies which apply to this field, numerically indexed |
305 | 305 | * @return EE_Validation_Strategy_Base[] |
306 | 306 | */ |
307 | - public function get_validation_strategies(){ |
|
308 | - if(is_array($this->_validation_strategies)){ |
|
307 | + public function get_validation_strategies() { |
|
308 | + if (is_array($this->_validation_strategies)) { |
|
309 | 309 | return $this->_validation_strategies; |
310 | - }else{ |
|
310 | + } else { |
|
311 | 311 | return array(); |
312 | 312 | } |
313 | 313 | |
@@ -317,9 +317,9 @@ discard block |
||
317 | 317 | * @param EE_Validation_Strategy_Base $validation_strategy |
318 | 318 | * @return void |
319 | 319 | */ |
320 | - protected function _add_validation_strategy( EE_Validation_Strategy_Base $validation_strategy ){ |
|
321 | - $validation_strategy->_construct_finalize( $this ); |
|
322 | - $this->_validation_strategies[ get_class($validation_strategy) ] = $validation_strategy; |
|
320 | + protected function _add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) { |
|
321 | + $validation_strategy->_construct_finalize($this); |
|
322 | + $this->_validation_strategies[get_class($validation_strategy)] = $validation_strategy; |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | /** |
@@ -327,18 +327,18 @@ discard block |
||
327 | 327 | * @param EE_Validation_Strategy_Base $validation_strategy |
328 | 328 | * @return void |
329 | 329 | */ |
330 | - public function add_validation_strategy( EE_Validation_Strategy_Base $validation_strategy ) { |
|
331 | - $this->_add_validation_strategy( $validation_strategy ); |
|
330 | + public function add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) { |
|
331 | + $this->_add_validation_strategy($validation_strategy); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | /** |
335 | 335 | * The classname of the validation strategy to remove |
336 | 336 | * @param string $validation_strategy_classname |
337 | 337 | */ |
338 | - public function remove_validation_strategy( $validation_strategy_classname ) { |
|
339 | - foreach( $this->_validation_strategies as $key => $validation_strategy ){ |
|
340 | - if( is_subclass_of( $validation_strategy, $validation_strategy_classname ) ){ |
|
341 | - unset( $this->_validation_strategies[ $key ] ); |
|
338 | + public function remove_validation_strategy($validation_strategy_classname) { |
|
339 | + foreach ($this->_validation_strategies as $key => $validation_strategy) { |
|
340 | + if (is_subclass_of($validation_strategy, $validation_strategy_classname)) { |
|
341 | + unset($this->_validation_strategies[$key]); |
|
342 | 342 | } |
343 | 343 | } |
344 | 344 | } |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | * to the parent form's layout strategy |
348 | 348 | * @return string |
349 | 349 | */ |
350 | - public function get_html_and_js(){ |
|
350 | + public function get_html_and_js() { |
|
351 | 351 | return $this->_parent_section->get_html_for_input($this); |
352 | 352 | } |
353 | 353 | /** |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | * Makes sure the JS and CSS are enqueued for it |
357 | 357 | * @return string |
358 | 358 | */ |
359 | - public function get_html_for_input(){ |
|
359 | + public function get_html_for_input() { |
|
360 | 360 | return $this->_get_display_strategy()->display(); |
361 | 361 | } |
362 | 362 | |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | * @return string |
367 | 367 | */ |
368 | 368 | public function html_other_attributes() { |
369 | - return ! empty( $this->_html_other_attributes ) ? ' ' . $this->_html_other_attributes : ''; |
|
369 | + return ! empty($this->_html_other_attributes) ? ' '.$this->_html_other_attributes : ''; |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | /** |
375 | 375 | * @param string $html_other_attributes |
376 | 376 | */ |
377 | - public function set_html_other_attributes( $html_other_attributes ) { |
|
377 | + public function set_html_other_attributes($html_other_attributes) { |
|
378 | 378 | $this->_html_other_attributes = $html_other_attributes; |
379 | 379 | } |
380 | 380 | |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | * according to the form section's layout strategy |
384 | 384 | * @return string |
385 | 385 | */ |
386 | - public function get_html_for_label(){ |
|
386 | + public function get_html_for_label() { |
|
387 | 387 | return $this->_parent_section->get_layout_strategy()->display_label($this); |
388 | 388 | } |
389 | 389 | /** |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | * according to the form section's layout strategy |
392 | 392 | * @return string |
393 | 393 | */ |
394 | - public function get_html_for_errors(){ |
|
394 | + public function get_html_for_errors() { |
|
395 | 395 | return $this->_parent_section->get_layout_strategy()->display_errors($this); |
396 | 396 | } |
397 | 397 | /** |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | * according to the form section's layout strategy |
400 | 400 | * @return string |
401 | 401 | */ |
402 | - public function get_html_for_help(){ |
|
402 | + public function get_html_for_help() { |
|
403 | 403 | return $this->_parent_section->get_layout_strategy()->display_help_text($this); |
404 | 404 | } |
405 | 405 | /** |
@@ -408,20 +408,20 @@ discard block |
||
408 | 408 | * @return boolean |
409 | 409 | */ |
410 | 410 | protected function _validate() { |
411 | - if(is_array($this->_validation_strategies)){ |
|
412 | - foreach($this->_validation_strategies as $validation_strategy){ |
|
413 | - if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) { |
|
414 | - try{ |
|
411 | + if (is_array($this->_validation_strategies)) { |
|
412 | + foreach ($this->_validation_strategies as $validation_strategy) { |
|
413 | + if ($validation_strategy instanceof EE_Validation_Strategy_Base) { |
|
414 | + try { |
|
415 | 415 | $validation_strategy->validate($this->normalized_value()); |
416 | - }catch(EE_Validation_Error $e){ |
|
416 | + } catch (EE_Validation_Error $e) { |
|
417 | 417 | $this->add_validation_error($e); |
418 | 418 | } |
419 | 419 | } |
420 | 420 | } |
421 | 421 | } |
422 | - if( $this->get_validation_errors()){ |
|
422 | + if ($this->get_validation_errors()) { |
|
423 | 423 | return false; |
424 | - }else{ |
|
424 | + } else { |
|
425 | 425 | return true; |
426 | 426 | } |
427 | 427 | } |
@@ -434,8 +434,8 @@ discard block |
||
434 | 434 | * @param string $value |
435 | 435 | * @return null|string |
436 | 436 | */ |
437 | - private function _sanitize($value){ |
|
438 | - return $value !== NULL ?stripslashes(html_entity_decode($value)) : NULL;//don't sanitize_text_field |
|
437 | + private function _sanitize($value) { |
|
438 | + return $value !== NULL ? stripslashes(html_entity_decode($value)) : NULL; //don't sanitize_text_field |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | |
@@ -447,24 +447,24 @@ discard block |
||
447 | 447 | * @param array $req_data like $_POST |
448 | 448 | * @return boolean whether or not there was an error |
449 | 449 | */ |
450 | - protected function _normalize( $req_data ) { |
|
450 | + protected function _normalize($req_data) { |
|
451 | 451 | //any existing validation errors don't apply so clear them |
452 | 452 | $this->_validation_errors = array(); |
453 | 453 | try { |
454 | - $raw_input = $this->find_form_data_for_this_section( $req_data ); |
|
454 | + $raw_input = $this->find_form_data_for_this_section($req_data); |
|
455 | 455 | //super simple sanitization for now |
456 | - if ( is_array( $raw_input )) { |
|
456 | + if (is_array($raw_input)) { |
|
457 | 457 | $this->_raw_value = array(); |
458 | - foreach( $raw_input as $key => $value ) { |
|
459 | - $this->_raw_value[ $key ] = $this->_sanitize( $value ); |
|
458 | + foreach ($raw_input as $key => $value) { |
|
459 | + $this->_raw_value[$key] = $this->_sanitize($value); |
|
460 | 460 | } |
461 | 461 | } else { |
462 | - $this->_raw_value = $this->_sanitize( $raw_input ); |
|
462 | + $this->_raw_value = $this->_sanitize($raw_input); |
|
463 | 463 | } |
464 | 464 | //we want ot mostly leave the input alone in case we need to re-display it to the user |
465 | - $this->_normalized_value = $this->_normalization_strategy->normalize( $this->raw_value() ); |
|
466 | - } catch ( EE_Validation_Error $e ) { |
|
467 | - $this->add_validation_error( $e ); |
|
465 | + $this->_normalized_value = $this->_normalization_strategy->normalize($this->raw_value()); |
|
466 | + } catch (EE_Validation_Error $e) { |
|
467 | + $this->add_validation_error($e); |
|
468 | 468 | } |
469 | 469 | } |
470 | 470 | |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | /** |
474 | 474 | * @return string |
475 | 475 | */ |
476 | - public function html_name(){ |
|
476 | + public function html_name() { |
|
477 | 477 | return $this->_html_name; |
478 | 478 | } |
479 | 479 | |
@@ -482,8 +482,8 @@ discard block |
||
482 | 482 | /** |
483 | 483 | * @return string |
484 | 484 | */ |
485 | - function html_label_id(){ |
|
486 | - return ! empty( $this->_html_label_id ) ? $this->_html_label_id : $this->_html_id . '-lbl'; |
|
485 | + function html_label_id() { |
|
486 | + return ! empty($this->_html_label_id) ? $this->_html_label_id : $this->_html_id.'-lbl'; |
|
487 | 487 | } |
488 | 488 | |
489 | 489 | |
@@ -491,7 +491,7 @@ discard block |
||
491 | 491 | /** |
492 | 492 | * @return string |
493 | 493 | */ |
494 | - function html_label_class(){ |
|
494 | + function html_label_class() { |
|
495 | 495 | return $this->_html_label_class; |
496 | 496 | } |
497 | 497 | |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | /** |
501 | 501 | * @return string |
502 | 502 | */ |
503 | - function html_label_style(){ |
|
503 | + function html_label_style() { |
|
504 | 504 | return $this->_html_label_style; |
505 | 505 | } |
506 | 506 | |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | /** |
510 | 510 | * @return string |
511 | 511 | */ |
512 | - function html_label_text(){ |
|
512 | + function html_label_text() { |
|
513 | 513 | return $this->_html_label_text; |
514 | 514 | } |
515 | 515 | |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | /** |
519 | 519 | * @return string |
520 | 520 | */ |
521 | - function html_help_text(){ |
|
521 | + function html_help_text() { |
|
522 | 522 | return $this->_html_help_text; |
523 | 523 | } |
524 | 524 | |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | /** |
528 | 528 | * @return string |
529 | 529 | */ |
530 | - function html_help_class(){ |
|
530 | + function html_help_class() { |
|
531 | 531 | return $this->_html_help_class; |
532 | 532 | } |
533 | 533 | |
@@ -536,7 +536,7 @@ discard block |
||
536 | 536 | /** |
537 | 537 | * @return string |
538 | 538 | */ |
539 | - function html_help_style(){ |
|
539 | + function html_help_style() { |
|
540 | 540 | return $this->_html_style; |
541 | 541 | } |
542 | 542 | /** |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | * in which case, we would have stored the malicious content to our database. |
550 | 550 | * @return string |
551 | 551 | */ |
552 | - function raw_value(){ |
|
552 | + function raw_value() { |
|
553 | 553 | return $this->_raw_value; |
554 | 554 | } |
555 | 555 | /** |
@@ -557,15 +557,15 @@ discard block |
||
557 | 557 | * it escapes all html entities |
558 | 558 | * @return string |
559 | 559 | */ |
560 | - function raw_value_in_form(){ |
|
561 | - return htmlentities($this->raw_value(),ENT_QUOTES, 'UTF-8'); |
|
560 | + function raw_value_in_form() { |
|
561 | + return htmlentities($this->raw_value(), ENT_QUOTES, 'UTF-8'); |
|
562 | 562 | } |
563 | 563 | /** |
564 | 564 | * returns the value after it's been sanitized, and then converted into it's proper type |
565 | 565 | * in PHP. Eg, a string, an int, an array, |
566 | 566 | * @return mixed |
567 | 567 | */ |
568 | - function normalized_value(){ |
|
568 | + function normalized_value() { |
|
569 | 569 | return $this->_normalized_value; |
570 | 570 | } |
571 | 571 | |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | * the best thing to display |
576 | 576 | * @return string |
577 | 577 | */ |
578 | - function pretty_value(){ |
|
578 | + function pretty_value() { |
|
579 | 579 | return $this->_normalized_value; |
580 | 580 | } |
581 | 581 | /** |
@@ -594,19 +594,19 @@ discard block |
||
594 | 594 | }</code> |
595 | 595 | * @return array |
596 | 596 | */ |
597 | - function get_jquery_validation_rules(){ |
|
597 | + function get_jquery_validation_rules() { |
|
598 | 598 | |
599 | 599 | $jquery_validation_rules = array(); |
600 | - foreach($this->get_validation_strategies() as $validation_strategy){ |
|
600 | + foreach ($this->get_validation_strategies() as $validation_strategy) { |
|
601 | 601 | $jquery_validation_rules = array_replace_recursive( |
602 | 602 | $jquery_validation_rules, |
603 | 603 | $validation_strategy->get_jquery_validation_rule_array() |
604 | 604 | ); |
605 | 605 | } |
606 | 606 | |
607 | - if(! empty($jquery_validation_rules)){ |
|
608 | - $jquery_validation_js[ $this->html_id( TRUE ) ] = $jquery_validation_rules; |
|
609 | - }else{ |
|
607 | + if ( ! empty($jquery_validation_rules)) { |
|
608 | + $jquery_validation_js[$this->html_id(TRUE)] = $jquery_validation_rules; |
|
609 | + } else { |
|
610 | 610 | return array(); |
611 | 611 | } |
612 | 612 | return $jquery_validation_js; |
@@ -618,9 +618,9 @@ discard block |
||
618 | 618 | * @param mixed $value |
619 | 619 | * @return void |
620 | 620 | */ |
621 | - function set_default($value){ |
|
621 | + function set_default($value) { |
|
622 | 622 | $this->_normalized_value = $value; |
623 | - $this->_raw_value = $this->_normalization_strategy->unnormalize( $value ); |
|
623 | + $this->_raw_value = $this->_normalization_strategy->unnormalize($value); |
|
624 | 624 | } |
625 | 625 | |
626 | 626 | /** |
@@ -628,7 +628,7 @@ discard block |
||
628 | 628 | * @param string $label |
629 | 629 | * @return void |
630 | 630 | */ |
631 | - function set_html_label_text($label){ |
|
631 | + function set_html_label_text($label) { |
|
632 | 632 | $this->_html_label_text = $label; |
633 | 633 | } |
634 | 634 | |
@@ -640,12 +640,12 @@ discard block |
||
640 | 640 | * @param boolean $required |
641 | 641 | * @param null $required_text |
642 | 642 | */ |
643 | - function set_required($required = true, $required_text = NULL ){ |
|
644 | - $required = filter_var( $required, FILTER_VALIDATE_BOOLEAN ); |
|
645 | - if ( $required ) { |
|
646 | - $this->_add_validation_strategy( new EE_Required_Validation_Strategy( $required_text ) ); |
|
643 | + function set_required($required = true, $required_text = NULL) { |
|
644 | + $required = filter_var($required, FILTER_VALIDATE_BOOLEAN); |
|
645 | + if ($required) { |
|
646 | + $this->_add_validation_strategy(new EE_Required_Validation_Strategy($required_text)); |
|
647 | 647 | } else { |
648 | - unset( $this->_validation_strategies[ 'EE_Required_Validation_Strategy' ] ); |
|
648 | + unset($this->_validation_strategies['EE_Required_Validation_Strategy']); |
|
649 | 649 | } |
650 | 650 | $this->_required = $required; |
651 | 651 | } |
@@ -653,7 +653,7 @@ discard block |
||
653 | 653 | * Returns whether or not this field is required |
654 | 654 | * @return boolean |
655 | 655 | */ |
656 | - public function required(){ |
|
656 | + public function required() { |
|
657 | 657 | return $this->_required; |
658 | 658 | } |
659 | 659 | |
@@ -662,7 +662,7 @@ discard block |
||
662 | 662 | /** |
663 | 663 | * @param string $required_css_class |
664 | 664 | */ |
665 | - public function set_required_css_class( $required_css_class ) { |
|
665 | + public function set_required_css_class($required_css_class) { |
|
666 | 666 | $this->_required_css_class = $required_css_class; |
667 | 667 | } |
668 | 668 | |
@@ -681,7 +681,7 @@ discard block |
||
681 | 681 | * Sets the help text, in case |
682 | 682 | * @param string $text |
683 | 683 | */ |
684 | - public function set_html_help_text($text){ |
|
684 | + public function set_html_help_text($text) { |
|
685 | 685 | $this->_html_help_text = $text; |
686 | 686 | } |
687 | 687 | /** |
@@ -693,8 +693,8 @@ discard block |
||
693 | 693 | public function clean_sensitive_data() { |
694 | 694 | //if we do ANY kind of sensitive data removal on this, then just clear out the raw value |
695 | 695 | //if we need more logic than this we'll make a strategy for it |
696 | - if( $this->_sensitive_data_removal_strategy && |
|
697 | - ! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal ){ |
|
696 | + if ($this->_sensitive_data_removal_strategy && |
|
697 | + ! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal) { |
|
698 | 698 | $this->_raw_value = NULL; |
699 | 699 | } |
700 | 700 | //and clean the normalized value according to the appropriate strategy |
@@ -708,10 +708,10 @@ discard block |
||
708 | 708 | * @param string $button_size |
709 | 709 | * @param string $other_attributes |
710 | 710 | */ |
711 | - public function set_button_css_attributes( $primary = TRUE, $button_size = '', $other_attributes = '' ) { |
|
711 | + public function set_button_css_attributes($primary = TRUE, $button_size = '', $other_attributes = '') { |
|
712 | 712 | $button_css_attributes = 'button'; |
713 | 713 | $button_css_attributes .= $primary === TRUE ? ' button-primary' : ' button-secondary'; |
714 | - switch ( $button_size ) { |
|
714 | + switch ($button_size) { |
|
715 | 715 | case 'xs' : |
716 | 716 | case 'extra-small' : |
717 | 717 | $button_css_attributes .= ' button-xs'; |
@@ -732,7 +732,7 @@ discard block |
||
732 | 732 | default : |
733 | 733 | $button_css_attributes .= ''; |
734 | 734 | } |
735 | - $this->_button_css_attributes .= ! empty( $other_attributes ) ? $button_css_attributes . ' ' . $other_attributes : $button_css_attributes; |
|
735 | + $this->_button_css_attributes .= ! empty($other_attributes) ? $button_css_attributes.' '.$other_attributes : $button_css_attributes; |
|
736 | 736 | } |
737 | 737 | |
738 | 738 | |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | * @return string |
742 | 742 | */ |
743 | 743 | public function button_css_attributes() { |
744 | - if ( empty( $this->_button_css_attributes )) { |
|
744 | + if (empty($this->_button_css_attributes)) { |
|
745 | 745 | $this->set_button_css_attributes(); |
746 | 746 | } |
747 | 747 | return $this->_button_css_attributes; |
@@ -761,27 +761,27 @@ discard block |
||
761 | 761 | * @param array $req_data |
762 | 762 | * @return mixed whatever the raw value of this form section is in the request data |
763 | 763 | */ |
764 | - public function find_form_data_for_this_section( $req_data ){ |
|
764 | + public function find_form_data_for_this_section($req_data) { |
|
765 | 765 | // break up the html name by "[]" |
766 | - if ( strpos( $this->html_name(), '[' ) !== FALSE ) { |
|
767 | - $before_any_brackets = substr( $this->html_name(), 0, strpos($this->html_name(), '[') ); |
|
766 | + if (strpos($this->html_name(), '[') !== FALSE) { |
|
767 | + $before_any_brackets = substr($this->html_name(), 0, strpos($this->html_name(), '[')); |
|
768 | 768 | } else { |
769 | 769 | $before_any_brackets = $this->html_name(); |
770 | 770 | } |
771 | 771 | // grab all of the segments |
772 | - preg_match_all('~\[([^]]*)\]~',$this->html_name(), $matches); |
|
773 | - if( isset( $matches[ 1 ] ) && is_array( $matches[ 1 ] ) ){ |
|
774 | - $name_parts = $matches[ 1 ]; |
|
772 | + preg_match_all('~\[([^]]*)\]~', $this->html_name(), $matches); |
|
773 | + if (isset($matches[1]) && is_array($matches[1])) { |
|
774 | + $name_parts = $matches[1]; |
|
775 | 775 | array_unshift($name_parts, $before_any_brackets); |
776 | - }else{ |
|
777 | - $name_parts = array( $before_any_brackets ); |
|
776 | + } else { |
|
777 | + $name_parts = array($before_any_brackets); |
|
778 | 778 | } |
779 | 779 | // now get the value for the input |
780 | 780 | $value = $this->_find_form_data_for_this_section_using_name_parts($name_parts, $req_data); |
781 | - if( $value === NULL ){ |
|
781 | + if ($value === NULL) { |
|
782 | 782 | //check if this thing's name is at the TOP level of the request data |
783 | - if( isset( $req_data[ $this->name() ] ) ){ |
|
784 | - $value = $req_data[ $this->name() ]; |
|
783 | + if (isset($req_data[$this->name()])) { |
|
784 | + $value = $req_data[$this->name()]; |
|
785 | 785 | } |
786 | 786 | } |
787 | 787 | return $value; |
@@ -795,15 +795,15 @@ discard block |
||
795 | 795 | * @param array $req_data |
796 | 796 | * @return array | NULL |
797 | 797 | */ |
798 | - public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data){ |
|
799 | - $first_part_to_consider = array_shift( $html_name_parts ); |
|
800 | - if( isset( $req_data[ $first_part_to_consider ] ) ){ |
|
801 | - if( empty($html_name_parts ) ){ |
|
802 | - return $req_data[ $first_part_to_consider ]; |
|
803 | - }else{ |
|
804 | - return $this->_find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data[ $first_part_to_consider ] ); |
|
798 | + public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data) { |
|
799 | + $first_part_to_consider = array_shift($html_name_parts); |
|
800 | + if (isset($req_data[$first_part_to_consider])) { |
|
801 | + if (empty($html_name_parts)) { |
|
802 | + return $req_data[$first_part_to_consider]; |
|
803 | + } else { |
|
804 | + return $this->_find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data[$first_part_to_consider]); |
|
805 | 805 | } |
806 | - }else{ |
|
806 | + } else { |
|
807 | 807 | return NULL; |
808 | 808 | } |
809 | 809 | } |
@@ -815,14 +815,14 @@ discard block |
||
815 | 815 | * @param array $req_data like $_POST |
816 | 816 | * @return boolean |
817 | 817 | */ |
818 | - public function form_data_present_in($req_data = NULL){ |
|
819 | - if( $req_data === NULL ){ |
|
818 | + public function form_data_present_in($req_data = NULL) { |
|
819 | + if ($req_data === NULL) { |
|
820 | 820 | $req_data = $_POST; |
821 | 821 | } |
822 | - $checked_value = $this->find_form_data_for_this_section( $req_data ); |
|
823 | - if( $checked_value !== null ){ |
|
822 | + $checked_value = $this->find_form_data_for_this_section($req_data); |
|
823 | + if ($checked_value !== null) { |
|
824 | 824 | return TRUE; |
825 | - }else{ |
|
825 | + } else { |
|
826 | 826 | return FALSE; |
827 | 827 | } |
828 | 828 | } |
@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
2 | 2 | /** |
3 | - * EE_Email_Input |
|
4 | - * |
|
5 | - * @package Event Espresso |
|
6 | - * @subpackage |
|
7 | - * @author Mike Nelson |
|
8 | - */ |
|
3 | + * EE_Email_Input |
|
4 | + * |
|
5 | + * @package Event Espresso |
|
6 | + * @subpackage |
|
7 | + * @author Mike Nelson |
|
8 | + */ |
|
9 | 9 | class EE_Email_Input extends EE_Form_Input_Base{ |
10 | 10 | |
11 | 11 | /** |
@@ -6,22 +6,22 @@ |
||
6 | 6 | * @subpackage |
7 | 7 | * @author Mike Nelson |
8 | 8 | */ |
9 | -class EE_Email_Input extends EE_Form_Input_Base{ |
|
9 | +class EE_Email_Input extends EE_Form_Input_Base { |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * @param array $input_settings |
13 | 13 | */ |
14 | - function __construct( $input_settings = array() ){ |
|
15 | - $this->_set_display_strategy( new EE_Text_Input_Display_Strategy('email') ); |
|
16 | - $this->_set_normalization_strategy( new EE_Text_Normalization() ); |
|
14 | + function __construct($input_settings = array()) { |
|
15 | + $this->_set_display_strategy(new EE_Text_Input_Display_Strategy('email')); |
|
16 | + $this->_set_normalization_strategy(new EE_Text_Normalization()); |
|
17 | 17 | $this->_add_validation_strategy( |
18 | 18 | new EE_Email_Validation_Strategy( |
19 | - isset( $input_settings[ 'validation_error_message' ] ) |
|
20 | - ? $input_settings[ 'validation_error_message' ] |
|
19 | + isset($input_settings['validation_error_message']) |
|
20 | + ? $input_settings['validation_error_message'] |
|
21 | 21 | : NULL |
22 | 22 | ) |
23 | 23 | ); |
24 | - parent::__construct( $input_settings ); |
|
25 | - $this->set_html_class( $this->html_class() . ' email' ); |
|
24 | + parent::__construct($input_settings); |
|
25 | + $this->set_html_class($this->html_class().' email'); |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | \ No newline at end of file |
@@ -1,21 +1,21 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
2 | 2 | EE_Registry::instance()->load_class( 'Processor_Base' ); |
3 | 3 | /** |
4 | - * |
|
5 | - * EE_Payment_Processor |
|
6 | - * |
|
7 | - * Class for handling processing of payments for transactions. |
|
8 | - * |
|
9 | - * @package Event Espresso |
|
10 | - * @subpackage core/libraries/payment_methods |
|
11 | - * @author Mike Nelson |
|
12 | - * |
|
13 | - */ |
|
4 | + * |
|
5 | + * EE_Payment_Processor |
|
6 | + * |
|
7 | + * Class for handling processing of payments for transactions. |
|
8 | + * |
|
9 | + * @package Event Espresso |
|
10 | + * @subpackage core/libraries/payment_methods |
|
11 | + * @author Mike Nelson |
|
12 | + * |
|
13 | + */ |
|
14 | 14 | class EE_Payment_Processor extends EE_Processor_Base { |
15 | 15 | /** |
16 | - * @var EE_Payment_Processor $_instance |
|
16 | + * @var EE_Payment_Processor $_instance |
|
17 | 17 | * @access private |
18 | - */ |
|
18 | + */ |
|
19 | 19 | private static $_instance = NULL; |
20 | 20 | |
21 | 21 | |
@@ -48,9 +48,8 @@ discard block |
||
48 | 48 | |
49 | 49 | |
50 | 50 | /** |
51 | - |
|
52 | 51 | * Using the selected gateway, processes the payment for that transaction, and updates the transaction appropriately. |
53 | - * Saves the payment that is generated |
|
52 | + * Saves the payment that is generated |
|
54 | 53 | * |
55 | 54 | * @param EE_Payment_Method $payment_method |
56 | 55 | * @param EE_Transaction $transaction |
@@ -1,5 +1,5 @@ discard block |
||
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 | * EE_Payment_Processor |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public static function instance() { |
29 | 29 | // check if class object is instantiated |
30 | - if ( ! self::$_instance instanceof EE_Payment_Processor ) { |
|
30 | + if ( ! self::$_instance instanceof EE_Payment_Processor) { |
|
31 | 31 | self::$_instance = new self(); |
32 | 32 | } |
33 | 33 | return self::$_instance; |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | *@return EE_Payment_Processor |
43 | 43 | */ |
44 | 44 | private function __construct() { |
45 | - do_action( 'AHEE__EE_Payment_Processor__construct' ); |
|
45 | + do_action('AHEE__EE_Payment_Processor__construct'); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | |
@@ -64,42 +64,42 @@ discard block |
||
64 | 64 | * @param string $cancel_url URL to return to if off-site payments are cancelled |
65 | 65 | * @return EE_Payment |
66 | 66 | */ |
67 | - public function process_payment( EE_Payment_Method $payment_method, EE_Transaction $transaction, $amount = NULL, $billing_form = NULL, $return_url = NULL, $method = 'CART', $by_admin = FALSE, $update_txn = TRUE, $cancel_url = '' ) { |
|
68 | - if( $amount < 0 ) { |
|
67 | + public function process_payment(EE_Payment_Method $payment_method, EE_Transaction $transaction, $amount = NULL, $billing_form = NULL, $return_url = NULL, $method = 'CART', $by_admin = FALSE, $update_txn = TRUE, $cancel_url = '') { |
|
68 | + if ($amount < 0) { |
|
69 | 69 | throw new EE_Error( |
70 | 70 | sprintf( |
71 | - __( 'Attempting to make a payment for a negative amount of %1$d for transaction %2$d. That should be a refund', 'event_espresso' ), |
|
71 | + __('Attempting to make a payment for a negative amount of %1$d for transaction %2$d. That should be a refund', 'event_espresso'), |
|
72 | 72 | $amount, |
73 | 73 | $transaction->ID() ) ); |
74 | 74 | } |
75 | 75 | // verify payment method |
76 | - $payment_method = EEM_Payment_Method::instance()->ensure_is_obj( $payment_method, TRUE ); |
|
76 | + $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method, TRUE); |
|
77 | 77 | // verify transaction |
78 | - EEM_Transaction::instance()->ensure_is_obj( $transaction ); |
|
79 | - $transaction->set_payment_method_ID( $payment_method->ID() ); |
|
78 | + EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
79 | + $transaction->set_payment_method_ID($payment_method->ID()); |
|
80 | 80 | // verify payment method type |
81 | - if ( $payment_method->type_obj() instanceof EE_PMT_Base ){ |
|
81 | + if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
|
82 | 82 | $payment = $payment_method->type_obj()->process_payment( |
83 | 83 | $transaction, |
84 | - min( $amount, $transaction->remaining() ),//make sure we don't overcharge |
|
84 | + min($amount, $transaction->remaining()), //make sure we don't overcharge |
|
85 | 85 | $billing_form, |
86 | 86 | $return_url, |
87 | - add_query_arg( array( 'ee_cancel_payment' => true ), $cancel_url ), |
|
87 | + add_query_arg(array('ee_cancel_payment' => true), $cancel_url), |
|
88 | 88 | $method, |
89 | 89 | $by_admin |
90 | 90 | ); |
91 | 91 | // check if payment method uses an off-site gateway |
92 | - if ( $payment_method->type_obj()->payment_occurs() != EE_PMT_Base::offsite ) { |
|
92 | + if ($payment_method->type_obj()->payment_occurs() != EE_PMT_Base::offsite) { |
|
93 | 93 | // don't process payments for off-site gateways yet because no payment has occurred yet |
94 | - $this->update_txn_based_on_payment( $transaction, $payment, $update_txn ); |
|
94 | + $this->update_txn_based_on_payment($transaction, $payment, $update_txn); |
|
95 | 95 | } |
96 | 96 | return $payment; |
97 | 97 | } else { |
98 | 98 | EE_Error::add_error( |
99 | 99 | sprintf( |
100 | - __( 'A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
100 | + __('A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
101 | 101 | '<br/>', |
102 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
102 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
103 | 103 | ), __FILE__, __FUNCTION__, __LINE__ |
104 | 104 | ); |
105 | 105 | return NULL; |
@@ -115,14 +115,14 @@ discard block |
||
115 | 115 | * @throws EE_Error |
116 | 116 | * @return string |
117 | 117 | */ |
118 | - public function get_ipn_url_for_payment_method( $transaction, $payment_method ){ |
|
118 | + public function get_ipn_url_for_payment_method($transaction, $payment_method) { |
|
119 | 119 | /** @type EE_Transaction $transaction */ |
120 | - $transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction ); |
|
120 | + $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
121 | 121 | $primary_reg = $transaction->primary_registration(); |
122 | - if( ! $primary_reg instanceof EE_Registration ){ |
|
123 | - throw new EE_Error(sprintf(__("Cannot get IPN URL for transaction with ID %d because it has no primary registration", "event_espresso"),$transaction->ID())); |
|
122 | + if ( ! $primary_reg instanceof EE_Registration) { |
|
123 | + throw new EE_Error(sprintf(__("Cannot get IPN URL for transaction with ID %d because it has no primary registration", "event_espresso"), $transaction->ID())); |
|
124 | 124 | } |
125 | - $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method,true); |
|
125 | + $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method, true); |
|
126 | 126 | $url = add_query_arg( |
127 | 127 | array( |
128 | 128 | 'e_reg_url_link'=>$primary_reg->reg_url_link(), |
@@ -149,81 +149,81 @@ discard block |
||
149 | 149 | * @throws Exception |
150 | 150 | * @return EE_Payment |
151 | 151 | */ |
152 | - public function process_ipn( $_req_data, $transaction = NULL, $payment_method = NULL, $update_txn = true, $separate_IPN_request = true ){ |
|
153 | - $_req_data = $this->_remove_unusable_characters( $_req_data ); |
|
154 | - EE_Registry::instance()->load_model( 'Change_Log' ); |
|
155 | - EE_Processor_Base::set_IPN( $separate_IPN_request ); |
|
156 | - if( $transaction instanceof EE_Transaction && $payment_method instanceof EE_Payment_Method ){ |
|
157 | - $obj_for_log = EEM_Payment::instance()->get_one( array( array( 'TXN_ID' => $transaction->ID(), 'PMD_ID' => $payment_method->ID() ), 'order_by' => array( 'PAY_timestamp' => 'desc' ) ) ); |
|
158 | - }elseif( $payment_method instanceof EE_Payment ){ |
|
152 | + public function process_ipn($_req_data, $transaction = NULL, $payment_method = NULL, $update_txn = true, $separate_IPN_request = true) { |
|
153 | + $_req_data = $this->_remove_unusable_characters($_req_data); |
|
154 | + EE_Registry::instance()->load_model('Change_Log'); |
|
155 | + EE_Processor_Base::set_IPN($separate_IPN_request); |
|
156 | + if ($transaction instanceof EE_Transaction && $payment_method instanceof EE_Payment_Method) { |
|
157 | + $obj_for_log = EEM_Payment::instance()->get_one(array(array('TXN_ID' => $transaction->ID(), 'PMD_ID' => $payment_method->ID()), 'order_by' => array('PAY_timestamp' => 'desc'))); |
|
158 | + }elseif ($payment_method instanceof EE_Payment) { |
|
159 | 159 | $obj_for_log = $payment_method; |
160 | - }elseif( $transaction instanceof EE_Transaction ){ |
|
160 | + }elseif ($transaction instanceof EE_Transaction) { |
|
161 | 161 | $obj_for_log = $transaction; |
162 | - }else{ |
|
162 | + } else { |
|
163 | 163 | $obj_for_log = null; |
164 | 164 | } |
165 | 165 | $log = EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data received'=>$_req_data), $obj_for_log); |
166 | - try{ |
|
166 | + try { |
|
167 | 167 | /** |
168 | 168 | * @var EE_Payment $payment |
169 | 169 | */ |
170 | 170 | $payment = NULL; |
171 | - if($transaction && $payment_method){ |
|
171 | + if ($transaction && $payment_method) { |
|
172 | 172 | /** @type EE_Transaction $transaction */ |
173 | 173 | $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
174 | 174 | /** @type EE_Payment_Method $payment_method */ |
175 | 175 | $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method); |
176 | - if ( $payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
177 | - $payment = $payment_method->type_obj()->handle_ipn( $_req_data, $transaction ); |
|
176 | + if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
|
177 | + $payment = $payment_method->type_obj()->handle_ipn($_req_data, $transaction); |
|
178 | 178 | $log->set_object($payment); |
179 | 179 | } else { |
180 | 180 | // not a payment |
181 | 181 | EE_Error::add_error( |
182 | 182 | sprintf( |
183 | - __( 'A valid payment method could not be determined due to a technical issue.%sPlease refresh your browser and try again or contact %s for assistance.', 'event_espresso' ), |
|
183 | + __('A valid payment method could not be determined due to a technical issue.%sPlease refresh your browser and try again or contact %s for assistance.', 'event_espresso'), |
|
184 | 184 | '<br/>', |
185 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
185 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
186 | 186 | ), |
187 | 187 | __FILE__, __FUNCTION__, __LINE__ |
188 | 188 | ); |
189 | 189 | } |
190 | - }else{ |
|
190 | + } else { |
|
191 | 191 | //that's actually pretty ok. The IPN just wasn't able |
192 | 192 | //to identify which transaction or payment method this was for |
193 | 193 | // give all active payment methods a chance to claim it |
194 | 194 | $active_pms = EEM_Payment_Method::instance()->get_all_active(); |
195 | - foreach( $active_pms as $payment_method ){ |
|
196 | - try{ |
|
197 | - $payment = $payment_method->type_obj()->handle_unclaimed_ipn( $_req_data ); |
|
195 | + foreach ($active_pms as $payment_method) { |
|
196 | + try { |
|
197 | + $payment = $payment_method->type_obj()->handle_unclaimed_ipn($_req_data); |
|
198 | 198 | EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $payment); |
199 | 199 | break; |
200 | - } catch( EE_Error $e ) { |
|
200 | + } catch (EE_Error $e) { |
|
201 | 201 | //that's fine- it apparently couldn't handle the IPN |
202 | 202 | } |
203 | 203 | } |
204 | 204 | |
205 | 205 | } |
206 | 206 | // EEM_Payment_Log::instance()->log("got to 7",$transaction,$payment_method); |
207 | - if( $payment instanceof EE_Payment){ |
|
207 | + if ($payment instanceof EE_Payment) { |
|
208 | 208 | $payment->save(); |
209 | 209 | // update the TXN |
210 | - $this->update_txn_based_on_payment( $transaction, $payment, $update_txn, $separate_IPN_request ); |
|
211 | - }else{ |
|
210 | + $this->update_txn_based_on_payment($transaction, $payment, $update_txn, $separate_IPN_request); |
|
211 | + } else { |
|
212 | 212 | //we couldn't find the payment for this IPN... let's try and log at least SOMETHING |
213 | - if($payment_method){ |
|
213 | + if ($payment_method) { |
|
214 | 214 | EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $payment_method); |
215 | - }elseif($transaction){ |
|
215 | + }elseif ($transaction) { |
|
216 | 216 | EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $transaction); |
217 | 217 | } |
218 | 218 | } |
219 | 219 | return $payment; |
220 | 220 | |
221 | - } catch( EE_Error $e ) { |
|
221 | + } catch (EE_Error $e) { |
|
222 | 222 | do_action( |
223 | 223 | 'AHEE__log', __FILE__, __FUNCTION__, sprintf( |
224 | - __( 'Error occurred while receiving IPN. Transaction: %1$s, req data: %2$s. The error was "%3$s"', 'event_espresso' ), |
|
225 | - print_r( $transaction, TRUE ), |
|
226 | - print_r( $_req_data, TRUE ), |
|
224 | + __('Error occurred while receiving IPN. Transaction: %1$s, req data: %2$s. The error was "%3$s"', 'event_espresso'), |
|
225 | + print_r($transaction, TRUE), |
|
226 | + print_r($_req_data, TRUE), |
|
227 | 227 | $e->getMessage() |
228 | 228 | ) |
229 | 229 | ); |
@@ -237,14 +237,14 @@ discard block |
||
237 | 237 | * @param array $request_data |
238 | 238 | * @return array|string |
239 | 239 | */ |
240 | - protected function _remove_unusable_characters( $request_data ) { |
|
241 | - if( is_array( $request_data ) ) { |
|
240 | + protected function _remove_unusable_characters($request_data) { |
|
241 | + if (is_array($request_data)) { |
|
242 | 242 | $return_data = array(); |
243 | - foreach( $request_data as $key => $value ) { |
|
244 | - $return_data[ $this->_remove_unusable_characters( $key ) ] = $this->_remove_unusable_characters( $value ); |
|
243 | + foreach ($request_data as $key => $value) { |
|
244 | + $return_data[$this->_remove_unusable_characters($key)] = $this->_remove_unusable_characters($value); |
|
245 | 245 | } |
246 | - }else{ |
|
247 | - $return_data = preg_replace('/[^[:print:]]/', '', $request_data); |
|
246 | + } else { |
|
247 | + $return_data = preg_replace('/[^[:print:]]/', '', $request_data); |
|
248 | 248 | } |
249 | 249 | return $return_data; |
250 | 250 | } |
@@ -266,13 +266,13 @@ discard block |
||
266 | 266 | * @return EE_Payment |
267 | 267 | * @deprecated 4.6.24 method is no longer used. Instead it is up to client code, like SPCO, to call handle_ipn() for offsite gateways that don't receive separate IPNs |
268 | 268 | */ |
269 | - public function finalize_payment_for( $transaction, $update_txn = TRUE ){ |
|
269 | + public function finalize_payment_for($transaction, $update_txn = TRUE) { |
|
270 | 270 | /** @var $transaction EE_Transaction */ |
271 | - $transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction ); |
|
271 | + $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
272 | 272 | $last_payment_method = $transaction->payment_method(); |
273 | - if ( $last_payment_method instanceof EE_Payment_Method ) { |
|
274 | - $payment = $last_payment_method->type_obj()->finalize_payment_for( $transaction ); |
|
275 | - $this->update_txn_based_on_payment( $transaction, $payment, $update_txn ); |
|
273 | + if ($last_payment_method instanceof EE_Payment_Method) { |
|
274 | + $payment = $last_payment_method->type_obj()->finalize_payment_for($transaction); |
|
275 | + $this->update_txn_based_on_payment($transaction, $payment, $update_txn); |
|
276 | 276 | return $payment; |
277 | 277 | } else { |
278 | 278 | return NULL; |
@@ -289,10 +289,10 @@ discard block |
||
289 | 289 | * @internal param float $amount |
290 | 290 | * @return EE_Payment |
291 | 291 | */ |
292 | - public function process_refund( EE_Payment_Method $payment_method, EE_Payment $payment_to_refund, $refund_info = array() ){ |
|
293 | - if ( $payment_method instanceof EE_Payment_Method && $payment_method->type_obj()->supports_sending_refunds() ) { |
|
294 | - $payment_method->type_obj()->process_refund( $payment_to_refund, $refund_info ); |
|
295 | - $this->update_txn_based_on_payment( $payment_to_refund->transaction(), $payment_to_refund ); |
|
292 | + public function process_refund(EE_Payment_Method $payment_method, EE_Payment $payment_to_refund, $refund_info = array()) { |
|
293 | + if ($payment_method instanceof EE_Payment_Method && $payment_method->type_obj()->supports_sending_refunds()) { |
|
294 | + $payment_method->type_obj()->process_refund($payment_to_refund, $refund_info); |
|
295 | + $this->update_txn_based_on_payment($payment_to_refund->transaction(), $payment_to_refund); |
|
296 | 296 | } |
297 | 297 | return $payment_to_refund; |
298 | 298 | } |
@@ -334,12 +334,12 @@ discard block |
||
334 | 334 | * TXN is locked before updating |
335 | 335 | * @throws \EE_Error |
336 | 336 | */ |
337 | - public function update_txn_based_on_payment( $transaction, $payment, $update_txn = true, $IPN = false ){ |
|
337 | + public function update_txn_based_on_payment($transaction, $payment, $update_txn = true, $IPN = false) { |
|
338 | 338 | $do_action = 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__not_successful'; |
339 | 339 | /** @type EE_Transaction $transaction */ |
340 | - $transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction ); |
|
340 | + $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
341 | 341 | // can we freely update the TXN at this moment? |
342 | - if ( $IPN && $transaction->is_locked() ) { |
|
342 | + if ($IPN && $transaction->is_locked()) { |
|
343 | 343 | // don't update the transaction at this exact moment |
344 | 344 | // because the TXN is active in another request |
345 | 345 | EE_Cron_Tasks::schedule_update_transaction_with_payment( |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | ); |
350 | 350 | } else { |
351 | 351 | // verify payment and that it has been saved |
352 | - if ( $payment instanceof EE_Payment && $payment->ID() ) { |
|
352 | + if ($payment instanceof EE_Payment && $payment->ID()) { |
|
353 | 353 | //$this->log( |
354 | 354 | // __CLASS__, __FUNCTION__, __LINE__, |
355 | 355 | // $payment->transaction(), |
@@ -358,8 +358,8 @@ discard block |
||
358 | 358 | // 'payment' => $payment, |
359 | 359 | // ) |
360 | 360 | //); |
361 | - if( $payment->payment_method() instanceof EE_Payment_Method && $payment->payment_method()->type_obj() instanceof EE_PMT_Base ){ |
|
362 | - $payment->payment_method()->type_obj()->update_txn_based_on_payment( $payment ); |
|
361 | + if ($payment->payment_method() instanceof EE_Payment_Method && $payment->payment_method()->type_obj() instanceof EE_PMT_Base) { |
|
362 | + $payment->payment_method()->type_obj()->update_txn_based_on_payment($payment); |
|
363 | 363 | //$this->log( |
364 | 364 | // __CLASS__, __FUNCTION__, __LINE__, |
365 | 365 | // $payment->transaction(), |
@@ -368,36 +368,36 @@ discard block |
||
368 | 368 | // ) |
369 | 369 | //); |
370 | 370 | // update TXN registrations with payment info |
371 | - $this->process_registration_payments( $transaction, $payment ); |
|
371 | + $this->process_registration_payments($transaction, $payment); |
|
372 | 372 | } |
373 | 373 | $do_action = $payment->just_approved() ? 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__successful' : $do_action; |
374 | 374 | } else { |
375 | 375 | // send out notifications |
376 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true' ); |
|
376 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true'); |
|
377 | 377 | $do_action = 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__no_payment_made'; |
378 | 378 | } |
379 | 379 | // if this is an IPN, then we want to know the initial TXN status prior to updating the TXN |
380 | 380 | // so that we know whether the status has changed and notifications should be triggered |
381 | - if ( $IPN ) { |
|
381 | + if ($IPN) { |
|
382 | 382 | /** @type EE_Transaction_Processor $transaction_processor */ |
383 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
384 | - $transaction_processor->set_old_txn_status( $transaction->status_ID() ); |
|
383 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
384 | + $transaction_processor->set_old_txn_status($transaction->status_ID()); |
|
385 | 385 | } |
386 | - if ( $payment->status() !== EEM_Payment::status_id_failed ) { |
|
386 | + if ($payment->status() !== EEM_Payment::status_id_failed) { |
|
387 | 387 | /** @type EE_Transaction_Payments $transaction_payments */ |
388 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
388 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
389 | 389 | // set new value for total paid |
390 | - $transaction_payments->calculate_total_payments_and_update_status( $transaction ); |
|
390 | + $transaction_payments->calculate_total_payments_and_update_status($transaction); |
|
391 | 391 | // call EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment() ??? |
392 | - if ( $update_txn ) { |
|
393 | - $this->_post_payment_processing( $transaction, $payment, $IPN ); |
|
392 | + if ($update_txn) { |
|
393 | + $this->_post_payment_processing($transaction, $payment, $IPN); |
|
394 | 394 | } |
395 | 395 | } |
396 | 396 | // granular hook for others to use. |
397 | - do_action( $do_action, $transaction, $payment ); |
|
398 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $do_action, '$do_action' ); |
|
397 | + do_action($do_action, $transaction, $payment); |
|
398 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $do_action, '$do_action'); |
|
399 | 399 | //global hook for others to use. |
400 | - do_action( 'AHEE__EE_Payment_Processor__update_txn_based_on_payment', $transaction, $payment ); |
|
400 | + do_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', $transaction, $payment); |
|
401 | 401 | } |
402 | 402 | } |
403 | 403 | |
@@ -411,25 +411,25 @@ discard block |
||
411 | 411 | * @param EE_Registration[] $registrations |
412 | 412 | * @throws \EE_Error |
413 | 413 | */ |
414 | - public function process_registration_payments( EE_Transaction $transaction, EE_Payment $payment, $registrations = array() ) { |
|
414 | + public function process_registration_payments(EE_Transaction $transaction, EE_Payment $payment, $registrations = array()) { |
|
415 | 415 | // only process if payment was successful |
416 | - if ( $payment->status() !== EEM_Payment::status_id_approved ) { |
|
416 | + if ($payment->status() !== EEM_Payment::status_id_approved) { |
|
417 | 417 | return; |
418 | 418 | } |
419 | 419 | //EEM_Registration::instance()->show_next_x_db_queries(); |
420 | - if ( empty( $registrations )) { |
|
420 | + if (empty($registrations)) { |
|
421 | 421 | // find registrations with monies owing that can receive a payment |
422 | - $registrations = $transaction->registrations( array( |
|
422 | + $registrations = $transaction->registrations(array( |
|
423 | 423 | array( |
424 | 424 | // only these reg statuses can receive payments |
425 | - 'STS_ID' => array( 'IN', EEM_Registration::reg_statuses_that_allow_payment() ), |
|
426 | - 'REG_final_price' => array( '!=', 0 ), |
|
427 | - 'REG_final_price*' => array( '!=', 'REG_paid', true ), |
|
425 | + 'STS_ID' => array('IN', EEM_Registration::reg_statuses_that_allow_payment()), |
|
426 | + 'REG_final_price' => array('!=', 0), |
|
427 | + 'REG_final_price*' => array('!=', 'REG_paid', true), |
|
428 | 428 | ) |
429 | - ) ); |
|
429 | + )); |
|
430 | 430 | } |
431 | 431 | // still nothing ??!?? |
432 | - if ( empty( $registrations )) { |
|
432 | + if (empty($registrations)) { |
|
433 | 433 | return; |
434 | 434 | } |
435 | 435 | // todo: break out the following logic into a separate strategy class |
@@ -441,28 +441,28 @@ discard block |
||
441 | 441 | |
442 | 442 | $refund = $payment->is_a_refund(); |
443 | 443 | // how much is available to apply to registrations? |
444 | - $available_payment_amount = abs( $payment->amount() ); |
|
445 | - foreach ( $registrations as $registration ) { |
|
446 | - if ( $registration instanceof EE_Registration ) { |
|
444 | + $available_payment_amount = abs($payment->amount()); |
|
445 | + foreach ($registrations as $registration) { |
|
446 | + if ($registration instanceof EE_Registration) { |
|
447 | 447 | // nothing left? |
448 | - if ( $available_payment_amount <= 0 ) { |
|
448 | + if ($available_payment_amount <= 0) { |
|
449 | 449 | break; |
450 | 450 | } |
451 | - if ( $refund ) { |
|
452 | - $available_payment_amount = $this->process_registration_refund( $registration, $payment, $available_payment_amount ); |
|
451 | + if ($refund) { |
|
452 | + $available_payment_amount = $this->process_registration_refund($registration, $payment, $available_payment_amount); |
|
453 | 453 | } else { |
454 | - $available_payment_amount = $this->process_registration_payment( $registration, $payment, $available_payment_amount ); |
|
454 | + $available_payment_amount = $this->process_registration_payment($registration, $payment, $available_payment_amount); |
|
455 | 455 | } |
456 | 456 | } |
457 | 457 | } |
458 | - if ( $available_payment_amount > 0 && apply_filters( 'FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', false ) ) { |
|
458 | + if ($available_payment_amount > 0 && apply_filters('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', false)) { |
|
459 | 459 | EE_Error::add_attention( |
460 | 460 | sprintf( |
461 | - __( 'A remainder of %1$s exists after applying this payment to Registration(s) %2$s.%3$sPlease verify that the original payment amount of %4$s is correct. If so, you should edit this payment and select at least one additional registration in the "Registrations to Apply Payment to" section, so that the remainder of this payment can be applied to the additional registration(s).', 'event_espresso' ), |
|
462 | - EEH_Template::format_currency( $available_payment_amount ), |
|
463 | - implode( ', ', array_keys( $registrations ) ), |
|
461 | + __('A remainder of %1$s exists after applying this payment to Registration(s) %2$s.%3$sPlease verify that the original payment amount of %4$s is correct. If so, you should edit this payment and select at least one additional registration in the "Registrations to Apply Payment to" section, so that the remainder of this payment can be applied to the additional registration(s).', 'event_espresso'), |
|
462 | + EEH_Template::format_currency($available_payment_amount), |
|
463 | + implode(', ', array_keys($registrations)), |
|
464 | 464 | '<br/>', |
465 | - EEH_Template::format_currency( $payment->amount() ) |
|
465 | + EEH_Template::format_currency($payment->amount()) |
|
466 | 466 | ), |
467 | 467 | __FILE__, __FUNCTION__, __LINE__ |
468 | 468 | ); |
@@ -479,17 +479,17 @@ discard block |
||
479 | 479 | * @param float $available_payment_amount |
480 | 480 | * @return float |
481 | 481 | */ |
482 | - public function process_registration_payment( EE_Registration $registration, EE_Payment $payment, $available_payment_amount = 0.00 ) { |
|
482 | + public function process_registration_payment(EE_Registration $registration, EE_Payment $payment, $available_payment_amount = 0.00) { |
|
483 | 483 | $owing = $registration->final_price() - $registration->paid(); |
484 | - if ( $owing > 0 ) { |
|
484 | + if ($owing > 0) { |
|
485 | 485 | // don't allow payment amount to exceed the available payment amount, OR the amount owing |
486 | - $payment_amount = min( $available_payment_amount, $owing ); |
|
486 | + $payment_amount = min($available_payment_amount, $owing); |
|
487 | 487 | // update $available_payment_amount |
488 | 488 | $available_payment_amount = $available_payment_amount - $payment_amount; |
489 | 489 | //calculate and set new REG_paid |
490 | - $registration->set_paid( $registration->paid() + $payment_amount ); |
|
490 | + $registration->set_paid($registration->paid() + $payment_amount); |
|
491 | 491 | // now save it |
492 | - $this->_apply_registration_payment( $registration, $payment, $payment_amount ); |
|
492 | + $this->_apply_registration_payment($registration, $payment, $payment_amount); |
|
493 | 493 | } |
494 | 494 | return $available_payment_amount; |
495 | 495 | } |
@@ -504,19 +504,19 @@ discard block |
||
504 | 504 | * @param float $payment_amount |
505 | 505 | * @return float |
506 | 506 | */ |
507 | - protected function _apply_registration_payment( EE_Registration $registration, EE_Payment $payment, $payment_amount = 0.00 ) { |
|
507 | + protected function _apply_registration_payment(EE_Registration $registration, EE_Payment $payment, $payment_amount = 0.00) { |
|
508 | 508 | // find any existing reg payment records for this registration and payment |
509 | 509 | $existing_reg_payment = EEM_Registration_Payment::instance()->get_one( |
510 | - array( array( 'REG_ID' => $registration->ID(), 'PAY_ID' => $payment->ID() ) ) |
|
510 | + array(array('REG_ID' => $registration->ID(), 'PAY_ID' => $payment->ID())) |
|
511 | 511 | ); |
512 | 512 | // if existing registration payment exists |
513 | - if ( $existing_reg_payment instanceof EE_Registration_Payment ) { |
|
513 | + if ($existing_reg_payment instanceof EE_Registration_Payment) { |
|
514 | 514 | // then update that record |
515 | - $existing_reg_payment->set_amount( $payment_amount ); |
|
515 | + $existing_reg_payment->set_amount($payment_amount); |
|
516 | 516 | $existing_reg_payment->save(); |
517 | 517 | } else { |
518 | 518 | // or add new relation between registration and payment and set amount |
519 | - $registration->_add_relation_to( $payment, 'Payment', array( 'RPY_amount' => $payment_amount ) ); |
|
519 | + $registration->_add_relation_to($payment, 'Payment', array('RPY_amount' => $payment_amount)); |
|
520 | 520 | // make it stick |
521 | 521 | $registration->save(); |
522 | 522 | } |
@@ -532,21 +532,21 @@ discard block |
||
532 | 532 | * @param float $available_refund_amount - IMPORTANT !!! SEND AVAILABLE REFUND AMOUNT AS A POSITIVE NUMBER |
533 | 533 | * @return float |
534 | 534 | */ |
535 | - public function process_registration_refund( EE_Registration $registration, EE_Payment $payment, $available_refund_amount = 0.00 ) { |
|
535 | + public function process_registration_refund(EE_Registration $registration, EE_Payment $payment, $available_refund_amount = 0.00) { |
|
536 | 536 | //EEH_Debug_Tools::printr( $payment->amount(), '$payment->amount()', __FILE__, __LINE__ ); |
537 | - if ( $registration->paid() > 0 ) { |
|
537 | + if ($registration->paid() > 0) { |
|
538 | 538 | // ensure $available_refund_amount is NOT negative |
539 | - $available_refund_amount = abs( $available_refund_amount ); |
|
539 | + $available_refund_amount = abs($available_refund_amount); |
|
540 | 540 | // don't allow refund amount to exceed the available payment amount, OR the amount paid |
541 | - $refund_amount = min( $available_refund_amount, $registration->paid() ); |
|
541 | + $refund_amount = min($available_refund_amount, $registration->paid()); |
|
542 | 542 | // update $available_payment_amount |
543 | 543 | $available_refund_amount = $available_refund_amount - $refund_amount; |
544 | 544 | //calculate and set new REG_paid |
545 | - $registration->set_paid( $registration->paid() - $refund_amount ); |
|
545 | + $registration->set_paid($registration->paid() - $refund_amount); |
|
546 | 546 | // convert payment amount back to a negative value for storage in the db |
547 | - $refund_amount = abs( $refund_amount ) * -1; |
|
547 | + $refund_amount = abs($refund_amount) * -1; |
|
548 | 548 | // now save it |
549 | - $this->_apply_registration_payment( $registration, $payment, $refund_amount ); |
|
549 | + $this->_apply_registration_payment($registration, $payment, $refund_amount); |
|
550 | 550 | } |
551 | 551 | return $available_refund_amount; |
552 | 552 | } |
@@ -564,12 +564,12 @@ discard block |
||
564 | 564 | * @param EE_Payment $payment |
565 | 565 | * @param bool $IPN |
566 | 566 | */ |
567 | - protected function _post_payment_processing( EE_Transaction $transaction, EE_Payment $payment, $IPN = false ) { |
|
567 | + protected function _post_payment_processing(EE_Transaction $transaction, EE_Payment $payment, $IPN = false) { |
|
568 | 568 | |
569 | 569 | /** @type EE_Transaction_Processor $transaction_processor */ |
570 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
570 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
571 | 571 | // is the Payment Options Reg Step completed ? |
572 | - $payment_options_step_completed = $transaction_processor->reg_step_completed( $transaction, 'payment_options' ); |
|
572 | + $payment_options_step_completed = $transaction_processor->reg_step_completed($transaction, 'payment_options'); |
|
573 | 573 | // DEBUG LOG |
574 | 574 | //$this->log( |
575 | 575 | // __CLASS__, __FUNCTION__, __LINE__, |
@@ -582,14 +582,14 @@ discard block |
||
582 | 582 | // if the Payment Options Reg Step is completed... |
583 | 583 | $revisit = $payment_options_step_completed === true ? true : false; |
584 | 584 | // then this is kinda sorta a revisit with regards to payments at least |
585 | - $transaction_processor->set_revisit( $revisit ); |
|
585 | + $transaction_processor->set_revisit($revisit); |
|
586 | 586 | // if this is an IPN, let's consider the Payment Options Reg Step completed if not already |
587 | 587 | if ( |
588 | 588 | $IPN && |
589 | 589 | $payment_options_step_completed !== true && |
590 | - ( $payment->is_approved() || $payment->is_pending() ) |
|
590 | + ($payment->is_approved() || $payment->is_pending()) |
|
591 | 591 | ) { |
592 | - $payment_options_step_completed = $transaction_processor->set_reg_step_completed( $transaction, 'payment_options' ); |
|
592 | + $payment_options_step_completed = $transaction_processor->set_reg_step_completed($transaction, 'payment_options'); |
|
593 | 593 | } |
594 | 594 | // DEBUG LOG |
595 | 595 | //$this->log( |
@@ -601,11 +601,11 @@ discard block |
||
601 | 601 | // ) |
602 | 602 | //); |
603 | 603 | /** @type EE_Transaction_Payments $transaction_payments */ |
604 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
604 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
605 | 605 | // maybe update status, but don't save transaction just yet |
606 | - $transaction_payments->update_transaction_status_based_on_total_paid( $transaction, false ); |
|
606 | + $transaction_payments->update_transaction_status_based_on_total_paid($transaction, false); |
|
607 | 607 | // check if 'finalize_registration' step has been completed... |
608 | - $finalized = $transaction_processor->reg_step_completed( $transaction, 'finalize_registration' ); |
|
608 | + $finalized = $transaction_processor->reg_step_completed($transaction, 'finalize_registration'); |
|
609 | 609 | // DEBUG LOG |
610 | 610 | //$this->log( |
611 | 611 | // __CLASS__, __FUNCTION__, __LINE__, |
@@ -616,9 +616,9 @@ discard block |
||
616 | 616 | // ) |
617 | 617 | //); |
618 | 618 | // if this is an IPN and the final step has not been initiated |
619 | - if ( $IPN && $payment_options_step_completed && $finalized === false ) { |
|
619 | + if ($IPN && $payment_options_step_completed && $finalized === false) { |
|
620 | 620 | // and if it hasn't already been set as being started... |
621 | - $finalized = $transaction_processor->set_reg_step_initiated( $transaction, 'finalize_registration' ); |
|
621 | + $finalized = $transaction_processor->set_reg_step_initiated($transaction, 'finalize_registration'); |
|
622 | 622 | // DEBUG LOG |
623 | 623 | //$this->log( |
624 | 624 | // __CLASS__, __FUNCTION__, __LINE__, |
@@ -631,13 +631,13 @@ discard block |
||
631 | 631 | } |
632 | 632 | $transaction->save(); |
633 | 633 | // because the above will return false if the final step was not fully completed, we need to check again... |
634 | - if ( $IPN && $finalized !== false ) { |
|
634 | + if ($IPN && $finalized !== false) { |
|
635 | 635 | // and if we are all good to go, then send out notifications |
636 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true' ); |
|
636 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true'); |
|
637 | 637 | // DEBUG LOG |
638 | 638 | //$this->log( __CLASS__, __FUNCTION__, __LINE__, $transaction ); |
639 | 639 | //ok, now process the transaction according to the payment |
640 | - $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( $transaction, $payment ); |
|
640 | + $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment($transaction, $payment); |
|
641 | 641 | } |
642 | 642 | // DEBUG LOG |
643 | 643 | //$this->log( |
@@ -1,26 +1,26 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2 | 2 | /** |
3 | - * Event Espresso |
|
4 | - * |
|
5 | - * Event Registration and Management Plugin for WordPress |
|
6 | - * |
|
7 | - * @ package Event Espresso |
|
8 | - * @ author Seth Shoultes |
|
9 | - * @ copyright (c) 2008-2011 Event Espresso All Rights Reserved. |
|
10 | - * @ license http://eventespresso.com/support/terms-conditions/ * see Plugin Licensing * |
|
11 | - * @ link http://www.eventespresso.com |
|
12 | - * @ version 4.0 |
|
13 | - * |
|
14 | - * ------------------------------------------------------------------------ |
|
15 | - * |
|
16 | - * Datetime Model |
|
17 | - * |
|
18 | - * @package Event Espresso |
|
19 | - * @subpackage includes/models/ |
|
20 | - * @author Brent Christensen |
|
21 | - * |
|
22 | - * ------------------------------------------------------------------------ |
|
23 | - */ |
|
3 | + * Event Espresso |
|
4 | + * |
|
5 | + * Event Registration and Management Plugin for WordPress |
|
6 | + * |
|
7 | + * @ package Event Espresso |
|
8 | + * @ author Seth Shoultes |
|
9 | + * @ copyright (c) 2008-2011 Event Espresso All Rights Reserved. |
|
10 | + * @ license http://eventespresso.com/support/terms-conditions/ * see Plugin Licensing * |
|
11 | + * @ link http://www.eventespresso.com |
|
12 | + * @ version 4.0 |
|
13 | + * |
|
14 | + * ------------------------------------------------------------------------ |
|
15 | + * |
|
16 | + * Datetime Model |
|
17 | + * |
|
18 | + * @package Event Espresso |
|
19 | + * @subpackage includes/models/ |
|
20 | + * @author Brent Christensen |
|
21 | + * |
|
22 | + * ------------------------------------------------------------------------ |
|
23 | + */ |
|
24 | 24 | require_once ( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' ); |
25 | 25 | require_once ( EE_CLASSES . 'EE_Datetime.class.php' ); |
26 | 26 | |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | |
76 | 76 | |
77 | 77 | /** |
78 | - * create new blank datetime |
|
79 | - * |
|
80 | - * @access public |
|
81 | - * @return EE_Datetime[] array on success, FALSE on fail |
|
82 | - */ |
|
78 | + * create new blank datetime |
|
79 | + * |
|
80 | + * @access public |
|
81 | + * @return EE_Datetime[] array on success, FALSE on fail |
|
82 | + */ |
|
83 | 83 | public function create_new_blank_datetime() { |
84 | 84 | $blank_datetime = EE_Datetime::new_instance( |
85 | 85 | array( |
@@ -100,12 +100,12 @@ discard block |
||
100 | 100 | |
101 | 101 | |
102 | 102 | /** |
103 | - * get event start date from db |
|
104 | - * |
|
105 | - * @access public |
|
106 | - * @param int $EVT_ID |
|
107 | - * @return EE_Datetime[] array on success, FALSE on fail |
|
108 | - */ |
|
103 | + * get event start date from db |
|
104 | + * |
|
105 | + * @access public |
|
106 | + * @param int $EVT_ID |
|
107 | + * @return EE_Datetime[] array on success, FALSE on fail |
|
108 | + */ |
|
109 | 109 | public function get_all_event_dates( $EVT_ID = 0 ) { |
110 | 110 | if ( ! $EVT_ID ) { // on add_new_event event_id gets set to 0 |
111 | 111 | return $this->create_new_blank_datetime(); |
@@ -250,14 +250,14 @@ discard block |
||
250 | 250 | } |
251 | 251 | |
252 | 252 | /** |
253 | - * Gets ALL the datetimes for an ticket (including trashed ones, for now), ordered |
|
254 | - * only by start date |
|
255 | - * @param int $TKT_ID |
|
256 | - * @param boolean $include_expired |
|
257 | - * @param boolean $include_deleted |
|
258 | - * @param int $limit |
|
259 | - * @return EE_Datetime[] |
|
260 | - */ |
|
253 | + * Gets ALL the datetimes for an ticket (including trashed ones, for now), ordered |
|
254 | + * only by start date |
|
255 | + * @param int $TKT_ID |
|
256 | + * @param boolean $include_expired |
|
257 | + * @param boolean $include_deleted |
|
258 | + * @param int $limit |
|
259 | + * @return EE_Datetime[] |
|
260 | + */ |
|
261 | 261 | public function get_datetimes_for_ticket_ordered_by_start_time($TKT_ID, $include_expired = true, $include_deleted= true, $limit = NULL){ |
262 | 262 | //sanitize TKT_ID |
263 | 263 | $TKT_ID = intval( $TKT_ID ); |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | * |
22 | 22 | * ------------------------------------------------------------------------ |
23 | 23 | */ |
24 | -require_once ( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' ); |
|
25 | -require_once ( EE_CLASSES . 'EE_Datetime.class.php' ); |
|
24 | +require_once (EE_MODELS.'EEM_Soft_Delete_Base.model.php'); |
|
25 | +require_once (EE_CLASSES.'EE_Datetime.class.php'); |
|
26 | 26 | |
27 | 27 | class EEM_Datetime extends EEM_Soft_Delete_Base { |
28 | 28 | |
@@ -35,28 +35,28 @@ discard block |
||
35 | 35 | * @access private |
36 | 36 | * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved). Note this just sends the timezone info to the date time model field objects. Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option) |
37 | 37 | */ |
38 | - protected function __construct( $timezone ) { |
|
39 | - $this->singular_item = __('Datetime','event_espresso'); |
|
40 | - $this->plural_item = __('Datetimes','event_espresso'); |
|
38 | + protected function __construct($timezone) { |
|
39 | + $this->singular_item = __('Datetime', 'event_espresso'); |
|
40 | + $this->plural_item = __('Datetimes', 'event_espresso'); |
|
41 | 41 | |
42 | 42 | $this->_tables = array( |
43 | 43 | 'Datetime'=> new EE_Primary_Table('esp_datetime', 'DTT_ID') |
44 | 44 | ); |
45 | 45 | $this->_fields = array( |
46 | 46 | 'Datetime'=>array( |
47 | - 'DTT_ID'=> new EE_Primary_Key_Int_Field('DTT_ID', __('Datetime ID','event_espresso')), |
|
48 | - 'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID','event_espresso'), false, 0, 'Event'), |
|
47 | + 'DTT_ID'=> new EE_Primary_Key_Int_Field('DTT_ID', __('Datetime ID', 'event_espresso')), |
|
48 | + 'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID', 'event_espresso'), false, 0, 'Event'), |
|
49 | 49 | 'DTT_name' => new EE_Plain_Text_Field('DTT_name', __('Datetime Name', 'event_espresso'), false, ''), |
50 | 50 | 'DTT_description' => new EE_Full_HTML_Field('DTT_description', __('Description for Datetime', 'event_espresso'), false, ''), |
51 | - 'DTT_EVT_start'=>new EE_Datetime_Field('DTT_EVT_start', __('Start time/date of Event','event_espresso'), false, time(), $timezone ), |
|
52 | - 'DTT_EVT_end'=>new EE_Datetime_Field('DTT_EVT_end', __('End time/date of Event','event_espresso'), false, time(), $timezone ), |
|
53 | - 'DTT_reg_limit'=>new EE_Infinite_Integer_Field('DTT_reg_limit', __('Registration Limit for this time','event_espresso'), true, EE_INF), |
|
54 | - 'DTT_sold'=>new EE_Integer_Field('DTT_sold', __('How many sales for this Datetime that have occurred', 'event_espresso'), true, 0 ), |
|
55 | - 'DTT_reserved' => new EE_Integer_Field('DTT_reserved',__('Quantity of tickets that are reserved, but not yet fully purchased','event_espresso'),false,0), |
|
56 | - 'DTT_is_primary'=>new EE_Boolean_Field('DTT_is_primary', __("Flag indicating datetime is primary one for event", "event_espresso"), false,false), |
|
51 | + 'DTT_EVT_start'=>new EE_Datetime_Field('DTT_EVT_start', __('Start time/date of Event', 'event_espresso'), false, time(), $timezone), |
|
52 | + 'DTT_EVT_end'=>new EE_Datetime_Field('DTT_EVT_end', __('End time/date of Event', 'event_espresso'), false, time(), $timezone), |
|
53 | + 'DTT_reg_limit'=>new EE_Infinite_Integer_Field('DTT_reg_limit', __('Registration Limit for this time', 'event_espresso'), true, EE_INF), |
|
54 | + 'DTT_sold'=>new EE_Integer_Field('DTT_sold', __('How many sales for this Datetime that have occurred', 'event_espresso'), true, 0), |
|
55 | + 'DTT_reserved' => new EE_Integer_Field('DTT_reserved', __('Quantity of tickets that are reserved, but not yet fully purchased', 'event_espresso'), false, 0), |
|
56 | + 'DTT_is_primary'=>new EE_Boolean_Field('DTT_is_primary', __("Flag indicating datetime is primary one for event", "event_espresso"), false, false), |
|
57 | 57 | 'DTT_order' => new EE_Integer_Field('DTT_order', __('The order in which the Datetime is displayed', 'event_espresso'), false, 0), |
58 | - 'DTT_parent' => new EE_Integer_Field('DTT_parent', __('Indicates what DTT_ID is the parent of this DTT_ID'), true, 0 ), |
|
59 | - 'DTT_deleted' => new EE_Trashed_Flag_Field('DTT_deleted', __('Flag indicating datetime is archived', 'event_espresso'), false, false ), |
|
58 | + 'DTT_parent' => new EE_Integer_Field('DTT_parent', __('Indicates what DTT_ID is the parent of this DTT_ID'), true, 0), |
|
59 | + 'DTT_deleted' => new EE_Trashed_Flag_Field('DTT_deleted', __('Flag indicating datetime is archived', 'event_espresso'), false, false), |
|
60 | 60 | )); |
61 | 61 | $this->_model_relations = array( |
62 | 62 | 'Ticket'=>new EE_HABTM_Relation('Datetime_Ticket'), |
@@ -65,11 +65,11 @@ discard block |
||
65 | 65 | ); |
66 | 66 | $this->_model_chain_to_wp_user = 'Event'; |
67 | 67 | //this model is generally available for reading |
68 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public( 'Event' ); |
|
69 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected( 'Event' ); |
|
70 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected( 'Event' ); |
|
71 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected( 'Event', EEM_Base::caps_edit ); |
|
72 | - parent::__construct( $timezone ); |
|
68 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Event_Related_Public('Event'); |
|
69 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Event_Related_Protected('Event'); |
|
70 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Event_Related_Protected('Event'); |
|
71 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Event_Related_Protected('Event', EEM_Base::caps_edit); |
|
72 | + parent::__construct($timezone); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | |
@@ -84,16 +84,16 @@ discard block |
||
84 | 84 | public function create_new_blank_datetime() { |
85 | 85 | $blank_datetime = EE_Datetime::new_instance( |
86 | 86 | array( |
87 | - 'DTT_EVT_start' => $this->current_time_for_query( 'DTT_EVT_start', true ) + (60 * 60 * 24 * 30), |
|
88 | - 'DTT_EVT_end' => $this->current_time_for_query( 'DTT_EVT_end', true ) + (60 * 60 * 24 * 30), |
|
87 | + 'DTT_EVT_start' => $this->current_time_for_query('DTT_EVT_start', true) + (60 * 60 * 24 * 30), |
|
88 | + 'DTT_EVT_end' => $this->current_time_for_query('DTT_EVT_end', true) + (60 * 60 * 24 * 30), |
|
89 | 89 | 'DTT_order' => 1, |
90 | 90 | 'DTT_reg_limit' => EE_INF |
91 | 91 | ), |
92 | 92 | $this->_timezone |
93 | 93 | ); |
94 | - $blank_datetime->set_start_time( $this->convert_datetime_for_query( 'DTT_EVT_start', '8am', 'ga', $this->_timezone ) ); |
|
95 | - $blank_datetime->set_end_time( $this->convert_datetime_for_query( 'DTT_EVT_end', '5pm', 'ga', $this->_timezone ) ); |
|
96 | - return array( $blank_datetime ); |
|
94 | + $blank_datetime->set_start_time($this->convert_datetime_for_query('DTT_EVT_start', '8am', 'ga', $this->_timezone)); |
|
95 | + $blank_datetime->set_end_time($this->convert_datetime_for_query('DTT_EVT_end', '5pm', 'ga', $this->_timezone)); |
|
96 | + return array($blank_datetime); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | |
@@ -107,13 +107,13 @@ discard block |
||
107 | 107 | * @param int $EVT_ID |
108 | 108 | * @return EE_Datetime[] array on success, FALSE on fail |
109 | 109 | */ |
110 | - public function get_all_event_dates( $EVT_ID = 0 ) { |
|
111 | - if ( ! $EVT_ID ) { // on add_new_event event_id gets set to 0 |
|
110 | + public function get_all_event_dates($EVT_ID = 0) { |
|
111 | + if ( ! $EVT_ID) { // on add_new_event event_id gets set to 0 |
|
112 | 112 | return $this->create_new_blank_datetime(); |
113 | 113 | } |
114 | - $results = $this->get_datetimes_for_event_ordered_by_DTT_order($EVT_ID); |
|
114 | + $results = $this->get_datetimes_for_event_ordered_by_DTT_order($EVT_ID); |
|
115 | 115 | |
116 | - if ( empty( $results ) ) { |
|
116 | + if (empty($results)) { |
|
117 | 117 | return $this->create_new_blank_datetime(); |
118 | 118 | } |
119 | 119 | |
@@ -134,26 +134,26 @@ discard block |
||
134 | 134 | * the given number |
135 | 135 | * @return EE_Datetime[] |
136 | 136 | */ |
137 | - public function get_datetimes_for_event_ordered_by_DTT_order( $EVT_ID, $include_expired = TRUE, $include_deleted= TRUE, $limit = NULL ) { |
|
137 | + public function get_datetimes_for_event_ordered_by_DTT_order($EVT_ID, $include_expired = TRUE, $include_deleted = TRUE, $limit = NULL) { |
|
138 | 138 | |
139 | 139 | //sanitize EVT_ID |
140 | - $EVT_ID = intval( $EVT_ID ); |
|
140 | + $EVT_ID = intval($EVT_ID); |
|
141 | 141 | |
142 | 142 | $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
143 | - $this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db ); |
|
144 | - $where_params = array( 'Event.EVT_ID' => $EVT_ID ); |
|
143 | + $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
144 | + $where_params = array('Event.EVT_ID' => $EVT_ID); |
|
145 | 145 | |
146 | - $query_params = ! empty( $limit ) ? array( $where_params, 'limit' => $limit, 'order_by' => array( 'DTT_order' => 'ASC' ), 'default_where_conditions' => 'none' ) : array( $where_params, 'order_by' => array( 'DTT_order' => 'ASC' ), 'default_where_conditions' => 'none' ); |
|
146 | + $query_params = ! empty($limit) ? array($where_params, 'limit' => $limit, 'order_by' => array('DTT_order' => 'ASC'), 'default_where_conditions' => 'none') : array($where_params, 'order_by' => array('DTT_order' => 'ASC'), 'default_where_conditions' => 'none'); |
|
147 | 147 | |
148 | - if( ! $include_expired){ |
|
149 | - $query_params[0]['DTT_EVT_end'] = array( '>=', current_time( 'mysql', TRUE ) ); |
|
148 | + if ( ! $include_expired) { |
|
149 | + $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE)); |
|
150 | 150 | } |
151 | - if( $include_deleted){ |
|
152 | - $query_params[0]['DTT_deleted'] = array( 'IN', array( TRUE, FALSE )); |
|
151 | + if ($include_deleted) { |
|
152 | + $query_params[0]['DTT_deleted'] = array('IN', array(TRUE, FALSE)); |
|
153 | 153 | } |
154 | 154 | |
155 | - $result = $this->get_all( $query_params ); |
|
156 | - $this->assume_values_already_prepared_by_model_object( $old_assumption ); |
|
155 | + $result = $this->get_all($query_params); |
|
156 | + $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
157 | 157 | return $result; |
158 | 158 | } |
159 | 159 | |
@@ -168,8 +168,8 @@ discard block |
||
168 | 168 | * @param int $limit |
169 | 169 | * @return EE_Datetime[] |
170 | 170 | */ |
171 | - public function get_datetimes_for_event_ordered_by_importance( $EVT_ID = 0, $limit = NULL){ |
|
172 | - return $this->get_all( array(array('Event.EVT_ID'=>$EVT_ID), |
|
171 | + public function get_datetimes_for_event_ordered_by_importance($EVT_ID = 0, $limit = NULL) { |
|
172 | + return $this->get_all(array(array('Event.EVT_ID'=>$EVT_ID), |
|
173 | 173 | 'limit'=>$limit, |
174 | 174 | 'order_by'=>array('DTT_EVT_start'=>'ASC'), |
175 | 175 | 'default_where_conditions' => 'none')); |
@@ -184,11 +184,11 @@ discard block |
||
184 | 184 | * @param boolean $include_deleted |
185 | 185 | * @return EE_Datetime |
186 | 186 | */ |
187 | - public function get_oldest_datetime_for_event($EVT_ID, $include_expired = false,$include_deleted = false){ |
|
188 | - $results = $this->get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired, $include_deleted, 1); |
|
189 | - if($results){ |
|
187 | + public function get_oldest_datetime_for_event($EVT_ID, $include_expired = false, $include_deleted = false) { |
|
188 | + $results = $this->get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired, $include_deleted, 1); |
|
189 | + if ($results) { |
|
190 | 190 | return array_shift($results); |
191 | - }else{ |
|
191 | + } else { |
|
192 | 192 | return NULL; |
193 | 193 | } |
194 | 194 | } |
@@ -202,16 +202,16 @@ discard block |
||
202 | 202 | * @param bool $try_to_exclude_deleted |
203 | 203 | * @return \EE_Datetime |
204 | 204 | */ |
205 | - public function get_primary_datetime_for_event($EVT_ID,$try_to_exclude_expired = true, $try_to_exclude_deleted = true){ |
|
206 | - if($try_to_exclude_expired){ |
|
207 | - $non_expired = $this->get_oldest_datetime_for_event($EVT_ID, false,false); |
|
208 | - if($non_expired){ |
|
205 | + public function get_primary_datetime_for_event($EVT_ID, $try_to_exclude_expired = true, $try_to_exclude_deleted = true) { |
|
206 | + if ($try_to_exclude_expired) { |
|
207 | + $non_expired = $this->get_oldest_datetime_for_event($EVT_ID, false, false); |
|
208 | + if ($non_expired) { |
|
209 | 209 | return $non_expired; |
210 | 210 | } |
211 | 211 | } |
212 | - if($try_to_exclude_deleted){ |
|
212 | + if ($try_to_exclude_deleted) { |
|
213 | 213 | $expired_even = $this->get_oldest_datetime_for_event($EVT_ID, true); |
214 | - if($expired_even){ |
|
214 | + if ($expired_even) { |
|
215 | 215 | return $expired_even; |
216 | 216 | } |
217 | 217 | } |
@@ -230,23 +230,23 @@ discard block |
||
230 | 230 | * @param int $limit |
231 | 231 | * @return EE_Datetime[] |
232 | 232 | */ |
233 | - public function get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired = true, $include_deleted= true, $limit = NULL ){ |
|
233 | + public function get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired = true, $include_deleted = true, $limit = NULL) { |
|
234 | 234 | //sanitize EVT_ID |
235 | - $EVT_ID = intval( $EVT_ID ); |
|
235 | + $EVT_ID = intval($EVT_ID); |
|
236 | 236 | $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
237 | - $this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db ); |
|
238 | - $query_params =array(array('Event.EVT_ID'=>$EVT_ID),'order_by'=>array('DTT_EVT_start'=>'asc')); |
|
239 | - if( ! $include_expired){ |
|
240 | - $query_params[0]['DTT_EVT_end'] = array('>=',current_time('mysql', TRUE)); |
|
237 | + $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
238 | + $query_params = array(array('Event.EVT_ID'=>$EVT_ID), 'order_by'=>array('DTT_EVT_start'=>'asc')); |
|
239 | + if ( ! $include_expired) { |
|
240 | + $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE)); |
|
241 | 241 | } |
242 | - if( $include_deleted){ |
|
243 | - $query_params[0]['DTT_deleted'] = array('IN',array(true,false)); |
|
242 | + if ($include_deleted) { |
|
243 | + $query_params[0]['DTT_deleted'] = array('IN', array(true, false)); |
|
244 | 244 | } |
245 | - if($limit){ |
|
245 | + if ($limit) { |
|
246 | 246 | $query_params['limit'] = $limit; |
247 | 247 | } |
248 | - $result = $this->get_all( $query_params ); |
|
249 | - $this->assume_values_already_prepared_by_model_object( $old_assumption ); |
|
248 | + $result = $this->get_all($query_params); |
|
249 | + $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
250 | 250 | return $result; |
251 | 251 | } |
252 | 252 | |
@@ -259,23 +259,23 @@ discard block |
||
259 | 259 | * @param int $limit |
260 | 260 | * @return EE_Datetime[] |
261 | 261 | */ |
262 | - public function get_datetimes_for_ticket_ordered_by_start_time($TKT_ID, $include_expired = true, $include_deleted= true, $limit = NULL){ |
|
262 | + public function get_datetimes_for_ticket_ordered_by_start_time($TKT_ID, $include_expired = true, $include_deleted = true, $limit = NULL) { |
|
263 | 263 | //sanitize TKT_ID |
264 | - $TKT_ID = intval( $TKT_ID ); |
|
264 | + $TKT_ID = intval($TKT_ID); |
|
265 | 265 | $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
266 | - $this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db ); |
|
267 | - $query_params =array(array('Ticket.TKT_ID'=>$TKT_ID),'order_by'=>array('DTT_EVT_start'=>'asc')); |
|
268 | - if( ! $include_expired){ |
|
269 | - $query_params[0]['DTT_EVT_end'] = array('>=',current_time('mysql', TRUE)); |
|
266 | + $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
267 | + $query_params = array(array('Ticket.TKT_ID'=>$TKT_ID), 'order_by'=>array('DTT_EVT_start'=>'asc')); |
|
268 | + if ( ! $include_expired) { |
|
269 | + $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE)); |
|
270 | 270 | } |
271 | - if( $include_deleted){ |
|
272 | - $query_params[0]['DTT_deleted'] = array('IN',array(true,false)); |
|
271 | + if ($include_deleted) { |
|
272 | + $query_params[0]['DTT_deleted'] = array('IN', array(true, false)); |
|
273 | 273 | } |
274 | - if($limit){ |
|
274 | + if ($limit) { |
|
275 | 275 | $query_params['limit'] = $limit; |
276 | 276 | } |
277 | - $result = $this->get_all( $query_params ); |
|
278 | - $this->assume_values_already_prepared_by_model_object( $old_assumption ); |
|
277 | + $result = $this->get_all($query_params); |
|
278 | + $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
279 | 279 | return $result; |
280 | 280 | } |
281 | 281 | |
@@ -291,24 +291,24 @@ discard block |
||
291 | 291 | * that number |
292 | 292 | * @return EE_Datetime[] |
293 | 293 | */ |
294 | - public function get_datetimes_for_ticket_ordered_by_DTT_order( $TKT_ID, $include_expired = true, $include_deleted = true, $limit = NULL ) { |
|
294 | + public function get_datetimes_for_ticket_ordered_by_DTT_order($TKT_ID, $include_expired = true, $include_deleted = true, $limit = NULL) { |
|
295 | 295 | //sanitize id. |
296 | - $TKT_ID = intval( $TKT_ID ); |
|
296 | + $TKT_ID = intval($TKT_ID); |
|
297 | 297 | $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
298 | - $this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db ); |
|
299 | - $where_params = array( 'Ticket.TKT_ID' => $TKT_ID ); |
|
300 | - $query_params = array( $where_params, 'order_by' => array( 'DTT_order' => 'ASC' ) ); |
|
301 | - if( ! $include_expired){ |
|
302 | - $query_params[0]['DTT_EVT_end'] = array('>=',current_time('mysql', TRUE)); |
|
298 | + $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
299 | + $where_params = array('Ticket.TKT_ID' => $TKT_ID); |
|
300 | + $query_params = array($where_params, 'order_by' => array('DTT_order' => 'ASC')); |
|
301 | + if ( ! $include_expired) { |
|
302 | + $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE)); |
|
303 | 303 | } |
304 | - if( $include_deleted){ |
|
305 | - $query_params[0]['DTT_deleted'] = array('IN',array(true,false)); |
|
304 | + if ($include_deleted) { |
|
305 | + $query_params[0]['DTT_deleted'] = array('IN', array(true, false)); |
|
306 | 306 | } |
307 | - if($limit){ |
|
307 | + if ($limit) { |
|
308 | 308 | $query_params['limit'] = $limit; |
309 | 309 | } |
310 | - $result = $this->get_all( $query_params ); |
|
311 | - $this->assume_values_already_prepared_by_model_object( $old_assumption ); |
|
310 | + $result = $this->get_all($query_params); |
|
311 | + $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
312 | 312 | return $result; |
313 | 313 | } |
314 | 314 | |
@@ -319,11 +319,11 @@ discard block |
||
319 | 319 | * @param int $EVT_ID |
320 | 320 | * @return EE_Datetime |
321 | 321 | */ |
322 | - public function get_most_important_datetime_for_event($EVT_ID){ |
|
322 | + public function get_most_important_datetime_for_event($EVT_ID) { |
|
323 | 323 | $results = $this->get_datetimes_for_event_ordered_by_importance($EVT_ID, 1); |
324 | - if($results){ |
|
324 | + if ($results) { |
|
325 | 325 | return array_shift($results); |
326 | - }else{ |
|
326 | + } else { |
|
327 | 327 | return null; |
328 | 328 | } |
329 | 329 | } |
@@ -342,78 +342,78 @@ discard block |
||
342 | 342 | * - inactive = Events that are either not published. |
343 | 343 | * @return wpdb results array |
344 | 344 | */ |
345 | - public function get_dtt_months_and_years( $where_params, $evt_active_status = '' ) { |
|
346 | - $current_time_for_DTT_EVT_start = $this->current_time_for_query( 'DTT_EVT_start' ); |
|
347 | - $current_time_for_DTT_EVT_end = $this->current_time_for_query( 'DTT_EVT_end' ); |
|
345 | + public function get_dtt_months_and_years($where_params, $evt_active_status = '') { |
|
346 | + $current_time_for_DTT_EVT_start = $this->current_time_for_query('DTT_EVT_start'); |
|
347 | + $current_time_for_DTT_EVT_end = $this->current_time_for_query('DTT_EVT_end'); |
|
348 | 348 | |
349 | - switch ( $evt_active_status ) { |
|
349 | + switch ($evt_active_status) { |
|
350 | 350 | case 'upcoming' : |
351 | 351 | $where_params['Event.status'] = 'publish'; |
352 | 352 | //if there are already query_params matching DTT_EVT_start then we need to modify that to add them. |
353 | - if ( isset( $where_params['DTT_EVT_start'] ) ) { |
|
353 | + if (isset($where_params['DTT_EVT_start'])) { |
|
354 | 354 | $where_params['DTT_EVT_start*****'] = $where_params['DTT_EVT_start']; |
355 | 355 | } |
356 | - $where_params['DTT_EVT_start'] = array('>', $current_time_for_DTT_EVT_start ); |
|
356 | + $where_params['DTT_EVT_start'] = array('>', $current_time_for_DTT_EVT_start); |
|
357 | 357 | break; |
358 | 358 | |
359 | 359 | case 'expired' : |
360 | - if ( isset( $where_params['Event.status'] ) ) unset( $where_params['Event.status'] ); |
|
360 | + if (isset($where_params['Event.status'])) unset($where_params['Event.status']); |
|
361 | 361 | //get events to exclude |
362 | - $exclude_query[0] = array_merge( $where_params, array( 'DTT_EVT_end' => array( '>', $current_time_for_DTT_EVT_end ) ) ); |
|
362 | + $exclude_query[0] = array_merge($where_params, array('DTT_EVT_end' => array('>', $current_time_for_DTT_EVT_end))); |
|
363 | 363 | //first get all events that have datetimes where its not expired. |
364 | - $event_ids = $this->_get_all_wpdb_results( $exclude_query, OBJECT_K, 'Datetime.EVT_ID' ); |
|
365 | - $event_ids = array_keys( $event_ids ); |
|
364 | + $event_ids = $this->_get_all_wpdb_results($exclude_query, OBJECT_K, 'Datetime.EVT_ID'); |
|
365 | + $event_ids = array_keys($event_ids); |
|
366 | 366 | |
367 | - if ( isset( $where_params['DTT_EVT_end'] ) ) { |
|
367 | + if (isset($where_params['DTT_EVT_end'])) { |
|
368 | 368 | $where_params['DTT_EVT_end****'] = $where_params['DTT_EVT_end']; |
369 | 369 | } |
370 | - $where_params['DTT_EVT_end'] = array( '<', $current_time_for_DTT_EVT_end ); |
|
371 | - $where_params['Event.EVT_ID'] = array( 'NOT IN', $event_ids ); |
|
370 | + $where_params['DTT_EVT_end'] = array('<', $current_time_for_DTT_EVT_end); |
|
371 | + $where_params['Event.EVT_ID'] = array('NOT IN', $event_ids); |
|
372 | 372 | break; |
373 | 373 | |
374 | 374 | case 'active' : |
375 | 375 | $where_params['Event.status'] = 'publish'; |
376 | - if ( isset( $where_params['DTT_EVT_start'] ) ) { |
|
376 | + if (isset($where_params['DTT_EVT_start'])) { |
|
377 | 377 | $where_params['Datetime.DTT_EVT_start******'] = $where_params['DTT_EVT_start']; |
378 | 378 | } |
379 | - if ( isset( $where_params['Datetime.DTT_EVT_end'] ) ) { |
|
379 | + if (isset($where_params['Datetime.DTT_EVT_end'])) { |
|
380 | 380 | $where_params['Datetime.DTT_EVT_end*****'] = $where_params['DTT_EVT_end']; |
381 | 381 | } |
382 | - $where_params['DTT_EVT_start'] = array('<', $current_time_for_DTT_EVT_start ); |
|
383 | - $where_params['DTT_EVT_end'] = array('>', $current_time_for_DTT_EVT_end ); |
|
382 | + $where_params['DTT_EVT_start'] = array('<', $current_time_for_DTT_EVT_start); |
|
383 | + $where_params['DTT_EVT_end'] = array('>', $current_time_for_DTT_EVT_end); |
|
384 | 384 | break; |
385 | 385 | |
386 | 386 | case 'inactive' : |
387 | - if ( isset( $where_params['Event.status'] ) ) unset( $where_params['Event.status'] ); |
|
388 | - if ( isset( $where_params['OR'] ) ) { |
|
387 | + if (isset($where_params['Event.status'])) unset($where_params['Event.status']); |
|
388 | + if (isset($where_params['OR'])) { |
|
389 | 389 | $where_params['AND']['OR'] = $where_params['OR']; |
390 | 390 | } |
391 | - if ( isset( $where_params['DTT_EVT_end'] ) ) { |
|
391 | + if (isset($where_params['DTT_EVT_end'])) { |
|
392 | 392 | $where_params['AND']['DTT_EVT_end****'] = $where_params['DTT_EVT_end']; |
393 | - unset( $where_params['DTT_EVT_end'] ); |
|
393 | + unset($where_params['DTT_EVT_end']); |
|
394 | 394 | } |
395 | 395 | |
396 | - if ( isset( $where_params['DTT_EVT_start'] ) ) { |
|
396 | + if (isset($where_params['DTT_EVT_start'])) { |
|
397 | 397 | $where_params['AND']['DTT_EVT_start'] = $where_params['DTT_EVT_start']; |
398 | - unset( $where_params['DTT_EVT_start'] ); |
|
398 | + unset($where_params['DTT_EVT_start']); |
|
399 | 399 | } |
400 | - $where_params['AND']['Event.status'] = array( '!=', 'publish' ); |
|
400 | + $where_params['AND']['Event.status'] = array('!=', 'publish'); |
|
401 | 401 | break; |
402 | 402 | } |
403 | 403 | |
404 | 404 | $query_params[0] = $where_params; |
405 | 405 | $query_params['group_by'] = array('dtt_year', 'dtt_month'); |
406 | - $query_params['order_by'] = array( 'DTT_EVT_start' => 'DESC' ); |
|
406 | + $query_params['order_by'] = array('DTT_EVT_start' => 'DESC'); |
|
407 | 407 | |
408 | - EE_Registry::instance()->load_helper( 'DTT_Helper' ); |
|
409 | - $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset( $this->get_timezone(), 'DTT_EVT_start' ); |
|
408 | + EE_Registry::instance()->load_helper('DTT_Helper'); |
|
409 | + $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'DTT_EVT_start'); |
|
410 | 410 | |
411 | 411 | $columns_to_select = array( |
412 | - 'dtt_year' => array('YEAR(' . $query_interval . ')', '%s'), |
|
413 | - 'dtt_month' => array('MONTHNAME(' . $query_interval . ')', '%s'), |
|
414 | - 'dtt_month_num' => array('MONTH(' . $query_interval .')', '%s') |
|
412 | + 'dtt_year' => array('YEAR('.$query_interval.')', '%s'), |
|
413 | + 'dtt_month' => array('MONTHNAME('.$query_interval.')', '%s'), |
|
414 | + 'dtt_month_num' => array('MONTH('.$query_interval.')', '%s') |
|
415 | 415 | ); |
416 | - return $this->_get_all_wpdb_results( $query_params, OBJECT, $columns_to_select ); |
|
416 | + return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select); |
|
417 | 417 | } |
418 | 418 | |
419 | 419 | /** |
@@ -421,8 +421,8 @@ discard block |
||
421 | 421 | * for the tickets for each datetime) |
422 | 422 | * @param EE_Datetime[] $datetimes |
423 | 423 | */ |
424 | - public function update_sold($datetimes){ |
|
425 | - foreach($datetimes as $datetime){ |
|
424 | + public function update_sold($datetimes) { |
|
425 | + foreach ($datetimes as $datetime) { |
|
426 | 426 | $datetime->update_sold(); |
427 | 427 | } |
428 | 428 | } |
@@ -437,10 +437,10 @@ discard block |
||
437 | 437 | * @param array $query_params |
438 | 438 | * @return int of tickets available. If sold out, return less than 1. If infinite, returns EE_INF, IF there are NO tickets attached to datetime then FALSE is returned. |
439 | 439 | */ |
440 | - public function sum_tickets_currently_available_at_datetime( $DTT_ID, $query_params = array() ) { |
|
441 | - $datetime = $this->get_one_by_ID( $DTT_ID ); |
|
442 | - if ( $datetime instanceof EE_Datetime ) { |
|
443 | - return $datetime->tickets_remaining( $query_params ); |
|
440 | + public function sum_tickets_currently_available_at_datetime($DTT_ID, $query_params = array()) { |
|
441 | + $datetime = $this->get_one_by_ID($DTT_ID); |
|
442 | + if ($datetime instanceof EE_Datetime) { |
|
443 | + return $datetime->tickets_remaining($query_params); |
|
444 | 444 | } |
445 | 445 | return 0; |
446 | 446 | } |
@@ -462,36 +462,36 @@ discard block |
||
462 | 462 | * EE_Datetime::upcoming |
463 | 463 | * EE_Datetime::expired |
464 | 464 | */ |
465 | - public function get_datetime_counts_by_status( $stati_to_include = array(), $query_params = array() ) { |
|
465 | + public function get_datetime_counts_by_status($stati_to_include = array(), $query_params = array()) { |
|
466 | 466 | //only accept where conditions for this query. |
467 | - $_where = isset( $query_params[0] ) ? $query_params[0] : array(); |
|
467 | + $_where = isset($query_params[0]) ? $query_params[0] : array(); |
|
468 | 468 | $status_query_args = array( |
469 | 469 | EE_Datetime::active => array_merge( |
470 | 470 | $_where, |
471 | - array( 'DTT_EVT_start' => array( '<', time() ), 'DTT_EVT_end' => array( '>', time() ) ) |
|
471 | + array('DTT_EVT_start' => array('<', time()), 'DTT_EVT_end' => array('>', time())) |
|
472 | 472 | ), |
473 | 473 | EE_Datetime::upcoming => array_merge( |
474 | 474 | $_where, |
475 | - array( 'DTT_EVT_start' => array( '>', time() ) ) |
|
475 | + array('DTT_EVT_start' => array('>', time())) |
|
476 | 476 | ), |
477 | 477 | EE_Datetime::expired => array_merge( |
478 | 478 | $_where, |
479 | - array( 'DTT_EVT_end' => array('<', time() ) ) |
|
479 | + array('DTT_EVT_end' => array('<', time())) |
|
480 | 480 | ) |
481 | 481 | ); |
482 | 482 | |
483 | - if ( ! empty( $stati_to_include ) ) { |
|
484 | - foreach( array_keys( $status_query_args ) as $status ) { |
|
485 | - if ( ! in_array( $status, $stati_to_include ) ) { |
|
486 | - unset( $status_query_args[$status] ); |
|
483 | + if ( ! empty($stati_to_include)) { |
|
484 | + foreach (array_keys($status_query_args) as $status) { |
|
485 | + if ( ! in_array($status, $stati_to_include)) { |
|
486 | + unset($status_query_args[$status]); |
|
487 | 487 | } |
488 | 488 | } |
489 | 489 | } |
490 | 490 | |
491 | 491 | //loop through and query counts for each stati. |
492 | 492 | $status_query_results = array(); |
493 | - foreach( $status_query_args as $status => $status_where_conditions ) { |
|
494 | - $status_query_results[ $status ] = EEM_Datetime::count( array( $status_where_conditions ), 'DTT_ID', true ); |
|
493 | + foreach ($status_query_args as $status => $status_where_conditions) { |
|
494 | + $status_query_results[$status] = EEM_Datetime::count(array($status_where_conditions), 'DTT_ID', true); |
|
495 | 495 | } |
496 | 496 | |
497 | 497 | return $status_query_results; |
@@ -505,9 +505,9 @@ discard block |
||
505 | 505 | * @param array $query_params |
506 | 506 | * @return int |
507 | 507 | */ |
508 | - public function get_datetime_count_for_status( $status = EE_Datetime::active, $query_params = array() ) { |
|
509 | - $count = $this->get_datetime_counts_by_status( array( $status ), $query_params ); |
|
510 | - return ! empty( $count[$status] ) ? $count[$status] : 0; |
|
508 | + public function get_datetime_count_for_status($status = EE_Datetime::active, $query_params = array()) { |
|
509 | + $count = $this->get_datetime_counts_by_status(array($status), $query_params); |
|
510 | + return ! empty($count[$status]) ? $count[$status] : 0; |
|
511 | 511 | } |
512 | 512 | |
513 | 513 |
@@ -1,33 +1,33 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2 | 2 | /** |
3 | - * Event Espresso |
|
4 | - * |
|
5 | - * Event Registration and Management Plugin for WordPress |
|
6 | - * |
|
7 | - * @ package Event Espresso |
|
8 | - * @ author Seth Shoultes |
|
9 | - * @ copyright (c) 2008-2011 Event Espresso All Rights Reserved. |
|
10 | - * @ license http://eventespresso.com/support/terms-conditions/ * see Plugin Licensing * |
|
11 | - * @ link http://www.eventespresso.com |
|
12 | - * @ version 4.0 |
|
13 | - * |
|
14 | - * ------------------------------------------------------------------------ |
|
15 | - * |
|
16 | - * EE_Admin |
|
17 | - * |
|
18 | - * @package Event Espresso |
|
19 | - * @subpackage /core/admin/ |
|
20 | - * @author Brent Christensen |
|
21 | - * |
|
22 | - * ------------------------------------------------------------------------ |
|
23 | - */ |
|
3 | + * Event Espresso |
|
4 | + * |
|
5 | + * Event Registration and Management Plugin for WordPress |
|
6 | + * |
|
7 | + * @ package Event Espresso |
|
8 | + * @ author Seth Shoultes |
|
9 | + * @ copyright (c) 2008-2011 Event Espresso All Rights Reserved. |
|
10 | + * @ license http://eventespresso.com/support/terms-conditions/ * see Plugin Licensing * |
|
11 | + * @ link http://www.eventespresso.com |
|
12 | + * @ version 4.0 |
|
13 | + * |
|
14 | + * ------------------------------------------------------------------------ |
|
15 | + * |
|
16 | + * EE_Admin |
|
17 | + * |
|
18 | + * @package Event Espresso |
|
19 | + * @subpackage /core/admin/ |
|
20 | + * @author Brent Christensen |
|
21 | + * |
|
22 | + * ------------------------------------------------------------------------ |
|
23 | + */ |
|
24 | 24 | final class EE_Admin { |
25 | 25 | |
26 | 26 | /** |
27 | - * EE_Admin Object |
|
28 | - * @private _instance |
|
29 | - * @private protected |
|
30 | - */ |
|
27 | + * EE_Admin Object |
|
28 | + * @private _instance |
|
29 | + * @private protected |
|
30 | + */ |
|
31 | 31 | private static $_instance = NULL; |
32 | 32 | |
33 | 33 | /** |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | |
57 | 57 | |
58 | 58 | /** |
59 | - * class constructor |
|
60 | - */ |
|
59 | + * class constructor |
|
60 | + */ |
|
61 | 61 | protected function __construct() { |
62 | 62 | // define global EE_Admin constants |
63 | 63 | $this->_define_all_constants(); |
@@ -168,11 +168,11 @@ discard block |
||
168 | 168 | |
169 | 169 | |
170 | 170 | /** |
171 | - * init- should fire after shortcode, module, addon, other plugin (default priority), and even EE_Front_Controller's init phases have run |
|
172 | - * |
|
173 | - * @access public |
|
174 | - * @return void |
|
175 | - */ |
|
171 | + * init- should fire after shortcode, module, addon, other plugin (default priority), and even EE_Front_Controller's init phases have run |
|
172 | + * |
|
173 | + * @access public |
|
174 | + * @return void |
|
175 | + */ |
|
176 | 176 | public function init() { |
177 | 177 | |
178 | 178 | //only enable most of the EE_Admin IF we're not in full maintenance mode |
@@ -463,11 +463,11 @@ discard block |
||
463 | 463 | |
464 | 464 | |
465 | 465 | /** |
466 | - * admin_init |
|
467 | - * |
|
468 | - * @access public |
|
469 | - * @return void |
|
470 | - */ |
|
466 | + * admin_init |
|
467 | + * |
|
468 | + * @access public |
|
469 | + * @return void |
|
470 | + */ |
|
471 | 471 | public function admin_init() { |
472 | 472 | |
473 | 473 | /** |
@@ -624,11 +624,11 @@ discard block |
||
624 | 624 | |
625 | 625 | |
626 | 626 | /** |
627 | - * dismiss_persistent_admin_notice |
|
628 | - * |
|
629 | - * @access public |
|
630 | - * @return void |
|
631 | - */ |
|
627 | + * dismiss_persistent_admin_notice |
|
628 | + * |
|
629 | + * @access public |
|
630 | + * @return void |
|
631 | + */ |
|
632 | 632 | public function dismiss_ee_nag_notice_callback() { |
633 | 633 | EE_Error::dismiss_persistent_admin_notice(); |
634 | 634 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | */ |
48 | 48 | public static function instance() { |
49 | 49 | // check if class object is instantiated |
50 | - if ( ! self::$_instance instanceof EE_Admin ) { |
|
50 | + if ( ! self::$_instance instanceof EE_Admin) { |
|
51 | 51 | self::$_instance = new self(); |
52 | 52 | } |
53 | 53 | return self::$_instance; |
@@ -62,25 +62,25 @@ discard block |
||
62 | 62 | // define global EE_Admin constants |
63 | 63 | $this->_define_all_constants(); |
64 | 64 | // set autoloaders for our admin page classes based on included path information |
65 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder( EE_ADMIN ); |
|
65 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_ADMIN); |
|
66 | 66 | // admin hooks |
67 | - add_filter( 'plugin_action_links', array( $this, 'filter_plugin_actions' ), 10, 2 ); |
|
67 | + add_filter('plugin_action_links', array($this, 'filter_plugin_actions'), 10, 2); |
|
68 | 68 | // load EE_Request_Handler early |
69 | - add_action( 'AHEE__EE_System__core_loaded_and_ready', array( $this, 'get_request' )); |
|
70 | - add_action( 'AHEE__EE_System__initialize_last', array( $this, 'init' )); |
|
71 | - add_action( 'AHEE__EE_Admin_Page__route_admin_request', array( $this, 'route_admin_request' ), 100, 2 ); |
|
72 | - add_action( 'wp_loaded', array( $this, 'wp_loaded' ), 100 ); |
|
73 | - add_action( 'admin_init', array( $this, 'admin_init' ), 100 ); |
|
74 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ), 20 ); |
|
75 | - add_action( 'admin_notices', array( $this, 'display_admin_notices' ), 10 ); |
|
76 | - add_action( 'network_admin_notices', array( $this, 'display_admin_notices' ), 10 ); |
|
77 | - add_filter( 'pre_update_option', array( $this, 'check_for_invalid_datetime_formats' ), 100, 2 ); |
|
78 | - add_filter('admin_footer_text', array( $this, 'espresso_admin_footer' )); |
|
69 | + add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'get_request')); |
|
70 | + add_action('AHEE__EE_System__initialize_last', array($this, 'init')); |
|
71 | + add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'route_admin_request'), 100, 2); |
|
72 | + add_action('wp_loaded', array($this, 'wp_loaded'), 100); |
|
73 | + add_action('admin_init', array($this, 'admin_init'), 100); |
|
74 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'), 20); |
|
75 | + add_action('admin_notices', array($this, 'display_admin_notices'), 10); |
|
76 | + add_action('network_admin_notices', array($this, 'display_admin_notices'), 10); |
|
77 | + add_filter('pre_update_option', array($this, 'check_for_invalid_datetime_formats'), 100, 2); |
|
78 | + add_filter('admin_footer_text', array($this, 'espresso_admin_footer')); |
|
79 | 79 | |
80 | 80 | //reset Environment config (we only do this on admin page loads); |
81 | 81 | EE_Registry::instance()->CFG->environment->recheck_values(); |
82 | 82 | |
83 | - do_action( 'AHEE__EE_Admin__loaded' ); |
|
83 | + do_action('AHEE__EE_Admin__loaded'); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | |
@@ -95,11 +95,11 @@ discard block |
||
95 | 95 | * @return void |
96 | 96 | */ |
97 | 97 | private function _define_all_constants() { |
98 | - define( 'EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/' ); |
|
99 | - define( 'EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/' ); |
|
100 | - define( 'EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates' . DS ); |
|
101 | - define( 'WP_ADMIN_PATH', ABSPATH . 'wp-admin/' ); |
|
102 | - define( 'WP_AJAX_URL', admin_url( 'admin-ajax.php' )); |
|
98 | + define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL.'core/admin/'); |
|
99 | + define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL.'admin_pages/'); |
|
100 | + define('EE_ADMIN_TEMPLATE', EE_ADMIN.'templates'.DS); |
|
101 | + define('WP_ADMIN_PATH', ABSPATH.'wp-admin/'); |
|
102 | + define('WP_AJAX_URL', admin_url('admin-ajax.php')); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -112,23 +112,23 @@ discard block |
||
112 | 112 | * @param string $plugin |
113 | 113 | * @return array |
114 | 114 | */ |
115 | - public function filter_plugin_actions( $links, $plugin ) { |
|
115 | + public function filter_plugin_actions($links, $plugin) { |
|
116 | 116 | // set $main_file in stone |
117 | 117 | static $main_file; |
118 | 118 | // if $main_file is not set yet |
119 | - if ( ! $main_file ) { |
|
120 | - $main_file = plugin_basename( EVENT_ESPRESSO_MAIN_FILE ); |
|
119 | + if ( ! $main_file) { |
|
120 | + $main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE); |
|
121 | 121 | } |
122 | - if ( $plugin == $main_file ) { |
|
122 | + if ($plugin == $main_file) { |
|
123 | 123 | // compare current plugin to this one |
124 | - if ( EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance ) { |
|
125 | - $maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings" title="Event Espresso is in maintenance mode. Click this link to learn why.">' . __('Maintenance Mode Active', 'event_espresso' ) . '</a>'; |
|
126 | - array_unshift( $links, $maintenance_link ); |
|
124 | + if (EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
125 | + $maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings" title="Event Espresso is in maintenance mode. Click this link to learn why.">'.__('Maintenance Mode Active', 'event_espresso').'</a>'; |
|
126 | + array_unshift($links, $maintenance_link); |
|
127 | 127 | } else { |
128 | - $org_settings_link = '<a href="admin.php?page=espresso_general_settings">' . __( 'Settings', 'event_espresso' ) . '</a>'; |
|
129 | - $events_link = '<a href="admin.php?page=espresso_events">' . __( 'Events', 'event_espresso' ) . '</a>'; |
|
128 | + $org_settings_link = '<a href="admin.php?page=espresso_general_settings">'.__('Settings', 'event_espresso').'</a>'; |
|
129 | + $events_link = '<a href="admin.php?page=espresso_events">'.__('Events', 'event_espresso').'</a>'; |
|
130 | 130 | // add before other links |
131 | - array_unshift( $links, $org_settings_link, $events_link ); |
|
131 | + array_unshift($links, $org_settings_link, $events_link); |
|
132 | 132 | } |
133 | 133 | } |
134 | 134 | return $links; |
@@ -143,8 +143,8 @@ discard block |
||
143 | 143 | * @return void |
144 | 144 | */ |
145 | 145 | public function get_request() { |
146 | - EE_Registry::instance()->load_core( 'Request_Handler' ); |
|
147 | - EE_Registry::instance()->load_core( 'CPT_Strategy' ); |
|
146 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
147 | + EE_Registry::instance()->load_core('CPT_Strategy'); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | |
@@ -156,11 +156,11 @@ discard block |
||
156 | 156 | * @param array $admin_page_folder_names |
157 | 157 | * @return array |
158 | 158 | */ |
159 | - public function hide_admin_pages_except_maintenance_mode( $admin_page_folder_names = array() ){ |
|
159 | + public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array()) { |
|
160 | 160 | return array( |
161 | - 'maintenance' => EE_ADMIN_PAGES . 'maintenance' . DS, |
|
162 | - 'about' => EE_ADMIN_PAGES . 'about' . DS, |
|
163 | - 'support' => EE_ADMIN_PAGES . 'support' . DS |
|
161 | + 'maintenance' => EE_ADMIN_PAGES.'maintenance'.DS, |
|
162 | + 'about' => EE_ADMIN_PAGES.'about'.DS, |
|
163 | + 'support' => EE_ADMIN_PAGES.'support'.DS |
|
164 | 164 | ); |
165 | 165 | } |
166 | 166 | |
@@ -175,36 +175,36 @@ discard block |
||
175 | 175 | public function init() { |
176 | 176 | |
177 | 177 | //only enable most of the EE_Admin IF we're not in full maintenance mode |
178 | - if ( EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance ){ |
|
178 | + if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
179 | 179 | //ok so we want to enable the entire admin |
180 | - add_action( 'wp_ajax_dismiss_ee_nag_notice', array( $this, 'dismiss_ee_nag_notice_callback' )); |
|
181 | - add_action( 'save_post', array( 'EE_Admin', 'parse_post_content_on_save' ), 100, 2 ); |
|
182 | - add_action( 'update_option', array( $this, 'reset_page_for_posts_on_change' ), 100, 3 ); |
|
183 | - add_filter( 'content_save_pre', array( $this, 'its_eSpresso' ), 10, 1 ); |
|
184 | - add_action( 'admin_notices', array( $this, 'get_persistent_admin_notices' ), 9 ); |
|
185 | - add_action( 'network_admin_notices', array( $this, 'get_persistent_admin_notices' ), 9 ); |
|
180 | + add_action('wp_ajax_dismiss_ee_nag_notice', array($this, 'dismiss_ee_nag_notice_callback')); |
|
181 | + add_action('save_post', array('EE_Admin', 'parse_post_content_on_save'), 100, 2); |
|
182 | + add_action('update_option', array($this, 'reset_page_for_posts_on_change'), 100, 3); |
|
183 | + add_filter('content_save_pre', array($this, 'its_eSpresso'), 10, 1); |
|
184 | + add_action('admin_notices', array($this, 'get_persistent_admin_notices'), 9); |
|
185 | + add_action('network_admin_notices', array($this, 'get_persistent_admin_notices'), 9); |
|
186 | 186 | //at a glance dashboard widget |
187 | - add_filter( 'dashboard_glance_items', array( $this, 'dashboard_glance_items'), 10 ); |
|
187 | + add_filter('dashboard_glance_items', array($this, 'dashboard_glance_items'), 10); |
|
188 | 188 | //filter for get_edit_post_link used on comments for custom post types |
189 | - add_filter('get_edit_post_link', array( $this, 'modify_edit_post_link' ), 10, 3 ); |
|
189 | + add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 3); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | // run the admin page factory but ONLY if we are doing an ee admin ajax request |
193 | - if ( !defined('DOING_AJAX') || EE_ADMIN_AJAX ) { |
|
193 | + if ( ! defined('DOING_AJAX') || EE_ADMIN_AJAX) { |
|
194 | 194 | try { |
195 | 195 | //this loads the controller for the admin pages which will setup routing etc |
196 | - EE_Registry::instance()->load_core( 'Admin_Page_Loader' ); |
|
197 | - } catch ( EE_Error $e ) { |
|
196 | + EE_Registry::instance()->load_core('Admin_Page_Loader'); |
|
197 | + } catch (EE_Error $e) { |
|
198 | 198 | $e->get_error(); |
199 | 199 | } |
200 | 200 | } |
201 | 201 | |
202 | 202 | //make sure our CPTs and custom taxonomy metaboxes get shown for first time users |
203 | - add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes' ), 10 ); |
|
204 | - add_action('admin_head', array( $this, 'register_custom_nav_menu_boxes' ), 10 ); |
|
203 | + add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes'), 10); |
|
204 | + add_action('admin_head', array($this, 'register_custom_nav_menu_boxes'), 10); |
|
205 | 205 | |
206 | 206 | //exclude EE critical pages from all nav menus and wp_list_pages |
207 | - add_filter('nav_menu_meta_box_object', array( $this, 'remove_pages_from_nav_menu'), 10 ); |
|
207 | + add_filter('nav_menu_meta_box_object', array($this, 'remove_pages_from_nav_menu'), 10); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | |
@@ -217,9 +217,9 @@ discard block |
||
217 | 217 | * @param object $post_type WP post type object |
218 | 218 | * @return object WP post type object |
219 | 219 | */ |
220 | - public function remove_pages_from_nav_menu( $post_type ) { |
|
220 | + public function remove_pages_from_nav_menu($post_type) { |
|
221 | 221 | //if this isn't the "pages" post type let's get out |
222 | - if ( $post_type->name !== 'page' ) |
|
222 | + if ($post_type->name !== 'page') |
|
223 | 223 | return $post_type; |
224 | 224 | |
225 | 225 | $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
@@ -239,28 +239,28 @@ discard block |
||
239 | 239 | */ |
240 | 240 | public function enable_hidden_ee_nav_menu_metaboxes() { |
241 | 241 | global $wp_meta_boxes, $pagenow; |
242 | - if ( ! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php' ) { |
|
242 | + if ( ! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') { |
|
243 | 243 | return; |
244 | 244 | } |
245 | 245 | $user = wp_get_current_user(); |
246 | 246 | //has this been done yet? |
247 | - if ( get_user_option( 'ee_nav_menu_initialized', $user->ID ) ) { |
|
247 | + if (get_user_option('ee_nav_menu_initialized', $user->ID)) { |
|
248 | 248 | return; |
249 | 249 | } |
250 | 250 | |
251 | - $hidden_meta_boxes = get_user_option( 'metaboxhidden_nav-menus', $user->ID ); |
|
252 | - $initial_meta_boxes = apply_filters( 'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes', array( 'nav-menu-theme-locations', 'add-page', 'add-custom-links', 'add-category', 'add-espresso_events', 'add-espresso_venues', 'add-espresso_event_categories', 'add-espresso_venue_categories', 'add-post-type-post', 'add-post-type-page' ) ); |
|
251 | + $hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus', $user->ID); |
|
252 | + $initial_meta_boxes = apply_filters('FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes', array('nav-menu-theme-locations', 'add-page', 'add-custom-links', 'add-category', 'add-espresso_events', 'add-espresso_venues', 'add-espresso_event_categories', 'add-espresso_venue_categories', 'add-post-type-post', 'add-post-type-page')); |
|
253 | 253 | |
254 | - if ( is_array( $hidden_meta_boxes ) ) { |
|
255 | - foreach ( $hidden_meta_boxes as $key => $meta_box_id ) { |
|
256 | - if ( in_array( $meta_box_id, $initial_meta_boxes ) ) { |
|
257 | - unset( $hidden_meta_boxes[ $key ] ); |
|
254 | + if (is_array($hidden_meta_boxes)) { |
|
255 | + foreach ($hidden_meta_boxes as $key => $meta_box_id) { |
|
256 | + if (in_array($meta_box_id, $initial_meta_boxes)) { |
|
257 | + unset($hidden_meta_boxes[$key]); |
|
258 | 258 | } |
259 | 259 | } |
260 | 260 | } |
261 | 261 | |
262 | - update_user_option( $user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true ); |
|
263 | - update_user_option( $user->ID, 'ee_nav_menu_initialized', 1, true ); |
|
262 | + update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true); |
|
263 | + update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | * @return void |
280 | 280 | */ |
281 | 281 | public function register_custom_nav_menu_boxes() { |
282 | - add_meta_box( 'add-extra-nav-menu-pages', __('Event Espresso Pages', 'event_espresso'), array( $this, 'ee_cpt_archive_pages' ), 'nav-menus', 'side', 'core' ); |
|
282 | + add_meta_box('add-extra-nav-menu-pages', __('Event Espresso Pages', 'event_espresso'), array($this, 'ee_cpt_archive_pages'), 'nav-menus', 'side', 'core'); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | |
@@ -296,17 +296,17 @@ discard block |
||
296 | 296 | * |
297 | 297 | * @return string the (maybe) modified link |
298 | 298 | */ |
299 | - public function modify_edit_post_link( $link, $id, $context ) { |
|
300 | - if ( ! $post = get_post( $id ) ) |
|
299 | + public function modify_edit_post_link($link, $id, $context) { |
|
300 | + if ( ! $post = get_post($id)) |
|
301 | 301 | return $link; |
302 | 302 | |
303 | - if ( $post->post_type == 'espresso_attendees' ) { |
|
303 | + if ($post->post_type == 'espresso_attendees') { |
|
304 | 304 | $query_args = array( |
305 | 305 | 'action' => 'edit_attendee', |
306 | 306 | 'post' => $id |
307 | 307 | ); |
308 | 308 | EE_Registry::instance()->load_helper('URL'); |
309 | - return EEH_URL::add_query_args_and_nonce( $query_args, admin_url('admin.php?page=espresso_registrations') ); |
|
309 | + return EEH_URL::add_query_args_and_nonce($query_args, admin_url('admin.php?page=espresso_registrations')); |
|
310 | 310 | } |
311 | 311 | return $link; |
312 | 312 | } |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | global $nav_menu_selected_id; |
319 | 319 | |
320 | 320 | $db_fields = false; |
321 | - $walker = new Walker_Nav_Menu_Checklist( $db_fields ); |
|
321 | + $walker = new Walker_Nav_Menu_Checklist($db_fields); |
|
322 | 322 | $current_tab = 'event-archives'; |
323 | 323 | |
324 | 324 | /*if ( ! empty( $_REQUEST['quick-search-posttype-' . $post_type_name] ) ) { |
@@ -337,9 +337,9 @@ discard block |
||
337 | 337 | ?> |
338 | 338 | <div id="posttype-extra-nav-menu-pages" class="posttypediv"> |
339 | 339 | <ul id="posttype-extra-nav-menu-pages-tabs" class="posttype-tabs add-menu-item-tabs"> |
340 | - <li <?php echo ( 'event-archives' == $current_tab ? ' class="tabs"' : '' ); ?>> |
|
341 | - <a class="nav-tab-link" data-type="tabs-panel-posttype-extra-nav-menu-pages-event-archives" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg('extra-nav-menu-pages-tab', 'event-archives', remove_query_arg($removed_args))); ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives"> |
|
342 | - <?php _e( 'Event Archive Pages', 'event_espresso' ); ?> |
|
340 | + <li <?php echo ('event-archives' == $current_tab ? ' class="tabs"' : ''); ?>> |
|
341 | + <a class="nav-tab-link" data-type="tabs-panel-posttype-extra-nav-menu-pages-event-archives" href="<?php if ($nav_menu_selected_id) echo esc_url(add_query_arg('extra-nav-menu-pages-tab', 'event-archives', remove_query_arg($removed_args))); ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives"> |
|
342 | + <?php _e('Event Archive Pages', 'event_espresso'); ?> |
|
343 | 343 | </a> |
344 | 344 | </li> |
345 | 345 | <?php /* // temporarily removing but leaving skeleton in place in case we ever decide to add more tabs. |
@@ -357,13 +357,13 @@ discard block |
||
357 | 357 | <?php */ ?> |
358 | 358 | |
359 | 359 | <div id="tabs-panel-posttype-extra-nav-menu-pages-event-archives" class="tabs-panel <?php |
360 | - echo ( 'event-archives' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); |
|
360 | + echo ('event-archives' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive'); |
|
361 | 361 | ?>"> |
362 | 362 | <ul id="extra-nav-menu-pageschecklist-event-archives" class="categorychecklist form-no-clear"> |
363 | 363 | <?php |
364 | 364 | $pages = $this->_get_extra_nav_menu_pages_items(); |
365 | 365 | $args['walker'] = $walker; |
366 | - echo walk_nav_menu_tree( array_map( array( $this, '_setup_extra_nav_menu_pages_items' ), $pages), 0, (object) $args ); |
|
366 | + echo walk_nav_menu_tree(array_map(array($this, '_setup_extra_nav_menu_pages_items'), $pages), 0, (object) $args); |
|
367 | 367 | ?> |
368 | 368 | </ul> |
369 | 369 | </div><!-- /.tabs-panel --> |
@@ -371,18 +371,18 @@ discard block |
||
371 | 371 | <p class="button-controls"> |
372 | 372 | <span class="list-controls"> |
373 | 373 | <a href="<?php |
374 | - echo esc_url( add_query_arg( |
|
374 | + echo esc_url(add_query_arg( |
|
375 | 375 | array( |
376 | 376 | 'extra-nav-menu-pages-tab' => 'event-archives', |
377 | 377 | 'selectall' => 1, |
378 | 378 | ), |
379 | - remove_query_arg( $removed_args ) |
|
379 | + remove_query_arg($removed_args) |
|
380 | 380 | )); |
381 | 381 | ?>#posttype-extra-nav-menu-pages>" class="select-all"><?php _e('Select All'); ?></a> |
382 | 382 | </span> |
383 | 383 | |
384 | 384 | <span class="add-to-menu"> |
385 | - <input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( __( 'Add to Menu' ) ); ?>" name="add-post-type-menu-item" id="<?php esc_attr_e( 'submit-posttype-extra-nav-menu-pages' ); ?>" /> |
|
385 | + <input type="submit"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e(__('Add to Menu')); ?>" name="add-post-type-menu-item" id="<?php esc_attr_e('submit-posttype-extra-nav-menu-pages'); ?>" /> |
|
386 | 386 | <span class="spinner"></span> |
387 | 387 | </span> |
388 | 388 | </p> |
@@ -403,10 +403,10 @@ discard block |
||
403 | 403 | private function _get_extra_nav_menu_pages_items() { |
404 | 404 | $menuitems[] = array( |
405 | 405 | 'title' => __('Event List', 'event_espresso'), |
406 | - 'url' => get_post_type_archive_link( 'espresso_events' ), |
|
406 | + 'url' => get_post_type_archive_link('espresso_events'), |
|
407 | 407 | 'description' => __('Archive page for all events.', 'event_espresso') |
408 | 408 | ); |
409 | - return apply_filters( 'FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems ); |
|
409 | + return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems); |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | * @param $menu_item_values |
419 | 419 | * @return stdClass |
420 | 420 | */ |
421 | - private function _setup_extra_nav_menu_pages_items( $menu_item_values ) { |
|
421 | + private function _setup_extra_nav_menu_pages_items($menu_item_values) { |
|
422 | 422 | $menu_item = new stdClass(); |
423 | 423 | $keys = array( |
424 | 424 | 'ID' => 0, |
@@ -438,8 +438,8 @@ discard block |
||
438 | 438 | 'xfn' => '' |
439 | 439 | ); |
440 | 440 | |
441 | - foreach ( $keys as $key => $value) { |
|
442 | - $menu_item->{$key} = isset( $menu_item_values[ $key]) ? $menu_item_values[ $key] : $value; |
|
441 | + foreach ($keys as $key => $value) { |
|
442 | + $menu_item->{$key} = isset($menu_item_values[$key]) ? $menu_item_values[$key] : $value; |
|
443 | 443 | } |
444 | 444 | return $menu_item; |
445 | 445 | } |
@@ -478,10 +478,10 @@ discard block |
||
478 | 478 | * - check if doing post processing of one of EE CPTs |
479 | 479 | * - instantiate the corresponding EE CPT model for the post_type being processed. |
480 | 480 | */ |
481 | - if ( isset( $_POST['action'] ) && $_POST['action'] == 'editpost' ) { |
|
482 | - if ( isset( $_POST['post_type'] ) ) { |
|
483 | - EE_Registry::instance()->load_core( 'Register_CPTs' ); |
|
484 | - EE_Register_CPTs::instantiate_cpt_models( $_POST['post_type'] ); |
|
481 | + if (isset($_POST['action']) && $_POST['action'] == 'editpost') { |
|
482 | + if (isset($_POST['post_type'])) { |
|
483 | + EE_Registry::instance()->load_core('Register_CPTs'); |
|
484 | + EE_Register_CPTs::instantiate_cpt_models($_POST['post_type']); |
|
485 | 485 | } |
486 | 486 | } |
487 | 487 | |
@@ -491,8 +491,8 @@ discard block |
||
491 | 491 | * 'options-reading.php' core WordPress admin settings page. This is for user-proofing. |
492 | 492 | */ |
493 | 493 | global $pagenow; |
494 | - if ( $pagenow == 'options-reading.php' ) { |
|
495 | - add_filter( 'wp_dropdown_pages', array( $this, 'modify_dropdown_pages' ) ); |
|
494 | + if ($pagenow == 'options-reading.php') { |
|
495 | + add_filter('wp_dropdown_pages', array($this, 'modify_dropdown_pages')); |
|
496 | 496 | } |
497 | 497 | |
498 | 498 | } |
@@ -504,25 +504,25 @@ discard block |
||
504 | 504 | * @param string $output Current output. |
505 | 505 | * @return string |
506 | 506 | */ |
507 | - public function modify_dropdown_pages( $output ) { |
|
507 | + public function modify_dropdown_pages($output) { |
|
508 | 508 | //get critical pages |
509 | 509 | $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
510 | 510 | |
511 | 511 | //split current output by line break for easier parsing. |
512 | - $split_output = explode( "\n", $output ); |
|
512 | + $split_output = explode("\n", $output); |
|
513 | 513 | |
514 | 514 | //loop through to remove any critical pages from the array. |
515 | - foreach ( $critical_pages as $page_id ) { |
|
516 | - $needle = 'value="' . $page_id . '"'; |
|
517 | - foreach( $split_output as $key => $haystack ) { |
|
518 | - if( strpos( $haystack, $needle ) !== false ) { |
|
519 | - unset( $split_output[$key] ); |
|
515 | + foreach ($critical_pages as $page_id) { |
|
516 | + $needle = 'value="'.$page_id.'"'; |
|
517 | + foreach ($split_output as $key => $haystack) { |
|
518 | + if (strpos($haystack, $needle) !== false) { |
|
519 | + unset($split_output[$key]); |
|
520 | 520 | } |
521 | 521 | } |
522 | 522 | } |
523 | 523 | |
524 | 524 | //replace output with the new contents |
525 | - $output = implode( "\n", $split_output ); |
|
525 | + $output = implode("\n", $split_output); |
|
526 | 526 | |
527 | 527 | return $output; |
528 | 528 | } |
@@ -538,37 +538,37 @@ discard block |
||
538 | 538 | public function enqueue_admin_scripts() { |
539 | 539 | // this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js. |
540 | 540 | // Note: the intention of this script is to only do TARGETED injections. I.E, only injecting on certain script calls. |
541 | - wp_enqueue_script('ee-inject-wp', EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
541 | + wp_enqueue_script('ee-inject-wp', EE_ADMIN_URL.'assets/ee-cpt-wp-injects.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
542 | 542 | // register cookie script for future dependencies |
543 | - wp_register_script('jquery-cookie', EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js', array('jquery'), '2.1', TRUE ); |
|
543 | + wp_register_script('jquery-cookie', EE_THIRD_PARTY_URL.'joyride/jquery.cookie.js', array('jquery'), '2.1', TRUE); |
|
544 | 544 | // jquery_validate loading is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again via: add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
545 | - if ( apply_filters( 'FHEE_load_jquery_validate', FALSE ) ) { |
|
545 | + if (apply_filters('FHEE_load_jquery_validate', FALSE)) { |
|
546 | 546 | // register jQuery Validate |
547 | - wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', array('jquery'), '1.15.0', TRUE); |
|
547 | + wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js', array('jquery'), '1.15.0', TRUE); |
|
548 | 548 | } |
549 | 549 | //joyride is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again vai: add_filter('FHEE_load_joyride', '__return_true' ); |
550 | - if ( apply_filters( 'FHEE_load_joyride', FALSE ) ) { |
|
550 | + if (apply_filters('FHEE_load_joyride', FALSE)) { |
|
551 | 551 | //joyride style |
552 | - wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1'); |
|
553 | - wp_register_style('ee-joyride-css', EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css', array('joyride-css'), EVENT_ESPRESSO_VERSION ); |
|
554 | - wp_register_script('joyride-modernizr', EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js', array(), '2.1', TRUE ); |
|
552 | + wp_register_style('joyride-css', EE_THIRD_PARTY_URL.'joyride/joyride-2.1.css', array(), '2.1'); |
|
553 | + wp_register_style('ee-joyride-css', EE_GLOBAL_ASSETS_URL.'css/ee-joyride-styles.css', array('joyride-css'), EVENT_ESPRESSO_VERSION); |
|
554 | + wp_register_script('joyride-modernizr', EE_THIRD_PARTY_URL.'joyride/modernizr.mq.js', array(), '2.1', TRUE); |
|
555 | 555 | //joyride JS |
556 | - wp_register_script('jquery-joyride', EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js', array('jquery-cookie', 'joyride-modernizr'), '2.1', TRUE ); |
|
556 | + wp_register_script('jquery-joyride', EE_THIRD_PARTY_URL.'joyride/jquery.joyride-2.1.js', array('jquery-cookie', 'joyride-modernizr'), '2.1', TRUE); |
|
557 | 557 | // wanna go for a joyride? |
558 | 558 | wp_enqueue_style('ee-joyride-css'); |
559 | 559 | wp_enqueue_script('jquery-joyride'); |
560 | 560 | } |
561 | 561 | //qtip is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again via: add_filter('FHEE_load_qtips', '__return_true' ); |
562 | - if ( apply_filters( 'FHEE_load_qtip', FALSE ) ) { |
|
562 | + if (apply_filters('FHEE_load_qtip', FALSE)) { |
|
563 | 563 | EE_Registry::instance()->load_helper('Qtip_Loader'); |
564 | 564 | EEH_Qtip_Loader::instance()->register_and_enqueue(); |
565 | 565 | } |
566 | 566 | //accounting.js library |
567 | 567 | // @link http://josscrowcroft.github.io/accounting.js/ |
568 | - if ( apply_filters( 'FHEE_load_accounting_js', FALSE ) ) { |
|
569 | - wp_register_script( 'ee-accounting', EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', array('ee-accounting-core'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
570 | - wp_register_script( 'ee-accounting-core', EE_THIRD_PARTY_URL . 'accounting/accounting.js', array('underscore'), '0.3.2', TRUE ); |
|
571 | - wp_enqueue_script( 'ee-accounting' ); |
|
568 | + if (apply_filters('FHEE_load_accounting_js', FALSE)) { |
|
569 | + wp_register_script('ee-accounting', EE_GLOBAL_ASSETS_URL.'scripts/ee-accounting-config.js', array('ee-accounting-core'), EVENT_ESPRESSO_VERSION, TRUE); |
|
570 | + wp_register_script('ee-accounting-core', EE_THIRD_PARTY_URL.'accounting/accounting.js', array('underscore'), '0.3.2', TRUE); |
|
571 | + wp_enqueue_script('ee-accounting'); |
|
572 | 572 | // array of settings to get converted to JSON array via wp_localize_script |
573 | 573 | $currency_config = array( |
574 | 574 | 'currency' => array( |
@@ -615,11 +615,11 @@ discard block |
||
615 | 615 | public function get_persistent_admin_notices() { |
616 | 616 | // http://www.example.com/wp-admin/admin.php?page=espresso_general_settings&action=critical_pages&critical_pages_nonce=2831ce0f30 |
617 | 617 | $args = array( |
618 | - 'page' => EE_Registry::instance()->REQ->is_set( 'page' ) ? EE_Registry::instance()->REQ->get( 'page' ) : '', |
|
619 | - 'action' => EE_Registry::instance()->REQ->is_set( 'action' ) ? EE_Registry::instance()->REQ->get( 'action' ) : '', |
|
618 | + 'page' => EE_Registry::instance()->REQ->is_set('page') ? EE_Registry::instance()->REQ->get('page') : '', |
|
619 | + 'action' => EE_Registry::instance()->REQ->is_set('action') ? EE_Registry::instance()->REQ->get('action') : '', |
|
620 | 620 | ); |
621 | - $return_url = EE_Admin_Page::add_query_args_and_nonce( $args, EE_ADMIN_URL ); |
|
622 | - echo EE_Error::get_persistent_admin_notices( $return_url ); |
|
621 | + $return_url = EE_Admin_Page::add_query_args_and_nonce($args, EE_ADMIN_URL); |
|
622 | + echo EE_Error::get_persistent_admin_notices($return_url); |
|
623 | 623 | } |
624 | 624 | |
625 | 625 | |
@@ -640,26 +640,26 @@ discard block |
||
640 | 640 | * @param $elements |
641 | 641 | * @return array |
642 | 642 | */ |
643 | - public function dashboard_glance_items( $elements ) { |
|
643 | + public function dashboard_glance_items($elements) { |
|
644 | 644 | $events = EEM_Event::instance()->count(); |
645 | - $items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce( array('page' => 'espresso_events'), admin_url('admin.php') ); |
|
646 | - $items['events']['text'] = sprintf( _n( '%s Event', '%s Events', $events ), number_format_i18n( $events ) ); |
|
645 | + $items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce(array('page' => 'espresso_events'), admin_url('admin.php')); |
|
646 | + $items['events']['text'] = sprintf(_n('%s Event', '%s Events', $events), number_format_i18n($events)); |
|
647 | 647 | $items['events']['title'] = __('Click to view all Events', 'event_espresso'); |
648 | 648 | $registrations = EEM_Registration::instance()->count( |
649 | 649 | array( |
650 | 650 | array( |
651 | - 'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete ) |
|
651 | + 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete) |
|
652 | 652 | ) |
653 | 653 | ) |
654 | 654 | ); |
655 | - $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce( array('page' => 'espresso_registrations' ), admin_url('admin.php') ); |
|
656 | - $items['registrations']['text'] = sprintf( _n( '%s Registration', '%s Registrations', $registrations ), number_format_i18n($registrations) ); |
|
655 | + $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce(array('page' => 'espresso_registrations'), admin_url('admin.php')); |
|
656 | + $items['registrations']['text'] = sprintf(_n('%s Registration', '%s Registrations', $registrations), number_format_i18n($registrations)); |
|
657 | 657 | $items['registrations']['title'] = __('Click to view all registrations', 'event_espresso'); |
658 | 658 | |
659 | - $items = apply_filters( 'FHEE__EE_Admin__dashboard_glance_items__items', $items ); |
|
659 | + $items = apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items); |
|
660 | 660 | |
661 | - foreach ( $items as $type => $item_properties ) { |
|
662 | - $elements[] = sprintf( '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>', $item_properties['url'], $item_properties['title'], $item_properties['text'] ); |
|
661 | + foreach ($items as $type => $item_properties) { |
|
662 | + $elements[] = sprintf('<a class="ee-dashboard-link-'.$type.'" href="%s" title="%s">%s</a>', $item_properties['url'], $item_properties['title'], $item_properties['text']); |
|
663 | 663 | } |
664 | 664 | return $elements; |
665 | 665 | } |
@@ -678,63 +678,63 @@ discard block |
||
678 | 678 | * @param $post |
679 | 679 | * @return void |
680 | 680 | */ |
681 | - public static function parse_post_content_on_save( $post_ID, $post ) { |
|
681 | + public static function parse_post_content_on_save($post_ID, $post) { |
|
682 | 682 | // default post types |
683 | - $post_types = array( 'post' => 0, 'page' => 1 ); |
|
683 | + $post_types = array('post' => 0, 'page' => 1); |
|
684 | 684 | // add CPTs |
685 | 685 | $CPTs = EE_Register_CPTs::get_CPTs(); |
686 | - $post_types = array_merge( $post_types, $CPTs ); |
|
686 | + $post_types = array_merge($post_types, $CPTs); |
|
687 | 687 | // for default or CPT posts... |
688 | - if ( isset( $post_types[ $post->post_type ] )) { |
|
688 | + if (isset($post_types[$post->post_type])) { |
|
689 | 689 | // post on frontpage ? |
690 | 690 | $page_for_posts = EE_Config::get_page_for_posts(); |
691 | 691 | $maybe_remove_from_posts = array(); |
692 | 692 | // critical page shortcodes that we do NOT want added to the Posts page (blog) |
693 | 693 | $critical_shortcodes = EE_Registry::instance()->CFG->core->get_critical_pages_shortcodes_array(); |
694 | 694 | // array of shortcodes indexed by post name |
695 | - EE_Registry::instance()->CFG->core->post_shortcodes = isset( EE_Registry::instance()->CFG->core->post_shortcodes ) ? EE_Registry::instance()->CFG->core->post_shortcodes : array(); |
|
695 | + EE_Registry::instance()->CFG->core->post_shortcodes = isset(EE_Registry::instance()->CFG->core->post_shortcodes) ? EE_Registry::instance()->CFG->core->post_shortcodes : array(); |
|
696 | 696 | // whether to proceed with update, if an entry already exists for this post, then we want to update |
697 | - $update_post_shortcodes = isset( EE_Registry::instance()->CFG->core->post_shortcodes[ $post->post_name ] ) ? true : false; |
|
697 | + $update_post_shortcodes = isset(EE_Registry::instance()->CFG->core->post_shortcodes[$post->post_name]) ? true : false; |
|
698 | 698 | // empty both arrays |
699 | - EE_Registry::instance()->CFG->core->post_shortcodes[ $post->post_name ] = array(); |
|
699 | + EE_Registry::instance()->CFG->core->post_shortcodes[$post->post_name] = array(); |
|
700 | 700 | // check that posts page is already being tracked |
701 | - if ( ! isset( EE_Registry::instance()->CFG->core->post_shortcodes[ $page_for_posts ] ) ) { |
|
701 | + if ( ! isset(EE_Registry::instance()->CFG->core->post_shortcodes[$page_for_posts])) { |
|
702 | 702 | // if not, then ensure that it is properly added |
703 | - EE_Registry::instance()->CFG->core->post_shortcodes[ $page_for_posts ] = array(); |
|
703 | + EE_Registry::instance()->CFG->core->post_shortcodes[$page_for_posts] = array(); |
|
704 | 704 | } |
705 | 705 | // loop thru shortcodes |
706 | - foreach ( EE_Registry::instance()->shortcodes as $EES_Shortcode => $shortcode_dir ) { |
|
706 | + foreach (EE_Registry::instance()->shortcodes as $EES_Shortcode => $shortcode_dir) { |
|
707 | 707 | // convert to UPPERCASE to get actual shortcode |
708 | - $EES_Shortcode = strtoupper( $EES_Shortcode ); |
|
708 | + $EES_Shortcode = strtoupper($EES_Shortcode); |
|
709 | 709 | // is the shortcode in the post_content ? |
710 | - if ( strpos( $post->post_content, $EES_Shortcode ) !== FALSE ) { |
|
710 | + if (strpos($post->post_content, $EES_Shortcode) !== FALSE) { |
|
711 | 711 | // map shortcode to post names and post IDs |
712 | - EE_Registry::instance()->CFG->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] = $post_ID; |
|
712 | + EE_Registry::instance()->CFG->core->post_shortcodes[$post->post_name][$EES_Shortcode] = $post_ID; |
|
713 | 713 | // if the shortcode is NOT one of the critical page shortcodes like ESPRESSO_TXN_PAGE |
714 | - if ( ! in_array( $EES_Shortcode, $critical_shortcodes )) { |
|
714 | + if ( ! in_array($EES_Shortcode, $critical_shortcodes)) { |
|
715 | 715 | // add shortcode to "Posts page" tracking |
716 | - EE_Registry::instance()->CFG->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] = $post_ID; |
|
716 | + EE_Registry::instance()->CFG->core->post_shortcodes[$page_for_posts][$EES_Shortcode] = $post_ID; |
|
717 | 717 | } |
718 | 718 | $update_post_shortcodes = TRUE; |
719 | - unset( $maybe_remove_from_posts[ $EES_Shortcode ] ); |
|
719 | + unset($maybe_remove_from_posts[$EES_Shortcode]); |
|
720 | 720 | } else { |
721 | - $maybe_remove_from_posts[ $EES_Shortcode ] = $post_ID; |
|
721 | + $maybe_remove_from_posts[$EES_Shortcode] = $post_ID; |
|
722 | 722 | } |
723 | 723 | } |
724 | - if ( $update_post_shortcodes ) { |
|
724 | + if ($update_post_shortcodes) { |
|
725 | 725 | // remove shortcodes from $maybe_remove_from_posts that are still being used |
726 | - foreach ( EE_Registry::instance()->CFG->core->post_shortcodes as $post_name => $shortcodes ) { |
|
727 | - if ( $post_name == $page_for_posts ) { |
|
726 | + foreach (EE_Registry::instance()->CFG->core->post_shortcodes as $post_name => $shortcodes) { |
|
727 | + if ($post_name == $page_for_posts) { |
|
728 | 728 | continue; |
729 | 729 | } |
730 | 730 | // compute difference between active post_shortcodes array and $maybe_remove_from_posts array |
731 | - $maybe_remove_from_posts = array_diff_key( $maybe_remove_from_posts, $shortcodes ); |
|
731 | + $maybe_remove_from_posts = array_diff_key($maybe_remove_from_posts, $shortcodes); |
|
732 | 732 | } |
733 | 733 | // now unset unused shortcodes from the $page_for_posts post_shortcodes |
734 | - foreach ( $maybe_remove_from_posts as $shortcode => $post_ID ) { |
|
735 | - unset( EE_Registry::instance()->CFG->core->post_shortcodes[ $page_for_posts ][ $shortcode ] ); |
|
734 | + foreach ($maybe_remove_from_posts as $shortcode => $post_ID) { |
|
735 | + unset(EE_Registry::instance()->CFG->core->post_shortcodes[$page_for_posts][$shortcode]); |
|
736 | 736 | } |
737 | - EE_Registry::instance()->CFG->update_post_shortcodes( $page_for_posts ); |
|
737 | + EE_Registry::instance()->CFG->update_post_shortcodes($page_for_posts); |
|
738 | 738 | } |
739 | 739 | } |
740 | 740 | } |
@@ -752,32 +752,32 @@ discard block |
||
752 | 752 | * @throws EE_Error |
753 | 753 | * @return string |
754 | 754 | */ |
755 | - public function check_for_invalid_datetime_formats( $value, $option ) { |
|
756 | - EE_Registry::instance()->load_helper( 'DTT_Helper' ); |
|
755 | + public function check_for_invalid_datetime_formats($value, $option) { |
|
756 | + EE_Registry::instance()->load_helper('DTT_Helper'); |
|
757 | 757 | // check for date_format or time_format |
758 | - switch ( $option ) { |
|
758 | + switch ($option) { |
|
759 | 759 | case 'date_format' : |
760 | - $date_time_format = $value . ' ' . get_option('time_format'); |
|
760 | + $date_time_format = $value.' '.get_option('time_format'); |
|
761 | 761 | break; |
762 | 762 | case 'time_format' : |
763 | - $date_time_format = get_option('date_format') . ' ' . $value; |
|
763 | + $date_time_format = get_option('date_format').' '.$value; |
|
764 | 764 | break; |
765 | 765 | default : |
766 | 766 | $date_time_format = FALSE; |
767 | 767 | } |
768 | 768 | // do we have a date_time format to check ? |
769 | - if ( $date_time_format ) { |
|
770 | - $error_msg = EEH_DTT_Helper::validate_format_string( $date_time_format ); |
|
769 | + if ($date_time_format) { |
|
770 | + $error_msg = EEH_DTT_Helper::validate_format_string($date_time_format); |
|
771 | 771 | |
772 | - if ( is_array( $error_msg ) ) { |
|
773 | - $msg = '<p>' . sprintf( __( 'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:', 'event_espresso' ), date( $date_time_format ) , $date_time_format ) . '</p><p><ul>'; |
|
772 | + if (is_array($error_msg)) { |
|
773 | + $msg = '<p>'.sprintf(__('The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:', 'event_espresso'), date($date_time_format), $date_time_format).'</p><p><ul>'; |
|
774 | 774 | |
775 | 775 | |
776 | - foreach ( $error_msg as $error ) { |
|
777 | - $msg .= '<li>' . $error . '</li>'; |
|
776 | + foreach ($error_msg as $error) { |
|
777 | + $msg .= '<li>'.$error.'</li>'; |
|
778 | 778 | } |
779 | 779 | |
780 | - $msg .= '</ul></p><p>' . sprintf( __( '%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s', 'event_espresso' ), '<span style="color:#D54E21;">', '</span>' ) . '</p>'; |
|
780 | + $msg .= '</ul></p><p>'.sprintf(__('%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s', 'event_espresso'), '<span style="color:#D54E21;">', '</span>').'</p>'; |
|
781 | 781 | |
782 | 782 | // trigger WP settings error |
783 | 783 | add_settings_error( |
@@ -787,7 +787,7 @@ discard block |
||
787 | 787 | ); |
788 | 788 | |
789 | 789 | // set format to something valid |
790 | - switch ( $option ) { |
|
790 | + switch ($option) { |
|
791 | 791 | case 'date_format' : |
792 | 792 | $value = 'F j, Y'; |
793 | 793 | break; |
@@ -813,14 +813,14 @@ discard block |
||
813 | 813 | * @param $value |
814 | 814 | * @return void |
815 | 815 | */ |
816 | - public function reset_page_for_posts_on_change( $option, $old_value, $value ) { |
|
817 | - if ( $option == 'page_for_posts' ) { |
|
816 | + public function reset_page_for_posts_on_change($option, $old_value, $value) { |
|
817 | + if ($option == 'page_for_posts') { |
|
818 | 818 | global $wpdb; |
819 | - $SQL = 'SELECT post_name from ' . $wpdb->posts . ' WHERE post_type="posts" OR post_type="page" AND post_status="publish" AND ID=%s'; |
|
820 | - $old_page_for_posts = $old_value ? $wpdb->get_var( $wpdb->prepare( $SQL, $old_value )) : 'posts'; |
|
821 | - $new_page_for_posts = $value ? $wpdb->get_var( $wpdb->prepare( $SQL, $value )) : 'posts'; |
|
822 | - EE_Registry::instance()->CFG->core->post_shortcodes[ $new_page_for_posts ] = EE_Registry::instance()->CFG->core->post_shortcodes[ $old_page_for_posts ]; |
|
823 | - EE_Registry::instance()->CFG->update_post_shortcodes( $new_page_for_posts ); |
|
819 | + $SQL = 'SELECT post_name from '.$wpdb->posts.' WHERE post_type="posts" OR post_type="page" AND post_status="publish" AND ID=%s'; |
|
820 | + $old_page_for_posts = $old_value ? $wpdb->get_var($wpdb->prepare($SQL, $old_value)) : 'posts'; |
|
821 | + $new_page_for_posts = $value ? $wpdb->get_var($wpdb->prepare($SQL, $value)) : 'posts'; |
|
822 | + EE_Registry::instance()->CFG->core->post_shortcodes[$new_page_for_posts] = EE_Registry::instance()->CFG->core->post_shortcodes[$old_page_for_posts]; |
|
823 | + EE_Registry::instance()->CFG->update_post_shortcodes($new_page_for_posts); |
|
824 | 824 | } |
825 | 825 | } |
826 | 826 | |
@@ -833,8 +833,8 @@ discard block |
||
833 | 833 | * @param $content |
834 | 834 | * @return string |
835 | 835 | */ |
836 | - public function its_eSpresso( $content ) { |
|
837 | - return str_replace( '[EXPRESSO_', '[ESPRESSO_', $content ); |
|
836 | + public function its_eSpresso($content) { |
|
837 | + return str_replace('[EXPRESSO_', '[ESPRESSO_', $content); |
|
838 | 838 | } |
839 | 839 | |
840 | 840 | |
@@ -847,9 +847,9 @@ discard block |
||
847 | 847 | */ |
848 | 848 | public function espresso_admin_footer() { |
849 | 849 | return sprintf( |
850 | - __( 'Event Registration and Ticketing Powered by %sEvent Registration Powered by Event Espresso%s', 'event_espresso' ), |
|
850 | + __('Event Registration and Ticketing Powered by %sEvent Registration Powered by Event Espresso%s', 'event_espresso'), |
|
851 | 851 | '<a href="https://eventespresso.com/" title="', |
852 | - '">' . EVENT_ESPRESSO_POWERED_BY . '</a>' |
|
852 | + '">'.EVENT_ESPRESSO_POWERED_BY.'</a>' |
|
853 | 853 | ); |
854 | 854 | } |
855 | 855 | |
@@ -869,11 +869,11 @@ discard block |
||
869 | 869 | * @param array $config |
870 | 870 | * @return void |
871 | 871 | */ |
872 | - public static function register_ee_admin_page( $page_basename, $page_path, $config = array() ) { |
|
873 | - EE_Error::doing_it_wrong( __METHOD__, sprintf( __('Usage is deprecated. Use EE_Register_Admin_Page::register() for registering the %s admin page.', 'event_espresso'), $page_basename), '4.3' ); |
|
874 | - if ( class_exists( 'EE_Register_Admin_Page' ) ) |
|
872 | + public static function register_ee_admin_page($page_basename, $page_path, $config = array()) { |
|
873 | + EE_Error::doing_it_wrong(__METHOD__, sprintf(__('Usage is deprecated. Use EE_Register_Admin_Page::register() for registering the %s admin page.', 'event_espresso'), $page_basename), '4.3'); |
|
874 | + if (class_exists('EE_Register_Admin_Page')) |
|
875 | 875 | $config['page_path'] = $page_path; |
876 | - EE_Register_Admin_Page::register( $page_basename, $config ); |
|
876 | + EE_Register_Admin_Page::register($page_basename, $config); |
|
877 | 877 | } |
878 | 878 | |
879 | 879 |
@@ -1,14 +1,14 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Espresso Template functions |
|
4 | - * |
|
5 | - * @ package Event Espresso |
|
6 | - * @ author Seth Shoultes |
|
7 | - * @ copyright (c) 2008-2014 Event Espresso All Rights Reserved. |
|
8 | - * @ license http://venueespresso.com/support/terms-conditions/ * see Plugin Licensing * |
|
9 | - * @ link http://www.eventespresso.com |
|
10 | - * @ version 4+ |
|
11 | - */ |
|
3 | + * Espresso Template functions |
|
4 | + * |
|
5 | + * @ package Event Espresso |
|
6 | + * @ author Seth Shoultes |
|
7 | + * @ copyright (c) 2008-2014 Event Espresso All Rights Reserved. |
|
8 | + * @ license http://venueespresso.com/support/terms-conditions/ * see Plugin Licensing * |
|
9 | + * @ link http://www.eventespresso.com |
|
10 | + * @ version 4+ |
|
11 | + */ |
|
12 | 12 | define( 'EE_THEME_FUNCTIONS_LOADED', TRUE ); |
13 | 13 | |
14 | 14 | /** |
@@ -9,9 +9,9 @@ discard block |
||
9 | 9 | * @ link http://www.eventespresso.com |
10 | 10 | * @ version 4+ |
11 | 11 | */ |
12 | -define( 'EE_THEME_FUNCTIONS_LOADED', TRUE ); |
|
12 | +define('EE_THEME_FUNCTIONS_LOADED', TRUE); |
|
13 | 13 | |
14 | -if ( ! function_exists( 'espresso_pagination' ) ) { |
|
14 | +if ( ! function_exists('espresso_pagination')) { |
|
15 | 15 | /** |
16 | 16 | * espresso_pagination |
17 | 17 | * |
@@ -23,21 +23,21 @@ discard block |
||
23 | 23 | $big = 999999999; // need an unlikely integer |
24 | 24 | $pagination = paginate_links( |
25 | 25 | array( |
26 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
26 | + 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
27 | 27 | 'format' => '?paged=%#%', |
28 | - 'current' => max( 1, get_query_var( 'paged' ) ), |
|
28 | + 'current' => max(1, get_query_var('paged')), |
|
29 | 29 | 'total' => $wp_query->max_num_pages, |
30 | 30 | 'show_all' => true, |
31 | 31 | 'end_size' => 10, |
32 | 32 | 'mid_size' => 6, |
33 | 33 | 'prev_next' => true, |
34 | - 'prev_text' => __( '‹ PREV', 'event_espresso' ), |
|
35 | - 'next_text' => __( 'NEXT ›', 'event_espresso' ), |
|
34 | + 'prev_text' => __('‹ PREV', 'event_espresso'), |
|
35 | + 'next_text' => __('NEXT ›', 'event_espresso'), |
|
36 | 36 | 'type' => 'plain', |
37 | 37 | 'add_args' => false, |
38 | 38 | 'add_fragment' => '' |
39 | 39 | ) |
40 | 40 | ); |
41 | - echo ! empty( $pagination ) ? '<div class="ee-pagination-dv clear">' . $pagination . '</div>' : ''; |
|
41 | + echo ! empty($pagination) ? '<div class="ee-pagination-dv clear">'.$pagination.'</div>' : ''; |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | \ No newline at end of file |
@@ -1,14 +1,14 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * This template will display The Loop that displays your venues |
|
4 | - * |
|
5 | - * @ package Event Espresso |
|
6 | - * @ author Seth Shoultes |
|
7 | - * @ copyright (c) 2008-2013 Event Espresso All Rights Reserved. |
|
8 | - * @ license http://eventespresso.com/support/terms-conditions/ * see Plugin Licensing * |
|
9 | - * @ link http://www.eventespresso.com |
|
10 | - * @ version 4+ |
|
11 | - */ |
|
3 | + * This template will display The Loop that displays your venues |
|
4 | + * |
|
5 | + * @ package Event Espresso |
|
6 | + * @ author Seth Shoultes |
|
7 | + * @ copyright (c) 2008-2013 Event Espresso All Rights Reserved. |
|
8 | + * @ license http://eventespresso.com/support/terms-conditions/ * see Plugin Licensing * |
|
9 | + * @ link http://www.eventespresso.com |
|
10 | + * @ version 4+ |
|
11 | + */ |
|
12 | 12 | |
13 | 13 | if ( have_posts() ) : ?> |
14 | 14 |
@@ -1,15 +1,15 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * This template will display The Loop that displays your events |
|
4 | - * DO NOT COPY THIS TEMPLATE TO YOUR THEMES FOLDER |
|
5 | - * |
|
6 | - * @ package Event Espresso |
|
7 | - * @ author Seth Shoultes |
|
8 | - * @ copyright (c) 2008-2013 Event Espresso All Rights Reserved. |
|
9 | - * @ license http://eventespresso.com/support/terms-conditions/ * see Plugin Licensing * |
|
10 | - * @ link http://www.eventespresso.com |
|
11 | - * @ version 4+ |
|
12 | - */ |
|
3 | + * This template will display The Loop that displays your events |
|
4 | + * DO NOT COPY THIS TEMPLATE TO YOUR THEMES FOLDER |
|
5 | + * |
|
6 | + * @ package Event Espresso |
|
7 | + * @ author Seth Shoultes |
|
8 | + * @ copyright (c) 2008-2013 Event Espresso All Rights Reserved. |
|
9 | + * @ license http://eventespresso.com/support/terms-conditions/ * see Plugin Licensing * |
|
10 | + * @ link http://www.eventespresso.com |
|
11 | + * @ version 4+ |
|
12 | + */ |
|
13 | 13 | |
14 | 14 | if ( have_posts() ) : ?> |
15 | 15 |