Created
August 17, 2012 18:09
-
-
Save codearachnid/3381230 to your computer and use it in GitHub Desktop.
Bugfix: Tri.be The Event Calendar PRO (or community) will not show draft/pending venues or organizers CPT in the dropdown. Replace the provided methods in the appropriate files to resolve.
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 | |
// This code is being introduced in TEC PRO v2.0.9 | |
// events-premium/events-calendar-pro.php | |
/** | |
* helper function for displaying the saved venue dropdown | |
* | |
* @since 2.0 | |
* @param mixed $current the current saved venue | |
* @param string $name the name value for the field | |
*/ | |
public function saved_venues_dropdown( $current = null, $name = 'venue[VenueID]' ){ | |
$my_venue_ids = array(); | |
$current_user = wp_get_current_user(); | |
$my_venues = false; | |
$my_venue_options = ''; | |
if ( 0 != $current_user->ID ) { | |
$my_venues = TribeEvents::instance()->get_venue_info( null, null, array('post_status' => array('publish', 'draft'), 'author' => $current_user->ID) ); | |
foreach($my_venues as $my_venue) { | |
$my_venue_ids[] = $my_venue->ID; | |
$venue_title = wp_kses( get_the_title( $my_venue->ID ), array() ); | |
$my_venue_options .= '<option data-address="' . esc_attr( TribeEvents::instance()->fullAddressString( $my_venue->ID ) ) . '" value="' . esc_attr( $my_venue->ID ) .'"'; | |
$my_venue_options .= selected( $current, $my_venue->ID, false ); | |
$my_venue_options .= '>' . $venue_title . '</option>'; | |
} | |
} | |
$venues = TribeEvents::instance()->get_venue_info( null, null, array('post_status' => 'publish', 'post__not_in' => $my_venue_ids) ); | |
if ( $venues || $my_venues ) { | |
echo '<select class="chosen venue-dropdown" name="' . esc_attr( $name ) . '" id="saved_venue">'; | |
echo '<option value="0">' . __( 'Use New Venue' , 'tribe-events-calendar-pro' ) . '</option>'; | |
if( $my_venues ) { | |
echo $venues ? '<optgroup label="' . apply_filters('tribe_events_saved_venues_dropdown_my_optgroup', __('My Venues', 'tribe-events-calendar-pro')) . '">' : ''; | |
echo $my_venue_options; | |
echo $venues ? '</optgroup>' : ''; | |
} | |
if ( $venues ) { | |
echo $my_venues ? '<optgroup label="' . apply_filters('tribe_events_saved_venues_dropdown_optgroup', __('Available Venues', 'tribe-events-calendar-pro')) . '">' : ''; | |
foreach ( $venues as $venue ) { | |
$venue_title = wp_kses( get_the_title( $venue->ID ), array() ); | |
echo '<option data-address="' . esc_attr( TribeEvents::instance()->fullAddressString( $venue->ID ) ) . '" value="' . esc_attr( $venue->ID ) .'"'; | |
selected( ($current == $venue->ID) ); | |
echo '>' . $venue_title . '</option>'; | |
} | |
echo $my_venues ? '</optgroup>' : ''; | |
} | |
echo '</select>'; | |
} else { | |
echo '<p class="nosaved">' . __( 'No saved venues yet.', 'tribe-events-calendar-pro' ) . '</p>'; | |
} | |
} | |
/** | |
* helper function for displaying the saved organizer dropdown | |
* | |
* @since 2.0 | |
* @param mixed $current the current saved venue | |
* @param string $name the name value for the field | |
*/ | |
public function saved_organizers_dropdown( $current = null, $name = 'organizer[OrganizerID]' ){ | |
$my_organizer_ids = array(); | |
$current_user = wp_get_current_user(); | |
$my_organizers = false; | |
$my_organizers_options = ''; | |
if ( 0 != $current_user->ID ) { | |
$my_organizers = TribeEvents::instance()->get_organizer_info( null, null, array('post_status' => array('publish', 'draft'), 'author' => $current_user->ID) ); | |
foreach($my_organizers as $my_organizer) { | |
$my_organizer_ids[] = $my_organizer->ID; | |
$organizer_title = wp_kses( get_the_title( $my_organizer->ID ), array() ); | |
$my_organizers_options .= '<option value="' . esc_attr( $my_organizer->ID ) .'"'; | |
$my_organizers_options .= selected( $current, $my_organizer->ID, false ); | |
$my_organizers_options .= '>' . $organizer_title . '</option>'; | |
} | |
} | |
$organizers = TribeEvents::instance()->get_organizer_info( null, null, array('post_status' => 'publish', 'post__not_in' => $my_organizer_ids) ); | |
if ( $organizers || $my_organizers ) { | |
echo '<select class="chosen organizer-dropdown" name="' . esc_attr( $name ) . '" id="saved_organizer">'; | |
echo '<option value="0">' . __( 'Use New Organizer' , 'tribe-events-calendar-pro' ) . '</option>'; | |
if( $my_organizers ) { | |
echo $organizers ? '<optgroup label="' . apply_filters('tribe_events_saved_organizers_dropdown_my_optgroup', __('My Organizers', 'tribe-events-calendar-pro')) . '">' : ''; | |
echo $my_organizers_options; | |
echo $organizers ? '</optgroup>' : ''; | |
} | |
if ( $organizers ) { | |
echo $my_organizers ? '<optgroup label="' . apply_filters('tribe_events_saved_organizers_dropdown_optgroup', __('Available Organizers', 'tribe-events-calendar-pro')) . '">' : ''; | |
foreach ( $organizers as $organizer ) { | |
$organizer_title = wp_kses( get_the_title( $organizer->ID ), array() ); | |
echo '<option value="' . esc_attr( $organizer->ID ) .'"'; | |
selected( ($current == $organizer->ID) ); | |
echo '>' . $organizer_title . '</option>'; | |
} | |
echo $my_organizers ? '</optgroup>' : ''; | |
} | |
echo '</select>'; | |
} else { | |
echo '<p class="nosaved">' . __( 'No saved organizers yet.', 'tribe-events-calendar-pro' ) . '</p>'; | |
} | |
} |
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 | |
// This code is being introduced in TEC v2.0.9 | |
// events/lib/the-events-calendar.class.php | |
/** | |
* | |
* @param $p | |
* @param $post_status (deprecated) | |
* @param $args | |
* | |
* @return WP_Query->posts || false | |
*/ | |
function get_venue_info( $p = null, $deprecated = null, $args = array() ){ | |
$defaults = array( | |
'post_type' => self::VENUE_POST_TYPE, | |
'nopaging' => 1, | |
'post_status' => 'publish', | |
'ignore_sticky_posts ' => 1, | |
'orderby'=>'title', | |
'order'=>'ASC', | |
'p' => $p | |
); | |
// allow deprecated param to pass through by default | |
// NOTE: setting post_status in $args will override $post_status | |
if ( $deprecated != null ) { | |
_deprecated_argument( __FUNCTION__, 'The Event Calendar v2.0.9', 'To use the latest code, please supply post_status in the argument array params.' ); | |
$defaults['post_status'] = $deprecated; | |
} | |
$args = wp_parse_args( $args, $defaults ); | |
$r = new WP_Query( $args ); | |
if ($r->have_posts()) : | |
return $r->posts; | |
endif; | |
return false; | |
} | |
/** | |
* | |
* @param $p | |
* @param $post_status (deprecated) | |
* @param $args | |
* | |
* @return WP_Query->posts || false | |
*/ | |
function get_organizer_info( $p = null, $deprecated = null, $args = array() ){ | |
$defaults = array( | |
'post_type' => self::ORGANIZER_POST_TYPE, | |
'nopaging' => 1, | |
'post_status' => 'publish', | |
'ignore_sticky_posts ' => 1, | |
'orderby'=>'title', | |
'order'=>'ASC', | |
'p' => $p | |
); | |
// allow deprecated param to pass through by default | |
// NOTE: setting post_status in $args will override $post_status | |
if ( $deprecated != null ) { | |
_deprecated_argument( __FUNCTION__, 'The Event Calendar v2.0.9', 'To use the latest code, please supply post_status in the argument array params.' ); | |
$defaults['post_status'] = $deprecated; | |
} | |
$args = wp_parse_args( $args, $defaults ); | |
$r = new WP_Query( $args ); | |
if ($r->have_posts()) : | |
return $r->posts; | |
endif; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment