TemplateLayouts
8 months ago
AirTable.php
1 year ago
Boomplay.php
1 year ago
Calendly.php
2 years ago
Canva.php
1 year ago
FITE.php
1 year ago
GettyImages.php
9 months ago
Giphy.php
2 years ago
GitHub.php
3 years ago
GoogleCalendar.php
8 months ago
GoogleDocs.php
2 years ago
GoogleDrive.php
2 years ago
GoogleMaps.php
2 years ago
GooglePhotos.php
7 months ago
Gumroad.php
2 years ago
InstagramFeed.php
6 months ago
LinkedIn.php
2 years ago
Meetup.php
6 months ago
NRKRadio.php
2 years ago
OneDrive.php
11 months ago
OpenSea.php
9 months ago
SelfHosted.php
2 years ago
Spreaker.php
1 year ago
TikTok.php
2 years ago
Twitch.php
2 years ago
Wistia.php
6 months ago
Wrapper.php
3 years ago
X.php
2 years ago
Youtube.php
9 months ago
index.html
7 years ago
GoogleCalendar.php
74 lines
| 1 | <?php |
| 2 | |
| 3 | namespace EmbedPress\Providers; |
| 4 | |
| 5 | use Embera\Provider\ProviderAdapter; |
| 6 | use Embera\Provider\ProviderInterface; |
| 7 | use Embera\Url; |
| 8 | |
| 9 | (defined('ABSPATH') && defined('EMBEDPRESS_IS_LOADED')) or die("No direct script access allowed."); |
| 10 | |
| 11 | /** |
| 12 | * Entity responsible to support GoogleCalendar embeds. |
| 13 | * |
| 14 | * @package EmbedPress |
| 15 | * @subpackage EmbedPress/Providers |
| 16 | * @author EmbedPress <help@embedpress.com> |
| 17 | * @copyright Copyright (C) 2023 WPDeveloper. All rights reserved. |
| 18 | * @license GPLv3 or later |
| 19 | * @since 1.0.0 |
| 20 | */ |
| 21 | class GoogleCalendar extends ProviderAdapter implements ProviderInterface |
| 22 | { |
| 23 | /** |
| 24 | * Method that verifies if the embed URL belongs to GoogleCalendar. |
| 25 | * |
| 26 | * @param Url $url |
| 27 | * @return boolean |
| 28 | * @since 1.0.0 |
| 29 | * |
| 30 | */ |
| 31 | public function validateUrl(Url $url) |
| 32 | { |
| 33 | return (bool) preg_match( |
| 34 | '~https?:\/\/(?:www\.)?calendar\.google\.com\/calendar\/(?:u\/\d+\/)?embed\?src=[^&]+(?:&[a-zA-Z0-9_%=.\-]+)*~i', |
| 35 | $url |
| 36 | ); |
| 37 | } |
| 38 | |
| 39 | |
| 40 | /** |
| 41 | * This method fakes an Oembed response. |
| 42 | * |
| 43 | * @since 1.0.0 |
| 44 | * |
| 45 | * @return array |
| 46 | */ |
| 47 | public function fakeResponse() |
| 48 | { |
| 49 | $iframeSrc = html_entity_decode($this->url); |
| 50 | |
| 51 | |
| 52 | |
| 53 | $width = isset($this->config['maxwidth']) ? $this->config['maxwidth'] : 600; |
| 54 | $height = isset($this->config['maxheight']) ? $this->config['maxheight'] : 450; |
| 55 | $html = '<iframe src="' . esc_url($iframeSrc) . '" width="' . esc_attr($width) . '" height="' . esc_attr($height) . '" style="border:0;" frameborder="0" scrolling="no"></iframe>'; |
| 56 | |
| 57 | |
| 58 | return [ |
| 59 | 'type' => 'rich', |
| 60 | 'provider_name' => 'Google Calendar', |
| 61 | 'provider_url' => 'https://calendar.google.com', |
| 62 | 'title' => 'Unknown title', |
| 63 | 'html' => $html, |
| 64 | 'wrapper_class' => 'ose-google-calendar', |
| 65 | ]; |
| 66 | } |
| 67 | |
| 68 | /** inline @inheritDoc */ |
| 69 | public function modifyResponse(array $response = []) |
| 70 | { |
| 71 | return $this->fakeResponse(); |
| 72 | } |
| 73 | } |
| 74 |