PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more / 3.9.10
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more v3.9.10
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 2 years ago Embedpress_Document.php 2 years ago Embedpress_Elementor.php 2 years ago Embedpress_Pdf.php 2 years ago
Embedpress_Calendar.php
340 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 $this->pro_class = is_embedpress_pro_active() ? '': 'embedpress-pro-control not-active';
129 $this->pro_text = is_embedpress_pro_active() ? '': '<sup class="embedpress-pro-label" style="color:red">'.__('Pro', 'embedpress').'</sup>';
130 /**
131 * EmbedPress Content Settings
132 */
133 $this->start_controls_section(
134 'embedpress_calendar_content_settings',
135 [
136 'label' => esc_html__( 'Content Settings', 'embedpress' ),
137 ]
138 );
139
140 $this->add_control(
141 'embedpress_calendar_type',
142 [
143 'label' => __( 'Calendar Type', 'embedpress' ),
144 'type' => Controls_Manager::SELECT,
145 'default' => 'public',
146 'options' => [
147 'private' => __( 'Private', 'embedpress' ),
148 'public' => __( 'Public', 'embedpress' )
149 ],
150 ]
151 );
152
153
154 $this->add_control(
155 'embedpress_public_cal_link',
156 [
157
158 'label' => __( 'Public Calendar Link', 'embedpress' ),
159 'type' => Controls_Manager::TEXT,
160 'dynamic' => [
161 'active' => true,
162 ],
163 'placeholder' => __( 'Enter public calendar link', 'embedpress' ),
164 'label_block' => true,
165 'condition' => [
166 'embedpress_calendar_type' => 'public'
167 ],
168
169 ]
170 );
171
172
173
174 $this->add_responsive_control(
175 'embedpress_elementor_calendar_width',
176 [
177 'label' => __( 'Width', 'embedpress' ),
178 'type' => Controls_Manager::SLIDER,
179 'separator' => 'before',
180 'default' => [
181 'unit' => 'px',
182 'size' => 600,
183 ],
184 'range' => [
185 'px' => [
186 'min' => 6,
187 'max' => 1200,
188 ],
189 ],
190 'selectors' => [
191 '{{WRAPPER}} .embedpress-calendar-embed iframe' => 'width: {{SIZE}}{{UNIT}} !important; max-width: 100%',
192 ],
193 'render_type' => 'template',
194 ]
195 );
196
197 $this->add_responsive_control(
198 'embedpress_elementor_calendar_height',
199 [
200 'label' => __( 'Height', 'embedpress' ),
201 'type' => Controls_Manager::SLIDER,
202 'default' => [
203 'unit' => 'px',
204 'size' => 600,
205 ],
206 'range' => [
207 'px' => [
208 'min' => 6,
209 'max' => 1000,
210 ],
211 ],
212 'selectors' => [
213 '{{WRAPPER}} .embedpress-calendar-embed iframe' => 'height: {{SIZE}}{{UNIT}};',
214 ],
215 'render_type' => 'template',
216
217 ]
218 );
219
220 $this->add_responsive_control(
221 'embedpress_elementor_calendar_align',
222 [
223 'label' => __( 'Alignment', 'embedpress' ),
224 'type' => Controls_Manager::CHOOSE,
225 'options' => [
226 'left' => [
227 'title' => __( 'Left', 'embedpress' ),
228 'icon' => 'eicon-text-align-left',
229 ],
230 'center' => [
231 'title' => __( 'Center', 'embedpress' ),
232 'icon' => 'eicon-text-align-center',
233 ],
234 'right' => [
235 'title' => __( 'Right', 'embedpress' ),
236 'icon' => 'eicon-text-align-right',
237 ]
238 ],
239 'prefix_class' => 'elementor%s-align-',
240 'default' => '',
241 ]
242 );
243
244 $this->add_control(
245 'embedpress_calendar_powered_by',
246 [
247 'label' => __( 'Powered By', 'embedpress' ),
248 'type' => Controls_Manager::SWITCHER,
249 'label_on' => __( 'Show', 'embedpress' ),
250 'label_off' => __( 'Hide', 'embedpress' ),
251 'return_value' => 'yes',
252 'default' => apply_filters( 'embedpress_calendar_powered_by_control', 'yes' ),
253 ]
254 );
255
256 $this->init_branding_controls( 'calendar');
257
258 $this->end_controls_section();
259
260 if (! is_embedpress_pro_active()) {
261 $this->start_controls_section(
262 'embedpress_pro_section',
263 [
264 'label' => __('Go Premium for More Features', 'embedpress'),
265 ]
266 );
267
268 $this->add_control(
269 'embedpress_pro_cta',
270 [
271 'label' => __('Unlock more possibilities', 'embedpress'),
272 'type' => Controls_Manager::CHOOSE,
273 'options' => [
274 '1' => [
275 'title' => '',
276 'icon' => 'eicon-lock',
277 ],
278 ],
279 'default' => '1',
280 '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>',
281 ]
282 );
283
284 $this->end_controls_section();
285 }
286 }
287
288
289 protected function render()
290 {
291 $settings = $this->get_settings();
292 $id = 'embedpress-calendar-' . $this->get_id();
293 $dimension = "width: " . esc_attr($settings['embedpress_elementor_calendar_width']['size']) . "px; height: " . esc_attr($settings['embedpress_elementor_calendar_height']['size']) . "px";
294
295 $this->add_render_attribute('embedpress-calendar-render', [
296 'class' => ['embedpress-embed-calendar-calendar', $id],
297 'data-emid' => $id
298 ]);
299 $this->add_render_attribute('embedpress-calendar', [
300 'class' => ['embedpress-calendar-embed', 'ep-cal-' . md5($id), 'ose-calendar']
301 ]);
302 $is_private_cal = (!empty($settings['embedpress_calendar_type']) && 'private' === $settings['embedpress_calendar_type']);
303 $is_editor_view = Plugin::$instance->editor->is_edit_mode();
304 ?>
305 <div <?php echo $this->get_render_attribute_string('embedpress-calendar'); ?> style="<?php echo esc_attr($dimension); ?>; max-width:100%; display: inline-block">
306 <?php
307 do_action('embedpress_calendar_after_embed', $settings, $id, $this);
308 ?>
309 <div <?php echo $this->get_render_attribute_string('embedpress-calendar-render'); ?>>
310 <?php if (!empty($settings['embedpress_public_cal_link']) && !empty($settings['embedpress_calendar_type']) && 'public' === $settings['embedpress_calendar_type']) { ?>
311 <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>
312 <?php } else {
313 if ($is_editor_view && empty($settings['embedpress_public_cal_link']) && !$is_private_cal) { ?>
314 <p><?php esc_html_e('Please paste your public google calendar link.', 'embedpress'); ?></p>
315 <?php }
316 if ($is_editor_view && $is_private_cal) {
317 if (!is_embedpress_pro_active()) { ?>
318 <p><?php esc_html_e('You need EmbedPress Pro to display Private Calendar Data.', 'embedpress'); ?></p>
319 <?php } else { ?>
320 <p><?php esc_html_e('Private Calendar Data will be displayed in the frontend', 'embedpress'); ?></p>
321 <?php }
322 } else {
323 if (is_embedpress_pro_active()) {
324 echo Embedpress_Google_Helper::shortcode();
325 }
326 }
327 } ?>
328 </div>
329 <?php
330 if ($settings['embedpress_calendar_powered_by'] === 'yes') {
331 printf('<p class="embedpress-el-powered">%s</p>', esc_html__('Powered By EmbedPress', 'embedpress'));
332 }
333 ?>
334 </div>
335 <?php
336 }
337
338
339 }
340