Goo Calendar Plugin for WordPress

Version 1.0.0.

This is an official home page with instructions of Goo Calendar plugin for WordPress
To people who builds or operate WordPress sites, current and potential users of Goo Calendar plugin
No, this software is meant for to all users of the WordPress. However, for implementing own functionality further, you are welcome to edit, modify or extend the code. 

Please visit goo-calendar.gootools.net to see the Goo Calendar in action.

Description

Build calendars with static and dynamic ranges for your WordPress pages. Once the calendar is set up, publish it, and run it via shortcode on page, post or widget area.

 

Display in day cells all kind of information:

  • Posts published that day
  • Posts published that day in particular category
  • Posts with clause for that day (post meta, ACF etc.)
  • Any post type (eg. product)
  • Create rules for: every day, every Monday…Sunday, odd-even days, and run different functions & configurations
  • Create your own display function
  • Combine all above in logic way

 

Create static and dynamic calendar ranges:

  • Static – for given start and end date, eg. January 1, 2017, to July 15, 2017
  • Dynamic – use pseudo values for date: {now}, {+30 days}, {+1 month}, {+1 year}, {-15 days} etc.

 

Style your calendars in any way you want to override default styling (fonts, colors, sizing).

  • Create own global styling defaults for your calendars
  • Override each styling setting at individual calendars
  • Style headings, day names, cell contents, calendar width, borders, colors
  • Insert own CSS class names in calendar DOM tree

This plugin provides calendar functionality to the front-end of your WordPress installation. Users with no experience of programming are able to set up calendars for own needs by implementing instructions from this page and connected “How To” posts. For advanced users, there is an ability to code own cell display functions or edit the default one, placing it in own functions.php file.


 

 

How to use this help file

If you are reading first time this content, please read it all, from top to bottom to get familiar with the plugin capabilities (later in the text “plugin” refer to THIS plugin: Goo Calendar if not marked otherwise).

In text below, sentences which start with (Advanced) are meant for advanced WordPress users, and usually describe internal plugin and/or WordPress mechanic.


 

 

Install Goo Calendar plugin

To install plugin go: Admin panel -> Plugins -> Add new -> Upload plugin -> Browse (and select .ZIP file) -> Install now. All you have to do now is to activate plugin.

If you omit to do it from installation page, you can always do it from Plugins page. Admin panel -> Plugins, find Goo Calendar plugin, and click Activate link right below.


 

 

Plugin settings

To access plugin settings page go: Admin panel -> Goo Calendar -> Settings or from Admin panel -> Plugins find Goo Calendar and click Settings link just below.

Your screen should look similar to this:

 

Here you will find three tabs: Simple styling, Advanced styling, Reset, Import & Export.

Simple styling

Simple styling options are reserved for a quick customization. Usually, if you are satisfied with the default outlook of the calendar, here you can quickly override some of the calendar defaults.

 

Changes done here will reflect across all calendars as a default options.
The options here correspond to the Appearance (simple options) section of calendar edit post page. All new calendars you create will have these options as defaults, and the old one will be altered only if their simple options are left blank. Don’t worry, you can change every option on the calendar page as calendar specific.

 

ADVANCED (tips & tricks): These changes are injected into the calendar DOM tree as inline styles. You can extend any HTML element style by typing the first argument to corresponding option and the second one as you wish. Eg. Main container -> Width can be set as: 80%; font-size: 2em . The font size will be propagated for the whole calendar.

Advanced styling

Similar to the simple styling options, advanced styling deal with CSS classes in DOM tree of the calendar. These settings allow you to fully customize calendar outlook. Completely override calendar default styling with your own controlling any HTML element of the calendar.

 

Some of the calendars internal JavaScript is bound to the default class names. We strongly advise adding classes rather than overwrite them.
Add a new CSS class name simply by separating with a blank space and hit SAVE CHANGES button. Changes applied here will only affect newly created calendars, while the existing one will preserve the old class name structure, unlike Simple styling. Anyway, you can edit each individual calendar according to your needs.

Advanced styling corresponds to the CSS Classes (advanced settings) of calendar edit post page.

 

Reset

Reset options to plugin defaults.

 

This is an irreversible process. All your plugin customization options will disappear.
Although your calendars are preserved and untouched, this action can affect them too. See Simple styling.

 

 

Import & Export

Here you can export and import plugin options to another Goo Calendar installation, or make a backup of your own. Both Import and Export action will only take care of the plugin options BUT NOT on calendars you created.

 

To export/import calendars you created use WordPress built in tools for such action: Dashboard->Tools->Import/Export


 

 

CREATE GOO CALENDAR

Go to Dashboard -> Goo Calendar -> Add New

Create new calendar from the WordPress dashboard

You should see screen similar to this:

Here you will find three main sections: Calendar settings, Appearance (simple options) and CSS Classes (advanced settings). Last two override plugin defaults and we already described it above.

Calendar settings

Here you define your calendar. Set up range for the calendar to display. Use static ranges or dynamic described in the picture.

 

Static ranges correspond to the two exact dates, while dynamic is always relative to the moment of viewing page displays calendar. Eg. if you want the calendar to always display last month period (dynamic range), setup should be from {-1 month} to {now}
Focus on and Days display options speak for themselves, but if you want to set starting day of the week you have to use WordPress built in settings at Wp Admin -> Settings -> General -> Week Starts On

 

Rules

Rules control what will be displayed in each day cell, by calling Goo Calendar default function goo_calendar_days_funct (with WP loop inside) or any other user defined a callable function, at certain days (every day, every Monday…Sunday, odd days, even days). The calendar needs at least one rule to run. This is default rule, you can edit or delete:

 

Rules section

The arguments for this rule means: get posts published on this particular day.

 

These arguments are solely interpreted by a function which accepts them (in our case it is default Goo Calendar function goo_calendar_days_funct).

 

 

Explanation:
{this_day} => standing alone, this pseudo variable means get posts associated with this date.
post_type = post => filter all posts except those of POST type.

 

Each clause or argument you pass to the function must be separated by ; sign

 

The post type can be changed to any post type you prefer. Eg. post_type = page will display pages published that day.

This is a default loop setting of the goo_calendar_days_funct function:

$args_query = array(
	'posts_per_page' => 5,
 	'offset' => 0,
 	'category' => '',
 	'category_name' => '',
 	'orderby' => 'date',
  	'order' => 'DESC',
  	'include' => '',
  	'exclude' => '',
  	'meta_key' => '',
  	'meta_value' => '',
  	'post_type' => 'post',
  	'post_mime_type' => '',
  	'post_parent' => '',
  	'author' => '',
  	'author_name' => '',
  	'post_status' => 'publish',
  	'suppress_filters' => true 
  	);

 

So, basically, you can change or add new filters as you find fit for your cause. All you need to pass arguments that override defaults. Here are a few examples:

 

category = 2,4 (only category IDs 2 and 4)
category_name = plugins (only category 'Plugins', use category slugs)
posts_per_page = 10 (control max posts listed)
order = ASC (in ascending order)
author = 123 (user ID, multiple entries allowed with comma separated)
author_name = user_nice_name
...

 

As you can see, with these arguments you can create endless filtering combinations.

Please consult this link for arguments you can pass to the function. Please, be noted, arguments with arrays are not accepted, and you have to create your own queries. However, we built in, the algorithm for accepting multiple meta keys and values which is about to be explained.

Filtering posts with custom fields are also easy. Basic usage for custom field is {custom_field_name} = YES

Rules arguments

Calendar setting

Post custom field

Post editor:

Also, you can add as many custom field key-value pairs as you need.

 

Advanced Custom Fields and WPML Integration

Custom fields created by Advanced Custom Fields plugin work in a similar way. Here is an example how the ACF date field works with Goo Calendar default function:

 

{date_cf_with_acf} = {this_day}

 

where {date_cf_with_acf} represents the name of the ACF field, and {this_day} pseudo variable has a second role beyond standing alone; to match the date with custom (meta) field.

If your WordPress install runs with the WordPress Multilingual Plugin, here is the way to select posts with exact language:

 

WPML_LANG = de

 

Adding New Rules

You can add as many rules as you think is necessary. Since every cell can have only one executive display function, and which rule come last, it will be executed.

#1 run -> Every day

#2 run -> Every Sunday

This is OK, since only Sundays second rule will be triggered.

#1 run -> Every Sunday

#2 run -> Every day

BAD. The second rule will overwrite first, and the first one will never be executed.


 

Your Custom Cell Display Function (advanced)

Rules you create can be applied to any callable function. No matter are you creating a new function or edit the default one, the best practice is to place your function into the functions.php file of your child theme.

 

(ADVANCED) This particular section of the tutorial is meant for developers or at least enthusiasts who are familiar to some extent of PHP programming in WordPress.

As mentioned before, default cell display function is goo_calendar_days_funct which is located in wp-content/plugins/goo-calendar/calendar-class-child.php file. DO NOT EDIT plugin core files, rather copy/paste function in functions.php and rename it as you wish, and then start to edit your local copy.

 

Ensure that your function accepts 3 variables in this order:

goo_calendar_days_your_custom_function ( integer $calendar_id, string $day_string, string $args )

where:

$calendar_id is calendar post type ID number

$day_string is YYYYMMDD string type variable eg. 20180128

$args is everything you type in the argument field of each rule section as an string type variable

All of these variables will be passed to your function in the same order for each function call triggered by the rule.

 

Don’t forget to echo your function result.

 

Run Calendar

When you are satisfied with your calendar, hit Publish and copy/paste provided shortcode anywhere you want.

[goo_calendar calendar_id=X]

 

Please visit goo-calendar.gootools.net to see the Goo Calendar in action.

Something to say...

Pin It on Pinterest

Share This