GCal Days

GCal Days Install Statistics

0
100%
Today: 0 Yesterday: 0 All-time: 1,657 downloads
GCal Days Icon

Try plugin: GCal Days

We'll create fresh WordPress site with GCal Days installed. You have 20 minutes to test the plugin after that site we'll be deleted.

Takes ~10 seconds to install.

About GCal Days

Shortcode and functions to query your Google Calendar for the number of days since or until the most recent event matching your search criteria.

0


0


0


0


0

updated: 8 years ago
since: 10 years ago
author: Scott Reilly

Description

This plugin provides a shortcode and a set of functions to return the number of days since the most recent past event in your Google Calendar matching specified search terms. The shortcode can also be used to return the number of days until the closest upcoming event matching specified search terms.

The Shortcode

[gcal-days search="" type="" id=""]

The shortcode name is gcal-days. It has three attributes, but only one of which is absolutely necessary:

  • search: (Required.) The search term.
  • type: (Optional.) The direction in time to search. Defaults to “since”, which searches past events. “until” will search future events.
  • id: (Conditionally optional.) The ID of the calendar to search. You can discover the IDs of calendars via the plugin’s settings page. This shortcode attribute can only be optionally omitted from shortcodes if you define a default calendar in the plugin’s settings.

The shortcode outputs a number representing the number of days until a matching event. If no event is found, a -1 will be displayed.

Examples: [gcal-days search="dentist"], [gcal-days type="until" search="vacation" id="[email protected]"]

Links: Plugin Homepage | Plugin Directory Page | Author Homepage

Functions

The plugin provides two functions for use in your theme templates, functions.php, or in plugins.

Functions

  • <?php function gcal_days_since( $search, $calendar_id = '' ) ?>
  • <?php function gcal_days_until( $search, $calendar_id = '' ) ?>

Arguments

  • $search (string)
    Required. The word or phrase to search for

  • $calendar_id (string)
    Optional. The ID for the Google Calendar. Check the plugin’s settings page for calendar IDs. This argument is only optional if you have defined a default calendar via the plugin’s settings.

Return Value

An integer value of the number of days since/until the matching event. -1 is returned if no event was found or an error was encountered.

Examples

  • <?php // Days until next dentist appointment
    $days_until = gcal_days_until( 'dentist' );
    ?>

  • <?php
    // Get the days since my last day off
    $days_since = gcal_days_since( 'day off' );
    // Echo a message using that number
    if ( -1 == $days_since ) {
    echo "You've never had a day off?! Take one soon!";
    } else {
    printf( _n( 'Your last day off was %d day ago.', 'Your last day off was $d days ago.', $days_since ), $days_since );
    }
    ?>