Last active
March 9, 2016 18:50
-
-
Save tripflex/d5a1bc5074d26a028e3a to your computer and use it in GitHub Desktop.
Multiselect field editor template with Chosen support
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 wp_enqueue_script( 'wp-job-manager-multiselect' ); ?> | |
<select multiple="multiple" name="<?php echo esc_attr( isset($field['name']) ? $field['name'] : $key ); ?>[]" id="<?php echo esc_attr( $key ); ?>" class="job-manager-multiselect" <?php if( ! empty($field['required']) ) echo 'required'; ?> data-no_results_text="<?php _e( 'No results match' ); ?>" data-multiple_text="<?php _e( 'Select Some Options' ); ?>"> | |
<?php | |
$no_values = isset( $field['value'] ) ? false : true; | |
foreach ( $field['options'] as $key => $value ) : | |
$key = str_replace( '*', '', $key, $replace_default ); | |
$key = str_replace( '~', '', $key, $replace_disabled ); | |
$field_value = isset( $field['value'] ) ? $field['value'] : array(); | |
if( $no_values && $replace_default > 0) $field[ 'value' ][ ] = $key; | |
$disabled_option = $replace_disabled > 0 ? 'disabled="disabled"' : ''; | |
?> | |
<option value="<?php echo esc_attr( $key ); ?>" <?php if ( ! empty( $field['value'] ) && is_array( $field['value'] ) ) selected( in_array( $key, $field['value'] ), true ); ?> <?php echo $disabled_option; ?>><?php echo esc_html( $value ); ?></option> | |
<?php endforeach; ?> | |
</select> | |
<?php if ( ! empty( $field['description'] ) ) : ?><small class="description"><?php echo $field['description']; ?></small><?php endif; ?> |
@waynep16 this is only for standard multiselect fields, it does not have anything to do with taxonomy fields, those are in different templates that already use chosen
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey there,
How can this be adapted to show a taxonomy list of job regions from wp job manager?
https://wordpress.org/plugins/wp-job-manager-locations/
I think the taxonomy is job_listing_region