Completed
Branch master (c054b3)
by
unknown
07:25
created
espresso.php 1 patch
Indentation   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -38,138 +38,138 @@
 block discarded – undo
38 38
  * @since       4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
42
-        /**
43
-         *    espresso_duplicate_plugin_error
44
-         *    displays if more than one version of EE is activated at the same time.
45
-         */
46
-        function espresso_duplicate_plugin_error()
47
-        {
48
-            ?>
41
+	if (! function_exists('espresso_duplicate_plugin_error')) {
42
+		/**
43
+		 *    espresso_duplicate_plugin_error
44
+		 *    displays if more than one version of EE is activated at the same time.
45
+		 */
46
+		function espresso_duplicate_plugin_error()
47
+		{
48
+			?>
49 49
 <div class="error">
50 50
     <p>
51 51
         <?php
52
-                    echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                    ); ?>
52
+					echo esc_html__(
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+					); ?>
56 56
     </p>
57 57
 </div>
58 58
 <?php
59
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-        }
61
-    }
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+		}
61
+	}
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '7.4.0');
65
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '7.4.0');
65
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
 <div class="error">
75 75
     <p>
76 76
         <?php
77
-                    printf(
78
-                        esc_html__(
79
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                            'event_espresso'
81
-                        ),
82
-                        EE_MIN_PHP_VER_REQUIRED,
83
-                        PHP_VERSION,
84
-                        '<br/>',
85
-                        '<a href="https://www.php.net/downloads.php">https://php.net/downloads.php</a>'
86
-                    );
87
-        ?>
77
+					printf(
78
+						esc_html__(
79
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+							'event_espresso'
81
+						),
82
+						EE_MIN_PHP_VER_REQUIRED,
83
+						PHP_VERSION,
84
+						'<br/>',
85
+						'<a href="https://www.php.net/downloads.php">https://php.net/downloads.php</a>'
86
+					);
87
+		?>
88 88
     </p>
89 89
 </div>
90 90
 <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97 97
 
98
-        require_once __DIR__ . '/vendor/autoload.php';
98
+		require_once __DIR__ . '/vendor/autoload.php';
99 99
 
100
-        /**
101
-         * espresso_version
102
-         * Returns the plugin version
103
-         *
104
-         * @return string
105
-         */
106
-        function espresso_version(): string
107
-        {
108
-            return apply_filters('FHEE__espresso__espresso_version', '5.0.51');
109
-        }
100
+		/**
101
+		 * espresso_version
102
+		 * Returns the plugin version
103
+		 *
104
+		 * @return string
105
+		 */
106
+		function espresso_version(): string
107
+		{
108
+			return apply_filters('FHEE__espresso__espresso_version', '5.0.51');
109
+		}
110 110
 
111
-        /**
112
-         * espresso_plugin_activation
113
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
114
-         */
115
-        function espresso_plugin_activation()
116
-        {
117
-            update_option('ee_espresso_activation', true);
118
-            update_option('event-espresso-core_allow_tracking', 'no');
119
-            update_option('event-espresso-core_tracking_notice', 'hide');
120
-            // Run WP GraphQL activation callback
121
-            espressoLoadWpGraphQL();
122
-            graphql_activation_callback();
123
-        }
111
+		/**
112
+		 * espresso_plugin_activation
113
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
114
+		 */
115
+		function espresso_plugin_activation()
116
+		{
117
+			update_option('ee_espresso_activation', true);
118
+			update_option('event-espresso-core_allow_tracking', 'no');
119
+			update_option('event-espresso-core_tracking_notice', 'hide');
120
+			// Run WP GraphQL activation callback
121
+			espressoLoadWpGraphQL();
122
+			graphql_activation_callback();
123
+		}
124 124
 
125
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
125
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
126 126
 
127
-        /**
128
-         * espresso_plugin_deactivation
129
-         */
130
-        function espresso_plugin_deactivation()
131
-        {
132
-            // Run WP GraphQL deactivation callback
133
-            espressoLoadWpGraphQL();
134
-            graphql_deactivation_callback();
135
-            delete_option('event-espresso-core_allow_tracking');
136
-            delete_option('event-espresso-core_tracking_notice');
137
-        }
138
-        register_deactivation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation');
127
+		/**
128
+		 * espresso_plugin_deactivation
129
+		 */
130
+		function espresso_plugin_deactivation()
131
+		{
132
+			// Run WP GraphQL deactivation callback
133
+			espressoLoadWpGraphQL();
134
+			graphql_deactivation_callback();
135
+			delete_option('event-espresso-core_allow_tracking');
136
+			delete_option('event-espresso-core_tracking_notice');
137
+		}
138
+		register_deactivation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation');
139 139
 
140
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
141
-        bootstrap_espresso();
142
-    }
140
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
141
+		bootstrap_espresso();
142
+	}
143 143
 }
144 144
 
145 145
 if (! function_exists('espresso_deactivate_plugin')) {
146
-    /**
147
-     *    deactivate_plugin
148
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
149
-     *
150
-     * @access public
151
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
152
-     * @return    void
153
-     */
154
-    function espresso_deactivate_plugin(string $plugin_basename = '')
155
-    {
156
-        if (! function_exists('deactivate_plugins')) {
157
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
158
-        }
159
-        unset($_GET['activate'], $_REQUEST['activate']);
160
-        deactivate_plugins($plugin_basename);
161
-    }
146
+	/**
147
+	 *    deactivate_plugin
148
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
149
+	 *
150
+	 * @access public
151
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
152
+	 * @return    void
153
+	 */
154
+	function espresso_deactivate_plugin(string $plugin_basename = '')
155
+	{
156
+		if (! function_exists('deactivate_plugins')) {
157
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
158
+		}
159
+		unset($_GET['activate'], $_REQUEST['activate']);
160
+		deactivate_plugins($plugin_basename);
161
+	}
162 162
 }
163 163
 
164 164
 
165 165
 if (! function_exists('espressoLoadWpGraphQL')) {
166
-    function espressoLoadWpGraphQL()
167
-    {
168
-        if (
169
-            ! class_exists('WPGraphQL')
170
-            && is_readable(__DIR__ . '/vendor/wp-graphql/wp-graphql/wp-graphql.php')
171
-        ) {
172
-            require_once __DIR__ . '/vendor/wp-graphql/wp-graphql/wp-graphql.php';
173
-        }
174
-    }
166
+	function espressoLoadWpGraphQL()
167
+	{
168
+		if (
169
+			! class_exists('WPGraphQL')
170
+			&& is_readable(__DIR__ . '/vendor/wp-graphql/wp-graphql/wp-graphql.php')
171
+		) {
172
+			require_once __DIR__ . '/vendor/wp-graphql/wp-graphql/wp-graphql.php';
173
+		}
174
+	}
175 175
 }
Please login to merge, or discard this patch.
PaymentMethods/PayPalCommerce/api/orders/CreateOrder.php 2 patches
Indentation   +457 added lines, -457 removed lines patch added patch discarded remove patch
@@ -36,461 +36,461 @@
 block discarded – undo
36 36
  */
37 37
 class CreateOrder extends OrdersApi
38 38
 {
39
-    /**
40
-     * Line items total.
41
-     *
42
-     * @var float
43
-     */
44
-    protected float $items_total = 0.0;
45
-
46
-    /**
47
-     * Promotions total.
48
-     *
49
-     * @var float
50
-     */
51
-    protected float $promos_total = 0.0;
52
-
53
-    /**
54
-     * Tax total.
55
-     *
56
-     * @var float
57
-     */
58
-    protected float $tax_total = 0.0;
59
-
60
-    /**
61
-     * Currency.
62
-     *
63
-     * @var string
64
-     */
65
-    protected string $currency_code;
66
-
67
-    /**
68
-     * Billing info.
69
-     *
70
-     * @var array
71
-     */
72
-    protected array $billing_info;
73
-
74
-    /**
75
-     * Transaction this order is for.
76
-     *
77
-     * @var EE_Transaction
78
-     */
79
-    protected EE_Transaction     $transaction;
80
-
81
-    private FeatureFlags         $feature;
82
-
83
-    private GatewayDataFormatter $gateway_data_formatter;
84
-
85
-    private EE_Payment           $payment;
86
-
87
-
88
-    /**
89
-     * CreateOrder constructor.
90
-     *
91
-     * @param PayPalApi      $api
92
-     * @param EE_Transaction $transaction
93
-     * @param array          $billing_info
94
-     * @param FeatureFlags   $feature
95
-     */
96
-    public function __construct(
97
-        PayPalApi            $api,
98
-        EE_Transaction       $transaction,
99
-        array                $billing_info,
100
-        FeatureFlags         $feature,
101
-        GatewayDataFormatter $gateway_data_formatter
102
-    ) {
103
-        parent::__construct($api);
104
-        $this->transaction   = $transaction;
105
-        $this->feature       = $feature;
106
-        $this->currency_code = CurrencyManager::currencyCode();
107
-        $this->sanitizeRequestParameters($billing_info);
108
-        $this->gateway_data_formatter = $gateway_data_formatter;
109
-        $this->setPaymentPlaceholder();
110
-    }
111
-
112
-
113
-    /**
114
-     * Sanitize the array of billing form data.
115
-     *
116
-     * @param array $billing_info
117
-     * @return void
118
-     */
119
-    public function sanitizeRequestParameters(array $billing_info): void
120
-    {
121
-        $sanitizer = new RequestSanitizer(new Basic());
122
-        foreach ($billing_info as $item => $value) {
123
-            $this->billing_info[ $item ] = $sanitizer->clean($value);
124
-        }
125
-    }
126
-
127
-
128
-    /**
129
-     * Create PayPal Order.
130
-     *
131
-     * @return array
132
-     * @throws EE_Error
133
-     * @throws ReflectionException
134
-     */
135
-    public function create(): array
136
-    {
137
-        $order_parameters = $this->getParameters();
138
-        // Create Order request.
139
-        $create_response = $this->api->sendRequest($order_parameters, $this->request_url);
140
-        // Check for MISMATCH errors.
141
-        if ($this->isMismatchError($create_response)) {
142
-            // Mismatch, fix items.
143
-            $order_parameters['purchase_units'][0]['items'] = $this->getSimplifiedItems();
144
-            // Add simplified breakdown.
145
-            $order_parameters['purchase_units'][0]['amount']['breakdown'] = $this->getSimplifiedAmountBreakdown();
146
-            // Retry Order request.
147
-            $create_response = $this->api->sendRequest($order_parameters, $this->request_url);
148
-        }
149
-        return $this->validateOrder($create_response, $order_parameters);
150
-    }
151
-
152
-
153
-    /**
154
-     * Form order parameters.
155
-     *
156
-     * @return array
157
-     * @throws EE_Error
158
-     * @throws ReflectionException
159
-     * @throws Exception
160
-     */
161
-    protected function getParameters(): array
162
-    {
163
-        $registrant  = $this->transaction->primary_registration();
164
-        $attendee    = $registrant->attendee();
165
-        $description = $this->gateway_data_formatter->formatOrderDescription($this->payment);
166
-        $parameters  = [
167
-            'intent'         => 'CAPTURE',
168
-            'purchase_units' => [
169
-                [
170
-                    'custom_id'   => $this->transaction->ID(),
171
-                    'description' => substr(wp_strip_all_tags($description), 0, 125),
172
-                    'items'       => $this->getLineItems(),
173
-                    'amount'      => [
174
-                        'value'         => (string) CurrencyManager::normalizeValue($this->transaction->remaining()),
175
-                        'currency_code' => $this->currency_code,
176
-                        'breakdown'     => $this->getBreakdown(),
177
-                    ],
178
-                ],
179
-            ],
180
-            'payment_source' => [
181
-                'paypal' => [
182
-                    'experience_context' => [
183
-                        'user_action' => 'PAY_NOW',
184
-                    ],
185
-                    'email_address'      => $attendee->email(),
186
-                    'name'               => [
187
-                        'given_name' => $attendee->fname(),
188
-                        'surname'    => $attendee->lname(),
189
-                    ],
190
-                ],
191
-            ],
192
-        ];
193
-        $CNT_ISO     = $attendee->country_ID();
194
-
195
-        // No country ID set, maybe just state?
196
-        if (empty($CNT_ISO)) {
197
-            $state_obj = $attendee->state_obj();
198
-            if ($state_obj instanceof EE_State) {
199
-                $CNT_ISO = $state_obj->country_iso();
200
-            }
201
-        }
202
-
203
-        if (strlen($CNT_ISO > 2)) {
204
-            // uh-oh... did someone save the country name for the ISO?
205
-            $country = EEM_Country::instance()->getCountryByName(ucwords(strtolower($CNT_ISO)));
206
-            if ($country instanceof EE_Country) {
207
-                $CNT_ISO = $country->ISO();
208
-            }
209
-        }
210
-
211
-        // If we have and address on the attendee, send it to PayPal.
212
-        if ($CNT_ISO && strlen($CNT_ISO == 2)) {
213
-            $parameters['payment_source']['paypal']['address'] = [
214
-                'address_line_1' => $attendee->address(),
215
-                'address_line_2' => $attendee->address2(),
216
-                'admin_area_2'   => $attendee->city(),
217
-                'admin_area_1'   => $attendee->state_abbrev(),
218
-                'postal_code'    => $attendee->zip(),
219
-                'country_code'   => $attendee->country_ID(),
220
-            ];
221
-        }
222
-
223
-        // Do we have the permissions for the fees ?
224
-        $scopes = PayPalExtraMetaManager::getPmOption(
225
-            $this->transaction->payment_method(),
226
-            Domain::META_KEY_AUTHORIZED_SCOPES
227
-        );
228
-        if (
229
-            (
230
-                (defined('EE_PPC_USE_PAYMENT_FEES') && EE_PPC_USE_PAYMENT_FEES)
231
-                || (! defined('EE_PPC_USE_PAYMENT_FEES')
232
-                    && $this->feature->allowed(FeatureFlag::USE_PAYMENT_PROCESSOR_FEES)
233
-                )
234
-            )
235
-            && ! empty($scopes)
236
-            && in_array('partnerfee', $scopes)
237
-        ) {
238
-            /** @var PartnerPaymentFees $payment_fees */
239
-            $payment_fees = LoaderFactory::getShared(PartnerPaymentFees::class);
240
-            $parameters['purchase_units'][0]['payment_instruction'] = [
241
-                'platform_fees' => [
242
-                    [
243
-                        'amount' => [
244
-                            'value'         => (string) $payment_fees->getPartnerFee($this->transaction),
245
-                            'currency_code' => $this->currency_code,
246
-                        ],
247
-                    ],
248
-                ],
249
-            ];
250
-        }
251
-        return $parameters;
252
-    }
253
-
254
-
255
-    /**
256
-     * Itemize the payment. List all the line items, discounts and taxes.
257
-     *
258
-     * @return array
259
-     * @throws EE_Error|ReflectionException
260
-     */
261
-    protected function getLineItems(): array
262
-    {
263
-        // Order line items.
264
-        $line_items       = [];
265
-        $event_line_items = $this->transaction->items_purchased();
266
-        // List actual line items.
267
-        foreach ($event_line_items as $line_item) {
268
-            if (
269
-                $line_item instanceof EE_Line_Item
270
-                && $line_item->OBJ_type() !== 'Promotion'
271
-                && $line_item->quantity() > 0
272
-            ) {
273
-                $item_money    = CurrencyManager::normalizeValue($line_item->unit_price());
274
-                $line_items [] = [
275
-                    'name'        => substr(
276
-                        wp_strip_all_tags(
277
-                            $this->gateway_data_formatter->formatLineItemName($line_item, $this->payment)
278
-                        ),
279
-                        0,
280
-                        125
281
-                    ),
282
-                    'quantity'    => $line_item->quantity(),
283
-                    'description' => substr(
284
-                        wp_strip_all_tags(
285
-                            $this->gateway_data_formatter->formatLineItemDesc($line_item, $this->payment)
286
-                        ),
287
-                        0,
288
-                        125
289
-                    ),
290
-                    'unit_amount' => [
291
-                        'currency_code' => $this->currency_code,
292
-                        'value'         => (string) $item_money,
293
-                    ],
294
-                    'category'    => 'DIGITAL_GOODS',
295
-                ];
296
-                // Line item total.
297
-                $this->items_total += $line_item->pretaxTotal();
298
-            } elseif ($line_item->OBJ_type() === 'Promotion' && $line_item->quantity() > 0) {
299
-                // Promotions total.
300
-                $this->promos_total += $line_item->total();
301
-            }
302
-        }
303
-        // Make sure we have an absolute number with only two decimal laces.
304
-        $this->items_total  = CurrencyManager::normalizeValue($this->items_total);
305
-        $this->promos_total = CurrencyManager::normalizeValue($this->promos_total);
306
-        // If this is a partial payment, apply the paid amount as a promo.
307
-        if ($this->transaction->paid() > 0) {
308
-            $this->promos_total += CurrencyManager::normalizeValue($this->transaction->paid());
309
-        }
310
-        $this->countTaxTotal();
311
-        return $line_items;
312
-    }
313
-
314
-
315
-    /**
316
-     * Count the tax total.
317
-     *
318
-     * @return void
319
-     * @throws EE_Error|ReflectionException
320
-     */
321
-    protected function countTaxTotal(): void
322
-    {
323
-        // List taxes.
324
-        $this->tax_total = 0.0;
325
-        $tax_items       = $this->transaction->tax_items();
326
-        foreach ($tax_items as $tax_item) {
327
-            $this->tax_total += $tax_item->total();
328
-        }
329
-        $this->tax_total = CurrencyManager::normalizeValue($this->tax_total);
330
-    }
331
-
332
-
333
-    /**
334
-     * Itemize the payment the breakdown list.
335
-     *
336
-     * @return array
337
-     */
338
-    protected function getBreakdown(): array
339
-    {
340
-        $breakdown['item_total'] = [
341
-            'currency_code' => $this->currency_code,
342
-            'value'         => (string) $this->items_total,
343
-        ];
344
-        $breakdown['tax_total']  = [
345
-            'currency_code' => $this->currency_code,
346
-            'value'         => (string) $this->tax_total,
347
-        ];
348
-        $breakdown['discount']   = [
349
-            'currency_code' => $this->currency_code,
350
-            'value'         => (string) abs($this->promos_total),
351
-        ];
352
-        return $breakdown;
353
-    }
354
-
355
-
356
-    /**
357
-     * Makes sure that we have received an Order back from the API call.
358
-     *
359
-     * @param $response
360
-     * @param $parameters
361
-     * @return array
362
-     * @throws EE_Error
363
-     * @throws ReflectionException
364
-     */
365
-    public function validateOrder($response, $parameters): array
366
-    {
367
-        PayPalLogger::errorLog(
368
-            esc_html__('Validating Order Create:', 'event_espresso'),
369
-            [$this->request_url, $response],
370
-            $this->transaction->payment_method(),
371
-            false,
372
-            $this->transaction
373
-        );
374
-        if (! empty($response['error'])) {
375
-            return $response;
376
-        }
377
-        if (! isset($response['id'])) {
378
-            $message = esc_html__('Unexpected response. Unable to find the order.', 'event_espresso');
379
-            try {
380
-                PayPalLogger::errorLog(
381
-                    $message,
382
-                    [$this->request_url, $parameters, $response],
383
-                    $this->transaction->payment_method()
384
-                );
385
-            } catch (EE_Error|ReflectionException $e) {
386
-                error_log("PayPalLogger Error: $message: " . json_encode($response));
387
-            }
388
-            return [
389
-                'error'    => $response['error'] ?? 'missing_order',
390
-                'message'  => $response['message'] ?? $message,
391
-                'response' => $response,
392
-            ];
393
-        }
394
-        return $response;
395
-    }
396
-
397
-
398
-    /**
399
-     * Check if PayPals response contains 'MISMATCH' errors.
400
-     *
401
-     * @return bool
402
-     */
403
-    public function isMismatchError($response): bool
404
-    {
405
-        if (! isset($response['details']) || ! is_array($response['details'])) {
406
-            return false;
407
-        }
408
-
409
-        foreach ($response['details'] as $detail) {
410
-            if (! empty($detail['issue'])) {
411
-                if (
412
-                    strtoupper($detail['issue']) === 'ITEM_TOTAL_MISMATCH'
413
-                    || strtoupper($detail['issue']) === 'AMOUNT_MISMATCH'
414
-                ) {
415
-                    PayPalLogger::errorLog(
416
-                        esc_html__('Mistmatch Error:', 'event_espresso'),
417
-                        [$this->request_url, $response],
418
-                        $this->transaction->payment_method(),
419
-                        false,
420
-                        $this->transaction
421
-                    );
422
-                    return true;
423
-                }
424
-            }
425
-        }
426
-        return false;
427
-    }
428
-
429
-
430
-    /**
431
-     * Itemize the simplified payment breakdown list.
432
-     *
433
-     * @return array
434
-     */
435
-    protected function getSimplifiedAmountBreakdown(): array
436
-    {
437
-        $tax_total               = $this->transaction->tax_total();
438
-        $breakdown['item_total'] = [
439
-            'currency_code' => $this->currency_code,
440
-            'value'         => (string) CurrencyManager::normalizeValue($this->transaction->remaining() - $tax_total),
441
-        ];
442
-        if ($tax_total > 0) {
443
-            $breakdown['tax_total'] = [
444
-                'currency_code' => $this->currency_code,
445
-                'value'         => (string) CurrencyManager::normalizeValue($tax_total),
446
-            ];
447
-        }
448
-        return $breakdown;
449
-    }
450
-
451
-
452
-    /**
453
-     * Generate single line item for full order.
454
-     *
455
-     * @return array
456
-     */
457
-    protected function getSimplifiedItems(): array
458
-    {
459
-        // Simplified single line item.
460
-        $line_items           = [];
461
-        $primary_registrant   = $this->transaction->primary_registration();
462
-        $event_obj            = $primary_registrant->event_obj();
463
-        $name_and_description = $this->gateway_data_formatter->formatOrderDescription($this->payment);
464
-
465
-        $line_items[] = [
466
-            'name'        => substr(wp_strip_all_tags($name_and_description), 0, 125),
467
-            'quantity'    => 1,
468
-            'description' => substr(wp_strip_all_tags($name_and_description), 0, 2047),
469
-            'unit_amount' => [
470
-                'currency_code' => $this->currency_code,
471
-                'value'         => (string) CurrencyManager::normalizeValue(
472
-                    $this->transaction->remaining() - $this->transaction->tax_total()
473
-                ),
474
-            ],
475
-            'category'    => 'DIGITAL_GOODS',
476
-        ];
477
-        return $line_items;
478
-    }
479
-
480
-
481
-    /**
482
-     * Generates an EE_Payment object but doesn't save it.
483
-     */
484
-    private function setPaymentPlaceholder(): void
485
-    {
486
-        $this->payment = EE_Payment::new_instance(
487
-            [
488
-                'STS_ID'        => EEM_Payment::status_id_pending,
489
-                'TXN_ID'        => $this->transaction->ID(),
490
-                'PMD_ID'        => $this->transaction->payment_method_ID(),
491
-                'PAY_amount'    => 0.00,
492
-                'PAY_timestamp' => time(),
493
-            ]
494
-        );
495
-    }
39
+	/**
40
+	 * Line items total.
41
+	 *
42
+	 * @var float
43
+	 */
44
+	protected float $items_total = 0.0;
45
+
46
+	/**
47
+	 * Promotions total.
48
+	 *
49
+	 * @var float
50
+	 */
51
+	protected float $promos_total = 0.0;
52
+
53
+	/**
54
+	 * Tax total.
55
+	 *
56
+	 * @var float
57
+	 */
58
+	protected float $tax_total = 0.0;
59
+
60
+	/**
61
+	 * Currency.
62
+	 *
63
+	 * @var string
64
+	 */
65
+	protected string $currency_code;
66
+
67
+	/**
68
+	 * Billing info.
69
+	 *
70
+	 * @var array
71
+	 */
72
+	protected array $billing_info;
73
+
74
+	/**
75
+	 * Transaction this order is for.
76
+	 *
77
+	 * @var EE_Transaction
78
+	 */
79
+	protected EE_Transaction     $transaction;
80
+
81
+	private FeatureFlags         $feature;
82
+
83
+	private GatewayDataFormatter $gateway_data_formatter;
84
+
85
+	private EE_Payment           $payment;
86
+
87
+
88
+	/**
89
+	 * CreateOrder constructor.
90
+	 *
91
+	 * @param PayPalApi      $api
92
+	 * @param EE_Transaction $transaction
93
+	 * @param array          $billing_info
94
+	 * @param FeatureFlags   $feature
95
+	 */
96
+	public function __construct(
97
+		PayPalApi            $api,
98
+		EE_Transaction       $transaction,
99
+		array                $billing_info,
100
+		FeatureFlags         $feature,
101
+		GatewayDataFormatter $gateway_data_formatter
102
+	) {
103
+		parent::__construct($api);
104
+		$this->transaction   = $transaction;
105
+		$this->feature       = $feature;
106
+		$this->currency_code = CurrencyManager::currencyCode();
107
+		$this->sanitizeRequestParameters($billing_info);
108
+		$this->gateway_data_formatter = $gateway_data_formatter;
109
+		$this->setPaymentPlaceholder();
110
+	}
111
+
112
+
113
+	/**
114
+	 * Sanitize the array of billing form data.
115
+	 *
116
+	 * @param array $billing_info
117
+	 * @return void
118
+	 */
119
+	public function sanitizeRequestParameters(array $billing_info): void
120
+	{
121
+		$sanitizer = new RequestSanitizer(new Basic());
122
+		foreach ($billing_info as $item => $value) {
123
+			$this->billing_info[ $item ] = $sanitizer->clean($value);
124
+		}
125
+	}
126
+
127
+
128
+	/**
129
+	 * Create PayPal Order.
130
+	 *
131
+	 * @return array
132
+	 * @throws EE_Error
133
+	 * @throws ReflectionException
134
+	 */
135
+	public function create(): array
136
+	{
137
+		$order_parameters = $this->getParameters();
138
+		// Create Order request.
139
+		$create_response = $this->api->sendRequest($order_parameters, $this->request_url);
140
+		// Check for MISMATCH errors.
141
+		if ($this->isMismatchError($create_response)) {
142
+			// Mismatch, fix items.
143
+			$order_parameters['purchase_units'][0]['items'] = $this->getSimplifiedItems();
144
+			// Add simplified breakdown.
145
+			$order_parameters['purchase_units'][0]['amount']['breakdown'] = $this->getSimplifiedAmountBreakdown();
146
+			// Retry Order request.
147
+			$create_response = $this->api->sendRequest($order_parameters, $this->request_url);
148
+		}
149
+		return $this->validateOrder($create_response, $order_parameters);
150
+	}
151
+
152
+
153
+	/**
154
+	 * Form order parameters.
155
+	 *
156
+	 * @return array
157
+	 * @throws EE_Error
158
+	 * @throws ReflectionException
159
+	 * @throws Exception
160
+	 */
161
+	protected function getParameters(): array
162
+	{
163
+		$registrant  = $this->transaction->primary_registration();
164
+		$attendee    = $registrant->attendee();
165
+		$description = $this->gateway_data_formatter->formatOrderDescription($this->payment);
166
+		$parameters  = [
167
+			'intent'         => 'CAPTURE',
168
+			'purchase_units' => [
169
+				[
170
+					'custom_id'   => $this->transaction->ID(),
171
+					'description' => substr(wp_strip_all_tags($description), 0, 125),
172
+					'items'       => $this->getLineItems(),
173
+					'amount'      => [
174
+						'value'         => (string) CurrencyManager::normalizeValue($this->transaction->remaining()),
175
+						'currency_code' => $this->currency_code,
176
+						'breakdown'     => $this->getBreakdown(),
177
+					],
178
+				],
179
+			],
180
+			'payment_source' => [
181
+				'paypal' => [
182
+					'experience_context' => [
183
+						'user_action' => 'PAY_NOW',
184
+					],
185
+					'email_address'      => $attendee->email(),
186
+					'name'               => [
187
+						'given_name' => $attendee->fname(),
188
+						'surname'    => $attendee->lname(),
189
+					],
190
+				],
191
+			],
192
+		];
193
+		$CNT_ISO     = $attendee->country_ID();
194
+
195
+		// No country ID set, maybe just state?
196
+		if (empty($CNT_ISO)) {
197
+			$state_obj = $attendee->state_obj();
198
+			if ($state_obj instanceof EE_State) {
199
+				$CNT_ISO = $state_obj->country_iso();
200
+			}
201
+		}
202
+
203
+		if (strlen($CNT_ISO > 2)) {
204
+			// uh-oh... did someone save the country name for the ISO?
205
+			$country = EEM_Country::instance()->getCountryByName(ucwords(strtolower($CNT_ISO)));
206
+			if ($country instanceof EE_Country) {
207
+				$CNT_ISO = $country->ISO();
208
+			}
209
+		}
210
+
211
+		// If we have and address on the attendee, send it to PayPal.
212
+		if ($CNT_ISO && strlen($CNT_ISO == 2)) {
213
+			$parameters['payment_source']['paypal']['address'] = [
214
+				'address_line_1' => $attendee->address(),
215
+				'address_line_2' => $attendee->address2(),
216
+				'admin_area_2'   => $attendee->city(),
217
+				'admin_area_1'   => $attendee->state_abbrev(),
218
+				'postal_code'    => $attendee->zip(),
219
+				'country_code'   => $attendee->country_ID(),
220
+			];
221
+		}
222
+
223
+		// Do we have the permissions for the fees ?
224
+		$scopes = PayPalExtraMetaManager::getPmOption(
225
+			$this->transaction->payment_method(),
226
+			Domain::META_KEY_AUTHORIZED_SCOPES
227
+		);
228
+		if (
229
+			(
230
+				(defined('EE_PPC_USE_PAYMENT_FEES') && EE_PPC_USE_PAYMENT_FEES)
231
+				|| (! defined('EE_PPC_USE_PAYMENT_FEES')
232
+					&& $this->feature->allowed(FeatureFlag::USE_PAYMENT_PROCESSOR_FEES)
233
+				)
234
+			)
235
+			&& ! empty($scopes)
236
+			&& in_array('partnerfee', $scopes)
237
+		) {
238
+			/** @var PartnerPaymentFees $payment_fees */
239
+			$payment_fees = LoaderFactory::getShared(PartnerPaymentFees::class);
240
+			$parameters['purchase_units'][0]['payment_instruction'] = [
241
+				'platform_fees' => [
242
+					[
243
+						'amount' => [
244
+							'value'         => (string) $payment_fees->getPartnerFee($this->transaction),
245
+							'currency_code' => $this->currency_code,
246
+						],
247
+					],
248
+				],
249
+			];
250
+		}
251
+		return $parameters;
252
+	}
253
+
254
+
255
+	/**
256
+	 * Itemize the payment. List all the line items, discounts and taxes.
257
+	 *
258
+	 * @return array
259
+	 * @throws EE_Error|ReflectionException
260
+	 */
261
+	protected function getLineItems(): array
262
+	{
263
+		// Order line items.
264
+		$line_items       = [];
265
+		$event_line_items = $this->transaction->items_purchased();
266
+		// List actual line items.
267
+		foreach ($event_line_items as $line_item) {
268
+			if (
269
+				$line_item instanceof EE_Line_Item
270
+				&& $line_item->OBJ_type() !== 'Promotion'
271
+				&& $line_item->quantity() > 0
272
+			) {
273
+				$item_money    = CurrencyManager::normalizeValue($line_item->unit_price());
274
+				$line_items [] = [
275
+					'name'        => substr(
276
+						wp_strip_all_tags(
277
+							$this->gateway_data_formatter->formatLineItemName($line_item, $this->payment)
278
+						),
279
+						0,
280
+						125
281
+					),
282
+					'quantity'    => $line_item->quantity(),
283
+					'description' => substr(
284
+						wp_strip_all_tags(
285
+							$this->gateway_data_formatter->formatLineItemDesc($line_item, $this->payment)
286
+						),
287
+						0,
288
+						125
289
+					),
290
+					'unit_amount' => [
291
+						'currency_code' => $this->currency_code,
292
+						'value'         => (string) $item_money,
293
+					],
294
+					'category'    => 'DIGITAL_GOODS',
295
+				];
296
+				// Line item total.
297
+				$this->items_total += $line_item->pretaxTotal();
298
+			} elseif ($line_item->OBJ_type() === 'Promotion' && $line_item->quantity() > 0) {
299
+				// Promotions total.
300
+				$this->promos_total += $line_item->total();
301
+			}
302
+		}
303
+		// Make sure we have an absolute number with only two decimal laces.
304
+		$this->items_total  = CurrencyManager::normalizeValue($this->items_total);
305
+		$this->promos_total = CurrencyManager::normalizeValue($this->promos_total);
306
+		// If this is a partial payment, apply the paid amount as a promo.
307
+		if ($this->transaction->paid() > 0) {
308
+			$this->promos_total += CurrencyManager::normalizeValue($this->transaction->paid());
309
+		}
310
+		$this->countTaxTotal();
311
+		return $line_items;
312
+	}
313
+
314
+
315
+	/**
316
+	 * Count the tax total.
317
+	 *
318
+	 * @return void
319
+	 * @throws EE_Error|ReflectionException
320
+	 */
321
+	protected function countTaxTotal(): void
322
+	{
323
+		// List taxes.
324
+		$this->tax_total = 0.0;
325
+		$tax_items       = $this->transaction->tax_items();
326
+		foreach ($tax_items as $tax_item) {
327
+			$this->tax_total += $tax_item->total();
328
+		}
329
+		$this->tax_total = CurrencyManager::normalizeValue($this->tax_total);
330
+	}
331
+
332
+
333
+	/**
334
+	 * Itemize the payment the breakdown list.
335
+	 *
336
+	 * @return array
337
+	 */
338
+	protected function getBreakdown(): array
339
+	{
340
+		$breakdown['item_total'] = [
341
+			'currency_code' => $this->currency_code,
342
+			'value'         => (string) $this->items_total,
343
+		];
344
+		$breakdown['tax_total']  = [
345
+			'currency_code' => $this->currency_code,
346
+			'value'         => (string) $this->tax_total,
347
+		];
348
+		$breakdown['discount']   = [
349
+			'currency_code' => $this->currency_code,
350
+			'value'         => (string) abs($this->promos_total),
351
+		];
352
+		return $breakdown;
353
+	}
354
+
355
+
356
+	/**
357
+	 * Makes sure that we have received an Order back from the API call.
358
+	 *
359
+	 * @param $response
360
+	 * @param $parameters
361
+	 * @return array
362
+	 * @throws EE_Error
363
+	 * @throws ReflectionException
364
+	 */
365
+	public function validateOrder($response, $parameters): array
366
+	{
367
+		PayPalLogger::errorLog(
368
+			esc_html__('Validating Order Create:', 'event_espresso'),
369
+			[$this->request_url, $response],
370
+			$this->transaction->payment_method(),
371
+			false,
372
+			$this->transaction
373
+		);
374
+		if (! empty($response['error'])) {
375
+			return $response;
376
+		}
377
+		if (! isset($response['id'])) {
378
+			$message = esc_html__('Unexpected response. Unable to find the order.', 'event_espresso');
379
+			try {
380
+				PayPalLogger::errorLog(
381
+					$message,
382
+					[$this->request_url, $parameters, $response],
383
+					$this->transaction->payment_method()
384
+				);
385
+			} catch (EE_Error|ReflectionException $e) {
386
+				error_log("PayPalLogger Error: $message: " . json_encode($response));
387
+			}
388
+			return [
389
+				'error'    => $response['error'] ?? 'missing_order',
390
+				'message'  => $response['message'] ?? $message,
391
+				'response' => $response,
392
+			];
393
+		}
394
+		return $response;
395
+	}
396
+
397
+
398
+	/**
399
+	 * Check if PayPals response contains 'MISMATCH' errors.
400
+	 *
401
+	 * @return bool
402
+	 */
403
+	public function isMismatchError($response): bool
404
+	{
405
+		if (! isset($response['details']) || ! is_array($response['details'])) {
406
+			return false;
407
+		}
408
+
409
+		foreach ($response['details'] as $detail) {
410
+			if (! empty($detail['issue'])) {
411
+				if (
412
+					strtoupper($detail['issue']) === 'ITEM_TOTAL_MISMATCH'
413
+					|| strtoupper($detail['issue']) === 'AMOUNT_MISMATCH'
414
+				) {
415
+					PayPalLogger::errorLog(
416
+						esc_html__('Mistmatch Error:', 'event_espresso'),
417
+						[$this->request_url, $response],
418
+						$this->transaction->payment_method(),
419
+						false,
420
+						$this->transaction
421
+					);
422
+					return true;
423
+				}
424
+			}
425
+		}
426
+		return false;
427
+	}
428
+
429
+
430
+	/**
431
+	 * Itemize the simplified payment breakdown list.
432
+	 *
433
+	 * @return array
434
+	 */
435
+	protected function getSimplifiedAmountBreakdown(): array
436
+	{
437
+		$tax_total               = $this->transaction->tax_total();
438
+		$breakdown['item_total'] = [
439
+			'currency_code' => $this->currency_code,
440
+			'value'         => (string) CurrencyManager::normalizeValue($this->transaction->remaining() - $tax_total),
441
+		];
442
+		if ($tax_total > 0) {
443
+			$breakdown['tax_total'] = [
444
+				'currency_code' => $this->currency_code,
445
+				'value'         => (string) CurrencyManager::normalizeValue($tax_total),
446
+			];
447
+		}
448
+		return $breakdown;
449
+	}
450
+
451
+
452
+	/**
453
+	 * Generate single line item for full order.
454
+	 *
455
+	 * @return array
456
+	 */
457
+	protected function getSimplifiedItems(): array
458
+	{
459
+		// Simplified single line item.
460
+		$line_items           = [];
461
+		$primary_registrant   = $this->transaction->primary_registration();
462
+		$event_obj            = $primary_registrant->event_obj();
463
+		$name_and_description = $this->gateway_data_formatter->formatOrderDescription($this->payment);
464
+
465
+		$line_items[] = [
466
+			'name'        => substr(wp_strip_all_tags($name_and_description), 0, 125),
467
+			'quantity'    => 1,
468
+			'description' => substr(wp_strip_all_tags($name_and_description), 0, 2047),
469
+			'unit_amount' => [
470
+				'currency_code' => $this->currency_code,
471
+				'value'         => (string) CurrencyManager::normalizeValue(
472
+					$this->transaction->remaining() - $this->transaction->tax_total()
473
+				),
474
+			],
475
+			'category'    => 'DIGITAL_GOODS',
476
+		];
477
+		return $line_items;
478
+	}
479
+
480
+
481
+	/**
482
+	 * Generates an EE_Payment object but doesn't save it.
483
+	 */
484
+	private function setPaymentPlaceholder(): void
485
+	{
486
+		$this->payment = EE_Payment::new_instance(
487
+			[
488
+				'STS_ID'        => EEM_Payment::status_id_pending,
489
+				'TXN_ID'        => $this->transaction->ID(),
490
+				'PMD_ID'        => $this->transaction->payment_method_ID(),
491
+				'PAY_amount'    => 0.00,
492
+				'PAY_timestamp' => time(),
493
+			]
494
+		);
495
+	}
496 496
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
     {
121 121
         $sanitizer = new RequestSanitizer(new Basic());
122 122
         foreach ($billing_info as $item => $value) {
123
-            $this->billing_info[ $item ] = $sanitizer->clean($value);
123
+            $this->billing_info[$item] = $sanitizer->clean($value);
124 124
         }
125 125
     }
126 126
 
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
                 ],
191 191
             ],
192 192
         ];
193
-        $CNT_ISO     = $attendee->country_ID();
193
+        $CNT_ISO = $attendee->country_ID();
194 194
 
195 195
         // No country ID set, maybe just state?
196 196
         if (empty($CNT_ISO)) {
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
         if (
229 229
             (
230 230
                 (defined('EE_PPC_USE_PAYMENT_FEES') && EE_PPC_USE_PAYMENT_FEES)
231
-                || (! defined('EE_PPC_USE_PAYMENT_FEES')
231
+                || ( ! defined('EE_PPC_USE_PAYMENT_FEES')
232 232
                     && $this->feature->allowed(FeatureFlag::USE_PAYMENT_PROCESSOR_FEES)
233 233
                 )
234 234
             )
@@ -341,11 +341,11 @@  discard block
 block discarded – undo
341 341
             'currency_code' => $this->currency_code,
342 342
             'value'         => (string) $this->items_total,
343 343
         ];
344
-        $breakdown['tax_total']  = [
344
+        $breakdown['tax_total'] = [
345 345
             'currency_code' => $this->currency_code,
346 346
             'value'         => (string) $this->tax_total,
347 347
         ];
348
-        $breakdown['discount']   = [
348
+        $breakdown['discount'] = [
349 349
             'currency_code' => $this->currency_code,
350 350
             'value'         => (string) abs($this->promos_total),
351 351
         ];
@@ -371,10 +371,10 @@  discard block
 block discarded – undo
371 371
             false,
372 372
             $this->transaction
373 373
         );
374
-        if (! empty($response['error'])) {
374
+        if ( ! empty($response['error'])) {
375 375
             return $response;
376 376
         }
377
-        if (! isset($response['id'])) {
377
+        if ( ! isset($response['id'])) {
378 378
             $message = esc_html__('Unexpected response. Unable to find the order.', 'event_espresso');
379 379
             try {
380 380
                 PayPalLogger::errorLog(
@@ -382,8 +382,8 @@  discard block
 block discarded – undo
382 382
                     [$this->request_url, $parameters, $response],
383 383
                     $this->transaction->payment_method()
384 384
                 );
385
-            } catch (EE_Error|ReflectionException $e) {
386
-                error_log("PayPalLogger Error: $message: " . json_encode($response));
385
+            } catch (EE_Error | ReflectionException $e) {
386
+                error_log("PayPalLogger Error: $message: ".json_encode($response));
387 387
             }
388 388
             return [
389 389
                 'error'    => $response['error'] ?? 'missing_order',
@@ -402,12 +402,12 @@  discard block
 block discarded – undo
402 402
      */
403 403
     public function isMismatchError($response): bool
404 404
     {
405
-        if (! isset($response['details']) || ! is_array($response['details'])) {
405
+        if ( ! isset($response['details']) || ! is_array($response['details'])) {
406 406
             return false;
407 407
         }
408 408
 
409 409
         foreach ($response['details'] as $detail) {
410
-            if (! empty($detail['issue'])) {
410
+            if ( ! empty($detail['issue'])) {
411 411
                 if (
412 412
                     strtoupper($detail['issue']) === 'ITEM_TOTAL_MISMATCH'
413 413
                     || strtoupper($detail['issue']) === 'AMOUNT_MISMATCH'
Please login to merge, or discard this patch.
PaymentMethods/PayPalCommerce/domain/Domain.php 1 patch
Indentation   +193 added lines, -193 removed lines patch added patch discarded remove patch
@@ -17,197 +17,197 @@
 block discarded – undo
17 17
  */
18 18
 class Domain
19 19
 {
20
-    /**
21
-     * Name of the extra meta key that stores this PM options as one meta.
22
-     */
23
-    public const META_KEY_PAYPAL_DATA = 'paypal_data';
24
-    /**
25
-     * Name of the extra meta key that stores this PM options as one meta.
26
-     */
27
-    public const META_KEY_PAYPAL_DATA_SANDBOX = 'paypal_data_sandbox';
28
-
29
-    /**
30
-     * Name of the extra meta that stores whether the credentials were for the sandbox or live mode.
31
-     */
32
-    public const META_KEY_SANDBOX_MODE = 'sandbox_mode';
33
-
34
-    /**
35
-     * Name of the extra meta that stores the Access Token that is used to auth in API requests to PayPal.
36
-     */
37
-    public const META_KEY_ACCESS_TOKEN = 'access_token';
38
-
39
-    /**
40
-     * Name of the extra meta that stores the last request tracking ID.
41
-     */
42
-    public const META_KEY_TRACKING_ID = 'tracking_id';
43
-
44
-    /**
45
-     * Name of the extra meta that stores the Event Espresso PayPal Account's merchant id.
46
-     */
47
-    public const META_KEY_APP_ID = 'app_id';
48
-
49
-    /**
50
-     * Name of the extra meta that holds the seller client ID.
51
-     */
52
-    public const META_KEY_CLIENT_ID = 'client_id';
53
-
54
-    /**
55
-     * Name of the extra meta that holds the seller secret.
56
-     */
57
-    public const META_KEY_CLIENT_SECRET = 'client_secret';
58
-
59
-    /**
60
-     * Name of the extra meta that stores the expiration date of the Access Token.
61
-     */
62
-    public const META_KEY_TOKEN_EXPIRES_IN = 'expires_in';
63
-
64
-    /**
65
-     * Name of the extra meta that holds the partner client ID.
66
-     */
67
-    public const META_KEY_PARTNER_CLIENT_ID = 'partner_client_id';
68
-
69
-    /**
70
-     * Name of the extra meta that holds the partner merchant ID.
71
-     */
72
-    public const META_KEY_PARTNER_MERCHANT_ID = 'partner_merchant_id';
73
-
74
-    /**
75
-     * Name of the extra meta that holds the seller merchant ID.
76
-     */
77
-    public const META_KEY_SELLER_MERCHANT_ID = 'merchantIdInPayPal';
78
-
79
-    /**
80
-     * Name of the extra meta that holds the BN / request tracking code.
81
-     */
82
-    public const META_KEY_BN_CODE = 'bn_code';
83
-
84
-    /**
85
-     * Name of the extra meta that stores the merchant authorized scopes for our app to work within.
86
-     */
87
-    public const META_KEY_AUTHORIZED_SCOPES = 'authorized_scopes';
88
-
89
-    /**
90
-     * Name of the extra meta that stores the PP checkout type selected by merchant after onboarding.
91
-     */
92
-    public const META_KEY_CHECKOUT_TYPE = 'checkout_type';
93
-
94
-    /**
95
-     * Name of the extra meta that stores the allowed PP checkout type selected by merchant while onboarding.
96
-     */
97
-    public const META_KEY_ALLOWED_CHECKOUT_TYPE = 'allowed_checkout_type';
98
-
99
-    /**
100
-     * Name of the extra meta that stores the selected PP function options.
101
-     */
102
-    public const META_KEY_FUNDING_OPTIONS = 'funding_options';
103
-
104
-    /**
105
-     * Name of the PayPal API parameter that holds the auth code.
106
-     */
107
-    public const API_KEY_AUTH_CODE = 'authCode';
108
-
109
-    /**
110
-     * Name of the PayPal API parameter that holds the client token.
111
-     */
112
-    public const API_KEY_CLIENT_TOKEN = 'client_token';
113
-
114
-     /**
115
-     * Name of the extra meta that holds the seller payer ID.
116
-     */
117
-    public const META_KEY_PAYER_ID = 'payer_id';
118
-
119
-    /**
120
-     * Name of the PayPal API parameter that holds the client token expiration time.
121
-     */
122
-    public const API_KEY_EXPIRES_IN = 'expires_in';
123
-
124
-    /**
125
-     * Name of the PayPal API parameter that holds the list of oAuth integrations related to the merchant.
126
-     */
127
-    public const API_PARAM_OAUTH_INTEGRATIONS = 'oauth_integrations';
128
-
129
-    /**
130
-     * Name of the PayPal API parameter that holds the list of third party permissions that were granted.
131
-     */
132
-    public const API_PARAM_PERMISSIONS_GRANTED = 'oauth_third_party';
133
-
134
-    /**
135
-     * Name of the PayPal API parameter that holds the bool of if the primary email was confirmed.
136
-     */
137
-    public const API_PARAM_PRIM_EMAIL_CONFIRMED = 'primary_email_confirmed';
138
-
139
-    /**
140
-     * Name of the PayPal API parameter that holds the bool of if email was confirmed.
141
-     */
142
-    public const API_PARAM_EMAIL_CONFIRMED = 'isEmailConfirmed';
143
-
144
-    /**
145
-     * Name of the PayPal API parameter that holds the partner ID.
146
-     */
147
-    public const API_PARAM_PARTNER_ID = 'merchantId';
148
-
149
-    /**
150
-     * Name of the PayPal API parameter that holds the merchant ID in the Track seller onboarding status request.
151
-     */
152
-    public const API_PARAM_TRACK_MERCHANT_ID = 'merchant_id';
153
-
154
-    /**
155
-     * Name of the PayPal API parameter that holds the payments_receivable status.
156
-     */
157
-    public const API_PARAM_PAYMENTS_RECEIVABLE = 'payments_receivable';
158
-
159
-    /**
160
-     * Name of the nonce used in the capture order request.
161
-     */
162
-    public const CAPTURE_ORDER_NONCE_NAME = 'eea_pp_commerce_capture_order_payment';
163
-
164
-    /**
165
-     * Name of the nonce used in the onboarding process.
166
-     */
167
-    public const NONCE_NAME_ONBOARDING_RETURN = 'eea_pp_commerce_onboarding_return';
168
-
169
-    /**
170
-     * Holds this payment method slug.
171
-     */
172
-    public const PM_SLUG = 'paypalcheckout';
173
-
174
-    /**
175
-     * Holds an array of funding options.
176
-     */
177
-    public const FUNDING_OPTIONS = [
178
-        'venmo',
179
-        'paylater',
180
-        'bancontact',
181
-        'blik',
182
-        'eps',
183
-        'giropay',
184
-        'ideal',
185
-        'mercadopago',
186
-        'mybank',
187
-        'p24',
188
-        'sepa',
189
-        'sofort',
190
-    ];
191
-
192
-    /**
193
-     * Holds an array of default/enabled funding options.
194
-     */
195
-    public const DEFAULT_FUNDING_OPTIONS = [
196
-        'venmo',
197
-        'paylater',
198
-    ];
199
-
200
-
201
-    /**
202
-     * Returns the base PayPal API URL.
203
-     *
204
-     * @param EE_Payment_Method $payment_method
205
-     * @return string
206
-     * @throws EE_Error
207
-     * @throws ReflectionException
208
-     */
209
-    public static function getPayPalApiUrl(EE_Payment_Method $payment_method): string
210
-    {
211
-        return $payment_method->debug_mode() ? 'https://api-m.sandbox.paypal.com' : 'https://api-m.paypal.com';
212
-    }
20
+	/**
21
+	 * Name of the extra meta key that stores this PM options as one meta.
22
+	 */
23
+	public const META_KEY_PAYPAL_DATA = 'paypal_data';
24
+	/**
25
+	 * Name of the extra meta key that stores this PM options as one meta.
26
+	 */
27
+	public const META_KEY_PAYPAL_DATA_SANDBOX = 'paypal_data_sandbox';
28
+
29
+	/**
30
+	 * Name of the extra meta that stores whether the credentials were for the sandbox or live mode.
31
+	 */
32
+	public const META_KEY_SANDBOX_MODE = 'sandbox_mode';
33
+
34
+	/**
35
+	 * Name of the extra meta that stores the Access Token that is used to auth in API requests to PayPal.
36
+	 */
37
+	public const META_KEY_ACCESS_TOKEN = 'access_token';
38
+
39
+	/**
40
+	 * Name of the extra meta that stores the last request tracking ID.
41
+	 */
42
+	public const META_KEY_TRACKING_ID = 'tracking_id';
43
+
44
+	/**
45
+	 * Name of the extra meta that stores the Event Espresso PayPal Account's merchant id.
46
+	 */
47
+	public const META_KEY_APP_ID = 'app_id';
48
+
49
+	/**
50
+	 * Name of the extra meta that holds the seller client ID.
51
+	 */
52
+	public const META_KEY_CLIENT_ID = 'client_id';
53
+
54
+	/**
55
+	 * Name of the extra meta that holds the seller secret.
56
+	 */
57
+	public const META_KEY_CLIENT_SECRET = 'client_secret';
58
+
59
+	/**
60
+	 * Name of the extra meta that stores the expiration date of the Access Token.
61
+	 */
62
+	public const META_KEY_TOKEN_EXPIRES_IN = 'expires_in';
63
+
64
+	/**
65
+	 * Name of the extra meta that holds the partner client ID.
66
+	 */
67
+	public const META_KEY_PARTNER_CLIENT_ID = 'partner_client_id';
68
+
69
+	/**
70
+	 * Name of the extra meta that holds the partner merchant ID.
71
+	 */
72
+	public const META_KEY_PARTNER_MERCHANT_ID = 'partner_merchant_id';
73
+
74
+	/**
75
+	 * Name of the extra meta that holds the seller merchant ID.
76
+	 */
77
+	public const META_KEY_SELLER_MERCHANT_ID = 'merchantIdInPayPal';
78
+
79
+	/**
80
+	 * Name of the extra meta that holds the BN / request tracking code.
81
+	 */
82
+	public const META_KEY_BN_CODE = 'bn_code';
83
+
84
+	/**
85
+	 * Name of the extra meta that stores the merchant authorized scopes for our app to work within.
86
+	 */
87
+	public const META_KEY_AUTHORIZED_SCOPES = 'authorized_scopes';
88
+
89
+	/**
90
+	 * Name of the extra meta that stores the PP checkout type selected by merchant after onboarding.
91
+	 */
92
+	public const META_KEY_CHECKOUT_TYPE = 'checkout_type';
93
+
94
+	/**
95
+	 * Name of the extra meta that stores the allowed PP checkout type selected by merchant while onboarding.
96
+	 */
97
+	public const META_KEY_ALLOWED_CHECKOUT_TYPE = 'allowed_checkout_type';
98
+
99
+	/**
100
+	 * Name of the extra meta that stores the selected PP function options.
101
+	 */
102
+	public const META_KEY_FUNDING_OPTIONS = 'funding_options';
103
+
104
+	/**
105
+	 * Name of the PayPal API parameter that holds the auth code.
106
+	 */
107
+	public const API_KEY_AUTH_CODE = 'authCode';
108
+
109
+	/**
110
+	 * Name of the PayPal API parameter that holds the client token.
111
+	 */
112
+	public const API_KEY_CLIENT_TOKEN = 'client_token';
113
+
114
+	 /**
115
+	  * Name of the extra meta that holds the seller payer ID.
116
+	  */
117
+	public const META_KEY_PAYER_ID = 'payer_id';
118
+
119
+	/**
120
+	 * Name of the PayPal API parameter that holds the client token expiration time.
121
+	 */
122
+	public const API_KEY_EXPIRES_IN = 'expires_in';
123
+
124
+	/**
125
+	 * Name of the PayPal API parameter that holds the list of oAuth integrations related to the merchant.
126
+	 */
127
+	public const API_PARAM_OAUTH_INTEGRATIONS = 'oauth_integrations';
128
+
129
+	/**
130
+	 * Name of the PayPal API parameter that holds the list of third party permissions that were granted.
131
+	 */
132
+	public const API_PARAM_PERMISSIONS_GRANTED = 'oauth_third_party';
133
+
134
+	/**
135
+	 * Name of the PayPal API parameter that holds the bool of if the primary email was confirmed.
136
+	 */
137
+	public const API_PARAM_PRIM_EMAIL_CONFIRMED = 'primary_email_confirmed';
138
+
139
+	/**
140
+	 * Name of the PayPal API parameter that holds the bool of if email was confirmed.
141
+	 */
142
+	public const API_PARAM_EMAIL_CONFIRMED = 'isEmailConfirmed';
143
+
144
+	/**
145
+	 * Name of the PayPal API parameter that holds the partner ID.
146
+	 */
147
+	public const API_PARAM_PARTNER_ID = 'merchantId';
148
+
149
+	/**
150
+	 * Name of the PayPal API parameter that holds the merchant ID in the Track seller onboarding status request.
151
+	 */
152
+	public const API_PARAM_TRACK_MERCHANT_ID = 'merchant_id';
153
+
154
+	/**
155
+	 * Name of the PayPal API parameter that holds the payments_receivable status.
156
+	 */
157
+	public const API_PARAM_PAYMENTS_RECEIVABLE = 'payments_receivable';
158
+
159
+	/**
160
+	 * Name of the nonce used in the capture order request.
161
+	 */
162
+	public const CAPTURE_ORDER_NONCE_NAME = 'eea_pp_commerce_capture_order_payment';
163
+
164
+	/**
165
+	 * Name of the nonce used in the onboarding process.
166
+	 */
167
+	public const NONCE_NAME_ONBOARDING_RETURN = 'eea_pp_commerce_onboarding_return';
168
+
169
+	/**
170
+	 * Holds this payment method slug.
171
+	 */
172
+	public const PM_SLUG = 'paypalcheckout';
173
+
174
+	/**
175
+	 * Holds an array of funding options.
176
+	 */
177
+	public const FUNDING_OPTIONS = [
178
+		'venmo',
179
+		'paylater',
180
+		'bancontact',
181
+		'blik',
182
+		'eps',
183
+		'giropay',
184
+		'ideal',
185
+		'mercadopago',
186
+		'mybank',
187
+		'p24',
188
+		'sepa',
189
+		'sofort',
190
+	];
191
+
192
+	/**
193
+	 * Holds an array of default/enabled funding options.
194
+	 */
195
+	public const DEFAULT_FUNDING_OPTIONS = [
196
+		'venmo',
197
+		'paylater',
198
+	];
199
+
200
+
201
+	/**
202
+	 * Returns the base PayPal API URL.
203
+	 *
204
+	 * @param EE_Payment_Method $payment_method
205
+	 * @return string
206
+	 * @throws EE_Error
207
+	 * @throws ReflectionException
208
+	 */
209
+	public static function getPayPalApiUrl(EE_Payment_Method $payment_method): string
210
+	{
211
+		return $payment_method->debug_mode() ? 'https://api-m.sandbox.paypal.com' : 'https://api-m.paypal.com';
212
+	}
213 213
 }
Please login to merge, or discard this patch.
PaymentMethods/PayPalCommerce/PayPalCheckout/forms/SettingsForm.php 2 patches
Indentation   +208 added lines, -208 removed lines patch added patch discarded remove patch
@@ -25,212 +25,212 @@
 block discarded – undo
25 25
  */
26 26
 class SettingsForm extends EE_Payment_Method_Form
27 27
 {
28
-    /**
29
-     *  Payment method.
30
-     *
31
-     * @var EE_PMT_Base|null
32
-     */
33
-    protected $payment_method = null;
34
-
35
-    /**
36
-     *  Payment method instance.
37
-     *
38
-     * @var EE_PMT_Base|null
39
-     */
40
-    protected $pm_instance = null;
41
-
42
-
43
-    /**
44
-     * Class constructor.
45
-     *
46
-     * @param EE_PMT_PayPalCheckout $payment_method
47
-     * @param EE_Payment_Method     $pm_instance
48
-     * @throws EE_Error
49
-     * @throws ReflectionException
50
-     */
51
-    public function __construct(EE_PMT_PayPalCheckout $payment_method, EE_Payment_Method $pm_instance)
52
-    {
53
-        $form_parameters      = [];
54
-        $this->payment_method = $payment_method;
55
-        $this->pm_instance    = $pm_instance;
56
-        // Allow Advanced Card Checkout if PPCP checkout type was possible and selected when onboarding.
57
-        $allowed_type = PayPalExtraMetaManager::getPmOption($pm_instance, Domain::META_KEY_ALLOWED_CHECKOUT_TYPE);
58
-        $is_onboard   = EED_PayPalOnboard::isOnboard($pm_instance);
59
-        if ($is_onboard) {
60
-            if ($allowed_type === 'ppcp' || $allowed_type === 'all') {
61
-                $form_parameters = $this->addCheckoutTypeSelect($form_parameters);
62
-            }
63
-            // If the checkout type is currently set to ACDC only, don't add funding options
64
-            if ($pm_instance->get_extra_meta(Domain::META_KEY_CHECKOUT_TYPE, true) !== 'ppcp') {
65
-                $form_parameters = $this->addFundingOptions($form_parameters);
66
-            }
67
-        }
68
-        // Build the PM form.
69
-        parent::__construct($form_parameters);
70
-        // Add a form for PayPal Onboard.
71
-        $this->addOnboardingForm($payment_method, $pm_instance);
72
-        // Add the clear data button.
73
-        $this->clearMetadataButton($pm_instance);
74
-        // Disable inputs if needed.
75
-        $this->toggleSubsections($pm_instance);
76
-    }
77
-
78
-
79
-    /**
80
-     * Adds an onboarding form as a subsection.
81
-     *
82
-     * @param EE_PMT_PayPalCheckout $payment_method
83
-     * @param EE_Payment_Method     $pm_instance
84
-     * @return void
85
-     */
86
-    public function addOnboardingForm(EE_PMT_PayPalCheckout $payment_method, EE_Payment_Method $pm_instance): void
87
-    {
88
-        // Add the connect button before the app id field.
89
-        try {
90
-            $this->add_subsections(
91
-                [
92
-                    'paypal_onboard' => new OnboardingForm($payment_method, $pm_instance),
93
-                ],
94
-                'PMD_debug_mode',
95
-                false
96
-            );
97
-        } catch (EE_Error $e) {
98
-            // Simply don't add the form.
99
-        }
100
-    }
101
-
102
-
103
-    /**
104
-     * Add a checkout type select.
105
-     *
106
-     * @param array $form_parameters
107
-     * @return array
108
-     * @throws EE_Error
109
-     * @throws ReflectionException
110
-     */
111
-    public function addCheckoutTypeSelect(array $form_parameters): array
112
-    {
113
-        $pm_slug = $this->pm_instance->slug();
114
-        // Section to be displayed if onboard.
115
-        $form_parameters['extra_meta_inputs'][ Domain::META_KEY_CHECKOUT_TYPE ] = new EE_Select_Input(
116
-            [
117
-                'express_checkout' => esc_html__('Express Checkout', 'event_espresso'),
118
-                'ppcp'             => esc_html__('Advanced Credit and Debit Card payments', 'event_espresso'),
119
-                'all'              => esc_html__('Both, ACDC and Express Checkout', 'event_espresso'),
120
-            ],
121
-            [
122
-                'html_name'  => "eep_checkout_type_option_$pm_slug",
123
-                'html_id'    => "eep_checkout_type_option_$pm_slug",
124
-                'html_class' => "eep-checkout-type-option-$pm_slug",
125
-                'required'   => true,
126
-                'default'    => PayPalExtraMetaManager::getPmOption(
127
-                    $this->pm_instance,
128
-                    Domain::META_KEY_ALLOWED_CHECKOUT_TYPE
129
-                ),
130
-            ]
131
-        );
132
-        return $form_parameters;
133
-    }
134
-
135
-
136
-    /**
137
-     * Add a checkout type select.
138
-     *
139
-     * @param array $form_parameters
140
-     * @return array
141
-     * @throws EE_Error
142
-     * @throws ReflectionException
143
-     */
144
-    public function addFundingOptions(array $form_parameters): array
145
-    {
146
-        $pm_slug = $this->pm_instance->slug();
147
-        // Section to be displayed if onboard.
148
-        $form_parameters['extra_meta_inputs'][ Domain::META_KEY_FUNDING_OPTIONS ] = new EE_Checkbox_Multi_Input(
149
-            [
150
-                'venmo'       => esc_html__('Venmo', 'event_espresso'),
151
-                'paylater'    => esc_html__('PayLater', 'event_espresso'),
152
-                'bancontact'  => esc_html__('Bancontact', 'event_espresso'),
153
-                'blik'        => esc_html__('BLIK', 'event_espresso'),
154
-                'eps'         => esc_html__('EPS', 'event_espresso'),
155
-                'giropay'     => esc_html__('giropay', 'event_espresso'),
156
-                'ideal'       => esc_html__('iDEAL', 'event_espresso'),
157
-                'mercadopago' => esc_html__('Mercado Pago', 'event_espresso'),
158
-                'mybank'      => esc_html__('MyBank', 'event_espresso'),
159
-                'p24'         => esc_html__('Przelewy24', 'event_espresso'),
160
-                'sepa'        => esc_html__('SEPA-Lastschrift', 'event_espresso'),
161
-                'sofort'      => esc_html__('Sofort', 'event_espresso'),
162
-            ],
163
-            [
164
-                'html_name'       => "eep_checkout_funding_options_$pm_slug",
165
-                'html_id'         => "eep_checkout_funding_options_$pm_slug",
166
-                'html_class'      => "eep-checkout-funding-options-$pm_slug",
167
-                'html_label_text' => esc_html__('Enable PayPal funding options:', 'event_espresso'),
168
-                'default'         => ['venmo', 'paylater'],
169
-            ]
170
-        );
171
-        return $form_parameters;
172
-    }
173
-
174
-
175
-    /**
176
-     * Adds a button for clearing the PM metadata.
177
-     *
178
-     * @param EE_Payment_Method $pm_instance
179
-     * @return void
180
-     */
181
-    public function clearMetadataButton(EE_Payment_Method $pm_instance): void
182
-    {
183
-        try {
184
-            $is_onboard = EED_PayPalOnboard::isOnboard($pm_instance);
185
-            if ($is_onboard) {
186
-                return;
187
-            }
188
-            $button_text = sprintf(
189
-                esc_html__('Clear %1$s metadata', 'event_espresso'),
190
-                $pm_instance->admin_name()
191
-            );
192
-            $this->add_subsections(
193
-                [
194
-                    'clear_pm_metadata' => new EE_Form_Section_HTML(
195
-                        EEH_HTML::tr(
196
-                            EEH_HTML::th(esc_html__('Clear PM metadata ?', 'event_espresso')) .
197
-                            EEH_HTML::td(
198
-                                EEH_HTML::link(
199
-                                    '',
200
-                                    $button_text,
201
-                                    $button_text,
202
-                                    'eea_clear_metadata_' . $pm_instance->slug(),
203
-                                    'espresso-button button button--secondary'
204
-                                )
205
-                            )
206
-                        )
207
-                    ),
208
-                ],
209
-                'PMD_order',
210
-                false
211
-            );
212
-        } catch (EE_Error $e) {
213
-            // Don't add the button if there's some error.
214
-        }
215
-    }
216
-
217
-
218
-    /**
219
-     * Toggles subsections depending on the OAuth status etc.
220
-     *
221
-     * @param EE_Payment_Method $pm_instance
222
-     * @return void
223
-     * @throws EE_Error
224
-     */
225
-    private function toggleSubsections(EE_Payment_Method $pm_instance): void
226
-    {
227
-        $onboard = EED_PayPalOnboard::isOnboard($pm_instance);
228
-        // Don't allow changing the debug mode setting while connected.
229
-        if ($onboard) {
230
-            $debug_mode_input = $this->get_input('PMD_debug_mode', false);
231
-            if (method_exists($debug_mode_input, 'isDisabled')) {
232
-                $debug_mode_input->disable();
233
-            }
234
-        }
235
-    }
28
+	/**
29
+	 *  Payment method.
30
+	 *
31
+	 * @var EE_PMT_Base|null
32
+	 */
33
+	protected $payment_method = null;
34
+
35
+	/**
36
+	 *  Payment method instance.
37
+	 *
38
+	 * @var EE_PMT_Base|null
39
+	 */
40
+	protected $pm_instance = null;
41
+
42
+
43
+	/**
44
+	 * Class constructor.
45
+	 *
46
+	 * @param EE_PMT_PayPalCheckout $payment_method
47
+	 * @param EE_Payment_Method     $pm_instance
48
+	 * @throws EE_Error
49
+	 * @throws ReflectionException
50
+	 */
51
+	public function __construct(EE_PMT_PayPalCheckout $payment_method, EE_Payment_Method $pm_instance)
52
+	{
53
+		$form_parameters      = [];
54
+		$this->payment_method = $payment_method;
55
+		$this->pm_instance    = $pm_instance;
56
+		// Allow Advanced Card Checkout if PPCP checkout type was possible and selected when onboarding.
57
+		$allowed_type = PayPalExtraMetaManager::getPmOption($pm_instance, Domain::META_KEY_ALLOWED_CHECKOUT_TYPE);
58
+		$is_onboard   = EED_PayPalOnboard::isOnboard($pm_instance);
59
+		if ($is_onboard) {
60
+			if ($allowed_type === 'ppcp' || $allowed_type === 'all') {
61
+				$form_parameters = $this->addCheckoutTypeSelect($form_parameters);
62
+			}
63
+			// If the checkout type is currently set to ACDC only, don't add funding options
64
+			if ($pm_instance->get_extra_meta(Domain::META_KEY_CHECKOUT_TYPE, true) !== 'ppcp') {
65
+				$form_parameters = $this->addFundingOptions($form_parameters);
66
+			}
67
+		}
68
+		// Build the PM form.
69
+		parent::__construct($form_parameters);
70
+		// Add a form for PayPal Onboard.
71
+		$this->addOnboardingForm($payment_method, $pm_instance);
72
+		// Add the clear data button.
73
+		$this->clearMetadataButton($pm_instance);
74
+		// Disable inputs if needed.
75
+		$this->toggleSubsections($pm_instance);
76
+	}
77
+
78
+
79
+	/**
80
+	 * Adds an onboarding form as a subsection.
81
+	 *
82
+	 * @param EE_PMT_PayPalCheckout $payment_method
83
+	 * @param EE_Payment_Method     $pm_instance
84
+	 * @return void
85
+	 */
86
+	public function addOnboardingForm(EE_PMT_PayPalCheckout $payment_method, EE_Payment_Method $pm_instance): void
87
+	{
88
+		// Add the connect button before the app id field.
89
+		try {
90
+			$this->add_subsections(
91
+				[
92
+					'paypal_onboard' => new OnboardingForm($payment_method, $pm_instance),
93
+				],
94
+				'PMD_debug_mode',
95
+				false
96
+			);
97
+		} catch (EE_Error $e) {
98
+			// Simply don't add the form.
99
+		}
100
+	}
101
+
102
+
103
+	/**
104
+	 * Add a checkout type select.
105
+	 *
106
+	 * @param array $form_parameters
107
+	 * @return array
108
+	 * @throws EE_Error
109
+	 * @throws ReflectionException
110
+	 */
111
+	public function addCheckoutTypeSelect(array $form_parameters): array
112
+	{
113
+		$pm_slug = $this->pm_instance->slug();
114
+		// Section to be displayed if onboard.
115
+		$form_parameters['extra_meta_inputs'][ Domain::META_KEY_CHECKOUT_TYPE ] = new EE_Select_Input(
116
+			[
117
+				'express_checkout' => esc_html__('Express Checkout', 'event_espresso'),
118
+				'ppcp'             => esc_html__('Advanced Credit and Debit Card payments', 'event_espresso'),
119
+				'all'              => esc_html__('Both, ACDC and Express Checkout', 'event_espresso'),
120
+			],
121
+			[
122
+				'html_name'  => "eep_checkout_type_option_$pm_slug",
123
+				'html_id'    => "eep_checkout_type_option_$pm_slug",
124
+				'html_class' => "eep-checkout-type-option-$pm_slug",
125
+				'required'   => true,
126
+				'default'    => PayPalExtraMetaManager::getPmOption(
127
+					$this->pm_instance,
128
+					Domain::META_KEY_ALLOWED_CHECKOUT_TYPE
129
+				),
130
+			]
131
+		);
132
+		return $form_parameters;
133
+	}
134
+
135
+
136
+	/**
137
+	 * Add a checkout type select.
138
+	 *
139
+	 * @param array $form_parameters
140
+	 * @return array
141
+	 * @throws EE_Error
142
+	 * @throws ReflectionException
143
+	 */
144
+	public function addFundingOptions(array $form_parameters): array
145
+	{
146
+		$pm_slug = $this->pm_instance->slug();
147
+		// Section to be displayed if onboard.
148
+		$form_parameters['extra_meta_inputs'][ Domain::META_KEY_FUNDING_OPTIONS ] = new EE_Checkbox_Multi_Input(
149
+			[
150
+				'venmo'       => esc_html__('Venmo', 'event_espresso'),
151
+				'paylater'    => esc_html__('PayLater', 'event_espresso'),
152
+				'bancontact'  => esc_html__('Bancontact', 'event_espresso'),
153
+				'blik'        => esc_html__('BLIK', 'event_espresso'),
154
+				'eps'         => esc_html__('EPS', 'event_espresso'),
155
+				'giropay'     => esc_html__('giropay', 'event_espresso'),
156
+				'ideal'       => esc_html__('iDEAL', 'event_espresso'),
157
+				'mercadopago' => esc_html__('Mercado Pago', 'event_espresso'),
158
+				'mybank'      => esc_html__('MyBank', 'event_espresso'),
159
+				'p24'         => esc_html__('Przelewy24', 'event_espresso'),
160
+				'sepa'        => esc_html__('SEPA-Lastschrift', 'event_espresso'),
161
+				'sofort'      => esc_html__('Sofort', 'event_espresso'),
162
+			],
163
+			[
164
+				'html_name'       => "eep_checkout_funding_options_$pm_slug",
165
+				'html_id'         => "eep_checkout_funding_options_$pm_slug",
166
+				'html_class'      => "eep-checkout-funding-options-$pm_slug",
167
+				'html_label_text' => esc_html__('Enable PayPal funding options:', 'event_espresso'),
168
+				'default'         => ['venmo', 'paylater'],
169
+			]
170
+		);
171
+		return $form_parameters;
172
+	}
173
+
174
+
175
+	/**
176
+	 * Adds a button for clearing the PM metadata.
177
+	 *
178
+	 * @param EE_Payment_Method $pm_instance
179
+	 * @return void
180
+	 */
181
+	public function clearMetadataButton(EE_Payment_Method $pm_instance): void
182
+	{
183
+		try {
184
+			$is_onboard = EED_PayPalOnboard::isOnboard($pm_instance);
185
+			if ($is_onboard) {
186
+				return;
187
+			}
188
+			$button_text = sprintf(
189
+				esc_html__('Clear %1$s metadata', 'event_espresso'),
190
+				$pm_instance->admin_name()
191
+			);
192
+			$this->add_subsections(
193
+				[
194
+					'clear_pm_metadata' => new EE_Form_Section_HTML(
195
+						EEH_HTML::tr(
196
+							EEH_HTML::th(esc_html__('Clear PM metadata ?', 'event_espresso')) .
197
+							EEH_HTML::td(
198
+								EEH_HTML::link(
199
+									'',
200
+									$button_text,
201
+									$button_text,
202
+									'eea_clear_metadata_' . $pm_instance->slug(),
203
+									'espresso-button button button--secondary'
204
+								)
205
+							)
206
+						)
207
+					),
208
+				],
209
+				'PMD_order',
210
+				false
211
+			);
212
+		} catch (EE_Error $e) {
213
+			// Don't add the button if there's some error.
214
+		}
215
+	}
216
+
217
+
218
+	/**
219
+	 * Toggles subsections depending on the OAuth status etc.
220
+	 *
221
+	 * @param EE_Payment_Method $pm_instance
222
+	 * @return void
223
+	 * @throws EE_Error
224
+	 */
225
+	private function toggleSubsections(EE_Payment_Method $pm_instance): void
226
+	{
227
+		$onboard = EED_PayPalOnboard::isOnboard($pm_instance);
228
+		// Don't allow changing the debug mode setting while connected.
229
+		if ($onboard) {
230
+			$debug_mode_input = $this->get_input('PMD_debug_mode', false);
231
+			if (method_exists($debug_mode_input, 'isDisabled')) {
232
+				$debug_mode_input->disable();
233
+			}
234
+		}
235
+	}
236 236
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
     {
113 113
         $pm_slug = $this->pm_instance->slug();
114 114
         // Section to be displayed if onboard.
115
-        $form_parameters['extra_meta_inputs'][ Domain::META_KEY_CHECKOUT_TYPE ] = new EE_Select_Input(
115
+        $form_parameters['extra_meta_inputs'][Domain::META_KEY_CHECKOUT_TYPE] = new EE_Select_Input(
116 116
             [
117 117
                 'express_checkout' => esc_html__('Express Checkout', 'event_espresso'),
118 118
                 'ppcp'             => esc_html__('Advanced Credit and Debit Card payments', 'event_espresso'),
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
     {
146 146
         $pm_slug = $this->pm_instance->slug();
147 147
         // Section to be displayed if onboard.
148
-        $form_parameters['extra_meta_inputs'][ Domain::META_KEY_FUNDING_OPTIONS ] = new EE_Checkbox_Multi_Input(
148
+        $form_parameters['extra_meta_inputs'][Domain::META_KEY_FUNDING_OPTIONS] = new EE_Checkbox_Multi_Input(
149 149
             [
150 150
                 'venmo'       => esc_html__('Venmo', 'event_espresso'),
151 151
                 'paylater'    => esc_html__('PayLater', 'event_espresso'),
@@ -193,13 +193,13 @@  discard block
 block discarded – undo
193 193
                 [
194 194
                     'clear_pm_metadata' => new EE_Form_Section_HTML(
195 195
                         EEH_HTML::tr(
196
-                            EEH_HTML::th(esc_html__('Clear PM metadata ?', 'event_espresso')) .
196
+                            EEH_HTML::th(esc_html__('Clear PM metadata ?', 'event_espresso')).
197 197
                             EEH_HTML::td(
198 198
                                 EEH_HTML::link(
199 199
                                     '',
200 200
                                     $button_text,
201 201
                                     $button_text,
202
-                                    'eea_clear_metadata_' . $pm_instance->slug(),
202
+                                    'eea_clear_metadata_'.$pm_instance->slug(),
203 203
                                     'espresso-button button button--secondary'
204 204
                                 )
205 205
                             )
Please login to merge, or discard this patch.
PaymentMethods/PayPalCommerce/PayPalCheckout/forms/BillingForm.php 2 patches
Indentation   +539 added lines, -539 removed lines patch added patch discarded remove patch
@@ -37,570 +37,570 @@
 block discarded – undo
37 37
  */
38 38
 class BillingForm extends EE_Billing_Attendee_Info_Form
39 39
 {
40
-    protected EE_Payment_Method $paypal_pmt;
40
+	protected EE_Payment_Method $paypal_pmt;
41 41
 
42
-    protected ?EE_Transaction   $transaction = null;
42
+	protected ?EE_Transaction   $transaction = null;
43 43
 
44
-    protected string            $checkout_type;
44
+	protected string            $checkout_type;
45 45
 
46
-    /**
47
-     * Filepath to template files
48
-     *
49
-     * @var string $template_path
50
-     */
51
-    protected string $template_path;
46
+	/**
47
+	 * Filepath to template files
48
+	 *
49
+	 * @var string $template_path
50
+	 */
51
+	protected string $template_path;
52 52
 
53 53
 
54
-    /**
55
-     * Class constructor.
56
-     *
57
-     * @param EE_Payment_Method $payment_method
58
-     * @param array             $options
59
-     * @throws EE_Error
60
-     * @throws ReflectionException
61
-     */
62
-    public function __construct(EE_Payment_Method $payment_method, array $options)
63
-    {
64
-        $this->paypal_pmt = $payment_method;
65
-        // Can't be too careful.
66
-        $this->transaction   = $options['transaction'] ?? null;
67
-        $this->template_path = $options['template_path'] ?? '';
68
-        $this->checkout_type = $payment_method->get_extra_meta(
69
-            Domain::META_KEY_CHECKOUT_TYPE,
70
-            true,
71
-            'express_checkout'
72
-        );
73
-        $pm_slug             = $payment_method->slug();
74
-        $parameters          = array_replace_recursive(
75
-            $options,
76
-            [
77
-                'name'        => 'PayPalCommerceBillingForm',
78
-                'html_id'     => 'pp-' . $pm_slug . '-billing-form',
79
-                'html_class'  => 'pp_commerce_billing_form',
80
-                'subsections' => [
81
-                    'eea_paypal_commerce_token' => new EE_Hidden_Input(
82
-                        [
83
-                            'html_id'   => 'eea-paypal-commerce-token',
84
-                            'html_name' => 'EEA_paymentToken',
85
-                            'default'   => '',
86
-                        ]
87
-                    ),
88
-                    'pp_order_nonce'            => new EE_Hidden_Input(
89
-                        [
90
-                            'html_id'   => 'eea-' . $pm_slug . '-order-nonce',
91
-                            'html_name' => 'pp_order_nonce',
92
-                            'default'   => '',
93
-                        ]
94
-                    ),
95
-                    'pp_order_id'               => new EE_Hidden_Input(
96
-                        [
97
-                            'html_id'   => 'eea-' . $pm_slug . '-order-id',
98
-                            'html_name' => 'pp_order_id',
99
-                            'default'   => '',
100
-                        ]
101
-                    ),
102
-                    'pp_order_status'           => new EE_Hidden_Input(
103
-                        [
104
-                            'html_id'   => 'eea-' . $pm_slug . '-order-status',
105
-                            'html_name' => 'pp_order_status',
106
-                            'default'   => '',
107
-                        ]
108
-                    ),
109
-                ],
110
-            ]
111
-        );
112
-        // Add data tags to the PP script.
113
-        add_filter('script_loader_tag', [$this, 'addDataTagsToScript'], 10, 2);
114
-        parent::__construct($payment_method, $parameters);
115
-        // Add and exclude other sections.
116
-        $this->addPaymentSections();
117
-        // Additional actions and/or filters.
118
-        $this->loadActionsAndFilters();
119
-    }
54
+	/**
55
+	 * Class constructor.
56
+	 *
57
+	 * @param EE_Payment_Method $payment_method
58
+	 * @param array             $options
59
+	 * @throws EE_Error
60
+	 * @throws ReflectionException
61
+	 */
62
+	public function __construct(EE_Payment_Method $payment_method, array $options)
63
+	{
64
+		$this->paypal_pmt = $payment_method;
65
+		// Can't be too careful.
66
+		$this->transaction   = $options['transaction'] ?? null;
67
+		$this->template_path = $options['template_path'] ?? '';
68
+		$this->checkout_type = $payment_method->get_extra_meta(
69
+			Domain::META_KEY_CHECKOUT_TYPE,
70
+			true,
71
+			'express_checkout'
72
+		);
73
+		$pm_slug             = $payment_method->slug();
74
+		$parameters          = array_replace_recursive(
75
+			$options,
76
+			[
77
+				'name'        => 'PayPalCommerceBillingForm',
78
+				'html_id'     => 'pp-' . $pm_slug . '-billing-form',
79
+				'html_class'  => 'pp_commerce_billing_form',
80
+				'subsections' => [
81
+					'eea_paypal_commerce_token' => new EE_Hidden_Input(
82
+						[
83
+							'html_id'   => 'eea-paypal-commerce-token',
84
+							'html_name' => 'EEA_paymentToken',
85
+							'default'   => '',
86
+						]
87
+					),
88
+					'pp_order_nonce'            => new EE_Hidden_Input(
89
+						[
90
+							'html_id'   => 'eea-' . $pm_slug . '-order-nonce',
91
+							'html_name' => 'pp_order_nonce',
92
+							'default'   => '',
93
+						]
94
+					),
95
+					'pp_order_id'               => new EE_Hidden_Input(
96
+						[
97
+							'html_id'   => 'eea-' . $pm_slug . '-order-id',
98
+							'html_name' => 'pp_order_id',
99
+							'default'   => '',
100
+						]
101
+					),
102
+					'pp_order_status'           => new EE_Hidden_Input(
103
+						[
104
+							'html_id'   => 'eea-' . $pm_slug . '-order-status',
105
+							'html_name' => 'pp_order_status',
106
+							'default'   => '',
107
+						]
108
+					),
109
+				],
110
+			]
111
+		);
112
+		// Add data tags to the PP script.
113
+		add_filter('script_loader_tag', [$this, 'addDataTagsToScript'], 10, 2);
114
+		parent::__construct($payment_method, $parameters);
115
+		// Add and exclude other sections.
116
+		$this->addPaymentSections();
117
+		// Additional actions and/or filters.
118
+		$this->loadActionsAndFilters();
119
+	}
120 120
 
121 121
 
122
-    /**
123
-     * Add PayPal payment sections.
124
-     *
125
-     * @return void
126
-     * @throws EE_Error
127
-     * @throws ReflectionException
128
-     */
129
-    public function addPaymentSections(): void
130
-    {
131
-        // Exclude the default billing form fields.
132
-        $this->exclude(
133
-            [
134
-                'first_name',
135
-                'last_name',
136
-                'email',
137
-            ]
138
-        );
139
-        // Add PayPal Hosted Fields.
140
-        if (! empty($this->checkout_type) && $this->checkout_type !== 'express_checkout') {
141
-            $this->addAdvancedCardFields();
142
-        }
143
-        // Add payment types separator, if both are enabled.
144
-        if ($this->checkout_type === 'all') {
145
-            $this->addTypesSeparator();
146
-        }
147
-        // Add PayPal Buttons section.
148
-        if ($this->checkout_type !== 'ppcp') {
149
-            $this->add_subsections(
150
-                [
151
-                    'paypal_commerce_pm_form' => $this->addPayPalCheckout(),
152
-                ]
153
-            );
154
-        }
155
-        // Exclude the rest billing form fields if the payment type is express checkout.
156
-        if ($this->checkout_type === 'express_checkout') {
157
-            $this->exclude(
158
-                [
159
-                    'address',
160
-                    'address2',
161
-                    'state',
162
-                    'phone',
163
-                    'city',
164
-                    'country',
165
-                    'zip',
166
-                ]
167
-            );
168
-            // Remove the Info subsection.
169
-            add_filter('FHEE__EE_Form_Section_Proper___construct__options_array', [$this, 'excludeInfoSubsection']);
170
-        }
171
-        $this->add_subsections(
172
-            [
173
-                'debug_content' => $this->addDebugContent($this->paypal_pmt),
174
-            ]
175
-        );
176
-    }
122
+	/**
123
+	 * Add PayPal payment sections.
124
+	 *
125
+	 * @return void
126
+	 * @throws EE_Error
127
+	 * @throws ReflectionException
128
+	 */
129
+	public function addPaymentSections(): void
130
+	{
131
+		// Exclude the default billing form fields.
132
+		$this->exclude(
133
+			[
134
+				'first_name',
135
+				'last_name',
136
+				'email',
137
+			]
138
+		);
139
+		// Add PayPal Hosted Fields.
140
+		if (! empty($this->checkout_type) && $this->checkout_type !== 'express_checkout') {
141
+			$this->addAdvancedCardFields();
142
+		}
143
+		// Add payment types separator, if both are enabled.
144
+		if ($this->checkout_type === 'all') {
145
+			$this->addTypesSeparator();
146
+		}
147
+		// Add PayPal Buttons section.
148
+		if ($this->checkout_type !== 'ppcp') {
149
+			$this->add_subsections(
150
+				[
151
+					'paypal_commerce_pm_form' => $this->addPayPalCheckout(),
152
+				]
153
+			);
154
+		}
155
+		// Exclude the rest billing form fields if the payment type is express checkout.
156
+		if ($this->checkout_type === 'express_checkout') {
157
+			$this->exclude(
158
+				[
159
+					'address',
160
+					'address2',
161
+					'state',
162
+					'phone',
163
+					'city',
164
+					'country',
165
+					'zip',
166
+				]
167
+			);
168
+			// Remove the Info subsection.
169
+			add_filter('FHEE__EE_Form_Section_Proper___construct__options_array', [$this, 'excludeInfoSubsection']);
170
+		}
171
+		$this->add_subsections(
172
+			[
173
+				'debug_content' => $this->addDebugContent($this->paypal_pmt),
174
+			]
175
+		);
176
+	}
177 177
 
178 178
 
179
-    /**
180
-     * Additional actions and/or filters.
181
-     *
182
-     * @return void
183
-     */
184
-    public function loadActionsAndFilters(): void
185
-    {
186
-        add_filter(
187
-            'FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form',
188
-            [__CLASS__, 'excludeBillingFormFields'],
189
-            10,
190
-            2
191
-        );
192
-    }
179
+	/**
180
+	 * Additional actions and/or filters.
181
+	 *
182
+	 * @return void
183
+	 */
184
+	public function loadActionsAndFilters(): void
185
+	{
186
+		add_filter(
187
+			'FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form',
188
+			[__CLASS__, 'excludeBillingFormFields'],
189
+			10,
190
+			2
191
+		);
192
+	}
193 193
 
194 194
 
195
-    /**
196
-     * Filter out billing form fields if pay button was used.
197
-     *
198
-     * @param EE_Billing_Info_Form $billing_form
199
-     * @param EE_Payment_Method    $payment_method
200
-     * @return EE_Billing_Info_Form
201
-     */
202
-    public static function excludeBillingFormFields(
203
-        EE_Billing_Info_Form $billing_form,
204
-        EE_Payment_Method    $payment_method
205
-    ): EE_Billing_Info_Form {
206
-        $request        = LoaderFactory::getShared(Request::class);
207
-        $request_params = $request->requestParams();
208
-        // Only the PPC billing form.
209
-        if (! $billing_form instanceof BillingForm) {
210
-            return $billing_form;
211
-        }
212
-        // Make sure the billing form subsections have correct names.
213
-        $inputs = $billing_form->inputs_in_subsections();
214
-        if (
215
-            ! empty($request_params['process_form_submission'])
216
-            && $request_params['process_form_submission'] === '1'
217
-            && ! empty($request_params['eep_ppc_skip_form_validation'])
218
-        ) {
219
-            // Hide card info fields.
220
-            $billing_form->exclude(
221
-                [
222
-                    'pp_name_on_card',
223
-                    'address',
224
-                    'address2',
225
-                    'state',
226
-                    'phone',
227
-                    'city',
228
-                    'country',
229
-                    'zip',
230
-                ]
231
-            );
232
-        }
233
-        return $billing_form;
234
-    }
195
+	/**
196
+	 * Filter out billing form fields if pay button was used.
197
+	 *
198
+	 * @param EE_Billing_Info_Form $billing_form
199
+	 * @param EE_Payment_Method    $payment_method
200
+	 * @return EE_Billing_Info_Form
201
+	 */
202
+	public static function excludeBillingFormFields(
203
+		EE_Billing_Info_Form $billing_form,
204
+		EE_Payment_Method    $payment_method
205
+	): EE_Billing_Info_Form {
206
+		$request        = LoaderFactory::getShared(Request::class);
207
+		$request_params = $request->requestParams();
208
+		// Only the PPC billing form.
209
+		if (! $billing_form instanceof BillingForm) {
210
+			return $billing_form;
211
+		}
212
+		// Make sure the billing form subsections have correct names.
213
+		$inputs = $billing_form->inputs_in_subsections();
214
+		if (
215
+			! empty($request_params['process_form_submission'])
216
+			&& $request_params['process_form_submission'] === '1'
217
+			&& ! empty($request_params['eep_ppc_skip_form_validation'])
218
+		) {
219
+			// Hide card info fields.
220
+			$billing_form->exclude(
221
+				[
222
+					'pp_name_on_card',
223
+					'address',
224
+					'address2',
225
+					'state',
226
+					'phone',
227
+					'city',
228
+					'country',
229
+					'zip',
230
+				]
231
+			);
232
+		}
233
+		return $billing_form;
234
+	}
235 235
 
236 236
 
237
-    /**
238
-     * Add advanced card & debit card fields.
239
-     *
240
-     * @return void
241
-     * @throws EE_Error|ReflectionException
242
-     */
243
-    public function addAdvancedCardFields(): void
244
-    {
245
-        $pm_slug = $this->paypal_pmt->slug();
246
-        $this->add_subsections(
247
-            [
248
-                'pp_card_number'     => new EE_Form_Section_HTML(
249
-                    EEH_HTML::label(
250
-                        esc_html__('Card Number', 'event_espresso'),
251
-                        "$pm_slug-card-number-lbl",
252
-                        "$pm_slug-card-fields",
253
-                        "",
254
-                        'for="' . $pm_slug . '-card-number"'
255
-                    ) .
256
-                    EEH_HTML::p(
257
-                        "",
258
-                        "$pm_slug-card-number",
259
-                        "card_field $pm_slug-card-fields"
260
-                    )
261
-                ),
262
-                'pp_expiration_date' => new EE_Form_Section_HTML(
263
-                    EEH_HTML::label(
264
-                        esc_html__('Expiration Date', 'event_espresso'),
265
-                        "$pm_slug-expiration-date-lbl",
266
-                        "$pm_slug-card-fields",
267
-                        "",
268
-                        'for="' . $pm_slug . '-expiration-date"'
269
-                    ) .
270
-                    EEH_HTML::p(
271
-                        "",
272
-                        "$pm_slug-expiration-date",
273
-                        "card_field $pm_slug-card-fields"
274
-                    )
275
-                ),
276
-                'pp_card_cvv'        => new EE_Form_Section_HTML(
277
-                    EEH_HTML::label(
278
-                        esc_html__('CVV', 'event_espresso'),
279
-                        "$pm_slug-cvv-lbl",
280
-                        "$pm_slug-card-fields",
281
-                        "",
282
-                        'for="' . $pm_slug . '-cvv"'
283
-                    ) .
284
-                    EEH_HTML::p(
285
-                        "",
286
-                        "$pm_slug-cvv",
287
-                        "card_field $pm_slug-card-fields"
288
-                    )
289
-                ),
290
-                'pp_name_on_card'    => new EE_Text_Input(
291
-                    [
292
-                        'html_label_text' => esc_html__('Name On Card', 'event_espresso'),
293
-                        'html_id'         => $pm_slug . '-card-holder-name',
294
-                        'html_name'       => 'card-holder-name',
295
-                        'html_class'      => '',
296
-                        'required'        => true,
297
-                    ]
298
-                ),
299
-            ]
300
-        );
301
-        // Add the submit button at the end.
302
-        $this->add_subsections(
303
-            [
304
-                'pp_cc_submit' => new EE_Submit_Input(
305
-                    [
306
-                        'html_label_text' => esc_html__('Submit', 'event_espresso'),
307
-                        'html_id'         => $pm_slug,
308
-                        'html_class'      => 'eep-ppc-btn',
309
-                    ]
310
-                ),
311
-            ],
312
-            'phone',
313
-            false
314
-        );
315
-    }
237
+	/**
238
+	 * Add advanced card & debit card fields.
239
+	 *
240
+	 * @return void
241
+	 * @throws EE_Error|ReflectionException
242
+	 */
243
+	public function addAdvancedCardFields(): void
244
+	{
245
+		$pm_slug = $this->paypal_pmt->slug();
246
+		$this->add_subsections(
247
+			[
248
+				'pp_card_number'     => new EE_Form_Section_HTML(
249
+					EEH_HTML::label(
250
+						esc_html__('Card Number', 'event_espresso'),
251
+						"$pm_slug-card-number-lbl",
252
+						"$pm_slug-card-fields",
253
+						"",
254
+						'for="' . $pm_slug . '-card-number"'
255
+					) .
256
+					EEH_HTML::p(
257
+						"",
258
+						"$pm_slug-card-number",
259
+						"card_field $pm_slug-card-fields"
260
+					)
261
+				),
262
+				'pp_expiration_date' => new EE_Form_Section_HTML(
263
+					EEH_HTML::label(
264
+						esc_html__('Expiration Date', 'event_espresso'),
265
+						"$pm_slug-expiration-date-lbl",
266
+						"$pm_slug-card-fields",
267
+						"",
268
+						'for="' . $pm_slug . '-expiration-date"'
269
+					) .
270
+					EEH_HTML::p(
271
+						"",
272
+						"$pm_slug-expiration-date",
273
+						"card_field $pm_slug-card-fields"
274
+					)
275
+				),
276
+				'pp_card_cvv'        => new EE_Form_Section_HTML(
277
+					EEH_HTML::label(
278
+						esc_html__('CVV', 'event_espresso'),
279
+						"$pm_slug-cvv-lbl",
280
+						"$pm_slug-card-fields",
281
+						"",
282
+						'for="' . $pm_slug . '-cvv"'
283
+					) .
284
+					EEH_HTML::p(
285
+						"",
286
+						"$pm_slug-cvv",
287
+						"card_field $pm_slug-card-fields"
288
+					)
289
+				),
290
+				'pp_name_on_card'    => new EE_Text_Input(
291
+					[
292
+						'html_label_text' => esc_html__('Name On Card', 'event_espresso'),
293
+						'html_id'         => $pm_slug . '-card-holder-name',
294
+						'html_name'       => 'card-holder-name',
295
+						'html_class'      => '',
296
+						'required'        => true,
297
+					]
298
+				),
299
+			]
300
+		);
301
+		// Add the submit button at the end.
302
+		$this->add_subsections(
303
+			[
304
+				'pp_cc_submit' => new EE_Submit_Input(
305
+					[
306
+						'html_label_text' => esc_html__('Submit', 'event_espresso'),
307
+						'html_id'         => $pm_slug,
308
+						'html_class'      => 'eep-ppc-btn',
309
+					]
310
+				),
311
+			],
312
+			'phone',
313
+			false
314
+		);
315
+	}
316 316
 
317 317
 
318
-    /**
319
-     * Add advanced card & debit card fields.
320
-     *
321
-     * @return void
322
-     * @throws EE_Error|ReflectionException
323
-     */
324
-    public function addTypesSeparator(): void
325
-    {
326
-        $this->add_subsections(
327
-            [
328
-                'pp_payment_types_separator' => new EE_Form_Section_HTML(
329
-                    EEH_HTML::div(
330
-                        EEH_HTML::div(
331
-                            ' ',
332
-                            'eep-' . $this->paypal_pmt->slug() . '-payments-separator',
333
-                            'eep-ppc-separator-line eep-left-floating'
334
-                        ) .
335
-                        EEH_HTML::div(
336
-                            esc_html__(' or ', 'event_espresso'),
337
-                            'eep-' . $this->paypal_pmt->slug() . '-separator-text',
338
-                            'eep-ppc-separator-text1 eep-mid-floating'
339
-                        ) . EEH_HTML::div(
340
-                            ' ',
341
-                            'eep-' . $this->paypal_pmt->slug() . '-payments-separator',
342
-                            'eep-ppc-separator-line eep-right-floating'
343
-                        ),
344
-                        'eep-ppc-separator-holder',
345
-                        'eep-ppc-separator-holder'
346
-                    )
347
-                ),
348
-            ]
349
-        );
350
-    }
318
+	/**
319
+	 * Add advanced card & debit card fields.
320
+	 *
321
+	 * @return void
322
+	 * @throws EE_Error|ReflectionException
323
+	 */
324
+	public function addTypesSeparator(): void
325
+	{
326
+		$this->add_subsections(
327
+			[
328
+				'pp_payment_types_separator' => new EE_Form_Section_HTML(
329
+					EEH_HTML::div(
330
+						EEH_HTML::div(
331
+							' ',
332
+							'eep-' . $this->paypal_pmt->slug() . '-payments-separator',
333
+							'eep-ppc-separator-line eep-left-floating'
334
+						) .
335
+						EEH_HTML::div(
336
+							esc_html__(' or ', 'event_espresso'),
337
+							'eep-' . $this->paypal_pmt->slug() . '-separator-text',
338
+							'eep-ppc-separator-text1 eep-mid-floating'
339
+						) . EEH_HTML::div(
340
+							' ',
341
+							'eep-' . $this->paypal_pmt->slug() . '-payments-separator',
342
+							'eep-ppc-separator-line eep-right-floating'
343
+						),
344
+						'eep-ppc-separator-holder',
345
+						'eep-ppc-separator-holder'
346
+					)
347
+				),
348
+			]
349
+		);
350
+	}
351 351
 
352 352
 
353
-    /**
354
-     * Exclude the info subsection from the PPC checkout form.
355
-     *
356
-     * @param array $options_array
357
-     * @return array
358
-     * @throws EE_Error
359
-     * @throws ReflectionException
360
-     */
361
-    public function excludeInfoSubsection(array $options_array): array
362
-    {
363
-        if (
364
-            ! empty($options_array['html_id'])
365
-            && $options_array['html_id'] === 'spco-payment-method-info-' . $this->paypal_pmt->slug()
366
-        ) {
367
-            if (! empty($options_array['subsections']) && isset($options_array['subsections']['info'])) {
368
-                unset($options_array['subsections']['info']);
369
-            }
370
-        }
371
-        return $options_array;
372
-    }
353
+	/**
354
+	 * Exclude the info subsection from the PPC checkout form.
355
+	 *
356
+	 * @param array $options_array
357
+	 * @return array
358
+	 * @throws EE_Error
359
+	 * @throws ReflectionException
360
+	 */
361
+	public function excludeInfoSubsection(array $options_array): array
362
+	{
363
+		if (
364
+			! empty($options_array['html_id'])
365
+			&& $options_array['html_id'] === 'spco-payment-method-info-' . $this->paypal_pmt->slug()
366
+		) {
367
+			if (! empty($options_array['subsections']) && isset($options_array['subsections']['info'])) {
368
+				unset($options_array['subsections']['info']);
369
+			}
370
+		}
371
+		return $options_array;
372
+	}
373 373
 
374 374
 
375
-    /**
376
-     * Possibly adds debug content to PayPal commerce billing form.
377
-     *
378
-     * @param EE_Payment_Method $paypal_pm
379
-     * @return EE_Form_Section_Base
380
-     * @throws EE_Error|ReflectionException
381
-     */
382
-    public function addDebugContent(EE_Payment_Method $paypal_pm): EE_Form_Section_Base
383
-    {
384
-        if ($paypal_pm->debug_mode()) {
385
-            return new EE_Form_Section_Proper(
386
-                [
387
-                    'layout_strategy' => new EE_Template_Layout(
388
-                        [
389
-                            'layout_template_file' => $this->template_path . 'debugInfo.template.php',
390
-                            'template_args'        => [],
391
-                        ]
392
-                    ),
393
-                ]
394
-            );
395
-        }
396
-        return new EE_Form_Section_HTML();
397
-    }
375
+	/**
376
+	 * Possibly adds debug content to PayPal commerce billing form.
377
+	 *
378
+	 * @param EE_Payment_Method $paypal_pm
379
+	 * @return EE_Form_Section_Base
380
+	 * @throws EE_Error|ReflectionException
381
+	 */
382
+	public function addDebugContent(EE_Payment_Method $paypal_pm): EE_Form_Section_Base
383
+	{
384
+		if ($paypal_pm->debug_mode()) {
385
+			return new EE_Form_Section_Proper(
386
+				[
387
+					'layout_strategy' => new EE_Template_Layout(
388
+						[
389
+							'layout_template_file' => $this->template_path . 'debugInfo.template.php',
390
+							'template_args'        => [],
391
+						]
392
+					),
393
+				]
394
+			);
395
+		}
396
+		return new EE_Form_Section_HTML();
397
+	}
398 398
 
399 399
 
400
-    /**
401
-     * Add PayPal checkout buttons.
402
-     *
403
-     * @return EE_Form_Section_Proper
404
-     * @throws EE_Error
405
-     * @throws ReflectionException
406
-     * @throws Exception
407
-     */
408
-    public function addPayPalCheckout(): EE_Form_Section_Proper
409
-    {
410
-        $template_args['pm_slug'] = $this->paypal_pmt->slug();
411
-        return new EE_Form_Section_Proper(
412
-            [
413
-                'layout_strategy' => new EE_Template_Layout(
414
-                    [
415
-                        'layout_template_file' => $this->template_path . 'paymentButtons.template.php',
416
-                        'template_args'        => $template_args,
417
-                    ]
418
-                ),
419
-            ]
420
-        );
421
-    }
400
+	/**
401
+	 * Add PayPal checkout buttons.
402
+	 *
403
+	 * @return EE_Form_Section_Proper
404
+	 * @throws EE_Error
405
+	 * @throws ReflectionException
406
+	 * @throws Exception
407
+	 */
408
+	public function addPayPalCheckout(): EE_Form_Section_Proper
409
+	{
410
+		$template_args['pm_slug'] = $this->paypal_pmt->slug();
411
+		return new EE_Form_Section_Proper(
412
+			[
413
+				'layout_strategy' => new EE_Template_Layout(
414
+					[
415
+						'layout_template_file' => $this->template_path . 'paymentButtons.template.php',
416
+						'template_args'        => $template_args,
417
+					]
418
+				),
419
+			]
420
+		);
421
+	}
422 422
 
423 423
 
424
-    /**
425
-     * Load scripts and localize data needed for this form.
426
-     *
427
-     * @param $tag
428
-     * @param $handle
429
-     * @return string
430
-     * @throws EE_Error
431
-     * @throws ReflectionException
432
-     */
433
-    public function addDataTagsToScript($tag, $handle): string
434
-    {
435
-        if ($handle === 'eea_paypal_commerce_js_lib') {
436
-            $bn_code  = PayPalExtraMetaManager::getPmOption($this->_pm_instance, Domain::META_KEY_BN_CODE);
437
-            $response = EED_PayPalCommerce::requestClientToken($this->paypal_pmt);
438
-            if (empty($response['client_token'])) {
439
-                return $tag;
440
-            }
441
-            $client_token = $response['client_token'];
442
-            $attributes   = " data-partner-attribution-id=\"$bn_code\" data-client-token=\"$client_token\"";
443
-            $tag          = str_replace('></script>', $attributes . '></script>', $tag);
444
-        }
445
-        return $tag;
446
-    }
424
+	/**
425
+	 * Load scripts and localize data needed for this form.
426
+	 *
427
+	 * @param $tag
428
+	 * @param $handle
429
+	 * @return string
430
+	 * @throws EE_Error
431
+	 * @throws ReflectionException
432
+	 */
433
+	public function addDataTagsToScript($tag, $handle): string
434
+	{
435
+		if ($handle === 'eea_paypal_commerce_js_lib') {
436
+			$bn_code  = PayPalExtraMetaManager::getPmOption($this->_pm_instance, Domain::META_KEY_BN_CODE);
437
+			$response = EED_PayPalCommerce::requestClientToken($this->paypal_pmt);
438
+			if (empty($response['client_token'])) {
439
+				return $tag;
440
+			}
441
+			$client_token = $response['client_token'];
442
+			$attributes   = " data-partner-attribution-id=\"$bn_code\" data-client-token=\"$client_token\"";
443
+			$tag          = str_replace('></script>', $attributes . '></script>', $tag);
444
+		}
445
+		return $tag;
446
+	}
447 447
 
448 448
 
449
-    /**
450
-     * Load scripts and localize data needed for this form.
451
-     *
452
-     * @return void
453
-     * @throws EE_Error
454
-     * @throws ReflectionException
455
-     * @throws Exception
456
-     */
457
-    public function enqueue_js(): void
458
-    {
459
-        // Setup default values
460
-        $client_id_key   = Domain::META_KEY_CLIENT_ID;
461
-        $merchant_id     = false;
462
-        // Override the above if third party integration
463
-        if (EED_PayPalCommerce::isThirdParty($this->_pm_instance)) {
464
-            $client_id_key = Domain::META_KEY_PARTNER_CLIENT_ID;
465
-            $merchant_id   = PayPalExtraMetaManager::getPmOption(
466
-                $this->_pm_instance,
467
-                Domain::META_KEY_SELLER_MERCHANT_ID
468
-            );
469
-        }
470
-        // Setup query args
471
-        $url_params = [
472
-            'client-id'   => PayPalExtraMetaManager::getPmOption($this->_pm_instance, $client_id_key),
473
-            'currency'    => CurrencyManager::currencyCode(),
474
-            'components'  => implode(',', ['buttons', 'hosted-fields']),
475
-            'intent'      => 'capture',
476
-            'merchant-id' => $merchant_id,
477
-        ];
478
-        // Which funding methods are active?
479
-        $enabled_funding = $this->_pm_instance->get_extra_meta(
480
-            Domain::META_KEY_FUNDING_OPTIONS,
481
-            true,
482
-            Domain::DEFAULT_FUNDING_OPTIONS
483
-        );
484
-        // Any funding method not enabled should be disabled.
485
-        $disabled_funding = array_diff(Domain::FUNDING_OPTIONS, $enabled_funding);
486
-        // Any funding options enabled?
487
-        if (count($enabled_funding) > 0) {
488
-            $url_params['enable-funding'] = implode(',', $enabled_funding);
489
-        }
490
-        // Any funding options disabled?
491
-        if (count($disabled_funding) > 0) {
492
-            $url_params['disable-funding'] = implode(',', $disabled_funding);
493
-        }
494
-        // Enqueue the PayPal JS
495
-        wp_enqueue_script(
496
-            'eea_paypal_commerce_js_lib',
497
-            add_query_arg($url_params, 'https://www.paypal.com/sdk/js'),
498
-            [],
499
-            null
500
-        );
501
-        wp_enqueue_script(
502
-            'eea_paypal_commerce_js',
503
-            EEP_PAYPAL_COMMERCE_URL . 'assets/js/paypal-commerce-payments.js',
504
-            ['eea_paypal_commerce_js_lib'],
505
-            EVENT_ESPRESSO_VERSION,
506
-            true
507
-        );
508
-        // Styles.
509
-        wp_enqueue_style(
510
-            'eea_paypal_checkout_form_styles',
511
-            EEP_PAYPAL_COMMERCE_URL . 'assets' . DS . 'css' . DS . 'eea-paypal-checkout.css',
512
-            [],
513
-            EVENT_ESPRESSO_VERSION
514
-        );
515
-        // Localize the script with our transaction data.
516
-        $parameters = $this->localizeParameters();
517
-        wp_localize_script('eea_paypal_commerce_js', 'eeaPPCommerceParameters', $parameters);
518
-        parent::enqueue_js();
519
-    }
449
+	/**
450
+	 * Load scripts and localize data needed for this form.
451
+	 *
452
+	 * @return void
453
+	 * @throws EE_Error
454
+	 * @throws ReflectionException
455
+	 * @throws Exception
456
+	 */
457
+	public function enqueue_js(): void
458
+	{
459
+		// Setup default values
460
+		$client_id_key   = Domain::META_KEY_CLIENT_ID;
461
+		$merchant_id     = false;
462
+		// Override the above if third party integration
463
+		if (EED_PayPalCommerce::isThirdParty($this->_pm_instance)) {
464
+			$client_id_key = Domain::META_KEY_PARTNER_CLIENT_ID;
465
+			$merchant_id   = PayPalExtraMetaManager::getPmOption(
466
+				$this->_pm_instance,
467
+				Domain::META_KEY_SELLER_MERCHANT_ID
468
+			);
469
+		}
470
+		// Setup query args
471
+		$url_params = [
472
+			'client-id'   => PayPalExtraMetaManager::getPmOption($this->_pm_instance, $client_id_key),
473
+			'currency'    => CurrencyManager::currencyCode(),
474
+			'components'  => implode(',', ['buttons', 'hosted-fields']),
475
+			'intent'      => 'capture',
476
+			'merchant-id' => $merchant_id,
477
+		];
478
+		// Which funding methods are active?
479
+		$enabled_funding = $this->_pm_instance->get_extra_meta(
480
+			Domain::META_KEY_FUNDING_OPTIONS,
481
+			true,
482
+			Domain::DEFAULT_FUNDING_OPTIONS
483
+		);
484
+		// Any funding method not enabled should be disabled.
485
+		$disabled_funding = array_diff(Domain::FUNDING_OPTIONS, $enabled_funding);
486
+		// Any funding options enabled?
487
+		if (count($enabled_funding) > 0) {
488
+			$url_params['enable-funding'] = implode(',', $enabled_funding);
489
+		}
490
+		// Any funding options disabled?
491
+		if (count($disabled_funding) > 0) {
492
+			$url_params['disable-funding'] = implode(',', $disabled_funding);
493
+		}
494
+		// Enqueue the PayPal JS
495
+		wp_enqueue_script(
496
+			'eea_paypal_commerce_js_lib',
497
+			add_query_arg($url_params, 'https://www.paypal.com/sdk/js'),
498
+			[],
499
+			null
500
+		);
501
+		wp_enqueue_script(
502
+			'eea_paypal_commerce_js',
503
+			EEP_PAYPAL_COMMERCE_URL . 'assets/js/paypal-commerce-payments.js',
504
+			['eea_paypal_commerce_js_lib'],
505
+			EVENT_ESPRESSO_VERSION,
506
+			true
507
+		);
508
+		// Styles.
509
+		wp_enqueue_style(
510
+			'eea_paypal_checkout_form_styles',
511
+			EEP_PAYPAL_COMMERCE_URL . 'assets' . DS . 'css' . DS . 'eea-paypal-checkout.css',
512
+			[],
513
+			EVENT_ESPRESSO_VERSION
514
+		);
515
+		// Localize the script with our transaction data.
516
+		$parameters = $this->localizeParameters();
517
+		wp_localize_script('eea_paypal_commerce_js', 'eeaPPCommerceParameters', $parameters);
518
+		parent::enqueue_js();
519
+	}
520 520
 
521 521
 
522
-    /**
523
-     * Form and return PayPal commerce parameters for script localization.
524
-     *
525
-     * @return array
526
-     * @throws EE_Error
527
-     * @throws ReflectionException
528
-     * @throws Exception
529
-     */
530
-    public function localizeParameters(): array
531
-    {
532
-        // Also tell the script about each instance of this PM.
533
-        $pm_versions            = [];
534
-        $active_payment_methods = EEM_Payment_Method::instance()->get_all_active(
535
-            EEM_Payment_Method::scope_cart,
536
-            [['PMD_slug' => ['LIKE', '%paypalcheckout%']]]
537
-        );
538
-        foreach ($active_payment_methods as $payment_method) {
539
-            $pm_versions[ $payment_method->slug() ] = [
540
-                'pm_slug' => $payment_method->slug(),
541
-            ];
542
-        }
543
-        // Convert money for a display format.
544
-        $decimal_places = CurrencyManager::getDecimalPlaces();
545
-        $org_country    = isset(EE_Registry::instance()->CFG->organization)
546
-                          && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
547
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
548
-            : 'US';
549
-        $transaction_id = $this->transaction instanceof EE_Transaction ? $this->transaction->ID() : 0;
550
-        $currency_code  = CurrencyManager::currencyCode();
551
-        return [
552
-            'pm_versions'            => $pm_versions,
553
-            'payment_currency'       => $currency_code,
554
-            'checkout_type'          => $this->checkout_type,
555
-            'currency_sign'          => EE_Registry::instance()->CFG->currency->sign,
556
-            'pp_order_nonce'         => wp_create_nonce(Domain::CAPTURE_ORDER_NONCE_NAME),
557
-            // The transaction ID is only used for logging errors.
558
-            'txn_id'                 => $transaction_id,
559
-            'org_country'            => $org_country,
560
-            'decimal_places'         => $decimal_places,
561
-            'site_name'              => get_bloginfo('name'),
562
-            'active_states'          => EED_PayPalCommerce::getActiveStates(),
563
-            'no_spco_error'          => esc_html__(
564
-                'It appears the SDK script was not loaded properly! Please refresh the page and try again or contact support.',
565
-                'event_espresso'
566
-            ),
567
-            'no_pm_error'            => esc_html__(
568
-                'It appears that PayPal Commerce checkout JavaScript was not loaded properly! Please refresh the page and try again or contact support. PayPal Commerce payments can\'t be processed.',
569
-                'event_espresso'
570
-            ),
571
-            'browser_not_supported'  => esc_html__(
572
-                'It appears that this browser is not supported by PayPal scripts. We apologize, but PayPal payments won\'t work in this browser version.',
573
-                'event_espresso'
574
-            ),
575
-            'get_token_error'        => esc_html__(
576
-                'There was an error while trying to get the payment token. Please refresh the page and try again or contact support.',
577
-                'event_espresso'
578
-            ),
579
-            'form_validation_notice' => esc_html__('Billing form information not valid.', 'event_espresso'),
580
-            'no_verification_token'  => esc_html__('Missing the Verification token.', 'event_espresso'),
581
-            'error_response'         => esc_html__('Error response received', 'event_espresso'),
582
-            'payment_error'          => esc_html__(
583
-                'There was an error with this payment. See the logs for details.',
584
-                'event_espresso'
585
-            ),
586
-            'no_order_id'            => esc_html__('No Order ID found.', 'event_espresso'),
587
-            'general_pp_error'       => esc_html__('PayPal form threw an error.', 'event_espresso'),
588
-            'hf_render_error'        => esc_html__('Hosted fields could not be rendered!', 'event_espresso'),
589
-            'pm_capture_error'       => esc_html__('Payment could not be captured!', 'event_espresso'),
590
-            'contact_support_msg'    => sprintf(
591
-                /* translators: %1$s: organization email, %2$s: the transaction ID */
592
-                esc_html__(
593
-                    'Please contact support (%1$s) for more details on this transaction #%2$s.',
594
-                    'event_espresso'
595
-                ),
596
-                EE_Registry::instance()->CFG->organization->get_pretty('email'),
597
-                $transaction_id
598
-            ),
599
-            'not_acdc_eligible'      => esc_html__(
600
-                'This merchant is not eligible for Advanced Card Fields checkout type.',
601
-                'event_espresso'
602
-            ),
603
-            'processor_response'     => esc_html__('Processor response: ', 'event_espresso'),
604
-        ];
605
-    }
522
+	/**
523
+	 * Form and return PayPal commerce parameters for script localization.
524
+	 *
525
+	 * @return array
526
+	 * @throws EE_Error
527
+	 * @throws ReflectionException
528
+	 * @throws Exception
529
+	 */
530
+	public function localizeParameters(): array
531
+	{
532
+		// Also tell the script about each instance of this PM.
533
+		$pm_versions            = [];
534
+		$active_payment_methods = EEM_Payment_Method::instance()->get_all_active(
535
+			EEM_Payment_Method::scope_cart,
536
+			[['PMD_slug' => ['LIKE', '%paypalcheckout%']]]
537
+		);
538
+		foreach ($active_payment_methods as $payment_method) {
539
+			$pm_versions[ $payment_method->slug() ] = [
540
+				'pm_slug' => $payment_method->slug(),
541
+			];
542
+		}
543
+		// Convert money for a display format.
544
+		$decimal_places = CurrencyManager::getDecimalPlaces();
545
+		$org_country    = isset(EE_Registry::instance()->CFG->organization)
546
+						  && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
547
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
548
+			: 'US';
549
+		$transaction_id = $this->transaction instanceof EE_Transaction ? $this->transaction->ID() : 0;
550
+		$currency_code  = CurrencyManager::currencyCode();
551
+		return [
552
+			'pm_versions'            => $pm_versions,
553
+			'payment_currency'       => $currency_code,
554
+			'checkout_type'          => $this->checkout_type,
555
+			'currency_sign'          => EE_Registry::instance()->CFG->currency->sign,
556
+			'pp_order_nonce'         => wp_create_nonce(Domain::CAPTURE_ORDER_NONCE_NAME),
557
+			// The transaction ID is only used for logging errors.
558
+			'txn_id'                 => $transaction_id,
559
+			'org_country'            => $org_country,
560
+			'decimal_places'         => $decimal_places,
561
+			'site_name'              => get_bloginfo('name'),
562
+			'active_states'          => EED_PayPalCommerce::getActiveStates(),
563
+			'no_spco_error'          => esc_html__(
564
+				'It appears the SDK script was not loaded properly! Please refresh the page and try again or contact support.',
565
+				'event_espresso'
566
+			),
567
+			'no_pm_error'            => esc_html__(
568
+				'It appears that PayPal Commerce checkout JavaScript was not loaded properly! Please refresh the page and try again or contact support. PayPal Commerce payments can\'t be processed.',
569
+				'event_espresso'
570
+			),
571
+			'browser_not_supported'  => esc_html__(
572
+				'It appears that this browser is not supported by PayPal scripts. We apologize, but PayPal payments won\'t work in this browser version.',
573
+				'event_espresso'
574
+			),
575
+			'get_token_error'        => esc_html__(
576
+				'There was an error while trying to get the payment token. Please refresh the page and try again or contact support.',
577
+				'event_espresso'
578
+			),
579
+			'form_validation_notice' => esc_html__('Billing form information not valid.', 'event_espresso'),
580
+			'no_verification_token'  => esc_html__('Missing the Verification token.', 'event_espresso'),
581
+			'error_response'         => esc_html__('Error response received', 'event_espresso'),
582
+			'payment_error'          => esc_html__(
583
+				'There was an error with this payment. See the logs for details.',
584
+				'event_espresso'
585
+			),
586
+			'no_order_id'            => esc_html__('No Order ID found.', 'event_espresso'),
587
+			'general_pp_error'       => esc_html__('PayPal form threw an error.', 'event_espresso'),
588
+			'hf_render_error'        => esc_html__('Hosted fields could not be rendered!', 'event_espresso'),
589
+			'pm_capture_error'       => esc_html__('Payment could not be captured!', 'event_espresso'),
590
+			'contact_support_msg'    => sprintf(
591
+				/* translators: %1$s: organization email, %2$s: the transaction ID */
592
+				esc_html__(
593
+					'Please contact support (%1$s) for more details on this transaction #%2$s.',
594
+					'event_espresso'
595
+				),
596
+				EE_Registry::instance()->CFG->organization->get_pretty('email'),
597
+				$transaction_id
598
+			),
599
+			'not_acdc_eligible'      => esc_html__(
600
+				'This merchant is not eligible for Advanced Card Fields checkout type.',
601
+				'event_espresso'
602
+			),
603
+			'processor_response'     => esc_html__('Processor response: ', 'event_espresso'),
604
+		];
605
+	}
606 606
 }
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
             $options,
76 76
             [
77 77
                 'name'        => 'PayPalCommerceBillingForm',
78
-                'html_id'     => 'pp-' . $pm_slug . '-billing-form',
78
+                'html_id'     => 'pp-'.$pm_slug.'-billing-form',
79 79
                 'html_class'  => 'pp_commerce_billing_form',
80 80
                 'subsections' => [
81 81
                     'eea_paypal_commerce_token' => new EE_Hidden_Input(
@@ -87,21 +87,21 @@  discard block
 block discarded – undo
87 87
                     ),
88 88
                     'pp_order_nonce'            => new EE_Hidden_Input(
89 89
                         [
90
-                            'html_id'   => 'eea-' . $pm_slug . '-order-nonce',
90
+                            'html_id'   => 'eea-'.$pm_slug.'-order-nonce',
91 91
                             'html_name' => 'pp_order_nonce',
92 92
                             'default'   => '',
93 93
                         ]
94 94
                     ),
95 95
                     'pp_order_id'               => new EE_Hidden_Input(
96 96
                         [
97
-                            'html_id'   => 'eea-' . $pm_slug . '-order-id',
97
+                            'html_id'   => 'eea-'.$pm_slug.'-order-id',
98 98
                             'html_name' => 'pp_order_id',
99 99
                             'default'   => '',
100 100
                         ]
101 101
                     ),
102 102
                     'pp_order_status'           => new EE_Hidden_Input(
103 103
                         [
104
-                            'html_id'   => 'eea-' . $pm_slug . '-order-status',
104
+                            'html_id'   => 'eea-'.$pm_slug.'-order-status',
105 105
                             'html_name' => 'pp_order_status',
106 106
                             'default'   => '',
107 107
                         ]
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
             ]
138 138
         );
139 139
         // Add PayPal Hosted Fields.
140
-        if (! empty($this->checkout_type) && $this->checkout_type !== 'express_checkout') {
140
+        if ( ! empty($this->checkout_type) && $this->checkout_type !== 'express_checkout') {
141 141
             $this->addAdvancedCardFields();
142 142
         }
143 143
         // Add payment types separator, if both are enabled.
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
         $request        = LoaderFactory::getShared(Request::class);
207 207
         $request_params = $request->requestParams();
208 208
         // Only the PPC billing form.
209
-        if (! $billing_form instanceof BillingForm) {
209
+        if ( ! $billing_form instanceof BillingForm) {
210 210
             return $billing_form;
211 211
         }
212 212
         // Make sure the billing form subsections have correct names.
@@ -251,8 +251,8 @@  discard block
 block discarded – undo
251 251
                         "$pm_slug-card-number-lbl",
252 252
                         "$pm_slug-card-fields",
253 253
                         "",
254
-                        'for="' . $pm_slug . '-card-number"'
255
-                    ) .
254
+                        'for="'.$pm_slug.'-card-number"'
255
+                    ).
256 256
                     EEH_HTML::p(
257 257
                         "",
258 258
                         "$pm_slug-card-number",
@@ -265,8 +265,8 @@  discard block
 block discarded – undo
265 265
                         "$pm_slug-expiration-date-lbl",
266 266
                         "$pm_slug-card-fields",
267 267
                         "",
268
-                        'for="' . $pm_slug . '-expiration-date"'
269
-                    ) .
268
+                        'for="'.$pm_slug.'-expiration-date"'
269
+                    ).
270 270
                     EEH_HTML::p(
271 271
                         "",
272 272
                         "$pm_slug-expiration-date",
@@ -279,8 +279,8 @@  discard block
 block discarded – undo
279 279
                         "$pm_slug-cvv-lbl",
280 280
                         "$pm_slug-card-fields",
281 281
                         "",
282
-                        'for="' . $pm_slug . '-cvv"'
283
-                    ) .
282
+                        'for="'.$pm_slug.'-cvv"'
283
+                    ).
284 284
                     EEH_HTML::p(
285 285
                         "",
286 286
                         "$pm_slug-cvv",
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
                 'pp_name_on_card'    => new EE_Text_Input(
291 291
                     [
292 292
                         'html_label_text' => esc_html__('Name On Card', 'event_espresso'),
293
-                        'html_id'         => $pm_slug . '-card-holder-name',
293
+                        'html_id'         => $pm_slug.'-card-holder-name',
294 294
                         'html_name'       => 'card-holder-name',
295 295
                         'html_class'      => '',
296 296
                         'required'        => true,
@@ -329,16 +329,16 @@  discard block
 block discarded – undo
329 329
                     EEH_HTML::div(
330 330
                         EEH_HTML::div(
331 331
                             ' ',
332
-                            'eep-' . $this->paypal_pmt->slug() . '-payments-separator',
332
+                            'eep-'.$this->paypal_pmt->slug().'-payments-separator',
333 333
                             'eep-ppc-separator-line eep-left-floating'
334
-                        ) .
334
+                        ).
335 335
                         EEH_HTML::div(
336 336
                             esc_html__(' or ', 'event_espresso'),
337
-                            'eep-' . $this->paypal_pmt->slug() . '-separator-text',
337
+                            'eep-'.$this->paypal_pmt->slug().'-separator-text',
338 338
                             'eep-ppc-separator-text1 eep-mid-floating'
339
-                        ) . EEH_HTML::div(
339
+                        ).EEH_HTML::div(
340 340
                             ' ',
341
-                            'eep-' . $this->paypal_pmt->slug() . '-payments-separator',
341
+                            'eep-'.$this->paypal_pmt->slug().'-payments-separator',
342 342
                             'eep-ppc-separator-line eep-right-floating'
343 343
                         ),
344 344
                         'eep-ppc-separator-holder',
@@ -362,9 +362,9 @@  discard block
 block discarded – undo
362 362
     {
363 363
         if (
364 364
             ! empty($options_array['html_id'])
365
-            && $options_array['html_id'] === 'spco-payment-method-info-' . $this->paypal_pmt->slug()
365
+            && $options_array['html_id'] === 'spco-payment-method-info-'.$this->paypal_pmt->slug()
366 366
         ) {
367
-            if (! empty($options_array['subsections']) && isset($options_array['subsections']['info'])) {
367
+            if ( ! empty($options_array['subsections']) && isset($options_array['subsections']['info'])) {
368 368
                 unset($options_array['subsections']['info']);
369 369
             }
370 370
         }
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
                 [
387 387
                     'layout_strategy' => new EE_Template_Layout(
388 388
                         [
389
-                            'layout_template_file' => $this->template_path . 'debugInfo.template.php',
389
+                            'layout_template_file' => $this->template_path.'debugInfo.template.php',
390 390
                             'template_args'        => [],
391 391
                         ]
392 392
                     ),
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
             [
413 413
                 'layout_strategy' => new EE_Template_Layout(
414 414
                     [
415
-                        'layout_template_file' => $this->template_path . 'paymentButtons.template.php',
415
+                        'layout_template_file' => $this->template_path.'paymentButtons.template.php',
416 416
                         'template_args'        => $template_args,
417 417
                     ]
418 418
                 ),
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
             }
441 441
             $client_token = $response['client_token'];
442 442
             $attributes   = " data-partner-attribution-id=\"$bn_code\" data-client-token=\"$client_token\"";
443
-            $tag          = str_replace('></script>', $attributes . '></script>', $tag);
443
+            $tag          = str_replace('></script>', $attributes.'></script>', $tag);
444 444
         }
445 445
         return $tag;
446 446
     }
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
         );
501 501
         wp_enqueue_script(
502 502
             'eea_paypal_commerce_js',
503
-            EEP_PAYPAL_COMMERCE_URL . 'assets/js/paypal-commerce-payments.js',
503
+            EEP_PAYPAL_COMMERCE_URL.'assets/js/paypal-commerce-payments.js',
504 504
             ['eea_paypal_commerce_js_lib'],
505 505
             EVENT_ESPRESSO_VERSION,
506 506
             true
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
         // Styles.
509 509
         wp_enqueue_style(
510 510
             'eea_paypal_checkout_form_styles',
511
-            EEP_PAYPAL_COMMERCE_URL . 'assets' . DS . 'css' . DS . 'eea-paypal-checkout.css',
511
+            EEP_PAYPAL_COMMERCE_URL.'assets'.DS.'css'.DS.'eea-paypal-checkout.css',
512 512
             [],
513 513
             EVENT_ESPRESSO_VERSION
514 514
         );
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
             [['PMD_slug' => ['LIKE', '%paypalcheckout%']]]
537 537
         );
538 538
         foreach ($active_payment_methods as $payment_method) {
539
-            $pm_versions[ $payment_method->slug() ] = [
539
+            $pm_versions[$payment_method->slug()] = [
540 540
                 'pm_slug' => $payment_method->slug(),
541 541
             ];
542 542
         }
Please login to merge, or discard this patch.
admin_pages/messages/help_tabs/messages_settings.help_tab.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -3,23 +3,23 @@
 block discarded – undo
3 3
 </p>
4 4
 <p>
5 5
     <?php esc_html_e(
6
-        'On its first activation, Event Espresso will automatically setup the core messenger (email) and message types (registration and payment).',
7
-        'event_espresso'
8
-    ); ?>
6
+		'On its first activation, Event Espresso will automatically setup the core messenger (email) and message types (registration and payment).',
7
+		'event_espresso'
8
+	); ?>
9 9
 </p>
10 10
 <p>
11 11
     <strong><?php esc_html_e('Recommendations', 'event_espresso'); ?></strong>
12 12
     <br />
13 13
     <?php esc_html_e(
14
-        'To learn more about the options on this page, take a look at the different tabs that appear on the left side of the page.',
15
-        'event_espresso'
16
-    ); ?>
14
+		'To learn more about the options on this page, take a look at the different tabs that appear on the left side of the page.',
15
+		'event_espresso'
16
+	); ?>
17 17
 </p>
18 18
 <p>
19 19
     <strong><?php esc_html_e('Screen Options', 'event_espresso'); ?></strong>
20 20
     <br />
21 21
     <?php esc_html_e(
22
-        'You can customize the information that is shown on this page by toggling the Screen Options tab. Then you can add or remove checkmarks to hide or show certain content.',
23
-        'event_espresso'
24
-    ); ?>
22
+		'You can customize the information that is shown on this page by toggling the Screen Options tab. Then you can add or remove checkmarks to hide or show certain content.',
23
+		'event_espresso'
24
+	); ?>
25 25
 </p>
Please login to merge, or discard this patch.
data_migration_scripts/4_1_0_stages/EE_DMS_4_1_0_org_options.dmsstage.php 1 patch
Indentation   +306 added lines, -306 removed lines patch added patch discarded remove patch
@@ -89,323 +89,323 @@
 block discarded – undo
89 89
  */
90 90
 class EE_DMS_4_1_0_org_options extends EE_Data_Migration_Script_Stage
91 91
 {
92
-    public function __construct()
93
-    {
94
-        $this->_pretty_name                        = esc_html__("Organization Options/Config", "event_espresso");
95
-        $this->_org_options_we_know_how_to_migrate = apply_filters(
96
-            'FHEE__EE_DMS_4_1_0_org_options__org_options_we_know_how_to_migrate',
97
-            $this->_org_options_we_know_how_to_migrate
98
-        );
99
-        parent::__construct();
100
-    }
92
+	public function __construct()
93
+	{
94
+		$this->_pretty_name                        = esc_html__("Organization Options/Config", "event_espresso");
95
+		$this->_org_options_we_know_how_to_migrate = apply_filters(
96
+			'FHEE__EE_DMS_4_1_0_org_options__org_options_we_know_how_to_migrate',
97
+			$this->_org_options_we_know_how_to_migrate
98
+		);
99
+		parent::__construct();
100
+	}
101 101
 
102 102
 
103
-    public function _migration_step($num_items_to_migrate = 50)
104
-    {
105
-        $items_actually_migrated = 0;
106
-        $old_org_options         = get_option('events_organization_settings');
107
-        foreach ($this->_org_options_we_know_how_to_migrate as $option_name) {
108
-            // only bother migrating if there's a setting to migrate. Otherwise we'll just use the default
109
-            if (isset($old_org_options[ $option_name ])) {
110
-                $this->_handle_org_option($option_name, $old_org_options[ $option_name ]);
111
-            }
112
-            if ($option_name == 'surcharge') {
113
-                $this->_insert_new_global_surcharge_price($old_org_options);
114
-            }
115
-            $items_actually_migrated++;
116
-        }
103
+	public function _migration_step($num_items_to_migrate = 50)
104
+	{
105
+		$items_actually_migrated = 0;
106
+		$old_org_options         = get_option('events_organization_settings');
107
+		foreach ($this->_org_options_we_know_how_to_migrate as $option_name) {
108
+			// only bother migrating if there's a setting to migrate. Otherwise we'll just use the default
109
+			if (isset($old_org_options[ $option_name ])) {
110
+				$this->_handle_org_option($option_name, $old_org_options[ $option_name ]);
111
+			}
112
+			if ($option_name == 'surcharge') {
113
+				$this->_insert_new_global_surcharge_price($old_org_options);
114
+			}
115
+			$items_actually_migrated++;
116
+		}
117 117
 
118
-        $success = EE_Config::instance()->update_espresso_config();
119
-        if (! $success) {
120
-            $this->add_error(
121
-                sprintf(
122
-                    esc_html__('Could not save EE Config during org options stage. Reason: %s', 'event_espresso'),
123
-                    EE_Error::get_notices(false)
124
-                )
125
-            );
126
-            EE_Error::overwrite_errors();
127
-        }
128
-        EE_Network_Config::instance()->update_config(false, false);
129
-        if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
130
-            // we may have added new pages and this might be necessary
131
-            flush_rewrite_rules();
132
-            $this->set_completed();
133
-        }
134
-        return $items_actually_migrated;
135
-    }
118
+		$success = EE_Config::instance()->update_espresso_config();
119
+		if (! $success) {
120
+			$this->add_error(
121
+				sprintf(
122
+					esc_html__('Could not save EE Config during org options stage. Reason: %s', 'event_espresso'),
123
+					EE_Error::get_notices(false)
124
+				)
125
+			);
126
+			EE_Error::overwrite_errors();
127
+		}
128
+		EE_Network_Config::instance()->update_config(false, false);
129
+		if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
130
+			// we may have added new pages and this might be necessary
131
+			flush_rewrite_rules();
132
+			$this->set_completed();
133
+		}
134
+		return $items_actually_migrated;
135
+	}
136 136
 
137 137
 
138
-    public function _count_records_to_migrate(): int
139
-    {
140
-        return (int) count($this->_org_options_we_know_how_to_migrate);
141
-    }
138
+	public function _count_records_to_migrate(): int
139
+	{
140
+		return (int) count($this->_org_options_we_know_how_to_migrate);
141
+	}
142 142
 
143 143
 
144
-    private function _handle_org_option($option_name, $value)
145
-    {
146
-        $c  = EE_Config::instance();
147
-        $cn = EE_Network_Config::instance();
148
-        switch ($option_name) {
149
-            case 'organization':
150
-                $c->organization->name = $value;
151
-                break;
152
-            case 'organization_street1':
153
-                $c->organization->address_1 = $value;
154
-                break;
155
-            case 'organization_street2':
156
-                $c->organization->address_2 = $value;
157
-                break;
158
-            case 'organization_city':
159
-                $c->organization->city = $value;
160
-                break;
161
-            case 'organization_state':
162
-                try {
163
-                    $state                   = $this->get_migration_script()->get_or_create_state($value);
164
-                    $state_id                = $state['STA_ID'];
165
-                    $c->organization->STA_ID = $state_id;
166
-                } catch (EE_Error $e) {
167
-                }
168
-                break;
169
-            case 'organization_zip':
170
-                $c->organization->zip = $value;
171
-                break;
172
-            case 'contact_email':
173
-                $c->organization->email = $value;
174
-                break;
175
-            case 'default_payment_status':
176
-                $c->registration->default_STS_ID =
177
-                    $this->get_migration_script()->convert_3_1_payment_status_to_4_1_STS_ID($value);
178
-                break;
179
-            case 'organization_country':
180
-                $iso                      = $this->get_migration_script()->get_iso_from_3_1_country_id($value);
181
-                $c->organization->CNT_ISO = $iso;
182
-                $country_row              = $this->get_migration_script()->get_or_create_country($iso);
183
-                if (! $country_row) {
184
-                    $this->add_error(
185
-                        sprintf(
186
-                            esc_html__(
187
-                                "Could not set country's currency config because no country exists for ISO %s",
188
-                                "event_espresso"
189
-                            ),
190
-                            $iso
191
-                        )
192
-                    );
193
-                }
194
-                // can't use EE_Currency_Config's handy constructor because the models are off-limits right now (and it uses them)
195
-                $c->currency->code    = $country_row['CNT_cur_code'];             // currency code: USD, CAD, EUR
196
-                $c->currency->name    = $country_row['CNT_cur_single'];           // Dollar
197
-                $c->currency->plural  = $country_row['CNT_cur_plural'];           // Dollars
198
-                $c->currency->sign    = $country_row['CNT_cur_sign'];             // currency sign: $
199
-                $c->currency->sign_b4 = filter_var(
200
-                    $country_row['CNT_cur_sign_b4'],
201
-                    FILTER_VALIDATE_BOOLEAN
202
-                );                                                                // currency sign before or after: $TRUE  or  FALSE$
203
-                $c->currency->dec_plc = (int) $country_row['CNT_cur_dec_plc'];    // decimal places: 2 = 0.00  3 = 0.000
204
-                $c->currency->dec_mrk =
205
-                    $country_row['CNT_cur_dec_mrk'];                              // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
206
-                $c->currency->thsnds  = $country_row['CNT_cur_thsnds'];
207
-                break;  // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
208
-            //  $c->currency = new EE_Currency_Config($c->organization->CNT_ISO);break;
209
-            //  case 'currency_symbol': ignore the currency symbol. we'll just go by their country.
210
-            //  $c->currency->sign = $value;break;
211
-            case 'show_pending_payment_options':
212
-                $c->registration->show_pending_payment_options = ($value == 'Y');
213
-                break;
214
-            // case 'display_address_in_regform':
215
-            //     $c->template_settings->display_address_in_regform = ($value == 'Y');
216
-            //     break;
217
-            case 'default_logo_url':
218
-                $c->organization->logo_url = $value;
219
-                break;
220
-            case 'event_page_id':
221
-                // also, find that post, and changes the shortcode in it from ESPRESSO_PAYMENTS
222
-                // to ESPRESSO_THANK_YOU
223
-                $reg_page_post               = get_post(absint($value));
224
-                $reg_page_post->post_content = str_replace(
225
-                    "[ESPRESSO_EVENTS]",
226
-                    "[ESPRESSO_CHECKOUT]",
227
-                    $reg_page_post->post_content
228
-                );
229
-                wp_update_post($reg_page_post);
230
-                $c->core->reg_page_id = $value;
231
-                break;
232
-            case 'return_url':
233
-                // also, find that post, and changes the shortcode in it from ESPRESSO_PAYMENTS
234
-                // to ESPRESSO_THANK_YOU
235
-                $thank_you_page_post               = get_post(absint($value));
236
-                $thank_you_page_post->post_content = str_replace(
237
-                    "[ESPRESSO_PAYMENTS]",
238
-                    "[ESPRESSO_THANK_YOU]",
239
-                    $thank_you_page_post->post_content
240
-                );
241
-                wp_update_post($thank_you_page_post);
242
-                $c->core->thank_you_page_id = absint($value);
243
-                break;
244
-            case 'cancel_return':
245
-                $c->core->cancel_page_id = absint($value);
144
+	private function _handle_org_option($option_name, $value)
145
+	{
146
+		$c  = EE_Config::instance();
147
+		$cn = EE_Network_Config::instance();
148
+		switch ($option_name) {
149
+			case 'organization':
150
+				$c->organization->name = $value;
151
+				break;
152
+			case 'organization_street1':
153
+				$c->organization->address_1 = $value;
154
+				break;
155
+			case 'organization_street2':
156
+				$c->organization->address_2 = $value;
157
+				break;
158
+			case 'organization_city':
159
+				$c->organization->city = $value;
160
+				break;
161
+			case 'organization_state':
162
+				try {
163
+					$state                   = $this->get_migration_script()->get_or_create_state($value);
164
+					$state_id                = $state['STA_ID'];
165
+					$c->organization->STA_ID = $state_id;
166
+				} catch (EE_Error $e) {
167
+				}
168
+				break;
169
+			case 'organization_zip':
170
+				$c->organization->zip = $value;
171
+				break;
172
+			case 'contact_email':
173
+				$c->organization->email = $value;
174
+				break;
175
+			case 'default_payment_status':
176
+				$c->registration->default_STS_ID =
177
+					$this->get_migration_script()->convert_3_1_payment_status_to_4_1_STS_ID($value);
178
+				break;
179
+			case 'organization_country':
180
+				$iso                      = $this->get_migration_script()->get_iso_from_3_1_country_id($value);
181
+				$c->organization->CNT_ISO = $iso;
182
+				$country_row              = $this->get_migration_script()->get_or_create_country($iso);
183
+				if (! $country_row) {
184
+					$this->add_error(
185
+						sprintf(
186
+							esc_html__(
187
+								"Could not set country's currency config because no country exists for ISO %s",
188
+								"event_espresso"
189
+							),
190
+							$iso
191
+						)
192
+					);
193
+				}
194
+				// can't use EE_Currency_Config's handy constructor because the models are off-limits right now (and it uses them)
195
+				$c->currency->code    = $country_row['CNT_cur_code'];             // currency code: USD, CAD, EUR
196
+				$c->currency->name    = $country_row['CNT_cur_single'];           // Dollar
197
+				$c->currency->plural  = $country_row['CNT_cur_plural'];           // Dollars
198
+				$c->currency->sign    = $country_row['CNT_cur_sign'];             // currency sign: $
199
+				$c->currency->sign_b4 = filter_var(
200
+					$country_row['CNT_cur_sign_b4'],
201
+					FILTER_VALIDATE_BOOLEAN
202
+				);                                                                // currency sign before or after: $TRUE  or  FALSE$
203
+				$c->currency->dec_plc = (int) $country_row['CNT_cur_dec_plc'];    // decimal places: 2 = 0.00  3 = 0.000
204
+				$c->currency->dec_mrk =
205
+					$country_row['CNT_cur_dec_mrk'];                              // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
206
+				$c->currency->thsnds  = $country_row['CNT_cur_thsnds'];
207
+				break;  // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
208
+			//  $c->currency = new EE_Currency_Config($c->organization->CNT_ISO);break;
209
+			//  case 'currency_symbol': ignore the currency symbol. we'll just go by their country.
210
+			//  $c->currency->sign = $value;break;
211
+			case 'show_pending_payment_options':
212
+				$c->registration->show_pending_payment_options = ($value == 'Y');
213
+				break;
214
+			// case 'display_address_in_regform':
215
+			//     $c->template_settings->display_address_in_regform = ($value == 'Y');
216
+			//     break;
217
+			case 'default_logo_url':
218
+				$c->organization->logo_url = $value;
219
+				break;
220
+			case 'event_page_id':
221
+				// also, find that post, and changes the shortcode in it from ESPRESSO_PAYMENTS
222
+				// to ESPRESSO_THANK_YOU
223
+				$reg_page_post               = get_post(absint($value));
224
+				$reg_page_post->post_content = str_replace(
225
+					"[ESPRESSO_EVENTS]",
226
+					"[ESPRESSO_CHECKOUT]",
227
+					$reg_page_post->post_content
228
+				);
229
+				wp_update_post($reg_page_post);
230
+				$c->core->reg_page_id = $value;
231
+				break;
232
+			case 'return_url':
233
+				// also, find that post, and changes the shortcode in it from ESPRESSO_PAYMENTS
234
+				// to ESPRESSO_THANK_YOU
235
+				$thank_you_page_post               = get_post(absint($value));
236
+				$thank_you_page_post->post_content = str_replace(
237
+					"[ESPRESSO_PAYMENTS]",
238
+					"[ESPRESSO_THANK_YOU]",
239
+					$thank_you_page_post->post_content
240
+				);
241
+				wp_update_post($thank_you_page_post);
242
+				$c->core->thank_you_page_id = absint($value);
243
+				break;
244
+			case 'cancel_return':
245
+				$c->core->cancel_page_id = absint($value);
246 246
 
247
-                break;
248
-            case 'notify_url':
249
-                $c->core->txn_page_id = absint($value);
250
-                break;
251
-            case 'use_captcha':
252
-                $c->registration->use_captcha = ($value == 'Y');
253
-                break;
254
-            case 'recaptcha_publickey':
255
-                $c->registration->recaptcha_publickey = $value;
256
-                break;
257
-            case 'recaptcha_privatekey':
258
-                $c->registration->recaptcha_privatekey = $value;
259
-                break;
260
-            case 'recaptcha_theme':
261
-                $c->registration->recaptcha_theme = $value;
262
-                break;
263
-            case 'recaptcha_width':
264
-                $c->registration->recaptcha_width = $value;
265
-                break;
266
-            case 'recaptcha_language':
267
-                $c->registration->recaptcha_language = $value;
268
-                break;
269
-            case 'espresso_dashboard_widget':
270
-                $c->admin->use_dashboard_widget = ($value == 'Y');
271
-                break;
272
-            case 'use_personnel_manager':
273
-                $c->admin->use_personnel_manager = ($value == 'Y');
274
-                break;
275
-            case 'use_event_timezones':
276
-                $c->admin->use_event_timezones = ($value == 'Y');
277
-                break;
278
-            case 'affiliate_id':
279
-                $c->admin->affiliate_id = $value;
280
-                break;
281
-            case 'site_license_key':
282
-                $cn->core->site_license_key = $value;
283
-                break;
284
-            default:
285
-                do_action('AHEE__EE_DMS_4_1_0__handle_org_option', $option_name, $value);
286
-        }
287
-    }
247
+				break;
248
+			case 'notify_url':
249
+				$c->core->txn_page_id = absint($value);
250
+				break;
251
+			case 'use_captcha':
252
+				$c->registration->use_captcha = ($value == 'Y');
253
+				break;
254
+			case 'recaptcha_publickey':
255
+				$c->registration->recaptcha_publickey = $value;
256
+				break;
257
+			case 'recaptcha_privatekey':
258
+				$c->registration->recaptcha_privatekey = $value;
259
+				break;
260
+			case 'recaptcha_theme':
261
+				$c->registration->recaptcha_theme = $value;
262
+				break;
263
+			case 'recaptcha_width':
264
+				$c->registration->recaptcha_width = $value;
265
+				break;
266
+			case 'recaptcha_language':
267
+				$c->registration->recaptcha_language = $value;
268
+				break;
269
+			case 'espresso_dashboard_widget':
270
+				$c->admin->use_dashboard_widget = ($value == 'Y');
271
+				break;
272
+			case 'use_personnel_manager':
273
+				$c->admin->use_personnel_manager = ($value == 'Y');
274
+				break;
275
+			case 'use_event_timezones':
276
+				$c->admin->use_event_timezones = ($value == 'Y');
277
+				break;
278
+			case 'affiliate_id':
279
+				$c->admin->affiliate_id = $value;
280
+				break;
281
+			case 'site_license_key':
282
+				$cn->core->site_license_key = $value;
283
+				break;
284
+			default:
285
+				do_action('AHEE__EE_DMS_4_1_0__handle_org_option', $option_name, $value);
286
+		}
287
+	}
288 288
 
289 289
 
290
-    /**
291
-     * Creates a 4.1 member price discount
292
-     *
293
-     * @param array $org_options
294
-     * @return void
295
-     * @global wpdb $wpdb
296
-     */
297
-    private function _insert_new_global_surcharge_price(array $org_options): void
298
-    {
299
-        $amount = (float) $org_options['surcharge'];
300
-        // dont create a price if the surcharge is 0
301
-        if ($amount <= .01) {
302
-            return;
303
-        }
304
-        if ($org_options['surcharge_type'] == 'flat_rate') {
305
-            $price_type = EE_DMS_4_1_0_prices::price_type_flat_surcharge;
306
-        } else {
307
-            $price_type = EE_DMS_4_1_0_prices::price_type_percent_surcharge;
308
-        }
309
-        global $wpdb;
310
-        $cols_n_values = [
311
-            'PRT_ID'         => $price_type,
312
-            'PRC_amount'     => $amount,
313
-            'PRC_name'       => $org_options['surcharge_text'],
314
-            'PRC_is_default' => true,
315
-            'PRC_overrides'  => false,
316
-            'PRC_order'      => 100,
317
-            'PRC_deleted'    => false,
318
-            'PRC_parent'     => null,
290
+	/**
291
+	 * Creates a 4.1 member price discount
292
+	 *
293
+	 * @param array $org_options
294
+	 * @return void
295
+	 * @global wpdb $wpdb
296
+	 */
297
+	private function _insert_new_global_surcharge_price(array $org_options): void
298
+	{
299
+		$amount = (float) $org_options['surcharge'];
300
+		// dont create a price if the surcharge is 0
301
+		if ($amount <= .01) {
302
+			return;
303
+		}
304
+		if ($org_options['surcharge_type'] == 'flat_rate') {
305
+			$price_type = EE_DMS_4_1_0_prices::price_type_flat_surcharge;
306
+		} else {
307
+			$price_type = EE_DMS_4_1_0_prices::price_type_percent_surcharge;
308
+		}
309
+		global $wpdb;
310
+		$cols_n_values = [
311
+			'PRT_ID'         => $price_type,
312
+			'PRC_amount'     => $amount,
313
+			'PRC_name'       => $org_options['surcharge_text'],
314
+			'PRC_is_default' => true,
315
+			'PRC_overrides'  => false,
316
+			'PRC_order'      => 100,
317
+			'PRC_deleted'    => false,
318
+			'PRC_parent'     => null,
319 319
 
320
-        ];
321
-        $data_types    = [
322
-            '%d',// PRT_ID
323
-            '%f',// PRT_amount
324
-            '%s',// PRC_name
325
-            '%d',// PRC_is_default
326
-            '%d',// PRC_overrides
327
-            '%d',// PRC_order
328
-            '%d',// PRC_deleted
329
-            '%d',// PRC_parent
330
-        ];
331
-        $price_table   = $wpdb->prefix . "esp_price";
332
-        $success       = $wpdb->insert($price_table, $cols_n_values, $data_types);
333
-        if (! $success) {
334
-            $this->add_error(
335
-                $this->get_migration_script()->_create_error_message_for_db_insertion(
336
-                    'org_options',
337
-                    [
338
-                        'surcharge'      => $org_options['surcharge'],
339
-                        'surcharge_type' => $org_options['surcharge_type'],
340
-                        'surcharge_text' => $org_options['surcharge_text'],
341
-                    ],
342
-                    $price_table,
343
-                    $cols_n_values,
344
-                    $data_types
345
-                )
346
-            );
347
-        }
348
-    }
320
+		];
321
+		$data_types    = [
322
+			'%d',// PRT_ID
323
+			'%f',// PRT_amount
324
+			'%s',// PRC_name
325
+			'%d',// PRC_is_default
326
+			'%d',// PRC_overrides
327
+			'%d',// PRC_order
328
+			'%d',// PRC_deleted
329
+			'%d',// PRC_parent
330
+		];
331
+		$price_table   = $wpdb->prefix . "esp_price";
332
+		$success       = $wpdb->insert($price_table, $cols_n_values, $data_types);
333
+		if (! $success) {
334
+			$this->add_error(
335
+				$this->get_migration_script()->_create_error_message_for_db_insertion(
336
+					'org_options',
337
+					[
338
+						'surcharge'      => $org_options['surcharge'],
339
+						'surcharge_type' => $org_options['surcharge_type'],
340
+						'surcharge_text' => $org_options['surcharge_text'],
341
+					],
342
+					$price_table,
343
+					$cols_n_values,
344
+					$data_types
345
+				)
346
+			);
347
+		}
348
+	}
349 349
 
350 350
 
351
-    protected $_org_options_we_know_how_to_migrate = [
352
-        'organization',
353
-        'organization_street1',
354
-        'organization_street2',
355
-        'organization_city',
356
-        'organization_state',
357
-        'organization_zip',
358
-        'contact_email',
359
-        'default_mail',
360
-        'payment_subject',
361
-        'payment_message',
362
-        'message',
363
-        'default_payment_status',
364
-        'surcharge',                                // used during price migration
365
-        'country_id',                               // used during price migration
366
-        'organization_country',
367
-        //'currency_symbol',
368
-        'expire_on_registration_end',
369
-        'email_before_payment',
370
-        'email_fancy_headers',
371
-        //'enable_default_style',                   // unused
372
-        'event_ssl_active',
373
-        'selected_style',
374
-        'show_pending_payment_options',
375
-        'show_reg_footer',
376
-        'skip_confirmation_page',
377
-        'allow_mer_discounts',                      // no equiv
378
-        'allow_mer_vouchers',                       // no equiv
379
-        'display_short_description_in_event_list',
380
-        //'display_description_on_multi_reg_page',  // unused
381
-        'display_address_in_event_list',
382
-        //'display_address_in_regform',             // unused
383
-        //'use_custom_post_types',                    // no equiv
384
-        'display_ical_download',
385
-        'display_featured_image',
386
-        'themeroller',
387
-        'default_logo_url',
388
-        'event_page_id',
389
-        'return_url',
390
-        'cancel_return',
391
-        'notify_url',
392
-        'events_in_dasboard',
393
-        'events_in_dashboard',
394
-        'use_captcha',
395
-        'recaptcha_publickey',
396
-        'recaptcha_privatekey',
397
-        'recaptcha_theme',
398
-        'recaptcha_width',
399
-        'recaptcha_language',
400
-        'espresso_dashboard_widget',
401
-        'time_reg_limit',
402
-        //'use_attendee_pre_approval',              // removed in 4.1- instead this is factored into the default reg status
403
-        'use_personnel_manager',                    // no equiv
404
-        'use_event_timezones',
405
-        //'full_logging',                           // unused
406
-        'surcharge_type',                           // used during price migration
407
-        'surcharge_text',                           // used during price migration
408
-        'affiliate_id',
409
-        'site_license_key',
410
-    ];
351
+	protected $_org_options_we_know_how_to_migrate = [
352
+		'organization',
353
+		'organization_street1',
354
+		'organization_street2',
355
+		'organization_city',
356
+		'organization_state',
357
+		'organization_zip',
358
+		'contact_email',
359
+		'default_mail',
360
+		'payment_subject',
361
+		'payment_message',
362
+		'message',
363
+		'default_payment_status',
364
+		'surcharge',                                // used during price migration
365
+		'country_id',                               // used during price migration
366
+		'organization_country',
367
+		//'currency_symbol',
368
+		'expire_on_registration_end',
369
+		'email_before_payment',
370
+		'email_fancy_headers',
371
+		//'enable_default_style',                   // unused
372
+		'event_ssl_active',
373
+		'selected_style',
374
+		'show_pending_payment_options',
375
+		'show_reg_footer',
376
+		'skip_confirmation_page',
377
+		'allow_mer_discounts',                      // no equiv
378
+		'allow_mer_vouchers',                       // no equiv
379
+		'display_short_description_in_event_list',
380
+		//'display_description_on_multi_reg_page',  // unused
381
+		'display_address_in_event_list',
382
+		//'display_address_in_regform',             // unused
383
+		//'use_custom_post_types',                    // no equiv
384
+		'display_ical_download',
385
+		'display_featured_image',
386
+		'themeroller',
387
+		'default_logo_url',
388
+		'event_page_id',
389
+		'return_url',
390
+		'cancel_return',
391
+		'notify_url',
392
+		'events_in_dasboard',
393
+		'events_in_dashboard',
394
+		'use_captcha',
395
+		'recaptcha_publickey',
396
+		'recaptcha_privatekey',
397
+		'recaptcha_theme',
398
+		'recaptcha_width',
399
+		'recaptcha_language',
400
+		'espresso_dashboard_widget',
401
+		'time_reg_limit',
402
+		//'use_attendee_pre_approval',              // removed in 4.1- instead this is factored into the default reg status
403
+		'use_personnel_manager',                    // no equiv
404
+		'use_event_timezones',
405
+		//'full_logging',                           // unused
406
+		'surcharge_type',                           // used during price migration
407
+		'surcharge_text',                           // used during price migration
408
+		'affiliate_id',
409
+		'site_license_key',
410
+	];
411 411
 }
Please login to merge, or discard this patch.
core/EE_Front_Controller.core.php 1 patch
Indentation   +516 added lines, -516 removed lines patch added patch discarded remove patch
@@ -20,520 +20,520 @@
 block discarded – undo
20 20
  */
21 21
 final class EE_Front_Controller
22 22
 {
23
-    /**
24
-     * @var string
25
-     */
26
-    private $_template_path;
27
-
28
-    /**
29
-     * @var string
30
-     */
31
-    private $_template;
32
-
33
-    /**
34
-     * @type EE_Registry
35
-     */
36
-    protected $Registry;
37
-
38
-    /**
39
-     * @type EE_Request_Handler
40
-     */
41
-    protected $Request_Handler;
42
-
43
-    /**
44
-     * @type EE_Module_Request_Router
45
-     */
46
-    protected $Module_Request_Router;
47
-
48
-    /**
49
-     * @type CurrentPage
50
-     */
51
-    protected $current_page;
52
-
53
-
54
-    /**
55
-     *    class constructor
56
-     *    should fire after shortcode, module, addon, or other plugin's default priority init phases have run
57
-     *
58
-     * @access    public
59
-     * @param EE_Registry              $Registry
60
-     * @param CurrentPage              $EspressoPage
61
-     * @param EE_Module_Request_Router $Module_Request_Router
62
-     */
63
-    public function __construct(
64
-        EE_Registry $Registry,
65
-        CurrentPage $EspressoPage,
66
-        EE_Module_Request_Router $Module_Request_Router
67
-    ) {
68
-        $this->Registry              = $Registry;
69
-        $this->current_page          = $EspressoPage;
70
-        $this->Module_Request_Router = $Module_Request_Router;
71
-        // load other resources and begin to actually run shortcodes and modules
72
-        // analyse the incoming WP request
73
-        add_action('parse_request', [$this, 'get_request'], 1);
74
-        // process request with module factory
75
-        add_action('pre_get_posts', [$this, 'pre_get_posts']);
76
-        // before headers sent
77
-        add_action('wp', [$this, 'wp'], 5);
78
-        // primarily used to process any content shortcodes
79
-        add_action('template_redirect', [$this, 'templateRedirect'], 999);
80
-        // header
81
-        add_action('wp_head', [$this, 'header_meta_tag'], 5);
82
-        add_action('wp_print_scripts', [$this, 'wp_print_scripts']);
83
-        add_filter('template_include', [$this, 'template_include'], 1);
84
-        // display errors
85
-        add_action('loop_start', [$this, 'display_errors'], 2);
86
-        // the content
87
-        // add_filter( 'the_content', array( $this, 'the_content' ), 5, 1 );
88
-        // exclude our private cpt comments
89
-        add_filter('comments_clauses', [$this, 'filter_wp_comments']);
90
-        // make sure any ajax requests will respect the url schema
91
-        // when requests are made against admin-ajax.php (http:// or https://)
92
-        add_filter('admin_url', [$this, 'maybe_force_admin_ajax_ssl'], 200);
93
-        // action hook EE
94
-        do_action('AHEE__EE_Front_Controller__construct__done', $this);
95
-    }
96
-
97
-
98
-    /**
99
-     * @return EE_Request_Handler
100
-     * @deprecated 4.10.14.p
101
-     */
102
-    public function Request_Handler()
103
-    {
104
-        if (! $this->Request_Handler instanceof EE_Request_Handler) {
105
-            $this->Request_Handler = LoaderFactory::getLoader()->getShared('EE_Request_Handler');
106
-        }
107
-        return $this->Request_Handler;
108
-    }
109
-
110
-
111
-    /**
112
-     * @return EE_Module_Request_Router
113
-     */
114
-    public function Module_Request_Router()
115
-    {
116
-        return $this->Module_Request_Router;
117
-    }
118
-
119
-
120
-    /**
121
-     * @return LegacyShortcodesManager
122
-     * @deprecated 4.10.14.p
123
-     */
124
-    public function getLegacyShortcodesManager()
125
-    {
126
-        return EE_Config::getLegacyShortcodesManager();
127
-    }
128
-
129
-
130
-
131
-
132
-
133
-    /***********************************************        INIT ACTION HOOK         ***********************************************/
134
-    /**
135
-     * filter_wp_comments
136
-     * This simply makes sure that any "private" EE CPTs do not have their comments show up in any wp comment
137
-     * widgets/queries done on frontend
138
-     *
139
-     * @param array $clauses array of comment clauses setup by WP_Comment_Query
140
-     * @return array array of comment clauses with modifications.
141
-     * @throws InvalidArgumentException
142
-     * @throws InvalidDataTypeException
143
-     * @throws InvalidInterfaceException
144
-     */
145
-    public function filter_wp_comments($clauses)
146
-    {
147
-        global $wpdb;
148
-        if (strpos($clauses['join'], $wpdb->posts) !== false) {
149
-            /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
150
-            $custom_post_types = LoaderFactory::getLoader()->getShared(
151
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
152
-            );
153
-            $cpts              = $custom_post_types->getPrivateCustomPostTypes();
154
-            foreach ($cpts as $cpt => $details) {
155
-                $clauses['where'] .= $wpdb->prepare(" AND $wpdb->posts.post_type != %s", $cpt);
156
-            }
157
-        }
158
-        return $clauses;
159
-    }
160
-
161
-
162
-    /**
163
-     * this just makes sure that if the site is using ssl that we force that for any admin ajax calls from frontend
164
-     *
165
-     * @param string $url incoming url
166
-     * @return string         final assembled url
167
-     */
168
-    public function maybe_force_admin_ajax_ssl($url)
169
-    {
170
-        if (is_ssl() && preg_match('/admin-ajax.php/', $url)) {
171
-            $url = str_replace('http://', 'https://', $url);
172
-        }
173
-        return $url;
174
-    }
175
-
176
-
177
-
178
-
179
-
180
-
181
-    /***********************************************        WP_LOADED ACTION HOOK         ***********************************************/
182
-
183
-
184
-    /**
185
-     *    wp_loaded - should fire after shortcode, module, addon, or other plugin's have been registered and their
186
-     *    default priority init phases have run
187
-     *
188
-     * @access    public
189
-     * @return    void
190
-     */
191
-    public function wp_loaded()
192
-    {
193
-    }
194
-
195
-
196
-
197
-
198
-
199
-    /***********************************************        PARSE_REQUEST HOOK         ***********************************************/
200
-    /**
201
-     *    _get_request
202
-     *
203
-     * @access public
204
-     * @param WP $WP
205
-     * @return void
206
-     */
207
-    public function get_request(WP $WP)
208
-    {
209
-        static $done = false;
210
-        if ($done) {
211
-            return;
212
-        }
213
-        $done = true;
214
-        do_action('AHEE__EE_Front_Controller__get_request__start');
215
-        $this->current_page->parseQueryVars($WP);
216
-        do_action('AHEE__EE_Front_Controller__get_request__complete');
217
-    }
218
-
219
-
220
-    /**
221
-     *    pre_get_posts - basically a module factory for instantiating modules and selecting the final view template
222
-     *
223
-     * @access    public
224
-     * @param WP_Query $WP_Query
225
-     * @return    void
226
-     * @throws EE_Error
227
-     * @throws ReflectionException
228
-     */
229
-    public function pre_get_posts($WP_Query)
230
-    {
231
-        // only load Module_Request_Router if this is the main query
232
-        if (
233
-            $this->Module_Request_Router instanceof EE_Module_Request_Router
234
-            && $WP_Query->is_main_query()
235
-        ) {
236
-            // cycle thru module routes
237
-            while ($route = $this->Module_Request_Router->get_route($WP_Query)) {
238
-                // determine module and method for route
239
-                $module = $this->Module_Request_Router->resolve_route($route[0], $route[1]);
240
-                if ($module instanceof EED_Module) {
241
-                    // get registered view for route
242
-                    $this->_template_path = $this->Module_Request_Router->get_view($route);
243
-                    // grab module name
244
-                    $module_name = $module->module_name();
245
-                    // map the module to the module objects
246
-                    $this->Registry->modules->{$module_name} = $module;
247
-                }
248
-            }
249
-        }
250
-    }
251
-
252
-
253
-
254
-
255
-
256
-    /***********************************************        WP HOOK         ***********************************************/
257
-
258
-
259
-    /**
260
-     *    wp - basically last chance to do stuff before headers sent
261
-     *
262
-     * @access    public
263
-     * @return    void
264
-     */
265
-    public function wp()
266
-    {
267
-        AriaLiveAnnouncer::setHooks();
268
-    }
269
-
270
-
271
-
272
-    /***********************     GET_HEADER && WP_HEAD HOOK     ***********************/
273
-
274
-
275
-    /**
276
-     * callback for the "template_redirect" hook point
277
-     * checks sidebars for EE widgets
278
-     * loads resources and assets accordingly
279
-     *
280
-     * @return void
281
-     */
282
-    public function templateRedirect()
283
-    {
284
-        global $wp_query;
285
-        if (empty($wp_query->posts)) {
286
-            return;
287
-        }
288
-        // if we already know this is an espresso page, then load assets
289
-        $load_assets = $this->current_page->isEspressoPage();
290
-        // if we are already loading assets then just move along, otherwise check for widgets
291
-        $load_assets = $load_assets || $this->espresso_widgets_in_active_sidebars();
292
-        if ($load_assets) {
293
-            add_action('wp_enqueue_scripts', [$this, 'enqueueStyle']);
294
-            add_action('wp_enqueue_scripts', [$this, 'enqueueScripts']);
295
-        }
296
-
297
-        if (is_singular(EspressoPostType::EVENTS)) {
298
-            new FilterNextPreviousEventPostQuery();
299
-        }
300
-    }
301
-
302
-
303
-    /**
304
-     * builds list of active widgets then scans active sidebars looking for them
305
-     * returns true is an EE widget is found in an active sidebar
306
-     * Please Note: this does NOT mean that the sidebar or widget
307
-     * is actually in use in a given template, as that is unfortunately not known
308
-     * until a sidebar and it's widgets are actually loaded
309
-     *
310
-     * @return boolean
311
-     */
312
-    private function espresso_widgets_in_active_sidebars()
313
-    {
314
-        $espresso_widgets = [];
315
-        foreach ($this->Registry->widgets as $widget_class => $widget) {
316
-            $id_base = EspressoWidget::getIdBase($widget_class);
317
-            if (is_active_widget(false, false, $id_base)) {
318
-                $espresso_widgets[] = $id_base;
319
-            }
320
-        }
321
-        $all_sidebar_widgets = wp_get_sidebars_widgets();
322
-        foreach ($all_sidebar_widgets as $sidebar_widgets) {
323
-            if (is_array($sidebar_widgets) && ! empty($sidebar_widgets)) {
324
-                foreach ($sidebar_widgets as $sidebar_widget) {
325
-                    foreach ($espresso_widgets as $espresso_widget) {
326
-                        if (strpos($sidebar_widget, $espresso_widget) !== false) {
327
-                            return true;
328
-                        }
329
-                    }
330
-                }
331
-            }
332
-        }
333
-        return false;
334
-    }
335
-
336
-
337
-    /**
338
-     *    header_meta_tag
339
-     *
340
-     * @access    public
341
-     * @return    void
342
-     */
343
-    public function header_meta_tag()
344
-    {
345
-        print(
346
-        apply_filters(
347
-            'FHEE__EE_Front_Controller__header_meta_tag',
348
-            '<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n"
349
-        )
350
-        );
351
-
352
-        // let's exclude all event type taxonomy term archive pages from search engine indexing
353
-        // @see https://events.codebasehq.com/projects/event-espresso/tickets/10249
354
-        // also exclude all critical pages from indexing
355
-        if (
356
-            (
357
-                is_tax('espresso_event_type')
358
-                && get_option('blog_public') !== '0'
359
-            )
360
-            || is_page(EE_Registry::instance()->CFG->core->get_critical_pages_array())
361
-        ) {
362
-            print(
363
-            apply_filters(
364
-                'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type',
365
-                '<meta name="robots" content="noindex,follow" />' . "\n"
366
-            )
367
-            );
368
-        }
369
-    }
370
-
371
-
372
-    /**
373
-     * wp_print_scripts
374
-     *
375
-     * @return void
376
-     * @throws EE_Error
377
-     */
378
-    public function wp_print_scripts()
379
-    {
380
-        global $post;
381
-        if (
382
-            isset($post->EE_Event)
383
-            && $post->EE_Event instanceof EE_Event
384
-            && get_post_type() === EspressoPostType::EVENTS
385
-            && is_singular()
386
-        ) {
387
-            EEH_Schema::add_json_linked_data_for_event($post->EE_Event);
388
-        }
389
-    }
390
-
391
-
392
-    public function enqueueStyle()
393
-    {
394
-        wp_enqueue_style('espresso_default');
395
-        wp_enqueue_style('espresso_custom_css');
396
-    }
397
-
398
-
399
-    /***********************************************        WP_FOOTER         ***********************************************/
400
-
401
-
402
-    public function enqueueScripts()
403
-    {
404
-        wp_enqueue_script('espresso_core');
405
-    }
406
-
407
-
408
-    /**
409
-     * @param WP_Query $query
410
-     * @return void
411
-     * @throws DomainException
412
-     */
413
-    public function display_errors(WP_Query $query)
414
-    {
415
-        if (! $query->is_main_query()) {
416
-            return;
417
-        }
418
-        static $shown_already = false;
419
-        do_action('AHEE__EE_Front_Controller__display_errors__begin');
420
-        if (
421
-            ! $shown_already
422
-            && apply_filters('FHEE__EE_Front_Controller__display_errors', true)
423
-            && is_main_query()
424
-            && ! is_feed()
425
-            && in_the_loop()
426
-            && $this->current_page->isEspressoPage()
427
-        ) {
428
-            $shown_already = true;
429
-            if (did_action('wp_head')) {
430
-                echo wp_kses($this->printNotices(), AllowedTags::getAllowedTags());
431
-            } else {
432
-                // block enabled themes run their query loop before headers are sent
433
-                // so we need to add our notices onto the beginning of the content
434
-                add_filter('the_content', [$this, 'prependNotices'], 1);
435
-            }
436
-        }
437
-        do_action('AHEE__EE_Front_Controller__display_errors__end');
438
-    }
439
-
440
-
441
-    /**
442
-     * @param string $the_content
443
-     * @return string
444
-     * @since 4.10.30.p
445
-     */
446
-    public function prependNotices($the_content)
447
-    {
448
-        $notices = $this->printNotices();
449
-        return $notices ? $notices . $the_content : $the_content;
450
-    }
451
-
452
-
453
-    /**
454
-     * @return false|string
455
-     * @since 4.10.30.p
456
-     */
457
-    public function printNotices()
458
-    {
459
-        ob_start();
460
-        echo wp_kses(EE_Error::get_notices(), AllowedTags::getWithFormTags());
461
-        EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php');
462
-        return ob_get_clean();
463
-    }
464
-
465
-
466
-
467
-    /***********************************************        UTILITIES         ***********************************************/
468
-
469
-
470
-    /**
471
-     * @param bool|string $template_include_path
472
-     * @return string
473
-     * @throws EE_Error
474
-     * @throws ReflectionException
475
-     */
476
-    public function template_include($template_include_path = '')
477
-    {
478
-        if ($this->current_page->isEspressoPage()) {
479
-            // despite all helpers having autoloaders set, we need to manually load the template loader
480
-            // because there are some side effects in that class for triggering template tag functions
481
-            $this->Registry->load_helper('EEH_Template');
482
-            $this->_template_path = ! empty($this->_template_path)
483
-                ? basename($this->_template_path)
484
-                : basename((string) $template_include_path);
485
-            $template_path        = EEH_Template::locate_template($this->_template_path, [], false);
486
-            $this->_template_path = ! empty($template_path) ? $template_path : $template_include_path;
487
-            $this->_template      = basename($this->_template_path);
488
-            return $this->_template_path;
489
-        }
490
-        return $template_include_path;
491
-    }
492
-
493
-
494
-    /**
495
-     * @param bool $with_path
496
-     * @return    string
497
-     */
498
-    public function get_selected_template($with_path = false)
499
-    {
500
-        return $with_path ? $this->_template_path : $this->_template;
501
-    }
502
-
503
-    /**
504
-     * @param string $shortcode_class
505
-     * @param WP     $wp
506
-     * @throws ReflectionException
507
-     * @deprecated 4.9.26
508
-     */
509
-    public function initialize_shortcode($shortcode_class = '', WP $wp = null)
510
-    {
511
-        EE_Error::doing_it_wrong(
512
-            __METHOD__,
513
-            esc_html__(
514
-                'Usage is deprecated. Please use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::initializeShortcode() instead.',
515
-                'event_espresso'
516
-            ),
517
-            '4.9.26'
518
-        );
519
-        $this->getLegacyShortcodesManager()->initializeShortcode($shortcode_class, $wp);
520
-    }
521
-
522
-
523
-    /**
524
-     * @return void
525
-     * @deprecated 4.9.57.p
526
-     */
527
-    public function loadPersistentAdminNoticeManager()
528
-    {
529
-    }
530
-
531
-
532
-    /**
533
-     * @return void
534
-     * @deprecated 4.9.64.p
535
-     */
536
-    public function employ_CPT_Strategy()
537
-    {
538
-    }
23
+	/**
24
+	 * @var string
25
+	 */
26
+	private $_template_path;
27
+
28
+	/**
29
+	 * @var string
30
+	 */
31
+	private $_template;
32
+
33
+	/**
34
+	 * @type EE_Registry
35
+	 */
36
+	protected $Registry;
37
+
38
+	/**
39
+	 * @type EE_Request_Handler
40
+	 */
41
+	protected $Request_Handler;
42
+
43
+	/**
44
+	 * @type EE_Module_Request_Router
45
+	 */
46
+	protected $Module_Request_Router;
47
+
48
+	/**
49
+	 * @type CurrentPage
50
+	 */
51
+	protected $current_page;
52
+
53
+
54
+	/**
55
+	 *    class constructor
56
+	 *    should fire after shortcode, module, addon, or other plugin's default priority init phases have run
57
+	 *
58
+	 * @access    public
59
+	 * @param EE_Registry              $Registry
60
+	 * @param CurrentPage              $EspressoPage
61
+	 * @param EE_Module_Request_Router $Module_Request_Router
62
+	 */
63
+	public function __construct(
64
+		EE_Registry $Registry,
65
+		CurrentPage $EspressoPage,
66
+		EE_Module_Request_Router $Module_Request_Router
67
+	) {
68
+		$this->Registry              = $Registry;
69
+		$this->current_page          = $EspressoPage;
70
+		$this->Module_Request_Router = $Module_Request_Router;
71
+		// load other resources and begin to actually run shortcodes and modules
72
+		// analyse the incoming WP request
73
+		add_action('parse_request', [$this, 'get_request'], 1);
74
+		// process request with module factory
75
+		add_action('pre_get_posts', [$this, 'pre_get_posts']);
76
+		// before headers sent
77
+		add_action('wp', [$this, 'wp'], 5);
78
+		// primarily used to process any content shortcodes
79
+		add_action('template_redirect', [$this, 'templateRedirect'], 999);
80
+		// header
81
+		add_action('wp_head', [$this, 'header_meta_tag'], 5);
82
+		add_action('wp_print_scripts', [$this, 'wp_print_scripts']);
83
+		add_filter('template_include', [$this, 'template_include'], 1);
84
+		// display errors
85
+		add_action('loop_start', [$this, 'display_errors'], 2);
86
+		// the content
87
+		// add_filter( 'the_content', array( $this, 'the_content' ), 5, 1 );
88
+		// exclude our private cpt comments
89
+		add_filter('comments_clauses', [$this, 'filter_wp_comments']);
90
+		// make sure any ajax requests will respect the url schema
91
+		// when requests are made against admin-ajax.php (http:// or https://)
92
+		add_filter('admin_url', [$this, 'maybe_force_admin_ajax_ssl'], 200);
93
+		// action hook EE
94
+		do_action('AHEE__EE_Front_Controller__construct__done', $this);
95
+	}
96
+
97
+
98
+	/**
99
+	 * @return EE_Request_Handler
100
+	 * @deprecated 4.10.14.p
101
+	 */
102
+	public function Request_Handler()
103
+	{
104
+		if (! $this->Request_Handler instanceof EE_Request_Handler) {
105
+			$this->Request_Handler = LoaderFactory::getLoader()->getShared('EE_Request_Handler');
106
+		}
107
+		return $this->Request_Handler;
108
+	}
109
+
110
+
111
+	/**
112
+	 * @return EE_Module_Request_Router
113
+	 */
114
+	public function Module_Request_Router()
115
+	{
116
+		return $this->Module_Request_Router;
117
+	}
118
+
119
+
120
+	/**
121
+	 * @return LegacyShortcodesManager
122
+	 * @deprecated 4.10.14.p
123
+	 */
124
+	public function getLegacyShortcodesManager()
125
+	{
126
+		return EE_Config::getLegacyShortcodesManager();
127
+	}
128
+
129
+
130
+
131
+
132
+
133
+	/***********************************************        INIT ACTION HOOK         ***********************************************/
134
+	/**
135
+	 * filter_wp_comments
136
+	 * This simply makes sure that any "private" EE CPTs do not have their comments show up in any wp comment
137
+	 * widgets/queries done on frontend
138
+	 *
139
+	 * @param array $clauses array of comment clauses setup by WP_Comment_Query
140
+	 * @return array array of comment clauses with modifications.
141
+	 * @throws InvalidArgumentException
142
+	 * @throws InvalidDataTypeException
143
+	 * @throws InvalidInterfaceException
144
+	 */
145
+	public function filter_wp_comments($clauses)
146
+	{
147
+		global $wpdb;
148
+		if (strpos($clauses['join'], $wpdb->posts) !== false) {
149
+			/** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
150
+			$custom_post_types = LoaderFactory::getLoader()->getShared(
151
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
152
+			);
153
+			$cpts              = $custom_post_types->getPrivateCustomPostTypes();
154
+			foreach ($cpts as $cpt => $details) {
155
+				$clauses['where'] .= $wpdb->prepare(" AND $wpdb->posts.post_type != %s", $cpt);
156
+			}
157
+		}
158
+		return $clauses;
159
+	}
160
+
161
+
162
+	/**
163
+	 * this just makes sure that if the site is using ssl that we force that for any admin ajax calls from frontend
164
+	 *
165
+	 * @param string $url incoming url
166
+	 * @return string         final assembled url
167
+	 */
168
+	public function maybe_force_admin_ajax_ssl($url)
169
+	{
170
+		if (is_ssl() && preg_match('/admin-ajax.php/', $url)) {
171
+			$url = str_replace('http://', 'https://', $url);
172
+		}
173
+		return $url;
174
+	}
175
+
176
+
177
+
178
+
179
+
180
+
181
+	/***********************************************        WP_LOADED ACTION HOOK         ***********************************************/
182
+
183
+
184
+	/**
185
+	 *    wp_loaded - should fire after shortcode, module, addon, or other plugin's have been registered and their
186
+	 *    default priority init phases have run
187
+	 *
188
+	 * @access    public
189
+	 * @return    void
190
+	 */
191
+	public function wp_loaded()
192
+	{
193
+	}
194
+
195
+
196
+
197
+
198
+
199
+	/***********************************************        PARSE_REQUEST HOOK         ***********************************************/
200
+	/**
201
+	 *    _get_request
202
+	 *
203
+	 * @access public
204
+	 * @param WP $WP
205
+	 * @return void
206
+	 */
207
+	public function get_request(WP $WP)
208
+	{
209
+		static $done = false;
210
+		if ($done) {
211
+			return;
212
+		}
213
+		$done = true;
214
+		do_action('AHEE__EE_Front_Controller__get_request__start');
215
+		$this->current_page->parseQueryVars($WP);
216
+		do_action('AHEE__EE_Front_Controller__get_request__complete');
217
+	}
218
+
219
+
220
+	/**
221
+	 *    pre_get_posts - basically a module factory for instantiating modules and selecting the final view template
222
+	 *
223
+	 * @access    public
224
+	 * @param WP_Query $WP_Query
225
+	 * @return    void
226
+	 * @throws EE_Error
227
+	 * @throws ReflectionException
228
+	 */
229
+	public function pre_get_posts($WP_Query)
230
+	{
231
+		// only load Module_Request_Router if this is the main query
232
+		if (
233
+			$this->Module_Request_Router instanceof EE_Module_Request_Router
234
+			&& $WP_Query->is_main_query()
235
+		) {
236
+			// cycle thru module routes
237
+			while ($route = $this->Module_Request_Router->get_route($WP_Query)) {
238
+				// determine module and method for route
239
+				$module = $this->Module_Request_Router->resolve_route($route[0], $route[1]);
240
+				if ($module instanceof EED_Module) {
241
+					// get registered view for route
242
+					$this->_template_path = $this->Module_Request_Router->get_view($route);
243
+					// grab module name
244
+					$module_name = $module->module_name();
245
+					// map the module to the module objects
246
+					$this->Registry->modules->{$module_name} = $module;
247
+				}
248
+			}
249
+		}
250
+	}
251
+
252
+
253
+
254
+
255
+
256
+	/***********************************************        WP HOOK         ***********************************************/
257
+
258
+
259
+	/**
260
+	 *    wp - basically last chance to do stuff before headers sent
261
+	 *
262
+	 * @access    public
263
+	 * @return    void
264
+	 */
265
+	public function wp()
266
+	{
267
+		AriaLiveAnnouncer::setHooks();
268
+	}
269
+
270
+
271
+
272
+	/***********************     GET_HEADER && WP_HEAD HOOK     ***********************/
273
+
274
+
275
+	/**
276
+	 * callback for the "template_redirect" hook point
277
+	 * checks sidebars for EE widgets
278
+	 * loads resources and assets accordingly
279
+	 *
280
+	 * @return void
281
+	 */
282
+	public function templateRedirect()
283
+	{
284
+		global $wp_query;
285
+		if (empty($wp_query->posts)) {
286
+			return;
287
+		}
288
+		// if we already know this is an espresso page, then load assets
289
+		$load_assets = $this->current_page->isEspressoPage();
290
+		// if we are already loading assets then just move along, otherwise check for widgets
291
+		$load_assets = $load_assets || $this->espresso_widgets_in_active_sidebars();
292
+		if ($load_assets) {
293
+			add_action('wp_enqueue_scripts', [$this, 'enqueueStyle']);
294
+			add_action('wp_enqueue_scripts', [$this, 'enqueueScripts']);
295
+		}
296
+
297
+		if (is_singular(EspressoPostType::EVENTS)) {
298
+			new FilterNextPreviousEventPostQuery();
299
+		}
300
+	}
301
+
302
+
303
+	/**
304
+	 * builds list of active widgets then scans active sidebars looking for them
305
+	 * returns true is an EE widget is found in an active sidebar
306
+	 * Please Note: this does NOT mean that the sidebar or widget
307
+	 * is actually in use in a given template, as that is unfortunately not known
308
+	 * until a sidebar and it's widgets are actually loaded
309
+	 *
310
+	 * @return boolean
311
+	 */
312
+	private function espresso_widgets_in_active_sidebars()
313
+	{
314
+		$espresso_widgets = [];
315
+		foreach ($this->Registry->widgets as $widget_class => $widget) {
316
+			$id_base = EspressoWidget::getIdBase($widget_class);
317
+			if (is_active_widget(false, false, $id_base)) {
318
+				$espresso_widgets[] = $id_base;
319
+			}
320
+		}
321
+		$all_sidebar_widgets = wp_get_sidebars_widgets();
322
+		foreach ($all_sidebar_widgets as $sidebar_widgets) {
323
+			if (is_array($sidebar_widgets) && ! empty($sidebar_widgets)) {
324
+				foreach ($sidebar_widgets as $sidebar_widget) {
325
+					foreach ($espresso_widgets as $espresso_widget) {
326
+						if (strpos($sidebar_widget, $espresso_widget) !== false) {
327
+							return true;
328
+						}
329
+					}
330
+				}
331
+			}
332
+		}
333
+		return false;
334
+	}
335
+
336
+
337
+	/**
338
+	 *    header_meta_tag
339
+	 *
340
+	 * @access    public
341
+	 * @return    void
342
+	 */
343
+	public function header_meta_tag()
344
+	{
345
+		print(
346
+		apply_filters(
347
+			'FHEE__EE_Front_Controller__header_meta_tag',
348
+			'<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n"
349
+		)
350
+		);
351
+
352
+		// let's exclude all event type taxonomy term archive pages from search engine indexing
353
+		// @see https://events.codebasehq.com/projects/event-espresso/tickets/10249
354
+		// also exclude all critical pages from indexing
355
+		if (
356
+			(
357
+				is_tax('espresso_event_type')
358
+				&& get_option('blog_public') !== '0'
359
+			)
360
+			|| is_page(EE_Registry::instance()->CFG->core->get_critical_pages_array())
361
+		) {
362
+			print(
363
+			apply_filters(
364
+				'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type',
365
+				'<meta name="robots" content="noindex,follow" />' . "\n"
366
+			)
367
+			);
368
+		}
369
+	}
370
+
371
+
372
+	/**
373
+	 * wp_print_scripts
374
+	 *
375
+	 * @return void
376
+	 * @throws EE_Error
377
+	 */
378
+	public function wp_print_scripts()
379
+	{
380
+		global $post;
381
+		if (
382
+			isset($post->EE_Event)
383
+			&& $post->EE_Event instanceof EE_Event
384
+			&& get_post_type() === EspressoPostType::EVENTS
385
+			&& is_singular()
386
+		) {
387
+			EEH_Schema::add_json_linked_data_for_event($post->EE_Event);
388
+		}
389
+	}
390
+
391
+
392
+	public function enqueueStyle()
393
+	{
394
+		wp_enqueue_style('espresso_default');
395
+		wp_enqueue_style('espresso_custom_css');
396
+	}
397
+
398
+
399
+	/***********************************************        WP_FOOTER         ***********************************************/
400
+
401
+
402
+	public function enqueueScripts()
403
+	{
404
+		wp_enqueue_script('espresso_core');
405
+	}
406
+
407
+
408
+	/**
409
+	 * @param WP_Query $query
410
+	 * @return void
411
+	 * @throws DomainException
412
+	 */
413
+	public function display_errors(WP_Query $query)
414
+	{
415
+		if (! $query->is_main_query()) {
416
+			return;
417
+		}
418
+		static $shown_already = false;
419
+		do_action('AHEE__EE_Front_Controller__display_errors__begin');
420
+		if (
421
+			! $shown_already
422
+			&& apply_filters('FHEE__EE_Front_Controller__display_errors', true)
423
+			&& is_main_query()
424
+			&& ! is_feed()
425
+			&& in_the_loop()
426
+			&& $this->current_page->isEspressoPage()
427
+		) {
428
+			$shown_already = true;
429
+			if (did_action('wp_head')) {
430
+				echo wp_kses($this->printNotices(), AllowedTags::getAllowedTags());
431
+			} else {
432
+				// block enabled themes run their query loop before headers are sent
433
+				// so we need to add our notices onto the beginning of the content
434
+				add_filter('the_content', [$this, 'prependNotices'], 1);
435
+			}
436
+		}
437
+		do_action('AHEE__EE_Front_Controller__display_errors__end');
438
+	}
439
+
440
+
441
+	/**
442
+	 * @param string $the_content
443
+	 * @return string
444
+	 * @since 4.10.30.p
445
+	 */
446
+	public function prependNotices($the_content)
447
+	{
448
+		$notices = $this->printNotices();
449
+		return $notices ? $notices . $the_content : $the_content;
450
+	}
451
+
452
+
453
+	/**
454
+	 * @return false|string
455
+	 * @since 4.10.30.p
456
+	 */
457
+	public function printNotices()
458
+	{
459
+		ob_start();
460
+		echo wp_kses(EE_Error::get_notices(), AllowedTags::getWithFormTags());
461
+		EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php');
462
+		return ob_get_clean();
463
+	}
464
+
465
+
466
+
467
+	/***********************************************        UTILITIES         ***********************************************/
468
+
469
+
470
+	/**
471
+	 * @param bool|string $template_include_path
472
+	 * @return string
473
+	 * @throws EE_Error
474
+	 * @throws ReflectionException
475
+	 */
476
+	public function template_include($template_include_path = '')
477
+	{
478
+		if ($this->current_page->isEspressoPage()) {
479
+			// despite all helpers having autoloaders set, we need to manually load the template loader
480
+			// because there are some side effects in that class for triggering template tag functions
481
+			$this->Registry->load_helper('EEH_Template');
482
+			$this->_template_path = ! empty($this->_template_path)
483
+				? basename($this->_template_path)
484
+				: basename((string) $template_include_path);
485
+			$template_path        = EEH_Template::locate_template($this->_template_path, [], false);
486
+			$this->_template_path = ! empty($template_path) ? $template_path : $template_include_path;
487
+			$this->_template      = basename($this->_template_path);
488
+			return $this->_template_path;
489
+		}
490
+		return $template_include_path;
491
+	}
492
+
493
+
494
+	/**
495
+	 * @param bool $with_path
496
+	 * @return    string
497
+	 */
498
+	public function get_selected_template($with_path = false)
499
+	{
500
+		return $with_path ? $this->_template_path : $this->_template;
501
+	}
502
+
503
+	/**
504
+	 * @param string $shortcode_class
505
+	 * @param WP     $wp
506
+	 * @throws ReflectionException
507
+	 * @deprecated 4.9.26
508
+	 */
509
+	public function initialize_shortcode($shortcode_class = '', WP $wp = null)
510
+	{
511
+		EE_Error::doing_it_wrong(
512
+			__METHOD__,
513
+			esc_html__(
514
+				'Usage is deprecated. Please use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::initializeShortcode() instead.',
515
+				'event_espresso'
516
+			),
517
+			'4.9.26'
518
+		);
519
+		$this->getLegacyShortcodesManager()->initializeShortcode($shortcode_class, $wp);
520
+	}
521
+
522
+
523
+	/**
524
+	 * @return void
525
+	 * @deprecated 4.9.57.p
526
+	 */
527
+	public function loadPersistentAdminNoticeManager()
528
+	{
529
+	}
530
+
531
+
532
+	/**
533
+	 * @return void
534
+	 * @deprecated 4.9.64.p
535
+	 */
536
+	public function employ_CPT_Strategy()
537
+	{
538
+	}
539 539
 }
Please login to merge, or discard this patch.
core/libraries/shortcodes/EE_Venue_Shortcodes.lib.php 2 patches
Indentation   +299 added lines, -299 removed lines patch added patch discarded remove patch
@@ -15,303 +15,303 @@
 block discarded – undo
15 15
  */
16 16
 class EE_Venue_Shortcodes extends EE_Shortcodes
17 17
 {
18
-    /**
19
-     * Will hold the EE_Event if available
20
-     *
21
-     * @var EE_Event
22
-     */
23
-    protected $_event;
24
-
25
-    /**
26
-     * Will hold the EE_Venue if available
27
-     *
28
-     * @var EE_Venue
29
-     */
30
-    protected $_venue;
31
-
32
-
33
-    /**
34
-     * Initialize properties
35
-     */
36
-    protected function _init_props()
37
-    {
38
-        $this->label = esc_html__('Venue Shortcodes', 'event_espresso');
39
-        $this->description = esc_html__('All shortcodes specific to venue related data', 'event_espresso');
40
-        $this->_shortcodes = array(
41
-            '[VENUE_TITLE]'             => esc_html__('The title for the event venue', 'event_espresso'),
42
-            '[VENUE_DESCRIPTION]'       => esc_html__('The description for the event venue', 'event_espresso'),
43
-            '[VENUE_URL]'               => esc_html__('A url to a webpage for the venue', 'event_espresso'),
44
-            '[VENUE_DETAILS_URL]'       => sprintf(
45
-                esc_html__(
46
-                    'This shortcode outputs the url or website address to the venue details page on this website. This differs from %s which outputs what is entered in the "url" field in the venue details page.',
47
-                    'event_espresso'
48
-                ),
49
-                '[VENUE_URL]'
50
-            ),
51
-            '[VENUE_IMAGE]'             => esc_html__('An image representing the event venue', 'event_espresso'),
52
-            '[VENUE_PHONE]'             => esc_html__('The phone number for the venue', 'event_espresso'),
53
-            '[VENUE_ADDRESS]'           => esc_html__('The address for the venue', 'event_espresso'),
54
-            '[VENUE_ADDRESS2]'          => esc_html__('Address 2 for the venue', 'event_espresso'),
55
-            '[VENUE_CITY]'              => esc_html__('The city the venue is in', 'event_espresso'),
56
-            '[VENUE_STATE]'             => esc_html__('The state the venue is located in', 'event_espresso'),
57
-            '[VENUE_COUNTRY]'           => esc_html__('The country the venue is located in', 'event_espresso'),
58
-            '[VENUE_FORMATTED_ADDRESS]' => esc_html__(
59
-                'This just outputs the venue address in a semantic address format.',
60
-                'event_espresso'
61
-            ),
62
-            '[VENUE_ZIP]'               => esc_html__('The zip code for the venue address', 'event_espresso'),
63
-            '[VENUE_META_*]'            => esc_html__(
64
-                'This is a special dynamic shortcode. After the "*", add the exact name for your custom field, if there is a value set for that custom field within the venue then it will be output in place of this shortcode.',
65
-                'event_espresso'
66
-            ),
67
-            '[GOOGLE_MAP_URL]'          => esc_html__(
68
-                'URL for the google map associated with the venue.',
69
-                'event_espresso'
70
-            ),
71
-            '[GOOGLE_MAP_LINK]'         => esc_html__('Link to a google map for the venue', 'event_espresso'),
72
-            '[GOOGLE_MAP_IMAGE]'        => esc_html__('Google map for venue wrapped in image tags', 'event_espresso'),
73
-        );
74
-    }
75
-
76
-
77
-    /**
78
-     * Parse incoming shortcode
79
-     *
80
-     * @param string $shortcode
81
-     * @return string
82
-     * @throws EE_Error
83
-     * @throws EntityNotFoundException
84
-     */
85
-    protected function _parser($shortcode)
86
-    {
87
-        $this->_venue = $this->_get_venue();
88
-        // If there is no venue object by now then get out.
89
-        if (! $this->_venue instanceof EE_Venue) {
90
-            return '';
91
-        }
92
-
93
-        switch ($shortcode) {
94
-            case '[VENUE_TITLE]':
95
-                return $this->_venue('title');
96
-
97
-            case '[VENUE_DESCRIPTION]':
98
-                return $this->_venue('description');
99
-
100
-            case '[VENUE_URL]':
101
-                return $this->_venue('url');
102
-
103
-            case '[VENUE_IMAGE]':
104
-                return $this->_venue('image');
105
-
106
-            case '[VENUE_PHONE]':
107
-                return $this->_venue('phone');
108
-
109
-            case '[VENUE_ADDRESS]':
110
-                return $this->_venue('address');
111
-
112
-            case '[VENUE_ADDRESS2]':
113
-                return $this->_venue('address2');
114
-
115
-            case '[VENUE_CITY]':
116
-                return $this->_venue('city');
117
-
118
-            case '[VENUE_COUNTRY]':
119
-                return $this->_venue('country');
120
-
121
-            case '[VENUE_STATE]':
122
-                return $this->_venue('state');
123
-
124
-            case '[VENUE_ZIP]':
125
-                return $this->_venue('zip');
126
-
127
-            case '[VENUE_FORMATTED_ADDRESS]':
128
-                return $this->_venue('formatted_address');
129
-
130
-            case '[GOOGLE_MAP_URL]':
131
-                return $this->_venue('gmap_url');
132
-
133
-            case '[GOOGLE_MAP_LINK]':
134
-                return $this->_venue('gmap_link');
135
-
136
-            case '[GOOGLE_MAP_IMAGE]':
137
-                return $this->_venue('gmap_link_img');
138
-
139
-            case '[VENUE_DETAILS_URL]':
140
-                return $this->_venue('permalink');
141
-        }
142
-
143
-        if (strpos($shortcode, '[VENUE_META_*') !== false) {
144
-            $shortcode = str_replace('[VENUE_META_*', '', $shortcode);
145
-            $shortcode = trim(str_replace(']', '', $shortcode));
146
-
147
-            // pull the meta value from the venue post
148
-            $venue_meta = $this->_venue->get_post_meta($shortcode, true);
149
-
150
-            return ! empty($venue_meta) ? $venue_meta : '';
151
-        }
152
-    }
153
-
154
-    /**
155
-     * This retrieves the EE_Venue from the available data object.
156
-     *
157
-     * @return EE_Venue|null
158
-     * @throws EE_Error
159
-     * @throws EntityNotFoundException
160
-     */
161
-    private function _get_venue()
162
-    {
163
-        // if we have datetime, use the venue assigned to it.
164
-        if( $this->_data instanceof EE_Datetime ) {
165
-            return $this->_data->venue();
166
-        }
167
-
168
-        // if we don't have a datetime, we need the EE_Event object to get the venue.
169
-        $this->_event = $this->_data instanceof EE_Event ? $this->_data : null;
170
-
171
-        // if no event, then let's see if there is a reg_obj.  If there IS, then we'll try and grab the event from the
172
-        // reg_obj instead.
173
-        if (! $this->_event instanceof EE_Event) {
174
-            $aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null;
175
-            $aee = $this->_extra_data instanceof EE_Messages_Addressee ? $this->_extra_data : $aee;
176
-
177
-            $this->_event = $aee instanceof EE_Messages_Addressee && $aee->reg_obj instanceof EE_Registration
178
-                ? $aee->reg_obj->event()
179
-                : null;
180
-
181
-            // if still empty do we have a ticket data item?
182
-            $this->_event = ! $this->_event instanceof EE_Event
183
-                            && $this->_data instanceof EE_Ticket
184
-                            && $this->_extra_data['data'] instanceof EE_Messages_Addressee
185
-                ? $this->_extra_data['data']->tickets[ $this->_data->ID() ]['EE_Event']
186
-                : $this->_event;
187
-
188
-            // if STILL empty event, let's try to get the first event in the list of events via EE_Messages_Addressee
189
-            // and use that.
190
-            $this->_event = ! $this->_event instanceof EE_Event && $aee instanceof EE_Messages_Addressee
191
-                ? reset($aee->events)
192
-                : $this->_event;
193
-        }
194
-
195
-        // If we have an event object use it to pull the venue.
196
-        if ($this->_event instanceof EE_Event) {
197
-            return $this->_event->get_first_related('Venue');
198
-        }
199
-
200
-        return null;
201
-    }
202
-
203
-    /**
204
-     * This retrieves the specified venue information
205
-     *
206
-     * @param string $field What Venue field to retrieve
207
-     * @return string What was retrieved!
208
-     * @throws EE_Error
209
-     * @throws EntityNotFoundException
210
-     */
211
-    private function _venue($field)
212
-    {
213
-
214
-        if (! $this->_venue instanceof EE_Venue) {
215
-            return '';
216
-        } //no venue so get out.
217
-
218
-        switch ($field) {
219
-            case 'title':
220
-                return $this->_venue->get('VNU_name');
221
-                break;
222
-
223
-            case 'description':
224
-                return $this->_venue->get('VNU_desc');
225
-                break;
226
-
227
-            case 'url':
228
-                $url = $this->_venue->get('VNU_url');
229
-                return empty($url) ? $this->_venue->get_permalink() : $url;
230
-                break;
231
-
232
-            case 'permalink':
233
-                return $this->_venue->get_permalink();
234
-                break;
235
-
236
-            case 'image':
237
-                return '<img src="' . $this->_venue->feature_image_url(array(200, 200,))
238
-                       . '" alt="' . sprintf(
239
-                           esc_attr__('%s Feature Image', 'event_espresso'),
240
-                           $this->_venue->get('VNU_name')
241
-                       ) . '" />';
242
-                break;
243
-
244
-            case 'phone':
245
-                return $this->_venue->get('VNU_phone');
246
-                break;
247
-
248
-            case 'address':
249
-                return $this->_venue->get('VNU_address');
250
-                break;
251
-
252
-            case 'address2':
253
-                return $this->_venue->get('VNU_address2');
254
-                break;
255
-
256
-            case 'city':
257
-                return $this->_venue->get('VNU_city');
258
-                break;
259
-
260
-            case 'state':
261
-                $state = $this->_venue->state_obj();
262
-                return is_object($state) ? $state->get('STA_name') : '';
263
-                break;
264
-
265
-            case 'country':
266
-                $country = $this->_venue->country_obj();
267
-                return is_object($country) ? $country->get('CNT_name') : '';
268
-                break;
269
-
270
-            case 'zip':
271
-                return $this->_venue->get('VNU_zip');
272
-                break;
273
-
274
-            case 'formatted_address':
275
-                return EEH_Address::format($this->_venue);
276
-                break;
277
-
278
-            case 'gmap_link':
279
-            case 'gmap_url':
280
-            case 'gmap_link_img':
281
-                $atts = $this->get_map_attributes($this->_venue, $field);
282
-                return EEH_Maps::google_map_link($atts);
283
-                break;
284
-        }
285
-        return '';
286
-    }
287
-
288
-
289
-    /**
290
-     * Generates the attributes for retrieving a google_map artifact.
291
-     *
292
-     * @param EE_Venue $venue
293
-     * @param string   $field
294
-     * @return array
295
-     * @throws EE_Error
296
-     */
297
-    protected function get_map_attributes(EE_Venue $venue, $field = 'gmap_link')
298
-    {
299
-        $state = $venue->state_obj();
300
-        $country = $venue->country_obj();
301
-        $atts = array(
302
-            'id'      => $venue->ID(),
303
-            'address' => $venue->get('VNU_address'),
304
-            'city'    => $venue->get('VNU_city'),
305
-            'state'   => is_object($state) ? $state->get('STA_name') : '',
306
-            'zip'     => $venue->get('VNU_zip'),
307
-            'country' => is_object($country) ? $country->get('CNT_name') : '',
308
-            'type'    => $field === 'gmap_link' ? 'url' : 'map',
309
-            'map_w'   => 200,
310
-            'map_h'   => 200,
311
-        );
312
-        if ($field === 'gmap_url') {
313
-            $atts['type'] = 'url_only';
314
-        }
315
-        return $atts;
316
-    }
18
+	/**
19
+	 * Will hold the EE_Event if available
20
+	 *
21
+	 * @var EE_Event
22
+	 */
23
+	protected $_event;
24
+
25
+	/**
26
+	 * Will hold the EE_Venue if available
27
+	 *
28
+	 * @var EE_Venue
29
+	 */
30
+	protected $_venue;
31
+
32
+
33
+	/**
34
+	 * Initialize properties
35
+	 */
36
+	protected function _init_props()
37
+	{
38
+		$this->label = esc_html__('Venue Shortcodes', 'event_espresso');
39
+		$this->description = esc_html__('All shortcodes specific to venue related data', 'event_espresso');
40
+		$this->_shortcodes = array(
41
+			'[VENUE_TITLE]'             => esc_html__('The title for the event venue', 'event_espresso'),
42
+			'[VENUE_DESCRIPTION]'       => esc_html__('The description for the event venue', 'event_espresso'),
43
+			'[VENUE_URL]'               => esc_html__('A url to a webpage for the venue', 'event_espresso'),
44
+			'[VENUE_DETAILS_URL]'       => sprintf(
45
+				esc_html__(
46
+					'This shortcode outputs the url or website address to the venue details page on this website. This differs from %s which outputs what is entered in the "url" field in the venue details page.',
47
+					'event_espresso'
48
+				),
49
+				'[VENUE_URL]'
50
+			),
51
+			'[VENUE_IMAGE]'             => esc_html__('An image representing the event venue', 'event_espresso'),
52
+			'[VENUE_PHONE]'             => esc_html__('The phone number for the venue', 'event_espresso'),
53
+			'[VENUE_ADDRESS]'           => esc_html__('The address for the venue', 'event_espresso'),
54
+			'[VENUE_ADDRESS2]'          => esc_html__('Address 2 for the venue', 'event_espresso'),
55
+			'[VENUE_CITY]'              => esc_html__('The city the venue is in', 'event_espresso'),
56
+			'[VENUE_STATE]'             => esc_html__('The state the venue is located in', 'event_espresso'),
57
+			'[VENUE_COUNTRY]'           => esc_html__('The country the venue is located in', 'event_espresso'),
58
+			'[VENUE_FORMATTED_ADDRESS]' => esc_html__(
59
+				'This just outputs the venue address in a semantic address format.',
60
+				'event_espresso'
61
+			),
62
+			'[VENUE_ZIP]'               => esc_html__('The zip code for the venue address', 'event_espresso'),
63
+			'[VENUE_META_*]'            => esc_html__(
64
+				'This is a special dynamic shortcode. After the "*", add the exact name for your custom field, if there is a value set for that custom field within the venue then it will be output in place of this shortcode.',
65
+				'event_espresso'
66
+			),
67
+			'[GOOGLE_MAP_URL]'          => esc_html__(
68
+				'URL for the google map associated with the venue.',
69
+				'event_espresso'
70
+			),
71
+			'[GOOGLE_MAP_LINK]'         => esc_html__('Link to a google map for the venue', 'event_espresso'),
72
+			'[GOOGLE_MAP_IMAGE]'        => esc_html__('Google map for venue wrapped in image tags', 'event_espresso'),
73
+		);
74
+	}
75
+
76
+
77
+	/**
78
+	 * Parse incoming shortcode
79
+	 *
80
+	 * @param string $shortcode
81
+	 * @return string
82
+	 * @throws EE_Error
83
+	 * @throws EntityNotFoundException
84
+	 */
85
+	protected function _parser($shortcode)
86
+	{
87
+		$this->_venue = $this->_get_venue();
88
+		// If there is no venue object by now then get out.
89
+		if (! $this->_venue instanceof EE_Venue) {
90
+			return '';
91
+		}
92
+
93
+		switch ($shortcode) {
94
+			case '[VENUE_TITLE]':
95
+				return $this->_venue('title');
96
+
97
+			case '[VENUE_DESCRIPTION]':
98
+				return $this->_venue('description');
99
+
100
+			case '[VENUE_URL]':
101
+				return $this->_venue('url');
102
+
103
+			case '[VENUE_IMAGE]':
104
+				return $this->_venue('image');
105
+
106
+			case '[VENUE_PHONE]':
107
+				return $this->_venue('phone');
108
+
109
+			case '[VENUE_ADDRESS]':
110
+				return $this->_venue('address');
111
+
112
+			case '[VENUE_ADDRESS2]':
113
+				return $this->_venue('address2');
114
+
115
+			case '[VENUE_CITY]':
116
+				return $this->_venue('city');
117
+
118
+			case '[VENUE_COUNTRY]':
119
+				return $this->_venue('country');
120
+
121
+			case '[VENUE_STATE]':
122
+				return $this->_venue('state');
123
+
124
+			case '[VENUE_ZIP]':
125
+				return $this->_venue('zip');
126
+
127
+			case '[VENUE_FORMATTED_ADDRESS]':
128
+				return $this->_venue('formatted_address');
129
+
130
+			case '[GOOGLE_MAP_URL]':
131
+				return $this->_venue('gmap_url');
132
+
133
+			case '[GOOGLE_MAP_LINK]':
134
+				return $this->_venue('gmap_link');
135
+
136
+			case '[GOOGLE_MAP_IMAGE]':
137
+				return $this->_venue('gmap_link_img');
138
+
139
+			case '[VENUE_DETAILS_URL]':
140
+				return $this->_venue('permalink');
141
+		}
142
+
143
+		if (strpos($shortcode, '[VENUE_META_*') !== false) {
144
+			$shortcode = str_replace('[VENUE_META_*', '', $shortcode);
145
+			$shortcode = trim(str_replace(']', '', $shortcode));
146
+
147
+			// pull the meta value from the venue post
148
+			$venue_meta = $this->_venue->get_post_meta($shortcode, true);
149
+
150
+			return ! empty($venue_meta) ? $venue_meta : '';
151
+		}
152
+	}
153
+
154
+	/**
155
+	 * This retrieves the EE_Venue from the available data object.
156
+	 *
157
+	 * @return EE_Venue|null
158
+	 * @throws EE_Error
159
+	 * @throws EntityNotFoundException
160
+	 */
161
+	private function _get_venue()
162
+	{
163
+		// if we have datetime, use the venue assigned to it.
164
+		if( $this->_data instanceof EE_Datetime ) {
165
+			return $this->_data->venue();
166
+		}
167
+
168
+		// if we don't have a datetime, we need the EE_Event object to get the venue.
169
+		$this->_event = $this->_data instanceof EE_Event ? $this->_data : null;
170
+
171
+		// if no event, then let's see if there is a reg_obj.  If there IS, then we'll try and grab the event from the
172
+		// reg_obj instead.
173
+		if (! $this->_event instanceof EE_Event) {
174
+			$aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null;
175
+			$aee = $this->_extra_data instanceof EE_Messages_Addressee ? $this->_extra_data : $aee;
176
+
177
+			$this->_event = $aee instanceof EE_Messages_Addressee && $aee->reg_obj instanceof EE_Registration
178
+				? $aee->reg_obj->event()
179
+				: null;
180
+
181
+			// if still empty do we have a ticket data item?
182
+			$this->_event = ! $this->_event instanceof EE_Event
183
+							&& $this->_data instanceof EE_Ticket
184
+							&& $this->_extra_data['data'] instanceof EE_Messages_Addressee
185
+				? $this->_extra_data['data']->tickets[ $this->_data->ID() ]['EE_Event']
186
+				: $this->_event;
187
+
188
+			// if STILL empty event, let's try to get the first event in the list of events via EE_Messages_Addressee
189
+			// and use that.
190
+			$this->_event = ! $this->_event instanceof EE_Event && $aee instanceof EE_Messages_Addressee
191
+				? reset($aee->events)
192
+				: $this->_event;
193
+		}
194
+
195
+		// If we have an event object use it to pull the venue.
196
+		if ($this->_event instanceof EE_Event) {
197
+			return $this->_event->get_first_related('Venue');
198
+		}
199
+
200
+		return null;
201
+	}
202
+
203
+	/**
204
+	 * This retrieves the specified venue information
205
+	 *
206
+	 * @param string $field What Venue field to retrieve
207
+	 * @return string What was retrieved!
208
+	 * @throws EE_Error
209
+	 * @throws EntityNotFoundException
210
+	 */
211
+	private function _venue($field)
212
+	{
213
+
214
+		if (! $this->_venue instanceof EE_Venue) {
215
+			return '';
216
+		} //no venue so get out.
217
+
218
+		switch ($field) {
219
+			case 'title':
220
+				return $this->_venue->get('VNU_name');
221
+				break;
222
+
223
+			case 'description':
224
+				return $this->_venue->get('VNU_desc');
225
+				break;
226
+
227
+			case 'url':
228
+				$url = $this->_venue->get('VNU_url');
229
+				return empty($url) ? $this->_venue->get_permalink() : $url;
230
+				break;
231
+
232
+			case 'permalink':
233
+				return $this->_venue->get_permalink();
234
+				break;
235
+
236
+			case 'image':
237
+				return '<img src="' . $this->_venue->feature_image_url(array(200, 200,))
238
+					   . '" alt="' . sprintf(
239
+						   esc_attr__('%s Feature Image', 'event_espresso'),
240
+						   $this->_venue->get('VNU_name')
241
+					   ) . '" />';
242
+				break;
243
+
244
+			case 'phone':
245
+				return $this->_venue->get('VNU_phone');
246
+				break;
247
+
248
+			case 'address':
249
+				return $this->_venue->get('VNU_address');
250
+				break;
251
+
252
+			case 'address2':
253
+				return $this->_venue->get('VNU_address2');
254
+				break;
255
+
256
+			case 'city':
257
+				return $this->_venue->get('VNU_city');
258
+				break;
259
+
260
+			case 'state':
261
+				$state = $this->_venue->state_obj();
262
+				return is_object($state) ? $state->get('STA_name') : '';
263
+				break;
264
+
265
+			case 'country':
266
+				$country = $this->_venue->country_obj();
267
+				return is_object($country) ? $country->get('CNT_name') : '';
268
+				break;
269
+
270
+			case 'zip':
271
+				return $this->_venue->get('VNU_zip');
272
+				break;
273
+
274
+			case 'formatted_address':
275
+				return EEH_Address::format($this->_venue);
276
+				break;
277
+
278
+			case 'gmap_link':
279
+			case 'gmap_url':
280
+			case 'gmap_link_img':
281
+				$atts = $this->get_map_attributes($this->_venue, $field);
282
+				return EEH_Maps::google_map_link($atts);
283
+				break;
284
+		}
285
+		return '';
286
+	}
287
+
288
+
289
+	/**
290
+	 * Generates the attributes for retrieving a google_map artifact.
291
+	 *
292
+	 * @param EE_Venue $venue
293
+	 * @param string   $field
294
+	 * @return array
295
+	 * @throws EE_Error
296
+	 */
297
+	protected function get_map_attributes(EE_Venue $venue, $field = 'gmap_link')
298
+	{
299
+		$state = $venue->state_obj();
300
+		$country = $venue->country_obj();
301
+		$atts = array(
302
+			'id'      => $venue->ID(),
303
+			'address' => $venue->get('VNU_address'),
304
+			'city'    => $venue->get('VNU_city'),
305
+			'state'   => is_object($state) ? $state->get('STA_name') : '',
306
+			'zip'     => $venue->get('VNU_zip'),
307
+			'country' => is_object($country) ? $country->get('CNT_name') : '',
308
+			'type'    => $field === 'gmap_link' ? 'url' : 'map',
309
+			'map_w'   => 200,
310
+			'map_h'   => 200,
311
+		);
312
+		if ($field === 'gmap_url') {
313
+			$atts['type'] = 'url_only';
314
+		}
315
+		return $atts;
316
+	}
317 317
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
     {
87 87
         $this->_venue = $this->_get_venue();
88 88
         // If there is no venue object by now then get out.
89
-        if (! $this->_venue instanceof EE_Venue) {
89
+        if ( ! $this->_venue instanceof EE_Venue) {
90 90
             return '';
91 91
         }
92 92
 
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
     private function _get_venue()
162 162
     {
163 163
         // if we have datetime, use the venue assigned to it.
164
-        if( $this->_data instanceof EE_Datetime ) {
164
+        if ($this->_data instanceof EE_Datetime) {
165 165
             return $this->_data->venue();
166 166
         }
167 167
 
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 
171 171
         // if no event, then let's see if there is a reg_obj.  If there IS, then we'll try and grab the event from the
172 172
         // reg_obj instead.
173
-        if (! $this->_event instanceof EE_Event) {
173
+        if ( ! $this->_event instanceof EE_Event) {
174 174
             $aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null;
175 175
             $aee = $this->_extra_data instanceof EE_Messages_Addressee ? $this->_extra_data : $aee;
176 176
 
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
             $this->_event = ! $this->_event instanceof EE_Event
183 183
                             && $this->_data instanceof EE_Ticket
184 184
                             && $this->_extra_data['data'] instanceof EE_Messages_Addressee
185
-                ? $this->_extra_data['data']->tickets[ $this->_data->ID() ]['EE_Event']
185
+                ? $this->_extra_data['data']->tickets[$this->_data->ID()]['EE_Event']
186 186
                 : $this->_event;
187 187
 
188 188
             // if STILL empty event, let's try to get the first event in the list of events via EE_Messages_Addressee
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
     private function _venue($field)
212 212
     {
213 213
 
214
-        if (! $this->_venue instanceof EE_Venue) {
214
+        if ( ! $this->_venue instanceof EE_Venue) {
215 215
             return '';
216 216
         } //no venue so get out.
217 217
 
@@ -234,11 +234,11 @@  discard block
 block discarded – undo
234 234
                 break;
235 235
 
236 236
             case 'image':
237
-                return '<img src="' . $this->_venue->feature_image_url(array(200, 200,))
238
-                       . '" alt="' . sprintf(
237
+                return '<img src="'.$this->_venue->feature_image_url(array(200, 200,))
238
+                       . '" alt="'.sprintf(
239 239
                            esc_attr__('%s Feature Image', 'event_espresso'),
240 240
                            $this->_venue->get('VNU_name')
241
-                       ) . '" />';
241
+                       ).'" />';
242 242
                 break;
243 243
 
244 244
             case 'phone':
Please login to merge, or discard this patch.