@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object. |
45 | 45 | * @return \Payments_Admin_Page |
46 | 46 | */ |
47 | - public function __construct( $routing = TRUE ) { |
|
48 | - parent::__construct( $routing ); |
|
47 | + public function __construct($routing = TRUE) { |
|
48 | + parent::__construct($routing); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | |
@@ -130,19 +130,19 @@ discard block |
||
130 | 130 | protected function _set_page_config() { |
131 | 131 | $payment_method_list_config = array( |
132 | 132 | 'nav' => array( |
133 | - 'label' => __( 'Payment Methods', 'event_espresso' ), |
|
133 | + 'label' => __('Payment Methods', 'event_espresso'), |
|
134 | 134 | 'order' => 10 |
135 | 135 | ), |
136 | 136 | 'metaboxes' => $this->_default_espresso_metaboxes, |
137 | 137 | 'help_tabs' => array_merge( |
138 | 138 | array( |
139 | 139 | 'payment_methods_overview_help_tab' => array( |
140 | - 'title' => __( 'Payment Methods Overview', 'event_espresso' ), |
|
140 | + 'title' => __('Payment Methods Overview', 'event_espresso'), |
|
141 | 141 | 'filename' => 'payment_methods_overview' |
142 | 142 | ) |
143 | 143 | ), |
144 | 144 | $this->_add_payment_method_help_tabs() ), |
145 | - 'help_tour' => array( 'Payment_Methods_Selection_Help_Tour' ), |
|
145 | + 'help_tour' => array('Payment_Methods_Selection_Help_Tour'), |
|
146 | 146 | 'require_nonce' => false |
147 | 147 | ); |
148 | 148 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | ) |
161 | 161 | ), |
162 | 162 | //'help_tour' => array( 'Payment_Methods_Settings_Help_Tour' ), |
163 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_publish_post_box' ) ), |
|
163 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
164 | 164 | 'require_nonce' => FALSE |
165 | 165 | ), |
166 | 166 | 'payment_log'=>array( |
@@ -179,18 +179,18 @@ discard block |
||
179 | 179 | /** |
180 | 180 | * @return array |
181 | 181 | */ |
182 | - protected function _add_payment_method_help_tabs(){ |
|
182 | + protected function _add_payment_method_help_tabs() { |
|
183 | 183 | EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
184 | 184 | $payment_method_types = EE_Payment_Method_Manager::instance()->payment_method_types(); |
185 | 185 | $all_pmt_help_tabs_config = array(); |
186 | - foreach( $payment_method_types as $payment_method_type ){ |
|
187 | - if ( ! EE_Registry::instance()->CAP->current_user_can( $payment_method_type->cap_name(), 'specific_payment_method_type_access' ) ) { |
|
186 | + foreach ($payment_method_types as $payment_method_type) { |
|
187 | + if ( ! EE_Registry::instance()->CAP->current_user_can($payment_method_type->cap_name(), 'specific_payment_method_type_access')) { |
|
188 | 188 | continue; |
189 | 189 | } |
190 | - foreach( $payment_method_type->help_tabs_config() as $help_tab_name => $config ){ |
|
190 | + foreach ($payment_method_type->help_tabs_config() as $help_tab_name => $config) { |
|
191 | 191 | $all_pmt_help_tabs_config[$help_tab_name] = array( |
192 | 192 | 'title'=>$config['title'], |
193 | - 'content'=>EEH_Template::display_template( $payment_method_type->file_folder().'help_tabs'.DS.$config['filename'].'.help_tab.php', array('admin_page_obj'=>$this), true) |
|
193 | + 'content'=>EEH_Template::display_template($payment_method_type->file_folder().'help_tabs'.DS.$config['filename'].'.help_tab.php', array('admin_page_obj'=>$this), true) |
|
194 | 194 | ); |
195 | 195 | } |
196 | 196 | } |
@@ -211,9 +211,9 @@ discard block |
||
211 | 211 | |
212 | 212 | |
213 | 213 | public function load_scripts_styles() { |
214 | - wp_enqueue_script( 'ee_admin_js' ); |
|
215 | - wp_enqueue_script( 'ee-text-links' ); |
|
216 | - wp_enqueue_script( 'espresso_payments', EE_PAYMENTS_ASSETS_URL . 'espresso_payments_admin.js', array( 'espresso-ui-theme', 'ee-datepicker' ), EVENT_ESPRESSO_VERSION, TRUE ); |
|
214 | + wp_enqueue_script('ee_admin_js'); |
|
215 | + wp_enqueue_script('ee-text-links'); |
|
216 | + wp_enqueue_script('espresso_payments', EE_PAYMENTS_ASSETS_URL.'espresso_payments_admin.js', array('espresso-ui-theme', 'ee-datepicker'), EVENT_ESPRESSO_VERSION, TRUE); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | |
@@ -222,9 +222,9 @@ discard block |
||
222 | 222 | |
223 | 223 | public function load_scripts_styles_default() { |
224 | 224 | //styles |
225 | - wp_register_style( 'espresso_payments', EE_PAYMENTS_ASSETS_URL . 'ee-payments.css', array(), EVENT_ESPRESSO_VERSION ); |
|
226 | - wp_enqueue_style( 'espresso_payments' ); |
|
227 | - wp_enqueue_style( 'ee-text-links' ); |
|
225 | + wp_register_style('espresso_payments', EE_PAYMENTS_ASSETS_URL.'ee-payments.css', array(), EVENT_ESPRESSO_VERSION); |
|
226 | + wp_enqueue_style('espresso_payments'); |
|
227 | + wp_enqueue_style('ee-text-links'); |
|
228 | 228 | //scripts |
229 | 229 | } |
230 | 230 | |
@@ -238,46 +238,46 @@ discard block |
||
238 | 238 | * to the loading process. However, people MUST setup the details for the payment method so its safe to do a |
239 | 239 | * recheck here. |
240 | 240 | */ |
241 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
241 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
242 | 242 | EEM_Payment_Method::instance()->verify_button_urls(); |
243 | - EE_Registry::instance()->load_helper( 'Tabbed_Content' ); |
|
244 | - EE_Registry::instance()->load_helper( 'HTML' ); |
|
243 | + EE_Registry::instance()->load_helper('Tabbed_Content'); |
|
244 | + EE_Registry::instance()->load_helper('HTML'); |
|
245 | 245 | //setup tabs, one for each payment method type |
246 | 246 | $tabs = array(); |
247 | 247 | $payment_methods = array(); |
248 | - foreach( EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj ) { |
|
248 | + foreach (EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj) { |
|
249 | 249 | // we don't want to show admin-only PMTs for now |
250 | - if ( $pmt_obj instanceof EE_PMT_Admin_Only ) { |
|
250 | + if ($pmt_obj instanceof EE_PMT_Admin_Only) { |
|
251 | 251 | continue; |
252 | 252 | } |
253 | 253 | //check access |
254 | - if ( ! EE_Registry::instance()->CAP->current_user_can( $pmt_obj->cap_name(), 'specific_payment_method_type_access' ) ) { |
|
254 | + if ( ! EE_Registry::instance()->CAP->current_user_can($pmt_obj->cap_name(), 'specific_payment_method_type_access')) { |
|
255 | 255 | continue; |
256 | 256 | } |
257 | 257 | //check for any active pms of that type |
258 | - $payment_method = EEM_Payment_Method::instance()->get_one_of_type( $pmt_obj->system_name() ); |
|
259 | - if ( ! $payment_method instanceof EE_Payment_Method ) { |
|
258 | + $payment_method = EEM_Payment_Method::instance()->get_one_of_type($pmt_obj->system_name()); |
|
259 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
260 | 260 | $payment_method = EE_Payment_Method::new_instance( |
261 | 261 | array( |
262 | - 'PMD_slug' =>sanitize_key( $pmt_obj->system_name() ), |
|
262 | + 'PMD_slug' =>sanitize_key($pmt_obj->system_name()), |
|
263 | 263 | 'PMD_type' =>$pmt_obj->system_name(), |
264 | 264 | 'PMD_name' =>$pmt_obj->pretty_name(), |
265 | 265 | 'PMD_admin_name' =>$pmt_obj->pretty_name() |
266 | 266 | ) |
267 | 267 | ); |
268 | 268 | } |
269 | - $payment_methods[ $payment_method->slug() ] = $payment_method; |
|
269 | + $payment_methods[$payment_method->slug()] = $payment_method; |
|
270 | 270 | } |
271 | - $payment_methods = apply_filters( 'FHEE__Payments_Admin_Page___payment_methods_list__payment_methods', $payment_methods ); |
|
272 | - foreach( $payment_methods as $payment_method ) { |
|
273 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
271 | + $payment_methods = apply_filters('FHEE__Payments_Admin_Page___payment_methods_list__payment_methods', $payment_methods); |
|
272 | + foreach ($payment_methods as $payment_method) { |
|
273 | + if ($payment_method instanceof EE_Payment_Method) { |
|
274 | 274 | add_meta_box( |
275 | 275 | //html id |
276 | - 'espresso_' . $payment_method->slug() . '_payment_settings', |
|
276 | + 'espresso_'.$payment_method->slug().'_payment_settings', |
|
277 | 277 | //title |
278 | - sprintf( __( '%s Settings', 'event_espresso' ), $payment_method->admin_name() ), |
|
278 | + sprintf(__('%s Settings', 'event_espresso'), $payment_method->admin_name()), |
|
279 | 279 | //callback |
280 | - array( $this, 'payment_method_settings_meta_box' ), |
|
280 | + array($this, 'payment_method_settings_meta_box'), |
|
281 | 281 | //post type |
282 | 282 | null, |
283 | 283 | //context |
@@ -285,19 +285,19 @@ discard block |
||
285 | 285 | //priority |
286 | 286 | 'default', |
287 | 287 | //callback args |
288 | - array( 'payment_method' => $payment_method ) |
|
288 | + array('payment_method' => $payment_method) |
|
289 | 289 | ); |
290 | 290 | //setup for tabbed content |
291 | - $tabs[ $payment_method->slug() ] = array( |
|
291 | + $tabs[$payment_method->slug()] = array( |
|
292 | 292 | 'label' => $payment_method->admin_name(), |
293 | 293 | 'class' => $payment_method->active() ? 'gateway-active' : '', |
294 | - 'href' => 'espresso_' . $payment_method->slug() . '_payment_settings', |
|
295 | - 'title' => __( 'Modify this Payment Method', 'event_espresso' ), |
|
294 | + 'href' => 'espresso_'.$payment_method->slug().'_payment_settings', |
|
295 | + 'title' => __('Modify this Payment Method', 'event_espresso'), |
|
296 | 296 | 'slug' => $payment_method->slug() |
297 | 297 | ); |
298 | 298 | } |
299 | 299 | } |
300 | - $this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links( $tabs, 'payment_method_links', '|', $this->_get_active_payment_method_slug() ); |
|
300 | + $this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links($tabs, 'payment_method_links', '|', $this->_get_active_payment_method_slug()); |
|
301 | 301 | $this->display_admin_page_with_sidebar(); |
302 | 302 | |
303 | 303 | } |
@@ -308,20 +308,20 @@ discard block |
||
308 | 308 | * _get_active_payment_method_slug |
309 | 309 | * @return string |
310 | 310 | */ |
311 | - protected function _get_active_payment_method_slug(){ |
|
311 | + protected function _get_active_payment_method_slug() { |
|
312 | 312 | $payment_method_slug = FALSE; |
313 | 313 | //decide which payment method tab to open first, as dictated by the request's 'payment_method' |
314 | - if ( isset( $this->_req_data['payment_method'] )) { |
|
314 | + if (isset($this->_req_data['payment_method'])) { |
|
315 | 315 | // if they provided the current payment method, use it |
316 | - $payment_method_slug = sanitize_key( $this->_req_data['payment_method'] ); |
|
316 | + $payment_method_slug = sanitize_key($this->_req_data['payment_method']); |
|
317 | 317 | } |
318 | - $payment_method = EEM_Payment_Method::instance()->get_one( array( array( 'PMD_slug' => $payment_method_slug ))); |
|
318 | + $payment_method = EEM_Payment_Method::instance()->get_one(array(array('PMD_slug' => $payment_method_slug))); |
|
319 | 319 | // if that didn't work or wasn't provided, find another way to select the current pm |
320 | - if ( ! $this->_verify_payment_method( $payment_method )) { |
|
320 | + if ( ! $this->_verify_payment_method($payment_method)) { |
|
321 | 321 | // like, looking for an active one |
322 | - $payment_method = EEM_Payment_Method::instance()->get_one_active( 'CART' ); |
|
322 | + $payment_method = EEM_Payment_Method::instance()->get_one_active('CART'); |
|
323 | 323 | // test that one as well |
324 | - if ( $this->_verify_payment_method( $payment_method )) { |
|
324 | + if ($this->_verify_payment_method($payment_method)) { |
|
325 | 325 | $payment_method_slug = $payment_method->slug(); |
326 | 326 | } else { |
327 | 327 | $payment_method_slug = 'paypal_standard'; |
@@ -339,11 +339,11 @@ discard block |
||
339 | 339 | * @param \EE_Payment_Method $payment_method |
340 | 340 | * @return boolean |
341 | 341 | */ |
342 | - protected function _verify_payment_method( $payment_method ){ |
|
342 | + protected function _verify_payment_method($payment_method) { |
|
343 | 343 | if ( |
344 | 344 | $payment_method instanceof EE_Payment_Method && |
345 | 345 | $payment_method->type_obj() instanceof EE_PMT_Base && |
346 | - EE_Registry::instance()->CAP->current_user_can( $payment_method->type_obj()->cap_name(), 'specific_payment_method_type_access' ) |
|
346 | + EE_Registry::instance()->CAP->current_user_can($payment_method->type_obj()->cap_name(), 'specific_payment_method_type_access') |
|
347 | 347 | ) { |
348 | 348 | return TRUE; |
349 | 349 | } |
@@ -360,21 +360,21 @@ discard block |
||
360 | 360 | * @return string |
361 | 361 | * @throws EE_Error |
362 | 362 | */ |
363 | - public function payment_method_settings_meta_box( $post_obj_which_is_null, $metabox ){ |
|
364 | - $payment_method = isset( $metabox['args'], $metabox['args']['payment_method'] ) ? $metabox['args']['payment_method'] : NULL; |
|
365 | - if ( ! $payment_method instanceof EE_Payment_Method ){ |
|
366 | - throw new EE_Error( sprintf( __( 'Payment method metabox setup incorrectly. No Payment method object was supplied', 'event_espresso' ))); |
|
363 | + public function payment_method_settings_meta_box($post_obj_which_is_null, $metabox) { |
|
364 | + $payment_method = isset($metabox['args'], $metabox['args']['payment_method']) ? $metabox['args']['payment_method'] : NULL; |
|
365 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
366 | + throw new EE_Error(sprintf(__('Payment method metabox setup incorrectly. No Payment method object was supplied', 'event_espresso'))); |
|
367 | 367 | } |
368 | 368 | $payment_method_scopes = $payment_method->active(); |
369 | 369 | // if the payment method really exists show its form, otherwise the activation template |
370 | - if ( $payment_method->ID() && ! empty( $payment_method_scopes )) { |
|
371 | - $form = $this->_generate_payment_method_settings_form( $payment_method ); |
|
372 | - if ( $form->form_data_present_in( $this->_req_data )) { |
|
373 | - $form->receive_form_submission( $this->_req_data ); |
|
370 | + if ($payment_method->ID() && ! empty($payment_method_scopes)) { |
|
371 | + $form = $this->_generate_payment_method_settings_form($payment_method); |
|
372 | + if ($form->form_data_present_in($this->_req_data)) { |
|
373 | + $form->receive_form_submission($this->_req_data); |
|
374 | 374 | } |
375 | - echo $form->form_open() . $form->get_html_and_js() . $form->form_close(); |
|
375 | + echo $form->form_open().$form->get_html_and_js().$form->form_close(); |
|
376 | 376 | } else { |
377 | - echo $this->_activate_payment_method_button( $payment_method )->get_html_and_js(); |
|
377 | + echo $this->_activate_payment_method_button($payment_method)->get_html_and_js(); |
|
378 | 378 | } |
379 | 379 | } |
380 | 380 | |
@@ -387,14 +387,14 @@ discard block |
||
387 | 387 | * @param \EE_Payment_Method $payment_method |
388 | 388 | * @return \EE_Form_Section_Proper |
389 | 389 | */ |
390 | - protected function _generate_payment_method_settings_form( EE_Payment_Method $payment_method ) { |
|
391 | - if ( ! $payment_method instanceof EE_Payment_Method ){ |
|
390 | + protected function _generate_payment_method_settings_form(EE_Payment_Method $payment_method) { |
|
391 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
392 | 392 | return new EE_Form_Section_Proper(); |
393 | 393 | } |
394 | 394 | return new EE_Form_Section_Proper( |
395 | 395 | array( |
396 | - 'name' => $payment_method->slug() . '_settings_form', |
|
397 | - 'html_id' => $payment_method->slug() . '_settings_form', |
|
396 | + 'name' => $payment_method->slug().'_settings_form', |
|
397 | + 'html_id' => $payment_method->slug().'_settings_form', |
|
398 | 398 | 'action' => EE_Admin_Page::add_query_args_and_nonce( |
399 | 399 | array( |
400 | 400 | 'action' => 'update_payment_method', |
@@ -406,12 +406,12 @@ discard block |
||
406 | 406 | 'subsections' => apply_filters( |
407 | 407 | 'FHEE__Payments_Admin_Page___generate_payment_method_settings_form__form_subsections', |
408 | 408 | array( |
409 | - 'pci_dss_compliance_' . $payment_method->slug() => $this->_pci_dss_compliance( $payment_method ), |
|
410 | - 'currency_support_' . $payment_method->slug() => $this->_currency_support( $payment_method ), |
|
411 | - 'payment_method_settings_' . $payment_method->slug() => $this->_payment_method_settings( $payment_method ), |
|
412 | - 'update_' . $payment_method->slug() => $this->_update_payment_method_button( $payment_method ), |
|
413 | - 'deactivate_' . $payment_method->slug() => $this->_deactivate_payment_method_button( $payment_method ), |
|
414 | - 'fine_print_' . $payment_method->slug() => $this->_fine_print() |
|
409 | + 'pci_dss_compliance_'.$payment_method->slug() => $this->_pci_dss_compliance($payment_method), |
|
410 | + 'currency_support_'.$payment_method->slug() => $this->_currency_support($payment_method), |
|
411 | + 'payment_method_settings_'.$payment_method->slug() => $this->_payment_method_settings($payment_method), |
|
412 | + 'update_'.$payment_method->slug() => $this->_update_payment_method_button($payment_method), |
|
413 | + 'deactivate_'.$payment_method->slug() => $this->_deactivate_payment_method_button($payment_method), |
|
414 | + 'fine_print_'.$payment_method->slug() => $this->_fine_print() |
|
415 | 415 | ), |
416 | 416 | $payment_method |
417 | 417 | ) |
@@ -428,19 +428,19 @@ discard block |
||
428 | 428 | * @param \EE_Payment_Method $payment_method |
429 | 429 | * @return \EE_Form_Section_Proper |
430 | 430 | */ |
431 | - protected function _pci_dss_compliance( EE_Payment_Method $payment_method ) { |
|
432 | - if ( $payment_method->type_obj()->requires_https() ) { |
|
431 | + protected function _pci_dss_compliance(EE_Payment_Method $payment_method) { |
|
432 | + if ($payment_method->type_obj()->requires_https()) { |
|
433 | 433 | return new EE_Form_Section_HTML( |
434 | 434 | EEH_HTML::tr( |
435 | 435 | EEH_HTML::th( |
436 | 436 | EEH_HTML::label( |
437 | - EEH_HTML::strong( __( 'IMPORTANT', 'event_espresso' ), '', 'important-notice' ) |
|
437 | + EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice') |
|
438 | 438 | ) |
439 | - ) . |
|
439 | + ). |
|
440 | 440 | EEH_HTML::td( |
441 | - EEH_HTML::strong( __( 'You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.', 'event_espresso' )) . |
|
442 | - EEH_HTML::br() . |
|
443 | - __( 'Learn more about ', 'event_espresso' ) . EEH_HTML::link( 'https://www.pcisecuritystandards.org/merchants/index.php', __( 'PCI DSS compliance', 'event_espresso' )) |
|
441 | + EEH_HTML::strong(__('You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.', 'event_espresso')). |
|
442 | + EEH_HTML::br(). |
|
443 | + __('Learn more about ', 'event_espresso').EEH_HTML::link('https://www.pcisecuritystandards.org/merchants/index.php', __('PCI DSS compliance', 'event_espresso')) |
|
444 | 444 | ) |
445 | 445 | ) |
446 | 446 | ); |
@@ -458,19 +458,19 @@ discard block |
||
458 | 458 | * @param \EE_Payment_Method $payment_method |
459 | 459 | * @return \EE_Form_Section_Proper |
460 | 460 | */ |
461 | - protected function _currency_support( EE_Payment_Method $payment_method ) { |
|
462 | - if ( ! $payment_method->usable_for_currency( EE_Config::instance()->currency->code )) { |
|
461 | + protected function _currency_support(EE_Payment_Method $payment_method) { |
|
462 | + if ( ! $payment_method->usable_for_currency(EE_Config::instance()->currency->code)) { |
|
463 | 463 | return new EE_Form_Section_HTML( |
464 | 464 | EEH_HTML::tr( |
465 | 465 | EEH_HTML::th( |
466 | 466 | EEH_HTML::label( |
467 | - EEH_HTML::strong( __( 'IMPORTANT', 'event_espresso' ), '', 'important-notice' ) |
|
467 | + EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice') |
|
468 | 468 | ) |
469 | - ) . |
|
469 | + ). |
|
470 | 470 | EEH_HTML::td( |
471 | 471 | EEH_HTML::strong( |
472 | 472 | sprintf( |
473 | - __( 'This payment method does not support the currency set on your site (%1$s) and so will not appear as a payment option to registrants. Please activate a different payment method or change your site\'s country and associated currency.', 'event_espresso'), |
|
473 | + __('This payment method does not support the currency set on your site (%1$s) and so will not appear as a payment option to registrants. Please activate a different payment method or change your site\'s country and associated currency.', 'event_espresso'), |
|
474 | 474 | EE_Config::instance()->currency->code |
475 | 475 | ) |
476 | 476 | ) |
@@ -490,9 +490,9 @@ discard block |
||
490 | 490 | * @param \EE_Payment_Method $payment_method |
491 | 491 | * @return \EE_Form_Section_HTML |
492 | 492 | */ |
493 | - protected function _payment_method_settings( EE_Payment_Method $payment_method ) { |
|
493 | + protected function _payment_method_settings(EE_Payment_Method $payment_method) { |
|
494 | 494 | //modify the form so we only have/show fields that will be implemented for this version |
495 | - return $this->_simplify_form( $payment_method->type_obj()->settings_form(), $payment_method->name() ); |
|
495 | + return $this->_simplify_form($payment_method->type_obj()->settings_form(), $payment_method->name()); |
|
496 | 496 | } |
497 | 497 | |
498 | 498 | |
@@ -505,8 +505,8 @@ discard block |
||
505 | 505 | * @return \EE_Payment_Method_Form |
506 | 506 | * @throws \EE_Error |
507 | 507 | */ |
508 | - protected function _simplify_form( $form_section, $payment_method_name = '' ){ |
|
509 | - if ( $form_section instanceof EE_Payment_Method_Form ) { |
|
508 | + protected function _simplify_form($form_section, $payment_method_name = '') { |
|
509 | + if ($form_section instanceof EE_Payment_Method_Form) { |
|
510 | 510 | $form_section->exclude( |
511 | 511 | array( |
512 | 512 | 'PMD_type', //dont want them changing the type |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | ); |
518 | 518 | return $form_section; |
519 | 519 | } else { |
520 | - throw new EE_Error( sprintf( __( 'The EE_Payment_Method_Form for the "%1$s" payment method is missing or invalid.', 'event_espresso' ), $payment_method_name )); |
|
520 | + throw new EE_Error(sprintf(__('The EE_Payment_Method_Form for the "%1$s" payment method is missing or invalid.', 'event_espresso'), $payment_method_name)); |
|
521 | 521 | } |
522 | 522 | } |
523 | 523 | |
@@ -530,18 +530,18 @@ discard block |
||
530 | 530 | * @param \EE_Payment_Method $payment_method |
531 | 531 | * @return \EE_Form_Section_HTML |
532 | 532 | */ |
533 | - protected function _update_payment_method_button( EE_Payment_Method $payment_method ) { |
|
533 | + protected function _update_payment_method_button(EE_Payment_Method $payment_method) { |
|
534 | 534 | $update_button = new EE_Submit_Input( |
535 | 535 | array( |
536 | - 'html_id' => 'save_' . $payment_method->slug() . '_settings', |
|
537 | - 'default' => sprintf( __( 'Update %s Payment Settings', 'event_espresso' ), $payment_method->admin_name() ), |
|
536 | + 'html_id' => 'save_'.$payment_method->slug().'_settings', |
|
537 | + 'default' => sprintf(__('Update %s Payment Settings', 'event_espresso'), $payment_method->admin_name()), |
|
538 | 538 | 'html_label' => EEH_HTML::nbsp() |
539 | 539 | ) |
540 | 540 | ); |
541 | 541 | return new EE_Form_Section_HTML( |
542 | - EEH_HTML::no_row( EEH_HTML::br(2) ) . |
|
542 | + EEH_HTML::no_row(EEH_HTML::br(2)). |
|
543 | 543 | EEH_HTML::tr( |
544 | - EEH_HTML::th( __( 'Update Settings', 'event_espresso') ) . |
|
544 | + EEH_HTML::th(__('Update Settings', 'event_espresso')). |
|
545 | 545 | EEH_HTML::td( |
546 | 546 | $update_button->get_html_for_input() |
547 | 547 | ) |
@@ -558,11 +558,11 @@ discard block |
||
558 | 558 | * @param \EE_Payment_Method $payment_method |
559 | 559 | * @return \EE_Form_Section_Proper |
560 | 560 | */ |
561 | - protected function _deactivate_payment_method_button( EE_Payment_Method $payment_method ) { |
|
562 | - $link_text_and_title = sprintf( __( 'Deactivate %1$s Payments?', 'event_espresso'), $payment_method->admin_name() ); |
|
561 | + protected function _deactivate_payment_method_button(EE_Payment_Method $payment_method) { |
|
562 | + $link_text_and_title = sprintf(__('Deactivate %1$s Payments?', 'event_espresso'), $payment_method->admin_name()); |
|
563 | 563 | return new EE_Form_Section_HTML( |
564 | 564 | EEH_HTML::tr( |
565 | - EEH_HTML::th( __( 'Deactivate Payment Method', 'event_espresso') ) . |
|
565 | + EEH_HTML::th(__('Deactivate Payment Method', 'event_espresso')). |
|
566 | 566 | EEH_HTML::td( |
567 | 567 | EEH_HTML::link( |
568 | 568 | EE_Admin_Page::add_query_args_and_nonce( |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | ), |
575 | 575 | $link_text_and_title, |
576 | 576 | $link_text_and_title, |
577 | - 'deactivate_' . $payment_method->slug(), |
|
577 | + 'deactivate_'.$payment_method->slug(), |
|
578 | 578 | 'espresso-button button-secondary' |
579 | 579 | ) |
580 | 580 | ) |
@@ -590,12 +590,12 @@ discard block |
||
590 | 590 | * @param \EE_Payment_Method $payment_method |
591 | 591 | * @return \EE_Form_Section_Proper |
592 | 592 | */ |
593 | - protected function _activate_payment_method_button( EE_Payment_Method $payment_method ) { |
|
594 | - $link_text_and_title = sprintf( __( 'Activate %1$s Payment Method?', 'event_espresso'), $payment_method->admin_name() ); |
|
593 | + protected function _activate_payment_method_button(EE_Payment_Method $payment_method) { |
|
594 | + $link_text_and_title = sprintf(__('Activate %1$s Payment Method?', 'event_espresso'), $payment_method->admin_name()); |
|
595 | 595 | return new EE_Form_Section_Proper( |
596 | 596 | array( |
597 | - 'name' => 'activate_' . $payment_method->slug() . '_settings_form', |
|
598 | - 'html_id' => 'activate_' . $payment_method->slug() . '_settings_form', |
|
597 | + 'name' => 'activate_'.$payment_method->slug().'_settings_form', |
|
598 | + 'html_id' => 'activate_'.$payment_method->slug().'_settings_form', |
|
599 | 599 | 'action' => '#', |
600 | 600 | 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
601 | 601 | 'subsections' => apply_filters( |
@@ -604,8 +604,8 @@ discard block |
||
604 | 604 | new EE_Form_Section_HTML( |
605 | 605 | EEH_HTML::tr( |
606 | 606 | EEH_HTML::th( |
607 | - EEH_HTML::label( __( 'Click to Activate ', 'event_espresso' )) |
|
608 | - ) . |
|
607 | + EEH_HTML::label(__('Click to Activate ', 'event_espresso')) |
|
608 | + ). |
|
609 | 609 | EEH_HTML::td( |
610 | 610 | EEH_HTML::link( |
611 | 611 | EE_Admin_Page::add_query_args_and_nonce( |
@@ -617,7 +617,7 @@ discard block |
||
617 | 617 | ), |
618 | 618 | $link_text_and_title, |
619 | 619 | $link_text_and_title, |
620 | - 'activate_' . $payment_method->slug(), |
|
620 | + 'activate_'.$payment_method->slug(), |
|
621 | 621 | 'espresso-button-green button-primary' |
622 | 622 | ) |
623 | 623 | ) |
@@ -638,9 +638,9 @@ discard block |
||
638 | 638 | protected function _fine_print() { |
639 | 639 | return new EE_Form_Section_HTML( |
640 | 640 | EEH_HTML::tr( |
641 | - EEH_HTML::th() . |
|
641 | + EEH_HTML::th(). |
|
642 | 642 | EEH_HTML::td( |
643 | - EEH_HTML::p( __( 'All fields marked with a * are required fields', 'event_espresso' ), '', 'grey-text' ) |
|
643 | + EEH_HTML::p(__('All fields marked with a * are required fields', 'event_espresso'), '', 'grey-text') |
|
644 | 644 | ) |
645 | 645 | ) |
646 | 646 | ); |
@@ -652,15 +652,15 @@ discard block |
||
652 | 652 | * Activates a payment method of that type. Mostly assuming there is only 1 of that type (or none so far) |
653 | 653 | * @global WP_User $current_user |
654 | 654 | */ |
655 | - protected function _activate_payment_method(){ |
|
656 | - if(isset($this->_req_data['payment_method_type'])){ |
|
655 | + protected function _activate_payment_method() { |
|
656 | + if (isset($this->_req_data['payment_method_type'])) { |
|
657 | 657 | $payment_method_type = sanitize_text_field($this->_req_data['payment_method_type']); |
658 | 658 | //see if one exists |
659 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
660 | - $payment_method = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( $payment_method_type ); |
|
659 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
660 | + $payment_method = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type($payment_method_type); |
|
661 | 661 | |
662 | - $this->_redirect_after_action(1, 'Payment Method', 'activated', array('action' => 'default','payment_method'=>$payment_method->slug())); |
|
663 | - }else{ |
|
662 | + $this->_redirect_after_action(1, 'Payment Method', 'activated', array('action' => 'default', 'payment_method'=>$payment_method->slug())); |
|
663 | + } else { |
|
664 | 664 | $this->_redirect_after_action(FALSE, 'Payment Method', 'activated', array('action' => 'default')); |
665 | 665 | } |
666 | 666 | } |
@@ -668,14 +668,14 @@ discard block |
||
668 | 668 | /** |
669 | 669 | * Deactivates the payment method with the specified slug, and redirects. |
670 | 670 | */ |
671 | - protected function _deactivate_payment_method(){ |
|
672 | - if(isset($this->_req_data['payment_method'])){ |
|
671 | + protected function _deactivate_payment_method() { |
|
672 | + if (isset($this->_req_data['payment_method'])) { |
|
673 | 673 | $payment_method_slug = sanitize_key($this->_req_data['payment_method']); |
674 | 674 | //deactivate it |
675 | 675 | EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
676 | - $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method( $payment_method_slug ); |
|
677 | - $this->_redirect_after_action($count_updated, 'Payment Method', 'deactivated', array('action' => 'default','payment_method'=>$payment_method_slug)); |
|
678 | - }else{ |
|
676 | + $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method($payment_method_slug); |
|
677 | + $this->_redirect_after_action($count_updated, 'Payment Method', 'deactivated', array('action' => 'default', 'payment_method'=>$payment_method_slug)); |
|
678 | + } else { |
|
679 | 679 | $this->_redirect_after_action(FALSE, 'Payment Method', 'deactivated', array('action' => 'default')); |
680 | 680 | } |
681 | 681 | } |
@@ -689,39 +689,39 @@ discard block |
||
689 | 689 | * subsequently called 'headers_sent_func' which is _payment_methods_list) |
690 | 690 | * @return void |
691 | 691 | */ |
692 | - protected function _update_payment_method(){ |
|
693 | - if( $_SERVER['REQUEST_METHOD'] == 'POST'){ |
|
692 | + protected function _update_payment_method() { |
|
693 | + if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
694 | 694 | //ok let's find which gateway form to use based on the form input |
695 | 695 | EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
696 | 696 | /** @var $correct_pmt_form_to_use EE_Payment_Method_Form */ |
697 | 697 | $correct_pmt_form_to_use = NULL; |
698 | 698 | $pmt_obj = NULL; |
699 | - foreach(EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj){ |
|
699 | + foreach (EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj) { |
|
700 | 700 | /** @var $pmt_obj EE_PMT_Base */ |
701 | 701 | //get the form and simplify it, like what we do when we display it |
702 | 702 | $pmt_form = $pmt_obj->settings_form(); |
703 | 703 | $this->_simplify_form($pmt_form); |
704 | - if($pmt_form->form_data_present_in($this->_req_data)){ |
|
704 | + if ($pmt_form->form_data_present_in($this->_req_data)) { |
|
705 | 705 | $correct_pmt_form_to_use = $pmt_form; |
706 | 706 | break; |
707 | 707 | } |
708 | 708 | } |
709 | 709 | //if we couldn't find the correct payment method type... |
710 | - if( ! $correct_pmt_form_to_use ){ |
|
710 | + if ( ! $correct_pmt_form_to_use) { |
|
711 | 711 | EE_Error::add_error(__("We could not find which payment method type your form submission related to. Please contact support", 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
712 | 712 | $this->_redirect_after_action(FALSE, 'Payment Method', 'activated', array('action' => 'default')); |
713 | 713 | } |
714 | 714 | $correct_pmt_form_to_use->receive_form_submission($this->_req_data); |
715 | - if($correct_pmt_form_to_use->is_valid()){ |
|
715 | + if ($correct_pmt_form_to_use->is_valid()) { |
|
716 | 716 | $correct_pmt_form_to_use->save(); |
717 | 717 | $pm = $correct_pmt_form_to_use->get_model_object(); |
718 | 718 | /** @var $pm EE_Payment_Method */ |
719 | - $this->_redirect_after_action(TRUE, 'Payment Method', 'updated', array('action' => 'default','payment_method'=>$pm->slug())); |
|
720 | - }else{ |
|
719 | + $this->_redirect_after_action(TRUE, 'Payment Method', 'updated', array('action' => 'default', 'payment_method'=>$pm->slug())); |
|
720 | + } else { |
|
721 | 721 | EE_Error::add_error( |
722 | 722 | sprintf( |
723 | 723 | __('Payment method of type %s was not saved because there were validation errors. They have been marked in the form', 'event_espresso'), |
724 | - $pmt_obj instanceof EE_PMT_Base ? $pmt_obj->pretty_name() : __( '"(unknown)"', 'event_espresso' ) |
|
724 | + $pmt_obj instanceof EE_PMT_Base ? $pmt_obj->pretty_name() : __('"(unknown)"', 'event_espresso') |
|
725 | 725 | ), |
726 | 726 | __FILE__, |
727 | 727 | __FUNCTION__, |
@@ -738,11 +738,11 @@ discard block |
||
738 | 738 | protected function _payment_settings() { |
739 | 739 | |
740 | 740 | $this->_template_args['values'] = $this->_yes_no_values; |
741 | - $this->_template_args['show_pending_payment_options'] = isset( EE_Registry::instance()->CFG->registration->show_pending_payment_options ) ? absint( EE_Registry::instance()->CFG->registration->show_pending_payment_options ) : FALSE; |
|
741 | + $this->_template_args['show_pending_payment_options'] = isset(EE_Registry::instance()->CFG->registration->show_pending_payment_options) ? absint(EE_Registry::instance()->CFG->registration->show_pending_payment_options) : FALSE; |
|
742 | 742 | |
743 | - $this->_set_add_edit_form_tags( 'update_payment_settings' ); |
|
744 | - $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
|
745 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( EE_PAYMENTS_TEMPLATE_PATH . 'payment_settings.template.php', $this->_template_args, TRUE ); |
|
743 | + $this->_set_add_edit_form_tags('update_payment_settings'); |
|
744 | + $this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE); |
|
745 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template(EE_PAYMENTS_TEMPLATE_PATH.'payment_settings.template.php', $this->_template_args, TRUE); |
|
746 | 746 | $this->display_admin_page_with_sidebar(); |
747 | 747 | |
748 | 748 | } |
@@ -756,13 +756,13 @@ discard block |
||
756 | 756 | * @return array |
757 | 757 | */ |
758 | 758 | protected function _update_payment_settings() { |
759 | - EE_Registry::instance()->CFG->registration->show_pending_payment_options = isset( $this->_req_data['show_pending_payment_options'] ) ? $this->_req_data['show_pending_payment_options'] : FALSE; |
|
760 | - EE_Registry::instance()->CFG = apply_filters( 'FHEE__Payments_Admin_Page___update_payment_settings__CFG', EE_Registry::instance()->CFG ); |
|
759 | + EE_Registry::instance()->CFG->registration->show_pending_payment_options = isset($this->_req_data['show_pending_payment_options']) ? $this->_req_data['show_pending_payment_options'] : FALSE; |
|
760 | + EE_Registry::instance()->CFG = apply_filters('FHEE__Payments_Admin_Page___update_payment_settings__CFG', EE_Registry::instance()->CFG); |
|
761 | 761 | |
762 | 762 | |
763 | - $what = __('Payment Settings','event_espresso'); |
|
764 | - $success = $this->_update_espresso_configuration( $what, EE_Registry::instance()->CFG, __FILE__, __FUNCTION__, __LINE__ ); |
|
765 | - $this->_redirect_after_action( $success, $what, __('updated','event_espresso'), array( 'action' => 'payment_settings' ) ); |
|
763 | + $what = __('Payment Settings', 'event_espresso'); |
|
764 | + $success = $this->_update_espresso_configuration($what, EE_Registry::instance()->CFG, __FILE__, __FUNCTION__, __LINE__); |
|
765 | + $this->_redirect_after_action($success, $what, __('updated', 'event_espresso'), array('action' => 'payment_settings')); |
|
766 | 766 | |
767 | 767 | } |
768 | 768 | protected function _payment_log_overview_list_table() { |
@@ -788,18 +788,18 @@ discard block |
||
788 | 788 | * @param bool $count |
789 | 789 | * @return array |
790 | 790 | */ |
791 | - public function get_payment_logs($per_page = 50, $current_page = 0, $count = false){ |
|
792 | - EE_Registry::instance()->load_model( 'Change_Log' ); |
|
791 | + public function get_payment_logs($per_page = 50, $current_page = 0, $count = false) { |
|
792 | + EE_Registry::instance()->load_model('Change_Log'); |
|
793 | 793 | //we may need to do multiple queries (joining differently), so we actually wan tan array of query params |
794 | - $query_params = array(array('LOG_type'=> EEM_Change_Log::type_gateway)); |
|
794 | + $query_params = array(array('LOG_type'=> EEM_Change_Log::type_gateway)); |
|
795 | 795 | //check if they've selected a specific payment method |
796 | - if( isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all'){ |
|
796 | + if (isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all') { |
|
797 | 797 | $query_params[0]['OR*pm_or_pay_pm'] = array('Payment.Payment_Method.PMD_ID'=>$this->_req_data['_payment_method'], |
798 | 798 | 'Payment_Method.PMD_ID'=>$this->_req_data['_payment_method']); |
799 | 799 | } |
800 | 800 | //take into account search |
801 | - if(isset($this->_req_data['s']) && $this->_req_data['s']){ |
|
802 | - $similarity_string = array('LIKE','%'.str_replace("","%",$this->_req_data['s']) .'%'); |
|
801 | + if (isset($this->_req_data['s']) && $this->_req_data['s']) { |
|
802 | + $similarity_string = array('LIKE', '%'.str_replace("", "%", $this->_req_data['s']).'%'); |
|
803 | 803 | $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_fname'] = $similarity_string; |
804 | 804 | $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_lname'] = $similarity_string; |
805 | 805 | $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_email'] = $similarity_string; |
@@ -814,48 +814,48 @@ discard block |
||
814 | 814 | $query_params[0]['OR*s']['LOG_message'] = $similarity_string; |
815 | 815 | |
816 | 816 | } |
817 | - if(isset( $this->_req_data['payment-filter-start-date'] ) && isset( $this->_req_data['payment-filter-end-date'] )){ |
|
817 | + if (isset($this->_req_data['payment-filter-start-date']) && isset($this->_req_data['payment-filter-end-date'])) { |
|
818 | 818 | //add date |
819 | - $start_date =wp_strip_all_tags( $this->_req_data['payment-filter-start-date'] ); |
|
820 | - $end_date = wp_strip_all_tags( $this->_req_data['payment-filter-end-date'] ); |
|
819 | + $start_date = wp_strip_all_tags($this->_req_data['payment-filter-start-date']); |
|
820 | + $end_date = wp_strip_all_tags($this->_req_data['payment-filter-end-date']); |
|
821 | 821 | //make sure our timestamps start and end right at the boundaries for each day |
822 | - $start_date = date( 'Y-m-d', strtotime( $start_date ) ) . ' 00:00:00'; |
|
823 | - $end_date = date( 'Y-m-d', strtotime( $end_date ) ) . ' 23:59:59'; |
|
822 | + $start_date = date('Y-m-d', strtotime($start_date)).' 00:00:00'; |
|
823 | + $end_date = date('Y-m-d', strtotime($end_date)).' 23:59:59'; |
|
824 | 824 | |
825 | 825 | //convert to timestamps |
826 | - $start_date = strtotime( $start_date ); |
|
827 | - $end_date = strtotime( $end_date ); |
|
826 | + $start_date = strtotime($start_date); |
|
827 | + $end_date = strtotime($end_date); |
|
828 | 828 | |
829 | 829 | //makes sure start date is the lowest value and vice versa |
830 | - $start_date = min( $start_date, $end_date ); |
|
831 | - $end_date = max( $start_date, $end_date ); |
|
830 | + $start_date = min($start_date, $end_date); |
|
831 | + $end_date = max($start_date, $end_date); |
|
832 | 832 | |
833 | 833 | //convert for query |
834 | - $start_date = EEM_Change_Log::instance()->convert_datetime_for_query( 'LOG_time', date( 'Y-m-d H:i:s', $start_date ), 'Y-m-d H:i:s' ); |
|
835 | - $end_date = EEM_Change_Log::instance()->convert_datetime_for_query( 'LOG_time', date( 'Y-m-d H:i:s', $end_date ), 'Y-m-d H:i:s' ); |
|
834 | + $start_date = EEM_Change_Log::instance()->convert_datetime_for_query('LOG_time', date('Y-m-d H:i:s', $start_date), 'Y-m-d H:i:s'); |
|
835 | + $end_date = EEM_Change_Log::instance()->convert_datetime_for_query('LOG_time', date('Y-m-d H:i:s', $end_date), 'Y-m-d H:i:s'); |
|
836 | 836 | |
837 | - $query_params[0]['LOG_time'] = array('BETWEEN',array($start_date,$end_date)); |
|
837 | + $query_params[0]['LOG_time'] = array('BETWEEN', array($start_date, $end_date)); |
|
838 | 838 | |
839 | 839 | } |
840 | - if($count){ |
|
840 | + if ($count) { |
|
841 | 841 | return EEM_Change_Log::instance()->count($query_params); |
842 | 842 | } |
843 | - if(isset($this->_req_data['order'])){ |
|
844 | - $sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'DESC'; |
|
843 | + if (isset($this->_req_data['order'])) { |
|
844 | + $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'DESC'; |
|
845 | 845 | $query_params['order_by'] = array('LOG_time' => $sort); |
846 | - }else{ |
|
846 | + } else { |
|
847 | 847 | $query_params['order_by'] = array('LOG_time' => 'DESC'); |
848 | 848 | } |
849 | - $offset = ($current_page-1)*$per_page; |
|
849 | + $offset = ($current_page - 1) * $per_page; |
|
850 | 850 | |
851 | - if( ! isset($this->_req_data['download_results'])){ |
|
852 | - $query_params['limit'] = array( $offset, $per_page ); |
|
851 | + if ( ! isset($this->_req_data['download_results'])) { |
|
852 | + $query_params['limit'] = array($offset, $per_page); |
|
853 | 853 | } |
854 | 854 | |
855 | 855 | |
856 | 856 | |
857 | 857 | //now they've requested to instead just download the file instead of viewing it. |
858 | - if(isset($this->_req_data['download_results'])){ |
|
858 | + if (isset($this->_req_data['download_results'])) { |
|
859 | 859 | $wpdb_results = EEM_Change_Log::instance()->get_all_efficiently($query_params); |
860 | 860 | header('Content-Disposition: attachment'); |
861 | 861 | header("Content-Disposition: attachment; filename=ee_payment_logs_for_".sanitize_key(site_url())); |
@@ -877,36 +877,36 @@ discard block |
||
877 | 877 | * @param EE_Change_Log $logB |
878 | 878 | * @return int |
879 | 879 | */ |
880 | - protected function _sort_logs_again($logA,$logB){ |
|
880 | + protected function _sort_logs_again($logA, $logB) { |
|
881 | 881 | $timeA = $logA->get_raw('LOG_time'); |
882 | 882 | $timeB = $logB->get_raw('LOG_time'); |
883 | - if($timeA == $timeB){ |
|
883 | + if ($timeA == $timeB) { |
|
884 | 884 | return 0; |
885 | 885 | } |
886 | 886 | $comparison = $timeA < $timeB ? -1 : 1; |
887 | - if(strtoupper($this->_sort_logs_again_direction) == 'DESC'){ |
|
887 | + if (strtoupper($this->_sort_logs_again_direction) == 'DESC') { |
|
888 | 888 | return $comparison * -1; |
889 | - }else{ |
|
889 | + } else { |
|
890 | 890 | return $comparison; |
891 | 891 | } |
892 | 892 | } |
893 | 893 | |
894 | 894 | protected function _payment_log_details() { |
895 | - EE_Registry::instance()->load_model( 'Change_Log' ); |
|
895 | + EE_Registry::instance()->load_model('Change_Log'); |
|
896 | 896 | /** @var $payment_log EE_Change_Log */ |
897 | 897 | $payment_log = EEM_Change_Log::instance()->get_one_by_ID($this->_req_data['ID']); |
898 | 898 | $payment_method = NULL; |
899 | 899 | $transaction = NULL; |
900 | - if( $payment_log instanceof EE_Change_Log ){ |
|
901 | - if( $payment_log->object() instanceof EE_Payment ){ |
|
900 | + if ($payment_log instanceof EE_Change_Log) { |
|
901 | + if ($payment_log->object() instanceof EE_Payment) { |
|
902 | 902 | $payment_method = $payment_log->object()->payment_method(); |
903 | 903 | $transaction = $payment_log->object()->transaction(); |
904 | - }elseif($payment_log->object() instanceof EE_Payment_Method){ |
|
904 | + }elseif ($payment_log->object() instanceof EE_Payment_Method) { |
|
905 | 905 | $payment_method = $payment_log->object(); |
906 | 906 | } |
907 | 907 | } |
908 | 908 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
909 | - EE_PAYMENTS_TEMPLATE_PATH . 'payment_log_details.template.php', |
|
909 | + EE_PAYMENTS_TEMPLATE_PATH.'payment_log_details.template.php', |
|
910 | 910 | array( |
911 | 911 | 'payment_log'=>$payment_log, |
912 | 912 | 'payment_method'=>$payment_method, |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -46,22 +46,22 @@ discard block |
||
46 | 46 | * @return string the assembled html string containing the tabbed content for display. |
47 | 47 | * @throws \EE_Error |
48 | 48 | */ |
49 | - public static function display($tabs_contents, $tabs_names = array(), $small_tabs = true, $tabs_content = TRUE ) { |
|
49 | + public static function display($tabs_contents, $tabs_names = array(), $small_tabs = true, $tabs_content = TRUE) { |
|
50 | 50 | |
51 | 51 | //first check if $tabs_names is not empty then the count must match the count of $tabs_content otherwise we've got a problem houston |
52 | - if ( !empty( $tabs_names) && ( count( (array) $tabs_names) != count( (array) $tabs_content) ) ) { |
|
53 | - throw new EE_Error( __('The count for $tabs_names and $tabs_content does not match.', 'event_espresso') ); |
|
52 | + if ( ! empty($tabs_names) && (count((array) $tabs_names) != count((array) $tabs_content))) { |
|
53 | + throw new EE_Error(__('The count for $tabs_names and $tabs_content does not match.', 'event_espresso')); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | //make sure we've got incoming data setup properly |
57 | - $tabs = !empty( $tabs_names ) ? (array) $tabs_names : array_keys( (array) $tabs_contents ); |
|
58 | - $tabs_content = !empty( $tabs_names ) ? array_combine( (array) $tabs_names, (array) $tabs_content ) : $tabs_contents; |
|
57 | + $tabs = ! empty($tabs_names) ? (array) $tabs_names : array_keys((array) $tabs_contents); |
|
58 | + $tabs_content = ! empty($tabs_names) ? array_combine((array) $tabs_names, (array) $tabs_content) : $tabs_contents; |
|
59 | 59 | |
60 | - $all_tabs = '<h2 class="nav-tab-wrapper">' . "\n"; |
|
60 | + $all_tabs = '<h2 class="nav-tab-wrapper">'."\n"; |
|
61 | 61 | $all_tabs_content = ''; |
62 | 62 | |
63 | 63 | $index = 0; |
64 | - foreach ( $tabs as $tab ) { |
|
64 | + foreach ($tabs as $tab) { |
|
65 | 65 | $active = $index === 0 ? true : false; |
66 | 66 | $all_tabs .= self::tab($tab, $active); |
67 | 67 | $all_tabs_content .= self::tab_content($tab, $tabs_content[$tab], $active); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | |
79 | 79 | $tab_container_class = $small_tabs ? 'ee-nav-tabs ee-nav-tabs-small' : 'ee-nav-tabs'; |
80 | 80 | |
81 | - return '<div class="'. $tab_container_class . '">' . "\n\t" . $all_tabs . $all_tabs_content . "\n" . '</div>'; |
|
81 | + return '<div class="'.$tab_container_class.'">'."\n\t".$all_tabs.$all_tabs_content."\n".'</div>'; |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | |
@@ -102,11 +102,11 @@ discard block |
||
102 | 102 | * @throws \EE_Error |
103 | 103 | */ |
104 | 104 | public static function display_admin_nav_tabs($nav_tabs = array()) { |
105 | - if ( empty($nav_tabs) ) |
|
106 | - throw new EE_Error( __('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso' ) ); |
|
105 | + if (empty($nav_tabs)) |
|
106 | + throw new EE_Error(__('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso')); |
|
107 | 107 | |
108 | - $all_tabs = '<h2 class="nav-tab-wrapper">' . "\n"; |
|
109 | - foreach ( $nav_tabs as $slug => $tab ) { |
|
108 | + $all_tabs = '<h2 class="nav-tab-wrapper">'."\n"; |
|
109 | + foreach ($nav_tabs as $slug => $tab) { |
|
110 | 110 | $all_tabs .= self::tab($slug, false, $tab['link_text'], $tab['url'], $tab['css_class']); |
111 | 111 | } |
112 | 112 | $all_tabs .= '</h2>'; |
@@ -122,13 +122,13 @@ discard block |
||
122 | 122 | * @param bool|string $css If string given then the generated tab will include that as the class. |
123 | 123 | * @return string html for tab |
124 | 124 | */ |
125 | - private static function tab($name, $active = false, $nice_name = FALSE, $url = FALSE, $css = FALSE ) { |
|
125 | + private static function tab($name, $active = false, $nice_name = FALSE, $url = FALSE, $css = FALSE) { |
|
126 | 126 | $name = str_replace(' ', '-', $name); |
127 | 127 | $class = $active ? 'nav-tab nav-tab-active' : 'nav-tab'; |
128 | - $class = $css ? $class . ' ' . $css : $class; |
|
129 | - $nice_name = $nice_name ? $nice_name : ucwords( preg_replace('/(-|_)/', ' ', $name) ); |
|
130 | - $url = $url ? $url : '#' . $name; |
|
131 | - $tab = '<a class="' . $class . '" rel="ee-tab-' . $name . '" href="' . $url . '">' . $nice_name . '</a>' . "\n\t"; |
|
128 | + $class = $css ? $class.' '.$css : $class; |
|
129 | + $nice_name = $nice_name ? $nice_name : ucwords(preg_replace('/(-|_)/', ' ', $name)); |
|
130 | + $url = $url ? $url : '#'.$name; |
|
131 | + $tab = '<a class="'.$class.'" rel="ee-tab-'.$name.'" href="'.$url.'">'.$nice_name.'</a>'."\n\t"; |
|
132 | 132 | return $tab; |
133 | 133 | } |
134 | 134 | |
@@ -144,9 +144,9 @@ discard block |
||
144 | 144 | */ |
145 | 145 | private static function tab_content($name, $tab_content, $active = false) { |
146 | 146 | $class = $active ? 'nav-tab-content' : 'nav-tab-content hidden'; |
147 | - $name = str_replace( ' ', '-', $name); |
|
148 | - $content = "\t" . '<div class="'. $class . '" id="ee-tab-' . $name . '">' . "\n"; |
|
149 | - $content .= "\t" . $tab_content . "\n"; |
|
147 | + $name = str_replace(' ', '-', $name); |
|
148 | + $content = "\t".'<div class="'.$class.'" id="ee-tab-'.$name.'">'."\n"; |
|
149 | + $content .= "\t".$tab_content."\n"; |
|
150 | 150 | $content .= '<div style="clear:both"></div></div>'; |
151 | 151 | return $content; |
152 | 152 | } |
@@ -172,9 +172,9 @@ discard block |
||
172 | 172 | * @param string $default You can include a string for the item that will receive the "item_display" class for the js. |
173 | 173 | * @return string a html snippet of of all the formatted link elements. |
174 | 174 | */ |
175 | - public static function tab_text_links( $item_array, $container_class = '', $sep = '|', $default = '' ) { |
|
176 | - $item_array = apply_filters( 'FHEE__EEH_Tabbed_Content__tab_text_links', $item_array, $container_class ); |
|
177 | - if ( !is_array($item_array) || empty( $item_array ) ) |
|
175 | + public static function tab_text_links($item_array, $container_class = '', $sep = '|', $default = '') { |
|
176 | + $item_array = apply_filters('FHEE__EEH_Tabbed_Content__tab_text_links', $item_array, $container_class); |
|
177 | + if ( ! is_array($item_array) || empty($item_array)) |
|
178 | 178 | return false; //get out we don't have even the basic thing we need! |
179 | 179 | |
180 | 180 | |
@@ -185,15 +185,15 @@ discard block |
||
185 | 185 | 'title' => esc_attr__('Link for Item', 'event_espresso'), |
186 | 186 | 'slug' => 'item_slug' |
187 | 187 | ); |
188 | - $container_class = !empty($container_class) ? 'ee-text-links ' . $container_class : 'ee-text-links'; |
|
189 | - $list = '<ul class="' . $container_class . '">'; |
|
188 | + $container_class = ! empty($container_class) ? 'ee-text-links '.$container_class : 'ee-text-links'; |
|
189 | + $list = '<ul class="'.$container_class.'">'; |
|
190 | 190 | |
191 | 191 | $ci = 1; |
192 | - foreach ( $item_array as $item ) { |
|
193 | - $item = wp_parse_args( $item, $defaults ); |
|
194 | - $item['class'] = !empty($default) && $default == $item['slug'] ? 'item_display ' . $item['class'] : $item['class']; |
|
192 | + foreach ($item_array as $item) { |
|
193 | + $item = wp_parse_args($item, $defaults); |
|
194 | + $item['class'] = ! empty($default) && $default == $item['slug'] ? 'item_display '.$item['class'] : $item['class']; |
|
195 | 195 | $list .= self::_text_link_item($item); |
196 | - if ( !empty($sep) && $ci != count($item_array) ) |
|
196 | + if ( ! empty($sep) && $ci != count($item_array)) |
|
197 | 197 | $list .= self::_text_link_item($sep); |
198 | 198 | $ci++; |
199 | 199 | } |
@@ -204,9 +204,9 @@ discard block |
||
204 | 204 | |
205 | 205 | |
206 | 206 | |
207 | - private static function _text_link_item( $item ) { |
|
207 | + private static function _text_link_item($item) { |
|
208 | 208 | //if this isn't an array then we're doing a separator |
209 | - if ( !is_array( $item ) ) { |
|
209 | + if ( ! is_array($item)) { |
|
210 | 210 | $label = $item; |
211 | 211 | $class = 'ee-text-link-sep'; |
212 | 212 | $href = ''; |
@@ -215,12 +215,12 @@ discard block |
||
215 | 215 | extract($item); |
216 | 216 | } |
217 | 217 | |
218 | - $class = $class != 'ee-text-link-sep' ? 'class="ee-text-link-li ' . $class . '"' : 'class="ee-text-link-sep"'; |
|
218 | + $class = $class != 'ee-text-link-sep' ? 'class="ee-text-link-li '.$class.'"' : 'class="ee-text-link-sep"'; |
|
219 | 219 | |
220 | - $content = '<li ' . $class . '>'; |
|
221 | - $content .= !empty($href) ? '<a class="ee-text-link" href="#' . $href . '" title="' . $title . '">' : ''; |
|
220 | + $content = '<li '.$class.'>'; |
|
221 | + $content .= ! empty($href) ? '<a class="ee-text-link" href="#'.$href.'" title="'.$title.'">' : ''; |
|
222 | 222 | $content .= $label; |
223 | - $content .= !empty($href) ? '</a>' : ''; |
|
223 | + $content .= ! empty($href) ? '</a>' : ''; |
|
224 | 224 | $content .= '</li>'; |
225 | 225 | return $content; |
226 | 226 | } |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -513,7 +515,7 @@ discard block |
||
513 | 515 | |
514 | 516 | if($count){ |
515 | 517 | return EEM_Price::instance()->count_deleted_and_undeleted(array($_where)); |
516 | - }else{ |
|
518 | + } else{ |
|
517 | 519 | return EEM_Price::instance()->get_all_deleted_and_undeleted($query_params); |
518 | 520 | } |
519 | 521 | } |
@@ -943,7 +945,7 @@ discard block |
||
943 | 945 | 'limit'=>$limit); |
944 | 946 | if($count){ |
945 | 947 | return EEM_Price_Type::instance()->count_deleted_and_undeleted($query_params); |
946 | - }else{ |
|
948 | + } else{ |
|
947 | 949 | return EEM_Price_Type::instance()->get_all_deleted_and_undeleted($query_params); |
948 | 950 | } |
949 | 951 |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public static function instance() { |
37 | 37 | // check if class object is instantiated, and instantiated properly |
38 | - if ( ! self::$_instance instanceof EE_Payment_Method_Manager ) { |
|
38 | + if ( ! self::$_instance instanceof EE_Payment_Method_Manager) { |
|
39 | 39 | self::$_instance = new self(); |
40 | 40 | } |
41 | 41 | EE_Registry::instance()->load_lib('PMT_Base'); |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * Resets the instance and returns a new one |
47 | 47 | * @return EE_Payment_Method_Manager |
48 | 48 | */ |
49 | - public static function reset(){ |
|
49 | + public static function reset() { |
|
50 | 50 | self::$_instance = NULL; |
51 | 51 | return self::instance(); |
52 | 52 | } |
@@ -57,12 +57,12 @@ discard block |
||
57 | 57 | * or just re-use the PMTs we found last time we checked during this request (if |
58 | 58 | * we have not yet checked during this request, then we need to check anyways) |
59 | 59 | */ |
60 | - public function maybe_register_payment_methods( $force_recheck = FALSE ){ |
|
61 | - if( ! $this->_payment_method_types || $force_recheck ){ |
|
60 | + public function maybe_register_payment_methods($force_recheck = FALSE) { |
|
61 | + if ( ! $this->_payment_method_types || $force_recheck) { |
|
62 | 62 | $this->_register_payment_methods(); |
63 | 63 | //if in admin lets ensure caps are set. |
64 | - if ( is_admin() ) { |
|
65 | - add_filter( 'FHEE__EE_Capabilities__init_caps_map__caps', array( $this, 'add_payment_method_caps' ) ); |
|
64 | + if (is_admin()) { |
|
65 | + add_filter('FHEE__EE_Capabilities__init_caps_map__caps', array($this, 'add_payment_method_caps')); |
|
66 | 66 | EE_Registry::instance()->CAP->init_caps(); |
67 | 67 | } |
68 | 68 | } |
@@ -75,19 +75,19 @@ discard block |
||
75 | 75 | */ |
76 | 76 | protected function _register_payment_methods() { |
77 | 77 | // grab list of installed modules |
78 | - $pm_to_register = glob( EE_PAYMENT_METHODS . '*', GLOB_ONLYDIR ); |
|
78 | + $pm_to_register = glob(EE_PAYMENT_METHODS.'*', GLOB_ONLYDIR); |
|
79 | 79 | // filter list of modules to register |
80 | - $pm_to_register = apply_filters( 'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register', $pm_to_register ); |
|
80 | + $pm_to_register = apply_filters('FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register', $pm_to_register); |
|
81 | 81 | |
82 | 82 | // loop through folders |
83 | - foreach ( $pm_to_register as $pm_path ) { |
|
84 | - $this->register_payment_method( $pm_path ); |
|
83 | + foreach ($pm_to_register as $pm_path) { |
|
84 | + $this->register_payment_method($pm_path); |
|
85 | 85 | } |
86 | - do_action( 'FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods' ); |
|
86 | + do_action('FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods'); |
|
87 | 87 | // filter list of installed modules |
88 | 88 | //keep them organized alphabetically by the payment method type's name |
89 | - ksort( $this->_payment_method_types ); |
|
90 | - return apply_filters( 'FHEE__EE_Payment_Method_Manager__register_payment_methods__installed_payment_methods', $this->_payment_method_types ); |
|
89 | + ksort($this->_payment_method_types); |
|
90 | + return apply_filters('FHEE__EE_Payment_Method_Manager__register_payment_methods__installed_payment_methods', $this->_payment_method_types); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | |
@@ -99,35 +99,35 @@ discard block |
||
99 | 99 | * @param string $payment_method_path - full path up to and including payment method folder |
100 | 100 | * @return boolean |
101 | 101 | */ |
102 | - public function register_payment_method( $payment_method_path = '' ) { |
|
103 | - do_action( 'AHEE__EE_Payment_Method_Manager__register_payment_method__begin',$payment_method_path ); |
|
102 | + public function register_payment_method($payment_method_path = '') { |
|
103 | + do_action('AHEE__EE_Payment_Method_Manager__register_payment_method__begin', $payment_method_path); |
|
104 | 104 | $module_ext = '.pm.php'; |
105 | 105 | // make all separators match |
106 | - $payment_method_path = rtrim( str_replace( '/\\', DS, $payment_method_path ), DS ); |
|
106 | + $payment_method_path = rtrim(str_replace('/\\', DS, $payment_method_path), DS); |
|
107 | 107 | // grab and sanitize module name |
108 | - $module_dir = basename( $payment_method_path ); |
|
108 | + $module_dir = basename($payment_method_path); |
|
109 | 109 | // create classname from module directory name |
110 | - $module = str_replace( ' ', '_', str_replace( '_', ' ', $module_dir )); |
|
110 | + $module = str_replace(' ', '_', str_replace('_', ' ', $module_dir)); |
|
111 | 111 | // add class prefix |
112 | - $module_class = 'EE_PMT_' . $module; |
|
112 | + $module_class = 'EE_PMT_'.$module; |
|
113 | 113 | // does the module exist ? |
114 | - if ( ! is_readable( $payment_method_path . DS . $module_class . $module_ext )) { |
|
115 | - $msg = sprintf( __( 'The requested %s payment method file could not be found or is not readable due to file permissions.', 'event_espresso' ), $module ); |
|
116 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
114 | + if ( ! is_readable($payment_method_path.DS.$module_class.$module_ext)) { |
|
115 | + $msg = sprintf(__('The requested %s payment method file could not be found or is not readable due to file permissions.', 'event_espresso'), $module); |
|
116 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
117 | 117 | return FALSE; |
118 | 118 | } |
119 | - if ( WP_DEBUG === TRUE ) { EEH_Debug_Tools::instance()->start_timer(); } |
|
119 | + if (WP_DEBUG === TRUE) { EEH_Debug_Tools::instance()->start_timer(); } |
|
120 | 120 | // load the module class file |
121 | - require_once( $payment_method_path . DS . $module_class . $module_ext ); |
|
122 | - if ( WP_DEBUG === TRUE ) { EEH_Debug_Tools::instance()->stop_timer("Requiring payment method $module_class"); } |
|
121 | + require_once($payment_method_path.DS.$module_class.$module_ext); |
|
122 | + if (WP_DEBUG === TRUE) { EEH_Debug_Tools::instance()->stop_timer("Requiring payment method $module_class"); } |
|
123 | 123 | // verify that class exists |
124 | - if ( ! class_exists( $module_class )) { |
|
125 | - $msg = sprintf( __( 'The requested %s module class does not exist.', 'event_espresso' ), $module_class ); |
|
126 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
124 | + if ( ! class_exists($module_class)) { |
|
125 | + $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class); |
|
126 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
127 | 127 | return FALSE; |
128 | 128 | } |
129 | 129 | // add to array of registered modules |
130 | - $this->_payment_method_types[ $module ] = $payment_method_path . DS . $module_class . $module_ext; |
|
130 | + $this->_payment_method_types[$module] = $payment_method_path.DS.$module_class.$module_ext; |
|
131 | 131 | return TRUE; |
132 | 132 | } |
133 | 133 | /** |
@@ -136,15 +136,15 @@ discard block |
||
136 | 136 | * @param boolean $force_recheck whether to force re-checking for new payment method types |
137 | 137 | * @return boolean |
138 | 138 | */ |
139 | - public function payment_method_type_exists($payment_method_name, $force_recheck = FALSE){ |
|
140 | - if ( ! is_array( $this->_payment_method_types ) || ! isset( $this->_payment_method_types[$payment_method_name] ) |
|
141 | - || $force_recheck ) { |
|
139 | + public function payment_method_type_exists($payment_method_name, $force_recheck = FALSE) { |
|
140 | + if ( ! is_array($this->_payment_method_types) || ! isset($this->_payment_method_types[$payment_method_name]) |
|
141 | + || $force_recheck) { |
|
142 | 142 | $this->maybe_register_payment_methods($force_recheck); |
143 | 143 | } |
144 | - if(isset($this->_payment_method_types[$payment_method_name])){ |
|
144 | + if (isset($this->_payment_method_types[$payment_method_name])) { |
|
145 | 145 | require_once($this->_payment_method_types[$payment_method_name]); |
146 | 146 | return true; |
147 | - }else{ |
|
147 | + } else { |
|
148 | 148 | return false; |
149 | 149 | } |
150 | 150 | } |
@@ -155,16 +155,16 @@ discard block |
||
155 | 155 | * @param boolean $force_recheck whether to force re-checking for new payment method types |
156 | 156 | * @return array |
157 | 157 | */ |
158 | - public function payment_method_type_names($with_prefixes = FALSE, $force_recheck = FALSE ){ |
|
158 | + public function payment_method_type_names($with_prefixes = FALSE, $force_recheck = FALSE) { |
|
159 | 159 | $this->maybe_register_payment_methods($force_recheck); |
160 | - if($with_prefixes){ |
|
160 | + if ($with_prefixes) { |
|
161 | 161 | $classnames = array_keys($this->_payment_method_types); |
162 | 162 | $payment_methods = array(); |
163 | - foreach($classnames as $classname){ |
|
163 | + foreach ($classnames as $classname) { |
|
164 | 164 | $payment_methods[] = $this->payment_method_class_from_type($classname); |
165 | 165 | } |
166 | 166 | return $payment_methods; |
167 | - }else{ |
|
167 | + } else { |
|
168 | 168 | return array_keys($this->_payment_method_types); |
169 | 169 | } |
170 | 170 | } |
@@ -174,10 +174,10 @@ discard block |
||
174 | 174 | * @param boolean $force_recheck whether to force re-checking for new payment method types |
175 | 175 | * @return EE_PMT_Base[] |
176 | 176 | */ |
177 | - public function payment_method_types( $force_recheck = FALSE ){ |
|
177 | + public function payment_method_types($force_recheck = FALSE) { |
|
178 | 178 | $this->maybe_register_payment_methods($force_recheck); |
179 | 179 | $pmt_objs = array(); |
180 | - foreach($this->payment_method_type_names(true) as $classname){ |
|
180 | + foreach ($this->payment_method_type_names(true) as $classname) { |
|
181 | 181 | $pmt_objs[] = new $classname; |
182 | 182 | } |
183 | 183 | return $pmt_objs; |
@@ -189,8 +189,8 @@ discard block |
||
189 | 189 | * @param string $classname |
190 | 190 | * @return string |
191 | 191 | */ |
192 | - public function payment_method_type_sans_class_prefix($classname){ |
|
193 | - $pmt_name = str_replace("EE_PMT_","",$classname); |
|
192 | + public function payment_method_type_sans_class_prefix($classname) { |
|
193 | + $pmt_name = str_replace("EE_PMT_", "", $classname); |
|
194 | 194 | return $pmt_name; |
195 | 195 | } |
196 | 196 | |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | * @param string $type |
200 | 200 | * @return string |
201 | 201 | */ |
202 | - public function payment_method_class_from_type($type){ |
|
202 | + public function payment_method_class_from_type($type) { |
|
203 | 203 | $this->maybe_register_payment_methods(); |
204 | 204 | return "EE_PMT_".$type; |
205 | 205 | } |
@@ -213,38 +213,38 @@ discard block |
||
213 | 213 | * @return \EE_Payment_Method |
214 | 214 | * @throws \EE_Error |
215 | 215 | */ |
216 | - public function activate_a_payment_method_of_type( $payment_method_type ){ |
|
216 | + public function activate_a_payment_method_of_type($payment_method_type) { |
|
217 | 217 | $payment_method = EEM_Payment_Method::instance()->get_one_of_type($payment_method_type); |
218 | - if( ! $payment_method instanceof EE_Payment_Method ){ |
|
218 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
219 | 219 | $pm_type_class = $this->payment_method_class_from_type($payment_method_type); |
220 | - if(class_exists($pm_type_class)){ |
|
220 | + if (class_exists($pm_type_class)) { |
|
221 | 221 | /** @var $pm_type_obj EE_PMT_Base */ |
222 | 222 | $pm_type_obj = new $pm_type_class; |
223 | 223 | $payment_method = EEM_Payment_Method::instance()->get_one_by_slug($pm_type_obj->system_name()); |
224 | - if( ! $payment_method){ |
|
225 | - $payment_method = $this->create_payment_method_of_type( $pm_type_obj ); |
|
224 | + if ( ! $payment_method) { |
|
225 | + $payment_method = $this->create_payment_method_of_type($pm_type_obj); |
|
226 | 226 | } |
227 | - $payment_method->set_type( $payment_method_type ); |
|
228 | - $this->initialize_payment_method( $payment_method ); |
|
227 | + $payment_method->set_type($payment_method_type); |
|
228 | + $this->initialize_payment_method($payment_method); |
|
229 | 229 | } else { |
230 | 230 | throw new EE_Error( |
231 | 231 | sprintf( |
232 | - __( 'There is no payment method of type %1$s, so it could not be activated', 'event_espresso'), |
|
232 | + __('There is no payment method of type %1$s, so it could not be activated', 'event_espresso'), |
|
233 | 233 | $pm_type_class ) |
234 | 234 | ); |
235 | 235 | } |
236 | 236 | } |
237 | 237 | $payment_method->set_active(); |
238 | 238 | $payment_method->save(); |
239 | - $this->set_usable_currencies_on_payment_method( $payment_method ); |
|
240 | - if( $payment_method->type() == 'Invoice' ){ |
|
241 | - $messages = EE_Registry::instance()->load_lib( 'messages' ); |
|
242 | - $messages->ensure_message_type_is_active( 'invoice', 'html' ); |
|
243 | - $messages->ensure_messenger_is_active( 'pdf' ); |
|
239 | + $this->set_usable_currencies_on_payment_method($payment_method); |
|
240 | + if ($payment_method->type() == 'Invoice') { |
|
241 | + $messages = EE_Registry::instance()->load_lib('messages'); |
|
242 | + $messages->ensure_message_type_is_active('invoice', 'html'); |
|
243 | + $messages->ensure_messenger_is_active('pdf'); |
|
244 | 244 | EE_Error::add_attention( |
245 | 245 | sprintf( |
246 | - __( 'Note, when the invoice payment method is activated, the invoice message type, html messenger, and pdf messenger are activated as well for the %1$smessages system%2$s.', 'event_espresso' ), |
|
247 | - '<a href="' . admin_url( 'admin.php?page=espresso_messages') . '">', |
|
246 | + __('Note, when the invoice payment method is activated, the invoice message type, html messenger, and pdf messenger are activated as well for the %1$smessages system%2$s.', 'event_espresso'), |
|
247 | + '<a href="'.admin_url('admin.php?page=espresso_messages').'">', |
|
248 | 248 | '</a>' |
249 | 249 | ) |
250 | 250 | ); |
@@ -258,17 +258,17 @@ discard block |
||
258 | 258 | * @param EE_PMT_Base $pm_type_obj |
259 | 259 | * @return EE_Payment_Method |
260 | 260 | */ |
261 | - public function create_payment_method_of_type( $pm_type_obj ) { |
|
261 | + public function create_payment_method_of_type($pm_type_obj) { |
|
262 | 262 | global $current_user; |
263 | 263 | $payment_method = EE_Payment_Method::new_instance( |
264 | 264 | array( |
265 | 265 | 'PMD_type' => $pm_type_obj->system_name(), |
266 | 266 | 'PMD_name' => $pm_type_obj->pretty_name(), |
267 | 267 | 'PMD_admin_name' => $pm_type_obj->pretty_name(), |
268 | - 'PMD_slug' => $pm_type_obj->system_name(),//automatically converted to slug |
|
268 | + 'PMD_slug' => $pm_type_obj->system_name(), //automatically converted to slug |
|
269 | 269 | 'PMD_wp_user' => $current_user->ID, |
270 | 270 | 'PMD_order' => EEM_Payment_Method::instance()->count( |
271 | - array( array( 'PMD_type' => array( '!=', 'Admin_Only' ))) |
|
271 | + array(array('PMD_type' => array('!=', 'Admin_Only'))) |
|
272 | 272 | ) * 10, |
273 | 273 | ) |
274 | 274 | ); |
@@ -280,16 +280,16 @@ discard block |
||
280 | 280 | * @param EE_Payment_Method $payment_method |
281 | 281 | * @return EE_Payment_Method |
282 | 282 | */ |
283 | - public function initialize_payment_method( $payment_method ) { |
|
283 | + public function initialize_payment_method($payment_method) { |
|
284 | 284 | $pm_type_obj = $payment_method->type_obj(); |
285 | - $payment_method->set_description( $pm_type_obj->default_description() ); |
|
286 | - if( ! $payment_method->button_url() ){ |
|
287 | - $payment_method->set_button_url( $pm_type_obj->default_button_url() ); |
|
285 | + $payment_method->set_description($pm_type_obj->default_description()); |
|
286 | + if ( ! $payment_method->button_url()) { |
|
287 | + $payment_method->set_button_url($pm_type_obj->default_button_url()); |
|
288 | 288 | } |
289 | 289 | //now add setup its default extra meta properties |
290 | 290 | $extra_metas = $pm_type_obj->settings_form()->extra_meta_inputs(); |
291 | - foreach( $extra_metas as $meta_name => $input ){ |
|
292 | - $payment_method->update_extra_meta($meta_name, $input->raw_value() ); |
|
291 | + foreach ($extra_metas as $meta_name => $input) { |
|
292 | + $payment_method->update_extra_meta($meta_name, $input->raw_value()); |
|
293 | 293 | } |
294 | 294 | return $payment_method; |
295 | 295 | } |
@@ -299,8 +299,8 @@ discard block |
||
299 | 299 | * @param EE_Payment_Method $payment_method |
300 | 300 | * @return EE_Payment_Method |
301 | 301 | */ |
302 | - public function set_usable_currencies_on_payment_method( $payment_method ) { |
|
303 | - foreach($payment_method->get_all_usable_currencies() as $currency_obj){ |
|
302 | + public function set_usable_currencies_on_payment_method($payment_method) { |
|
303 | + foreach ($payment_method->get_all_usable_currencies() as $currency_obj) { |
|
304 | 304 | $payment_method->_add_relation_to($currency_obj, 'Currency'); |
305 | 305 | } |
306 | 306 | return $payment_method; |
@@ -318,8 +318,8 @@ discard block |
||
318 | 318 | * |
319 | 319 | * @return int count of rows updated. |
320 | 320 | */ |
321 | - public function deactivate_payment_method( $payment_method_slug ) { |
|
322 | - $count_updated = EEM_Payment_Method::instance()->update(array('PMD_scope'=>array()),array(array('PMD_slug'=>$payment_method_slug))); |
|
321 | + public function deactivate_payment_method($payment_method_slug) { |
|
322 | + $count_updated = EEM_Payment_Method::instance()->update(array('PMD_scope'=>array()), array(array('PMD_slug'=>$payment_method_slug))); |
|
323 | 323 | return $count_updated; |
324 | 324 | } |
325 | 325 | |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | * @param array $caps capabilities being filtered |
333 | 333 | * @return array |
334 | 334 | */ |
335 | - public function add_payment_method_caps( $caps ) { |
|
335 | + public function add_payment_method_caps($caps) { |
|
336 | 336 | /* add dynamic caps from payment methods |
337 | 337 | * at the time of writing, october 20 2014, these are the caps added: |
338 | 338 | * ee_payment_method_admin_only |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | * their related capability automatically added too, so long as they are |
348 | 348 | * registered properly using EE_Register_Payment_Method::register() |
349 | 349 | */ |
350 | - foreach( $this->payment_method_types() as $payment_method_type_obj ){ |
|
350 | + foreach ($this->payment_method_types() as $payment_method_type_obj) { |
|
351 | 351 | $caps['administrator'][] = $payment_method_type_obj->cap_name(); |
352 | 352 | } |
353 | 353 | return $caps; |
@@ -5,42 +5,42 @@ |
||
5 | 5 | <table class="admin-primary-mbox-tbl"> |
6 | 6 | <thead> |
7 | 7 | <tr> |
8 | - <th class="jst-left"><?php esc_html_e( 'Event Name', 'event_espresso' );?></th> |
|
9 | - <th class="jst-left"><?php esc_html_e( 'REG ID', 'event_espresso' );?></th> |
|
10 | - <th class="jst-left"><?php esc_html_e( 'TXN ID', 'event_espresso' );?></th> |
|
11 | - <th class="jst-left"><?php esc_html_e( 'Reg Code', 'event_espresso' );?></th> |
|
12 | - <th class="jst-rght"><?php esc_html_e( 'Ticket Price', 'event_espresso' );?></th> |
|
8 | + <th class="jst-left"><?php esc_html_e('Event Name', 'event_espresso'); ?></th> |
|
9 | + <th class="jst-left"><?php esc_html_e('REG ID', 'event_espresso'); ?></th> |
|
10 | + <th class="jst-left"><?php esc_html_e('TXN ID', 'event_espresso'); ?></th> |
|
11 | + <th class="jst-left"><?php esc_html_e('Reg Code', 'event_espresso'); ?></th> |
|
12 | + <th class="jst-rght"><?php esc_html_e('Ticket Price', 'event_espresso'); ?></th> |
|
13 | 13 | </tr> |
14 | 14 | </thead> |
15 | 15 | <tbody> |
16 | - <?php foreach( $registrations as $registration ) : ?> |
|
16 | + <?php foreach ($registrations as $registration) : ?> |
|
17 | 17 | <tr> |
18 | 18 | <td class="jst-left"> |
19 | 19 | <?php |
20 | - $event_url = add_query_arg( array( 'action' => 'edit', 'post' => $registration->event_ID() ), admin_url( 'admin.php?page=espresso_events' )); |
|
21 | - echo EE_Registry::instance()->CAP->current_user_can( 'ee_edit_event', 'espresso_events_edit', $registration->event_ID() ) ? '<a href="'. $event_url .'" title="'. esc_attr__( 'Edit Event', 'event_espresso' ) .'">' . $registration->event_name() . '</a>' : $registration->event_name(); |
|
20 | + $event_url = add_query_arg(array('action' => 'edit', 'post' => $registration->event_ID()), admin_url('admin.php?page=espresso_events')); |
|
21 | + echo EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'espresso_events_edit', $registration->event_ID()) ? '<a href="'.$event_url.'" title="'.esc_attr__('Edit Event', 'event_espresso').'">'.$registration->event_name().'</a>' : $registration->event_name(); |
|
22 | 22 | ?> |
23 | 23 | </td> |
24 | 24 | <td class="jst-left"> |
25 | 25 | <?php |
26 | - $reg_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_registration', '_REG_ID'=>$registration->ID() ), REG_ADMIN_URL ); |
|
27 | - echo EE_Registry::instance()->CAP->current_user_can( 'ee_read_registration', 'espresso_registrations_view_registration', $registration->ID() ) ? ' |
|
28 | - <a href="'.$reg_url.'" title="' . esc_attr__( 'View Registration Details', 'event_espresso' ) . '">' . |
|
29 | - esc_html__( 'View Registration', 'event_espresso' ) . |
|
26 | + $reg_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_registration', '_REG_ID'=>$registration->ID()), REG_ADMIN_URL); |
|
27 | + echo EE_Registry::instance()->CAP->current_user_can('ee_read_registration', 'espresso_registrations_view_registration', $registration->ID()) ? ' |
|
28 | + <a href="'.$reg_url.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'">'. |
|
29 | + esc_html__('View Registration', 'event_espresso'). |
|
30 | 30 | '</a>' : $registration->ID(); |
31 | 31 | ?> |
32 | 32 | </td> |
33 | 33 | <td class="jst-left"> |
34 | 34 | <?php |
35 | - $txn_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_transaction', 'TXN_ID'=>$registration->transaction_ID() ), TXN_ADMIN_URL ); |
|
36 | - echo EE_Registry::instance()->CAP->current_user_can( 'ee_read_transaction', 'espresso_transactions_view_transaction' ) ? ' |
|
37 | - <a href="'.$txn_url.'" title="' . esc_attr__( 'View Transaction Details', 'event_espresso' ) . '">' . |
|
38 | - sprintf( esc_html__('View Transaction %d', 'event_espresso'), $registration->transaction_ID() ) . |
|
35 | + $txn_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_transaction', 'TXN_ID'=>$registration->transaction_ID()), TXN_ADMIN_URL); |
|
36 | + echo EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', 'espresso_transactions_view_transaction') ? ' |
|
37 | + <a href="'.$txn_url.'" title="'.esc_attr__('View Transaction Details', 'event_espresso').'">'. |
|
38 | + sprintf(esc_html__('View Transaction %d', 'event_espresso'), $registration->transaction_ID()). |
|
39 | 39 | '</a>' : $registration->transaction_ID(); |
40 | 40 | ?> |
41 | 41 | </td> |
42 | - <td class="jst-left"><?php echo $registration->reg_code();?></td> |
|
43 | - <td class="jst-rght"><?php echo EEH_Template::format_currency( $registration->final_price() );?></td> |
|
42 | + <td class="jst-left"><?php echo $registration->reg_code(); ?></td> |
|
43 | + <td class="jst-rght"><?php echo EEH_Template::format_currency($registration->final_price()); ?></td> |
|
44 | 44 | </tr> |
45 | 45 | <?php endforeach; ?> |
46 | 46 | </tbody> |
@@ -32,7 +32,6 @@ |
||
32 | 32 | /** |
33 | 33 | * |
34 | 34 | * @param string $model_name |
35 | - * @param string $comparison_model_name |
|
36 | 35 | * @param string $id_or_name_field should be the string 'ID' or 'name' only |
37 | 36 | * @return EE_Model_Field_Base |
38 | 37 | */ |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Joins any two models together via a has-and-belongs-to-many relation, using |
4 | 4 | * the esp_extra_join table. |
5 | 5 | */ |
6 | -class EE_HABTM_Any_Relation extends EE_HABTM_Relation{ |
|
6 | +class EE_HABTM_Any_Relation extends EE_HABTM_Relation { |
|
7 | 7 | /** |
8 | 8 | * |
9 | 9 | * @var string |
@@ -17,16 +17,16 @@ discard block |
||
17 | 17 | * @param boolean $block_deletes for this type of relation, we block by default for now. if there are related models across this relation, block (prevent and add an error) the deletion of this model |
18 | 18 | * @param type $blocking_delete_error_message a customized error message on blocking deletes instead of the default |
19 | 19 | */ |
20 | - function __construct( $block_deletes = true, $blocking_delete_error_message =''){ |
|
21 | - parent::__construct( 'Extra_Join', $block_deletes, $blocking_delete_error_message); |
|
20 | + function __construct($block_deletes = true, $blocking_delete_error_message = '') { |
|
21 | + parent::__construct('Extra_Join', $block_deletes, $blocking_delete_error_message); |
|
22 | 22 | } |
23 | - function _construct_finalize_set_models($this_model_name, $other_model_name){ |
|
24 | - if( $this_model_name < $other_model_name ) { |
|
23 | + function _construct_finalize_set_models($this_model_name, $other_model_name) { |
|
24 | + if ($this_model_name < $other_model_name) { |
|
25 | 25 | $this->_alphabetically_first_model_name = $this_model_name; |
26 | - } else{ |
|
26 | + } else { |
|
27 | 27 | $this->_alphabetically_first_model_name = $other_model_name; |
28 | 28 | } |
29 | - return parent::_construct_finalize_set_models( $this_model_name, $other_model_name ); |
|
29 | + return parent::_construct_finalize_set_models($this_model_name, $other_model_name); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | /** |
@@ -36,21 +36,21 @@ discard block |
||
36 | 36 | * @param string $id_or_name_field should be the string 'ID' or 'name' only |
37 | 37 | * @return EE_Model_Field_Base |
38 | 38 | */ |
39 | - function get_join_table_fk_field_to( $model_name, $id_or_name_field ) { |
|
39 | + function get_join_table_fk_field_to($model_name, $id_or_name_field) { |
|
40 | 40 | $order = null; |
41 | - if( $model_name === $this->_alphabetically_first_model_name ) { |
|
41 | + if ($model_name === $this->_alphabetically_first_model_name) { |
|
42 | 42 | $order = 'first'; |
43 | 43 | } else { |
44 | 44 | $order = 'second'; |
45 | 45 | } |
46 | - return $this->get_join_model()->field_settings_for( 'EXJ_' . $order . '_model_' . $id_or_name_field ); |
|
46 | + return $this->get_join_model()->field_settings_for('EXJ_'.$order.'_model_'.$id_or_name_field); |
|
47 | 47 | } |
48 | 48 | /** |
49 | 49 | * Gets the SQL string for joining the main model's table containing the pk to the join table. Eg "LEFT JOIN real_join_table AS join_table_alias ON this_table_alias.pk = join_table_alias.fk_to_this_table" |
50 | 50 | * @param string $model_relation_chain like 'Event.Event_Venue.Venue' |
51 | 51 | * @return string of SQL |
52 | 52 | */ |
53 | - function get_join_to_intermediate_model_statement($model_relation_chain){ |
|
53 | + function get_join_to_intermediate_model_statement($model_relation_chain) { |
|
54 | 54 | //create sql like |
55 | 55 | //LEFT JOIN join_table AS join_table_alias ON this_table_alias.this_table_pk = join_table_alias.join_table_fk_to_this |
56 | 56 | //LEFT JOIN other_table AS other_table_alias ON join_table_alias.join_table_fk_to_other = other_table_alias.other_table_pk |
@@ -64,8 +64,8 @@ discard block |
||
64 | 64 | $field_with_model_name = $this->get_join_table_fk_field_to( |
65 | 65 | $this->get_this_model()->get_this_model_name(), |
66 | 66 | 'name' ); |
67 | - $this_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model()->get_this_model_name()) . $this_table_pk_field->get_table_alias(); |
|
68 | - $join_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_join_model()->get_this_model_name()) . $join_table_fk_field_to_this_table->get_table_alias(); |
|
67 | + $this_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model()->get_this_model_name()).$this_table_pk_field->get_table_alias(); |
|
68 | + $join_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_join_model()->get_this_model_name()).$join_table_fk_field_to_this_table->get_table_alias(); |
|
69 | 69 | $join_table = $this->get_join_model()->get_table_for_alias($join_table_alias); |
70 | 70 | //phew! ok, we have all the info we need, now we can create the SQL join string |
71 | 71 | $SQL = $this->_left_join( |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | $join_table_fk_field_to_this_table->get_table_column(), |
75 | 75 | $this_table_alias, |
76 | 76 | $this_table_pk_field->get_table_column(), |
77 | - $field_with_model_name->get_qualified_column()."='".$this->get_this_model()->get_this_model_name()."'" ) . |
|
77 | + $field_with_model_name->get_qualified_column()."='".$this->get_this_model()->get_this_model_name()."'" ). |
|
78 | 78 | $this->get_join_model()->_construct_internal_join_to_table_with_alias($join_table_alias); |
79 | 79 | |
80 | 80 | return $SQL; |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | * @param string $model_relation_chain like 'Event.Event_Venue.Venue' |
88 | 88 | * @return string of SQL |
89 | 89 | */ |
90 | - function get_join_statement($model_relation_chain){ |
|
91 | - if( $this->_model_relation_chain_to_join_model === NULL ){ |
|
92 | - throw new EE_Error( sprintf( __( 'When using EE_HABTM_Relation to create a join, you must call get_join_to_intermediate_model_statement BEFORE get_join_statement', 'event_espresso' ))); |
|
90 | + function get_join_statement($model_relation_chain) { |
|
91 | + if ($this->_model_relation_chain_to_join_model === NULL) { |
|
92 | + throw new EE_Error(sprintf(__('When using EE_HABTM_Relation to create a join, you must call get_join_to_intermediate_model_statement BEFORE get_join_statement', 'event_espresso'))); |
|
93 | 93 | } |
94 | 94 | $join_table_fk_field_to_this_table = $this->get_join_table_fk_field_to( |
95 | 95 | $this->get_this_model()->get_this_model_name(), |
@@ -101,10 +101,10 @@ discard block |
||
101 | 101 | $this->get_other_model()->get_this_model_name(), |
102 | 102 | 'name' ); |
103 | 103 | |
104 | - $join_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($this->_model_relation_chain_to_join_model, $this->get_join_model()->get_this_model_name()) . $join_table_fk_field_to_this_table->get_table_alias(); |
|
104 | + $join_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($this->_model_relation_chain_to_join_model, $this->get_join_model()->get_this_model_name()).$join_table_fk_field_to_this_table->get_table_alias(); |
|
105 | 105 | |
106 | 106 | $other_table_pk_field = $this->get_other_model()->get_primary_key_field(); |
107 | - $other_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_other_model()->get_this_model_name()) . $other_table_pk_field->get_table_alias(); |
|
107 | + $other_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_other_model()->get_this_model_name()).$other_table_pk_field->get_table_alias(); |
|
108 | 108 | $other_table = $this->get_other_model()->get_table_for_alias($other_table_alias); |
109 | 109 | |
110 | 110 | $SQL = $this->_left_join( |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | $join_table_alias, |
115 | 115 | $join_table_fk_field_to_other_table->get_table_column(), |
116 | 116 | $field_with_other_model_name->get_qualified_column()."='".$this->get_other_model()->get_this_model_name()."'" |
117 | - ) . |
|
117 | + ). |
|
118 | 118 | $this->get_other_model()->_construct_internal_join_to_table_with_alias($other_table_alias); |
119 | 119 | return $SQL; |
120 | 120 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * @param array $extra_join_model_fields_n_values col=>val pairs that are used as extra conditions for checking existing values and for setting new rows if no exact matches. |
127 | 127 | * @return EE_Base_Class |
128 | 128 | */ |
129 | - function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array() ){ |
|
129 | + function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array()) { |
|
130 | 130 | $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true); |
131 | 131 | $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
132 | 132 | //check if such a relationship already exists |
@@ -143,31 +143,31 @@ discard block |
||
143 | 143 | $this->get_other_model()->get_this_model_name(), |
144 | 144 | 'name' ); |
145 | 145 | |
146 | - $cols_n_values = array( |
|
146 | + $cols_n_values = array( |
|
147 | 147 | $join_model_fk_to_this_model->get_name() => $this_model_obj->ID(), |
148 | 148 | $join_model_name_field_to_this_model->get_name() => $this_model_obj->get_model()->get_this_model_name(), |
149 | 149 | $join_model_fk_to_other_model->get_name() => $other_model_obj->ID(), |
150 | 150 | $join_model_name_field_to_other_model->get_name() => $other_model_obj->get_model()->get_this_model_name() ); |
151 | 151 | |
152 | 152 | //if $where_query exists lets add them to the query_params. |
153 | - if ( !empty( $extra_join_model_fields_n_values ) ) { |
|
153 | + if ( ! empty($extra_join_model_fields_n_values)) { |
|
154 | 154 | //make sure we strip any of the join model names from the $where_query cause we don't need that in here (why? because client code may have used the same conditionals for get_all_related which DOES need the join model name) |
155 | 155 | //make sure we strip THIS models name from the query param |
156 | - foreach ( $extra_join_model_fields_n_values as $query_param => $val ) { |
|
157 | - $query_param = str_replace($this->get_join_model()->get_this_model_name().".","", $query_param); |
|
156 | + foreach ($extra_join_model_fields_n_values as $query_param => $val) { |
|
157 | + $query_param = str_replace($this->get_join_model()->get_this_model_name().".", "", $query_param); |
|
158 | 158 | $parsed_query[$query_param] = $val; |
159 | 159 | } |
160 | - $cols_n_values = array_merge( $cols_n_values, $parsed_query ); |
|
160 | + $cols_n_values = array_merge($cols_n_values, $parsed_query); |
|
161 | 161 | } |
162 | 162 | |
163 | - $query_params = array( $cols_n_values ); |
|
163 | + $query_params = array($cols_n_values); |
|
164 | 164 | |
165 | 165 | |
166 | 166 | $existing_entry_in_join_table = $this->get_join_model()->get_one($query_params); |
167 | 167 | //if there is already an entry in the join table, indicating a relationship, we're done |
168 | 168 | //again, if you want more sophisticated logic or insertions (handling more columns than just 2 foreign keys to |
169 | 169 | //the other tables, use the joining model directly! |
170 | - if( ! $existing_entry_in_join_table ){ |
|
170 | + if ( ! $existing_entry_in_join_table) { |
|
171 | 171 | $this->get_join_model()->insert($cols_n_values); |
172 | 172 | } |
173 | 173 | return $other_model_obj; |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | * * @param array $where_query col=>val pairs that are used as extra conditions for checking existing values and for removing existing rows if exact matches exist. |
180 | 180 | * @return EE_Base_Class |
181 | 181 | */ |
182 | - function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array() ){ |
|
182 | + function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array()) { |
|
183 | 183 | $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true); |
184 | 184 | $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
185 | 185 | //check if such a relationship already exists |
@@ -196,24 +196,24 @@ discard block |
||
196 | 196 | $this->get_other_model()->get_this_model_name(), |
197 | 197 | 'name' ); |
198 | 198 | |
199 | - $cols_n_values = array( |
|
199 | + $cols_n_values = array( |
|
200 | 200 | $join_model_fk_to_this_model->get_name() => $this_model_obj->ID(), |
201 | 201 | $join_model_name_field_to_this_model->get_name() => $this_model_obj->get_model()->get_this_model_name(), |
202 | 202 | $join_model_fk_to_other_model->get_name() => $other_model_obj->ID(), |
203 | 203 | $join_model_name_field_to_other_model->get_name() => $other_model_obj->get_model()->get_this_model_name() ); |
204 | 204 | |
205 | 205 | //if $where_query exists lets add them to the query_params. |
206 | - if ( !empty( $where_query ) ) { |
|
206 | + if ( ! empty($where_query)) { |
|
207 | 207 | //make sure we strip any of the join model names from the $where_query cause we don't need that in here (why? because client code may have used the same conditionals for get_all_related which DOES need the join model name) |
208 | 208 | //make sure we strip THIS models name from the query param |
209 | - foreach ( $where_query as $query_param => $val ) { |
|
210 | - $query_param = str_replace($this->get_join_model()->get_this_model_name().".","", $query_param); |
|
209 | + foreach ($where_query as $query_param => $val) { |
|
210 | + $query_param = str_replace($this->get_join_model()->get_this_model_name().".", "", $query_param); |
|
211 | 211 | $parsed_query[$query_param] = $val; |
212 | 212 | } |
213 | - $cols_n_values = array_merge( $cols_n_values, $parsed_query ); |
|
213 | + $cols_n_values = array_merge($cols_n_values, $parsed_query); |
|
214 | 214 | } |
215 | 215 | |
216 | - $existing_entry_in_join_table = $this->get_join_model()->delete( array($cols_n_values) ); |
|
216 | + $existing_entry_in_join_table = $this->get_join_model()->delete(array($cols_n_values)); |
|
217 | 217 | return $other_model_obj; |
218 | 218 | } |
219 | 219 | } |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2 | 2 | /** |
3 | - * Contains definition for EE_Extra_Join model object |
|
4 | - * @package Event Espresso |
|
5 | - * @subpackage models |
|
6 | - * @since $VID$ |
|
7 | - */ |
|
3 | + * Contains definition for EE_Extra_Join model object |
|
4 | + * @package Event Espresso |
|
5 | + * @subpackage models |
|
6 | + * @since $VID$ |
|
7 | + */ |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * EE_Extra_Join |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | * @param null $timezone |
23 | 23 | * @return EE_Event_Message_Template|mixed |
24 | 24 | */ |
25 | - public static function new_instance( $props_n_values = array(), $timezone = NULL ) { |
|
26 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone ); |
|
27 | - return $has_object ? $has_object : new self( $props_n_values, FALSE, $timezone ); |
|
25 | + public static function new_instance($props_n_values = array(), $timezone = NULL) { |
|
26 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone); |
|
27 | + return $has_object ? $has_object : new self($props_n_values, FALSE, $timezone); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | * @param null $timezone |
35 | 35 | * @return EE_Event_Message_Template |
36 | 36 | */ |
37 | - public static function new_instance_from_db ( $props_n_values = array(), $timezone = NULL ) { |
|
38 | - return new self( $props_n_values, TRUE, $timezone ); |
|
37 | + public static function new_instance_from_db($props_n_values = array(), $timezone = NULL) { |
|
38 | + return new self($props_n_values, TRUE, $timezone); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | } |
@@ -12,8 +12,8 @@ discard block |
||
12 | 12 | * @ version 4.0 |
13 | 13 | * |
14 | 14 | */ |
15 | -require_once( EE_HELPERS . 'EEH_Base.helper.php' ); |
|
16 | -require_once( EE_INTERFACES . 'EEI_Interfaces.php' ); |
|
15 | +require_once(EE_HELPERS.'EEH_Base.helper.php'); |
|
16 | +require_once(EE_INTERFACES.'EEI_Interfaces.php'); |
|
17 | 17 | /** |
18 | 18 | * |
19 | 19 | * Class EEH_File |
@@ -42,30 +42,30 @@ discard block |
||
42 | 42 | * @throws EE_Error |
43 | 43 | * @return WP_Filesystem_Base |
44 | 44 | */ |
45 | - private static function _get_wp_filesystem( $filepath = null) { |
|
46 | - if( apply_filters( |
|
45 | + private static function _get_wp_filesystem($filepath = null) { |
|
46 | + if (apply_filters( |
|
47 | 47 | 'FHEE__EEH_File___get_wp_filesystem__allow_using_filesystem_direct', |
48 | - $filepath && EEH_File::is_in_uploads_folder( $filepath ), |
|
49 | - $filepath ) ) { |
|
50 | - if( ! EEH_File::$_wp_filesystem_direct instanceof WP_Filesystem_Direct ) { |
|
51 | - require_once(ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php'); |
|
48 | + $filepath && EEH_File::is_in_uploads_folder($filepath), |
|
49 | + $filepath )) { |
|
50 | + if ( ! EEH_File::$_wp_filesystem_direct instanceof WP_Filesystem_Direct) { |
|
51 | + require_once(ABSPATH.'wp-admin/includes/class-wp-filesystem-base.php'); |
|
52 | 52 | $method = 'direct'; |
53 | - $wp_filesystem_direct_file = apply_filters( 'filesystem_method_file', ABSPATH . 'wp-admin/includes/class-wp-filesystem-' . $method . '.php', $method ); |
|
53 | + $wp_filesystem_direct_file = apply_filters('filesystem_method_file', ABSPATH.'wp-admin/includes/class-wp-filesystem-'.$method.'.php', $method); |
|
54 | 54 | //check constants defined, just like in wp-admin/includes/file.php's WP_Filesystem() |
55 | - if ( ! defined('FS_CHMOD_DIR') ) { |
|
56 | - define('FS_CHMOD_DIR', ( fileperms( ABSPATH ) & 0777 | 0755 ) ); |
|
55 | + if ( ! defined('FS_CHMOD_DIR')) { |
|
56 | + define('FS_CHMOD_DIR', (fileperms(ABSPATH) & 0777 | 0755)); |
|
57 | 57 | } |
58 | - if ( ! defined('FS_CHMOD_FILE') ) { |
|
59 | - define('FS_CHMOD_FILE', ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ) ); |
|
58 | + if ( ! defined('FS_CHMOD_FILE')) { |
|
59 | + define('FS_CHMOD_FILE', (fileperms(ABSPATH.'index.php') & 0777 | 0644)); |
|
60 | 60 | } |
61 | - require_once( $wp_filesystem_direct_file ); |
|
62 | - EEH_File::$_wp_filesystem_direct = new WP_Filesystem_Direct( array() ); |
|
61 | + require_once($wp_filesystem_direct_file); |
|
62 | + EEH_File::$_wp_filesystem_direct = new WP_Filesystem_Direct(array()); |
|
63 | 63 | } |
64 | 64 | return EEH_File::$_wp_filesystem_direct; |
65 | 65 | } |
66 | 66 | global $wp_filesystem; |
67 | 67 | // no filesystem setup ??? |
68 | - if ( ! $wp_filesystem instanceof WP_Filesystem_Base ) { |
|
68 | + if ( ! $wp_filesystem instanceof WP_Filesystem_Base) { |
|
69 | 69 | // if some eager beaver's just trying to get in there too early... |
70 | 70 | // let them do it, because we are one of those eager beavers! :P |
71 | 71 | /** |
@@ -78,34 +78,34 @@ discard block |
||
78 | 78 | * and there may be troubles if the WP files are owned by a different user |
79 | 79 | * than the server user. But both of these issues should exist in 4.4 and earlier too |
80 | 80 | */ |
81 | - if ( FALSE && ! did_action( 'wp_loaded' )) { |
|
81 | + if (FALSE && ! did_action('wp_loaded')) { |
|
82 | 82 | $msg = __('An attempt to access and/or write to a file on the server could not be completed due to a lack of sufficient credentials.', 'event_espresso'); |
83 | - if ( WP_DEBUG ) { |
|
84 | - $msg .= '<br />' . __('The WP Filesystem can not be accessed until after the "wp_loaded" hook has run, so it\'s best not to attempt access until the "admin_init" hookpoint.', 'event_espresso'); |
|
83 | + if (WP_DEBUG) { |
|
84 | + $msg .= '<br />'.__('The WP Filesystem can not be accessed until after the "wp_loaded" hook has run, so it\'s best not to attempt access until the "admin_init" hookpoint.', 'event_espresso'); |
|
85 | 85 | } |
86 | - throw new EE_Error( $msg ); |
|
86 | + throw new EE_Error($msg); |
|
87 | 87 | } else { |
88 | 88 | // should be loaded if we are past the wp_loaded hook... |
89 | - if ( ! function_exists( 'WP_Filesystem' )) { |
|
90 | - require_once( ABSPATH . 'wp-admin/includes/file.php' ); |
|
91 | - require_once( ABSPATH . 'wp-admin/includes/template.php' ); |
|
89 | + if ( ! function_exists('WP_Filesystem')) { |
|
90 | + require_once(ABSPATH.'wp-admin/includes/file.php'); |
|
91 | + require_once(ABSPATH.'wp-admin/includes/template.php'); |
|
92 | 92 | } |
93 | 93 | // turn on output buffering so that we can capture the credentials form |
94 | 94 | ob_start(); |
95 | - $credentials = request_filesystem_credentials( '' ); |
|
95 | + $credentials = request_filesystem_credentials(''); |
|
96 | 96 | // store credentials form for the time being |
97 | 97 | EEH_File::$_credentials_form = ob_get_clean(); |
98 | 98 | // basically check for direct or previously configured access |
99 | - if ( ! WP_Filesystem( $credentials ) ) { |
|
99 | + if ( ! WP_Filesystem($credentials)) { |
|
100 | 100 | // if credentials do NOT exist |
101 | - if ( $credentials === FALSE ) { |
|
102 | - add_action( 'admin_notices', array( 'EEH_File', 'display_request_filesystem_credentials_form' ), 999 ); |
|
103 | - throw new EE_Error( __('An attempt to access and/or write to a file on the server could not be completed due to a lack of sufficient credentials.', 'event_espresso')); |
|
104 | - } elseif( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) { |
|
105 | - add_action( 'admin_notices', array( 'EEH_File', 'display_request_filesystem_credentials_form' ), 999 ); |
|
101 | + if ($credentials === FALSE) { |
|
102 | + add_action('admin_notices', array('EEH_File', 'display_request_filesystem_credentials_form'), 999); |
|
103 | + throw new EE_Error(__('An attempt to access and/or write to a file on the server could not be completed due to a lack of sufficient credentials.', 'event_espresso')); |
|
104 | + } elseif (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) { |
|
105 | + add_action('admin_notices', array('EEH_File', 'display_request_filesystem_credentials_form'), 999); |
|
106 | 106 | throw new EE_Error( |
107 | 107 | sprintf( |
108 | - __( 'WP Filesystem Error: $1%s', 'event_espresso' ), |
|
108 | + __('WP Filesystem Error: $1%s', 'event_espresso'), |
|
109 | 109 | $wp_filesystem->errors->get_error_message() ) ); |
110 | 110 | } |
111 | 111 | } |
@@ -118,8 +118,8 @@ discard block |
||
118 | 118 | * display_request_filesystem_credentials_form |
119 | 119 | */ |
120 | 120 | public static function display_request_filesystem_credentials_form() { |
121 | - if ( ! empty( EEH_File::$_credentials_form )) { |
|
122 | - echo '<div class="updated espresso-notices-attention"><p>' . EEH_File::$_credentials_form . '</p></div>'; |
|
121 | + if ( ! empty(EEH_File::$_credentials_form)) { |
|
122 | + echo '<div class="updated espresso-notices-attention"><p>'.EEH_File::$_credentials_form.'</p></div>'; |
|
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
@@ -137,29 +137,29 @@ discard block |
||
137 | 137 | * @throws EE_Error |
138 | 138 | * @return bool |
139 | 139 | */ |
140 | - public static function verify_filepath_and_permissions( $full_file_path = '', $file_name = '', $file_ext = '', $type_of_file = '' ) { |
|
140 | + public static function verify_filepath_and_permissions($full_file_path = '', $file_name = '', $file_ext = '', $type_of_file = '') { |
|
141 | 141 | // load WP_Filesystem and set file permissions |
142 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path ); |
|
143 | - $full_file_path = EEH_File::standardise_directory_separators( $full_file_path ); |
|
144 | - if ( ! $wp_filesystem->is_readable( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) )) { |
|
145 | - $file_name = ! empty( $type_of_file ) ? $file_name . ' ' . $type_of_file : $file_name; |
|
146 | - $file_name .= ! empty( $file_ext ) ? ' file' : ' folder'; |
|
142 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path); |
|
143 | + $full_file_path = EEH_File::standardise_directory_separators($full_file_path); |
|
144 | + if ( ! $wp_filesystem->is_readable(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path))) { |
|
145 | + $file_name = ! empty($type_of_file) ? $file_name.' '.$type_of_file : $file_name; |
|
146 | + $file_name .= ! empty($file_ext) ? ' file' : ' folder'; |
|
147 | 147 | $msg = sprintf( |
148 | - __( 'The requested %1$s could not be found or is not readable, possibly due to an incorrect filepath, or incorrect file permissions.%2$s', 'event_espresso' ), |
|
148 | + __('The requested %1$s could not be found or is not readable, possibly due to an incorrect filepath, or incorrect file permissions.%2$s', 'event_espresso'), |
|
149 | 149 | $file_name, |
150 | 150 | '<br />' |
151 | 151 | ); |
152 | - if ( EEH_File::exists( $full_file_path )) { |
|
153 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path, $type_of_file ); |
|
152 | + if (EEH_File::exists($full_file_path)) { |
|
153 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path, $type_of_file); |
|
154 | 154 | } else { |
155 | 155 | // no file permissions means the file was not found |
156 | 156 | $msg .= sprintf( |
157 | - __( 'Please ensure the following path is correct: "%s".', 'event_espresso' ), |
|
157 | + __('Please ensure the following path is correct: "%s".', 'event_espresso'), |
|
158 | 158 | $full_file_path |
159 | 159 | ); |
160 | 160 | } |
161 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
162 | - throw new EE_Error( $msg . '||' . $msg ); |
|
161 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
162 | + throw new EE_Error($msg.'||'.$msg); |
|
163 | 163 | } |
164 | 164 | return FALSE; |
165 | 165 | } |
@@ -176,24 +176,24 @@ discard block |
||
176 | 176 | * @param string $type_of_file - general type of file (ie: "module"), this is only used to improve error messages |
177 | 177 | * @return string |
178 | 178 | */ |
179 | - private static function _permissions_error_for_unreadable_filepath( $full_file_path = '', $type_of_file = '' ){ |
|
179 | + private static function _permissions_error_for_unreadable_filepath($full_file_path = '', $type_of_file = '') { |
|
180 | 180 | // load WP_Filesystem and set file permissions |
181 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path ); |
|
181 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path); |
|
182 | 182 | // check file permissions |
183 | - $perms = $wp_filesystem->getchmod( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) ); |
|
184 | - if ( $perms ) { |
|
183 | + $perms = $wp_filesystem->getchmod(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path)); |
|
184 | + if ($perms) { |
|
185 | 185 | // file permissions exist, but way be set incorrectly |
186 | - $type_of_file = ! empty( $type_of_file ) ? $type_of_file . ' ' : ''; |
|
187 | - $type_of_file .= ! empty( $type_of_file ) ? 'file' : 'folder'; |
|
186 | + $type_of_file = ! empty($type_of_file) ? $type_of_file.' ' : ''; |
|
187 | + $type_of_file .= ! empty($type_of_file) ? 'file' : 'folder'; |
|
188 | 188 | return sprintf( |
189 | - __( 'File permissions for the requested %1$s are currently set at "%2$s". The recommended permissions are 644 for files and 755 for folders.', 'event_espresso' ), |
|
189 | + __('File permissions for the requested %1$s are currently set at "%2$s". The recommended permissions are 644 for files and 755 for folders.', 'event_espresso'), |
|
190 | 190 | $type_of_file, |
191 | 191 | $perms |
192 | 192 | ); |
193 | 193 | } else { |
194 | 194 | // file exists but file permissions could not be read ?!?! |
195 | 195 | return sprintf( |
196 | - __( 'Please ensure that the server and/or PHP configuration allows the current process to access the following file: "%s".', 'event_espresso' ), |
|
196 | + __('Please ensure that the server and/or PHP configuration allows the current process to access the following file: "%s".', 'event_espresso'), |
|
197 | 197 | $full_file_path |
198 | 198 | ); |
199 | 199 | } |
@@ -211,35 +211,35 @@ discard block |
||
211 | 211 | * can't write to it |
212 | 212 | * @return bool false if folder isn't writable; true if it exists and is writeable, |
213 | 213 | */ |
214 | - public static function ensure_folder_exists_and_is_writable( $folder = '' ){ |
|
215 | - if ( empty( $folder )) { |
|
214 | + public static function ensure_folder_exists_and_is_writable($folder = '') { |
|
215 | + if (empty($folder)) { |
|
216 | 216 | return false; |
217 | 217 | } |
218 | 218 | // remove ending DS |
219 | - $folder = EEH_File::standardise_directory_separators( rtrim( $folder, '/\\' )); |
|
220 | - $parent_folder = EEH_File::get_parent_folder( $folder ); |
|
219 | + $folder = EEH_File::standardise_directory_separators(rtrim($folder, '/\\')); |
|
220 | + $parent_folder = EEH_File::get_parent_folder($folder); |
|
221 | 221 | // add DS to folder |
222 | - $folder = EEH_File::end_with_directory_separator( $folder ); |
|
223 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $folder ); |
|
224 | - if ( ! $wp_filesystem->is_dir( EEH_File::convert_local_filepath_to_remote_filepath( $folder ) ) ) { |
|
222 | + $folder = EEH_File::end_with_directory_separator($folder); |
|
223 | + $wp_filesystem = EEH_File::_get_wp_filesystem($folder); |
|
224 | + if ( ! $wp_filesystem->is_dir(EEH_File::convert_local_filepath_to_remote_filepath($folder))) { |
|
225 | 225 | //ok so it doesn't exist. Does its parent? Can we write to it? |
226 | - if( ! EEH_File::ensure_folder_exists_and_is_writable( $parent_folder ) ) { |
|
226 | + if ( ! EEH_File::ensure_folder_exists_and_is_writable($parent_folder)) { |
|
227 | 227 | return false; |
228 | 228 | } |
229 | - if ( ! EEH_File::verify_is_writable( $parent_folder, 'folder' )) { |
|
229 | + if ( ! EEH_File::verify_is_writable($parent_folder, 'folder')) { |
|
230 | 230 | return false; |
231 | 231 | } else { |
232 | - if ( ! $wp_filesystem->mkdir( EEH_File::convert_local_filepath_to_remote_filepath( $folder ) ) ) { |
|
233 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
234 | - $msg = sprintf( __( '"%s" could not be created.', 'event_espresso' ), $folder ); |
|
235 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $folder ); |
|
236 | - throw new EE_Error( $msg ); |
|
232 | + if ( ! $wp_filesystem->mkdir(EEH_File::convert_local_filepath_to_remote_filepath($folder))) { |
|
233 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
234 | + $msg = sprintf(__('"%s" could not be created.', 'event_espresso'), $folder); |
|
235 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($folder); |
|
236 | + throw new EE_Error($msg); |
|
237 | 237 | } |
238 | 238 | return false; |
239 | 239 | } |
240 | - EEH_File::add_index_file( $folder ); |
|
240 | + EEH_File::add_index_file($folder); |
|
241 | 241 | } |
242 | - } elseif ( ! EEH_File::verify_is_writable( $folder, 'folder' )) { |
|
242 | + } elseif ( ! EEH_File::verify_is_writable($folder, 'folder')) { |
|
243 | 243 | return false; |
244 | 244 | } |
245 | 245 | return true; |
@@ -254,15 +254,15 @@ discard block |
||
254 | 254 | * @throws EE_Error |
255 | 255 | * @return bool |
256 | 256 | */ |
257 | - public static function verify_is_writable( $full_path = '', $file_or_folder = 'folder' ){ |
|
257 | + public static function verify_is_writable($full_path = '', $file_or_folder = 'folder') { |
|
258 | 258 | // load WP_Filesystem and set file permissions |
259 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_path ); |
|
260 | - $full_path = EEH_File::standardise_directory_separators( $full_path ); |
|
261 | - if ( ! $wp_filesystem->is_writable( EEH_File::convert_local_filepath_to_remote_filepath( $full_path ) ) ) { |
|
262 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
263 | - $msg = sprintf( __( 'The "%1$s" %2$s is not writable.', 'event_espresso' ), $full_path, $file_or_folder ); |
|
264 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_path ); |
|
265 | - throw new EE_Error( $msg ); |
|
259 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_path); |
|
260 | + $full_path = EEH_File::standardise_directory_separators($full_path); |
|
261 | + if ( ! $wp_filesystem->is_writable(EEH_File::convert_local_filepath_to_remote_filepath($full_path))) { |
|
262 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
263 | + $msg = sprintf(__('The "%1$s" %2$s is not writable.', 'event_espresso'), $full_path, $file_or_folder); |
|
264 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_path); |
|
265 | + throw new EE_Error($msg); |
|
266 | 266 | } |
267 | 267 | return FALSE; |
268 | 268 | } |
@@ -279,25 +279,25 @@ discard block |
||
279 | 279 | * @throws EE_Error |
280 | 280 | * @return bool |
281 | 281 | */ |
282 | - public static function ensure_file_exists_and_is_writable( $full_file_path = '' ) { |
|
282 | + public static function ensure_file_exists_and_is_writable($full_file_path = '') { |
|
283 | 283 | // load WP_Filesystem and set file permissions |
284 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path ); |
|
285 | - $full_file_path = EEH_File::standardise_directory_separators( $full_file_path ); |
|
286 | - $parent_folder = EEH_File::get_parent_folder( $full_file_path ); |
|
287 | - if ( ! EEH_File::exists( $full_file_path )) { |
|
288 | - if( ! EEH_File::ensure_folder_exists_and_is_writable( $parent_folder ) ) { |
|
284 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path); |
|
285 | + $full_file_path = EEH_File::standardise_directory_separators($full_file_path); |
|
286 | + $parent_folder = EEH_File::get_parent_folder($full_file_path); |
|
287 | + if ( ! EEH_File::exists($full_file_path)) { |
|
288 | + if ( ! EEH_File::ensure_folder_exists_and_is_writable($parent_folder)) { |
|
289 | 289 | return false; |
290 | 290 | } |
291 | - if ( ! $wp_filesystem->touch( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) ) ) { |
|
292 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
293 | - $msg = sprintf( __( 'The "%s" file could not be created.', 'event_espresso' ), $full_file_path ); |
|
294 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path ); |
|
295 | - throw new EE_Error( $msg ); |
|
291 | + if ( ! $wp_filesystem->touch(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path))) { |
|
292 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
293 | + $msg = sprintf(__('The "%s" file could not be created.', 'event_espresso'), $full_file_path); |
|
294 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path); |
|
295 | + throw new EE_Error($msg); |
|
296 | 296 | } |
297 | 297 | return false; |
298 | 298 | } |
299 | 299 | } |
300 | - if ( ! EEH_File::verify_is_writable( $full_file_path, 'file' )) { |
|
300 | + if ( ! EEH_File::verify_is_writable($full_file_path, 'file')) { |
|
301 | 301 | return false; |
302 | 302 | } |
303 | 303 | return true; |
@@ -309,15 +309,15 @@ discard block |
||
309 | 309 | * @param string $file_or_folder_path |
310 | 310 | * @return string parent folder, ENDING with a directory separator |
311 | 311 | */ |
312 | - public static function get_parent_folder( $file_or_folder_path ) { |
|
312 | + public static function get_parent_folder($file_or_folder_path) { |
|
313 | 313 | //find the last DS, ignoring a DS on the very end |
314 | 314 | //eg if given "/var/something/somewhere/", we want to get "somewhere"'s |
315 | 315 | //parent folder, "/var/something/" |
316 | - $ds = strrpos( $file_or_folder_path, DS, -2 ); |
|
317 | - return substr( $file_or_folder_path, 0, $ds + 1 ); |
|
316 | + $ds = strrpos($file_or_folder_path, DS, -2); |
|
317 | + return substr($file_or_folder_path, 0, $ds + 1); |
|
318 | 318 | } |
319 | 319 | |
320 | - public static function ensure_folder_exists_recursively( $folder ) { |
|
320 | + public static function ensure_folder_exists_recursively($folder) { |
|
321 | 321 | |
322 | 322 | } |
323 | 323 | |
@@ -328,12 +328,12 @@ discard block |
||
328 | 328 | * @param string $full_file_path |
329 | 329 | * @return string |
330 | 330 | */ |
331 | - public static function get_file_contents( $full_file_path = '' ){ |
|
332 | - $full_file_path = EEH_File::standardise_directory_separators( $full_file_path ); |
|
333 | - if ( EEH_File::verify_filepath_and_permissions( $full_file_path, EEH_File::get_filename_from_filepath( $full_file_path ) , EEH_File::get_file_extension( $full_file_path ))) { |
|
331 | + public static function get_file_contents($full_file_path = '') { |
|
332 | + $full_file_path = EEH_File::standardise_directory_separators($full_file_path); |
|
333 | + if (EEH_File::verify_filepath_and_permissions($full_file_path, EEH_File::get_filename_from_filepath($full_file_path), EEH_File::get_file_extension($full_file_path))) { |
|
334 | 334 | // load WP_Filesystem and set file permissions |
335 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path ); |
|
336 | - return $wp_filesystem->get_contents(EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) ); |
|
335 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path); |
|
336 | + return $wp_filesystem->get_contents(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path)); |
|
337 | 337 | } |
338 | 338 | return ''; |
339 | 339 | } |
@@ -348,26 +348,26 @@ discard block |
||
348 | 348 | * @throws EE_Error |
349 | 349 | * @return bool |
350 | 350 | */ |
351 | - public static function write_to_file( $full_file_path = '', $file_contents = '', $file_type = '' ){ |
|
352 | - $full_file_path = EEH_File::standardise_directory_separators( $full_file_path ); |
|
353 | - $file_type = ! empty( $file_type ) ? rtrim( $file_type, ' ' ) . ' ' : ''; |
|
354 | - $folder = EEH_File::remove_filename_from_filepath( $full_file_path ); |
|
355 | - if ( ! EEH_File::verify_is_writable( $folder, 'folder' )) { |
|
356 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
357 | - $msg = sprintf( __( 'The %1$sfile located at "%2$s" is not writable.', 'event_espresso' ), $file_type, $full_file_path ); |
|
358 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path ); |
|
359 | - throw new EE_Error( $msg ); |
|
351 | + public static function write_to_file($full_file_path = '', $file_contents = '', $file_type = '') { |
|
352 | + $full_file_path = EEH_File::standardise_directory_separators($full_file_path); |
|
353 | + $file_type = ! empty($file_type) ? rtrim($file_type, ' ').' ' : ''; |
|
354 | + $folder = EEH_File::remove_filename_from_filepath($full_file_path); |
|
355 | + if ( ! EEH_File::verify_is_writable($folder, 'folder')) { |
|
356 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
357 | + $msg = sprintf(__('The %1$sfile located at "%2$s" is not writable.', 'event_espresso'), $file_type, $full_file_path); |
|
358 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path); |
|
359 | + throw new EE_Error($msg); |
|
360 | 360 | } |
361 | 361 | return FALSE; |
362 | 362 | } |
363 | 363 | // load WP_Filesystem and set file permissions |
364 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path ); |
|
364 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path); |
|
365 | 365 | // write the file |
366 | - if ( ! $wp_filesystem->put_contents(EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ), $file_contents )) { |
|
367 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
368 | - $msg = sprintf( __( 'The %1$sfile located at "%2$s" could not be written to.', 'event_espresso' ), $file_type, $full_file_path ); |
|
369 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path, 'f' ); |
|
370 | - throw new EE_Error( $msg ); |
|
366 | + if ( ! $wp_filesystem->put_contents(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path), $file_contents)) { |
|
367 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
368 | + $msg = sprintf(__('The %1$sfile located at "%2$s" could not be written to.', 'event_espresso'), $file_type, $full_file_path); |
|
369 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path, 'f'); |
|
370 | + throw new EE_Error($msg); |
|
371 | 371 | } |
372 | 372 | return FALSE; |
373 | 373 | } |
@@ -382,9 +382,9 @@ discard block |
||
382 | 382 | * @param boolean|string $type 'd' for directory, 'f' for file |
383 | 383 | * @return boolean |
384 | 384 | */ |
385 | - public static function delete( $filepath, $recursive = false, $type = false ) { |
|
385 | + public static function delete($filepath, $recursive = false, $type = false) { |
|
386 | 386 | $wp_filesystem = EEH_File::_get_wp_filesystem(); |
387 | - return $wp_filesystem->delete( $filepath, $recursive, $type ) ? TRUE : FALSE; |
|
387 | + return $wp_filesystem->delete($filepath, $recursive, $type) ? TRUE : FALSE; |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | |
@@ -396,9 +396,9 @@ discard block |
||
396 | 396 | * @param string $full_file_path |
397 | 397 | * @return bool |
398 | 398 | */ |
399 | - public static function exists( $full_file_path = '' ) { |
|
400 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path ); |
|
401 | - return $wp_filesystem->exists( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) ) ? TRUE : FALSE; |
|
399 | + public static function exists($full_file_path = '') { |
|
400 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path); |
|
401 | + return $wp_filesystem->exists(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path)) ? TRUE : FALSE; |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | |
@@ -410,9 +410,9 @@ discard block |
||
410 | 410 | * @param string $full_file_path |
411 | 411 | * @return bool |
412 | 412 | */ |
413 | - public static function is_readable( $full_file_path = '' ) { |
|
414 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path ); |
|
415 | - if( $wp_filesystem->is_readable( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) ) ) { |
|
413 | + public static function is_readable($full_file_path = '') { |
|
414 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path); |
|
415 | + if ($wp_filesystem->is_readable(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path))) { |
|
416 | 416 | return true; |
417 | 417 | } else { |
418 | 418 | return false; |
@@ -428,8 +428,8 @@ discard block |
||
428 | 428 | * @param string $full_file_path |
429 | 429 | * @return string |
430 | 430 | */ |
431 | - public static function remove_filename_from_filepath( $full_file_path = '' ) { |
|
432 | - return pathinfo( $full_file_path, PATHINFO_DIRNAME ); |
|
431 | + public static function remove_filename_from_filepath($full_file_path = '') { |
|
432 | + return pathinfo($full_file_path, PATHINFO_DIRNAME); |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | |
@@ -439,8 +439,8 @@ discard block |
||
439 | 439 | * @param string $full_file_path |
440 | 440 | * @return string |
441 | 441 | */ |
442 | - public static function get_filename_from_filepath( $full_file_path = '' ) { |
|
443 | - return pathinfo( $full_file_path, PATHINFO_BASENAME ); |
|
442 | + public static function get_filename_from_filepath($full_file_path = '') { |
|
443 | + return pathinfo($full_file_path, PATHINFO_BASENAME); |
|
444 | 444 | } |
445 | 445 | |
446 | 446 | |
@@ -450,8 +450,8 @@ discard block |
||
450 | 450 | * @param string $full_file_path |
451 | 451 | * @return string |
452 | 452 | */ |
453 | - public static function get_file_extension( $full_file_path = '' ) { |
|
454 | - return pathinfo( $full_file_path, PATHINFO_EXTENSION ); |
|
453 | + public static function get_file_extension($full_file_path = '') { |
|
454 | + return pathinfo($full_file_path, PATHINFO_EXTENSION); |
|
455 | 455 | } |
456 | 456 | |
457 | 457 | |
@@ -461,10 +461,10 @@ discard block |
||
461 | 461 | * @param string $folder |
462 | 462 | * @return bool |
463 | 463 | */ |
464 | - public static function add_htaccess_deny_from_all( $folder = '' ) { |
|
465 | - $folder = EEH_File::standardise_and_end_with_directory_separator( $folder ); |
|
466 | - if ( ! EEH_File::exists( $folder . '.htaccess' ) ) { |
|
467 | - if ( ! EEH_File::write_to_file( $folder . '.htaccess', 'deny from all', '.htaccess' )) { |
|
464 | + public static function add_htaccess_deny_from_all($folder = '') { |
|
465 | + $folder = EEH_File::standardise_and_end_with_directory_separator($folder); |
|
466 | + if ( ! EEH_File::exists($folder.'.htaccess')) { |
|
467 | + if ( ! EEH_File::write_to_file($folder.'.htaccess', 'deny from all', '.htaccess')) { |
|
468 | 468 | return FALSE; |
469 | 469 | } |
470 | 470 | } |
@@ -477,10 +477,10 @@ discard block |
||
477 | 477 | * @param string $folder |
478 | 478 | * @return boolean |
479 | 479 | */ |
480 | - public static function add_index_file( $folder ) { |
|
481 | - $folder = EEH_File::standardise_and_end_with_directory_separator( $folder ); |
|
482 | - if ( ! EEH_File::exists( $folder . 'index.php' ) ) { |
|
483 | - if ( ! EEH_File::write_to_file( $folder . 'index.php', 'You are not permitted to read from this folder', '.php' )) { |
|
480 | + public static function add_index_file($folder) { |
|
481 | + $folder = EEH_File::standardise_and_end_with_directory_separator($folder); |
|
482 | + if ( ! EEH_File::exists($folder.'index.php')) { |
|
483 | + if ( ! EEH_File::write_to_file($folder.'index.php', 'You are not permitted to read from this folder', '.php')) { |
|
484 | 484 | return false; |
485 | 485 | } |
486 | 486 | } |
@@ -495,11 +495,11 @@ discard block |
||
495 | 495 | * @param string $file_path |
496 | 496 | * @return string |
497 | 497 | */ |
498 | - public static function get_classname_from_filepath_with_standard_filename( $file_path ){ |
|
498 | + public static function get_classname_from_filepath_with_standard_filename($file_path) { |
|
499 | 499 | //extract file from path |
500 | - $filename = basename( $file_path ); |
|
500 | + $filename = basename($file_path); |
|
501 | 501 | //now remove the first period and everything after |
502 | - $pos_of_first_period = strpos( $filename,'.' ); |
|
502 | + $pos_of_first_period = strpos($filename, '.'); |
|
503 | 503 | return substr($filename, 0, $pos_of_first_period); |
504 | 504 | } |
505 | 505 | |
@@ -511,8 +511,8 @@ discard block |
||
511 | 511 | * @param string $file_path |
512 | 512 | * @return string |
513 | 513 | */ |
514 | - public static function standardise_directory_separators( $file_path ){ |
|
515 | - return str_replace( array( '\\', '/' ), DS, $file_path ); |
|
514 | + public static function standardise_directory_separators($file_path) { |
|
515 | + return str_replace(array('\\', '/'), DS, $file_path); |
|
516 | 516 | } |
517 | 517 | |
518 | 518 | |
@@ -523,8 +523,8 @@ discard block |
||
523 | 523 | * @param string $file_path |
524 | 524 | * @return string |
525 | 525 | */ |
526 | - public static function end_with_directory_separator( $file_path ){ |
|
527 | - return rtrim( $file_path, '/\\' ) . DS; |
|
526 | + public static function end_with_directory_separator($file_path) { |
|
527 | + return rtrim($file_path, '/\\').DS; |
|
528 | 528 | } |
529 | 529 | |
530 | 530 | |
@@ -534,8 +534,8 @@ discard block |
||
534 | 534 | * @param $file_path |
535 | 535 | * @return string |
536 | 536 | */ |
537 | - public static function standardise_and_end_with_directory_separator( $file_path ){ |
|
538 | - return self::end_with_directory_separator( self::standardise_directory_separators( $file_path )); |
|
537 | + public static function standardise_and_end_with_directory_separator($file_path) { |
|
538 | + return self::end_with_directory_separator(self::standardise_directory_separators($file_path)); |
|
539 | 539 | } |
540 | 540 | |
541 | 541 | |
@@ -552,21 +552,21 @@ discard block |
||
552 | 552 | * if $index_numerically == FALSE (Default) keys are what the class names SHOULD be; |
553 | 553 | * and values are their filepaths |
554 | 554 | */ |
555 | - public static function get_contents_of_folders( $folder_paths = array(), $index_numerically = FALSE ){ |
|
555 | + public static function get_contents_of_folders($folder_paths = array(), $index_numerically = FALSE) { |
|
556 | 556 | $class_to_folder_path = array(); |
557 | - foreach( $folder_paths as $folder_path ){ |
|
558 | - $folder_path = self::standardise_and_end_with_directory_separator( $folder_path ); |
|
557 | + foreach ($folder_paths as $folder_path) { |
|
558 | + $folder_path = self::standardise_and_end_with_directory_separator($folder_path); |
|
559 | 559 | // load WP_Filesystem and set file permissions |
560 | - $files_in_folder = glob( $folder_path . '*' ); |
|
560 | + $files_in_folder = glob($folder_path.'*'); |
|
561 | 561 | $class_to_folder_path = array(); |
562 | - if ( $files_in_folder ) { |
|
563 | - foreach( $files_in_folder as $file_path ){ |
|
562 | + if ($files_in_folder) { |
|
563 | + foreach ($files_in_folder as $file_path) { |
|
564 | 564 | //only add files, not folders |
565 | - if ( ! is_dir( $file_path )) { |
|
566 | - if ( $index_numerically ) { |
|
565 | + if ( ! is_dir($file_path)) { |
|
566 | + if ($index_numerically) { |
|
567 | 567 | $class_to_folder_path[] = $file_path; |
568 | 568 | } else { |
569 | - $classname = self::get_classname_from_filepath_with_standard_filename( $file_path ); |
|
569 | + $classname = self::get_classname_from_filepath_with_standard_filename($file_path); |
|
570 | 570 | $class_to_folder_path[$classname] = $file_path; |
571 | 571 | } |
572 | 572 | } |
@@ -586,39 +586,39 @@ discard block |
||
586 | 586 | * @return boolean success |
587 | 587 | * @throws EE_Error |
588 | 588 | */ |
589 | - public static function copy( $source_file, $destination_file, $overwrite = FALSE ){ |
|
590 | - $full_source_path = EEH_File::standardise_directory_separators( $source_file ); |
|
591 | - if( ! EEH_File::exists( $full_source_path ) ){ |
|
592 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
593 | - $msg = sprintf( __( 'The file located at "%2$s" is not readable or doesn\'t exist.', 'event_espresso' ), $full_source_path ); |
|
594 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_source_path ); |
|
595 | - throw new EE_Error( $msg ); |
|
589 | + public static function copy($source_file, $destination_file, $overwrite = FALSE) { |
|
590 | + $full_source_path = EEH_File::standardise_directory_separators($source_file); |
|
591 | + if ( ! EEH_File::exists($full_source_path)) { |
|
592 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
593 | + $msg = sprintf(__('The file located at "%2$s" is not readable or doesn\'t exist.', 'event_espresso'), $full_source_path); |
|
594 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_source_path); |
|
595 | + throw new EE_Error($msg); |
|
596 | 596 | } |
597 | 597 | return FALSE; |
598 | 598 | } |
599 | 599 | |
600 | - $full_dest_path = EEH_File::standardise_directory_separators( $destination_file ); |
|
601 | - $folder = EEH_File::remove_filename_from_filepath( $full_dest_path ); |
|
602 | - if ( ! EEH_File::verify_is_writable( $folder, 'folder' )) { |
|
603 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
604 | - $msg = sprintf( __( 'The file located at "%2$s" is not writable.', 'event_espresso' ), $full_dest_path ); |
|
605 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_dest_path ); |
|
606 | - throw new EE_Error( $msg ); |
|
600 | + $full_dest_path = EEH_File::standardise_directory_separators($destination_file); |
|
601 | + $folder = EEH_File::remove_filename_from_filepath($full_dest_path); |
|
602 | + if ( ! EEH_File::verify_is_writable($folder, 'folder')) { |
|
603 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
604 | + $msg = sprintf(__('The file located at "%2$s" is not writable.', 'event_espresso'), $full_dest_path); |
|
605 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_dest_path); |
|
606 | + throw new EE_Error($msg); |
|
607 | 607 | } |
608 | 608 | return FALSE; |
609 | 609 | } |
610 | 610 | |
611 | 611 | // load WP_Filesystem and set file permissions |
612 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $destination_file ); |
|
612 | + $wp_filesystem = EEH_File::_get_wp_filesystem($destination_file); |
|
613 | 613 | // write the file |
614 | 614 | if ( ! $wp_filesystem->copy( |
615 | - EEH_File::convert_local_filepath_to_remote_filepath( $full_source_path ), |
|
616 | - EEH_File::convert_local_filepath_to_remote_filepath( $full_dest_path ), |
|
615 | + EEH_File::convert_local_filepath_to_remote_filepath($full_source_path), |
|
616 | + EEH_File::convert_local_filepath_to_remote_filepath($full_dest_path), |
|
617 | 617 | $overwrite )) { |
618 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
619 | - $msg = sprintf( __( 'Attempted writing to file %1$s, but could not, probably because of permissions issues', 'event_espresso' ), $full_source_path ); |
|
620 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_source_path, 'f' ); |
|
621 | - throw new EE_Error( $msg ); |
|
618 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
619 | + $msg = sprintf(__('Attempted writing to file %1$s, but could not, probably because of permissions issues', 'event_espresso'), $full_source_path); |
|
620 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_source_path, 'f'); |
|
621 | + throw new EE_Error($msg); |
|
622 | 622 | } |
623 | 623 | return FALSE; |
624 | 624 | } |
@@ -630,9 +630,9 @@ discard block |
||
630 | 630 | * @param string $filepath |
631 | 631 | * @return boolean |
632 | 632 | */ |
633 | - public static function is_in_uploads_folder( $filepath ) { |
|
633 | + public static function is_in_uploads_folder($filepath) { |
|
634 | 634 | $uploads = wp_upload_dir(); |
635 | - return strpos( $filepath, $uploads[ 'basedir' ] ) === 0 ? true : false; |
|
635 | + return strpos($filepath, $uploads['basedir']) === 0 ? true : false; |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | /** |
@@ -646,9 +646,9 @@ discard block |
||
646 | 646 | * @return string the remote filepath (eg the filepath the filesystem method, eg |
647 | 647 | * ftp or ssh, will use to access the folder |
648 | 648 | */ |
649 | - public static function convert_local_filepath_to_remote_filepath( $local_filepath ) { |
|
650 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $local_filepath ); |
|
651 | - return str_replace( WP_CONTENT_DIR . DS, $wp_filesystem->wp_content_dir(), $local_filepath ); |
|
649 | + public static function convert_local_filepath_to_remote_filepath($local_filepath) { |
|
650 | + $wp_filesystem = EEH_File::_get_wp_filesystem($local_filepath); |
|
651 | + return str_replace(WP_CONTENT_DIR.DS, $wp_filesystem->wp_content_dir(), $local_filepath); |
|
652 | 652 | } |
653 | 653 | } |
654 | 654 | // End of file EEH_File.helper.php |
@@ -21,26 +21,26 @@ |
||
21 | 21 | * @since $VID:$ |
22 | 22 | * |
23 | 23 | */ |
24 | -if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
24 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
25 | 25 | exit('No direct script access allowed'); |
26 | 26 | } |
27 | 27 | |
28 | -class EEM_Extra_Join extends EEM_Base{ |
|
28 | +class EEM_Extra_Join extends EEM_Base { |
|
29 | 29 | // private instance of the Extra Join object |
30 | 30 | protected static $_instance = NULL; |
31 | 31 | |
32 | 32 | public function __construct($timezone = NULL) { |
33 | - $models_this_can_join = array_keys( EE_Registry::instance()->non_abstract_db_models ); |
|
33 | + $models_this_can_join = array_keys(EE_Registry::instance()->non_abstract_db_models); |
|
34 | 34 | $this->_tables = array( |
35 | - 'Extra_Join' => new EE_Primary_Table( 'esp_extra_join', 'EXJ_ID' ), |
|
35 | + 'Extra_Join' => new EE_Primary_Table('esp_extra_join', 'EXJ_ID'), |
|
36 | 36 | ); |
37 | 37 | $this->_fields = array( |
38 | 38 | 'Extra_Join' => array( |
39 | - 'EXJ_ID' => new EE_Primary_Key_Int_Field( 'EXJ_ID', __( 'Extra Join ID', 'event_espresso' ) ), |
|
40 | - 'EXJ_first_model_ID' => new EE_Foreign_Key_String_Field( 'EXJ_first_model_ID', __( 'First Model ID', 'event_espresso' ), true, 0, $models_this_can_join ), |
|
41 | - 'EXJ_first_model_name' => new EE_Any_Foreign_Model_Name_Field( 'EXJ_first_model_name', __( 'First Model Name', 'event_espresso'), true, '', $models_this_can_join ), |
|
42 | - 'EXJ_second_model_ID' => new EE_Foreign_Key_String_Field( 'EXJ_second_model_ID', __( 'Second Model ID', 'event_espresso' ), true, 0, $models_this_can_join ), |
|
43 | - 'EXJ_second_model_name' => new EE_Any_Foreign_Model_Name_Field( 'EXJ_second_model_name', __( 'Second Model Name', 'event_espresso'), true, '', $models_this_can_join ), |
|
39 | + 'EXJ_ID' => new EE_Primary_Key_Int_Field('EXJ_ID', __('Extra Join ID', 'event_espresso')), |
|
40 | + 'EXJ_first_model_ID' => new EE_Foreign_Key_String_Field('EXJ_first_model_ID', __('First Model ID', 'event_espresso'), true, 0, $models_this_can_join), |
|
41 | + 'EXJ_first_model_name' => new EE_Any_Foreign_Model_Name_Field('EXJ_first_model_name', __('First Model Name', 'event_espresso'), true, '', $models_this_can_join), |
|
42 | + 'EXJ_second_model_ID' => new EE_Foreign_Key_String_Field('EXJ_second_model_ID', __('Second Model ID', 'event_espresso'), true, 0, $models_this_can_join), |
|
43 | + 'EXJ_second_model_name' => new EE_Any_Foreign_Model_Name_Field('EXJ_second_model_name', __('Second Model Name', 'event_espresso'), true, '', $models_this_can_join), |
|
44 | 44 | |
45 | 45 | ) |
46 | 46 | ); |