diff --git a/app/Gateways/AbstractGateway.php b/app/Gateways/AbstractGateway.php index d16c012..d994664 100644 --- a/app/Gateways/AbstractGateway.php +++ b/app/Gateways/AbstractGateway.php @@ -212,16 +212,16 @@ public function setup_payment(): void private function get_order_data(float $amount, Product $product): array { $transactionMetaDto = \Learndash_Transaction_Meta_DTO::create( - array( + [ Transaction::$meta_key_gateway_name => self::get_name(), Transaction::$meta_key_price_type => LEARNDASH_PRICE_TYPE_PAYNOW, Transaction::$meta_key_pricing_info => \Learndash_Pricing_DTO::create( - array( + [ 'currency' => $this->currency_code, 'price' => number_format($amount / 100, 2, '.', ''), - ) + ] ), - ) + ] ); $item = [ @@ -230,11 +230,11 @@ private function get_order_data(float $amount, Product $product): array ]; $metadata = array_merge( - array( + [ 'is_learndash' => true, 'learndash_version' => LEARNDASH_VERSION, 'post_id' => $product->get_id(), - ), + ], array_map( function ($value) { return is_array($value) ? wp_json_encode($value) : $value; @@ -243,10 +243,10 @@ function ($value) { ) ); - return array( + return [ 'item' => $item, 'metadata' => $metadata - ); + ]; } /** @@ -276,13 +276,13 @@ private function get_subscription_data(float $amount, \Learndash_Pricing_DTO $pr $courseTrialPrice = $hasTrial ? $pricing->trial_price : 0.; $transactionMetaDto = \Learndash_Transaction_Meta_DTO::create( - array( + [ Transaction::$meta_key_gateway_name => self::get_name(), Transaction::$meta_key_price_type => LEARNDASH_PRICE_TYPE_SUBSCRIBE, Transaction::$meta_key_pricing_info => $pricing, Transaction::$meta_key_has_trial => $hasTrial, Transaction::$meta_key_has_free_trial => $hasTrial && 0. === $courseTrialPrice, - ) + ] ); $item = [ @@ -291,12 +291,12 @@ private function get_subscription_data(float $amount, \Learndash_Pricing_DTO $pr ]; $metadata = array_merge( - array( + [ 'is_learndash' => true, 'learndash_version' => LEARNDASH_VERSION, 'post_id' => $product->get_id(), 'trial_period_days' => $trialDurationInDays > 0 ? $trialDurationInDays : null, - ), + ], array_map( function ($value) { return is_array($value) ? wp_json_encode($value) : $value; @@ -305,10 +305,10 @@ function ($value) { ) ); - return array( + return [ 'item' => $item, 'metadata' => $metadata, - ); + ]; } /** @@ -322,12 +322,12 @@ private function map_trial_duration_in_days(int $durationValue, string $duration return 0; } - $durationNumberInDaysByLength = array( + $durationNumberInDaysByLength = [ 'D' => 1, 'W' => 7, 'M' => 30, 'Y' => 365, - ); + ]; return $durationValue * $durationNumberInDaysByLength[$durationLength]; } @@ -371,15 +371,15 @@ protected function map_transaction_meta(mixed $entity, Product $product): \Learn $is_subscription = 'subscription' === $entity->mode; $meta = array_merge( - $entity->metadata ? $entity->metadata->toArray() : array(), - array( + $entity->metadata ? $entity->metadata->toArray() : [], + [ Transaction::$meta_key_gateway_transaction => \Learndash_Transaction_Gateway_Transaction_DTO::create( - array( + [ 'id' => $is_subscription ? $entity->subscription : $entity->payment_intent, 'event' => $entity, - ) + ] ), - ) + ] ); $meta = $this->process_legacy_meta( @@ -406,8 +406,8 @@ protected function map_transaction_meta(mixed $entity, Product $product): \Learn */ public function enqueue_scripts(): void { - $deps = array_merge(array('jquery'), $this->get_deps()); - wp_enqueue_style('ldlms-cp-style', LDLMS_CRYPTOPAY_URL . 'assets/css/main.css', array(), LDLMS_CRYPTOPAY_VERSION); + $deps = array_merge(['jquery'], $this->get_deps()); + wp_enqueue_style('ldlms-cp-style', LDLMS_CRYPTOPAY_URL . 'assets/css/main.css', [], LDLMS_CRYPTOPAY_VERSION); wp_enqueue_script('ldlms-cp-script', LDLMS_CRYPTOPAY_URL . 'assets/js/main.js', $deps, LDLMS_CRYPTOPAY_VERSION, true); $ajaxUrl = admin_url('admin-ajax.php'); diff --git a/app/Sections/AbstractSection.php b/app/Sections/AbstractSection.php index da1297a..2cba7ce 100644 --- a/app/Sections/AbstractSection.php +++ b/app/Sections/AbstractSection.php @@ -97,29 +97,29 @@ public function load_settings_values(): void */ public function load_settings_fields(): void { - $this->setting_option_fields = array( - 'enabled' => array( + $this->setting_option_fields = [ + 'enabled' => [ 'name' => 'enabled', 'type' => 'checkbox-switch', 'label' => esc_html__('Active', 'ldlms-cryptopay'), 'value' => $this->setting_option_values['enabled'] ?? '', - 'options' => array( + 'options' => [ 'yes' => '', '' => '', - ), - ), - 'theme' => array( + ], + ], + 'theme' => [ 'name' => 'theme', 'label' => esc_html__('Theme', 'ldlms-cryptopay'), 'type' => 'select', - 'options' => array( + 'options' => [ 'light' => esc_html__('Light', 'ldlms-cryptopay'), 'dark' => esc_html__('Dark', 'ldlms-cryptopay'), - ), + ], 'default' => 'light', 'value' => $this->setting_option_values['theme'] ?? 'light', - ), - ); + ], + ]; $this->setting_option_fields = apply_filters( 'learndash_settings_fields', @@ -154,7 +154,7 @@ public function filter_section_save_fields($value, $oldValue, $settingsSectionKe if (isset($_POST['learndash_settings_payments_list_nonce'])) { if (!is_array($oldValue)) { - $oldValue = array(); + $oldValue = []; } foreach ($value as $valueIdx => $valueVal) {