Sorry if this is super "newbie", but I'm stumped. I'm trying to create a function in WP All Import that states if the cell is empty it populates with "Not Specified". Please see below:
function power_translate_data( $data ) {
$map = array(
' ' => 'Not Specified',
);
foreach ( $map as $partial_match => $mapped_value ) {
if ( stristr( $data, $partial_match ) ) {
return $mapped_value;
}
}
return $data;
}
I appreciate any help you can give. Thank you!
stristrwith' 'will attemp to find the string value of a space in the data. You want to useif ( trim($data) == $partial_match )and set the value to''(no space)