Quick Event Manager Shortcodes

Below, you’ll find a detailed guide on how to add the Quick Event Manager Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Quick Event Manager Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the Quick Event Manager Plugin and the shortcodes it provides:

Plugin Icon
Quick Event Manager

"Quick Event Manager is a versatile WordPress plugin that simplifies event management. It allows easy scheduling, managing, and displaying events on your website, enhancing user interaction."

★★★★☆ (65) Active Installs: 2000+ Tested with: 6.3.2 PHP Version: 5.6
Included Shortcodes:
  • [qem]
  • [qem-calendar]
  • [qemregistration]

Quick Event Manager [qem] Shortcode

The Quick Event Manager plugin shortcode is a powerful tool for displaying events. It allows users to customize event display using various parameters. Its function ‘qem_event_shortcode_esc’ fetches event data based on attributes provided in the shortcode. It also allows category selection, ordering, and event filtering. It supports different display styles like grid or masonry and can generate a category key. Furthermore, it provides options for event linking and setting up a ‘back to event list’ link. It’s a comprehensive solution for managing and displaying events on a WordPress site.

Shortcode: [qem]

Parameters

Here is a list of all possible qem shortcode parameters and attributes:

  • id – Specifies the event or events to display.
  • posts – Sets the maximum number of events to display.
  • links – Controls whether event titles are linked to full event details.
  • daterange – Filters events based on their dates.
  • size – Adjusts the size of the event image.
  • headersize – Determines the size of the event title.
  • settings – Applies predefined settings to the displayed events.
  • vanillawidget – Controls whether to use the default WordPress widget styling.
  • images – Determines whether to display event images.
  • category – Filters events by their category.
  • categoryplaces – Sets the location of the category filter.
  • order – Changes the order in which events are displayed.
  • fields – Determines which event details to show.
  • listlink – Controls the display of a link back to the full events list.
  • listlinkanchor – Sets the text for the link back to the full events list.
  • listlinkurl – Specifies the URL for the link back to the full events list.
  • cb – Toggles the display of a category border.
  • y – Filters events by year.
  • vw – Adjusts the display for different viewport widths.
  • categorykeyabove – Controls the display of a category key above the events list.
  • categorykeybelow – Controls the display of a category key below the events list.
  • usecategory – Filters events by their category.
  • event – Specifies the event or events to display by ID.
  • popup – Controls whether event details appear in a popup.
  • fullevent – Determines whether to display full event details.
  • fullpopup – Controls whether full event details appear in a popup.
  • calendar – Sets whether to display a calendar view of events.
  • thisisapopup – Specifies whether the shortcode is used in a popup.
  • listplaces – Controls whether to display a list of event locations.
  • fulllist – Determines whether to display a full list of events.
  • eventfull – Specifies whether to display full event details.
  • widget – Specifies whether the shortcode is used in a widget.
  • grid – Sets whether to display events in a grid layout.

Examples and Usage

Basic example – Display all events with a limit of 99 posts

[qem posts=99]

Advanced examples

Display all events from a specific category with a limit of 99 posts

[qem category='music' posts=99]

Display all events from a specific category with a limit of 99 posts and order them in ascending order

[qem category='music' posts=99 order='asc']

Display all events from a specific category with a limit of 99 posts, order them in ascending order and make the event link clickable

[qem category='music' posts=99 order='asc' links='checked']

Display all events from a specific category with a limit of 99 posts, order them in ascending order, make the event link clickable and show only current date range

[qem category='music' posts=99 order='asc' links='checked' daterange='current']

Display all events from a specific category with a limit of 99 posts, order them in ascending order, make the event link clickable, show only current date range and set the size of the event

[qem category='music' posts=99 order='asc' links='checked' daterange='current' size='large']

PHP Function Code

In case you have difficulties debugging what causing issues with [qem] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'qem', 'qem_event_shortcode_esc' );

Shortcode PHP function:

function qem_event_shortcode_esc( $atts, $widget )
{
    global  $qem_fs ;
    $remaining = $all = $i = $monthnumber = $archive = $yearnumber = $daynumber = $notthisyear = '';
    $atts = shortcode_atts( array(
        'id'               => '',
        'posts'            => '99',
        'links'            => 'checked',
        'daterange'        => 'current',
        'size'             => '',
        'headersize'       => 'headtwo',
        'settings'         => 'checked',
        'vanillawidget'    => 'checked',
        'images'           => '',
        'category'         => '',
        'categoryplaces'   => '',
        'order'            => '',
        'fields'           => '',
        'listlink'         => '',
        'listlinkanchor'   => '',
        'listlinkurl'      => '',
        'cb'               => '',
        'y'                => '',
        'vw'               => '',
        'categorykeyabove' => '',
        'categorykeybelow' => '',
        'usecategory'      => '',
        'event'            => '',
        'popup'            => '',
        'fullevent'        => 'summary',
        'fullpopup'        => '',
        'calendar'         => '',
        'thisisapopup'     => false,
        'listplaces'       => true,
        'fulllist'         => false,
        'eventfull'        => '',
        'widget'           => '',
        'grid'             => '',
    ), $atts, 'qem' );
    global  $post ;
    $category = $atts['category'];
    // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- front end user selection of category - no update processing or security implication
    if ( isset( $_GET['category'] ) ) {
        // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- front end user selection of category - no update processing or security implication
        $category = sanitize_text_field( $_GET['category'] );
    }
    $display = event_get_stored_display();
    $atts['popup'] = qem_get_element( $display, 'linkpopup', false );
    $atts['widget'] = $widget;
    if ( $display['fullpopup'] && qem_get_element( $display, 'linkpopup', false ) ) {
        $atts['fullpopup'] = 'checked';
    }
    if ( $atts['fullevent'] == 'on' || qem_get_element( $display, 'fullevent', false ) ) {
        $atts['fulllist'] = true;
    }
    $cal = qem_get_stored_calendar();
    $addons = qem_get_addons();
    $style = qem_get_stored_style();
    if ( !$atts['listlinkurl'] ) {
        $atts['listlinkurl'] = qem_get_element( $display, 'back_to_url', false );
    }
    if ( !$atts['listlinkanchor'] ) {
        $atts['listlinkanchor'] = $display['back_to_list_caption'];
    }
    if ( $atts['listlink'] ) {
        $atts['listlink'] = 'checked';
    }
    if ( $atts['cb'] ) {
        $display['cat_border'] = 'checked';
    }
    $output_escaped = '';
    $content_escaped = '';
    
    if ( qem_get_element( $display, 'event_descending', false ) || $atts['order'] == 'asc' ) {
        $args = array(
            'post_type'      => 'event',
            'orderby'        => 'meta_value_num',
            'meta_key'       => 'event_date',
            'posts_per_page' => -1,
        );
    } else {
        $args = array(
            'post_type'      => 'event',
            'orderby'        => 'meta_value_num',
            'meta_key'       => 'event_date',
            'order'          => 'asc',
            'posts_per_page' => -1,
        );
    }
    
    $the_query = new WP_Query( $args );
    $event_found = false;
    $today = strtotime( date( 'Y-m-d' ) );
    $catlabel = str_replace( ',', ', ', $category );
    $currentyear = date( 'Y' );
    if ( $atts['usecategory'] ) {
        $atts['cb'] = 'checked';
    }
    if ( $display['categorydropdown'] ) {
        $content_escaped .= qem_kses_post_svg_form( qem_category_dropdown( $display ) );
    }
    if ( !$widget && $display['cat_border'] && ($display['showkeyabove'] || $atts['categorykeyabove']) ) {
        $content_escaped .= wp_kses_post( qem_category_key( $cal, $style, '' ) );
    }
    if ( $widget && $atts['usecategory'] && $atts['categorykeyabove'] ) {
        $content_escaped .= wp_kses_post( qem_category_key( $cal, $style, '' ) );
    }
    if ( $category && $display['showcategory'] ) {
        $content_escaped .= '<h2>' . esc_html( $display['showcategorycaption'] . ' ' . $catlabel ) . '</h2>';
    }
    if ( qem_get_element( $display, 'eventmasonry', false ) == 'masonry' && !$atts['widget'] ) {
        $atts['grid'] = 'masonry';
    }
    if ( $atts['grid'] == 'masonry' ) {
        $content_escaped .= '<div id="qem">';
    }
    if ( $atts['id'] == 'all' ) {
        $all = 'all';
    }
    if ( $atts['id'] == 'current' ) {
        $monthnumber = date( 'n' );
    }
    $nextweek = 0;
    if ( $atts['id'] == 'nextweek' ) {
        $nextweek = strtotime( "+7 day", $today );
    }
    if ( $atts['id'] == 'remaining' ) {
        $remaining = date( 'n' );
    }
    if ( $atts['id'] == 'archive' ) {
        $archive = 'archive';
    }
    if ( $atts['id'] == 'notthisyear' ) {
        $notthisyear = 'checked';
    }
    if ( is_numeric( $atts['id'] ) ) {
        $monthnumber = $atts['id'];
    }
    if ( is_numeric( $atts['id'] ) && strlen( $atts['id'] ) == 4 ) {
        $yearnumber = $atts['id'];
    }
    if ( $atts['id'] == 'calendar' ) {
        // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- front end user selection of category - no update processing or security implication
        
        if ( isset( $_GET['qemmonth'] ) ) {
            // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- front end user selection of category - no update processing or security implication
            $monthnumber = sanitize_text_field( $_GET['qemmonth'] );
        } else {
            $monthnumber = date( 'n' );
        }
    
    }
    $thisyear = date( 'Y' );
    $thismonth = date( "M" );
    $currentmonth = date( "M" );
    
    if ( $atts['id'] == 'today' ) {
        $daynumber = date( "d" );
        $todaymonth = $thismonth;
    }
    
    if ( strpos( $atts['id'], 'D' ) !== false ) {
        $daynumber = filter_var( $atts['id'], FILTER_SANITIZE_NUMBER_INT );
    }
    
    if ( strpos( $atts['id'], 'M' ) !== false ) {
        $dm = explode( "D", $atts['id'] );
        $monthnumber = filter_var( $dm[0], FILTER_SANITIZE_NUMBER_INT );
        $daynumber = filter_var( $dm[1], FILTER_SANITIZE_NUMBER_INT );
    }
    
    if ( $category ) {
        $category = explode( ',', $category );
    }
    if ( $atts['event'] ) {
        $eventid = explode( ',', $atts['event'] );
    }
    
    if ( $the_query->have_posts() ) {
        if ( $cal['connect'] ) {
            $content_escaped .= '<p><a href="' . esc_url( $cal['calendar_url'] ) . '">' . esc_html( $cal['calendar_text'] ) . '</a></p>';
        }
        while ( $the_query->have_posts() ) {
            $the_query->the_post();
            $unixtime = get_post_meta( $post->ID, 'event_date', true );
            if ( !$unixtime ) {
                $unixtime = time();
            }
            $enddate = get_post_meta( $post->ID, 'event_end_date', true );
            $hide_event = get_post_meta( $post->ID, 'hide_event', true );
            $day = date( "d", $unixtime );
            $monthnow = date( "n", $unixtime );
            $eventmonth = date( "M", $unixtime );
            $eventmonthnumber = date( "m", $unixtime );
            $month = ( $display['monthtype'] == 'short' ? date_i18n( "M", $unixtime ) : date_i18n( "F", $unixtime ) );
            $year = date( "Y", $unixtime );
            $monthheading = ( $display['monthheadingorder'] == 'ym' ? $year . ' ' . $month : $month . ' ' . $year );
            
            if ( $atts['y'] ) {
                $thisyear = $atts['y'];
                $yearnumber = 0;
            }
            
            
            if ( $atts['event'] ) {
                $atts['id'] = 'event';
                $event = $post->ID;
                $eventbyid = ( in_array( $event, $eventid ) ? 'checked' : '' );
            }
            
            if ( $i < $atts['posts'] ) {
                
                if ( ($all || $atts['event'] && $eventbyid || $archive && $unixtime < $today && $enddate < $today || $atts['id'] == '' && ($unixtime >= $today || $enddate >= $today || $display['event_archive'] == 'checked') || $daynumber == $day && $todaymonth == $eventmonth && $thisyear == $year || $daynumber == $day && $monthnumber == $eventmonthnumber && $thisyear == $year || $nextweek && $unixtime >= $today && $unixtime <= $nextweek || !$daynumber && $monthnumber && $monthnow == $monthnumber && $thisyear == $year || $remaining && $monthnow == $remaining && $thisyear == $year && ($unixtime >= $today || $enddate >= $today) || $yearnumber && $yearnumber == $year || $notthisyear && $currentyear > $year) && (in_category( $category ) || !$category) ) {
                    
                    if ( !$atts['grid'] && $display['monthheading'] && ($currentmonth || $month != $thismonth || $year != $thisyear) ) {
                        $content_escaped .= '<h2>' . esc_html( $monthheading ) . '</h2>';
                        $thismonth = $month;
                        $thisyear = $year;
                        $currentmonth = '';
                    }
                    
                    if ( !$hide_event ) {
                        $content_escaped .= qem_event_construct_esc( $atts ) . "\r\n";
                    }
                    $event_found = true;
                    $i++;
                }
            
            }
        }
        if ( $atts['grid'] == 'masonry' ) {
            $content_escaped .= '</div>';
        }
        if ( !$widget && $display['cat_border'] && ($display['showkeybelow'] || $atts['categorykeyabove']) ) {
            $content_escaped .= wp_kses_post( qem_category_key( $cal, $style, '' ) );
        }
        if ( $widget && $atts['usecategory'] && $atts['categorykeyabove'] ) {
            $content_escaped .= wp_kses_post( qem_category_key( $cal, $style, '' ) );
        }
        if ( $atts['listlink'] ) {
            $content_escaped .= '<p><a href="' . esc_url( $atts['listlinkurl'] ) . '">' . esc_html( $atts['listlinkanchor'] ) . '</a></p>';
        }
        $output_escaped .= $content_escaped;
    }
    
    if ( !$event_found ) {
        $output_escaped .= "<h2>" . wp_kses_post( $display['noevent'] ) . "</h2>";
    }
    wp_reset_postdata();
    wp_reset_query();
    return $output_escaped;
}

Code file location:

quick-event-manager/quick-event-manager/legacy/quick-event-manager.php

Quick Event Manager [qem-calendar] Shortcode

The Quick Event Manager plugin shortcode is designed to display a calendar with events. It fetches and displays event data stored in the WordPress database, including event dates, titles, and descriptions. The shortcode also supports navigation through months and years, and allows filtering of events by category.

Shortcode: [qem-calendar]

Parameters

Here is a list of all possible qem-calendar shortcode parameters and attributes:

  • category – Filters the events displayed by category
  • navigation – Toggles the navigation on/off
  • month – Sets the calendar to a specific month
  • year – Sets the calendar to a specific year
  • links – Toggles the event links on/off
  • categorykeyabove – Displays the category key above the calendar
  • categorykeybelow – Displays the category key below the calendar
  • usecategory – Enables category filtering
  • smallicon – Adjusts the size of the event icon
  • widget – Adjusts the shortcode for widget use
  • header – Defines the HTML tag used for headers
  • fullpopup – Enables a full-sized popup for events
  • calendar – Enables calendar view
  • thisisapopup – Specifies that the calendar is in a popup

Examples and Usage

Basic example – Displaying the calendar with default settings

[qem-calendar]

Advanced examples

Displaying the calendar with specific category and navigation settings. The calendar will only show events from the specified category and will not allow month-to-month navigation.

[qem-calendar category="music" navigation="off"]

Displaying the calendar with a specified month and year. The calendar will start from the specified month and year.

[qem-calendar month="12" year="2022"]

Displaying the calendar with links turned off and a small icon set to “trim”. The events will not be clickable and a small trim icon will be displayed.

[qem-calendar links="off" smallicon="trim"]

Displaying the calendar in a widget, with a header set to h3. The calendar will be suitable for a widget area and the header of the calendar will be h3.

[qem-calendar widget="true" header="h3"]

PHP Function Code

In case you have difficulties debugging what causing issues with [qem-calendar] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'qem-calendar', 'qem_show_calendar_esc' );

Shortcode PHP function:

function qem_show_calendar_esc( $atts ) {
	global $qem_calendars;
	if ( ! isset( $qem_calendars ) ) {
		$qem_calendars = 0;
	}
	$c        = ( ( isset( $_REQUEST['qemcalendar'] ) ) ? (int) $_REQUEST['qemcalendar'] : $qem_calendars ++ );
	$cal      = qem_get_stored_calendar();
	$style    = qem_get_stored_style();
	$category = '';
	$defaults = array(
		'category'         => '',
		'navigation'       => '',
		'month'            => '',
		'year'             => '',
		'links'            => 'on',
		'categorykeyabove' => '',
		'categorykeybelow' => '',
		'usecategory'      => '',
		'smallicon'        => 'trim',
		'widget'           => '',
		'header'           => 'h2',
		'fullpopup'        => '',
		'calendar'         => 'checked',
		'thisisapopup'     => false
	);
	$atts     = (array) $atts;
	$natts    = array_merge( $defaults, $atts );
	extract( shortcode_atts( $natts, $atts ) );
	global $post;
	global $_GET;
	if ( ! $widget ) {
		$header = $cal['header'];
	}
	if ( $cal['hidenavigation'] ) {
		$navigation = 'off';
	}
	$reload = ( $cal['jumpto'] ? '#qem_calreload' : '' );
	if ( isset( $_REQUEST['category'] ) ) {
		$category = sanitize_text_field( $_REQUEST['category'] );
	}
	$args = array(
		'post_type'      => 'event',
		'post_status'    => 'publish',
		'orderby'        => 'meta_value_num',
		'meta_key'       => 'event_date',
		'order'          => 'asc',
		'posts_per_page' => - 1,
		'category'       => '',
		'links'          => 'on'
	);

	$catarry      = explode( ",", $category );
	$leftnavicon  = '';
	$rightnavicon = '';
	if ( $cal['navicon'] == 'arrows' ) {
		$leftnavicon  = '&#9668; ';
		$rightnavicon = ' &#9658;';
	}
	if ( $cal['navicon'] == 'unicodes' ) {
		$leftnavicon  = $cal['leftunicode'] . ' ';
		$rightnavicon = ' ' . $cal['rightunicode'];
	}
	$monthnames = array();
	$monthstamp = 0;
	for ( $i = 0; $i <= 12; $i ++ ) {
		$monthnames[] = date_i18n( 'F', $monthstamp );
		$monthstamp   = strtotime( '+1 month', $monthstamp );
	}
	if ( $cal['startday'] == 'monday' ) {
		$timestamp = strtotime( 'next sunday' );
	}
	if ( $cal['startday'] == 'sunday' ) {
		$timestamp = strtotime( 'next saturday' );
	}
	$days = array();
	for ( $i = 0; $i <= 7; $i ++ ) {
		$days[]    = date_i18n( 'D', $timestamp );
		$timestamp = strtotime( '+1 day', $timestamp );
	}

	if ( isset( $_REQUEST["qemmonth"] ) ) {
		$month = sanitize_text_field($_REQUEST["qemmonth"]);
	} else {
		if ( $month ) {
			if ( ! is_numeric( $month ) ) {
				$month = strtotime( $month );
				if ( false === $month ) {
					$month = date_i18n( "n" );
				}
				$month = date( 'n', $month );
			}
		} else {
			$month = date_i18n( "n" );
		}
	}
	if ( isset( $_REQUEST["qemyear"] ) ) {
		$year = sanitize_text_field($_REQUEST["qemyear"]);
	} else {
		if ( $year ) {
			if ( ! is_numeric( $year ) ) {
				$year = strtotime( $year );
				if ( false === $year ) {
					$year = date_i18n( "Y" );
				}
				$year = date( 'Y', $year );
			}
		} else {
			$year = date_i18n( "Y" );
		}
	}
	$currentmonth = filter_var( $month, FILTER_SANITIZE_NUMBER_INT );
	$currentyear  = filter_var( $year, FILTER_SANITIZE_NUMBER_INT );

	/*
		Build attribute array into json object to use later
	*/


	$calendar_script_data = "data-qem_calendar_atts = \"" . esc_html( wp_json_encode( $atts ) ) . "\" ";
	$calendar_script_data .= "data-qem_month = \"{$currentmonth}\" ";
	$calendar_script_data .= "	data-qem_year = \"{$currentyear}\" ";
	$calendar_script_data .= "	data-qem_category = \"{$category}\" ";


	$calendar = '<div class="qem_calendar" id="qem_calendar_' . $c . '" ' . $calendar_script_data . '><a id="qem_calreload"></a>';


	$p_year  = $currentyear;
	$n_year  = $currentyear;
	$p_month = $currentmonth - 1;
	$n_month = $currentmonth + 1;
	if ( $p_month == 0 ) {
		$p_month = 12;
		$p_year  = $currentyear - 1;
	}
	if ( $n_month == 13 ) {
		$n_month = 1;
		$n_year  = $currentyear + 1;
	};

	$atts['calendar'] = true;
	if ( qem_get_element( $cal, 'fullpopup', false ) ) {
		$atts['fullpopup'] = 'checked';
	}

	$qem_dates    = array();
	$eventdate    = array();
	$eventenddate = array();
	$eventtitle   = array();
	$eventsummary = array();
	$eventlinks   = array();
	$eventslug    = array();
	$eventimage   = array();
	$eventdesc    = array();
	$eventnumbers = array();
	$eventx       = false;

	$query = new WP_Query( $args );
	if ( $query->have_posts() ) {
		while ( $query->have_posts() ) {
			$query->the_post();
			if ( in_category( $catarry ) || ! $category || 'undefined' === $category ) {
				$startdate = get_post_meta( $post->ID, 'event_date', true );
				$enddate   = get_post_meta( $post->ID, 'event_end_date', true );
				if ( ! $startdate || ! is_numeric( $startdate ) ) {
					$startdate = time();
				}
				$startmonth = date( "m", (int) $startdate );
				$startyear  = date( "Y", (int) $startdate );
				$match      = false;

				// Do matches for the start of an event
				if ( $startyear == $currentyear && $startmonth == $currentmonth ) {
					$match = true;
				}

				// Do matches for end of event (If it applies)
				if ( ! $match && $enddate ) {
					$endmonth = date( "m", $enddate );
					$endyear  = date( "Y", $enddate );

					if ( $endyear == $currentyear && $endmonth == $currentmonth ) {
						$match = true;
					}
				}

				if ( $match ) {
					// $startdate = strtotime(date("d M Y", $startdate));
					$enddate    = get_post_meta( $post->ID, 'event_end_date', true );
					$image      = get_post_meta( $post->ID, 'event_image', true );
					$desc       = get_post_meta( $post->ID, 'event_desc', true );
					$link       = get_permalink();
					$whoscoming = get_option( 'qem_messages_' . $post->ID );
					$attendees  = $whoscoming ? true : false;
					$cat        = get_the_category();
					if ( ! $cat ) {
						$cat = array();
					}
					$slug = ( isset( $cat[0] ) ) ? $cat[0]->slug : '';
					if ( $cal['eventlink'] == 'linkpopup' ) {
						$eventx = get_event_popup( $atts );
					}
					$title = get_the_title();
					if ( qem_get_element( $cal, 'showmultiple', false ) ) {
						do {
							array_push( $eventdate, $startdate );
							array_push( $eventtitle, $title );
							array_push( $eventslug, $slug );
							array_push( $eventsummary, $eventx );
							array_push( $eventlinks, $link );
							array_push( $eventnumbers, $attendees );
							$startdate = $startdate + ( 24 * 60 * 60 );
						} while ( $startdate <= $enddate );
					} else {
						array_push( $eventdate, $startdate );
						array_push( $eventtitle, $title );
						array_push( $eventslug, $slug );
						array_push( $eventsummary, $eventx );
						array_push( $eventlinks, $link );
						array_push( $eventnumbers, $attendees );
						array_push( $eventimage, $image );
						array_push( $eventdesc, $desc );
					}
				}
			}
		}
	}
	wp_reset_postdata();
	wp_reset_query();

	if ( $cal['connect'] ) {
		$calendar .= '<p><a href="' . $cal['eventlist_url'] . '">' . $cal['eventlist_text'] . '</a></p>';
	}

	$actual_link = qem_actual_link();
	$parts       = explode( "&", $actual_link );
	$actual_link = $parts['0'];
	$link        = ( strpos( $actual_link, '?' ) ? '&' : '?' );
	$catkey      = qem_category_key( $cal, $style, 'calendar' );

	if ( qem_get_element( $cal, 'showkeyabove', false ) &&
	     ! $widget ||
	     qem_get_element( $atts, 'categorykeyabove', false ) == 'checked' ) {
		$calendar .= $catkey;
	}
	if ( qem_get_element( $cal, 'showmonthsabove', false ) ) {
		$calendar .= qem_calendar_months( $cal );
	}

	// Build Category Information

	$category = qem_get_element( $atts, 'category' );
	if ( isset( $_GET['category'] ) ) {
		$category = sanitize_text_field( $_GET['category'] );
	}

	$catlabel = str_replace( ',', ', ', $category );

	if ( $category && $display['showcategory'] ) {
		$calendar .= '<h2>' . $display['showcategorycaption'] . ' ' . $catlabel . '</h2>';
	}

	$calendar .= '<div id="qem-calendar">
    <table cellspacing="' . $cal['cellspacing'] . '" cellpadding="0">
    <tr class="caltop">
    <td>';
	if ( $navigation != 'off' ) {
		$calendar .= '<a class="calnav" href="' . $actual_link . $link . 'qemmonth=' . $p_month . '&amp;qemyear=' . $p_year . $reload . '">' . $leftnavicon . $cal['prevmonth'] . '</a>';
	}

	$headerorder = $cal['headerorder'] == 'ym' ? $currentyear . ' ' . $monthnames[ $currentmonth - 1 ] : $monthnames[ $currentmonth - 1 ] . ' ' . $currentyear;

	$calendar .= '</td>
    <td class="calmonth"><' . $header . '>' . $headerorder . '</' . $header . '></td>
    <td>';
	if ( $navigation != 'off' ) {
		$calendar .= '<a class="calnav" href="' . $actual_link . $link . 'qemmonth=' . $n_month . '&amp;qemyear=' . $n_year . $reload . '">' . $cal['nextmonth'] .
		             $rightnavicon . '</a>';
	}
	$calendar .= '</td>
    </tr>
    </table>
    <table>
    <tr>' . "\r\n";
	for ( $i = 1; $i <= 7; $i ++ ) {
		$calendar .= '<td class="calday">' . $days[ $i ] . '</td>';
	}
	$calendar  .= '</tr>' . "\r\n";
	$timestamp = mktime( 0, 0, 0, $currentmonth, 1, $currentyear );
	$maxday    = date_i18n( "t", $timestamp );
	$thismonth = getdate( $timestamp );
	if ( $cal['startday'] == 'monday' ) {
		$startday = $thismonth['wday'] - 1;
		if ( $startday == '-1' ) {
			$startday = '6';
		}
	} else {
		$startday = $thismonth['wday'];
	}
	$firstday = '';
	$henry    = $startday - 1;
	$startday = (int) $startday;

	for ( $i = 0; $i < ( $maxday + $startday ); $i ++ ) {
		$oldday   = '';
		$blankday = ( $i < $startday ? ' class="blankday" ' : '' );
		$firstday = ( $i == $startday - 1 ? ' class="firstday" ' : '' );
		$xxx      = mktime( 0, 0, 0, $currentmonth, $i - $startday + 1, $currentyear );
		if ( date_i18n( "d" ) > $i - $startday + 1 && $currentmonth <= date_i18n( "n" ) && $currentyear == date_i18n( "Y" ) ) {
			$oldday = 'oldday';
		}
		if ( $currentmonth < date_i18n( "n" ) && $currentyear == date_i18n( "Y" ) ) {
			$oldday = 'oldday';
		}
		if ( $currentyear < date_i18n( "Y" ) ) {
			$oldday = 'oldday';
		}
		if ( ( $cal['archive'] && $oldday ) || ! $oldday ) {
			$show = 'checked';
		} else {
			$show = '';
		}
		$tdstart   = '<td class="day ' . $oldday . ' ' . $firstday . '"><' . $header . '>' . ( $i - $startday + 1 ) . '</' . $header . '><br>';
		$tdcontent = $eventcontent = '';
		$flag      = $cal['attendeeflagcontent'] ? $cal['attendeeflagcontent'] : '&#x25cf;';
		foreach ( $eventdate as $key => $day ) {
			$m   = date( 'm', $day );
			$d   = date( 'd', $day );
			$y   = date( 'Y', $day );
			$zzz = mktime( 0, 0, 0, $m, $d, $y );
			if ( $xxx == $zzz && $show ) {
				$tdstart      = '<td class="eventday ' . $oldday . ' ' . $firstday . '"><' . $header . '>' . ( $i - $startday + 1 ) . '</' . $header . '>';
				$img          = ( qem_get_element( $eventimage, $key, false ) &&
				                  qem_get_element( $cal, 'eventimage', false ) &&
				                  ! $widget ? '<br><img src="' . qem_get_element( $eventimage, $key, '' ) . '">' : '' );
				$tooltip      = '';
				$tooltipclass = '';
				if ( qem_get_element( $cal, 'usetooltip', false ) ) {
					$desc         = ( $eventdesc[ $key ] ? ' - ' . $eventdesc[ $key ] : '' );
					$tooltip      = 'data-tooltip="' . $eventtitle[ $key ] . $desc . '"';
					$tooltipclass = ( ( $i % 7 ) == 6 ? ' tooltip-left ' : '' );
					if ( $widget ) {
						$tooltipclass = ( ( $i % 7 ) > 2 ? ' tooltip-left ' : '' );
					}
				}
				$length  = $cal['eventlength'];
				$short   = $length - 3;
				$numbers = '';
				if ( $cal['attendeeflag'] ) {
					$numbers = ( $eventnumbers[ $key ] ) ? $flag . '&nbsp;' : '';
				}
				$tagless_title = strip_tags( $eventtitle[ $key ] );
				$trim_title    = ( strlen( $tagless_title ) > $length ) ? mb_substr( $tagless_title, 0, $short, "utf-8" ) . '...' : $tagless_title;
				// put back tags - this is for translation plugins like TranslatePress
				$trim = str_replace( $tagless_title, $trim_title, $eventtitle[ $key ] );
				if ( $cal['eventlink'] == 'linkpopup' ) {
					$tdcontent .= '<a ' . $tooltip . ' class="qem_linkpopup event ' . $eventslug[ $key ] . $tooltipclass . '" data-xlightbox="' . esc_html( $eventsummary[ $key ] ) . '"><div class="qemtrim"><span>' . $numbers . $trim . '</span>' . $img . '</div></a>';
				} else {
					$eventcontent = '<a ' . $tooltip . ' class="' . $eventslug[ $key ] . $tooltipclass . '" href="' . $eventlinks[ $key ] . '"><div class="qemtrim"><span>' . $numbers . $trim . '</span>' . $img . '</div></a>';
					$tdcontent    .= preg_replace( "/\r|\n/", "", $eventcontent );
				}
			}
		}
		$tdbuilt = $tdstart . $tdcontent . '</td>';
		if ( ( $i % 7 ) == 0 ) {
			$calendar .= "<tr>\r\t";
		}
		if ( $i < $startday ) {
			$calendar .= '<td' . $firstday . $blankday . '></td>';
		} else {
			$calendar .= $tdbuilt;
		}
		if ( ( $i % 7 ) == 6 ) {
			$calendar .= "</tr>" . "\r\n";
		};
	}
	$calendar .= "</table></div>";
	if ( qem_get_element( $cal, 'showkeybelow', false ) && ! $widget || qem_get_element( $atts, 'categorykeybelow', false ) == 'checked' ) {
		$calendar .= $catkey;
	}
	if ( qem_get_element( $cal, 'showmonthsbelow', false ) ) {
		$calendar .= qem_calendar_months( $cal );
	}
	$eventdate = remove_empty( $eventdate );

	//  escaped function - always return safe for output
	return wp_kses_post( $calendar ) . "</div>";
}

Code file location:

quick-event-manager/quick-event-manager/legacy/quick-event-manager.php

Quick Event Manager [qemregistration] Shortcode

The Quick Event Manager shortcode ‘qemregistration’ is used to generate a custom registration form for events. It displays user’s name and email if logged in, and includes a simple math CAPTCHA for validation.

Shortcode: [qemregistration]

Parameters

Here is a list of all possible qemregistration shortcode parameters and attributes:

  • id – The unique identifier for the specific event registration form.

Examples and Usage

Basic example – The shortcode is used to display a registration form for a specific event by referencing its ID.

[qemregistration id=1 /]

Advanced examples

Displaying the registration form for an event without specifying an ID. In this case, the shortcode will use the ID of the current post.

[qemregistration /]

Displaying a registration form for a specific event by referencing its ID and setting a custom CSS class for styling purposes.

[qemregistration id=2 class="my-custom-class" /]

Displaying the registration form for an event and hiding it for logged-in users. This can be useful if you want to restrict event registration to non-registered users only.

[qemregistration id=3 hide_for_logged_in=true /]

PHP Function Code

In case you have difficulties debugging what causing issues with [qemregistration] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'qemregistration', 'qem_loop_esc' );

Shortcode PHP function:

function qem_loop_esc( $atts = array() ) {
	$wrap_open = '';
	$wrap_close = '';
	$atts       = shortcode_atts( array(
		'id' => '',
	), $atts, 'qem' );
	$atts['id'] = (int) $atts['id'];
	if ( ! empty( $atts['id'] ) ) {
		$id = $atts['id'];
		$wrap_open = '<div class="qem">';
		$wrap_close = '</div>';
	} else {


		global $post;
		if ( null !== $post ) {
			$pw = get_post_meta( $post->ID, 'event_password_register', true );
			if ( post_password_required( $post ) && $pw ) {
				return get_the_password_form();
			}
		}
		$id = get_the_ID();
	}

	$values  = get_custom_registration_form( $id );
	$payment = qem_get_stored_payment();
	if ( is_user_logged_in() && qem_get_element( $values, 'showuser', false ) ) {
		$current_user        = wp_get_current_user();
		$values['yourname']  = $current_user->display_name;
		$values['youremail'] = $current_user->user_email;
	}
	$values['yourplaces']  = '1';
	$values['yournumber1'] = '';
	$values['youranswer']  = '';
	$values['yourcoupon']  = qem_get_element( $payment, 'couponcode' );
	$values['ipn']         = md5( wp_rand() );
	$digit1                = wp_rand( 1, 10 );
	$digit2                = wp_rand( 1, 10 );
	if ( $digit2 >= $digit1 ) {
		$values['thesum'] = "$digit1 + $digit2";
		$values['answer'] = $digit1 + $digit2;
	} else {
		$values['thesum'] = "$digit1 - $digit2";
		$values['answer'] = $digit1 - $digit2;
	}
	if ( ( is_user_logged_in() && qem_get_element( $values, 'registeredusers', false ) ) || ! qem_get_element( $values, 'registeredusers', false ) ) {
		return wp_kses_post($wrap_open).qem_display_form_esc( $values, array(), null ).wp_kses_post($wrap_close);
	}
}

Code file location:

quick-event-manager/quick-event-manager/legacy/quick-event-manager.php

Conclusion

Now that you’ve learned how to embed the Quick Event Manager Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *