get_meta( '_anonymized' ) === 'yes' || empty( $shipment['tracking'] ) ) { return $shipment; } $matches = array(); foreach ( (array) $order->get_meta( '_storesuit_labels' ) as $label ) { if ( ! is_array( $label ) || ( $label['state'] ?? '' ) !== 'purchased' || ( $label['mode'] ?? '' ) !== 'live' || (string) ( $label['tracking'] ?? '' ) !== (string) $shipment['tracking'] ) { continue; } $url = (string) ( $label['tracking_url'] ?? '' ); if ( $url === '' ) { $url = (string) ( $label['tracker']['public_url'] ?? '' ); } $url = esc_url_raw( $url, array( 'https' ) ); if ( $url !== '' && wp_parse_url( $url, PHP_URL_HOST ) && ! wp_parse_url( $url, PHP_URL_USER ) && ! wp_parse_url( $url, PHP_URL_PASS ) ) { $matches[] = $url; } } $matches = array_values( array_unique( $matches ) ); if ( count( $matches ) === 1 ) { $shipment['tracking_url'] = $matches[0]; } return $shipment; } public static function report( string $report, array $row, array $filters ): string { $id = absint( $row['id'] ?? 0 ); $key = (string) ( $row['key'] ?? '' ); if ( in_array( $report, array( 'sales_product','sales_variant','stock_levels','stock_low','stock_moves','stock_alerts','stock_dead','catalog_photo','catalog_gaps' ), true ) && $id && get_post_status( $id ) ) { return admin_url( 'admin.php?page=storesuit-products&id=' . $id ); } if ( $report === 'sales_customer' && ctype_digit( $key ) && (int) $key && current_user_can( 'storesuit_orders' ) ) { return admin_url( 'admin.php?page=storesuit-customers&id=' . (int) $key ); } if ( $report === 'receivables' && preg_match( '/^u([1-9][0-9]*)$/D', $key, $m ) && current_user_can( 'storesuit_orders' ) ) { return admin_url( 'admin.php?page=storesuit-customers&id=' . $m[1] ); } // Guest groups have no invented account, and an unfiltered order list is not a guest drill-down. if ( $id && in_array( $report, array( 'sales_category','sales_brand','sales_tag' ), true ) ) { $taxonomy = array( 'sales_category'=>'product_cat','sales_brand'=>'product_brand','sales_tag'=>'product_tag' )[$report]; $url = get_edit_term_link( $id, $taxonomy, 'product' ); return is_string( $url ) ? $url : ''; } if ( current_user_can( 'storesuit_orders' ) && $report==='sales_channel' && in_array($key,OrderIndex::channels(),true) && Store::valid_date($filters['from']??'') && Store::valid_date($filters['to']??'') ) { return add_query_arg( array( 'channel'=>$key, 'period'=>'custom', 'from'=>$filters['from'], 'to'=>$filters['to'] ), admin_url( 'admin.php?page=storesuit-orders' ) ); } return ''; // Unsupported group dimensions remain plain text; never pretend an unfiltered list is a drill-down. } }