Skip to content

Instantly share code, notes, and snippets.

@paulvanbuuren
Last active August 29, 2015 14:12
Show Gist options
  • Save paulvanbuuren/64aa8e3fe93b35e60371 to your computer and use it in GitHub Desktop.
Save paulvanbuuren/64aa8e3fe93b35e60371 to your computer and use it in GitHub Desktop.
wbvb-event-manager
<?php
/*
Plugin Name: Events Manager Improvements
Version: 1.0
Description: Improves some of Event Manager's functionality (WordPress plugin)
Author: Paul van Buuren
Author URI: http://wbvb.nl/
*/
add_action( 'init', 'WBVB_overrule_eventmanager', 10 );
function WBVB_overrule_eventmanager() {
if ( class_exists( 'EM_Event_Post' ) ) {
class WBVB_extend_eventmanager extends EM_Event_Post {
public static function init(){
global $wp_query;
//Front Side Modifiers
if( !is_admin() ){
// replace the old filter with my new filter
remove_filter('the_content', array('EM_Event_Post','the_content') );
add_filter('the_content', array('WBVB_extend_eventmanager','the_content') );
}
}
public static function the_content( $content ){
//override formatting for single page
global $post, $EM_Event;
if( $post->post_type == EM_POST_TYPE_EVENT ){
if( is_archive() || is_search() ){
if(get_option('dbem_cp_events_archive_formats')){
$EM_Event = em_get_event($post);
$content = $EM_Event->output(get_option('dbem_event_list_item_format'));
}
}else{
if( get_option('dbem_cp_events_formats') && !post_password_required() ){
$EM_Event = em_get_event($post);
ob_start();
em_locate_template('templates/event-single.php',true);
$content = ob_get_clean();
}elseif( !post_password_required() ){
$EM_Event = em_get_event($post);
if( $EM_Event->event_rsvp ){
//================
// changing this line is what this plugin is all about
// (see <plugins>/events-manager/classes/em-event-post.php, line 135)
$content .= $EM_Event->output('<h3>' . __('Bookings','dbem') . '</h3>#_BOOKINGFORM');
//================
}
}
}
}
return $content;
}
}
WBVB_extend_eventmanager::init();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment