woocsv_echo_header_preview_option

The Woocommerce CSV Import woocsv echo header preview option function.

Description

woocsv_echo_header_preview_option( $field, $lines, $i, $saved_fields ); 

Parameters (4)

0. $field
The field.
1. $lines
The lines.
2. $i
The i.
3. $saved_fields
The saved fields.

Usage

  1. if ( !function_exists( 'woocsv_echo_header_preview_option' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce-csv-import/admin/partials/woocsv-import-admin-header-preview.php'; 
  3.  
  4. // The field. 
  5. $field = null; 
  6.  
  7. // The lines. 
  8. $lines = null; 
  9.  
  10. // The i. 
  11. $i = null; 
  12.  
  13. // The saved fields. 
  14. $saved_fields = null; 
  15.  
  16. // NOTICE! Understand what this does before running. 
  17. $result = woocsv_echo_header_preview_option($field, $lines, $i, $saved_fields); 
  18.  

Defined (1)

The function is defined in the following location(s).

/admin/partials/woocsv-import-admin-header-preview.php  
  1. function woocsv_echo_header_preview_option ($field, $lines, $i, $saved_fields) 
  2. // if field of is the same as the saved field in the same place -> selected 
  3. // if field is the same header field --> selected 
  4. $original = $field; 
  5. $field = trim( strtolower( $field ) ); 
  6. $saved_field = trim( strtolower( $saved_fields[ $i ] ) ); 
  7. $header_field = trim( strtolower( $lines[ 0 ][ $i ] ) ); 
  8.  
  9. if ($field == $saved_field) { 
  10. return '<option value="' . $original . '" selected>'; 
  11.  
  12. if ($field == $header_field) { 
  13. return '<option value="' . $original . '" selected>'; 
  14.  
  15. return '<option value="' . $original . '">';