Available Hooks & Filters

"View <post type>" text in calendar popover

Use this filter to change the "View <post type>" text in the calendar popover for all events.

add_filter('piecal_popover_link_text', 'my_callback');


function my_callback( $text ) {

$text = "Buy Tickets";

return $text;

}

Event query arguments

You can use the following code to change the query that returns all of Pie Calendar's events on the front-end. Below is an example that conditionally changes the post type shown on the calendar based on an arbitrary shortcode attribute.

add_filter('piecal_event_query_args', 'my_callback', 10, 2);


function my_callback( $args, $atts ) {

if( isset($atts['sandwich']) && $atts['sandwich'] == 'salami' ) {

$args['post_type'] = 'game_tournaments';

}

return $args;

}

Shortcode $atts

You can filter the $atts of the Pie Calendar shortcode using the code below.

add_filter('piecal_shortcode_atts', 'my_callback', 10, 1);


function my_callback( $atts ) {

if( isset($atts['sandwich']) && $atts['sandwich'] == 'salami' ) {

$atts['type'] = 'product';

}

return $atts;

}

Date format for calendar popover

The date strings output in the Pie Calendar popover are output via toLocaleDateString, which accepts an options array to define the format.

You can manipulate this array using the filters below. Note that there is one filter for the format of dates for events that are not all day events, and one filter for the format of dates that are all day events. This separation is due to the fact that it's often desirable to not show start and end times (hour/minute) for all day events.

add_filter('piecal_locale_date_string_format', 'my_callback');


function my_callback( $format ) {

$format['weekday'] = 'short'; // Other possible values: long, short, narrow
$format['day'] = 'numeric'; // Other possible values: numeric, 2-digit
$format['year'] = 'numeric'; // Other possible values: numeric, 2-digit
$format['month'] = 'long'; // Other possible values: numeric, 2-digit, long, short, narrow
$format['hour'] = 'numeric'; // Other possible values: numeric, 2-digit
$format['minute'] = 'numeric'; // Other possible values: numeric, 2-digit
$format['second'] = 'numeric'; // Other possible values: numeric, 2-digit

return $format;

}


add_filter('piecal_allday_locale_date_string_format', 'my_allday_callback');


function my_allday_callback( $format ) {

$format['weekday'] = 'short'; // Other possible values: long, short, narrow
$format['day'] = 'numeric'; // Other possible values: numeric, 2-digit
$format['year'] = 'numeric'; // Other possible values: numeric, 2-digit
$format['month'] = 'long'; // Other possible values: numeric, 2-digit, long, short, narrow

return $format;

}

Add classes to piecal-wrapper div

This feature is coming soon and is not yet implemented in a publicly available version of Pie Calendar.

add_filter('piecal_wrapper_class', function() {

return "sandwich";

});

The above code will result in the div being output with the class attribute value "piecal-wrapper sandwich".

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.