PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents / 4.3.1
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents v4.3.1
4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.2.0 2.2.1 2.2.2 2.3.0 2.3.1 2.3.2 2.3.3 2.4.0 2.4.1 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.1.3 3.2.0 3.2.1 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.4.0 3.4.1 3.4.2 3.4.3 3.5.0 3.5.1 3.5.2 3.5.3 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.7.0 3.7.1 3.7.2 3.7.3 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.9.0 3.9.1 3.9.10 3.9.11 3.9.12 3.9.13 3.9.14 3.9.15 3.9.16 3.9.17 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9 4.0.0 4.0.1 4.0.10 4.0.11 4.0.12 4.0.13 4.0.14 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.0.9 4.1.0 4.1.1 4.1.10 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.2.7 4.2.8 4.2.9 4.3.0 4.3.1 4.4.0 4.4.1 4.4.10 4.4.11 4.4.2 4.4.3 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 4.5.0 4.5.1
embedpress / EmbedPress / Elementor / Widgets / Embedpress_Calendar.php
embedpress / EmbedPress / Elementor / Widgets Last commit date
Embedpress_Calendar.php 1 year ago Embedpress_Document.php 1 year ago Embedpress_Elementor.php 10 months ago Embedpress_Pdf.php 11 months ago
Embedpress_Calendar.php
329 lines
1 <?php
2
3 namespace EmbedPress\Elementor\Widgets;
4
5
6 use \Elementor\Controls_Manager as Controls_Manager;
7 use \Elementor\Modules\DynamicTags\Module as TagsModule;
8 use \Elementor\Widget_Base as Widget_Base;
9 use \Elementor\Plugin;
10 use EmbedPress\Includes\Traits\Branding;
11 use Embedpress_Google_Helper;
12 use EmbedPress\Includes\Classes\Helper;
13
14 ( defined( 'ABSPATH' ) ) or die( "No direct script access allowed." );
15
16 class Embedpress_Calendar extends Widget_Base
17 {
18 use Branding;
19 protected $pro_class = '';
20 protected $pro_text = '';
21 public function __construct($data = [], $args = null) {
22 parent::__construct($data, $args);
23
24 wp_register_style('fullcalendar', EPGC_ASSET_URL . 'lib/fullcalendar4/core/main.min.css', null, EMBEDPRESS_VERSION);
25 wp_register_style('fullcalendar_daygrid', EPGC_ASSET_URL . 'lib/fullcalendar4/daygrid/main.min.css', ['fullcalendar'], EMBEDPRESS_VERSION);
26 wp_register_style('fullcalendar_timegrid', EPGC_ASSET_URL . 'lib/fullcalendar4/timegrid/main.min.css', ['fullcalendar_daygrid'], EMBEDPRESS_VERSION);
27 wp_register_style('fullcalendar_list', EPGC_ASSET_URL . 'lib/fullcalendar4/list/main.min.css', ['fullcalendar'], EMBEDPRESS_VERSION);
28 wp_register_style('epgc', EPGC_ASSET_URL . 'css/epgc.css', ['fullcalendar_timegrid'], EMBEDPRESS_VERSION);
29 wp_register_style('tippy_light', EPGC_ASSET_URL . 'lib/tippy/light-border.css', null, EMBEDPRESS_VERSION);
30
31 //wp_enqueue_style( 'fullcalendar');
32 //wp_enqueue_style( 'fullcalendar_daygrid');
33 //wp_enqueue_style( 'fullcalendar_timegrid');
34 //wp_enqueue_style( 'fullcalendar_list');
35 //wp_enqueue_style( 'epgc');
36 //wp_enqueue_style( 'tippy_light');
37
38
39 wp_register_script('popper',EPGC_ASSET_URL . 'lib/popper.min.js', null, EMBEDPRESS_VERSION, true);
40 wp_register_script('tippy',EPGC_ASSET_URL . 'lib/tippy/tippy-bundle.umd.min.js', ['popper'], EMBEDPRESS_VERSION, true);
41 wp_register_script('my_moment',EPGC_ASSET_URL . 'lib/moment/moment-with-locales.min.js', null, EMBEDPRESS_VERSION, true);
42 wp_register_script('my_moment_timezone',EPGC_ASSET_URL . 'lib/moment/moment-timezone-with-data.min.js', ['my_moment'], EMBEDPRESS_VERSION, true);
43 wp_register_script('fullcalendar',EPGC_ASSET_URL . 'lib/fullcalendar4/core/main.min.js', ['my_moment_timezone'], EMBEDPRESS_VERSION, true);
44 wp_register_script('fullcalendar_moment',EPGC_ASSET_URL . 'lib/fullcalendar4/moment/main.min.js', ['fullcalendar'], EMBEDPRESS_VERSION, true);
45 wp_register_script('fullcalendar_moment_timezone',EPGC_ASSET_URL . 'lib/fullcalendar4/moment-timezone/main.min.js', ['fullcalendar_moment'], EMBEDPRESS_VERSION, true);
46 wp_register_script('fullcalendar_daygrid',EPGC_ASSET_URL . 'lib/fullcalendar4/daygrid/main.min.js', ['fullcalendar'], EMBEDPRESS_VERSION, true);
47 wp_register_script('fullcalendar_timegrid',EPGC_ASSET_URL . 'lib/fullcalendar4/timegrid/main.min.js', ['fullcalendar_daygrid'], EMBEDPRESS_VERSION, true);
48 wp_register_script('fullcalendar_list',EPGC_ASSET_URL . 'lib/fullcalendar4/list/main.min.js', ['fullcalendar'], EMBEDPRESS_VERSION, true);
49 wp_register_script('fullcalendar_locales',EPGC_ASSET_URL . 'lib/fullcalendar4/core/locales-all.min.js',['fullcalendar'], EMBEDPRESS_VERSION, true);
50 wp_register_script('epgc', EPGC_ASSET_URL . 'js/main.js',['fullcalendar'], EMBEDPRESS_VERSION, true);
51
52 //wp_enqueue_script('popper');
53 //wp_enqueue_script('my_moment');
54 //wp_enqueue_script('my_moment_timezone');
55 //wp_enqueue_script('fullcalendar');
56 //wp_enqueue_script('fullcalendar_moment');
57 //wp_enqueue_script('fullcalendar_moment_timezone');
58 //wp_enqueue_script('fullcalendar_daygrid');
59 //wp_enqueue_script('fullcalendar_timegrid');
60 //wp_enqueue_script('fullcalendar_list');
61 //wp_enqueue_script('fullcalendar_locales');
62 //wp_enqueue_script('epgc');
63
64 $nonce = wp_create_nonce('epgc_nonce');
65 wp_localize_script('epgc', 'epgc_object', [
66 'ajax_url' => admin_url('admin-ajax.php'),
67 'nonce' => $nonce,
68 'trans' => [
69 'all_day' => __('All day', 'embedpress'),
70 'created_by' => __('Created by', 'embedpress'),
71 'go_to_event' => __('Go to event', 'embedpress'),
72 'unknown_error' => __('Unknown error', 'embedpress'),
73 'request_error' => __('Request error', 'embedpress'),
74 'loading' => __('Loading', 'embedpress')
75 ]
76 ]);
77 }
78 public function get_name()
79 {
80 return 'embedpress_calendar';
81 }
82
83 public function get_title()
84 {
85 return esc_html__( 'EmbedPress Google Calendar', 'embedpress' );
86 }
87
88 public function get_categories()
89 {
90 return ['embedpress'];
91 }
92
93 public function get_custom_help_url()
94 {
95 return 'https://embedpress.com/docs/embed-google-calendar-in-wordpress/';
96 }
97
98 public function get_icon()
99 {
100 return 'eicon-calendar';
101 }
102
103 public function get_script_depends() {
104 return ['popper','tippy', 'my_moment', 'my_moment_timezone', 'fullcalendar', 'fullcalendar_moment', 'fullcalendar_moment_timezone', 'fullcalendar_daygrid', 'fullcalendar_timegrid', 'fullcalendar_list', 'fullcalendar_locales', 'epgc'];
105 }
106
107 public function get_style_depends() {
108 return ['fullcalendar', 'fullcalendar_daygrid', 'fullcalendar_list','epgc', 'tippy_light'];
109 }
110
111 /**
112 * Get widget keywords.
113 *
114 * Retrieve the list of keywords the widget belongs to.
115 *
116 * @return array Widget keywords.
117 * @since 2.5.5
118 * @access public
119 *
120 */
121 public function get_keywords()
122 {
123 return ['embedpress', 'calendar', 'google', 'google calendar', 'google-calendar', 'ics', 'event', 'embedpress calendar'];
124 }
125
126 protected function register_controls()
127 {
128 $class = 'embedpress-pro-control not-active';
129 $text = '<sup class="embedpress-pro-label" style="color:red">' . __('Pro', 'embedpress') . '</sup>';
130 $this->pro_class = apply_filters('embedpress/pro_class', $class);
131 $this->pro_text = apply_filters('embedpress/pro_text', $text);
132
133 /**
134 * EmbedPress Content Settings
135 */
136 $this->start_controls_section(
137 'embedpress_calendar_content_settings',
138 [
139 'label' => esc_html__( 'Content Settings', 'embedpress' ),
140 ]
141 );
142
143 $this->add_control(
144 'embedpress_calendar_type',
145 [
146 'label' => __( 'Calendar Type', 'embedpress' ),
147 'type' => Controls_Manager::SELECT,
148 'default' => 'public',
149 'options' => [
150 'private' => __( 'Private', 'embedpress' ),
151 'public' => __( 'Public', 'embedpress' )
152 ],
153 ]
154 );
155
156
157 $this->add_control(
158 'embedpress_public_cal_link',
159 [
160
161 'label' => __( 'Public Calendar Link', 'embedpress' ),
162 'type' => Controls_Manager::TEXT,
163 'dynamic' => [
164 'active' => true,
165 ],
166 'placeholder' => __( 'Enter public calendar link', 'embedpress' ),
167 'label_block' => true,
168 'condition' => [
169 'embedpress_calendar_type' => 'public'
170 ],
171
172 ]
173 );
174
175
176
177 $this->add_responsive_control(
178 'embedpress_elementor_calendar_width',
179 [
180 'label' => __( 'Width', 'embedpress' ),
181 'type' => Controls_Manager::SLIDER,
182 'separator' => 'before',
183 'default' => [
184 'unit' => 'px',
185 'size' => Helper::get_options_value('enableEmbedResizeWidth'),
186 ],
187 'range' => [
188 'px' => [
189 'min' => 6,
190 'max' => 1200,
191 ],
192 ],
193 'selectors' => [
194 '{{WRAPPER}} .embedpress-calendar-embed iframe' => 'width: {{SIZE}}{{UNIT}} !important; max-width: 100%',
195 ],
196 'render_type' => 'template',
197 ]
198 );
199
200 $this->add_responsive_control(
201 'embedpress_elementor_calendar_height',
202 [
203 'label' => __( 'Height', 'embedpress' ),
204 'type' => Controls_Manager::SLIDER,
205 'default' => [
206 'unit' => 'px',
207 'size' => Helper::get_options_value('enableEmbedResizeHeight'),
208 ],
209 'range' => [
210 'px' => [
211 'min' => 6,
212 'max' => 1000,
213 ],
214 ],
215 'selectors' => [
216 '{{WRAPPER}} .embedpress-calendar-embed iframe' => 'height: {{SIZE}}{{UNIT}};',
217 ],
218 'render_type' => 'template',
219
220 ]
221 );
222
223 $this->add_responsive_control(
224 'embedpress_elementor_calendar_align',
225 [
226 'label' => __( 'Alignment', 'embedpress' ),
227 'type' => Controls_Manager::CHOOSE,
228 'options' => [
229 'left' => [
230 'title' => __( 'Left', 'embedpress' ),
231 'icon' => 'eicon-text-align-left',
232 ],
233 'center' => [
234 'title' => __( 'Center', 'embedpress' ),
235 'icon' => 'eicon-text-align-center',
236 ],
237 'right' => [
238 'title' => __( 'Right', 'embedpress' ),
239 'icon' => 'eicon-text-align-right',
240 ]
241 ],
242 'prefix_class' => 'elementor%s-align-',
243 'default' => '',
244 ]
245 );
246
247 $this->add_control(
248 'embedpress_calendar_powered_by',
249 [
250 'label' => __( 'Powered By', 'embedpress' ),
251 'type' => Controls_Manager::SWITCHER,
252 'label_on' => __( 'Show', 'embedpress' ),
253 'label_off' => __( 'Hide', 'embedpress' ),
254 'return_value' => 'yes',
255 'default' => apply_filters( 'embedpress_calendar_powered_by_control', 'yes' ),
256 ]
257 );
258
259 $this->init_branding_controls( 'calendar');
260
261 $this->end_controls_section();
262
263 }
264
265 public function isGoogleCalendar($url) {
266 $pattern = '/^https:\/\/calendar\.google\.com\/calendar\/embed\?.*$/';
267 return preg_match($pattern, $url);
268 }
269
270 protected function render()
271 {
272 $settings = $this->get_settings();
273 $id = 'embedpress-calendar-' .esc_attr( $this->get_id());
274 $dimension = "width: " . esc_attr($settings['embedpress_elementor_calendar_width']['size']) . "px; height: " . esc_attr($settings['embedpress_elementor_calendar_height']['size']) . "px";
275
276 if(!empty($settings['embedpress_public_cal_link']) && !$this->isGoogleCalendar($settings['embedpress_public_cal_link'])) {
277 echo esc_html__('Invalid Calendar URL.');
278 return;
279 }
280
281 $this->add_render_attribute('embedpress-calendar-render', [
282 'class' => ['embedpress-embed-calendar-calendar', esc_attr($id)],
283 'data-emid' => esc_attr($id)
284 ]);
285 $this->add_render_attribute('embedpress-calendar', [
286 'class' => ['embedpress-calendar-embed', 'ep-cal-' . md5($id), 'ose-calendar']
287 ]);
288 $is_private_cal = (!empty($settings['embedpress_calendar_type']) && 'private' === $settings['embedpress_calendar_type']);
289 $is_editor_view = Plugin::$instance->editor->is_edit_mode();
290 ?>
291 <div <?php echo $this->get_render_attribute_string('embedpress-calendar'); ?> style="<?php echo esc_attr($dimension); ?>; max-width:100%; display: inline-block">
292 <?php
293 do_action('embedpress_calendar_after_embed', $settings, $id, $this);
294 ?>
295 <div <?php echo $this->get_render_attribute_string('embedpress-calendar-render'); ?>>
296 <?php if (!empty($settings['embedpress_public_cal_link']) && !empty($settings['embedpress_calendar_type']) && 'public' === $settings['embedpress_calendar_type']) { ?>
297 <iframe title="" style="<?php echo esc_attr($dimension); ?>; max-width:100%; display: inline-block" src="<?php echo esc_url($settings['embedpress_public_cal_link']); ?>" frameborder="0"></iframe>
298 <?php } else {
299 if ($is_editor_view && empty($settings['embedpress_public_cal_link']) && !$is_private_cal) { ?>
300 <p><?php esc_html_e('Please paste your public google calendar link.', 'embedpress'); ?></p>
301 <?php }
302
303
304 if ($is_editor_view && $is_private_cal) {
305
306 if (!apply_filters('embedpress/is_allow_rander', false)) { ?>
307 <p><?php esc_html_e('You need EmbedPress Pro to display Private Calendar Data.', 'embedpress'); ?></p>
308 <?php } else { ?>
309 <p><?php esc_html_e('Private Calendar Data will be displayed in the frontend', 'embedpress'); ?></p>
310 <?php }
311
312 } else {
313 do_action('embedpress_google_helper_shortcode', 10);
314 }
315
316 } ?>
317 </div>
318 <?php
319 if ($settings['embedpress_calendar_powered_by'] === 'yes') {
320 printf('<p class="embedpress-el-powered">%s</p>', esc_html__('Powered By EmbedPress', 'embedpress'));
321 }
322 ?>
323 </div>
324 <?php
325 }
326
327
328 }
329