GCALENDAR_ADDEVENT::process_action( int $user_id, array $action_data, int $recipe_id, array $args, $parsed )
Process the action.
Contents
Parameters Parameters
- $user_id
-
(Required)
- $action_data
-
(Required)
- $recipe_id
-
(Required)
- $args
-
(Required)
- $parsed
-
(Required)
Return Return
(Uncanny_Automatorvoid.)
Source Source
File: src/integrations/google-calendar/actions/gcalendar-addevent.php
protected function process_action( $user_id, $action_data, $recipe_id, $args, $parsed ) { $calendar_id = isset( $parsed[ $this->get_formatted_code( 'calendar' ) ] ) ? sanitize_text_field( $parsed[ $this->get_formatted_code( 'calendar' ) ] ) : 0; $summary = isset( $parsed[ $this->get_action_meta() ] ) ? sanitize_text_field( $parsed[ $this->get_action_meta() ] ) : ''; $location = isset( $parsed[ $this->get_formatted_code( 'location' ) ] ) ? sanitize_text_field( $parsed[ $this->get_formatted_code( 'location' ) ] ) : ''; $description = isset( $parsed[ $this->get_formatted_code( 'description' ) ] ) ? sanitize_textarea_field( $parsed[ $this->get_formatted_code( 'description' ) ] ) : ''; $start_date = isset( $parsed[ $this->get_formatted_code( 'start_date' ) ] ) ? sanitize_text_field( $parsed[ $this->get_formatted_code( 'start_date' ) ] ) : false; $start_time = isset( $parsed[ $this->get_formatted_code( 'start_time' ) ] ) ? sanitize_text_field( $parsed[ $this->get_formatted_code( 'start_time' ) ] ) : false; $end_date = isset( $parsed[ $this->get_formatted_code( 'end_date' ) ] ) ? sanitize_text_field( $parsed[ $this->get_formatted_code( 'end_date' ) ] ) : false; $end_time = isset( $parsed[ $this->get_formatted_code( 'end_time' ) ] ) ? sanitize_text_field( $parsed[ $this->get_formatted_code( 'end_time' ) ] ) : false; $attendees = isset( $parsed[ $this->get_formatted_code( 'attendees' ) ] ) ? sanitize_text_field( $parsed[ $this->get_formatted_code( 'attendees' ) ] ) : ''; $notification_email = isset( $parsed[ $this->get_formatted_code( 'notification_email' ) ] ) ? sanitize_text_field( $parsed[ $this->get_formatted_code( 'notification_email' ) ] ) : 0; $notification_popup = isset( $parsed[ $this->get_formatted_code( 'notification_popup' ) ] ) ? sanitize_text_field( $parsed[ $this->get_formatted_code( 'notification_popup' ) ] ) : 0; $notification_time_email = isset( $parsed[ $this->get_formatted_code( 'notification_time_email' ) ] ) ? sanitize_text_field( $parsed[ $this->get_formatted_code( 'notification_time_email' ) ] ) : 0; $notification_time_popup = isset( $parsed[ $this->get_formatted_code( 'notification_time_popup' ) ] ) ? sanitize_text_field( $parsed[ $this->get_formatted_code( 'notification_time_popup' ) ] ) : 0; $helper = Automator()->helpers->recipe->google_calendar->options; $body = array( 'action' => 'create_event', 'access_token' => $helper->get_client(), 'summary' => $summary, 'location' => $location, 'calendar_id' => $calendar_id, 'description' => $description, 'start_date' => $start_date, 'start_time' => $start_time, 'end_date' => $end_date, 'end_time' => $end_time, 'attendees' => str_replace( ' ', '', trim( $attendees ) ), 'notification_email' => $notification_email, 'notification_popup' => $notification_popup, 'notification_time_email' => $notification_time_email, 'notification_time_popup' => $notification_time_popup, 'timezone' => apply_filters( 'automator_google_calendar_add_event_timezone', wp_timezone_string() ), 'date_format' => 'Y-m-d', ); try { $response = $helper->api_call( $body, $action_data ); Automator()->complete->action( $user_id, $action_data, $recipe_id ); } catch ( \Exception $e ) { $action_data['complete_with_errors'] = true; Automator()->complete->action( $user_id, $action_data, $recipe_id, $e->getMessage() ); } }
Expand full source code Collapse full source code View on Github