PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents / 3.3.3
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents v3.3.3
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 4 years ago Embedpress_Document.php 4 years ago Embedpress_Elementor.php 4 years ago Embedpress_Pdf.php 4 years ago
Embedpress_Calendar.php
357 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
13 ( defined( 'ABSPATH' ) ) or die( "No direct script access allowed." );
14
15 class Embedpress_Calendar extends Widget_Base
16 {
17 use Branding;
18 protected $pro_class = '';
19 protected $pro_text = '';
20 public function __construct($data = [], $args = null) {
21 parent::__construct($data, $args);
22
23 wp_register_style('fullcalendar', EPGC_ASSET_URL . 'lib/fullcalendar4/core/main.min.css', null, EMBEDPRESS_VERSION);
24 wp_register_style('fullcalendar_daygrid', EPGC_ASSET_URL . 'lib/fullcalendar4/daygrid/main.min.css', ['fullcalendar'], EMBEDPRESS_VERSION);
25 wp_register_style('fullcalendar_timegrid', EPGC_ASSET_URL . 'lib/fullcalendar4/timegrid/main.min.css', ['fullcalendar_daygrid'], EMBEDPRESS_VERSION);
26 wp_register_style('fullcalendar_list', EPGC_ASSET_URL . 'lib/fullcalendar4/list/main.min.css', ['fullcalendar'], EMBEDPRESS_VERSION);
27 wp_register_style('epgc', EPGC_ASSET_URL . 'css/epgc.css', ['fullcalendar_timegrid'], EMBEDPRESS_VERSION);
28 wp_register_style('tippy_light', EPGC_ASSET_URL . 'lib/tippy/light-border.css', null, EMBEDPRESS_VERSION);
29
30 //wp_enqueue_style( 'fullcalendar');
31 //wp_enqueue_style( 'fullcalendar_daygrid');
32 //wp_enqueue_style( 'fullcalendar_timegrid');
33 //wp_enqueue_style( 'fullcalendar_list');
34 //wp_enqueue_style( 'epgc');
35 //wp_enqueue_style( 'tippy_light');
36
37
38 wp_register_script('popper',EPGC_ASSET_URL . 'lib/popper.min.js', null, EMBEDPRESS_VERSION, true);
39 wp_register_script('tippy',EPGC_ASSET_URL . 'lib/tippy/tippy-bundle.umd.min.js', ['popper'], EMBEDPRESS_VERSION, true);
40 wp_register_script('my_moment',EPGC_ASSET_URL . 'lib/moment/moment-with-locales.min.js', null, EMBEDPRESS_VERSION, true);
41 wp_register_script('my_moment_timezone',EPGC_ASSET_URL . 'lib/moment/moment-timezone-with-data.min.js', ['my_moment'], EMBEDPRESS_VERSION, true);
42 wp_register_script('fullcalendar',EPGC_ASSET_URL . 'lib/fullcalendar4/core/main.min.js', ['my_moment_timezone'], EMBEDPRESS_VERSION, true);
43 wp_register_script('fullcalendar_moment',EPGC_ASSET_URL . 'lib/fullcalendar4/moment/main.min.js', ['fullcalendar'], EMBEDPRESS_VERSION, true);
44 wp_register_script('fullcalendar_moment_timezone',EPGC_ASSET_URL . 'lib/fullcalendar4/moment-timezone/main.min.js', ['fullcalendar_moment'], EMBEDPRESS_VERSION, true);
45 wp_register_script('fullcalendar_daygrid',EPGC_ASSET_URL . 'lib/fullcalendar4/daygrid/main.min.js', ['fullcalendar'], EMBEDPRESS_VERSION, true);
46 wp_register_script('fullcalendar_timegrid',EPGC_ASSET_URL . 'lib/fullcalendar4/timegrid/main.min.js', ['fullcalendar_daygrid'], EMBEDPRESS_VERSION, true);
47 wp_register_script('fullcalendar_list',EPGC_ASSET_URL . 'lib/fullcalendar4/list/main.min.js', ['fullcalendar'], EMBEDPRESS_VERSION, true);
48 wp_register_script('fullcalendar_locales',EPGC_ASSET_URL . 'lib/fullcalendar4/core/locales-all.min.js',['fullcalendar'], EMBEDPRESS_VERSION, true);
49 wp_register_script('epgc', EPGC_ASSET_URL . 'js/main.js',['fullcalendar'], EMBEDPRESS_VERSION, true);
50
51 //wp_enqueue_script('popper');
52 //wp_enqueue_script('my_moment');
53 //wp_enqueue_script('my_moment_timezone');
54 //wp_enqueue_script('fullcalendar');
55 //wp_enqueue_script('fullcalendar_moment');
56 //wp_enqueue_script('fullcalendar_moment_timezone');
57 //wp_enqueue_script('fullcalendar_daygrid');
58 //wp_enqueue_script('fullcalendar_timegrid');
59 //wp_enqueue_script('fullcalendar_list');
60 //wp_enqueue_script('fullcalendar_locales');
61 //wp_enqueue_script('epgc');
62
63 $nonce = wp_create_nonce('epgc_nonce');
64 wp_localize_script('epgc', 'epgc_object', [
65 'ajax_url' => admin_url('admin-ajax.php'),
66 'nonce' => $nonce,
67 'trans' => [
68 'all_day' => __('All day', 'embedpress'),
69 'created_by' => __('Created by', 'embedpress'),
70 'go_to_event' => __('Go to event', 'embedpress'),
71 'unknown_error' => __('Unknown error', 'embedpress'),
72 'request_error' => __('Request error', 'embedpress'),
73 'loading' => __('Loading', 'embedpress')
74 ]
75 ]);
76 }
77 public function get_name()
78 {
79 return 'embedpress_calendar';
80 }
81
82 public function get_title()
83 {
84 return esc_html__( 'EmbedPress Google Calendar', 'embedpress' );
85 }
86
87 public function get_categories()
88 {
89 return ['embedpress'];
90 }
91
92 public function get_custom_help_url()
93 {
94 return 'https://embedpress.com/docs/embed-google-calendar-in-wordpress/';
95 }
96
97 public function get_icon()
98 {
99 return 'eicon-calendar';
100 }
101
102 public function get_script_depends() {
103 return ['popper','tippy', 'my_moment', 'my_moment_timezone', 'fullcalendar', 'fullcalendar_moment', 'fullcalendar_moment_timezone', 'fullcalendar_daygrid', 'fullcalendar_timegrid', 'fullcalendar_list', 'fullcalendar_locales', 'epgc'];
104 }
105
106 public function get_style_depends() {
107 return ['fullcalendar', 'fullcalendar_daygrid', 'fullcalendar_list','epgc', 'tippy_light'];
108 }
109
110 /**
111 * Get widget keywords.
112 *
113 * Retrieve the list of keywords the widget belongs to.
114 *
115 * @return array Widget keywords.
116 * @since 2.5.5
117 * @access public
118 *
119 */
120 public function get_keywords()
121 {
122 return ['embedpress', 'calendar', 'google', 'google calendar', 'google-calendar', 'ics', 'event', 'embedpress calendar'];
123 }
124
125 protected function _register_controls()
126 {
127 $this->pro_class = is_embedpress_pro_active() ? '': 'embedpress-pro-control';
128 $this->pro_text = is_embedpress_pro_active() ? '': '<sup class="embedpress-pro-label" style="color:red">'.__('Pro', 'embedpress').'</sup>';
129 /**
130 * EmbedPress Content Settings
131 */
132 $this->start_controls_section(
133 'embedpress_calendar_content_settings',
134 [
135 'label' => esc_html__( 'Content Settings', 'embedpress' ),
136 ]
137 );
138
139 $this->add_control(
140 'embedpress_calendar_type',
141 [
142 'label' => __( 'Calendar Type', 'embedpress' ),
143 'type' => Controls_Manager::SELECT,
144 'default' => 'public',
145 'options' => [
146 'private' => __( 'Private', 'embedpress' ),
147 'public' => __( 'Public', 'embedpress' )
148 ],
149 ]
150 );
151
152
153 $this->add_control(
154 'embedpress_public_cal_link',
155 [
156
157 'label' => __( 'Public Calendar Link', 'embedpress' ),
158 'type' => Controls_Manager::TEXT,
159 'dynamic' => [
160 'active' => true,
161 ],
162 'placeholder' => __( 'Enter public calendar link', 'embedpress' ),
163 'label_block' => true,
164 'condition' => [
165 'embedpress_calendar_type' => 'public'
166 ],
167
168 ]
169 );
170
171
172
173 $this->add_responsive_control(
174 'embedpress_elementor_calendar_width',
175 [
176 'label' => __( 'Width', 'embedpress' ),
177 'type' => Controls_Manager::SLIDER,
178 'separator' => 'before',
179 'default' => [
180 'unit' => 'px',
181 'size' => 600,
182 ],
183 'range' => [
184 'px' => [
185 'min' => 6,
186 'max' => 1200,
187 ],
188 ],
189 'selectors' => [
190 '{{WRAPPER}} .embedpress-calendar-embed iframe' => 'width: {{SIZE}}{{UNIT}} !important; max-width: 100%',
191 ],
192 'render_type' => 'template',
193 ]
194 );
195
196 $this->add_responsive_control(
197 'embedpress_elementor_calendar_height',
198 [
199 'label' => __( 'Height', 'embedpress' ),
200 'type' => Controls_Manager::SLIDER,
201 'default' => [
202 'unit' => 'px',
203 'size' => 600,
204 ],
205 'range' => [
206 'px' => [
207 'min' => 6,
208 'max' => 1000,
209 ],
210 ],
211 'selectors' => [
212 '{{WRAPPER}} .embedpress-calendar-embed iframe' => 'height: {{SIZE}}{{UNIT}};',
213 ],
214 'render_type' => 'template',
215
216 ]
217 );
218
219 $this->add_responsive_control(
220 'embedpress_elementor_calendar_align',
221 [
222 'label' => __( 'Alignment', 'embedpress' ),
223 'type' => Controls_Manager::CHOOSE,
224 'options' => [
225 'left' => [
226 'title' => __( 'Left', 'embedpress' ),
227 'icon' => 'eicon-text-align-left',
228 ],
229 'center' => [
230 'title' => __( 'Center', 'embedpress' ),
231 'icon' => 'eicon-text-align-center',
232 ],
233 'right' => [
234 'title' => __( 'Right', 'embedpress' ),
235 'icon' => 'eicon-text-align-right',
236 ]
237 ],
238 'prefix_class' => 'elementor%s-align-',
239 'default' => '',
240 ]
241 );
242
243 $this->add_control(
244 'embedpress_calendar_powered_by',
245 [
246 'label' => __( 'Powered By', 'embedpress' ),
247 'type' => Controls_Manager::SWITCHER,
248 'label_on' => __( 'Show', 'embedpress' ),
249 'label_off' => __( 'Hide', 'embedpress' ),
250 'return_value' => 'yes',
251 'default' => apply_filters( 'embedpress_calendar_powered_by_control', 'yes' ),
252 ]
253 );
254
255 $this->init_branding_controls( 'calendar');
256
257 $this->end_controls_section();
258
259 if (! is_embedpress_pro_active()) {
260 $this->start_controls_section(
261 'embedpress_pro_section',
262 [
263 'label' => __('Go Premium for More Features', 'embedpress'),
264 ]
265 );
266
267 $this->add_control(
268 'embedpress_pro_cta',
269 [
270 'label' => __('Unlock more possibilities', 'embedpress'),
271 'type' => Controls_Manager::CHOOSE,
272 'options' => [
273 '1' => [
274 'title' => '',
275 'icon' => 'eicon-lock',
276 ],
277 ],
278 'default' => '1',
279 'description' => '<span class="pro-feature"> Get the <a href="https://wpdeveloper.com/in/upgrade-embedpress" target="_blank">Pro version</a> for more provider support and customization options.</span>',
280 ]
281 );
282
283 $this->end_controls_section();
284 }
285 }
286
287
288 protected function render()
289 {
290 $settings = $this->get_settings();
291 $id = 'embedpress-calendar-' . $this->get_id();
292 $dimension = "width: {$settings['embedpress_elementor_calendar_width']['size']}px;height: {$settings['embedpress_elementor_calendar_height']['size']}px";
293
294 $this->add_render_attribute( 'embedpress-calendar-render', [
295 'class' => ['embedpress-embed-calendar-calendar', $id],
296 'data-emid' => $id
297 ] );
298 $this->add_render_attribute( 'embedpress-calendar', [
299 'class' => ['embedpress-calendar-embed', 'ep-cal-'.md5( $id), 'ose-calendar']
300 ] );
301 $is_private_cal = (!empty( $settings['embedpress_calendar_type']) && 'private' === $settings['embedpress_calendar_type']);
302 $is_editor_view = Plugin::$instance->editor->is_edit_mode();
303 ?>
304 <div <?php echo $this->get_render_attribute_string( 'embedpress-calendar' ); ?> style="<?php echo esc_attr( $dimension); ?>; max-width:100%; display: inline-block">
305
306
307 <?php
308 do_action( 'embedpress_calendar_after_embed', $settings, $id, $this);
309 ?>
310 <div <?php echo $this->get_render_attribute_string( 'embedpress-calendar-render' ); ?>>
311 <?php if ( !empty( $settings['embedpress_public_cal_link']) && !empty( $settings['embedpress_calendar_type']) && 'public' === $settings['embedpress_calendar_type'] ) {
312 ?>
313 <iframe style="<?php echo esc_attr( $dimension); ?>; max-width:100%; display: inline-block" src="<?php echo esc_attr( $settings['embedpress_public_cal_link']); ?>"
314 frameborder="0"></iframe>
315 <?php
316 } else {
317 if ( $is_editor_view && empty( $settings['embedpress_public_cal_link']) && !$is_private_cal ) {
318 ?>
319 <p><?php esc_html_e( 'Please paste your public google calendar link.', 'embedpress'); ?></p>
320 <?php
321 }
322 // handle notice display
323 if ( $is_editor_view && $is_private_cal ) {
324 if ( !is_embedpress_pro_active()) {
325 ?>
326 <p><?php esc_html_e( 'You need EmbedPress Pro to display Private Calendar Data.', 'embedpress'); ?></p>
327 <?php
328 }else{
329 ?>
330 <p><?php esc_html_e( 'Private Calendar Data will be displayed in the frontend', 'embedpress'); ?></p>
331 <?php
332 }
333 }else{
334 // handle printing private calendar data
335 if ( is_embedpress_pro_active() ) {
336 echo Embedpress_Google_Helper::shortcode();
337 }
338 }
339
340
341 }
342 ?>
343 </div>
344 <?php
345 if ( $settings[ 'embedpress_calendar_powered_by' ] === 'yes' ) {
346 printf( '<p class="embedpress-el-powered">%s</p>', __( 'Powered By EmbedPress', 'embedpress' ) );
347 }
348
349 ?>
350 </div>
351
352 <?php
353
354 }
355
356 }
357