Plugin Directory

Changeset 3740659


Ignore:
Timestamp:
10/12/2026 07:03:00 AM (11 days ago)
Author:
weareplanet
Message:

Update to version 3.4.9 from GitHub

Location:
weareplanet
Files:
24 deleted
96 edited
1 copied

Legend:

Unmodified
Added
Removed
  • weareplanet/tags/3.4.9/changelog.txt

    r3676036 r3740659  
    963963- [Tested Against] PHP SDK 4.8.0
    964964
    965 = 3.4.8 - July 22nd 2025 =
     965= 3.4.9 - July 22nd 2025 =
    966966- [Bugfix] Fix class loading order issues
    967967- [Bugfix] Fix problem with multisite not installing tables when plugin is network activated
    … …  
    979979- [Hotfix] Rollback to stable version
    980980
    981 = 3.4.8 - July 29nd 2025 =
     981= 3.4.9 - July 29nd 2025 =
    982982- [Bugfix] Fix class loading order issues
    983983- [Bugfix] Fix problem with multisite not installing tables when plugin is network activated
    … …  
    992992- [Tested Against] PHP SDK 4.8.0
    993993
    994 = 3.4.8 - July 30th 2025 =
     994= 3.4.9 - July 30th 2025 =
    995995- [Bugfix] Fix issue with calling a renamed function
    996996- [Tested Against] PHP 8.2
    … …  
    11151115- [Tested Against] PHP SDK 4.9.1
    11161116
     1117= 3.4.9 - October 7 2026 =
     1118- [Feature] Tested against Wordpress 7.1.2
     1119- [Bugfix] Fixed issue where translations for payment methods were incorrect
     1120- [Tested Against] PHP 8.4.20
     1121- [Tested Against] Wordpress 7.1.2
     1122- [Tested Against] Woocommerce 11.2.0
     1123- [Tested Against] PHP SDK 4.9.2
     1124
  • weareplanet/tags/3.4.9/docs/en/documentation.html

    r3676036 r3740659  
    2424        </li>
    2525        <li>
    26                 <a href="https://github.com/weareplanet/woocommerce/releases/tag/3.4.8/">
     26                <a href="https://github.com/weareplanet/woocommerce/releases/tag/3.4.9/">
    2727                        Source
    2828                </a>
    … …  
    397397<td class="tableblock halign-left valign-top"><p class="tableblock">Device/session ID for fraud prevention during payment. Set/updated by the plugin on the WordPress init hook.</p></td>
    398398</tr>
    399 <tr>
    400 <td class="tableblock halign-left valign-top"><p class="tableblock"><code>weareplanetNewUi</code></p></td>
    401 <td class="tableblock halign-left valign-top"><p class="tableblock">Functional</p></td>
    402 <td class="tableblock halign-left valign-top"><p class="tableblock">Persistent (10 years)</p></td>
    403 <td class="tableblock halign-left valign-top"><p class="tableblock">WeArePlanet</p></td>
    404 <td class="tableblock halign-left valign-top"><p class="tableblock">UI-version toggle for the WeArePlanet merchant portal (old vs. new UI). Set automatically on every login based on the user&#8217;s stored preference, and can be toggled by the user. HttpOnly, Secure on HTTPS.</p></td>
    405 </tr>
    406399</tbody>
    407400</table>                                        </div>
  • weareplanet/tags/3.4.9/includes/admin/class-wc-weareplanet-admin-refund.php

    r3433358 r3740659  
    146146         * Executes refund.
    147147         *
    148          * @param WC_Order $order wc_order.
     148         * @param WC_Order        $order wc_order.
    149149         * @param WC_Order_Refund $refund refund.
    150150         * @return void
    … …  
    279279         * Creates a new refund job for the given order and refund.
    280280         *
    281          * @param WC_Order $order wc_order.
    282          * @param WC_Order_Refund $refund refund.
     281         * @param WC_Order                                      $order wc_order.
     282         * @param WC_Order_Refund                               $refund refund.
    283283         * @param \WeArePlanet\Sdk\Model\RefundCreate $refund_create refund_create.
    284284         * @return WC_WeArePlanet_Entity_Refund_Job
  • weareplanet/tags/3.4.9/includes/admin/class-wc-weareplanet-admin-settings-page.php

    r3676036 r3740659  
    109109         */
    110110        protected function get_settings_for_weareplanet_order_statuses_section() {
     111                // phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- $hide_save_button is a woocommerce core global used to control settings page ui, therefore we don't rename it
    111112                global $current_section, $hide_save_button;
    112113                $hide_save_button = true;
     114                // phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
    113115                return $this->get_order_statuses();
    114116        }
    … …  
    206208                        array(
    207209                                'links' => array(
    208                                         'https://plugin-documentation.weareplanet.com/weareplanet/woocommerce/3.4.8/docs/en/documentation.html' => esc_html__( 'Documentation', 'woo-weareplanet' ),
     210                                        'https://plugin-documentation.weareplanet.com/weareplanet/woocommerce/3.4.9/docs/en/documentation.html' => esc_html__( 'Documentation', 'woo-weareplanet' ),
    209211                                        'https://www.weareplanet.com/contact/sales' => esc_html__( 'Sign Up', 'woo-weareplanet' ),
    210212                                ),
    … …  
    268270                        ),
    269271
    270             array(
    271                 'title'  => esc_html__( 'Disable Pending Email', 'woo-weareplanet' ),
    272                 'desc'    => esc_html__( 'Enable this setting to prevent WooCommerce from sending "pending payment" emails for WeArePlanet payment methods.', 'woo-weareplanet' ),
    273                 'id'      => WooCommerce_WeArePlanet::WEAREPLANET_CK_DISABLE_PENDING_EMAIL,
    274                 'type'    => 'checkbox',
    275                 'default' => 'no',
    276                 'css'    => 'min-width:300px;',
    277             ),
     272                        array(
     273                                'title' => esc_html__( 'Disable Pending Email', 'woo-weareplanet' ),
     274                                'desc' => esc_html__( 'Enable this setting to prevent WooCommerce from sending "pending payment" emails for WeArePlanet payment methods.', 'woo-weareplanet' ),
     275                                'id'  => WooCommerce_WeArePlanet::WEAREPLANET_CK_DISABLE_PENDING_EMAIL,
     276                                'type' => 'checkbox',
     277                                'default' => 'no',
     278                                'css' => 'min-width:300px;',
     279                        ),
    278280
    279281                        array(
    … …  
    339341                                'desc_tip' => wp_kses_post(
    340342                                        __(
    341                                           'The Integration Options setting determines how the payment form is displayed during the WooCommerce checkout process.<br><br><strong>IFrame</strong>: Embeds the payment form directly within the WooCommerce checkout page for a seamless experience.<br><br><strong>Lightbox</strong>: Opens a secure popup window for customers to complete their payment without leaving the checkout page.<br><br><strong>Payment Page</strong>: Redirects customers to a dedicated payment page hosted by the payment provider.',
    342                                           'woo-weareplanet'
     343                                                'The Integration Options setting determines how the payment form is displayed during the WooCommerce checkout process.<br><br><strong>IFrame</strong>: Embeds the payment form directly within the WooCommerce checkout page for a seamless experience.<br><br><strong>Lightbox</strong>: Opens a secure popup window for customers to complete their payment without leaving the checkout page.<br><br><strong>Payment Page</strong>: Redirects customers to a dedicated payment page hosted by the payment provider.',
     344                                                'woo-weareplanet'
    343345                                        )
    344346                                ),
    … …  
    365367                        ),
    366368
    367                   array(
    368                         'title' => esc_html__( 'Enforce Consistency', 'woo-weareplanet' ),
    369                         'desc' => esc_html__( 'Enable this setting to require that the sum of all line items matches the order total value.', 'woo-weareplanet' ),
    370                         'desc_tip' => esc_html__(
    371                                 "WooCommerce calculates taxes at the line-item level, which may result in minor discrepancies (typically a few cents) between the order's total tax and the displayed price. This occurs due to rounding differences during individual line-item calculations.\n\nIf the \"Enforce consistency\" setting is enabled, the portal will automatically reject orders with such discrepancies. To avoid payment processing issues, we recommend disabling this setting unless strict tax total validation is required.",
    372                                 'woo-weareplanet'
    373                         ),
    374                         'id' => WooCommerce_WeArePlanet::WEAREPLANET_CK_ENFORCE_CONSISTENCY,
    375                         'type' => 'checkbox',
    376                         'default' => 'yes',
    377                         'css' => 'min-width:300px;',
    378                   ),
     369                        array(
     370                                'title' => esc_html__( 'Enforce Consistency', 'woo-weareplanet' ),
     371                                'desc' => esc_html__( 'Enable this setting to require that the sum of all line items matches the order total value.', 'woo-weareplanet' ),
     372                                'desc_tip' => esc_html__(
     373                                        "WooCommerce calculates taxes at the line-item level, which may result in minor discrepancies (typically a few cents) between the order's total tax and the displayed price. This occurs due to rounding differences during individual line-item calculations.\n\nIf the \"Enforce consistency\" setting is enabled, the portal will automatically reject orders with such discrepancies. To avoid payment processing issues, we recommend disabling this setting unless strict tax total validation is required.",
     374                                        'woo-weareplanet'
     375                                ),
     376                                'id' => WooCommerce_WeArePlanet::WEAREPLANET_CK_ENFORCE_CONSISTENCY,
     377                                'type' => 'checkbox',
     378                                'default' => 'yes',
     379                                'css' => 'min-width:300px;',
     380                        ),
    379381
    380382                        array(
    … …  
    392394                                'title' => esc_html__( 'Order Reference Type', 'woo-weareplanet' ),
    393395                                'desc_tip' => esc_html__(
    394                                   'Choose how orders are uniquely identified when sent to the portal. This reference ensures orders can be tracked and reconciled between systems. We recommend to use Order ID unless your workflow requires custom identifiers.',
    395                                   'woo-weareplanet'
     396                                        'Choose how orders are uniquely identified when sent to the portal. This reference ensures orders can be tracked and reconciled between systems. We recommend to use Order ID unless your workflow requires custom identifiers.',
     397                                        'woo-weareplanet'
    396398                                ),
    397399                                'id' => WooCommerce_WeArePlanet::WEAREPLANET_CK_ORDER_REFERENCE,
    … …  
    440442         */
    441443        public function get_order_status_settings() {
    442                 $settings = [];
     444                $settings = array();
    443445                $is_custom_status_mapping_enabled = WC_WeArePlanet_Helper::is_custom_status_mapping_enabled();
    444446
    … …  
    454456                        'desc' => esc_html__( 'If enabled, custom statuses (such as Manual Decision) will be used instead of the default WooCommerce statuses.', 'woo-weareplanet' ),
    455457                        'id' => WooCommerce_WeArePlanet::WEAREPLANET_CK_ENABLE_CUSTOM_STATUS_MAPPING,
    456                         'type'    => 'checkbox',
     458                        'type' => 'checkbox',
    457459                        'default' => 'no',
    458                         'css'     => 'min-width:300px;',
     460                        'css' => 'min-width:300px;',
    459461                );
    460462
    … …  
    475477                                                <span class="weareplanet-status-mapping-col-left">%s</span>
    476478                                                <span class="weareplanet-status-mapping-col-right">%s</span>
    477                                         </div>'
    478                                         ,
     479                                        </div>',
    479480                                        esc_html__( 'WeArePlanet payment status', 'woo-weareplanet' ),
    480481                                        esc_html__( 'WooCommerce Order Status', 'woo-weareplanet' )
    … …  
    519520                );
    520521
    521 
    522522                return apply_filters( 'weareplanet_custom_order_statuses_settings', $settings );
    523523        }
    … …  
    592592                                'underscore',
    593593                                'backbone',
    594                                 'wc-backbone-modal'
     594                                'wc-backbone-modal',
    595595                        ),
    596596                        $version,
  • weareplanet/tags/3.4.9/includes/admin/class-wc-weareplanet-admin-transaction.php

    r3463230 r3740659  
    4545         * @see: https://woo.com/document/high-performance-order-storage/#section-8
    4646         * @see: https://developer.wordpress.org/reference/hooks/add_meta_boxes/
    47          * @param string $post_type The type of post where the meta box should be added.
     47         * @param string                $post_type The type of post where the meta box should be added.
    4848         * @param WP_Post|WC_Order|null $post_or_order_object The post or order object.
    4949         */
    50         public static function add_meta_box( $post_type = "", $post_or_order_object = null ) {
     50        public static function add_meta_box( $post_type = '', $post_or_order_object = null ) {
    5151                // WooCommerce is moving the Order information from Post to Order class. For now, we need to support both ways.
    52                 if ( empty( $post_or_order_object ) || ! ( $post_or_order_object instanceof \Automattic\WooCommerce\Admin\Overrides\Order) ) {
     52                if ( empty( $post_or_order_object ) || ! ( $post_or_order_object instanceof \Automattic\WooCommerce\Admin\Overrides\Order ) ) {
    5353                        if ( empty( $post_or_order_object ) || ! ( $post_or_order_object instanceof WP_Post ) || empty( $post_or_order_object->ID ) || 'shop_order' != $post_or_order_object->post_type ) {
    5454                                return;
  • weareplanet/tags/3.4.9/includes/admin/class-wc-weareplanet-admin.php

    r3463230 r3740659  
    245245         * Remove unwanted order actions
    246246         *
    247          * @param array $actions actions.
     247         * @param array    $actions actions.
    248248         * @param WC_Order $order order.
    249249         * @return array
    … …  
    389389         */
    390390        public function display_attribute_options_edit() {
     391                // phpcs:disable WordPress.Security.NonceVerification.Recommended -- read only display function. $_GET['edit'] is a woocommerce admin url param. Nonce is verified in the save handler.
    391392                if ( ! isset( $_GET['edit'] ) ) {
    392393                        return;
    … …  
    394395                        $edit = absint( $_GET['edit'] );
    395396                }
     397                // phpcs:enable WordPress.Security.NonceVerification.Recommended
    396398                $checked = false;
    397399                $attribute_options = WC_WeArePlanet_Entity_Attribute_Options::load_by_attribute_id( $edit );
    … …  
    407409                        </th>
    408410                        <td>
    409                                 <?php wp_nonce_field('weareplanet_attribute_option_send', 'weareplanet_attribute_option_send_nonce' ); ?>
     411                                <?php wp_nonce_field( 'weareplanet_attribute_option_send', 'weareplanet_attribute_option_send_nonce' ); ?>
    410412                                <input
    411413                                        name="weareplanet_attribute_option_send"
    … …  
    429431                        <div class="form-field">
    430432                                <label for="weareplanet_attribute_option_send">
    431                                         <?php wp_nonce_field('weareplanet_attribute_option_send', 'weareplanet_attribute_option_send_nonce' ); ?>
     433                                        <?php wp_nonce_field( 'weareplanet_attribute_option_send', 'weareplanet_attribute_option_send_nonce' ); ?>
    432434                                        <input name="weareplanet_attribute_option_send" id="weareplanet_attribute_option_send" type="checkbox" value="1">
    433435                                        <?php esc_html_e( 'Send attribute to WeArePlanet', 'woo-weareplanet' ); ?>
  • weareplanet/tags/3.4.9/includes/class-wc-weareplanet-blocks-support.php

    r3676036 r3740659  
    11<?php
    2 
    32/**
    43 * Plugin Name: WeArePlanet
    … …  
    5857        public function get_payment_method_script_handles() {
    5958                $dependencies = array();
    60                 $version = '3.4.8';
     59                $version = '3.4.9';
    6160
    6261                wp_register_script(
    … …  
    107106                        $update_transaction = isset( $_POST['updateTransaction'] ) ? (bool) sanitize_key( wp_unslash( $_POST['updateTransaction'] ) ) : false; // phpcs:ignore WordPress.Security.NonceVerification.Missing
    108107                        $enqueue_portal_scripts = isset( $_POST['enqueuePortalScripts'] ) ? (bool) sanitize_key( wp_unslash( $_POST['enqueuePortalScripts'] ) ) : false; // phpcs:ignore WordPress.Security.NonceVerification.Missing
    109                        
     108
    110109                        if ( true === $update_transaction ) {
    111110                                $transaction_service = WC_WeArePlanet_Service_Transaction::instance();
    … …  
    122121
    123122                        $payment_plugin = array_filter(
    124                           $payment_gateways,
    125                           fn( $key ) => str_contains( $key, 'weareplanet_' ),
    126                           ARRAY_FILTER_USE_KEY
     123                                $payment_gateways,
     124                                fn( $key ) => str_contains( $key, 'weareplanet_' ),
     125                                ARRAY_FILTER_USE_KEY
    127126                        );
    128127
    129128                        $payments_list =
    130                           array_map(
    131                                 function ( $payment_gateway ) use ( $available_payment_methods ) {
    132                                         $has_subscription = WC_WeArePlanet_Zero_Gateway::cart_has_subscription();
    133                                         $cartTotal = (WC()->cart && WC()->cart->total) ?? 0;
    134 
    135                                         $isPaymentMethodVisibleOnCheckout = $payment_gateway->get_payment_configuration_id() === WC_WeArePlanet_Zero_Gateway::ZERO_PAYMENT_CONF_ID && $cartTotal == 0;
    136                                         $integration_mode = $payment_gateway->get_payment_configuration_id() === WC_WeArePlanet_Zero_Gateway::ZERO_PAYMENT_CONF_ID
    137                                                 ? WC_WeArePlanet_Integration::WEAREPLANET_PAYMENTPAGE
    138                                                 : get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_INTEGRATION );
    139 
    140                                         if ( !$isPaymentMethodVisibleOnCheckout ) {
    141                                                 $isPaymentMethodVisibleOnCheckout = in_array( $payment_gateway->get_payment_configuration_id(), $available_payment_methods, true ) && ( $cartTotal > 0 || $has_subscription );
    142                                         }
    143 
    144                                         return array(
    145                                           'name' => $payment_gateway->id,
    146                                           'label' => $payment_gateway->get_title(),
    147                                           'ariaLabel' => $payment_gateway->get_title(),
    148                                           'description' => $payment_gateway->get_description(),
    149                                           'configuration_id' => $payment_gateway->get_payment_configuration_id(),
    150                                           'integration_mode' => $integration_mode,
    151                                           'supports' => $payment_gateway->supports,
    152                                           'icon' => $payment_gateway->get_icon(),
    153                                           'isActive' => $isPaymentMethodVisibleOnCheckout
    154                                         );
    155                                 },
    156                                 $payment_plugin
    157                           );
     129                                array_map(
     130                                        function ( $payment_gateway ) use ( $available_payment_methods ) {
     131                                                $has_subscription = WC_WeArePlanet_Zero_Gateway::cart_has_subscription();
     132                                                $cart_total = ( WC()->cart && WC()->cart->total ) ?? 0;
     133
     134                                                $is_payment_method_visible_on_checkout = $payment_gateway->get_payment_configuration_id() === WC_WeArePlanet_Zero_Gateway::ZERO_PAYMENT_CONF_ID && 0 === $cart_total;
     135                                                $integration_mode = $payment_gateway->get_payment_configuration_id() === WC_WeArePlanet_Zero_Gateway::ZERO_PAYMENT_CONF_ID
     136                                                        ? WC_WeArePlanet_Integration::WEAREPLANET_PAYMENTPAGE
     137                                                        : get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_INTEGRATION );
     138
     139                                                if ( ! $is_payment_method_visible_on_checkout ) {
     140                                                        $is_payment_method_visible_on_checkout = in_array( $payment_gateway->get_payment_configuration_id(), $available_payment_methods, true ) && ( $cart_total > 0 || $has_subscription );
     141                                                }
     142
     143                                                return array(
     144                                                        'name' => $payment_gateway->id,
     145                                                        'label' => $payment_gateway->get_title(),
     146                                                        'ariaLabel' => $payment_gateway->get_title(),
     147                                                        'description' => $payment_gateway->get_description(),
     148                                                        'configuration_id' => $payment_gateway->get_payment_configuration_id(),
     149                                                        'integration_mode' => $integration_mode,
     150                                                        'supports' => $payment_gateway->supports,
     151                                                        'icon' => $payment_gateway->get_icon(),
     152                                                        'isActive' => $is_payment_method_visible_on_checkout,
     153                                                );
     154                                        },
     155                                        $payment_plugin
     156                                );
    158157
    159158                        return array_values( $payments_list );
    160                 } catch (\Exception $e) {
    161                         return [];
     159                } catch ( \Exception $e ) {
     160                        return array();
    162161                }
    163162        }
    … …  
    213212         */
    214213        public static function enqueue_portal_scripts() {
    215                 if ( is_order_received_page() ) return;
     214                if ( is_order_received_page() ) {
     215                        return;
     216                }
    216217
    217218                try {
    … …  
    219220                        $transaction_service = WC_WeArePlanet_Service_Transaction::instance();
    220221                        $transaction = $transaction_service->get_transaction_from_session();
    221                         switch( get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_INTEGRATION ) ) {
     222                        switch ( get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_INTEGRATION ) ) {
    222223                                case WC_WeArePlanet_Integration::WEAREPLANET_IFRAME:
    223224                                        $js_url = $transaction_service->get_javascript_url_for_transaction( $transaction );
    … …  
    281282                [$gateway_result, $transaction] = $payment_method_object->process_payment_transaction( $context->order, $transaction_id, $space_id, true, $transaction_service );
    282283
    283 
    284284                $integration_mode = get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_INTEGRATION );
    285285                $redirect_url = $gateway_result['redirect'];
  • weareplanet/tags/3.4.9/includes/class-wc-weareplanet-commands.php

    r3378673 r3740659  
    1919if ( class_exists( 'WP_CLI' ) && ! class_exists( 'WC_WeArePlanet_Commands' ) ) {
    2020
    21     /**
    22     * Class WC_WeArePlanet_Commands.
    23     * This class contains custom commands for WeArePlanet.
    24     *
    25     * @class WC_WeArePlanet_Commands
    26     */
    27     class WC_WeArePlanet_Commands {
     21        /**
     22        * Class WC_WeArePlanet_Commands.
     23        * This class contains custom commands for WeArePlanet.
     24        *
     25        * @class WC_WeArePlanet_Commands
     26        */
     27        class WC_WeArePlanet_Commands {
    2828
    29         /**
    30         * Register commands.
    31         */
    32         public static function init() {
    33             WP_CLI::add_command(
    34                 'weareplanet settings init',
    35                 array(
    36                     __CLASS__,
    37                     'settings_init'
    38                 )
    39             );
    40             WP_CLI::add_command(
    41                 'weareplanet webhooks install',
    42                 array(
    43                     __CLASS__,
    44                     'webhooks_install'
    45                 )
    46             );
    47             WP_CLI::add_command(
    48                 'weareplanet payment-methods sync',
    49                 array(
    50                     __CLASS__,
    51                     'payment_methods_sync'
    52                 )
    53             );
    54         }
     29                /**
     30                * Register commands.
     31                */
     32                public static function init() {
     33                        WP_CLI::add_command(
     34                                'weareplanet settings init',
     35                                array(
     36                                        __CLASS__,
     37                                        'settings_init',
     38                                )
     39                        );
     40                        WP_CLI::add_command(
     41                                'weareplanet webhooks install',
     42                                array(
     43                                        __CLASS__,
     44                                        'webhooks_install',
     45                                )
     46                        );
     47                        WP_CLI::add_command(
     48                                'weareplanet payment-methods sync',
     49                                array(
     50                                        __CLASS__,
     51                                        'payment_methods_sync',
     52                                )
     53                        );
     54                }
    5555
    56         /**
    57         * Initialize WeArePlanet settings.
    58         * It doesn't reset settings to default, it sets default settings if they haven't been initialized yet.
    59         *
    60         * ## EXAMPLE
    61         *
    62          *     $ wp weareplanet settings init
    63         *
    64         * @param array $args WP-CLI positional arguments.
    65         * @param array $assoc_args WP-CLI associative arguments.
    66         */
    67         public static function settings_init( $args, $assoc_args ) {
    68             try {
    69                 $default_settings = WC_WeArePlanet_Helper::instance()->get_default_settings();
    70                 foreach ( $default_settings as $setting => $value ) {
    71                     $current_setting = get_option( $setting, false );
    72                     if ( $current_setting === false ) {
    73                         update_option( $setting, $value );
    74                     }
    75                 }
    76                 WP_CLI::success( "Settings initialized." );
    77             } catch ( \Exception $e ) {
    78                 WooCommerce_WeArePlanet::instance()->log( $e->getMessage(), WC_Log_Levels::ERROR );
    79                 WP_CLI::error( "Failed to initialize settings: " . $e->getMessage() );
    80             }
    81         }
     56                /**
     57                * Initialize WeArePlanet settings.
     58                * It doesn't reset settings to default, it sets default settings if they haven't been initialized yet.
     59                *
     60                * ## EXAMPLE
     61                *
     62                 *   $ wp weareplanet settings init
     63                *
     64                * @param array $args WP-CLI positional arguments.
     65                * @param array $assoc_args WP-CLI associative arguments.
     66                */
     67                public static function settings_init( $args, $assoc_args ) {
     68                        try {
     69                                $default_settings = WC_WeArePlanet_Helper::instance()->get_default_settings();
     70                                foreach ( $default_settings as $setting => $value ) {
     71                                        $current_setting = get_option( $setting, false );
     72                                        if ( false === $current_setting ) {
     73                                                update_option( $setting, $value );
     74                                        }
     75                                }
     76                                WP_CLI::success( 'Settings initialized.' );
     77                        } catch ( \Exception $e ) {
     78                                WooCommerce_WeArePlanet::instance()->log( $e->getMessage(), WC_Log_Levels::ERROR );
     79                                WP_CLI::error( 'Failed to initialize settings: ' . $e->getMessage() );
     80                        }
     81                }
    8282
    83         /**
    84         * Create webhook URL and webhook listeners in the portal for WeArePlanet.
    85         *
    86         * ## EXAMPLE
    87         *
    88          *     $ wp weareplanet webhooks install
    89         *
    90         * @param array $args WP-CLI positional arguments.
    91         * @param array $assoc_args WP-CLI associative arguments.
    92         */
    93         public static function webhooks_install( $args, $assoc_args ) {
    94             try {
    95                 WC_WeArePlanet_Helper::instance()->reset_api_client();
    96                 WC_WeArePlanet_Service_Webhook::instance()->install();
    97                 WP_CLI::success( "Webhooks installed." );
    98             } catch ( \Exception $e ) {
    99                 WooCommerce_WeArePlanet::instance()->log( $e->getMessage(), WC_Log_Levels::ERROR );
    100                 WP_CLI::error( "Failed to install webhooks: " . $e->getMessage() );
    101             }
    102         }
     83                /**
     84                * Create webhook URL and webhook listeners in the portal for WeArePlanet.
     85                *
     86                * ## EXAMPLE
     87                *
     88                 *    $ wp weareplanet webhooks install
     89                *
     90                * @param array $args WP-CLI positional arguments.
     91                * @param array $assoc_args WP-CLI associative arguments.
     92                */
     93                public static function webhooks_install( $args, $assoc_args ) {
     94                        try {
     95                                WC_WeArePlanet_Helper::instance()->reset_api_client();
     96                                WC_WeArePlanet_Service_Webhook::instance()->install();
     97                                WP_CLI::success( 'Webhooks installed.' );
     98                        } catch ( \Exception $e ) {
     99                                WooCommerce_WeArePlanet::instance()->log( $e->getMessage(), WC_Log_Levels::ERROR );
     100                                WP_CLI::error( 'Failed to install webhooks: ' . $e->getMessage() );
     101                        }
     102                }
    103103
    104         /**
    105         * Synchronizes payment methods in the WeArePlanet from the portal.
    106         *
    107         * ## EXAMPLE
    108         *
    109          *     $ wp weareplanet payment-methods sync
    110         *
    111         * @param array $args WP-CLI positional arguments.
    112         * @param array $assoc_args WP-CLI associative arguments.
    113         */
    114         public static function payment_methods_sync( $args, $assoc_args ) {
    115             try {
    116                 WC_WeArePlanet_Helper::instance()->reset_api_client();
    117                 WC_WeArePlanet_Service_Method_Configuration::instance()->synchronize();
    118                 WC_WeArePlanet_Helper::instance()->delete_provider_transients();
    119                 WP_CLI::success( "Payment methods synchronized." );
    120             } catch ( \Exception $e ) {
    121                 WooCommerce_WeArePlanet::instance()->log( $e->getMessage(), WC_Log_Levels::ERROR );
    122                 WP_CLI::error( "Failed to synchronize payment methods: " . $e->getMessage() );
    123             }
    124         }
    125     }
     104                /**
     105                * Synchronizes payment methods in the WeArePlanet from the portal.
     106                *
     107                * ## EXAMPLE
     108                *
     109                 *    $ wp weareplanet payment-methods sync
     110                *
     111                * @param array $args WP-CLI positional arguments.
     112                * @param array $assoc_args WP-CLI associative arguments.
     113                */
     114                public static function payment_methods_sync( $args, $assoc_args ) {
     115                        try {
     116                                WC_WeArePlanet_Helper::instance()->reset_api_client();
     117                                WC_WeArePlanet_Service_Method_Configuration::instance()->synchronize();
     118                                WC_WeArePlanet_Helper::instance()->delete_provider_transients();
     119                                WP_CLI::success( 'Payment methods synchronized.' );
     120                        } catch ( \Exception $e ) {
     121                                WooCommerce_WeArePlanet::instance()->log( $e->getMessage(), WC_Log_Levels::ERROR );
     122                                WP_CLI::error( 'Failed to synchronize payment methods: ' . $e->getMessage() );
     123                        }
     124                }
     125        }
    126126}
    127127
  • weareplanet/tags/3.4.9/includes/class-wc-weareplanet-customer-document.php

    r3288388 r3740659  
    109109                                                        array(
    110110                                                                'weareplanet_action' => 'download_packing',
    111                                                                 'post'                         => $order_id,
    112                                                                 'nonce'                        => wp_create_nonce( 'download_packing' ),
     111                                                                'post' => $order_id,
     112                                                                'nonce' => wp_create_nonce( 'download_packing' ),
    113113                                                        )
    114114                                                )
    … …  
    130130         */
    131131        private static function is_pdf_request() {
     132                // phpcs:disable WordPress.Security.NonceVerification.Recommended -- nonce is verified in download_document()
    132133                return ( isset( $_GET['post'] ) && isset( $_GET['weareplanet_action'] ) && isset( $_GET['nonce'] ) );
     134                // phpcs:enable WordPress.Security.NonceVerification.Recommended
    133135        }
    134136
  • weareplanet/tags/3.4.9/includes/class-wc-weareplanet-email.php

    r3378673 r3740659  
    2828        /**
    2929         * Allow on hold emails being sent when germanized plugin is installed.
     30         *
     31         * @var bool
    3032         */
    3133        private static $allow_on_hold_emails = false;
    … …  
    3941                        array(
    4042                                __CLASS__,
    41                                 'send_on_hold_email_when_authorized'
     43                                'send_on_hold_email_when_authorized',
    4244                        ),
    4345                        10,
    … …  
    156158                add_filter( 'woocommerce_email_actions', array( __CLASS__, 'add_email_actions' ), 10, 1 );
    157159                add_filter( 'woocommerce_email_classes', array( __CLASS__, 'add_email_classes' ), 100, 1 );
    158         add_filter(
    159             'woocommerce_email_enabled_customer_on_hold_order',
    160             array( __CLASS__, 'disable_pending_payment_email' ),
    161             10,
    162             2
    163         );
    164         }
    165 
    166         /**
    167          * @param $order_id
     160                add_filter(
     161                        'woocommerce_email_enabled_customer_on_hold_order',
     162                        array( __CLASS__, 'disable_pending_payment_email' ),
     163                        10,
     164                        2
     165                );
     166        }
     167
     168        /**
     169         * Trigger the on-hold email when an order is authorized.
     170         *
     171         * @param int $order_id order id.
    168172         * @return void
    169173         */
    … …  
    336340        public static function add_email_actions( $actions ) {
    337341
    338         $to_add = array(
    339                 'woocommerce_order_status_wearep-redirected_to_processing',
    340                 'woocommerce_order_status_wearep-redirected_to_completed',
    341                 'woocommerce_order_status_wearep-redirected_to_on-hold',
    342                 'woocommerce_order_status_wearep-redirected_to_weareplanet-waiting',
    343                 'woocommerce_order_status_wearep-redirected_to_weareplanet-manual',
    344                 'woocommerce_order_status_wearep-manual_to_cancelled',
    345                 'woocommerce_order_status_wearep-waiting_to_cancelled',
    346                 'woocommerce_order_status_wearep-manual_to_processing',
    347                 'woocommerce_order_status_wearep-waiting_to_processing',
    348         );
    349 
    350         $authorized_status = self::get_transaction_mapped_status( 'authorized' );
    351         $fulfill_status = self::get_transaction_mapped_status( 'fulfill' );
    352 
    353         if ( $authorized_status && $fulfill_status ) {
    354                 self::add_unique_action( $to_add, 'woocommerce_order_status_' . $fulfill_status . '_to_' . $authorized_status );
    355                 self::add_unique_action( $to_add, 'woocommerce_order_status_' . $authorized_status . '_to_' . $fulfill_status );
    356         }
     342                $to_add = array(
     343                        'woocommerce_order_status_wearep-redirected_to_processing',
     344                        'woocommerce_order_status_wearep-redirected_to_completed',
     345                        'woocommerce_order_status_wearep-redirected_to_on-hold',
     346                        'woocommerce_order_status_wearep-redirected_to_weareplanet-waiting',
     347                        'woocommerce_order_status_wearep-redirected_to_weareplanet-manual',
     348                        'woocommerce_order_status_wearep-manual_to_cancelled',
     349                        'woocommerce_order_status_wearep-waiting_to_cancelled',
     350                        'woocommerce_order_status_wearep-manual_to_processing',
     351                        'woocommerce_order_status_wearep-waiting_to_processing',
     352                );
     353
     354                $authorized_status = self::get_transaction_mapped_status( 'authorized' );
     355                $fulfill_status = self::get_transaction_mapped_status( 'fulfill' );
     356
     357                if ( $authorized_status && $fulfill_status ) {
     358                        self::add_unique_action( $to_add, 'woocommerce_order_status_' . $fulfill_status . '_to_' . $authorized_status );
     359                        self::add_unique_action( $to_add, 'woocommerce_order_status_' . $authorized_status . '_to_' . $fulfill_status );
     360                }
    357361
    358362                if ( class_exists( 'woocommerce_wpml' ) ) {
    … …  
    537541                                        break;
    538542
    539                         case 'WC_Email_Customer_On_Hold_Order':
    540                                 add_action( 'woocommerce_order_status_wearep-redirected_to_on-hold_notification', array( $email_object, 'trigger' ), 10, 2 );
    541                                 if ( $authorized_status && $fulfill_status ) {
    542                                         add_action( 'woocommerce_order_status_' . $fulfill_status . '_to_' . $authorized_status . '_notification', array( __CLASS__, 'maybe_send_on_hold_email_for_manual_status' ), 10, 2 );
    543                                 }
    544                                 break;
    545 
    546                         case 'WC_Email_Customer_Processing_Order':
    547                                 add_action( 'woocommerce_order_status_wearep-redirected_to_processing_notification', array( $email_object, 'trigger' ), 10, 2 );
    548                                 add_action( 'woocommerce_order_status_wearep-manual_to_processing_notification', array( $email_object, 'trigger' ), 10, 2 );
    549                                 add_action( 'woocommerce_order_status_wearep-waiting_to_processing_notification', array( $email_object, 'trigger' ), 10, 2 );
    550                                 if ( $authorized_status && $fulfill_status ) {
    551                                         add_action( 'woocommerce_order_status_' . $authorized_status . '_to_' . $fulfill_status . '_notification', array( $email_object, 'trigger' ), 10, 2 );
    552                                 }
    553                                 break;
     543                                case 'WC_Email_Customer_On_Hold_Order':
     544                                        add_action( 'woocommerce_order_status_wearep-redirected_to_on-hold_notification', array( $email_object, 'trigger' ), 10, 2 );
     545                                        if ( $authorized_status && $fulfill_status ) {
     546                                                add_action( 'woocommerce_order_status_' . $fulfill_status . '_to_' . $authorized_status . '_notification', array( __CLASS__, 'maybe_send_on_hold_email_for_manual_status' ), 10, 2 );
     547                                        }
     548                                        break;
     549
     550                                case 'WC_Email_Customer_Processing_Order':
     551                                        add_action( 'woocommerce_order_status_wearep-redirected_to_processing_notification', array( $email_object, 'trigger' ), 10, 2 );
     552                                        add_action( 'woocommerce_order_status_wearep-manual_to_processing_notification', array( $email_object, 'trigger' ), 10, 2 );
     553                                        add_action( 'woocommerce_order_status_wearep-waiting_to_processing_notification', array( $email_object, 'trigger' ), 10, 2 );
     554                                        if ( $authorized_status && $fulfill_status ) {
     555                                                add_action( 'woocommerce_order_status_' . $authorized_status . '_to_' . $fulfill_status . '_notification', array( $email_object, 'trigger' ), 10, 2 );
     556                                        }
     557                                        break;
    554558
    555559                                case 'WC_Email_Customer_Completed_Order':
    … …  
    575579         * @return bool
    576580         */
    577         public static function gzd_block_send_instant_order_confirmation ( $email_sent, $order ) {
     581        public static function gzd_block_send_instant_order_confirmation( $email_sent, $order ) {
    578582                if ( ! ( $order instanceof WC_Order ) ) {
    579583                        return $email_sent;
    … …  
    623627
    624628        /**
    625          * @param WC_Order $order
     629         * Check if the order is an on-hold order and if it is authorized.
     630         *
     631         * @param WC_Order $order WooCommerce order object.
    626632         * @return bool
    627633         */
    … …  
    639645        }
    640646
    641     /**
    642     * This prevents WooCommerce from sending the "customer on hold" email
    643     * when the order was placed using any WeArePlanet payment method
    644     * and the merchant has disabled this behavior in the plugin settings.
    645     *
    646     * @param bool     $enabled Whether the email is enabled.
    647      * @param WC_Order $order  WooCommerce order object.
    648     *
    649     * @return bool
    650     */
    651     public static function disable_pending_payment_email( $enabled, $order ) {
    652         if ( ! $enabled || ! is_a( $order, 'WC_Order' ) ) {
    653             return $enabled;
    654         }
    655 
    656         $disable = get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_DISABLE_PENDING_EMAIL, 'no' );
    657         $gateway = wc_get_payment_gateway_by_order( $order );
    658 
    659         if ( $gateway instanceof WC_WeArePlanet_Gateway && $disable === 'yes' ) {
    660             return false;
    661         }
    662 
    663         return $enabled;
    664     }
     647        /**
     648        * This prevents WooCommerce from sending the "customer on hold" email
     649        * when the order was placed using any WeArePlanet payment method
     650        * and the merchant has disabled this behavior in the plugin settings.
     651        *
     652        * @param bool     $enabled Whether the email is enabled.
     653         * @param WC_Order $order WooCommerce order object.
     654        *
     655        * @return bool
     656        */
     657        public static function disable_pending_payment_email( $enabled, $order ) {
     658                if ( ! $enabled || ! is_a( $order, 'WC_Order' ) ) {
     659                        return $enabled;
     660                }
     661
     662                $disable = get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_DISABLE_PENDING_EMAIL, 'no' );
     663                $gateway = wc_get_payment_gateway_by_order( $order );
     664
     665                if ( $gateway instanceof WC_WeArePlanet_Gateway && 'yes' === $disable ) {
     666                        return false;
     667                }
     668
     669                return $enabled;
     670        }
    665671}
    666672
  • weareplanet/tags/3.4.9/includes/class-wc-weareplanet-gateway.php

    r3550708 r3740659  
    278278                $field_key = $this->get_field_key( $key );
    279279                $defaults = array(
    280                         'title'                         => '',
    281                         'class'                         => '',
    282                         'css'                           => '',
    283                         'placeholder'           => '',
    284                         'desc_tip'                      => true,
    285                         'description'           => '',
     280                        'title'             => '',
     281                        'class'             => '',
     282                        'css'               => '',
     283                        'placeholder'       => '',
     284                        'desc_tip'          => true,
     285                        'description'       => '',
    286286                        'custom_attributes' => array(),
    287287                );
    … …  
    292292                        <th scope="row" class="titledesc">
    293293                                <label for="<?php echo esc_attr( $field_key ); ?>"><?php echo esc_html( $data['title'] ); ?></label>
    294                                 <?php echo $this->get_tooltip_html( $data ); ?>
     294                                <?php echo wp_kses_post( $this->get_tooltip_html( $data ) ); ?>
    295295                        </th>
    296296                        <td class="forminp">
    … …  
    303303                                                id="<?php echo esc_attr( $field_key ); ?>"
    304304                                                style="<?php echo esc_attr( $data['css'] ); ?>"
    305                                                 <?php echo $this->get_custom_attribute_html( $data ); ?>
     305                                                <?php echo wp_kses_post( $this->get_custom_attribute_html( $data ) ); ?>
    306306                                                >
    307307                                                <?php echo wp_kses_post( $data['value'] ); ?>
    … …  
    331331                static $checking = false;
    332332                if ( $checking ) {
    333                         return false; // prevent reentry/loop
     333                        return false; // prevent reentry/loop.
    334334                }
    335335                $checking = true;
    336336
    337337                try {
    338                         // Respect parent availability
     338                        // Respect parent availability.
    339339                        if ( ! parent::is_available() ) {
    340340                                return false;
    341341                        }
    342342
    343                         // Prevent conflict with tax rounding
     343                        // Prevent conflict with tax rounding.
    344344                        if ( wc_tax_enabled() && 'yes' === get_option( 'woocommerce_tax_round_at_subtotal' ) ) {
    345345                                if ( 'yes' === get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_ENFORCE_CONSISTENCY ) ) {
    … …  
    350350                        }
    351351
    352                         // Use session cache if available
     352                        // Use session cache if available.
    353353                        $gateway_available = WC()->session && $this->has_session()
    354354                                ? WC()->session->get( 'weareplanet_payment_gateways' )
    … …  
    359359                        }
    360360
    361                         // Allow admin and non-checkout pages to pass
     361                        // Allow admin and non-checkout pages to pass.
    362362                        if ( apply_filters(
    363363                                'weareplanet_is_method_available',
    … …  
    368368                        }
    369369
    370                         // Handle "order received" page logic
     370                        // Handle "order received" page logic.
    371371                        global $wp;
    372372                        if ( is_checkout() && isset( $wp->query_vars['order-received'] ) ) {
    … …  
    374374                        }
    375375
    376                         // Handle "order pay" endpoint
     376                        // Handle "order pay" endpoint.
    377377                        if ( apply_filters( 'wc_weareplanet_is_order_pay_endpoint', is_checkout_pay_page() ) ) {
    378378                                $order = WC_Order_Factory::get_order( $wp->query_vars['order-pay'] ?? 0 );
    … …  
    385385                        }
    386386
    387                         // Check if this gateway is among the possible ones
     387                        // Check if this gateway is among the possible ones.
    388388                        $possible = false;
    389389                        foreach ( $possible_methods as $method_id ) {
    … …  
    398398                        }
    399399
    400                         // Cache success in session
     400                        // Cache success in session.
    401401                        if ( WC()->session && $this->has_session() ) {
    402402                                $gateway_available[ $this->pln_payment_method_configuration_id ] = true;
    … …  
    538538        }
    539539
     540        /**
     541         * Enqueue checkout scripts.
     542         */
    540543        public function enqueue_checkout_scripts() {
    541544                if ( ! is_checkout() && ! is_checkout_pay_page() ) {
    … …  
    565568                        }
    566569
    567             if (get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_INTEGRATION ) == WC_WeArePlanet_Integration::WEAREPLANET_PAYMENTPAGE) {
    568                 return false;
     570                        if ( get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_INTEGRATION ) == WC_WeArePlanet_Integration::WEAREPLANET_PAYMENTPAGE ) {
     571                                return false;
    569572                        }
    570573
    571574                        wp_enqueue_script(
    572                           'weareplanet-remote-checkout-js',
    573                           $ajax_url,
    574                           array(
    575                                 'jquery',
    576                           ),
    577                           1,
    578                           true
     575                                'weareplanet-remote-checkout-js',
     576                                $ajax_url,
     577                                array(
     578                                        'jquery',
     579                                ),
     580                                1,
     581                                true
    579582                        );
    580583                        wp_enqueue_script(
    581                           'weareplanet-checkout-js',
    582                           WooCommerce_WeArePlanet::instance()->plugin_url() . '/assets/js/frontend/checkout.js',
    583                           array(
    584                                 'jquery',
    585                                 'jquery-blockui',
    586                                 'weareplanet-remote-checkout-js',
    587                           ),
    588                           1,
    589                           true
     584                                'weareplanet-checkout-js',
     585                                WooCommerce_WeArePlanet::instance()->plugin_url() . '/assets/js/frontend/checkout.js',
     586                                array(
     587                                        'jquery',
     588                                        'jquery-blockui',
     589                                        'weareplanet-remote-checkout-js',
     590                                ),
     591                                1,
     592                                true
    590593                        );
    591594                        global $wp_version;
    592595                        $localize = array(
    593                           'i18n_not_complete' => esc_html__( 'Please fill out all required fields.', 'woo-weareplanet' ),
    594                           'integration' => get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_INTEGRATION ),
    595                           'versions' => array(
    596                                 'wordpress' => $wp_version,
    597                                 'woocommerce' => $woocommerce_data['Version'],
    598                                 'weareplanet' => WC_WEAREPLANET_VERSION,
    599                           ),
     596                                'i18n_not_complete' => esc_html__( 'Please fill out all required fields.', 'woo-weareplanet' ),
     597                                'integration' => get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_INTEGRATION ),
     598                                'versions' => array(
     599                                        'wordpress' => $wp_version,
     600                                        'woocommerce' => $woocommerce_data['Version'],
     601                                        'weareplanet' => WC_WEAREPLANET_VERSION,
     602                                ),
    600603                        );
    601604                        wp_localize_script( 'weareplanet-checkout-js', 'weareplanet_js_params', $localize );
    … …  
    666669
    667670                        [ $result, $transaction ] = $this->process_payment_transaction( $order, $transaction_id, $space_id, $is_order_pay_endpoint, $transaction_service );
    668 
    669671
    670672                        $integration_mode = get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_INTEGRATION );
    … …  
    717719         * in the order. It also sets up the redirect URL upon successful payment and returns the result and transaction.
    718720         *
    719          * @param WC_Order                        $order The WooCommerce order object.
    720          * @param int                             $transaction_id The ID of the transaction.
    721          * @param int                             $space_id The space ID associated with the transaction.
    722          * @param bool                            $is_order_pay_endpoint Flag to determine if the order is being paid for at the order-pay endpoint.
     721         * @param WC_Order                                     $order The WooCommerce order object.
     722         * @param int                                          $transaction_id The ID of the transaction.
     723         * @param int                                          $space_id The space ID associated with the transaction.
     724         * @param bool                                         $is_order_pay_endpoint Flag to determine if the order is being paid for at the order-pay endpoint.
    723725         * @param WC_WeArePlanet_Service_Transaction $transaction_service The transaction service instance.
    724726         * @return array An array containing the result of the transaction and the transaction object.
  • weareplanet/tags/3.4.9/includes/class-wc-weareplanet-helper.php

    r3676036 r3740659  
    7676         *
    7777         * @param string $status_slug Order status slug, with or without the `wc-` prefix.
    78          * @param bool   $prefixed    When true the returned status contains the `wc-` prefix.
     78         * @param bool   $prefixed When true the returned status contains the `wc-` prefix.
    7979         * @return string
    8080         */
    … …  
    121121
    122122        /**
     123         * Delete language transient.
     124         *
     125         * @return void
     126         */
     127        public function delete_language_transient() {
     128                delete_transient( 'wc_weareplanet_languages' );
     129        }
     130
     131        /**
    123132         * Get api client.
    124133         *
    … …  
    144153         * Add headers to api client.
    145154         *
     155         * @param \WeArePlanet\Sdk\ApiClient $api_client api client.
    146156         * @param array $additional_headers Additional headers.
    147157         * @return void
    148158         */
    149         public static function add_headers( &$api_client, array $additional_headers = [] ) {
     159        public static function add_headers( &$api_client, array $additional_headers = array() ) {
    150160                $default_header_data = self::get_default_header_data();
    151161                $default_header_data = array_merge( $default_header_data, $additional_headers );
    … …  
    269279                        $name = $line_item->getName();
    270280
    271                         // Handle coupons normally
     281                        // Handle coupons normally.
    272282                        if ( $exclude_discounts && \WeArePlanet\Sdk\Model\LineItemType::DISCOUNT === $type
    273283                                && strpos( $name, WC_WeArePlanet_Packages_Coupon_Discount::WEAREPLANET_COUPON ) !== false
    … …  
    275285                                // Convert negative values to positive in order to be able to subtract it.
    276286                                $sum -= abs( $line_item->getAmountIncludingTax() );
    277                         }
    278                         // Handle gift cards separately (already negative, do not abs())
    279                         elseif ( \WeArePlanet\Sdk\Model\LineItemType::DISCOUNT === $type
    280                                 && stripos( $name, WC_WeArePlanet_Packages_Gift_Card::WEAREPLANET_GIFT_CARD) !== false
     287                        } elseif ( \WeArePlanet\Sdk\Model\LineItemType::DISCOUNT === $type
     288                                && stripos( $name, WC_WeArePlanet_Packages_Gift_Card::WEAREPLANET_GIFT_CARD ) !== false
    281289                        ) {
     290                                // Handle gift cards separately (already negative, do not abs()).
    282291                                $sum += $line_item->getAmountIncludingTax();
    283                         }
    284                         else {
     292                        } else {
    285293                                $sum += $line_item->getAmountIncludingTax();
    286294                        }
    … …  
    295303         * @param mixed $expected_sum expected sum.
    296304         * @param mixed $currency currency.
     305         * @param bool  $is_recurrent is recurrent.
    297306         * @return \WeArePlanet\Sdk\Model\LineItemCreate[]
    298307         * @throws WC_WeArePlanet_Exception_Invalid_Transaction_Amount WC_WeArePlanet_Exception_Invalid_Transaction_Amount.
    … …  
    301310                // Check if coupon is applied to order. Session cart might be empty during webhook processing.
    302311                $has_coupons = apply_filters( 'wc_weareplanet_packages_coupon_line_items_have_coupon_discounts', $line_items, $currency );
    303                 // ensure that the effective sum coincides with the total discounted by the coupons.
     312                // ensure that the effective sum coincides with the total discounted by the coupons.
    304313                $effective_sum = $this->round_amount( $this->get_total_amount_including_tax( $line_items, $has_coupons ), $currency );
    305314                $rounded_expected_sum = $this->round_amount( $expected_sum, $currency );
    … …  
    441450                $locked_at = gmdate( 'Y-m-d H:i:s' );
    442451                $table_transaction_info = $wpdb->prefix . 'weareplanet_transaction_info';
    443                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     452                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    444453                $wpdb->query(
    445454                        $wpdb->prepare(
    … …  
    450459                );
    451460
    452                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
    453                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     461                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
     462                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    454463                $wpdb->query(
    455464                        $wpdb->prepare(
    … …  
    462471                        )
    463472                );
    464                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     473                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    465474        }
    466475
    … …  
    634643
    635644                $shop_version = str_replace( 'v', '', $version );
    636                 $plugin_version = '3.4.8';
     645                $plugin_version = '3.4.9';
    637646                list ($major_version, $minor_version) = explode( '.', $shop_version, 3 );
    638647                return array(
    … …  
    645654
    646655        /**
    647         * Get WooCommerce order statuses in JSON format.
    648         *
    649         * This method retrieves the WooCommerce order statuses, applies any filters,
    650         * and returns them as an array with structured data.
    651         *
    652         * @return array[] An array of WooCommerce order statuses, where each status is represented
    653         *                 as an associative array containing:
    654         *                 - 'key' (string)   : The order status key.
    655         *                 - 'label' (string) : The human-readable label for the status.
    656         *                 - 'type' (string)  : The type of status ('core' if it starts with 'wc-', otherwise 'custom').
    657         */
     656         * Get WooCommerce order statuses in JSON format.
     657         *
     658         * This method retrieves the WooCommerce order statuses, applies any filters,
     659         * and returns them as an array with structured data.
     660         *
     661         * @return array[] An array of WooCommerce order statuses, where each status is represented
     662         *                 as an associative array containing:
     663         *                 - 'key' (string)   : The order status key.
     664         *                 - 'label' (string) : The human-readable label for the status.
     665         *                 - 'type' (string)  : The type of status ('core' if it starts with 'wc-', otherwise 'custom').
     666         */
    658667        public function get_woocommerce_order_statuses_json() {
    659668                $woocommerce_statuses = apply_filters( 'weareplanet_woocommerce_statuses', array() );
    … …  
    667676                        'wc-failed',
    668677                        'wc-trash',
    669                         'wc-checkout-draft'
     678                        'wc-checkout-draft',
    670679                );
    671680                if ( self::is_custom_status_mapping_enabled() ) {
    … …  
    675684                                        'wc-wearep-manual',
    676685                                        'wc-wearep-redirected',
    677                                         'wc-wearep-waiting'
     686                                        'wc-wearep-waiting',
    678687                                )
    679688                        );
    680689                }
    681690
    682                 return array_map( function( $key, $value ) use ( $excluded_statuses ) {
     691                return array_map(
     692                        function ( $key, $value ) use ( $excluded_statuses ) {
    683693                                return array(
    684694                                        'key'  => $key,
    … …  
    693703
    694704        /**
    695          * @param $order
     705         * Set virtual zero total orders to complete.
     706         *
     707         * @param WC_Order $order WC_Order The WooCommerce order object.
    696708         * @return void
    697709         */
    … …  
    704716
    705717        /**
    706          * @param $order
     718         * Check if the order is virtual (contains only virtual products).
     719         *
     720         * @param WC_Order $order WC_Order The WooCommerce order object.
    707721         * @return bool
    708722         */
    … …  
    728742         * Update WooCommerce order status to "Pre-Order" if any product is out of stock or marked as pre-order.
    729743         *
    730          * @param WC_Order $order        WooCommerce order object.
     744         * @param WC_Order $order WooCommerce order object.
    731745         */
    732746        public static function update_order_status_for_preorder_if_needed( $order ) {
    … …  
    757771
    758772                        if ( $is_preorder_wc || $is_preorder_yith ) {
    759                                 // Check if order is marked as pre-ordered
     773                                // Check if order is marked as pre-ordered.
    760774                                if ( 'yes' !== $order->get_meta( '_order_has_preorder' ) ) {
    761775                                        return;
    762776                                }
    763777
    764                                 // Check if Yith Pre-Order plugin setting
     778                                // Check if Yith Pre-Order plugin setting.
    765779                                if ( 'default' === get_option( 'ywpo_order_status', 'default' ) ) {
    766780                                        return;
    … …  
    770784                        }
    771785
    772                         // Check if product is not out of stock. Edge case: sometimes get_stock_quantity is not set, but then items are available
     786                        // Check if product is not out of stock. Edge case: sometimes get_stock_quantity is not set, but then items are available.
    773787                        if ( ( $product->get_stock_quantity() ?? 1 ) < 1 ) {
    774788                                $is_out_of_stock = true;
    … …  
    777791                }
    778792
    779                 if ( !$is_preorder && !$is_out_of_stock ) {
     793                if ( ! $is_preorder && ! $is_out_of_stock ) {
    780794                        return;
    781795                }
    … …  
    796810
    797811                        $order->update_status(
    798                           $preorder_status_slug,
    799                           __( 'Product is on pre-order. Status set automatically.', 'woo-weareplanet' )
     812                                $preorder_status_slug,
     813                                __( 'Product is on pre-order. Status set automatically.', 'woo-weareplanet' )
    800814                        );
    801815
    802816                        $order->add_order_note(
    803                           __( 'Order status automatically set to pre-order.', 'woo-weareplanet' )
     817                                __( 'Order status automatically set to pre-order.', 'woo-weareplanet' )
    804818                        );
    805819                }
    … …  
    823837                return $settings;
    824838        }
    825 
    826839}
  • weareplanet/tags/3.4.9/includes/class-wc-weareplanet-migration.php

    r3676036 r3740659  
    5656                '1.0.9' => 'update_1_0_9_restore_default_status_mappings',
    5757                '1.0.10' => 'update_1_0_10_remove_previous_min_version',
     58                '1.0.11' => 'update_1_0_11_enforce_signed_webhook_listeners',
     59                '1.0.12' => 'update_1_0_12_clear_language_cache',
    5860        );
    5961
    … …  
    7476                        array(
    7577                                __CLASS__,
    76                                 'wp_initialize_site'
     78                                'wp_initialize_site',
    7779                        ),
    7880                        10,
    … …  
    180182         * Create tables if new MU blog is created
    181183         *
    182          * wp_initialize_site hook introduced since 5.1.0
     184         * Function wp_initialize_site hook introduced since 5.1.0
     185         *
    183186         * @link https://developer.wordpress.org/reference/hooks/wp_initialize_site/
    184187         *
    185          * @param WP_Site $site
    186          * @param array $args
     188         * @param WP_Site $site site.
     189         * @param array   $args arguments.
    187190         * @return void
    188191         */
    … …  
    190193                if ( is_plugin_active_for_network( 'woo-weareplanet/weareplanet.php' ) ) {
    191194                        $blog_id = $site->blog_id;
    192                         // Defensive check: blog_id should always be set, otherwise will be shown as weareplanet error
     195                        // Defensive check: blog_id should always be set, otherwise will be shown as weareplanet error.
    193196                        if ( ! $blog_id ) {
    194197                                $logger = wc_get_logger();
    195                                 $logger->error( 'Could not detect blog_id during wp_initialize_site.', [ 'source' => 'weareplanet' ] );
     198                                $logger->error( 'Could not detect blog_id during wp_initialize_site.', array( 'source' => 'weareplanet' ) );
    196199                                return;
    197200                        }
    … …  
    252255                        $current_version = get_option( self::WEAREPLANET_CK_DB_VERSION, 0 );
    253256                        $version_keys = array_keys( self::$db_migrations );
    254                         if ( $current_version === 0 || version_compare( $current_version, '0', '>' ) && version_compare( $current_version, end( $version_keys ), '<' ) ) {
     257                        if ( version_compare( $current_version, end( $version_keys ), '<' )
     258                                && (
     259                                        0 === $current_version
     260                                        || version_compare( $current_version, '0', '>' )
     261                                )
     262                        ) {
    255263                                // We migrate the Db for all blogs.
    256264                                self::install_db( true );
    … …  
    279287                if ( WC_WEAREPLANET_PLUGIN_BASENAME === $file ) {
    280288                        $row_meta = array(
    281                                 'docs' => '<a href="https://plugin-documentation.weareplanet.com/weareplanet/woocommerce/3.4.8/docs/en/documentation.html" aria-label="' . esc_html__( 'View Documentation', 'woo-weareplanet' ) . '">' . esc_html__( 'Documentation', 'woo-weareplanet' ) . '</a>',
     289                                'docs' => '<a href="https://plugin-documentation.weareplanet.com/weareplanet/woocommerce/3.4.9/docs/en/documentation.html" aria-label="' . esc_html__( 'View Documentation', 'woo-weareplanet' ) . '">' . esc_html__( 'Documentation', 'woo-weareplanet' ) . '</a>',
    282290                        );
    283291
    … …  
    297305
    298306                $table_method_config = $wpdb->prefix . 'weareplanet_method_config';
    299                 // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     307                // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    300308                $sql = "CREATE TABLE IF NOT EXISTS $table_method_config(
    301309                                `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
    … …  
    315323                        ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
    316324                // phpcs:enable
    317                 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching,WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery -- $sql is prepared.
     325                // phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching,WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery,PluginCheck.Security.DirectDB.UnescapedDBParameter -- $sql is prepared.
    318326                $result = $wpdb->query( $sql );
    319                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.NoCachin,WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery
     327                // phpcs:enable WordPress.DB.DirectDatabaseQuery.NoCachin,WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery,PluginCheck.Security.DirectDB.UnescapedDBParameter
    320328
    321329                if ( false === $result ) {
    … …  
    325333                $table_transaction_info = $wpdb->prefix . 'weareplanet_transaction_info';
    326334
    327                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     335                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    328336                $result = $wpdb->query(
    329337                        "CREATE TABLE IF NOT EXISTS $table_transaction_info(
    … …  
    350358                        ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"
    351359                );
    352                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     360                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter
    353361
    354362                if ( false === $result ) {
    … …  
    358366                $table_token_info = $wpdb->prefix . 'weareplanet_token_info';
    359367
    360                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     368                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    361369                $result = $wpdb->query(
    362370                        "CREATE TABLE IF NOT EXISTS $table_token_info(
    … …  
    378386                        ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"
    379387                );
    380                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     388                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    381389
    382390                if ( false === $result ) {
    … …  
    386394                $table_completion_job = $wpdb->prefix . 'weareplanet_completion_job';
    387395
    388                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     396                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    389397                $result = $wpdb->query(
    390398                        "CREATE TABLE IF NOT EXISTS $table_completion_job(
    … …  
    406414                        ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"
    407415                );
    408                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     416                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    409417
    410418                if ( false === $result ) {
    … …  
    414422                $table_void_job = $wpdb->prefix . 'weareplanet_void_job';
    415423
    416                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     424                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    417425                $result = $wpdb->query(
    418426                        "CREATE TABLE IF NOT EXISTS $table_void_job(
    … …  
    432440                        ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"
    433441                );
    434                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     442                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    435443
    436444                if ( false === $result ) {
    … …  
    440448                $table_refund_job = $wpdb->prefix . 'weareplanet_refund_job';
    441449
    442                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     450                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    443451                $result = $wpdb->query(
    444452                        "CREATE TABLE IF NOT EXISTS $table_refund_job(
    … …  
    459467                        ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"
    460468                );
    461                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     469                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    462470
    463471                if ( false === $result ) {
    … …  
    477485                $table_method_config = $wpdb->prefix . 'weareplanet_method_config';
    478486
    479                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     487                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    480488                $result = $wpdb->query( "ALTER TABLE $table_method_config CHANGE `image` `image` VARCHAR(2047) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL" );
    481                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
    482 
    483                 if ( false === $result ) {
    484                         throw new Exception( esc_html( $wpdb->last_error ) );
    485                 }
    486 
    487                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     489                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
     490
     491                if ( false === $result ) {
     492                        throw new Exception( esc_html( $wpdb->last_error ) );
     493                }
     494
     495                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    488496                $result = $wpdb->query( "ALTER TABLE $table_transaction_info CHANGE `image` `image` VARCHAR(2047) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL" );
    489                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     497                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    490498
    491499                if ( false === $result ) {
    … …  
    505513                $table_token_info = $wpdb->prefix . 'weareplanet_token_info';
    506514
    507                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     515                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    508516                $result = $wpdb->query( "ALTER TABLE $table_transaction_info CHANGE `order_id` `order_id` int(10) unsigned NULL DEFAULT NULL" );
    509                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
    510 
    511                 if ( false === $result ) {
    512                         throw new Exception( esc_html( $wpdb->last_error ) );
    513                 }
    514 
    515                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     517                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
     518
     519                if ( false === $result ) {
     520                        throw new Exception( esc_html( $wpdb->last_error ) );
     521                }
     522
     523                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    516524                $result = $wpdb->query(
    517525                        $wpdb->prepare( "SHOW COLUMNS FROM $table_transaction_info LIKE %s", 'order_mapping_id' )
    518526                );
    519                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     527                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    520528
    521529                if ( 0 === $result ) {
    522                         // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     530                        // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    523531                        $result = $wpdb->query( "ALTER TABLE $table_transaction_info ADD `order_mapping_id` int(10) unsigned NULL AFTER order_id" );
    524532                        // phpcs:enable WordPress.DB.DirectDatabaseQuery.NoCachin,WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery
    … …  
    529537                }
    530538
    531                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     539                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    532540                $result = $wpdb->query( "ALTER TABLE $table_token_info CHANGE `customer_id` `customer_id` int(10) unsigned NULL DEFAULT NULL" );
    533541                // phpcs:enable WordPress.DB.DirectDatabaseQuery.NoCachin,WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery
    … …  
    552560
    553561                if ( 0 === $result ) {
    554                         // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     562                        // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    555563                        $result = $wpdb->query( "ALTER TABLE $table_method_config ADD COLUMN `image_base` VARCHAR(2047) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL AFTER image" );
    556                         // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     564                        // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    557565
    558566                        if ( false === $result ) {
    … …  
    561569                }
    562570
    563                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     571                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    564572                $result = $wpdb->query( $wpdb->prepare( "SHOW COLUMNS FROM $table_transaction_info LIKE %s", 'image_base' ) );
    565                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     573                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    566574
    567575                if ( 0 === $result ) {
    568                         // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     576                        // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    569577                        $result = $wpdb->query( "ALTER TABLE $table_transaction_info ADD COLUMN `image_base` VARCHAR(2047) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL AFTER image" );
    570                         // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     578                        // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    571579
    572580                        if ( false === $result ) {
    … …  
    587595                $table_attribute_options = $wpdb->prefix . 'weareplanet_attribute_options'; //phpcs:ignore
    588596
    589                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     597                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    590598                $result = $wpdb->query( $wpdb->prepare( "SHOW COLUMNS FROM $table_transaction_info LIKE %s", 'user_failure_message' ) );
    591                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     599                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    592600
    593601                if ( 0 === $result ) {
    594                         // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     602                        // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    595603                        $result = $wpdb->query( "ALTER TABLE $table_transaction_info ADD COLUMN `user_failure_message` VARCHAR(2047) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL AFTER failure_reason" );
    596                         // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     604                        // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    597605
    598606                        if ( false === $result ) {
    … …  
    601609                }
    602610                // Do not use foreign keys to reference attribute to cascade deletion, as some shop still run with MyISAM enginge as default.
    603                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     611                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    604612                $result = $wpdb->query(
    605613                        "CREATE TABLE IF NOT EXISTS $table_attribute_options(
    … …  
    611619                        ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"
    612620                );
    613                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     621                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    614622
    615623                if ( false == $result ) {
    … …  
    703711                global $wpdb;
    704712                // rollback table rename if there are issues.
    705                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     713                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    706714                $wpdb->query( 'START TRANSACTION' ); //phpcs:ignore
    707                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     715                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    708716                $table_stament = 'Tables_in_' . $wpdb->dbname;
    709717
    710718                foreach ( $table_rename_map as $old_table_name => $new_table_name ) {
    711719                        // check old table exists.
    712                         // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     720                        // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    713721                        $old_table_result = $wpdb->get_row(
    714722                                $wpdb->prepare( "SHOW TABLES WHERE $table_stament = %s", $old_table_name )
    715723                        );
    716                         // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     724                        // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    717725
    718726                        if ( $old_table_result ) {
    719727                                // check new table doesn't exist, if it does there's a problem!.
    720                                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     728                                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    721729                                $new_table_result = $wpdb->get_row(
    722730                                        $wpdb->prepare( "SHOW TABLES WHERE $table_stament = %s", $new_table_name )
    723731                                );
    724                                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     732                                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    725733
    726734                                if ( ! $new_table_result ) {
    727                                         // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     735                                        // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    728736                                        $result = $wpdb->query( "RENAME TABLE $old_table_name TO $new_table_name" );
    729                                         // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     737                                        // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    730738                                        if ( false === $result ) {
    731739                                                throw new Exception( esc_html( $wpdb->last_error ) );
    … …  
    762770         */
    763771        public static function update_1_0_10_remove_previous_min_version() {
    764                 delete_metadata( 'user', 0, "weareplanet-previous-wc-min-version", '', true );
     772                delete_metadata( 'user', 0, 'weareplanet-previous-wc-min-version', '', true );
     773        }
     774
     775        /**
     776         * Enforces payload signatures on webhook listeners.
     777         */
     778        public static function update_1_0_11_enforce_signed_webhook_listeners() {
     779                WC_WeArePlanet_Service_Webhook::instance()->enforce_signed_listeners();
     780        }
     781
     782        /**
     783         * Clear the language cache, which earlier versions filled with languages without IETF codes.
     784         * Only the cache is removed, it is rebuilt on the next access.
     785         */
     786        public static function update_1_0_12_clear_language_cache() {
     787                WC_WeArePlanet_Helper::instance()->delete_language_transient();
    765788        }
    766789}
  • weareplanet/tags/3.4.9/includes/class-wc-weareplanet-order-reference.php

    r3288388 r3740659  
    11<?php
    2 
    32/**
    43 * Plugin Name: WeArePlanet
  • weareplanet/tags/3.4.9/includes/class-wc-weareplanet-order-status-adapter.php

    r3463230 r3740659  
    2323 * based on the transaction statuses in WeArePlanet.
    2424 */
    25 class WC_WeArePlanet_Order_Status_Adapter
    26 {
     25class WC_WeArePlanet_Order_Status_Adapter {
    2726        /**
    2827         * Constants for WeArePlanet transaction statuses.
    2928         */
    30         const WEAREPLANET_STATUS_PENDING = 'pending';
    31         const WEAREPLANET_STATUS_CONFIRMED = 'confirmed';
     29        const WEAREPLANET_STATUS_PENDING    = 'pending';
     30        const WEAREPLANET_STATUS_CONFIRMED  = 'confirmed';
    3231        const WEAREPLANET_STATUS_PROCESSING = 'processing';
    3332        const WEAREPLANET_STATUS_AUTHORIZED = 'authorized';
    34         const WEAREPLANET_STATUS_COMPLETED = 'completed';
    35         const WEAREPLANET_STATUS_FAILED = 'failed';
    36         const WEAREPLANET_STATUS_VOIDED = 'voided';
    37         const WEAREPLANET_STATUS_FULFILL = 'fulfill';
    38         const WEAREPLANET_STATUS_DECLINE = 'decline';
     33        const WEAREPLANET_STATUS_COMPLETED  = 'completed';
     34        const WEAREPLANET_STATUS_FAILED     = 'failed';
     35        const WEAREPLANET_STATUS_VOIDED     = 'voided';
     36        const WEAREPLANET_STATUS_FULFILL    = 'fulfill';
     37        const WEAREPLANET_STATUS_DECLINE    = 'decline';
    3938
    4039        const WEAREPLANET_ORDER_STATUS_MAPPING_PREFIX = 'weareplanet_order_status_mapping_';
    41         const WEAREPLANET_CUSTOM_ORDER_STATUS_PREFIX = 'weareplanet_custom_order_status_';
     40        const WEAREPLANET_CUSTOM_ORDER_STATUS_PREFIX  = 'weareplanet_custom_order_status_';
    4241        /**
    4342         * Stores the status mappings loaded from the database.
    … …  
    5251         * Initializes the settings and adds the filter for updating order status.
    5352         */
    54         public function __construct()
    55         {
     53        public function __construct() {
    5654                $this->initialize_filters();
    5755                $this->initialize_status_mappings();
    … …  
    6159         * Initialise filters and actions.
    6260         */
    63         public static function init(): void
    64         {
     61        public static function init(): void {
    6562                add_action( 'plugins_loaded', array( __CLASS__, 'register_weareplanet_service_status_adapter' ) );
    6663        }
    … …  
    7471         * @return void
    7572         */
    76         public static function register_weareplanet_service_status_adapter(): void
    77         {
     73        public static function register_weareplanet_service_status_adapter(): void {
    7874                new WC_WeArePlanet_Order_Status_Adapter();
    7975        }
    … …  
    8278         * Initialize filters.
    8379         */
    84         private function initialize_filters(): void
    85         {
     80        private function initialize_filters(): void {
    8681                add_filter( 'weareplanet_default_order_status_mappings', array( $this, 'get_default_status_mappings' ) );
    8782                add_filter( 'weareplanet_woocommerce_statuses', array( $this, 'get_all_woocommerce_statuses' ) );
    … …  
    9388                add_filter( 'woocommerce_payment_complete_order_status', array( $this, 'get_order_status_on_payment_complete' ), 10, 3 );
    9489
    95                 //tests.
     90                // tests.
    9691                // CPT-based orders.
    97                 add_filter( 'bulk_actions-edit-shop_order', array($this, 'bulk_actions_shop_order'), 20, 1 );
    98                 add_action( 'handle_bulk_actions-edit-shop_order', array($this, 'bulk_process_custom_status'), 20, 3 );
     92                add_filter( 'bulk_actions-edit-shop_order', array( $this, 'bulk_actions_shop_order' ), 20, 1 );
     93                add_action( 'handle_bulk_actions-edit-shop_order', array( $this, 'bulk_process_custom_status' ), 20, 3 );
    9994                // HPOS orders.
    100                 add_filter( 'bulk_actions-woocommerce_page_wc-orders', array($this, 'bulk_actions_shop_order'), 20, 1 );
    101                 add_filter( 'handle_bulk_actions-woocommerce_page_wc-orders', array($this, 'bulk_process_custom_status'), 20, 3 );
     95                add_filter( 'bulk_actions-woocommerce_page_wc-orders', array( $this, 'bulk_actions_shop_order' ), 20, 1 );
     96                add_filter( 'handle_bulk_actions-woocommerce_page_wc-orders', array( $this, 'bulk_process_custom_status' ), 20, 3 );
    10297        }
    10398
    … …  
    133128                global $wpdb;
    134129
    135                 $prefix = self::WEAREPLANET_CUSTOM_ORDER_STATUS_PREFIX . '%'; //We use % as wildcard for LIKE.
    136                 $results = $wpdb->get_results( $wpdb->prepare( "SELECT option_name, option_value FROM {$wpdb->options} WHERE option_name LIKE %s", $prefix ), ARRAY_A );
    137 
    138                 //Build the array with the desired structure.
     130                $cache_key = 'weareplanet_custom_order_statuses';
     131                $cache_group = 'weareplanet';
     132
     133                $results = wp_cache_get( $cache_key, $cache_group );
     134
     135                if ( $results === false ) {
     136                        $prefix = self::WEAREPLANET_CUSTOM_ORDER_STATUS_PREFIX . '%'; //We use % as wildcard for LIKE.
     137                        // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
     138                        $results = $wpdb->get_results( $wpdb->prepare( "SELECT option_name, option_value FROM {$wpdb->options} WHERE option_name LIKE %s", $prefix ), ARRAY_A );
     139
     140                        wp_cache_set( $cache_key, $results, $cache_group, HOUR_IN_SECONDS );
     141                }
     142
     143                // Build the array with the desired structure.
    139144                foreach ( $results as $row ) {
    140145                        $status_label = ucfirst( str_replace( array( 'wc-', '_' ), array( '', ' ' ), $row['option_value'] ) );
     146
    141147                        $order_statuses[ $row['option_value'] ] = $status_label;
    142148                }
    … …  
    161167                );
    162168
    163                 $order_statuses_without_prefix = array_map( function( $status ) {
    164                         return str_replace( 'wc-', '', $status );
    165                 }, array_values( $default_mappings ) );
    166 
    167                 return array_merge($order_statuses, $order_statuses_without_prefix);
     169                $order_statuses_without_prefix = array_map(
     170                        function ( $status ) {
     171                                return str_replace( 'wc-', '', $status );
     172                        },
     173                        array_values( $default_mappings )
     174                );
     175
     176                return array_merge( $order_statuses, $order_statuses_without_prefix );
    168177        }
    169178
    … …  
    171180         * Loads the status mappings from the database or initializes them if not present.
    172181         */
    173         private function initialize_status_mappings(): void
    174         {
     182        private function initialize_status_mappings(): void {
    175183                $is_custom_mapping_enabled = WC_WeArePlanet_Helper::is_custom_status_mapping_enabled();
    176184                $default_mappings = apply_filters( 'weareplanet_default_order_status_mappings', array() );
    … …  
    203211         * @return bool
    204212         */
    205         private function is_custom_order_status( string $order_status ): bool
    206         {
     213        private function is_custom_order_status( string $order_status ): bool {
    207214                return strpos( $order_status, 'wc-wearep-' ) === 0 || strpos( $order_status, 'wearep-' ) === 0;
    208215        }
    … …  
    214221         * @return string
    215222         */
    216         private function ensure_status_has_prefix( string $status ): string
    217         {
     223        private function ensure_status_has_prefix( string $status ): string {
    218224                if ( '' === $status ) {
    219225                        return $status;
    … …  
    236242         * @return void
    237243         */
    238         public function store_default_status_mappings_on_database(): void
    239         {
     244        public function store_default_status_mappings_on_database(): void {
    240245                $default_mappings = $this->get_default_status_mappings();
    241246
    … …  
    255260         *
    256261         * WooCommerce introduced the `OrderInternalStatus` constants in version 9.6.0.
    257          * To maintain compatibility with earlier versions, string values are used as a fallback.
     262         * To maintain compatibility with earlier versions, string values are used as a fallback.
    258263         * This is the interface to use in next versions Automattic\WooCommerce\Enums\OrderInternalStatus
    259264         *
    … …  
    276281         * @return array
    277282         */
    278         public function get_default_status_mappings() : array
    279         {
     283        public function get_default_status_mappings(): array {
    280284                $default_mappings = array(
    281285                        self::WEAREPLANET_STATUS_PENDING => 'wc-pending',
    … …  
    309313         * @return array
    310314         */
    311         public function get_legacy_default_status_mappings() : array
    312         {
     315        public function get_legacy_default_status_mappings(): array {
    313316                return array(
    314317                        self::WEAREPLANET_STATUS_CONFIRMED => 'wearep-redirected',
    … …  
    323326         * @return array
    324327         */
    325         public function get_all_woocommerce_statuses(): array
    326         {
     328        public function get_all_woocommerce_statuses(): array {
    327329                return wc_get_order_statuses();
    328330        }
    … …  
    333335         * @return array
    334336         */
    335         public function get_weareplanet_statuses(): array
    336         {
     337        public function get_weareplanet_statuses(): array {
    337338                return array(
    338339                        self::WEAREPLANET_STATUS_PENDING => ucwords( self::WEAREPLANET_STATUS_PENDING ),
    … …  
    354355         * @return string|null The corresponding WooCommerce order status or null if not found.
    355356         */
    356         private function map_weareplanet_status_to_woocommerce( ?string $status ): ?string
    357         {
     357        private function map_weareplanet_status_to_woocommerce( ?string $status ): ?string {
    358358                if ( null === $status || '' === $status ) {
    359359                        return $status;
    … …  
    361361
    362362                if ( empty( $this->settings ) ) {
    363                         return $status; //Return the current status if there are no mappings available.
    364                 }
    365 
    366                 //Search in 'transaction_status' first.
     363                        return $status; // Return the current status if there are no mappings available.
     364                }
     365
     366                // Search in 'transaction_status' first.
    367367                foreach ( $this->settings as $setting ) {
    368                         if ( $setting['transaction_status'] === strtolower( $status ) ) {
    369                                 return str_replace( 'wc-', '', $setting['order_status'] ); //Return the mapped WooCommerce order status.
     368                        if ( strtolower( $status ) === $setting['transaction_status'] ) {
     369                                return str_replace( 'wc-', '', $setting['order_status'] ); // Return the mapped WooCommerce order status.
    370370                        }
    371371                }
    372372
    373                 //Fallback to legacy mappings if no match was found.
     373                // Fallback to legacy mappings if no match was found.
    374374                $legacy_mappings = $this->get_legacy_default_status_mappings();
    375375                $transaction_status_key = array_search( $status, $legacy_mappings, true );
    376376
    377                 if ( !empty( $transaction_status_key ) ) {
     377                if ( ! empty( $transaction_status_key ) ) {
    378378                        foreach ( $this->settings as $setting ) {
    379379                                if ( $setting['transaction_status'] === $transaction_status_key ) {
    380                                         return str_replace( 'wc-', '', $setting['order_status'] ); //Return the mapped WooCommerce order status.
     380                                        return str_replace( 'wc-', '', $setting['order_status'] ); // Return the mapped WooCommerce order status.
    381381                                }
    382382                        }
    383383                }
    384384
    385                 return str_replace( 'wc-', '', $status ); //Return legacy status or original (ensuring WC prefix is stripped).
     385                return str_replace( 'wc-', '', $status ); // Return legacy status or original (ensuring WC prefix is stripped).
    386386        }
    387387
    … …  
    389389         * Updates the status of a WooCommerce order based on the WeArePlanet status.
    390390         *
    391          * @param WC_Order $order $order The WooCommerce order.
     391         * @param WC_Order    $order $order The WooCommerce order.
    392392         * @param string|null $status The WeArePlanet transaction status.
    393          * @param string|null $default status The WeArePlanet transaction status by default.
    394          * @param string $note Optional note to add when updating the status.
     393         * @param string|null $default_status The WeArePlanet transaction status by default.
     394         * @param string      $note Optional note to add when updating the status.
    395395         * @param @param bool $manual Whether this is a manual order status change.
    396396         */
    397         public function update_order_status( WC_Order $order, ?string $status, ?string $default_status, string $note = '', bool $manual = false ): void
    398         {
     397        public function update_order_status(
     398                WC_Order $order,
     399                ?string $status,
     400                ?string $default_status,
     401                string $note = '',
     402                bool $manual = false
     403        ): void {
    399404                // If status is empty.
    400                 if ( $status === null && $order !== null ) {
     405                if ( null === $status && null !== $order ) {
    401406                        $transaction_info = WC_WeArePlanet_Entity_Transaction_Info::load_by_order_id( $order->get_id() );
    402407                        if ( $transaction_info ) {
    … …  
    419424                $new_status = $should_force_completed ? 'completed' : $this->map_weareplanet_status_to_woocommerce( $status );
    420425
    421                 if ( !empty( $new_status ) && !empty( $order ) ) {
     426                if ( ! empty( $new_status ) && ! empty( $order ) ) {
    422427                        $order->update_status( $new_status, $note, $manual );
    423428                        // Apply a post-update filter to allow modifications after updating the status.
    … …  
    430435         * and return the order status accordingly when the order is fulfill.
    431436         *
    432          * @param string $status The default order status (processing or completed).
    433          * @param int $order_id The WooCommerce order ID.
     437         * @param string   $status The default order status (processing or completed).
     438         * @param int      $order_id The WooCommerce order ID.
    434439         * @param WC_Order $order The WooCommerce order object.
    435440         * @return string The updated order status.
    436441         */
    437         public function get_order_status_on_payment_complete( string $status, int $order_id, WC_Order $order ): string
    438         {
     442        public function get_order_status_on_payment_complete( string $status, int $order_id, WC_Order $order ): string {
    439443                $change_setting_enabled = 'yes' === get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_CHANGE_ORDER_STATUS );
    440444                $is_virtual_order = WC_WeArePlanet_Helper::is_order_virtual( $order );
    … …  
    448452                }
    449453
    450                 // Check if the transaction status is mapped in WooCommerce
     454                // Check if the transaction status is mapped in WooCommerce.
    451455                $mapped_status = $this->map_weareplanet_status_to_woocommerce( \WeArePlanet\Sdk\Model\TransactionState::FULFILL );
    452456
    453457                if ( ! empty( $mapped_status ) ) {
    454                         return $mapped_status; // Return the mapped WooCommerce status
     458                        return $mapped_status; // Return the mapped WooCommerce status.
    455459                }
    456460
    … …  
    472476         * @return string|null The mapped WooCommerce order status, or null if no mapping is found.
    473477         */
    474         public function get_wc_status_for_transaction( ?string $weareplanet_status ): ?string
    475         {
     478        public function get_wc_status_for_transaction( ?string $weareplanet_status ): ?string {
    476479                if ( null === $weareplanet_status || '' === $weareplanet_status ) {
    477480                        return null;
  • weareplanet/tags/3.4.9/includes/class-wc-weareplanet-return-handler.php

    r3288388 r3740659  
    4646                        $order_id = absint( wp_unslash( $_GET['order_id'] ) ); //phpcs:ignore
    4747                        $order = WC_Order_Factory::get_order( $order_id );
    48                         $action = sanitize_text_field( wp_unslash( $_GET['action'] ) );
     48                        $action = sanitize_text_field( wp_unslash( $_GET['action'] ) ); // phpcs:ignore
    4949                        if ( $order->get_id() === $order_id && $order->get_order_key() === $order_key ) {
    5050                                switch ( $action ) {
  • weareplanet/tags/3.4.9/includes/class-wc-weareplanet-subscription-gateway.php

    r3463230 r3740659  
    9797        public function process_scheduled_subscription_payment( $amount_to_charge, WC_Order $order ) {
    9898                try {
    99                         $token_data = $this->get_token_data_from_order($order);
     99                        $token_data = $this->get_token_data_from_order( $order );
    100100
    101101                        $token_space_id = $token_data['_weareplanet_subscription_space_id'];
    102                         $token_id = $token_data['_weareplanet_subscription_token_id'];
     102                        $token_id       = $token_data['_weareplanet_subscription_token_id'];
    103103
    104104                        $transaction_service = WC_WeArePlanet_Service_Transaction::instance();
    … …  
    107107                        if ( $transaction_info->get_id() > 0 ) {
    108108                                $existing_transaction = $transaction_service->get_transaction( $transaction_info->get_space_id(), $transaction_info->get_id() );
    109                                 if ( $existing_transaction->getState() != \WeArePlanet\Sdk\Model\TransactionState::PENDING ) {
     109                                if ( $existing_transaction->getState() !== \WeArePlanet\Sdk\Model\TransactionState::PENDING ) {
    110110                                        return;
    111111                                }
    … …  
    162162                        if ( ! isset( $payment_meta['post_meta']['_weareplanet_subscription_space_id']['value'] ) || empty( $payment_meta['post_meta']['_weareplanet_subscription_space_id']['value'] ) ) {
    163163                                throw new Exception( esc_html__( 'The WeArePlanet Space Id value is required.', 'woo-weareplanet' ) );
    164                         } elseif ( get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_SPACE_ID ) != $payment_meta['post_meta']['_weareplanet_subscription_space_id']['value'] ) {
     164                        } elseif ( get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_SPACE_ID ) !== $payment_meta['post_meta']['_weareplanet_subscription_space_id']['value'] ) {
    165165                                throw new Exception( esc_html__( 'The WeArePlanet Space Id needs to be in the same space as configured in the main configuration.', 'woo-weareplanet' ) );
    166166                        }
    … …  
    180180         */
    181181        public function update_payment_method( $update, $new_payment_method, $subscription ) {
    182                 if ( $this->gateway->id == $new_payment_method ) {
     182                if ( $this->gateway->id === $new_payment_method ) {
    183183                        $update = false;
    184184                        add_filter(
    … …  
    212212         * @param WC_Order $order Order.
    213213         * @return array
    214          */
    215         private function get_token_data_from_order($order)
    216         {
    217                 $order_id = $order->get_id();
    218                 $token_data = [];
     214         * @throws Exception Exception.
     215         */
     216        private function get_token_data_from_order( $order ) {
     217                $order_id   = $order->get_id();
     218                $token_data = array();
    219219                $token_data['_weareplanet_subscription_space_id'] = get_post_meta( $order_id, '_weareplanet_subscription_space_id', true );
    220220                $token_data['_weareplanet_subscription_token_id'] = get_post_meta( $order_id, '_weareplanet_subscription_token_id', true );
    221221
    222                 if( ! isset($token_data['_weareplanet_subscription_space_id']) || isset($token_data['_weareplanet_subscription_token_id']) ) {
     222                if ( ! isset( $token_data['_weareplanet_subscription_space_id'] ) || isset( $token_data['_weareplanet_subscription_token_id'] ) ) {
    223223
    224224                        $subscriptions = wcs_get_subscriptions_for_renewal_order( $order_id );
    225                         // In theory, each of the array elements should contain the same token and space data
    226                         $subscription_object = array_pop($subscriptions);
    227                         $subscription_meta = $subscription_object->get_meta_data();
    228                         $token_data = [];
    229                         $subscription_keys = [
     225                        // In theory, each of the array elements should contain the same token and space data.
     226                        $subscription_object = array_pop( $subscriptions );
     227                        $subscription_meta   = $subscription_object->get_meta_data();
     228                        $token_data          = array();
     229                        $subscription_keys   = array(
    230230                                '_weareplanet_subscription_space_id',
    231                                 '_weareplanet_subscription_token_id'
    232                         ];
    233 
    234                         foreach( $subscription_meta as $meta_data ) {
     231                                '_weareplanet_subscription_token_id',
     232                        );
     233
     234                        foreach ( $subscription_meta as $meta_data ) {
    235235                                $contained_data = $meta_data->get_data();
    236                                 if ( in_array($contained_data['key'], $subscription_keys ) ) {
    237                                         $token_data[$contained_data['key']] = $contained_data['value'];
     236                                if ( in_array( $contained_data['key'], $subscription_keys ) ) {
     237                                        $token_data[ $contained_data['key'] ] = $contained_data['value'];
    238238                                }
    239239                        }
    240240                }
    241241
    242                 if( ! isset($token_data['_weareplanet_subscription_space_id']) ) {
     242                if ( ! isset( $token_data['_weareplanet_subscription_space_id'] ) ) {
    243243                        $order->update_status( 'failed', esc_html__( 'No Space Id is found.', 'woo-weareplanet' ) );
    244                         throw new Exception('Missing space id details');
    245                 }
    246 
    247                 if( ! isset($token_data['_weareplanet_subscription_token_id']) ) {
     244                        throw new Exception( 'Missing space id details' );
     245                }
     246
     247                if ( ! isset( $token_data['_weareplanet_subscription_token_id'] ) ) {
    248248                        $order->update_status( 'failed', esc_html__( 'No Token Id is found.', 'woo-weareplanet' ) );
    249                         throw new Exception('Missing token id');
    250                 }
    251 
    252                 if ( get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_SPACE_ID ) != $token_data['_weareplanet_subscription_space_id'] ) {
     249                        throw new Exception( 'Missing token id' );
     250                }
     251
     252                if ( get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_SPACE_ID ) !== $token_data['_weareplanet_subscription_space_id'] ) {
    253253                        $order->update_status( 'failed', esc_html__( 'The token space and the configured space are not equal.', 'woo-weareplanet' ) );
    254                         throw new Exception('Token space does not match configured space');
     254                        throw new Exception( 'Token space does not match configured space' );
    255255                }
    256256
    … …  
    297297        public function store_gateway_result_in_globals( $result, $subscription ) {
    298298                if ( isset( $result['weareplanet'] ) ) {
    299                         $GLOBALS['_wc_weareplanet_subscription_gateway_result'] = $result;
     299                        $GLOBALS['wc_weareplanet_subscription_gateway_result'] = $result;
    300300                        return array(
    301                                 'result' => $result['result'],
     301                                'result'   => $result['result'],
    302302                                'redirect' => 'wc_weareplanet_subscription_redirect',
    303303                        );
    … …  
    314314         */
    315315        public function create_json_response( $location, $status ) {
    316                 $location = basename($location);
    317                 if ( 'wc_weareplanet_subscription_redirect' == $location && isset( $GLOBALS['_wc_weareplanet_subscription_gateway_result'] ) ) {
     316                $location = basename( $location );
     317                if ( 'wc_weareplanet_subscription_redirect' === $location && isset( $GLOBALS['_wc_weareplanet_subscription_gateway_result'] ) ) {
    318318                        wp_send_json( $GLOBALS['_wc_weareplanet_subscription_gateway_result'] );
    319319                        exit;
  • weareplanet/tags/3.4.9/includes/class-wc-weareplanet-subscription.php

    r3433358 r3740659  
    5454        }
    5555
     56        /**
     57         * Boot the subscription integration.
     58         *
     59         * @return void
     60         */
    5661        public function boot() {
    5762                add_filter(
    … …  
    466471        public function fulfill_in_progress( \WeArePlanet\Sdk\Model\Transaction $transaction, $order ) {
    467472                if ( wcs_order_contains_subscription( $order, array( 'parent', 'resubscribe', 'switch', 'renewal' ) ) ) {
    468                         $GLOBALS['_wc_weareplanet_subscription_fulfill'] = true;
     473                        $GLOBALS['wc_weareplanet_subscription_fulfill'] = true;
    469474                }
    470475        }
    … …  
    478483         */
    479484        public function add_valid_order_statuses_for_subscription_completion( $statuses, $order = null ) {
    480                 if ( isset( $GLOBALS['_wc_weareplanet_subscription_fulfill'] ) ) {
     485                if ( isset( $GLOBALS['wc_weareplanet_subscription_fulfill'] ) ) {
    481486                        $statuses[] = 'wearep-waiting';
    482487                        $statuses[] = 'wearep-manual';
    … …  
    490495         * @param WC_WeArePlanet_Entity_Transaction_Info $info Info.
    491496         * @param \WeArePlanet\Sdk\Model\Transaction     $transaction Transaction.
    492          * @param WC_Order                                         $order Oder.
     497         * @param WC_Order                                         $order Order.
    493498         * @return WC_WeArePlanet_Entity_Transaction_Info
    494499         */
    … …  
    565570         */
    566571        public function before_renewal_setup_cart( $subscriptions, $order ) {
    567                 $GLOBALS['_wc_weareplanet_renewal_cart_setup'] = true;
     572                $GLOBALS['wc_weareplanet_renewal_cart_setup'] = true;
    568573        }
    569574
    … …  
    576581         */
    577582        public function after_renewal_setup_cart( $subscriptions, $order ) {
    578                 $GLOBALS['_wc_weareplanet_renewal_cart_setup'] = false;
     583                $GLOBALS['wc_weareplanet_renewal_cart_setup'] = false;
    579584        }
    580585
    … …  
    586591         */
    587592        public function method_available_for_cart_renewal( $available ) {
    588                 if ( isset( $GLOBALS['_wc_weareplanet_renewal_cart_setup'] ) && $GLOBALS['_wc_weareplanet_renewal_cart_setup'] ) {
     593                if ( isset( $GLOBALS['wc_weareplanet_renewal_cart_setup'] ) && $GLOBALS['wc_weareplanet_renewal_cart_setup'] ) {
    589594                        return true;
    590595                }
    … …  
    626631        }
    627632}
    628 
    629 
  • weareplanet/tags/3.4.9/includes/class-wc-weareplanet-unique-id.php

    r3673687 r3740659  
    3333                        array(
    3434                                __CLASS__,
    35                                 'copy_unqiue_id_to_order_item',
     35                                'copy_unique_id_to_order_item',
    3636                        ),
    3737                        10,
    … …  
    4242                        array(
    4343                                __CLASS__,
    44                                 'copy_unqiue_id_to_order_fee',
     44                                'copy_unique_id_to_order_fee',
    4545                        ),
    4646                        10,
    … …  
    5151                        array(
    5252                                __CLASS__,
    53                                 'copy_unqiue_id_to_order_shipping',
     53                                'copy_unique_id_to_order_shipping',
    5454                        ),
    5555                        10,
    … …  
    8181         * @return WC_Order_Item_Product $item item
    8282         */
    83         public static function copy_unqiue_id_to_order_item( WC_Order_Item_Product $item, $cart_item_key, $values, ?WC_Order $order = null ) { //phpcs:ignore
     83        public static function copy_unique_id_to_order_item( WC_Order_Item_Product $item, $cart_item_key, $values, WC_Order $order = null ) { //phpcs:ignore
    8484                // We do not use the cart_item_key as it is deprecated.
    8585                $item->add_meta_data( '_weareplanet_unique_line_item_id', self::get_uuid(), true );
    … …  
    9797         * @return WC_Order_Item_Shipping $item item
    9898         */
    99         public static function copy_unqiue_id_to_order_shipping( WC_Order_Item_Shipping $item, $package_key, $package, ?WC_Order $order = null ) { //phpcs:ignore
     99        public static function copy_unique_id_to_order_shipping( WC_Order_Item_Shipping $item, $package_key, $package, WC_Order $order = null ) { //phpcs:ignore
    100100                $item->add_meta_data( '_weareplanet_unique_line_item_id', self::get_uuid(), true );
    101101                return $item;
    … …  
    112112         * @return WC_Order_Item_Shipping $item item
    113113         */
    114         public static function copy_unqiue_id_to_order_fee( WC_Order_Item_Fee $item, $fee_key, $fee, ?WC_Order $order = null ) { //phpcs:ignore
     114        public static function copy_unique_id_to_order_fee( WC_Order_Item_Fee $item, $fee_key, $fee, ?WC_Order $order = null ) { //phpcs:ignore
    115115                $unique_id = null;
    116116                if ( $fee->amount < 0 ) {
  • weareplanet/tags/3.4.9/includes/class-wc-weareplanet-webhook-handler.php

    r3288388 r3740659  
    7272                $raw_post_data = $wp_filesystem->get_contents( 'php://input' );
    7373                $signature = isset( $_SERVER['HTTP_X_SIGNATURE'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_SIGNATURE'] ) ) : '';
     74                // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_set_error_handler
    7475                set_error_handler( array( __CLASS__, 'handle_webhook_errors' ) );
    7576                try {
    … …  
    7980                        $webhook_service = WC_WeArePlanet_Service_Webhook::instance();
    8081
    81                         // Handling of payloads without a signature (legacy method).
    82                         // TODO add config to disable strategy/use default webhooks
    83                         // Deprecated since 3.0.12.
     82                        // Handling of payloads without a signature removed since 3.4.9.
     83                        // Log received unsigned webhook payloads and request that webhook signature to be enabled.
    8484                        if ( empty( $signature ) ) {
    85                                 $webhook_model = $webhook_service->get_webhook_entity_for_id( $request->get_listener_entity_id() );
    86                                 $webhook_handler_class_name = $webhook_model->get_handler_class_name();
    87                                 $webhook_handler = $webhook_handler_class_name::instance();
    88                                 $webhook_handler->process( $request );
     85                                $signature_missing_message = 'Webhook ' . $request->get_listener_entity_technical_name()
     86                                . ' lacked a signature. Enable payload signature and state for '
     87                                . $request->get_listener_entity_technical_name() . ' webhook listener.';
     88                                WooCommerce_WeArePlanet::instance()->log( $signature_missing_message, WC_Log_Levels::ERROR );
     89                                echo esc_textarea( $signature_missing_message );
    8990                        }
    9091
  • weareplanet/tags/3.4.9/includes/class-wc-weareplanet-zero-gateway.php

    r3321215 r3740659  
    11<?php
     2/**
     3 * Plugin Name: WeArePlanet
     4 * Author: Planet Merchant Services Ltd
     5 * Text Domain: weareplanet
     6 * Domain Path: /languages/
     7 *
     8 * WeArePlanet
     9 * This plugin will add support for all WeArePlanet payments methods and connect the WeArePlanet servers to your WooCommerce webshop (https://www.weareplanet.com/).
     10 *
     11 * @category Class
     12 * @package  WeArePlanet
     13 * @author   Planet Merchant Services Ltd (https://www.weareplanet.com)
     14 * @license  http://www.apache.org/licenses/LICENSE-2.0 Apache Software License (ASL 2.0)
     15 */
    216
    317if ( ! defined( 'ABSPATH' ) ) {
    … …  
    519}
    620
     21/**
     22 * Class WC_WeArePlanet_Zero_Gateway.
     23 * This class handles the zero payment gateway of WeArePlanet
     24 *
     25 * @class WC_WeArePlanet_Zero_Gateway
     26 */
    727class WC_WeArePlanet_Zero_Gateway extends WC_Payment_Gateway {
    828
    929        public const ZERO_PAYMENT_CONF_ID = 999999;
    1030
     31        /**
     32         * Constructor for the gateway.
     33         */
    1134        public function __construct() {
    1235                $this->id = 'weareplanet_zero';
    … …  
    2447
    2548                add_action(
    26                   'woocommerce_update_options_payment_gateways_' . $this->id,
    27                   array( $this, 'process_admin_options' )
     49                        'woocommerce_update_options_payment_gateways_' . $this->id,
     50                        array( $this, 'process_admin_options' )
    2851                );
    2952
    3053                add_filter(
    31                   'woocommerce_available_payment_gateways',
    32                   array( $this, 'hide_gateways_for_zero_order_total' )
     54                        'woocommerce_available_payment_gateways',
     55                        array( $this, 'hide_gateways_for_zero_order_total' )
    3356                );
    3457        }
    3558
     59        /**
     60         * Initialize form fields for the gateway settings.
     61         */
    3662        public function init_form_fields() {
    3763                $this->form_fields = array(
    38                   'enabled' => array(
    39                         'title'   => __( 'Enable/Disable', 'woo-weareplanet' ),
    40                         'type'    => 'checkbox',
    41                         'label'   => __( 'Enable No Payment Required Gateway', 'woo-weareplanet' ),
    42                         'default' => 'yes',
    43                   ),
    44                   'title' => array(
    45                         'title'       => __( 'Title', 'woo-weareplanet' ),
    46                         'type'        => 'text',
    47                         'description' => __( 'This controls the title seen by the customer during checkout.', 'woo-weareplanet' ),
    48                         'default'     => __( 'No Payment Required', 'woo-weareplanet' ),
    49                         'desc_tip'    => true,
    50                   ),
     64                        'enabled' => array(
     65                                'title'   => __( 'Enable/Disable', 'woo-weareplanet' ),
     66                                'type'    => 'checkbox',
     67                                'label'   => __( 'Enable No Payment Required Gateway', 'woo-weareplanet' ),
     68                                'default' => 'yes',
     69                        ),
     70                        'title' => array(
     71                                'title'       => __( 'Title', 'woo-weareplanet' ),
     72                                'type'        => 'text',
     73                                'description' => __( 'This controls the title seen by the customer during checkout.', 'woo-weareplanet' ),
     74                                'default'     => __( 'No Payment Required', 'woo-weareplanet' ),
     75                                'desc_tip'    => true,
     76                        ),
    5177                );
    5278        }
    5379
     80        /**
     81         * Check if the gateway is available for the current order.
     82         *
     83         * @return bool True if available, false otherwise.
     84         */
    5485        public function is_available() {
    55                 if (isset($_GET['pay_for_order']) && boolval($_GET['pay_for_order']) === true) {
     86                if ( isset( $_GET['pay_for_order'] ) && boolval( $_GET['pay_for_order'] ) === true ) {// phpcs:disable WordPress.Security.NonceVerification.Recommended -- $pay_for_order is a woocommerce read-only URL param. Value is only used as a bool flag.
    5687                        $order_id = get_query_var( 'order-pay' );
    5788                        $order = wc_get_order( $order_id );
    … …  
    6394                        return false;
    6495                }
    65                 return ( WC()->cart && WC()->cart->total == 0 ) && $this->enabled === 'yes';
     96                return ( WC()->cart && WC()->cart->total == 0 ) && 'yes' === $this->enabled;
    6697        }
    6798
     99        /**
     100         * Get the payment configuration ID for the zero payment gateway.
     101         *
     102         * @return int The payment configuration ID.
     103         */
    68104        public function get_payment_configuration_id() {
    69105                // This can be a fake or static ID just to satisfy the interface.
    … …  
    71107        }
    72108
     109        /**
     110         * Process the payment for the order.
     111         *
     112         * @param int $order_id The ID of the order being processed.
     113         * @return array An array containing the result and redirect URL.
     114         */
    73115        public function process_payment( $order_id ) {
    74116                $order = wc_get_order( $order_id );
    … …  
    77119
    78120                return array(
    79                   'result'   => 'success',
    80                   'redirect' => $this->get_return_url( $order ),
     121                        'result'   => 'success',
     122                        'redirect' => $this->get_return_url( $order ),
    81123                );
    82124        }
    83125
     126        /**
     127         * Hide other payment gateways when the order total is zero.
     128         *
     129         * @param array $available_gateways The available payment gateways.
     130         * @return array The modified list of available payment gateways.
     131         */
    84132        public function hide_gateways_for_zero_order_total( $available_gateways ) {
    85133                if ( is_admin() ) {
    … …  
    87135                }
    88136
    89                 if (isset($_GET['pay_for_order']) && boolval($_GET['pay_for_order']) === true) {
     137                if ( isset( $_GET['pay_for_order'] ) && boolval( $_GET['pay_for_order'] ) === true ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- $pay_for_order is a woocommerce read-only URL param. Value is only used as a bool flag.
    90138                        $order_id = get_query_var( 'order-pay' );
    91139                        $order = wc_get_order( $order_id );
    … …  
    97145
    98146                $has_subscription = self::cart_has_subscription();
    99                 if ( WC()->cart && WC()->cart->total == 0 && !$has_subscription ) {
     147                if ( WC()->cart && WC()->cart->total == 0 && ! $has_subscription ) {
    100148                        foreach ( $available_gateways as $gateway_id => $gateway ) {
    101                                 if ( $gateway_id !== 'weareplanet_zero' ) {
     149                                if ( 'weareplanet_zero' !== $gateway_id ) {
    102150                                        unset( $available_gateways[ $gateway_id ] );
    103151                                }
    … …  
    108156        }
    109157
     158        /**
     159         * Check if the cart contains any subscription products.
     160         *
     161         * @return bool True if the cart has a subscription, false otherwise.
     162         */
    110163        public static function cart_has_subscription() {
    111164                if ( ! function_exists( 'WC' ) || ! WC()->cart ) {
    … …  
    113166                }
    114167
    115                 $subscription_classes = [
    116                   'WC_Subscription_Product',
    117                   'WC_Product_Subscription',
    118                   'WC_Product_Subscription_Variation',
    119                 ];
     168                $subscription_classes = array(
     169                        'WC_Subscription_Product',
     170                        'WC_Product_Subscription',
     171                        'WC_Product_Subscription_Variation',
     172                );
    120173
    121174                foreach ( WC()->cart->get_cart() as $cart_item ) {
  • weareplanet/tags/3.4.9/includes/entity/class-wc-weareplanet-entity-attribute-options.php

    r3288388 r3740659  
    7171                global $wpdb;
    7272                $table = $wpdb->prefix . self::get_table_name();
    73                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     73                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    7474                $result = $wpdb->get_row(
    7575                        $wpdb->prepare(
    … …  
    7979                        ARRAY_A
    8080                );
    81                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     81                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    8282                if ( null !== $result ) {
    8383                        return new self( $result );
  • weareplanet/tags/3.4.9/includes/entity/class-wc-weareplanet-entity-method-configuration.php

    r3288388 r3740659  
    8282
    8383                $table = $wpdb->prefix . self::get_table_name();
    84                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     84                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    8585                $result = $wpdb->get_row(
    8686                        $wpdb->prepare(
    … …  
    9191                        ARRAY_A
    9292                );
    93                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     93                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    9494
    9595                if ( null !== $result ) {
  • weareplanet/tags/3.4.9/includes/entity/class-wc-weareplanet-entity-refund-job.php

    r3288388 r3740659  
    9898
    9999                $table = $wpdb->prefix . self::get_table_name();
    100                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     100                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    101101                $result = $wpdb->get_row(
    102102                        $wpdb->prepare(
    … …  
    107107                        ARRAY_A
    108108                );
    109                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     109                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    110110                if ( null !== $result ) {
    111111                        return new self( $result );
  • weareplanet/tags/3.4.9/includes/entity/class-wc-weareplanet-entity-token-info.php

    r3288388 r3740659  
    7474                global $wpdb;
    7575                $table = $wpdb->prefix . self::get_table_name();
    76                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     76                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    7777                $result = $wpdb->get_row(
    7878                        $wpdb->prepare(
    … …  
    8383                        ARRAY_A
    8484                );
    85                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     85                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    8686                if ( null !== $result ) {
    8787                        return new self( $result );
  • weareplanet/tags/3.4.9/includes/entity/class-wc-weareplanet-entity-transaction-info.php

    r3288388 r3740659  
    139139                global $wpdb;
    140140                $table = $wpdb->prefix . self::get_table_name();
    141                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     141                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    142142                $result = $wpdb->get_row(
    143143                        $wpdb->prepare(
    … …  
    148148                        ARRAY_A
    149149                );
    150                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     150                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    151151                if ( null !== $result ) {
    152152                        return new self( $result );
    … …  
    165165                global $wpdb;
    166166                $table = $wpdb->prefix . self::get_table_name();
    167                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     167                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    168168                $result = $wpdb->get_row(
    169169                        $wpdb->prepare(
    … …  
    173173                        ARRAY_A
    174174                );
    175                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     175                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    176176                if ( null !== $result ) {
    177177                        return new self( $result );
  • weareplanet/tags/3.4.9/includes/entity/class-wc-weareplanet-entity-void-job.php

    r3288388 r3740659  
    9393                global $wpdb;
    9494                $table = $wpdb->prefix . self::get_table_name();
    95                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     95                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    9696                $result = $wpdb->get_row( //phpcs:ignore
    9797                        $wpdb->prepare(
    … …  
    102102                        ARRAY_A
    103103                );
    104                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     104                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    105105                if ( null !== $result ) {
    106106                        return new self( $result );
    … …  
    120120
    121121                $table = $wpdb->prefix . self::get_table_name();
    122                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     122                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    123123                $result = $wpdb->get_var(
    124124                        $wpdb->prepare(
    … …  
    129129                        )
    130130                );
    131                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     131                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    132132                return $result;
    133133        }
    … …  
    143143                global $wpdb;
    144144                $table = $wpdb->prefix . self::get_table_name();
    145                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     145                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    146146                $result = $wpdb->get_row(
    147147                        $wpdb->prepare(
    … …  
    153153                        ARRAY_A
    154154                );
    155                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     155                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    156156                if ( null !== $result ) {
    157157                        return new self( $result );
    … …  
    172172                $time->sub( new DateInterval( 'PT10M' ) );
    173173                $table = $wpdb->prefix . self::get_table_name();
    174                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     174                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    175175                $db_results = $wpdb->get_results(
    176176                        $wpdb->prepare(
    … …  
    181181                        ARRAY_A
    182182                );
    183                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     183                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    184184                $result = array();
    185185                if ( is_array( $db_results ) ) {
  • weareplanet/tags/3.4.9/includes/packages/gift-card/class-wc-weareplanet-packages-gift-card.php

    r3433358 r3740659  
    2222 * This class provides constants for Gift Cards and serves as a placeholder for future improvements.
    2323 */
    24 class WC_WeArePlanet_Packages_Gift_Card
    25 {
     24class WC_WeArePlanet_Packages_Gift_Card {
    2625        const WEAREPLANET_GIFT_CARD = 'Gift Card';
    2726}
  • weareplanet/tags/3.4.9/includes/provider/class-wc-weareplanet-provider-language.php

    r3288388 r3740659  
    8989         */
    9090        protected function fetch_data() {
     91                // LanguageService::all() decodes languages.json into associative arrays, which the
     92                // ObjectSerializer cannot map onto models, so every language ends up without codes.
     93                $sdk_service = new \ReflectionClass( \WeArePlanet\Sdk\Service\LanguageService::class );
     94                $json_file   = dirname( $sdk_service->getFileName() ) . '/../languages.json';
     95                if ( is_readable( $json_file ) ) {
     96                        $languages = json_decode( file_get_contents( $json_file ) ); //phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
     97                        if ( ! empty( $languages ) && is_array( $languages ) ) {
     98                                return \WeArePlanet\Sdk\ObjectSerializer::deserialize( $languages, '\WeArePlanet\Sdk\Model\RestLanguage[]' );
     99                        }
     100                }
    91101                $language_service = new \WeArePlanet\Sdk\Service\LanguageService( WC_WeArePlanet_Helper::instance()->get_api_client() );
    92102                return $language_service->all();
  • weareplanet/tags/3.4.9/includes/service/class-wc-weareplanet-service-line-item.php

    r3477965 r3740659  
    273273         *
    274274         * @param WC_Coupon|WC_Order_Item_Coupon $coupon The coupon object.
    275          * @param float $total_discount_amount The amount of the coupon.
     275         * @param float                          $total_discount_amount The amount of the coupon.
     276         * @param array                          $items The items to calculate the proportional discount for.
    276277         * @return \WeArePlanet\Sdk\Model\LineItemCreate|null The line item created or null if the coupon is not valid.
    277278         */
    278         private function create_coupon_line_items( $coupon, float $total_discount_amount = 0, array $items = [] ) {
     279        private function create_coupon_line_items( $coupon, float $total_discount_amount = 0, array $items = array() ) {
    279280                if ( ! $coupon instanceof WC_Coupon && ! $coupon instanceof WC_Order_Item_Coupon ) {
    280281                        return array();
    … …  
    317318         * Calculate discount rates
    318319         *
     320         * @param array $items items.
    319321         * @param float $total_discount_amount total_discount_amount.
    320322         * @return array
    321323         */
    322324        private function calculate_discount_rates_proportionally( array $items, float $total_discount_amount ): array {
    323                 $tax_totals = [];
     325                $tax_totals = array();
    324326                $total_amount = 0;
    325327                // If coupon line items are created from session, $items will always be an empty array. If from order, it will have said order line items.
    326                 $is_created_from_order = ! empty($items);
     328                $is_created_from_order = ! empty( $items );
    327329
    328330                // Check whether line items are no created from existing order. If not, line items are fetched from cart.
    329                 if ( ! $is_created_from_order) {
     331                if ( ! $is_created_from_order ) {
    330332                        $cart = WC()->cart;
    331333                        $items = $cart->get_cart();
    … …  
    340342                        // If product has no tax rates class set, then create a fake 0 rate one.
    341343                        if ( empty( $tax_rates_class ) ) {
    342                                 $tax_rates_class = [
    343                                         0 => [
     344                                $tax_rates_class = array(
     345                                        0 => array(
    344346                                                'rate' => 0,
    345                                         ],
    346                                 ];
     347                                        ),
     348                                );
    347349                        }
    348350
    … …  
    352354                                $line_total = ! $is_created_from_order ? $item['line_total'] : $item->get_total();
    353355                                $line_tax = ! $is_created_from_order ? $item['line_tax'] : $item->get_total_tax();
    354                                 $line_total_with_tax = floor(($line_total + $line_tax) * 100) / 100;
     356                                $line_total_with_tax = floor( ($line_total + $line_tax ) * 100 ) / 100;
    355357
    356358                                if ( ! isset( $tax_totals[ $rate_id ] ) ) {
    357                                         $tax_totals[ $rate_id ] = [
     359                                        $tax_totals[ $rate_id ] = array(
    358360                                                'total' => 0,
    359361                                                'rate_percentage' => $rate['rate'],
    360                                         ];
     362                                        );
    361363                                }
    362364
    363                                 $tax_totals[ $rate_id ]['total'] += floor(($line_total_with_tax) * 100) / 100;
     365                                $tax_totals[ $rate_id ]['total'] += floor( ( $line_total_with_tax ) * 100 ) / 100;
    364366                                $total_amount += $line_total_with_tax;
    365367                        }
    … …  
    367369
    368370                if ( $total_amount <= 0 ) {
    369                         return [];
    370                 }
    371 
    372                 $discounts = [];
     371                        return array();
     372                }
     373
     374                $discounts = array();
    373375                foreach ( $tax_totals as $rate_id => $data ) {
    374                         if ( $total_amount == 0 ) {
     376                        if ( 0 === $total_amount ) {
    375377                                // If $total_amount is 0, no proportional discounts are applied, as there is nothing to distribute.
    376378                                $proportional_discount_amount = 0;
    377379                        } else {
    378                                 $proportional_discount_amount = floor($total_discount_amount * ( $data['total'] / $total_amount ) * 100) / 100;
     380                                $proportional_discount_amount = floor( $total_discount_amount * ( $data['total'] / $total_amount ) * 100 ) / 100;
    379381                        }
    380382
    381383                        if ( $proportional_discount_amount > 0 ) {
    382                                 $discounts[] = [
    383                                   'rate_id' => $rate_id,
    384                                   'amount' => $proportional_discount_amount,
    385                                   'rate_percentage' => $data['rate_percentage'],
    386                                 ];
     384                                $discounts[] = array(
     385                                        'rate_id' => $rate_id,
     386                                        'amount' => $proportional_discount_amount,
     387                                        'rate_percentage' => $data['rate_percentage'],
     388                                );
    387389                        }
    388390                }
    … …  
    641643         * Get items from backend.
    642644         *
    643          * @param array $backend_items backend items.
    644          * @param mixed $amount amount.
     645         * @param array    $backend_items backend items.
     646         * @param mixed    $amount amount.
    645647         * @param WC_Order $order order.
    646648         * @return \WeArePlanet\Sdk\Model\LineItemCreate[]
    … …  
    660662         * Creates the line items for the products
    661663         *
    662          * @param array $backend_items backend items.
     664         * @param array    $backend_items backend items.
    663665         * @param WC_Order $order order.
    664666         * @return \WeArePlanet\Sdk\Model\LineItemCreate[]
    … …  
    753755         * Returns the line items for fees.
    754756         *
    755          * @param array $backend_items backend items.
     757         * @param array    $backend_items backend items.
    756758         * @param WC_Order $order order.
    757759         * @return array
    … …  
    821823         * Returns the line items for the shipping costs.
    822824         *
    823          * @param array $backend_items backend items.
     825         * @param array    $backend_items backend items.
    824826         * @param WC_Order $order order.
    825827         * @return array
    … …  
    9991001         * Returns the line items from the given cart for order renewal.
    10001002         *
    1001          * @param WC_Order $order order.
    1002          * @param mixed $order_total Order total.
     1003         * @param WC_Order                                                    $order order.
     1004         * @param mixed                                                       $order_total Order total.
    10031005         * @param \WeArePlanet\Sdk\Model\AbstractTransactionPending $transaction Transaction.
    10041006         *
    … …  
    10231025                $gift_card_items = array();
    10241026
    1025                 $redeemed = WC()->session->get('_wc_gc_giftcards', []);
     1027                $redeemed = WC()->session->get( '_wc_gc_giftcards', array() );
    10261028
    10271029                if ( empty( $redeemed ) ) {
    … …  
    10451047                        }
    10461048
    1047                         // Receive the amount debited from the card for this order
     1049                        // Receive the amount debited from the card for this order.
    10481050                        $used_amount = $item['amount'];
    10491051
    … …  
    10521054                        }
    10531055
    1054                         // Prevent rounding errors from sdk
     1056                        // Prevent rounding errors from sdk.
    10551057                        $used_amount = round($used_amount, 2);
    10561058
    1057                         // Create Line Items for gift cards
     1059                        // Create Line Items for gift cards.
    10581060                        $line_item = new \WeArePlanet\Sdk\Model\LineItemCreate();
    10591061                        $line_item->setAmountIncludingTax( -1 * abs( $used_amount ) );
    … …  
    10661068                        $line_item->setType( \WeArePlanet\Sdk\Model\LineItemType::DISCOUNT );
    10671069
    1068                         // Zero tax for gift card
     1070                        // Zero tax for gift card.
    10691071                        $tax_rate = new \WeArePlanet\Sdk\Model\TaxCreate(
    10701072                                array(
    … …  
    10841086         * Create gift card line items from an order object (used in backend or sync).
    10851087         *
    1086          * @return \WeArePlanet\Sdk\Model\LineItemCreate[]
    1087          */
    1088         protected function create_gift_card_line_items_from_order( $order) {
     1088         * @param WC_Order $order order.
     1089         *
     1090         * @return \WeArePlanet\Sdk\Model\LineItemCreate[]
     1091         */
     1092        protected function create_gift_card_line_items_from_order( $order ) {
    10891093                if ( ! function_exists( 'WC_GC' ) ) {
    10901094                        return array();
    … …  
    10931097                $gift_card_items = array();
    10941098
    1095                 //Get array of strings with codes used in current order
     1099                // Get array of strings with codes used in current order.
    10961100                $used_codes = WC_GC()->order->get_gift_cards( $order );
    10971101
    … …  
    11001104                }
    11011105
    1102                 $order_gift_cards = [];
    1103 
    1104                 //Initialize appropriate Gift Card Objects for each code
     1106                $order_gift_cards = array();
     1107
     1108                // Initialize appropriate Gift Card Objects for each code.
    11051109                foreach ( $used_codes['codes'] as $item ) {
    11061110                        $order_gift_cards[] = wc_gc_get_gift_card_by_code( $item );
    … …  
    11111115                }
    11121116
    1113                 $items = $order->get_items('gift_card');
     1117                $items = $order->get_items( 'gift_card' );
    11141118
    11151119                foreach ( $items as $giftcard_item ) {
    … …  
    11281132
    11291133                        $line_item = new \WeArePlanet\Sdk\Model\LineItemCreate();
    1130                         // WeArePlanet expects discounts as negative values
     1134                        // WeArePlanet expects discounts as negative values.
    11311135                        $line_item->setAmountIncludingTax( -1 * abs( $used_amount ) );
    11321136                        /* translators: %s: gift card code */
    … …  
    11381142                        $line_item->setType( \WeArePlanet\Sdk\Model\LineItemType::DISCOUNT );
    11391143
    1140                         // Zero tax for gift card
     1144                        // Zero tax for gift card.
    11411145                        $tax_rate = new \WeArePlanet\Sdk\Model\TaxCreate(
    11421146                                array(
  • weareplanet/tags/3.4.9/includes/service/class-wc-weareplanet-service-token.php

    r3433358 r3740659  
    111111                        return;
    112112                }
    113                
    114                 // need to add a safety check here to see if the $token_version->getPaymentConnectorConfiguration()->getPaymentMethodConfiguration() exists
     113
     114                // need to add a safety check here to see if the $token_version->getPaymentConnectorConfiguration()->getPaymentMethodConfiguration() exists.
    115115                if ( $token_version->getPaymentConnectorConfiguration() === null ) {
    116116                        return;
  • weareplanet/tags/3.4.9/includes/service/class-wc-weareplanet-service-transaction.php

    r3463230 r3740659  
    9090         * @throws Exception If the API client cannot be initialized.
    9191         */
    92         public function __construct()
    93         {
     92        public function __construct() {
    9493                $this->api_client = WC_WeArePlanet_Helper::instance()->get_api_client();
    9594        }
    … …  
    503502         */
    504503        public function get_possible_payment_methods_for_cart() {
    505                 $paymentConfigurations = $this->get_possible_payment_methods( null );
    506                 $paymentConfigurations[] = WC_WeArePlanet_Zero_Gateway::ZERO_PAYMENT_CONF_ID;
    507 
    508                 return $paymentConfigurations;
     504                $payment_configurations = $this->get_possible_payment_methods( null );
     505                $payment_configurations[] = WC_WeArePlanet_Zero_Gateway::ZERO_PAYMENT_CONF_ID;
     506
     507                return $payment_configurations;
    509508        }
    510509
    … …  
    521520         */
    522521        public function get_possible_payment_methods_for_order( WC_Order $order ) {
    523                 $paymentConfigurations = $this->get_possible_payment_methods( $order );
    524                 $paymentConfigurations[] = WC_WeArePlanet_Zero_Gateway::ZERO_PAYMENT_CONF_ID;
    525 
    526                 return $paymentConfigurations;
     522                $payment_configurations = $this->get_possible_payment_methods( $order );
     523                $payment_configurations[] = WC_WeArePlanet_Zero_Gateway::ZERO_PAYMENT_CONF_ID;
     524
     525                return $payment_configurations;
    527526        }
    528527
    … …  
    569568         * @param WC_Order                                                    $order order.
    570569         * @param \WeArePlanet\Sdk\Model\AbstractTransactionPending $transaction transaction.
    571          * @param bool $set_line_items Set line items.
     570         * @param bool                                                        $set_line_items Set line items.
    572571         * @throws WC_WeArePlanet_Exception_Invalid_Transaction_Amount WC_WeArePlanet_Exception_Invalid_Transaction_Amount.
    573572         */
    … …  
    579578                $transaction->setCustomerId( $this->get_customer_id() );
    580579                $customer_note = $order->get_customer_note();
    581                 if (!empty($customer_note)) {
    582                         $transaction->setMetaData(['customerNotes' => $customer_note]);
     580                if ( ! empty( $customer_note ) ) {
     581                        $transaction->setMetaData( array( 'customerNotes' => $customer_note ) );
    583582                }
    584583                $language = null;
    … …  
    786785         * If no transaction exists, a new one is created.
    787786         *
     787         * @param int|null $current_cart_id current cart id.
    788788         * @return \WeArePlanet\Sdk\Model\Transaction
    789789         * @throws Exception Exception.
    790790         */
    791         public function get_transaction_from_session( $current_cart_id = null) {
     791        public function get_transaction_from_session( $current_cart_id = null ) {
    792792
    793793                if ( null === $current_cart_id ) {
    … …  
    910910         * Load and update transaction for order.
    911911         *
    912          * @param WC_Order $order order.
     912         * @param WC_Order                                         $order order.
    913913         * @param WC_WeArePlanet_Entity_Transaction_Info $existing_transaction existing transaction.
    914914         * @return \WeArePlanet\Sdk\Model\Transaction|\WeArePlanet\Sdk\Model\TransactionCreate
    … …  
    12071207         * Set modified order line items.
    12081208         *
    1209          * @param WC_Order                                                    $order       Order.
     1209         * @param WC_Order                                                    $order Order.
    12101210         * @param mixed                                                       $order_total Order total.
    12111211         * @param \WeArePlanet\Sdk\Model\AbstractTransactionPending $transaction Transaction.
    … …  
    12211221         *
    12221222         * @param WC_Order $order Order.
    1223          * @param mixed $order_total Order total.
    1224          * @param int $token_id Token id.
     1223         * @param mixed    $order_total Order total.
     1224         * @param int      $token_id Token id.
    12251225         *
    12261226         * @return \WeArePlanet\Sdk\Model\Transaction
    1227          * @throws Exception
    1228          *       If the transaction being created is not valid.
     1227         * @throws Exception Exception.
    12291228         */
    12301229        public function create_transaction_by_renewal_order( WC_Order $order, $order_total, $token_id ) {
    … …  
    12411240
    12421241                $create_transaction = apply_filters( 'wc_weareplanet_subscription_create_transaction', $create_transaction, $order );
    1243                 if (!$create_transaction->valid()) {
    1244                         throw new Exception("The transaction you are trying to create is not valid.");
    1245                 }
    1246                 WC_WeArePlanet_Helper::instance()->add_headers( $this->api_client, [
    1247                         WC_WeArePlanet_Helper::SUBSCRIPTION_TRANSACTION => true
    1248                 ]);
     1242                if ( ! $create_transaction->valid() ) {
     1243                        throw new Exception( 'The transaction you are trying to create is not valid.' );
     1244                }
     1245                WC_WeArePlanet_Helper::instance()->add_headers(
     1246                        $this->api_client,
     1247                        array(
     1248                                WC_WeArePlanet_Helper::SUBSCRIPTION_TRANSACTION => true,
     1249                        )
     1250                );
    12491251                $transaction = $this->get_transaction_service()->create( $space_id, $create_transaction );
    12501252                $this->update_transaction_info( $transaction, $order );
    … …  
    12551257         * Creates a transaction for the given order.
    12561258         *
    1257          * @param WC_Order                                     $order       Order.
     1259         * @param WC_Order                                     $order Order.
    12581260         * @param mixed                                        $order_total Order total.
    1259          * @param int                                          $token_id    Token id.
     1261         * @param int                                          $token_id Token id.
    12601262         * @param \WeArePlanet\Sdk\Model\Transaction $transaction Transaction.
    12611263         *
    … …  
    12751277                                $this->set_modified_order_line_items( $order, $order_total, $pending_transaction );
    12761278                                $pending_transaction = apply_filters( 'wc_weareplanet_subscription_update_transaction', $pending_transaction, $order );
    1277                                 WC_WeArePlanet_Helper::instance()->add_headers( $this->api_client, [
    1278                                         WC_WeArePlanet_Helper::SUBSCRIPTION_TRANSACTION => true
    1279                                 ]);
     1279                                WC_WeArePlanet_Helper::instance()->add_headers(
     1280                                        $this->api_client,
     1281                                        array(
     1282                                                WC_WeArePlanet_Helper::SUBSCRIPTION_TRANSACTION => true,
     1283                                        )
     1284                                );
    12801285                                return $this->get_transaction_service()->update( $transaction->getLinkedSpaceId(), $pending_transaction );
    12811286                        } catch ( \WeArePlanet\Sdk\VersioningException $e ) {
    … …  
    12891294         * Process transaction without user interaction.
    12901295         *
    1291          * @param mixed $space_id       Space id.
     1296         * @param mixed $space_id Space id.
    12921297         * @param mixed $transaction_id Transaction id.
    12931298         *
  • weareplanet/tags/3.4.9/includes/service/class-wc-weareplanet-service-webhook.php

    r3288388 r3740659  
    200200                        }
    201201                }
     202                $this->enforce_signed_listeners();
    202203        }
    203204
    … …  
    219220         * Create a webhook listener.
    220221         *
    221          * @param WC_WeArePlanet_Webhook_Entity $entity entity.
    222          * @param int $space_id space id.
     222         * @param WC_WeArePlanet_Webhook_Entity     $entity entity.
     223         * @param int                                         $space_id space id.
    223224         * @param \WeArePlanet\Sdk\Model\WebhookUrl $webhook_url webhook url.
    224225         *
    … …  
    241242         * Returns the existing webhook listeners.
    242243         *
    243          * @param int $space_id space id.
     244         * @param int                                         $space_id space id.
    244245         * @param \WeArePlanet\Sdk\Model\WebhookUrl $webhook_url webhook url.
    245246         *
    … …  
    343344                return $this->webhook_url_service;
    344345        }
     346
     347        /**
     348         * Enforces payload signatures on webhook listeners.
     349         *
     350         * @throws \Exception Exception.
     351         */
     352        public function enforce_signed_listeners() {
     353                $space_id = get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_SPACE_ID );
     354                if ( empty( $space_id ) ) {
     355                        return;
     356                }
     357                $webhook_url = $this->get_webhook_url( $space_id );
     358                if ( null === $webhook_url ) {
     359                        return;
     360                }
     361                try {
     362                        $webhook_listeners = $this->get_webhook_listeners( $space_id, $webhook_url );
     363                } catch ( Exception $e ) {
     364                        WooCommerce_WeArePlanet::instance()->log(
     365                                'Could not load webhook listeners to enforce signing: ' . $e->getMessage(),
     366                                WC_Log_Levels::ERROR
     367                        );
     368                }
     369                $webhook_service = $this->get_webhook_listener_service();
     370                foreach ( $webhook_listeners as $listener ) {
     371                        if ( $listener->getEnablePayloadSignatureAndState() ) {
     372                                continue;
     373                        }
     374                        try {
     375                                $update = new \WeArePlanet\Sdk\Model\WebhookListenerUpdate();
     376                                $update->setId( $listener->getId() );
     377                                $update->setVersion( $listener->getVersion() );
     378                                $update->setEnablePayloadSignatureAndState( true );
     379                                $webhook_service->update( $space_id, $update );
     380                        } catch ( \Exception $e ) {
     381                                WooCommerce_WeArePlanet::instance()->log(
     382                                        'Could not update webhook listeners to enforce signing: ' . $e->getMessage(),
     383                                        WC_Log_Levels::ERROR
     384                                );
     385                        }
     386                }
     387        }
    345388}
  • weareplanet/tags/3.4.9/includes/webhook/strategies/class-wc-weareplanet-webhook-delivery-indication-strategy.php

    r3378673 r3740659  
    6363
    6464        /**
    65          * Meant to bridge code from deprecated processor.
    66          *
    67          * @param WC_Order $order The WooCommerce order linked to the delivery indication.
    68          * @param \WeArePlanet\Sdk\Model\DeliveryIndication $delivery_indication The delivery indication object.
    69          * @param WC_WeArePlanet_Webhook_Request $request The webhook request.
    70          * @return void
    71          */
    72         public function bridge_process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\DeliveryIndication $delivery_indication, WC_WeArePlanet_Webhook_Request $request ) {
    73         $this->process_order_related_inner( $order, $delivery_indication, $request, true );
    74     }
    75 
    76         /**
    7765         * Processes the incoming webhook request pertaining to delivery indications.
    7866         *
    … …  
    9583         * Additional processing on the order based on the state of the delivery indication.
    9684         *
    97          * @param WC_Order $order The WooCommerce order linked to the delivery indication.
     85         * @param WC_Order                                            $order The WooCommerce order linked to the delivery indication.
    9886         * @param \WeArePlanet\Sdk\Model\DeliveryIndication $delivery_indication The delivery indication object.
    99          * @param WC_WeArePlanet_Webhook_Request $request The webhook request.
    100          * @param bool $legacy_mode legacy code used.
     87         * @param WC_WeArePlanet_Webhook_Request            $request The webhook request.
    10188         * @return void
    10289         */
    103         protected function process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\DeliveryIndication $delivery_indication, WC_WeArePlanet_Webhook_Request $request, $legacy_mode = false ) {
    104                 $entity_state = $legacy_mode ? $delivery_indication->getState() : $request->get_state();
     90        protected function process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\DeliveryIndication $delivery_indication, WC_WeArePlanet_Webhook_Request $request ) {
     91                $entity_state = $request->get_state();
    10592                switch ( $entity_state ) {
    10693                        case \WeArePlanet\Sdk\Model\DeliveryIndicationState::MANUAL_CHECK_REQUIRED:
  • weareplanet/tags/3.4.9/includes/webhook/strategies/class-wc-weareplanet-webhook-refund-strategy.php

    r3378673 r3740659  
    6262
    6363        /**
    64          * Meant to bridge code from deprecated processor.
    65          *
    66          * @param WC_Order $order The WooCommerce order associated with the refund.
    67          * @param \WeArePlanet\Sdk\Model\Refund $refund The transaction refund object.
    68          * @param WC_WeArePlanet_Webhook_Request $request The webhook request object.
    69          * @return void
    70          */
    71         public function bridge_process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\Refund $refund, WC_WeArePlanet_Webhook_Request $request ) {
    72         $this->process_order_related_inner( $order, $refund, $request, true );
    73     }
    74 
    75         /**
    7664         * Processes the incoming webhook request related to refunds.
    7765         *
    … …  
    9785         * @param \WeArePlanet\Sdk\Model\Refund $refund The transaction refund object.
    9886         * @param WC_WeArePlanet_Webhook_Request $request The webhook request object.
    99          * @param bool $legacy_mode legacy code used.
    10087         * @return void
    10188         */
    102         protected function process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\Refund $refund, WC_WeArePlanet_Webhook_Request $request, $legacy_mode = false ) {
     89        protected function process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\Refund $refund, WC_WeArePlanet_Webhook_Request $request ) {
    10390                /* @var \WeArePlanet\Sdk\Model\Refund $refund */
    104                 $entity_state = $legacy_mode ? $refund->getState() : $request->get_state();
     91                $entity_state = $request->get_state();
    10592                switch ( $entity_state ) {
    10693                        case \WeArePlanet\Sdk\Model\RefundState::FAILED:
  • weareplanet/tags/3.4.9/includes/webhook/strategies/class-wc-weareplanet-webhook-transaction-completion-strategy.php

    r3378673 r3740659  
    6363
    6464        /**
    65          * Meant to bridge code from deprecated processor.
    66          *
    67          * @param WC_Order $order The WooCommerce order linked to the completion.
    68          * @param \WeArePlanet\Sdk\Model\TransactionCompletion $completion The transaction completion object.
    69          * @param WC_WeArePlanet_Webhook_Request $request The webhook request.
    70          * @return void
    71          */
    72         public function bridge_process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\TransactionCompletion $completion, WC_WeArePlanet_Webhook_Request $request ) {
    73         $this->process_order_related_inner( $order, $completion, $request, true );
    74     }
    75 
    76         /**
    7765         * Processes the incoming webhook request pertaining to transaction completions.
    7866         *
    … …  
    9886         * @param \WeArePlanet\Sdk\Model\TransactionCompletion $completion The transaction completion object.
    9987         * @param WC_WeArePlanet_Webhook_Request $request The webhook request.
    100          * @param bool $legacy_mode legacy code used.
    101          * @return void
    102          */
    103         protected function process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\TransactionCompletion $completion, WC_WeArePlanet_Webhook_Request $request, $legacy_mode = false ) {
    104                 $entity_state = $legacy_mode ? $completion->getState() : $request->get_state();
     88         * @return void
     89         */
     90        protected function process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\TransactionCompletion $completion, WC_WeArePlanet_Webhook_Request $request ) {
     91                $entity_state = $request->get_state();
    10592                switch ( $entity_state ) {
    10693                        case \WeArePlanet\Sdk\Model\TransactionCompletionState::FAILED:
  • weareplanet/tags/3.4.9/includes/webhook/strategies/class-wc-weareplanet-webhook-transaction-invoice-strategy.php

    r3378673 r3740659  
    6363
    6464        /**
    65          * Meant to bridge code from deprecated processor.
    66          *
    67          * @param WC_Order $order The WooCommerce order linked to the invoice.
    68          * @param \WeArePlanet\Sdk\Model\TransactionInvoice $transaction_invoice The transaction invoice object.
    69          * @param WC_WeArePlanet_Webhook_Request $request The webhook request object.
    70          * @return void
    71          */
    72         public function bridge_process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\TransactionInvoice $transaction_invoice, WC_WeArePlanet_Webhook_Request $request ) {
    73         $this->process_order_related_inner( $order, $transaction_invoice, $request, true );
    74     }
    75 
    76         /**
    7765         * Processes the incoming webhook request pertaining to transaction invoices.
    7866         *
    … …  
    9583         * Additional processing on the order based on the state of the transaction invoice.
    9684         *
    97          * @param WC_Order $order The WooCommerce order linked to the invoice.
     85         * @param WC_Order                                            $order The WooCommerce order linked to the invoice.
    9886         * @param \WeArePlanet\Sdk\Model\TransactionInvoice $transaction_invoice The transaction invoice object.
    99          * @param WC_WeArePlanet_Webhook_Request $request The webhook request object.
    100          * @param bool $legacy_mode legacy code used.
     87         * @param WC_WeArePlanet_Webhook_Request            $request The webhook request object.
    10188         * @return void
    10289         */
    103         protected function process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\TransactionInvoice $transaction_invoice, WC_WeArePlanet_Webhook_Request $request, $legacy_mode = false ) {
    104                 $entity_state = $legacy_mode ? $transaction_invoice->getState() : $request->get_state();
     90        protected function process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\TransactionInvoice $transaction_invoice, WC_WeArePlanet_Webhook_Request $request ) {
     91                $entity_state = $request->get_state();
    10592                switch ( $entity_state ) {
    10693                        case \WeArePlanet\Sdk\Model\TransactionInvoiceState::DERECOGNIZED:
  • weareplanet/tags/3.4.9/includes/webhook/strategies/class-wc-weareplanet-webhook-transaction-strategy.php

    r3598699 r3740659  
    3838
    3939        /**
    40          * Meant to bridge code from deprecated processor.
    41          *
    42          * @param WC_Order $order order.
    43          * @param mixed $transaction transaction.
    44          * @return mixed The result of the processing.
    45          */
    46         public function bridge_process_order_related_inner( WC_Order $order, $transaction ) {
    47         $this->process_order_related_inner( $order, $transaction, true );
    48     }
    49 
    50         /**
    5140         * Process the webhook request.
    5241         *
    53          * @param \WeArePlanet\Sdk\Model\Transaction $transaction The webhook request object.
     42         * @param WC_WeArePlanet_Webhook_Request $request The webhook request.
    5443         * @return mixed The result of the processing.
    5544         */
    … …  
    5847                $entity = $this->load_entity( $request );
    5948
    60                 // retry orphaned transaction, fall back to merchant reference
     49                // Retry orphaned transaction, fall back to merchant reference.
    6150                if ( ( false === $order || ! $order->get_id() ) && $entity ) {
    6251                        $merchant_ref = $entity->getMerchantReference();
    … …  
    6857                if ( false != $order && $order->get_id() ) {
    6958                        $this->process_order_related_inner( $order, $entity );
    70                         if ($request->get_state() === \WeArePlanet\Sdk\Model\TransactionState::AUTHORIZED) {
     59                        if ( $request->get_state() === \WeArePlanet\Sdk\Model\TransactionState::AUTHORIZED ) {
    7160                                do_action( 'weareplanet_transaction_authorized_send_email', $order->get_id() );
    7261                        }
    … …  
    7968         * @param WC_Order $order order.
    8069         * @param mixed $transaction transaction.
    81          * @param bool $legacy_mode legacy code used.
    8270         * @return void
    8371         * @throws Exception Exception.
    8472         */
    85         protected function process_order_related_inner( WC_Order $order, $transaction, $legacy_mode = false ) {
     73        protected function process_order_related_inner( WC_Order $order, $transaction ) {
    8674                if ( strpos( $order->get_payment_method(), 'weareplanet' ) === false ) {
    8775                        return;
    … …  
    10896                                        $this->authorize( $transaction, $order );
    10997                                        $this->fulfill( $transaction, $order );
    110                                         if ( $legacy_mode ) {
    111                                                 do_action( 'weareplanet_transaction_authorized_send_email', $order->get_id() );
    112                                         }
    11398                                        WC_WeArePlanet_Helper::set_virtual_zero_total_orders_to_complete( $order );
    11499                                        WC_WeArePlanet_Helper::update_order_status_for_preorder_if_needed( $order );
    … …  
    127112                        WC_WeArePlanet_Service_Transaction::instance()->update_transaction_info( $transaction, $order );
    128113                }
    129 
    130                 if ( $legacy_mode ) {
    131                         // This is edge case for deferred payment methods
    132                         $transaction_info = WC_WeArePlanet_Entity_Transaction_Info::load_by_order_id( $order->get_id() );
    133                         if ($transaction_info->get_state() === \WeArePlanet\Sdk\Model\TransactionState::AUTHORIZED) {
    134                                 do_action( 'weareplanet_transaction_authorized_send_email', $order->get_id() );
    135                         }
    136                 }
    137114        }
    138115
    … …  
    141118         *
    142119         * @param \WeArePlanet\Sdk\Model\Transaction $transaction transaction.
    143          * @param WC_Order $order order.
     120         * @param WC_Order                                     $order order.
    144121         * @return void
    145122         */
    … …  
    162139         *
    163140         * @param \WeArePlanet\Sdk\Model\Transaction $transaction transaction.
    164          * @param \WC_Order $order order.
     141         * @param \WC_Order                                    $order order.
    165142         */
    166143        protected function authorize( \WeArePlanet\Sdk\Model\Transaction $transaction, WC_Order $order ) {
    … …  
    181158         *
    182159         * @param \WeArePlanet\Sdk\Model\Transaction $transaction transaction.
    183          * @param WC_Order $order order.
     160         * @param WC_Order                                     $order order.
    184161         * @return void
    185162         */
    … …  
    200177         *
    201178         * @param \WeArePlanet\Sdk\Model\Transaction $transaction transaction.
    202          * @param WC_Order $order order.
     179         * @param WC_Order                                     $order order.
    203180         * @return void
    204181         */
    … …  
    217194         *
    218195         * @param \WeArePlanet\Sdk\Model\Transaction $transaction transaction.
    219          * @param WC_Order $order order.
     196         * @param WC_Order                                     $order order.
    220197         * @return void
    221198         */
    … …  
    231208                        // Custom order statuses mapped.
    232209                        apply_filters( 'weareplanet_wc_status_for_transaction', 'confirmed' ),
    233                         apply_filters( 'weareplanet_wc_status_for_transaction', 'failed' )
     210                        apply_filters( 'weareplanet_wc_status_for_transaction', 'failed' ),
    234211                );
    235212                if ( in_array( $order->get_status( 'edit' ), $valid_order_statuses ) ) {
    … …  
    244221         *
    245222         * @param \WeArePlanet\Sdk\Model\Transaction $transaction transaction.
    246          * @param WC_Order $order order.
     223         * @param WC_Order                                     $order order.
    247224         * @return void
    248225         */
    … …  
    274251         *
    275252         * @param \WeArePlanet\Sdk\Model\Transaction $transaction transaction.
    276          * @param WC_Order $order order.
     253         * @param WC_Order                                     $order order.
    277254         * @return void
    278255         */
  • weareplanet/tags/3.4.9/includes/webhook/strategies/class-wc-weareplanet-webhook-transaction-void-strategy.php

    r3378673 r3740659  
    6666
    6767        /**
    68          * Meant to bridge code from deprecated processor.
    69          *
    70          * @param WC_Order $order The WooCommerce order associated with the void request.
    71          * @param \WeArePlanet\Sdk\Model\TransactionVoid $void The transaction void object.
    72          * @param WC_WeArePlanet_Webhook_Request $request The webhook request object.
    73          * @return void
    74          */
    75         public function bridge_process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\TransactionVoid $void, WC_WeArePlanet_Webhook_Request $request ) {
    76         $this->process_order_related_inner( $order, $void, $request, true );
    77     }
    78 
    79         /**
    8068         * Processes the incoming webhook request related to transaction voids.
    8169         *
    … …  
    10189         * @param \WeArePlanet\Sdk\Model\TransactionVoid $void The transaction void object.
    10290         * @param WC_WeArePlanet_Webhook_Request $request The webhook request object.
    103          * @param bool $legacy_mode legacy code used.
    10491         * @return void
    10592         */
    106         protected function process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\TransactionVoid $void, WC_WeArePlanet_Webhook_Request $request, $legacy_mode = false ) {
    107                 $entity_state = $legacy_mode ? $void->getState() : $request->get_state();
     93        protected function process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\TransactionVoid $void, WC_WeArePlanet_Webhook_Request $request ) {
     94                $entity_state = $request->get_state();
    10895                switch ( $entity_state ) {
    10996                        case \WeArePlanet\Sdk\Model\TransactionVoidState::FAILED:
  • weareplanet/tags/3.4.9/readme.txt

    r3676036 r3740659  
    33Tags: payment, WeArePlanet, e-commerce, invoice, psp
    44Requires at least: 6.0
    5 Tested up to: 7.0
    6 Stable tag: 3.4.8
     5Tested up to: 7.1.2
     6Stable tag: 3.4.9
    77License: Apache-2.0
    88License URI: http://www.apache.org/licenses/LICENSE-2.0
    … …  
    2222
    2323Additional documentation for this plugin is available:
    24 [here](https://plugin-documentation.weareplanet.com/weareplanet/woocommerce/3.4.8/docs/en/documentation.html).
     24[here](https://plugin-documentation.weareplanet.com/weareplanet/woocommerce/3.4.9/docs/en/documentation.html).
    2525
    2626== Source code and build process ==
    … …  
    204204== Changelog ==
    205205
    206 = 3.4.8 - September 1 2026 =
    207 - [BugFix] Fixed missing assets
     206= 3.4.9 - October 7 2026 =
     207- [Feature] Tested against Wordpress 7.1.2
     208- [Bugfix] Fixed issue where translations for payment methods were incorrect
    208209- [Tested Against] PHP 8.4.20
    209 - [Tested Against] Wordpress 7
    210 - [Tested Against] Woocommerce 11.0.1
    211 - [Tested Against] PHP SDK 4.9.1
     210- [Tested Against] Wordpress 7.1.2
     211- [Tested Against] Woocommerce 11.2.0
     212- [Tested Against] PHP SDK 4.9.2
  • weareplanet/tags/3.4.9/views/admin-notices/subscription-plugin-deactivate.php

    r3433358 r3740659  
    1919?>
    2020<div class="error notice notice-error">
    21     <p>
    22         <?php esc_html_e( 'WeArePlanet Subscription plugin has been deactivated because subscriptions are now handled directly by the WeArePlanet plugin. You can safely remove the old plugin', 'woo-weareplanet' ); ?>
    23     </p>
     21        <p>
     22                <?php esc_html_e( 'WeArePlanet Subscription plugin has been deactivated because subscriptions are now handled directly by the WeArePlanet plugin. You can safely remove the old plugin', 'woo-weareplanet' ); ?>
     23        </p>
    2424</div>
  • weareplanet/tags/3.4.9/views/admin-settings/html-admin-page-order-statuses.php

    r3463230 r3740659  
    2525        <thead>
    2626                <tr>
    27                         <?php foreach ( $order_statuses_columns as $status_key => $heading ) : ?>
    28                                 <th class="<?php echo esc_attr( $status_key ); ?>"><?php echo esc_html( $heading ); ?></th>
     27                        <?php foreach ( $order_statuses_columns as $weareplanet_status_key => $weareplanet_heading ) : ?>
     28                                <th class="<?php echo esc_attr( $weareplanet_status_key ); ?>"><?php echo esc_html( $weareplanet_heading ); ?></th>
    2929                        <?php endforeach; ?>
    3030                        <th />
    … …  
    5555                                <article>
    5656                                <form action="" method="post">
    57                     <input type="hidden" name="key" value="{{{ data.key }}}" />
     57                                        <input type="hidden" name="key" value="{{{ data.key }}}" />
    5858                                        <?php
    59                                         foreach ( $order_statuses_columns as $status_key => $heading ) {
    60                                                 echo '<div class="weareplanet-order-statuses-modal-input wc-shipping-class-modal-input ' . esc_attr( $status_key ) . '">';
    61                                                 switch ( $status_key ) {
     59                                        foreach ( $order_statuses_columns as $weareplanet_status_key => $weareplanet_heading ) {
     60                                                echo '<div class="weareplanet-order-statuses-modal-input wc-shipping-class-modal-input ' . esc_attr( $weareplanet_status_key ) . '">';
     61                                                switch ( $weareplanet_status_key ) {
    6262                                                        case 'weareplanet-order-status-key':
    6363                                                                ?>
    6464                                                                <div class="view">
    65                                                                         <?php echo esc_html( $heading ); ?> *
     65                                                                        <?php echo esc_html( $weareplanet_heading ); ?> *
    6666                                                                </div>
    6767                                                                <div class="edit">
    … …  
    7474                                                                                        placeholder="<?php esc_attr_e( 'e.g. awaiting', 'woo-weareplanet' ); ?>" />
    7575                                                                        </label>
    76                                     <small id="charCount" style="color: gray;"></small>
     76                                                                        <small id="charCount" style="color: gray;"></small>
    7777                                                                </div>
    7878                                                                <div class="weareplanet-order-statuses-modal-help-text wc-shipping-class-modal-help-text"><?php esc_html_e( 'Give your custom status a name for easy identification', 'woo-weareplanet' ); ?></div>
    … …  
    102102        <tr data-id="{{ data.key }}">
    103103                <?php
    104                 foreach ( $order_statuses_columns as $status_key => $heading ) {
    105                         echo '<td class="' . esc_attr( $status_key ) . '">';
    106                         switch ( $status_key ) {
     104                foreach ( $order_statuses_columns as $weareplanet_status_key => $weareplanet_heading ) {
     105                        echo '<td class="' . esc_attr( $weareplanet_status_key ) . '">';
     106                        switch ( $weareplanet_status_key ) {
    107107                                case 'weareplanet-order-status-key':
    108108                                        ?>
  • weareplanet/tags/3.4.9/weareplanet-sdk/composer.json

    r3673687 r3740659  
    11{
    22        "name": "weareplanet/sdk",
    3         "version": "4.9.1",
     3        "version": "4.9.2",
    44        "description": "WeArePlanet SDK for PHP",
    55        "keywords": [
  • weareplanet/tags/3.4.9/weareplanet-sdk/lib/ApiClient.php

    r3673687 r3740659  
    4949         */
    5050        private $defaultHeaders = [
    51         'x-meta-sdk-version' => "4.9.1",
     51        'x-meta-sdk-version' => "4.9.2",
    5252        'x-meta-sdk-language' => 'php',
    5353        'x-meta-sdk-provider' => "WeArePlanet",
    … …  
    5959         * @var string
    6060         */
    61         private $userAgent = 'PHP-Client/4.9.1/php';
     61        private $userAgent = 'PHP-Client/4.9.2/php';
    6262
    6363        /**
  • weareplanet/tags/3.4.9/weareplanet-sdk/lib/Configuration.php

    r3673687 r3740659  
    8181     * @var string
    8282     */
    83     protected $userAgent = 'WeArePlanet\Sdk/4.9.1/php';
     83    protected $userAgent = 'WeArePlanet\Sdk/4.9.2/php';
    8484
    8585    /**
    … …  
    389389        $report .= '    OS: ' . php_uname() . PHP_EOL;
    390390        $report .= '    PHP Version: ' . PHP_VERSION . PHP_EOL;
    391         $report .= '    OpenAPI Spec Version: 4.9.1' . PHP_EOL;
    392         $report .= '    SDK Package Version: 4.9.1' . PHP_EOL;
     391        $report .= '    OpenAPI Spec Version: 4.9.2' . PHP_EOL;
     392        $report .= '    SDK Package Version: 4.9.2' . PHP_EOL;
    393393        $report .= '    Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL;
    394394
  • weareplanet/tags/3.4.9/weareplanet-sdk/lib/Model/AbstractWebhookListenerUpdate.php

    r3673687 r3740659  
    4949      */
    5050    protected static $swaggerTypes = [
     51        'enable_payload_signature_and_state' => 'bool',
    5152        'entity_states' => 'string[]',
    5253        'name' => 'string',
    … …  
    6162      */
    6263    protected static $swaggerFormats = [
     64        'enable_payload_signature_and_state' => null,
    6365        'entity_states' => null,
    6466        'name' => null,
    … …  
    7476     */
    7577    protected static $attributeMap = [
     78        'enable_payload_signature_and_state' => 'enablePayloadSignatureAndState',
    7679        'entity_states' => 'entityStates',
    7780        'name' => 'name',
    … …  
    8689     */
    8790    protected static $setters = [
     91        'enable_payload_signature_and_state' => 'setEnablePayloadSignatureAndState',
    8892        'entity_states' => 'setEntityStates',
    8993        'name' => 'setName',
    … …  
    98102     */
    99103    protected static $getters = [
     104        'enable_payload_signature_and_state' => 'getEnablePayloadSignatureAndState',
    100105        'entity_states' => 'getEntityStates',
    101106        'name' => 'getName',
    … …  
    121126    public function __construct(?array $data = null)
    122127    {
     128
     129        $this->container['enable_payload_signature_and_state'] = isset($data['enable_payload_signature_and_state']) ? $data['enable_payload_signature_and_state'] : null;
    123130       
    124131        $this->container['entity_states'] = isset($data['entity_states']) ? $data['entity_states'] : null;
  • weareplanet/tags/3.4.9/weareplanet-sdk/test/ApiClientTest.php

    r3673687 r3740659  
    145145
    146146        // Check SDK default header values.
    147         $this->assertEquals($headers['x-meta-sdk-version'], "4.9.1");
     147        $this->assertEquals($headers['x-meta-sdk-version'], "4.9.2");
    148148        $this->assertEquals($headers['x-meta-sdk-language'], 'php');
    149149        $this->assertEquals($headers['x-meta-sdk-provider'], "WeArePlanet");
  • weareplanet/tags/3.4.9/weareplanet.php

    r3676036 r3740659  
    44 * Plugin URI: https://wordpress.org/plugins/woo-weareplanet
    55 * Description: Process WooCommerce payments with WeArePlanet.
    6  * Version: 3.4.8
     6 * Version: 3.4.9
    77 * Author: Planet Merchant Services Ltd
    88 * Author URI: https://www.weareplanet.com
    … …  
    1616 * License: Apache-2.0
    1717 * License URI: http://www.apache.org/licenses/LICENSE-2.0
     18 *
     19 * @package WeArePlanet
    1820 */
     21
    1922if ( ! defined( 'ABSPATH' ) ) {
    2023        exit(); // Exit if accessed directly.
    … …  
    4346                const WEAREPLANET_CK_DISABLE_PENDING_EMAIL = 'wc_weareplanet_disable_pending_email';
    4447                const WEAREPLANET_CK_ENABLE_CUSTOM_STATUS_MAPPING = 'wc_weareplanet_enable_custom_status_mapping';
    45                 const WEAREPLANET_UPGRADE_VERSION = '3.1.1';
    46                 const WC_MAXIMUM_VERSION = '11.0.1';
     48                const WEAREPLANET_UPGRADE_VERSION = '3.1.1'; // Leave this number alone! It was a fix for a problem introduced at this version.
     49                const WC_MAXIMUM_VERSION = '11.2.0';
    4750                const REQUIRED_WC_SUBSCRIPTION_VERSION = '2.5';
    4851
    … …  
    5255                 * @var string
    5356                 */
    54                 private $version = '3.4.8';
     57                private $version = '3.4.9';
    5558
    5659                /**
    … …  
    8992                }
    9093
     94                /**
     95                 * Define constant if not already set.
     96                 */
    9197                public function boot() {
    9298                        $this->init();
    9399                }
    94100
     101                /**
     102                 * Initialize the plugin.
     103                 */
    95104                private function init() {
    96105                        $this->includes();
    … …  
    159168                                array(
    160169                                        'WooCommerce_WeArePlanet',
    161                                         'migrate_plugin_data_on_activation'
     170                                        'migrate_plugin_data_on_activation',
    162171                                )
    163172                        );
    … …  
    393402                 */
    394403                public static function get_installed_plugin_version( $plugin_slug ) {
    395                         if (!function_exists( 'get_plugins' ) ) {
     404                        if ( ! function_exists( 'get_plugins' ) ) {
    396405                                require_once ABSPATH . 'wp-admin/includes/plugin.php';
    397406                        }
    … …  
    400409                        foreach ( $all_plugins as $plugin_path => $plugin_info ) {
    401410                                if ( strpos( $plugin_path, $plugin_slug ) !== false ) {
    402                                         return $plugin_info[ 'Version' ];
     411                                        return $plugin_info['Version'];
    403412                                }
    404413                        }
    … …  
    457466
    458467                        global $wpdb;
    459                         $options_to_migrate = [
     468                        $options_to_migrate = array(
    460469                                $old_option_prefix . WC_WeArePlanet_Migration::WEAREPLANET_CK_DB_VERSION,
    461470                                $old_option_prefix . WC_WeArePlanet_Service_Manual_Task::WEAREPLANET_CONFIG_KEY,
    … …  
    472481                                $old_option_prefix . self::WEAREPLANET_CK_CHANGE_ORDER_STATUS,
    473482                                $old_option_prefix . self::WC_MAXIMUM_VERSION,
    474                         ];
     483                        );
    475484
    476485                        // If the old plugin options exist, perform the migration.
    … …  
    487496                                                add_option( $new_option_name, $option_value );
    488497                                        }
    489                                         // Delete the old option.
    490                                         //delete_option( $option_name );.
     498                                        // Delete the old option: delete_option( $option_name );.
    491499                                }
    492500                        }
    … …  
    498506                 *
    499507                 * @param object $upgrader_object The upgrader object.
    500                  * @param array $options The options array.
     508                 * @param array  $options The options array.
    501509                 */
    502510                public static function migrate_plugin_data_after_update( $upgrader_object, $options ) {
    … …  
    530538
    531539                        // WordPress.org will auto-load translations. No need to call load_plugin_textdomain().
    532                         // $this->load_plugin_textdomain();
    533                         add_action('plugins_loaded', function () {
    534                                 if (class_exists('WC_Payment_Gateway')) {
    535                                         require_once WC_WEAREPLANET_ABSPATH . 'includes/class-wc-weareplanet-zero-gateway.php';
    536                                         add_filter(
    537                                           'woocommerce_payment_gateways',
    538                                           array(
    539                                                 WooCommerce_WeArePlanet::instance(),
    540                                                 'add_gateways',
    541                                           )
    542                                         );
    543                                 }
    544                         }, 20);
     540                        // $this->load_plugin_textdomain();.
     541                        add_action(
     542                                'plugins_loaded',
     543                                function () {
     544                                        if ( class_exists( 'WC_Payment_Gateway' ) ) {
     545                                                require_once WC_WEAREPLANET_ABSPATH . 'includes/class-wc-weareplanet-zero-gateway.php';
     546                                                add_filter(
     547                                                        'woocommerce_payment_gateways',
     548                                                        array(
     549                                                                WooCommerce_WeArePlanet::instance(),
     550                                                                'add_gateways',
     551                                                        )
     552                                                );
     553                                        }
     554                                },
     555                                20
     556                        );
    545557                        add_action(
    546558                                'plugins_loaded',
    … …  
    603615                        add_filter(
    604616                                'woocommerce_cart_needs_payment',
    605                                 function($value, $object) {
     617                                function ( $value, $object ) {
    606618                                        return true;
    607                                 }, 10, 2
     619                                },
     620                                10,
     621                                2
    608622                        );
    609623                        add_filter(
    610                                 'woocommerce_order_needs_payment',
    611                                 function($value, $order) {
     624                                'woocommerce_order_needs_payment',
     625                                function ( $value, $order ) {
    612626                                        $order_data = $order->get_data();
    613                                         if (substr_count($order_data['payment_method'], "weareplanet")) {
     627                                        if ( substr_count( $order_data['payment_method'], 'weareplanet' ) ) {
    614628                                                // If the order is using our payment method, we want to process it
    615629                                                // even if the value of the transaction is 0, which woocommerce by default
    616630                                                // process it without payment gateway.
    617631                                                $transaction_info = WC_WeArePlanet_Entity_Transaction_Info::load_by_order_id( $order->get_id() );
    618                                                 if ( in_array(
    619                                                   $transaction_info->get_state(),
    620                                                   array(
    621                                                         \WeArePlanet\Sdk\Model\TransactionState::FULFILL,
    622                                                         \WeArePlanet\Sdk\Model\TransactionState::AUTHORIZED,
    623                                                         \WeArePlanet\Sdk\Model\TransactionState::COMPLETED,
    624                                                         \WeArePlanet\Sdk\Model\TransactionState::FAILED,
    625                                                         \WeArePlanet\Sdk\Model\TransactionState::DECLINE,
    626                                                   ),
    627                                                   true
    628                                                 ) ) {
     632                                                if (
     633                                                        in_array(
     634                                                                $transaction_info->get_state(),
     635                                                                array(
     636                                                                        \WeArePlanet\Sdk\Model\TransactionState::FULFILL,
     637                                                                        \WeArePlanet\Sdk\Model\TransactionState::AUTHORIZED,
     638                                                                        \WeArePlanet\Sdk\Model\TransactionState::COMPLETED,
     639                                                                        \WeArePlanet\Sdk\Model\TransactionState::FAILED,
     640                                                                        \WeArePlanet\Sdk\Model\TransactionState::DECLINE,
     641                                                                ),
     642                                                                true
     643                                                        )
     644                                                ) {
    629645                                                        return false;
    630646                                                }
    … …  
    632648                                        }
    633649                                        return $value;
    634                                 }, 10, 2
     650                                },
     651                                10,
     652                                2
    635653                        );
    636654                        add_action(
    … …  
    772790                        );
    773791
    774                         add_filter('the_content', function($content) {
    775                                 if ( is_checkout() && ! is_order_received_page() ) {
    776                                         // When in checkout, we inject the list of payment methods in the HTML.
    777                                         // The goal here is to speed up the process of registering the payment methods.
    778                                         $payment_methods = WC_WeArePlanet_Blocks_Support::get_payment_methods();
    779                                         $json_data = json_encode( $payment_methods );
    780                                         $content .= '<div id="weareplanet-payment-methods" data-json="' . esc_attr( $json_data ) . '"></div>';
    781                                 }
    782 
    783                                 return $content;
    784                         });
     792                        add_filter(
     793                                'the_content',
     794                                function ( $content ) {
     795                                        if ( is_checkout() && ! is_order_received_page() ) {
     796                                                // When in checkout, we inject the list of payment methods in the HTML.
     797                                                // The goal here is to speed up the process of registering the payment methods.
     798                                                $payment_methods = WC_WeArePlanet_Blocks_Support::get_payment_methods();
     799                                                $json_data = json_encode( $payment_methods );
     800                                                $content .= '<div id="weareplanet-payment-methods" data-json="' . esc_attr( $json_data ) . '"></div>';
     801                                        }
     802
     803                                        return $content;
     804                                }
     805                        );
    785806                }
    786807
    … …  
    806827                 * @return bool
    807828                 */
    808                 public static function is_subscriptions_compatible(): bool  {
     829                public static function is_subscriptions_compatible(): bool {
    809830                        $plugin_name = 'woocommerce-subscriptions.php';
    810831                        $woocommerce_subscriptions_directory = self::find_plugin_path( $plugin_name );
    … …  
    825846                 * Looks for legacy subscription plugin's directory.
    826847                 *
     848                 * @param string $plugin_name The plugin file name to search for.
    827849                 * @return string|null
    828850                 */
    … …  
    867889                }
    868890
    869         /**
    870         * Register order statuses.
    871         *
    872         * @return void
    873         */
    874         public function register_order_statuses() {
    875                 $common_args = array(
    876                         'public' => true,
    877                         'exclude_from_search' => false,
    878                         'show_in_admin_all_list' => true,
    879                         'show_in_admin_status_list' => true,
    880                 );
    881 
    882                 register_post_status(
    883                         'wc-wearep-redirected',
    884                         array_merge(
     891                /**
     892                * Register order statuses.
     893                *
     894                * @return void
     895                */
     896                public function register_order_statuses() {
     897                        $common_args = array(
     898                                'public' => true,
     899                                'exclude_from_search' => false,
     900                                'show_in_admin_all_list' => true,
     901                                'show_in_admin_status_list' => true,
     902                        );
     903
     904                        register_post_status(
     905                                'wc-wearep-redirected',
     906                                array_merge(
    885907                                        $common_args,
    886908                                        array(
    … …  
    918940                 * Add order statuses.
    919941                 *
    920         * @param mixed $order_statuses order statuses.
    921         * @return mixed
    922         */
    923         public function add_order_statuses( $order_statuses ) {
    924                 $order_statuses['wc-wearep-redirected'] = _x( 'Redirected', 'Order status', 'woo-weareplanet' );
    925                 $order_statuses['wc-wearep-waiting'] = _x( 'Waiting', 'Order status', 'woo-weareplanet' );
    926                 $order_statuses['wc-wearep-manual'] = _x( 'Manual Decision', 'Order status', 'woo-weareplanet' );
    927 
    928                 return $order_statuses;
     942                * @param mixed $order_statuses order statuses.
     943                * @return mixed
     944                */
     945                public function add_order_statuses( $order_statuses ) {
     946                        $order_statuses['wc-wearep-redirected'] = _x( 'Redirected', 'Order status', 'woo-weareplanet' );
     947                        $order_statuses['wc-wearep-waiting'] = _x( 'Waiting', 'Order status', 'woo-weareplanet' );
     948                        $order_statuses['wc-wearep-manual'] = _x( 'Manual Decision', 'Order status', 'woo-weareplanet' );
     949
     950                        return $order_statuses;
    929951                }
    930952
    … …  
    936958                 * @return mixed
    937959                 */
    938         public function valid_order_statuses_for_payment( $statuses, $order = null ) { //phpcs:ignore
    939                 if ( WC_WeArePlanet_Helper::is_custom_status_mapping_enabled() ) {
    940                         $statuses[] = 'wearep-redirected';
    941                 }
    942 
    943                 return $statuses;
    944         }
     960                public function valid_order_statuses_for_payment( $statuses, $order = null ) { //phpcs:ignore
     961                        if ( WC_WeArePlanet_Helper::is_custom_status_mapping_enabled() ) {
     962                                $statuses[] = 'wearep-redirected';
     963                        }
     964
     965                        return $statuses;
     966                }
    945967
    946968                /**
    … …  
    964986                        }
    965987
    966                         // Sanitize input properly.
    967                         $changes = sanitize_text_field( wp_unslash( $_POST['changes'] ) );
     988                        // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- $_POST['changes'] array is unslashed with wp_unslash(). We sanitize each field individually with array_map( 'sanitize_text_field' ) and sanitize_key() below.
     989                        $changes = wp_unslash( $_POST['changes'] );
    968990
    969991                        // Get the first key inside the 'changes' array.
    970992                        $first_key = key( $changes );
    971                         $data = $_POST['changes'][$first_key];
     993                        if ( ! isset( $changes[ $first_key ] ) || ! is_array( $changes[ $first_key ] ) ) {
     994                                wp_send_json_error( 'invalid_data' );
     995                                wp_die();
     996                        }
     997                        $raw_data = $changes[ $first_key ];
     998                        $data = array_map( 'sanitize_text_field', $raw_data );
     999                        $first_key = sanitize_key( $first_key );
    9721000
    9731001                        if ( isset( $data['key'] ) ) {
    974                                 $label = str_replace( ['-', '_'], ' ', sanitize_text_field( $data['key'] ) );
     1002                                $label = str_replace( array( '-', '_' ), ' ', sanitize_text_field( $data['key'] ) );
    9751003
    9761004                                // Normalize the key by replacing spaces and dashes with underscores.
    977                                 $sanitized_key_underscore = str_replace( [' ', '-'], '_', WC_WeArePlanet_Order_Status_Adapter::WEAREPLANET_CUSTOM_ORDER_STATUS_PREFIX . $first_key );
    978                                 $sanitized_key_hyphen = str_replace( [' ', '_'], '-', $first_key );
     1005                                $sanitized_key_underscore = str_replace( array( '-', '_' ), '_', WC_WeArePlanet_Order_Status_Adapter::WEAREPLANET_CUSTOM_ORDER_STATUS_PREFIX . $first_key );
     1006                                $sanitized_key_hyphen = str_replace( array( ' ', '_' ), '-', $first_key );
    9791007
    9801008                                // Construct the full option name with the required prefix.
    … …  
    9841012                                update_option( $custom_order_name, $custom_order_value );
    9851013
    986                                 register_post_status( $custom_order_value, array(
    987                                         'label' => $label,
    988                                         'public' => true,
    989                                         'show_in_admin_status_list' => true,
    990                                         'show_in_admin_all_list' => true,
    991                                         'exclude_from_search' => false,
    992                                         'label_count' => array(
    993                                                 'singular' => sprintf( '%s <span class="count">(%s)</span>', $label, '%s' ),
    994                                                 'plural'   => sprintf( '%s <span class="count">(%s)</span>', $label, '%s' ),
     1014                                wp_cache_delete( 'weareplanet_custom_order_statuses', 'weareplanet' );
     1015
     1016                                register_post_status(
     1017                                        $custom_order_value,
     1018                                        array(
     1019                                                'label' => $label,
     1020                                                'public' => true,
     1021                                                'show_in_admin_status_list' => true,
     1022                                                'show_in_admin_all_list' => true,
     1023                                                'exclude_from_search' => false,
     1024                                                'label_count' => array(
     1025                                                        'singular' => sprintf( '%s <span class="count">(%s)</span>', $label, '%s' ),
     1026                                                        'plural'   => sprintf( '%s <span class="count">(%s)</span>', $label, '%s' ),
     1027                                                )
    9951028                                        )
    996                                 ) );
     1029                                );
    9971030
    9981031                                // Send a success response with the saved order status details.
    999                                 wp_send_json_success([
    1000                                         'message'      => 'Success',
    1001                                         'order_status' => [
    1002                                                 'key'   => $custom_order_value,  // The full key with the prefix.
    1003                                                 'label' => ucfirst( $label ), // As received from the form data.
    1004                                                 'type'  => __( 'custom' , 'woo-weareplanet' )
    1005                                         ]
    1006                                 ]);
     1032                                wp_send_json_success(
     1033                                        array(
     1034                                                'message' => 'Success',
     1035                                                'order_status' => array(
     1036                                                        'key' => $custom_order_value,  // The full key with the prefix.
     1037                                                        'label' => ucfirst( $label ), // As received from the form data.
     1038                                                        'type' => __( 'custom', 'woo-weareplanet' ),
     1039                                                ),
     1040                                        )
     1041                                );
    10071042                        } else {
    10081043                                wp_send_json_error( 'invalid_data' );
    … …  
    10331068
    10341069                        $sanitized_key = sanitize_text_field( wp_unslash( $_POST['key'] ) );
    1035 
    1036                         // Check if this order status is being used in wp_options with key prefix "weareplanet_order_status_mapping_".
    1037                         $like_pattern = WC_WeArePlanet_Order_Status_Adapter::WEAREPLANET_ORDER_STATUS_MAPPING_PREFIX . '%';
    1038                         $is_used = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->options} WHERE option_name LIKE %s AND option_value = %s", $like_pattern, $sanitized_key ) );
     1070                        $cache_group = 'weareplanet';
     1071
     1072                        $is_used_cache_key = 'weareplanet_status_in_use_' . md5( $sanitized_key );
     1073                        $is_used = wp_cache_get( $is_used_cache_key, $cache_group );
     1074
     1075                        if ( $is_used === false ) {
     1076                                // Check if this order status is being used in wp_options with key prefix "weareplanet_order_status_mapping_".
     1077                                $like_pattern = WC_WeArePlanet_Order_Status_Adapter::WEAREPLANET_ORDER_STATUS_MAPPING_PREFIX . '%';
     1078                                // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
     1079                                $is_used = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->options} WHERE option_name LIKE %s AND option_value = %s", $like_pattern, $sanitized_key ) );
     1080                                wp_cache_set( $is_used_cache_key, $is_used, $cache_group, HOUR_IN_SECONDS );
     1081                        }
    10391082
    10401083                        if ( $is_used > 0 ) {
    10411084                                // The status is in use, so do not delete it.
    1042                                 wp_send_json_error( ['message' => __( 'Cannot delete: this status is currently in use.', 'woo-weareplanet' ), 'key' => ucfirst( $sanitized_key )], 400 );
    1043                         }
    1044 
    1045                          // Get the custom order status in wp_options with key prefix "weareplanet_order_status_mapping_".
    1046                         $like_pattern = WC_WeArePlanet_Order_Status_Adapter::WEAREPLANET_CUSTOM_ORDER_STATUS_PREFIX . '%';
    1047                         $custom_order_status_name = $wpdb->get_var( $wpdb->prepare( "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE %s AND option_value = %s", $like_pattern, $sanitized_key ) );
     1085                                wp_send_json_error(
     1086                                        array(
     1087                                                'message' => __( 'Cannot delete: this status is currently in use.', 'woo-weareplanet' ),
     1088                                                'key' => ucfirst( $sanitized_key ),
     1089                                        ),
     1090                                        400
     1091                                );
     1092                        }
     1093
     1094                        $option_name_cache_key = 'weareplanet_status_option_name_' . md5( $sanitized_key );
     1095                        $custom_order_status_name = wp_cache_get( $option_name_cache_key, $cache_group );
     1096
     1097                        if ( $custom_order_status_name === false ) {
     1098                                // Get the custom order status in wp_options with key prefix "weareplanet_order_status_mapping_".
     1099                                $like_pattern = WC_WeArePlanet_Order_Status_Adapter::WEAREPLANET_CUSTOM_ORDER_STATUS_PREFIX . '%';
     1100                                // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
     1101                                $custom_order_status_name = $wpdb->get_var( $wpdb->prepare( "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE %s AND option_value = %s", $like_pattern, $sanitized_key ) );
     1102                                wp_cache_set( $option_name_cache_key, $custom_order_status_name, $cache_group, HOUR_IN_SECONDS );
     1103                        }
    10481104
    10491105                        // Remove from wp_options.
    10501106                        delete_option( $custom_order_status_name );
    10511107
     1108                        wp_cache_delete( $is_used_cache_key, $cache_group );
     1109                        wp_cache_delete( $option_name_cache_key, $cache_group );
     1110                        wp_cache_delete( 'weareplanet_custom_order_statuses', $cache_group );
     1111
    10521112                        // Return success response.
    1053                         wp_send_json_success( ['message' => __( 'Deleted successfully', 'woo-weareplanet' ), 'key' => ucfirst( $sanitized_key )] );
     1113                        wp_send_json_success(
     1114                                array(
     1115                                        'message' => __( 'Deleted successfully', 'woo-weareplanet' ),
     1116                                        'key' => ucfirst( $sanitized_key ),
     1117                                )
     1118                        );
    10541119                }
    10551120
    … …  
    10601125                 */
    10611126                public function set_device_id_cookie() {
    1062                         if(!headers_sent()) {
     1127                        if ( ! headers_sent() ) {
    10631128                                $value = WC_WeArePlanet_Unique_Id::get_uuid();
    10641129                                if ( isset( $_COOKIE['wc_weareplanet_device_id'] ) && ! empty( $_COOKIE['wc_weareplanet_device_id'] ) ) {
    … …  
    11221187                 * @return false|mixed
    11231188                 */
    1124                 public function order_editable_check( $allowed, WC_Order $order = null ) {
     1189                public function order_editable_check( $allowed, ?WC_Order $order = null ) {
    11251190                        if ( is_null( $order ) ) {
    11261191                                return $allowed;
    … …  
    11391204                 * @return mixed
    11401205                 */
    1141                 public function valid_order_status_for_completion( $statuses, WC_Order $order = null ) { //phpcs:ignore
     1206                public function valid_order_status_for_completion( $statuses, ?WC_Order $order = null ) { //phpcs:ignore
    11421207                        if ( WC_WeArePlanet_Helper::is_custom_status_mapping_enabled() ) {
    11431208                                $statuses[] = 'wearep-waiting';
    … …  
    11921257                                foreach ( $method_configurations as $configuration ) {
    11931258                                        $gateway = new WC_WeArePlanet_Gateway( $configuration );
    1194                                         $methods[] = apply_filters('wc_weareplanet_enhance_gateway', $gateway);
     1259                                        $methods[] = apply_filters( 'wc_weareplanet_enhance_gateway', $gateway );
    11951260                                }
    11961261                        } catch ( \WeArePlanet\Sdk\ApiException $e ) {
    … …  
    13521417                 */
    13531418                public function register_checkout_error_msg() {
    1354                         if ( ! isset( WC()->session ) ) return false;
     1419                        if ( ! isset( WC()->session ) ) {
     1420                                return false;
     1421                        }
    13551422                        $msg = WC()->session->get( 'weareplanet_failure_message', null );
    13561423                        if ( ! empty( $msg ) ) {
    … …  
    13801447                 */
    13811448                protected function define( $name, $value ) {
     1449                        // phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.VariableConstantNameFound -- $name is a local, not a global parameter
    13821450                        if ( ! defined( $name ) ) {
    13831451                                define( $name, $value );
    13841452                        }
     1453                        // phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.VariableConstantNameFound
    13851454                }
    13861455
    … …  
    15881657        }
    15891658
    1590         add_action( 'woocommerce_loaded', function () {
    1591                 WooCommerce_WeArePlanet::instance()->boot();
    1592                 add_action( 'woocommerce_blocks_loaded', 'WC_WeArePlanet_Blocks_Support' );
    1593         });
     1659        add_action(
     1660                'woocommerce_loaded',
     1661                function () {
     1662                        WooCommerce_WeArePlanet::instance()->boot();
     1663                        add_action( 'woocommerce_blocks_loaded', 'WC_WeArePlanet_Blocks_Support' );
     1664                }
     1665        );
    15941666
    15951667        function WC_WeArePlanet_Blocks_Support() { //phpcs:ignore
  • weareplanet/trunk/changelog.txt

    r3676036 r3740659  
    963963- [Tested Against] PHP SDK 4.8.0
    964964
    965 = 3.4.8 - July 22nd 2025 =
     965= 3.4.9 - July 22nd 2025 =
    966966- [Bugfix] Fix class loading order issues
    967967- [Bugfix] Fix problem with multisite not installing tables when plugin is network activated
    … …  
    979979- [Hotfix] Rollback to stable version
    980980
    981 = 3.4.8 - July 29nd 2025 =
     981= 3.4.9 - July 29nd 2025 =
    982982- [Bugfix] Fix class loading order issues
    983983- [Bugfix] Fix problem with multisite not installing tables when plugin is network activated
    … …  
    992992- [Tested Against] PHP SDK 4.8.0
    993993
    994 = 3.4.8 - July 30th 2025 =
     994= 3.4.9 - July 30th 2025 =
    995995- [Bugfix] Fix issue with calling a renamed function
    996996- [Tested Against] PHP 8.2
    … …  
    11151115- [Tested Against] PHP SDK 4.9.1
    11161116
     1117= 3.4.9 - October 7 2026 =
     1118- [Feature] Tested against Wordpress 7.1.2
     1119- [Bugfix] Fixed issue where translations for payment methods were incorrect
     1120- [Tested Against] PHP 8.4.20
     1121- [Tested Against] Wordpress 7.1.2
     1122- [Tested Against] Woocommerce 11.2.0
     1123- [Tested Against] PHP SDK 4.9.2
     1124
  • weareplanet/trunk/docs/en/documentation.html

    r3676036 r3740659  
    2424        </li>
    2525        <li>
    26                 <a href="https://github.com/weareplanet/woocommerce/releases/tag/3.4.8/">
     26                <a href="https://github.com/weareplanet/woocommerce/releases/tag/3.4.9/">
    2727                        Source
    2828                </a>
    … …  
    397397<td class="tableblock halign-left valign-top"><p class="tableblock">Device/session ID for fraud prevention during payment. Set/updated by the plugin on the WordPress init hook.</p></td>
    398398</tr>
    399 <tr>
    400 <td class="tableblock halign-left valign-top"><p class="tableblock"><code>weareplanetNewUi</code></p></td>
    401 <td class="tableblock halign-left valign-top"><p class="tableblock">Functional</p></td>
    402 <td class="tableblock halign-left valign-top"><p class="tableblock">Persistent (10 years)</p></td>
    403 <td class="tableblock halign-left valign-top"><p class="tableblock">WeArePlanet</p></td>
    404 <td class="tableblock halign-left valign-top"><p class="tableblock">UI-version toggle for the WeArePlanet merchant portal (old vs. new UI). Set automatically on every login based on the user&#8217;s stored preference, and can be toggled by the user. HttpOnly, Secure on HTTPS.</p></td>
    405 </tr>
    406399</tbody>
    407400</table>                                        </div>
  • weareplanet/trunk/includes/admin/class-wc-weareplanet-admin-refund.php

    r3433358 r3740659  
    146146         * Executes refund.
    147147         *
    148          * @param WC_Order $order wc_order.
     148         * @param WC_Order        $order wc_order.
    149149         * @param WC_Order_Refund $refund refund.
    150150         * @return void
    … …  
    279279         * Creates a new refund job for the given order and refund.
    280280         *
    281          * @param WC_Order $order wc_order.
    282          * @param WC_Order_Refund $refund refund.
     281         * @param WC_Order                                      $order wc_order.
     282         * @param WC_Order_Refund                               $refund refund.
    283283         * @param \WeArePlanet\Sdk\Model\RefundCreate $refund_create refund_create.
    284284         * @return WC_WeArePlanet_Entity_Refund_Job
  • weareplanet/trunk/includes/admin/class-wc-weareplanet-admin-settings-page.php

    r3676036 r3740659  
    109109         */
    110110        protected function get_settings_for_weareplanet_order_statuses_section() {
     111                // phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- $hide_save_button is a woocommerce core global used to control settings page ui, therefore we don't rename it
    111112                global $current_section, $hide_save_button;
    112113                $hide_save_button = true;
     114                // phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
    113115                return $this->get_order_statuses();
    114116        }
    … …  
    206208                        array(
    207209                                'links' => array(
    208                                         'https://plugin-documentation.weareplanet.com/weareplanet/woocommerce/3.4.8/docs/en/documentation.html' => esc_html__( 'Documentation', 'woo-weareplanet' ),
     210                                        'https://plugin-documentation.weareplanet.com/weareplanet/woocommerce/3.4.9/docs/en/documentation.html' => esc_html__( 'Documentation', 'woo-weareplanet' ),
    209211                                        'https://www.weareplanet.com/contact/sales' => esc_html__( 'Sign Up', 'woo-weareplanet' ),
    210212                                ),
    … …  
    268270                        ),
    269271
    270             array(
    271                 'title'  => esc_html__( 'Disable Pending Email', 'woo-weareplanet' ),
    272                 'desc'    => esc_html__( 'Enable this setting to prevent WooCommerce from sending "pending payment" emails for WeArePlanet payment methods.', 'woo-weareplanet' ),
    273                 'id'      => WooCommerce_WeArePlanet::WEAREPLANET_CK_DISABLE_PENDING_EMAIL,
    274                 'type'    => 'checkbox',
    275                 'default' => 'no',
    276                 'css'    => 'min-width:300px;',
    277             ),
     272                        array(
     273                                'title' => esc_html__( 'Disable Pending Email', 'woo-weareplanet' ),
     274                                'desc' => esc_html__( 'Enable this setting to prevent WooCommerce from sending "pending payment" emails for WeArePlanet payment methods.', 'woo-weareplanet' ),
     275                                'id'  => WooCommerce_WeArePlanet::WEAREPLANET_CK_DISABLE_PENDING_EMAIL,
     276                                'type' => 'checkbox',
     277                                'default' => 'no',
     278                                'css' => 'min-width:300px;',
     279                        ),
    278280
    279281                        array(
    … …  
    339341                                'desc_tip' => wp_kses_post(
    340342                                        __(
    341                                           'The Integration Options setting determines how the payment form is displayed during the WooCommerce checkout process.<br><br><strong>IFrame</strong>: Embeds the payment form directly within the WooCommerce checkout page for a seamless experience.<br><br><strong>Lightbox</strong>: Opens a secure popup window for customers to complete their payment without leaving the checkout page.<br><br><strong>Payment Page</strong>: Redirects customers to a dedicated payment page hosted by the payment provider.',
    342                                           'woo-weareplanet'
     343                                                'The Integration Options setting determines how the payment form is displayed during the WooCommerce checkout process.<br><br><strong>IFrame</strong>: Embeds the payment form directly within the WooCommerce checkout page for a seamless experience.<br><br><strong>Lightbox</strong>: Opens a secure popup window for customers to complete their payment without leaving the checkout page.<br><br><strong>Payment Page</strong>: Redirects customers to a dedicated payment page hosted by the payment provider.',
     344                                                'woo-weareplanet'
    343345                                        )
    344346                                ),
    … …  
    365367                        ),
    366368
    367                   array(
    368                         'title' => esc_html__( 'Enforce Consistency', 'woo-weareplanet' ),
    369                         'desc' => esc_html__( 'Enable this setting to require that the sum of all line items matches the order total value.', 'woo-weareplanet' ),
    370                         'desc_tip' => esc_html__(
    371                                 "WooCommerce calculates taxes at the line-item level, which may result in minor discrepancies (typically a few cents) between the order's total tax and the displayed price. This occurs due to rounding differences during individual line-item calculations.\n\nIf the \"Enforce consistency\" setting is enabled, the portal will automatically reject orders with such discrepancies. To avoid payment processing issues, we recommend disabling this setting unless strict tax total validation is required.",
    372                                 'woo-weareplanet'
    373                         ),
    374                         'id' => WooCommerce_WeArePlanet::WEAREPLANET_CK_ENFORCE_CONSISTENCY,
    375                         'type' => 'checkbox',
    376                         'default' => 'yes',
    377                         'css' => 'min-width:300px;',
    378                   ),
     369                        array(
     370                                'title' => esc_html__( 'Enforce Consistency', 'woo-weareplanet' ),
     371                                'desc' => esc_html__( 'Enable this setting to require that the sum of all line items matches the order total value.', 'woo-weareplanet' ),
     372                                'desc_tip' => esc_html__(
     373                                        "WooCommerce calculates taxes at the line-item level, which may result in minor discrepancies (typically a few cents) between the order's total tax and the displayed price. This occurs due to rounding differences during individual line-item calculations.\n\nIf the \"Enforce consistency\" setting is enabled, the portal will automatically reject orders with such discrepancies. To avoid payment processing issues, we recommend disabling this setting unless strict tax total validation is required.",
     374                                        'woo-weareplanet'
     375                                ),
     376                                'id' => WooCommerce_WeArePlanet::WEAREPLANET_CK_ENFORCE_CONSISTENCY,
     377                                'type' => 'checkbox',
     378                                'default' => 'yes',
     379                                'css' => 'min-width:300px;',
     380                        ),
    379381
    380382                        array(
    … …  
    392394                                'title' => esc_html__( 'Order Reference Type', 'woo-weareplanet' ),
    393395                                'desc_tip' => esc_html__(
    394                                   'Choose how orders are uniquely identified when sent to the portal. This reference ensures orders can be tracked and reconciled between systems. We recommend to use Order ID unless your workflow requires custom identifiers.',
    395                                   'woo-weareplanet'
     396                                        'Choose how orders are uniquely identified when sent to the portal. This reference ensures orders can be tracked and reconciled between systems. We recommend to use Order ID unless your workflow requires custom identifiers.',
     397                                        'woo-weareplanet'
    396398                                ),
    397399                                'id' => WooCommerce_WeArePlanet::WEAREPLANET_CK_ORDER_REFERENCE,
    … …  
    440442         */
    441443        public function get_order_status_settings() {
    442                 $settings = [];
     444                $settings = array();
    443445                $is_custom_status_mapping_enabled = WC_WeArePlanet_Helper::is_custom_status_mapping_enabled();
    444446
    … …  
    454456                        'desc' => esc_html__( 'If enabled, custom statuses (such as Manual Decision) will be used instead of the default WooCommerce statuses.', 'woo-weareplanet' ),
    455457                        'id' => WooCommerce_WeArePlanet::WEAREPLANET_CK_ENABLE_CUSTOM_STATUS_MAPPING,
    456                         'type'    => 'checkbox',
     458                        'type' => 'checkbox',
    457459                        'default' => 'no',
    458                         'css'     => 'min-width:300px;',
     460                        'css' => 'min-width:300px;',
    459461                );
    460462
    … …  
    475477                                                <span class="weareplanet-status-mapping-col-left">%s</span>
    476478                                                <span class="weareplanet-status-mapping-col-right">%s</span>
    477                                         </div>'
    478                                         ,
     479                                        </div>',
    479480                                        esc_html__( 'WeArePlanet payment status', 'woo-weareplanet' ),
    480481                                        esc_html__( 'WooCommerce Order Status', 'woo-weareplanet' )
    … …  
    519520                );
    520521
    521 
    522522                return apply_filters( 'weareplanet_custom_order_statuses_settings', $settings );
    523523        }
    … …  
    592592                                'underscore',
    593593                                'backbone',
    594                                 'wc-backbone-modal'
     594                                'wc-backbone-modal',
    595595                        ),
    596596                        $version,
  • weareplanet/trunk/includes/admin/class-wc-weareplanet-admin-transaction.php

    r3463230 r3740659  
    4545         * @see: https://woo.com/document/high-performance-order-storage/#section-8
    4646         * @see: https://developer.wordpress.org/reference/hooks/add_meta_boxes/
    47          * @param string $post_type The type of post where the meta box should be added.
     47         * @param string                $post_type The type of post where the meta box should be added.
    4848         * @param WP_Post|WC_Order|null $post_or_order_object The post or order object.
    4949         */
    50         public static function add_meta_box( $post_type = "", $post_or_order_object = null ) {
     50        public static function add_meta_box( $post_type = '', $post_or_order_object = null ) {
    5151                // WooCommerce is moving the Order information from Post to Order class. For now, we need to support both ways.
    52                 if ( empty( $post_or_order_object ) || ! ( $post_or_order_object instanceof \Automattic\WooCommerce\Admin\Overrides\Order) ) {
     52                if ( empty( $post_or_order_object ) || ! ( $post_or_order_object instanceof \Automattic\WooCommerce\Admin\Overrides\Order ) ) {
    5353                        if ( empty( $post_or_order_object ) || ! ( $post_or_order_object instanceof WP_Post ) || empty( $post_or_order_object->ID ) || 'shop_order' != $post_or_order_object->post_type ) {
    5454                                return;
  • weareplanet/trunk/includes/admin/class-wc-weareplanet-admin.php

    r3463230 r3740659  
    245245         * Remove unwanted order actions
    246246         *
    247          * @param array $actions actions.
     247         * @param array    $actions actions.
    248248         * @param WC_Order $order order.
    249249         * @return array
    … …  
    389389         */
    390390        public function display_attribute_options_edit() {
     391                // phpcs:disable WordPress.Security.NonceVerification.Recommended -- read only display function. $_GET['edit'] is a woocommerce admin url param. Nonce is verified in the save handler.
    391392                if ( ! isset( $_GET['edit'] ) ) {
    392393                        return;
    … …  
    394395                        $edit = absint( $_GET['edit'] );
    395396                }
     397                // phpcs:enable WordPress.Security.NonceVerification.Recommended
    396398                $checked = false;
    397399                $attribute_options = WC_WeArePlanet_Entity_Attribute_Options::load_by_attribute_id( $edit );
    … …  
    407409                        </th>
    408410                        <td>
    409                                 <?php wp_nonce_field('weareplanet_attribute_option_send', 'weareplanet_attribute_option_send_nonce' ); ?>
     411                                <?php wp_nonce_field( 'weareplanet_attribute_option_send', 'weareplanet_attribute_option_send_nonce' ); ?>
    410412                                <input
    411413                                        name="weareplanet_attribute_option_send"
    … …  
    429431                        <div class="form-field">
    430432                                <label for="weareplanet_attribute_option_send">
    431                                         <?php wp_nonce_field('weareplanet_attribute_option_send', 'weareplanet_attribute_option_send_nonce' ); ?>
     433                                        <?php wp_nonce_field( 'weareplanet_attribute_option_send', 'weareplanet_attribute_option_send_nonce' ); ?>
    432434                                        <input name="weareplanet_attribute_option_send" id="weareplanet_attribute_option_send" type="checkbox" value="1">
    433435                                        <?php esc_html_e( 'Send attribute to WeArePlanet', 'woo-weareplanet' ); ?>
  • weareplanet/trunk/includes/class-wc-weareplanet-blocks-support.php

    r3676036 r3740659  
    11<?php
    2 
    32/**
    43 * Plugin Name: WeArePlanet
    … …  
    5857        public function get_payment_method_script_handles() {
    5958                $dependencies = array();
    60                 $version = '3.4.8';
     59                $version = '3.4.9';
    6160
    6261                wp_register_script(
    … …  
    107106                        $update_transaction = isset( $_POST['updateTransaction'] ) ? (bool) sanitize_key( wp_unslash( $_POST['updateTransaction'] ) ) : false; // phpcs:ignore WordPress.Security.NonceVerification.Missing
    108107                        $enqueue_portal_scripts = isset( $_POST['enqueuePortalScripts'] ) ? (bool) sanitize_key( wp_unslash( $_POST['enqueuePortalScripts'] ) ) : false; // phpcs:ignore WordPress.Security.NonceVerification.Missing
    109                        
     108
    110109                        if ( true === $update_transaction ) {
    111110                                $transaction_service = WC_WeArePlanet_Service_Transaction::instance();
    … …  
    122121
    123122                        $payment_plugin = array_filter(
    124                           $payment_gateways,
    125                           fn( $key ) => str_contains( $key, 'weareplanet_' ),
    126                           ARRAY_FILTER_USE_KEY
     123                                $payment_gateways,
     124                                fn( $key ) => str_contains( $key, 'weareplanet_' ),
     125                                ARRAY_FILTER_USE_KEY
    127126                        );
    128127
    129128                        $payments_list =
    130                           array_map(
    131                                 function ( $payment_gateway ) use ( $available_payment_methods ) {
    132                                         $has_subscription = WC_WeArePlanet_Zero_Gateway::cart_has_subscription();
    133                                         $cartTotal = (WC()->cart && WC()->cart->total) ?? 0;
    134 
    135                                         $isPaymentMethodVisibleOnCheckout = $payment_gateway->get_payment_configuration_id() === WC_WeArePlanet_Zero_Gateway::ZERO_PAYMENT_CONF_ID && $cartTotal == 0;
    136                                         $integration_mode = $payment_gateway->get_payment_configuration_id() === WC_WeArePlanet_Zero_Gateway::ZERO_PAYMENT_CONF_ID
    137                                                 ? WC_WeArePlanet_Integration::WEAREPLANET_PAYMENTPAGE
    138                                                 : get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_INTEGRATION );
    139 
    140                                         if ( !$isPaymentMethodVisibleOnCheckout ) {
    141                                                 $isPaymentMethodVisibleOnCheckout = in_array( $payment_gateway->get_payment_configuration_id(), $available_payment_methods, true ) && ( $cartTotal > 0 || $has_subscription );
    142                                         }
    143 
    144                                         return array(
    145                                           'name' => $payment_gateway->id,
    146                                           'label' => $payment_gateway->get_title(),
    147                                           'ariaLabel' => $payment_gateway->get_title(),
    148                                           'description' => $payment_gateway->get_description(),
    149                                           'configuration_id' => $payment_gateway->get_payment_configuration_id(),
    150                                           'integration_mode' => $integration_mode,
    151                                           'supports' => $payment_gateway->supports,
    152                                           'icon' => $payment_gateway->get_icon(),
    153                                           'isActive' => $isPaymentMethodVisibleOnCheckout
    154                                         );
    155                                 },
    156                                 $payment_plugin
    157                           );
     129                                array_map(
     130                                        function ( $payment_gateway ) use ( $available_payment_methods ) {
     131                                                $has_subscription = WC_WeArePlanet_Zero_Gateway::cart_has_subscription();
     132                                                $cart_total = ( WC()->cart && WC()->cart->total ) ?? 0;
     133
     134                                                $is_payment_method_visible_on_checkout = $payment_gateway->get_payment_configuration_id() === WC_WeArePlanet_Zero_Gateway::ZERO_PAYMENT_CONF_ID && 0 === $cart_total;
     135                                                $integration_mode = $payment_gateway->get_payment_configuration_id() === WC_WeArePlanet_Zero_Gateway::ZERO_PAYMENT_CONF_ID
     136                                                        ? WC_WeArePlanet_Integration::WEAREPLANET_PAYMENTPAGE
     137                                                        : get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_INTEGRATION );
     138
     139                                                if ( ! $is_payment_method_visible_on_checkout ) {
     140                                                        $is_payment_method_visible_on_checkout = in_array( $payment_gateway->get_payment_configuration_id(), $available_payment_methods, true ) && ( $cart_total > 0 || $has_subscription );
     141                                                }
     142
     143                                                return array(
     144                                                        'name' => $payment_gateway->id,
     145                                                        'label' => $payment_gateway->get_title(),
     146                                                        'ariaLabel' => $payment_gateway->get_title(),
     147                                                        'description' => $payment_gateway->get_description(),
     148                                                        'configuration_id' => $payment_gateway->get_payment_configuration_id(),
     149                                                        'integration_mode' => $integration_mode,
     150                                                        'supports' => $payment_gateway->supports,
     151                                                        'icon' => $payment_gateway->get_icon(),
     152                                                        'isActive' => $is_payment_method_visible_on_checkout,
     153                                                );
     154                                        },
     155                                        $payment_plugin
     156                                );
    158157
    159158                        return array_values( $payments_list );
    160                 } catch (\Exception $e) {
    161                         return [];
     159                } catch ( \Exception $e ) {
     160                        return array();
    162161                }
    163162        }
    … …  
    213212         */
    214213        public static function enqueue_portal_scripts() {
    215                 if ( is_order_received_page() ) return;
     214                if ( is_order_received_page() ) {
     215                        return;
     216                }
    216217
    217218                try {
    … …  
    219220                        $transaction_service = WC_WeArePlanet_Service_Transaction::instance();
    220221                        $transaction = $transaction_service->get_transaction_from_session();
    221                         switch( get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_INTEGRATION ) ) {
     222                        switch ( get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_INTEGRATION ) ) {
    222223                                case WC_WeArePlanet_Integration::WEAREPLANET_IFRAME:
    223224                                        $js_url = $transaction_service->get_javascript_url_for_transaction( $transaction );
    … …  
    281282                [$gateway_result, $transaction] = $payment_method_object->process_payment_transaction( $context->order, $transaction_id, $space_id, true, $transaction_service );
    282283
    283 
    284284                $integration_mode = get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_INTEGRATION );
    285285                $redirect_url = $gateway_result['redirect'];
  • weareplanet/trunk/includes/class-wc-weareplanet-commands.php

    r3378673 r3740659  
    1919if ( class_exists( 'WP_CLI' ) && ! class_exists( 'WC_WeArePlanet_Commands' ) ) {
    2020
    21     /**
    22     * Class WC_WeArePlanet_Commands.
    23     * This class contains custom commands for WeArePlanet.
    24     *
    25     * @class WC_WeArePlanet_Commands
    26     */
    27     class WC_WeArePlanet_Commands {
     21        /**
     22        * Class WC_WeArePlanet_Commands.
     23        * This class contains custom commands for WeArePlanet.
     24        *
     25        * @class WC_WeArePlanet_Commands
     26        */
     27        class WC_WeArePlanet_Commands {
    2828
    29         /**
    30         * Register commands.
    31         */
    32         public static function init() {
    33             WP_CLI::add_command(
    34                 'weareplanet settings init',
    35                 array(
    36                     __CLASS__,
    37                     'settings_init'
    38                 )
    39             );
    40             WP_CLI::add_command(
    41                 'weareplanet webhooks install',
    42                 array(
    43                     __CLASS__,
    44                     'webhooks_install'
    45                 )
    46             );
    47             WP_CLI::add_command(
    48                 'weareplanet payment-methods sync',
    49                 array(
    50                     __CLASS__,
    51                     'payment_methods_sync'
    52                 )
    53             );
    54         }
     29                /**
     30                * Register commands.
     31                */
     32                public static function init() {
     33                        WP_CLI::add_command(
     34                                'weareplanet settings init',
     35                                array(
     36                                        __CLASS__,
     37                                        'settings_init',
     38                                )
     39                        );
     40                        WP_CLI::add_command(
     41                                'weareplanet webhooks install',
     42                                array(
     43                                        __CLASS__,
     44                                        'webhooks_install',
     45                                )
     46                        );
     47                        WP_CLI::add_command(
     48                                'weareplanet payment-methods sync',
     49                                array(
     50                                        __CLASS__,
     51                                        'payment_methods_sync',
     52                                )
     53                        );
     54                }
    5555
    56         /**
    57         * Initialize WeArePlanet settings.
    58         * It doesn't reset settings to default, it sets default settings if they haven't been initialized yet.
    59         *
    60         * ## EXAMPLE
    61         *
    62          *     $ wp weareplanet settings init
    63         *
    64         * @param array $args WP-CLI positional arguments.
    65         * @param array $assoc_args WP-CLI associative arguments.
    66         */
    67         public static function settings_init( $args, $assoc_args ) {
    68             try {
    69                 $default_settings = WC_WeArePlanet_Helper::instance()->get_default_settings();
    70                 foreach ( $default_settings as $setting => $value ) {
    71                     $current_setting = get_option( $setting, false );
    72                     if ( $current_setting === false ) {
    73                         update_option( $setting, $value );
    74                     }
    75                 }
    76                 WP_CLI::success( "Settings initialized." );
    77             } catch ( \Exception $e ) {
    78                 WooCommerce_WeArePlanet::instance()->log( $e->getMessage(), WC_Log_Levels::ERROR );
    79                 WP_CLI::error( "Failed to initialize settings: " . $e->getMessage() );
    80             }
    81         }
     56                /**
     57                * Initialize WeArePlanet settings.
     58                * It doesn't reset settings to default, it sets default settings if they haven't been initialized yet.
     59                *
     60                * ## EXAMPLE
     61                *
     62                 *   $ wp weareplanet settings init
     63                *
     64                * @param array $args WP-CLI positional arguments.
     65                * @param array $assoc_args WP-CLI associative arguments.
     66                */
     67                public static function settings_init( $args, $assoc_args ) {
     68                        try {
     69                                $default_settings = WC_WeArePlanet_Helper::instance()->get_default_settings();
     70                                foreach ( $default_settings as $setting => $value ) {
     71                                        $current_setting = get_option( $setting, false );
     72                                        if ( false === $current_setting ) {
     73                                                update_option( $setting, $value );
     74                                        }
     75                                }
     76                                WP_CLI::success( 'Settings initialized.' );
     77                        } catch ( \Exception $e ) {
     78                                WooCommerce_WeArePlanet::instance()->log( $e->getMessage(), WC_Log_Levels::ERROR );
     79                                WP_CLI::error( 'Failed to initialize settings: ' . $e->getMessage() );
     80                        }
     81                }
    8282
    83         /**
    84         * Create webhook URL and webhook listeners in the portal for WeArePlanet.
    85         *
    86         * ## EXAMPLE
    87         *
    88          *     $ wp weareplanet webhooks install
    89         *
    90         * @param array $args WP-CLI positional arguments.
    91         * @param array $assoc_args WP-CLI associative arguments.
    92         */
    93         public static function webhooks_install( $args, $assoc_args ) {
    94             try {
    95                 WC_WeArePlanet_Helper::instance()->reset_api_client();
    96                 WC_WeArePlanet_Service_Webhook::instance()->install();
    97                 WP_CLI::success( "Webhooks installed." );
    98             } catch ( \Exception $e ) {
    99                 WooCommerce_WeArePlanet::instance()->log( $e->getMessage(), WC_Log_Levels::ERROR );
    100                 WP_CLI::error( "Failed to install webhooks: " . $e->getMessage() );
    101             }
    102         }
     83                /**
     84                * Create webhook URL and webhook listeners in the portal for WeArePlanet.
     85                *
     86                * ## EXAMPLE
     87                *
     88                 *    $ wp weareplanet webhooks install
     89                *
     90                * @param array $args WP-CLI positional arguments.
     91                * @param array $assoc_args WP-CLI associative arguments.
     92                */
     93                public static function webhooks_install( $args, $assoc_args ) {
     94                        try {
     95                                WC_WeArePlanet_Helper::instance()->reset_api_client();
     96                                WC_WeArePlanet_Service_Webhook::instance()->install();
     97                                WP_CLI::success( 'Webhooks installed.' );
     98                        } catch ( \Exception $e ) {
     99                                WooCommerce_WeArePlanet::instance()->log( $e->getMessage(), WC_Log_Levels::ERROR );
     100                                WP_CLI::error( 'Failed to install webhooks: ' . $e->getMessage() );
     101                        }
     102                }
    103103
    104         /**
    105         * Synchronizes payment methods in the WeArePlanet from the portal.
    106         *
    107         * ## EXAMPLE
    108         *
    109          *     $ wp weareplanet payment-methods sync
    110         *
    111         * @param array $args WP-CLI positional arguments.
    112         * @param array $assoc_args WP-CLI associative arguments.
    113         */
    114         public static function payment_methods_sync( $args, $assoc_args ) {
    115             try {
    116                 WC_WeArePlanet_Helper::instance()->reset_api_client();
    117                 WC_WeArePlanet_Service_Method_Configuration::instance()->synchronize();
    118                 WC_WeArePlanet_Helper::instance()->delete_provider_transients();
    119                 WP_CLI::success( "Payment methods synchronized." );
    120             } catch ( \Exception $e ) {
    121                 WooCommerce_WeArePlanet::instance()->log( $e->getMessage(), WC_Log_Levels::ERROR );
    122                 WP_CLI::error( "Failed to synchronize payment methods: " . $e->getMessage() );
    123             }
    124         }
    125     }
     104                /**
     105                * Synchronizes payment methods in the WeArePlanet from the portal.
     106                *
     107                * ## EXAMPLE
     108                *
     109                 *    $ wp weareplanet payment-methods sync
     110                *
     111                * @param array $args WP-CLI positional arguments.
     112                * @param array $assoc_args WP-CLI associative arguments.
     113                */
     114                public static function payment_methods_sync( $args, $assoc_args ) {
     115                        try {
     116                                WC_WeArePlanet_Helper::instance()->reset_api_client();
     117                                WC_WeArePlanet_Service_Method_Configuration::instance()->synchronize();
     118                                WC_WeArePlanet_Helper::instance()->delete_provider_transients();
     119                                WP_CLI::success( 'Payment methods synchronized.' );
     120                        } catch ( \Exception $e ) {
     121                                WooCommerce_WeArePlanet::instance()->log( $e->getMessage(), WC_Log_Levels::ERROR );
     122                                WP_CLI::error( 'Failed to synchronize payment methods: ' . $e->getMessage() );
     123                        }
     124                }
     125        }
    126126}
    127127
  • weareplanet/trunk/includes/class-wc-weareplanet-customer-document.php

    r3288388 r3740659  
    109109                                                        array(
    110110                                                                'weareplanet_action' => 'download_packing',
    111                                                                 'post'                         => $order_id,
    112                                                                 'nonce'                        => wp_create_nonce( 'download_packing' ),
     111                                                                'post' => $order_id,
     112                                                                'nonce' => wp_create_nonce( 'download_packing' ),
    113113                                                        )
    114114                                                )
    … …  
    130130         */
    131131        private static function is_pdf_request() {
     132                // phpcs:disable WordPress.Security.NonceVerification.Recommended -- nonce is verified in download_document()
    132133                return ( isset( $_GET['post'] ) && isset( $_GET['weareplanet_action'] ) && isset( $_GET['nonce'] ) );
     134                // phpcs:enable WordPress.Security.NonceVerification.Recommended
    133135        }
    134136
  • weareplanet/trunk/includes/class-wc-weareplanet-email.php

    r3378673 r3740659  
    2828        /**
    2929         * Allow on hold emails being sent when germanized plugin is installed.
     30         *
     31         * @var bool
    3032         */
    3133        private static $allow_on_hold_emails = false;
    … …  
    3941                        array(
    4042                                __CLASS__,
    41                                 'send_on_hold_email_when_authorized'
     43                                'send_on_hold_email_when_authorized',
    4244                        ),
    4345                        10,
    … …  
    156158                add_filter( 'woocommerce_email_actions', array( __CLASS__, 'add_email_actions' ), 10, 1 );
    157159                add_filter( 'woocommerce_email_classes', array( __CLASS__, 'add_email_classes' ), 100, 1 );
    158         add_filter(
    159             'woocommerce_email_enabled_customer_on_hold_order',
    160             array( __CLASS__, 'disable_pending_payment_email' ),
    161             10,
    162             2
    163         );
    164         }
    165 
    166         /**
    167          * @param $order_id
     160                add_filter(
     161                        'woocommerce_email_enabled_customer_on_hold_order',
     162                        array( __CLASS__, 'disable_pending_payment_email' ),
     163                        10,
     164                        2
     165                );
     166        }
     167
     168        /**
     169         * Trigger the on-hold email when an order is authorized.
     170         *
     171         * @param int $order_id order id.
    168172         * @return void
    169173         */
    … …  
    336340        public static function add_email_actions( $actions ) {
    337341
    338         $to_add = array(
    339                 'woocommerce_order_status_wearep-redirected_to_processing',
    340                 'woocommerce_order_status_wearep-redirected_to_completed',
    341                 'woocommerce_order_status_wearep-redirected_to_on-hold',
    342                 'woocommerce_order_status_wearep-redirected_to_weareplanet-waiting',
    343                 'woocommerce_order_status_wearep-redirected_to_weareplanet-manual',
    344                 'woocommerce_order_status_wearep-manual_to_cancelled',
    345                 'woocommerce_order_status_wearep-waiting_to_cancelled',
    346                 'woocommerce_order_status_wearep-manual_to_processing',
    347                 'woocommerce_order_status_wearep-waiting_to_processing',
    348         );
    349 
    350         $authorized_status = self::get_transaction_mapped_status( 'authorized' );
    351         $fulfill_status = self::get_transaction_mapped_status( 'fulfill' );
    352 
    353         if ( $authorized_status && $fulfill_status ) {
    354                 self::add_unique_action( $to_add, 'woocommerce_order_status_' . $fulfill_status . '_to_' . $authorized_status );
    355                 self::add_unique_action( $to_add, 'woocommerce_order_status_' . $authorized_status . '_to_' . $fulfill_status );
    356         }
     342                $to_add = array(
     343                        'woocommerce_order_status_wearep-redirected_to_processing',
     344                        'woocommerce_order_status_wearep-redirected_to_completed',
     345                        'woocommerce_order_status_wearep-redirected_to_on-hold',
     346                        'woocommerce_order_status_wearep-redirected_to_weareplanet-waiting',
     347                        'woocommerce_order_status_wearep-redirected_to_weareplanet-manual',
     348                        'woocommerce_order_status_wearep-manual_to_cancelled',
     349                        'woocommerce_order_status_wearep-waiting_to_cancelled',
     350                        'woocommerce_order_status_wearep-manual_to_processing',
     351                        'woocommerce_order_status_wearep-waiting_to_processing',
     352                );
     353
     354                $authorized_status = self::get_transaction_mapped_status( 'authorized' );
     355                $fulfill_status = self::get_transaction_mapped_status( 'fulfill' );
     356
     357                if ( $authorized_status && $fulfill_status ) {
     358                        self::add_unique_action( $to_add, 'woocommerce_order_status_' . $fulfill_status . '_to_' . $authorized_status );
     359                        self::add_unique_action( $to_add, 'woocommerce_order_status_' . $authorized_status . '_to_' . $fulfill_status );
     360                }
    357361
    358362                if ( class_exists( 'woocommerce_wpml' ) ) {
    … …  
    537541                                        break;
    538542
    539                         case 'WC_Email_Customer_On_Hold_Order':
    540                                 add_action( 'woocommerce_order_status_wearep-redirected_to_on-hold_notification', array( $email_object, 'trigger' ), 10, 2 );
    541                                 if ( $authorized_status && $fulfill_status ) {
    542                                         add_action( 'woocommerce_order_status_' . $fulfill_status . '_to_' . $authorized_status . '_notification', array( __CLASS__, 'maybe_send_on_hold_email_for_manual_status' ), 10, 2 );
    543                                 }
    544                                 break;
    545 
    546                         case 'WC_Email_Customer_Processing_Order':
    547                                 add_action( 'woocommerce_order_status_wearep-redirected_to_processing_notification', array( $email_object, 'trigger' ), 10, 2 );
    548                                 add_action( 'woocommerce_order_status_wearep-manual_to_processing_notification', array( $email_object, 'trigger' ), 10, 2 );
    549                                 add_action( 'woocommerce_order_status_wearep-waiting_to_processing_notification', array( $email_object, 'trigger' ), 10, 2 );
    550                                 if ( $authorized_status && $fulfill_status ) {
    551                                         add_action( 'woocommerce_order_status_' . $authorized_status . '_to_' . $fulfill_status . '_notification', array( $email_object, 'trigger' ), 10, 2 );
    552                                 }
    553                                 break;
     543                                case 'WC_Email_Customer_On_Hold_Order':
     544                                        add_action( 'woocommerce_order_status_wearep-redirected_to_on-hold_notification', array( $email_object, 'trigger' ), 10, 2 );
     545                                        if ( $authorized_status && $fulfill_status ) {
     546                                                add_action( 'woocommerce_order_status_' . $fulfill_status . '_to_' . $authorized_status . '_notification', array( __CLASS__, 'maybe_send_on_hold_email_for_manual_status' ), 10, 2 );
     547                                        }
     548                                        break;
     549
     550                                case 'WC_Email_Customer_Processing_Order':
     551                                        add_action( 'woocommerce_order_status_wearep-redirected_to_processing_notification', array( $email_object, 'trigger' ), 10, 2 );
     552                                        add_action( 'woocommerce_order_status_wearep-manual_to_processing_notification', array( $email_object, 'trigger' ), 10, 2 );
     553                                        add_action( 'woocommerce_order_status_wearep-waiting_to_processing_notification', array( $email_object, 'trigger' ), 10, 2 );
     554                                        if ( $authorized_status && $fulfill_status ) {
     555                                                add_action( 'woocommerce_order_status_' . $authorized_status . '_to_' . $fulfill_status . '_notification', array( $email_object, 'trigger' ), 10, 2 );
     556                                        }
     557                                        break;
    554558
    555559                                case 'WC_Email_Customer_Completed_Order':
    … …  
    575579         * @return bool
    576580         */
    577         public static function gzd_block_send_instant_order_confirmation ( $email_sent, $order ) {
     581        public static function gzd_block_send_instant_order_confirmation( $email_sent, $order ) {
    578582                if ( ! ( $order instanceof WC_Order ) ) {
    579583                        return $email_sent;
    … …  
    623627
    624628        /**
    625          * @param WC_Order $order
     629         * Check if the order is an on-hold order and if it is authorized.
     630         *
     631         * @param WC_Order $order WooCommerce order object.
    626632         * @return bool
    627633         */
    … …  
    639645        }
    640646
    641     /**
    642     * This prevents WooCommerce from sending the "customer on hold" email
    643     * when the order was placed using any WeArePlanet payment method
    644     * and the merchant has disabled this behavior in the plugin settings.
    645     *
    646     * @param bool     $enabled Whether the email is enabled.
    647      * @param WC_Order $order  WooCommerce order object.
    648     *
    649     * @return bool
    650     */
    651     public static function disable_pending_payment_email( $enabled, $order ) {
    652         if ( ! $enabled || ! is_a( $order, 'WC_Order' ) ) {
    653             return $enabled;
    654         }
    655 
    656         $disable = get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_DISABLE_PENDING_EMAIL, 'no' );
    657         $gateway = wc_get_payment_gateway_by_order( $order );
    658 
    659         if ( $gateway instanceof WC_WeArePlanet_Gateway && $disable === 'yes' ) {
    660             return false;
    661         }
    662 
    663         return $enabled;
    664     }
     647        /**
     648        * This prevents WooCommerce from sending the "customer on hold" email
     649        * when the order was placed using any WeArePlanet payment method
     650        * and the merchant has disabled this behavior in the plugin settings.
     651        *
     652        * @param bool     $enabled Whether the email is enabled.
     653         * @param WC_Order $order WooCommerce order object.
     654        *
     655        * @return bool
     656        */
     657        public static function disable_pending_payment_email( $enabled, $order ) {
     658                if ( ! $enabled || ! is_a( $order, 'WC_Order' ) ) {
     659                        return $enabled;
     660                }
     661
     662                $disable = get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_DISABLE_PENDING_EMAIL, 'no' );
     663                $gateway = wc_get_payment_gateway_by_order( $order );
     664
     665                if ( $gateway instanceof WC_WeArePlanet_Gateway && 'yes' === $disable ) {
     666                        return false;
     667                }
     668
     669                return $enabled;
     670        }
    665671}
    666672
  • weareplanet/trunk/includes/class-wc-weareplanet-gateway.php

    r3550708 r3740659  
    278278                $field_key = $this->get_field_key( $key );
    279279                $defaults = array(
    280                         'title'                         => '',
    281                         'class'                         => '',
    282                         'css'                           => '',
    283                         'placeholder'           => '',
    284                         'desc_tip'                      => true,
    285                         'description'           => '',
     280                        'title'             => '',
     281                        'class'             => '',
     282                        'css'               => '',
     283                        'placeholder'       => '',
     284                        'desc_tip'          => true,
     285                        'description'       => '',
    286286                        'custom_attributes' => array(),
    287287                );
    … …  
    292292                        <th scope="row" class="titledesc">
    293293                                <label for="<?php echo esc_attr( $field_key ); ?>"><?php echo esc_html( $data['title'] ); ?></label>
    294                                 <?php echo $this->get_tooltip_html( $data ); ?>
     294                                <?php echo wp_kses_post( $this->get_tooltip_html( $data ) ); ?>
    295295                        </th>
    296296                        <td class="forminp">
    … …  
    303303                                                id="<?php echo esc_attr( $field_key ); ?>"
    304304                                                style="<?php echo esc_attr( $data['css'] ); ?>"
    305                                                 <?php echo $this->get_custom_attribute_html( $data ); ?>
     305                                                <?php echo wp_kses_post( $this->get_custom_attribute_html( $data ) ); ?>
    306306                                                >
    307307                                                <?php echo wp_kses_post( $data['value'] ); ?>
    … …  
    331331                static $checking = false;
    332332                if ( $checking ) {
    333                         return false; // prevent reentry/loop
     333                        return false; // prevent reentry/loop.
    334334                }
    335335                $checking = true;
    336336
    337337                try {
    338                         // Respect parent availability
     338                        // Respect parent availability.
    339339                        if ( ! parent::is_available() ) {
    340340                                return false;
    341341                        }
    342342
    343                         // Prevent conflict with tax rounding
     343                        // Prevent conflict with tax rounding.
    344344                        if ( wc_tax_enabled() && 'yes' === get_option( 'woocommerce_tax_round_at_subtotal' ) ) {
    345345                                if ( 'yes' === get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_ENFORCE_CONSISTENCY ) ) {
    … …  
    350350                        }
    351351
    352                         // Use session cache if available
     352                        // Use session cache if available.
    353353                        $gateway_available = WC()->session && $this->has_session()
    354354                                ? WC()->session->get( 'weareplanet_payment_gateways' )
    … …  
    359359                        }
    360360
    361                         // Allow admin and non-checkout pages to pass
     361                        // Allow admin and non-checkout pages to pass.
    362362                        if ( apply_filters(
    363363                                'weareplanet_is_method_available',
    … …  
    368368                        }
    369369
    370                         // Handle "order received" page logic
     370                        // Handle "order received" page logic.
    371371                        global $wp;
    372372                        if ( is_checkout() && isset( $wp->query_vars['order-received'] ) ) {
    … …  
    374374                        }
    375375
    376                         // Handle "order pay" endpoint
     376                        // Handle "order pay" endpoint.
    377377                        if ( apply_filters( 'wc_weareplanet_is_order_pay_endpoint', is_checkout_pay_page() ) ) {
    378378                                $order = WC_Order_Factory::get_order( $wp->query_vars['order-pay'] ?? 0 );
    … …  
    385385                        }
    386386
    387                         // Check if this gateway is among the possible ones
     387                        // Check if this gateway is among the possible ones.
    388388                        $possible = false;
    389389                        foreach ( $possible_methods as $method_id ) {
    … …  
    398398                        }
    399399
    400                         // Cache success in session
     400                        // Cache success in session.
    401401                        if ( WC()->session && $this->has_session() ) {
    402402                                $gateway_available[ $this->pln_payment_method_configuration_id ] = true;
    … …  
    538538        }
    539539
     540        /**
     541         * Enqueue checkout scripts.
     542         */
    540543        public function enqueue_checkout_scripts() {
    541544                if ( ! is_checkout() && ! is_checkout_pay_page() ) {
    … …  
    565568                        }
    566569
    567             if (get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_INTEGRATION ) == WC_WeArePlanet_Integration::WEAREPLANET_PAYMENTPAGE) {
    568                 return false;
     570                        if ( get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_INTEGRATION ) == WC_WeArePlanet_Integration::WEAREPLANET_PAYMENTPAGE ) {
     571                                return false;
    569572                        }
    570573
    571574                        wp_enqueue_script(
    572                           'weareplanet-remote-checkout-js',
    573                           $ajax_url,
    574                           array(
    575                                 'jquery',
    576                           ),
    577                           1,
    578                           true
     575                                'weareplanet-remote-checkout-js',
     576                                $ajax_url,
     577                                array(
     578                                        'jquery',
     579                                ),
     580                                1,
     581                                true
    579582                        );
    580583                        wp_enqueue_script(
    581                           'weareplanet-checkout-js',
    582                           WooCommerce_WeArePlanet::instance()->plugin_url() . '/assets/js/frontend/checkout.js',
    583                           array(
    584                                 'jquery',
    585                                 'jquery-blockui',
    586                                 'weareplanet-remote-checkout-js',
    587                           ),
    588                           1,
    589                           true
     584                                'weareplanet-checkout-js',
     585                                WooCommerce_WeArePlanet::instance()->plugin_url() . '/assets/js/frontend/checkout.js',
     586                                array(
     587                                        'jquery',
     588                                        'jquery-blockui',
     589                                        'weareplanet-remote-checkout-js',
     590                                ),
     591                                1,
     592                                true
    590593                        );
    591594                        global $wp_version;
    592595                        $localize = array(
    593                           'i18n_not_complete' => esc_html__( 'Please fill out all required fields.', 'woo-weareplanet' ),
    594                           'integration' => get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_INTEGRATION ),
    595                           'versions' => array(
    596                                 'wordpress' => $wp_version,
    597                                 'woocommerce' => $woocommerce_data['Version'],
    598                                 'weareplanet' => WC_WEAREPLANET_VERSION,
    599                           ),
     596                                'i18n_not_complete' => esc_html__( 'Please fill out all required fields.', 'woo-weareplanet' ),
     597                                'integration' => get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_INTEGRATION ),
     598                                'versions' => array(
     599                                        'wordpress' => $wp_version,
     600                                        'woocommerce' => $woocommerce_data['Version'],
     601                                        'weareplanet' => WC_WEAREPLANET_VERSION,
     602                                ),
    600603                        );
    601604                        wp_localize_script( 'weareplanet-checkout-js', 'weareplanet_js_params', $localize );
    … …  
    666669
    667670                        [ $result, $transaction ] = $this->process_payment_transaction( $order, $transaction_id, $space_id, $is_order_pay_endpoint, $transaction_service );
    668 
    669671
    670672                        $integration_mode = get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_INTEGRATION );
    … …  
    717719         * in the order. It also sets up the redirect URL upon successful payment and returns the result and transaction.
    718720         *
    719          * @param WC_Order                        $order The WooCommerce order object.
    720          * @param int                             $transaction_id The ID of the transaction.
    721          * @param int                             $space_id The space ID associated with the transaction.
    722          * @param bool                            $is_order_pay_endpoint Flag to determine if the order is being paid for at the order-pay endpoint.
     721         * @param WC_Order                                     $order The WooCommerce order object.
     722         * @param int                                          $transaction_id The ID of the transaction.
     723         * @param int                                          $space_id The space ID associated with the transaction.
     724         * @param bool                                         $is_order_pay_endpoint Flag to determine if the order is being paid for at the order-pay endpoint.
    723725         * @param WC_WeArePlanet_Service_Transaction $transaction_service The transaction service instance.
    724726         * @return array An array containing the result of the transaction and the transaction object.
  • weareplanet/trunk/includes/class-wc-weareplanet-helper.php

    r3676036 r3740659  
    7676         *
    7777         * @param string $status_slug Order status slug, with or without the `wc-` prefix.
    78          * @param bool   $prefixed    When true the returned status contains the `wc-` prefix.
     78         * @param bool   $prefixed When true the returned status contains the `wc-` prefix.
    7979         * @return string
    8080         */
    … …  
    121121
    122122        /**
     123         * Delete language transient.
     124         *
     125         * @return void
     126         */
     127        public function delete_language_transient() {
     128                delete_transient( 'wc_weareplanet_languages' );
     129        }
     130
     131        /**
    123132         * Get api client.
    124133         *
    … …  
    144153         * Add headers to api client.
    145154         *
     155         * @param \WeArePlanet\Sdk\ApiClient $api_client api client.
    146156         * @param array $additional_headers Additional headers.
    147157         * @return void
    148158         */
    149         public static function add_headers( &$api_client, array $additional_headers = [] ) {
     159        public static function add_headers( &$api_client, array $additional_headers = array() ) {
    150160                $default_header_data = self::get_default_header_data();
    151161                $default_header_data = array_merge( $default_header_data, $additional_headers );
    … …  
    269279                        $name = $line_item->getName();
    270280
    271                         // Handle coupons normally
     281                        // Handle coupons normally.
    272282                        if ( $exclude_discounts && \WeArePlanet\Sdk\Model\LineItemType::DISCOUNT === $type
    273283                                && strpos( $name, WC_WeArePlanet_Packages_Coupon_Discount::WEAREPLANET_COUPON ) !== false
    … …  
    275285                                // Convert negative values to positive in order to be able to subtract it.
    276286                                $sum -= abs( $line_item->getAmountIncludingTax() );
    277                         }
    278                         // Handle gift cards separately (already negative, do not abs())
    279                         elseif ( \WeArePlanet\Sdk\Model\LineItemType::DISCOUNT === $type
    280                                 && stripos( $name, WC_WeArePlanet_Packages_Gift_Card::WEAREPLANET_GIFT_CARD) !== false
     287                        } elseif ( \WeArePlanet\Sdk\Model\LineItemType::DISCOUNT === $type
     288                                && stripos( $name, WC_WeArePlanet_Packages_Gift_Card::WEAREPLANET_GIFT_CARD ) !== false
    281289                        ) {
     290                                // Handle gift cards separately (already negative, do not abs()).
    282291                                $sum += $line_item->getAmountIncludingTax();
    283                         }
    284                         else {
     292                        } else {
    285293                                $sum += $line_item->getAmountIncludingTax();
    286294                        }
    … …  
    295303         * @param mixed $expected_sum expected sum.
    296304         * @param mixed $currency currency.
     305         * @param bool  $is_recurrent is recurrent.
    297306         * @return \WeArePlanet\Sdk\Model\LineItemCreate[]
    298307         * @throws WC_WeArePlanet_Exception_Invalid_Transaction_Amount WC_WeArePlanet_Exception_Invalid_Transaction_Amount.
    … …  
    301310                // Check if coupon is applied to order. Session cart might be empty during webhook processing.
    302311                $has_coupons = apply_filters( 'wc_weareplanet_packages_coupon_line_items_have_coupon_discounts', $line_items, $currency );
    303                 // ensure that the effective sum coincides with the total discounted by the coupons.
     312                // ensure that the effective sum coincides with the total discounted by the coupons.
    304313                $effective_sum = $this->round_amount( $this->get_total_amount_including_tax( $line_items, $has_coupons ), $currency );
    305314                $rounded_expected_sum = $this->round_amount( $expected_sum, $currency );
    … …  
    441450                $locked_at = gmdate( 'Y-m-d H:i:s' );
    442451                $table_transaction_info = $wpdb->prefix . 'weareplanet_transaction_info';
    443                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     452                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    444453                $wpdb->query(
    445454                        $wpdb->prepare(
    … …  
    450459                );
    451460
    452                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
    453                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     461                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
     462                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    454463                $wpdb->query(
    455464                        $wpdb->prepare(
    … …  
    462471                        )
    463472                );
    464                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     473                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    465474        }
    466475
    … …  
    634643
    635644                $shop_version = str_replace( 'v', '', $version );
    636                 $plugin_version = '3.4.8';
     645                $plugin_version = '3.4.9';
    637646                list ($major_version, $minor_version) = explode( '.', $shop_version, 3 );
    638647                return array(
    … …  
    645654
    646655        /**
    647         * Get WooCommerce order statuses in JSON format.
    648         *
    649         * This method retrieves the WooCommerce order statuses, applies any filters,
    650         * and returns them as an array with structured data.
    651         *
    652         * @return array[] An array of WooCommerce order statuses, where each status is represented
    653         *                 as an associative array containing:
    654         *                 - 'key' (string)   : The order status key.
    655         *                 - 'label' (string) : The human-readable label for the status.
    656         *                 - 'type' (string)  : The type of status ('core' if it starts with 'wc-', otherwise 'custom').
    657         */
     656         * Get WooCommerce order statuses in JSON format.
     657         *
     658         * This method retrieves the WooCommerce order statuses, applies any filters,
     659         * and returns them as an array with structured data.
     660         *
     661         * @return array[] An array of WooCommerce order statuses, where each status is represented
     662         *                 as an associative array containing:
     663         *                 - 'key' (string)   : The order status key.
     664         *                 - 'label' (string) : The human-readable label for the status.
     665         *                 - 'type' (string)  : The type of status ('core' if it starts with 'wc-', otherwise 'custom').
     666         */
    658667        public function get_woocommerce_order_statuses_json() {
    659668                $woocommerce_statuses = apply_filters( 'weareplanet_woocommerce_statuses', array() );
    … …  
    667676                        'wc-failed',
    668677                        'wc-trash',
    669                         'wc-checkout-draft'
     678                        'wc-checkout-draft',
    670679                );
    671680                if ( self::is_custom_status_mapping_enabled() ) {
    … …  
    675684                                        'wc-wearep-manual',
    676685                                        'wc-wearep-redirected',
    677                                         'wc-wearep-waiting'
     686                                        'wc-wearep-waiting',
    678687                                )
    679688                        );
    680689                }
    681690
    682                 return array_map( function( $key, $value ) use ( $excluded_statuses ) {
     691                return array_map(
     692                        function ( $key, $value ) use ( $excluded_statuses ) {
    683693                                return array(
    684694                                        'key'  => $key,
    … …  
    693703
    694704        /**
    695          * @param $order
     705         * Set virtual zero total orders to complete.
     706         *
     707         * @param WC_Order $order WC_Order The WooCommerce order object.
    696708         * @return void
    697709         */
    … …  
    704716
    705717        /**
    706          * @param $order
     718         * Check if the order is virtual (contains only virtual products).
     719         *
     720         * @param WC_Order $order WC_Order The WooCommerce order object.
    707721         * @return bool
    708722         */
    … …  
    728742         * Update WooCommerce order status to "Pre-Order" if any product is out of stock or marked as pre-order.
    729743         *
    730          * @param WC_Order $order        WooCommerce order object.
     744         * @param WC_Order $order WooCommerce order object.
    731745         */
    732746        public static function update_order_status_for_preorder_if_needed( $order ) {
    … …  
    757771
    758772                        if ( $is_preorder_wc || $is_preorder_yith ) {
    759                                 // Check if order is marked as pre-ordered
     773                                // Check if order is marked as pre-ordered.
    760774                                if ( 'yes' !== $order->get_meta( '_order_has_preorder' ) ) {
    761775                                        return;
    762776                                }
    763777
    764                                 // Check if Yith Pre-Order plugin setting
     778                                // Check if Yith Pre-Order plugin setting.
    765779                                if ( 'default' === get_option( 'ywpo_order_status', 'default' ) ) {
    766780                                        return;
    … …  
    770784                        }
    771785
    772                         // Check if product is not out of stock. Edge case: sometimes get_stock_quantity is not set, but then items are available
     786                        // Check if product is not out of stock. Edge case: sometimes get_stock_quantity is not set, but then items are available.
    773787                        if ( ( $product->get_stock_quantity() ?? 1 ) < 1 ) {
    774788                                $is_out_of_stock = true;
    … …  
    777791                }
    778792
    779                 if ( !$is_preorder && !$is_out_of_stock ) {
     793                if ( ! $is_preorder && ! $is_out_of_stock ) {
    780794                        return;
    781795                }
    … …  
    796810
    797811                        $order->update_status(
    798                           $preorder_status_slug,
    799                           __( 'Product is on pre-order. Status set automatically.', 'woo-weareplanet' )
     812                                $preorder_status_slug,
     813                                __( 'Product is on pre-order. Status set automatically.', 'woo-weareplanet' )
    800814                        );
    801815
    802816                        $order->add_order_note(
    803                           __( 'Order status automatically set to pre-order.', 'woo-weareplanet' )
     817                                __( 'Order status automatically set to pre-order.', 'woo-weareplanet' )
    804818                        );
    805819                }
    … …  
    823837                return $settings;
    824838        }
    825 
    826839}
  • weareplanet/trunk/includes/class-wc-weareplanet-migration.php

    r3676036 r3740659  
    5656                '1.0.9' => 'update_1_0_9_restore_default_status_mappings',
    5757                '1.0.10' => 'update_1_0_10_remove_previous_min_version',
     58                '1.0.11' => 'update_1_0_11_enforce_signed_webhook_listeners',
     59                '1.0.12' => 'update_1_0_12_clear_language_cache',
    5860        );
    5961
    … …  
    7476                        array(
    7577                                __CLASS__,
    76                                 'wp_initialize_site'
     78                                'wp_initialize_site',
    7779                        ),
    7880                        10,
    … …  
    180182         * Create tables if new MU blog is created
    181183         *
    182          * wp_initialize_site hook introduced since 5.1.0
     184         * Function wp_initialize_site hook introduced since 5.1.0
     185         *
    183186         * @link https://developer.wordpress.org/reference/hooks/wp_initialize_site/
    184187         *
    185          * @param WP_Site $site
    186          * @param array $args
     188         * @param WP_Site $site site.
     189         * @param array   $args arguments.
    187190         * @return void
    188191         */
    … …  
    190193                if ( is_plugin_active_for_network( 'woo-weareplanet/weareplanet.php' ) ) {
    191194                        $blog_id = $site->blog_id;
    192                         // Defensive check: blog_id should always be set, otherwise will be shown as weareplanet error
     195                        // Defensive check: blog_id should always be set, otherwise will be shown as weareplanet error.
    193196                        if ( ! $blog_id ) {
    194197                                $logger = wc_get_logger();
    195                                 $logger->error( 'Could not detect blog_id during wp_initialize_site.', [ 'source' => 'weareplanet' ] );
     198                                $logger->error( 'Could not detect blog_id during wp_initialize_site.', array( 'source' => 'weareplanet' ) );
    196199                                return;
    197200                        }
    … …  
    252255                        $current_version = get_option( self::WEAREPLANET_CK_DB_VERSION, 0 );
    253256                        $version_keys = array_keys( self::$db_migrations );
    254                         if ( $current_version === 0 || version_compare( $current_version, '0', '>' ) && version_compare( $current_version, end( $version_keys ), '<' ) ) {
     257                        if ( version_compare( $current_version, end( $version_keys ), '<' )
     258                                && (
     259                                        0 === $current_version
     260                                        || version_compare( $current_version, '0', '>' )
     261                                )
     262                        ) {
    255263                                // We migrate the Db for all blogs.
    256264                                self::install_db( true );
    … …  
    279287                if ( WC_WEAREPLANET_PLUGIN_BASENAME === $file ) {
    280288                        $row_meta = array(
    281                                 'docs' => '<a href="https://plugin-documentation.weareplanet.com/weareplanet/woocommerce/3.4.8/docs/en/documentation.html" aria-label="' . esc_html__( 'View Documentation', 'woo-weareplanet' ) . '">' . esc_html__( 'Documentation', 'woo-weareplanet' ) . '</a>',
     289                                'docs' => '<a href="https://plugin-documentation.weareplanet.com/weareplanet/woocommerce/3.4.9/docs/en/documentation.html" aria-label="' . esc_html__( 'View Documentation', 'woo-weareplanet' ) . '">' . esc_html__( 'Documentation', 'woo-weareplanet' ) . '</a>',
    282290                        );
    283291
    … …  
    297305
    298306                $table_method_config = $wpdb->prefix . 'weareplanet_method_config';
    299                 // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     307                // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    300308                $sql = "CREATE TABLE IF NOT EXISTS $table_method_config(
    301309                                `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
    … …  
    315323                        ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
    316324                // phpcs:enable
    317                 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching,WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery -- $sql is prepared.
     325                // phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching,WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery,PluginCheck.Security.DirectDB.UnescapedDBParameter -- $sql is prepared.
    318326                $result = $wpdb->query( $sql );
    319                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.NoCachin,WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery
     327                // phpcs:enable WordPress.DB.DirectDatabaseQuery.NoCachin,WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery,PluginCheck.Security.DirectDB.UnescapedDBParameter
    320328
    321329                if ( false === $result ) {
    … …  
    325333                $table_transaction_info = $wpdb->prefix . 'weareplanet_transaction_info';
    326334
    327                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     335                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    328336                $result = $wpdb->query(
    329337                        "CREATE TABLE IF NOT EXISTS $table_transaction_info(
    … …  
    350358                        ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"
    351359                );
    352                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     360                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter
    353361
    354362                if ( false === $result ) {
    … …  
    358366                $table_token_info = $wpdb->prefix . 'weareplanet_token_info';
    359367
    360                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     368                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    361369                $result = $wpdb->query(
    362370                        "CREATE TABLE IF NOT EXISTS $table_token_info(
    … …  
    378386                        ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"
    379387                );
    380                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     388                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    381389
    382390                if ( false === $result ) {
    … …  
    386394                $table_completion_job = $wpdb->prefix . 'weareplanet_completion_job';
    387395
    388                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     396                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    389397                $result = $wpdb->query(
    390398                        "CREATE TABLE IF NOT EXISTS $table_completion_job(
    … …  
    406414                        ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"
    407415                );
    408                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     416                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    409417
    410418                if ( false === $result ) {
    … …  
    414422                $table_void_job = $wpdb->prefix . 'weareplanet_void_job';
    415423
    416                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     424                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    417425                $result = $wpdb->query(
    418426                        "CREATE TABLE IF NOT EXISTS $table_void_job(
    … …  
    432440                        ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"
    433441                );
    434                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     442                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    435443
    436444                if ( false === $result ) {
    … …  
    440448                $table_refund_job = $wpdb->prefix . 'weareplanet_refund_job';
    441449
    442                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     450                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    443451                $result = $wpdb->query(
    444452                        "CREATE TABLE IF NOT EXISTS $table_refund_job(
    … …  
    459467                        ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"
    460468                );
    461                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     469                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    462470
    463471                if ( false === $result ) {
    … …  
    477485                $table_method_config = $wpdb->prefix . 'weareplanet_method_config';
    478486
    479                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     487                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    480488                $result = $wpdb->query( "ALTER TABLE $table_method_config CHANGE `image` `image` VARCHAR(2047) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL" );
    481                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
    482 
    483                 if ( false === $result ) {
    484                         throw new Exception( esc_html( $wpdb->last_error ) );
    485                 }
    486 
    487                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     489                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
     490
     491                if ( false === $result ) {
     492                        throw new Exception( esc_html( $wpdb->last_error ) );
     493                }
     494
     495                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    488496                $result = $wpdb->query( "ALTER TABLE $table_transaction_info CHANGE `image` `image` VARCHAR(2047) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL" );
    489                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     497                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    490498
    491499                if ( false === $result ) {
    … …  
    505513                $table_token_info = $wpdb->prefix . 'weareplanet_token_info';
    506514
    507                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     515                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    508516                $result = $wpdb->query( "ALTER TABLE $table_transaction_info CHANGE `order_id` `order_id` int(10) unsigned NULL DEFAULT NULL" );
    509                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
    510 
    511                 if ( false === $result ) {
    512                         throw new Exception( esc_html( $wpdb->last_error ) );
    513                 }
    514 
    515                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     517                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
     518
     519                if ( false === $result ) {
     520                        throw new Exception( esc_html( $wpdb->last_error ) );
     521                }
     522
     523                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    516524                $result = $wpdb->query(
    517525                        $wpdb->prepare( "SHOW COLUMNS FROM $table_transaction_info LIKE %s", 'order_mapping_id' )
    518526                );
    519                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     527                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    520528
    521529                if ( 0 === $result ) {
    522                         // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     530                        // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    523531                        $result = $wpdb->query( "ALTER TABLE $table_transaction_info ADD `order_mapping_id` int(10) unsigned NULL AFTER order_id" );
    524532                        // phpcs:enable WordPress.DB.DirectDatabaseQuery.NoCachin,WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery
    … …  
    529537                }
    530538
    531                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     539                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    532540                $result = $wpdb->query( "ALTER TABLE $table_token_info CHANGE `customer_id` `customer_id` int(10) unsigned NULL DEFAULT NULL" );
    533541                // phpcs:enable WordPress.DB.DirectDatabaseQuery.NoCachin,WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery
    … …  
    552560
    553561                if ( 0 === $result ) {
    554                         // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     562                        // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    555563                        $result = $wpdb->query( "ALTER TABLE $table_method_config ADD COLUMN `image_base` VARCHAR(2047) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL AFTER image" );
    556                         // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     564                        // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    557565
    558566                        if ( false === $result ) {
    … …  
    561569                }
    562570
    563                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     571                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    564572                $result = $wpdb->query( $wpdb->prepare( "SHOW COLUMNS FROM $table_transaction_info LIKE %s", 'image_base' ) );
    565                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     573                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    566574
    567575                if ( 0 === $result ) {
    568                         // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     576                        // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    569577                        $result = $wpdb->query( "ALTER TABLE $table_transaction_info ADD COLUMN `image_base` VARCHAR(2047) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL AFTER image" );
    570                         // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     578                        // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    571579
    572580                        if ( false === $result ) {
    … …  
    587595                $table_attribute_options = $wpdb->prefix . 'weareplanet_attribute_options'; //phpcs:ignore
    588596
    589                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     597                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    590598                $result = $wpdb->query( $wpdb->prepare( "SHOW COLUMNS FROM $table_transaction_info LIKE %s", 'user_failure_message' ) );
    591                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     599                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    592600
    593601                if ( 0 === $result ) {
    594                         // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     602                        // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    595603                        $result = $wpdb->query( "ALTER TABLE $table_transaction_info ADD COLUMN `user_failure_message` VARCHAR(2047) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL AFTER failure_reason" );
    596                         // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     604                        // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    597605
    598606                        if ( false === $result ) {
    … …  
    601609                }
    602610                // Do not use foreign keys to reference attribute to cascade deletion, as some shop still run with MyISAM enginge as default.
    603                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     611                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    604612                $result = $wpdb->query(
    605613                        "CREATE TABLE IF NOT EXISTS $table_attribute_options(
    … …  
    611619                        ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"
    612620                );
    613                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     621                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    614622
    615623                if ( false == $result ) {
    … …  
    703711                global $wpdb;
    704712                // rollback table rename if there are issues.
    705                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     713                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    706714                $wpdb->query( 'START TRANSACTION' ); //phpcs:ignore
    707                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     715                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    708716                $table_stament = 'Tables_in_' . $wpdb->dbname;
    709717
    710718                foreach ( $table_rename_map as $old_table_name => $new_table_name ) {
    711719                        // check old table exists.
    712                         // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     720                        // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    713721                        $old_table_result = $wpdb->get_row(
    714722                                $wpdb->prepare( "SHOW TABLES WHERE $table_stament = %s", $old_table_name )
    715723                        );
    716                         // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     724                        // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    717725
    718726                        if ( $old_table_result ) {
    719727                                // check new table doesn't exist, if it does there's a problem!.
    720                                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     728                                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    721729                                $new_table_result = $wpdb->get_row(
    722730                                        $wpdb->prepare( "SHOW TABLES WHERE $table_stament = %s", $new_table_name )
    723731                                );
    724                                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     732                                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    725733
    726734                                if ( ! $new_table_result ) {
    727                                         // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     735                                        // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    728736                                        $result = $wpdb->query( "RENAME TABLE $old_table_name TO $new_table_name" );
    729                                         // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     737                                        // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    730738                                        if ( false === $result ) {
    731739                                                throw new Exception( esc_html( $wpdb->last_error ) );
    … …  
    762770         */
    763771        public static function update_1_0_10_remove_previous_min_version() {
    764                 delete_metadata( 'user', 0, "weareplanet-previous-wc-min-version", '', true );
     772                delete_metadata( 'user', 0, 'weareplanet-previous-wc-min-version', '', true );
     773        }
     774
     775        /**
     776         * Enforces payload signatures on webhook listeners.
     777         */
     778        public static function update_1_0_11_enforce_signed_webhook_listeners() {
     779                WC_WeArePlanet_Service_Webhook::instance()->enforce_signed_listeners();
     780        }
     781
     782        /**
     783         * Clear the language cache, which earlier versions filled with languages without IETF codes.
     784         * Only the cache is removed, it is rebuilt on the next access.
     785         */
     786        public static function update_1_0_12_clear_language_cache() {
     787                WC_WeArePlanet_Helper::instance()->delete_language_transient();
    765788        }
    766789}
  • weareplanet/trunk/includes/class-wc-weareplanet-order-reference.php

    r3288388 r3740659  
    11<?php
    2 
    32/**
    43 * Plugin Name: WeArePlanet
  • weareplanet/trunk/includes/class-wc-weareplanet-order-status-adapter.php

    r3463230 r3740659  
    2323 * based on the transaction statuses in WeArePlanet.
    2424 */
    25 class WC_WeArePlanet_Order_Status_Adapter
    26 {
     25class WC_WeArePlanet_Order_Status_Adapter {
    2726        /**
    2827         * Constants for WeArePlanet transaction statuses.
    2928         */
    30         const WEAREPLANET_STATUS_PENDING = 'pending';
    31         const WEAREPLANET_STATUS_CONFIRMED = 'confirmed';
     29        const WEAREPLANET_STATUS_PENDING    = 'pending';
     30        const WEAREPLANET_STATUS_CONFIRMED  = 'confirmed';
    3231        const WEAREPLANET_STATUS_PROCESSING = 'processing';
    3332        const WEAREPLANET_STATUS_AUTHORIZED = 'authorized';
    34         const WEAREPLANET_STATUS_COMPLETED = 'completed';
    35         const WEAREPLANET_STATUS_FAILED = 'failed';
    36         const WEAREPLANET_STATUS_VOIDED = 'voided';
    37         const WEAREPLANET_STATUS_FULFILL = 'fulfill';
    38         const WEAREPLANET_STATUS_DECLINE = 'decline';
     33        const WEAREPLANET_STATUS_COMPLETED  = 'completed';
     34        const WEAREPLANET_STATUS_FAILED     = 'failed';
     35        const WEAREPLANET_STATUS_VOIDED     = 'voided';
     36        const WEAREPLANET_STATUS_FULFILL    = 'fulfill';
     37        const WEAREPLANET_STATUS_DECLINE    = 'decline';
    3938
    4039        const WEAREPLANET_ORDER_STATUS_MAPPING_PREFIX = 'weareplanet_order_status_mapping_';
    41         const WEAREPLANET_CUSTOM_ORDER_STATUS_PREFIX = 'weareplanet_custom_order_status_';
     40        const WEAREPLANET_CUSTOM_ORDER_STATUS_PREFIX  = 'weareplanet_custom_order_status_';
    4241        /**
    4342         * Stores the status mappings loaded from the database.
    … …  
    5251         * Initializes the settings and adds the filter for updating order status.
    5352         */
    54         public function __construct()
    55         {
     53        public function __construct() {
    5654                $this->initialize_filters();
    5755                $this->initialize_status_mappings();
    … …  
    6159         * Initialise filters and actions.
    6260         */
    63         public static function init(): void
    64         {
     61        public static function init(): void {
    6562                add_action( 'plugins_loaded', array( __CLASS__, 'register_weareplanet_service_status_adapter' ) );
    6663        }
    … …  
    7471         * @return void
    7572         */
    76         public static function register_weareplanet_service_status_adapter(): void
    77         {
     73        public static function register_weareplanet_service_status_adapter(): void {
    7874                new WC_WeArePlanet_Order_Status_Adapter();
    7975        }
    … …  
    8278         * Initialize filters.
    8379         */
    84         private function initialize_filters(): void
    85         {
     80        private function initialize_filters(): void {
    8681                add_filter( 'weareplanet_default_order_status_mappings', array( $this, 'get_default_status_mappings' ) );
    8782                add_filter( 'weareplanet_woocommerce_statuses', array( $this, 'get_all_woocommerce_statuses' ) );
    … …  
    9388                add_filter( 'woocommerce_payment_complete_order_status', array( $this, 'get_order_status_on_payment_complete' ), 10, 3 );
    9489
    95                 //tests.
     90                // tests.
    9691                // CPT-based orders.
    97                 add_filter( 'bulk_actions-edit-shop_order', array($this, 'bulk_actions_shop_order'), 20, 1 );
    98                 add_action( 'handle_bulk_actions-edit-shop_order', array($this, 'bulk_process_custom_status'), 20, 3 );
     92                add_filter( 'bulk_actions-edit-shop_order', array( $this, 'bulk_actions_shop_order' ), 20, 1 );
     93                add_action( 'handle_bulk_actions-edit-shop_order', array( $this, 'bulk_process_custom_status' ), 20, 3 );
    9994                // HPOS orders.
    100                 add_filter( 'bulk_actions-woocommerce_page_wc-orders', array($this, 'bulk_actions_shop_order'), 20, 1 );
    101                 add_filter( 'handle_bulk_actions-woocommerce_page_wc-orders', array($this, 'bulk_process_custom_status'), 20, 3 );
     95                add_filter( 'bulk_actions-woocommerce_page_wc-orders', array( $this, 'bulk_actions_shop_order' ), 20, 1 );
     96                add_filter( 'handle_bulk_actions-woocommerce_page_wc-orders', array( $this, 'bulk_process_custom_status' ), 20, 3 );
    10297        }
    10398
    … …  
    133128                global $wpdb;
    134129
    135                 $prefix = self::WEAREPLANET_CUSTOM_ORDER_STATUS_PREFIX . '%'; //We use % as wildcard for LIKE.
    136                 $results = $wpdb->get_results( $wpdb->prepare( "SELECT option_name, option_value FROM {$wpdb->options} WHERE option_name LIKE %s", $prefix ), ARRAY_A );
    137 
    138                 //Build the array with the desired structure.
     130                $cache_key = 'weareplanet_custom_order_statuses';
     131                $cache_group = 'weareplanet';
     132
     133                $results = wp_cache_get( $cache_key, $cache_group );
     134
     135                if ( $results === false ) {
     136                        $prefix = self::WEAREPLANET_CUSTOM_ORDER_STATUS_PREFIX . '%'; //We use % as wildcard for LIKE.
     137                        // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
     138                        $results = $wpdb->get_results( $wpdb->prepare( "SELECT option_name, option_value FROM {$wpdb->options} WHERE option_name LIKE %s", $prefix ), ARRAY_A );
     139
     140                        wp_cache_set( $cache_key, $results, $cache_group, HOUR_IN_SECONDS );
     141                }
     142
     143                // Build the array with the desired structure.
    139144                foreach ( $results as $row ) {
    140145                        $status_label = ucfirst( str_replace( array( 'wc-', '_' ), array( '', ' ' ), $row['option_value'] ) );
     146
    141147                        $order_statuses[ $row['option_value'] ] = $status_label;
    142148                }
    … …  
    161167                );
    162168
    163                 $order_statuses_without_prefix = array_map( function( $status ) {
    164                         return str_replace( 'wc-', '', $status );
    165                 }, array_values( $default_mappings ) );
    166 
    167                 return array_merge($order_statuses, $order_statuses_without_prefix);
     169                $order_statuses_without_prefix = array_map(
     170                        function ( $status ) {
     171                                return str_replace( 'wc-', '', $status );
     172                        },
     173                        array_values( $default_mappings )
     174                );
     175
     176                return array_merge( $order_statuses, $order_statuses_without_prefix );
    168177        }
    169178
    … …  
    171180         * Loads the status mappings from the database or initializes them if not present.
    172181         */
    173         private function initialize_status_mappings(): void
    174         {
     182        private function initialize_status_mappings(): void {
    175183                $is_custom_mapping_enabled = WC_WeArePlanet_Helper::is_custom_status_mapping_enabled();
    176184                $default_mappings = apply_filters( 'weareplanet_default_order_status_mappings', array() );
    … …  
    203211         * @return bool
    204212         */
    205         private function is_custom_order_status( string $order_status ): bool
    206         {
     213        private function is_custom_order_status( string $order_status ): bool {
    207214                return strpos( $order_status, 'wc-wearep-' ) === 0 || strpos( $order_status, 'wearep-' ) === 0;
    208215        }
    … …  
    214221         * @return string
    215222         */
    216         private function ensure_status_has_prefix( string $status ): string
    217         {
     223        private function ensure_status_has_prefix( string $status ): string {
    218224                if ( '' === $status ) {
    219225                        return $status;
    … …  
    236242         * @return void
    237243         */
    238         public function store_default_status_mappings_on_database(): void
    239         {
     244        public function store_default_status_mappings_on_database(): void {
    240245                $default_mappings = $this->get_default_status_mappings();
    241246
    … …  
    255260         *
    256261         * WooCommerce introduced the `OrderInternalStatus` constants in version 9.6.0.
    257          * To maintain compatibility with earlier versions, string values are used as a fallback.
     262         * To maintain compatibility with earlier versions, string values are used as a fallback.
    258263         * This is the interface to use in next versions Automattic\WooCommerce\Enums\OrderInternalStatus
    259264         *
    … …  
    276281         * @return array
    277282         */
    278         public function get_default_status_mappings() : array
    279         {
     283        public function get_default_status_mappings(): array {
    280284                $default_mappings = array(
    281285                        self::WEAREPLANET_STATUS_PENDING => 'wc-pending',
    … …  
    309313         * @return array
    310314         */
    311         public function get_legacy_default_status_mappings() : array
    312         {
     315        public function get_legacy_default_status_mappings(): array {
    313316                return array(
    314317                        self::WEAREPLANET_STATUS_CONFIRMED => 'wearep-redirected',
    … …  
    323326         * @return array
    324327         */
    325         public function get_all_woocommerce_statuses(): array
    326         {
     328        public function get_all_woocommerce_statuses(): array {
    327329                return wc_get_order_statuses();
    328330        }
    … …  
    333335         * @return array
    334336         */
    335         public function get_weareplanet_statuses(): array
    336         {
     337        public function get_weareplanet_statuses(): array {
    337338                return array(
    338339                        self::WEAREPLANET_STATUS_PENDING => ucwords( self::WEAREPLANET_STATUS_PENDING ),
    … …  
    354355         * @return string|null The corresponding WooCommerce order status or null if not found.
    355356         */
    356         private function map_weareplanet_status_to_woocommerce( ?string $status ): ?string
    357         {
     357        private function map_weareplanet_status_to_woocommerce( ?string $status ): ?string {
    358358                if ( null === $status || '' === $status ) {
    359359                        return $status;
    … …  
    361361
    362362                if ( empty( $this->settings ) ) {
    363                         return $status; //Return the current status if there are no mappings available.
    364                 }
    365 
    366                 //Search in 'transaction_status' first.
     363                        return $status; // Return the current status if there are no mappings available.
     364                }
     365
     366                // Search in 'transaction_status' first.
    367367                foreach ( $this->settings as $setting ) {
    368                         if ( $setting['transaction_status'] === strtolower( $status ) ) {
    369                                 return str_replace( 'wc-', '', $setting['order_status'] ); //Return the mapped WooCommerce order status.
     368                        if ( strtolower( $status ) === $setting['transaction_status'] ) {
     369                                return str_replace( 'wc-', '', $setting['order_status'] ); // Return the mapped WooCommerce order status.
    370370                        }
    371371                }
    372372
    373                 //Fallback to legacy mappings if no match was found.
     373                // Fallback to legacy mappings if no match was found.
    374374                $legacy_mappings = $this->get_legacy_default_status_mappings();
    375375                $transaction_status_key = array_search( $status, $legacy_mappings, true );
    376376
    377                 if ( !empty( $transaction_status_key ) ) {
     377                if ( ! empty( $transaction_status_key ) ) {
    378378                        foreach ( $this->settings as $setting ) {
    379379                                if ( $setting['transaction_status'] === $transaction_status_key ) {
    380                                         return str_replace( 'wc-', '', $setting['order_status'] ); //Return the mapped WooCommerce order status.
     380                                        return str_replace( 'wc-', '', $setting['order_status'] ); // Return the mapped WooCommerce order status.
    381381                                }
    382382                        }
    383383                }
    384384
    385                 return str_replace( 'wc-', '', $status ); //Return legacy status or original (ensuring WC prefix is stripped).
     385                return str_replace( 'wc-', '', $status ); // Return legacy status or original (ensuring WC prefix is stripped).
    386386        }
    387387
    … …  
    389389         * Updates the status of a WooCommerce order based on the WeArePlanet status.
    390390         *
    391          * @param WC_Order $order $order The WooCommerce order.
     391         * @param WC_Order    $order $order The WooCommerce order.
    392392         * @param string|null $status The WeArePlanet transaction status.
    393          * @param string|null $default status The WeArePlanet transaction status by default.
    394          * @param string $note Optional note to add when updating the status.
     393         * @param string|null $default_status The WeArePlanet transaction status by default.
     394         * @param string      $note Optional note to add when updating the status.
    395395         * @param @param bool $manual Whether this is a manual order status change.
    396396         */
    397         public function update_order_status( WC_Order $order, ?string $status, ?string $default_status, string $note = '', bool $manual = false ): void
    398         {
     397        public function update_order_status(
     398                WC_Order $order,
     399                ?string $status,
     400                ?string $default_status,
     401                string $note = '',
     402                bool $manual = false
     403        ): void {
    399404                // If status is empty.
    400                 if ( $status === null && $order !== null ) {
     405                if ( null === $status && null !== $order ) {
    401406                        $transaction_info = WC_WeArePlanet_Entity_Transaction_Info::load_by_order_id( $order->get_id() );
    402407                        if ( $transaction_info ) {
    … …  
    419424                $new_status = $should_force_completed ? 'completed' : $this->map_weareplanet_status_to_woocommerce( $status );
    420425
    421                 if ( !empty( $new_status ) && !empty( $order ) ) {
     426                if ( ! empty( $new_status ) && ! empty( $order ) ) {
    422427                        $order->update_status( $new_status, $note, $manual );
    423428                        // Apply a post-update filter to allow modifications after updating the status.
    … …  
    430435         * and return the order status accordingly when the order is fulfill.
    431436         *
    432          * @param string $status The default order status (processing or completed).
    433          * @param int $order_id The WooCommerce order ID.
     437         * @param string   $status The default order status (processing or completed).
     438         * @param int      $order_id The WooCommerce order ID.
    434439         * @param WC_Order $order The WooCommerce order object.
    435440         * @return string The updated order status.
    436441         */
    437         public function get_order_status_on_payment_complete( string $status, int $order_id, WC_Order $order ): string
    438         {
     442        public function get_order_status_on_payment_complete( string $status, int $order_id, WC_Order $order ): string {
    439443                $change_setting_enabled = 'yes' === get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_CHANGE_ORDER_STATUS );
    440444                $is_virtual_order = WC_WeArePlanet_Helper::is_order_virtual( $order );
    … …  
    448452                }
    449453
    450                 // Check if the transaction status is mapped in WooCommerce
     454                // Check if the transaction status is mapped in WooCommerce.
    451455                $mapped_status = $this->map_weareplanet_status_to_woocommerce( \WeArePlanet\Sdk\Model\TransactionState::FULFILL );
    452456
    453457                if ( ! empty( $mapped_status ) ) {
    454                         return $mapped_status; // Return the mapped WooCommerce status
     458                        return $mapped_status; // Return the mapped WooCommerce status.
    455459                }
    456460
    … …  
    472476         * @return string|null The mapped WooCommerce order status, or null if no mapping is found.
    473477         */
    474         public function get_wc_status_for_transaction( ?string $weareplanet_status ): ?string
    475         {
     478        public function get_wc_status_for_transaction( ?string $weareplanet_status ): ?string {
    476479                if ( null === $weareplanet_status || '' === $weareplanet_status ) {
    477480                        return null;
  • weareplanet/trunk/includes/class-wc-weareplanet-return-handler.php

    r3288388 r3740659  
    4646                        $order_id = absint( wp_unslash( $_GET['order_id'] ) ); //phpcs:ignore
    4747                        $order = WC_Order_Factory::get_order( $order_id );
    48                         $action = sanitize_text_field( wp_unslash( $_GET['action'] ) );
     48                        $action = sanitize_text_field( wp_unslash( $_GET['action'] ) ); // phpcs:ignore
    4949                        if ( $order->get_id() === $order_id && $order->get_order_key() === $order_key ) {
    5050                                switch ( $action ) {
  • weareplanet/trunk/includes/class-wc-weareplanet-subscription-gateway.php

    r3463230 r3740659  
    9797        public function process_scheduled_subscription_payment( $amount_to_charge, WC_Order $order ) {
    9898                try {
    99                         $token_data = $this->get_token_data_from_order($order);
     99                        $token_data = $this->get_token_data_from_order( $order );
    100100
    101101                        $token_space_id = $token_data['_weareplanet_subscription_space_id'];
    102                         $token_id = $token_data['_weareplanet_subscription_token_id'];
     102                        $token_id       = $token_data['_weareplanet_subscription_token_id'];
    103103
    104104                        $transaction_service = WC_WeArePlanet_Service_Transaction::instance();
    … …  
    107107                        if ( $transaction_info->get_id() > 0 ) {
    108108                                $existing_transaction = $transaction_service->get_transaction( $transaction_info->get_space_id(), $transaction_info->get_id() );
    109                                 if ( $existing_transaction->getState() != \WeArePlanet\Sdk\Model\TransactionState::PENDING ) {
     109                                if ( $existing_transaction->getState() !== \WeArePlanet\Sdk\Model\TransactionState::PENDING ) {
    110110                                        return;
    111111                                }
    … …  
    162162                        if ( ! isset( $payment_meta['post_meta']['_weareplanet_subscription_space_id']['value'] ) || empty( $payment_meta['post_meta']['_weareplanet_subscription_space_id']['value'] ) ) {
    163163                                throw new Exception( esc_html__( 'The WeArePlanet Space Id value is required.', 'woo-weareplanet' ) );
    164                         } elseif ( get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_SPACE_ID ) != $payment_meta['post_meta']['_weareplanet_subscription_space_id']['value'] ) {
     164                        } elseif ( get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_SPACE_ID ) !== $payment_meta['post_meta']['_weareplanet_subscription_space_id']['value'] ) {
    165165                                throw new Exception( esc_html__( 'The WeArePlanet Space Id needs to be in the same space as configured in the main configuration.', 'woo-weareplanet' ) );
    166166                        }
    … …  
    180180         */
    181181        public function update_payment_method( $update, $new_payment_method, $subscription ) {
    182                 if ( $this->gateway->id == $new_payment_method ) {
     182                if ( $this->gateway->id === $new_payment_method ) {
    183183                        $update = false;
    184184                        add_filter(
    … …  
    212212         * @param WC_Order $order Order.
    213213         * @return array
    214          */
    215         private function get_token_data_from_order($order)
    216         {
    217                 $order_id = $order->get_id();
    218                 $token_data = [];
     214         * @throws Exception Exception.
     215         */
     216        private function get_token_data_from_order( $order ) {
     217                $order_id   = $order->get_id();
     218                $token_data = array();
    219219                $token_data['_weareplanet_subscription_space_id'] = get_post_meta( $order_id, '_weareplanet_subscription_space_id', true );
    220220                $token_data['_weareplanet_subscription_token_id'] = get_post_meta( $order_id, '_weareplanet_subscription_token_id', true );
    221221
    222                 if( ! isset($token_data['_weareplanet_subscription_space_id']) || isset($token_data['_weareplanet_subscription_token_id']) ) {
     222                if ( ! isset( $token_data['_weareplanet_subscription_space_id'] ) || isset( $token_data['_weareplanet_subscription_token_id'] ) ) {
    223223
    224224                        $subscriptions = wcs_get_subscriptions_for_renewal_order( $order_id );
    225                         // In theory, each of the array elements should contain the same token and space data
    226                         $subscription_object = array_pop($subscriptions);
    227                         $subscription_meta = $subscription_object->get_meta_data();
    228                         $token_data = [];
    229                         $subscription_keys = [
     225                        // In theory, each of the array elements should contain the same token and space data.
     226                        $subscription_object = array_pop( $subscriptions );
     227                        $subscription_meta   = $subscription_object->get_meta_data();
     228                        $token_data          = array();
     229                        $subscription_keys   = array(
    230230                                '_weareplanet_subscription_space_id',
    231                                 '_weareplanet_subscription_token_id'
    232                         ];
    233 
    234                         foreach( $subscription_meta as $meta_data ) {
     231                                '_weareplanet_subscription_token_id',
     232                        );
     233
     234                        foreach ( $subscription_meta as $meta_data ) {
    235235                                $contained_data = $meta_data->get_data();
    236                                 if ( in_array($contained_data['key'], $subscription_keys ) ) {
    237                                         $token_data[$contained_data['key']] = $contained_data['value'];
     236                                if ( in_array( $contained_data['key'], $subscription_keys ) ) {
     237                                        $token_data[ $contained_data['key'] ] = $contained_data['value'];
    238238                                }
    239239                        }
    240240                }
    241241
    242                 if( ! isset($token_data['_weareplanet_subscription_space_id']) ) {
     242                if ( ! isset( $token_data['_weareplanet_subscription_space_id'] ) ) {
    243243                        $order->update_status( 'failed', esc_html__( 'No Space Id is found.', 'woo-weareplanet' ) );
    244                         throw new Exception('Missing space id details');
    245                 }
    246 
    247                 if( ! isset($token_data['_weareplanet_subscription_token_id']) ) {
     244                        throw new Exception( 'Missing space id details' );
     245                }
     246
     247                if ( ! isset( $token_data['_weareplanet_subscription_token_id'] ) ) {
    248248                        $order->update_status( 'failed', esc_html__( 'No Token Id is found.', 'woo-weareplanet' ) );
    249                         throw new Exception('Missing token id');
    250                 }
    251 
    252                 if ( get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_SPACE_ID ) != $token_data['_weareplanet_subscription_space_id'] ) {
     249                        throw new Exception( 'Missing token id' );
     250                }
     251
     252                if ( get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_SPACE_ID ) !== $token_data['_weareplanet_subscription_space_id'] ) {
    253253                        $order->update_status( 'failed', esc_html__( 'The token space and the configured space are not equal.', 'woo-weareplanet' ) );
    254                         throw new Exception('Token space does not match configured space');
     254                        throw new Exception( 'Token space does not match configured space' );
    255255                }
    256256
    … …  
    297297        public function store_gateway_result_in_globals( $result, $subscription ) {
    298298                if ( isset( $result['weareplanet'] ) ) {
    299                         $GLOBALS['_wc_weareplanet_subscription_gateway_result'] = $result;
     299                        $GLOBALS['wc_weareplanet_subscription_gateway_result'] = $result;
    300300                        return array(
    301                                 'result' => $result['result'],
     301                                'result'   => $result['result'],
    302302                                'redirect' => 'wc_weareplanet_subscription_redirect',
    303303                        );
    … …  
    314314         */
    315315        public function create_json_response( $location, $status ) {
    316                 $location = basename($location);
    317                 if ( 'wc_weareplanet_subscription_redirect' == $location && isset( $GLOBALS['_wc_weareplanet_subscription_gateway_result'] ) ) {
     316                $location = basename( $location );
     317                if ( 'wc_weareplanet_subscription_redirect' === $location && isset( $GLOBALS['_wc_weareplanet_subscription_gateway_result'] ) ) {
    318318                        wp_send_json( $GLOBALS['_wc_weareplanet_subscription_gateway_result'] );
    319319                        exit;
  • weareplanet/trunk/includes/class-wc-weareplanet-subscription.php

    r3433358 r3740659  
    5454        }
    5555
     56        /**
     57         * Boot the subscription integration.
     58         *
     59         * @return void
     60         */
    5661        public function boot() {
    5762                add_filter(
    … …  
    466471        public function fulfill_in_progress( \WeArePlanet\Sdk\Model\Transaction $transaction, $order ) {
    467472                if ( wcs_order_contains_subscription( $order, array( 'parent', 'resubscribe', 'switch', 'renewal' ) ) ) {
    468                         $GLOBALS['_wc_weareplanet_subscription_fulfill'] = true;
     473                        $GLOBALS['wc_weareplanet_subscription_fulfill'] = true;
    469474                }
    470475        }
    … …  
    478483         */
    479484        public function add_valid_order_statuses_for_subscription_completion( $statuses, $order = null ) {
    480                 if ( isset( $GLOBALS['_wc_weareplanet_subscription_fulfill'] ) ) {
     485                if ( isset( $GLOBALS['wc_weareplanet_subscription_fulfill'] ) ) {
    481486                        $statuses[] = 'wearep-waiting';
    482487                        $statuses[] = 'wearep-manual';
    … …  
    490495         * @param WC_WeArePlanet_Entity_Transaction_Info $info Info.
    491496         * @param \WeArePlanet\Sdk\Model\Transaction     $transaction Transaction.
    492          * @param WC_Order                                         $order Oder.
     497         * @param WC_Order                                         $order Order.
    493498         * @return WC_WeArePlanet_Entity_Transaction_Info
    494499         */
    … …  
    565570         */
    566571        public function before_renewal_setup_cart( $subscriptions, $order ) {
    567                 $GLOBALS['_wc_weareplanet_renewal_cart_setup'] = true;
     572                $GLOBALS['wc_weareplanet_renewal_cart_setup'] = true;
    568573        }
    569574
    … …  
    576581         */
    577582        public function after_renewal_setup_cart( $subscriptions, $order ) {
    578                 $GLOBALS['_wc_weareplanet_renewal_cart_setup'] = false;
     583                $GLOBALS['wc_weareplanet_renewal_cart_setup'] = false;
    579584        }
    580585
    … …  
    586591         */
    587592        public function method_available_for_cart_renewal( $available ) {
    588                 if ( isset( $GLOBALS['_wc_weareplanet_renewal_cart_setup'] ) && $GLOBALS['_wc_weareplanet_renewal_cart_setup'] ) {
     593                if ( isset( $GLOBALS['wc_weareplanet_renewal_cart_setup'] ) && $GLOBALS['wc_weareplanet_renewal_cart_setup'] ) {
    589594                        return true;
    590595                }
    … …  
    626631        }
    627632}
    628 
    629 
  • weareplanet/trunk/includes/class-wc-weareplanet-unique-id.php

    r3673687 r3740659  
    3333                        array(
    3434                                __CLASS__,
    35                                 'copy_unqiue_id_to_order_item',
     35                                'copy_unique_id_to_order_item',
    3636                        ),
    3737                        10,
    … …  
    4242                        array(
    4343                                __CLASS__,
    44                                 'copy_unqiue_id_to_order_fee',
     44                                'copy_unique_id_to_order_fee',
    4545                        ),
    4646                        10,
    … …  
    5151                        array(
    5252                                __CLASS__,
    53                                 'copy_unqiue_id_to_order_shipping',
     53                                'copy_unique_id_to_order_shipping',
    5454                        ),
    5555                        10,
    … …  
    8181         * @return WC_Order_Item_Product $item item
    8282         */
    83         public static function copy_unqiue_id_to_order_item( WC_Order_Item_Product $item, $cart_item_key, $values, ?WC_Order $order = null ) { //phpcs:ignore
     83        public static function copy_unique_id_to_order_item( WC_Order_Item_Product $item, $cart_item_key, $values, WC_Order $order = null ) { //phpcs:ignore
    8484                // We do not use the cart_item_key as it is deprecated.
    8585                $item->add_meta_data( '_weareplanet_unique_line_item_id', self::get_uuid(), true );
    … …  
    9797         * @return WC_Order_Item_Shipping $item item
    9898         */
    99         public static function copy_unqiue_id_to_order_shipping( WC_Order_Item_Shipping $item, $package_key, $package, ?WC_Order $order = null ) { //phpcs:ignore
     99        public static function copy_unique_id_to_order_shipping( WC_Order_Item_Shipping $item, $package_key, $package, WC_Order $order = null ) { //phpcs:ignore
    100100                $item->add_meta_data( '_weareplanet_unique_line_item_id', self::get_uuid(), true );
    101101                return $item;
    … …  
    112112         * @return WC_Order_Item_Shipping $item item
    113113         */
    114         public static function copy_unqiue_id_to_order_fee( WC_Order_Item_Fee $item, $fee_key, $fee, ?WC_Order $order = null ) { //phpcs:ignore
     114        public static function copy_unique_id_to_order_fee( WC_Order_Item_Fee $item, $fee_key, $fee, ?WC_Order $order = null ) { //phpcs:ignore
    115115                $unique_id = null;
    116116                if ( $fee->amount < 0 ) {
  • weareplanet/trunk/includes/class-wc-weareplanet-webhook-handler.php

    r3288388 r3740659  
    7272                $raw_post_data = $wp_filesystem->get_contents( 'php://input' );
    7373                $signature = isset( $_SERVER['HTTP_X_SIGNATURE'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_SIGNATURE'] ) ) : '';
     74                // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_set_error_handler
    7475                set_error_handler( array( __CLASS__, 'handle_webhook_errors' ) );
    7576                try {
    … …  
    7980                        $webhook_service = WC_WeArePlanet_Service_Webhook::instance();
    8081
    81                         // Handling of payloads without a signature (legacy method).
    82                         // TODO add config to disable strategy/use default webhooks
    83                         // Deprecated since 3.0.12.
     82                        // Handling of payloads without a signature removed since 3.4.9.
     83                        // Log received unsigned webhook payloads and request that webhook signature to be enabled.
    8484                        if ( empty( $signature ) ) {
    85                                 $webhook_model = $webhook_service->get_webhook_entity_for_id( $request->get_listener_entity_id() );
    86                                 $webhook_handler_class_name = $webhook_model->get_handler_class_name();
    87                                 $webhook_handler = $webhook_handler_class_name::instance();
    88                                 $webhook_handler->process( $request );
     85                                $signature_missing_message = 'Webhook ' . $request->get_listener_entity_technical_name()
     86                                . ' lacked a signature. Enable payload signature and state for '
     87                                . $request->get_listener_entity_technical_name() . ' webhook listener.';
     88                                WooCommerce_WeArePlanet::instance()->log( $signature_missing_message, WC_Log_Levels::ERROR );
     89                                echo esc_textarea( $signature_missing_message );
    8990                        }
    9091
  • weareplanet/trunk/includes/class-wc-weareplanet-zero-gateway.php

    r3321215 r3740659  
    11<?php
     2/**
     3 * Plugin Name: WeArePlanet
     4 * Author: Planet Merchant Services Ltd
     5 * Text Domain: weareplanet
     6 * Domain Path: /languages/
     7 *
     8 * WeArePlanet
     9 * This plugin will add support for all WeArePlanet payments methods and connect the WeArePlanet servers to your WooCommerce webshop (https://www.weareplanet.com/).
     10 *
     11 * @category Class
     12 * @package  WeArePlanet
     13 * @author   Planet Merchant Services Ltd (https://www.weareplanet.com)
     14 * @license  http://www.apache.org/licenses/LICENSE-2.0 Apache Software License (ASL 2.0)
     15 */
    216
    317if ( ! defined( 'ABSPATH' ) ) {
    … …  
    519}
    620
     21/**
     22 * Class WC_WeArePlanet_Zero_Gateway.
     23 * This class handles the zero payment gateway of WeArePlanet
     24 *
     25 * @class WC_WeArePlanet_Zero_Gateway
     26 */
    727class WC_WeArePlanet_Zero_Gateway extends WC_Payment_Gateway {
    828
    929        public const ZERO_PAYMENT_CONF_ID = 999999;
    1030
     31        /**
     32         * Constructor for the gateway.
     33         */
    1134        public function __construct() {
    1235                $this->id = 'weareplanet_zero';
    … …  
    2447
    2548                add_action(
    26                   'woocommerce_update_options_payment_gateways_' . $this->id,
    27                   array( $this, 'process_admin_options' )
     49                        'woocommerce_update_options_payment_gateways_' . $this->id,
     50                        array( $this, 'process_admin_options' )
    2851                );
    2952
    3053                add_filter(
    31                   'woocommerce_available_payment_gateways',
    32                   array( $this, 'hide_gateways_for_zero_order_total' )
     54                        'woocommerce_available_payment_gateways',
     55                        array( $this, 'hide_gateways_for_zero_order_total' )
    3356                );
    3457        }
    3558
     59        /**
     60         * Initialize form fields for the gateway settings.
     61         */
    3662        public function init_form_fields() {
    3763                $this->form_fields = array(
    38                   'enabled' => array(
    39                         'title'   => __( 'Enable/Disable', 'woo-weareplanet' ),
    40                         'type'    => 'checkbox',
    41                         'label'   => __( 'Enable No Payment Required Gateway', 'woo-weareplanet' ),
    42                         'default' => 'yes',
    43                   ),
    44                   'title' => array(
    45                         'title'       => __( 'Title', 'woo-weareplanet' ),
    46                         'type'        => 'text',
    47                         'description' => __( 'This controls the title seen by the customer during checkout.', 'woo-weareplanet' ),
    48                         'default'     => __( 'No Payment Required', 'woo-weareplanet' ),
    49                         'desc_tip'    => true,
    50                   ),
     64                        'enabled' => array(
     65                                'title'   => __( 'Enable/Disable', 'woo-weareplanet' ),
     66                                'type'    => 'checkbox',
     67                                'label'   => __( 'Enable No Payment Required Gateway', 'woo-weareplanet' ),
     68                                'default' => 'yes',
     69                        ),
     70                        'title' => array(
     71                                'title'       => __( 'Title', 'woo-weareplanet' ),
     72                                'type'        => 'text',
     73                                'description' => __( 'This controls the title seen by the customer during checkout.', 'woo-weareplanet' ),
     74                                'default'     => __( 'No Payment Required', 'woo-weareplanet' ),
     75                                'desc_tip'    => true,
     76                        ),
    5177                );
    5278        }
    5379
     80        /**
     81         * Check if the gateway is available for the current order.
     82         *
     83         * @return bool True if available, false otherwise.
     84         */
    5485        public function is_available() {
    55                 if (isset($_GET['pay_for_order']) && boolval($_GET['pay_for_order']) === true) {
     86                if ( isset( $_GET['pay_for_order'] ) && boolval( $_GET['pay_for_order'] ) === true ) {// phpcs:disable WordPress.Security.NonceVerification.Recommended -- $pay_for_order is a woocommerce read-only URL param. Value is only used as a bool flag.
    5687                        $order_id = get_query_var( 'order-pay' );
    5788                        $order = wc_get_order( $order_id );
    … …  
    6394                        return false;
    6495                }
    65                 return ( WC()->cart && WC()->cart->total == 0 ) && $this->enabled === 'yes';
     96                return ( WC()->cart && WC()->cart->total == 0 ) && 'yes' === $this->enabled;
    6697        }
    6798
     99        /**
     100         * Get the payment configuration ID for the zero payment gateway.
     101         *
     102         * @return int The payment configuration ID.
     103         */
    68104        public function get_payment_configuration_id() {
    69105                // This can be a fake or static ID just to satisfy the interface.
    … …  
    71107        }
    72108
     109        /**
     110         * Process the payment for the order.
     111         *
     112         * @param int $order_id The ID of the order being processed.
     113         * @return array An array containing the result and redirect URL.
     114         */
    73115        public function process_payment( $order_id ) {
    74116                $order = wc_get_order( $order_id );
    … …  
    77119
    78120                return array(
    79                   'result'   => 'success',
    80                   'redirect' => $this->get_return_url( $order ),
     121                        'result'   => 'success',
     122                        'redirect' => $this->get_return_url( $order ),
    81123                );
    82124        }
    83125
     126        /**
     127         * Hide other payment gateways when the order total is zero.
     128         *
     129         * @param array $available_gateways The available payment gateways.
     130         * @return array The modified list of available payment gateways.
     131         */
    84132        public function hide_gateways_for_zero_order_total( $available_gateways ) {
    85133                if ( is_admin() ) {
    … …  
    87135                }
    88136
    89                 if (isset($_GET['pay_for_order']) && boolval($_GET['pay_for_order']) === true) {
     137                if ( isset( $_GET['pay_for_order'] ) && boolval( $_GET['pay_for_order'] ) === true ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- $pay_for_order is a woocommerce read-only URL param. Value is only used as a bool flag.
    90138                        $order_id = get_query_var( 'order-pay' );
    91139                        $order = wc_get_order( $order_id );
    … …  
    97145
    98146                $has_subscription = self::cart_has_subscription();
    99                 if ( WC()->cart && WC()->cart->total == 0 && !$has_subscription ) {
     147                if ( WC()->cart && WC()->cart->total == 0 && ! $has_subscription ) {
    100148                        foreach ( $available_gateways as $gateway_id => $gateway ) {
    101                                 if ( $gateway_id !== 'weareplanet_zero' ) {
     149                                if ( 'weareplanet_zero' !== $gateway_id ) {
    102150                                        unset( $available_gateways[ $gateway_id ] );
    103151                                }
    … …  
    108156        }
    109157
     158        /**
     159         * Check if the cart contains any subscription products.
     160         *
     161         * @return bool True if the cart has a subscription, false otherwise.
     162         */
    110163        public static function cart_has_subscription() {
    111164                if ( ! function_exists( 'WC' ) || ! WC()->cart ) {
    … …  
    113166                }
    114167
    115                 $subscription_classes = [
    116                   'WC_Subscription_Product',
    117                   'WC_Product_Subscription',
    118                   'WC_Product_Subscription_Variation',
    119                 ];
     168                $subscription_classes = array(
     169                        'WC_Subscription_Product',
     170                        'WC_Product_Subscription',
     171                        'WC_Product_Subscription_Variation',
     172                );
    120173
    121174                foreach ( WC()->cart->get_cart() as $cart_item ) {
  • weareplanet/trunk/includes/entity/class-wc-weareplanet-entity-attribute-options.php

    r3288388 r3740659  
    7171                global $wpdb;
    7272                $table = $wpdb->prefix . self::get_table_name();
    73                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     73                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    7474                $result = $wpdb->get_row(
    7575                        $wpdb->prepare(
    … …  
    7979                        ARRAY_A
    8080                );
    81                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     81                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    8282                if ( null !== $result ) {
    8383                        return new self( $result );
  • weareplanet/trunk/includes/entity/class-wc-weareplanet-entity-method-configuration.php

    r3288388 r3740659  
    8282
    8383                $table = $wpdb->prefix . self::get_table_name();
    84                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     84                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    8585                $result = $wpdb->get_row(
    8686                        $wpdb->prepare(
    … …  
    9191                        ARRAY_A
    9292                );
    93                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     93                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    9494
    9595                if ( null !== $result ) {
  • weareplanet/trunk/includes/entity/class-wc-weareplanet-entity-refund-job.php

    r3288388 r3740659  
    9898
    9999                $table = $wpdb->prefix . self::get_table_name();
    100                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     100                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    101101                $result = $wpdb->get_row(
    102102                        $wpdb->prepare(
    … …  
    107107                        ARRAY_A
    108108                );
    109                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     109                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    110110                if ( null !== $result ) {
    111111                        return new self( $result );
  • weareplanet/trunk/includes/entity/class-wc-weareplanet-entity-token-info.php

    r3288388 r3740659  
    7474                global $wpdb;
    7575                $table = $wpdb->prefix . self::get_table_name();
    76                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     76                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    7777                $result = $wpdb->get_row(
    7878                        $wpdb->prepare(
    … …  
    8383                        ARRAY_A
    8484                );
    85                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     85                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    8686                if ( null !== $result ) {
    8787                        return new self( $result );
  • weareplanet/trunk/includes/entity/class-wc-weareplanet-entity-transaction-info.php

    r3288388 r3740659  
    139139                global $wpdb;
    140140                $table = $wpdb->prefix . self::get_table_name();
    141                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     141                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    142142                $result = $wpdb->get_row(
    143143                        $wpdb->prepare(
    … …  
    148148                        ARRAY_A
    149149                );
    150                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     150                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    151151                if ( null !== $result ) {
    152152                        return new self( $result );
    … …  
    165165                global $wpdb;
    166166                $table = $wpdb->prefix . self::get_table_name();
    167                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     167                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    168168                $result = $wpdb->get_row(
    169169                        $wpdb->prepare(
    … …  
    173173                        ARRAY_A
    174174                );
    175                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     175                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    176176                if ( null !== $result ) {
    177177                        return new self( $result );
  • weareplanet/trunk/includes/entity/class-wc-weareplanet-entity-void-job.php

    r3288388 r3740659  
    9393                global $wpdb;
    9494                $table = $wpdb->prefix . self::get_table_name();
    95                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     95                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    9696                $result = $wpdb->get_row( //phpcs:ignore
    9797                        $wpdb->prepare(
    … …  
    102102                        ARRAY_A
    103103                );
    104                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     104                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    105105                if ( null !== $result ) {
    106106                        return new self( $result );
    … …  
    120120
    121121                $table = $wpdb->prefix . self::get_table_name();
    122                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     122                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    123123                $result = $wpdb->get_var(
    124124                        $wpdb->prepare(
    … …  
    129129                        )
    130130                );
    131                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     131                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    132132                return $result;
    133133        }
    … …  
    143143                global $wpdb;
    144144                $table = $wpdb->prefix . self::get_table_name();
    145                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     145                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    146146                $result = $wpdb->get_row(
    147147                        $wpdb->prepare(
    … …  
    153153                        ARRAY_A
    154154                );
    155                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     155                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    156156                if ( null !== $result ) {
    157157                        return new self( $result );
    … …  
    172172                $time->sub( new DateInterval( 'PT10M' ) );
    173173                $table = $wpdb->prefix . self::get_table_name();
    174                 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.
     174                // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare.
    175175                $db_results = $wpdb->get_results(
    176176                        $wpdb->prepare(
    … …  
    181181                        ARRAY_A
    182182                );
    183                 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare.
     183                // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter.
    184184                $result = array();
    185185                if ( is_array( $db_results ) ) {
  • weareplanet/trunk/includes/packages/gift-card/class-wc-weareplanet-packages-gift-card.php

    r3433358 r3740659  
    2222 * This class provides constants for Gift Cards and serves as a placeholder for future improvements.
    2323 */
    24 class WC_WeArePlanet_Packages_Gift_Card
    25 {
     24class WC_WeArePlanet_Packages_Gift_Card {
    2625        const WEAREPLANET_GIFT_CARD = 'Gift Card';
    2726}
  • weareplanet/trunk/includes/provider/class-wc-weareplanet-provider-language.php

    r3288388 r3740659  
    8989         */
    9090        protected function fetch_data() {
     91                // LanguageService::all() decodes languages.json into associative arrays, which the
     92                // ObjectSerializer cannot map onto models, so every language ends up without codes.
     93                $sdk_service = new \ReflectionClass( \WeArePlanet\Sdk\Service\LanguageService::class );
     94                $json_file   = dirname( $sdk_service->getFileName() ) . '/../languages.json';
     95                if ( is_readable( $json_file ) ) {
     96                        $languages = json_decode( file_get_contents( $json_file ) ); //phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
     97                        if ( ! empty( $languages ) && is_array( $languages ) ) {
     98                                return \WeArePlanet\Sdk\ObjectSerializer::deserialize( $languages, '\WeArePlanet\Sdk\Model\RestLanguage[]' );
     99                        }
     100                }
    91101                $language_service = new \WeArePlanet\Sdk\Service\LanguageService( WC_WeArePlanet_Helper::instance()->get_api_client() );
    92102                return $language_service->all();
  • weareplanet/trunk/includes/service/class-wc-weareplanet-service-line-item.php

    r3477965 r3740659  
    273273         *
    274274         * @param WC_Coupon|WC_Order_Item_Coupon $coupon The coupon object.
    275          * @param float $total_discount_amount The amount of the coupon.
     275         * @param float                          $total_discount_amount The amount of the coupon.
     276         * @param array                          $items The items to calculate the proportional discount for.
    276277         * @return \WeArePlanet\Sdk\Model\LineItemCreate|null The line item created or null if the coupon is not valid.
    277278         */
    278         private function create_coupon_line_items( $coupon, float $total_discount_amount = 0, array $items = [] ) {
     279        private function create_coupon_line_items( $coupon, float $total_discount_amount = 0, array $items = array() ) {
    279280                if ( ! $coupon instanceof WC_Coupon && ! $coupon instanceof WC_Order_Item_Coupon ) {
    280281                        return array();
    … …  
    317318         * Calculate discount rates
    318319         *
     320         * @param array $items items.
    319321         * @param float $total_discount_amount total_discount_amount.
    320322         * @return array
    321323         */
    322324        private function calculate_discount_rates_proportionally( array $items, float $total_discount_amount ): array {
    323                 $tax_totals = [];
     325                $tax_totals = array();
    324326                $total_amount = 0;
    325327                // If coupon line items are created from session, $items will always be an empty array. If from order, it will have said order line items.
    326                 $is_created_from_order = ! empty($items);
     328                $is_created_from_order = ! empty( $items );
    327329
    328330                // Check whether line items are no created from existing order. If not, line items are fetched from cart.
    329                 if ( ! $is_created_from_order) {
     331                if ( ! $is_created_from_order ) {
    330332                        $cart = WC()->cart;
    331333                        $items = $cart->get_cart();
    … …  
    340342                        // If product has no tax rates class set, then create a fake 0 rate one.
    341343                        if ( empty( $tax_rates_class ) ) {
    342                                 $tax_rates_class = [
    343                                         0 => [
     344                                $tax_rates_class = array(
     345                                        0 => array(
    344346                                                'rate' => 0,
    345                                         ],
    346                                 ];
     347                                        ),
     348                                );
    347349                        }
    348350
    … …  
    352354                                $line_total = ! $is_created_from_order ? $item['line_total'] : $item->get_total();
    353355                                $line_tax = ! $is_created_from_order ? $item['line_tax'] : $item->get_total_tax();
    354                                 $line_total_with_tax = floor(($line_total + $line_tax) * 100) / 100;
     356                                $line_total_with_tax = floor( ($line_total + $line_tax ) * 100 ) / 100;
    355357
    356358                                if ( ! isset( $tax_totals[ $rate_id ] ) ) {
    357                                         $tax_totals[ $rate_id ] = [
     359                                        $tax_totals[ $rate_id ] = array(
    358360                                                'total' => 0,
    359361                                                'rate_percentage' => $rate['rate'],
    360                                         ];
     362                                        );
    361363                                }
    362364
    363                                 $tax_totals[ $rate_id ]['total'] += floor(($line_total_with_tax) * 100) / 100;
     365                                $tax_totals[ $rate_id ]['total'] += floor( ( $line_total_with_tax ) * 100 ) / 100;
    364366                                $total_amount += $line_total_with_tax;
    365367                        }
    … …  
    367369
    368370                if ( $total_amount <= 0 ) {
    369                         return [];
    370                 }
    371 
    372                 $discounts = [];
     371                        return array();
     372                }
     373
     374                $discounts = array();
    373375                foreach ( $tax_totals as $rate_id => $data ) {
    374                         if ( $total_amount == 0 ) {
     376                        if ( 0 === $total_amount ) {
    375377                                // If $total_amount is 0, no proportional discounts are applied, as there is nothing to distribute.
    376378                                $proportional_discount_amount = 0;
    377379                        } else {
    378                                 $proportional_discount_amount = floor($total_discount_amount * ( $data['total'] / $total_amount ) * 100) / 100;
     380                                $proportional_discount_amount = floor( $total_discount_amount * ( $data['total'] / $total_amount ) * 100 ) / 100;
    379381                        }
    380382
    381383                        if ( $proportional_discount_amount > 0 ) {
    382                                 $discounts[] = [
    383                                   'rate_id' => $rate_id,
    384                                   'amount' => $proportional_discount_amount,
    385                                   'rate_percentage' => $data['rate_percentage'],
    386                                 ];
     384                                $discounts[] = array(
     385                                        'rate_id' => $rate_id,
     386                                        'amount' => $proportional_discount_amount,
     387                                        'rate_percentage' => $data['rate_percentage'],
     388                                );
    387389                        }
    388390                }
    … …  
    641643         * Get items from backend.
    642644         *
    643          * @param array $backend_items backend items.
    644          * @param mixed $amount amount.
     645         * @param array    $backend_items backend items.
     646         * @param mixed    $amount amount.
    645647         * @param WC_Order $order order.
    646648         * @return \WeArePlanet\Sdk\Model\LineItemCreate[]
    … …  
    660662         * Creates the line items for the products
    661663         *
    662          * @param array $backend_items backend items.
     664         * @param array    $backend_items backend items.
    663665         * @param WC_Order $order order.
    664666         * @return \WeArePlanet\Sdk\Model\LineItemCreate[]
    … …  
    753755         * Returns the line items for fees.
    754756         *
    755          * @param array $backend_items backend items.
     757         * @param array    $backend_items backend items.
    756758         * @param WC_Order $order order.
    757759         * @return array
    … …  
    821823         * Returns the line items for the shipping costs.
    822824         *
    823          * @param array $backend_items backend items.
     825         * @param array    $backend_items backend items.
    824826         * @param WC_Order $order order.
    825827         * @return array
    … …  
    9991001         * Returns the line items from the given cart for order renewal.
    10001002         *
    1001          * @param WC_Order $order order.
    1002          * @param mixed $order_total Order total.
     1003         * @param WC_Order                                                    $order order.
     1004         * @param mixed                                                       $order_total Order total.
    10031005         * @param \WeArePlanet\Sdk\Model\AbstractTransactionPending $transaction Transaction.
    10041006         *
    … …  
    10231025                $gift_card_items = array();
    10241026
    1025                 $redeemed = WC()->session->get('_wc_gc_giftcards', []);
     1027                $redeemed = WC()->session->get( '_wc_gc_giftcards', array() );
    10261028
    10271029                if ( empty( $redeemed ) ) {
    … …  
    10451047                        }
    10461048
    1047                         // Receive the amount debited from the card for this order
     1049                        // Receive the amount debited from the card for this order.
    10481050                        $used_amount = $item['amount'];
    10491051
    … …  
    10521054                        }
    10531055
    1054                         // Prevent rounding errors from sdk
     1056                        // Prevent rounding errors from sdk.
    10551057                        $used_amount = round($used_amount, 2);
    10561058
    1057                         // Create Line Items for gift cards
     1059                        // Create Line Items for gift cards.
    10581060                        $line_item = new \WeArePlanet\Sdk\Model\LineItemCreate();
    10591061                        $line_item->setAmountIncludingTax( -1 * abs( $used_amount ) );
    … …  
    10661068                        $line_item->setType( \WeArePlanet\Sdk\Model\LineItemType::DISCOUNT );
    10671069
    1068                         // Zero tax for gift card
     1070                        // Zero tax for gift card.
    10691071                        $tax_rate = new \WeArePlanet\Sdk\Model\TaxCreate(
    10701072                                array(
    … …  
    10841086         * Create gift card line items from an order object (used in backend or sync).
    10851087         *
    1086          * @return \WeArePlanet\Sdk\Model\LineItemCreate[]
    1087          */
    1088         protected function create_gift_card_line_items_from_order( $order) {
     1088         * @param WC_Order $order order.
     1089         *
     1090         * @return \WeArePlanet\Sdk\Model\LineItemCreate[]
     1091         */
     1092        protected function create_gift_card_line_items_from_order( $order ) {
    10891093                if ( ! function_exists( 'WC_GC' ) ) {
    10901094                        return array();
    … …  
    10931097                $gift_card_items = array();
    10941098
    1095                 //Get array of strings with codes used in current order
     1099                // Get array of strings with codes used in current order.
    10961100                $used_codes = WC_GC()->order->get_gift_cards( $order );
    10971101
    … …  
    11001104                }
    11011105
    1102                 $order_gift_cards = [];
    1103 
    1104                 //Initialize appropriate Gift Card Objects for each code
     1106                $order_gift_cards = array();
     1107
     1108                // Initialize appropriate Gift Card Objects for each code.
    11051109                foreach ( $used_codes['codes'] as $item ) {
    11061110                        $order_gift_cards[] = wc_gc_get_gift_card_by_code( $item );
    … …  
    11111115                }
    11121116
    1113                 $items = $order->get_items('gift_card');
     1117                $items = $order->get_items( 'gift_card' );
    11141118
    11151119                foreach ( $items as $giftcard_item ) {
    … …  
    11281132
    11291133                        $line_item = new \WeArePlanet\Sdk\Model\LineItemCreate();
    1130                         // WeArePlanet expects discounts as negative values
     1134                        // WeArePlanet expects discounts as negative values.
    11311135                        $line_item->setAmountIncludingTax( -1 * abs( $used_amount ) );
    11321136                        /* translators: %s: gift card code */
    … …  
    11381142                        $line_item->setType( \WeArePlanet\Sdk\Model\LineItemType::DISCOUNT );
    11391143
    1140                         // Zero tax for gift card
     1144                        // Zero tax for gift card.
    11411145                        $tax_rate = new \WeArePlanet\Sdk\Model\TaxCreate(
    11421146                                array(
  • weareplanet/trunk/includes/service/class-wc-weareplanet-service-token.php

    r3433358 r3740659  
    111111                        return;
    112112                }
    113                
    114                 // need to add a safety check here to see if the $token_version->getPaymentConnectorConfiguration()->getPaymentMethodConfiguration() exists
     113
     114                // need to add a safety check here to see if the $token_version->getPaymentConnectorConfiguration()->getPaymentMethodConfiguration() exists.
    115115                if ( $token_version->getPaymentConnectorConfiguration() === null ) {
    116116                        return;
  • weareplanet/trunk/includes/service/class-wc-weareplanet-service-transaction.php

    r3463230 r3740659  
    9090         * @throws Exception If the API client cannot be initialized.
    9191         */
    92         public function __construct()
    93         {
     92        public function __construct() {
    9493                $this->api_client = WC_WeArePlanet_Helper::instance()->get_api_client();
    9594        }
    … …  
    503502         */
    504503        public function get_possible_payment_methods_for_cart() {
    505                 $paymentConfigurations = $this->get_possible_payment_methods( null );
    506                 $paymentConfigurations[] = WC_WeArePlanet_Zero_Gateway::ZERO_PAYMENT_CONF_ID;
    507 
    508                 return $paymentConfigurations;
     504                $payment_configurations = $this->get_possible_payment_methods( null );
     505                $payment_configurations[] = WC_WeArePlanet_Zero_Gateway::ZERO_PAYMENT_CONF_ID;
     506
     507                return $payment_configurations;
    509508        }
    510509
    … …  
    521520         */
    522521        public function get_possible_payment_methods_for_order( WC_Order $order ) {
    523                 $paymentConfigurations = $this->get_possible_payment_methods( $order );
    524                 $paymentConfigurations[] = WC_WeArePlanet_Zero_Gateway::ZERO_PAYMENT_CONF_ID;
    525 
    526                 return $paymentConfigurations;
     522                $payment_configurations = $this->get_possible_payment_methods( $order );
     523                $payment_configurations[] = WC_WeArePlanet_Zero_Gateway::ZERO_PAYMENT_CONF_ID;
     524
     525                return $payment_configurations;
    527526        }
    528527
    … …  
    569568         * @param WC_Order                                                    $order order.
    570569         * @param \WeArePlanet\Sdk\Model\AbstractTransactionPending $transaction transaction.
    571          * @param bool $set_line_items Set line items.
     570         * @param bool                                                        $set_line_items Set line items.
    572571         * @throws WC_WeArePlanet_Exception_Invalid_Transaction_Amount WC_WeArePlanet_Exception_Invalid_Transaction_Amount.
    573572         */
    … …  
    579578                $transaction->setCustomerId( $this->get_customer_id() );
    580579                $customer_note = $order->get_customer_note();
    581                 if (!empty($customer_note)) {
    582                         $transaction->setMetaData(['customerNotes' => $customer_note]);
     580                if ( ! empty( $customer_note ) ) {
     581                        $transaction->setMetaData( array( 'customerNotes' => $customer_note ) );
    583582                }
    584583                $language = null;
    … …  
    786785         * If no transaction exists, a new one is created.
    787786         *
     787         * @param int|null $current_cart_id current cart id.
    788788         * @return \WeArePlanet\Sdk\Model\Transaction
    789789         * @throws Exception Exception.
    790790         */
    791         public function get_transaction_from_session( $current_cart_id = null) {
     791        public function get_transaction_from_session( $current_cart_id = null ) {
    792792
    793793                if ( null === $current_cart_id ) {
    … …  
    910910         * Load and update transaction for order.
    911911         *
    912          * @param WC_Order $order order.
     912         * @param WC_Order                                         $order order.
    913913         * @param WC_WeArePlanet_Entity_Transaction_Info $existing_transaction existing transaction.
    914914         * @return \WeArePlanet\Sdk\Model\Transaction|\WeArePlanet\Sdk\Model\TransactionCreate
    … …  
    12071207         * Set modified order line items.
    12081208         *
    1209          * @param WC_Order                                                    $order       Order.
     1209         * @param WC_Order                                                    $order Order.
    12101210         * @param mixed                                                       $order_total Order total.
    12111211         * @param \WeArePlanet\Sdk\Model\AbstractTransactionPending $transaction Transaction.
    … …  
    12211221         *
    12221222         * @param WC_Order $order Order.
    1223          * @param mixed $order_total Order total.
    1224          * @param int $token_id Token id.
     1223         * @param mixed    $order_total Order total.
     1224         * @param int      $token_id Token id.
    12251225         *
    12261226         * @return \WeArePlanet\Sdk\Model\Transaction
    1227          * @throws Exception
    1228          *       If the transaction being created is not valid.
     1227         * @throws Exception Exception.
    12291228         */
    12301229        public function create_transaction_by_renewal_order( WC_Order $order, $order_total, $token_id ) {
    … …  
    12411240
    12421241                $create_transaction = apply_filters( 'wc_weareplanet_subscription_create_transaction', $create_transaction, $order );
    1243                 if (!$create_transaction->valid()) {
    1244                         throw new Exception("The transaction you are trying to create is not valid.");
    1245                 }
    1246                 WC_WeArePlanet_Helper::instance()->add_headers( $this->api_client, [
    1247                         WC_WeArePlanet_Helper::SUBSCRIPTION_TRANSACTION => true
    1248                 ]);
     1242                if ( ! $create_transaction->valid() ) {
     1243                        throw new Exception( 'The transaction you are trying to create is not valid.' );
     1244                }
     1245                WC_WeArePlanet_Helper::instance()->add_headers(
     1246                        $this->api_client,
     1247                        array(
     1248                                WC_WeArePlanet_Helper::SUBSCRIPTION_TRANSACTION => true,
     1249                        )
     1250                );
    12491251                $transaction = $this->get_transaction_service()->create( $space_id, $create_transaction );
    12501252                $this->update_transaction_info( $transaction, $order );
    … …  
    12551257         * Creates a transaction for the given order.
    12561258         *
    1257          * @param WC_Order                                     $order       Order.
     1259         * @param WC_Order                                     $order Order.
    12581260         * @param mixed                                        $order_total Order total.
    1259          * @param int                                          $token_id    Token id.
     1261         * @param int                                          $token_id Token id.
    12601262         * @param \WeArePlanet\Sdk\Model\Transaction $transaction Transaction.
    12611263         *
    … …  
    12751277                                $this->set_modified_order_line_items( $order, $order_total, $pending_transaction );
    12761278                                $pending_transaction = apply_filters( 'wc_weareplanet_subscription_update_transaction', $pending_transaction, $order );
    1277                                 WC_WeArePlanet_Helper::instance()->add_headers( $this->api_client, [
    1278                                         WC_WeArePlanet_Helper::SUBSCRIPTION_TRANSACTION => true
    1279                                 ]);
     1279                                WC_WeArePlanet_Helper::instance()->add_headers(
     1280                                        $this->api_client,
     1281                                        array(
     1282                                                WC_WeArePlanet_Helper::SUBSCRIPTION_TRANSACTION => true,
     1283                                        )
     1284                                );
    12801285                                return $this->get_transaction_service()->update( $transaction->getLinkedSpaceId(), $pending_transaction );
    12811286                        } catch ( \WeArePlanet\Sdk\VersioningException $e ) {
    … …  
    12891294         * Process transaction without user interaction.
    12901295         *
    1291          * @param mixed $space_id       Space id.
     1296         * @param mixed $space_id Space id.
    12921297         * @param mixed $transaction_id Transaction id.
    12931298         *
  • weareplanet/trunk/includes/service/class-wc-weareplanet-service-webhook.php

    r3288388 r3740659  
    200200                        }
    201201                }
     202                $this->enforce_signed_listeners();
    202203        }
    203204
    … …  
    219220         * Create a webhook listener.
    220221         *
    221          * @param WC_WeArePlanet_Webhook_Entity $entity entity.
    222          * @param int $space_id space id.
     222         * @param WC_WeArePlanet_Webhook_Entity     $entity entity.
     223         * @param int                                         $space_id space id.
    223224         * @param \WeArePlanet\Sdk\Model\WebhookUrl $webhook_url webhook url.
    224225         *
    … …  
    241242         * Returns the existing webhook listeners.
    242243         *
    243          * @param int $space_id space id.
     244         * @param int                                         $space_id space id.
    244245         * @param \WeArePlanet\Sdk\Model\WebhookUrl $webhook_url webhook url.
    245246         *
    … …  
    343344                return $this->webhook_url_service;
    344345        }
     346
     347        /**
     348         * Enforces payload signatures on webhook listeners.
     349         *
     350         * @throws \Exception Exception.
     351         */
     352        public function enforce_signed_listeners() {
     353                $space_id = get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_SPACE_ID );
     354                if ( empty( $space_id ) ) {
     355                        return;
     356                }
     357                $webhook_url = $this->get_webhook_url( $space_id );
     358                if ( null === $webhook_url ) {
     359                        return;
     360                }
     361                try {
     362                        $webhook_listeners = $this->get_webhook_listeners( $space_id, $webhook_url );
     363                } catch ( Exception $e ) {
     364                        WooCommerce_WeArePlanet::instance()->log(
     365                                'Could not load webhook listeners to enforce signing: ' . $e->getMessage(),
     366                                WC_Log_Levels::ERROR
     367                        );
     368                }
     369                $webhook_service = $this->get_webhook_listener_service();
     370                foreach ( $webhook_listeners as $listener ) {
     371                        if ( $listener->getEnablePayloadSignatureAndState() ) {
     372                                continue;
     373                        }
     374                        try {
     375                                $update = new \WeArePlanet\Sdk\Model\WebhookListenerUpdate();
     376                                $update->setId( $listener->getId() );
     377                                $update->setVersion( $listener->getVersion() );
     378                                $update->setEnablePayloadSignatureAndState( true );
     379                                $webhook_service->update( $space_id, $update );
     380                        } catch ( \Exception $e ) {
     381                                WooCommerce_WeArePlanet::instance()->log(
     382                                        'Could not update webhook listeners to enforce signing: ' . $e->getMessage(),
     383                                        WC_Log_Levels::ERROR
     384                                );
     385                        }
     386                }
     387        }
    345388}
  • weareplanet/trunk/includes/webhook/strategies/class-wc-weareplanet-webhook-delivery-indication-strategy.php

    r3378673 r3740659  
    6363
    6464        /**
    65          * Meant to bridge code from deprecated processor.
    66          *
    67          * @param WC_Order $order The WooCommerce order linked to the delivery indication.
    68          * @param \WeArePlanet\Sdk\Model\DeliveryIndication $delivery_indication The delivery indication object.
    69          * @param WC_WeArePlanet_Webhook_Request $request The webhook request.
    70          * @return void
    71          */
    72         public function bridge_process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\DeliveryIndication $delivery_indication, WC_WeArePlanet_Webhook_Request $request ) {
    73         $this->process_order_related_inner( $order, $delivery_indication, $request, true );
    74     }
    75 
    76         /**
    7765         * Processes the incoming webhook request pertaining to delivery indications.
    7866         *
    … …  
    9583         * Additional processing on the order based on the state of the delivery indication.
    9684         *
    97          * @param WC_Order $order The WooCommerce order linked to the delivery indication.
     85         * @param WC_Order                                            $order The WooCommerce order linked to the delivery indication.
    9886         * @param \WeArePlanet\Sdk\Model\DeliveryIndication $delivery_indication The delivery indication object.
    99          * @param WC_WeArePlanet_Webhook_Request $request The webhook request.
    100          * @param bool $legacy_mode legacy code used.
     87         * @param WC_WeArePlanet_Webhook_Request            $request The webhook request.
    10188         * @return void
    10289         */
    103         protected function process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\DeliveryIndication $delivery_indication, WC_WeArePlanet_Webhook_Request $request, $legacy_mode = false ) {
    104                 $entity_state = $legacy_mode ? $delivery_indication->getState() : $request->get_state();
     90        protected function process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\DeliveryIndication $delivery_indication, WC_WeArePlanet_Webhook_Request $request ) {
     91                $entity_state = $request->get_state();
    10592                switch ( $entity_state ) {
    10693                        case \WeArePlanet\Sdk\Model\DeliveryIndicationState::MANUAL_CHECK_REQUIRED:
  • weareplanet/trunk/includes/webhook/strategies/class-wc-weareplanet-webhook-refund-strategy.php

    r3378673 r3740659  
    6262
    6363        /**
    64          * Meant to bridge code from deprecated processor.
    65          *
    66          * @param WC_Order $order The WooCommerce order associated with the refund.
    67          * @param \WeArePlanet\Sdk\Model\Refund $refund The transaction refund object.
    68          * @param WC_WeArePlanet_Webhook_Request $request The webhook request object.
    69          * @return void
    70          */
    71         public function bridge_process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\Refund $refund, WC_WeArePlanet_Webhook_Request $request ) {
    72         $this->process_order_related_inner( $order, $refund, $request, true );
    73     }
    74 
    75         /**
    7664         * Processes the incoming webhook request related to refunds.
    7765         *
    … …  
    9785         * @param \WeArePlanet\Sdk\Model\Refund $refund The transaction refund object.
    9886         * @param WC_WeArePlanet_Webhook_Request $request The webhook request object.
    99          * @param bool $legacy_mode legacy code used.
    10087         * @return void
    10188         */
    102         protected function process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\Refund $refund, WC_WeArePlanet_Webhook_Request $request, $legacy_mode = false ) {
     89        protected function process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\Refund $refund, WC_WeArePlanet_Webhook_Request $request ) {
    10390                /* @var \WeArePlanet\Sdk\Model\Refund $refund */
    104                 $entity_state = $legacy_mode ? $refund->getState() : $request->get_state();
     91                $entity_state = $request->get_state();
    10592                switch ( $entity_state ) {
    10693                        case \WeArePlanet\Sdk\Model\RefundState::FAILED:
  • weareplanet/trunk/includes/webhook/strategies/class-wc-weareplanet-webhook-transaction-completion-strategy.php

    r3378673 r3740659  
    6363
    6464        /**
    65          * Meant to bridge code from deprecated processor.
    66          *
    67          * @param WC_Order $order The WooCommerce order linked to the completion.
    68          * @param \WeArePlanet\Sdk\Model\TransactionCompletion $completion The transaction completion object.
    69          * @param WC_WeArePlanet_Webhook_Request $request The webhook request.
    70          * @return void
    71          */
    72         public function bridge_process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\TransactionCompletion $completion, WC_WeArePlanet_Webhook_Request $request ) {
    73         $this->process_order_related_inner( $order, $completion, $request, true );
    74     }
    75 
    76         /**
    7765         * Processes the incoming webhook request pertaining to transaction completions.
    7866         *
    … …  
    9886         * @param \WeArePlanet\Sdk\Model\TransactionCompletion $completion The transaction completion object.
    9987         * @param WC_WeArePlanet_Webhook_Request $request The webhook request.
    100          * @param bool $legacy_mode legacy code used.
    101          * @return void
    102          */
    103         protected function process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\TransactionCompletion $completion, WC_WeArePlanet_Webhook_Request $request, $legacy_mode = false ) {
    104                 $entity_state = $legacy_mode ? $completion->getState() : $request->get_state();
     88         * @return void
     89         */
     90        protected function process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\TransactionCompletion $completion, WC_WeArePlanet_Webhook_Request $request ) {
     91                $entity_state = $request->get_state();
    10592                switch ( $entity_state ) {
    10693                        case \WeArePlanet\Sdk\Model\TransactionCompletionState::FAILED:
  • weareplanet/trunk/includes/webhook/strategies/class-wc-weareplanet-webhook-transaction-invoice-strategy.php

    r3378673 r3740659  
    6363
    6464        /**
    65          * Meant to bridge code from deprecated processor.
    66          *
    67          * @param WC_Order $order The WooCommerce order linked to the invoice.
    68          * @param \WeArePlanet\Sdk\Model\TransactionInvoice $transaction_invoice The transaction invoice object.
    69          * @param WC_WeArePlanet_Webhook_Request $request The webhook request object.
    70          * @return void
    71          */
    72         public function bridge_process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\TransactionInvoice $transaction_invoice, WC_WeArePlanet_Webhook_Request $request ) {
    73         $this->process_order_related_inner( $order, $transaction_invoice, $request, true );
    74     }
    75 
    76         /**
    7765         * Processes the incoming webhook request pertaining to transaction invoices.
    7866         *
    … …  
    9583         * Additional processing on the order based on the state of the transaction invoice.
    9684         *
    97          * @param WC_Order $order The WooCommerce order linked to the invoice.
     85         * @param WC_Order                                            $order The WooCommerce order linked to the invoice.
    9886         * @param \WeArePlanet\Sdk\Model\TransactionInvoice $transaction_invoice The transaction invoice object.
    99          * @param WC_WeArePlanet_Webhook_Request $request The webhook request object.
    100          * @param bool $legacy_mode legacy code used.
     87         * @param WC_WeArePlanet_Webhook_Request            $request The webhook request object.
    10188         * @return void
    10289         */
    103         protected function process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\TransactionInvoice $transaction_invoice, WC_WeArePlanet_Webhook_Request $request, $legacy_mode = false ) {
    104                 $entity_state = $legacy_mode ? $transaction_invoice->getState() : $request->get_state();
     90        protected function process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\TransactionInvoice $transaction_invoice, WC_WeArePlanet_Webhook_Request $request ) {
     91                $entity_state = $request->get_state();
    10592                switch ( $entity_state ) {
    10693                        case \WeArePlanet\Sdk\Model\TransactionInvoiceState::DERECOGNIZED:
  • weareplanet/trunk/includes/webhook/strategies/class-wc-weareplanet-webhook-transaction-strategy.php

    r3598699 r3740659  
    3838
    3939        /**
    40          * Meant to bridge code from deprecated processor.
    41          *
    42          * @param WC_Order $order order.
    43          * @param mixed $transaction transaction.
    44          * @return mixed The result of the processing.
    45          */
    46         public function bridge_process_order_related_inner( WC_Order $order, $transaction ) {
    47         $this->process_order_related_inner( $order, $transaction, true );
    48     }
    49 
    50         /**
    5140         * Process the webhook request.
    5241         *
    53          * @param \WeArePlanet\Sdk\Model\Transaction $transaction The webhook request object.
     42         * @param WC_WeArePlanet_Webhook_Request $request The webhook request.
    5443         * @return mixed The result of the processing.
    5544         */
    … …  
    5847                $entity = $this->load_entity( $request );
    5948
    60                 // retry orphaned transaction, fall back to merchant reference
     49                // Retry orphaned transaction, fall back to merchant reference.
    6150                if ( ( false === $order || ! $order->get_id() ) && $entity ) {
    6251                        $merchant_ref = $entity->getMerchantReference();
    … …  
    6857                if ( false != $order && $order->get_id() ) {
    6958                        $this->process_order_related_inner( $order, $entity );
    70                         if ($request->get_state() === \WeArePlanet\Sdk\Model\TransactionState::AUTHORIZED) {
     59                        if ( $request->get_state() === \WeArePlanet\Sdk\Model\TransactionState::AUTHORIZED ) {
    7160                                do_action( 'weareplanet_transaction_authorized_send_email', $order->get_id() );
    7261                        }
    … …  
    7968         * @param WC_Order $order order.
    8069         * @param mixed $transaction transaction.
    81          * @param bool $legacy_mode legacy code used.
    8270         * @return void
    8371         * @throws Exception Exception.
    8472         */
    85         protected function process_order_related_inner( WC_Order $order, $transaction, $legacy_mode = false ) {
     73        protected function process_order_related_inner( WC_Order $order, $transaction ) {
    8674                if ( strpos( $order->get_payment_method(), 'weareplanet' ) === false ) {
    8775                        return;
    … …  
    10896                                        $this->authorize( $transaction, $order );
    10997                                        $this->fulfill( $transaction, $order );
    110                                         if ( $legacy_mode ) {
    111                                                 do_action( 'weareplanet_transaction_authorized_send_email', $order->get_id() );
    112                                         }
    11398                                        WC_WeArePlanet_Helper::set_virtual_zero_total_orders_to_complete( $order );
    11499                                        WC_WeArePlanet_Helper::update_order_status_for_preorder_if_needed( $order );
    … …  
    127112                        WC_WeArePlanet_Service_Transaction::instance()->update_transaction_info( $transaction, $order );
    128113                }
    129 
    130                 if ( $legacy_mode ) {
    131                         // This is edge case for deferred payment methods
    132                         $transaction_info = WC_WeArePlanet_Entity_Transaction_Info::load_by_order_id( $order->get_id() );
    133                         if ($transaction_info->get_state() === \WeArePlanet\Sdk\Model\TransactionState::AUTHORIZED) {
    134                                 do_action( 'weareplanet_transaction_authorized_send_email', $order->get_id() );
    135                         }
    136                 }
    137114        }
    138115
    … …  
    141118         *
    142119         * @param \WeArePlanet\Sdk\Model\Transaction $transaction transaction.
    143          * @param WC_Order $order order.
     120         * @param WC_Order                                     $order order.
    144121         * @return void
    145122         */
    … …  
    162139         *
    163140         * @param \WeArePlanet\Sdk\Model\Transaction $transaction transaction.
    164          * @param \WC_Order $order order.
     141         * @param \WC_Order                                    $order order.
    165142         */
    166143        protected function authorize( \WeArePlanet\Sdk\Model\Transaction $transaction, WC_Order $order ) {
    … …  
    181158         *
    182159         * @param \WeArePlanet\Sdk\Model\Transaction $transaction transaction.
    183          * @param WC_Order $order order.
     160         * @param WC_Order                                     $order order.
    184161         * @return void
    185162         */
    … …  
    200177         *
    201178         * @param \WeArePlanet\Sdk\Model\Transaction $transaction transaction.
    202          * @param WC_Order $order order.
     179         * @param WC_Order                                     $order order.
    203180         * @return void
    204181         */
    … …  
    217194         *
    218195         * @param \WeArePlanet\Sdk\Model\Transaction $transaction transaction.
    219          * @param WC_Order $order order.
     196         * @param WC_Order                                     $order order.
    220197         * @return void
    221198         */
    … …  
    231208                        // Custom order statuses mapped.
    232209                        apply_filters( 'weareplanet_wc_status_for_transaction', 'confirmed' ),
    233                         apply_filters( 'weareplanet_wc_status_for_transaction', 'failed' )
     210                        apply_filters( 'weareplanet_wc_status_for_transaction', 'failed' ),
    234211                );
    235212                if ( in_array( $order->get_status( 'edit' ), $valid_order_statuses ) ) {
    … …  
    244221         *
    245222         * @param \WeArePlanet\Sdk\Model\Transaction $transaction transaction.
    246          * @param WC_Order $order order.
     223         * @param WC_Order                                     $order order.
    247224         * @return void
    248225         */
    … …  
    274251         *
    275252         * @param \WeArePlanet\Sdk\Model\Transaction $transaction transaction.
    276          * @param WC_Order $order order.
     253         * @param WC_Order                                     $order order.
    277254         * @return void
    278255         */
  • weareplanet/trunk/includes/webhook/strategies/class-wc-weareplanet-webhook-transaction-void-strategy.php

    r3378673 r3740659  
    6666
    6767        /**
    68          * Meant to bridge code from deprecated processor.
    69          *
    70          * @param WC_Order $order The WooCommerce order associated with the void request.
    71          * @param \WeArePlanet\Sdk\Model\TransactionVoid $void The transaction void object.
    72          * @param WC_WeArePlanet_Webhook_Request $request The webhook request object.
    73          * @return void
    74          */
    75         public function bridge_process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\TransactionVoid $void, WC_WeArePlanet_Webhook_Request $request ) {
    76         $this->process_order_related_inner( $order, $void, $request, true );
    77     }
    78 
    79         /**
    8068         * Processes the incoming webhook request related to transaction voids.
    8169         *
    … …  
    10189         * @param \WeArePlanet\Sdk\Model\TransactionVoid $void The transaction void object.
    10290         * @param WC_WeArePlanet_Webhook_Request $request The webhook request object.
    103          * @param bool $legacy_mode legacy code used.
    10491         * @return void
    10592         */
    106         protected function process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\TransactionVoid $void, WC_WeArePlanet_Webhook_Request $request, $legacy_mode = false ) {
    107                 $entity_state = $legacy_mode ? $void->getState() : $request->get_state();
     93        protected function process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\TransactionVoid $void, WC_WeArePlanet_Webhook_Request $request ) {
     94                $entity_state = $request->get_state();
    10895                switch ( $entity_state ) {
    10996                        case \WeArePlanet\Sdk\Model\TransactionVoidState::FAILED:
  • weareplanet/trunk/readme.txt

    r3676036 r3740659  
    33Tags: payment, WeArePlanet, e-commerce, invoice, psp
    44Requires at least: 6.0
    5 Tested up to: 7.0
    6 Stable tag: 3.4.8
     5Tested up to: 7.1.2
     6Stable tag: 3.4.9
    77License: Apache-2.0
    88License URI: http://www.apache.org/licenses/LICENSE-2.0
    … …  
    2222
    2323Additional documentation for this plugin is available:
    24 [here](https://plugin-documentation.weareplanet.com/weareplanet/woocommerce/3.4.8/docs/en/documentation.html).
     24[here](https://plugin-documentation.weareplanet.com/weareplanet/woocommerce/3.4.9/docs/en/documentation.html).
    2525
    2626== Source code and build process ==
    … …  
    204204== Changelog ==
    205205
    206 = 3.4.8 - September 1 2026 =
    207 - [BugFix] Fixed missing assets
     206= 3.4.9 - October 7 2026 =
     207- [Feature] Tested against Wordpress 7.1.2
     208- [Bugfix] Fixed issue where translations for payment methods were incorrect
    208209- [Tested Against] PHP 8.4.20
    209 - [Tested Against] Wordpress 7
    210 - [Tested Against] Woocommerce 11.0.1
    211 - [Tested Against] PHP SDK 4.9.1
     210- [Tested Against] Wordpress 7.1.2
     211- [Tested Against] Woocommerce 11.2.0
     212- [Tested Against] PHP SDK 4.9.2
  • weareplanet/trunk/views/admin-notices/subscription-plugin-deactivate.php

    r3433358 r3740659  
    1919?>
    2020<div class="error notice notice-error">
    21     <p>
    22         <?php esc_html_e( 'WeArePlanet Subscription plugin has been deactivated because subscriptions are now handled directly by the WeArePlanet plugin. You can safely remove the old plugin', 'woo-weareplanet' ); ?>
    23     </p>
     21        <p>
     22                <?php esc_html_e( 'WeArePlanet Subscription plugin has been deactivated because subscriptions are now handled directly by the WeArePlanet plugin. You can safely remove the old plugin', 'woo-weareplanet' ); ?>
     23        </p>
    2424</div>
  • weareplanet/trunk/views/admin-settings/html-admin-page-order-statuses.php

    r3463230 r3740659  
    2525        <thead>
    2626                <tr>
    27                         <?php foreach ( $order_statuses_columns as $status_key => $heading ) : ?>
    28                                 <th class="<?php echo esc_attr( $status_key ); ?>"><?php echo esc_html( $heading ); ?></th>
     27                        <?php foreach ( $order_statuses_columns as $weareplanet_status_key => $weareplanet_heading ) : ?>
     28                                <th class="<?php echo esc_attr( $weareplanet_status_key ); ?>"><?php echo esc_html( $weareplanet_heading ); ?></th>
    2929                        <?php endforeach; ?>
    3030                        <th />
    … …  
    5555                                <article>
    5656                                <form action="" method="post">
    57                     <input type="hidden" name="key" value="{{{ data.key }}}" />
     57                                        <input type="hidden" name="key" value="{{{ data.key }}}" />
    5858                                        <?php
    59                                         foreach ( $order_statuses_columns as $status_key => $heading ) {
    60                                                 echo '<div class="weareplanet-order-statuses-modal-input wc-shipping-class-modal-input ' . esc_attr( $status_key ) . '">';
    61                                                 switch ( $status_key ) {
     59                                        foreach ( $order_statuses_columns as $weareplanet_status_key => $weareplanet_heading ) {
     60                                                echo '<div class="weareplanet-order-statuses-modal-input wc-shipping-class-modal-input ' . esc_attr( $weareplanet_status_key ) . '">';
     61                                                switch ( $weareplanet_status_key ) {
    6262                                                        case 'weareplanet-order-status-key':
    6363                                                                ?>
    6464                                                                <div class="view">
    65                                                                         <?php echo esc_html( $heading ); ?> *
     65                                                                        <?php echo esc_html( $weareplanet_heading ); ?> *
    6666                                                                </div>
    6767                                                                <div class="edit">
    … …  
    7474                                                                                        placeholder="<?php esc_attr_e( 'e.g. awaiting', 'woo-weareplanet' ); ?>" />
    7575                                                                        </label>
    76                                     <small id="charCount" style="color: gray;"></small>
     76                                                                        <small id="charCount" style="color: gray;"></small>
    7777                                                                </div>
    7878                                                                <div class="weareplanet-order-statuses-modal-help-text wc-shipping-class-modal-help-text"><?php esc_html_e( 'Give your custom status a name for easy identification', 'woo-weareplanet' ); ?></div>
    … …  
    102102        <tr data-id="{{ data.key }}">
    103103                <?php
    104                 foreach ( $order_statuses_columns as $status_key => $heading ) {
    105                         echo '<td class="' . esc_attr( $status_key ) . '">';
    106                         switch ( $status_key ) {
     104                foreach ( $order_statuses_columns as $weareplanet_status_key => $weareplanet_heading ) {
     105                        echo '<td class="' . esc_attr( $weareplanet_status_key ) . '">';
     106                        switch ( $weareplanet_status_key ) {
    107107                                case 'weareplanet-order-status-key':
    108108                                        ?>
  • weareplanet/trunk/weareplanet-sdk/composer.json

    r3673687 r3740659  
    11{
    22        "name": "weareplanet/sdk",
    3         "version": "4.9.1",
     3        "version": "4.9.2",
    44        "description": "WeArePlanet SDK for PHP",
    55        "keywords": [
  • weareplanet/trunk/weareplanet-sdk/lib/ApiClient.php

    r3673687 r3740659  
    4949         */
    5050        private $defaultHeaders = [
    51         'x-meta-sdk-version' => "4.9.1",
     51        'x-meta-sdk-version' => "4.9.2",
    5252        'x-meta-sdk-language' => 'php',
    5353        'x-meta-sdk-provider' => "WeArePlanet",
    … …  
    5959         * @var string
    6060         */
    61         private $userAgent = 'PHP-Client/4.9.1/php';
     61        private $userAgent = 'PHP-Client/4.9.2/php';
    6262
    6363        /**
  • weareplanet/trunk/weareplanet-sdk/lib/Configuration.php

    r3673687 r3740659  
    8181     * @var string
    8282     */
    83     protected $userAgent = 'WeArePlanet\Sdk/4.9.1/php';
     83    protected $userAgent = 'WeArePlanet\Sdk/4.9.2/php';
    8484
    8585    /**
    … …  
    389389        $report .= '    OS: ' . php_uname() . PHP_EOL;
    390390        $report .= '    PHP Version: ' . PHP_VERSION . PHP_EOL;
    391         $report .= '    OpenAPI Spec Version: 4.9.1' . PHP_EOL;
    392         $report .= '    SDK Package Version: 4.9.1' . PHP_EOL;
     391        $report .= '    OpenAPI Spec Version: 4.9.2' . PHP_EOL;
     392        $report .= '    SDK Package Version: 4.9.2' . PHP_EOL;
    393393        $report .= '    Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL;
    394394
  • weareplanet/trunk/weareplanet-sdk/lib/Model/AbstractWebhookListenerUpdate.php

    r3673687 r3740659  
    4949      */
    5050    protected static $swaggerTypes = [
     51        'enable_payload_signature_and_state' => 'bool',
    5152        'entity_states' => 'string[]',
    5253        'name' => 'string',
    … …  
    6162      */
    6263    protected static $swaggerFormats = [
     64        'enable_payload_signature_and_state' => null,
    6365        'entity_states' => null,
    6466        'name' => null,
    … …  
    7476     */
    7577    protected static $attributeMap = [
     78        'enable_payload_signature_and_state' => 'enablePayloadSignatureAndState',
    7679        'entity_states' => 'entityStates',
    7780        'name' => 'name',
    … …  
    8689     */
    8790    protected static $setters = [
     91        'enable_payload_signature_and_state' => 'setEnablePayloadSignatureAndState',
    8892        'entity_states' => 'setEntityStates',
    8993        'name' => 'setName',
    … …  
    98102     */
    99103    protected static $getters = [
     104        'enable_payload_signature_and_state' => 'getEnablePayloadSignatureAndState',
    100105        'entity_states' => 'getEntityStates',
    101106        'name' => 'getName',
    … …  
    121126    public function __construct(?array $data = null)
    122127    {
     128
     129        $this->container['enable_payload_signature_and_state'] = isset($data['enable_payload_signature_and_state']) ? $data['enable_payload_signature_and_state'] : null;
    123130       
    124131        $this->container['entity_states'] = isset($data['entity_states']) ? $data['entity_states'] : null;
  • weareplanet/trunk/weareplanet-sdk/test/ApiClientTest.php

    r3673687 r3740659  
    145145
    146146        // Check SDK default header values.
    147         $this->assertEquals($headers['x-meta-sdk-version'], "4.9.1");
     147        $this->assertEquals($headers['x-meta-sdk-version'], "4.9.2");
    148148        $this->assertEquals($headers['x-meta-sdk-language'], 'php');
    149149        $this->assertEquals($headers['x-meta-sdk-provider'], "WeArePlanet");
  • weareplanet/trunk/weareplanet.php

    r3676036 r3740659  
    44 * Plugin URI: https://wordpress.org/plugins/woo-weareplanet
    55 * Description: Process WooCommerce payments with WeArePlanet.
    6  * Version: 3.4.8
     6 * Version: 3.4.9
    77 * Author: Planet Merchant Services Ltd
    88 * Author URI: https://www.weareplanet.com
    … …  
    1616 * License: Apache-2.0
    1717 * License URI: http://www.apache.org/licenses/LICENSE-2.0
     18 *
     19 * @package WeArePlanet
    1820 */
     21
    1922if ( ! defined( 'ABSPATH' ) ) {
    2023        exit(); // Exit if accessed directly.
    … …  
    4346                const WEAREPLANET_CK_DISABLE_PENDING_EMAIL = 'wc_weareplanet_disable_pending_email';
    4447                const WEAREPLANET_CK_ENABLE_CUSTOM_STATUS_MAPPING = 'wc_weareplanet_enable_custom_status_mapping';
    45                 const WEAREPLANET_UPGRADE_VERSION = '3.1.1';
    46                 const WC_MAXIMUM_VERSION = '11.0.1';
     48                const WEAREPLANET_UPGRADE_VERSION = '3.1.1'; // Leave this number alone! It was a fix for a problem introduced at this version.
     49                const WC_MAXIMUM_VERSION = '11.2.0';
    4750                const REQUIRED_WC_SUBSCRIPTION_VERSION = '2.5';
    4851
    … …  
    5255                 * @var string
    5356                 */
    54                 private $version = '3.4.8';
     57                private $version = '3.4.9';
    5558
    5659                /**
    … …  
    8992                }
    9093
     94                /**
     95                 * Define constant if not already set.
     96                 */
    9197                public function boot() {
    9298                        $this->init();
    9399                }
    94100
     101                /**
     102                 * Initialize the plugin.
     103                 */
    95104                private function init() {
    96105                        $this->includes();
    … …  
    159168                                array(
    160169                                        'WooCommerce_WeArePlanet',
    161                                         'migrate_plugin_data_on_activation'
     170                                        'migrate_plugin_data_on_activation',
    162171                                )
    163172                        );
    … …  
    393402                 */
    394403                public static function get_installed_plugin_version( $plugin_slug ) {
    395                         if (!function_exists( 'get_plugins' ) ) {
     404                        if ( ! function_exists( 'get_plugins' ) ) {
    396405                                require_once ABSPATH . 'wp-admin/includes/plugin.php';
    397406                        }
    … …  
    400409                        foreach ( $all_plugins as $plugin_path => $plugin_info ) {
    401410                                if ( strpos( $plugin_path, $plugin_slug ) !== false ) {
    402                                         return $plugin_info[ 'Version' ];
     411                                        return $plugin_info['Version'];
    403412                                }
    404413                        }
    … …  
    457466
    458467                        global $wpdb;
    459                         $options_to_migrate = [
     468                        $options_to_migrate = array(
    460469                                $old_option_prefix . WC_WeArePlanet_Migration::WEAREPLANET_CK_DB_VERSION,
    461470                                $old_option_prefix . WC_WeArePlanet_Service_Manual_Task::WEAREPLANET_CONFIG_KEY,
    … …  
    472481                                $old_option_prefix . self::WEAREPLANET_CK_CHANGE_ORDER_STATUS,
    473482                                $old_option_prefix . self::WC_MAXIMUM_VERSION,
    474                         ];
     483                        );
    475484
    476485                        // If the old plugin options exist, perform the migration.
    … …  
    487496                                                add_option( $new_option_name, $option_value );
    488497                                        }
    489                                         // Delete the old option.
    490                                         //delete_option( $option_name );.
     498                                        // Delete the old option: delete_option( $option_name );.
    491499                                }
    492500                        }
    … …  
    498506                 *
    499507                 * @param object $upgrader_object The upgrader object.
    500                  * @param array $options The options array.
     508                 * @param array  $options The options array.
    501509                 */
    502510                public static function migrate_plugin_data_after_update( $upgrader_object, $options ) {
    … …  
    530538
    531539                        // WordPress.org will auto-load translations. No need to call load_plugin_textdomain().
    532                         // $this->load_plugin_textdomain();
    533                         add_action('plugins_loaded', function () {
    534                                 if (class_exists('WC_Payment_Gateway')) {
    535                                         require_once WC_WEAREPLANET_ABSPATH . 'includes/class-wc-weareplanet-zero-gateway.php';
    536                                         add_filter(
    537                                           'woocommerce_payment_gateways',
    538                                           array(
    539                                                 WooCommerce_WeArePlanet::instance(),
    540                                                 'add_gateways',
    541                                           )
    542                                         );
    543                                 }
    544                         }, 20);
     540                        // $this->load_plugin_textdomain();.
     541                        add_action(
     542                                'plugins_loaded',
     543                                function () {
     544                                        if ( class_exists( 'WC_Payment_Gateway' ) ) {
     545                                                require_once WC_WEAREPLANET_ABSPATH . 'includes/class-wc-weareplanet-zero-gateway.php';
     546                                                add_filter(
     547                                                        'woocommerce_payment_gateways',
     548                                                        array(
     549                                                                WooCommerce_WeArePlanet::instance(),
     550                                                                'add_gateways',
     551                                                        )
     552                                                );
     553                                        }
     554                                },
     555                                20
     556                        );
    545557                        add_action(
    546558                                'plugins_loaded',
    … …  
    603615                        add_filter(
    604616                                'woocommerce_cart_needs_payment',
    605                                 function($value, $object) {
     617                                function ( $value, $object ) {
    606618                                        return true;
    607                                 }, 10, 2
     619                                },
     620                                10,
     621                                2
    608622                        );
    609623                        add_filter(
    610                                 'woocommerce_order_needs_payment',
    611                                 function($value, $order) {
     624                                'woocommerce_order_needs_payment',
     625                                function ( $value, $order ) {
    612626                                        $order_data = $order->get_data();
    613                                         if (substr_count($order_data['payment_method'], "weareplanet")) {
     627                                        if ( substr_count( $order_data['payment_method'], 'weareplanet' ) ) {
    614628                                                // If the order is using our payment method, we want to process it
    615629                                                // even if the value of the transaction is 0, which woocommerce by default
    616630                                                // process it without payment gateway.
    617631                                                $transaction_info = WC_WeArePlanet_Entity_Transaction_Info::load_by_order_id( $order->get_id() );
    618                                                 if ( in_array(
    619                                                   $transaction_info->get_state(),
    620                                                   array(
    621                                                         \WeArePlanet\Sdk\Model\TransactionState::FULFILL,
    622                                                         \WeArePlanet\Sdk\Model\TransactionState::AUTHORIZED,
    623                                                         \WeArePlanet\Sdk\Model\TransactionState::COMPLETED,
    624                                                         \WeArePlanet\Sdk\Model\TransactionState::FAILED,
    625                                                         \WeArePlanet\Sdk\Model\TransactionState::DECLINE,
    626                                                   ),
    627                                                   true
    628                                                 ) ) {
     632                                                if (
     633                                                        in_array(
     634                                                                $transaction_info->get_state(),
     635                                                                array(
     636                                                                        \WeArePlanet\Sdk\Model\TransactionState::FULFILL,
     637                                                                        \WeArePlanet\Sdk\Model\TransactionState::AUTHORIZED,
     638                                                                        \WeArePlanet\Sdk\Model\TransactionState::COMPLETED,
     639                                                                        \WeArePlanet\Sdk\Model\TransactionState::FAILED,
     640                                                                        \WeArePlanet\Sdk\Model\TransactionState::DECLINE,
     641                                                                ),
     642                                                                true
     643                                                        )
     644                                                ) {
    629645                                                        return false;
    630646                                                }
    … …  
    632648                                        }
    633649                                        return $value;
    634                                 }, 10, 2
     650                                },
     651                                10,
     652                                2
    635653                        );
    636654                        add_action(
    … …  
    772790                        );
    773791
    774                         add_filter('the_content', function($content) {
    775                                 if ( is_checkout() && ! is_order_received_page() ) {
    776                                         // When in checkout, we inject the list of payment methods in the HTML.
    777                                         // The goal here is to speed up the process of registering the payment methods.
    778                                         $payment_methods = WC_WeArePlanet_Blocks_Support::get_payment_methods();
    779                                         $json_data = json_encode( $payment_methods );
    780                                         $content .= '<div id="weareplanet-payment-methods" data-json="' . esc_attr( $json_data ) . '"></div>';
    781                                 }
    782 
    783                                 return $content;
    784                         });
     792                        add_filter(
     793                                'the_content',
     794                                function ( $content ) {
     795                                        if ( is_checkout() && ! is_order_received_page() ) {
     796                                                // When in checkout, we inject the list of payment methods in the HTML.
     797                                                // The goal here is to speed up the process of registering the payment methods.
     798                                                $payment_methods = WC_WeArePlanet_Blocks_Support::get_payment_methods();
     799                                                $json_data = json_encode( $payment_methods );
     800                                                $content .= '<div id="weareplanet-payment-methods" data-json="' . esc_attr( $json_data ) . '"></div>';
     801                                        }
     802
     803                                        return $content;
     804                                }
     805                        );
    785806                }
    786807
    … …  
    806827                 * @return bool
    807828                 */
    808                 public static function is_subscriptions_compatible(): bool  {
     829                public static function is_subscriptions_compatible(): bool {
    809830                        $plugin_name = 'woocommerce-subscriptions.php';
    810831                        $woocommerce_subscriptions_directory = self::find_plugin_path( $plugin_name );
    … …  
    825846                 * Looks for legacy subscription plugin's directory.
    826847                 *
     848                 * @param string $plugin_name The plugin file name to search for.
    827849                 * @return string|null
    828850                 */
    … …  
    867889                }
    868890
    869         /**
    870         * Register order statuses.
    871         *
    872         * @return void
    873         */
    874         public function register_order_statuses() {
    875                 $common_args = array(
    876                         'public' => true,
    877                         'exclude_from_search' => false,
    878                         'show_in_admin_all_list' => true,
    879                         'show_in_admin_status_list' => true,
    880                 );
    881 
    882                 register_post_status(
    883                         'wc-wearep-redirected',
    884                         array_merge(
     891                /**
     892                * Register order statuses.
     893                *
     894                * @return void
     895                */
     896                public function register_order_statuses() {
     897                        $common_args = array(
     898                                'public' => true,
     899                                'exclude_from_search' => false,
     900                                'show_in_admin_all_list' => true,
     901                                'show_in_admin_status_list' => true,
     902                        );
     903
     904                        register_post_status(
     905                                'wc-wearep-redirected',
     906                                array_merge(
    885907                                        $common_args,
    886908                                        array(
    … …  
    918940                 * Add order statuses.
    919941                 *
    920         * @param mixed $order_statuses order statuses.
    921         * @return mixed
    922         */
    923         public function add_order_statuses( $order_statuses ) {
    924                 $order_statuses['wc-wearep-redirected'] = _x( 'Redirected', 'Order status', 'woo-weareplanet' );
    925                 $order_statuses['wc-wearep-waiting'] = _x( 'Waiting', 'Order status', 'woo-weareplanet' );
    926                 $order_statuses['wc-wearep-manual'] = _x( 'Manual Decision', 'Order status', 'woo-weareplanet' );
    927 
    928                 return $order_statuses;
     942                * @param mixed $order_statuses order statuses.
     943                * @return mixed
     944                */
     945                public function add_order_statuses( $order_statuses ) {
     946                        $order_statuses['wc-wearep-redirected'] = _x( 'Redirected', 'Order status', 'woo-weareplanet' );
     947                        $order_statuses['wc-wearep-waiting'] = _x( 'Waiting', 'Order status', 'woo-weareplanet' );
     948                        $order_statuses['wc-wearep-manual'] = _x( 'Manual Decision', 'Order status', 'woo-weareplanet' );
     949
     950                        return $order_statuses;
    929951                }
    930952
    … …  
    936958                 * @return mixed
    937959                 */
    938         public function valid_order_statuses_for_payment( $statuses, $order = null ) { //phpcs:ignore
    939                 if ( WC_WeArePlanet_Helper::is_custom_status_mapping_enabled() ) {
    940                         $statuses[] = 'wearep-redirected';
    941                 }
    942 
    943                 return $statuses;
    944         }
     960                public function valid_order_statuses_for_payment( $statuses, $order = null ) { //phpcs:ignore
     961                        if ( WC_WeArePlanet_Helper::is_custom_status_mapping_enabled() ) {
     962                                $statuses[] = 'wearep-redirected';
     963                        }
     964
     965                        return $statuses;
     966                }
    945967
    946968                /**
    … …  
    964986                        }
    965987
    966                         // Sanitize input properly.
    967                         $changes = sanitize_text_field( wp_unslash( $_POST['changes'] ) );
     988                        // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- $_POST['changes'] array is unslashed with wp_unslash(). We sanitize each field individually with array_map( 'sanitize_text_field' ) and sanitize_key() below.
     989                        $changes = wp_unslash( $_POST['changes'] );
    968990
    969991                        // Get the first key inside the 'changes' array.
    970992                        $first_key = key( $changes );
    971                         $data = $_POST['changes'][$first_key];
     993                        if ( ! isset( $changes[ $first_key ] ) || ! is_array( $changes[ $first_key ] ) ) {
     994                                wp_send_json_error( 'invalid_data' );
     995                                wp_die();
     996                        }
     997                        $raw_data = $changes[ $first_key ];
     998                        $data = array_map( 'sanitize_text_field', $raw_data );
     999                        $first_key = sanitize_key( $first_key );
    9721000
    9731001                        if ( isset( $data['key'] ) ) {
    974                                 $label = str_replace( ['-', '_'], ' ', sanitize_text_field( $data['key'] ) );
     1002                                $label = str_replace( array( '-', '_' ), ' ', sanitize_text_field( $data['key'] ) );
    9751003
    9761004                                // Normalize the key by replacing spaces and dashes with underscores.
    977                                 $sanitized_key_underscore = str_replace( [' ', '-'], '_', WC_WeArePlanet_Order_Status_Adapter::WEAREPLANET_CUSTOM_ORDER_STATUS_PREFIX . $first_key );
    978                                 $sanitized_key_hyphen = str_replace( [' ', '_'], '-', $first_key );
     1005                                $sanitized_key_underscore = str_replace( array( '-', '_' ), '_', WC_WeArePlanet_Order_Status_Adapter::WEAREPLANET_CUSTOM_ORDER_STATUS_PREFIX . $first_key );
     1006                                $sanitized_key_hyphen = str_replace( array( ' ', '_' ), '-', $first_key );
    9791007
    9801008                                // Construct the full option name with the required prefix.
    … …  
    9841012                                update_option( $custom_order_name, $custom_order_value );
    9851013
    986                                 register_post_status( $custom_order_value, array(
    987                                         'label' => $label,
    988                                         'public' => true,
    989                                         'show_in_admin_status_list' => true,
    990                                         'show_in_admin_all_list' => true,
    991                                         'exclude_from_search' => false,
    992                                         'label_count' => array(
    993                                                 'singular' => sprintf( '%s <span class="count">(%s)</span>', $label, '%s' ),
    994                                                 'plural'   => sprintf( '%s <span class="count">(%s)</span>', $label, '%s' ),
     1014                                wp_cache_delete( 'weareplanet_custom_order_statuses', 'weareplanet' );
     1015
     1016                                register_post_status(
     1017                                        $custom_order_value,
     1018                                        array(
     1019                                                'label' => $label,
     1020                                                'public' => true,
     1021                                                'show_in_admin_status_list' => true,
     1022                                                'show_in_admin_all_list' => true,
     1023                                                'exclude_from_search' => false,
     1024                                                'label_count' => array(
     1025                                                        'singular' => sprintf( '%s <span class="count">(%s)</span>', $label, '%s' ),
     1026                                                        'plural'   => sprintf( '%s <span class="count">(%s)</span>', $label, '%s' ),
     1027                                                )
    9951028                                        )
    996                                 ) );
     1029                                );
    9971030
    9981031                                // Send a success response with the saved order status details.
    999                                 wp_send_json_success([
    1000                                         'message'      => 'Success',
    1001                                         'order_status' => [
    1002                                                 'key'   => $custom_order_value,  // The full key with the prefix.
    1003                                                 'label' => ucfirst( $label ), // As received from the form data.
    1004                                                 'type'  => __( 'custom' , 'woo-weareplanet' )
    1005                                         ]
    1006                                 ]);
     1032                                wp_send_json_success(
     1033                                        array(
     1034                                                'message' => 'Success',
     1035                                                'order_status' => array(
     1036                                                        'key' => $custom_order_value,  // The full key with the prefix.
     1037                                                        'label' => ucfirst( $label ), // As received from the form data.
     1038                                                        'type' => __( 'custom', 'woo-weareplanet' ),
     1039                                                ),
     1040                                        )
     1041                                );
    10071042                        } else {
    10081043                                wp_send_json_error( 'invalid_data' );
    … …  
    10331068
    10341069                        $sanitized_key = sanitize_text_field( wp_unslash( $_POST['key'] ) );
    1035 
    1036                         // Check if this order status is being used in wp_options with key prefix "weareplanet_order_status_mapping_".
    1037                         $like_pattern = WC_WeArePlanet_Order_Status_Adapter::WEAREPLANET_ORDER_STATUS_MAPPING_PREFIX . '%';
    1038                         $is_used = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->options} WHERE option_name LIKE %s AND option_value = %s", $like_pattern, $sanitized_key ) );
     1070                        $cache_group = 'weareplanet';
     1071
     1072                        $is_used_cache_key = 'weareplanet_status_in_use_' . md5( $sanitized_key );
     1073                        $is_used = wp_cache_get( $is_used_cache_key, $cache_group );
     1074
     1075                        if ( $is_used === false ) {
     1076                                // Check if this order status is being used in wp_options with key prefix "weareplanet_order_status_mapping_".
     1077                                $like_pattern = WC_WeArePlanet_Order_Status_Adapter::WEAREPLANET_ORDER_STATUS_MAPPING_PREFIX . '%';
     1078                                // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
     1079                                $is_used = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->options} WHERE option_name LIKE %s AND option_value = %s", $like_pattern, $sanitized_key ) );
     1080                                wp_cache_set( $is_used_cache_key, $is_used, $cache_group, HOUR_IN_SECONDS );
     1081                        }
    10391082
    10401083                        if ( $is_used > 0 ) {
    10411084                                // The status is in use, so do not delete it.
    1042                                 wp_send_json_error( ['message' => __( 'Cannot delete: this status is currently in use.', 'woo-weareplanet' ), 'key' => ucfirst( $sanitized_key )], 400 );
    1043                         }
    1044 
    1045                          // Get the custom order status in wp_options with key prefix "weareplanet_order_status_mapping_".
    1046                         $like_pattern = WC_WeArePlanet_Order_Status_Adapter::WEAREPLANET_CUSTOM_ORDER_STATUS_PREFIX . '%';
    1047                         $custom_order_status_name = $wpdb->get_var( $wpdb->prepare( "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE %s AND option_value = %s", $like_pattern, $sanitized_key ) );
     1085                                wp_send_json_error(
     1086                                        array(
     1087                                                'message' => __( 'Cannot delete: this status is currently in use.', 'woo-weareplanet' ),
     1088                                                'key' => ucfirst( $sanitized_key ),
     1089                                        ),
     1090                                        400
     1091                                );
     1092                        }
     1093
     1094                        $option_name_cache_key = 'weareplanet_status_option_name_' . md5( $sanitized_key );
     1095                        $custom_order_status_name = wp_cache_get( $option_name_cache_key, $cache_group );
     1096
     1097                        if ( $custom_order_status_name === false ) {
     1098                                // Get the custom order status in wp_options with key prefix "weareplanet_order_status_mapping_".
     1099                                $like_pattern = WC_WeArePlanet_Order_Status_Adapter::WEAREPLANET_CUSTOM_ORDER_STATUS_PREFIX . '%';
     1100                                // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
     1101                                $custom_order_status_name = $wpdb->get_var( $wpdb->prepare( "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE %s AND option_value = %s", $like_pattern, $sanitized_key ) );
     1102                                wp_cache_set( $option_name_cache_key, $custom_order_status_name, $cache_group, HOUR_IN_SECONDS );
     1103                        }
    10481104
    10491105                        // Remove from wp_options.
    10501106                        delete_option( $custom_order_status_name );
    10511107
     1108                        wp_cache_delete( $is_used_cache_key, $cache_group );
     1109                        wp_cache_delete( $option_name_cache_key, $cache_group );
     1110                        wp_cache_delete( 'weareplanet_custom_order_statuses', $cache_group );
     1111
    10521112                        // Return success response.
    1053                         wp_send_json_success( ['message' => __( 'Deleted successfully', 'woo-weareplanet' ), 'key' => ucfirst( $sanitized_key )] );
     1113                        wp_send_json_success(
     1114                                array(
     1115                                        'message' => __( 'Deleted successfully', 'woo-weareplanet' ),
     1116                                        'key' => ucfirst( $sanitized_key ),
     1117                                )
     1118                        );
    10541119                }
    10551120
    … …  
    10601125                 */
    10611126                public function set_device_id_cookie() {
    1062                         if(!headers_sent()) {
     1127                        if ( ! headers_sent() ) {
    10631128                                $value = WC_WeArePlanet_Unique_Id::get_uuid();
    10641129                                if ( isset( $_COOKIE['wc_weareplanet_device_id'] ) && ! empty( $_COOKIE['wc_weareplanet_device_id'] ) ) {
    … …  
    11221187                 * @return false|mixed
    11231188                 */
    1124                 public function order_editable_check( $allowed, WC_Order $order = null ) {
     1189                public function order_editable_check( $allowed, ?WC_Order $order = null ) {
    11251190                        if ( is_null( $order ) ) {
    11261191                                return $allowed;
    … …  
    11391204                 * @return mixed
    11401205                 */
    1141                 public function valid_order_status_for_completion( $statuses, WC_Order $order = null ) { //phpcs:ignore
     1206                public function valid_order_status_for_completion( $statuses, ?WC_Order $order = null ) { //phpcs:ignore
    11421207                        if ( WC_WeArePlanet_Helper::is_custom_status_mapping_enabled() ) {
    11431208                                $statuses[] = 'wearep-waiting';
    … …  
    11921257                                foreach ( $method_configurations as $configuration ) {
    11931258                                        $gateway = new WC_WeArePlanet_Gateway( $configuration );
    1194                                         $methods[] = apply_filters('wc_weareplanet_enhance_gateway', $gateway);
     1259                                        $methods[] = apply_filters( 'wc_weareplanet_enhance_gateway', $gateway );
    11951260                                }
    11961261                        } catch ( \WeArePlanet\Sdk\ApiException $e ) {
    … …  
    13521417                 */
    13531418                public function register_checkout_error_msg() {
    1354                         if ( ! isset( WC()->session ) ) return false;
     1419                        if ( ! isset( WC()->session ) ) {
     1420                                return false;
     1421                        }
    13551422                        $msg = WC()->session->get( 'weareplanet_failure_message', null );
    13561423                        if ( ! empty( $msg ) ) {
    … …  
    13801447                 */
    13811448                protected function define( $name, $value ) {
     1449                        // phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.VariableConstantNameFound -- $name is a local, not a global parameter
    13821450                        if ( ! defined( $name ) ) {
    13831451                                define( $name, $value );
    13841452                        }
     1453                        // phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.VariableConstantNameFound
    13851454                }
    13861455
    … …  
    15881657        }
    15891658
    1590         add_action( 'woocommerce_loaded', function () {
    1591                 WooCommerce_WeArePlanet::instance()->boot();
    1592                 add_action( 'woocommerce_blocks_loaded', 'WC_WeArePlanet_Blocks_Support' );
    1593         });
     1659        add_action(
     1660                'woocommerce_loaded',
     1661                function () {
     1662                        WooCommerce_WeArePlanet::instance()->boot();
     1663                        add_action( 'woocommerce_blocks_loaded', 'WC_WeArePlanet_Blocks_Support' );
     1664                }
     1665        );
    15941666
    15951667        function WC_WeArePlanet_Blocks_Support() { //phpcs:ignore
Note: See TracChangeset for help on using the changeset viewer.