@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | use EventEspresso\core\services\database\TableAnalysis; |
| 3 | -if (!defined('EVENT_ESPRESSO_VERSION') ){ |
|
| 3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 4 | 4 | exit('NO direct script access allowed'); |
| 5 | 5 | } |
| 6 | 6 | /** |
@@ -27,18 +27,18 @@ discard block |
||
| 27 | 27 | */ |
| 28 | 28 | public function __construct() { |
| 29 | 29 | //define some page related constants |
| 30 | - define( 'EE_PAYMENTS_PG_SLUG', 'espresso_payment_settings' ); |
|
| 31 | - define( 'EE_PAYMENTS_ADMIN_URL', admin_url( 'admin.php?page=' . EE_PAYMENTS_PG_SLUG )); |
|
| 32 | - define( 'EE_PAYMENTS_ADMIN', EE_ADMIN_PAGES . 'payments' . DS ); |
|
| 33 | - define( 'EE_PAYMENTS_TEMPLATE_PATH', EE_PAYMENTS_ADMIN . 'templates' . DS ); |
|
| 34 | - define( 'EE_PAYMENTS_ASSETS_URL', EE_ADMIN_PAGES_URL . 'payments/assets/' ); |
|
| 35 | - $this->_table_analysis = EE_Registry::instance()->create( 'TableAnalysis', array(), true ); |
|
| 30 | + define('EE_PAYMENTS_PG_SLUG', 'espresso_payment_settings'); |
|
| 31 | + define('EE_PAYMENTS_ADMIN_URL', admin_url('admin.php?page='.EE_PAYMENTS_PG_SLUG)); |
|
| 32 | + define('EE_PAYMENTS_ADMIN', EE_ADMIN_PAGES.'payments'.DS); |
|
| 33 | + define('EE_PAYMENTS_TEMPLATE_PATH', EE_PAYMENTS_ADMIN.'templates'.DS); |
|
| 34 | + define('EE_PAYMENTS_ASSETS_URL', EE_ADMIN_PAGES_URL.'payments/assets/'); |
|
| 35 | + $this->_table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
| 36 | 36 | //check that there are active gateways on all admin page loads. but dont do it just yet |
| 37 | 37 | // echo "constructing payments admin page";die; |
| 38 | - add_action('admin_notices',array($this,'check_payment_gateway_setup')); |
|
| 38 | + add_action('admin_notices', array($this, 'check_payment_gateway_setup')); |
|
| 39 | 39 | |
| 40 | 40 | // Show/hide PP Standard along side PP Express. |
| 41 | - add_filter( 'FHEE__Payments_Admin_Page___payment_methods_list__payment_methods', array( $this, 'unset_pp_standard' ) ); |
|
| 41 | + add_filter('FHEE__Payments_Admin_Page___payment_methods_list__payment_methods', array($this, 'unset_pp_standard')); |
|
| 42 | 42 | |
| 43 | 43 | parent::__construct(); |
| 44 | 44 | } |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | 'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY, |
| 63 | 63 | 'parent_slug' => 'espresso_events', |
| 64 | 64 | 'menu_slug' => EE_PAYMENTS_PG_SLUG, |
| 65 | - 'menu_label' => __( 'Payment Methods', 'event_espresso' ), |
|
| 65 | + 'menu_label' => __('Payment Methods', 'event_espresso'), |
|
| 66 | 66 | 'capability' => 'ee_manage_gateways', |
| 67 | 67 | 'admin_init_page' => $this, |
| 68 | 68 | ) |
@@ -76,25 +76,25 @@ discard block |
||
| 76 | 76 | * |
| 77 | 77 | * @throws \EE_Error |
| 78 | 78 | */ |
| 79 | - public function check_payment_gateway_setup(){ |
|
| 79 | + public function check_payment_gateway_setup() { |
|
| 80 | 80 | //ONLY do this check if models can query |
| 81 | 81 | //and avoid a bug where when we nuke EE4's data that this causes a fatal error |
| 82 | 82 | //because the tables are deleted just before this request runs. see https://events.codebasehq.com/projects/event-espresso/tickets/7539 |
| 83 | 83 | if ( |
| 84 | 84 | ! EE_Maintenance_Mode::instance()->models_can_query() |
| 85 | - || ! $this->_get_table_analysis()->tableExists( EEM_Payment_Method::instance()->table() ) |
|
| 85 | + || ! $this->_get_table_analysis()->tableExists(EEM_Payment_Method::instance()->table()) |
|
| 86 | 86 | ) { |
| 87 | 87 | return; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | |
| 91 | 91 | // ensure Payment_Method model is loaded |
| 92 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
| 93 | - $actives = EEM_Payment_Method::instance()->count_active( EEM_Payment_Method::scope_cart ); |
|
| 94 | - if( $actives < 1 ){ |
|
| 92 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
| 93 | + $actives = EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart); |
|
| 94 | + if ($actives < 1) { |
|
| 95 | 95 | $url = EE_Admin_Page::add_query_args_and_nonce(array(), EE_PAYMENTS_ADMIN_URL); |
| 96 | 96 | echo '<div class="error"> |
| 97 | - <p>'. sprintf(__("There are no Active Payment Methods setup for Event Espresso. Please %s activate at least one.%s", "event_espresso"),"<a href='$url'>","</a>").'</p> |
|
| 97 | + <p>'. sprintf(__("There are no Active Payment Methods setup for Event Espresso. Please %s activate at least one.%s", "event_espresso"), "<a href='$url'>", "</a>").'</p> |
|
| 98 | 98 | </div>'; |
| 99 | 99 | } |
| 100 | 100 | } |
@@ -105,13 +105,13 @@ discard block |
||
| 105 | 105 | * @throws \EE_Error |
| 106 | 106 | */ |
| 107 | 107 | protected function _get_table_analysis() { |
| 108 | - if( $this->_table_analysis instanceof TableAnalysis ) { |
|
| 108 | + if ($this->_table_analysis instanceof TableAnalysis) { |
|
| 109 | 109 | return $this->_table_analysis; |
| 110 | 110 | } else { |
| 111 | 111 | throw new \EE_Error( |
| 112 | 112 | sprintf( |
| 113 | - __( 'Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
| 114 | - get_class( $this ) |
|
| 113 | + __('Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
| 114 | + get_class($this) |
|
| 115 | 115 | ) |
| 116 | 116 | ); |
| 117 | 117 | } |
@@ -122,20 +122,20 @@ discard block |
||
| 122 | 122 | /** |
| 123 | 123 | * Hide PayPal Standard for "new" users. |
| 124 | 124 | */ |
| 125 | - public static function unset_pp_standard( $payment_method_types ) { |
|
| 126 | - $pps = EEM_Payment_Method::instance()->get_one_of_type( 'Paypal_Standard' ); |
|
| 127 | - $ppstandard_active = ( ! empty($pps) ) ? $pps->active() : false; |
|
| 125 | + public static function unset_pp_standard($payment_method_types) { |
|
| 126 | + $pps = EEM_Payment_Method::instance()->get_one_of_type('Paypal_Standard'); |
|
| 127 | + $ppstandard_active = ( ! empty($pps)) ? $pps->active() : false; |
|
| 128 | 128 | $ppstandard_active_before = false; |
| 129 | - if ( $pps ) { |
|
| 129 | + if ($pps) { |
|
| 130 | 130 | // PP Standard used before ? |
| 131 | - $paypal_id = $pps->get_extra_meta( 'paypal_id', TRUE ); |
|
| 132 | - if ( $paypal_id && ! empty($paypal_id) ) { |
|
| 131 | + $paypal_id = $pps->get_extra_meta('paypal_id', TRUE); |
|
| 132 | + if ($paypal_id && ! empty($paypal_id)) { |
|
| 133 | 133 | $ppstandard_active_before = true; |
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | // Not using PP Standard? Then display only PayPal Express, do not show PayPal Standard. |
| 138 | - if ( apply_filters( 'FHEE__EE_PMT_Paypal_Express__register_payment_methods__hide_paypal_standard', ! $ppstandard_active && ! $ppstandard_active_before ) ) { |
|
| 138 | + if (apply_filters('FHEE__EE_PMT_Paypal_Express__register_payment_methods__hide_paypal_standard', ! $ppstandard_active && ! $ppstandard_active_before)) { |
|
| 139 | 139 | unset($payment_method_types['paypal_standard']); |
| 140 | 140 | } |
| 141 | 141 | return $payment_method_types; |