Skip to main content

GV_Extension_Calendar_Feed

Source: includes/class-calendar-feed.php:29

Details​

Methods​

MethodDescription
get_members_caps()Lists this add-on's own capabilities in the Members plugin's UI.
__construct()Creates the add-on instance.
get_instance()Returns an instance of this class.
get_form_fields_as_choices()Adds our Entry Date and Entry Time options to the field mapping <select> dropdowns.
is_admin()Determines if the current request is for an administrative interface page; logic re-used from \GV\Request.
is_gutenberg_editor()Determines if the current page is a Gutenberg editor.
get_min_suffix()Returns the filename suffix for the plugin's minified assets.
scripts()Returns the scripts which should be enqueued.
localize_admin_script()Localizes the admin script that has been added via self::scripts().
styles()Returns the stylesheets which should be enqueued.
feed_settings_init()Renders settings and adds calendar data inline in GF v2.5+
settings()Renders settings and adds calendar data inline
get_views_for_form()Gets the published GravityView Views, ordered by title, optionally only those of one form.
feed_settings_fields()Configures the settings which should be rendered on the feed edit page in the Form Settings > Calendar Feed Add-On area.
attach_file_to_notification()Attach ics file to a notification.
get_notifications_fields()Get notifications fields for the feed.
validate_html_content()Validate type="text" fields that may contain HTML content on save.
validate_allow_html_content()Refuses to turn on "Allow HTML Content" for a user who cannot post unfiltered HTML.
settings_button()Output a <button> field in the feed settings
get_shortcode_for_feed()Returns shortcode for the current feed.
settings_calendar_embed()Adds Calendar Preview placeholder in GF v2.5+
settings_calendar_preview()Adds Calendar Preview placeholder in GF v2.5+
single_setting_row_calendar_preview()Adds Calendar Preview placeholder
single_setting_row_select()Overrides select row to check if it has a requirement
single_setting_row_text()Overrides text row to check if it has a requirement
single_setting_row_calendar_options()Overrides textarea row to check if it has a requirement
render_requires()Adds a data-requires attribute to the field
settings_calendar_controls()Render calendar control setting field markup
settings_calendar_options()Render calendar options setting field markup
control_button_markup()Returns markup for each control button type
feed_list_columns()Configures which columns should be displayed on the feed list page.
get_column_value_shortcode()Formats the value to be displayed in the shortcode column.
get_column_value_previewlink()Formats the value to be displayed in the preview column.
is_rest_request()Checks whether the current request is called from the Block Editor
is_rest_request_without_page()Checks whether the current request is a REST request that does not print the scripts a calendar needs.
is_gravityview_lightbox_request()Checks whether GravityView is rendering an entry in its lightbox.
set_lightbox_calendar()Sets whether the calendar being served is in GravityView's entry lightbox.
get_calendar_instance_options()Gets calendar options that are used to configure each calendar instance.
output_calendar_scripts()Generates and outputs <script> tags for calendars.
gv_calendar_clipboard_frontend_scripts()Adds clipboard scripts for frontend use.
output_calendar_styles()Outputs styles for calendars.
sanitize_height()Normalizes a per-embed height into a value FullCalendar accepts.
get_embed_height()Returns the height one embed of a feed should render at.
calendar_options()Generates FullCalendar options data for the feed.
get_feed()Reduces queries by only fetching feeds from the database once per request.
forget_feed()Drops a feed from the {@see get_feed()} cache, so the next read in this request sees what is stored.
user_has_edit_roles()Checks whether the user has required roles for editing events.
generate_controls_option()Generates array of control data based on settings value.
calendar_events()Returns event data, or sample data when none exists.
calendar_events_for_entry()Returns the event for a single entry, if the feed has one for it.
validate_event_url()Validates the event URL.
set_origin_post_id()Sets the page single entry event URLs should point back to.
maybe_use_calendar_origin_back_link()Points the single entry back link to the calendar page the visitor came from.
map_fields()Maps fields from settings.
get_sample_events()Generates some sample events to display.
get_fc_locales()Returns an array of available FullCalendar locales and, where available, their WP equivalent.
get_roles_as_choices()Returns roles as a choices list for use with Event Editing.
get_menu_icon()Returns calendar icon for the form settings menu.
feed_list_no_item_message(){@inheritdoc}
empty_feeds_message_string()Generates an empty feeds message with a dynamic URL.
is_feed_edit_page()Determines if the current view is the screen for editing a form's feed settings..
is_feed_list_page()
define_gform_hooks_before_gravityforms_script()Attaches Gravity Forms' JavaScript hook API to the front of gravityforms.js on the feed settings screen.
register_noconflict_scripts()
register_noconflict_styles()
register_routes()Registers REST API routes.
proxy_icalendar_feed()Sends one of a calendar's external event sources through this site, so the browser avoids the CORS policy error.
serve_proxy_feed_body()Prints the file proxy_icalendar_feed() returns in place of the REST server's JSON.
ics_export_route()Exports calendar feed REST route.
install_calendar_language_on_save()Installs the translation for a calendar's language when its settings are saved.
discard_cached_ics_on_save()Discards a feed's cached calendar when its settings are saved.
invalidate_on_entry_status_change()Discards affected calendars when an entry is trashed, spammed or restored.
invalidate_on_entry_saved()Invalidates a feed's calendar after an entry is saved from an editing screen.
invalidate_on_inline_edit()Invalidates a feed's calendar after GravityEdit changes an entry in place.
invalidate_on_revision_restored()Invalidates a feed's calendar after GravityRevisions restores an entry.
invalidate_on_revision_restored_legacy()Invalidates a feed's calendar on a GravityRevisions without the restore action.
invalidate_on_entry_deleted()Discards affected calendars when an entry is removed.
discard_cached_ics_on_feed_toggle()Discards a feed's stored calendar when it is activated or deactivated.
discard_cached_ics_on_feed_delete()Discards a feed's stored calendar before the feed itself is deleted.
mark_ics_cache_stale()Records that a feed's stored calendar no longer reflects its entries.
is_ics_cache_stale()Whether a feed's entries have changed since its calendar was built.
invalidate_feeds_for_entry()Marks every feed an entry can appear in as stale.
get_ics_cache_file()Returns the path of the file holding a feed's generated calendar.
get_cached_ics_body()Returns a feed's cached calendar, if one is present and still current.
may_serve_stored_calendar()Whether a request may answer with the stored calendar instead of building one.
read_ics_cache()Returns a feed's stored calendar whatever its age.
store_ics_body()Stores a feed's generated calendar for subsequent requests to serve.
delete_ics_cache()Discards a feed's cached calendar so the next request rebuilds it.
generate_ics_file()Generates an ICS file for calendar feed.
maybe_display_helpscout_beacon()Conditionally displays Help Scout beacon on certain pages.
is_secure()Whether the provided feed is secured.
get_validation_secret()Calculates and returns the calendar feed's validation secret.
is_valid_secret()Returns whether the provided secret validates for a calendar feed.
start_post_content()Notes which post's content is being filtered, so a secret in it can be traced to who wrote it.
start_acf_field()Notes the post an ACF editor field belongs to, which may not be the post being shown.
end_post_content()Ends what start_post_content() started.
may_add_secret_here()Whether a widget that works out a secured calendar's secret for itself may do so where it is shown.
remember_new_post_saver()Remembers who wrote a new post's content.
remember_post_saver()Remembers who changed a post's content, from any editor.
remember_builder_saver()Remembers who changed a layout kept in post meta, such as an Elementor page's or a GravityView View's.
current_user_can_use_secured_calendars()Whether the current user may get a secured calendar's secret or preview in an editor.
maybe_establish_secret_key_boundary()Saves, once, the IDs of the calendars that are secured when this site first runs the per-site key code.
logger()Returns the logger for this plugin.

Method Reference​

get_members_caps()​

public function get_members_caps()

Lists this add-on's own capabilities in the Members plugin's UI.

\GFAddOn::get_members_caps() only lists the form settings and uninstall capabilities when they are stored as strings, and both are arrays here so that a second capability can act as a fallback. Without this override they vanish from Members, leaving a site owner no way to grant a role calendar access — which is the one manual remedy for anyone the fallback misses.

Returns​

  • array — Capability name => label, as Members expects.

Since: 2.22.0

Source: includes/class-calendar-feed.php:122

__construct()​

public function __construct()

Creates the add-on instance.

Throws​

  • Exception

Since: 1.5.7

Source: includes/class-calendar-feed.php:370

get_instance()​

public static function get_instance()

Returns an instance of this class.

Returns​

Since: 1.0.0

Source: includes/class-calendar-feed.php:430

get_form_fields_as_choices()​

public function get_form_fields_as_choices( $form, $args=[] )

Adds our Entry Date and Entry Time options to the field mapping <select> dropdowns.

Parameters​

NameTypeDefaultDescription
$formarray
$argsarray[]

Returns​

  • array

Since: 1.2

Source: includes/class-calendar-feed.php:449

is_admin()​

public function is_admin()

Determines if the current request is for an administrative interface page; logic re-used from \GV\Request.

Returns​

  • boolean

Since: 1.5.1

Source: includes/class-calendar-feed.php:538

is_gutenberg_editor()​

public function is_gutenberg_editor()

Determines if the current page is a Gutenberg editor.

Returns​

  • boolean

Since: 1.5.1

Source: includes/class-calendar-feed.php:552

get_min_suffix()​

public static function get_min_suffix()

Returns the filename suffix for the plugin's minified assets.

Returns​

  • string — .min, or an empty string when SCRIPT_DEBUG or ?gform_debug asks for the sources.

Since: 2.22.0

Source: includes/class-calendar-feed.php:569

scripts()​

public function scripts()

Returns the scripts which should be enqueued.

Returns​

  • array

Since: 1.0.0

Source: includes/class-calendar-feed.php:580

localize_admin_script()​

public function localize_admin_script()

Localizes the admin script that has been added via self::scripts().

Returns​

  • void

Source: includes/class-calendar-feed.php:704

styles()​

public function styles( $options=[] )

Returns the stylesheets which should be enqueued.

Parameters​

NameTypeDefaultDescription
$options[]

Returns​

  • array

Since: 1.0.0

Source: includes/class-calendar-feed.php:720

feed_settings_init()​

public function feed_settings_init()

Renders settings and adds calendar data inline in GF v2.5+

Returns​

  • void

Since: 1.4

Source: includes/class-calendar-feed.php:775

settings()​

public function settings( $sections=[] )

Renders settings and adds calendar data inline

Parameters​

NameTypeDefaultDescription
$sectionsarray[]Configuration array containing all fields to be rendered grouped into sections

Returns​

  • void

Since: 1.0.0

Source: includes/class-calendar-feed.php:791

get_views_for_form()​

public function get_views_for_form( int $form_id=0 ): array

Gets the published GravityView Views, ordered by title, optionally only those of one form.

The list the eventurlentry field offers; also what the calendar abilities accept for it.

Parameters​

NameTypeDefaultDescription
$form_idint0Only Views whose main form is this one. 0 for every View.

Returns​

Since: 2.26.0

Source: includes/class-calendar-feed.php:999

feed_settings_fields()​

public function feed_settings_fields()

Configures the settings which should be rendered on the feed edit page in the Form Settings > Calendar Feed Add-On area.

Returns​

  • array

Since: 1.0.0

Source: includes/class-calendar-feed.php:1062

attach_file_to_notification()​

public function attach_file_to_notification( $notification, $form, $entry )

Attach ics file to a notification.

Parameters​

NameTypeDefaultDescription
$notificationarray
$formarray
$entryarray

Returns​

  • array

Source: includes/class-calendar-feed.php:2021

get_notifications_fields()​

public function get_notifications_fields()

Get notifications fields for the feed.

Returns​

  • array

Source: includes/class-calendar-feed.php:2108

validate_html_content()​

public function validate_html_content( $field, $value )

Validate type="text" fields that may contain HTML content on save.

Parameters​

NameTypeDefaultDescription
$fieldTextSetting field being validated.
$valuestringValue of the setting field.

Since: 2.13.0

Source: includes/class-calendar-feed.php:2168

validate_allow_html_content()​

public function validate_allow_html_content( $field, $value )

Refuses to turn on "Allow HTML Content" for a user who cannot post unfiltered HTML.

The setting puts HTML from entries, which site visitors write, into the calendar page. A calendar that already has it on keeps it when such a user saves other changes.

Parameters​

NameTypeDefaultDescription
$fieldCheckboxThe "Allow HTML Content" setting field.
$valuestringThe submitted value: '1' when checked.

Returns​

  • void

Since: 2.26.0

Source: includes/class-calendar-feed.php:2200

settings_button()​

public function settings_button( $field, $echo=true )

Output a <button> field in the feed settings

Parameters​

NameTypeDefaultDescription
$fieldarrayField configuration array
$echobooltrue

Returns​

  • string — HTML output for the <button>

Source: includes/class-calendar-feed.php:2390

get_shortcode_for_feed()​

public function get_shortcode_for_feed( array $feed=[] ): string

Returns shortcode for the current feed.

Parameters​

NameTypeDefaultDescription
$feedarray[]The feed to get the shortcode for.

Returns​

  • string — The shortcode.

Since: 2.6

Source: includes/class-calendar-feed.php:2424

settings_calendar_embed()​

public function settings_calendar_embed( $field=[] )

Adds Calendar Preview placeholder in GF v2.5+

Parameters​

NameTypeDefaultDescription
$fieldarray[]Section field data

Returns​

  • void

Since: 2.0

Source: includes/class-calendar-feed.php:2461

settings_calendar_preview()​

public function settings_calendar_preview( $field=[] )

Adds Calendar Preview placeholder in GF v2.5+

Parameters​

NameTypeDefaultDescription
$fieldarray[]Section field data

Returns​

  • void

Since: 1.4

Source: includes/class-calendar-feed.php:2498

single_setting_row_calendar_preview()​

public function single_setting_row_calendar_preview( $field=[] )

Adds Calendar Preview placeholder

Parameters​

NameTypeDefaultDescription
$fieldarray[]Section field data

Returns​

  • void

Since: 1.0.0

Source: includes/class-calendar-feed.php:2511

single_setting_row_select()​

public function single_setting_row_select( $field )

Overrides select row to check if it has a requirement

Parameters​

NameTypeDefaultDescription
$fieldarrayfield data

Returns​

  • void

Since: 1.0.0

Source: includes/class-calendar-feed.php:2532

single_setting_row_text()​

public function single_setting_row_text( $field )

Overrides text row to check if it has a requirement

Parameters​

NameTypeDefaultDescription
$fieldarrayfield data

Returns​

  • void

Since: 1.0.0

Source: includes/class-calendar-feed.php:2551

single_setting_row_calendar_options()​

public function single_setting_row_calendar_options( $field )

Overrides textarea row to check if it has a requirement

Parameters​

NameTypeDefaultDescription
$fieldarrayfield data

Returns​

  • void

Since: 1.0.0

Source: includes/class-calendar-feed.php:2572

render_requires()​

public function render_requires( $field=[] )

Adds a data-requires attribute to the field

Parameters​

NameTypeDefaultDescription
$fieldarray[]field data

Returns​

  • void

Since: 1.0.0

Source: includes/class-calendar-feed.php:2593

settings_calendar_controls()​

public function settings_calendar_controls( $field=[] )

Render calendar control setting field markup

Parameters​

NameTypeDefaultDescription
$fieldarray[]Array of field data

Returns​

  • void

Since: 1.0.0

Source: includes/class-calendar-feed.php:2640

settings_calendar_options()​

public function settings_calendar_options( $field=[], $echo=true )

Render calendar options setting field markup

Parameters​

NameTypeDefaultDescription
$fieldarray[]Array of field data
$echotrue

Returns​

  • string — HTML of the "calendar_options" field type

Since: 1.0.0

Source: includes/class-calendar-feed.php:2857

control_button_markup()​

public function control_button_markup( $type='', $echo=true )

Returns markup for each control button type

Parameters​

NameTypeDefaultDescription
$typestring''Type of control button
$echobooleantrueEcho markup or return

Returns​

  • mixed — Echo markup if $echo is true, otherwise return markup

Since: 1.0.0

Source: includes/class-calendar-feed.php:2890

feed_list_columns()​

public function feed_list_columns()

Configures which columns should be displayed on the feed list page.

Returns​

  • array

Since: 1.0.0

Source: includes/class-calendar-feed.php:2944

get_column_value_shortcode()​

public function get_column_value_shortcode( $feed )

Formats the value to be displayed in the shortcode column.

Parameters​

NameTypeDefaultDescription
$feedarray | falseThe feed being included in the feed list. False if we are in a new feed.

Returns​

  • string

Since: 1.0.0

Source: includes/class-calendar-feed.php:2965

public function get_column_value_previewlink( $feed )

Formats the value to be displayed in the preview column.

Parameters​

NameTypeDefaultDescription
$feedarrayThe feed being included in the feed list.

Returns​

  • string

Since: 1.0.0

Source: includes/class-calendar-feed.php:2981

is_rest_request()​

public function is_rest_request()

Checks whether the current request is called from the Block Editor

Returns​

  • bool — True: doing a REST request; false: not doing a REST request.

See Also​

Since: 1.0.0

Source: includes/class-calendar-feed.php:2998

is_rest_request_without_page()​

public function is_rest_request_without_page()

Checks whether the current request is a REST request that does not print the scripts a calendar needs.

GravityView's entry lightbox is served from a REST route, but it is a full page that prints them.

Returns​

  • bool — True: a REST request without a page; false: any other request.

Since: 2.26.0

Source: includes/class-calendar-feed.php:3011

is_gravityview_lightbox_request()​

public function is_gravityview_lightbox_request()

Checks whether GravityView is rendering an entry in its lightbox.

Returns​

  • bool

Since: 2.26.0

Source: includes/class-calendar-feed.php:3022

set_lightbox_calendar()​

public function set_lightbox_calendar( $lightbox_calendar )

Sets whether the calendar being served is in GravityView's entry lightbox.

The events request of a calendar in the lightbox is not itself a lightbox request, so it says so.

Parameters​

NameTypeDefaultDescription
$lightbox_calendarboolWhether the calendar is in the lightbox.

Returns​

  • void

Since: 2.26.0

Source: includes/class-calendar-feed.php:3037

get_calendar_instance_options()​

public function get_calendar_instance_options( $feed_id=0, $form_id=0, $view_id=0, $height='' )

Gets calendar options that are used to configure each calendar instance.

Parameters​

NameTypeDefaultDescription
$feed_idint0View ID.
$form_idint0ID of the form.
$view_id0
$heightmixed''Per-embed height override. Empty means the feed's own Sizing/Height settings decide.

Returns​

  • array[]

Since:

  • 1.5.1
  • 2.22.0 (Added the $height parameter.)

Source: includes/class-calendar-feed.php:3094

output_calendar_scripts()​

public function output_calendar_scripts( $feed_id=0, $form_id=0, $view_id=0, $height='' )

Generates and outputs <script> tags for calendars.

Parameters​

NameTypeDefaultDescription
$feed_idint0Feed ID.
$form_idint0ID of the form.
$view_idint0View ID.
$heightmixed''Per-embed height override. Empty means the feed's own Sizing/Height settings decide.

Returns​

  • void

Since:

  • 1.0.0
  • 1.5 (Added $view_id parameter.)
  • 2.22.0 (Added $height parameter.)

Source: includes/class-calendar-feed.php:3461

gv_calendar_clipboard_frontend_scripts()​

public static function gv_calendar_clipboard_frontend_scripts()

Adds clipboard scripts for frontend use.

Returns​

  • void

Since: 2.0

Source: includes/class-calendar-feed.php:3504

output_calendar_styles()​

public function output_calendar_styles( $feed_id=0 )

Outputs styles for calendars.

Parameters​

NameTypeDefaultDescription
$feed_idint0Feed ID.

Returns​

  • void

Since:

  • 1.0.0
  • 1.5 (Added $view_id parameter.)

Source: includes/class-calendar-feed.php:3551

sanitize_height()​

public static function sanitize_height( $height )

Normalizes a per-embed height into a value FullCalendar accepts.

The value reaches FullCalendar as height, which it writes into the calendar element's inline style, and it is echoed back as the element's data-height attribute. Both are why this is a whitelist rather than a filter: only a number with an optional CSS length unit, or the keyword auto, survives. Anything carrying a space, semicolon, quote, bracket, parenthesis or a function call (calc(), expression(), url()) fails the pattern and returns an empty string, which every caller reads as "no override — use the feed's own setting".

A bare number is normalized to pixels. FullCalendar accepts an integer as pixels but assigns a plain string straight to style.height, where "400" is invalid CSS and silently does nothing.

Parameters​

NameTypeDefaultDescription
$heightmixedRaw height, from a shortcode attribute, block attribute or widget setting.

Returns​

  • string — A FullCalendar height value, or an empty string when there is no usable override.

Since: 2.22.0

Source: includes/class-calendar-feed.php:3591

get_embed_height()​

public function get_embed_height( $feed_id=0, $height='' )

Returns the height one embed of a feed should render at.

A height on the embed implies fixed sizing. Sizing is a feed-level setting that defaults to auto and is not exposed per placement, so deferring to it would make an override a silent no-op on every feed whose Sizing was never switched to Fixed.

Parameters​

NameTypeDefaultDescription
$feed_idint0Feed ID.
$heightmixed''Per-embed height override. Empty means the feed's own settings decide.

Returns​

  • string — A FullCalendar height value. Never empty; auto when nothing sets a height.

Since: 2.22.0

Source: includes/class-calendar-feed.php:3630

calendar_options()​

public function calendar_options( $feed_id=0, $height='' )

Generates FullCalendar options data for the feed.

Parameters​

NameTypeDefaultDescription
$feed_idinteger0Feed ID.
$heightmixed''Per-embed height override. Empty means the feed's own Sizing/Height settings decide.

Returns​

  • array — Array of options data.

Since:

  • 1.0.0
  • 2.22.0 (Added the $height parameter.)

Source: includes/class-calendar-feed.php:3659

get_feed()​

public function get_feed( $id )

Reduces queries by only fetching feeds from the database once per request.

Parameters​

NameTypeDefaultDescription
$idintFeed ID.

Returns​

  • array | false

Since: 2.5

Source: includes/class-calendar-feed.php:3756

forget_feed()​

public static function forget_feed( $id )

Drops a feed from the {@see get_feed()} cache, so the next read in this request sees what is stored.

Parameters​

NameTypeDefaultDescription
$idintFeed ID.

Returns​

  • void

Since: 2.26.0

Source: includes/class-calendar-feed.php:3775

user_has_edit_roles()​

public function user_has_edit_roles( $edit_roles=[] )

Checks whether the user has required roles for editing events.

Parameters​

NameTypeDefaultDescription
$edit_rolesarray[]Array of role keys.

Returns​

  • bool — True: user can edit events.

Since: 1.0.0

Source: includes/class-calendar-feed.php:3788

generate_controls_option()​

public function generate_controls_option( $location='header', $controls_settings=[] )

Generates array of control data based on settings value.

Parameters​

NameTypeDefaultDescription
$locationstring'header'Location name.
$controls_settingsarray[]Control settings values.

Returns​

  • array | false — Array of setting data or false if not set.

Since: 1.0.0

Source: includes/class-calendar-feed.php:3820

calendar_events()​

public function calendar_events( $feed_id=0, $from_date=null, $to_date=null )

Returns event data, or sample data when none exists.

Parameters​

NameTypeDefaultDescription
$feed_idinteger0ID of the calendar feed.
$from_datestring | false | nullnullStart date timestamp used to filter events. False if error creating timestamp. Null if not set.
$to_datestring | false | nullnullEnd date timestamp used to filter events. False if error creating timestamp. Null if not set.

Returns​

  • array — Array of event data.

Throws​

  • Exception

Since:

  • 1.0.0
  • 1.5 (Added $from_date and $to_date parameters.)

Source: includes/class-calendar-feed.php:3868

calendar_events_for_entry()​

public function calendar_events_for_entry( $feed_id=0, $entry_id=0 )

Returns the event for a single entry, if the feed has one for it.

Produces the same event \calendar_events would, narrowed to the one entry while the entries are read rather than after every event has been built. A per-entry download and a notification attachment each need one event out of a calendar that can hold thousands, and building the rest of it costs ~30 ms an entry that nobody reads.

Parameters​

NameTypeDefaultDescription
$feed_idint0ID of the calendar feed.
$entry_idint0ID of the entry to build the event from.

Returns​

  • array — The entry's event data as a single-element array, empty when it has none.

Throws​

  • Exception

Since: 2.21.0

Source: includes/class-calendar-feed.php:3931

validate_event_url()​

public function validate_event_url( $field, $event_url )

Validates the event URL.

Parameters​

NameTypeDefaultDescription
$fieldTextThe field object.
$event_urlstringThe URL to validate.

Returns​

  • void

Since: 2.11.0

Source: includes/class-calendar-feed.php:4546

set_origin_post_id()​

public function set_origin_post_id( $post_id )

Sets the page single entry event URLs should point back to.

Only calendar rendering and the calendar events AJAX endpoint set this; other flows that build event URLs (ICS export, notification attachments) must leave it at 0.

Parameters​

NameTypeDefaultDescription
$post_idmixedPost ID of the page displaying the calendar.

Returns​

  • void

Since: 2.18.0

Source: includes/class-calendar-feed.php:4724

public function maybe_use_calendar_origin_back_link( $href, $context=null )

Points the single entry back link to the calendar page the visitor came from.

Parameters​

NameTypeDefaultDescription
$hrefstringExisting back link URL.
$context\GV\Template_Context | nullnullThe template context.

Returns​

  • string — Back link URL.

Since: 2.18.0

Source: includes/class-calendar-feed.php:4738

map_fields()​

public function map_fields( $feed=[], $entry=false )

Maps fields from settings.

Parameters​

NameTypeDefaultDescription
$feedarray[]Array of feed settings.
$entryarrayfalseForm entry.

Returns​

  • array — Array of mapped fields, filtered for empty status.

Since: 1.0.0

Source: includes/class-calendar-feed.php:4839

get_sample_events()​

public function get_sample_events( $meta=null )

Generates some sample events to display.

Parameters​

NameTypeDefaultDescription
$metastring | nullnullMetadata to add to each sample event.

Returns​

  • array — Array of sample event data.

Since: 1.0.0

Source: includes/class-calendar-feed.php:4868

get_fc_locales()​

public function get_fc_locales()

Returns an array of available FullCalendar locales and, where available, their WP equivalent.

Returns​

  • array[] — FullCalendar locales.

Since: 1.3

Source: includes/class-calendar-feed.php:4950

get_roles_as_choices()​

public function get_roles_as_choices()

Returns roles as a choices list for use with Event Editing.

Returns​

  • array[] — Each user role has a label and value.

Since: 1.0.0

Source: includes/class-calendar-feed.php:5375

get_menu_icon()​

public function get_menu_icon()

Returns calendar icon for the form settings menu.

Returns​

  • string

Since: 1.5

Source: includes/class-calendar-feed.php:5401

feed_list_no_item_message()​

public function feed_list_no_item_message(): string

{@inheritdoc}

Returns​

  • string

Since: 2.9.0

Source: includes/class-calendar-feed.php:5412

empty_feeds_message_string()​

public function empty_feeds_message_string(): string

Generates an empty feeds message with a dynamic URL.

Returns​

  • string — The message string with the URL.

Since: 2.9.0

Source: includes/class-calendar-feed.php:5430

is_feed_edit_page()​

public function is_feed_edit_page()

Determines if the current view is the screen for editing a form's feed settings..

Returns​

  • bool

Since: 1.5.7

Source: includes/class-calendar-feed.php:5465

is_feed_list_page()​

public function is_feed_list_page()

Returns​

  • bool

Since: 2.2

Source: includes/class-calendar-feed.php:5480

define_gform_hooks_before_gravityforms_script()​

public function define_gform_hooks_before_gravityforms_script()

Attaches Gravity Forms' JavaScript hook API to the front of gravityforms.js on the feed settings screen.

gforms_hooks.js defines gform.addFilter() and gform.applyFilters() only if ( ! gform ), and every Gravity Forms bundle opens with var gform = window.gform || {}, so the hook API exists only when that file runs before the first bundle. Gravity Forms prints it in front of gform_gravityforms_libraries, assuming that is the first bundle on an admin screen. On this screen it is not: the add-on framework enqueues gform_form_admin before Gravity Forms enqueues its own admin scripts, so gravityforms.js prints first, defines an empty gform, and the hook file becomes a no-op. The merge tag script then throws on gform.applyFilters before attaching a picker to any field.

Attaching the same code to gform_gravityforms with before prints it immediately ahead of gravityforms.js wherever WordPress places that script, which is what Gravity Forms itself does on the front end. Its own copy still prints later and hits the guard, which is what the guard is for.

Returns​

  • void

See Also​

Since: 2.22.0

Source: includes/class-calendar-feed.php:5505

register_noconflict_scripts()​

public function register_noconflict_scripts( $scripts )

Parameters​

NameTypeDefaultDescription
$scripts

Since: 1.5.7

Source: includes/class-calendar-feed.php:5540

register_noconflict_styles()​

public function register_noconflict_styles( $styles )

Parameters​

NameTypeDefaultDescription
$styles

Since: 1.5.7

Source: includes/class-calendar-feed.php:5552

register_routes()​

public function register_routes()

Registers REST API routes.

Returns​

  • void

Source: includes/class-calendar-feed.php:5564

proxy_icalendar_feed()​

public function proxy_icalendar_feed( $request )

Sends one of a calendar's external event sources through this site, so the browser avoids the CORS policy error.

Parameters​

NameTypeDefaultDescription
$request\WP_REST_Request

Returns​

Since:

  • 2.3
  • 2.26.0 (Requires the token from get_script_event_sources() for a secured or turned-off calendar, and returns the file as a REST response that serve_proxy_feed_body() prints.)

Source: includes/class-calendar-feed.php:5615

serve_proxy_feed_body()​

public function serve_proxy_feed_body( $served, $result, $request )

Prints the file proxy_icalendar_feed() returns in place of the REST server's JSON.

The REST server has already sent the response's headers, CORS ones included. A response another plugin replaced, such as a denial, is left to the REST server.

Parameters​

NameTypeDefaultDescription
$servedboolWhether the request was already served.
$resultWP_HTTP_ResponseThe response to send.
$requestWP_REST_RequestThe request.

Returns​

  • bool — Whether the request was served.

Since: 2.26.0

Source: includes/class-calendar-feed.php:5705

ics_export_route()​

public function ics_export_route( $data )

Exports calendar feed REST route.

Parameters​

NameTypeDefaultDescription
$dataarray

Returns​

Source: includes/class-calendar-feed.php:5778

install_calendar_language_on_save()​

public function install_calendar_language_on_save( $feed_id, $form_id, $settings, $addon )

Installs the translation for a calendar's language when its settings are saved.

Parameters​

NameTypeDefaultDescription
$feed_idintFeed ID.
$form_idintForm ID.
$settingsarraySaved settings.
$addonGFAddOnAdd-on whose feed was saved.

Returns​

  • void

Since: 2.25.0

Source: includes/class-calendar-feed.php:5824

discard_cached_ics_on_save()​

public function discard_cached_ics_on_save( $feed_id, $form_id, $settings, $addon )

Discards a feed's cached calendar when its settings are saved.

Parameters​

NameTypeDefaultDescription
$feed_idint | boolSaved feed ID, or false when the save failed.
$form_idintForm ID.
$settingsarraySaved settings.
$addonobjectAdd-on instance.

Returns​

  • void

Since: 2.21.0

Source: includes/class-calendar-feed.php:5844

invalidate_on_entry_status_change()​

public function invalidate_on_entry_status_change( $entry_id, $status, $previous_status )

Discards affected calendars when an entry is trashed, spammed or restored.

The hook fires after the write, so reading the entry back reports the new status and a trashed entry would look as though it had never been in the calendar. The previous value is what says whether it was.

Parameters​

NameTypeDefaultDescription
$entry_idintEntry ID.
$statusstringStatus after the change.
$previous_statusstringStatus before it.

Returns​

  • void

Since: 2.21.0

Source: includes/class-calendar-feed.php:5867

invalidate_on_entry_saved()​

public function invalidate_on_entry_saved( $form, $entry_id, $original_entry=[] )

Invalidates a feed's calendar after an entry is saved from an editing screen.

Gravity Forms' entry detail screen and GravityView's Edit Entry both write through GFFormsModel::save_lead(), which fires no entry hook at all — this action is the whole announcement. GravityView's bulk edit writes fields directly and then fires it by hand, so those arrive here too. Where gform_post_update_entry also fires, the second call is a no-op: a feed already stale is not marked again.

Parameters​

NameTypeDefaultDescription
$formarrayForm the entry belongs to.
$entry_idintEntry that was saved.
$original_entryarray[]Entry before the save, where the caller provides it.

Returns​

  • void

Since: 2.21.0

Source: includes/class-calendar-feed.php:5900

invalidate_on_inline_edit()​

public function invalidate_on_inline_edit( $result, $entry, $form_id=0, $field=null, $original_entry=[] )

Invalidates a feed's calendar after GravityEdit changes an entry in place.

GravityEdit removes every gform_post_update_entry action before its own update, so this filter is the only thing left that reports the change. Its value is passed through untouched: this reads the result, it does not decide it.

Parameters​

NameTypeDefaultDescription
$resultbool | WP_ErrorWhether the entry was updated.
$entryarrayEntry after the change.
$form_idint0Form ID.
$fieldGF_Field | nullnullField that changed, or null for entry meta.
$original_entryarray[]Entry before the change.

Returns​

  • bool | WP_Error — The result, unchanged.

Since: 2.21.0

Source: includes/class-calendar-feed.php:5927

invalidate_on_revision_restored()​

public function invalidate_on_revision_restored( $entry_id, $prior_entry=[], $restored=[] )

Invalidates a feed's calendar after GravityRevisions restores an entry.

Parameters​

NameTypeDefaultDescription
$entry_idintEntry that was restored.
$prior_entryarray[]Entry before the restore.
$restoredarray[]Entry as restored.

Returns​

  • void

Since: 2.21.0

Source: includes/class-calendar-feed.php:5947

invalidate_on_revision_restored_legacy()​

public function invalidate_on_revision_restored_legacy( $add_new, $prior_entry=[], $restored=[] )

Invalidates a feed's calendar on a GravityRevisions without the restore action.

Released versions announce nothing after restoring an entry, and they remove every gform_post_update_entry action before writing it — so on those sites a restored event would sit outside the calendar until the lifetime lapsed. This filter runs immediately after the restore is written, which makes it the only signal those sites can give. Its value is passed through untouched: whether a revision is added is not this plugin's decision.

Parameters​

NameTypeDefaultDescription
$add_newboolWhether GravityRevisions will store the prior state.
$prior_entryarray[]Entry before the restore.
$restoredarray[]Entry as restored, without its id and status.

Returns​

  • bool — The value, unchanged.

Since: 2.21.0

Source: includes/class-calendar-feed.php:5975

invalidate_on_entry_deleted()​

public function invalidate_on_entry_deleted( $entry_id )

Discards affected calendars when an entry is removed.

Parameters​

NameTypeDefaultDescription
$entry_idint | arrayEntry ID, or the entry itself.

Returns​

  • void

Since: 2.21.0

Source: includes/class-calendar-feed.php:5994

discard_cached_ics_on_feed_toggle()​

public function discard_cached_ics_on_feed_toggle( $feed_id, $active, $addon=null )

Discards a feed's stored calendar when it is activated or deactivated.

A deactivated feed is skipped by the route, so its stored calendar is unreachable until it comes back — at which point the calendar it kept may be months old.

Parameters​

NameTypeDefaultDescription
$feed_idintFeed ID.
$activeboolNew state.
$addonobjectnullAdd-on instance.

Returns​

  • void

Since: 2.21.0

Source: includes/class-calendar-feed.php:6018

discard_cached_ics_on_feed_delete()​

public function discard_cached_ics_on_feed_delete( $feed_id, $addon=null )

Discards a feed's stored calendar before the feed itself is deleted.

Deleted last, nothing would ever reclaim the file: the cache path is derived from the feed ID, and no request can arrive for a feed that no longer exists.

Parameters​

NameTypeDefaultDescription
$feed_idintFeed ID.
$addonobjectnullAdd-on instance.

Returns​

  • void

Since: 2.21.0

Source: includes/class-calendar-feed.php:6039

mark_ics_cache_stale()​

public function mark_ics_cache_stale( $feed_id )

Records that a feed's stored calendar no longer reflects its entries.

Writes nothing when there is no stored calendar, and nothing when the feed is already stale. An import changes thousands of entries; without that second guard the invalidation would cost more than the rebuild it defers.

Parameters​

NameTypeDefaultDescription
$feed_idintFeed ID.

Returns​

  • bool — Whether this call recorded the change.

Since: 2.21.0

Source: includes/class-calendar-feed.php:6097

is_ics_cache_stale()​

public function is_ics_cache_stale( $feed_id )

Whether a feed's entries have changed since its calendar was built.

Parameters​

NameTypeDefaultDescription
$feed_idintFeed ID.

Returns​

  • bool

Since: 2.21.0

Source: includes/class-calendar-feed.php:6123

invalidate_feeds_for_entry()​

public function invalidate_feeds_for_entry( $entry, $original=null )

Marks every feed an entry can appear in as stale.

Checked before and after the change: an entry that stops qualifying has left the calendar, and a calendar still listing it is as wrong as one missing a new entry.

Parameters​

NameTypeDefaultDescription
$entryarrayEntry after the change, or the deleted entry.
$originalarray | nullnullEntry before the change, where one exists.

Returns​

  • void

Since: 2.21.0

Source: includes/class-calendar-feed.php:6167

get_ics_cache_file()​

public function get_ics_cache_file( $feed_id )

Returns the path of the file holding a feed's generated calendar.

Named from a private hash rather than the feed's public URL hash: the REST route re-checks on every request that the feed still exists and is still enabled, and a guessable path would keep serving a calendar after either stopped being true.

Parameters​

NameTypeDefaultDescription
$feed_idintFeed ID.

Returns​

  • string — Absolute path, or an empty string where uploads are unavailable.

Since: 2.21.0

Source: includes/class-calendar-feed.php:6378

get_cached_ics_body()​

public function get_cached_ics_body( $feed_id )

Returns a feed's cached calendar, if one is present and still current.

Parameters​

NameTypeDefaultDescription
$feed_idintFeed ID.

Returns​

  • string | null — Calendar body, or null when there is nothing current to serve.

Since: 2.21.0

Source: includes/class-calendar-feed.php:6403

may_serve_stored_calendar()​

public function may_serve_stored_calendar( $feed_id )

Whether a request may answer with the stored calendar instead of building one.

A current copy is always served. An out-of-date copy is served too, with the rebuild following the response: a subscriber polling every fifteen minutes is better served slightly-old events now than correct events after a timeout. That trade needs something to run the rebuild once the response has gone, which is fastcgi_finish_request(). Where it is missing the out-of-date copy is refused and the request rebuilds inline, as it did before the stored copy existed. Serving it anyway would leave nothing to rebuild the calendar at all, and the subscription would answer with its first build forever.

Parameters​

NameTypeDefaultDescription
$feed_idintFeed ID.

Returns​

  • bool

Since: 2.21.0

Source: includes/class-calendar-feed.php:6424

read_ics_cache()​

public function read_ics_cache( $feed_id )

Returns a feed's stored calendar whatever its age.

Parameters​

NameTypeDefaultDescription
$feed_idintFeed ID.

Returns​

  • string | null — Calendar body, or null when there is nothing stored or it cannot be read.

Since: 2.21.0

Source: includes/class-calendar-feed.php:6458

store_ics_body()​

public function store_ics_body( $feed_id, $body, $built_at=null )

Stores a feed's generated calendar for subsequent requests to serve.

Written to a sibling temporary file and renamed into place. Rename within a directory is atomic, so a subscriber reading concurrently sees either the previous complete calendar or the new one, never a partial write.

Parameters​

NameTypeDefaultDescription
$feed_idintFeed ID.
$bodystringCalendar body.
$built_atint | nullnullWhen the build read its data; stamped as the file's mtime and compared against the stale marker so a change raised mid-build is not cleared. Null skips both.

Returns​

  • bool — Whether the calendar was stored.

Since: 2.21.0

Source: includes/class-calendar-feed.php:6722

delete_ics_cache()​

public function delete_ics_cache( $feed_id )

Discards a feed's cached calendar so the next request rebuilds it.

Parameters​

NameTypeDefaultDescription
$feed_idintFeed ID.

Returns​

  • void

Since: 2.21.0

Source: includes/class-calendar-feed.php:6882

generate_ics_file()​

public function generate_ics_file( $feed, $download=false, $single_entry=false )

Generates an ICS file for calendar feed.

Parameters​

NameTypeDefaultDescription
$feedarray
$downloadbooleanfalse
$single_entryintegerfalse

Returns​

Source: includes/class-calendar-feed.php:7013

maybe_display_helpscout_beacon()​

public function maybe_display_helpscout_beacon( $display )

Conditionally displays Help Scout beacon on certain pages.

Parameters​

NameTypeDefaultDescription
$displaybool

Returns​

  • bool

Since: 2.2

Source: includes/class-calendar-feed.php:7598

is_secure()​

final public function is_secure( array $feed ): bool

Whether the provided feed is secured.

Parameters​

NameTypeDefaultDescription
$feedarrayThe feed object.

Returns​

  • bool

Since: 2.6

Source: includes/class-calendar-feed.php:7615

get_validation_secret()​

final public function get_validation_secret( array $feed, $skip_feed_security_check=false ): ?string

Calculates and returns the calendar feed's validation secret.

Parameters​

NameTypeDefaultDescription
$feedarrayThe feed object.
$skip_feed_security_checkboolfalseWhether to skip the security check. Default is false.

Returns​

  • string | null — The calendar feed's secret.

Throws​

  • InvalidArgumentException — When the feed object is not valid.

Since:

  • 2.6
  • 2.26.0 (Derived from a per-site key.)

Source: includes/class-calendar-feed.php:7636

is_valid_secret()​

final public function is_valid_secret( array $feed, #[\SensitiveParameter] string $secret ): bool

Returns whether the provided secret validates for a calendar feed.

Parameters​

NameTypeDefaultDescription
$feedarrayThe feed object.
$secretstringThe provided secret.

Returns​

  • bool

Throws​

  • InvalidArgumentException — When the feed object is not valid.

Since:

  • 2.6
  • 2.26.0 (Accepts the previous secret only for calendars secured before the per-site key.)

Source: includes/class-calendar-feed.php:7675

start_post_content()​

public static function start_post_content( $content )

Notes which post's content is being filtered, so a secret in it can be traced to who wrote it.

Parameters​

NameTypeDefaultDescription
$contentmixedThe post content.

Returns​

  • mixed — The content, unchanged.

Since: 2.26.0

Source: includes/class-calendar-feed.php:7731

start_acf_field()​

public static function start_acf_field( $value, $post_id )

Notes the post an ACF editor field belongs to, which may not be the post being shown.

Parameters​

NameTypeDefaultDescription
$valuemixedThe field value.
$post_idint | stringWhat ACF loaded the value from: a post ID, or another ID such as options or user_2.

Returns​

  • mixed — The value, unchanged.

Since: 2.26.0

Source: includes/class-calendar-feed.php:7747

end_post_content()​

public static function end_post_content( $content )

Ends what start_post_content() started.

Parameters​

NameTypeDefaultDescription
$contentmixedThe post content.

Returns​

  • mixed — The content, unchanged.

Since: 2.26.0

Source: includes/class-calendar-feed.php:7790

may_add_secret_here()​

public static function may_add_secret_here( array $feed, ?WP_Post $document_post=null ): bool

Whether a widget that works out a secured calendar's secret for itself may do so where it is shown.

Such a widget stores only the calendar ID, so whoever places it could otherwise show any secured calendar.

Parameters​

NameTypeDefaultDescription
$feedarrayThe calendar feed.
$document_postWP_Post | nullnullThe post being shown, when the widget knows it better than the_content does.

Returns​

  • bool

Since: 2.26.0

Source: includes/class-calendar-feed.php:7896

remember_new_post_saver()​

public static function remember_new_post_saver( $post_id, $post, $update )

Remembers who wrote a new post's content.

Parameters​

NameTypeDefaultDescription
$post_idintPost ID.
$postWP_PostThe post.
$updateboolWhether this is an update, which remember_post_saver() handles.

Returns​

  • void

Since: 2.26.0

Source: includes/class-calendar-feed.php:8003

remember_post_saver()​

public static function remember_post_saver( $post_id, $post_after, $post_before )

Remembers who changed a post's content, from any editor.

Revisions can be turned off and _edit_last is not kept up to date, so neither is a reliable record.

Parameters​

NameTypeDefaultDescription
$post_idintPost ID.
$post_afterWP_PostThe post after the save.
$post_beforeWP_PostThe post before the save.

Returns​

  • void

Since: 2.26.0

Source: includes/class-calendar-feed.php:8022

remember_builder_saver()​

public static function remember_builder_saver( $meta_id, $post_id, $meta_key )

Remembers who changed a layout kept in post meta, such as an Elementor page's or a GravityView View's.

Parameters​

NameTypeDefaultDescription
$meta_idintMeta ID.
$post_idintPost ID.
$meta_keystringMeta key.

Returns​

  • void

Since: 2.26.0

Source: includes/class-calendar-feed.php:8039

current_user_can_use_secured_calendars()​

public static function current_user_can_use_secured_calendars(): bool

Whether the current user may get a secured calendar's secret or preview in an editor.

Anyone who can write a post can open an editor, so only users who can see secrets in calendar settings get them.

Returns​

  • bool

Since: 2.26.0

Source: includes/class-calendar-feed.php:8094

maybe_establish_secret_key_boundary()​

public static function maybe_establish_secret_key_boundary(): ?array

Saves, once, the IDs of the calendars that are secured when this site first runs the per-site key code.

Only calendars on the list accept the previous secret. Empty on a new install.

Returns​

  • int[] | null — The calendar IDs, or null if they cannot be read or saved.

Since: 2.26.0

Source: includes/class-calendar-feed.php:8215

logger()​

final public static function logger()

Returns the logger for this plugin.

Returns​

  • LoggerInterface

Since: 2.6

Source: includes/class-calendar-feed.php:8305