Skip to main content

GV_Extension_Calendar_Feed

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

Details

Methods

MethodDescription
__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.
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
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.
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
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.
calendar_options()Generates FullCalendar options data for the feed.
get_feed()Reduces queries by only fetching feeds from the database once per request.
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.
validate_event_url()Validates the event URL.
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()
is_calendars_overview_page()Determines if the current view is the calendars overview page.
register_noconflict_scripts()
register_noconflict_styles()
register_routes()Registers REST API routes.
proxy_icalendar_feed()Regenerates calendar feed from url to avoid CORS policy error.
ics_export_route()Exports calendar feed REST route.
generate_ics_file()Generates an ICS file for calendar feed.
post_feed_save()Fires action after a feed is saved.
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.
logger()Returns the logger for this plugin.

Method Reference

__construct()

public function __construct()

Creates the add-on instance.

Throws

  • Exception

Since: 1.5.7

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

get_instance()

public static function get_instance()

Returns an instance of this class.

Returns

Since: 1.0.0

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

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:143

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:215

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:229

scripts()

public function scripts()

Returns the scripts which should be enqueued.

Returns

  • array

Since: 1.0.0

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

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:359

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:375

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:432

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:448

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:593

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:1477

get_notifications_fields()

public function get_notifications_fields()

Get notifications fields for the feed.

Returns

  • array

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

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:1616

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:1682

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:1716

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:1753

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:1790

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:1803

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:1824

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:1843

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:1864

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:1885

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:1932

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:2149

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:2182

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:2236

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:2257

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:2273

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:2290

get_calendar_instance_options()

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

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

Parameters

NameTypeDefaultDescription
$feed_idint0View ID.
$form_idint0ID of the form.
$view_id0

Returns

  • array[]

Since: 1.5.1

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

output_calendar_scripts()

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

Generates and outputs <script> tags for calendars.

Parameters

NameTypeDefaultDescription
$feed_idint0Feed ID.
$form_idint0ID of the form.
$view_idint0View ID.

Returns

  • void

Since:

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

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:2570

output_calendar_styles()

public function output_calendar_styles( $feed_id=0 )

Outputs styles for calendars.

Parameters

NameTypeDefaultDescription
$feed_idint0Feed ID.

Returns

  • void

Since:

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

calendar_options()

public function calendar_options( $feed_id=0 )

Generates FullCalendar options data for the feed.

Parameters

NameTypeDefaultDescription
$feed_idinteger0Feed ID.

Returns

  • array — Array of options data.

Since: 1.0.0

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

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:2742

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:2765

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:2797

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:2845

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:3277

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:3393

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:3422

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:3504

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:3929

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:3955

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:3966

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:3984

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:4019

is_feed_list_page()

public function is_feed_list_page()

Returns

  • bool

Since: 2.2

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

is_calendars_overview_page()

public function is_calendars_overview_page()

Determines if the current view is the calendars overview page.

Returns

  • bool

Since: 2.9.0

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

register_noconflict_scripts()

public function register_noconflict_scripts( $scripts )

Parameters

NameTypeDefaultDescription
$scripts

Since: 1.5.7

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

register_noconflict_styles()

public function register_noconflict_styles( $styles )

Parameters

NameTypeDefaultDescription
$styles

Since: 1.5.7

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

register_routes()

public function register_routes()

Registers REST API routes.

Returns

  • void

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

proxy_icalendar_feed()

public function proxy_icalendar_feed( $request )

Regenerates calendar feed from url to avoid CORS policy error.

Parameters

NameTypeDefaultDescription
$request\WP_REST_Request

Returns

  • void | mixed

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

ics_export_route()

public function ics_export_route( $data )

Exports calendar feed REST route.

Parameters

NameTypeDefaultDescription
$dataarray

Returns

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

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:4272

post_feed_save()

public function post_feed_save( $feed_id, $form_id, $settings, $class )

Fires action after a feed is saved.

Parameters

NameTypeDefaultDescription
$feed_idinteger
$form_idinteger
$settingsarray
$classobject

Returns

  • void

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

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:4395

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:4412

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

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

is_valid_secret()

final public function is_valid_secret( array $feed, 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

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

logger()

final public static function logger()

Returns the logger for this plugin.

Returns

  • LoggerInterface

Since: 2.6

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