Skip to content

Instantly share code, notes, and snippets.

@slimndap
Last active January 28, 2016 22:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slimndap/ea7b9a6d07b2f992831b to your computer and use it in GitHub Desktop.
Save slimndap/ea7b9a6d07b2f992831b to your computer and use it in GitHub Desktop.
Replaces the venue input in the event editor with a dropdown. Place this code inside the functions.php of your theme.
<?php
/**
* Replaces the venue input in the event editor with a dropdown.
*
* @param string $html The default venue input HTML.
* @param mixed $field The venue field.
* @param int $event_id The ID of the event.
* @return string The vnue dropwdown HTML.
*/
function wpt_event_editor_get_venue_dropdown_html($html, $field, $event_id) {
global $wp_theatre;
// Replace this with your own options.
$venues = array('', 'Room 1', 'Room 2');
$html = '';
$html.= '<select id="wpt_event_editor_'.$field['id'].'" name="wpt_event_editor_'.$field['id'].'"';
if ( ! empty( $field['disabled'] ) ) {
$html.= ' disabled';
}
$html.= '>';
foreach ($venues as $venue) {
$html.= '<option value="'.$venue.'" ';
$html.= selected($venue, $wp_theatre->event_editor->get_value( $field, $event_id ), false);
$html.= '>'.$venue.'</option>';
}
$html.= '</select>';
return $html;
}
add_filter( 'wpt/event_editor/control/html/field=venue', 'wpt_event_editor_get_venue_dropdown_html', 10, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment