Quantcast
Channel: Topic Tag: plugin | WordPress.org
Viewing all articles
Browse latest Browse all 26892

theqwertman on "[Plugin: Events Manager] Get function no longer working"

$
0
0

I updated this plugin from an old version, and the following function no longer works. I've narrowed down the problem to that EM_Events::get() is returning an empty array, although it should not. Before updating the plugin this worked flawlessly. How do I need to change the code to adapt to the new version?

Part of the code in question is padded with line breaks.

/**
* shortcode - tpevents
* outputs the tp events slider
* @param unknown_type $atts
* @return string
*/
function tpevents_shortcode($atts) {
	global $EM_Event;
	$EM_Event_old = $EM_Event; //When looping, we can replace EM_Event global with the current event in the loop
	//Can be either an array for the get search or an array of EM_Event objects

	extract( shortcode_atts( array(), $atts ) );

	//define default EM query attributes
	$defaults = array(
		'limit' => 5,
		'scope' => 'future',
	);	

	$atts = wp_parse_args( $atts, $defaults );

	//open the slider
	$output = '
			<div class="events_slides">
				<div class="slides_container">';

	$format = 	'<div class="event_slide">
					<div class="event_img">
	     				<a href="#_EVENTURL">#_EVENTIMAGE</a>
					</div>
					<div class="event_detail" rel="#_EVENTURL">
	     				<h3 class="event_link">#_EVENTLINK</h3>
	     				<span class="event_date">#_{D M j} at #_12HSTARTTIME</span>
					</div>
				</div>';

	$today = strtotime('today');
	$events_count = 0;
	$old_limit = (int)$atts['limit'];
	$atts['limit'] = $old_limit + 1;//increase the events returned to support an expired event

	$events = EM_Events::get($atts);

	foreach($events as $EM_Event){
		if($events_count < $old_limit){
			$event_start_date = strtotime($EM_Event->start_date);
			if($event_start_date >= $today){
				$output .= $EM_Event->output($format);
				$events_count++;
			}
		}else{
			break;//stop loop
		}
	}
	//close the slider
	$output .= '</div></div>';

	//check if no events were returned
	if($events_count == 0)
		$debugline = print_r($atts,true);
		$output = 'There are no events';

	//restore existing $EM_Event
	$EM_Event = $EM_Event_old;

	return $output;
}
add_shortcode('tpevents', 'tpevents_shortcode');

http://wordpress.org/extend/plugins/events-manager/


Viewing all articles
Browse latest Browse all 26892

Trending Articles