Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/embedpre.../EmbedPre.../Provider...
File: Calendly.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace EmbedPress\Providers;
[2] Fix | Delete
[3] Fix | Delete
use Embera\Provider\ProviderAdapter;
[4] Fix | Delete
use Embera\Provider\ProviderInterface;
[5] Fix | Delete
use Embera\Url;
[6] Fix | Delete
[7] Fix | Delete
(defined('ABSPATH') && defined('EMBEDPRESS_IS_LOADED')) or die("No direct script access allowed.");
[8] Fix | Delete
[9] Fix | Delete
/**
[10] Fix | Delete
* Entity responsible to support Calendly embeds.
[11] Fix | Delete
*
[12] Fix | Delete
* @package EmbedPress
[13] Fix | Delete
* @subpackage EmbedPress/Providers
[14] Fix | Delete
* @author EmbedPress <help@embedpress.com>
[15] Fix | Delete
* @copyright Copyright (C) 2023 WPDeveloper. All rights reserved.
[16] Fix | Delete
* @license GPLv3 or later
[17] Fix | Delete
* @since 1.0.0
[18] Fix | Delete
*/
[19] Fix | Delete
class Calendly extends ProviderAdapter implements ProviderInterface
[20] Fix | Delete
{
[21] Fix | Delete
/** inline {@inheritdoc} */
[22] Fix | Delete
protected static $hosts = ["calendly.com"];
[23] Fix | Delete
/**
[24] Fix | Delete
* Method that verifies if the embed URL belongs to Calendly.
[25] Fix | Delete
*
[26] Fix | Delete
* @param Url $url
[27] Fix | Delete
* @return boolean
[28] Fix | Delete
* @since 1.0.0
[29] Fix | Delete
*
[30] Fix | Delete
*/
[31] Fix | Delete
[32] Fix | Delete
/** inline {@inheritdoc} */
[33] Fix | Delete
/** @var array Array with allowed params for the current Provider */
[34] Fix | Delete
protected $allowedParams = [
[35] Fix | Delete
'cEmbedType',
[36] Fix | Delete
'calendlyData',
[37] Fix | Delete
'hideCookieBanner',
[38] Fix | Delete
'hideEventTypeDetails',
[39] Fix | Delete
'cBackgroundColor',
[40] Fix | Delete
'cTextColor',
[41] Fix | Delete
'cButtonLinkColor',
[42] Fix | Delete
'cPopupButtonText',
[43] Fix | Delete
'cPopupButtonBGColor',
[44] Fix | Delete
'cPopupButtonTextColor',
[45] Fix | Delete
'cPopupLinkText'
[46] Fix | Delete
];
[47] Fix | Delete
[48] Fix | Delete
[49] Fix | Delete
/** inline {@inheritdoc} */
[50] Fix | Delete
protected $httpsSupport = true;
[51] Fix | Delete
[52] Fix | Delete
public function getAllowedParams(){
[53] Fix | Delete
return $this->allowedParams;
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
public function validateUrl(Url $url)
[57] Fix | Delete
{
[58] Fix | Delete
return (bool) preg_match(
[59] Fix | Delete
"/^https:\/\/calendly\.com\/[a-zA-Z0-9_-]+\/.*/",
[60] Fix | Delete
(string) $url
[61] Fix | Delete
);
[62] Fix | Delete
}
[63] Fix | Delete
[64] Fix | Delete
public function validateCalendly($url)
[65] Fix | Delete
{
[66] Fix | Delete
return (bool) preg_match(
[67] Fix | Delete
"/^https:\/\/calendly\.com\/[a-zA-Z0-9_-]+\/.*/",
[68] Fix | Delete
(string) $url
[69] Fix | Delete
);
[70] Fix | Delete
}
[71] Fix | Delete
[72] Fix | Delete
/**
[73] Fix | Delete
* This method fakes an Oembed response.
[74] Fix | Delete
*
[75] Fix | Delete
* @since 1.0.0
[76] Fix | Delete
*
[77] Fix | Delete
* @return array
[78] Fix | Delete
*/
[79] Fix | Delete
public function fakeResponse()
[80] Fix | Delete
{
[81] Fix | Delete
$params = $this->getParams();
[82] Fix | Delete
[83] Fix | Delete
$parameters = array();
[84] Fix | Delete
[85] Fix | Delete
if (!empty($params['calendlyData']) && $params['calendlyData'] !== 'false') {
[86] Fix | Delete
$parameters['calendlyData'] = 1;
[87] Fix | Delete
}
[88] Fix | Delete
[89] Fix | Delete
if (!empty($params['hideCookieBanner']) && $params['hideCookieBanner'] !== 'false') {
[90] Fix | Delete
$parameters['hide_gdpr_banner'] = 1;
[91] Fix | Delete
}
[92] Fix | Delete
[93] Fix | Delete
if (!empty($params['hideEventTypeDetails']) && $params['hideEventTypeDetails'] !== 'false') {
[94] Fix | Delete
$parameters['hide_event_type_details'] = 1;
[95] Fix | Delete
}
[96] Fix | Delete
[97] Fix | Delete
if (!empty($params['cBackgroundColor']) && $params['cBackgroundColor'] !== 'false') {
[98] Fix | Delete
$parameters['background_color'] = ltrim($params['cBackgroundColor'], '#');
[99] Fix | Delete
}
[100] Fix | Delete
[101] Fix | Delete
if (!empty($params['cTextColor']) && $params['cTextColor'] !== 'false') {
[102] Fix | Delete
$parameters['text_color'] = ltrim($params['cTextColor'], '#');
[103] Fix | Delete
}
[104] Fix | Delete
[105] Fix | Delete
if (!empty($params['cButtonLinkColor']) && $params['cButtonLinkColor'] !== 'false') {
[106] Fix | Delete
$parameters['primary_color'] = ltrim($params['cButtonLinkColor'], '#');
[107] Fix | Delete
}
[108] Fix | Delete
[109] Fix | Delete
$query_string = http_build_query($parameters);
[110] Fix | Delete
[111] Fix | Delete
$src_url = $this->url.'?'.$query_string;
[112] Fix | Delete
[113] Fix | Delete
[114] Fix | Delete
$cButtonLinkColor = !empty($params['cButtonLinkColor']) ? $params['cButtonLinkColor'] : '';
[115] Fix | Delete
$cPopupButtonText = !empty($params['cPopupButtonText']) ? $params['cPopupButtonText'] : '';
[116] Fix | Delete
$cPopupButtonBGColor = !empty($params['cPopupButtonBGColor']) ? $params['cPopupButtonBGColor'] : '';
[117] Fix | Delete
[118] Fix | Delete
$cPopupButtonTextColor = !empty($params['cPopupButtonTextColor']) ? $params['cPopupButtonTextColor'] : '';
[119] Fix | Delete
[120] Fix | Delete
$cPopupLinkText = !empty($params['cPopupLinkText']) ? $params['cPopupLinkText'] : '';
[121] Fix | Delete
[122] Fix | Delete
[123] Fix | Delete
$width = isset($this->config['maxwidth']) ? $this->config['maxwidth'] : 600;
[124] Fix | Delete
$height = isset($this->config['maxheight']) ? $this->config['maxheight'] : 350;
[125] Fix | Delete
[126] Fix | Delete
$cEmbedType = !empty($params['cEmbedType']) ? $params['cEmbedType'] : '';
[127] Fix | Delete
[128] Fix | Delete
// Check if the url is already converted to the embed format
[129] Fix | Delete
if ($this->validateCalendly($src_url)) {
[130] Fix | Delete
[131] Fix | Delete
if($cEmbedType == 'inline'){
[132] Fix | Delete
$html = '<script type="text/javascript" src="https://assets.calendly.com/assets/external/widget.js" async></script>
[133] Fix | Delete
<link href="https://assets.calendly.com/assets/external/widget.css" rel="stylesheet">
[134] Fix | Delete
<div class="calendly-inline-widget" data-url="'.esc_url($src_url).'" style="min-width:'. esc_attr( $width ).'px;height:'.esc_attr($height).'px;"></div>';
[135] Fix | Delete
}
[136] Fix | Delete
else if($cEmbedType == 'popup_button'){
[137] Fix | Delete
$html = '<!-- Calendly badge widget begin -->
[138] Fix | Delete
<link href="https://assets.calendly.com/assets/external/widget.css" rel="stylesheet">
[139] Fix | Delete
<script src="https://assets.calendly.com/assets/external/widget.js" type="text/javascript" async></script>
[140] Fix | Delete
[141] Fix | Delete
<script type="text/javascript">window.onload = function() { Calendly.initBadgeWidget({ url: "'.$src_url.'", text: "'.esc_html( $cPopupButtonText ).'", color: "'. $cPopupButtonBGColor .'", textColor: "'.$cPopupButtonTextColor.'", branding: undefined }); }</script>';
[142] Fix | Delete
[143] Fix | Delete
if (class_exists('Elementor\Plugin')) {
[144] Fix | Delete
if (\Elementor\Plugin::$instance->editor->is_edit_mode() && $cEmbedType === 'popup_button') {
[145] Fix | Delete
$html = $html .'
[146] Fix | Delete
<div class="elementor-cbutton-preview-wrapper">
[147] Fix | Delete
<h4 class="cbutton-preview-text">Preview Popup Button</h4>
[148] Fix | Delete
<div style="position: static" class="calendly-badge-widget">
[149] Fix | Delete
<div class="calendly-badge-content" style="color: ' . $cPopupButtonTextColor . '; background: ' . $cPopupButtonBGColor . ';">' . esc_html( $cPopupButtonText ) . '</div>
[150] Fix | Delete
</div>
[151] Fix | Delete
</div>
[152] Fix | Delete
';
[153] Fix | Delete
}
[154] Fix | Delete
}
[155] Fix | Delete
[156] Fix | Delete
}
[157] Fix | Delete
else{
[158] Fix | Delete
$html = '';
[159] Fix | Delete
[160] Fix | Delete
}
[161] Fix | Delete
[162] Fix | Delete
} else {
[163] Fix | Delete
$html = '';
[164] Fix | Delete
}
[165] Fix | Delete
[166] Fix | Delete
[167] Fix | Delete
[168] Fix | Delete
[169] Fix | Delete
[170] Fix | Delete
return [
[171] Fix | Delete
'type' => 'rich',
[172] Fix | Delete
'provider_name' => 'Calendly',
[173] Fix | Delete
'provider_url' => 'https://calendly.com',
[174] Fix | Delete
'title' => 'Unknown title',
[175] Fix | Delete
'html' => $html,
[176] Fix | Delete
];
[177] Fix | Delete
}
[178] Fix | Delete
/** inline @inheritDoc */
[179] Fix | Delete
public function modifyResponse(array $response = [])
[180] Fix | Delete
{
[181] Fix | Delete
return $this->fakeResponse();
[182] Fix | Delete
}
[183] Fix | Delete
}
[184] Fix | Delete
[185] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function