Created
August 1, 2017 16:24
-
-
Save tripflex/e36a71ff24b17b1914a64f04211518af to your computer and use it in GitHub Desktop.
WP Job Manager Field Editor add custom Auto Output Locations/Hooks/Actions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'field_editor_output_options', 'smyles_custom_output_locations', 20, 2 ); | |
/** | |
* Add Custom Auto Output Locations | |
* | |
* This will add custom auto output locations to the modal configuration in auto | |
* output field configuration. All you would need to do is add the do_action( $key ) | |
* in the template file. The $key value should be the KEY used in the array .. in the example | |
* below that would be single_resume_middle_meta_area, single_resume_right_meta_area | |
* | |
* @param $locations | |
* @param $field_group | |
* | |
* @return mixed | |
*/ | |
function smyles_custom_output_locations( $locations, $field_group ) { | |
// We only want to add custom actions when no field group (to automatically setup callback) | |
// or when resume_fields field_group passed (meaning called for output in dropdown in modal) | |
if( empty( $field_group ) || $field_group === 'resume_fields' ){ | |
$locations['single_resume_middle_meta_area'] = __( 'Resume Middle Meta Area' ); | |
$locations['single_resume_right_meta_area'] = __( 'Resume Right Meta Area' ); | |
} | |
// Same as above, but specifically for job or company fields | |
if ( empty( $field_group ) || $field_group === 'job' || $field_group === 'company' ) { | |
$locations['job_middle_meta_area'] = __( 'Job Middle Meta Area' ); | |
$locations['job_right_meta_area'] = __( 'Job Right Meta Area' ); | |
} | |
return $locations; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment