Skip to content

Commit

Permalink
Check if wc_admin_get_core_pages_to_connect() exists before usage. Pa…
Browse files Browse the repository at this point in the history
…rse default props needed for label creation to not throw any errors.
  • Loading branch information
dennisnissle committed Nov 29, 2023
1 parent 0ad7643 commit ef49ccc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/Admin/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ public static function register_admin_connected_pages( $is_connected, $current_p
}

public static function register_admin_breadcrumbs( $breadcrumbs, $current_page ) {
if ( ! function_exists( 'wc_admin_get_core_pages_to_connect' ) ) {
return $breadcrumbs;
}

if ( false === $current_page ) {
$screen = get_current_screen();

Expand Down
2 changes: 1 addition & 1 deletion src/Rest/ShipmentsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@ public function create_label( $request ) {
$args = array();
$args['product_id'] = wc_clean( wp_unslash( $request['product_id'] ) );
$args['print_format'] = wc_clean( wp_unslash( $request['print_format'] ) );
$args['services'] = wc_clean( wp_unslash( $request['services'] ) );
$args['services'] = (array) wc_clean( wp_unslash( $request['services'] ) );

if ( isset( $request['meta_data'] ) && is_array( $request['meta_data'] ) ) {
foreach ( $request['meta_data'] as $meta ) {
Expand Down
6 changes: 6 additions & 0 deletions src/ShippingProvider/Auto.php
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,12 @@ public function create_label( $shipment, $props = false ) {
$props = array_merge( $props, $dimensions );
}

$props = wp_parse_args( $props, array(
'services' => array(),
'print_format' => '',
'product_id' => '',
) );

/**
* Neither allow invalid service configuration from automatic nor manual requests.
*/
Expand Down

0 comments on commit ef49ccc

Please sign in to comment.