- get_type() ) ), esc_html( $position_number ), esc_html( $total_shipments ) ); ?>
+ get_type() ) ), esc_html( $position_number ), esc_html( $total_shipments ) ); ?>
get_order() ) && is_callable( array( $s_order, 'get_edit_order_url' ) ) ) : ?>
- get_order_number() ) ); ?>
+ get_order_number() ) ); ?>
- get_order_number() ) ); ?>
+ get_order_number() ) ); ?>
@@ -34,7 +34,7 @@
if ( ! empty( $provider ) && ! empty( $tracking_id ) ) :
?>
-
get_error_messages() as $message ) : ?>
diff --git a/includes/emails/class-wc-stc-email-customer-shipment.php b/includes/emails/class-wc-stc-email-customer-shipment.php
index bcd32585..b51e1b28 100644
--- a/includes/emails/class-wc-stc-email-customer-shipment.php
+++ b/includes/emails/class-wc-stc-email-customer-shipment.php
@@ -191,7 +191,7 @@ public function get_shipped_position_number( $shipment_id ) {
foreach ( $order->get_simple_shipments() as $key => $shipment ) {
if ( $shipment->is_shipped() ) {
if ( (int) $shipment->get_id() !== (int) $shipment_id ) {
- $shipped_count++;
+ ++$shipped_count;
}
}
}
diff --git a/includes/wc-stc-shipment-functions.php b/includes/wc-stc-shipment-functions.php
index 05614fd5..f39c0e6a 100644
--- a/includes/wc-stc-shipment-functions.php
+++ b/includes/wc-stc-shipment-functions.php
@@ -1548,12 +1548,12 @@ function wc_stc_get_shipment_error( $error ) {
}
}
-function wc_shiptastic_substring( $string, $start, $length = null ) {
+function wc_shiptastic_substring( $str, $start, $length = null ) {
if ( function_exists( 'mb_substr' ) ) {
- $string = mb_substr( $string, $start, $length );
+ $str = mb_substr( $str, $start, $length );
} else {
- $string = substr( $string, $start, $length );
+ $str = substr( $str, $start, $length );
}
- return $string;
+ return $str;
}
diff --git a/includes/wc-stc-template-functions.php b/includes/wc-stc-template-functions.php
index 026bce84..6dc6d7fc 100644
--- a/includes/wc-stc-template-functions.php
+++ b/includes/wc-stc-template-functions.php
@@ -141,7 +141,6 @@ function woocommerce_shiptastic_template_view_shipment( $shipment_id ) {
if ( ! function_exists( 'woocommerce_shiptastic_template_add_return_shipment' ) ) {
function woocommerce_shiptastic_template_add_return_shipment( $order_id ) {
-
if ( ( ! ( $order = wc_get_order( $order_id ) ) ) || ( ! wc_stc_customer_can_add_return_shipment( $order_id ) ) ) {
echo '
';
return;
@@ -156,7 +155,7 @@ function woocommerce_shiptastic_template_add_return_shipment( $order_id ) {
// Output notices in case notices have not been outputted yet.
if ( ! empty( $notices ) ) {
- echo '
' . $notices . '
'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ echo '
' . wc_kses_notice( $notices ) . '
'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
wc_get_template(
diff --git a/phpcs.xml b/phpcs.xml
index 11c241ca..ce9a9ef8 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -104,7 +104,28 @@
*
-
+
*
+
+
+ *
+
+
+
+ *
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Admin/Admin.php b/src/Admin/Admin.php
index bbc43113..b9a5f5cd 100644
--- a/src/Admin/Admin.php
+++ b/src/Admin/Admin.php
@@ -85,7 +85,7 @@ public static function init() {
add_action(
'admin_init',
- function() {
+ function () {
// Order shipping status
add_filter( 'manage_' . ( 'shop_order' === self::get_order_screen_id() ? 'shop_order_posts' : self::get_order_screen_id() ) . '_columns', array( __CLASS__, 'register_order_shipping_status_column' ), 20 );
add_action( 'manage_' . ( 'shop_order' === self::get_order_screen_id() ? 'shop_order_posts' : self::get_order_screen_id() ) . '_custom_column', array( __CLASS__, 'render_order_columns' ), 20, 2 );
@@ -603,7 +603,7 @@ public static function render_packaging_page() {
-
+
@@ -616,7 +616,7 @@ public static function hide_packaging_page_from_menu() {
}
public static function save_packaging_page() {
- if ( ! current_user_can( 'manage_woocommerce' ) || ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( wp_unslash( $_POST['_wpnonce'] ), 'woocommerce-stc-packaging-settings' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
+ if ( ! current_user_can( 'manage_woocommerce' ) || ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( wc_clean( wp_unslash( $_POST['_wpnonce'] ) ), 'woocommerce-stc-packaging-settings' ) ) {
wp_die( '', 400 );
}
@@ -913,7 +913,7 @@ protected static function add_settings_after( $settings, $id, $insert = array(),
$key = self::get_setting_key_by_id( $settings, $id, $type );
if ( is_numeric( $key ) ) {
- $key ++;
+ ++$key;
$settings = array_merge( array_merge( array_slice( $settings, 0, $key, true ), $insert ), array_slice( $settings, $key, count( $settings ) - 1, true ) );
} else {
$settings += $insert;
@@ -1151,41 +1151,31 @@ public static function output_return_reasons_field( $value ) {
-
-
-
- ';
- }
+ $count = 0;
+ foreach ( wc_stc_get_return_shipment_reasons() as $reason ) :
+ ?>
+
+
+
+
+
+
+
+
+
+
+
-
-
-
wc_stc_get_packaging_types(),
+ );
if ( self::is_shipping_settings_request() ) {
$params['clean_input_callback'] = 'shiptastic.admin.shipping_provider_method.getCleanInputId';
diff --git a/src/Admin/BulkActionHandler.php b/src/Admin/BulkActionHandler.php
index 0a5e18b2..853e7806 100644
--- a/src/Admin/BulkActionHandler.php
+++ b/src/Admin/BulkActionHandler.php
@@ -81,11 +81,9 @@ public function get_success_message() {
}
public function admin_handled() {
-
}
public function admin_after_error() {
-
}
public function add_notice( $notice, $type = 'error' ) {
diff --git a/src/Admin/BulkLabel.php b/src/Admin/BulkLabel.php
index 06450b6a..f10bd017 100644
--- a/src/Admin/BulkLabel.php
+++ b/src/Admin/BulkLabel.php
@@ -75,7 +75,6 @@ protected function get_download_button() {
$download_button = '';
if ( ( $path = $this->get_file() ) && file_exists( $path ) ) {
-
$download_url = add_query_arg(
array(
'action' => 'wc-stc-download-export-shipment-label',
@@ -94,7 +93,7 @@ public function get_success_message() {
$download_button = $this->get_download_button();
if ( empty( $download_button ) ) {
- return sprintf( _x( 'The chosen shipments were not suitable for automatic label creation. Please check the shipping provider option of the corresponding shipments.', 'shipments', 'shiptastic-for-woocommerce' ), $download_button );
+ return sprintf( _x( 'The chosen shipments were not suitable for automatic label creation. Please check the shipping provider option of the corresponding shipments.', 'shipments', 'shiptastic-for-woocommerce' ), $download_button ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
} else {
return sprintf( _x( 'Successfully generated labels. %s', 'shipments', 'shiptastic-for-woocommerce' ), $download_button );
}
diff --git a/src/Admin/PackagingSettings.php b/src/Admin/PackagingSettings.php
index f5faad76..bfe62d87 100644
--- a/src/Admin/PackagingSettings.php
+++ b/src/Admin/PackagingSettings.php
@@ -264,7 +264,7 @@ public static function save_settings( $packaging, $tab, $section = '' ) {
add_filter(
'woocommerce_admin_settings_sanitize_option',
- function( $value, $setting, $raw_value ) use ( $packaging ) {
+ function ( $value, $setting, $raw_value ) use ( $packaging ) {
$setting_id = $setting['id'];
$args = $packaging->get_configuration_set_args_by_id( $setting_id );
$value = wc_clean( $value );
@@ -289,7 +289,7 @@ function( $value, $setting, $raw_value ) use ( $packaging ) {
} else {
add_filter(
'pre_update_option',
- function( $value, $option, $old_value ) use ( $packaging ) {
+ function ( $value, $option, $old_value ) use ( $packaging ) {
if ( is_callable( array( $packaging, "set_{$option}" ) ) ) {
$setter = "set_{$option}";
diff --git a/src/Admin/Settings.php b/src/Admin/Settings.php
index f4600f5a..352dab28 100644
--- a/src/Admin/Settings.php
+++ b/src/Admin/Settings.php
@@ -152,7 +152,7 @@ public static function get_sanitized_settings( $settings, $data = null ) {
return $settings_to_save;
}
- public static function render_label_fields( $settings, $shipment, $echo = false ) {
+ public static function render_label_fields( $settings, $shipment, $do_echo = false ) {
$missing_div_closes = 0;
ob_start();
foreach ( $settings as $setting ) {
@@ -198,7 +198,7 @@ public static function render_label_fields( $settings, $shipment, $echo = false
woocommerce_wp_text_input( $setting );
} elseif ( 'services_start' === $setting['type'] ) {
$hide_default = isset( $setting['hide_default'] ) ? wc_string_to_bool( $setting['hide_default'] ) : false;
- $missing_div_closes++;
+ ++$missing_div_closes;
?>
@@ -211,17 +211,17 @@ public static function render_label_fields( $settings, $shipment, $echo = false
0 ) {
while ( $missing_div_closes > 0 ) {
- $missing_div_closes--;
+ --$missing_div_closes;
echo '
';
}
}
$html = ob_get_clean();
- if ( ! $echo ) {
+ if ( ! $do_echo ) {
return $html;
} else {
echo $html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
diff --git a/src/Admin/Table.php b/src/Admin/Table.php
index 78365cb5..07aefbd0 100644
--- a/src/Admin/Table.php
+++ b/src/Admin/Table.php
@@ -120,7 +120,7 @@ public function handle_bulk_actions( $action, $ids, $redirect_to ) {
* @package Vendidero/Shiptastic
*/
do_action( 'woocommerce_shiptastic_shipment_edit_status', $id, $new_status );
- $changed++;
+ ++$changed;
}
}
}
@@ -128,7 +128,7 @@ public function handle_bulk_actions( $action, $ids, $redirect_to ) {
foreach ( $ids as $id ) {
if ( $shipment = wc_stc_get_shipment( $id ) ) {
$shipment->delete( true );
- $changed++;
+ ++$changed;
}
}
} elseif ( 'confirm_requests' === $action ) {
@@ -137,7 +137,7 @@ public function handle_bulk_actions( $action, $ids, $redirect_to ) {
if ( 'return' === $shipment->get_type() ) {
if ( $shipment->is_customer_requested() && $shipment->has_status( 'requested' ) ) {
if ( $shipment->confirm_customer_request() ) {
- $changed++;
+ ++$changed;
}
}
}
@@ -375,7 +375,6 @@ public function no_items() {
/**
* Determine if the current view is the "All" view.
*
- *
* @return bool Whether the current view is the "All" view.
*/
protected function is_base_request() {
@@ -434,8 +433,15 @@ protected function get_views() {
'shipment_status' => $status,
);
+ $label = array(
+ 'singular' => sprintf( '%s
(%s) ', esc_html( $title ), $num_shipments[ $status ] ),
+ 'plural' => sprintf( '%s
(%s) ', esc_html( $title ), $num_shipments[ $status ] ),
+ 'context' => '',
+ 'domain' => 'shiptastic-for-woocommerce',
+ );
+
$status_label = sprintf(
- translate_nooped_plural( _nx_noop( ( $title . '
(%s) ' ), ( $title . '
(%s) ' ), 'shipments', 'shiptastic-for-woocommerce' ), $num_shipments[ $status ] ), // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralSingle,WordPress.WP.I18n.NonSingularStringLiteralPlural
+ translate_nooped_plural( $label, $num_shipments[ $status ] ), // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralSingular, WordPress.WP.I18n.NonSingularStringLiteralPlural
number_format_i18n( $num_shipments[ $status ] )
);
@@ -451,20 +457,21 @@ protected function get_views() {
*
* @param string[] $args Associative array of URL parameters for the link.
* @param string $label Link text.
- * @param string $class Optional. Class attribute. Default empty string.
+ * @param string $class_name Optional. Class attribute. Default empty string.
+ *
* @return string The formatted link string.
*/
- protected function get_edit_link( $args, $label, $class = '' ) {
+ protected function get_edit_link( $args, $label, $class_name = '' ) {
$url = add_query_arg( $args, $this->get_main_page() );
$class_html = $aria_current = '';
- if ( ! empty( $class ) ) {
+ if ( ! empty( $class_name ) ) {
$class_html = sprintf(
' class="%s"',
- esc_attr( $class )
+ esc_attr( $class_name )
);
- if ( 'current' === $class ) {
+ if ( 'current' === $class_name ) {
$aria_current = ' aria-current="page"';
}
}
@@ -686,7 +693,7 @@ protected function order_filter() {
}
?>
-
+
get_hook_prefix()}bulk_actions", $actions );
}
-
}
diff --git a/src/Admin/Tabs/ShippingProvider.php b/src/Admin/Tabs/ShippingProvider.php
index 2283579b..c14bfc42 100644
--- a/src/Admin/Tabs/ShippingProvider.php
+++ b/src/Admin/Tabs/ShippingProvider.php
@@ -180,7 +180,7 @@ public function get_next_pointers_link( $provider_name = false ) {
if ( is_a( $provider, '\Vendidero\Shiptastic\ShippingProvider\Auto' ) && ! empty( $provider->get_settings_help_pointers() ) ) {
$provider_indexes[ $provider_key ] = $count;
$provider_counts[ $count ] = $provider_key;
- $count++;
+ ++$count;
}
}
diff --git a/src/Admin/Tabs/Tab.php b/src/Admin/Tabs/Tab.php
index 27cae372..4fe92ff8 100644
--- a/src/Admin/Tabs/Tab.php
+++ b/src/Admin/Tabs/Tab.php
@@ -52,7 +52,7 @@ public function header() {
$count = 0;
foreach ( $breadcrumb as $breadcrumb_item ) {
- $count ++;
+ ++$count;
echo '
' . ( ! empty( $breadcrumb_item['href'] ) ? '' . wp_kses_post( $breadcrumb_item['title'] ) . ' ' : wp_kses_post( $breadcrumb_item['title'] ) ) . ' ';
}
diff --git a/src/Admin/Tabs/Tabs.php b/src/Admin/Tabs/Tabs.php
index 4128eab0..0c125566 100644
--- a/src/Admin/Tabs/Tabs.php
+++ b/src/Admin/Tabs/Tabs.php
@@ -44,7 +44,7 @@ public function header() {
' . wp_kses_post( $breadcrumb_item['title'] ) . '' : wp_kses_post( $breadcrumb_item['title'] ) ); ?>
diff --git a/src/Ajax.php b/src/Ajax.php
index 6c20ee0c..c21f9c26 100644
--- a/src/Ajax.php
+++ b/src/Ajax.php
@@ -59,8 +59,11 @@ public static function add_ajax_events() {
}
public static function suppress_errors() {
+ /**
+ * Turn off display_errors during AJAX events to prevent malformed JSON.
+ */
if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) {
- @ini_set( 'display_errors', 0 ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged,WordPress.PHP.IniSet.display_errors_Blacklisted
+ @ini_set( 'display_errors', 0 ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged, WordPress.PHP.IniSet.display_errors_Disallowed
}
$GLOBALS['wpdb']->hide_errors();
@@ -92,8 +95,7 @@ public static function send_return_shipment_notification_email() {
if ( isset( $_GET['shipment_id'] ) ) {
wp_safe_redirect( wp_get_referer() ? wp_get_referer() : admin_url( 'admin.php?page=wc-stc-return-shipments' ) );
exit;
- } else {
- if ( $success ) {
+ } elseif ( $success ) {
wp_send_json(
array(
'success' => true,
@@ -102,16 +104,15 @@ public static function send_return_shipment_notification_email() {
),
)
);
- } else {
- wp_send_json(
- array(
- 'success' => false,
- 'messages' => array(
- _x( 'There was an error while sending the notification.', 'shipments', 'shiptastic-for-woocommerce' ),
- ),
- )
- );
- }
+ } else {
+ wp_send_json(
+ array(
+ 'success' => false,
+ 'messages' => array(
+ _x( 'There was an error while sending the notification.', 'shipments', 'shiptastic-for-woocommerce' ),
+ ),
+ )
+ );
}
}
}
@@ -143,8 +144,7 @@ public static function confirm_return_request() {
if ( isset( $_GET['shipment_id'] ) ) {
wp_safe_redirect( wp_get_referer() ? wp_get_referer() : admin_url( 'admin.php?page=wc-stc-return-shipments' ) );
exit;
- } else {
- if ( $success ) {
+ } elseif ( $success ) {
wp_send_json(
array(
'success' => true,
@@ -158,16 +158,15 @@ public static function confirm_return_request() {
),
)
);
- } else {
- wp_send_json(
- array(
- 'success' => false,
- 'messages' => array(
- _x( 'There was an error while confirming the request.', 'shipments', 'shiptastic-for-woocommerce' ),
- ),
- )
- );
- }
+ } else {
+ wp_send_json(
+ array(
+ 'success' => false,
+ 'messages' => array(
+ _x( 'There was an error while confirming the request.', 'shipments', 'shiptastic-for-woocommerce' ),
+ ),
+ )
+ );
}
}
}
@@ -638,7 +637,7 @@ public static function update_shipment_status() {
private static function get_shipment_ids( $shipments ) {
return array_values(
array_map(
- function( $s ) {
+ function ( $s ) {
return $s->get_id();
},
$shipments
@@ -748,7 +747,7 @@ public static function add_shipment() {
$shipment_count = 0;
foreach ( $shipments as $id => $shipment ) {
- $shipment_count++;
+ ++$shipment_count;
$shipment_type = $shipment->get_type();
if ( 1 === $shipment_count ) {
@@ -986,19 +985,17 @@ public static function json_search_orders() {
if ( Package::is_hpos_enabled() ) {
$ids = wc_get_orders( array( 's' => $term ) );
- } else {
- if ( ! is_numeric( $term ) ) {
+ } elseif ( ! is_numeric( $term ) ) {
$ids = wc_get_orders( array( 's' => $term ) );
- } else {
- global $wpdb;
+ } else {
+ global $wpdb;
- $ids = $wpdb->get_col(
- $wpdb->prepare(
- "SELECT DISTINCT p1.ID FROM {$wpdb->posts} p1 WHERE p1.ID LIKE %s AND post_type = 'shop_order'", // @codingStandardsIgnoreLine
- $wpdb->esc_like( wc_clean( $term ) ) . '%'
- )
- );
- }
+ $ids = $wpdb->get_col(
+ $wpdb->prepare(
+ "SELECT DISTINCT p1.ID FROM {$wpdb->posts} p1 WHERE p1.ID LIKE %s AND post_type = 'shop_order'", // @codingStandardsIgnoreLine
+ $wpdb->esc_like( wc_clean( $term ) ) . '%'
+ )
+ );
}
$excluded = array();
diff --git a/src/Api.php b/src/Api.php
index 2309d15b..50843564 100644
--- a/src/Api.php
+++ b/src/Api.php
@@ -30,8 +30,8 @@ public static function init() {
add_filter( 'woocommerce_rest_prepare_product_variation_object', array( __CLASS__, 'prepare_product' ), 10, 3 );
}
- public static function prepare_product( $response, $object, $request ) {
- if ( $product = wc_get_product( $object ) ) {
+ public static function prepare_product( $response, $product_object, $request ) {
+ if ( $product = wc_get_product( $product_object ) ) {
$context = ! empty( $request['context'] ) ? $request['context'] : 'view';
$response->set_data( array_merge_recursive( $response->data, self::get_product_data( $product, $context ) ) );
diff --git a/src/Automation.php b/src/Automation.php
index 2163c30a..c8fe6b8e 100644
--- a/src/Automation.php
+++ b/src/Automation.php
@@ -33,7 +33,7 @@ public static function init() {
*/
add_action(
'woocommerce_new_order',
- function( $order_id ) {
+ function ( $order_id ) {
self::$current_new_order_id = $order_id;
add_action( 'woocommerce_after_order_object_save', array( __CLASS__, 'after_new_order' ), 150 );
},
@@ -278,13 +278,12 @@ public static function maybe_create_shipments( $order_id, $args = array() ) {
if ( self::is_admin_edit_order_request() ) {
add_action(
'woocommerce_process_shop_order_meta',
- function( $order_id ) {
+ function ( $order_id ) {
self::create_shipments( $order_id );
},
70
);
- } else {
- if ( $args['allow_deferred_sync'] ) {
+ } elseif ( $args['allow_deferred_sync'] ) {
Package::log( 'Deferring order #' . $order_id . ' shipments sync' );
$queue = WC()->queue();
@@ -303,9 +302,8 @@ function( $order_id ) {
$defer_args,
'woocommerce-shiptastic-order-sync'
);
- } else {
- self::create_shipments( $order_id );
- }
+ } else {
+ self::create_shipments( $order_id );
}
}
}
diff --git a/src/Blocks/Checkout.php b/src/Blocks/Checkout.php
index af9a6c98..ec1b9b74 100644
--- a/src/Blocks/Checkout.php
+++ b/src/Blocks/Checkout.php
@@ -28,7 +28,7 @@ public function __construct( $schema_controller ) {
private function register_validation_and_storage() {
add_action(
'woocommerce_store_api_checkout_update_order_from_request',
- function( $order, $request ) {
+ function ( $order, $request ) {
$this->validate_checkout_data( $order, $request );
},
10,
@@ -161,7 +161,7 @@ private function validate_checkout_data( $order, $request ) {
private function register_integrations() {
add_action(
'woocommerce_blocks_checkout_block_registration',
- function( $integration_registry ) {
+ function ( $integration_registry ) {
$integration_registry->register( Package::container()->get( Integrations\CheckoutPickupLocationSelect::class ) );
}
);
@@ -179,7 +179,7 @@ private function register_endpoint_data() {
array(
'endpoint' => CartSchema::IDENTIFIER,
'namespace' => 'woocommerce-shiptastic',
- 'data_callback' => function() {
+ 'data_callback' => function () {
return $this->get_cart_data();
},
'schema_callback' => function () {
@@ -282,7 +282,7 @@ private function get_cart_data() {
'default_pickup_location' => WC()->customer->get_meta( 'pickup_location_code' ),
'default_pickup_location_customer_number' => WC()->customer->get_meta( 'pickup_location_customer_number' ),
'pickup_locations' => array_map(
- function( $location ) {
+ function ( $location ) {
return $location->get_data();
},
$locations
diff --git a/src/Blocks/Integrations/CheckoutPickupLocationSelect.php b/src/Blocks/Integrations/CheckoutPickupLocationSelect.php
index 115cfbe6..08424a59 100644
--- a/src/Blocks/Integrations/CheckoutPickupLocationSelect.php
+++ b/src/Blocks/Integrations/CheckoutPickupLocationSelect.php
@@ -38,7 +38,7 @@ public function initialize() {
add_action(
'woocommerce_blocks_enqueue_checkout_block_scripts_after',
- function() {
+ function () {
wp_enqueue_style( 'wc-shiptastic-checkout-pickup-location-select-block' );
wp_enqueue_style( 'wc-shiptastic-checkout' );
}
diff --git a/src/Blocks/StoreApi/Routes/V1/CartSearchPickupLocations.php b/src/Blocks/StoreApi/Routes/V1/CartSearchPickupLocations.php
index 436baeb0..9dae9889 100644
--- a/src/Blocks/StoreApi/Routes/V1/CartSearchPickupLocations.php
+++ b/src/Blocks/StoreApi/Routes/V1/CartSearchPickupLocations.php
@@ -100,7 +100,7 @@ protected function get_route_post_response( \WP_REST_Request $request ) {
$result = new \stdClass();
$result->pickup_locations = array_map(
- function( $location ) {
+ function ( $location ) {
return $location->get_data();
},
$results['locations']
diff --git a/src/Blocks/StoreApi/RoutesController.php b/src/Blocks/StoreApi/RoutesController.php
index 6a12bc32..161a9fc4 100644
--- a/src/Blocks/StoreApi/RoutesController.php
+++ b/src/Blocks/StoreApi/RoutesController.php
@@ -77,7 +77,7 @@ public function get( $name, $version = 'v1' ) {
* @param string $version API Version being registered..
* @param string $namespace Overrides the default route namespace.
*/
- protected function register_routes( $version = 'v1', $namespace = 'wc/store/v1' ) {
+ protected function register_routes( $version = 'v1', $namespace = 'wc/store/v1' ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.namespaceFound
if ( ! isset( $this->routes[ $version ] ) ) {
return;
}
diff --git a/src/Blocks/StoreApi/StoreApi.php b/src/Blocks/StoreApi/StoreApi.php
index 33ea2254..4aab15db 100644
--- a/src/Blocks/StoreApi/StoreApi.php
+++ b/src/Blocks/StoreApi/StoreApi.php
@@ -13,7 +13,7 @@ final class StoreApi {
public function init() {
add_action(
'rest_api_init',
- function() {
+ function () {
Package::container()->get( RoutesController::class )->register_all_routes();
}
);
diff --git a/src/Bootstrap.php b/src/Bootstrap.php
index 5775bf0b..293318e7 100644
--- a/src/Bootstrap.php
+++ b/src/Bootstrap.php
@@ -57,7 +57,7 @@ protected function init() {
} else {
add_action(
'woocommerce_blocks_loaded',
- function() {
+ function () {
$this->load_blocks();
}
);
diff --git a/src/Caches/Helper.php b/src/Caches/Helper.php
index fa788c37..c7c52849 100644
--- a/src/Caches/Helper.php
+++ b/src/Caches/Helper.php
@@ -16,14 +16,14 @@ class Helper {
public static function init() {
add_action(
'woocommerce_after_order_object_save',
- function( $order_id ) {
+ function ( $order_id ) {
self::flush_order_cache( $order_id );
}
);
add_action(
'woocommerce_before_delete_order',
- function( $order_id ) {
+ function ( $order_id ) {
self::flush_order_cache( $order_id );
}
);
diff --git a/src/Caches/PackagingCache.php b/src/Caches/PackagingCache.php
index f2195eaf..36e56e6b 100644
--- a/src/Caches/PackagingCache.php
+++ b/src/Caches/PackagingCache.php
@@ -22,22 +22,24 @@ public function get_object_type(): string {
/**
* Get the id of an object to be cached.
*
- * @param array|object $object The object to be cached.
+ * @param array|object $cache_object The object to be cached.
+ *
* @return int|string|null The id of the object, or null if it can't be determined.
*/
- protected function get_object_id( $object ) {
- return $object->get_id();
+ protected function get_object_id( $cache_object ) {
+ return $cache_object->get_id();
}
/**
* Validate an object before caching it.
*
- * @param array|object $object The object to validate.
+ * @param array|object $cache_object The object to validate.
+ *
* @return string[]|null An array of error messages, or null if the object is valid.
*/
- protected function validate( $object ): ?array {
- if ( ! $object instanceof Packaging ) {
- return array( 'The supplied packaging is not an instance of Packaging, ' . gettype( $object ) );
+ protected function validate( $cache_object ): ?array {
+ if ( ! $cache_object instanceof Packaging ) {
+ return array( 'The supplied packaging is not an instance of Packaging, ' . gettype( $cache_object ) );
}
return null;
diff --git a/src/Caches/ShipmentCache.php b/src/Caches/ShipmentCache.php
index bbec5ff8..5504f7c8 100644
--- a/src/Caches/ShipmentCache.php
+++ b/src/Caches/ShipmentCache.php
@@ -22,22 +22,24 @@ public function get_object_type(): string {
/**
* Get the id of an object to be cached.
*
- * @param array|object $object The object to be cached.
+ * @param array|object $cache_object The object to be cached.
+ *
* @return int|string|null The id of the object, or null if it can't be determined.
*/
- protected function get_object_id( $object ) {
- return $object->get_id();
+ protected function get_object_id( $cache_object ) {
+ return $cache_object->get_id();
}
/**
* Validate an object before caching it.
*
- * @param array|object $object The object to validate.
+ * @param array|object $cache_object The object to validate.
+ *
* @return string[]|null An array of error messages, or null if the object is valid.
*/
- protected function validate( $object ): ?array {
- if ( ! $object instanceof Shipment ) {
- return array( 'The supplied shipment is not an instance of Shipment, ' . gettype( $object ) );
+ protected function validate( $cache_object ): ?array {
+ if ( ! $cache_object instanceof Shipment ) {
+ return array( 'The supplied shipment is not an instance of Shipment, ' . gettype( $cache_object ) );
}
return null;
diff --git a/src/Caches/ShipmentLabelCache.php b/src/Caches/ShipmentLabelCache.php
index 71e0c521..05d1d67f 100644
--- a/src/Caches/ShipmentLabelCache.php
+++ b/src/Caches/ShipmentLabelCache.php
@@ -22,22 +22,24 @@ public function get_object_type(): string {
/**
* Get the id of an object to be cached.
*
- * @param array|object $object The object to be cached.
+ * @param array|object $cache_object The object to be cached.
+ *
* @return int|string|null The id of the object, or null if it can't be determined.
*/
- protected function get_object_id( $object ) {
- return $object->get_id();
+ protected function get_object_id( $cache_object ) {
+ return $cache_object->get_id();
}
/**
* Validate an object before caching it.
*
- * @param array|object $object The object to validate.
+ * @param array|object $cache_object The object to validate.
+ *
* @return string[]|null An array of error messages, or null if the object is valid.
*/
- protected function validate( $object ): ?array {
- if ( ! $object instanceof Label ) {
- return array( 'The supplied label is not an instance of Label, ' . gettype( $object ) );
+ protected function validate( $cache_object ): ?array {
+ if ( ! $cache_object instanceof Label ) {
+ return array( 'The supplied label is not an instance of Label, ' . gettype( $cache_object ) );
}
return null;
diff --git a/src/Caches/ShipmentOrderCache.php b/src/Caches/ShipmentOrderCache.php
index 6f2de4f7..83094f6b 100644
--- a/src/Caches/ShipmentOrderCache.php
+++ b/src/Caches/ShipmentOrderCache.php
@@ -22,22 +22,24 @@ public function get_object_type(): string {
/**
* Get the id of an object to be cached.
*
- * @param array|object $object The object to be cached.
+ * @param array|object $cache_object The object to be cached.
+ *
* @return int|string|null The id of the object, or null if it can't be determined.
*/
- protected function get_object_id( $object ) {
- return $object->get_id();
+ protected function get_object_id( $cache_object ) {
+ return $cache_object->get_id();
}
/**
* Validate an object before caching it.
*
- * @param array|object $object The object to validate.
+ * @param array|object $cache_object The object to validate.
+ *
* @return string[]|null An array of error messages, or null if the object is valid.
*/
- protected function validate( $object ): ?array {
- if ( ! $object instanceof Order ) {
- return array( 'The supplied order is not an instance of Order, ' . gettype( $object ) );
+ protected function validate( $cache_object ): ?array {
+ if ( ! $cache_object instanceof Order ) {
+ return array( 'The supplied order is not an instance of Order, ' . gettype( $cache_object ) );
}
return null;
diff --git a/src/Caches/ShippingProviderCache.php b/src/Caches/ShippingProviderCache.php
index fd5c0f46..5524e149 100644
--- a/src/Caches/ShippingProviderCache.php
+++ b/src/Caches/ShippingProviderCache.php
@@ -22,22 +22,24 @@ public function get_object_type(): string {
/**
* Get the id of an object to be cached.
*
- * @param array|object $object The object to be cached.
+ * @param array|object $cache_object The object to be cached.
+ *
* @return int|string|null The id of the object, or null if it can't be determined.
*/
- protected function get_object_id( $object ) {
- return $object->get_id();
+ protected function get_object_id( $cache_object ) {
+ return $cache_object->get_id();
}
/**
* Validate an object before caching it.
*
- * @param array|object $object The object to validate.
+ * @param array|object $cache_object The object to validate.
+ *
* @return string[]|null An array of error messages, or null if the object is valid.
*/
- protected function validate( $object ): ?array {
- if ( ! $object instanceof ShippingProvider ) {
- return array( 'The supplied shipping provider is not an instance of ShippingProvider, ' . gettype( $object ) );
+ protected function validate( $cache_object ): ?array {
+ if ( ! $cache_object instanceof ShippingProvider ) {
+ return array( 'The supplied shipping provider is not an instance of ShippingProvider, ' . gettype( $cache_object ) );
}
return null;
diff --git a/src/Compatibility/Bundles.php b/src/Compatibility/Bundles.php
index 79e5e219..ba8fb093 100644
--- a/src/Compatibility/Bundles.php
+++ b/src/Compatibility/Bundles.php
@@ -19,7 +19,7 @@ public static function is_active() {
public static function init() {
add_action(
'woocommerce_shiptastic_before_prepare_cart_contents',
- function() {
+ function () {
self::$cart_bundled_by_map = array();
}
);
diff --git a/src/DataStores/Label.php b/src/DataStores/Label.php
index 1272aeb3..a9904a5f 100644
--- a/src/DataStores/Label.php
+++ b/src/DataStores/Label.php
@@ -417,18 +417,18 @@ protected function save_label_data( &$label ) {
*
* Note: WordPress `get_metadata` function returns an empty string when meta data does not exist.
*
- * @param WC_Data $object The WP_Data object (WC_Coupon for coupons, etc).
+ * @param WC_Data $label The WP_Data object (WC_Coupon for coupons, etc).
* @param string $meta_key Meta key to update.
* @param mixed $meta_value Value to save.
*
*
* @return bool True if updated/deleted.
*/
- protected function update_or_delete_meta( $object, $meta_key, $meta_value ) {
+ protected function update_or_delete_meta( $label, $meta_key, $meta_value ) {
if ( in_array( $meta_value, array( array(), '' ), true ) && ! in_array( $meta_key, $this->must_exist_meta_keys, true ) ) {
- $updated = delete_metadata( $this->meta_type, $object->get_id(), $meta_key );
+ $updated = delete_metadata( $this->meta_type, $label->get_id(), $meta_key );
} else {
- $updated = update_metadata( $this->meta_type, $object->get_id(), $meta_key, $meta_value );
+ $updated = update_metadata( $this->meta_type, $label->get_id(), $meta_key, $meta_value );
}
return (bool) $updated;
diff --git a/src/DataStores/Packaging.php b/src/DataStores/Packaging.php
index db615d45..4015434d 100644
--- a/src/DataStores/Packaging.php
+++ b/src/DataStores/Packaging.php
@@ -368,18 +368,18 @@ protected function save_packaging_data( &$packaging ) {
*
* Note: WordPress `get_metadata` function returns an empty string when meta data does not exist.
*
- * @param WC_Data $object The WP_Data object (WC_Coupon for coupons, etc).
+ * @param WC_Data $packaging The WP_Data object (WC_Coupon for coupons, etc).
* @param string $meta_key Meta key to update.
* @param mixed $meta_value Value to save.
*
*
* @return bool True if updated/deleted.
*/
- protected function update_or_delete_meta( $object, $meta_key, $meta_value ) {
+ protected function update_or_delete_meta( $packaging, $meta_key, $meta_value ) {
if ( in_array( $meta_value, array( array(), '' ), true ) && ! in_array( $meta_key, $this->must_exist_meta_keys, true ) ) {
- $updated = delete_metadata( $this->meta_type, $object->get_id(), $meta_key );
+ $updated = delete_metadata( $this->meta_type, $packaging->get_id(), $meta_key );
} else {
- $updated = update_metadata( $this->meta_type, $object->get_id(), $meta_key, $meta_value );
+ $updated = update_metadata( $this->meta_type, $packaging->get_id(), $meta_key, $meta_value );
}
return (bool) $updated;
diff --git a/src/DataStores/Shipment.php b/src/DataStores/Shipment.php
index 78e07954..8ebc5db4 100644
--- a/src/DataStores/Shipment.php
+++ b/src/DataStores/Shipment.php
@@ -508,18 +508,18 @@ protected function save_shipment_data( &$shipment ) {
*
* Note: WordPress `get_metadata` function returns an empty string when meta data does not exist.
*
- * @param WC_Data $object The WP_Data object (WC_Coupon for coupons, etc).
+ * @param WC_Data $shipment The WP_Data object (WC_Coupon for coupons, etc).
* @param string $meta_key Meta key to update.
* @param mixed $meta_value Value to save.
*
*
* @return bool True if updated/deleted.
*/
- protected function update_or_delete_meta( $object, $meta_key, $meta_value ) {
+ protected function update_or_delete_meta( $shipment, $meta_key, $meta_value ) {
if ( in_array( $meta_value, array( array(), '' ), true ) && ! in_array( $meta_key, $this->must_exist_meta_keys, true ) ) {
- $updated = delete_metadata( 'stc_shipment', $object->get_id(), $meta_key );
+ $updated = delete_metadata( 'stc_shipment', $shipment->get_id(), $meta_key );
} else {
- $updated = update_metadata( 'stc_shipment', $object->get_id(), $meta_key, $meta_value );
+ $updated = update_metadata( 'stc_shipment', $shipment->get_id(), $meta_key, $meta_value );
}
return (bool) $updated;
@@ -560,7 +560,7 @@ public function read_items( $shipment ) {
$shipment_type = $shipment->get_type();
$items = array_map(
- function( $item_id ) use ( $shipment_type, $shipment ) {
+ function ( $item_id ) use ( $shipment_type, $shipment ) {
$item = wc_stc_get_shipment_item( $item_id, $shipment_type );
if ( $item ) {
diff --git a/src/DataStores/ShipmentItem.php b/src/DataStores/ShipmentItem.php
index 0c8cdafc..c679bab0 100644
--- a/src/DataStores/ShipmentItem.php
+++ b/src/DataStores/ShipmentItem.php
@@ -234,18 +234,18 @@ protected function read_item_data( &$item ) {
*
* Note: WordPress `get_metadata` function returns an empty string when meta data does not exist.
*
- * @param WC_Data $object The WP_Data object (WC_Coupon for coupons, etc).
+ * @param WC_Data $shipment_item The WP_Data object (WC_Coupon for coupons, etc).
* @param string $meta_key Meta key to update.
* @param mixed $meta_value Value to save.
*
*
* @return bool True if updated/deleted.
*/
- protected function update_or_delete_meta( $object, $meta_key, $meta_value ) {
+ protected function update_or_delete_meta( $shipment_item, $meta_key, $meta_value ) {
if ( in_array( $meta_value, array( array(), '' ), true ) && ! in_array( $meta_key, $this->must_exist_meta_keys, true ) ) {
- $updated = delete_metadata( $this->meta_type, $object->get_id(), $meta_key );
+ $updated = delete_metadata( $this->meta_type, $shipment_item->get_id(), $meta_key );
} else {
- $updated = update_metadata( $this->meta_type, $object->get_id(), $meta_key, $meta_value );
+ $updated = update_metadata( $this->meta_type, $shipment_item->get_id(), $meta_key, $meta_value );
}
return (bool) $updated;
@@ -341,7 +341,7 @@ public function read_children( &$item ) {
if ( ! empty( $items ) ) {
$items = array_map(
- function( $item ) {
+ function ( $item ) {
return wc_stc_get_shipment_item( $item->shipment_item_id, $item->shipment_item_type );
},
$items
diff --git a/src/DataStores/ShippingProvider.php b/src/DataStores/ShippingProvider.php
index 72ba7826..2958efbc 100644
--- a/src/DataStores/ShippingProvider.php
+++ b/src/DataStores/ShippingProvider.php
@@ -125,7 +125,7 @@ protected function get_unqiue_name( $provider ) {
do {
$alt_provider_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
$provider_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_provider_name, $provider->get_id() ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
- $suffix++;
+ ++$suffix;
} while ( $provider_name_check || ( $this->is_manual_creation_request() && $this->is_reserved_name( $alt_provider_name ) ) );
$slug = $alt_provider_name;
}
@@ -405,18 +405,18 @@ protected function save_provider_data( &$provider ) {
*
* Note: WordPress `get_metadata` function returns an empty string when meta data does not exist.
*
- * @param WC_Data $object The WP_Data object (WC_Coupon for coupons, etc).
+ * @param WC_Data $shipping_provider The WP_Data object (WC_Coupon for coupons, etc).
* @param string $meta_key Meta key to update.
* @param mixed $meta_value Value to save.
*
*
* @return bool True if updated/deleted.
*/
- protected function update_or_delete_meta( $object, $meta_key, $meta_value ) {
+ protected function update_or_delete_meta( $shipping_provider, $meta_key, $meta_value ) {
if ( in_array( $meta_value, array( array(), '' ), true ) && ! in_array( $meta_key, $this->must_exist_meta_keys, true ) ) {
- $updated = delete_metadata( 'stc_shipping_provider', $object->get_id(), $meta_key );
+ $updated = delete_metadata( 'stc_shipping_provider', $shipping_provider->get_id(), $meta_key );
} else {
- $updated = update_metadata( 'stc_shipping_provider', $object->get_id(), $meta_key, $meta_value );
+ $updated = update_metadata( 'stc_shipping_provider', $shipping_provider->get_id(), $meta_key, $meta_value );
}
return (bool) $updated;
diff --git a/src/FormHandler.php b/src/FormHandler.php
index fec2547f..680419d8 100644
--- a/src/FormHandler.php
+++ b/src/FormHandler.php
@@ -2,7 +2,7 @@
namespace Vendidero\Shiptastic;
-use \Exception;
+use Exception;
use WC_Order;
use WP_Query;
diff --git a/src/Install.php b/src/Install.php
index c9f8f68e..f334b970 100644
--- a/src/Install.php
+++ b/src/Install.php
@@ -261,15 +261,15 @@ private static function create_upload_dir() {
$dir = Package::get_upload_dir();
if ( ! @is_dir( $dir['basedir'] ) ) { // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
- @mkdir( $dir['basedir'] ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
+ @mkdir( $dir['basedir'] ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged, WordPress.WP.AlternativeFunctions.file_system_operations_mkdir
}
if ( ! file_exists( trailingslashit( $dir['basedir'] ) . '.htaccess' ) ) {
- @file_put_contents( trailingslashit( $dir['basedir'] ) . '.htaccess', 'deny from all' ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged,WordPress.WP.AlternativeFunctions.file_system_read_file_put_contents
+ @file_put_contents( trailingslashit( $dir['basedir'] ) . '.htaccess', 'deny from all' ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged, WordPress.WP.AlternativeFunctions.file_system_operations_file_put_contents
}
if ( ! file_exists( trailingslashit( $dir['basedir'] ) . 'index.php' ) ) {
- @touch( trailingslashit( $dir['basedir'] ) . 'index.php' ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
+ @touch( trailingslashit( $dir['basedir'] ) . 'index.php' ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged, WordPress.WP.AlternativeFunctions.file_system_operations_touch
}
}
diff --git a/src/Interfaces/Compatibility.php b/src/Interfaces/Compatibility.php
index 5e3b2e93..bfcb2216 100644
--- a/src/Interfaces/Compatibility.php
+++ b/src/Interfaces/Compatibility.php
@@ -2,11 +2,6 @@
namespace Vendidero\Shiptastic\Interfaces;
-/**
- * Compatibility
- *
- * @version 1.0.0
- */
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
diff --git a/src/Interfaces/LabelConfigurationSet.php b/src/Interfaces/LabelConfigurationSet.php
index b681b822..1381f754 100644
--- a/src/Interfaces/LabelConfigurationSet.php
+++ b/src/Interfaces/LabelConfigurationSet.php
@@ -3,11 +3,6 @@
use Vendidero\Shiptastic\Labels\ConfigurationSet;
-/**
- * Shipment Label Interface
- *
- * @version 3.1.0
- */
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
diff --git a/src/Interfaces/ShipmentLabel.php b/src/Interfaces/ShipmentLabel.php
index 939d12df..04b2b898 100644
--- a/src/Interfaces/ShipmentLabel.php
+++ b/src/Interfaces/ShipmentLabel.php
@@ -3,11 +3,6 @@
use Vendidero\Shiptastic\ShipmentError;
-/**
- * Shipment Label Interface
- *
- * @version 3.1.0
- */
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
diff --git a/src/Interfaces/ShipmentReturnLabel.php b/src/Interfaces/ShipmentReturnLabel.php
index 873d5614..078b9f36 100644
--- a/src/Interfaces/ShipmentReturnLabel.php
+++ b/src/Interfaces/ShipmentReturnLabel.php
@@ -1,18 +1,10 @@
services ) ) {
return $name;
- } else {
- if ( $key = array_search( $name, $this->get_all_services(), true ) ) {
+ } elseif ( $key = array_search( $name, $this->get_all_services(), true ) ) {
return $key;
- }
}
return $name;
@@ -238,12 +236,12 @@ public function get_service_meta( $service_id, $meta_key, $default_value = null
return array_key_exists( $additional_id, $this->additional ) ? $this->additional[ $additional_id ] : $default_value;
}
- public function get_service_value( $service, $default = null ) {
+ public function get_service_value( $service, $default_value = null ) {
if ( $service_id = $this->get_service_id( $service ) ) {
$service = $service_id;
}
- return array_key_exists( $service, $this->services ) ? $this->services[ $service ]['value'] : $default;
+ return array_key_exists( $service, $this->services ) ? $this->services[ $service ]['value'] : $default_value;
}
public function get_settings() {
@@ -314,7 +312,7 @@ public function has_setting( $id ) {
return false;
}
- public function get_setting( $id, $default = null, $group = '' ) {
+ public function get_setting( $id, $default_value = null, $group = '' ) {
$details = $this->get_setting_details( $id );
$settings = $this->get_settings();
@@ -324,7 +322,7 @@ public function get_setting( $id, $default = null, $group = '' ) {
}
if ( 'service_meta' === $group && ! empty( $details['service_meta'] ) ) {
- return $this->get_service_meta( $id, $details['service_meta'], $default );
+ return $this->get_service_meta( $id, $details['service_meta'], $default_value );
} else {
$setting_id = $this->get_clean_setting_id( $id );
@@ -333,7 +331,7 @@ public function get_setting( $id, $default = null, $group = '' ) {
}
}
- return $default;
+ return $default_value;
}
public function update_setting( $id, $value, $group = '' ) {
diff --git a/src/Labels/DownloadHandler.php b/src/Labels/DownloadHandler.php
index d6461d46..0f042ccf 100644
--- a/src/Labels/DownloadHandler.php
+++ b/src/Labels/DownloadHandler.php
@@ -24,7 +24,7 @@ public static function init() {
public static function download_bulk_export() {
if ( isset( $_GET['action'] ) && 'wc-stc-download-export-shipment-label' === $_GET['action'] && isset( $_REQUEST['_wpnonce'] ) ) {
- if ( wp_verify_nonce( wp_unslash( $_REQUEST['_wpnonce'] ), 'download-export-shipment-label' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
+ if ( wp_verify_nonce( wc_clean( wp_unslash( $_REQUEST['_wpnonce'] ) ), 'download-export-shipment-label' ) ) {
$args = array(
'force' => isset( $_GET['force'] ) ? wc_clean( wp_unslash( $_GET['force'] ) ) : 'no', // phpcs:ignore WordPress.Security.NonceVerification.Recommended
);
@@ -45,7 +45,7 @@ public static function download_bulk_export() {
}
public static function download_label() {
- if ( 'wc-stc-download-shipment-label' === $_GET['action'] && wp_verify_nonce( wp_unslash( $_REQUEST['_wpnonce'] ), 'download-shipment-label' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
+ if ( 'wc-stc-download-shipment-label' === $_GET['action'] && wp_verify_nonce( wc_clean( wp_unslash( $_REQUEST['_wpnonce'] ) ), 'download-shipment-label' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated
$shipment_id = absint( $_GET['shipment_id'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated
$has_permission = current_user_can( 'edit_shop_orders' );
@@ -127,7 +127,7 @@ private static function embed( $file_path, $filename ) {
header( 'Content-Length: ' . $file_size );
- @readfile( $file_path ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged,WordPress.WP.AlternativeFunctions.file_system_read_readfile
+ @readfile( $file_path ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged, WordPress.WP.AlternativeFunctions.file_system_operations_readfile
exit();
}
}
diff --git a/src/Labels/Factory.php b/src/Labels/Factory.php
index 995e02fd..31fc03d5 100644
--- a/src/Labels/Factory.php
+++ b/src/Labels/Factory.php
@@ -10,8 +10,8 @@
use Vendidero\Shiptastic\Caches\Helper;
use Vendidero\Shiptastic\Interfaces\ShipmentLabel;
-use \WC_Data_Store;
-use \Exception;
+use WC_Data_Store;
+use Exception;
defined( 'ABSPATH' ) || exit;
diff --git a/src/Labels/Label.php b/src/Labels/Label.php
index e4f642bd..5860a4d8 100644
--- a/src/Labels/Label.php
+++ b/src/Labels/Label.php
@@ -295,17 +295,17 @@ public function has_service( $service ) {
*
* @param $service
* @param $prop
- * @param $default
+ * @param $default_value
*
* @return mixed
*/
- public function get_service_prop( $service, $prop, $default = null, $context = 'view' ) {
+ public function get_service_prop( $service, $prop, $default_value = null, $context = 'view' ) {
$meta_key = "service_{$service}_{$prop}";
if ( $this->get_meta( $meta_key, true, $context ) ) {
return $this->get_meta( $meta_key, true, $context );
} else {
- return $default;
+ return $default_value;
}
}
@@ -744,7 +744,7 @@ protected function get_per_item_weights( $total_weight, $item_weights, $shipment
* Discrepancies detected between item weights and total shipment weight.
* Try to distribute the mismatch between items.
*/
- if ( $item_total_weight != $total_weight ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
+ if ( $item_total_weight != $total_weight ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseNotEqual
$diff = $total_weight - $item_total_weight;
$diff_abs = abs( $diff );
diff --git a/src/Labels/Query.php b/src/Labels/Query.php
index d2da7150..f04bdf04 100644
--- a/src/Labels/Query.php
+++ b/src/Labels/Query.php
@@ -402,25 +402,26 @@ protected function prepare_query() {
* Used internally to generate an SQL string for searching across multiple columns
*
*
- * @global \wpdb $wpdb WordPress database abstraction object.
- *
- * @param string $string
+ * @param string $search_query
* @param array $cols
* @param bool $wild Whether to allow wildcard searches. Default is false for Network Admin, true for single site.
* Single site allows leading and trailing wildcards, Network Admin only trailing.
+ *
* @return string
+ *@global \wpdb $wpdb WordPress database abstraction object.
+ *
*/
- protected function get_search_sql( $string, $cols, $wild = false ) {
+ protected function get_search_sql( $search_query, $cols, $wild = false ) {
global $wpdb;
$searches = array();
$leading_wild = ( 'leading' === $wild || 'both' === $wild ) ? '%' : '';
$trailing_wild = ( 'trailing' === $wild || 'both' === $wild ) ? '%' : '';
- $like = $leading_wild . $wpdb->esc_like( $string ) . $trailing_wild;
+ $like = $leading_wild . $wpdb->esc_like( $search_query ) . $trailing_wild;
foreach ( $cols as $col ) {
if ( 'ID' === $col ) {
- $searches[] = $wpdb->prepare( "$col = %s", $string ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
+ $searches[] = $wpdb->prepare( "$col = %s", $search_query ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
} else {
$searches[] = $wpdb->prepare( "$col LIKE %s", $like ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
}
diff --git a/src/Order.php b/src/Order.php
index 869d2a8d..765deda4 100644
--- a/src/Order.php
+++ b/src/Order.php
@@ -336,49 +336,47 @@ public function create_shipments( $default_status = 'processing' ) {
$errors->add( $code, $message );
}
}
- } else {
- if ( 0 === count( $packed_boxes ) ) {
+ } elseif ( 0 === count( $packed_boxes ) ) {
$errors->add( 404, sprintf( _x( 'Seems like none of your packaging options is available for this order.', 'shipments', 'shiptastic-for-woocommerce' ), Settings::get_settings_url( 'packaging' ) ) );
- } else {
- foreach ( $packed_boxes as $box ) {
- $packaging = $box->getBox();
- $items = $box->getItems();
- $shipment_items = array();
-
- foreach ( $items as $item ) {
- $order_item = $item->getItem();
-
- if ( ! isset( $shipment_items[ $order_item->get_id() ] ) ) {
- $shipment_items[ $order_item->get_id() ] = 1;
- } else {
- $shipment_items[ $order_item->get_id() ]++;
- }
- }
+ } else {
+ foreach ( $packed_boxes as $box ) {
+ $packaging = $box->getBox();
+ $items = $box->getItems();
+ $shipment_items = array();
+
+ foreach ( $items as $item ) {
+ $order_item = $item->getItem();
- $shipment = wc_stc_create_shipment(
- $this,
- array(
- 'items' => $shipment_items,
- 'props' => array(
- 'packaging_id' => $packaging->get_id(),
- 'status' => $default_status,
- ),
- )
- );
-
- if ( ! is_wp_error( $shipment ) ) {
- $this->add_shipment( $shipment );
-
- $shipments_created[ $shipment->get_id() ] = $shipment;
+ if ( ! isset( $shipment_items[ $order_item->get_id() ] ) ) {
+ $shipment_items[ $order_item->get_id() ] = 1;
} else {
- foreach ( $shipments_created as $id => $shipment_created ) {
- $shipment_created->delete( true );
- $this->remove_shipment( $id );
- }
-
- foreach ( $shipment->get_error_messages() as $code => $message ) {
- $errors->add( $code, $message );
- }
+ ++$shipment_items[ $order_item->get_id() ];
+ }
+ }
+
+ $shipment = wc_stc_create_shipment(
+ $this,
+ array(
+ 'items' => $shipment_items,
+ 'props' => array(
+ 'packaging_id' => $packaging->get_id(),
+ 'status' => $default_status,
+ ),
+ )
+ );
+
+ if ( ! is_wp_error( $shipment ) ) {
+ $this->add_shipment( $shipment );
+
+ $shipments_created[ $shipment->get_id() ] = $shipment;
+ } else {
+ foreach ( $shipments_created as $id => $shipment_created ) {
+ $shipment_created->delete( true );
+ $this->remove_shipment( $id );
+ }
+
+ foreach ( $shipment->get_error_messages() as $code => $message ) {
+ $errors->add( $code, $message );
}
}
}
@@ -590,7 +588,7 @@ public function get_shipment_position_number( $shipment ) {
if ( $shipment->get_id() === $loop_shipment->get_id() ) {
break;
}
- $number++;
+ ++$number;
}
}
diff --git a/src/Orders/Factory.php b/src/Orders/Factory.php
index 2e63acb1..660e7ab8 100644
--- a/src/Orders/Factory.php
+++ b/src/Orders/Factory.php
@@ -10,7 +10,7 @@
use Vendidero\Shiptastic\Caches\Helper;
use Vendidero\Shiptastic\Order;
-use \Exception;
+use Exception;
defined( 'ABSPATH' ) || exit;
diff --git a/src/PDFMerger.php b/src/PDFMerger.php
index 283dc5a0..7f9408ea 100644
--- a/src/PDFMerger.php
+++ b/src/PDFMerger.php
@@ -32,7 +32,7 @@ public function add( $filename, $pages = array(), $width = 210 ) {
if ( file_exists( $filename ) ) {
$page_count = $this->_pdf->setSourceFile( $filename );
- for ( $i = 1; $i <= $page_count; $i ++ ) {
+ for ( $i = 1; $i <= $page_count; $i++ ) {
if ( $this->_isPageInRange( $i, $pages ) ) {
$this->_addPage( $i, $width );
}
diff --git a/src/PDFSplitter.php b/src/PDFSplitter.php
index fe2f6f62..c6a137ad 100644
--- a/src/PDFSplitter.php
+++ b/src/PDFSplitter.php
@@ -173,5 +173,4 @@ private function _getRange( $value = null ) { // phpcs:ignore PSR2.Methods.Metho
return range( $value[0] > $value[1] ? $value[1] : $value[0], $value[0] > $value[1] ? $value[0] : $value[1] );
}
-
}
diff --git a/src/Package.php b/src/Package.php
index 9ce244c7..62101ce5 100644
--- a/src/Package.php
+++ b/src/Package.php
@@ -851,10 +851,10 @@ public static function get_assets_url( $script_or_style ) {
return trailingslashit( $assets_url ) . $script_or_style;
}
- public static function get_setting( $name, $default = false ) {
+ public static function get_setting( $name, $default_value = false ) {
$option_name = "woocommerce_shiptastic_{$name}";
- return get_option( $option_name, $default );
+ return get_option( $option_name, $default_value );
}
public static function get_store_address_country() {
diff --git a/src/Packaging/AsyncReportGenerator.php b/src/Packaging/AsyncReportGenerator.php
index cb32cad0..e535954b 100644
--- a/src/Packaging/AsyncReportGenerator.php
+++ b/src/Packaging/AsyncReportGenerator.php
@@ -113,7 +113,7 @@ public function next() {
$packaging_data[ $country ][ "$packaging_id" ]['count'] += 1;
$packaging_data[ $country ][ "$packaging_id" ]['weight_in_kg'] += wc_add_number_precision( (float) wc_get_weight( $packaging_weight, 'kg', $shipment->get_weight_unit() ), false );
- $shipments_processed++;
+ ++$shipments_processed;
}
$this->args['processed'] = absint( $this->args['processed'] ) + $shipments_processed;
diff --git a/src/Packaging/Report.php b/src/Packaging/Report.php
index ffbff60c..84c14270 100644
--- a/src/Packaging/Report.php
+++ b/src/Packaging/Report.php
@@ -251,10 +251,8 @@ public function get_packaging_count( $packaging_id, $country = '' ) {
if ( isset( $this->args['packaging'][ "$packaging_id" ] ) ) {
$count = absint( $this->args['packaging'][ "$packaging_id" ]['count'] );
}
- } else {
- if ( isset( $this->args['countries'][ $country ], $this->args['countries'][ $country ]['packaging'][ "$packaging_id" ] ) ) {
+ } elseif ( isset( $this->args['countries'][ $country ], $this->args['countries'][ $country ]['packaging'][ "$packaging_id" ] ) ) {
$count = absint( $this->args['countries'][ $country ]['packaging'][ "$packaging_id" ]['count'] );
- }
}
return $count;
@@ -267,10 +265,8 @@ public function get_packaging_weight( $packaging_id, $country = '', $round = tru
if ( isset( $this->args['packaging'][ "$packaging_id" ] ) ) {
$weight = $this->args['packaging'][ "$packaging_id" ]['weight_in_kg'];
}
- } else {
- if ( isset( $this->args['countries'][ $country ], $this->args['countries'][ $country ]['packaging'][ "$packaging_id" ] ) ) {
+ } elseif ( isset( $this->args['countries'][ $country ], $this->args['countries'][ $country ]['packaging'][ "$packaging_id" ] ) ) {
$weight = $this->args['countries'][ $country ]['packaging'][ "$packaging_id" ]['weight_in_kg'];
- }
}
$weight = wc_get_weight( $weight, $unit, 'kg' );
diff --git a/src/Packaging/ReportHelper.php b/src/Packaging/ReportHelper.php
index 4ed8f0fb..1539bd47 100644
--- a/src/Packaging/ReportHelper.php
+++ b/src/Packaging/ReportHelper.php
@@ -18,7 +18,7 @@ public static function init() {
add_action(
ReportQueue::get_hook_name( $id ),
- function( $args ) use ( $type ) {
+ function ( $args ) use ( $type ) {
ReportQueue::next( $type, $args );
},
10,
@@ -171,7 +171,7 @@ public static function render_report() {
else :
$details = ReportQueue::get_queue_details( $report_id );
?>
- Find pending actions', 'shipments', 'shiptastic-for-woocommerce' ), esc_html( $details['shipment_count'] ), ( $details['next_date'] ? esc_html( $details['next_date']->date_i18n( wc_date_format() . ' @ ' . wc_time_format() ) ) : esc_html_x( 'Not yet known', 'shipments', 'shiptastic-for-woocommerce' ) ), esc_url( $details['link'] ) ); ?>
+ Find pending actions', 'shipments', 'shiptastic-for-woocommerce' ), esc_html( $details['shipment_count'] ), ( $details['next_date'] ? esc_html( $details['next_date']->date_i18n( wc_date_format() . ' @ ' . wc_time_format() ) ) : esc_html_x( 'Not yet known', 'shipments', 'shiptastic-for-woocommerce' ) ), esc_url( $details['link'] ) ) ); ?>
get_status() ) {
- $report->delete();
- }
+ } elseif ( $report = self::get_report( $report_id ) ) {
+ if ( 'completed' !== $report->get_status() ) {
+ $report->delete();
}
}
}
@@ -380,7 +378,7 @@ public static function get_reports( $args = array() ) {
if ( array_key_exists( $args['orderby'], array( 'date_start', 'date_end' ) ) ) {
usort(
$reports_sorted,
- function( $a, $b ) use ( $args ) {
+ function ( $a, $b ) use ( $args ) {
if ( $a[ $args['orderby'] ] === $b[ $args['orderby'] ] ) {
return 0;
}
@@ -439,7 +437,7 @@ public static function get_report( $id ) {
}
public static function delete_report() {
- if ( ! current_user_can( 'manage_woocommerce' ) || ! wp_verify_nonce( isset( $_GET['_wpnonce'] ) ? wp_unslash( $_GET['_wpnonce'] ) : '', 'wc_shiptastic_packaging_delete_report' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
+ if ( ! current_user_can( 'manage_woocommerce' ) || ! wp_verify_nonce( isset( $_GET['_wpnonce'] ) ? wc_clean( wp_unslash( $_GET['_wpnonce'] ) ) : '', 'wc_shiptastic_packaging_delete_report' ) ) {
wp_die();
}
@@ -472,7 +470,7 @@ protected static function get_clean_referer() {
}
public static function refresh_report() {
- if ( ! current_user_can( 'manage_woocommerce' ) || ! wp_verify_nonce( isset( $_GET['_wpnonce'] ) ? wp_unslash( $_GET['_wpnonce'] ) : '', 'wc_shiptastic_packaging_refresh_report' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
+ if ( ! current_user_can( 'manage_woocommerce' ) || ! wp_verify_nonce( isset( $_GET['_wpnonce'] ) ? wc_clean( wp_unslash( $_GET['_wpnonce'] ) ) : '', 'wc_shiptastic_packaging_refresh_report' ) ) {
wp_die();
}
@@ -490,7 +488,7 @@ public static function refresh_report() {
}
public static function cancel_report() {
- if ( ! current_user_can( 'manage_woocommerce' ) || ! wp_verify_nonce( isset( $_GET['_wpnonce'] ) ? wp_unslash( $_GET['_wpnonce'] ) : '', 'wc_shiptastic_packaging_cancel_report' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
+ if ( ! current_user_can( 'manage_woocommerce' ) || ! wp_verify_nonce( isset( $_GET['_wpnonce'] ) ? wc_clean( wp_unslash( $_GET['_wpnonce'] ) ) : '', 'wc_shiptastic_packaging_cancel_report' ) ) {
wp_die();
}
diff --git a/src/PackagingFactory.php b/src/PackagingFactory.php
index 4c542c52..e528c0c1 100644
--- a/src/PackagingFactory.php
+++ b/src/PackagingFactory.php
@@ -9,7 +9,7 @@
*/
namespace Vendidero\Shiptastic;
-use \Exception;
+use Exception;
use Vendidero\Shiptastic\Caches\Helper;
defined( 'ABSPATH' ) || exit;
diff --git a/src/Packing/Helper.php b/src/Packing/Helper.php
index 763b8f4e..de21891f 100644
--- a/src/Packing/Helper.php
+++ b/src/Packing/Helper.php
@@ -81,13 +81,13 @@ public static function enable_auto_packing() {
*
* @return PackedBoxList
*/
- public static function pack( $items, $boxes, $for = 'order' ) {
+ public static function pack( $items, $boxes, $context = 'order' ) {
self::$items_too_large = array();
/**
* @var \Vendidero\Shiptastic\Packing\Packer $packer
*/
- $packer = apply_filters( 'woocommerce_shiptastic_packer_instance', new Packer(), $items, $boxes, $for );
+ $packer = apply_filters( 'woocommerce_shiptastic_packer_instance', new Packer(), $items, $boxes, $context );
$packer->set_boxes( $boxes );
$packer->set_items( $items );
@@ -98,7 +98,7 @@ public static function pack( $items, $boxes, $for = 'order' ) {
$packer->set_max_boxes_to_balance_weight( 0 );
}
- do_action( 'woocommerce_shiptastic_packer_before_pack', $packer, $for );
+ do_action( 'woocommerce_shiptastic_packer_before_pack', $packer, $context );
$packed_boxes = $packer->pack();
diff --git a/src/PickupDelivery.php b/src/PickupDelivery.php
index 2569b3a0..ffe230dd 100644
--- a/src/PickupDelivery.php
+++ b/src/PickupDelivery.php
@@ -3,7 +3,7 @@
namespace Vendidero\Shiptastic;
use Automattic\WooCommerce\StoreApi\Utilities\CartController;
-use \Exception;
+use Exception;
use WC_Order;
use WP_Query;
@@ -371,7 +371,7 @@ public static function register_pickup_location_notice_field( $field, $key, $arg
>
-
+
get_label() : '' ); ?>
@@ -877,7 +877,7 @@ public static function register_classic_checkout_fields( $fields ) {
if ( 'order' === $current_pickup_location_field_group ) {
add_action(
'woocommerce_after_order_notes',
- function( $checkout ) use ( $current_pickup_location_field ) {
+ function ( $checkout ) use ( $current_pickup_location_field ) {
if ( ! did_action( 'woocommerce_shiptastic_current_pickup_location_field_rendered' ) ) {
woocommerce_form_field( 'current_pickup_location', $current_pickup_location_field, $checkout->get_value( 'current_pickup_location' ) );
}
diff --git a/src/Registry/Container.php b/src/Registry/Container.php
index a67ec600..39216034 100644
--- a/src/Registry/Container.php
+++ b/src/Registry/Container.php
@@ -86,7 +86,7 @@ public function get( $id ) {
throw new Exception(
sprintf(
'Cannot construct an instance of %s because it has not been registered.',
- $id
+ esc_html( $id )
)
);
}
diff --git a/src/Rest/ShipmentsController.php b/src/Rest/ShipmentsController.php
index e5713d11..33d50a39 100644
--- a/src/Rest/ShipmentsController.php
+++ b/src/Rest/ShipmentsController.php
@@ -351,10 +351,8 @@ protected function prepare_object_for_database( $request, $creating = false ) {
if ( ! $order_shipment->needs_return() ) {
throw new \WC_REST_Exception( 'woocommerce_stc_rest_invalid_id', esc_html_x( 'This order does need a return.', 'shipments', 'shiptastic-for-woocommerce' ) );
}
- } else {
- if ( ! $order_shipment->needs_shipping() ) {
+ } elseif ( ! $order_shipment->needs_shipping() ) {
throw new \WC_REST_Exception( 'woocommerce_stc_rest_invalid_id', esc_html_x( 'This order does need shipping.', 'shipments', 'shiptastic-for-woocommerce' ) );
- }
}
$shipment->sync();
@@ -613,40 +611,38 @@ protected function set_item( $shipment, $posted ) {
}
$item->sync( array( 'quantity' => $quantity ) );
- } else {
- if ( $order_shipment = $shipment->get_order_shipment() ) {
+ } elseif ( $order_shipment = $shipment->get_order_shipment() ) {
$quantity = isset( $posted['quantity'] ) ? absint( wp_unslash( $posted['quantity'] ) ) : $item->get_quantity();
$quantity_left = 0;
- if ( 'return' === $shipment->get_type() ) {
- $quantity_left = $order_shipment->get_item_quantity_left_for_returning(
- $item->get_order_item_id(),
- array(
- 'exclude_current_shipment' => true,
- 'shipment_id' => $shipment->get_id(),
- )
- );
- } elseif ( $order_item = $item->get_order_item() ) {
- $quantity_left = $order_shipment->get_item_quantity_left_for_shipping(
- $order_item,
- array(
- 'exclude_current_shipment' => true,
- 'shipment_id' => $shipment->get_id(),
- )
- );
- }
+ if ( 'return' === $shipment->get_type() ) {
+ $quantity_left = $order_shipment->get_item_quantity_left_for_returning(
+ $item->get_order_item_id(),
+ array(
+ 'exclude_current_shipment' => true,
+ 'shipment_id' => $shipment->get_id(),
+ )
+ );
+ } elseif ( $order_item = $item->get_order_item() ) {
+ $quantity_left = $order_shipment->get_item_quantity_left_for_shipping(
+ $order_item,
+ array(
+ 'exclude_current_shipment' => true,
+ 'shipment_id' => $shipment->get_id(),
+ )
+ );
+ }
- if ( $quantity > $quantity_left ) {
- $quantity = $quantity_left;
- }
+ if ( $quantity > $quantity_left ) {
+ $quantity = $quantity_left;
+ }
- if ( $quantity <= 0 ) {
- $shipment->remove_item( $item->get_id() );
- return;
- }
+ if ( $quantity <= 0 ) {
+ $shipment->remove_item( $item->get_id() );
+ return;
+ }
$shipment->update_item_quantity( $item->get_id(), $quantity );
- }
}
$props_to_set = array(
diff --git a/src/SecretBox.php b/src/SecretBox.php
index 82b45adf..f289ed6d 100644
--- a/src/SecretBox.php
+++ b/src/SecretBox.php
@@ -198,7 +198,7 @@ public static function supports_auto_insert() {
*/
$path_to_wp_config = ABSPATH . '/wp-config.php'; // phpcs:ignore
- if ( @file_exists( $path_to_wp_config ) && @is_writeable( $path_to_wp_config ) ) { // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
+ if ( @file_exists( $path_to_wp_config ) && @is_writeable( $path_to_wp_config ) ) { // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged, WordPress.WP.AlternativeFunctions.file_system_operations_is_writeable
$supports = true;
}
@@ -230,8 +230,6 @@ public static function maybe_insert_missing_key( $encryption_type = '' ) {
$path_to_wp_config = ABSPATH . '/wp-config.php'; // phpcs:ignore
if ( @file_exists( $path_to_wp_config ) ) { // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
- error_reporting( 0 ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.runtime_configuration_error_reporting,WordPress.PHP.DevelopmentFunctions.prevent_path_disclosure_error_reporting
-
// Load file data
$config_file = file( $path_to_wp_config );
$last_define_line = false;
@@ -275,14 +273,14 @@ public static function maybe_insert_missing_key( $encryption_type = '' ) {
array_splice( $config_file, $last_define_line + 1, 0, $to_insert );
}
- $handle = fopen( $path_to_wp_config, 'w' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fopen
+ $handle = fopen( $path_to_wp_config, 'w' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fopen
if ( $handle ) {
foreach ( $config_file as $line ) {
- fwrite( $handle, $line ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fwrite
+ fwrite( $handle, $line ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fwrite
}
- fclose( $handle ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fclose
+ fclose( $handle ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fclose
$updated = true;
}
}
diff --git a/src/Shipment.php b/src/Shipment.php
index 1ce73add..f50012e1 100644
--- a/src/Shipment.php
+++ b/src/Shipment.php
@@ -2081,13 +2081,13 @@ public function sync_packaging() {
public function update_packaging() {
if ( $packaging = $this->get_packaging() ) {
- $packaging_dimension = wc_stc_get_packaging_dimension_unit();
+ $dimension_unit = wc_stc_get_packaging_dimension_unit();
$props = array(
- 'width' => wc_get_dimension( $packaging->get_width( 'edit' ), $this->get_dimension_unit(), $packaging_dimension ),
- 'length' => wc_get_dimension( $packaging->get_length( 'edit' ), $this->get_dimension_unit(), $packaging_dimension ),
- 'height' => wc_get_dimension( $packaging->get_height( 'edit' ), $this->get_dimension_unit(), $packaging_dimension ),
- 'packaging_weight' => wc_get_weight( $packaging->get_weight( 'edit' ), $this->get_weight_unit(), wc_stc_get_packaging_weight_unit() ),
+ 'width' => wc_get_dimension( $packaging->get_width(), $this->get_dimension_unit(), $dimension_unit ),
+ 'length' => wc_get_dimension( $packaging->get_length(), $this->get_dimension_unit(), $dimension_unit ),
+ 'height' => wc_get_dimension( $packaging->get_height(), $this->get_dimension_unit(), $dimension_unit ),
+ 'packaging_weight' => wc_get_weight( $packaging->get_weight(), $this->get_weight_unit(), wc_stc_get_packaging_weight_unit() ),
'packaging_title' => $packaging->get_title(),
);
diff --git a/src/ShipmentFactory.php b/src/ShipmentFactory.php
index 4cbe8e6e..c11fe5d7 100644
--- a/src/ShipmentFactory.php
+++ b/src/ShipmentFactory.php
@@ -11,8 +11,8 @@
use Vendidero\Shiptastic\Caches\Helper;
use Vendidero\Shiptastic\Shipment;
-use \WC_Data_Store;
-use \Exception;
+use WC_Data_Store;
+use Exception;
defined( 'ABSPATH' ) || exit;
diff --git a/src/ShipmentQuery.php b/src/ShipmentQuery.php
index 6f22fe53..d66c62b4 100644
--- a/src/ShipmentQuery.php
+++ b/src/ShipmentQuery.php
@@ -522,25 +522,26 @@ protected function prepare_query() {
* Used internally to generate an SQL string for searching across multiple columns
*
*
- * @global wpdb $wpdb WordPress database abstraction object.
- *
- * @param string $string
+ * @param string $search_query
* @param array $cols
* @param bool $wild Whether to allow wildcard searches. Default is false for Network Admin, true for single site.
* Single site allows leading and trailing wildcards, Network Admin only trailing.
+ *
* @return string
+ *@global wpdb $wpdb WordPress database abstraction object.
+ *
*/
- protected function get_search_sql( $string, $cols, $wild = false ) {
+ protected function get_search_sql( $search_query, $cols, $wild = false ) {
global $wpdb;
$searches = array();
$leading_wild = ( 'leading' === $wild || 'both' === $wild ) ? '%' : '';
$trailing_wild = ( 'trailing' === $wild || 'both' === $wild ) ? '%' : '';
- $like = $leading_wild . $wpdb->esc_like( $string ) . $trailing_wild;
+ $like = $leading_wild . $wpdb->esc_like( $search_query ) . $trailing_wild;
foreach ( $cols as $col ) {
if ( 'ID' === $col ) {
- $searches[] = $wpdb->prepare( "$wpdb->stc_shipments.$col = %s", $string ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
+ $searches[] = $wpdb->prepare( "$wpdb->stc_shipments.$col = %s", $search_query ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
} else {
$searches[] = $wpdb->prepare( "$wpdb->stc_shipments.$col LIKE %s", $like ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
}
diff --git a/src/ShippingMethod/MethodHelper.php b/src/ShippingMethod/MethodHelper.php
index 7717b13b..9f1c757e 100644
--- a/src/ShippingMethod/MethodHelper.php
+++ b/src/ShippingMethod/MethodHelper.php
@@ -191,7 +191,7 @@ public static function set_method_filters( $methods ) {
if ( is_callable( array( $wc, 'is_rest_api_request' ) ) && $wc->is_rest_api_request() ) {
add_filter(
'pre_option',
- function( $pre, $option, $default_value ) {
+ function ( $pre, $option, $default_value ) {
if ( strstr( $option, 'woocommerce_' ) && '_settings' === substr( $option, -9 ) ) {
$option_clean = explode( '_', substr( $option, 0, -9 ) );
$last_part = $option_clean[ count( $option_clean ) - 1 ];
@@ -202,7 +202,7 @@ function( $pre, $option, $default_value ) {
if ( absint( $last_part ) > 0 ) {
add_filter(
"option_{$option}",
- function( $option_value, $option_name ) {
+ function ( $option_value, $option_name ) {
if ( is_array( $option_value ) ) {
foreach ( self::get_method_settings() as $setting_id => $setting ) {
if ( ! array_key_exists( $setting_id, $option_value ) ) {
@@ -514,7 +514,7 @@ public static function get_method_settings( $force_load_all = false ) {
$count = 0;
foreach ( $provider_inner_settings as $shipment_type => $settings ) {
- $count ++;
+ ++$count;
$tabs_open_id = "label_config_set_tabs_{$provider}_{$shipment_type}_open";
$tabs_close_id = "label_config_set_tabs_{$provider}_{$shipment_type}_close";
@@ -646,7 +646,7 @@ public static function render_method_tabs( $html, $key, $setting, $method ) {
$tab_title ) :
- $count++;
+ ++$count;
?>
diff --git a/src/ShippingMethod/ShippingMethod.php b/src/ShippingMethod/ShippingMethod.php
index ba72ed5a..df0b3522 100644
--- a/src/ShippingMethod/ShippingMethod.php
+++ b/src/ShippingMethod/ShippingMethod.php
@@ -359,7 +359,7 @@ public function get_condition_types() {
'data_type' => 'array',
'class' => 'wc-enhanced-select',
'label' => _x( 'Class', 'shipments', 'shiptastic-for-woocommerce' ),
- 'options' => function() {
+ 'options' => function () {
return Package::get_shipping_classes();
},
),
@@ -375,7 +375,7 @@ public function get_condition_types() {
'data_type' => 'array',
'class' => 'wc-enhanced-select',
'label' => _x( 'Class', 'shipments', 'shiptastic-for-woocommerce' ),
- 'options' => function() {
+ 'options' => function () {
return Package::get_shipping_classes();
},
),
@@ -424,7 +424,7 @@ public function get_rate_label( $costs ) {
return $label;
}
- public function get_cache( $property = null, $default = null ) {
+ public function get_cache( $property = null, $default_value = null ) {
$cache = wp_parse_args(
$this->get_option( 'cache', array() ),
array(
@@ -443,7 +443,7 @@ public function get_cache( $property = null, $default = null ) {
if ( array_key_exists( $property, $cache ) ) {
return $cache[ $property ];
} else {
- return $default;
+ return $default_value;
}
}
@@ -714,18 +714,18 @@ public function calculate_shipping( $package = array() ) {
$weight += $cart_item_wrapper->getWeight();
if ( array_key_exists( $product_key, $item_map ) ) {
- $item_map[ $product_key ]++;
+ ++$item_map[ $product_key ];
} else {
$item_map[ $product_key ] = 1;
}
if ( array_key_exists( $product_key, $total_packed_item_map ) ) {
- $total_packed_item_map[ $product_key ]++;
+ ++$total_packed_item_map[ $product_key ];
} else {
$total_packed_item_map[ $product_key ] = 1;
}
- $total_packed_items++;
+ ++$total_packed_items;
}
$applied_rules[] = array(
@@ -746,7 +746,7 @@ public function calculate_shipping( $package = array() ) {
foreach ( $applied_rules as $applied_rule ) {
if ( $packaging = wc_stc_get_packaging( $applied_rule['packaging_id'] ) ) {
- $package_count++;
+ ++$package_count;
$debug_notices[] = sprintf( _x( '## Package %1$d/%2$d: %3$s: ', 'shipments', 'shiptastic-for-woocommerce' ), $package_count, count( $applied_rules ), $packaging->get_title() );
foreach ( $applied_rule['rules'] as $rule ) {
@@ -959,13 +959,11 @@ protected function rule_applies( $rule, $package_data, $global_only = false ) {
if ( 'exactly' === $operator_name ) {
$has_missing_shipping_classes = 'package_shipping_classes' === $condition_type_name ? $package_data['package_has_missing_shipping_classes'] : $package_data['has_missing_shipping_classes'];
$condition_applies = ! $has_missing_shipping_classes && $package_data[ $condition_type_name ] === $classes;
- } else {
- if ( array_intersect( $package_data[ $condition_type_name ], $classes ) ) {
- if ( 'any_of' === $operator_name ) {
- $condition_applies = true;
- } elseif ( 'none_of' === $operator_name ) {
- $condition_applies = false;
- }
+ } elseif ( array_intersect( $package_data[ $condition_type_name ], $classes ) ) {
+ if ( 'any_of' === $operator_name ) {
+ $condition_applies = true;
+ } elseif ( 'none_of' === $operator_name ) {
+ $condition_applies = false;
}
}
}
diff --git a/src/ShippingProvider/Auto.php b/src/ShippingProvider/Auto.php
index d3b557c7..6a470307 100644
--- a/src/ShippingProvider/Auto.php
+++ b/src/ShippingProvider/Auto.php
@@ -923,7 +923,7 @@ protected function get_label_settings_by_zone( $configuration_set ) {
$count = 0;
foreach ( $service_setting_fields as $k => $service_setting ) {
- $count++;
+ ++$count;
$service_setting_fields[ $k ] = wp_parse_args(
$service_setting_fields[ $k ],
@@ -1379,7 +1379,7 @@ public function create_label( $shipment, $props = false ) {
$hits = false === get_transient( "{$this->get_general_hook_prefix()}label_rate_limit_hits" ) ? 0 : absint( get_transient( "{$this->get_general_hook_prefix()}label_rate_limit_hits" ) );
if ( $hits <= apply_filters( 'woocommerce_shiptastic_max_api_retries', 5 ) ) {
- $hits++;
+ ++$hits;
sleep( 0.25 * $hits );
set_transient( "{$this->get_general_hook_prefix()}label_rate_limit_hits", $hits, MINUTE_IN_SECONDS );
@@ -1649,19 +1649,19 @@ public function get_configuration_set_setting_type() {
return 'shipping_provider';
}
- public function get_setting( $key, $default = null, $context = 'view' ) {
+ public function get_setting( $key, $default_value = null, $context = 'view' ) {
$setting_name_clean = $this->unprefix_setting_key( $key );
if ( $this->is_configuration_set_setting( $setting_name_clean ) ) {
if ( $configuration_set = $this->get_configuration_set( $setting_name_clean ) ) {
- $value = $configuration_set->get_setting( $setting_name_clean, $default );
+ $value = $configuration_set->get_setting( $setting_name_clean, $default_value );
} else {
- $value = $default;
+ $value = $default_value;
}
- return apply_filters( "{$this->get_hook_prefix()}setting_{$setting_name_clean}", $value, $key, $default, $context );
+ return apply_filters( "{$this->get_hook_prefix()}setting_{$setting_name_clean}", $value, $key, $default_value, $context );
} else {
- return parent::get_setting( $key, $default, $context );
+ return parent::get_setting( $key, $default_value, $context );
}
}
diff --git a/src/ShippingProvider/PickupLocation.php b/src/ShippingProvider/PickupLocation.php
index ba02fdfb..3439294b 100644
--- a/src/ShippingProvider/PickupLocation.php
+++ b/src/ShippingProvider/PickupLocation.php
@@ -190,12 +190,12 @@ public function get_address_replacements() {
return $replacements;
}
- public function replace_address( $object ) {
+ public function replace_address( $target_object ) {
foreach ( $this->get_address_replacements() as $address_field => $address_value ) {
$setter = "set_shipping_{$address_field}";
- if ( is_callable( array( $object, $setter ) ) ) {
- $object->{$setter}( $address_value );
+ if ( is_callable( array( $target_object, $setter ) ) ) {
+ $target_object->{$setter}( $address_value );
}
}
}
diff --git a/src/ShippingProvider/Product.php b/src/ShippingProvider/Product.php
index 8673a2a2..37dbc83f 100644
--- a/src/ShippingProvider/Product.php
+++ b/src/ShippingProvider/Product.php
@@ -114,25 +114,25 @@ public function __construct( $shipping_provider, $args = array() ) {
$this->set_min_max_prop( 'height', $args['height'] );
}
- private function set_min_max_prop( $prop, $default = null ) {
- if ( ! is_null( $default ) ) {
- $default = wp_parse_args(
- (array) $default,
+ private function set_min_max_prop( $prop, $default_value = null ) {
+ if ( ! is_null( $default_value ) ) {
+ $default_value = wp_parse_args(
+ (array) $default_value,
array(
'min' => null,
'max' => null,
)
);
- if ( is_null( $default['min'] ) && is_null( $default['max'] ) ) {
+ if ( is_null( $default_value['min'] ) && is_null( $default_value['max'] ) ) {
$this->{$prop} = null;
} else {
- $default['min'] = is_null( $default['min'] ) ? null : (float) wc_format_decimal( $default['min'] );
- $default['max'] = is_null( $default['max'] ) ? null : (float) wc_format_decimal( $default['max'] );
+ $default_value['min'] = is_null( $default_value['min'] ) ? null : (float) wc_format_decimal( $default_value['min'] );
+ $default_value['max'] = is_null( $default_value['max'] ) ? null : (float) wc_format_decimal( $default_value['max'] );
$this->{$prop} = array(
- 'min' => $default['min'],
- 'max' => $default['max'],
+ 'min' => $default_value['min'],
+ 'max' => $default_value['max'],
);
}
}
@@ -174,13 +174,13 @@ public function supports_zone( $zone ) {
return in_array( $zone, $this->zones, true );
}
- public function get_meta( $prop = null, $default = false ) {
+ public function get_meta( $prop = null, $default_value = false ) {
if ( is_null( $prop ) ) {
return $this->meta;
} elseif ( array_key_exists( $prop, $this->meta ) ) {
return $this->meta[ $prop ];
} else {
- return $default;
+ return $default_value;
}
}
diff --git a/src/ShippingProvider/Simple.php b/src/ShippingProvider/Simple.php
index 9db9f45e..d22d35c8 100644
--- a/src/ShippingProvider/Simple.php
+++ b/src/ShippingProvider/Simple.php
@@ -926,28 +926,28 @@ protected function get_general_settings() {
* @param Shipment $shipment
* @param $key
*/
- public function get_shipment_setting( $shipment, $key, $default = null ) {
- $value = $this->get_setting( $key, $default );
+ public function get_shipment_setting( $shipment, $key, $default_value = null ) {
+ $value = $this->get_setting( $key, $default_value );
if ( $config_set = $shipment->get_label_configuration_set() ) {
if ( $config_set->has_setting( $key ) ) {
- $value = $config_set->get_setting( $key, $default );
+ $value = $config_set->get_setting( $key, $default_value );
}
}
return $value;
}
- public function get_setting( $key, $default = null, $context = 'view' ) {
+ public function get_setting( $key, $default_value = null, $context = 'view' ) {
$clean_key = $this->unprefix_setting_key( $key );
$getter = "get_{$clean_key}";
- $value = $default;
+ $value = $default_value;
if ( is_callable( array( $this, $getter ) ) ) {
$value = $this->$getter( $context );
- if ( '' === $value && 'view' === $context && ! is_null( $default ) ) {
- $value = $default;
+ if ( '' === $value && 'view' === $context && ! is_null( $default_value ) ) {
+ $value = $default_value;
}
} elseif ( $this->meta_exists( $clean_key ) ) {
$value = $this->get_meta( $clean_key, true, $context );
@@ -963,7 +963,7 @@ public function get_setting( $key, $default = null, $context = 'view' ) {
$value = $this->retrieve_password( $value );
}
- return apply_filters( "{$this->get_hook_prefix()}setting_{$clean_key}", $value, $key, $default, $context );
+ return apply_filters( "{$this->get_hook_prefix()}setting_{$clean_key}", $value, $key, $default_value, $context );
}
protected function retrieve_password( $value ) {
@@ -1199,7 +1199,6 @@ public function get_product( $id ) {
}
protected function register_products() {
-
}
protected function register_product( $id, $args = array() ) {
@@ -1256,7 +1255,6 @@ public function get_print_format( $id ) {
}
protected function register_print_formats() {
-
}
protected function register_print_format( $id, $args = array() ) {
@@ -1310,7 +1308,6 @@ public function get_service( $id ) {
}
protected function register_services() {
-
}
/**
diff --git a/src/Utilities/NumberUtil.php b/src/Utilities/NumberUtil.php
index a7dc5d43..45a418f4 100644
--- a/src/Utilities/NumberUtil.php
+++ b/src/Utilities/NumberUtil.php
@@ -24,7 +24,7 @@ final class NumberUtil {
*
* @return float The value rounded to the given precision as a float, or the supplied default value.
*/
- public static function round( $val, int $precision = 0, int $mode = PHP_ROUND_HALF_UP ) : float {
+ public static function round( $val, int $precision = 0, int $mode = PHP_ROUND_HALF_UP ): float {
if ( ! is_numeric( $val ) ) {
$val = floatval( $val );
}
diff --git a/src/Validation.php b/src/Validation.php
index 7acaa4c3..d49c7e0b 100644
--- a/src/Validation.php
+++ b/src/Validation.php
@@ -20,7 +20,7 @@ public static function init() {
add_action(
'woocommerce_before_order_object_save',
- function( $order ) {
+ function ( $order ) {
$changes = $order->get_changes();
$screen = is_admin() && function_exists( 'get_current_screen' ) ? get_current_screen() : false;
$is_edit_order_request = $screen ? in_array( $screen->id, array( 'woocommerce_page_wc-orders' ), true ) : false;
@@ -36,7 +36,7 @@ function( $order ) {
if ( ! $skip_validation ) {
add_action(
'woocommerce_update_order',
- function( $order_id ) use ( $order ) {
+ function ( $order_id ) use ( $order ) {
if ( $order_id === $order->get_id() ) {
self::update_order( $order_id );
}
@@ -51,7 +51,7 @@ function( $order_id ) use ( $order ) {
*/
add_action(
'woocommerce_update_order_item',
- function( $order_item_id, $order_item ) use ( $order ) {
+ function ( $order_item_id, $order_item ) use ( $order ) {
if ( is_a( $order_item, 'WC_Order_Item' ) ) {
if ( $order_item->get_order_id() === $order->get_id() ) {
remove_action( 'woocommerce_update_order_item', array( __CLASS__, 'update_order_item' ), 10 );
@@ -67,10 +67,10 @@ function( $order_item_id, $order_item ) use ( $order ) {
add_action(
'woocommerce_new_order',
- function( $order_id ) {
+ function ( $order_id ) {
add_action(
'woocommerce_after_order_object_save',
- function( $order ) use ( $order_id ) {
+ function ( $order ) use ( $order_id ) {
if ( $order_id === $order->get_id() ) {
self::new_order( $order );
}
diff --git a/templates/emails/customer-guest-return-shipment-request.php b/templates/emails/customer-guest-return-shipment-request.php
index 8901c38f..73bf1cca 100644
--- a/templates/emails/customer-guest-return-shipment-request.php
+++ b/templates/emails/customer-guest-return-shipment-request.php
@@ -23,7 +23,7 @@
do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
- get_billing_first_name() ) ); // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch ?>
+ get_billing_first_name() ) ); ?>
get_order_number() ) ); ?>
diff --git a/templates/emails/customer-return-shipment-delivered.php b/templates/emails/customer-return-shipment-delivered.php
index 7d49776b..78c1bb3b 100644
--- a/templates/emails/customer-return-shipment-delivered.php
+++ b/templates/emails/customer-return-shipment-delivered.php
@@ -23,7 +23,7 @@
do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
-
get_billing_first_name() ) ); // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch ?>
+ get_billing_first_name() ) ); ?>
diff --git a/templates/emails/customer-return-shipment.php b/templates/emails/customer-return-shipment.php
index 8f800ed7..819f23dc 100644
--- a/templates/emails/customer-return-shipment.php
+++ b/templates/emails/customer-return-shipment.php
@@ -23,7 +23,7 @@
do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
-
get_billing_first_name() ) ); // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch ?>
+ get_billing_first_name() ) ); ?>
-
get_billing_first_name() ) ); // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch ?>
+ get_billing_first_name() ) ); ?>
diff --git a/templates/emails/email-order-shipments.php b/templates/emails/email-order-shipments.php
index af7376ee..88d268ba 100644
--- a/templates/emails/email-order-shipments.php
+++ b/templates/emails/email-order-shipments.php
@@ -25,7 +25,7 @@
$shipment ) :
- $count++;
+ ++$count;
?>
1 ) : ?>
diff --git a/templates/emails/plain/customer-guest-return-shipment-request.php b/templates/emails/plain/customer-guest-return-shipment-request.php
index 2a804e14..d8de2a00 100644
--- a/templates/emails/plain/customer-guest-return-shipment-request.php
+++ b/templates/emails/plain/customer-guest-return-shipment-request.php
@@ -20,7 +20,7 @@
echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
/* translators: %s: Customer first name */
-echo sprintf( esc_html__( 'Hi %s,', 'woocommerce' ), esc_html( $order->get_billing_first_name() ) ) . "\n\n"; // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
+echo sprintf( esc_html_x( 'Hi %s,', 'shipments', 'shiptastic-for-woocommerce' ), esc_html( $order->get_billing_first_name() ) ) . "\n\n";
echo sprintf( esc_html_x( 'You\'ve requested a return to your order %s. Please follow the link to add your return request.', 'shipments', 'shiptastic-for-woocommerce' ), esc_html( $order->get_order_number() ) ) . "\n\n";
diff --git a/templates/emails/plain/customer-return-shipment-delivered.php b/templates/emails/plain/customer-return-shipment-delivered.php
index 4360692d..18df6ca5 100644
--- a/templates/emails/plain/customer-return-shipment-delivered.php
+++ b/templates/emails/plain/customer-return-shipment-delivered.php
@@ -20,7 +20,7 @@
echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
/* translators: %s: Customer first name */
-echo sprintf( esc_html__( 'Hi %s,', 'woocommerce' ), esc_html( $order->get_billing_first_name() ) ) . "\n\n"; // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
+echo sprintf( esc_html_x( 'Hi %s,', 'shipments', 'shiptastic-for-woocommerce' ), esc_html( $order->get_billing_first_name() ) ) . "\n\n";
echo esc_html_x( 'Thank you! Your return has been received successfully. There are more details below for your reference:', 'shipments', 'shiptastic-for-woocommerce' );
diff --git a/templates/emails/plain/customer-return-shipment.php b/templates/emails/plain/customer-return-shipment.php
index bfb87767..de2c59cb 100644
--- a/templates/emails/plain/customer-return-shipment.php
+++ b/templates/emails/plain/customer-return-shipment.php
@@ -20,8 +20,7 @@
echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
/* translators: %s: Customer first name */
-echo sprintf( esc_html__( 'Hi %s,', 'woocommerce' ), esc_html( $order->get_billing_first_name() ) ) . "\n\n"; // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
-
+echo sprintf( esc_html_x( 'Hi %s,', 'shipments', 'shiptastic-for-woocommerce' ), esc_html( $order->get_billing_first_name() ) ) . "\n\n";
if ( $is_confirmation ) {
echo esc_html_x( 'Your return request has been accepted. Please follow the instructions beneath to return your shipment.', 'shipments', 'shiptastic-for-woocommerce' );
diff --git a/templates/emails/plain/customer-shipment.php b/templates/emails/plain/customer-shipment.php
index 32d1e5da..c264d0bb 100644
--- a/templates/emails/plain/customer-shipment.php
+++ b/templates/emails/plain/customer-shipment.php
@@ -20,14 +20,14 @@
echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
/* translators: %s: Customer first name */
-echo sprintf( esc_html__( 'Hi %s,', 'woocommerce' ), esc_html( $order->get_billing_first_name() ) ) . "\n\n"; // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
+echo sprintf( esc_html_x( 'Hi %s,', 'shipments', 'shiptastic-for-woocommerce' ), esc_html( $order->get_billing_first_name() ) ) . "\n\n";
if ( $partial_shipment ) {
/* translators: %s: Site title */
- printf( esc_html_x( 'Your order on %1$s has been partially shipped via %2$s. Find details below for your reference:', 'shipments', 'shiptastic-for-woocommerce' ), wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ), wc_stc_get_shipment_shipping_provider_title( $shipment ) ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
+ printf( esc_html_x( 'Your order on %1$s has been partially shipped via %2$s. Find details below for your reference:', 'shipments', 'shiptastic-for-woocommerce' ), wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ), wc_stc_get_shipment_shipping_provider_title( $shipment ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
} else {
/* translators: %s: Site title */
- printf( esc_html_x( 'Your order on %1$s has been shipped via %2$s. Find details below for your reference:', 'shipments', 'shiptastic-for-woocommerce' ), wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ), wc_stc_get_shipment_shipping_provider_title( $shipment ) ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
+ printf( esc_html_x( 'Your order on %1$s has been shipped via %2$s. Find details below for your reference:', 'shipments', 'shiptastic-for-woocommerce' ), wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ), wc_stc_get_shipment_shipping_provider_title( $shipment ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
echo "\n\n";
diff --git a/templates/emails/plain/email-order-shipments.php b/templates/emails/plain/email-order-shipments.php
index 5659cae8..5ed9bc4d 100644
--- a/templates/emails/plain/email-order-shipments.php
+++ b/templates/emails/plain/email-order-shipments.php
@@ -20,7 +20,7 @@
$count = 0;
foreach ( $shipments as $key => $shipment ) {
- $count++;
+ ++$count;
echo "\n";
diff --git a/templates/global/empty.php b/templates/global/empty.php
index 82e45d2c..68926212 100644
--- a/templates/global/empty.php
+++ b/templates/global/empty.php
@@ -16,5 +16,3 @@
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
-
-
diff --git a/templates/global/form-return-request.php b/templates/global/form-return-request.php
index e02eb706..d30a5a92 100644
--- a/templates/global/form-return-request.php
+++ b/templates/global/form-return-request.php
@@ -16,13 +16,11 @@
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
-
?>