GCALENDAR_ADDEVENT::setup_action()

Setup Action.


Return Return

(Uncanny_Automatorvoid.)


Source Source

File: src/integrations/google-calendar/actions/gcalendar-addevent.php

	protected function setup_action() {

		$this->set_integration( 'GOOGLE_CALENDAR' );

		$this->set_action_code( self::PREFIX . '_CODE' );

		$this->set_action_meta( self::PREFIX . '_META' );

		$this->set_support_link( Automator()->get_author_support_link( $this->get_action_code(), 'knowledge-base/google-calendar/' ) );

		$this->set_is_pro( false );

		$this->set_requires_user( false );

		$this->set_sentence(
			sprintf(
			/* translators: Action sentence */
				esc_attr__( 'Add {{an event:%1$s}} to {{a Google Calendar:%2$s}}', 'uncanny-automator' ),
				$this->get_action_meta(),
				$this->get_formatted_code( 'calendar' ) . ':' . $this->get_action_meta()
			)
		);

		$date_format_wp = get_option( 'date_format', 'F j, Y' );

		$timezone_wp = wp_timezone_string();

		/* translators: Action - WordPress */
		$this->set_readable_sentence( esc_attr__( 'Add {{an event}} to {{a Google Calendar}}', 'uncanny-automator' ) );

		$options_group = array(
			$this->get_action_meta() => array(
				// Calendar list.
				array(
					'option_code'           => $this->get_formatted_code( 'calendar' ),
					/* translators: Calendar field */
					'label'                 => esc_attr__( 'Calendar', 'uncanny-automator' ),
					'input_type'            => 'select',
					'is_ajax'               => true,
					'endpoint'              => 'automator_google_calendar_list_calendars_dropdown',
					'required'              => true,
					'supports_custom_value' => false,
					'required'              => true,
					'options_show_id'       => false,
				),
				// Summary.
				array(
					'option_code'           => $this->get_action_meta(),
					/* translators: Calendar field */
					'label'                 => esc_attr__( 'Title', 'uncanny-automator' ),
					'input_type'            => 'text',
					'supports_custom_value' => true,
					'required'              => true,
				),
				// Location.
				array(
					'option_code'           => $this->get_formatted_code( 'location' ),
					/* translators: Calendar field */
					'label'                 => esc_attr__( 'Location', 'uncanny-automator' ),
					'input_type'            => 'text',
					'supports_custom_value' => true,
					'required'              => false,
				),
				// Description.
				array(
					'option_code'           => $this->get_formatted_code( 'description' ),
					/* translators: Calendar field */
					'label'                 => esc_attr__( 'Description', 'uncanny-automator' ),
					'input_type'            => 'textarea',
					'supports_custom_value' => true,
					'required'              => false,
				),
				// Start date.
				array(
					'option_code'     => $this->get_formatted_code( 'start_date' ),
					/* translators: Calendar field */
					'label'           => esc_attr__( 'Start date', 'uncanny-automator' ),
					'input_type'      => 'date',
					'supports_tokens' => true,
					'required'        => true,
					'description'     => sprintf(
						'%1$s <a target="_blank" title="%3$s" href="%2$s">%3$s</a>.',
						esc_attr__( 'Start date must be in the date format set in', 'uncanny-automator' ),
						admin_url( 'options-general.php#timezone_string' ),
						esc_attr__( 'WordPress', 'uncanny-automator' )
					),
				),
				// Start time.
				array(
					'option_code'     => $this->get_formatted_code( 'start_time' ),
					/* translators: Calendar field */
					'label'           => esc_attr__( 'Start time', 'uncanny-automator' ),
					'input_type'      => 'time',
					'supports_tokens' => true,
					'required'        => false,
					'description'     => sprintf(
						'%1$s <a target="_blank" title="%3$s" href="%2$s">%3$s</a>. %4$s',
						esc_attr__( 'The event time will match the timezone set in', 'uncanny-automator' ),
						admin_url( 'options-general.php#timezone_string' ),
						esc_attr__( 'WordPress Settings', 'uncanny-automator' ),
						esc_attr__( 'Leave blank to create an all-day event.', 'uncanny-automator' )
					),
				),
				// End date.
				array(
					'option_code'     => $this->get_formatted_code( 'end_date' ),
					/* translators: Calendar field */
					'label'           => esc_attr__( 'End date', 'uncanny-automator' ),
					'input_type'      => 'date',
					'supports_tokens' => true,
					'required'        => true,
					'description'     => sprintf(
						'%1$s <a target="_blank" title="%3$s" href="%2$s">%3$s</a>.',
						esc_attr__( 'End date must be in the date format set in', 'uncanny-automator' ),
						admin_url( 'options-general.php#timezone_string' ),
						esc_attr__( 'WordPress', 'uncanny-automator' )
					),
				),
				// End time.
				array(
					'option_code'     => $this->get_formatted_code( 'end_time' ),
					/* translators: Calendar field */
					'label'           => esc_attr__( 'End time', 'uncanny-automator' ),
					'input_type'      => 'time',
					'supports_tokens' => true,
					'required'        => false,
					'description'     => sprintf(
						'%1$s <a target="_blank" title="%3$s" href="%2$s">%3$s</a>. %4$s',
						esc_attr__( 'The event time will match the timezone set in', 'uncanny-automator' ),
						admin_url( 'options-general.php#timezone_string' ),
						esc_attr__( 'WordPress Settings', 'uncanny-automator' ),
						esc_attr__( 'Leave blank to create an all-day event.', 'uncanny-automator' )
					),
				),
				// Attendees.
				array(
					'option_code'           => $this->get_formatted_code( 'attendees' ),
					/* translators: Calendar field */
					'label'                 => esc_attr__( 'Attendees', 'uncanny-automator' ),
					'description'           => esc_attr__( 'Comma separated email addresses of the attendees', 'uncanny-automator' ),
					'input_type'            => 'text',
					'supports_custom_value' => true,
					'required'              => false,
				),
				// Email Notifications.
				array(
					'option_code'   => $this->get_formatted_code( 'notification_email' ),
					/* translators: Calendar field */
					'label'         => esc_attr__( 'Enable email notifications in Google Calendar', 'uncanny-automator' ),
					'input_type'    => 'checkbox',
					'default_value' => true,
				),

				// Notification time.
				array(
					'option_code'   => $this->get_formatted_code( 'notification_time_email' ),
					/* translators: Calendar field */
					'label'         => esc_attr__( 'Minutes before event to trigger email notification', 'uncanny-automator' ),
					'description'   => esc_attr__( 'If no value is entered, the notification will fire 15 minutes before the event.', 'uncanny-automator' ),
					'placeholder'   => esc_attr__( '15', 'uncanny-automator' ),
					'input_type'    => 'text',
					'default_value' => 15,
					'required'      => false,
				),
				// Popup Notifications.
				array(
					'option_code'   => $this->get_formatted_code( 'notification_popup' ),
					/* translators: Calendar field */
					'label'         => esc_attr__( 'Enable popup notifications in Google Calendar', 'uncanny-automator' ),
					'input_type'    => 'checkbox',
					'default_value' => true,
				),
				array(
					'option_code'   => $this->get_formatted_code( 'notification_time_popup' ),
					/* translators: Calendar field */
					'label'         => esc_attr__( 'Minutes before event to trigger popup notification', 'uncanny-automator' ),
					'description'   => esc_attr__( 'If no value is entered, the notification will fire 15 minutes before the event.', 'uncanny-automator' ),
					'placeholder'   => esc_attr__( '15', 'uncanny-automator' ),
					'input_type'    => 'text',
					'default_value' => 15,
					'required'      => false,
				),
			),
		);

		$this->set_options_group( $options_group );

		$this->register_action();

	}