I'm developing a site that features a number of pages

Hi, I'm developing a site that features a number of pages categorized by city, with each city having it's own group of events. The [eab_calendar] shortcode comes close to what I'd like to do, but is there an [eab_list] shortcode? The Next Event shortcode add-on is also close but I'd like to show a list of events based on category.

I'm comfortable writing my own shortcodes too, if necessary, but didn't see any developer documentation for Events+ before I start poking around in the plugin for hooks and filters.

Does something like that already exist? If not, could you provide me with the documentation to jury rig something up? I would use posts, but like all the meta data in your Events+.

  • Vaughan

    Hi @SageMG,

    Hope you're well?

    there is the [eab-archive] shortcode which lists events.

    [eab-archive category="category-slug" lookahead="1" weeks="20" limit="10" order="ASC" paged="1" page="1"]

    which should list the upcoming events in the next 20 weeks, showing 10 per page in ascending order.

    If the next event shortcode is very close to what you want, you could perhaps modify the next event shortcode addon to enable category in the shortcode.

    "/events-and-bookings/lib/plugins/eab-events-next-event-shortcode.php"

    then in the function shortcode

    $args = $codec->parse_arguments($args, array(
    			'format'=> 'H:i T l',
    			'class'	=> '',
    			'add' => 0,
    			'expired'	=> __('Closed', Eab_EventsHub::TEXT_DOMAIN),
    			'legacy' => false,
    			'category' => false,
    			'categories' => false,
    		));

    set category to '' so 'category' => ''

    Then we need to add some sanitation.

    So something like this (Untested)

    public function shortcode ($args=array(), $content='') {
    		$original_arguments = $args;
    		$codec = new Eab_Codec_ArgumentsCodec;
    		$args = $codec->parse_arguments($args, array(
    			'format'=> 'H:i T l',
    			'class'	=> '',
    			'add' => 0,
    			'expired'	=> __('Closed', Eab_EventsHub::TEXT_DOMAIN),
    			'legacy' => false,
    			'category' => '',
    			'categories' => false,
    		));
    
    		if (!empty($args['legacy'])) return $this->_legacy_shortcode($original_arguments);
    		$class = !empty($args['class'])
    			? 'class="' . sanitize_html_class($args['class']) . '"'
    			: ''
    		;
    		$format = "<div {$class}>%s</div>";
    
            $category = !empty($args['category'])
    			? 'category="' . sanitize_text_field($args['category']) . '"'
    			: ''
    		;
    
            $output = '';
    
    		$additional = 0;
    		if (!empty($args['add']) && (int)$args['add']) {
    			$additional = (int)$args['add'] * 60;
    		}
    
    		$query = $codec->get_query_args($args);
    
    		$now = eab_current_time() + $additional;
    		$events = Eab_CollectionFactory::get_upcoming_events($now, $query);
    		$ret = array();
    		foreach ($events as $event) {
    			$ts = $event->get_start_timestamp();
    			if ($ts < $now) continue;
    			$ret[$ts] = $event;
    		}
    		ksort($ret);
    		$next = reset($ret);
    		if ($next) {
    			$output = date_i18n($args['format'], $next->get_start_timestamp());
    		} else {
    			$output = !empty($args['expired'])
    				? esc_html($args['expired'])
    				: $content
    			;
    		}
    
    		return sprintf($format, $output);
    	}

    I haven't tested this so i'm unsure if it will still accept the category argument. But if it works you should be able to use;

    [next_event format="H:i T l" class="next-event-class" add="-120" expired="Too late!" category="category-slug"]

    Hope this helps

  • SageMG

    Ok, a more questions. How do I customize the output of the eab_archive shortcode? Looks like I can make a template, so more specifically, how would I change the phrasing of certain parts of the output? So instead of the get_start_dates() spitting out a little calendar image followed by "Takes place from (date/time) to (date/time), I could have replace that with (date/time) - (date/time)?

    Also remove the buttons for View Event and the RSVP stuff, as I'm going to wrap the whole excerpt in an tag and have it show the single event post in a modal.

  • Predrag Dubajic

    Hi SageMG,

    My apologies for the long overdue on this thread.

    You can change the certain wording on your site by using our Ultimate Branding plugin and its Text Change option.

    For example replace from with <img src="myimage.png">

    For hiding the buttons you can use this CSS code:

    .wpmudevevents-viewevent,
    .wpmudevevents-buttons {
    	display: none;
    }

    If the theme is not one you made, then you may wish to use a child theme or a plugin like this one for this additional CSS. That way you're protected when you come to upgrade.

    Best regards,
    Predrag

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.