diff --git a/includes/oauthhelper/class-oauth-service.php b/includes/oauthhelper/class-oauth-service.php index 935904e5..113a8f5b 100644 --- a/includes/oauthhelper/class-oauth-service.php +++ b/includes/oauthhelper/class-oauth-service.php @@ -29,6 +29,13 @@ public function __construct() add_filter('simple_calendar_oauth_get_calendars', [$this, 'oauth_helper_get_calendar'], 10, 3); add_filter('simple_calendar_oauth_schedule_events', [$this, 'oauth_helper_schedule_events'], 10, 2); + + add_filter( + 'simple_calendar_oauth_get_events_cover_base64image', + [$this, 'auth_get_events_cover_base64image'], + 10, + 2 + ); } /** @@ -155,6 +162,21 @@ public function oauth_helper_schedule_events($calendarId, $event_data) $get_calendars = $Oauth_Ajax->oauth_helper_schedule_event_action($calendarId, $event_data); return $get_calendars; } + /** + * Get events cover base64 image. + * + * @since 1.0.0 + * + * @param string $fileid + * @param array $args + * @return array + */ + public function auth_get_events_cover_base64image($fileid, $args) + { + $Oauth_Ajax = new Oauth_Ajax(); + $get_events_cover_image = $Oauth_Ajax->auth_get_events_cover_base64image($fileid, $args); + return $get_events_cover_image; + } } new Auth_Service_Helpers(); diff --git a/includes/oauthhelper/oauth-service-actions.php b/includes/oauthhelper/oauth-service-actions.php index 7b8e2dfb..aa7bef99 100644 --- a/includes/oauthhelper/oauth-service-actions.php +++ b/includes/oauthhelper/oauth-service-actions.php @@ -247,6 +247,45 @@ public function oauth_helper_schedule_event_action($calendarId, $event_data) return $response; } } + + /* + * Get calendar Cover Image Base64 + */ + public function auth_get_events_cover_base64image($fileid, $args) + { + $send_data = [ + 'site_url' => self::$my_site_url, + 'auth_token' => get_option('simple_calendar_auth_site_token'), + 'fileid' => $fileid, + 'arguments' => $args, + ]; + $request = wp_remote_post(self::$url . 'auth_get_events_cover_base64image', [ + 'method' => 'POST', + 'body' => $send_data, + 'timeout' => 30, + 'cookies' => [], + ]); + + $response = wp_remote_retrieve_body($request); + $response_arr = json_decode($response, true); + + if (isset($response_arr['response']) && !empty($response_arr['response'])) { + if ($response_arr['response']) { + return $response_arr; + } + } elseif (isset($response_arr['message']) && !empty($response_arr['message'])) { + $response = [ + 'Error' => $response_arr['message'], + ]; + return $response; + } else { + $response = [ + 'response' => false, + 'message' => __('Network issue.', 'google-calendar-events'), + ]; + return $response; + } + } } //class End new Oauth_Ajax();