Upcoming Calendar Events
Build a small WordPress plugin called "Upcoming Calendar Events" that displays upcoming events from a Google Calendar on the front-end of a WordPress site.
by Plugin Developer · github.com/varind3r/upcoming-calendar-events · website
★ 0stars
0forks
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/varind3r/upcoming-calendar-events/archive/refs/heads/main.zipReadme
Upcoming Calendar Events
A lightweight WordPress plugin that displays upcoming events from a Google Calendar using a shortcode and AJAX rendering.
Features
- Admin settings page under
Settings -> Calendar Events - Google API key configuration
- Cache duration and default event count settings
- Shortcode
[upcoming_events]with support forcount,days_ahead,show_description, andgoogle_calendar_id - Cache stored in WordPress transients and invalidated on settings save
- AJAX-powered frontend rendering with graceful error handling
Installation
- Copy the
upcoming-calendar-eventsfolder intowp-content/plugins/. - Run
composer installfrom the plugin folder:cd wp-content/plugins/upcoming-calendar-events composer install - Activate the plugin from the WordPress admin Plugins screen.
Setup
- Go to
Settings -> Calendar Eventsin the WordPress admin. - Enter your Google API key in the API key field.
- Set the cache duration in minutes (default is
60). - Set the default number of events to display (default is
5). - Click
Save and validateto store the settings and verify the API key.
Usage
Add the shortcode to a page or post:
[upcoming_events count="10" days_ahead="30" show_description="true" google_calendar_id="something@group.calendar.google.com"]
Required shortcode attributes:
days_ahead- mandatory numeric number of days ahead to show events forgoogle_calendar_id- mandatory Google Calendar ID
Optional shortcode attributes:
count- number of events to show; if omitted, the plugin uses the default count from settingsshow_description-trueorfalse; defaults tofalse
Google API Key and Calendar ID
- Create or select a project in the Google Cloud Console.
- Enable the Google Calendar API.
- Create an API key under
APIs & Services -> Credentials. - Use that API key in the plugin settings page.
- Get the calendar ID from Google Calendar settings under
Integrate calendar. - Use a public or shared calendar ID such as
something@group.calendar.google.com. - Do not use an OAuth client ID/secret for this plugin.
Architecture
upcoming-calendar-events.php- plugin bootstrap and Composer autoload.src/Plugin.php- main plugin orchestrator.src/Admin/Settings.php- admin menu, settings page, validation, and cache refresh.src/Frontend/Shortcode.php- shortcode registration and AJAX placeholder output.src/Frontend/AjaxRenderer.php- AJAX endpoint for rendering events.src/Api/GoogleCalendarClient.php- Google Calendar API client.src/Cache/CacheManager.php- transient-based caching and cache-key management.