Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save matadorjobs/e7ed229e559e3753937ac37dcea8e33e to your computer and use it in GitHub Desktop.
Save matadorjobs/e7ed229e559e3753937ac37dcea8e33e to your computer and use it in GitHub Desktop.
Matador Docs Example: Modify Job General Location Meta Field
<?php //omit opening PHP tag
add_filter( 'matador_import_job_general_location', 'mdocs_example_matador_import_job_general_location', 10, 2 );
/**
* Example Job General Location Filter Function
*
* @copyright 2020, Matador Software, LLC
* @author Jeremy Scott, Matador Software LLC
* @link https://matadorjobs.com/
*
* @param string $general_location
* @param array $location_data. Values are "street", "city" for city or locality, "state", "zip" for ZIP or Postal Code, and "country"
*
* @return string $general_location
*/
function mdocs_example_matador_import_job_general_location( $general_location, $location_data ) {
if ( ! empty ( $location_data['city'] ) && ! empty( $location_data['state'] ) ) {
return esc_html( $location_data['city'] . ', ' . $location_data['state'] );
} esleif ( ! empty( $location_data['city'] ) {
return esc_html( $location_data['city'] );
} elseif ( ! empty( $location_data['state'] ) {
return esc_html( $location_data['state'] );
}
return 'No Location Set';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment