functions.php
<?php
/**
* Filter for fields before filtering based on $filter value
*
* Filter syntax is `job_manager_field_editor_get_fields_pre_filter_{$field_group}` ... replace {$field_group} with field group
*
* Job Fields: job_manager_field_editor_get_fields_pre_filter_job
* Company Fields: job_manager_field_editor_get_fields_pre_filter_company
* Resume Fields: job_manager_field_editor_get_fields_pre_filter_resume_fields
*
* @param array $fields All fields in array structured format, similar to
* 'meta_key' => array( 'label' => 'Field Label' ....
* @param string $filter The type of filter that will be used on the fields (all, default, custom, enabled, disabled) after you return them
*/
add_filter( 'job_manager_field_editor_get_fields_pre_filter_job', 'my_custom_options_filter', 10, 2 );
/**
* Add Custom Options to Field Through Filter
*
* This example function adds custom options to a field, but you can use this to set
* pretty much any field value, or configuration, before it is passed to plugin to output
* in list table, or to core WP Job Manager (for frontend output, etc).
*
* Any changes made here will show up in the List Table GUI where you edit fields.
*
* @since 1.4.2
*
* @param array $fields
* @param string $filter
*
* @return array
*/
function my_custom_options_filter( $fields, $filter ){
// If our meta key `job_options` does not exist, return all fields
if( ! isset( $fields['job_options'] ) ) return $fields;
/**
* Set our custom options for the `job_options` meta key field
*
* Add ~ to the end of the key to set it as a disabled option
* Add * to the end of the key to set it as the default selected option
*
* Options MUST be in the following format:
* array(
* 'option_value' => 'Option Label'
* );
*
* The value saved to the database (and output on frontend) will only be the key,
* the label is ONLY for output of the dropdown, radio, etc.
*
* In example above, if Option Label is selected by user, option_value is what is saved to db
*/
$fields['job_options']['options'] = array(
'value_disabled~' => 'Disabled Value Label',
'value_default*' => 'Default Value Label',
'regular_value' => 'Regular Label'
);
return $fields;
}
No comments yet.