@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | * @access public |
51 | 51 | * @param \WP $WP |
52 | 52 | */ |
53 | - public function run( WP $WP ) { |
|
54 | - add_filter( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true' ); |
|
53 | + public function run(WP $WP) { |
|
54 | + add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | |
@@ -62,14 +62,14 @@ discard block |
||
62 | 62 | * @param array $attributes |
63 | 63 | * @return string |
64 | 64 | */ |
65 | - public function process_shortcode( $attributes = array() ) { |
|
66 | - extract( $attributes ); |
|
67 | - $event_id = isset( $event_id ) ? $event_id : 0; |
|
68 | - $event = EE_Registry::instance()->load_model( 'Event' )->get_one_by_ID( $event_id ); |
|
65 | + public function process_shortcode($attributes = array()) { |
|
66 | + extract($attributes); |
|
67 | + $event_id = isset($event_id) ? $event_id : 0; |
|
68 | + $event = EE_Registry::instance()->load_model('Event')->get_one_by_ID($event_id); |
|
69 | 69 | ob_start(); |
70 | - do_action( 'AHEE_event_details_before_post', $event_id ); |
|
71 | - espresso_ticket_selector( $event ); |
|
72 | - do_action( 'AHEE_event_details_after_post' ); |
|
70 | + do_action('AHEE_event_details_before_post', $event_id); |
|
71 | + espresso_ticket_selector($event); |
|
72 | + do_action('AHEE_event_details_after_post'); |
|
73 | 73 | return ob_get_clean(); |
74 | 74 | } |
75 | 75 |
@@ -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; |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('No direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * |
26 | 26 | * ------------------------------------------------------------------------ |
27 | 27 | */ |
28 | -class EEG_Paypal_Pro extends EE_Onsite_Gateway{ |
|
28 | +class EEG_Paypal_Pro extends EE_Onsite_Gateway { |
|
29 | 29 | /** |
30 | 30 | * |
31 | 31 | * @var $_paypal_api_username string |
@@ -88,30 +88,30 @@ discard block |
||
88 | 88 | * } @see parent::do_direct_payment for more info |
89 | 89 | * @return \EE_Payment|\EEI_Payment |
90 | 90 | */ |
91 | - public function do_direct_payment($payment,$billing_info = null){ |
|
91 | + public function do_direct_payment($payment, $billing_info = null) { |
|
92 | 92 | $transaction = $payment->transaction(); |
93 | 93 | $primary_registrant = $transaction->primary_registration(); |
94 | - $order_description = $this->_format_order_description( $payment ); |
|
94 | + $order_description = $this->_format_order_description($payment); |
|
95 | 95 | //charge for the full amount. Show itemized list |
96 | - if( $this->_can_easily_itemize_transaction_for( $payment ) ){ |
|
96 | + if ($this->_can_easily_itemize_transaction_for($payment)) { |
|
97 | 97 | $item_num = 1; |
98 | 98 | $total_line_item = $transaction->total_line_item(); |
99 | 99 | $order_items = array(); |
100 | 100 | foreach ($total_line_item->get_items() as $line_item) { |
101 | 101 | //ignore line items with a quantity of 0 |
102 | - if( $line_item->quantity() == 0 ) { |
|
102 | + if ($line_item->quantity() == 0) { |
|
103 | 103 | continue; |
104 | 104 | } |
105 | 105 | $item = array( |
106 | 106 | // Item Name. 127 char max. |
107 | 107 | 'l_name' => substr( |
108 | - $this->_format_line_item_name( $line_item, $payment ), |
|
108 | + $this->_format_line_item_name($line_item, $payment), |
|
109 | 109 | 0, |
110 | 110 | 127 |
111 | 111 | ), |
112 | 112 | // Item description. 127 char max. |
113 | 113 | 'l_desc' => substr( |
114 | - $this->_format_line_item_desc( $line_item, $payment ), |
|
114 | + $this->_format_line_item_desc($line_item, $payment), |
|
115 | 115 | 0, |
116 | 116 | 127 |
117 | 117 | ), |
@@ -135,20 +135,20 @@ discard block |
||
135 | 135 | } |
136 | 136 | $item_amount = $total_line_item->get_items_total(); |
137 | 137 | $tax_amount = $total_line_item->get_total_tax(); |
138 | - }else{ |
|
138 | + } else { |
|
139 | 139 | $order_items = array(); |
140 | 140 | $item_amount = $payment->amount(); |
141 | 141 | $tax_amount = 0; |
142 | - array_push($order_items,array( |
|
142 | + array_push($order_items, array( |
|
143 | 143 | // Item Name. 127 char max. |
144 | 144 | 'l_name' => substr( |
145 | - $this->_format_partial_payment_line_item_name( $payment ), |
|
145 | + $this->_format_partial_payment_line_item_name($payment), |
|
146 | 146 | 0, |
147 | 147 | 127 |
148 | 148 | ), |
149 | 149 | // Item description. 127 char max. |
150 | 150 | 'l_desc' => substr( |
151 | - $this->_format_partial_payment_line_item_desc( $payment ), |
|
151 | + $this->_format_partial_payment_line_item_desc($payment), |
|
152 | 152 | 0, |
153 | 153 | 127 |
154 | 154 | ), |
@@ -196,11 +196,11 @@ discard block |
||
196 | 196 | // Payer's salutation. 20 char max. |
197 | 197 | 'salutation' => '', |
198 | 198 | // Payer's first name. 25 char max. |
199 | - 'firstname' => substr($billing_info['first_name'],0,25), |
|
199 | + 'firstname' => substr($billing_info['first_name'], 0, 25), |
|
200 | 200 | // Payer's middle name. 25 char max. |
201 | 201 | 'middlename' => '', |
202 | 202 | // Payer's last name. 25 char max. |
203 | - 'lastname' => substr($billing_info['last_name'],0,25), |
|
203 | + 'lastname' => substr($billing_info['last_name'], 0, 25), |
|
204 | 204 | // Payer's suffix. 12 char max. |
205 | 205 | 'suffix' => '' |
206 | 206 | ); |
@@ -213,13 +213,13 @@ discard block |
||
213 | 213 | // Required. Name of City. |
214 | 214 | 'city' => $billing_info['city'], |
215 | 215 | // Required. Name of State or Province. |
216 | - 'state' => substr( $billing_info['state'], 0, 40 ), |
|
216 | + 'state' => substr($billing_info['state'], 0, 40), |
|
217 | 217 | // Required. Country code. |
218 | 218 | 'countrycode' => $billing_info['country'], |
219 | 219 | // Required. Postal code of payer. |
220 | 220 | 'zip' => $billing_info['zip'], |
221 | 221 | // Phone Number of payer. 20 char max. |
222 | - 'shiptophonenum' => substr($billing_info['phone'],0,20) |
|
222 | + 'shiptophonenum' => substr($billing_info['phone'], 0, 20) |
|
223 | 223 | ); |
224 | 224 | |
225 | 225 | |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | // Required. Three-letter currency code. Default is USD. |
230 | 230 | 'currencycode' => $payment->currency_code(), |
231 | 231 | // Required if you include itemized cart details. (L_AMTn, etc.) Subtotal of items not including S&H, or tax. |
232 | - 'itemamt' => $this->format_currency($item_amount),// |
|
232 | + 'itemamt' => $this->format_currency($item_amount), // |
|
233 | 233 | // Total shipping costs for the order. If you specify shippingamt, you must also specify itemamt. |
234 | 234 | 'shippingamt' => '', |
235 | 235 | // Total handling costs for the order. If you specify handlingamt, you must also specify itemamt. |
@@ -241,10 +241,10 @@ discard block |
||
241 | 241 | // Free-form field for your own use. 256 char max. |
242 | 242 | 'custom' => $primary_registrant ? $primary_registrant->ID() : '', |
243 | 243 | // Your own invoice or tracking number |
244 | - 'invnum' => wp_generate_password(12,false),//$transaction->ID(), |
|
244 | + 'invnum' => wp_generate_password(12, false), //$transaction->ID(), |
|
245 | 245 | // URL for receiving Instant Payment Notifications. This overrides what your profile is set to use. |
246 | 246 | 'notifyurl' => '', |
247 | - 'buttonsource' => 'EventEspresso_SP',//EE will blow up if you change this |
|
247 | + 'buttonsource' => 'EventEspresso_SP', //EE will blow up if you change this |
|
248 | 248 | ); |
249 | 249 | // Wrap all data arrays into a single, "master" array which will be passed into the class function. |
250 | 250 | $PayPalRequestData = array( |
@@ -257,32 +257,32 @@ discard block |
||
257 | 257 | 'OrderItems' => $order_items, |
258 | 258 | ); |
259 | 259 | $this->_log_clean_request($PayPalRequestData, $payment); |
260 | - try{ |
|
260 | + try { |
|
261 | 261 | $PayPalResult = $this->prep_and_curl_request($PayPalRequestData); |
262 | 262 | //remove PCI-sensitive data so it doesn't get stored |
263 | - $PayPalResult = $this->_log_clean_response($PayPalResult,$payment); |
|
263 | + $PayPalResult = $this->_log_clean_response($PayPalResult, $payment); |
|
264 | 264 | |
265 | 265 | $message = isset($PayPalResult['L_LONGMESSAGE0']) ? $PayPalResult['L_LONGMESSAGE0'] : $PayPalResult['ACK']; |
266 | - if( empty($PayPalResult[ 'RAWRESPONSE' ] ) ) { |
|
267 | - $payment->set_status( $this->_pay_model->failed_status() ) ; |
|
268 | - $payment->set_gateway_response( __( 'No response received from Paypal Pro', 'event_espresso' ) ); |
|
266 | + if (empty($PayPalResult['RAWRESPONSE'])) { |
|
267 | + $payment->set_status($this->_pay_model->failed_status()); |
|
268 | + $payment->set_gateway_response(__('No response received from Paypal Pro', 'event_espresso')); |
|
269 | 269 | $payment->set_details($PayPalResult); |
270 | - }else{ |
|
271 | - if($this->_APICallSuccessful($PayPalResult)){ |
|
270 | + } else { |
|
271 | + if ($this->_APICallSuccessful($PayPalResult)) { |
|
272 | 272 | $payment->set_status($this->_pay_model->approved_status()); |
273 | - }else{ |
|
273 | + } else { |
|
274 | 274 | $payment->set_status($this->_pay_model->declined_status()); |
275 | 275 | } |
276 | 276 | //make sure we interpret the AMT as a float, not an international string (where periods are thousand separators) |
277 | - $payment->set_amount(isset($PayPalResult['AMT']) ? floatval( $PayPalResult['AMT'] ) : 0); |
|
277 | + $payment->set_amount(isset($PayPalResult['AMT']) ? floatval($PayPalResult['AMT']) : 0); |
|
278 | 278 | $payment->set_gateway_response($message); |
279 | - $payment->set_txn_id_chq_nmbr(isset( $PayPalResult['TRANSACTIONID'] )? $PayPalResult['TRANSACTIONID'] : null); |
|
279 | + $payment->set_txn_id_chq_nmbr(isset($PayPalResult['TRANSACTIONID']) ? $PayPalResult['TRANSACTIONID'] : null); |
|
280 | 280 | |
281 | 281 | $primary_registration_code = $primary_registrant instanceof EE_Registration ? $primary_registrant->reg_code() : ''; |
282 | 282 | $payment->set_extra_accntng($primary_registration_code); |
283 | 283 | $payment->set_details($PayPalResult); |
284 | 284 | } |
285 | - }catch(Exception $e){ |
|
285 | + } catch (Exception $e) { |
|
286 | 286 | $payment->set_status($this->_pay_model->failed_status()); |
287 | 287 | $payment->set_gateway_response($e->getMessage()); |
288 | 288 | } |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | * @param EEI_Payment $payment |
300 | 300 | * @return array |
301 | 301 | */ |
302 | - private function _log_clean_request($request,$payment){ |
|
302 | + private function _log_clean_request($request, $payment) { |
|
303 | 303 | $cleaned_request_data = $request; |
304 | 304 | unset($cleaned_request_data['CCDetails']['acct']); |
305 | 305 | unset($cleaned_request_data['CCDetails']['cvv2']); |
@@ -315,13 +315,13 @@ discard block |
||
315 | 315 | * @param EEI_Payment $payment |
316 | 316 | * @return array cleaned |
317 | 317 | */ |
318 | - private function _log_clean_response($response,$payment){ |
|
318 | + private function _log_clean_response($response, $payment) { |
|
319 | 319 | unset($response['REQUESTDATA']['CREDITCARDTYPE']); |
320 | 320 | unset($response['REQUESTDATA']['ACCT']); |
321 | 321 | unset($response['REQUESTDATA']['EXPDATE']); |
322 | 322 | unset($response['REQUESTDATA']['CVV2']); |
323 | 323 | unset($response['RAWREQUEST']); |
324 | - $this->log(array('Paypal Response'=>$response),$payment); |
|
324 | + $this->log(array('Paypal Response'=>$response), $payment); |
|
325 | 325 | return $response; |
326 | 326 | } |
327 | 327 | |
@@ -346,32 +346,32 @@ discard block |
||
346 | 346 | // DP Fields |
347 | 347 | $DPFields = isset($DataArray['DPFields']) ? $DataArray['DPFields'] : array(); |
348 | 348 | foreach ($DPFields as $DPFieldsVar => $DPFieldsVal) |
349 | - $DPFieldsNVP .= '&' . strtoupper($DPFieldsVar) . '=' . urlencode($DPFieldsVal); |
|
349 | + $DPFieldsNVP .= '&'.strtoupper($DPFieldsVar).'='.urlencode($DPFieldsVal); |
|
350 | 350 | |
351 | 351 | // CC Details Fields |
352 | 352 | $CCDetails = isset($DataArray['CCDetails']) ? $DataArray['CCDetails'] : array(); |
353 | 353 | foreach ($CCDetails as $CCDetailsVar => $CCDetailsVal) |
354 | - $CCDetailsNVP .= '&' . strtoupper($CCDetailsVar) . '=' . urlencode($CCDetailsVal); |
|
354 | + $CCDetailsNVP .= '&'.strtoupper($CCDetailsVar).'='.urlencode($CCDetailsVal); |
|
355 | 355 | |
356 | 356 | // PayerInfo Type Fields |
357 | 357 | $PayerInfo = isset($DataArray['PayerInfo']) ? $DataArray['PayerInfo'] : array(); |
358 | 358 | foreach ($PayerInfo as $PayerInfoVar => $PayerInfoVal) |
359 | - $PayerInfoNVP .= '&' . strtoupper($PayerInfoVar) . '=' . urlencode($PayerInfoVal); |
|
359 | + $PayerInfoNVP .= '&'.strtoupper($PayerInfoVar).'='.urlencode($PayerInfoVal); |
|
360 | 360 | |
361 | 361 | // Payer Name Fields |
362 | 362 | $PayerName = isset($DataArray['PayerName']) ? $DataArray['PayerName'] : array(); |
363 | 363 | foreach ($PayerName as $PayerNameVar => $PayerNameVal) |
364 | - $PayerNameNVP .= '&' . strtoupper($PayerNameVar) . '=' . urlencode($PayerNameVal); |
|
364 | + $PayerNameNVP .= '&'.strtoupper($PayerNameVar).'='.urlencode($PayerNameVal); |
|
365 | 365 | |
366 | 366 | // Address Fields (Billing) |
367 | 367 | $BillingAddress = isset($DataArray['BillingAddress']) ? $DataArray['BillingAddress'] : array(); |
368 | 368 | foreach ($BillingAddress as $BillingAddressVar => $BillingAddressVal) |
369 | - $BillingAddressNVP .= '&' . strtoupper($BillingAddressVar) . '=' . urlencode($BillingAddressVal); |
|
369 | + $BillingAddressNVP .= '&'.strtoupper($BillingAddressVar).'='.urlencode($BillingAddressVal); |
|
370 | 370 | |
371 | 371 | // Payment Details Type Fields |
372 | 372 | $PaymentDetails = isset($DataArray['PaymentDetails']) ? $DataArray['PaymentDetails'] : array(); |
373 | 373 | foreach ($PaymentDetails as $PaymentDetailsVar => $PaymentDetailsVal) |
374 | - $PaymentDetailsNVP .= '&' . strtoupper($PaymentDetailsVar) . '=' . urlencode($PaymentDetailsVal); |
|
374 | + $PaymentDetailsNVP .= '&'.strtoupper($PaymentDetailsVar).'='.urlencode($PaymentDetailsVal); |
|
375 | 375 | |
376 | 376 | // Payment Details Item Type Fields |
377 | 377 | $OrderItems = isset($DataArray['OrderItems']) ? $DataArray['OrderItems'] : array(); |
@@ -379,22 +379,22 @@ discard block |
||
379 | 379 | foreach ($OrderItems as $OrderItemsVar => $OrderItemsVal) { |
380 | 380 | $CurrentItem = $OrderItems[$OrderItemsVar]; |
381 | 381 | foreach ($CurrentItem as $CurrentItemVar => $CurrentItemVal) |
382 | - $OrderItemsNVP .= '&' . strtoupper($CurrentItemVar) . $n . '=' . urlencode($CurrentItemVal); |
|
382 | + $OrderItemsNVP .= '&'.strtoupper($CurrentItemVar).$n.'='.urlencode($CurrentItemVal); |
|
383 | 383 | $n++; |
384 | 384 | } |
385 | 385 | |
386 | 386 | // Ship To Address Fields |
387 | 387 | $ShippingAddress = isset($DataArray['ShippingAddress']) ? $DataArray['ShippingAddress'] : array(); |
388 | 388 | foreach ($ShippingAddress as $ShippingAddressVar => $ShippingAddressVal) |
389 | - $ShippingAddressNVP .= '&' . strtoupper($ShippingAddressVar) . '=' . urlencode($ShippingAddressVal); |
|
389 | + $ShippingAddressNVP .= '&'.strtoupper($ShippingAddressVar).'='.urlencode($ShippingAddressVal); |
|
390 | 390 | |
391 | 391 | // 3D Secure Fields |
392 | 392 | $Secure3D = isset($DataArray['Secure3D']) ? $DataArray['Secure3D'] : array(); |
393 | 393 | foreach ($Secure3D as $Secure3DVar => $Secure3DVal) |
394 | - $Secure3DNVP .= '&' . strtoupper($Secure3DVar) . '=' . urlencode($Secure3DVal); |
|
394 | + $Secure3DNVP .= '&'.strtoupper($Secure3DVar).'='.urlencode($Secure3DVal); |
|
395 | 395 | |
396 | 396 | // Now that we have each chunk we need to go ahead and append them all together for our entire NVP string |
397 | - $NVPRequest = 'USER=' . $this->_username . '&PWD=' . $this->_password . '&VERSION=64.0' . '&SIGNATURE=' . $this->_signature . $DPFieldsNVP . $CCDetailsNVP . $PayerInfoNVP . $PayerNameNVP . $BillingAddressNVP . $PaymentDetailsNVP . $OrderItemsNVP . $ShippingAddressNVP . $Secure3DNVP; |
|
397 | + $NVPRequest = 'USER='.$this->_username.'&PWD='.$this->_password.'&VERSION=64.0'.'&SIGNATURE='.$this->_signature.$DPFieldsNVP.$CCDetailsNVP.$PayerInfoNVP.$PayerNameNVP.$BillingAddressNVP.$PaymentDetailsNVP.$OrderItemsNVP.$ShippingAddressNVP.$Secure3DNVP; |
|
398 | 398 | $NVPResponse = $this->_CURLRequest($NVPRequest); |
399 | 399 | $NVPRequestArray = $this->_NVPToArray($NVPRequest); |
400 | 400 | $NVPResponseArray = $this->_NVPToArray($NVPResponse); |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | private function _CURLRequest($Request) { |
419 | 419 | $EndPointURL = $this->_debug_mode ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp'; |
420 | 420 | $curl = curl_init(); |
421 | - curl_setopt($curl, CURLOPT_VERBOSE, apply_filters('FHEE__EEG_Paypal_Pro__CurlRequest__CURLOPT_VERBOSE', TRUE ) ); |
|
421 | + curl_setopt($curl, CURLOPT_VERBOSE, apply_filters('FHEE__EEG_Paypal_Pro__CurlRequest__CURLOPT_VERBOSE', TRUE)); |
|
422 | 422 | curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); |
423 | 423 | curl_setopt($curl, CURLOPT_TIMEOUT, 60); |
424 | 424 | curl_setopt($curl, CURLOPT_URL, $EndPointURL); |
@@ -468,9 +468,9 @@ discard block |
||
468 | 468 | private function _APICallSuccessful($PayPalResult) { |
469 | 469 | $approved = false; |
470 | 470 | // check main response message from PayPal |
471 | - if (isset($PayPalResult['ACK']) && !empty($PayPalResult['ACK'])) { |
|
471 | + if (isset($PayPalResult['ACK']) && ! empty($PayPalResult['ACK'])) { |
|
472 | 472 | $ack = strtoupper($PayPalResult['ACK']); |
473 | - $approved = ( $ack == 'SUCCESS' || $ack == 'SUCCESSWITHWARNING' || $ack == 'PARTIALSUCCESS' ) ? true : false; |
|
473 | + $approved = ($ack == 'SUCCESS' || $ack == 'SUCCESSWITHWARNING' || $ack == 'PARTIALSUCCESS') ? true : false; |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | return $approved; |
@@ -486,11 +486,11 @@ discard block |
||
486 | 486 | |
487 | 487 | $Errors = array(); |
488 | 488 | $n = 0; |
489 | - while (isset($DataArray['L_ERRORCODE' . $n . ''])) { |
|
490 | - $LErrorCode = isset($DataArray['L_ERRORCODE' . $n . '']) ? $DataArray['L_ERRORCODE' . $n . ''] : ''; |
|
491 | - $LShortMessage = isset($DataArray['L_SHORTMESSAGE' . $n . '']) ? $DataArray['L_SHORTMESSAGE' . $n . ''] : ''; |
|
492 | - $LLongMessage = isset($DataArray['L_LONGMESSAGE' . $n . '']) ? $DataArray['L_LONGMESSAGE' . $n . ''] : ''; |
|
493 | - $LSeverityCode = isset($DataArray['L_SEVERITYCODE' . $n . '']) ? $DataArray['L_SEVERITYCODE' . $n . ''] : ''; |
|
489 | + while (isset($DataArray['L_ERRORCODE'.$n.''])) { |
|
490 | + $LErrorCode = isset($DataArray['L_ERRORCODE'.$n.'']) ? $DataArray['L_ERRORCODE'.$n.''] : ''; |
|
491 | + $LShortMessage = isset($DataArray['L_SHORTMESSAGE'.$n.'']) ? $DataArray['L_SHORTMESSAGE'.$n.''] : ''; |
|
492 | + $LLongMessage = isset($DataArray['L_LONGMESSAGE'.$n.'']) ? $DataArray['L_LONGMESSAGE'.$n.''] : ''; |
|
493 | + $LSeverityCode = isset($DataArray['L_SEVERITYCODE'.$n.'']) ? $DataArray['L_SEVERITYCODE'.$n.''] : ''; |
|
494 | 494 | |
495 | 495 | $CurrentItem = array( |
496 | 496 | 'L_ERRORCODE' => $LErrorCode, |
@@ -530,7 +530,7 @@ discard block |
||
530 | 530 | elseif ($CurrentErrorVar == 'L_SEVERITYCODE') |
531 | 531 | $CurrentVarName = 'Severity Code'; |
532 | 532 | |
533 | - $error .= '<br />' . $CurrentVarName . ': ' . $CurrentErrorVal; |
|
533 | + $error .= '<br />'.$CurrentVarName.': '.$CurrentErrorVal; |
|
534 | 534 | } |
535 | 535 | } |
536 | 536 | return $error; |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | * @return EED_Ticket_Selector_Caff |
17 | 17 | */ |
18 | 18 | public static function instance() { |
19 | - return parent::get_instance( __CLASS__ ); |
|
19 | + return parent::get_instance(__CLASS__); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | |
@@ -37,24 +37,24 @@ discard block |
||
37 | 37 | * @return void |
38 | 38 | */ |
39 | 39 | public static function set_hooks_admin() { |
40 | - define( 'TICKET_SELECTOR_CAFF_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS ); |
|
41 | - add_action( 'AHEE__template_settings__template__before_settings_form', array( 'EED_Ticket_Selector_Caff', 'template_settings_form' ), 10 ); |
|
42 | - add_filter( 'FHEE__General_Settings_Admin_Page__update_template_settings__data', array( 'EED_Ticket_Selector_Caff', 'update_template_settings' ), 10, 2 ); |
|
40 | + define('TICKET_SELECTOR_CAFF_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS); |
|
41 | + add_action('AHEE__template_settings__template__before_settings_form', array('EED_Ticket_Selector_Caff', 'template_settings_form'), 10); |
|
42 | + add_filter('FHEE__General_Settings_Admin_Page__update_template_settings__data', array('EED_Ticket_Selector_Caff', 'update_template_settings'), 10, 2); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | |
46 | 46 | //just required because of abstract declaration |
47 | - public function run( $WP ) { |
|
47 | + public function run($WP) { |
|
48 | 48 | $this->set_config(); |
49 | 49 | } |
50 | 50 | |
51 | 51 | |
52 | 52 | |
53 | 53 | |
54 | - protected function set_config(){ |
|
55 | - $this->set_config_section( 'template_settings' ); |
|
56 | - $this->set_config_class( 'EE_Ticket_Selector_Config' ); |
|
57 | - $this->set_config_name( 'EED_Ticket_Selector' ); |
|
54 | + protected function set_config() { |
|
55 | + $this->set_config_section('template_settings'); |
|
56 | + $this->set_config_class('EE_Ticket_Selector_Config'); |
|
57 | + $this->set_config_name('EED_Ticket_Selector'); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | 'FHEE__EED_Ticket_Selector_Caff___ticket_selector_settings_form__form_subsections', |
88 | 88 | array( |
89 | 89 | 'appearance_settings_hdr' => new EE_Form_Section_HTML( |
90 | - EEH_HTML::br(2) . |
|
91 | - EEH_HTML::h2( __( 'Ticket Selector Template Settings', 'event_espresso' )) |
|
90 | + EEH_HTML::br(2). |
|
91 | + EEH_HTML::h2(__('Ticket Selector Template Settings', 'event_espresso')) |
|
92 | 92 | ), |
93 | 93 | 'appearance_settings' => EED_Ticket_Selector_Caff::_ticket_selector_appearance_settings() |
94 | 94 | ) |
@@ -113,9 +113,9 @@ discard block |
||
113 | 113 | array( |
114 | 114 | 'show_ticket_details' => new EE_Yes_No_Input( |
115 | 115 | array( |
116 | - 'html_label_text' => __('Show Ticket Details?', 'event_espresso' ), |
|
117 | - 'html_help_text' => __( 'This lets you choose whether the extra ticket details section is displayed with the ticket selector.', 'event_espresso'), |
|
118 | - 'default' => isset( EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_ticket_details ) |
|
116 | + 'html_label_text' => __('Show Ticket Details?', 'event_espresso'), |
|
117 | + 'html_help_text' => __('This lets you choose whether the extra ticket details section is displayed with the ticket selector.', 'event_espresso'), |
|
118 | + 'default' => isset(EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_ticket_details) |
|
119 | 119 | ? EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_ticket_details |
120 | 120 | : true, |
121 | 121 | 'display_html_label_text' => false |
@@ -123,9 +123,9 @@ discard block |
||
123 | 123 | ), |
124 | 124 | 'show_ticket_sale_columns' => new EE_Yes_No_Input( |
125 | 125 | array( |
126 | - 'html_label_text' => __('Show Ticket Sale Info?', 'event_espresso' ), |
|
127 | - 'html_help_text' => __( 'This lets you indicate whether information about ticket sales is shown with ticket details in the ticket selector.', 'event_espresso'), |
|
128 | - 'default' => isset( EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_ticket_sale_columns ) |
|
126 | + 'html_label_text' => __('Show Ticket Sale Info?', 'event_espresso'), |
|
127 | + 'html_help_text' => __('This lets you indicate whether information about ticket sales is shown with ticket details in the ticket selector.', 'event_espresso'), |
|
128 | + 'default' => isset(EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_ticket_sale_columns) |
|
129 | 129 | ? EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_ticket_sale_columns |
130 | 130 | : true, |
131 | 131 | 'display_html_label_text' => false |
@@ -133,9 +133,9 @@ discard block |
||
133 | 133 | ), |
134 | 134 | 'show_expired_tickets' => new EE_Yes_No_Input( |
135 | 135 | array( |
136 | - 'html_label_text' => __( 'Show Expired Tickets?', 'event_espresso' ), |
|
137 | - 'html_help_text' => __( 'Indicate whether to show expired tickets in the ticket selector', 'event_espresso' ), |
|
138 | - 'default' => isset( EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets ) |
|
136 | + 'html_label_text' => __('Show Expired Tickets?', 'event_espresso'), |
|
137 | + 'html_help_text' => __('Indicate whether to show expired tickets in the ticket selector', 'event_espresso'), |
|
138 | + 'default' => isset(EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets) |
|
139 | 139 | ? EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets |
140 | 140 | : true, |
141 | 141 | 'display_html_label_text' => false |
@@ -158,21 +158,21 @@ discard block |
||
158 | 158 | * @param array $REQ incoming request |
159 | 159 | * @return EE_Template_Config |
160 | 160 | */ |
161 | - public static function update_template_settings( EE_Template_Config $CFG, $REQ ) { |
|
162 | - if ( ! isset( $CFG->EED_Ticket_Selector ) ) { |
|
161 | + public static function update_template_settings(EE_Template_Config $CFG, $REQ) { |
|
162 | + if ( ! isset($CFG->EED_Ticket_Selector)) { |
|
163 | 163 | $CFG->EED_Ticket_Selector = new EE_Ticket_Selector_Config(); |
164 | 164 | } |
165 | 165 | try { |
166 | 166 | $ticket_selector_form = EED_Ticket_Selector_Caff::_ticket_selector_settings_form(); |
167 | 167 | |
168 | 168 | //check for form submission |
169 | - if ( $ticket_selector_form->was_submitted() ) { |
|
169 | + if ($ticket_selector_form->was_submitted()) { |
|
170 | 170 | |
171 | 171 | //capture form data |
172 | 172 | $ticket_selector_form->receive_form_submission(); |
173 | 173 | |
174 | 174 | //validate form data |
175 | - if ( $ticket_selector_form->is_valid() ) { |
|
175 | + if ($ticket_selector_form->is_valid()) { |
|
176 | 176 | |
177 | 177 | //grab validated data from form |
178 | 178 | $valid_data = $ticket_selector_form->valid_data(); |
@@ -182,13 +182,13 @@ discard block |
||
182 | 182 | $CFG->EED_Ticket_Selector->show_ticket_details = $valid_data['appearance_settings']['show_ticket_details']; |
183 | 183 | $CFG->EED_Ticket_Selector->show_expired_tickets = $valid_data['appearance_settings']['show_expired_tickets']; |
184 | 184 | } else { |
185 | - if ( $ticket_selector_form->submission_error_message() !== '' ) { |
|
186 | - EE_Error::add_error( $ticket_selector_form->submission_error_message(), __FILE__, __FUNCTION__, __LINE__ ); |
|
185 | + if ($ticket_selector_form->submission_error_message() !== '') { |
|
186 | + EE_Error::add_error($ticket_selector_form->submission_error_message(), __FILE__, __FUNCTION__, __LINE__); |
|
187 | 187 | } |
188 | 188 | } |
189 | 189 | |
190 | 190 | } |
191 | - } catch( EE_Error $e ) { |
|
191 | + } catch (EE_Error $e) { |
|
192 | 192 | $e->get_error(); |
193 | 193 | } |
194 | 194 |
@@ -21,8 +21,8 @@ |
||
21 | 21 | |
22 | 22 | |
23 | 23 | <div id="postbox-container-2" class="postbox-container"> |
24 | - <?php do_meta_boxes( $current_page, 'normal', NULL ); ?> |
|
25 | - <?php do_meta_boxes( $current_page, 'advanced', NULL ); ?> |
|
24 | + <?php do_meta_boxes($current_page, 'normal', NULL); ?> |
|
25 | + <?php do_meta_boxes($current_page, 'advanced', NULL); ?> |
|
26 | 26 | </div> |
27 | 27 | <!-- postbox-container-2 --> |
28 | 28 | <div class="clear"></div> |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * @since 4.5.0 |
12 | 12 | * |
13 | 13 | */ |
14 | -class EE_Model_Form_Section extends EE_Form_Section_Proper{ |
|
14 | +class EE_Model_Form_Section extends EE_Form_Section_Proper { |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * |
@@ -36,36 +36,36 @@ discard block |
||
36 | 36 | * } |
37 | 37 | * @throws EE_Error |
38 | 38 | */ |
39 | - public function __construct($options_array = array()){ |
|
40 | - if(isset($options_array['model']) && $options_array['model'] instanceof EEM_Base){ |
|
39 | + public function __construct($options_array = array()) { |
|
40 | + if (isset($options_array['model']) && $options_array['model'] instanceof EEM_Base) { |
|
41 | 41 | $this->_model = $options_array['model']; |
42 | 42 | } |
43 | - if( ! $this->_model || ! $this->_model instanceof EEM_Base ){ |
|
43 | + if ( ! $this->_model || ! $this->_model instanceof EEM_Base) { |
|
44 | 44 | throw new EE_Error(sprintf(__("Model Form Sections must first specify the _model property to be a subclass of EEM_Base", "event_espresso"))); |
45 | 45 | } |
46 | 46 | |
47 | - if(isset($options_array['subsection_args'])){ |
|
47 | + if (isset($options_array['subsection_args'])) { |
|
48 | 48 | $subsection_args = $options_array['subsection_args']; |
49 | - }else{ |
|
49 | + } else { |
|
50 | 50 | $subsection_args = array(); |
51 | 51 | } |
52 | 52 | |
53 | 53 | //gather fields and relations to convert to inputs |
54 | 54 | //but if they're just going to exclude a field anyways, don't bother converting it to an input |
55 | 55 | $exclude = $this->_subsections; |
56 | - if(isset($options_array['exclude'])){ |
|
57 | - $exclude = array_merge($exclude,array_flip($options_array['exclude'])); |
|
56 | + if (isset($options_array['exclude'])) { |
|
57 | + $exclude = array_merge($exclude, array_flip($options_array['exclude'])); |
|
58 | 58 | } |
59 | 59 | $model_fields = array_diff_key($this->_model->field_settings(), $exclude); |
60 | 60 | $model_relations = array_diff_key($this->_model->relation_settings(), $exclude); |
61 | 61 | //convert fields and relations to inputs |
62 | 62 | $this->_subsections = array_merge( |
63 | 63 | $this->_convert_model_fields_to_inputs($model_fields), |
64 | - $this->_convert_model_relations_to_inputs($model_relations,$subsection_args), |
|
64 | + $this->_convert_model_relations_to_inputs($model_relations, $subsection_args), |
|
65 | 65 | $this->_subsections |
66 | 66 | ); |
67 | 67 | parent::__construct($options_array); |
68 | - if(isset($options_array['model_object']) && $options_array['model_object'] instanceof EE_Base_Class){ |
|
68 | + if (isset($options_array['model_object']) && $options_array['model_object'] instanceof EE_Base_Class) { |
|
69 | 69 | $this->populate_model_obj($options_array['model_object']); |
70 | 70 | } |
71 | 71 | |
@@ -83,9 +83,9 @@ discard block |
||
83 | 83 | * } |
84 | 84 | * @return array |
85 | 85 | */ |
86 | - protected function _convert_model_relations_to_inputs($relations,$subsection_args = array()){ |
|
86 | + protected function _convert_model_relations_to_inputs($relations, $subsection_args = array()) { |
|
87 | 87 | $inputs = array(); |
88 | - foreach( $relations as $relation_name => $relation_obj ) { |
|
88 | + foreach ($relations as $relation_name => $relation_obj) { |
|
89 | 89 | $input_constructor_args = array( |
90 | 90 | array_merge( |
91 | 91 | array( |
@@ -96,19 +96,19 @@ discard block |
||
96 | 96 | ) |
97 | 97 | ); |
98 | 98 | $input = NULL; |
99 | - switch(get_class($relation_obj)){ |
|
99 | + switch (get_class($relation_obj)) { |
|
100 | 100 | case 'EE_HABTM_Relation': |
101 | - if(isset($subsection_args[$relation_name]) && |
|
102 | - isset($subsection_args[$relation_name]['model_objects'])){ |
|
101 | + if (isset($subsection_args[$relation_name]) && |
|
102 | + isset($subsection_args[$relation_name]['model_objects'])) { |
|
103 | 103 | $model_objects = $subsection_args[$relation_name]['model_objects']; |
104 | - }else{ |
|
104 | + } else { |
|
105 | 105 | $model_objects = $relation_obj->get_other_model()->get_all(); |
106 | 106 | } |
107 | - $input = new EE_Select_Multi_Model_Input($model_objects,$input_constructor_args); |
|
107 | + $input = new EE_Select_Multi_Model_Input($model_objects, $input_constructor_args); |
|
108 | 108 | break; |
109 | 109 | default: |
110 | 110 | } |
111 | - if($input){ |
|
111 | + if ($input) { |
|
112 | 112 | $inputs[$relation_name] = $input; |
113 | 113 | } |
114 | 114 | } |
@@ -123,10 +123,10 @@ discard block |
||
123 | 123 | * @throws EE_Error |
124 | 124 | * @return EE_Form_Input_Base[] |
125 | 125 | */ |
126 | - protected function _convert_model_fields_to_inputs( $model_fields = array() ){ |
|
126 | + protected function _convert_model_fields_to_inputs($model_fields = array()) { |
|
127 | 127 | $inputs = array(); |
128 | - foreach( $model_fields as $field_name=>$model_field ){ |
|
129 | - if ( $model_field instanceof EE_Model_Field_Base ) { |
|
128 | + foreach ($model_fields as $field_name=>$model_field) { |
|
129 | + if ($model_field instanceof EE_Model_Field_Base) { |
|
130 | 130 | $input_constructor_args = array( |
131 | 131 | array( |
132 | 132 | 'required'=> ! $model_field->is_nullable() && $model_field->get_default_value() === NULL, |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | 'default'=>$model_field->get_default_value(), |
135 | 135 | ) |
136 | 136 | ); |
137 | - switch(get_class($model_field)){ |
|
137 | + switch (get_class($model_field)) { |
|
138 | 138 | case 'EE_All_Caps_Text_Field': |
139 | 139 | case 'EE_Any_Foreign_Model_Name_Field': |
140 | 140 | $input_class = 'EE_Text_Input'; |
@@ -143,16 +143,16 @@ discard block |
||
143 | 143 | $input_class = 'EE_Yes_No_Input'; |
144 | 144 | break; |
145 | 145 | case 'EE_Datetime_Field': |
146 | - throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"),get_class($model_field))); |
|
146 | + throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"), get_class($model_field))); |
|
147 | 147 | break; |
148 | 148 | case 'EE_Email_Field': |
149 | 149 | $input_class = 'EE_Email_Input'; |
150 | 150 | break; |
151 | 151 | case 'EE_Enum_Integer_Field': |
152 | - throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"),get_class($model_field))); |
|
152 | + throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"), get_class($model_field))); |
|
153 | 153 | break; |
154 | 154 | case 'EE_Enum_Text_Field': |
155 | - throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"),get_class($model_field))); |
|
155 | + throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"), get_class($model_field))); |
|
156 | 156 | break; |
157 | 157 | case 'EE_Float_Field': |
158 | 158 | $input_class = 'EE_Float_Input'; |
@@ -161,15 +161,15 @@ discard block |
||
161 | 161 | case 'EE_Foreign_Key_String_Field': |
162 | 162 | case 'EE_WP_User_Field': |
163 | 163 | $models_pointed_to = $model_field instanceof EE_Field_With_Model_Name ? $model_field->get_model_class_names_pointed_to() : array(); |
164 | - if(true || is_array($models_pointed_to) && count($models_pointed_to) > 1){ |
|
164 | + if (true || is_array($models_pointed_to) && count($models_pointed_to) > 1) { |
|
165 | 165 | $input_class = 'EE_Text_Input'; |
166 | - }else{ |
|
166 | + } else { |
|
167 | 167 | //so its just one model |
168 | 168 | $model_name = is_array($models_pointed_to) ? reset($models_pointed_to) : $models_pointed_to; |
169 | 169 | $model = EE_Registry::instance()->load_model($model_name); |
170 | 170 | $model_names = $model->get_all_names(array('limit'=>10)); |
171 | - if($model_field->is_nullable()){ |
|
172 | - array_unshift( $model_names, __( "Please Select", 'event_espresso' )); |
|
171 | + if ($model_field->is_nullable()) { |
|
172 | + array_unshift($model_names, __("Please Select", 'event_espresso')); |
|
173 | 173 | } |
174 | 174 | $input_constructor_args[1] = $input_constructor_args[0]; |
175 | 175 | $input_constructor_args[0] = $model_names; |
@@ -178,10 +178,10 @@ discard block |
||
178 | 178 | break; |
179 | 179 | case 'EE_Full_HTML_Field': |
180 | 180 | $input_class = 'EE_Text_Area_Input'; |
181 | - $input_constructor_args[ 0 ]['validation_strategies'] = array( new EE_Full_HTML_Validation_Strategy() ); |
|
181 | + $input_constructor_args[0]['validation_strategies'] = array(new EE_Full_HTML_Validation_Strategy()); |
|
182 | 182 | break; |
183 | 183 | case 'EE_Infinite_Integer': |
184 | - throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"),get_class($model_field))); |
|
184 | + throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"), get_class($model_field))); |
|
185 | 185 | break; |
186 | 186 | case 'EE_Integer_Field': |
187 | 187 | $input_class = 'EE_Text_Input'; |
@@ -190,11 +190,11 @@ discard block |
||
190 | 190 | $input_class = 'EE_Text_Area_Input'; |
191 | 191 | break; |
192 | 192 | case 'EE_Money_Field': |
193 | - throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"),get_class($model_field))); |
|
193 | + throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"), get_class($model_field))); |
|
194 | 194 | break; |
195 | 195 | case 'EE_Post_Content_Field': |
196 | 196 | $input_class = 'EE_Text_Area_Input'; |
197 | - $input_constructor_args[ 0 ][ 'validation_strategies' ] = array( new EE_Full_HTML_Validation_Strategy() ); |
|
197 | + $input_constructor_args[0]['validation_strategies'] = array(new EE_Full_HTML_Validation_Strategy()); |
|
198 | 198 | break; |
199 | 199 | case 'EE_Plain_Text_Field': |
200 | 200 | $input_class = 'EE_Text_Input'; |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | break; |
212 | 212 | case 'EE_Simple_HTML_Field': |
213 | 213 | $input_class = 'EE_Text_Area_Input'; |
214 | - $input_constructor_args[ 0 ][ 'validation_strategies' ] = array( new EE_Simple_HTML_Validation_Strategy() ); |
|
214 | + $input_constructor_args[0]['validation_strategies'] = array(new EE_Simple_HTML_Validation_Strategy()); |
|
215 | 215 | break; |
216 | 216 | case 'EE_Slug_Field': |
217 | 217 | $input_class = 'EE_Text_Input'; |
@@ -220,13 +220,13 @@ discard block |
||
220 | 220 | $input_class = 'EE_Yes_No_Input'; |
221 | 221 | break; |
222 | 222 | case 'EE_WP_Post_Status_Field': |
223 | - throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"),get_class($model_field))); |
|
223 | + throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"), get_class($model_field))); |
|
224 | 224 | break; |
225 | 225 | case 'EE_WP_Post_Type_Field': |
226 | - throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"),get_class($model_field))); |
|
226 | + throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"), get_class($model_field))); |
|
227 | 227 | break; |
228 | 228 | default: |
229 | - throw new EE_Error(sprintf(__("Model field of type '%s' does not convert to any known Form Input. Please add a case to EE_Model_Form_section's _convert_model_fields_to_inputs switch statement", "event_espresso"),get_class($model_field))); |
|
229 | + throw new EE_Error(sprintf(__("Model field of type '%s' does not convert to any known Form Input. Please add a case to EE_Model_Form_section's _convert_model_fields_to_inputs switch statement", "event_espresso"), get_class($model_field))); |
|
230 | 230 | } |
231 | 231 | $reflection = new ReflectionClass($input_class); |
232 | 232 | $input = $reflection->newInstanceArgs($input_constructor_args); |
@@ -245,21 +245,21 @@ discard block |
||
245 | 245 | * @param EE_Base_Class $model_obj |
246 | 246 | * @return void |
247 | 247 | */ |
248 | - public function populate_model_obj($model_obj){ |
|
248 | + public function populate_model_obj($model_obj) { |
|
249 | 249 | $model_obj = $this->_model->ensure_is_obj($model_obj); |
250 | 250 | $this->_model_object = $model_obj; |
251 | 251 | $defaults = $model_obj->model_field_array(); |
252 | - foreach($this->_model->relation_settings() as $relation_name => $relation_obj){ |
|
252 | + foreach ($this->_model->relation_settings() as $relation_name => $relation_obj) { |
|
253 | 253 | $form_inputs = $this->inputs(); |
254 | - if(isset($form_inputs[$relation_name])){ |
|
255 | - if($relation_obj instanceof EE_Belongs_To_Relation){ |
|
254 | + if (isset($form_inputs[$relation_name])) { |
|
255 | + if ($relation_obj instanceof EE_Belongs_To_Relation) { |
|
256 | 256 | //then we only expect there to be one |
257 | 257 | $related_item = $this->_model_object->get_first_related($relation_name); |
258 | 258 | $defaults[$relation_name] = $related_item->ID(); |
259 | - }else{ |
|
259 | + } else { |
|
260 | 260 | $related_items = $this->_model_object->get_many_related($relation_name); |
261 | 261 | $ids = array(); |
262 | - foreach($related_items as $related_item){ |
|
262 | + foreach ($related_items as $related_item) { |
|
263 | 263 | $ids[] = $related_item->ID(); |
264 | 264 | } |
265 | 265 | $defaults[$relation_name] = $ids; |
@@ -281,8 +281,8 @@ discard block |
||
281 | 281 | * values are their normalized values |
282 | 282 | * @return array |
283 | 283 | */ |
284 | - public function inputs_values_corresponding_to_model_fields(){ |
|
285 | - return array_intersect_key($this->input_values(),$this->_model->field_settings()); |
|
284 | + public function inputs_values_corresponding_to_model_fields() { |
|
285 | + return array_intersect_key($this->input_values(), $this->_model->field_settings()); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | |
@@ -293,17 +293,17 @@ discard block |
||
293 | 293 | * @param array $req_data should usually be $_REQUEST (the default). |
294 | 294 | * @return void |
295 | 295 | */ |
296 | - public function _normalize( $req_data ) { |
|
297 | - parent::_normalize( $req_data ); |
|
296 | + public function _normalize($req_data) { |
|
297 | + parent::_normalize($req_data); |
|
298 | 298 | //create or set the model object, if it isn't already |
299 | - if( ! $this->_model_object ){ |
|
299 | + if ( ! $this->_model_object) { |
|
300 | 300 | //check to see if the form indicates a PK, in which case we want to only retrieve it and update it |
301 | 301 | $pk_name = $this->_model->primary_key_name(); |
302 | 302 | $model_obj = $this->_model->get_one_by_ID($this->get_input_value($pk_name)); |
303 | - if($model_obj){ |
|
303 | + if ($model_obj) { |
|
304 | 304 | $this->_model_object = $model_obj; |
305 | - }else{ |
|
306 | - $this->_model_object = EE_Registry::instance()->load_class($this->_model->get_this_model_name() ); |
|
305 | + } else { |
|
306 | + $this->_model_object = EE_Registry::instance()->load_class($this->_model->get_this_model_name()); |
|
307 | 307 | } |
308 | 308 | } |
309 | 309 | } |
@@ -318,24 +318,24 @@ discard block |
||
318 | 318 | * @return int, 1 on a successful update, the ID of |
319 | 319 | * the new entry on insert; 0 on failure |
320 | 320 | */ |
321 | - public function save(){ |
|
322 | - if( ! $this->_model_object){ |
|
323 | - throw new EE_Error(sprintf(__("Cannot save the model form's model object (model is '%s') because there is no model object set. You must either set it, or call receive_form_submission where it is set automatically", "event_espresso"),get_class($this->_model))); |
|
321 | + public function save() { |
|
322 | + if ( ! $this->_model_object) { |
|
323 | + throw new EE_Error(sprintf(__("Cannot save the model form's model object (model is '%s') because there is no model object set. You must either set it, or call receive_form_submission where it is set automatically", "event_espresso"), get_class($this->_model))); |
|
324 | 324 | } |
325 | 325 | //ok so the model object is set. Just set it with the submitted form data |
326 | - foreach($this->inputs_values_corresponding_to_model_fields() as $field_name=>$field_value){ |
|
326 | + foreach ($this->inputs_values_corresponding_to_model_fields() as $field_name=>$field_value) { |
|
327 | 327 | //only set the non-primary key |
328 | - if($field_name != $this->_model->primary_key_name()){ |
|
329 | - $this->_model_object->set($field_name,$field_value); |
|
328 | + if ($field_name != $this->_model->primary_key_name()) { |
|
329 | + $this->_model_object->set($field_name, $field_value); |
|
330 | 330 | } |
331 | 331 | } |
332 | - $success = $this->_model_object->save(); |
|
333 | - foreach($this->_model->relation_settings() as $relation_name => $relation_obj){ |
|
334 | - if(isset($this->_subsections[$relation_name])){ |
|
332 | + $success = $this->_model_object->save(); |
|
333 | + foreach ($this->_model->relation_settings() as $relation_name => $relation_obj) { |
|
334 | + if (isset($this->_subsections[$relation_name])) { |
|
335 | 335 | $success = $this->_save_related_info($relation_name); |
336 | 336 | } |
337 | 337 | } |
338 | - do_action( 'AHEE__EE_Model_Form_Section__save__done', $this, $success ); |
|
338 | + do_action('AHEE__EE_Model_Form_Section__save__done', $this, $success); |
|
339 | 339 | return $success; |
340 | 340 | } |
341 | 341 | |
@@ -348,29 +348,29 @@ discard block |
||
348 | 348 | * @return bool |
349 | 349 | * @throws EE_Error |
350 | 350 | */ |
351 | - protected function _save_related_info($relation_name){ |
|
351 | + protected function _save_related_info($relation_name) { |
|
352 | 352 | $relation_obj = $this->_model->related_settings_for($relation_name); |
353 | - if($relation_obj instanceof EE_Belongs_To_Relation){ |
|
353 | + if ($relation_obj instanceof EE_Belongs_To_Relation) { |
|
354 | 354 | //there is just a foreign key on this model pointing to that one |
355 | 355 | $this->_model_object->_add_relation_to($this->get_input_value($relation_name), $relation_name); |
356 | - }elseif($relation_obj instanceof EE_Has_Many_Relation){ |
|
356 | + }elseif ($relation_obj instanceof EE_Has_Many_Relation) { |
|
357 | 357 | //then we want to consider all of its currently-related things. |
358 | 358 | //if they're in this list, keep them |
359 | 359 | //if they're not in this list, remove them |
360 | 360 | //and lastly add all the new items |
361 | 361 | throw new EE_Error(sprintf(__('Automatic saving of related info across a "has many" relation is not yet supported', "event_espresso"))); |
362 | - }elseif($relation_obj instanceof EE_HABTM_Relation){ |
|
362 | + }elseif ($relation_obj instanceof EE_HABTM_Relation) { |
|
363 | 363 | //delete everything NOT in this list |
364 | 364 | $normalized_input_value = $this->get_input_value($relation_name); |
365 | - if($normalized_input_value && is_array($normalized_input_value)){ |
|
365 | + if ($normalized_input_value && is_array($normalized_input_value)) { |
|
366 | 366 | $where_query_params = array( |
367 | - $relation_obj->get_other_model()->primary_key_name() => array('NOT_IN',$normalized_input_value)); |
|
368 | - }else{ |
|
367 | + $relation_obj->get_other_model()->primary_key_name() => array('NOT_IN', $normalized_input_value)); |
|
368 | + } else { |
|
369 | 369 | $where_query_params = array(); |
370 | 370 | } |
371 | - $this->_model_object->_remove_relations( $relation_name, $where_query_params ); |
|
372 | - foreach($normalized_input_value as $id){ |
|
373 | - $this->_model_object->_add_relation_to( $id, $relation_name ); |
|
371 | + $this->_model_object->_remove_relations($relation_name, $where_query_params); |
|
372 | + foreach ($normalized_input_value as $id) { |
|
373 | + $this->_model_object->_add_relation_to($id, $relation_name); |
|
374 | 374 | } |
375 | 375 | } |
376 | 376 | return TRUE; |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | * Gets the model of this model form |
383 | 383 | * @return EEM_Base |
384 | 384 | */ |
385 | - public function get_model(){ |
|
385 | + public function get_model() { |
|
386 | 386 | return $this->_model; |
387 | 387 | } |
388 | 388 | |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | * when receive_form_submission($req_data) was called. |
396 | 396 | * @return EE_Base_Class |
397 | 397 | */ |
398 | - public function get_model_object(){ |
|
398 | + public function get_model_object() { |
|
399 | 399 | return $this->_model_object; |
400 | 400 | } |
401 | 401 | |
@@ -405,10 +405,10 @@ discard block |
||
405 | 405 | * gets teh default name of this form section if none is specified |
406 | 406 | * @return string |
407 | 407 | */ |
408 | - protected function _set_default_name_if_empty(){ |
|
409 | - if( ! $this->_name ){ |
|
410 | - $default_name = str_replace("EEM_", "", get_class($this->_model)) . "_Model_Form"; |
|
411 | - $this->_name = $default_name; |
|
408 | + protected function _set_default_name_if_empty() { |
|
409 | + if ( ! $this->_name) { |
|
410 | + $default_name = str_replace("EEM_", "", get_class($this->_model))."_Model_Form"; |
|
411 | + $this->_name = $default_name; |
|
412 | 412 | } |
413 | 413 | } |
414 | 414 |
@@ -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,17 +179,17 @@ 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 ){ |
|
191 | - $template_args = isset( $config[ 'template_args' ] ) ? $config[ 'template_args' ] : array(); |
|
192 | - $template_args[ 'admin_page_obj' ] = $this; |
|
190 | + foreach ($payment_method_type->help_tabs_config() as $help_tab_name => $config) { |
|
191 | + $template_args = isset($config['template_args']) ? $config['template_args'] : array(); |
|
192 | + $template_args['admin_page_obj'] = $this; |
|
193 | 193 | $all_pmt_help_tabs_config[$help_tab_name] = array( |
194 | 194 | 'title'=>$config['title'], |
195 | 195 | 'content'=>EEH_Template::display_template( |
@@ -216,9 +216,9 @@ discard block |
||
216 | 216 | |
217 | 217 | |
218 | 218 | public function load_scripts_styles() { |
219 | - wp_enqueue_script( 'ee_admin_js' ); |
|
220 | - wp_enqueue_script( 'ee-text-links' ); |
|
221 | - wp_enqueue_script( 'espresso_payments', EE_PAYMENTS_ASSETS_URL . 'espresso_payments_admin.js', array( 'espresso-ui-theme', 'ee-datepicker' ), EVENT_ESPRESSO_VERSION, TRUE ); |
|
219 | + wp_enqueue_script('ee_admin_js'); |
|
220 | + wp_enqueue_script('ee-text-links'); |
|
221 | + wp_enqueue_script('espresso_payments', EE_PAYMENTS_ASSETS_URL.'espresso_payments_admin.js', array('espresso-ui-theme', 'ee-datepicker'), EVENT_ESPRESSO_VERSION, TRUE); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | |
@@ -227,9 +227,9 @@ discard block |
||
227 | 227 | |
228 | 228 | public function load_scripts_styles_default() { |
229 | 229 | //styles |
230 | - wp_register_style( 'espresso_payments', EE_PAYMENTS_ASSETS_URL . 'ee-payments.css', array(), EVENT_ESPRESSO_VERSION ); |
|
231 | - wp_enqueue_style( 'espresso_payments' ); |
|
232 | - wp_enqueue_style( 'ee-text-links' ); |
|
230 | + wp_register_style('espresso_payments', EE_PAYMENTS_ASSETS_URL.'ee-payments.css', array(), EVENT_ESPRESSO_VERSION); |
|
231 | + wp_enqueue_style('espresso_payments'); |
|
232 | + wp_enqueue_style('ee-text-links'); |
|
233 | 233 | //scripts |
234 | 234 | } |
235 | 235 | |
@@ -243,44 +243,44 @@ discard block |
||
243 | 243 | * to the loading process. However, people MUST setup the details for the payment method so its safe to do a |
244 | 244 | * recheck here. |
245 | 245 | */ |
246 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
246 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
247 | 247 | EEM_Payment_Method::instance()->verify_button_urls(); |
248 | 248 | //setup tabs, one for each payment method type |
249 | 249 | $tabs = array(); |
250 | 250 | $payment_methods = array(); |
251 | - foreach( EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj ) { |
|
251 | + foreach (EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj) { |
|
252 | 252 | // we don't want to show admin-only PMTs for now |
253 | - if ( $pmt_obj instanceof EE_PMT_Admin_Only ) { |
|
253 | + if ($pmt_obj instanceof EE_PMT_Admin_Only) { |
|
254 | 254 | continue; |
255 | 255 | } |
256 | 256 | //check access |
257 | - if ( ! EE_Registry::instance()->CAP->current_user_can( $pmt_obj->cap_name(), 'specific_payment_method_type_access' ) ) { |
|
257 | + if ( ! EE_Registry::instance()->CAP->current_user_can($pmt_obj->cap_name(), 'specific_payment_method_type_access')) { |
|
258 | 258 | continue; |
259 | 259 | } |
260 | 260 | //check for any active pms of that type |
261 | - $payment_method = EEM_Payment_Method::instance()->get_one_of_type( $pmt_obj->system_name() ); |
|
262 | - if ( ! $payment_method instanceof EE_Payment_Method ) { |
|
261 | + $payment_method = EEM_Payment_Method::instance()->get_one_of_type($pmt_obj->system_name()); |
|
262 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
263 | 263 | $payment_method = EE_Payment_Method::new_instance( |
264 | 264 | array( |
265 | - 'PMD_slug' =>sanitize_key( $pmt_obj->system_name() ), |
|
265 | + 'PMD_slug' =>sanitize_key($pmt_obj->system_name()), |
|
266 | 266 | 'PMD_type' =>$pmt_obj->system_name(), |
267 | 267 | 'PMD_name' =>$pmt_obj->pretty_name(), |
268 | 268 | 'PMD_admin_name' =>$pmt_obj->pretty_name() |
269 | 269 | ) |
270 | 270 | ); |
271 | 271 | } |
272 | - $payment_methods[ $payment_method->slug() ] = $payment_method; |
|
272 | + $payment_methods[$payment_method->slug()] = $payment_method; |
|
273 | 273 | } |
274 | - $payment_methods = apply_filters( 'FHEE__Payments_Admin_Page___payment_methods_list__payment_methods', $payment_methods ); |
|
275 | - foreach( $payment_methods as $payment_method ) { |
|
276 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
274 | + $payment_methods = apply_filters('FHEE__Payments_Admin_Page___payment_methods_list__payment_methods', $payment_methods); |
|
275 | + foreach ($payment_methods as $payment_method) { |
|
276 | + if ($payment_method instanceof EE_Payment_Method) { |
|
277 | 277 | add_meta_box( |
278 | 278 | //html id |
279 | - 'espresso_' . $payment_method->slug() . '_payment_settings', |
|
279 | + 'espresso_'.$payment_method->slug().'_payment_settings', |
|
280 | 280 | //title |
281 | - sprintf( __( '%s Settings', 'event_espresso' ), $payment_method->admin_name() ), |
|
281 | + sprintf(__('%s Settings', 'event_espresso'), $payment_method->admin_name()), |
|
282 | 282 | //callback |
283 | - array( $this, 'payment_method_settings_meta_box' ), |
|
283 | + array($this, 'payment_method_settings_meta_box'), |
|
284 | 284 | //post type |
285 | 285 | null, |
286 | 286 | //context |
@@ -288,19 +288,19 @@ discard block |
||
288 | 288 | //priority |
289 | 289 | 'default', |
290 | 290 | //callback args |
291 | - array( 'payment_method' => $payment_method ) |
|
291 | + array('payment_method' => $payment_method) |
|
292 | 292 | ); |
293 | 293 | //setup for tabbed content |
294 | - $tabs[ $payment_method->slug() ] = array( |
|
294 | + $tabs[$payment_method->slug()] = array( |
|
295 | 295 | 'label' => $payment_method->admin_name(), |
296 | 296 | 'class' => $payment_method->active() ? 'gateway-active' : '', |
297 | - 'href' => 'espresso_' . $payment_method->slug() . '_payment_settings', |
|
298 | - 'title' => __( 'Modify this Payment Method', 'event_espresso' ), |
|
297 | + 'href' => 'espresso_'.$payment_method->slug().'_payment_settings', |
|
298 | + 'title' => __('Modify this Payment Method', 'event_espresso'), |
|
299 | 299 | 'slug' => $payment_method->slug() |
300 | 300 | ); |
301 | 301 | } |
302 | 302 | } |
303 | - $this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links( $tabs, 'payment_method_links', '|', $this->_get_active_payment_method_slug() ); |
|
303 | + $this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links($tabs, 'payment_method_links', '|', $this->_get_active_payment_method_slug()); |
|
304 | 304 | $this->display_admin_page_with_sidebar(); |
305 | 305 | |
306 | 306 | } |
@@ -311,20 +311,20 @@ discard block |
||
311 | 311 | * _get_active_payment_method_slug |
312 | 312 | * @return string |
313 | 313 | */ |
314 | - protected function _get_active_payment_method_slug(){ |
|
314 | + protected function _get_active_payment_method_slug() { |
|
315 | 315 | $payment_method_slug = FALSE; |
316 | 316 | //decide which payment method tab to open first, as dictated by the request's 'payment_method' |
317 | - if ( isset( $this->_req_data['payment_method'] )) { |
|
317 | + if (isset($this->_req_data['payment_method'])) { |
|
318 | 318 | // if they provided the current payment method, use it |
319 | - $payment_method_slug = sanitize_key( $this->_req_data['payment_method'] ); |
|
319 | + $payment_method_slug = sanitize_key($this->_req_data['payment_method']); |
|
320 | 320 | } |
321 | - $payment_method = EEM_Payment_Method::instance()->get_one( array( array( 'PMD_slug' => $payment_method_slug ))); |
|
321 | + $payment_method = EEM_Payment_Method::instance()->get_one(array(array('PMD_slug' => $payment_method_slug))); |
|
322 | 322 | // if that didn't work or wasn't provided, find another way to select the current pm |
323 | - if ( ! $this->_verify_payment_method( $payment_method )) { |
|
323 | + if ( ! $this->_verify_payment_method($payment_method)) { |
|
324 | 324 | // like, looking for an active one |
325 | - $payment_method = EEM_Payment_Method::instance()->get_one_active( 'CART' ); |
|
325 | + $payment_method = EEM_Payment_Method::instance()->get_one_active('CART'); |
|
326 | 326 | // test that one as well |
327 | - if ( $this->_verify_payment_method( $payment_method )) { |
|
327 | + if ($this->_verify_payment_method($payment_method)) { |
|
328 | 328 | $payment_method_slug = $payment_method->slug(); |
329 | 329 | } else { |
330 | 330 | $payment_method_slug = 'paypal_standard'; |
@@ -342,11 +342,11 @@ discard block |
||
342 | 342 | * @param \EE_Payment_Method $payment_method |
343 | 343 | * @return boolean |
344 | 344 | */ |
345 | - protected function _verify_payment_method( $payment_method ){ |
|
345 | + protected function _verify_payment_method($payment_method) { |
|
346 | 346 | if ( |
347 | 347 | $payment_method instanceof EE_Payment_Method && |
348 | 348 | $payment_method->type_obj() instanceof EE_PMT_Base && |
349 | - EE_Registry::instance()->CAP->current_user_can( $payment_method->type_obj()->cap_name(), 'specific_payment_method_type_access' ) |
|
349 | + EE_Registry::instance()->CAP->current_user_can($payment_method->type_obj()->cap_name(), 'specific_payment_method_type_access') |
|
350 | 350 | ) { |
351 | 351 | return TRUE; |
352 | 352 | } |
@@ -363,21 +363,21 @@ discard block |
||
363 | 363 | * @return string |
364 | 364 | * @throws EE_Error |
365 | 365 | */ |
366 | - public function payment_method_settings_meta_box( $post_obj_which_is_null, $metabox ){ |
|
367 | - $payment_method = isset( $metabox['args'], $metabox['args']['payment_method'] ) ? $metabox['args']['payment_method'] : NULL; |
|
368 | - if ( ! $payment_method instanceof EE_Payment_Method ){ |
|
369 | - throw new EE_Error( sprintf( __( 'Payment method metabox setup incorrectly. No Payment method object was supplied', 'event_espresso' ))); |
|
366 | + public function payment_method_settings_meta_box($post_obj_which_is_null, $metabox) { |
|
367 | + $payment_method = isset($metabox['args'], $metabox['args']['payment_method']) ? $metabox['args']['payment_method'] : NULL; |
|
368 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
369 | + throw new EE_Error(sprintf(__('Payment method metabox setup incorrectly. No Payment method object was supplied', 'event_espresso'))); |
|
370 | 370 | } |
371 | 371 | $payment_method_scopes = $payment_method->active(); |
372 | 372 | // if the payment method really exists show its form, otherwise the activation template |
373 | - if ( $payment_method->ID() && ! empty( $payment_method_scopes )) { |
|
374 | - $form = $this->_generate_payment_method_settings_form( $payment_method ); |
|
375 | - if ( $form->form_data_present_in( $this->_req_data )) { |
|
376 | - $form->receive_form_submission( $this->_req_data ); |
|
373 | + if ($payment_method->ID() && ! empty($payment_method_scopes)) { |
|
374 | + $form = $this->_generate_payment_method_settings_form($payment_method); |
|
375 | + if ($form->form_data_present_in($this->_req_data)) { |
|
376 | + $form->receive_form_submission($this->_req_data); |
|
377 | 377 | } |
378 | - echo $form->form_open() . $form->get_html_and_js() . $form->form_close(); |
|
378 | + echo $form->form_open().$form->get_html_and_js().$form->form_close(); |
|
379 | 379 | } else { |
380 | - echo $this->_activate_payment_method_button( $payment_method )->get_html_and_js(); |
|
380 | + echo $this->_activate_payment_method_button($payment_method)->get_html_and_js(); |
|
381 | 381 | } |
382 | 382 | } |
383 | 383 | |
@@ -390,14 +390,14 @@ discard block |
||
390 | 390 | * @param \EE_Payment_Method $payment_method |
391 | 391 | * @return \EE_Form_Section_Proper |
392 | 392 | */ |
393 | - protected function _generate_payment_method_settings_form( EE_Payment_Method $payment_method ) { |
|
394 | - if ( ! $payment_method instanceof EE_Payment_Method ){ |
|
393 | + protected function _generate_payment_method_settings_form(EE_Payment_Method $payment_method) { |
|
394 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
395 | 395 | return new EE_Form_Section_Proper(); |
396 | 396 | } |
397 | 397 | return new EE_Form_Section_Proper( |
398 | 398 | array( |
399 | - 'name' => $payment_method->slug() . '_settings_form', |
|
400 | - 'html_id' => $payment_method->slug() . '_settings_form', |
|
399 | + 'name' => $payment_method->slug().'_settings_form', |
|
400 | + 'html_id' => $payment_method->slug().'_settings_form', |
|
401 | 401 | 'action' => EE_Admin_Page::add_query_args_and_nonce( |
402 | 402 | array( |
403 | 403 | 'action' => 'update_payment_method', |
@@ -409,12 +409,12 @@ discard block |
||
409 | 409 | 'subsections' => apply_filters( |
410 | 410 | 'FHEE__Payments_Admin_Page___generate_payment_method_settings_form__form_subsections', |
411 | 411 | array( |
412 | - 'pci_dss_compliance_' . $payment_method->slug() => $this->_pci_dss_compliance( $payment_method ), |
|
413 | - 'currency_support_' . $payment_method->slug() => $this->_currency_support( $payment_method ), |
|
414 | - 'payment_method_settings_' . $payment_method->slug() => $this->_payment_method_settings( $payment_method ), |
|
415 | - 'update_' . $payment_method->slug() => $this->_update_payment_method_button( $payment_method ), |
|
416 | - 'deactivate_' . $payment_method->slug() => $this->_deactivate_payment_method_button( $payment_method ), |
|
417 | - 'fine_print_' . $payment_method->slug() => $this->_fine_print() |
|
412 | + 'pci_dss_compliance_'.$payment_method->slug() => $this->_pci_dss_compliance($payment_method), |
|
413 | + 'currency_support_'.$payment_method->slug() => $this->_currency_support($payment_method), |
|
414 | + 'payment_method_settings_'.$payment_method->slug() => $this->_payment_method_settings($payment_method), |
|
415 | + 'update_'.$payment_method->slug() => $this->_update_payment_method_button($payment_method), |
|
416 | + 'deactivate_'.$payment_method->slug() => $this->_deactivate_payment_method_button($payment_method), |
|
417 | + 'fine_print_'.$payment_method->slug() => $this->_fine_print() |
|
418 | 418 | ), |
419 | 419 | $payment_method |
420 | 420 | ) |
@@ -431,19 +431,19 @@ discard block |
||
431 | 431 | * @param \EE_Payment_Method $payment_method |
432 | 432 | * @return \EE_Form_Section_Proper |
433 | 433 | */ |
434 | - protected function _pci_dss_compliance( EE_Payment_Method $payment_method ) { |
|
435 | - if ( $payment_method->type_obj()->requires_https() ) { |
|
434 | + protected function _pci_dss_compliance(EE_Payment_Method $payment_method) { |
|
435 | + if ($payment_method->type_obj()->requires_https()) { |
|
436 | 436 | return new EE_Form_Section_HTML( |
437 | 437 | EEH_HTML::tr( |
438 | 438 | EEH_HTML::th( |
439 | 439 | EEH_HTML::label( |
440 | - EEH_HTML::strong( __( 'IMPORTANT', 'event_espresso' ), '', 'important-notice' ) |
|
440 | + EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice') |
|
441 | 441 | ) |
442 | - ) . |
|
442 | + ). |
|
443 | 443 | EEH_HTML::td( |
444 | - EEH_HTML::strong( __( 'You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.', 'event_espresso' )) . |
|
445 | - EEH_HTML::br() . |
|
446 | - __( 'Learn more about ', 'event_espresso' ) . EEH_HTML::link( 'https://www.pcisecuritystandards.org/merchants/index.php', __( 'PCI DSS compliance', 'event_espresso' )) |
|
444 | + EEH_HTML::strong(__('You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.', 'event_espresso')). |
|
445 | + EEH_HTML::br(). |
|
446 | + __('Learn more about ', 'event_espresso').EEH_HTML::link('https://www.pcisecuritystandards.org/merchants/index.php', __('PCI DSS compliance', 'event_espresso')) |
|
447 | 447 | ) |
448 | 448 | ) |
449 | 449 | ); |
@@ -461,19 +461,19 @@ discard block |
||
461 | 461 | * @param \EE_Payment_Method $payment_method |
462 | 462 | * @return \EE_Form_Section_Proper |
463 | 463 | */ |
464 | - protected function _currency_support( EE_Payment_Method $payment_method ) { |
|
465 | - if ( ! $payment_method->usable_for_currency( EE_Config::instance()->currency->code )) { |
|
464 | + protected function _currency_support(EE_Payment_Method $payment_method) { |
|
465 | + if ( ! $payment_method->usable_for_currency(EE_Config::instance()->currency->code)) { |
|
466 | 466 | return new EE_Form_Section_HTML( |
467 | 467 | EEH_HTML::tr( |
468 | 468 | EEH_HTML::th( |
469 | 469 | EEH_HTML::label( |
470 | - EEH_HTML::strong( __( 'IMPORTANT', 'event_espresso' ), '', 'important-notice' ) |
|
470 | + EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice') |
|
471 | 471 | ) |
472 | - ) . |
|
472 | + ). |
|
473 | 473 | EEH_HTML::td( |
474 | 474 | EEH_HTML::strong( |
475 | 475 | sprintf( |
476 | - __( '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'), |
|
476 | + __('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'), |
|
477 | 477 | EE_Config::instance()->currency->code |
478 | 478 | ) |
479 | 479 | ) |
@@ -493,9 +493,9 @@ discard block |
||
493 | 493 | * @param \EE_Payment_Method $payment_method |
494 | 494 | * @return \EE_Form_Section_HTML |
495 | 495 | */ |
496 | - protected function _payment_method_settings( EE_Payment_Method $payment_method ) { |
|
496 | + protected function _payment_method_settings(EE_Payment_Method $payment_method) { |
|
497 | 497 | //modify the form so we only have/show fields that will be implemented for this version |
498 | - return $this->_simplify_form( $payment_method->type_obj()->settings_form(), $payment_method->name() ); |
|
498 | + return $this->_simplify_form($payment_method->type_obj()->settings_form(), $payment_method->name()); |
|
499 | 499 | } |
500 | 500 | |
501 | 501 | |
@@ -508,8 +508,8 @@ discard block |
||
508 | 508 | * @return \EE_Payment_Method_Form |
509 | 509 | * @throws \EE_Error |
510 | 510 | */ |
511 | - protected function _simplify_form( $form_section, $payment_method_name = '' ){ |
|
512 | - if ( $form_section instanceof EE_Payment_Method_Form ) { |
|
511 | + protected function _simplify_form($form_section, $payment_method_name = '') { |
|
512 | + if ($form_section instanceof EE_Payment_Method_Form) { |
|
513 | 513 | $form_section->exclude( |
514 | 514 | array( |
515 | 515 | 'PMD_type', //dont want them changing the type |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | ); |
521 | 521 | return $form_section; |
522 | 522 | } else { |
523 | - 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 )); |
|
523 | + 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)); |
|
524 | 524 | } |
525 | 525 | } |
526 | 526 | |
@@ -533,19 +533,19 @@ discard block |
||
533 | 533 | * @param \EE_Payment_Method $payment_method |
534 | 534 | * @return \EE_Form_Section_HTML |
535 | 535 | */ |
536 | - protected function _update_payment_method_button( EE_Payment_Method $payment_method ) { |
|
536 | + protected function _update_payment_method_button(EE_Payment_Method $payment_method) { |
|
537 | 537 | $update_button = new EE_Submit_Input( |
538 | 538 | array( |
539 | 539 | 'name' => 'submit', |
540 | - 'html_id' => 'save_' . $payment_method->slug() . '_settings', |
|
541 | - 'default' => sprintf( __( 'Update %s Payment Settings', 'event_espresso' ), $payment_method->admin_name() ), |
|
540 | + 'html_id' => 'save_'.$payment_method->slug().'_settings', |
|
541 | + 'default' => sprintf(__('Update %s Payment Settings', 'event_espresso'), $payment_method->admin_name()), |
|
542 | 542 | 'html_label' => EEH_HTML::nbsp() |
543 | 543 | ) |
544 | 544 | ); |
545 | 545 | return new EE_Form_Section_HTML( |
546 | - EEH_HTML::no_row( EEH_HTML::br(2) ) . |
|
546 | + EEH_HTML::no_row(EEH_HTML::br(2)). |
|
547 | 547 | EEH_HTML::tr( |
548 | - EEH_HTML::th( __( 'Update Settings', 'event_espresso') ) . |
|
548 | + EEH_HTML::th(__('Update Settings', 'event_espresso')). |
|
549 | 549 | EEH_HTML::td( |
550 | 550 | $update_button->get_html_for_input() |
551 | 551 | ) |
@@ -562,11 +562,11 @@ discard block |
||
562 | 562 | * @param \EE_Payment_Method $payment_method |
563 | 563 | * @return \EE_Form_Section_Proper |
564 | 564 | */ |
565 | - protected function _deactivate_payment_method_button( EE_Payment_Method $payment_method ) { |
|
566 | - $link_text_and_title = sprintf( __( 'Deactivate %1$s Payments?', 'event_espresso'), $payment_method->admin_name() ); |
|
565 | + protected function _deactivate_payment_method_button(EE_Payment_Method $payment_method) { |
|
566 | + $link_text_and_title = sprintf(__('Deactivate %1$s Payments?', 'event_espresso'), $payment_method->admin_name()); |
|
567 | 567 | return new EE_Form_Section_HTML( |
568 | 568 | EEH_HTML::tr( |
569 | - EEH_HTML::th( __( 'Deactivate Payment Method', 'event_espresso') ) . |
|
569 | + EEH_HTML::th(__('Deactivate Payment Method', 'event_espresso')). |
|
570 | 570 | EEH_HTML::td( |
571 | 571 | EEH_HTML::link( |
572 | 572 | EE_Admin_Page::add_query_args_and_nonce( |
@@ -578,7 +578,7 @@ discard block |
||
578 | 578 | ), |
579 | 579 | $link_text_and_title, |
580 | 580 | $link_text_and_title, |
581 | - 'deactivate_' . $payment_method->slug(), |
|
581 | + 'deactivate_'.$payment_method->slug(), |
|
582 | 582 | 'espresso-button button-secondary' |
583 | 583 | ) |
584 | 584 | ) |
@@ -594,12 +594,12 @@ discard block |
||
594 | 594 | * @param \EE_Payment_Method $payment_method |
595 | 595 | * @return \EE_Form_Section_Proper |
596 | 596 | */ |
597 | - protected function _activate_payment_method_button( EE_Payment_Method $payment_method ) { |
|
598 | - $link_text_and_title = sprintf( __( 'Activate %1$s Payment Method?', 'event_espresso'), $payment_method->admin_name() ); |
|
597 | + protected function _activate_payment_method_button(EE_Payment_Method $payment_method) { |
|
598 | + $link_text_and_title = sprintf(__('Activate %1$s Payment Method?', 'event_espresso'), $payment_method->admin_name()); |
|
599 | 599 | return new EE_Form_Section_Proper( |
600 | 600 | array( |
601 | - 'name' => 'activate_' . $payment_method->slug() . '_settings_form', |
|
602 | - 'html_id' => 'activate_' . $payment_method->slug() . '_settings_form', |
|
601 | + 'name' => 'activate_'.$payment_method->slug().'_settings_form', |
|
602 | + 'html_id' => 'activate_'.$payment_method->slug().'_settings_form', |
|
603 | 603 | 'action' => '#', |
604 | 604 | 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
605 | 605 | 'subsections' => apply_filters( |
@@ -607,17 +607,17 @@ discard block |
||
607 | 607 | array( |
608 | 608 | new EE_Form_Section_HTML( |
609 | 609 | EEH_HTML::tr( |
610 | - EEH_HTML::td( $payment_method->type_obj()->introductory_html(), |
|
610 | + EEH_HTML::td($payment_method->type_obj()->introductory_html(), |
|
611 | 611 | '', |
612 | 612 | '', |
613 | 613 | '', |
614 | 614 | 'colspan="2"' |
615 | 615 | ) |
616 | - ) . |
|
616 | + ). |
|
617 | 617 | EEH_HTML::tr( |
618 | 618 | EEH_HTML::th( |
619 | - EEH_HTML::label( __( 'Click to Activate ', 'event_espresso' )) |
|
620 | - ) . |
|
619 | + EEH_HTML::label(__('Click to Activate ', 'event_espresso')) |
|
620 | + ). |
|
621 | 621 | EEH_HTML::td( |
622 | 622 | EEH_HTML::link( |
623 | 623 | EE_Admin_Page::add_query_args_and_nonce( |
@@ -629,7 +629,7 @@ discard block |
||
629 | 629 | ), |
630 | 630 | $link_text_and_title, |
631 | 631 | $link_text_and_title, |
632 | - 'activate_' . $payment_method->slug(), |
|
632 | + 'activate_'.$payment_method->slug(), |
|
633 | 633 | 'espresso-button-green button-primary' |
634 | 634 | ) |
635 | 635 | ) |
@@ -651,9 +651,9 @@ discard block |
||
651 | 651 | protected function _fine_print() { |
652 | 652 | return new EE_Form_Section_HTML( |
653 | 653 | EEH_HTML::tr( |
654 | - EEH_HTML::th() . |
|
654 | + EEH_HTML::th(). |
|
655 | 655 | EEH_HTML::td( |
656 | - EEH_HTML::p( __( 'All fields marked with a * are required fields', 'event_espresso' ), '', 'grey-text' ) |
|
656 | + EEH_HTML::p(__('All fields marked with a * are required fields', 'event_espresso'), '', 'grey-text') |
|
657 | 657 | ) |
658 | 658 | ) |
659 | 659 | ); |
@@ -665,15 +665,15 @@ discard block |
||
665 | 665 | * Activates a payment method of that type. Mostly assuming there is only 1 of that type (or none so far) |
666 | 666 | * @global WP_User $current_user |
667 | 667 | */ |
668 | - protected function _activate_payment_method(){ |
|
669 | - if(isset($this->_req_data['payment_method_type'])){ |
|
668 | + protected function _activate_payment_method() { |
|
669 | + if (isset($this->_req_data['payment_method_type'])) { |
|
670 | 670 | $payment_method_type = sanitize_text_field($this->_req_data['payment_method_type']); |
671 | 671 | //see if one exists |
672 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
673 | - $payment_method = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( $payment_method_type ); |
|
672 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
673 | + $payment_method = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type($payment_method_type); |
|
674 | 674 | |
675 | - $this->_redirect_after_action(1, 'Payment Method', 'activated', array('action' => 'default','payment_method'=>$payment_method->slug())); |
|
676 | - }else{ |
|
675 | + $this->_redirect_after_action(1, 'Payment Method', 'activated', array('action' => 'default', 'payment_method'=>$payment_method->slug())); |
|
676 | + } else { |
|
677 | 677 | $this->_redirect_after_action(FALSE, 'Payment Method', 'activated', array('action' => 'default')); |
678 | 678 | } |
679 | 679 | } |
@@ -681,14 +681,14 @@ discard block |
||
681 | 681 | /** |
682 | 682 | * Deactivates the payment method with the specified slug, and redirects. |
683 | 683 | */ |
684 | - protected function _deactivate_payment_method(){ |
|
685 | - if(isset($this->_req_data['payment_method'])){ |
|
684 | + protected function _deactivate_payment_method() { |
|
685 | + if (isset($this->_req_data['payment_method'])) { |
|
686 | 686 | $payment_method_slug = sanitize_key($this->_req_data['payment_method']); |
687 | 687 | //deactivate it |
688 | 688 | EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
689 | - $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method( $payment_method_slug ); |
|
690 | - $this->_redirect_after_action($count_updated, 'Payment Method', 'deactivated', array('action' => 'default','payment_method'=>$payment_method_slug)); |
|
691 | - }else{ |
|
689 | + $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method($payment_method_slug); |
|
690 | + $this->_redirect_after_action($count_updated, 'Payment Method', 'deactivated', array('action' => 'default', 'payment_method'=>$payment_method_slug)); |
|
691 | + } else { |
|
692 | 692 | $this->_redirect_after_action(FALSE, 'Payment Method', 'deactivated', array('action' => 'default')); |
693 | 693 | } |
694 | 694 | } |
@@ -702,46 +702,46 @@ discard block |
||
702 | 702 | * subsequently called 'headers_sent_func' which is _payment_methods_list) |
703 | 703 | * @return void |
704 | 704 | */ |
705 | - protected function _update_payment_method(){ |
|
706 | - if( $_SERVER['REQUEST_METHOD'] == 'POST'){ |
|
705 | + protected function _update_payment_method() { |
|
706 | + if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
707 | 707 | //ok let's find which gateway form to use based on the form input |
708 | 708 | EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
709 | 709 | /** @var $correct_pmt_form_to_use EE_Payment_Method_Form */ |
710 | 710 | $correct_pmt_form_to_use = NULL; |
711 | 711 | $payment_method = NULL; |
712 | - foreach( EEM_Payment_Method::instance()->get_all() as $payment_method){ |
|
712 | + foreach (EEM_Payment_Method::instance()->get_all() as $payment_method) { |
|
713 | 713 | //get the form and simplify it, like what we do when we display it |
714 | - $pmt_form = $this->_generate_payment_method_settings_form( $payment_method ); |
|
715 | - if($pmt_form->form_data_present_in($this->_req_data)){ |
|
714 | + $pmt_form = $this->_generate_payment_method_settings_form($payment_method); |
|
715 | + if ($pmt_form->form_data_present_in($this->_req_data)) { |
|
716 | 716 | $correct_pmt_form_to_use = $pmt_form; |
717 | 717 | break; |
718 | 718 | } |
719 | 719 | } |
720 | 720 | //if we couldn't find the correct payment method type... |
721 | - if( ! $correct_pmt_form_to_use ){ |
|
721 | + if ( ! $correct_pmt_form_to_use) { |
|
722 | 722 | 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__); |
723 | 723 | $this->_redirect_after_action(FALSE, 'Payment Method', 'activated', array('action' => 'default')); |
724 | 724 | } |
725 | 725 | $correct_pmt_form_to_use->receive_form_submission($this->_req_data); |
726 | - if($correct_pmt_form_to_use->is_valid()){ |
|
727 | - $subsection_name = 'payment_method_settings_' . $payment_method->slug(); |
|
728 | - $payment_settings_subform = $correct_pmt_form_to_use->get_subsection( $subsection_name ); |
|
729 | - if( ! $payment_settings_subform instanceof EE_Payment_Method_Form ) { |
|
726 | + if ($correct_pmt_form_to_use->is_valid()) { |
|
727 | + $subsection_name = 'payment_method_settings_'.$payment_method->slug(); |
|
728 | + $payment_settings_subform = $correct_pmt_form_to_use->get_subsection($subsection_name); |
|
729 | + if ( ! $payment_settings_subform instanceof EE_Payment_Method_Form) { |
|
730 | 730 | throw new EE_Error( |
731 | 731 | sprintf( |
732 | - __( 'The payment method could not be saved because the form sections were misnamed. We expected to find %1$s, but did not.','event_espresso' ), |
|
732 | + __('The payment method could not be saved because the form sections were misnamed. We expected to find %1$s, but did not.', 'event_espresso'), |
|
733 | 733 | $subsection_name |
734 | 734 | ) |
735 | 735 | ); |
736 | 736 | } |
737 | 737 | $payment_settings_subform->save(); |
738 | 738 | /** @var $pm EE_Payment_Method */ |
739 | - $this->_redirect_after_action(TRUE, 'Payment Method', 'updated', array('action' => 'default','payment_method'=>$payment_method->slug())); |
|
740 | - }else{ |
|
739 | + $this->_redirect_after_action(TRUE, 'Payment Method', 'updated', array('action' => 'default', 'payment_method'=>$payment_method->slug())); |
|
740 | + } else { |
|
741 | 741 | EE_Error::add_error( |
742 | 742 | sprintf( |
743 | 743 | __('Payment method of type %s was not saved because there were validation errors. They have been marked in the form', 'event_espresso'), |
744 | - $payment_method instanceof EE_PMT_Base ? $payment_method->pretty_name() : __( '"(unknown)"', 'event_espresso' ) |
|
744 | + $payment_method instanceof EE_PMT_Base ? $payment_method->pretty_name() : __('"(unknown)"', 'event_espresso') |
|
745 | 745 | ), |
746 | 746 | __FILE__, |
747 | 747 | __FUNCTION__, |
@@ -758,11 +758,11 @@ discard block |
||
758 | 758 | protected function _payment_settings() { |
759 | 759 | |
760 | 760 | $this->_template_args['values'] = $this->_yes_no_values; |
761 | - $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; |
|
761 | + $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; |
|
762 | 762 | |
763 | - $this->_set_add_edit_form_tags( 'update_payment_settings' ); |
|
764 | - $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
|
765 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( EE_PAYMENTS_TEMPLATE_PATH . 'payment_settings.template.php', $this->_template_args, TRUE ); |
|
763 | + $this->_set_add_edit_form_tags('update_payment_settings'); |
|
764 | + $this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE); |
|
765 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template(EE_PAYMENTS_TEMPLATE_PATH.'payment_settings.template.php', $this->_template_args, TRUE); |
|
766 | 766 | $this->display_admin_page_with_sidebar(); |
767 | 767 | |
768 | 768 | } |
@@ -776,8 +776,8 @@ discard block |
||
776 | 776 | * @return array |
777 | 777 | */ |
778 | 778 | protected function _update_payment_settings() { |
779 | - 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; |
|
780 | - EE_Registry::instance()->CFG = apply_filters( 'FHEE__Payments_Admin_Page___update_payment_settings__CFG', EE_Registry::instance()->CFG ); |
|
779 | + 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; |
|
780 | + EE_Registry::instance()->CFG = apply_filters('FHEE__Payments_Admin_Page___update_payment_settings__CFG', EE_Registry::instance()->CFG); |
|
781 | 781 | |
782 | 782 | // $superform = new EE_Form_Section_Proper( |
783 | 783 | // array( |
@@ -797,9 +797,9 @@ discard block |
||
797 | 797 | // $this->_redirect_after_action( 0, 'settings', 'updated', array( 'action' => 'payment_settings' ) ); |
798 | 798 | // } |
799 | 799 | |
800 | - $what = __('Payment Settings','event_espresso'); |
|
801 | - $success = $this->_update_espresso_configuration( $what, EE_Registry::instance()->CFG, __FILE__, __FUNCTION__, __LINE__ ); |
|
802 | - $this->_redirect_after_action( $success, $what, __('updated','event_espresso'), array( 'action' => 'payment_settings' ) ); |
|
800 | + $what = __('Payment Settings', 'event_espresso'); |
|
801 | + $success = $this->_update_espresso_configuration($what, EE_Registry::instance()->CFG, __FILE__, __FUNCTION__, __LINE__); |
|
802 | + $this->_redirect_after_action($success, $what, __('updated', 'event_espresso'), array('action' => 'payment_settings')); |
|
803 | 803 | |
804 | 804 | } |
805 | 805 | protected function _payment_log_overview_list_table() { |
@@ -825,18 +825,18 @@ discard block |
||
825 | 825 | * @param bool $count |
826 | 826 | * @return array |
827 | 827 | */ |
828 | - public function get_payment_logs($per_page = 50, $current_page = 0, $count = false){ |
|
829 | - EE_Registry::instance()->load_model( 'Change_Log' ); |
|
828 | + public function get_payment_logs($per_page = 50, $current_page = 0, $count = false) { |
|
829 | + EE_Registry::instance()->load_model('Change_Log'); |
|
830 | 830 | //we may need to do multiple queries (joining differently), so we actually wan tan array of query params |
831 | - $query_params = array(array('LOG_type'=> EEM_Change_Log::type_gateway)); |
|
831 | + $query_params = array(array('LOG_type'=> EEM_Change_Log::type_gateway)); |
|
832 | 832 | //check if they've selected a specific payment method |
833 | - if( isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all'){ |
|
833 | + if (isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all') { |
|
834 | 834 | $query_params[0]['OR*pm_or_pay_pm'] = array('Payment.Payment_Method.PMD_ID'=>$this->_req_data['_payment_method'], |
835 | 835 | 'Payment_Method.PMD_ID'=>$this->_req_data['_payment_method']); |
836 | 836 | } |
837 | 837 | //take into account search |
838 | - if(isset($this->_req_data['s']) && $this->_req_data['s']){ |
|
839 | - $similarity_string = array('LIKE','%'.str_replace("","%",$this->_req_data['s']) .'%'); |
|
838 | + if (isset($this->_req_data['s']) && $this->_req_data['s']) { |
|
839 | + $similarity_string = array('LIKE', '%'.str_replace("", "%", $this->_req_data['s']).'%'); |
|
840 | 840 | $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_fname'] = $similarity_string; |
841 | 841 | $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_lname'] = $similarity_string; |
842 | 842 | $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_email'] = $similarity_string; |
@@ -851,48 +851,48 @@ discard block |
||
851 | 851 | $query_params[0]['OR*s']['LOG_message'] = $similarity_string; |
852 | 852 | |
853 | 853 | } |
854 | - if(isset( $this->_req_data['payment-filter-start-date'] ) && isset( $this->_req_data['payment-filter-end-date'] )){ |
|
854 | + if (isset($this->_req_data['payment-filter-start-date']) && isset($this->_req_data['payment-filter-end-date'])) { |
|
855 | 855 | //add date |
856 | - $start_date =wp_strip_all_tags( $this->_req_data['payment-filter-start-date'] ); |
|
857 | - $end_date = wp_strip_all_tags( $this->_req_data['payment-filter-end-date'] ); |
|
856 | + $start_date = wp_strip_all_tags($this->_req_data['payment-filter-start-date']); |
|
857 | + $end_date = wp_strip_all_tags($this->_req_data['payment-filter-end-date']); |
|
858 | 858 | //make sure our timestamps start and end right at the boundaries for each day |
859 | - $start_date = date( 'Y-m-d', strtotime( $start_date ) ) . ' 00:00:00'; |
|
860 | - $end_date = date( 'Y-m-d', strtotime( $end_date ) ) . ' 23:59:59'; |
|
859 | + $start_date = date('Y-m-d', strtotime($start_date)).' 00:00:00'; |
|
860 | + $end_date = date('Y-m-d', strtotime($end_date)).' 23:59:59'; |
|
861 | 861 | |
862 | 862 | //convert to timestamps |
863 | - $start_date = strtotime( $start_date ); |
|
864 | - $end_date = strtotime( $end_date ); |
|
863 | + $start_date = strtotime($start_date); |
|
864 | + $end_date = strtotime($end_date); |
|
865 | 865 | |
866 | 866 | //makes sure start date is the lowest value and vice versa |
867 | - $start_date = min( $start_date, $end_date ); |
|
868 | - $end_date = max( $start_date, $end_date ); |
|
867 | + $start_date = min($start_date, $end_date); |
|
868 | + $end_date = max($start_date, $end_date); |
|
869 | 869 | |
870 | 870 | //convert for query |
871 | - $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' ); |
|
872 | - $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' ); |
|
871 | + $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'); |
|
872 | + $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'); |
|
873 | 873 | |
874 | - $query_params[0]['LOG_time'] = array('BETWEEN',array($start_date,$end_date)); |
|
874 | + $query_params[0]['LOG_time'] = array('BETWEEN', array($start_date, $end_date)); |
|
875 | 875 | |
876 | 876 | } |
877 | - if($count){ |
|
877 | + if ($count) { |
|
878 | 878 | return EEM_Change_Log::instance()->count($query_params); |
879 | 879 | } |
880 | - if(isset($this->_req_data['order'])){ |
|
881 | - $sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'DESC'; |
|
880 | + if (isset($this->_req_data['order'])) { |
|
881 | + $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'DESC'; |
|
882 | 882 | $query_params['order_by'] = array('LOG_time' => $sort); |
883 | - }else{ |
|
883 | + } else { |
|
884 | 884 | $query_params['order_by'] = array('LOG_time' => 'DESC'); |
885 | 885 | } |
886 | - $offset = ($current_page-1)*$per_page; |
|
886 | + $offset = ($current_page - 1) * $per_page; |
|
887 | 887 | |
888 | - if( ! isset($this->_req_data['download_results'])){ |
|
889 | - $query_params['limit'] = array( $offset, $per_page ); |
|
888 | + if ( ! isset($this->_req_data['download_results'])) { |
|
889 | + $query_params['limit'] = array($offset, $per_page); |
|
890 | 890 | } |
891 | 891 | |
892 | 892 | |
893 | 893 | |
894 | 894 | //now they've requested to instead just download the file instead of viewing it. |
895 | - if(isset($this->_req_data['download_results'])){ |
|
895 | + if (isset($this->_req_data['download_results'])) { |
|
896 | 896 | $wpdb_results = EEM_Change_Log::instance()->get_all_efficiently($query_params); |
897 | 897 | header('Content-Disposition: attachment'); |
898 | 898 | header("Content-Disposition: attachment; filename=ee_payment_logs_for_".sanitize_key(site_url())); |
@@ -914,36 +914,36 @@ discard block |
||
914 | 914 | * @param EE_Change_Log $logB |
915 | 915 | * @return int |
916 | 916 | */ |
917 | - protected function _sort_logs_again($logA,$logB){ |
|
917 | + protected function _sort_logs_again($logA, $logB) { |
|
918 | 918 | $timeA = $logA->get_raw('LOG_time'); |
919 | 919 | $timeB = $logB->get_raw('LOG_time'); |
920 | - if($timeA == $timeB){ |
|
920 | + if ($timeA == $timeB) { |
|
921 | 921 | return 0; |
922 | 922 | } |
923 | 923 | $comparison = $timeA < $timeB ? -1 : 1; |
924 | - if(strtoupper($this->_sort_logs_again_direction) == 'DESC'){ |
|
924 | + if (strtoupper($this->_sort_logs_again_direction) == 'DESC') { |
|
925 | 925 | return $comparison * -1; |
926 | - }else{ |
|
926 | + } else { |
|
927 | 927 | return $comparison; |
928 | 928 | } |
929 | 929 | } |
930 | 930 | |
931 | 931 | protected function _payment_log_details() { |
932 | - EE_Registry::instance()->load_model( 'Change_Log' ); |
|
932 | + EE_Registry::instance()->load_model('Change_Log'); |
|
933 | 933 | /** @var $payment_log EE_Change_Log */ |
934 | 934 | $payment_log = EEM_Change_Log::instance()->get_one_by_ID($this->_req_data['ID']); |
935 | 935 | $payment_method = NULL; |
936 | 936 | $transaction = NULL; |
937 | - if( $payment_log instanceof EE_Change_Log ){ |
|
938 | - if( $payment_log->object() instanceof EE_Payment ){ |
|
937 | + if ($payment_log instanceof EE_Change_Log) { |
|
938 | + if ($payment_log->object() instanceof EE_Payment) { |
|
939 | 939 | $payment_method = $payment_log->object()->payment_method(); |
940 | 940 | $transaction = $payment_log->object()->transaction(); |
941 | - }elseif($payment_log->object() instanceof EE_Payment_Method){ |
|
941 | + }elseif ($payment_log->object() instanceof EE_Payment_Method) { |
|
942 | 942 | $payment_method = $payment_log->object(); |
943 | 943 | } |
944 | 944 | } |
945 | 945 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
946 | - EE_PAYMENTS_TEMPLATE_PATH . 'payment_log_details.template.php', |
|
946 | + EE_PAYMENTS_TEMPLATE_PATH.'payment_log_details.template.php', |
|
947 | 947 | array( |
948 | 948 | 'payment_log'=>$payment_log, |
949 | 949 | 'payment_method'=>$payment_method, |
@@ -1,11 +1,11 @@ discard block |
||
1 | 1 | <p> |
2 | - <strong><?php _e( 'PayPal Express Checkout', 'event_espresso' ); ?></strong> |
|
2 | + <strong><?php _e('PayPal Express Checkout', 'event_espresso'); ?></strong> |
|
3 | 3 | </p> |
4 | 4 | <p> |
5 | 5 | <?php _e('Please be sure to update the settings for the PayPal Express Checkout payment method.', 'event_espresso'); ?> |
6 | 6 | </p> |
7 | 7 | <p> |
8 | - <?php printf( __('For more information on how to get your API credentials, please view the %1$sPayPal Documentation%2$s.', 'event_espresso'), '<a target="_blank" href="https://developer.paypal.com/docs/classic/api/apiCredentials/#create-an-api-signature">', '</a>' ); ?> |
|
8 | + <?php printf(__('For more information on how to get your API credentials, please view the %1$sPayPal Documentation%2$s.', 'event_espresso'), '<a target="_blank" href="https://developer.paypal.com/docs/classic/api/apiCredentials/#create-an-api-signature">', '</a>'); ?> |
|
9 | 9 | </p> |
10 | 10 | |
11 | 11 | |
@@ -14,25 +14,25 @@ discard block |
||
14 | 14 | </p> |
15 | 15 | <ul> |
16 | 16 | <li> |
17 | - <strong><?php _e( 'API Username', 'event_espresso' ); ?></strong><br/> |
|
18 | - <?php _e( 'Your PayPal API Username.'); ?> |
|
17 | + <strong><?php _e('API Username', 'event_espresso'); ?></strong><br/> |
|
18 | + <?php _e('Your PayPal API Username.'); ?> |
|
19 | 19 | </li> |
20 | 20 | <li> |
21 | - <strong><?php _e( 'API Password', 'event_espresso' ); ?></strong><br/> |
|
22 | - <?php _e( 'Your PayPal API Password.' ); ?> |
|
21 | + <strong><?php _e('API Password', 'event_espresso'); ?></strong><br/> |
|
22 | + <?php _e('Your PayPal API Password.'); ?> |
|
23 | 23 | </li> |
24 | 24 | <li> |
25 | - <strong><?php _e( 'API Signature', 'event_espresso' ); ?></strong><br/> |
|
26 | - <?php _e( 'Your PayPal Account Signature.' ); ?> |
|
25 | + <strong><?php _e('API Signature', 'event_espresso'); ?></strong><br/> |
|
26 | + <?php _e('Your PayPal Account Signature.'); ?> |
|
27 | 27 | </li> |
28 | 28 | <li> |
29 | - <strong><?php _e( 'Request Shipping Address', 'event_espresso' ); ?></strong><br/> |
|
30 | - <?php _e( 'Indicates whether or not you require the buyer\'s shipping address on file with PayPal be a confirmed address.' ); ?> |
|
29 | + <strong><?php _e('Request Shipping Address', 'event_espresso'); ?></strong><br/> |
|
30 | + <?php _e('Indicates whether or not you require the buyer\'s shipping address on file with PayPal be a confirmed address.'); ?> |
|
31 | 31 | </li> |
32 | 32 | </ul> |
33 | 33 | <p> |
34 | - <?php printf( __('For testing please use a %1$s PaypPal Sandbox account%2$s.', 'event_espresso'), '<a target="_blank" href="https://developer.paypal.com">', '</a>' ); ?> |
|
34 | + <?php printf(__('For testing please use a %1$s PaypPal Sandbox account%2$s.', 'event_espresso'), '<a target="_blank" href="https://developer.paypal.com">', '</a>'); ?> |
|
35 | 35 | </p> |
36 | 36 | <p> |
37 | - <?php printf( __('Don\'t have PayPal? %1$sSign up for an account%2$s to get start right away.', 'event_espresso'), '<a target="_blank" href="hhttps://eventespresso.com/go/paypalstandard/">', '</a>' ); ?> |
|
37 | + <?php printf(__('Don\'t have PayPal? %1$sSign up for an account%2$s to get start right away.', 'event_espresso'), '<a target="_blank" href="hhttps://eventespresso.com/go/paypalstandard/">', '</a>'); ?> |
|
38 | 38 | </p> |
39 | 39 | \ No newline at end of file |
@@ -259,7 +259,7 @@ |
||
259 | 259 | * @param int $ID |
260 | 260 | * @param $shortcode_class |
261 | 261 | * @param $shortcode_posts |
262 | - * @param $page_for_posts |
|
262 | + * @param string $page_for_posts |
|
263 | 263 | * @param bool $update_post_shortcodes |
264 | 264 | * @return bool |
265 | 265 | */ |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | namespace EventEspresso\core\admin; |
3 | 3 | |
4 | 4 | if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
5 | - exit( 'No direct script access allowed' ); |
|
5 | + exit( 'No direct script access allowed' ); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -19,450 +19,450 @@ discard block |
||
19 | 19 | class PostShortcodeTracking |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * set_hooks_admin |
|
24 | - * |
|
25 | - * @access public |
|
26 | - */ |
|
27 | - public static function set_hooks_admin() |
|
28 | - { |
|
29 | - add_action( |
|
30 | - 'save_post', |
|
31 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'parse_post_content_on_save' ), |
|
32 | - 100, |
|
33 | - 2 |
|
34 | - ); |
|
35 | - add_action( |
|
36 | - 'delete_post', |
|
37 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'unset_post_shortcodes_on_delete' ), |
|
38 | - 100, |
|
39 | - 1 |
|
40 | - ); |
|
41 | - add_action( |
|
42 | - 'add_option_page_for_posts', |
|
43 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_initial_set' ), |
|
44 | - 100, |
|
45 | - 2 |
|
46 | - ); |
|
47 | - add_action( |
|
48 | - 'update_option', |
|
49 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_change' ), |
|
50 | - 100, |
|
51 | - 3 |
|
52 | - ); |
|
53 | - add_action( |
|
54 | - 'delete_option', |
|
55 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_delete' ), |
|
56 | - 100, |
|
57 | - 1 |
|
58 | - ); |
|
59 | - } |
|
60 | - |
|
61 | - |
|
62 | - |
|
63 | - /** |
|
64 | - * parse_post_content_on_save |
|
65 | - * any time a post is saved, we need to check for any EE shortcodes that may be embedded in the content, |
|
66 | - * and then track what posts those shortcodes are on, so that we can initialize shortcodes well before |
|
67 | - * the_content() runs. this allows us to do things like enqueue scripts for shortcodes ONLY on the pages the |
|
68 | - * shortcodes are actually used on |
|
69 | - * |
|
70 | - * @access public |
|
71 | - * @param int $post_ID |
|
72 | - * @param \WP_Post $post |
|
73 | - * @return void |
|
74 | - */ |
|
75 | - public static function parse_post_content_on_save( $post_ID, $post ) |
|
76 | - { |
|
77 | - // if the post is trashed, then let's remove our post shortcode tracking |
|
78 | - if ( $post instanceof \WP_Post && $post->post_status === 'trash' ) { |
|
79 | - PostShortcodeTracking::unset_post_shortcodes_on_delete( $post_ID ); |
|
80 | - return; |
|
81 | - } |
|
82 | - // default post types |
|
83 | - $post_types = array( 'post' => 0, 'page' => 1 ); |
|
84 | - // add CPTs |
|
85 | - $CPTs = \EE_Register_CPTs::get_CPTs(); |
|
86 | - $post_types = array_merge( $post_types, $CPTs ); |
|
87 | - // for default or CPT posts... |
|
88 | - if ( isset( $post_types[ $post->post_type ] ) ) { |
|
89 | - // post on frontpage ? |
|
90 | - $page_for_posts = \EE_Config::get_page_for_posts(); |
|
91 | - if ( $post->post_name === $page_for_posts ) { |
|
92 | - PostShortcodeTracking::set_post_shortcodes_for_posts_page( $page_for_posts ); |
|
93 | - return; |
|
94 | - } |
|
95 | - // array of shortcodes indexed by post name |
|
96 | - \EE_Registry::CFG()->core->post_shortcodes = isset( \EE_Registry::CFG()->core->post_shortcodes ) |
|
97 | - ? \EE_Registry::CFG()->core->post_shortcodes |
|
98 | - : array(); |
|
99 | - // whether to proceed with update |
|
100 | - $update_post_shortcodes = false; |
|
101 | - // empty both arrays |
|
102 | - \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ] = array(); |
|
103 | - // check that posts page is already being tracked |
|
104 | - if ( ! isset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ] ) ) { |
|
105 | - // if not, then ensure that it is properly added |
|
106 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ] = array(); |
|
107 | - } |
|
108 | - // loop thru shortcodes |
|
109 | - foreach ( \EE_Registry::instance()->shortcodes as $EES_Shortcode => $shortcode_dir ) { |
|
110 | - // convert to UPPERCASE to get actual shortcode |
|
111 | - $EES_Shortcode = strtoupper( $EES_Shortcode ); |
|
112 | - // is the shortcode in the post_content ? |
|
113 | - if ( strpos( $post->post_content, $EES_Shortcode ) !== false ) { |
|
114 | - // map shortcode to post names and post IDs |
|
115 | - \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] = $post_ID; |
|
116 | - // and add this shortcode to the tracking for the blog page |
|
117 | - PostShortcodeTracking::set_post_shortcode_for_posts_page( $page_for_posts, $EES_Shortcode, |
|
118 | - $post_ID ); |
|
119 | - $update_post_shortcodes = true; |
|
120 | - } else { |
|
121 | - // shortcode is not present in post content, so check if we were tracking it previously |
|
122 | - // stop tracking if shortcode is not used in this specific post |
|
123 | - if ( isset( \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] ) ) { |
|
124 | - unset( \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] ); |
|
125 | - $update_post_shortcodes = true; |
|
126 | - } |
|
127 | - // make sure that something is set for the shortcode posts (even though we may remove this) |
|
128 | - $shortcode_posts = isset( |
|
129 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] |
|
130 | - ) |
|
131 | - ? \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] |
|
132 | - : array(); |
|
133 | - // and stop tracking for this shortcode on the blog page if it is not used |
|
134 | - $update_post_shortcodes = PostShortcodeTracking::unset_posts_page_shortcode_for_post( |
|
135 | - $post_ID, |
|
136 | - $EES_Shortcode, |
|
137 | - $shortcode_posts, |
|
138 | - $page_for_posts, |
|
139 | - $update_post_shortcodes |
|
140 | - ) |
|
141 | - ? true |
|
142 | - : $update_post_shortcodes; |
|
143 | - } |
|
144 | - } |
|
145 | - if ( $update_post_shortcodes ) { |
|
146 | - PostShortcodeTracking::update_post_shortcodes( $page_for_posts ); |
|
147 | - } |
|
148 | - } |
|
149 | - } |
|
150 | - |
|
151 | - |
|
152 | - |
|
153 | - /** |
|
154 | - * set_post_shortcodes_for_posts_page (plz note: shortcodes is plural) |
|
155 | - * called when updating the WordPress Posts Page, |
|
156 | - * and adds shortcode tracking for the Posts Page, for all shortcodes currently tracked on individual posts |
|
157 | - * |
|
158 | - * @access protected |
|
159 | - * @param string $page_for_posts |
|
160 | - * @return void |
|
161 | - */ |
|
162 | - protected static function set_post_shortcodes_for_posts_page( $page_for_posts ) |
|
163 | - { |
|
164 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ] = array(); |
|
165 | - // loop thru shortcodes |
|
166 | - foreach ( \EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes ) { |
|
167 | - foreach ( $post_shortcodes as $EES_Shortcode => $post_ID ) { |
|
168 | - PostShortcodeTracking::set_post_shortcode_for_posts_page( $page_for_posts, $EES_Shortcode, $post_ID ); |
|
169 | - } |
|
170 | - } |
|
171 | - PostShortcodeTracking::update_post_shortcodes( $page_for_posts ); |
|
172 | - } |
|
173 | - |
|
174 | - |
|
175 | - |
|
176 | - /** |
|
177 | - * set_post_shortcode_for_posts_page (plz note: shortcode is singular) |
|
178 | - * adds Posts Page shortcode tracking for the supplied shortcode for an individual post |
|
179 | - * |
|
180 | - * @access protected |
|
181 | - * @param string $page_for_posts |
|
182 | - * @param $EES_Shortcode |
|
183 | - * @param $post_ID |
|
184 | - */ |
|
185 | - protected static function set_post_shortcode_for_posts_page( $page_for_posts, $EES_Shortcode, $post_ID ) |
|
186 | - { |
|
187 | - // critical page shortcodes that we do NOT want added to the Posts page (blog) |
|
188 | - $critical_shortcodes = \EE_Registry::CFG()->core->get_critical_pages_shortcodes_array(); |
|
189 | - // if the shortcode is NOT one of the critical page shortcodes like ESPRESSO_TXN_PAGE |
|
190 | - if ( in_array( $EES_Shortcode, $critical_shortcodes ) ) { |
|
191 | - return; |
|
192 | - } |
|
193 | - // add shortcode to "Posts page" tracking |
|
194 | - if ( isset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] ) ) { |
|
195 | - // make sure tracking is in form of an array |
|
196 | - if ( ! is_array( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] ) ) { |
|
197 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] = array( |
|
198 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] => true, |
|
199 | - ); |
|
200 | - } |
|
201 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] += array( $post_ID => true ); |
|
202 | - } else { |
|
203 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] = array( $post_ID => true ); |
|
204 | - } |
|
205 | - } |
|
206 | - |
|
207 | - |
|
208 | - |
|
209 | - /** |
|
210 | - * unset_post_shortcodes_on_delete |
|
211 | - * |
|
212 | - * @access protected |
|
213 | - * @param int $ID |
|
214 | - * @return void |
|
215 | - */ |
|
216 | - public static function unset_post_shortcodes_on_delete( $ID ) |
|
217 | - { |
|
218 | - $update_post_shortcodes = false; |
|
219 | - // post on frontpage ? |
|
220 | - $page_for_posts = \EE_Config::get_page_for_posts(); |
|
221 | - // looking for any references to this post |
|
222 | - foreach ( \EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes ) { |
|
223 | - // is this the "Posts Page" (blog) ? |
|
224 | - if ( $post_name === $page_for_posts ) { |
|
225 | - // loop thru shortcodes registered for the posts page |
|
226 | - foreach ( $post_shortcodes as $shortcode_class => $shortcode_posts ) { |
|
227 | - $update_post_shortcodes = PostShortcodeTracking::unset_posts_page_shortcode_for_post( |
|
228 | - $ID, |
|
229 | - $shortcode_class, |
|
230 | - $shortcode_posts, |
|
231 | - $page_for_posts, |
|
232 | - $update_post_shortcodes |
|
233 | - ) |
|
234 | - ? true |
|
235 | - : $update_post_shortcodes; |
|
236 | - } |
|
237 | - } else { |
|
238 | - // loop thru shortcodes registered for each page |
|
239 | - foreach ( $post_shortcodes as $shortcode_class => $post_ID ) { |
|
240 | - // if this is page is being deleted, then don't track any post shortcodes for it |
|
241 | - if ( $post_ID === $ID ) { |
|
242 | - unset( \EE_Registry::CFG()->core->post_shortcodes[ $post_name ] ); |
|
243 | - $update_post_shortcodes = true; |
|
244 | - } |
|
245 | - } |
|
246 | - } |
|
247 | - } |
|
248 | - if ( $update_post_shortcodes ) { |
|
249 | - PostShortcodeTracking::update_post_shortcodes( $page_for_posts ); |
|
250 | - } |
|
251 | - } |
|
252 | - |
|
253 | - |
|
254 | - |
|
255 | - /** |
|
256 | - * unset_post_shortcodes_on_delete |
|
257 | - * |
|
258 | - * @access protected |
|
259 | - * @param int $ID |
|
260 | - * @param $shortcode_class |
|
261 | - * @param $shortcode_posts |
|
262 | - * @param $page_for_posts |
|
263 | - * @param bool $update_post_shortcodes |
|
264 | - * @return bool |
|
265 | - */ |
|
266 | - protected static function unset_posts_page_shortcode_for_post( |
|
267 | - $ID, |
|
268 | - $shortcode_class, |
|
269 | - $shortcode_posts, |
|
270 | - $page_for_posts, |
|
271 | - $update_post_shortcodes = false |
|
272 | - ) { |
|
273 | - // make sure that an array of post IDs is being tracked for each shortcode |
|
274 | - if ( ! is_array( $shortcode_posts ) ) { |
|
275 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] = array( |
|
276 | - $shortcode_posts => true, |
|
277 | - ); |
|
278 | - $update_post_shortcodes = true; |
|
279 | - } |
|
280 | - // now if the ID of the post being deleted is in the $shortcode_posts array |
|
281 | - if ( is_array( $shortcode_posts ) && isset( $shortcode_posts[ $ID ] ) ) { |
|
282 | - unset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ][ $ID ] ); |
|
283 | - $update_post_shortcodes = true; |
|
284 | - } |
|
285 | - // if nothing is registered for that shortcode anymore, then delete the shortcode altogether |
|
286 | - if ( empty( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] ) ) { |
|
287 | - unset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] ); |
|
288 | - $update_post_shortcodes = true; |
|
289 | - } |
|
290 | - return $update_post_shortcodes; |
|
291 | - } |
|
292 | - |
|
293 | - |
|
294 | - |
|
295 | - /** |
|
296 | - * update_post_shortcodes |
|
297 | - * |
|
298 | - * @access public |
|
299 | - * @param $page_for_posts |
|
300 | - * @return void |
|
301 | - */ |
|
302 | - public static function update_post_shortcodes( $page_for_posts = '' ) |
|
303 | - { |
|
304 | - // make sure page_for_posts is set |
|
305 | - $page_for_posts = ! empty( $page_for_posts ) |
|
306 | - ? $page_for_posts |
|
307 | - : \EE_Config::get_page_for_posts(); |
|
308 | - // allow others to mess stuff up :D |
|
309 | - do_action( |
|
310 | - 'AHEE__\EventEspresso\core\admin\PostShortcodeTracking__update_post_shortcodes', |
|
311 | - \EE_Config::instance()->core->post_shortcodes, |
|
312 | - $page_for_posts |
|
313 | - ); |
|
314 | - // keep old hookpoint for now, will deprecate later |
|
315 | - do_action( |
|
316 | - 'AHEE__EE_Config__update_post_shortcodes', |
|
317 | - \EE_Config::instance()->core->post_shortcodes, |
|
318 | - $page_for_posts |
|
319 | - ); |
|
320 | - // verify that post_shortcodes is set |
|
321 | - \EE_Config::instance()->core->post_shortcodes = isset( \EE_Config::instance()->core->post_shortcodes ) |
|
322 | - && is_array( \EE_Config::instance()->core->post_shortcodes ) |
|
323 | - ? \EE_Config::instance()->core->post_shortcodes |
|
324 | - : array(); |
|
325 | - // cycle thru post_shortcodes |
|
326 | - foreach ( \EE_Config::instance()->core->post_shortcodes as $post_name => $shortcodes ) { |
|
327 | - // are there any shortcodes to track ? |
|
328 | - if ( ! empty( $shortcodes ) ) { |
|
329 | - // skip the posts page, because we want all shortcodes registered for it |
|
330 | - if ( $post_name === $page_for_posts ) { |
|
331 | - continue; |
|
332 | - } |
|
333 | - // loop thru list of tracked shortcodes |
|
334 | - foreach ( $shortcodes as $shortcode => $post_id ) { |
|
335 | - // make sure post still exists |
|
336 | - $post = get_post( $post_id ); |
|
337 | - // check that the post name matches what we have saved |
|
338 | - if ( $post && $post->post_name === $post_name ) { |
|
339 | - // if so, then break before hitting the unset below |
|
340 | - continue; |
|
341 | - } |
|
342 | - // we don't like missing posts around here >:( |
|
343 | - unset( \EE_Config::instance()->core->post_shortcodes[ $post_name ] ); |
|
344 | - } |
|
345 | - } else { |
|
346 | - // you got no shortcodes to keep track of ! |
|
347 | - unset( \EE_Config::instance()->core->post_shortcodes[ $post_name ] ); |
|
348 | - } |
|
349 | - } |
|
350 | - // critical page shortcodes that we do NOT want added to the Posts page (blog) |
|
351 | - $critical_shortcodes = \EE_Config::instance()->core->get_critical_pages_shortcodes_array(); |
|
352 | - $critical_shortcodes = array_flip( $critical_shortcodes ); |
|
353 | - foreach ( $critical_shortcodes as $critical_shortcode ) { |
|
354 | - unset( \EE_Config::instance()->core->post_shortcodes[ $page_for_posts ][ $critical_shortcode ] ); |
|
355 | - } |
|
356 | - //only show errors |
|
357 | - \EE_Config::instance()->update_espresso_config(); |
|
358 | - } |
|
359 | - |
|
360 | - |
|
361 | - |
|
362 | - /** |
|
363 | - * reset_page_for_posts_on_initial_set |
|
364 | - * if an admin is on the WP Reading Settings page and sets the option for "Posts page", |
|
365 | - * when it had previously been unset, |
|
366 | - * then we need to attribute any actively used shortcodes to the new blog page |
|
367 | - * |
|
368 | - * @access public |
|
369 | - * @param string $option |
|
370 | - * @param string $value |
|
371 | - * @return void |
|
372 | - */ |
|
373 | - public static function reset_page_for_posts_on_initial_set( $option, $value ) |
|
374 | - { |
|
375 | - PostShortcodeTracking::reset_page_for_posts_on_change( $option, '', $value ); |
|
376 | - } |
|
377 | - |
|
378 | - |
|
379 | - |
|
380 | - /** |
|
381 | - * reset_page_for_posts_on_change |
|
382 | - * if an admin is on the WP Reading Settings page and changes the option for "Posts page", |
|
383 | - * then we need to attribute any actively used shortcodes for the previous blog page to the new blog page |
|
384 | - * |
|
385 | - * @access public |
|
386 | - * @param string $option |
|
387 | - * @param string $old_value |
|
388 | - * @param string $value |
|
389 | - * @return void |
|
390 | - */ |
|
391 | - public static function reset_page_for_posts_on_change( $option, $old_value = '', $value = '' ) |
|
392 | - { |
|
393 | - if ( $option === 'page_for_posts' ) { |
|
394 | - global $wpdb; |
|
395 | - $table = $wpdb->posts; |
|
396 | - $SQL = "SELECT post_name from $table WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d"; |
|
397 | - $new_page_for_posts = $value ? $wpdb->get_var( $wpdb->prepare( $SQL, $value ) ) : 'posts'; |
|
398 | - PostShortcodeTracking::set_post_shortcodes_for_posts_page( $new_page_for_posts ); |
|
399 | - } |
|
400 | - } |
|
401 | - |
|
402 | - |
|
403 | - |
|
404 | - /** |
|
405 | - * reset_page_for_posts_on_delete |
|
406 | - * if an admin deletes a page designated as the WP "Posts page", |
|
407 | - * then we need to attribute any actively used shortcodes for that blog page to a generic 'posts' page |
|
408 | - * |
|
409 | - * @access public |
|
410 | - * @param string $option |
|
411 | - * @return void |
|
412 | - */ |
|
413 | - public static function reset_page_for_posts_on_delete( $option ) |
|
414 | - { |
|
415 | - if ( $option === 'page_for_posts' ) { |
|
416 | - PostShortcodeTracking::set_post_shortcodes_for_posts_page( 'posts' ); |
|
417 | - } |
|
418 | - } |
|
419 | - |
|
420 | - |
|
421 | - |
|
422 | - /** |
|
423 | - * @param array|string $shortcodes |
|
424 | - * @param bool $index_results if passing more than one shortcode for the $shortcodes parameter above, |
|
425 | - * then setting this to true, will return as associative array indexed by |
|
426 | - * the shortcodes. If false, then the returned array will be unindexed |
|
427 | - * @return array |
|
428 | - */ |
|
429 | - public static function get_post_ids_for_shortcode( $shortcodes, $index_results = true ) |
|
430 | - { |
|
431 | - $post_ids = array(); |
|
432 | - if ( is_array( $shortcodes ) ) { |
|
433 | - foreach ( $shortcodes as $shortcode ) { |
|
434 | - $new_post_ids = PostShortcodeTracking::get_post_ids_for_shortcode( |
|
435 | - $shortcode, |
|
436 | - $index_results |
|
437 | - ); |
|
438 | - foreach ( $new_post_ids as $new_post_id ) { |
|
439 | - if ( $index_results ) { |
|
440 | - $post_ids[ $shortcode ][ $new_post_id ] = $new_post_id; |
|
441 | - } else { |
|
442 | - $post_ids[ $new_post_id ] = $new_post_id; |
|
443 | - } |
|
444 | - } |
|
445 | - } |
|
446 | - } else { |
|
447 | - $shortcode = strtoupper( $shortcodes ); |
|
448 | - $shortcode = strpos( $shortcode, 'ESPRESSO_' ) !== 0 ? "ESPRESSO_{$shortcode}" : $shortcode; |
|
449 | - $page_for_posts = \EE_Config::get_page_for_posts(); |
|
450 | - // looking for any references to this post |
|
451 | - foreach ( \EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes ) { |
|
452 | - // if this is the "Posts Page" (blog), then skip it |
|
453 | - if ( $post_name === $page_for_posts ) { |
|
454 | - continue; |
|
455 | - } |
|
456 | - // loop thru shortcodes registered for each page, and grab post id for matches |
|
457 | - foreach ( (array) $post_shortcodes as $post_shortcode => $post_ID ) { |
|
458 | - if ( $post_shortcode === $shortcode ) { |
|
459 | - $post_ids[ $post_ID ] = $post_ID; |
|
460 | - } |
|
461 | - } |
|
462 | - } |
|
463 | - } |
|
464 | - return $post_ids; |
|
465 | - } |
|
22 | + /** |
|
23 | + * set_hooks_admin |
|
24 | + * |
|
25 | + * @access public |
|
26 | + */ |
|
27 | + public static function set_hooks_admin() |
|
28 | + { |
|
29 | + add_action( |
|
30 | + 'save_post', |
|
31 | + array( 'EventEspresso\core\admin\PostShortcodeTracking', 'parse_post_content_on_save' ), |
|
32 | + 100, |
|
33 | + 2 |
|
34 | + ); |
|
35 | + add_action( |
|
36 | + 'delete_post', |
|
37 | + array( 'EventEspresso\core\admin\PostShortcodeTracking', 'unset_post_shortcodes_on_delete' ), |
|
38 | + 100, |
|
39 | + 1 |
|
40 | + ); |
|
41 | + add_action( |
|
42 | + 'add_option_page_for_posts', |
|
43 | + array( 'EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_initial_set' ), |
|
44 | + 100, |
|
45 | + 2 |
|
46 | + ); |
|
47 | + add_action( |
|
48 | + 'update_option', |
|
49 | + array( 'EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_change' ), |
|
50 | + 100, |
|
51 | + 3 |
|
52 | + ); |
|
53 | + add_action( |
|
54 | + 'delete_option', |
|
55 | + array( 'EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_delete' ), |
|
56 | + 100, |
|
57 | + 1 |
|
58 | + ); |
|
59 | + } |
|
60 | + |
|
61 | + |
|
62 | + |
|
63 | + /** |
|
64 | + * parse_post_content_on_save |
|
65 | + * any time a post is saved, we need to check for any EE shortcodes that may be embedded in the content, |
|
66 | + * and then track what posts those shortcodes are on, so that we can initialize shortcodes well before |
|
67 | + * the_content() runs. this allows us to do things like enqueue scripts for shortcodes ONLY on the pages the |
|
68 | + * shortcodes are actually used on |
|
69 | + * |
|
70 | + * @access public |
|
71 | + * @param int $post_ID |
|
72 | + * @param \WP_Post $post |
|
73 | + * @return void |
|
74 | + */ |
|
75 | + public static function parse_post_content_on_save( $post_ID, $post ) |
|
76 | + { |
|
77 | + // if the post is trashed, then let's remove our post shortcode tracking |
|
78 | + if ( $post instanceof \WP_Post && $post->post_status === 'trash' ) { |
|
79 | + PostShortcodeTracking::unset_post_shortcodes_on_delete( $post_ID ); |
|
80 | + return; |
|
81 | + } |
|
82 | + // default post types |
|
83 | + $post_types = array( 'post' => 0, 'page' => 1 ); |
|
84 | + // add CPTs |
|
85 | + $CPTs = \EE_Register_CPTs::get_CPTs(); |
|
86 | + $post_types = array_merge( $post_types, $CPTs ); |
|
87 | + // for default or CPT posts... |
|
88 | + if ( isset( $post_types[ $post->post_type ] ) ) { |
|
89 | + // post on frontpage ? |
|
90 | + $page_for_posts = \EE_Config::get_page_for_posts(); |
|
91 | + if ( $post->post_name === $page_for_posts ) { |
|
92 | + PostShortcodeTracking::set_post_shortcodes_for_posts_page( $page_for_posts ); |
|
93 | + return; |
|
94 | + } |
|
95 | + // array of shortcodes indexed by post name |
|
96 | + \EE_Registry::CFG()->core->post_shortcodes = isset( \EE_Registry::CFG()->core->post_shortcodes ) |
|
97 | + ? \EE_Registry::CFG()->core->post_shortcodes |
|
98 | + : array(); |
|
99 | + // whether to proceed with update |
|
100 | + $update_post_shortcodes = false; |
|
101 | + // empty both arrays |
|
102 | + \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ] = array(); |
|
103 | + // check that posts page is already being tracked |
|
104 | + if ( ! isset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ] ) ) { |
|
105 | + // if not, then ensure that it is properly added |
|
106 | + \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ] = array(); |
|
107 | + } |
|
108 | + // loop thru shortcodes |
|
109 | + foreach ( \EE_Registry::instance()->shortcodes as $EES_Shortcode => $shortcode_dir ) { |
|
110 | + // convert to UPPERCASE to get actual shortcode |
|
111 | + $EES_Shortcode = strtoupper( $EES_Shortcode ); |
|
112 | + // is the shortcode in the post_content ? |
|
113 | + if ( strpos( $post->post_content, $EES_Shortcode ) !== false ) { |
|
114 | + // map shortcode to post names and post IDs |
|
115 | + \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] = $post_ID; |
|
116 | + // and add this shortcode to the tracking for the blog page |
|
117 | + PostShortcodeTracking::set_post_shortcode_for_posts_page( $page_for_posts, $EES_Shortcode, |
|
118 | + $post_ID ); |
|
119 | + $update_post_shortcodes = true; |
|
120 | + } else { |
|
121 | + // shortcode is not present in post content, so check if we were tracking it previously |
|
122 | + // stop tracking if shortcode is not used in this specific post |
|
123 | + if ( isset( \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] ) ) { |
|
124 | + unset( \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] ); |
|
125 | + $update_post_shortcodes = true; |
|
126 | + } |
|
127 | + // make sure that something is set for the shortcode posts (even though we may remove this) |
|
128 | + $shortcode_posts = isset( |
|
129 | + \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] |
|
130 | + ) |
|
131 | + ? \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] |
|
132 | + : array(); |
|
133 | + // and stop tracking for this shortcode on the blog page if it is not used |
|
134 | + $update_post_shortcodes = PostShortcodeTracking::unset_posts_page_shortcode_for_post( |
|
135 | + $post_ID, |
|
136 | + $EES_Shortcode, |
|
137 | + $shortcode_posts, |
|
138 | + $page_for_posts, |
|
139 | + $update_post_shortcodes |
|
140 | + ) |
|
141 | + ? true |
|
142 | + : $update_post_shortcodes; |
|
143 | + } |
|
144 | + } |
|
145 | + if ( $update_post_shortcodes ) { |
|
146 | + PostShortcodeTracking::update_post_shortcodes( $page_for_posts ); |
|
147 | + } |
|
148 | + } |
|
149 | + } |
|
150 | + |
|
151 | + |
|
152 | + |
|
153 | + /** |
|
154 | + * set_post_shortcodes_for_posts_page (plz note: shortcodes is plural) |
|
155 | + * called when updating the WordPress Posts Page, |
|
156 | + * and adds shortcode tracking for the Posts Page, for all shortcodes currently tracked on individual posts |
|
157 | + * |
|
158 | + * @access protected |
|
159 | + * @param string $page_for_posts |
|
160 | + * @return void |
|
161 | + */ |
|
162 | + protected static function set_post_shortcodes_for_posts_page( $page_for_posts ) |
|
163 | + { |
|
164 | + \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ] = array(); |
|
165 | + // loop thru shortcodes |
|
166 | + foreach ( \EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes ) { |
|
167 | + foreach ( $post_shortcodes as $EES_Shortcode => $post_ID ) { |
|
168 | + PostShortcodeTracking::set_post_shortcode_for_posts_page( $page_for_posts, $EES_Shortcode, $post_ID ); |
|
169 | + } |
|
170 | + } |
|
171 | + PostShortcodeTracking::update_post_shortcodes( $page_for_posts ); |
|
172 | + } |
|
173 | + |
|
174 | + |
|
175 | + |
|
176 | + /** |
|
177 | + * set_post_shortcode_for_posts_page (plz note: shortcode is singular) |
|
178 | + * adds Posts Page shortcode tracking for the supplied shortcode for an individual post |
|
179 | + * |
|
180 | + * @access protected |
|
181 | + * @param string $page_for_posts |
|
182 | + * @param $EES_Shortcode |
|
183 | + * @param $post_ID |
|
184 | + */ |
|
185 | + protected static function set_post_shortcode_for_posts_page( $page_for_posts, $EES_Shortcode, $post_ID ) |
|
186 | + { |
|
187 | + // critical page shortcodes that we do NOT want added to the Posts page (blog) |
|
188 | + $critical_shortcodes = \EE_Registry::CFG()->core->get_critical_pages_shortcodes_array(); |
|
189 | + // if the shortcode is NOT one of the critical page shortcodes like ESPRESSO_TXN_PAGE |
|
190 | + if ( in_array( $EES_Shortcode, $critical_shortcodes ) ) { |
|
191 | + return; |
|
192 | + } |
|
193 | + // add shortcode to "Posts page" tracking |
|
194 | + if ( isset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] ) ) { |
|
195 | + // make sure tracking is in form of an array |
|
196 | + if ( ! is_array( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] ) ) { |
|
197 | + \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] = array( |
|
198 | + \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] => true, |
|
199 | + ); |
|
200 | + } |
|
201 | + \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] += array( $post_ID => true ); |
|
202 | + } else { |
|
203 | + \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] = array( $post_ID => true ); |
|
204 | + } |
|
205 | + } |
|
206 | + |
|
207 | + |
|
208 | + |
|
209 | + /** |
|
210 | + * unset_post_shortcodes_on_delete |
|
211 | + * |
|
212 | + * @access protected |
|
213 | + * @param int $ID |
|
214 | + * @return void |
|
215 | + */ |
|
216 | + public static function unset_post_shortcodes_on_delete( $ID ) |
|
217 | + { |
|
218 | + $update_post_shortcodes = false; |
|
219 | + // post on frontpage ? |
|
220 | + $page_for_posts = \EE_Config::get_page_for_posts(); |
|
221 | + // looking for any references to this post |
|
222 | + foreach ( \EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes ) { |
|
223 | + // is this the "Posts Page" (blog) ? |
|
224 | + if ( $post_name === $page_for_posts ) { |
|
225 | + // loop thru shortcodes registered for the posts page |
|
226 | + foreach ( $post_shortcodes as $shortcode_class => $shortcode_posts ) { |
|
227 | + $update_post_shortcodes = PostShortcodeTracking::unset_posts_page_shortcode_for_post( |
|
228 | + $ID, |
|
229 | + $shortcode_class, |
|
230 | + $shortcode_posts, |
|
231 | + $page_for_posts, |
|
232 | + $update_post_shortcodes |
|
233 | + ) |
|
234 | + ? true |
|
235 | + : $update_post_shortcodes; |
|
236 | + } |
|
237 | + } else { |
|
238 | + // loop thru shortcodes registered for each page |
|
239 | + foreach ( $post_shortcodes as $shortcode_class => $post_ID ) { |
|
240 | + // if this is page is being deleted, then don't track any post shortcodes for it |
|
241 | + if ( $post_ID === $ID ) { |
|
242 | + unset( \EE_Registry::CFG()->core->post_shortcodes[ $post_name ] ); |
|
243 | + $update_post_shortcodes = true; |
|
244 | + } |
|
245 | + } |
|
246 | + } |
|
247 | + } |
|
248 | + if ( $update_post_shortcodes ) { |
|
249 | + PostShortcodeTracking::update_post_shortcodes( $page_for_posts ); |
|
250 | + } |
|
251 | + } |
|
252 | + |
|
253 | + |
|
254 | + |
|
255 | + /** |
|
256 | + * unset_post_shortcodes_on_delete |
|
257 | + * |
|
258 | + * @access protected |
|
259 | + * @param int $ID |
|
260 | + * @param $shortcode_class |
|
261 | + * @param $shortcode_posts |
|
262 | + * @param $page_for_posts |
|
263 | + * @param bool $update_post_shortcodes |
|
264 | + * @return bool |
|
265 | + */ |
|
266 | + protected static function unset_posts_page_shortcode_for_post( |
|
267 | + $ID, |
|
268 | + $shortcode_class, |
|
269 | + $shortcode_posts, |
|
270 | + $page_for_posts, |
|
271 | + $update_post_shortcodes = false |
|
272 | + ) { |
|
273 | + // make sure that an array of post IDs is being tracked for each shortcode |
|
274 | + if ( ! is_array( $shortcode_posts ) ) { |
|
275 | + \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] = array( |
|
276 | + $shortcode_posts => true, |
|
277 | + ); |
|
278 | + $update_post_shortcodes = true; |
|
279 | + } |
|
280 | + // now if the ID of the post being deleted is in the $shortcode_posts array |
|
281 | + if ( is_array( $shortcode_posts ) && isset( $shortcode_posts[ $ID ] ) ) { |
|
282 | + unset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ][ $ID ] ); |
|
283 | + $update_post_shortcodes = true; |
|
284 | + } |
|
285 | + // if nothing is registered for that shortcode anymore, then delete the shortcode altogether |
|
286 | + if ( empty( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] ) ) { |
|
287 | + unset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] ); |
|
288 | + $update_post_shortcodes = true; |
|
289 | + } |
|
290 | + return $update_post_shortcodes; |
|
291 | + } |
|
292 | + |
|
293 | + |
|
294 | + |
|
295 | + /** |
|
296 | + * update_post_shortcodes |
|
297 | + * |
|
298 | + * @access public |
|
299 | + * @param $page_for_posts |
|
300 | + * @return void |
|
301 | + */ |
|
302 | + public static function update_post_shortcodes( $page_for_posts = '' ) |
|
303 | + { |
|
304 | + // make sure page_for_posts is set |
|
305 | + $page_for_posts = ! empty( $page_for_posts ) |
|
306 | + ? $page_for_posts |
|
307 | + : \EE_Config::get_page_for_posts(); |
|
308 | + // allow others to mess stuff up :D |
|
309 | + do_action( |
|
310 | + 'AHEE__\EventEspresso\core\admin\PostShortcodeTracking__update_post_shortcodes', |
|
311 | + \EE_Config::instance()->core->post_shortcodes, |
|
312 | + $page_for_posts |
|
313 | + ); |
|
314 | + // keep old hookpoint for now, will deprecate later |
|
315 | + do_action( |
|
316 | + 'AHEE__EE_Config__update_post_shortcodes', |
|
317 | + \EE_Config::instance()->core->post_shortcodes, |
|
318 | + $page_for_posts |
|
319 | + ); |
|
320 | + // verify that post_shortcodes is set |
|
321 | + \EE_Config::instance()->core->post_shortcodes = isset( \EE_Config::instance()->core->post_shortcodes ) |
|
322 | + && is_array( \EE_Config::instance()->core->post_shortcodes ) |
|
323 | + ? \EE_Config::instance()->core->post_shortcodes |
|
324 | + : array(); |
|
325 | + // cycle thru post_shortcodes |
|
326 | + foreach ( \EE_Config::instance()->core->post_shortcodes as $post_name => $shortcodes ) { |
|
327 | + // are there any shortcodes to track ? |
|
328 | + if ( ! empty( $shortcodes ) ) { |
|
329 | + // skip the posts page, because we want all shortcodes registered for it |
|
330 | + if ( $post_name === $page_for_posts ) { |
|
331 | + continue; |
|
332 | + } |
|
333 | + // loop thru list of tracked shortcodes |
|
334 | + foreach ( $shortcodes as $shortcode => $post_id ) { |
|
335 | + // make sure post still exists |
|
336 | + $post = get_post( $post_id ); |
|
337 | + // check that the post name matches what we have saved |
|
338 | + if ( $post && $post->post_name === $post_name ) { |
|
339 | + // if so, then break before hitting the unset below |
|
340 | + continue; |
|
341 | + } |
|
342 | + // we don't like missing posts around here >:( |
|
343 | + unset( \EE_Config::instance()->core->post_shortcodes[ $post_name ] ); |
|
344 | + } |
|
345 | + } else { |
|
346 | + // you got no shortcodes to keep track of ! |
|
347 | + unset( \EE_Config::instance()->core->post_shortcodes[ $post_name ] ); |
|
348 | + } |
|
349 | + } |
|
350 | + // critical page shortcodes that we do NOT want added to the Posts page (blog) |
|
351 | + $critical_shortcodes = \EE_Config::instance()->core->get_critical_pages_shortcodes_array(); |
|
352 | + $critical_shortcodes = array_flip( $critical_shortcodes ); |
|
353 | + foreach ( $critical_shortcodes as $critical_shortcode ) { |
|
354 | + unset( \EE_Config::instance()->core->post_shortcodes[ $page_for_posts ][ $critical_shortcode ] ); |
|
355 | + } |
|
356 | + //only show errors |
|
357 | + \EE_Config::instance()->update_espresso_config(); |
|
358 | + } |
|
359 | + |
|
360 | + |
|
361 | + |
|
362 | + /** |
|
363 | + * reset_page_for_posts_on_initial_set |
|
364 | + * if an admin is on the WP Reading Settings page and sets the option for "Posts page", |
|
365 | + * when it had previously been unset, |
|
366 | + * then we need to attribute any actively used shortcodes to the new blog page |
|
367 | + * |
|
368 | + * @access public |
|
369 | + * @param string $option |
|
370 | + * @param string $value |
|
371 | + * @return void |
|
372 | + */ |
|
373 | + public static function reset_page_for_posts_on_initial_set( $option, $value ) |
|
374 | + { |
|
375 | + PostShortcodeTracking::reset_page_for_posts_on_change( $option, '', $value ); |
|
376 | + } |
|
377 | + |
|
378 | + |
|
379 | + |
|
380 | + /** |
|
381 | + * reset_page_for_posts_on_change |
|
382 | + * if an admin is on the WP Reading Settings page and changes the option for "Posts page", |
|
383 | + * then we need to attribute any actively used shortcodes for the previous blog page to the new blog page |
|
384 | + * |
|
385 | + * @access public |
|
386 | + * @param string $option |
|
387 | + * @param string $old_value |
|
388 | + * @param string $value |
|
389 | + * @return void |
|
390 | + */ |
|
391 | + public static function reset_page_for_posts_on_change( $option, $old_value = '', $value = '' ) |
|
392 | + { |
|
393 | + if ( $option === 'page_for_posts' ) { |
|
394 | + global $wpdb; |
|
395 | + $table = $wpdb->posts; |
|
396 | + $SQL = "SELECT post_name from $table WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d"; |
|
397 | + $new_page_for_posts = $value ? $wpdb->get_var( $wpdb->prepare( $SQL, $value ) ) : 'posts'; |
|
398 | + PostShortcodeTracking::set_post_shortcodes_for_posts_page( $new_page_for_posts ); |
|
399 | + } |
|
400 | + } |
|
401 | + |
|
402 | + |
|
403 | + |
|
404 | + /** |
|
405 | + * reset_page_for_posts_on_delete |
|
406 | + * if an admin deletes a page designated as the WP "Posts page", |
|
407 | + * then we need to attribute any actively used shortcodes for that blog page to a generic 'posts' page |
|
408 | + * |
|
409 | + * @access public |
|
410 | + * @param string $option |
|
411 | + * @return void |
|
412 | + */ |
|
413 | + public static function reset_page_for_posts_on_delete( $option ) |
|
414 | + { |
|
415 | + if ( $option === 'page_for_posts' ) { |
|
416 | + PostShortcodeTracking::set_post_shortcodes_for_posts_page( 'posts' ); |
|
417 | + } |
|
418 | + } |
|
419 | + |
|
420 | + |
|
421 | + |
|
422 | + /** |
|
423 | + * @param array|string $shortcodes |
|
424 | + * @param bool $index_results if passing more than one shortcode for the $shortcodes parameter above, |
|
425 | + * then setting this to true, will return as associative array indexed by |
|
426 | + * the shortcodes. If false, then the returned array will be unindexed |
|
427 | + * @return array |
|
428 | + */ |
|
429 | + public static function get_post_ids_for_shortcode( $shortcodes, $index_results = true ) |
|
430 | + { |
|
431 | + $post_ids = array(); |
|
432 | + if ( is_array( $shortcodes ) ) { |
|
433 | + foreach ( $shortcodes as $shortcode ) { |
|
434 | + $new_post_ids = PostShortcodeTracking::get_post_ids_for_shortcode( |
|
435 | + $shortcode, |
|
436 | + $index_results |
|
437 | + ); |
|
438 | + foreach ( $new_post_ids as $new_post_id ) { |
|
439 | + if ( $index_results ) { |
|
440 | + $post_ids[ $shortcode ][ $new_post_id ] = $new_post_id; |
|
441 | + } else { |
|
442 | + $post_ids[ $new_post_id ] = $new_post_id; |
|
443 | + } |
|
444 | + } |
|
445 | + } |
|
446 | + } else { |
|
447 | + $shortcode = strtoupper( $shortcodes ); |
|
448 | + $shortcode = strpos( $shortcode, 'ESPRESSO_' ) !== 0 ? "ESPRESSO_{$shortcode}" : $shortcode; |
|
449 | + $page_for_posts = \EE_Config::get_page_for_posts(); |
|
450 | + // looking for any references to this post |
|
451 | + foreach ( \EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes ) { |
|
452 | + // if this is the "Posts Page" (blog), then skip it |
|
453 | + if ( $post_name === $page_for_posts ) { |
|
454 | + continue; |
|
455 | + } |
|
456 | + // loop thru shortcodes registered for each page, and grab post id for matches |
|
457 | + foreach ( (array) $post_shortcodes as $post_shortcode => $post_ID ) { |
|
458 | + if ( $post_shortcode === $shortcode ) { |
|
459 | + $post_ids[ $post_ID ] = $post_ID; |
|
460 | + } |
|
461 | + } |
|
462 | + } |
|
463 | + } |
|
464 | + return $post_ids; |
|
465 | + } |
|
466 | 466 | |
467 | 467 | |
468 | 468 |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\admin; |
3 | 3 | |
4 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -28,31 +28,31 @@ discard block |
||
28 | 28 | { |
29 | 29 | add_action( |
30 | 30 | 'save_post', |
31 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'parse_post_content_on_save' ), |
|
31 | + array('EventEspresso\core\admin\PostShortcodeTracking', 'parse_post_content_on_save'), |
|
32 | 32 | 100, |
33 | 33 | 2 |
34 | 34 | ); |
35 | 35 | add_action( |
36 | 36 | 'delete_post', |
37 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'unset_post_shortcodes_on_delete' ), |
|
37 | + array('EventEspresso\core\admin\PostShortcodeTracking', 'unset_post_shortcodes_on_delete'), |
|
38 | 38 | 100, |
39 | 39 | 1 |
40 | 40 | ); |
41 | 41 | add_action( |
42 | 42 | 'add_option_page_for_posts', |
43 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_initial_set' ), |
|
43 | + array('EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_initial_set'), |
|
44 | 44 | 100, |
45 | 45 | 2 |
46 | 46 | ); |
47 | 47 | add_action( |
48 | 48 | 'update_option', |
49 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_change' ), |
|
49 | + array('EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_change'), |
|
50 | 50 | 100, |
51 | 51 | 3 |
52 | 52 | ); |
53 | 53 | add_action( |
54 | 54 | 'delete_option', |
55 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_delete' ), |
|
55 | + array('EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_delete'), |
|
56 | 56 | 100, |
57 | 57 | 1 |
58 | 58 | ); |
@@ -72,63 +72,63 @@ discard block |
||
72 | 72 | * @param \WP_Post $post |
73 | 73 | * @return void |
74 | 74 | */ |
75 | - public static function parse_post_content_on_save( $post_ID, $post ) |
|
75 | + public static function parse_post_content_on_save($post_ID, $post) |
|
76 | 76 | { |
77 | 77 | // if the post is trashed, then let's remove our post shortcode tracking |
78 | - if ( $post instanceof \WP_Post && $post->post_status === 'trash' ) { |
|
79 | - PostShortcodeTracking::unset_post_shortcodes_on_delete( $post_ID ); |
|
78 | + if ($post instanceof \WP_Post && $post->post_status === 'trash') { |
|
79 | + PostShortcodeTracking::unset_post_shortcodes_on_delete($post_ID); |
|
80 | 80 | return; |
81 | 81 | } |
82 | 82 | // default post types |
83 | - $post_types = array( 'post' => 0, 'page' => 1 ); |
|
83 | + $post_types = array('post' => 0, 'page' => 1); |
|
84 | 84 | // add CPTs |
85 | 85 | $CPTs = \EE_Register_CPTs::get_CPTs(); |
86 | - $post_types = array_merge( $post_types, $CPTs ); |
|
86 | + $post_types = array_merge($post_types, $CPTs); |
|
87 | 87 | // for default or CPT posts... |
88 | - if ( isset( $post_types[ $post->post_type ] ) ) { |
|
88 | + if (isset($post_types[$post->post_type])) { |
|
89 | 89 | // post on frontpage ? |
90 | 90 | $page_for_posts = \EE_Config::get_page_for_posts(); |
91 | - if ( $post->post_name === $page_for_posts ) { |
|
92 | - PostShortcodeTracking::set_post_shortcodes_for_posts_page( $page_for_posts ); |
|
91 | + if ($post->post_name === $page_for_posts) { |
|
92 | + PostShortcodeTracking::set_post_shortcodes_for_posts_page($page_for_posts); |
|
93 | 93 | return; |
94 | 94 | } |
95 | 95 | // array of shortcodes indexed by post name |
96 | - \EE_Registry::CFG()->core->post_shortcodes = isset( \EE_Registry::CFG()->core->post_shortcodes ) |
|
96 | + \EE_Registry::CFG()->core->post_shortcodes = isset(\EE_Registry::CFG()->core->post_shortcodes) |
|
97 | 97 | ? \EE_Registry::CFG()->core->post_shortcodes |
98 | 98 | : array(); |
99 | 99 | // whether to proceed with update |
100 | 100 | $update_post_shortcodes = false; |
101 | 101 | // empty both arrays |
102 | - \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ] = array(); |
|
102 | + \EE_Registry::CFG()->core->post_shortcodes[$post->post_name] = array(); |
|
103 | 103 | // check that posts page is already being tracked |
104 | - if ( ! isset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ] ) ) { |
|
104 | + if ( ! isset(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts])) { |
|
105 | 105 | // if not, then ensure that it is properly added |
106 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ] = array(); |
|
106 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts] = array(); |
|
107 | 107 | } |
108 | 108 | // loop thru shortcodes |
109 | - foreach ( \EE_Registry::instance()->shortcodes as $EES_Shortcode => $shortcode_dir ) { |
|
109 | + foreach (\EE_Registry::instance()->shortcodes as $EES_Shortcode => $shortcode_dir) { |
|
110 | 110 | // convert to UPPERCASE to get actual shortcode |
111 | - $EES_Shortcode = strtoupper( $EES_Shortcode ); |
|
111 | + $EES_Shortcode = strtoupper($EES_Shortcode); |
|
112 | 112 | // is the shortcode in the post_content ? |
113 | - if ( strpos( $post->post_content, $EES_Shortcode ) !== false ) { |
|
113 | + if (strpos($post->post_content, $EES_Shortcode) !== false) { |
|
114 | 114 | // map shortcode to post names and post IDs |
115 | - \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] = $post_ID; |
|
115 | + \EE_Registry::CFG()->core->post_shortcodes[$post->post_name][$EES_Shortcode] = $post_ID; |
|
116 | 116 | // and add this shortcode to the tracking for the blog page |
117 | - PostShortcodeTracking::set_post_shortcode_for_posts_page( $page_for_posts, $EES_Shortcode, |
|
118 | - $post_ID ); |
|
117 | + PostShortcodeTracking::set_post_shortcode_for_posts_page($page_for_posts, $EES_Shortcode, |
|
118 | + $post_ID); |
|
119 | 119 | $update_post_shortcodes = true; |
120 | 120 | } else { |
121 | 121 | // shortcode is not present in post content, so check if we were tracking it previously |
122 | 122 | // stop tracking if shortcode is not used in this specific post |
123 | - if ( isset( \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] ) ) { |
|
124 | - unset( \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] ); |
|
123 | + if (isset(\EE_Registry::CFG()->core->post_shortcodes[$post->post_name][$EES_Shortcode])) { |
|
124 | + unset(\EE_Registry::CFG()->core->post_shortcodes[$post->post_name][$EES_Shortcode]); |
|
125 | 125 | $update_post_shortcodes = true; |
126 | 126 | } |
127 | 127 | // make sure that something is set for the shortcode posts (even though we may remove this) |
128 | 128 | $shortcode_posts = isset( |
129 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] |
|
129 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] |
|
130 | 130 | ) |
131 | - ? \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] |
|
131 | + ? \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] |
|
132 | 132 | : array(); |
133 | 133 | // and stop tracking for this shortcode on the blog page if it is not used |
134 | 134 | $update_post_shortcodes = PostShortcodeTracking::unset_posts_page_shortcode_for_post( |
@@ -142,8 +142,8 @@ discard block |
||
142 | 142 | : $update_post_shortcodes; |
143 | 143 | } |
144 | 144 | } |
145 | - if ( $update_post_shortcodes ) { |
|
146 | - PostShortcodeTracking::update_post_shortcodes( $page_for_posts ); |
|
145 | + if ($update_post_shortcodes) { |
|
146 | + PostShortcodeTracking::update_post_shortcodes($page_for_posts); |
|
147 | 147 | } |
148 | 148 | } |
149 | 149 | } |
@@ -159,16 +159,16 @@ discard block |
||
159 | 159 | * @param string $page_for_posts |
160 | 160 | * @return void |
161 | 161 | */ |
162 | - protected static function set_post_shortcodes_for_posts_page( $page_for_posts ) |
|
162 | + protected static function set_post_shortcodes_for_posts_page($page_for_posts) |
|
163 | 163 | { |
164 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ] = array(); |
|
164 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts] = array(); |
|
165 | 165 | // loop thru shortcodes |
166 | - foreach ( \EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes ) { |
|
167 | - foreach ( $post_shortcodes as $EES_Shortcode => $post_ID ) { |
|
168 | - PostShortcodeTracking::set_post_shortcode_for_posts_page( $page_for_posts, $EES_Shortcode, $post_ID ); |
|
166 | + foreach (\EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes) { |
|
167 | + foreach ($post_shortcodes as $EES_Shortcode => $post_ID) { |
|
168 | + PostShortcodeTracking::set_post_shortcode_for_posts_page($page_for_posts, $EES_Shortcode, $post_ID); |
|
169 | 169 | } |
170 | 170 | } |
171 | - PostShortcodeTracking::update_post_shortcodes( $page_for_posts ); |
|
171 | + PostShortcodeTracking::update_post_shortcodes($page_for_posts); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | |
@@ -182,25 +182,25 @@ discard block |
||
182 | 182 | * @param $EES_Shortcode |
183 | 183 | * @param $post_ID |
184 | 184 | */ |
185 | - protected static function set_post_shortcode_for_posts_page( $page_for_posts, $EES_Shortcode, $post_ID ) |
|
185 | + protected static function set_post_shortcode_for_posts_page($page_for_posts, $EES_Shortcode, $post_ID) |
|
186 | 186 | { |
187 | 187 | // critical page shortcodes that we do NOT want added to the Posts page (blog) |
188 | 188 | $critical_shortcodes = \EE_Registry::CFG()->core->get_critical_pages_shortcodes_array(); |
189 | 189 | // if the shortcode is NOT one of the critical page shortcodes like ESPRESSO_TXN_PAGE |
190 | - if ( in_array( $EES_Shortcode, $critical_shortcodes ) ) { |
|
190 | + if (in_array($EES_Shortcode, $critical_shortcodes)) { |
|
191 | 191 | return; |
192 | 192 | } |
193 | 193 | // add shortcode to "Posts page" tracking |
194 | - if ( isset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] ) ) { |
|
194 | + if (isset(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode])) { |
|
195 | 195 | // make sure tracking is in form of an array |
196 | - if ( ! is_array( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] ) ) { |
|
197 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] = array( |
|
198 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] => true, |
|
196 | + if ( ! is_array(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode])) { |
|
197 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] = array( |
|
198 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] => true, |
|
199 | 199 | ); |
200 | 200 | } |
201 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] += array( $post_ID => true ); |
|
201 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] += array($post_ID => true); |
|
202 | 202 | } else { |
203 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] = array( $post_ID => true ); |
|
203 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] = array($post_ID => true); |
|
204 | 204 | } |
205 | 205 | } |
206 | 206 | |
@@ -213,17 +213,17 @@ discard block |
||
213 | 213 | * @param int $ID |
214 | 214 | * @return void |
215 | 215 | */ |
216 | - public static function unset_post_shortcodes_on_delete( $ID ) |
|
216 | + public static function unset_post_shortcodes_on_delete($ID) |
|
217 | 217 | { |
218 | 218 | $update_post_shortcodes = false; |
219 | 219 | // post on frontpage ? |
220 | 220 | $page_for_posts = \EE_Config::get_page_for_posts(); |
221 | 221 | // looking for any references to this post |
222 | - foreach ( \EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes ) { |
|
222 | + foreach (\EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes) { |
|
223 | 223 | // is this the "Posts Page" (blog) ? |
224 | - if ( $post_name === $page_for_posts ) { |
|
224 | + if ($post_name === $page_for_posts) { |
|
225 | 225 | // loop thru shortcodes registered for the posts page |
226 | - foreach ( $post_shortcodes as $shortcode_class => $shortcode_posts ) { |
|
226 | + foreach ($post_shortcodes as $shortcode_class => $shortcode_posts) { |
|
227 | 227 | $update_post_shortcodes = PostShortcodeTracking::unset_posts_page_shortcode_for_post( |
228 | 228 | $ID, |
229 | 229 | $shortcode_class, |
@@ -236,17 +236,17 @@ discard block |
||
236 | 236 | } |
237 | 237 | } else { |
238 | 238 | // loop thru shortcodes registered for each page |
239 | - foreach ( $post_shortcodes as $shortcode_class => $post_ID ) { |
|
239 | + foreach ($post_shortcodes as $shortcode_class => $post_ID) { |
|
240 | 240 | // if this is page is being deleted, then don't track any post shortcodes for it |
241 | - if ( $post_ID === $ID ) { |
|
242 | - unset( \EE_Registry::CFG()->core->post_shortcodes[ $post_name ] ); |
|
241 | + if ($post_ID === $ID) { |
|
242 | + unset(\EE_Registry::CFG()->core->post_shortcodes[$post_name]); |
|
243 | 243 | $update_post_shortcodes = true; |
244 | 244 | } |
245 | 245 | } |
246 | 246 | } |
247 | 247 | } |
248 | - if ( $update_post_shortcodes ) { |
|
249 | - PostShortcodeTracking::update_post_shortcodes( $page_for_posts ); |
|
248 | + if ($update_post_shortcodes) { |
|
249 | + PostShortcodeTracking::update_post_shortcodes($page_for_posts); |
|
250 | 250 | } |
251 | 251 | } |
252 | 252 | |
@@ -271,20 +271,20 @@ discard block |
||
271 | 271 | $update_post_shortcodes = false |
272 | 272 | ) { |
273 | 273 | // make sure that an array of post IDs is being tracked for each shortcode |
274 | - if ( ! is_array( $shortcode_posts ) ) { |
|
275 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] = array( |
|
274 | + if ( ! is_array($shortcode_posts)) { |
|
275 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$shortcode_class] = array( |
|
276 | 276 | $shortcode_posts => true, |
277 | 277 | ); |
278 | 278 | $update_post_shortcodes = true; |
279 | 279 | } |
280 | 280 | // now if the ID of the post being deleted is in the $shortcode_posts array |
281 | - if ( is_array( $shortcode_posts ) && isset( $shortcode_posts[ $ID ] ) ) { |
|
282 | - unset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ][ $ID ] ); |
|
281 | + if (is_array($shortcode_posts) && isset($shortcode_posts[$ID])) { |
|
282 | + unset(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$shortcode_class][$ID]); |
|
283 | 283 | $update_post_shortcodes = true; |
284 | 284 | } |
285 | 285 | // if nothing is registered for that shortcode anymore, then delete the shortcode altogether |
286 | - if ( empty( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] ) ) { |
|
287 | - unset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] ); |
|
286 | + if (empty(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$shortcode_class])) { |
|
287 | + unset(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$shortcode_class]); |
|
288 | 288 | $update_post_shortcodes = true; |
289 | 289 | } |
290 | 290 | return $update_post_shortcodes; |
@@ -299,10 +299,10 @@ discard block |
||
299 | 299 | * @param $page_for_posts |
300 | 300 | * @return void |
301 | 301 | */ |
302 | - public static function update_post_shortcodes( $page_for_posts = '' ) |
|
302 | + public static function update_post_shortcodes($page_for_posts = '') |
|
303 | 303 | { |
304 | 304 | // make sure page_for_posts is set |
305 | - $page_for_posts = ! empty( $page_for_posts ) |
|
305 | + $page_for_posts = ! empty($page_for_posts) |
|
306 | 306 | ? $page_for_posts |
307 | 307 | : \EE_Config::get_page_for_posts(); |
308 | 308 | // allow others to mess stuff up :D |
@@ -318,40 +318,40 @@ discard block |
||
318 | 318 | $page_for_posts |
319 | 319 | ); |
320 | 320 | // verify that post_shortcodes is set |
321 | - \EE_Config::instance()->core->post_shortcodes = isset( \EE_Config::instance()->core->post_shortcodes ) |
|
322 | - && is_array( \EE_Config::instance()->core->post_shortcodes ) |
|
321 | + \EE_Config::instance()->core->post_shortcodes = isset(\EE_Config::instance()->core->post_shortcodes) |
|
322 | + && is_array(\EE_Config::instance()->core->post_shortcodes) |
|
323 | 323 | ? \EE_Config::instance()->core->post_shortcodes |
324 | 324 | : array(); |
325 | 325 | // cycle thru post_shortcodes |
326 | - foreach ( \EE_Config::instance()->core->post_shortcodes as $post_name => $shortcodes ) { |
|
326 | + foreach (\EE_Config::instance()->core->post_shortcodes as $post_name => $shortcodes) { |
|
327 | 327 | // are there any shortcodes to track ? |
328 | - if ( ! empty( $shortcodes ) ) { |
|
328 | + if ( ! empty($shortcodes)) { |
|
329 | 329 | // skip the posts page, because we want all shortcodes registered for it |
330 | - if ( $post_name === $page_for_posts ) { |
|
330 | + if ($post_name === $page_for_posts) { |
|
331 | 331 | continue; |
332 | 332 | } |
333 | 333 | // loop thru list of tracked shortcodes |
334 | - foreach ( $shortcodes as $shortcode => $post_id ) { |
|
334 | + foreach ($shortcodes as $shortcode => $post_id) { |
|
335 | 335 | // make sure post still exists |
336 | - $post = get_post( $post_id ); |
|
336 | + $post = get_post($post_id); |
|
337 | 337 | // check that the post name matches what we have saved |
338 | - if ( $post && $post->post_name === $post_name ) { |
|
338 | + if ($post && $post->post_name === $post_name) { |
|
339 | 339 | // if so, then break before hitting the unset below |
340 | 340 | continue; |
341 | 341 | } |
342 | 342 | // we don't like missing posts around here >:( |
343 | - unset( \EE_Config::instance()->core->post_shortcodes[ $post_name ] ); |
|
343 | + unset(\EE_Config::instance()->core->post_shortcodes[$post_name]); |
|
344 | 344 | } |
345 | 345 | } else { |
346 | 346 | // you got no shortcodes to keep track of ! |
347 | - unset( \EE_Config::instance()->core->post_shortcodes[ $post_name ] ); |
|
347 | + unset(\EE_Config::instance()->core->post_shortcodes[$post_name]); |
|
348 | 348 | } |
349 | 349 | } |
350 | 350 | // critical page shortcodes that we do NOT want added to the Posts page (blog) |
351 | 351 | $critical_shortcodes = \EE_Config::instance()->core->get_critical_pages_shortcodes_array(); |
352 | - $critical_shortcodes = array_flip( $critical_shortcodes ); |
|
353 | - foreach ( $critical_shortcodes as $critical_shortcode ) { |
|
354 | - unset( \EE_Config::instance()->core->post_shortcodes[ $page_for_posts ][ $critical_shortcode ] ); |
|
352 | + $critical_shortcodes = array_flip($critical_shortcodes); |
|
353 | + foreach ($critical_shortcodes as $critical_shortcode) { |
|
354 | + unset(\EE_Config::instance()->core->post_shortcodes[$page_for_posts][$critical_shortcode]); |
|
355 | 355 | } |
356 | 356 | //only show errors |
357 | 357 | \EE_Config::instance()->update_espresso_config(); |
@@ -370,9 +370,9 @@ discard block |
||
370 | 370 | * @param string $value |
371 | 371 | * @return void |
372 | 372 | */ |
373 | - public static function reset_page_for_posts_on_initial_set( $option, $value ) |
|
373 | + public static function reset_page_for_posts_on_initial_set($option, $value) |
|
374 | 374 | { |
375 | - PostShortcodeTracking::reset_page_for_posts_on_change( $option, '', $value ); |
|
375 | + PostShortcodeTracking::reset_page_for_posts_on_change($option, '', $value); |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | |
@@ -388,14 +388,14 @@ discard block |
||
388 | 388 | * @param string $value |
389 | 389 | * @return void |
390 | 390 | */ |
391 | - public static function reset_page_for_posts_on_change( $option, $old_value = '', $value = '' ) |
|
391 | + public static function reset_page_for_posts_on_change($option, $old_value = '', $value = '') |
|
392 | 392 | { |
393 | - if ( $option === 'page_for_posts' ) { |
|
393 | + if ($option === 'page_for_posts') { |
|
394 | 394 | global $wpdb; |
395 | 395 | $table = $wpdb->posts; |
396 | 396 | $SQL = "SELECT post_name from $table WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d"; |
397 | - $new_page_for_posts = $value ? $wpdb->get_var( $wpdb->prepare( $SQL, $value ) ) : 'posts'; |
|
398 | - PostShortcodeTracking::set_post_shortcodes_for_posts_page( $new_page_for_posts ); |
|
397 | + $new_page_for_posts = $value ? $wpdb->get_var($wpdb->prepare($SQL, $value)) : 'posts'; |
|
398 | + PostShortcodeTracking::set_post_shortcodes_for_posts_page($new_page_for_posts); |
|
399 | 399 | } |
400 | 400 | } |
401 | 401 | |
@@ -410,10 +410,10 @@ discard block |
||
410 | 410 | * @param string $option |
411 | 411 | * @return void |
412 | 412 | */ |
413 | - public static function reset_page_for_posts_on_delete( $option ) |
|
413 | + public static function reset_page_for_posts_on_delete($option) |
|
414 | 414 | { |
415 | - if ( $option === 'page_for_posts' ) { |
|
416 | - PostShortcodeTracking::set_post_shortcodes_for_posts_page( 'posts' ); |
|
415 | + if ($option === 'page_for_posts') { |
|
416 | + PostShortcodeTracking::set_post_shortcodes_for_posts_page('posts'); |
|
417 | 417 | } |
418 | 418 | } |
419 | 419 | |
@@ -426,37 +426,37 @@ discard block |
||
426 | 426 | * the shortcodes. If false, then the returned array will be unindexed |
427 | 427 | * @return array |
428 | 428 | */ |
429 | - public static function get_post_ids_for_shortcode( $shortcodes, $index_results = true ) |
|
429 | + public static function get_post_ids_for_shortcode($shortcodes, $index_results = true) |
|
430 | 430 | { |
431 | 431 | $post_ids = array(); |
432 | - if ( is_array( $shortcodes ) ) { |
|
433 | - foreach ( $shortcodes as $shortcode ) { |
|
432 | + if (is_array($shortcodes)) { |
|
433 | + foreach ($shortcodes as $shortcode) { |
|
434 | 434 | $new_post_ids = PostShortcodeTracking::get_post_ids_for_shortcode( |
435 | 435 | $shortcode, |
436 | 436 | $index_results |
437 | 437 | ); |
438 | - foreach ( $new_post_ids as $new_post_id ) { |
|
439 | - if ( $index_results ) { |
|
440 | - $post_ids[ $shortcode ][ $new_post_id ] = $new_post_id; |
|
438 | + foreach ($new_post_ids as $new_post_id) { |
|
439 | + if ($index_results) { |
|
440 | + $post_ids[$shortcode][$new_post_id] = $new_post_id; |
|
441 | 441 | } else { |
442 | - $post_ids[ $new_post_id ] = $new_post_id; |
|
442 | + $post_ids[$new_post_id] = $new_post_id; |
|
443 | 443 | } |
444 | 444 | } |
445 | 445 | } |
446 | 446 | } else { |
447 | - $shortcode = strtoupper( $shortcodes ); |
|
448 | - $shortcode = strpos( $shortcode, 'ESPRESSO_' ) !== 0 ? "ESPRESSO_{$shortcode}" : $shortcode; |
|
447 | + $shortcode = strtoupper($shortcodes); |
|
448 | + $shortcode = strpos($shortcode, 'ESPRESSO_') !== 0 ? "ESPRESSO_{$shortcode}" : $shortcode; |
|
449 | 449 | $page_for_posts = \EE_Config::get_page_for_posts(); |
450 | 450 | // looking for any references to this post |
451 | - foreach ( \EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes ) { |
|
451 | + foreach (\EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes) { |
|
452 | 452 | // if this is the "Posts Page" (blog), then skip it |
453 | - if ( $post_name === $page_for_posts ) { |
|
453 | + if ($post_name === $page_for_posts) { |
|
454 | 454 | continue; |
455 | 455 | } |
456 | 456 | // loop thru shortcodes registered for each page, and grab post id for matches |
457 | - foreach ( (array) $post_shortcodes as $post_shortcode => $post_ID ) { |
|
458 | - if ( $post_shortcode === $shortcode ) { |
|
459 | - $post_ids[ $post_ID ] = $post_ID; |
|
457 | + foreach ((array) $post_shortcodes as $post_shortcode => $post_ID) { |
|
458 | + if ($post_shortcode === $shortcode) { |
|
459 | + $post_ids[$post_ID] = $post_ID; |
|
460 | 460 | } |
461 | 461 | } |
462 | 462 | } |