Plugin Directory

Changeset 3483127


Ignore:
Timestamp:
03/15/2026 01:59:45 PM (2 weeks ago)
Author:
shipdayinc
Message:

Update to version 2.3.0 - Wordpress feedback resolved

Location:
shipday-for-woocommerce/trunk
Files:
6 added
8 deleted
44 edited

Legend:

Unmodified
Added
Removed
  • shipday-for-woocommerce/trunk/admin/Shipday_Menu_Settings.php

    r3419924 r3483127  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) {
     4    exit;
     5}
    26require_once dirname(__FILE__). '/../rest_api/WooCommerce_REST_API.php';
    37
    48class Shipday_Menu_Settings {
     9    private static $allowed_order_managers = array( 'admin_manage', 'vendor_manage' );
     10    private static $allowed_week_days = array( '0', '1', '2', '3', '4', '5', '6' );
     11    private static $allowed_slot_durations = array( '10', '15', '30', '45', '60', '90', '120', '150', '180', '240', '300', '360' );
     12
    513    public static function initialize() {
    614        add_action( 'admin_enqueue_scripts',[ __CLASS__, 'enqueue_styles' ] );
     
    4654
    4755        add_menu_page(
    48             __('Shipday', 'shipday-delivery'),
    49             __('Shipday', 'shipday-delivery'),
     56            __('Shipday', 'shipday-for-woocommerce'),
     57            __('Shipday', 'shipday-for-woocommerce'),
    5058            'manage_options',
    5159            'shipday-delivery-settings',
     
    6876    }
    6977
     78    private static function ensure_settings_access() {
     79        if ( ! current_user_can( 'manage_options' ) ) {
     80            wp_send_json_error( array( 'message' => 'Unauthorized' ), 403 );
     81        }
     82    }
     83
     84    private static function get_form_data_from_request() {
     85        // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Nonce is verified in each AJAX handler before this helper runs.
     86        if ( ! isset( $_POST['formData'] ) || ! is_string( $_POST['formData'] ) ) {
     87            wp_send_json_error( array( 'message' => 'Invalid form data.' ), 400 );
     88        }
     89
     90        $form_data = array();
     91        // phpcs:ignore WordPress.Security.NonceVerification.Missing,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Serialized form payload is unslashed here and each parsed field is sanitized individually before use.
     92        parse_str( wp_unslash( $_POST['formData'] ), $form_data );
     93
     94        return is_array( $form_data ) ? $form_data : array();
     95    }
     96
     97    private static function sanitize_yes_no_flag( $is_enabled ) {
     98        return $is_enabled ? 'yes' : 'no';
     99    }
     100
     101    private static function sanitize_allowed_value( $value, $allowed_values, $default ) {
     102        $value = sanitize_text_field( (string) $value );
     103
     104        return in_array( $value, $allowed_values, true ) ? $value : $default;
     105    }
     106
     107    private static function sanitize_day_list( $days ) {
     108        if ( ! is_array( $days ) ) {
     109            return array();
     110        }
     111
     112        $sanitized_days = array();
     113        foreach ( $days as $day ) {
     114            $day = sanitize_text_field( (string) $day );
     115            if ( in_array( $day, self::$allowed_week_days, true ) ) {
     116                $sanitized_days[] = $day;
     117            }
     118        }
     119
     120        return array_values( array_unique( $sanitized_days ) );
     121    }
     122
     123    private static function sanitize_positive_int( $value, $default ) {
     124        $value = absint( $value );
     125
     126        return $value > 0 ? $value : $default;
     127    }
     128
     129    private static function sanitize_time_slot( $hour, $minute, $ampm ) {
     130        $hour = max( 1, min( 12, absint( $hour ) ) );
     131        $minute = max( 0, min( 59, absint( $minute ) ) );
     132        $ampm = self::sanitize_allowed_value( $ampm, array( 'AM', 'PM' ), 'AM' );
     133
     134        return array(
     135            'hh'   => str_pad( (string) $hour, 2, '0', STR_PAD_LEFT ),
     136            'mm'   => str_pad( (string) $minute, 2, '0', STR_PAD_LEFT ),
     137            'ampm' => $ampm,
     138        );
     139    }
    70140
    71141    public static function save_connect_settings() {
    72142        check_ajax_referer('shipday_nonce');
    73 
    74         parse_str( $_POST[ 'formData' ], $form_data );
    75         $api_key = sanitize_text_field($form_data['shipday_api_key']);
    76         $enable_pickup = !isset($form_data['wc_settings_tab_shipday_enable_pickup']) ? "no" : "yes";
    77         $enable_prev_order_sync = isset($form_data['wc_settings_tab_shipday_sync']) ? "yes" : "no";
    78 
    79         $order_manage = !isset($form_data['wc_settings_tab_shipday_order_manage']) ? "admin_manage" : $form_data['wc_settings_tab_shipday_order_manage'];
     143        self::ensure_settings_access();
     144
     145        $form_data = self::get_form_data_from_request();
     146        $api_key = isset( $form_data['shipday_api_key'] ) ? sanitize_text_field( $form_data['shipday_api_key'] ) : '';
     147        $enable_pickup = self::sanitize_yes_no_flag( isset( $form_data['wc_settings_tab_shipday_enable_pickup'] ) );
     148        $enable_prev_order_sync = self::sanitize_yes_no_flag( isset( $form_data['wc_settings_tab_shipday_sync'] ) );
     149        $order_manage = isset( $form_data['wc_settings_tab_shipday_order_manage'] )
     150            ? self::sanitize_allowed_value( $form_data['wc_settings_tab_shipday_order_manage'], self::$allowed_order_managers, 'admin_manage' )
     151            : 'admin_manage';
    80152
    81153        update_option('wc_settings_tab_shipday_enable_pickup', $enable_pickup);
     
    90162    public static function save_rest_api_settings() {
    91163        check_ajax_referer('shipday_nonce');
    92 
    93         parse_str( $_POST[ 'formData' ], $form_data );
    94         $consumer_key = sanitize_text_field($form_data['shipday_consumer_key']);
    95         $consumer_secret = sanitize_text_field($form_data['shipday_consumer_secret']);
     164        self::ensure_settings_access();
     165
     166        $form_data = self::get_form_data_from_request();
     167        $consumer_key = isset( $form_data['shipday_consumer_key'] ) ? sanitize_text_field( $form_data['shipday_consumer_key'] ) : '';
     168        $consumer_secret = isset( $form_data['shipday_consumer_secret'] ) ? sanitize_text_field( $form_data['shipday_consumer_secret'] ) : '';
    96169
    97170        update_option('wc_settings_tab_shipday_rest_api_consumer_key', $consumer_key);
     
    107180    public static function save_general_settings() {
    108181        check_ajax_referer('shipday_nonce');
    109 
    110         parse_str( $_POST[ 'formData' ], $form_data );
    111         $enable_datetime =  !isset($form_data['shipday_enable_datetime_plugin']) ? "no" : "yes";
    112         $enable_order_type = !isset($form_data['shipday_enable_delivery_option']) ? "no" : "yes";
     182        self::ensure_settings_access();
     183
     184        $form_data = self::get_form_data_from_request();
     185        $enable_datetime = self::sanitize_yes_no_flag( isset( $form_data['shipday_enable_datetime_plugin'] ) );
     186        $enable_order_type = self::sanitize_yes_no_flag( isset( $form_data['shipday_enable_delivery_option'] ) );
    113187
    114188        update_option('shipday_enable_datetime_plugin', $enable_datetime);
    115189        update_option('shipday_enable_delivery_option', $enable_order_type);
    116         if(isset($form_data['shipday_delivery_pickup_label']))
    117             update_option('shipday_delivery_pickup_label', $form_data['shipday_delivery_pickup_label']);
     190        if ( isset( $form_data['shipday_delivery_pickup_label'] ) ) {
     191            update_option( 'shipday_delivery_pickup_label', sanitize_text_field( $form_data['shipday_delivery_pickup_label'] ) );
     192        }
    118193
    119194        if($enable_datetime === "no"){
     
    138213    public static function save_delivery_settings() {
    139214        check_ajax_referer('shipday_nonce');
    140 
    141         parse_str( $_POST[ 'formData' ], $form_data );
    142 
    143         $enable_delivery_date =  !isset($form_data['shipday_enable_delivery_date']) ? "no" : "yes";
    144         $delivery_date_mandatory = !isset($form_data['shipday_delivery_date_mandatory']) ? "no" : "yes";
    145         $available_days_ = !isset($form_data['shipday_avaialble_delivery_days'])? [] : array_map('strval', $form_data['shipday_avaialble_delivery_days']);
    146 
    147         $start_delivery_slot = [];
    148         $start_delivery_slot['hh'] = $form_data['shipday_delivery_time_slot_start_hh'];
    149         $start_delivery_slot['mm'] = $form_data['shipday_delivery_time_slot_start_mm'];
    150         $start_delivery_slot['ampm'] = $form_data['shipday_delivery_time_slot_start_ampm'];
    151 
    152         $enable_delivery_time =  !isset($form_data['shipday_enable_delivery_time']) ? "no" : "yes";
    153         $delivery_time_mandatory = !isset($form_data['shipday_delivery_time_mandatory']) ? "no" : "yes";
    154 
    155         $end_delivery_slot = [];
    156         $end_delivery_slot['hh'] = $form_data['shipday_delivery_time_slot_end_hh'];
    157         $end_delivery_slot['mm'] = $form_data['shipday_delivery_time_slot_end_mm'];
    158         $end_delivery_slot['ampm'] = $form_data['shipday_delivery_time_slot_end_ampm'];
     215        self::ensure_settings_access();
     216
     217        $form_data = self::get_form_data_from_request();
     218
     219        $enable_delivery_date = self::sanitize_yes_no_flag( isset( $form_data['shipday_enable_delivery_date'] ) );
     220        $delivery_date_mandatory = self::sanitize_yes_no_flag( isset( $form_data['shipday_delivery_date_mandatory'] ) );
     221        $available_days_ = isset( $form_data['shipday_avaialble_delivery_days'] )
     222            ? self::sanitize_day_list( $form_data['shipday_avaialble_delivery_days'] )
     223            : array();
     224        $start_delivery_slot = self::sanitize_time_slot(
     225            $form_data['shipday_delivery_time_slot_start_hh'] ?? 9,
     226            $form_data['shipday_delivery_time_slot_start_mm'] ?? 0,
     227            $form_data['shipday_delivery_time_slot_start_ampm'] ?? 'AM'
     228        );
     229        $enable_delivery_time = self::sanitize_yes_no_flag( isset( $form_data['shipday_enable_delivery_time'] ) );
     230        $delivery_time_mandatory = self::sanitize_yes_no_flag( isset( $form_data['shipday_delivery_time_mandatory'] ) );
     231        $end_delivery_slot = self::sanitize_time_slot(
     232            $form_data['shipday_delivery_time_slot_end_hh'] ?? 9,
     233            $form_data['shipday_delivery_time_slot_end_mm'] ?? 0,
     234            $form_data['shipday_delivery_time_slot_end_ampm'] ?? 'AM'
     235        );
     236        $selectable_delivery_days = self::sanitize_positive_int( $form_data['shipday_selectable_delivery_days'] ?? 30, 30 );
     237        $delivery_slot_duration = self::sanitize_allowed_value(
     238            $form_data['shipday_delivery_time_slot_duration'] ?? '60',
     239            self::$allowed_slot_durations,
     240            '60'
     241        );
    159242
    160243        update_option('shipday_enable_delivery_date', $enable_delivery_date);
    161244        update_option('shipday_delivery_date_mandatory', $delivery_date_mandatory);
    162245        update_option('shipday_avaialble_delivery_days',  $available_days_);
    163         update_option('shipday_selectable_delivery_days', $form_data['shipday_selectable_delivery_days']);
     246        update_option('shipday_selectable_delivery_days', $selectable_delivery_days);
    164247
    165248        update_option('shipday_enable_delivery_time', $enable_delivery_time);
     
    169252        update_option('shipday_delivery_time_slot_start',  $start_delivery_slot);
    170253        update_option('shipday_delivery_time_slot_end',  $end_delivery_slot);
    171         update_option('shipday_delivery_time_slot_duration',  $form_data['shipday_delivery_time_slot_duration']);
     254        update_option('shipday_delivery_time_slot_duration',  $delivery_slot_duration);
    172255
    173256        wp_send_json_success();
     
    177260    public static function save_pickup_settings() {
    178261        check_ajax_referer('shipday_nonce');
    179 
    180         parse_str( $_POST[ 'formData' ], $form_data );
    181 
    182         $enable_pickup_date =  !isset($form_data['shipday_enable_pickup_date']) ? "no" : "yes";
    183         $pickup_date_mandatory = !isset($form_data['shipday_pickup_date_mandatory']) ? "no" : "yes";
    184         $available_days_ = !isset($form_data['shipday_avaialble_pickup_days'])? [] : array_map('strval', $form_data['shipday_avaialble_pickup_days']);
    185 
    186         $start_pickup_slot = [];
    187         $start_pickup_slot['hh'] = $form_data['shipday_pickup_time_slot_start_hh'];
    188         $start_pickup_slot['mm'] = $form_data['shipday_pickup_time_slot_start_mm'];
    189         $start_pickup_slot['ampm'] = $form_data['shipday_pickup_time_slot_start_ampm'];
    190 
    191         $enable_pickup_time =  !isset($form_data['shipday_enable_pickup_time']) ? "no" : "yes";
    192         $pickup_time_mandatory = !isset($form_data['shipday_pickup_time_mandatory']) ? "no" : "yes";
    193 
    194         $end_pickup_slot = [];
    195         $end_pickup_slot['hh'] = $form_data['shipday_pickup_time_slot_end_hh'];
    196         $end_pickup_slot['mm'] = $form_data['shipday_pickup_time_slot_end_mm'];
    197         $end_pickup_slot['ampm'] = $form_data['shipday_pickup_time_slot_end_ampm'];
     262        self::ensure_settings_access();
     263
     264        $form_data = self::get_form_data_from_request();
     265
     266        $enable_pickup_date = self::sanitize_yes_no_flag( isset( $form_data['shipday_enable_pickup_date'] ) );
     267        $pickup_date_mandatory = self::sanitize_yes_no_flag( isset( $form_data['shipday_pickup_date_mandatory'] ) );
     268        $available_days_ = isset( $form_data['shipday_avaialble_pickup_days'] )
     269            ? self::sanitize_day_list( $form_data['shipday_avaialble_pickup_days'] )
     270            : array();
     271        $start_pickup_slot = self::sanitize_time_slot(
     272            $form_data['shipday_pickup_time_slot_start_hh'] ?? 9,
     273            $form_data['shipday_pickup_time_slot_start_mm'] ?? 0,
     274            $form_data['shipday_pickup_time_slot_start_ampm'] ?? 'AM'
     275        );
     276        $enable_pickup_time = self::sanitize_yes_no_flag( isset( $form_data['shipday_enable_pickup_time'] ) );
     277        $pickup_time_mandatory = self::sanitize_yes_no_flag( isset( $form_data['shipday_pickup_time_mandatory'] ) );
     278        $end_pickup_slot = self::sanitize_time_slot(
     279            $form_data['shipday_pickup_time_slot_end_hh'] ?? 9,
     280            $form_data['shipday_pickup_time_slot_end_mm'] ?? 0,
     281            $form_data['shipday_pickup_time_slot_end_ampm'] ?? 'AM'
     282        );
     283        $selectable_pickup_days = self::sanitize_positive_int( $form_data['shipday_selectable_pickup_days'] ?? 30, 30 );
     284        $pickup_slot_duration = self::sanitize_allowed_value(
     285            $form_data['shipday_pickup_time_slot_duration'] ?? '60',
     286            self::$allowed_slot_durations,
     287            '60'
     288        );
    198289
    199290        update_option('shipday_enable_pickup_date', $enable_pickup_date);
    200291        update_option('shipday_pickup_date_mandatory', $pickup_date_mandatory);
    201292        update_option('shipday_avaialble_pickup_days',  $available_days_);
    202         update_option('shipday_selectable_pickup_days', $form_data['shipday_selectable_pickup_days']);
     293        update_option('shipday_selectable_pickup_days', $selectable_pickup_days);
    203294
    204295        update_option('shipday_enable_pickup_time', $enable_pickup_time);
     
    206297        update_option('shipday_pickup_time_slot_start',  $start_pickup_slot);
    207298        update_option('shipday_pickup_time_slot_end',  $end_pickup_slot);
    208         update_option('shipday_pickup_time_slot_duration',  $form_data['shipday_pickup_time_slot_duration']);
     299        update_option('shipday_pickup_time_slot_duration',  $pickup_slot_duration);
    209300
    210301        wp_send_json_success();
  • shipday-for-woocommerce/trunk/admin/Shipday_Time_Slot_Util.php

    r3419924 r3483127  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) {
     4    exit;
     5}
    26
    37class Shipday_Time_Slot_Util {
     
    1923        // HH
    2024        echo '<input type="text" id="' . esc_attr( $id ) . '_hh" name="' . esc_attr( $id ) . '[hh]" '
    21             . 'value="' . $hh . '" size="2" maxlength="2" min="1" max="12" step="1" inputmode="numeric" pattern="\d{2}" '
     25            . 'value="' . esc_attr( $hh ) . '" size="2" maxlength="2" min="1" max="12" step="1" inputmode="numeric" pattern="\d{2}" '
    2226            . 'placeholder="HH" style="min-width:120px;text-align:center;" />';
    2327
     
    2630        // MM
    2731        echo '<input type="text" id="' . esc_attr( $id ) . '_mm" name="' . esc_attr( $id ) . '[mm]" '
    28             . 'value="' . $mm . '" size="2" maxlength="2" inputmode="numeric" pattern="\d{2}" '
     32            . 'value="' . esc_attr( $mm ) . '" size="2" maxlength="2" inputmode="numeric" pattern="\d{2}" '
    2933            . 'placeholder="MM" style="min-width:120px;text-align:center;" />';
    3034
  • shipday-for-woocommerce/trunk/admin/partials/shipday-admin-display.php

    r3419924 r3483127  
    11<?php
    2 $active_tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'general';
     2
     3if ( ! defined( 'ABSPATH' ) ) {
     4    exit;
     5}
     6// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Included admin partial uses file-scoped template variables.
     7$shipday_active_tab = filter_input( INPUT_GET, 'tab', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
     8$shipday_active_tab = is_string( $shipday_active_tab ) && '' !== $shipday_active_tab ? $shipday_active_tab : 'general';
    39?>
    410<div class="sd-root">
     
    1723      <div class="sd-tab-list">
    1824        <!-- GENERAL TAB BUTTON (active by default) -->
    19         <button type="button" data-tab="general" class="sd-tab-button <?php echo $active_tab === 'general' ? 'sd-tab-button--active' : ''; ?>">
     25        <button type="button" data-tab="general" class="sd-tab-button <?php echo esc_attr( $shipday_active_tab === 'general' ? 'sd-tab-button--active' : '' ); ?>">
    2026          <span>General</span>
    2127        </button>
     
    2329        <!-- REST API TAB BUTTON -->
    2430        <?php if ( !is_plugin_active( 'dokan-lite/dokan.php' ) && !is_plugin_active( 'wc-multivendor-marketplace/wc-multivendor-marketplace.php' )) {?>
    25           <button type="button" data-tab="rest-api" class="sd-tab-button <?php echo $active_tab === 'rest-api' ? 'sd-tab-button--active' : ''; ?>">
     31          <button type="button" data-tab="rest-api" class="sd-tab-button <?php echo esc_attr( $shipday_active_tab === 'rest-api' ? 'sd-tab-button--active' : '' ); ?>">
    2632            <span>Rest API</span>
    2733          </button>
     
    4854
    4955    <!-- GENERAL TAB PANEL -->
    50     <div data-tab-panel="general" class="sd-tab-panel <?php echo $active_tab === 'general' ? 'sd-tab-panel--active' : ''; ?>">
     56    <div data-tab-panel="general" class="sd-tab-panel <?php echo esc_attr( $shipday_active_tab === 'general' ? 'sd-tab-panel--active' : '' ); ?>">
    5157        <?php
    5258          include plugin_dir_path(__FILE__) . 'tab-shipday-connect.php';
     
    5561
    5662    <!-- REST API TAB PANEL -->
    57     <div data-tab-panel="rest-api" class="sd-tab-panel <?php echo $active_tab === 'rest-api' ? 'sd-tab-panel--active' : ''; ?>">
     63    <div data-tab-panel="rest-api" class="sd-tab-panel <?php echo esc_attr( $shipday_active_tab === 'rest-api' ? 'sd-tab-panel--active' : '' ); ?>">
    5864        <?php
    5965        include plugin_dir_path( __FILE__ ) . 'tab-rest-api.php';
     
    123129  })();
    124130</script>
    125 
  • shipday-for-woocommerce/trunk/admin/partials/shipday-admin-new.php

    r3419924 r3483127  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) {
     4    exit;
     5}
     6// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Included admin partial uses file-scoped template variables.
    27// Default to the new Overview tab if none is provided
    3 $active_tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'overview';
     8$shipday_active_tab = filter_input( INPUT_GET, 'tab', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
     9$shipday_active_tab = is_string( $shipday_active_tab ) && '' !== $shipday_active_tab ? $shipday_active_tab : 'overview';
    410?>
    511<div class="sd-root">
     
    2228        <!-- Overview -->
    2329        <button type="button" data-tab="overview"
    24                 class="sd-tab-button <?php echo $active_tab === 'overview' ? 'sd-tab-button--active' : ''; ?>"
    25                 id="tab-overview" role="tab" aria-selected="<?php echo $active_tab === 'overview' ? 'true' : 'false'; ?>">
     30                class="sd-tab-button <?php echo esc_attr( $shipday_active_tab === 'overview' ? 'sd-tab-button--active' : '' ); ?>"
     31                id="tab-overview" role="tab" aria-selected="<?php echo esc_attr( $shipday_active_tab === 'overview' ? 'true' : 'false' ); ?>">
    2632          <span>Overview</span>
    2733        </button>
     
    3238        <!-- General-->
    3339        <button type="button" data-tab="general"
    34                 class="sd-tab-button <?php echo $active_tab === 'general' ? 'sd-tab-button--active' : ''; ?>"
    35                 id="tab-general" role="tab" aria-selected="<?php echo $active_tab === 'general' ? 'true' : 'false'; ?>">
     40                class="sd-tab-button <?php echo esc_attr( $shipday_active_tab === 'general' ? 'sd-tab-button--active' : '' ); ?>"
     41                id="tab-general" role="tab" aria-selected="<?php echo esc_attr( $shipday_active_tab === 'general' ? 'true' : 'false' ); ?>">
    3642          <span>General</span>
    3743        </button>
     
    3945        <!-- Delivery -->
    4046        <button type="button" data-tab="delivery"
    41                 class="sd-tab-button <?php echo $active_tab === 'delivery' ? 'sd-tab-button--active' : ''; ?>"
    42                 id="tab-delivery" role="tab" aria-selected="<?php echo $active_tab === 'delivery' ? 'true' : 'false'; ?>">
     47                class="sd-tab-button <?php echo esc_attr( $shipday_active_tab === 'delivery' ? 'sd-tab-button--active' : '' ); ?>"
     48                id="tab-delivery" role="tab" aria-selected="<?php echo esc_attr( $shipday_active_tab === 'delivery' ? 'true' : 'false' ); ?>">
    4349          <span>Delivery</span>
    4450        </button>
     
    4652        <!-- Pickup -->
    4753        <button type="button" data-tab="pickup"
    48                 class="sd-tab-button <?php echo $active_tab === 'pickup' ? 'sd-tab-button--active' : ''; ?>"
    49                 id="tab-pickup" role="tab" aria-selected="<?php echo $active_tab === 'pickup' ? 'true' : 'false'; ?>">
     54                class="sd-tab-button <?php echo esc_attr( $shipday_active_tab === 'pickup' ? 'sd-tab-button--active' : '' ); ?>"
     55                id="tab-pickup" role="tab" aria-selected="<?php echo esc_attr( $shipday_active_tab === 'pickup' ? 'true' : 'false' ); ?>">
    5056          <span>Pickup</span>
    5157        </button>
     
    5662        <!-- Shipday Connect -->
    5763        <button type="button" data-tab="shipday-connect"
    58                 class="sd-tab-button <?php echo $active_tab === 'shipday-connect' ? 'sd-tab-button--active' : ''; ?>"
    59                 id="tab-shipday-connect" role="tab" aria-selected="<?php echo $active_tab === 'shipday-connect' ? 'true' : 'false'; ?>">
     64                class="sd-tab-button <?php echo esc_attr( $shipday_active_tab === 'shipday-connect' ? 'sd-tab-button--active' : '' ); ?>"
     65                id="tab-shipday-connect" role="tab" aria-selected="<?php echo esc_attr( $shipday_active_tab === 'shipday-connect' ? 'true' : 'false' ); ?>">
    6066          <span>Connect Shipday Account</span>
    6167        </button>
     
    6470          <?php if ( !is_plugin_active( 'dokan-lite/dokan.php' ) && !is_plugin_active( 'wc-multivendor-marketplace/wc-multivendor-marketplace.php' )) { ?>
    6571            <button type="button" data-tab="rest-api"
    66                     class="sd-tab-button <?php echo $active_tab === 'rest-api' ? 'sd-tab-button--active' : ''; ?>"
    67                     id="tab-rest-api" role="tab" aria-selected="<?php echo $active_tab === 'rest-api' ? 'true' : 'false'; ?>">
     72                    class="sd-tab-button <?php echo esc_attr( $shipday_active_tab === 'rest-api' ? 'sd-tab-button--active' : '' ); ?>"
     73                    id="tab-rest-api" role="tab" aria-selected="<?php echo esc_attr( $shipday_active_tab === 'rest-api' ? 'true' : 'false' ); ?>">
    6874              <span>Rest API</span>
    6975            </button>
     
    7884
    7985    <!-- OVERVIEW -->
    80     <div data-tab-panel="overview" class="sd-tab-panel <?php echo $active_tab === 'overview' ? 'sd-tab-panel--active' : ''; ?>">
     86    <div data-tab-panel="overview" class="sd-tab-panel <?php echo esc_attr( $shipday_active_tab === 'overview' ? 'sd-tab-panel--active' : '' ); ?>">
    8187        <?php
    8288        include plugin_dir_path( __FILE__ ) . 'tab-overview.php';
     
    8591
    8692    <!-- SHIPDAY CONNECT (old general) -->
    87     <div data-tab-panel="shipday-connect" class="sd-tab-panel <?php echo $active_tab === 'shipday-connect' ? 'sd-tab-panel--active' : ''; ?>">
     93    <div data-tab-panel="shipday-connect" class="sd-tab-panel <?php echo esc_attr( $shipday_active_tab === 'shipday-connect' ? 'sd-tab-panel--active' : '' ); ?>">
    8894        <?php include plugin_dir_path( __FILE__ ) . 'tab-shipday-connect.php'; ?>
    8995    </div>
    9096
    9197    <!-- REST API (unchanged) -->
    92     <div data-tab-panel="rest-api" class="sd-tab-panel <?php echo $active_tab === 'rest-api' ? 'sd-tab-panel--active' : ''; ?>">
     98    <div data-tab-panel="rest-api" class="sd-tab-panel <?php echo esc_attr( $shipday_active_tab === 'rest-api' ? 'sd-tab-panel--active' : '' ); ?>">
    9399        <?php include plugin_dir_path( __FILE__ ) . 'tab-rest-api.php'; ?>
    94100    </div>
    95101
    96102    <!-- DELIVERY (unchanged) -->
    97     <div data-tab-panel="delivery" class="sd-tab-panel <?php echo $active_tab === 'delivery' ? 'sd-tab-panel--active' : ''; ?>">
     103    <div data-tab-panel="delivery" class="sd-tab-panel <?php echo esc_attr( $shipday_active_tab === 'delivery' ? 'sd-tab-panel--active' : '' ); ?>">
    98104        <?php include plugin_dir_path( __FILE__ ) . 'tab-delivery.php'; ?>
    99105    </div>
    100106
    101107    <!-- PICKUP (unchanged) -->
    102     <div data-tab-panel="pickup" class="sd-tab-panel <?php echo $active_tab === 'pickup' ? 'sd-tab-panel--active' : ''; ?>">
     108    <div data-tab-panel="pickup" class="sd-tab-panel <?php echo esc_attr( $shipday_active_tab === 'pickup' ? 'sd-tab-panel--active' : '' ); ?>">
    103109        <?php include plugin_dir_path( __FILE__ ) . 'tab-pickup.php'; ?>
    104110    </div>
    105111
    106112    <!-- General Settings (new) -->
    107     <div data-tab-panel="general" class="sd-tab-panel <?php echo $active_tab === 'general' ? 'sd-tab-panel--active' : ''; ?>">
     113    <div data-tab-panel="general" class="sd-tab-panel <?php echo esc_attr( $shipday_active_tab === 'general' ? 'sd-tab-panel--active' : '' ); ?>">
    108114        <?php include plugin_dir_path( __FILE__ ) . 'tab-general.php'; ?>
    109115    </div>
     
    155161  })();
    156162</script>
    157 
  • shipday-for-woocommerce/trunk/admin/partials/tab-delivery.php

    r3467875 r3483127  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) {
     4    exit;
     5}
     6// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Included admin partial uses file-scoped template variables.
    27$enable_delivery_date = get_option('shipday_enable_delivery_date', "no") === "yes";
    38$delivery_date_mandatory = get_option('shipday_delivery_date_mandatory', "no") === "yes";
     
    3035<div class="sd-panel-body">
    3136
    32   <fieldset class="sd-fieldset" <?php echo $datetime_enabled ? '' : 'disabled aria-disabled="true"'; ?> <?php echo $datetime_enabled ? '' : 'disabled'; ?>>
     37  <fieldset class="sd-fieldset" <?php disabled( ! $datetime_enabled ); ?> aria-disabled="<?php echo esc_attr( $datetime_enabled ? 'false' : 'true' ); ?>">
    3338  <p class="shipday-delivery-notice"><span
    34         class="dashicons dashicons-yes"></span><?php _e(' Settings Changed Successfully', 'shipday-delivery'); ?>
     39        class="dashicons dashicons-yes"></span><?php esc_html_e( ' Settings Changed Successfully', 'shipday-for-woocommerce' ); ?>
    3540  </p>
    3641
     
    5459                name="shipday_enable_delivery_date"
    5560                class="shipday-switch__input"
    56                 <?php echo ($enable_delivery_date) ? "checked" : "" ?>
     61                <?php checked( $enable_delivery_date ); ?>
    5762            />
    5863            <span class="shipday-switch__track">
     
    7479            <input
    7580                type="checkbox" id="shipday_delivery_date_mandatory" name="shipday_delivery_date_mandatory" class="shipday-switch__input"
    76                 <?php echo ($delivery_date_mandatory) ? "checked" : "" ?>
     81                <?php checked( $delivery_date_mandatory ); ?>
    7782            />
    7883            <span class="shipday-switch__track">
     
    108113          <label class="shipday-day-chip">
    109114            <input type="checkbox" class="shipday-day-chip__input" name="shipday_avaialble_delivery_days[]" value="0"
    110                 <?php echo (in_array("0", $available_delivery_days)) ? "checked" : "" ?>
     115                <?php checked( in_array( '0', $available_delivery_days, true ) ); ?>
    111116            />
    112117            <span class="shipday-day-chip__pill">Sunday</span>
     
    116121            <input
    117122                type="checkbox" class="shipday-day-chip__input" name="shipday_avaialble_delivery_days[]" value="1"
    118                 <?php echo (in_array("1", $available_delivery_days, true)) ? "checked" : "" ?>
     123                <?php checked( in_array( '1', $available_delivery_days, true ) ); ?>
    119124            />
    120125            <span class="shipday-day-chip__pill">Monday</span>
     
    124129            <input
    125130                type="checkbox" class="shipday-day-chip__input" name="shipday_avaialble_delivery_days[]" value="2"
    126                 <?php echo (in_array("2", $available_delivery_days, true)) ? "checked" : "" ?>
     131                <?php checked( in_array( '2', $available_delivery_days, true ) ); ?>
    127132            />
    128133            <span class="shipday-day-chip__pill">Tuesday</span>
     
    132137            <input
    133138                type="checkbox" class="shipday-day-chip__input" name="shipday_avaialble_delivery_days[]" value="3"
    134                 <?php echo (in_array("3", $available_delivery_days, true)) ? "checked" : "" ?>
     139                <?php checked( in_array( '3', $available_delivery_days, true ) ); ?>
    135140            />
    136141            <span class="shipday-day-chip__pill">Wednesday</span>
     
    140145            <input
    141146                type="checkbox" class="shipday-day-chip__input" name="shipday_avaialble_delivery_days[]" value="4"
    142                 <?php echo (in_array("4", $available_delivery_days, true)) ? "checked" : "" ?>
     147                <?php checked( in_array( '4', $available_delivery_days, true ) ); ?>
    143148            />
    144149            <span class="shipday-day-chip__pill">Thursday</span>
     
    148153            <input
    149154                type="checkbox" class="shipday-day-chip__input" name="shipday_avaialble_delivery_days[]" value="5"
    150                 <?php echo (in_array("5", $available_delivery_days, true)) ? "checked" : "" ?>
     155                <?php checked( in_array( '5', $available_delivery_days, true ) ); ?>
    151156            />
    152157            <span class="shipday-day-chip__pill">Friday</span>
     
    156161            <input
    157162                type="checkbox" class="shipday-day-chip__input" name="shipday_avaialble_delivery_days[]" value="6"
    158                 <?php echo (in_array("6", $available_delivery_days, true)) ? "checked" : "" ?>
     163                <?php checked( in_array( '6', $available_delivery_days, true ) ); ?>
    159164            />
    160165            <span class="shipday-day-chip__pill">Saturday</span>
     
    181186        <div class="sd-input-wrapper">
    182187          <input type="text" placeholder="" class="sd-text-input" name="shipday_selectable_delivery_days"
    183                  value="<?php echo $selectable_delivery_days ?>"
     188                 value="<?php echo esc_attr( $selectable_delivery_days ); ?>"
    184189          />
    185190        </div>
     
    204209            <input
    205210                type="checkbox" id="shipday_enable_delivery_time" name="shipday_enable_delivery_time" class="shipday-switch__input"
    206                 <?php echo ($enable_delivery_time) ? "checked" : "" ?>
     211                <?php checked( $enable_delivery_time ); ?>
    207212            />
    208213            <span class="shipday-switch__track">
     
    224229            <input
    225230                type="checkbox" id="shipday_delivery_time_mandatory" name="shipday_delivery_time_mandatory" class="shipday-switch__input"
    226                 <?php echo ($delivery_time_mandatory) ? "checked" : "" ?>
     231                <?php checked( $delivery_time_mandatory ); ?>
    227232            />
    228233            <span class="shipday-switch__track">
     
    252257                    type="number" min="1" max="12" id="shipday_delivery_time_slot_start_hh" name="shipday_delivery_time_slot_start_hh"
    253258                    class="shipday-time-input__field"
    254                     value="<?php echo $start_delivery_slot['hh'] ?>"
     259                    value="<?php echo esc_attr( $start_delivery_slot['hh'] ); ?>"
    255260                />
    256261              </div>
     
    263268                    type="number" min="0" max="59" step="5" id="shipday_delivery_time_slot_start_mm" name="shipday_delivery_time_slot_start_mm"
    264269                    class="shipday-time-input__field"
    265                     value="<?php echo $start_delivery_slot['mm'] ?>"
     270                    value="<?php echo esc_attr( $start_delivery_slot['mm'] ); ?>"
    266271                />
    267272              </div>
     
    274279                    class="shipday-ampm-select__field sd-text-input"
    275280                >
    276                   <option value="AM" <?php echo ($start_delivery_slot["ampm"]==="AM") ? "selected" : "" ?> >AM</option>
    277                   <option value="PM" <?php echo ($start_delivery_slot["ampm"]==="PM") ? "selected" : "" ?> >PM</option>
     281                  <option value="AM" <?php selected( $start_delivery_slot['ampm'], 'AM' ); ?>>AM</option>
     282                  <option value="PM" <?php selected( $start_delivery_slot['ampm'], 'PM' ); ?>>PM</option>
    278283                </select>
    279284              </div>
     
    293298                    type="number"  min="1"  max="12" step="1"  id="shipday_delivery_time_slot_end_hh" name="shipday_delivery_time_slot_end_hh"
    294299                    class="shipday-time-input__field"
    295                     value="<?php echo $end_delivery_slot['hh'] ?>"
     300                    value="<?php echo esc_attr( $end_delivery_slot['hh'] ); ?>"
    296301                />
    297302              </div>
     
    304309                    type="number" min="0" max="59" step="5" id="shipday_delivery_time_slot_end_mm" name="shipday_delivery_time_slot_end_mm"
    305310                    class="shipday-time-input__field"
    306                     value="<?php echo $end_delivery_slot['mm'] ?>"
     311                    value="<?php echo esc_attr( $end_delivery_slot['mm'] ); ?>"
    307312                />
    308313              </div>
     
    315320                    class="shipday-ampm-select__field sd-text-input"
    316321                >
    317                   <option value="AM" <?php echo ($end_delivery_slot["ampm"]==="AM") ? "selected" : "" ?> >AM</option>
    318                   <option value="PM" <?php echo ($end_delivery_slot["ampm"]==="PM") ? "selected" : "" ?> >PM</option>
     322                  <option value="AM" <?php selected( $end_delivery_slot['ampm'], 'AM' ); ?>>AM</option>
     323                  <option value="PM" <?php selected( $end_delivery_slot['ampm'], 'PM' ); ?>>PM</option>
    319324                </select>
    320325              </div>
     
    334339                  class="shipday-slot-duration-field__select sd-text-input"
    335340              >
    336                 <option value="10" <?php echo ($delivery_slot_duration === "10") ? "selected" : ""?>>10</option>
    337                 <option value="15" <?php echo ($delivery_slot_duration === "15") ? "selected" : ""?>>15</option>
    338                 <option value="30" <?php echo ($delivery_slot_duration === "30") ? "selected" : ""?>>30</option>
    339                 <option value="45" <?php echo ($delivery_slot_duration === "45") ? "selected" : ""?>>45</option>
    340                 <option value="60" <?php echo ($delivery_slot_duration === "60") ? "selected" : ""?>>60</option>
    341                 <option value="90" <?php echo ($delivery_slot_duration === "90") ? "selected" : ""?>>90</option>
    342                 <option value="120" <?php echo ($delivery_slot_duration === "120") ? "selected" : ""?>>120</option>
    343                 <option value="150" <?php echo ($delivery_slot_duration === "150") ? "selected" : ""?>>150</option>
    344                 <option value="180" <?php echo ($delivery_slot_duration === "180") ? "selected" : ""?>>180</option>
    345                 <option value="240" <?php echo ($delivery_slot_duration === "240") ? "selected" : ""?>>240</option>
    346                 <option value="300" <?php echo ($delivery_slot_duration === "300") ? "selected" : ""?>>300</option>
    347                 <option value="360" <?php echo ($delivery_slot_duration === "360") ? "selected" : ""?>>360</option>
     341                <option value="10" <?php selected( $delivery_slot_duration, '10' ); ?>>10</option>
     342                <option value="15" <?php selected( $delivery_slot_duration, '15' ); ?>>15</option>
     343                <option value="30" <?php selected( $delivery_slot_duration, '30' ); ?>>30</option>
     344                <option value="45" <?php selected( $delivery_slot_duration, '45' ); ?>>45</option>
     345                <option value="60" <?php selected( $delivery_slot_duration, '60' ); ?>>60</option>
     346                <option value="90" <?php selected( $delivery_slot_duration, '90' ); ?>>90</option>
     347                <option value="120" <?php selected( $delivery_slot_duration, '120' ); ?>>120</option>
     348                <option value="150" <?php selected( $delivery_slot_duration, '150' ); ?>>150</option>
     349                <option value="180" <?php selected( $delivery_slot_duration, '180' ); ?>>180</option>
     350                <option value="240" <?php selected( $delivery_slot_duration, '240' ); ?>>240</option>
     351                <option value="300" <?php selected( $delivery_slot_duration, '300' ); ?>>300</option>
     352                <option value="360" <?php selected( $delivery_slot_duration, '360' ); ?>>360</option>
    348353              </select>
    349354            </div>
  • shipday-for-woocommerce/trunk/admin/partials/tab-general.php

    r3419924 r3483127  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) {
     4    exit;
     5}
     6// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Included admin partial uses file-scoped template variables.
    27$datetime_enabled = get_option('shipday_enable_datetime_plugin', "no") === "yes";
    38$order_type_enabled = get_option('shipday_enable_delivery_option', "no") === "yes";
     
    2025  <p class="shipday-general-notice">
    2126    <span class="dashicons dashicons-yes"></span>
    22       <?php _e(' Settings Changed Successfully', 'shipday-delivery'); ?>
     27      <?php esc_html_e( ' Settings Changed Successfully', 'shipday-for-woocommerce' ); ?>
    2328  </p>
    2429  <form action="" method="post" id="shipday-general-settings-form">
     
    3641              name="shipday_enable_datetime_plugin"
    3742              class="shipday-switch__input"
    38               <?php echo ($datetime_enabled) ? "checked" : "" ?>
     43              <?php checked( $datetime_enabled ); ?>
    3944          />
    4045          <span class="shipday-switch__track">
     
    6469              name="shipday_enable_delivery_option"
    6570              class="shipday-switch__input"
    66               <?php echo ($order_type_enabled) ? "checked" : "" ?>
     71              <?php checked( $order_type_enabled ); ?>
    6772          />
    6873          <span class="shipday-switch__track">
     
    107112      <div class="sd-input-wrapper sd-text-input">
    108113        <input type="text" placeholder="" class="sd-text-input" name="shipday_delivery_pickup_label"
    109                value="<?php echo $datetime_heading_label?>"
     114               value="<?php echo esc_attr( $datetime_heading_label ); ?>"
    110115        />
    111116      </div>
  • shipday-for-woocommerce/trunk/admin/partials/tab-order-sync.php

    r3419924 r3483127  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) {
     4    exit;
     5}
     6// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Included admin partial uses file-scoped template variables.
    27$pickup_order_enabled = get_option('wc_settings_tab_shipday_enable_pickup', "no") === "yes";
    38$delivery_order_enabled = get_option('wc_settings_tab_shipday_enable_delivery', "yes") === "yes";
     
    2227  <p class="shipday-order-sync-notice">
    2328    <span class="dashicons dashicons-yes"></span>
    24       <?php _e(' Settings Changed Successfully', 'shipday-delivery'); ?>
     29      <?php esc_html_e( ' Settings Changed Successfully', 'shipday-for-woocommerce' ); ?>
    2530  </p>
    2631  <form action="" method="post" id="shipday-order-sync-settings-form">
     
    5762                    name="wc_settings_tab_shipday_order_manage"
    5863                    value="admin_manage"
    59                     <?php echo ($manage_order === 'admin_manage') ? 'checked' : ''; ?>
     64                    <?php checked( $manage_order, 'admin_manage' ); ?>
    6065                />
    6166                <span class="sd-radio__mark" aria-hidden="true"></span>
     
    6974                    name="wc_settings_tab_shipday_order_manage"
    7075                    value="vendor_manage"
    71                     <?php echo ($manage_order === 'vendor_manage') ? 'checked' : ''; ?>
     76                    <?php checked( $manage_order, 'vendor_manage' ); ?>
    7277                />
    7378                <span class="sd-radio__mark" aria-hidden="true"></span>
  • shipday-for-woocommerce/trunk/admin/partials/tab-overview.php

    r3419924 r3483127  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) {
     4    exit;
     5}
    26// Helper to build a same-page link to a specific tab
    37function shipday_tab_link( $tab_slug ) {
     
    2933      <div class="sd-link-row">
    3034        <!-- General (blank page for now) -->
    31         <a class="sd-link-tile" href="<?php echo shipday_tab_link('general'); ?>">
     35        <a class="sd-link-tile" href="<?php echo esc_url( shipday_tab_link( 'general' ) ); ?>">
    3236          <span class="sd-link-tile__icon" aria-hidden="true">
    3337             <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
     
    4246
    4347        <!-- Delivery -->
    44         <a class="sd-link-tile" href="<?php echo shipday_tab_link('delivery'); ?>">
     48        <a class="sd-link-tile" href="<?php echo esc_url( shipday_tab_link( 'delivery' ) ); ?>">
    4549          <span class="sd-link-tile__icon" aria-hidden="true">
    4650            <!-- Delivery icon (24x24) -->
     
    5761
    5862        <!-- Pickup -->
    59         <a class="sd-link-tile" href="<?php echo shipday_tab_link('pickup'); ?>">
     63        <a class="sd-link-tile" href="<?php echo esc_url( shipday_tab_link( 'pickup' ) ); ?>">
    6064          <span class="sd-link-tile__icon" aria-hidden="true">
    6165           <svg  width="24" height="24" viewBox="0 0 24 24" fill="none" class="sd-link-tile__svg" xmlns="http://www.w3.org/2000/svg"><path d="M4.72745 17.2913C4.30662 17.2913 3.95037 17.1455 3.6587 16.8538C3.36704 16.5622 3.2212 16.2059 3.2212 15.7849V9.1278C2.88565 8.85224 2.63377 8.49461 2.46558 8.05488C2.29725 7.6153 2.29377 7.14072 2.45516 6.63113L3.29808 3.8778C3.40919 3.52738 3.59773 3.24481 3.8637 3.03009C4.12982 2.81537 4.44766 2.70801 4.81725 2.70801H16.1922C16.562 2.70801 16.8777 2.81058 17.1393 3.01572C17.4011 3.22086 17.5918 3.50294 17.7114 3.86197L18.5704 6.63113C18.7318 7.14072 18.7283 7.6137 18.56 8.05009C18.3918 8.48662 18.1399 8.8512 17.8043 9.14384V15.7849C17.8043 16.2059 17.6585 16.5622 17.3668 16.8538C17.0752 17.1455 16.7189 17.2913 16.2981 17.2913H4.72745ZM12.3462 8.54134C12.8013 8.54134 13.1435 8.40217 13.3727 8.12384C13.6018 7.84551 13.6956 7.54662 13.6539 7.22717L13.1475 3.95801H11.1377V7.24967C11.1377 7.60009 11.2563 7.90301 11.4935 8.15842C11.7307 8.4137 12.015 8.54134 12.3462 8.54134ZM8.5962 8.54134C8.97968 8.54134 9.29079 8.4137 9.52954 8.15842C9.76843 7.90301 9.88787 7.60009 9.88787 7.24967V3.95801H7.87808L7.37183 7.25926C7.32683 7.55523 7.41975 7.84294 7.65058 8.12238C7.88141 8.40169 8.19662 8.54134 8.5962 8.54134ZM4.88787 8.54134C5.19662 8.54134 5.46211 8.4337 5.68433 8.21842C5.90655 8.00315 6.04384 7.73259 6.0962 7.40676L6.58641 3.95801H4.81725C4.72641 3.95801 4.65433 3.97801 4.601 4.01801C4.54752 4.05815 4.50745 4.11829 4.48079 4.19842L3.67933 6.90988C3.56933 7.2678 3.6212 7.62919 3.83495 7.99405C4.04857 8.35891 4.39954 8.54134 4.88787 8.54134ZM16.1379 8.54134C16.5887 8.54134 16.9338 8.36426 17.1731 8.01009C17.4124 7.65592 17.4701 7.28919 17.3462 6.90988L16.5031 4.18238C16.4764 4.10224 16.4364 4.04481 16.3831 4.01009C16.3296 3.97537 16.2575 3.95801 16.1666 3.95801H14.4391L14.9293 7.40676C14.9817 7.73259 15.119 8.00315 15.3412 8.21842C15.5634 8.4337 15.829 8.54134 16.1379 8.54134ZM4.72745 16.0413H16.2981C16.3728 16.0413 16.4342 16.0173 16.4822 15.9693C16.5304 15.9212 16.5545 15.8597 16.5545 15.7849V9.71759C16.4637 9.75078 16.3878 9.77134 16.3268 9.77926C16.266 9.78731 16.203 9.79134 16.1379 9.79134C15.7629 9.79134 15.433 9.72349 15.1483 9.5878C14.8636 9.45211 14.5876 9.23467 14.3204 8.93551C14.0865 9.1962 13.8098 9.40405 13.4904 9.55905C13.1709 9.71391 12.8066 9.79134 12.3975 9.79134C12.0438 9.79134 11.7105 9.71787 11.3975 9.57092C11.0844 9.42412 10.7895 9.21231 10.5129 8.93551C10.2554 9.21231 9.9637 9.42412 9.63787 9.57092C9.3119 9.71787 8.98176 9.79134 8.64745 9.79134C8.27134 9.79134 7.91877 9.72322 7.58975 9.58697C7.26072 9.45072 6.9712 9.23356 6.7212 8.93551C6.37065 9.28592 6.04766 9.5162 5.75225 9.62634C5.45697 9.73634 5.16884 9.79134 4.88787 9.79134C4.82259 9.79134 4.75523 9.78731 4.68579 9.77926C4.61634 9.77134 4.54475 9.75078 4.471 9.71759V15.7849C4.471 15.8597 4.49509 15.9212 4.54329 15.9693C4.59134 16.0173 4.65273 16.0413 4.72745 16.0413Z" fill="#525252"></path></svg>
     
    8185    <div class="shipday-delivery-card__content">
    8286      <div class="sd-link-row">
    83         <a class="sd-link-tile" href="<?php echo shipday_tab_link('shipday-connect'); ?>">
     87        <a class="sd-link-tile" href="<?php echo esc_url( shipday_tab_link( 'shipday-connect' ) ); ?>">
    8488          <span class="sd-link-tile__icon" aria-hidden="true">
    8589             <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
     
    9599        <!-- Rest API (honor your existing vendor check) -->
    96100          <?php if ( !is_plugin_active( 'dokan-lite/dokan.php' ) && !is_plugin_active( 'wc-multivendor-marketplace/wc-multivendor-marketplace.php' ) ) { ?>
    97             <a class="sd-link-tile" href="<?php echo shipday_tab_link('rest-api'); ?>">
     101            <a class="sd-link-tile" href="<?php echo esc_url( shipday_tab_link( 'rest-api' ) ); ?>">
    98102              <span class="sd-link-tile__icon" aria-hidden="true">
    99103                 <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
  • shipday-for-woocommerce/trunk/admin/partials/tab-pickup.php

    r3467875 r3483127  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) {
     4    exit;
     5}
     6// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Included admin partial uses file-scoped template variables.
    27$enable_pickup_date = get_option('shipday_enable_pickup_date', "no") === "yes";
    38$pickup_date_mandatory = get_option('shipday_pickup_date_mandatory', "no") === "yes";
     
    2934
    3035<div class="sd-panel-body">
    31   <fieldset class="sd-fieldset" <?php echo $datetime_enabled ? '' : 'disabled aria-disabled="true"'; ?> <?php echo $datetime_enabled ? '' : 'disabled'; ?>>
     36  <fieldset class="sd-fieldset" <?php disabled( ! $datetime_enabled ); ?> aria-disabled="<?php echo esc_attr( $datetime_enabled ? 'false' : 'true' ); ?>">
    3237
    3338  <p class="shipday-pickup-notice"><span
    34         class="dashicons dashicons-yes"></span><?php _e(' Settings Changed Successfully', 'shipday-delivery'); ?>
     39        class="dashicons dashicons-yes"></span><?php esc_html_e( ' Settings Changed Successfully', 'shipday-for-woocommerce' ); ?>
    3540  </p>
    3641
     
    5459                name="shipday_enable_pickup_date"
    5560                class="shipday-switch__input"
    56                 <?php echo ($enable_pickup_date) ? "checked" : "" ?>
     61                <?php checked( $enable_pickup_date ); ?>
    5762            />
    5863            <span class="shipday-switch__track">
     
    7479            <input
    7580                type="checkbox" id="shipday_pickup_date_mandatory" name="shipday_pickup_date_mandatory" class="shipday-switch__input"
    76                 <?php echo ($pickup_date_mandatory) ? "checked" : "" ?>
     81                <?php checked( $pickup_date_mandatory ); ?>
    7782            />
    7883            <span class="shipday-switch__track">
     
    108113            <label class="shipday-day-chip">
    109114              <input type="checkbox" class="shipday-day-chip__input" name="shipday_avaialble_pickup_days[]" value="0"
    110                   <?php echo (in_array("0", $available_pickup_days)) ? "checked" : "" ?>
     115                  <?php checked( in_array( '0', $available_pickup_days, true ) ); ?>
    111116              />
    112117              <span class="shipday-day-chip__pill">Sunday</span>
     
    116121              <input
    117122                  type="checkbox" class="shipday-day-chip__input" name="shipday_avaialble_pickup_days[]" value="1"
    118                   <?php echo (in_array("1", $available_pickup_days, true)) ? "checked" : "" ?>
     123                  <?php checked( in_array( '1', $available_pickup_days, true ) ); ?>
    119124              />
    120125              <span class="shipday-day-chip__pill">Monday</span>
     
    124129              <input
    125130                  type="checkbox" class="shipday-day-chip__input" name="shipday_avaialble_pickup_days[]" value="2"
    126                   <?php echo (in_array("2", $available_pickup_days, true)) ? "checked" : "" ?>
     131                  <?php checked( in_array( '2', $available_pickup_days, true ) ); ?>
    127132              />
    128133              <span class="shipday-day-chip__pill">Tuesday</span>
     
    132137              <input
    133138                  type="checkbox" class="shipday-day-chip__input" name="shipday_avaialble_pickup_days[]" value="3"
    134                   <?php echo (in_array("3", $available_pickup_days, true)) ? "checked" : "" ?>
     139                  <?php checked( in_array( '3', $available_pickup_days, true ) ); ?>
    135140              />
    136141              <span class="shipday-day-chip__pill">Wednesday</span>
     
    140145              <input
    141146                  type="checkbox" class="shipday-day-chip__input" name="shipday_avaialble_pickup_days[]" value="4"
    142                   <?php echo (in_array("4", $available_pickup_days, true)) ? "checked" : "" ?>
     147                  <?php checked( in_array( '4', $available_pickup_days, true ) ); ?>
    143148              />
    144149              <span class="shipday-day-chip__pill">Thursday</span>
     
    148153              <input
    149154                  type="checkbox" class="shipday-day-chip__input" name="shipday_avaialble_pickup_days[]" value="5"
    150                   <?php echo (in_array("5", $available_pickup_days, true)) ? "checked" : "" ?>
     155                  <?php checked( in_array( '5', $available_pickup_days, true ) ); ?>
    151156              />
    152157              <span class="shipday-day-chip__pill">Friday</span>
     
    156161              <input
    157162                  type="checkbox" class="shipday-day-chip__input" name="shipday_avaialble_pickup_days[]" value="6"
    158                   <?php echo (in_array("6", $available_pickup_days, true)) ? "checked" : "" ?>
     163                  <?php checked( in_array( '6', $available_pickup_days, true ) ); ?>
    159164              />
    160165              <span class="shipday-day-chip__pill">Saturday</span>
     
    181186          <div class="sd-input-wrapper">
    182187            <input type="text" placeholder="" class="sd-text-input" name="shipday_selectable_pickup_days"
    183                    value="<?php echo $selectable_pickup_days ?>"
     188                   value="<?php echo esc_attr( $selectable_pickup_days ); ?>"
    184189            />
    185190          </div>
     
    204209            <input
    205210                type="checkbox" id="shipday_enable_pickup_time" name="shipday_enable_pickup_time" class="shipday-switch__input"
    206                 <?php echo ($enable_pickup_time) ? "checked" : "" ?>
     211                <?php checked( $enable_pickup_time ); ?>
    207212            />
    208213            <span class="shipday-switch__track">
     
    224229            <input
    225230                type="checkbox" id="shipday_pickup_time_mandatory" name="shipday_pickup_time_mandatory" class="shipday-switch__input"
    226                 <?php echo ($pickup_time_mandatory) ? "checked" : "" ?>
     231                <?php checked( $pickup_time_mandatory ); ?>
    227232            />
    228233            <span class="shipday-switch__track">
     
    252257                       type="number" min="1" max="12" id="shipday_pickup_time_slot_start_hh" name="shipday_pickup_time_slot_start_hh"
    253258                       class="shipday-time-input__field"
    254                        value="<?php echo $start_pickup_slot['hh'] ?>"
     259                       value="<?php echo esc_attr( $start_pickup_slot['hh'] ); ?>"
    255260                />
    256261              </div>
     
    263268                       type="number" min="0" max="59" step="5" id="shipday_pickup_time_slot_start_mm" name="shipday_pickup_time_slot_start_mm"
    264269                       class="shipday-time-input__field"
    265                        value="<?php echo $start_pickup_slot['mm'] ?>"
     270                       value="<?php echo esc_attr( $start_pickup_slot['mm'] ); ?>"
    266271                />
    267272              </div>
     
    274279                    class="shipday-ampm-select__field sd-text-input"
    275280                >
    276                   <option value="AM" <?php echo ($start_pickup_slot["ampm"]==="AM") ? "selected" : "" ?> >AM</option>
    277                   <option value="PM" <?php echo ($start_pickup_slot["ampm"]==="PM") ? "selected" : "" ?> >PM</option>
     281                  <option value="AM" <?php selected( $start_pickup_slot['ampm'], 'AM' ); ?>>AM</option>
     282                  <option value="PM" <?php selected( $start_pickup_slot['ampm'], 'PM' ); ?>>PM</option>
    278283                </select>
    279284              </div>
     
    293298                       type="number"  min="1"  max="12" step="1"  id="shipday_pickup_time_slot_end_hh" name="shipday_pickup_time_slot_end_hh"
    294299                       class="shipday-time-input__field"
    295                        value="<?php echo $end_pickup_slot['hh'] ?>"
     300                       value="<?php echo esc_attr( $end_pickup_slot['hh'] ); ?>"
    296301                />
    297302              </div>
     
    304309                       type="number" min="0" max="59" step="5" id="shipday_pickup_time_slot_end_mm" name="shipday_pickup_time_slot_end_mm"
    305310                       class="shipday-time-input__field"
    306                        value="<?php echo $end_pickup_slot['mm'] ?>"
     311                       value="<?php echo esc_attr( $end_pickup_slot['mm'] ); ?>"
    307312                />
    308313              </div>
     
    315320                    class="shipday-ampm-select__field sd-text-input"
    316321                >
    317                   <option value="AM" <?php echo ($end_pickup_slot["ampm"]==="AM") ? "selected" : "" ?> >AM</option>
    318                   <option value="PM" <?php echo ($end_pickup_slot["ampm"]==="PM") ? "selected" : "" ?> >PM</option>
     322                  <option value="AM" <?php selected( $end_pickup_slot['ampm'], 'AM' ); ?>>AM</option>
     323                  <option value="PM" <?php selected( $end_pickup_slot['ampm'], 'PM' ); ?>>PM</option>
    319324                </select>
    320325              </div>
     
    334339                  class="shipday-slot-duration-field__select sd-text-input"
    335340              >
    336                 <option value="10" <?php echo ($pickup_slot_duration === "10") ? "selected" : ""?>>10</option>
    337                 <option value="15" <?php echo ($pickup_slot_duration === "15") ? "selected" : ""?>>15</option>
    338                 <option value="30" <?php echo ($pickup_slot_duration === "30") ? "selected" : ""?>>30</option>
    339                 <option value="45" <?php echo ($pickup_slot_duration === "45") ? "selected" : ""?>>45</option>
    340                 <option value="60" <?php echo ($pickup_slot_duration === "60") ? "selected" : ""?>>60</option>
    341                 <option value="90" <?php echo ($pickup_slot_duration === "90") ? "selected" : ""?>>90</option>
    342                 <option value="120" <?php echo ($pickup_slot_duration === "120") ? "selected" : ""?>>120</option>
    343                 <option value="150" <?php echo ($pickup_slot_duration === "150") ? "selected" : ""?>>150</option>
    344                 <option value="180" <?php echo ($pickup_slot_duration === "180") ? "selected" : ""?>>180</option>
    345                 <option value="240" <?php echo ($pickup_slot_duration === "240") ? "selected" : ""?>>240</option>
    346                 <option value="300" <?php echo ($pickup_slot_duration === "300") ? "selected" : ""?>>300</option>
    347                 <option value="360" <?php echo ($pickup_slot_duration === "360") ? "selected" : ""?>>360</option>
     341                <option value="10" <?php selected( $pickup_slot_duration, '10' ); ?>>10</option>
     342                <option value="15" <?php selected( $pickup_slot_duration, '15' ); ?>>15</option>
     343                <option value="30" <?php selected( $pickup_slot_duration, '30' ); ?>>30</option>
     344                <option value="45" <?php selected( $pickup_slot_duration, '45' ); ?>>45</option>
     345                <option value="60" <?php selected( $pickup_slot_duration, '60' ); ?>>60</option>
     346                <option value="90" <?php selected( $pickup_slot_duration, '90' ); ?>>90</option>
     347                <option value="120" <?php selected( $pickup_slot_duration, '120' ); ?>>120</option>
     348                <option value="150" <?php selected( $pickup_slot_duration, '150' ); ?>>150</option>
     349                <option value="180" <?php selected( $pickup_slot_duration, '180' ); ?>>180</option>
     350                <option value="240" <?php selected( $pickup_slot_duration, '240' ); ?>>240</option>
     351                <option value="300" <?php selected( $pickup_slot_duration, '300' ); ?>>300</option>
     352                <option value="360" <?php selected( $pickup_slot_duration, '360' ); ?>>360</option>
    348353              </select>
    349354            </div>
  • shipday-for-woocommerce/trunk/admin/partials/tab-rest-api.php

    r3419924 r3483127  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) {
     4    exit;
     5}
     6// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Included admin partial uses file-scoped template variables.
    27  $consumer_key = get_option('wc_settings_tab_shipday_rest_api_consumer_key');
    38  $consumer_secret = get_option('wc_settings_tab_shipday_rest_api_consumer_secret');
     
    1621
    1722<div class="sd-panel-body">
    18   <p class="shipday-rest-api-notice"><span class="dashicons dashicons-yes"></span><?php _e(' Settings Changed Successfully', 'shipday-delivery'); ?></p>
     23  <p class="shipday-rest-api-notice"><span class="dashicons dashicons-yes"></span><?php esc_html_e( ' Settings Changed Successfully', 'shipday-for-woocommerce' ); ?></p>
    1924  <form action="" method="post" id ="shipday-rest-api-settings-form">
    2025      <?php wp_nonce_field('shipday_nonce'); ?>
     
    3136      <div class="sd-input-wrapper">
    3237        <input type="text" placeholder="Enter consumer Key" class="sd-text-input" name="shipday_consumer_key"
    33                value="<?php echo (isset($consumer_key) && !empty($consumer_key)) ? stripslashes($consumer_key) : '' ?>"
     38               value="<?php echo esc_attr( ! empty( $consumer_key ) ? wp_unslash( $consumer_key ) : '' ); ?>"
    3439        />
    3540      </div>
     
    4146      <div class="sd-input-wrapper">
    4247        <input type="text" placeholder="Enter consumer secret" class="sd-text-input" name="shipday_consumer_secret"
    43                value="<?php echo (isset($consumer_secret) && !empty($consumer_secret)) ? stripslashes($consumer_secret) : '' ?>"
     48               value="<?php echo esc_attr( ! empty( $consumer_secret ) ? wp_unslash( $consumer_secret ) : '' ); ?>"
    4449        />
    4550      </div>
  • shipday-for-woocommerce/trunk/admin/partials/tab-shipday-connect.php

    r3419924 r3483127  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) {
     4    exit;
     5}
     6// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Included admin partial uses file-scoped template variables.
    27$api_key = get_option('wc_settings_tab_shipday_api_key');
    38$pickup_order_enabled = get_option('wc_settings_tab_shipday_enable_pickup', "no") === "yes";
     
    2025
    2126<div class="sd-panel-body">
    22   <p class="shipday-connect-notice"><span class="dashicons dashicons-yes"></span><?php _e(' Settings Changed Successfully', 'shipday-delivery'); ?></p>
     27  <p class="shipday-connect-notice"><span class="dashicons dashicons-yes"></span><?php esc_html_e( ' Settings Changed Successfully', 'shipday-for-woocommerce' ); ?></p>
    2328  <form action="" method="post" id ="shipday-connect-settings-form">
    2429      <?php wp_nonce_field('shipday_nonce'); ?>
     
    3237        <div class="sd-input-wrapper">
    3338            <input type="text" placeholder="Enter API Key" class="sd-text-input" name="shipday_api_key"
    34                    value="<?php echo (isset($api_key) && !empty($api_key)) ? stripslashes($api_key) : '' ?>"
     39                   value="<?php echo esc_attr( ! empty( $api_key ) ? wp_unslash( $api_key ) : '' ); ?>"
    3540            />
    3641        </div>
     
    4853              name="wc_settings_tab_shipday_enable_pickup"
    4954              class="shipday-switch__input"
    50               <?php echo ($pickup_order_enabled) ? "checked" : "" ?>
     55              <?php checked( $pickup_order_enabled ); ?>
    5156          />
    5257          <span class="shipday-switch__track">
     
    7378              name="wc_settings_tab_shipday_sync"
    7479              class="shipday-switch__input"
    75               <?php echo ($order_sync_enabled) ? "checked" : "" ?>
     80              <?php checked( $order_sync_enabled ); ?>
    7681          />
    7782          <span class="shipday-switch__track">
     
    115120                    name="wc_settings_tab_shipday_order_manage"
    116121                    value="admin_manage"
    117                     <?php echo ($manage_order === 'admin_manage') ? 'checked' : ''; ?>
     122                    <?php checked( $manage_order, 'admin_manage' ); ?>
    118123                />
    119124                <span class="sd-radio__mark" aria-hidden="true"></span>
     
    127132                    name="wc_settings_tab_shipday_order_manage"
    128133                    value="vendor_manage"
    129                     <?php echo ($manage_order === 'vendor_manage') ? 'checked' : ''; ?>
     134                    <?php checked( $manage_order, 'vendor_manage' ); ?>
    130135                />
    131136                <span class="sd-radio__mark" aria-hidden="true"></span>
  • shipday-for-woocommerce/trunk/date-modifiers/Coderocks_Woo_Delivery.php

    r2692251 r3483127  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) {
     4    exit;
     5}
     6// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound -- Compatibility class mirrors the third-party integration name.
    27require_once dirname( __FILE__ ) . '/Date_Picker_Object.php';
    38
  • shipday-for-woocommerce/trunk/date-modifiers/Date_Picker_Object.php

    r2662253 r3483127  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) {
     4    exit;
     5}
     6// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound -- Compatibility class mirrors the third-party integration name.
    27
    38class Date_Picker_Object {
  • shipday-for-woocommerce/trunk/date-modifiers/Delivery_Area_Pro.php

    r2712411 r3483127  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) {
     4    exit;
     5}
     6// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound -- Compatibility class mirrors the third-party integration name.
    27
    38require_once dirname( __FILE__ ) . '/Date_Picker_Object.php';
  • shipday-for-woocommerce/trunk/date-modifiers/Order_Delivery_Date_Shipday.php

    r2670834 r3483127  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) {
     4    exit;
     5}
     6// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound -- Compatibility class mirrors the third-party integration name.
    27require_once dirname( __FILE__ ) . '/Date_Picker_Object.php';
    38
  • shipday-for-woocommerce/trunk/date-modifiers/order_delivery_date.php

    r2829892 r3483127  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) {
     4    exit;
     5}
     6// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- Compatibility helpers keep their legacy public names.
    27
    38require_once dirname( __DIR__ ) . '/functions/common.php';
  • shipday-for-woocommerce/trunk/dispatch_post/payload_post.php

    r3419924 r3483127  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) {
     4    exit;
     5}
     6// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound,WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- Legacy payload helpers are used across the plugin codebase.
    27require_once dirname(__DIR__). '/functions/logger.php';
    38require_once dirname(__DIR__). '/functions/common.php';
     
    1116{
    1217    global $single_vendor_webhook_url;
    13     $response = shipday_curl_post_payload($payload, $single_vendor_webhook_url);
     18    $response = shipday_http_post_payload($payload, $single_vendor_webhook_url);
    1419    if ($response['http_code'] != 200) {
    15         shipday_logger('error', 'Curl(single-vendor) failed with code: '.$response['http_code'].' Response: '.json_encode($response));
    16         $response = streams_post_payload($payload, $single_vendor_webhook_url);
    17     }
    18     if ($response['http_code'] != 200) {
    19         shipday_logger('error', 'Stream(single-vendor) failed with code: '.$response['http_code'].' Response: '.json_encode($response));
     20        shipday_logger('error', 'HTTP API(single-vendor) failed with code: '.$response['http_code'].' Response: '.json_encode($response));
    2021    }
    2122    return $response;
     
    2526{
    2627    global $multi_vendor_webhook_url;
    27     $response = shipday_curl_post_payload($payload, $multi_vendor_webhook_url);
     28    $response = shipday_http_post_payload($payload, $multi_vendor_webhook_url);
    2829    if ($response['http_code'] != 200) {
    29         shipday_logger('error', 'Curl(multi-vendor) failed with code: '.$response['http_code'].' Response: '.json_encode($response));
    30         $response = streams_post_payload($payload, $multi_vendor_webhook_url);
    31     }
    32     if ($response['http_code'] != 200) {
    33         shipday_logger('error', 'Stream(multi-vendor) failed with code: '.$response['http_code'].' Response: '.json_encode($response));
     30        shipday_logger('error', 'HTTP API(multi-vendor) failed with code: '.$response['http_code'].' Response: '.json_encode($response));
    3431    }
    3532    return $response;
     
    3936{
    4037    global $cancel_webhook_url;
    41     $response = shipday_curl_post_payload($payload, $cancel_webhook_url);
     38    $response = shipday_http_post_payload($payload, $cancel_webhook_url);
    4239    if ($response['http_code'] != 200) {
    43         shipday_logger('error', 'Curl(cancel-order) failed with code: '.$response['http_code'].' Response: '.json_encode($response));
    44         $response = streams_post_payload($payload, $cancel_webhook_url);
    45     }
    46     if ($response['http_code'] != 200) {
    47         shipday_logger('error', 'Stream(cancel-order) failed with code: '.$response['http_code'].' Response: '.json_encode($response));
     40        shipday_logger('error', 'HTTP API(cancel-order) failed with code: '.$response['http_code'].' Response: '.json_encode($response));
    4841    }
    4942    return $response;
    5043}
    5144
    52 function streams_post_payload(array $payload, $url) {
    53     $opts = array(
    54         'http' => array(
    55             'method' => 'POST',
    56             'header' => array(
    57                 'Content-Type: application/json'
     45function shipday_http_post_payload(array $payload, $url) {
     46    return shipday_remote_post(
     47        $url,
     48        array(
     49            'headers' => array(
     50                'Content-Type' => 'application/json',
    5851            ),
    59             'content' => json_encode($payload)
     52            'body'    => remove_emoji( wp_json_encode( $payload ) ),
    6053        )
    6154    );
    62     $context = stream_context_create($opts);
    63     file_get_contents($url, false, $context);
    64     return $http_response_header;
    6555}
    66 
    67 function shipday_curl_post_payload(array $payload, $url) {
    68     $curl = curl_init();
    69     curl_setopt_array(
    70         $curl,
    71         array(
    72             CURLOPT_URL            => $url,
    73             CURLOPT_RETURNTRANSFER => true,
    74             CURLOPT_ENCODING       => '',
    75             CURLOPT_MAXREDIRS      => 10,
    76             CURLOPT_TIMEOUT        => 0,
    77             CURLOPT_FOLLOWLOCATION => true,
    78             CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
    79             CURLOPT_CUSTOMREQUEST  => 'POST',
    80             CURLOPT_POSTFIELDS     => remove_emoji(json_encode($payload)),
    81             CURLOPT_HTTPHEADER     => array(
    82                 'Content-Type: application/json'
    83             )
    84         )
    85     );
    86     $response = curl_exec($curl);
    87     return curl_getinfo($curl);
    88 }
  • shipday-for-woocommerce/trunk/dispatch_post/post_fun.php

    r3336343 r3483127  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) {
     4    exit;
     5}
    26require_once dirname(__DIR__). '/functions/logger.php';
    37require_once dirname(__DIR__). '/functions/common.php';
     
    5559function shipday_post_order(array $payload, string $api_key, $url) {
    5660    if (strlen($api_key) < 3) return false;
    57     $response = shipday_curl_post_order($payload, $api_key, $url);
     61    $response = shipday_http_post_order($payload, $api_key, $url);
    5862    if ($response['http_code'] != 200) {
    59         shipday_logger('error', 'Curl failed with code: '.$response['http_code'].' Response: '.json_encode($response));
    60         shipday_logger('info', 'Trying with stream post order');
    61         $response = streams_post_order($payload, $api_key, $url);
    62     }
    63     if ($response['http_code'] != 200) {
    64         shipday_logger('error', 'Stream failed with code: '.$response['http_code'].' Response: '.json_encode($response));
     63        shipday_logger('error', 'HTTP API request failed with code: '.$response['http_code'].' Response: '.json_encode($response));
    6564    }
    6665    return $response;
    6766}
    6867
    69 function streams_post_order(array $payload, string $api_key, $url) {
    70     $opts = array(
    71         'http' => array(
    72             'method' => 'POST',
    73             'header' => array(
    74                 'Content-Type: application/json',
    75                 'Authorization: Basic '.$api_key,
     68function shipday_http_post_order(array $payload, string $api_key, $url) {
     69    return shipday_remote_post(
     70        $url,
     71        array(
     72            'headers' => array(
     73                'Authorization' => 'Basic ' . $api_key,
     74                'Content-Type'  => 'application/json',
    7675            ),
    77             'content' => json_encode($payload)
     76            'body'    => remove_emoji( wp_json_encode( $payload ) ),
    7877        )
    7978    );
    80     $context = stream_context_create($opts);
    81     file_get_contents($url, false, $context);
    82     return $http_response_header;
    8379}
    84 
    85 function shipday_curl_post_order(array $payload, string $api_key, $url) {
    86     $curl = curl_init();
    87     curl_setopt_array(
    88         $curl,
    89         array(
    90             CURLOPT_URL            => $url,
    91             CURLOPT_RETURNTRANSFER => true,
    92             CURLOPT_ENCODING       => '',
    93             CURLOPT_MAXREDIRS      => 10,
    94             CURLOPT_TIMEOUT        => 0,
    95             CURLOPT_FOLLOWLOCATION => true,
    96             CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
    97             CURLOPT_CUSTOMREQUEST  => 'POST',
    98             CURLOPT_POSTFIELDS     => remove_emoji(json_encode($payload)),
    99             CURLOPT_HTTPHEADER     => array(
    100                 'Authorization: Basic '.$api_key,
    101                 'Content-Type: application/json'
    102             )
    103         )
    104     );
    105     $response = curl_exec($curl);
    106     return curl_getinfo($curl);
    107 }
  • shipday-for-woocommerce/trunk/functions/common.php

    r3381147 r3483127  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) {
     4    exit;
     5}
     6// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound,WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- Legacy helper API is used across the plugin codebase.
    27
    38/** Global Variables */
     
    8994}
    9095
     96function shipday_remote_post( $url, array $args = array() ) {
     97    $request_args = wp_parse_args(
     98        $args,
     99        array(
     100            'method'      => 'POST',
     101            'timeout'     => 20,
     102            'redirection' => 5,
     103            'httpversion' => '1.1',
     104            'blocking'    => true,
     105        )
     106    );
     107
     108    $response = wp_safe_remote_post( esc_url_raw( $url ), $request_args );
     109
     110    if ( is_wp_error( $response ) ) {
     111        return array(
     112            'http_code' => 0,
     113            'body'      => $response->get_error_message(),
     114            'error'     => $response->get_error_code(),
     115        );
     116    }
     117
     118    return array(
     119        'http_code' => (int) wp_remote_retrieve_response_code( $response ),
     120        'body'      => wp_remote_retrieve_body( $response ),
     121        'headers'   => wp_remote_retrieve_headers( $response ),
     122    );
     123}
     124
    91125?>
  • shipday-for-woocommerce/trunk/functions/logger.php

    r2685513 r3483127  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) {
     4    exit;
     5}
    26/** Debug Functions */
    37function shipday_logger(string $level, string $message) {
  • shipday-for-woocommerce/trunk/order_data/Dokan_Order_Shipday.php

    r3336343 r3483127  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) {
     4    exit;
     5}
    26require_once dirname( __DIR__ ) . '/functions/common.php';
    37require_once dirname( __DIR__ ) . '/date-modifiers/order_delivery_date.php';
  • shipday-for-woocommerce/trunk/order_data/FoodStore_Order_Shipday.php

    r2685513 r3483127  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) {
     4    exit;
     5}
    26require_once dirname( __DIR__ ) . '/functions/common.php';
    37require_once dirname(__DIR__). '/date-modifiers/order_delivery_date.php';
    48require_once dirname( __FILE__ ) . '/Woo_Order_Shipday.php';
    59
     10// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound -- Legacy class name retained for backwards compatibility.
    611class FoodStore_Order_Shipday extends Woo_Order_Shipday
    712{
  • shipday-for-woocommerce/trunk/order_data/WCFM_Order_Shipday.php

    r3365528 r3483127  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) {
     4    exit;
     5}
    26
    37require_once dirname( __DIR__ ) . '/functions/common.php';
     
    610require_once dirname(__DIR__). '/date-modifiers/order_delivery_date.php';
    711
     12// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound -- Legacy class name retained for backwards compatibility.
    813class WCFM_Order_Shipday extends Woocommerce_Core_Shipday {
    914    protected $order;
     
    253258        } elseif (isset($times['expectedPickupDate'])) {
    254259            $result['expectedPickupDate'] = $times['expectedPickupDate'];
    255         } else {
    256             // Default to today if no date specified
    257             $result['expectedPickupDate'] = date('Y-m-d');
    258         }
    259        
    260         // If no time specified, set a default
    261         if (!isset($result['expectedPickupTime'])) {
    262             $result['expectedPickupTime'] = date('H:i:s', strtotime('+1 hour'));
    263         }
     260            } else {
     261                // Default to today if no date specified
     262                $result['expectedPickupDate'] = wp_date( 'Y-m-d' );
     263            }
     264           
     265            // If no time specified, set a default
     266            if (!isset($result['expectedPickupTime'])) {
     267                $result['expectedPickupTime'] = wp_date( 'H:i:s', time() + HOUR_IN_SECONDS );
     268            }
    264269       
    265270        return $result;
  • shipday-for-woocommerce/trunk/order_data/Woo_Order_Shipday.php

    r3365528 r3483127  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) {
     4    exit;
     5}
    26require_once dirname( __DIR__ ) . '/functions/common.php';
    37require_once dirname(__DIR__). '/date-modifiers/order_delivery_date.php';
    48require_once dirname( __FILE__ ) . '/Woocommerce_Core_Shipday.php';
    59
    6 
     10// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound -- Legacy class name retained for backwards compatibility.
    711class Woo_Order_Shipday extends Woocommerce_Core_Shipday {
    812    protected $order;
     
    200204        } elseif (isset($times['expectedPickupDate'])) {
    201205            $result['expectedPickupDate'] = $times['expectedPickupDate'];
    202         } else {
    203             // Default to today if no date specified
    204             $result['expectedPickupDate'] = date('Y-m-d');
    205         }
    206        
    207         // If no time specified, set a default
    208         if (!isset($result['expectedPickupTime'])) {
    209             $result['expectedPickupTime'] = date('H:i:s', strtotime('+1 hour'));
    210         }
     206            } else {
     207                // Default to today if no date specified
     208                $result['expectedPickupDate'] = wp_date( 'Y-m-d' );
     209            }
     210           
     211            // If no time specified, set a default
     212            if (!isset($result['expectedPickupTime'])) {
     213                $result['expectedPickupTime'] = wp_date( 'H:i:s', time() + HOUR_IN_SECONDS );
     214            }
    211215       
    212216        return $result;
  • shipday-for-woocommerce/trunk/order_data/Woocommerce_Core_Shipday.php

    r3365528 r3483127  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) {
     4    exit;
     5}
    26require_once dirname( __DIR__ ) . '/functions/common.php';
    37
     8// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound -- Legacy class name retained for backwards compatibility.
    49class Woocommerce_Core_Shipday {
    510    protected $order;
  • shipday-for-woocommerce/trunk/payload/Core_Payload.php

    r3381147 r3483127  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) {
     4    exit;
     5}
    26
    37require_once dirname(__DIR__) . '/functions/common.php';
    48
     9// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound -- Legacy class name retained for backwards compatibility.
    510class _CorePayload
    611{
  • shipday-for-woocommerce/trunk/payload/Dokan_Payload.php

    r3457794 r3483127  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) {
     4    exit;
     5}
    26
    37require_once dirname(__DIR__) . '/functions/common.php';
  • shipday-for-woocommerce/trunk/payload/FoodStore_Payload.php

    r3381147 r3483127  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) {
     4    exit;
     5}
    26
    37require_once dirname(__DIR__) . '/functions/common.php';
     
    59require_once dirname(__FILE__) . '/Core_Payload.php';
    610
    7 
     11// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound -- Legacy class name retained for backwards compatibility.
    812class FoodStore_Payload extends _CorePayload
    913{
  • shipday-for-woocommerce/trunk/payload/WCFM_Payload.php

    r3381147 r3483127  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) {
     4    exit;
     5}
    26
    37require_once dirname(__DIR__) . '/functions/common.php';
     
    59require_once dirname(__FILE__) . '/Core_Payload.php';
    610
    7 
     11// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound -- Legacy class name retained for backwards compatibility.
    812class WCFM_Payload extends _CorePayload
    913{
  • shipday-for-woocommerce/trunk/payload/Woo_Payload.php

    r3381147 r3483127  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) {
     4    exit;
     5}
    26
    37require_once dirname(__DIR__) . '/functions/common.php';
     
    59require_once dirname(__FILE__) . '/Core_Payload.php';
    610
    7 
     11// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound -- Legacy class name retained for backwards compatibility.
    812class Woo_Payload extends _CorePayload
    913{
  • shipday-for-woocommerce/trunk/readme.txt

    r3467875 r3483127  
    1 === Local Delivery App for WordPress (WooCommerce) by Shipday ===
    2 Contributors: shipdayinc, shhrrtnvr
    3 Tags: delivery tracking, route-planning, delivery/pickup datetime, delivery dispatch, same day delivery, local pickup, local delivery, driver app
     1=== Shipday Local Delivery for WooCommerce ===
     2Contributors: shipdayinc, shhrrtnvr, shammo, hadi
     3Tags: local delivery, delivery tracking, woocommerce delivery, same day delivery, driver app
    44Requires at least: 5.8
    5 Tested up to: 6.8
     5Tested up to: 6.9
    66WC requires at least: 7.0.0
    77WC tested up to: 9.8.2
    88Requires PHP: 7.4
    9 Stable tag: 2.2.0
     9Stable tag: 2.3.0
    1010License: GPLv2 or later
     11
     12Shipday adds local delivery and pickup workflows, dispatch sync, and checkout date/time selection to WooCommerce.
    1113
    1214== Description ==
     
    116118* Datetime support in the order checkout
    117119* New admin configuration page
    118 
    119 
  • shipday-for-woocommerce/trunk/rest_api/WooCommerce_REST_API.php

    r3419924 r3483127  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) {
     4    exit;
     5}
    26
    37require_once dirname(__DIR__). '/functions/common.php';
    48
     9// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound -- Legacy class name retained for backwards compatibility.
    510class WooCommerce_REST_API {
    611
     
    1116    public static function is_consumer_secret_valid($consumer_secret) {
    1217        global $wpdb;
     18        $cache_key = 'shipday_rest_api_secret_' . md5( $consumer_secret );
     19        $rest_api_key = wp_cache_get( $cache_key, 'shipday' );
     20        if ( false !== $rest_api_key ) {
     21            return ! is_null( $rest_api_key );
     22        }
     23        // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching -- WooCommerce stores API keys in a custom table; result is cached immediately below.
    1324        $rest_api_key = $wpdb->get_row(
    1425            $wpdb->prepare(
     
    2334            ARRAY_A
    2435        );
     36        wp_cache_set( $cache_key, $rest_api_key, 'shipday', MINUTE_IN_SECONDS * 5 );
    2537        return !is_null($rest_api_key);
    2638    }
     
    3648    public static function is_consumer_keys_valid($consumer_key, $consumer_secret) {
    3749        global $wpdb;
    38         $rest_api_key = $wpdb->get_row(
    39             $wpdb->prepare(
    40                 "
     50        $cache_key = 'shipday_rest_api_keys_' . md5( $consumer_secret );
     51        $rest_api_key = wp_cache_get( $cache_key, 'shipday' );
     52        if ( false === $rest_api_key ) {
     53            // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching -- WooCommerce stores API keys in a custom table; result is cached immediately below.
     54            $rest_api_key = $wpdb->get_row(
     55                $wpdb->prepare(
     56                    "
    4157                    SELECT consumer_key, consumer_secret, truncated_key, permissions
    4258                    FROM {$wpdb->prefix}woocommerce_api_keys
     
    4460                      and permissions = 'read_write'
    4561                ",
    46                 $consumer_secret
    47             ),
    48             ARRAY_A
    49         );
     62                    $consumer_secret
     63                ),
     64                ARRAY_A
     65            );
     66            wp_cache_set( $cache_key, $rest_api_key, 'shipday', MINUTE_IN_SECONDS * 5 );
     67        }
    5068        return !is_null($rest_api_key) && self::str_ends_with($consumer_key, $rest_api_key['truncated_key']);
    5169    }
     
    8098        $url              = get_rest_url();
    8199
    82         $curl             = curl_init();
    83         curl_setopt_array(
    84             $curl,
     100        $response = shipday_remote_post(
     101            get_shipday_rest_key_install_url(),
    85102            array(
    86                 CURLOPT_URL            => get_shipday_rest_key_install_url(),
    87                 CURLOPT_RETURNTRANSFER => true,
    88                 CURLOPT_ENCODING       => '',
    89                 CURLOPT_MAXREDIRS      => 10,
    90                 CURLOPT_TIMEOUT        => 0,
    91                 CURLOPT_FOLLOWLOCATION => true,
    92                 CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
    93                 CURLOPT_CUSTOMREQUEST  => 'POST',
    94                 CURLOPT_POSTFIELDS     => '{
    95                         "url": "' . $url . '",
    96                         "consumer_key": "' . $key . '",
    97                         "consumer_secret": "' . $secret . '"
    98                         }',
    99                 CURLOPT_HTTPHEADER     => array(
    100                     'Authorization: Basic '. get_shipday_api_key(),
    101                     'Content-Type: application/json',
     103                'headers' => array(
     104                    'Authorization' => 'Basic ' . get_shipday_api_key(),
     105                    'Content-Type'  => 'application/json',
     106                ),
     107                'body'    => wp_json_encode(
     108                    array(
     109                        'url'             => $url,
     110                        'consumer_key'    => $key,
     111                        'consumer_secret' => $secret,
     112                    )
    102113                ),
    103114            )
    104115        );
    105116
    106         $response        = curl_exec($curl);
    107         if (is_null($response)) return null;
    108         $response_decoded = json_decode($response);
     117        if ( empty( $response['body'] ) ) {
     118            return null;
     119        }
     120
     121        $response_decoded = json_decode( $response['body'] );
    109122        if (!isset($response_decoded->success)) return null;
    110123        $uuid            = $response_decoded->uuid;
  • shipday-for-woocommerce/trunk/shipday-datetime/block-checkout/Shipday_Woo_DateTime_Util.php

    r3467875 r3483127  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) {
     4    exit;
     5}
    26
    37
     
    3034
    3135        // Other settings
    32         $data['delivery_heading_checkout'] = get_option('shipday_delivery_pickup_label', __("Delivery/Pickup info", "shipday-woo-delivery"));
     36        $data['delivery_heading_checkout'] = get_option('shipday_delivery_pickup_label', __("Delivery/Pickup info", "shipday-for-woocommerce"));
    3337        $data['enable_delivery_option'] = get_option('shipday_enable_delivery_option', "no") === "yes";
    34         $data['delivery_option_field_label'] = __("Order Option", "shipday-woo-delivery");
    35         $data['delivery_options'] = ["Delivery" => __("Delivery", "shipday-woo-delivery"), "Pickup" => __("Pickup", "shipday-woo-delivery")];
     38        $data['delivery_option_field_label'] = __("Order Option", "shipday-for-woocommerce");
     39        $data['delivery_options'] = ["Delivery" => __("Delivery", "shipday-for-woocommerce"), "Pickup" => __("Pickup", "shipday-for-woocommerce")];
    3640
    3741        // Delivery dates
     
    3943        $data['delivery_date_selectable_days'] = get_option('shipday_selectable_delivery_days', 30);
    4044        $data['delivery_disable_week_days'] = self::get_disable_week_days(get_option('shipday_avaialble_delivery_days', self::WEEK_DAYS));
    41         $data['delivery_date_field_label'] = __("Delivery Date", "shipday-woo-delivery");
     45        $data['delivery_date_field_label'] = __("Delivery Date", "shipday-for-woocommerce");
    4246        $data['auto_select_first_date'] = true;
    4347        $data['delivery_date_mandatory'] = get_option('shipday_delivery_date_mandatory', "no") === "yes";
     
    4751        // Delivery times
    4852        $data['enable_delivery_time'] = get_option('shipday_enable_delivery_time', "no") === "yes";
    49         $data['delivery_time_field_label'] = __("Delivery Time", "shipday-woo-delivery");
     53        $data['delivery_time_field_label'] = __("Delivery Time", "shipday-for-woocommerce");
    5054        $data['delivery_time_mandatory'] = get_option('shipday_delivery_time_mandatory', "no") === "yes";;
    5155        $data['auto_select_first_time'] = false;
     
    6064        $data['pickup_date_selectable_days'] = get_option('shipday_selectable_pickup_days', 15);
    6165        $data['pickup_disable_week_days'] = self::get_disable_week_days(get_option('shipday_avaialble_pickup_days', self::WEEK_DAYS));
    62         $data['pickup_date_field_label'] = __("Pickup Date", "shipday-woo-delivery");
     66        $data['pickup_date_field_label'] = __("Pickup Date", "shipday-for-woocommerce");
    6367        $data['pickup_auto_select_first_date'] = true;
    6468        $data['pickup_date_mandatory'] = get_option('shipday_pickup_date_mandatory', "no") === "yes";;
     
    6973        // Pickup times
    7074        $data['enable_pickup_time'] = get_option('shipday_enable_pickup_time', "no") === "yes";
    71         $data['pickup_time_field_label'] = __("Pickup Time", "shipday-woo-delivery");
     75        $data['pickup_time_field_label'] = __("Pickup Time", "shipday-for-woocommerce");
    7276        $data['pickup_time_mandatory'] = get_option('shipday_pickup_time_mandatory', "no") === "yes";
    7377        $data['pickup_auto_select_first_time'] = false;
     
    8791
    8892        // Localization
    89         $data['checkout_delivery_option_notice'] = __("Please select order type", "shipday-woo-delivery");
    90         $data['checkout_date_notice'] = __("Please enter delivery date", "shipday-woo-delivery");
    91         $data['checkout_pickup_date_notice'] = __("Please enter pickup date", "shipday-woo-delivery");
    92         $data['checkout_time_notice'] = __("Please select delivery time", "shipday-woo-delivery");
    93         $data['checkout_pickup_time_notice'] = __("Please select pickup time", "shipday-woo-delivery");
    94         $data['select_order_type_text'] = __("Select order type", "shipday-woo-delivery");
    95         $data['select_delivery_time_text'] = __("Select delivery time", "shipday-woo-delivery");
    96         $data['select_pickup_time_text'] = __("Select pickup time", "shipday-woo-delivery");
     93        $data['checkout_delivery_option_notice'] = __("Please select order type", "shipday-for-woocommerce");
     94        $data['checkout_date_notice'] = __("Please enter delivery date", "shipday-for-woocommerce");
     95        $data['checkout_pickup_date_notice'] = __("Please enter pickup date", "shipday-for-woocommerce");
     96        $data['checkout_time_notice'] = __("Please select delivery time", "shipday-for-woocommerce");
     97        $data['checkout_pickup_time_notice'] = __("Please select pickup time", "shipday-for-woocommerce");
     98        $data['select_order_type_text'] = __("Select order type", "shipday-for-woocommerce");
     99        $data['select_delivery_time_text'] = __("Select delivery time", "shipday-for-woocommerce");
     100        $data['select_pickup_time_text'] = __("Select pickup time", "shipday-for-woocommerce");
    97101
    98102        return $data;
  • shipday-for-woocommerce/trunk/shipday-datetime/block-checkout/Shipday_Woo_Delivery_Block.php

    r3420256 r3483127  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) {
     4    exit;
     5}
    26
    37use Automattic\WooCommerce\StoreApi\Schemas\V1\CartSchema;
     
    711    protected static $instance = null;
    812    static $IDENTIFIER = 'shipday_woo_delivery';
     13    static $BLOCK_NAME = 'shipday-for-woocommerce/delivery-block';
    914
    1015    private function __clone() {}
     
    3843
    3944    function register_woo_delivery_block() {
    40         register_block_type( 'shipday-woo-delivery/delivery-block' );
     45        register_block_type( self::$BLOCK_NAME );
    4146    }
    4247
     
    98103            'shipday_order_type'    => array(
    99104                'type'        => ['string', 'null'],
    100                 'description' => __( 'Type of order', 'shipday-delivery' ),
     105                'description' => __( 'Type of order', 'shipday-for-woocommerce' ),
    101106                'enum'        => array_merge( array_keys( $settings['delivery_options'] ), ["", null] ),
    102107            ),
    103108            'shipday_delivery_date' => array(
    104109                'type'        => ['string', 'null'],
    105                 'description' => __( 'Delivery Date', 'shipday-delivery' ),
     110                'description' => __( 'Delivery Date', 'shipday-for-woocommerce' ),
    106111            ),
    107112            'shipday_delivery_time' => array(
    108113                'type'        => ['string', 'null'],
    109                 'description' => __( 'Delivery Time', 'shipday-delivery' ),
     114                'description' => __( 'Delivery Time', 'shipday-for-woocommerce' ),
    110115            ),
    111116            'shipday_pickup_date' => array(
    112117                'type'        => ['string', 'null'],
    113                 'description' => __( 'Pickup Date', 'shipday-delivery' ),
     118                'description' => __( 'Pickup Date', 'shipday-for-woocommerce' ),
    114119            ),
    115120            'pickup_time' => array(
    116121                'type'        => ['string', 'null'],
    117                 'description' => __( 'Pickup Time', 'shipday-delivery' ),
     122                'description' => __( 'Pickup Time', 'shipday-for-woocommerce' ),
    118123            ),
    119124        );
  • shipday-for-woocommerce/trunk/shipday-datetime/block-checkout/Shipday_Woo_Delivery_Block_Integration.php

    r3457794 r3483127  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) {
     4    exit;
     5}
    26
    37use Automattic\WooCommerce\Blocks\Integrations\IntegrationInterface;
     
    6569        wp_register_script( $this->get_name(), plugin_dir_url( __FILE__ ) . 'assets/js/frontend.js', array( 'wp-plugins', 'wp-element', 'wp-components', 'wp-hooks', 'wp-i18n', 'wc-blocks-checkout', 'flatpickr_js' ), "2.0.1", true );
    6670
    67         wp_enqueue_style( $this->get_name(), plugin_dir_url( __FILE__ ) . 'assets/css/frontend.css', "2.1.4" );
     71        wp_enqueue_style( $this->get_name(), plugin_dir_url( __FILE__ ) . 'assets/css/frontend.css', array(), "2.1.4" );
    6872    }
    6973
  • shipday-for-woocommerce/trunk/shipday-datetime/block-checkout/Shipday_Woo_Delivery_Block_Storage.php

    r3420256 r3483127  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) {
     4    exit;
     5}
    26
    37class Shipday_Woo_Delivery_Block_Storage {
     
    3640        if ( $errors->has_errors() ) {
    3741            $error_messages = $errors->get_error_messages();
    38             $combined_error_message = implode( "<br>", $error_messages );
    39             throw new \WC_Data_Exception( 'SHIPDAY_WOO_ERROR', $combined_error_message );
     42            throw new \WC_Data_Exception(
     43                'SHIPDAY_WOO_ERROR',
     44                esc_html( implode( ' ', array_map( 'sanitize_text_field', $error_messages ) ) )
     45            );
    4046        }
    4147
  • shipday-for-woocommerce/trunk/shipday-datetime/block-checkout/assets/js/frontend.js

    r3457794 r3483127  
    5050  const validateField = (value, fieldType) => {
    5151    let errorKey = "shipday_woo_" + fieldType + "_error";
    52     let errorMessage =  __('This field is mandatory', 'shipday-woo-delivery' );
     52    let errorMessage =  __('This field is mandatory', 'shipday-for-woocommerce' );
    5353    let isRequired = false;
    5454
    5555    // Determine error message and required status based on field type
    5656    if (fieldType === "shipday_order_type") {
    57       errorMessage = __( 'Order type is required', 'shipday-woo-delivery' );
     57      errorMessage = __( 'Order type is required', 'shipday-for-woocommerce' );
    5858      isRequired = shipdaySettings.enable_delivery_option;
    5959      errorKey = "shipday_woo_order_type_error";
    6060    } else if (fieldType === "shipday_delivery_date") {
    61       errorMessage = __( 'Delivery date is required', 'shipday-woo-delivery' );
     61      errorMessage = __( 'Delivery date is required', 'shipday-for-woocommerce' );
    6262      errorKey = "shipday_woo_delivery_date_error";
    6363      isRequired = shipdaySettings.enable_delivery_date && shipdaySettings.delivery_date_mandatory;
    6464    } else if (fieldType === "shipday_delivery_time") {
    65       errorMessage =  __('Delivery time is mandatory', 'shipday-woo-delivery' );
     65      errorMessage =  __('Delivery time is mandatory', 'shipday-for-woocommerce' );
    6666      errorKey = "shipday_woo_delivery_time_error";
    6767      isRequired = shipdaySettings.enable_delivery_time && shipdaySettings.delivery_time_mandatory;
    6868    } else if (fieldType === "shipday_pickup_date") {
    69       errorMessage = __('Pickup date is mandatory', 'shipday-woo-delivery' );
     69      errorMessage = __('Pickup date is mandatory', 'shipday-for-woocommerce' );
    7070      isRequired = shipdaySettings.enable_pickup_date && shipdaySettings.pickup_date_mandatory;
    7171    }else if (fieldType === "pickup_time") {
    72       errorMessage = __('Pickup time is mandatory', 'shipday-woo-delivery' );
     72      errorMessage = __('Pickup time is mandatory', 'shipday-for-woocommerce' );
    7373      isRequired = shipdaySettings.enable_pickup_time && shipdaySettings.pickup_time_mandatory;
    7474    }
     
    682682        });
    683683
    684         let fieldLabel = __('Pickup time', 'shipday-woo-delivery');
     684        let fieldLabel = __('Pickup time', 'shipday-for-woocommerce');
    685685
    686686        // Generate options for the select dropdown
     
    726726                React.createElement("option", {
    727727                  value: ""
    728                 }, __('Select pickup slot', 'shipday-woo-delivery')),
     728                }, __('Select pickup slot', 'shipday-for-woocommerce')),
    729729
    730730                // Time options
     
    891891  shipday_woo_delivery_metadata = {
    892892    apiVersion: 3,
    893     name: "shipday-woo-delivery",
     893    name: "shipday-for-woocommerce/delivery-block",
    894894    title: "Shipday Woocommerce",
    895895    category: "woocommerce",
  • shipday-for-woocommerce/trunk/shipday-datetime/classic-checkout/Classic_Datetime.php

    r3467875 r3483127  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) {
     4    exit;
     5}
    26/**
    37 * Plugin Name: Shipday Datetime
     
    1115require_once dirname(__FILE__) . '../../block-checkout/Shipday_Woo_DateTime_Util.php';
    1216
     17// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound -- Legacy class name retained for backwards compatibility.
    1318class Classic_Datetime {
    1419
     
    5560        // Delivery dates
    5661        $enable_delivery_date = get_option('shipday_enable_delivery_date', "no") === "yes";
    57         $delivery_date_field_label =  __('Delivery Date', 'shipday-woo-delivery' );
     62        $delivery_date_field_label =  __('Delivery Date', 'shipday-for-woocommerce' );
    5863        $delivery_date_mandatory = get_option('shipday_delivery_date_mandatory', "no") === "yes";
    5964        $delivery_date_selectable_days = get_option('shipday_selectable_delivery_days', 30);
     
    6469        // Pickup dates
    6570        $enable_pickup_date = get_option('shipday_enable_pickup_date', "no") === "yes";
    66         $pickup_date_field_label =  __('Pickup Date', 'shipday-woo-delivery' );
     71        $pickup_date_field_label =  __('Pickup Date', 'shipday-for-woocommerce' );
    6772        $pickup_date_mandatory = get_option('shipday_pickup_date_mandatory', "no") === "yes";
    6873
     
    7176        $pickup_auto_select_first_date = true;
    7277
    73         echo "<div data-today_date='" . $today . "'  id='shipday_woo_delivery_setting_wrapper'>";
    74 
    75         $order_type_label = get_option('shipday_delivery_pickup_label', __('Delivery/Pickup info', 'shipday-woo-delivery'));
     78        echo '<div data-today_date="' . esc_attr( $today ) . '" id="shipday_woo_delivery_setting_wrapper">';
     79
     80        $order_type_label = get_option('shipday_delivery_pickup_label', __('Delivery/Pickup info', 'shipday-for-woocommerce'));
    7681
    7782        // delivery options
     
    8590                    ],
    8691                    'label'       => $order_type_label,
    87                     'placeholder' => __('Choose Option', 'shipday-woo-delivery'),
     92                    'placeholder' => __('Choose Option', 'shipday-for-woocommerce'),
    8893                    'options'     => Classic_Datetime::getDeliveryoptions(),
    8994                    'required'    => true,
     
    103108                    'id' => "shipday_delivery_date_datepicker",
    104109                    'label' => $delivery_date_field_label,
    105                     'placeholder' => __('Choose Date', 'shipday-woo-delivery'),
     110                    'placeholder' => __('Choose Date', 'shipday-for-woocommerce'),
    106111                    'required' => $delivery_date_mandatory,
    107112                    'custom_attributes' => [
     
    118123        // Delivery Time --------------------------------------------------------------
    119124        $enable_delivery_time = get_option('shipday_enable_delivery_time', "no") === "yes";
    120         $delivery_time_field_label = __('Delivery Time', 'shipday-woo-delivery');
     125        $delivery_time_field_label = __('Delivery Time', 'shipday-for-woocommerce');
    121126        $delivery_time_mandatory = get_option('shipday_delivery_time_mandatory', "no") === "yes";
    122127        $auto_select_first_time = false;
     
    172177        // Pickup Time --------------------------------------------------------------
    173178        $enable_pickup_time =  get_option('shipday_enable_pickup_time', "no") === "yes";
    174         $pickup_time_field_label = __('Pickup time', 'shipday-woo-delivery');
     179        $pickup_time_field_label = __('Pickup time', 'shipday-for-woocommerce');
    175180        $pickup_time_mandatory = get_option('shipday_pickup_time_mandatory', "no") === "yes";
    176181        $start_pickup_slot = get_option('shipday_pickup_time_slot_start', Shipday_Woo_DateTime_Util::DEFAULT_START_SLOT);
     
    204209    }
    205210
     211    private static function has_valid_checkout_nonce() {
     212        // phpcs:ignore WordPress.Security.NonceVerification.Missing -- This helper performs the checkout nonce validation itself.
     213        if ( ! isset( $_POST['woocommerce-process-checkout-nonce'] ) ) {
     214            return false;
     215        }
     216
     217        // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Nonce is being verified in this helper.
     218        $nonce = sanitize_text_field( wp_unslash( $_POST['woocommerce-process-checkout-nonce'] ) );
     219
     220        return (bool) wp_verify_nonce( $nonce, 'woocommerce-process_checkout' );
     221    }
     222
     223    private static function get_checkout_post_value( $key ) {
     224        // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Callers gate access with self::has_valid_checkout_nonce().
     225        if ( ! isset( $_POST[ $key ] ) ) {
     226            return '';
     227        }
     228
     229        // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Callers gate access with self::has_valid_checkout_nonce().
     230        return sanitize_text_field( wp_unslash( $_POST[ $key ] ) );
     231    }
     232
    206233    public static function validate_before_save() {
    207234        /*
    208235        if ( self::is_required() && empty( $_POST['shipday_delivery_datetime'] ) ) {
    209             wc_add_notice( __( 'Please choose your preferred delivery date & time.', 'shipday-datetime' ), 'error' );
     236            wc_add_notice( __( 'Please choose your preferred delivery date & time.', 'shipday-for-woocommerce' ), 'error' );
    210237        }
    211238        */
     
    221248        $enable_pickup_time =  get_option('shipday_enable_pickup_time', "no") === "yes";
    222249        $pickup_time_mandatory = get_option('shipday_pickup_time_mandatory', "no") === "yes";
     250        if ( ! self::has_valid_checkout_nonce() ) {
     251            return;
     252        }
     253
     254        $order_type = self::get_checkout_post_value( 'shipday_order_type_field' );
     255        $delivery_date = self::get_checkout_post_value( 'shipday_delivery_date_field' );
     256        $pickup_date = self::get_checkout_post_value( 'shipday_pickup_date_field' );
     257        $pickup_time = self::get_checkout_post_value( 'shipday_pickup_time_field' );
     258        $delivery_time = self::get_checkout_post_value( 'shipday_delivery_time_field' );
    223259
    224260
    225261
    226262        if ( $enable_datetime_plugin && $enable_delivery_option ) {
    227             if (!isset( $_POST['shipday_order_type_field'] ) || $_POST['shipday_order_type_field'] === "" ||  $_POST['shipday_order_type_field'] === "Choose Option" ) {
    228                 wc_add_notice( __( "Please select order type", "shipday-woo-delivery" ), 'error' );
     263            if ( '' === $order_type || 'Choose Option' === $order_type ) {
     264                wc_add_notice( __( "Please select order type", "shipday-for-woocommerce" ), 'error' );
    229265            }
    230266
    231267        }
    232268        if ( $enable_datetime_plugin  && $enable_delivery_date && $delivery_date_mandatory &&
    233             (!$enable_delivery_option || $_POST['shipday_order_type_field'] === "Delivery")
     269            (!$enable_delivery_option || 'Delivery' === $order_type)
    234270        ) {
    235271
    236             if (!isset($_POST['shipday_delivery_date_field']) || $_POST['shipday_delivery_date_field'] === "" ) {
    237                 wc_add_notice( __( "Please enter delivery date", "shipday-woo-delivery" ), 'error' );
     272            if ( '' === $delivery_date ) {
     273                wc_add_notice( __( "Please enter delivery date", "shipday-for-woocommerce" ), 'error' );
    238274            }
    239275
    240276        }
    241277        if ( $enable_datetime_plugin  && $enable_pickup_date && $pickup_date_mandatory &&
    242             (!$enable_delivery_option || $_POST['shipday_order_type_field'] === "Pickup")
     278            (!$enable_delivery_option || 'Pickup' === $order_type)
    243279        ) {
    244             if (!isset($_POST['shipday_pickup_date_field']) || $_POST['shipday_pickup_date_field'] === "" || $_POST['shipday_pickup_date_field'] ==="Pickup Date" ) {
    245                 wc_add_notice( __( "Please enter pickup date", "shipday-woo-delivery" ), 'error' );
     280            if ( '' === $pickup_date || 'Pickup Date' === $pickup_date ) {
     281                wc_add_notice( __( "Please enter pickup date", "shipday-for-woocommerce" ), 'error' );
    246282            }
    247283
    248284        }
    249285        if ( $enable_datetime_plugin  && $enable_pickup_time && $pickup_time_mandatory &&
    250             (!$enable_delivery_option || $_POST['shipday_order_type_field'] === "Pickup")
     286            (!$enable_delivery_option || 'Pickup' === $order_type)
    251287        ) {
    252288
    253             if (!isset($_POST['shipday_pickup_time_field']) || is_null($_POST['shipday_pickup_time_field']) || $_POST['shipday_pickup_time_field'] === "") {
    254                 wc_add_notice( __( "Please select pickup time", "shipday-woo-delivery" ), 'error' );
     289            if ( '' === $pickup_time ) {
     290                wc_add_notice( __( "Please select pickup time", "shipday-for-woocommerce" ), 'error' );
    255291            }
    256292
    257293        }
    258294        if ( $enable_datetime_plugin  && $enable_delivery_time && $delivery_time_mandatory &&
    259             (!$enable_delivery_option || $_POST['shipday_order_type_field'] === "Delivery")
     295            (!$enable_delivery_option || 'Delivery' === $order_type)
    260296        ) {
    261             if (!isset($_POST['shipday_delivery_time_field']) || is_null($_POST['shipday_delivery_time_field']) || $_POST['shipday_delivery_time_field'] === "") {
    262                 wc_add_notice( __( "Please select delivery time", "shipday-woo-delivery" ), 'error' );
     297            if ( '' === $delivery_time ) {
     298                wc_add_notice( __( "Please select delivery time", "shipday-for-woocommerce" ), 'error' );
    263299            }
    264300
     
    270306
    271307    public static function getDeliveryoptions() {
    272         $delivery_option['Delivery'] = __( "Delivery", "shipday-woo-delivery" );
    273         $delivery_option['Pickup'] = __( "Pickup", "shipday-woo-delivery" );
     308        $delivery_option['Delivery'] = __( "Delivery", "shipday-for-woocommerce" );
     309        $delivery_option['Pickup'] = __( "Pickup", "shipday-for-woocommerce" );
    274310        return $delivery_option;
    275311    }
     
    277313    public static function classic_save( $order_id) {
    278314        if ( ! function_exists('is_checkout') || ! is_checkout() ) return;
     315        if ( ! self::has_valid_checkout_nonce() ) {
     316            return;
     317        }
    279318        $order = wc_get_order( $order_id );
    280319
     
    286325        $enable_pickup_time =  get_option('shipday_enable_pickup_time', "no") === "yes";
    287326
    288         $order_type = sanitize_text_field( wp_unslash( $_POST['shipday_order_type_field'] ) );
    289         if ( $enable_datetime_plugin && $enable_order_type && isset( $_POST['shipday_order_type_field'] ) ) {
     327        $order_type = self::get_checkout_post_value( 'shipday_order_type_field' );
     328        if ( $enable_datetime_plugin && $enable_order_type && '' !== $order_type ) {
    290329            if ( $order_type !== '' ) {
    291330                if ( self::$hpos === true ) {
     
    296335            }
    297336        }
    298         if ( $enable_datetime_plugin && (!$enable_order_type || $order_type==='Delivery') && $enable_delivery_date && isset( $_POST['shipday_delivery_date_field'] ) ) {
    299             $val = sanitize_text_field( wp_unslash( $_POST['shipday_delivery_date_field'] ) );
     337        if ( $enable_datetime_plugin && (!$enable_order_type || $order_type==='Delivery') && $enable_delivery_date ) {
     338            $val = self::get_checkout_post_value( 'shipday_delivery_date_field' );
    300339            shipday_logger('error', 'datetime : '.$val);
    301340            if ( $val !== '' ) {
     
    307346            }
    308347        }
    309         if ( $enable_datetime_plugin && (!$enable_order_type || $order_type==='Delivery') && $enable_delivery_time && isset( $_POST['shipday_delivery_time_field'] ) ) {
    310             $val_time = sanitize_text_field( $_POST['shipday_delivery_time_field'] );
     348        if ( $enable_datetime_plugin && (!$enable_order_type || $order_type==='Delivery') && $enable_delivery_time ) {
     349            $val_time = self::get_checkout_post_value( 'shipday_delivery_time_field' );
    311350            if ( $val_time !== '' ) {
    312351                if ( self::$hpos === true ) {
     
    318357        }
    319358
    320         if ( $enable_datetime_plugin && (!$enable_order_type || $order_type==='Pickup') && $enable_pickup_date && isset( $_POST['shipday_pickup_date_field'] ) ) {
    321             $val = sanitize_text_field( wp_unslash( $_POST['shipday_pickup_date_field'] ) );
     359        if ( $enable_datetime_plugin && (!$enable_order_type || $order_type==='Pickup') && $enable_pickup_date ) {
     360            $val = self::get_checkout_post_value( 'shipday_pickup_date_field' );
    322361            shipday_logger('error', 'datetime : '.$val);
    323362            if ( $val !== '' ) {
     
    330369        }
    331370
    332         if ( $enable_datetime_plugin && (!$enable_order_type || $order_type==='Pickup') &&  $enable_pickup_time && isset( $_POST['shipday_pickup_time_field'] ) ) {
    333             $val_time = sanitize_text_field( $_POST['shipday_pickup_time_field'] );
     371        if ( $enable_datetime_plugin && (!$enable_order_type || $order_type==='Pickup') &&  $enable_pickup_time ) {
     372            $val_time = self::get_checkout_post_value( 'shipday_pickup_time_field' );
    334373            if ( $val_time !== '' ) {
    335374                if ( self::$hpos === true ) {
     
    359398
    360399            if ( self::$hpos === true ) {
    361                 $delivery_date = date($delivery_date_format, strtotime($order->get_meta( '_shipday_delivery_date', true )));
     400                $delivery_date = wp_date( $delivery_date_format, strtotime($order->get_meta( '_shipday_delivery_date', true )) );
    362401            } else {
    363                 $delivery_date = date($delivery_date_format, strtotime(get_post_meta( $order_id, '_shipday_delivery_date', true )));
    364             }
    365 
    366             echo '<p><strong>'.__($delivery_date_field_label, "shipday-woo-delivery").':</strong> ' . $delivery_date . '</p>';
     402                $delivery_date = wp_date( $delivery_date_format, strtotime(get_post_meta( $order_id, '_shipday_delivery_date', true )) );
     403            }
     404
     405            echo '<p><strong>' . esc_html__( 'Scheduled Date', 'shipday-for-woocommerce' ) . ':</strong> ' . esc_html( $delivery_date ) . '</p>';
    367406
    368407        }
     
    374413                $time_slot = get_post_meta( $order_id, '_shipday_delivery_time', true );
    375414            }
    376             echo '<p><strong>'.__($delivery_time_field_label, "shipday-woo-delivery").':</strong> ' .$time_slot. '</p>';
     415            echo '<p><strong>' . esc_html__( 'Time slot', 'shipday-for-woocommerce' ) . ':</strong> ' . esc_html( $time_slot ) . '</p>';
    377416        }
    378417    }
     
    454493
    455494}
    456 
    457 
  • shipday-for-woocommerce/trunk/shipday_order_management/Shipday_Order_Management.php

    r3419924 r3483127  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) {
     4    exit;
     5}
    26
    37require_once dirname(__DIR__). '/functions/logger.php';
  • shipday-for-woocommerce/trunk/shipday_order_management/Woo_Sync_Order.php

    r2685513 r3483127  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) {
     4    exit;
     5}
    26
    37require_once dirname(__DIR__). '/functions/common.php';
    48require_once dirname(__FILE__). '/Shipday_Order_Management.php';
    59
     10// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound -- Legacy class name retained for backwards compatibility.
    611class Woo_Sync_Order
    712{
     
    2025    }
    2126
    22     public static function get_processing_orders_from_db() {
    23         global $wpdb;
    24         $orders = $wpdb->get_results(
    25             "SELECT order_id FROM {$wpdb->prefix}wc_order_stats ".
    26             "WHERE status='wc-processing'"
    27         );
    28         $ids = [];
    29         foreach ($orders as $order) {
    30             $ids[] = intval($order->order_id);
    31         }
    32         return $ids;
    33     }
    34 
    3527    public static function sync(){
    36         $orders = self::get_processing_orders_from_db();
     28        $orders = self::get_processing_orders();
    3729        foreach ( $orders as $order_id) {
    3830            Shipday_Order_Management::process_and_send($order_id);
  • shipday-for-woocommerce/trunk/views/Dokan_vendor_settings_shipday.php

    r3419924 r3483127  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) {
     4    exit;
     5}
    26require_once dirname(__DIR__). '/functions/logger.php';
    37
     
    1317    public static function save_api_key() {
    1418        // Only handle POST requests
    15         if ( $_SERVER['REQUEST_METHOD'] !== 'POST' ) {
     19        if (
     20            ! isset( $_SERVER['REQUEST_METHOD'] )
     21            || 'POST' !== strtoupper( sanitize_text_field( wp_unslash( $_SERVER['REQUEST_METHOD'] ) ) )
     22        ) {
    1623            return;
    1724        }
     
    2229        }
    2330
    24         $post_data = wp_unslash($_POST);
    25         if (!is_null($post_data) && !is_null($post_data['shipday_api_key']) && !empty(trim($post_data['shipday_api_key'])))
    26             update_user_meta(wp_get_current_user()->ID, 'shipday_api_key', trim($post_data['shipday_api_key']));
     31        if (
     32            ! isset( $_POST['_wpnonce'] )
     33            || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ) ), 'dokan_delivery_settings_nonce' )
     34        ) {
     35            return;
     36        }
     37
     38        if ( ! isset( $_POST['shipday_api_key'] ) ) {
     39            return;
     40        }
     41
     42        $api_key = sanitize_text_field( wp_unslash( $_POST['shipday_api_key'] ) );
     43        if ( '' !== $api_key ) {
     44            update_user_meta( wp_get_current_user()->ID, 'shipday_api_key', $api_key );
     45        }
    2746    }
    2847
     
    3958    public static function dokan_add_help_menu( $urls ) {
    4059        $urls['delivery'] = array(
    41             'title' => __( 'Delivery', 'shipday'),
     60            'title' => __( 'Delivery', 'shipday-for-woocommerce'),
    4261            'icon'  => '<i class="fas fa-truck"></i>',
    4362            'url'   => dokan_get_navigation_url( 'delivery' ),
     
    6887
    6988                            <div class="dokan-form-group">
    70                                 <label class="dokan-w3 dokan-control-label" for="shipday_api_key"><?php esc_html_e( 'Shipday API key', 'shipday' ); ?></label>
     89                                <label class="dokan-w3 dokan-control-label" for="shipday_api_key"><?php esc_html_e( 'Shipday API key', 'shipday-for-woocommerce' ); ?></label>
    7190
    7291                                <div class="dokan-w5 dokan-text-left">
    73                                     <input id="shipday_api_key" required value="<?php echo esc_attr(self::get_api_key()); ?>" name="shipday_api_key" placeholder="<?php esc_attr_e( 'Enter shipday api key', 'shipday' ); ?>" class="dokan-form-control" type="text">
     92                                    <input id="shipday_api_key" required value="<?php echo esc_attr(self::get_api_key()); ?>" name="shipday_api_key" placeholder="<?php esc_attr_e( 'Enter shipday api key', 'shipday-for-woocommerce' ); ?>" class="dokan-form-control" type="text">
    7493                                </div>
    7594                            </div>
     
    7897
    7998                                <div class="dokan-w4 ajax_prev dokan-text-left" style="margin-left:24%;">
    80                                     <input type="submit" name="shipday_vendor_settings" class="dokan-btn dokan-btn-danger dokan-btn-theme" value="<?php esc_attr_e( 'Update Settings', 'dokan-lite' ); ?>">
     99                                    <input type="submit" name="shipday_vendor_settings" class="dokan-btn dokan-btn-danger dokan-btn-theme" value="<?php esc_attr_e( 'Update Settings', 'shipday-for-woocommerce' ); ?>">
    81100                                </div>
    82101                            </div>
  • shipday-for-woocommerce/trunk/views/Notices.php

    r3419924 r3483127  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) {
     4    exit;
     5}
    26
    37require_once dirname(__DIR__). '/functions/common.php';
    48
    5 
     9// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound -- Legacy class name retained for backwards compatibility.
    610class Notices {
    711    public static function init() {
     
    1721            ?>
    1822            <div class='notice notice-warning is-dismissible'>
    19                 <p>Your Shipday API Key Field is blank. To set up API Key, <a href="<?php echo $shipday_tab_url; ?>" target="_top">Click
     23                <p>Your Shipday API Key Field is blank. To set up API Key, <a href="<?php echo esc_url( $shipday_tab_url ); ?>" target="_top">Click
    2024                        Here</a>.</p>
    2125            </div>
     
    4044                <div class='notice notice-warning is-dismissible'>
    4145                    <p>REST API key is essential for order status update in WooCommerce dashboard. To add REST API Key,
    42                         <a href="<?php echo $rest_api_section_url; ?>" style="color: red">Click here</a> and take note of consumer key and consumer secret.
    43                         Then enter the keys in shipday settings tab <a href="<?php echo $shipday_tab_url; ?>"> here</a>.</p>
     46                        <a href="<?php echo esc_url( $rest_api_section_url ); ?>" style="color: red">Click here</a> and take note of consumer key and consumer secret.
     47                        Then enter the keys in shipday settings tab <a href="<?php echo esc_url( $shipday_tab_url ); ?>"> here</a>.</p>
    4448                </div>
    4549            <?php
     
    5559        ?>
    5660        <div class='notice notice-warning is-dismissible'>
    57             <p>You have set <?php echo $consumer_secret.'.'.$consumer_key; ?>.</p>
     61            <p>You have set <?php echo esc_html( $consumer_secret . '.' . $consumer_key ); ?>.</p>
    5862        </div>
    5963        <?php
  • shipday-for-woocommerce/trunk/views/WCFM_vendor_settings_shipday.php

    r2592964 r3483127  
    11<?php
    22
     3if ( ! defined( 'ABSPATH' ) ) {
     4    exit;
     5}
     6
     7// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound -- Legacy class name retained for backwards compatibility.
    38class WCFM_vendor_settings_shipday {
    49    public static function init() {
     
    1520
    1621        global $WCFM;
     22        // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- This is an external WCFM hook name.
    1723        $user_id = apply_filters( 'wcfm_current_vendor_id', get_current_user_id() );
    1824        $vendor_data = get_user_meta( $user_id, 'wcfmmp_profile_settings', true );
     
    2026        $api_key = isset( $vendor_data['shipday']['api_key'] ) ? $vendor_data['shipday']['api_key'] : '';
    2127        $fields = array(
    22             "api_key" => array("label" => __('Shipday API Key', 'wcfm-settings-tab-shipday'),
     28            "api_key" => array("label" => __('Shipday API Key', 'shipday-for-woocommerce'),
    2329                                      "name" => "shipday[api_key]",
    2430                                      "type" => "text",
  • shipday-for-woocommerce/trunk/views/WC_Settings_Tab_Shipday_menus.php

    r3381147 r3483127  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) {
     4    exit;
     5}
     6// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound,WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Legacy settings/filter API is retained for backwards compatibility.
    27
    38function get_woocommerce_settings()
     
    510    $settings = array(
    611        array(
    7             'name' => __('General Settings', 'woocommerce-settings-tab-shipday'),
     12            'name' => __('General Settings', 'shipday-for-woocommerce'),
    813            'type' => 'title',
    914            'desc' => '',
     
    1116        ),
    1217        array(
    13             'name' => __('Shipday API Key', 'woocommerce-settings-tab-shipday'),
     18            'name' => __('Shipday API Key', 'shipday-for-woocommerce'),
    1419            'type' => 'text',
    1520            'desc' => 'To get API Key, Login to your Shipday account and go to My Account > Profile > Api key',
     
    2227        ),
    2328        array(
    24             'name' => __('REST API Settings', 'woocommerce-settings-tab-shipday'),
     29            'name' => __('REST API Settings', 'shipday-for-woocommerce'),
    2530            'type' => 'title',
    2631            'desc' => 'To get REST API Keys, go to WooCommerce > Settings > Advanced > API Key. Then generate a new API key with any description, '.
     
    2934        ),
    3035        array(
    31             'name' => __('Consumer Key', 'woocommerce-settings-tab-shipday'),
     36            'name' => __('Consumer Key', 'shipday-for-woocommerce'),
    3237            'type' => 'text',
    3338//            'value' => "",
     
    3540        ),
    3641        array(
    37             'name' => __('Consumer Secret', 'woocommerce-settings-tab-shipday'),
     42            'name' => __('Consumer Secret', 'shipday-for-woocommerce'),
    3843            'type' => 'text',
    3944//            'value' => "",
     
    4954        ),
    5055        array(
    51             'name' => __('Orders Settings', 'woocommerce-settings-tab-shipday'),
     56            'name' => __('Orders Settings', 'shipday-for-woocommerce'),
    5257            'type' => 'title',
    5358            'desc' => '',
     
    5560        ),
    5661        array(
    57             'title'       => __( 'Sync previous orders', 'woocommerce-settings-tab-shipday' ),
    58             'label'       => __( 'Sync previous orders', 'woocommerce-settings-tab-shipday'),
     62            'title'       => __( 'Sync previous orders', 'shipday-for-woocommerce' ),
     63            'label'       => __( 'Sync previous orders', 'shipday-for-woocommerce'),
    5964            'type'        => 'checkbox',
    6065            'description' => '',
     
    6368        ),
    6469        array(
    65             'title'       => __( 'Enable pickup orders', 'woocommerce-settings-tab-shipday' ),
    66             'label'       => __( 'Enable pickup orders', 'woocommerce-settings-tab-shipday'),
     70            'title'       => __( 'Enable pickup orders', 'shipday-for-woocommerce' ),
     71            'label'       => __( 'Enable pickup orders', 'shipday-for-woocommerce'),
    6772            'type'        => 'checkbox',
    6873            'description' => 'Allow orders with local pickup shipping method to be sent to Shipday',
     
    7277
    7378        array(
    74             'title'       => __( 'Enable new Shipday webhook', 'woocommerce-settings-tab-shipday' ),
    75             'label'       => __( 'Enable new Shipday webhook', 'woocommerce-settings-tab-shipday'),
     79            'title'       => __( 'Enable new Shipday webhook', 'shipday-for-woocommerce' ),
     80            'label'       => __( 'Enable new Shipday webhook', 'shipday-for-woocommerce'),
    7681            'type'        => 'checkbox',
    7782            'description' => 'Enable this to send your orders to new Shipday Webhook',
     
    9499    $settings = array(
    95100        array(
    96             'name' => __('General Settings', 'woocommerce-settings-tab-shipday'),
     101            'name' => __('General Settings', 'shipday-for-woocommerce'),
    97102            'type' => 'title',
    98103            'desc' => '',
     
    100105        ),
    101106        array(
    102             'name' => __('Order Management Settings for Dokan Multi-vendor', 'woocommerce-settings-tab-shipday'),
     107            'name' => __('Order Management Settings for Dokan Multi-vendor', 'shipday-for-woocommerce'),
    103108            'type' => 'radio',
    104109            'std' => 'admin_manage',
    105110            'default' => 'admin_manage',
    106111            'options' => array(
    107                 'admin_manage' => __('Dokan Admin account manages deliveries for all vendors'),
    108                 'vendor_manage' => __('Vendors manage their orders in Shipday'),
     112                'admin_manage' => __('Dokan Admin account manages deliveries for all vendors', 'shipday-for-woocommerce'),
     113                'vendor_manage' => __('Vendors manage their orders in Shipday', 'shipday-for-woocommerce'),
    109114            ),
    110115            'id' => 'wc_settings_tab_shipday_order_manage',
    111116        ),
    112117        array(
    113             'name' => __('Shipday API Key of Admin\'s Account', 'woocommerce-settings-tab-shipday'),
     118            'name' => __('Shipday API Key of Admin\'s Account', 'shipday-for-woocommerce'),
    114119            'type' => 'text',
    115120            'desc' => 'To get API Key, Login to your Shipday account and go to My Account > Profile > Api key',
     
    117122        ),
    118123        array(
    119             'title'       => __( 'Enable pickup orders', 'woocommerce-settings-tab-shipday' ),
    120             'label'       => __( 'Enable pickup orders', 'woocommerce-settings-tab-shipday'),
     124            'title'       => __( 'Enable pickup orders', 'shipday-for-woocommerce' ),
     125            'label'       => __( 'Enable pickup orders', 'shipday-for-woocommerce'),
    121126            'type'        => 'checkbox',
    122127            'description' => 'Allow orders with local pickup shipping method to be sent to Shipday',
     
    125130        ),
    126131        array(
    127             'title'       => __( 'Enable new Shipday webhook', 'woocommerce-settings-tab-shipday' ),
    128             'label'       => __( 'Enable new Shipday webhook', 'woocommerce-settings-tab-shipday'),
     132            'title'       => __( 'Enable new Shipday webhook', 'shipday-for-woocommerce' ),
     133            'label'       => __( 'Enable new Shipday webhook', 'shipday-for-woocommerce'),
    129134            'type'        => 'checkbox',
    130135            'description' => 'Enable this to send your orders to new Shipday Webhook',
     
    146151    $settings = array(
    147152        array(
    148             'name' => __('General Settings', 'woocommerce-settings-tab-shipday'),
     153            'name' => __('General Settings', 'shipday-for-woocommerce'),
    149154            'type' => 'title',
    150155            'desc' => '',
     
    152157        ),
    153158        array(
    154             'name' => __('Order Management Settings for WCFM Multi-vendor', 'woocommerce-settings-tab-shipday'),
     159            'name' => __('Order Management Settings for WCFM Multi-vendor', 'shipday-for-woocommerce'),
    155160            'type' => 'radio',
    156161            'std' => 'admin_manage',
    157162            'default' => 'admin_manage',
    158163            'options' => array(
    159                 'admin_manage' => __('WCFM Admin account manages deliveries for all vendors'),
    160                 'vendor_manage' => __('Vendors manage their orders in Shipday'),
     164                'admin_manage' => __('WCFM Admin account manages deliveries for all vendors', 'shipday-for-woocommerce'),
     165                'vendor_manage' => __('Vendors manage their orders in Shipday', 'shipday-for-woocommerce'),
    161166            ),
    162167            'id' => 'wc_settings_tab_shipday_order_manage',
    163168        ),
    164169        array(
    165             'name' => __('Shipday API Key of Admin\'s Account', 'woocommerce-settings-tab-shipday'),
     170            'name' => __('Shipday API Key of Admin\'s Account', 'shipday-for-woocommerce'),
    166171            'type' => 'text',
    167172            'desc' => 'To get API Key, Login to your Shipday account and go to My Account > Profile > Api key',
     
    169174        ),
    170175        array(
    171             'title'       => __( 'Enable pickup orders', 'woocommerce-settings-tab-shipday' ),
    172             'label'       => __( 'Enable pickup orders', 'woocommerce-settings-tab-shipday'),
     176            'title'       => __( 'Enable pickup orders', 'shipday-for-woocommerce' ),
     177            'label'       => __( 'Enable pickup orders', 'shipday-for-woocommerce'),
    173178            'type'        => 'checkbox',
    174179            'description' => 'Allow orders with local pickup shipping method to be sent to Shipday',
     
    177182        ),
    178183        array(
    179             'title'       => __( 'Enable new Shipday webhook', 'woocommerce-settings-tab-shipday' ),
    180             'label'       => __( 'Enable new Shipday webhook', 'woocommerce-settings-tab-shipday'),
     184            'title'       => __( 'Enable new Shipday webhook', 'shipday-for-woocommerce' ),
     185            'label'       => __( 'Enable new Shipday webhook', 'shipday-for-woocommerce'),
    181186            'type'        => 'checkbox',
    182187            'description' => 'Enable this to send your orders to new Shipday Webhook',
Note: See TracChangeset for help on using the changeset viewer.