PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents / 4.4.2
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents v4.4.2
4.6.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 / Embedpress_Elementor_Integration.php
embedpress / EmbedPress / Elementor Last commit date
Widgets 9 months ago Elementor_Upsale.php 1 year ago Embedpress_Elementor_Integration.php 10 months ago
Embedpress_Elementor_Integration.php
823 lines
1 <?php
2
3 namespace EmbedPress\Elementor;
4
5
6 (defined('ABSPATH')) or die("No direct script access allowed.");
7
8 use EmbedPress\Compatibility;
9 use EmbedPress\Elementor\Widgets\Embedpress_Calendar;
10 use EmbedPress\Elementor\Widgets\Embedpress_Document;
11 use EmbedPress\Elementor\Widgets\Embedpress_Elementor;
12 use EmbedPress\Elementor\Widgets\Embedpress_Pdf;
13 use EmbedPress\Includes\Classes\Helper;
14
15 class Embedpress_Elementor_Integration
16 {
17
18 /**
19 * @since 2.4.2
20 */
21 public function init()
22 {
23 $elements = (array) get_option(EMBEDPRESS_PLG_NAME . ":elements", []);
24 $e_blocks = isset($elements['elementor']) ? (array) $elements['elementor'] : [];
25 if (!empty($e_blocks['embedpress']) || !empty($e_blocks['embedpress-document']) || !empty($e_blocks['embedpress-pdf'])) {
26 // Asset enqueuing now handled by AssetManager
27 add_action('elementor/elements/categories_registered', array($this, 'register_widget_categories'));
28 add_action('elementor/widgets/widgets_registered', array($this, 'register_widget'));
29 add_action('elementor/widgets/register', array($this, 'register_widget'));
30 add_filter('oembed_providers', [$this, 'addOEmbedProviders']);
31
32 if (Helper::get_options_value('turn_off_rating_help') || !is_plugin_active('embedpress-pro/embedpress-pro.php')) {
33 add_action('elementor/editor/after_enqueue_scripts', [$this, 'elementor_upsale']);
34 }
35 }
36 }
37
38 /**
39 * Add elementor category
40 *
41 * @since 2.4.3
42 */
43 public function register_widget_categories($elements_manager)
44 {
45 $elements_manager->add_category(
46 'embedpress',
47 [
48 'title' => __('EmbedPress', 'embedpress'),
49 'icon' => 'font',
50 ],
51 1
52 );
53 }
54
55 /**
56 * Load elementor widget
57 *
58 * @param $widgets_manager
59 * @throws \Exception
60 * @since 2.4.2
61 */
62 public function register_widget($widgets_manager)
63 {
64 if (
65 did_action('elementor/widgets/widgets_registered') &&
66 did_action('elementor/widgets/register') // doing action
67 ) {
68 return;
69 }
70
71 $elements = (array) get_option(EMBEDPRESS_PLG_NAME . ":elements", []);
72 $e_blocks = isset($elements['elementor']) ? (array) $elements['elementor'] : [];
73
74 if (method_exists($widgets_manager, 'register')) {
75 if (!empty($e_blocks['embedpress'])) {
76 $widgets_manager->register(new Embedpress_Elementor);
77 }
78 if (!empty($e_blocks['embedpress-document'])) {
79 $widgets_manager->register(new Embedpress_Document);
80 }
81
82 if (!empty($e_blocks['embedpress-pdf'])) {
83 $widgets_manager->register(new Embedpress_Pdf);
84 }
85 if (!empty($e_blocks['embedpress-calendar'])) {
86 $widgets_manager->register(new Embedpress_Calendar);
87 }
88 } else {
89 if (!empty($e_blocks['embedpress'])) {
90 $widgets_manager->register_widget_type(new Embedpress_Elementor);
91 }
92 if (!empty($e_blocks['embedpress-document'])) {
93 $widgets_manager->register_widget_type(new Embedpress_Document);
94 }
95
96 if (!empty($e_blocks['embedpress-pdf'])) {
97 $widgets_manager->register_widget_type(new Embedpress_Pdf);
98 }
99 if (!empty($e_blocks['embedpress-calendar'])) {
100 $widgets_manager->register_widget_type(new Embedpress_Calendar);
101 }
102 }
103 }
104
105 /**
106 * Enqueue elementor assets
107 * @since 2.4.3
108 * Now handled by AssetManager
109 */
110 public function embedpress_enqueue_style()
111 {
112 // Assets are now handled by the centralized AssetManager
113 // This method is kept for backward compatibility
114 }
115
116 public function editor_enqueue_style()
117 {
118 // Assets are now handled by the centralized AssetManager
119 // This method is kept for backward compatibility
120 }
121
122 public function editor_enqueue_scripts()
123 { }
124
125 public function addOEmbedProviders($providers)
126 {
127 if (Compatibility::isWordPress5() && !Compatibility::isClassicalEditorActive()) {
128 unset($providers['#https?://(.+\.)?wistia\.com/medias/.+#i'], $providers['#https?://(.+\.)?fast\.wistia\.com/embed/medias/.+#i\.jsonp']);
129 }
130
131 return $providers;
132 }
133
134 public function elementor_upsale()
135 {
136 ?>
137 <style>
138 :root {
139 /* Light Mode Variables */
140 --background-color: #FDFAFF;
141 --text-color: #0C0D0E;
142 --secondary-text-color: #5f6c7f;
143 --description-text-color: #5f6c7f;
144 --border-color: #ECEFF5;
145 --button-bg: #5b4e96;
146 --button-text: #ffffff;
147 --upgrade-bg: linear-gradient(181.32deg, #fffbf8 1.12%, #ffffff 98.95%);
148 --star-color: #b1b8c2;
149 --placeholder-text-color: #5f6c7f;
150 --submit-button-color: #5b4e96;
151 --form-control-backgound: #fff;
152 --upgrade-box-title-color: #1d2939;
153 }
154
155 @media (prefers-color-scheme: light) {
156 :root {
157 /* Light Mode Variables */
158 --background-color: #FDFAFF;
159 --text-color: #0C0D0E;
160 --secondary-text-color: #5f6c7f;
161 --description-text-color: #5f6c7f;
162 --border-color: #ECEFF5;
163 --button-bg: #5b4e96;
164 --button-text: #ffffff;
165 --upgrade-bg: linear-gradient(181.32deg, #fffbf8 1.12%, #ffffff 98.95%);
166 --star-color: #b1b8c2;
167 --placeholder-text-color: #5f6c7f;
168 --submit-button-color: #5b4e96;
169 --form-control-backgound: #fff;
170 --upgrade-box-title-color: #1d2939;
171
172 }
173 }
174
175 @media (prefers-color-scheme: dark) {
176 :root {
177 /* Dark Mode Variables */
178 --background-color: #1A1C1F;
179 --text-color: #ffffff;
180 --secondary-text-color: #CBCBD0;
181 --description-text-color: #fff;
182 --border-color: #272A2F;
183 --button-bg: #4b3293;
184 --button-text: #ffffff;
185 --upgrade-bg: linear-gradient(181.32deg, #1F2023 1.12%, #18191B 98.95%);
186 --star-color: #676D76;
187 --placeholder-text-color: #CBCBD0;
188 --submit-button-color: #fff;
189 --form-control-backgound: #1F2124;
190 --upgrade-box-title-color: #fff;
191
192
193 }
194 }
195
196 .elementor-panel .plugin-rating {
197 border-top: 2px solid #e6e8ea;
198 }
199
200 /* Applying Variables */
201 .elementor-panel .rating-chat-content {
202 background-color: var(--background-color);
203 border: 0.6px solid var(--border-color);
204 color: var(--text-color);
205 }
206
207 .elementor-panel .plugin-rating h4 {
208 color: var(--text-color);
209 }
210
211 .elementor-panel .plugin-rating .chat-button {
212 background-color: var(--button-bg);
213 color: var(--button-text);
214 }
215
216 .elementor-panel .plugin-rating .upgrade-box {
217 background: var(--upgrade-bg);
218 border: 0.6px solid var(--border-color);
219 }
220
221 .elementor-panel p.thank-you-message {
222 color: var(--secondary-text-color);
223 }
224
225 .elementor-panel .plugin-rating .stars .star {
226 color: var(--star-color);
227 }
228
229
230 .elementor-panel .plugin-rating {
231 font-family: system-ui;
232 padding: 15px;
233 padding-top: 0;
234 }
235
236 .elementor-panel .rating-chat-content {
237 border-radius: 4px;
238 border-width: 0.6px;
239 gap: 12px;
240 padding: 15px;
241 position: relative;
242 display: flex;
243 flex-direction: column;
244 overflow: hidden;
245 margin-top: 15px;
246 }
247
248 .rating-chat-content::after {
249 content: "";
250 position: absolute;
251 top: -65px;
252 right: -65px;
253 width: 120px;
254 height: 120px;
255 background: radial-gradient(circle, rgb(121 62 255 / 14%) 20%, transparent 70%);
256 border-radius: 50%;
257 }
258
259
260 /* .rating-chat-content::after{
261 content: '';
262 background: linear-gradient(175.54deg, rgba(81, 241, 255, 0.117) 19.13%, rgba(71, 58, 217, 0.132319) 22.57%, rgba(127, 22, 255, 0.2085) 39.66%, rgba(17, 1, 35, 0.3) 60.19%);
263 transform: rotate(60deg);
264 top: 0;
265 right: 0;
266 z-index: 1212;
267 width: 118.63550843535211px;
268 height: 208.14842708207777px;
269 position: absolute;
270 transform: rotate(60deg);
271 backdrop-filter: blur(20px);
272 } */
273
274
275 .elementor-panel .plugin-rating h4 {
276 font-size: 15px;
277 font-weight: 500;
278 }
279
280 .elementor-panel .plugin-rating .stars {
281 display: flex;
282 gap: 5px;
283 margin-bottom: 10px;
284 color: #FFFFFF;
285 }
286
287 .elementor-panel .plugin-rating .stars .star {
288 cursor: pointer;
289 width: 20px;
290 height: 20px;
291 }
292
293 .elementor-panel .plugin-rating .thank-you-msg-container {
294 padding: 15px;
295 border-radius: 8px;
296 text-align: left;
297 background: linear-gradient(181.32deg, #f5f3ff 1.12%, #ffffff 98.95%);
298 border: 0.6px solid #f4efec;
299 position: relative;
300 }
301
302 .elementor-panel .plugin-rating .thank-you-msg-container span.close-icon {
303 position: absolute;
304 top: 8px;
305 right: 8px;
306 }
307
308 .elementor-panel .plugin-rating .thank-you-msg-container span.close-icon svg {
309 height: 12px;
310 width: 12px;
311 cursor: pointer;
312 }
313
314 /* .elementor-panel .plugin-rating .thankyou-msg-container span.close-icon {
315 position: absolute;
316 top: 8px;
317 right: 8px;
318 } */
319
320 .elementor-panel .plugin-rating .thank-you-msg-container p.thank-you-message {
321 font-weight: 400;
322 color: #232c39;
323 margin-bottom: 8px;
324 font-size: 12px;
325 }
326
327 .elementor-panel .plugin-rating .thank-you-msg-container span.undo-review {
328 color: #5b4e96;
329 font-weight: 400;
330 text-decoration: none;
331 cursor: pointer !important;
332 }
333
334 .elementor-panel .plugin-rating .chat-button {
335 color: white;
336 border: none;
337 padding: 10px 20px;
338 border-radius: 5px;
339 cursor: pointer;
340 font-size: 14px;
341 display: flex;
342 align-items: center;
343 justify-content: center;
344 gap: 5px;
345 font-weight: 400;
346 width: 100%;
347 }
348
349 .elementor-panel .plugin-rating .chat-button svg {
350 width: 18px;
351 height: 18px;
352 }
353
354 .elementor-panel .plugin-rating .chat-button:hover {
355 background-color: #4b3293;
356 }
357
358 .elementor-panel .plugin-rating .upgrade-box {
359 padding: 15px;
360 margin-top: 15px;
361 border-radius: 8px;
362 text-align: left;
363 }
364
365 .elementor-panel .plugin-rating .upgrade-box h5 {
366 font-size: 14px;
367 margin-top: 0;
368 margin-bottom: 10px;
369 color: #1d2939;
370 color: #fff;
371 color: var(--upgrade-box-title-color);
372 font-weight: 600;
373 }
374
375 .elementor-panel .plugin-rating .upgrade-box p {
376 font-size: 12px;
377 color: var(--secondary-text-color);
378 margin-bottom: 12px;
379 font-weight: 400;
380 line-height: 1.6;
381 }
382
383 .elementor-panel .plugin-rating .upgrade-box .upgrade-link {
384 color: #ec6e00;
385 font-weight: 400;
386 text-decoration: none;
387 }
388
389 .elementor-panel .plugin-rating .upgrade-box .upgrade-link:hover {
390 text-decoration: underline;
391 }
392
393
394
395 .elementor-panel .thankyou-msg-container,
396 .elementor-panel .feedback-submit-container {
397 border-radius: 8px;
398 text-align: left;
399 position: relative;
400 margin-bottom: 10px;
401 }
402
403 .elementor-panel .thankyou-msg-container textarea.form-control,
404 .elementor-panel .feedback-submit-container textarea.form-control {
405 width: 100%;
406 background: var(--form-control-backgound);
407 outline: 1px solid var(--border-color);
408 margin-bottom: 10px;
409 border: none;
410 font-weight: 400;
411 font-size: 14px;
412 line-height: 1.6;
413 font-family: system-ui;
414 padding: 8px 8px;
415 }
416
417 .elementor-panel .thankyou-msg-container textarea.form-control::placeholder,
418 .elementor-panel .feedback-submit-container textarea.form-control::placeholder {
419 font-weight: 400;
420 font-size: 14px;
421 line-height: 1.6;
422 color: var(--placeholder-text-color);
423 font-family: system-ui;
424 }
425
426 .elementor-panel .thankyou-msg-container textarea:focus,
427 .elementor-panel .feedback-submit-container textarea:focus {
428 outline-color: #5b4e96;
429 box-shadow: none !important;
430 outline: 1px solid #5b4e96;
431 }
432
433 .elementor-panel .submit-button,
434 .elementor-panel .rating-button {
435 border-radius: 4px;
436 border-width: 1px;
437 width: 100%;
438 border: 1px solid #5b4e96;
439 color: var(--submit-button-color);
440 background: transparent;
441 cursor: pointer;
442 display: flex;
443 align-items: center;
444 justify-content: center;
445 padding: 12px 8px;
446
447 }
448
449 .elementor-panel .submit-button svg,
450 .elementor-panel .rating-button svg {
451 height: 18px;
452 width: 18px;
453 }
454
455 .elementor-panel .help-message {
456 font-weight: 500;
457 font-size: 15px;
458 line-height: 1.6;
459 letter-spacing: 0%;
460 margin-bottom: 10px;
461 margin-top: 0;
462 color: var(--text-color);
463 }
464
465 .elementor-panel p.form-description {
466 font-size: 14px;
467 margin-bottom: 12px;
468 font-family: system-ui;
469 color: var(--description-text-color);
470 line-height: 1.4;
471 }
472
473 .elementor-panel span.close-icon {
474 position: absolute;
475 top: 8px;
476 right: 8px;
477 }
478
479 .elementor-panel span.close-icon svg {
480 height: 12px;
481 width: 12px;
482 cursor: pointer;
483 }
484
485 .elementor-panel span.undo-review {
486 color: #5b4e96;
487 font-weight: 400;
488 text-decoration: none;
489 cursor: pointer;
490 }
491
492 .elementor-panel p.thank-you-message {
493 font-weight: 400;
494 color: var(--secondary-text-color);
495 font-size: 14px;
496 line-height: 1.6;
497 }
498
499 .elementor-panel .chat-button {
500 background-color: #5b4e96;
501 color: white;
502 border: none;
503 padding: 10px 20px;
504 border-radius: 5px;
505 cursor: pointer;
506 font-size: 12px;
507 display: flex;
508 align-items: center;
509 justify-content: center;
510 gap: 5px;
511 font-weight: 500;
512 width: 100%;
513 }
514
515 .elementor-panel .chat-button {
516 background-color: transparent;
517 border: 1px solid #5B4E96;
518 color: #fff;
519 }
520
521 .elementor-panel .rating-button {
522 background-color: transparent;
523 border: 1px solid #5B4E96;
524 color: var(--submit-button-color);
525 margin-top: 20px;
526 }
527
528 .elementor-panel .chat-button svg {
529 width: 18px;
530 height: 18px;
531 }
532
533 .elementor-panel .chat-button:hover {
534 background-color: #4b3293;
535 }
536 </style>
537
538 <script>
539 document.addEventListener("DOMContentLoaded", function() {
540 if (typeof jQuery === 'undefined') {
541 console.error("❌ jQuery is not loaded!");
542 return;
543 }
544
545 jQuery(document).ready(function($) {
546 console.log("�
547 jQuery is loaded and ready!");
548
549 let message = ""; // Store the thank-you message state
550 let rating = 0; // Store rating state
551 let showThank = localStorage.getItem("feedbackSubmitted") ? 1 : 0; // Store rating state
552 let targetNode = null; // Store reference to the Elementor controls section
553
554 const currentUser = <?php echo json_encode(wp_get_current_user()->data); ?>;
555 const isProActive = <?php echo json_encode(is_plugin_active('embedpress-pro/embedpress-pro.php')); ?>;
556 const isEmbedpressFeedbackSubmited = <?php echo json_encode(get_option('embedpress_feedback_submited')); ?>;
557
558 const turnOffRattingHelp = <?php echo json_encode(Helper::get_options_value('turn_off_rating_help')); ?>;
559
560 function handleRating(selectedRating) {
561
562 rating = selectedRating;
563
564 $(".star").each(function() {
565 const starValue = $(this).data("rating");
566 $(this).attr("fill", starValue <= rating ? "#FFD700" : "#B1B8C2"); // Gold for selected, Grey for unselected
567 });
568
569 if (rating == 5) {
570 sendFiveStarRating();
571 }
572
573 // Delay message update by 2 seconds
574 setTimeout(() => {
575 if (rating < 5) {
576 message = "Please describe your issue in details.";
577 } else {
578 message = `Thanks for rating ${rating} stars!`;
579 }
580 renderUpsellSection();
581 }, 500);
582
583 }
584
585 function setMessage(value) {
586 message = value;
587 renderUpsellSection();
588 }
589
590 function handleSubmit(event) {
591 event.preventDefault();
592
593 const submitButton = event.target.querySelector('.submit-button');
594 submitButton.disabled = true; // Disable the button
595 submitButton.textContent = 'Sending...'; // Update button text
596
597 const formData = new FormData(event.target);
598 const data = {
599 name: currentUser.display_name,
600 email: currentUser.user_email,
601 rating: rating,
602 message: formData.get('message')
603 };
604
605 fetch('/wp-json/embedpress/v1/send-feedback', { // Updated API endpoint
606 method: 'POST',
607 headers: {
608 'Content-Type': 'application/json'
609 },
610 body: JSON.stringify(data)
611 })
612 .then(response => response.json())
613 .then(data => {
614
615 submitButton.disabled = false; // Re-enable the button
616 submitButton.textContent = 'Send'; // Reset button text
617 showThank = 1;
618
619 localStorage.setItem("feedbackSubmitted", "true");
620 renderUpsellSection();
621
622 setTimeout(() => {
623 $(".thankyou-msg-container").fadeOut(500, function() {
624 $(this).remove();
625 });
626 }, 3000); // Disappear after 3 seconds
627
628 })
629 .catch(error => {
630 console.error('Error:', error);
631 alert('Failed to send email.');
632 });
633 };
634
635 function sendFiveStarRating() {
636 const data = {
637 name: currentUser.display_name,
638 email: currentUser.user_email,
639 rating: '5',
640 message: ''
641 };
642
643 fetch('/wp-json/embedpress/v1/send-feedback', { // Updated API endpoint
644 method: 'POST',
645 headers: {
646 'Content-Type': 'application/json'
647 },
648 body: JSON.stringify(data)
649 })
650 .then(response => response.json())
651 .then(data => {
652 console.log('Success:', data);
653 localStorage.setItem("feedbackSubmitted", "true");
654 renderUpsellSection();
655
656 })
657 .catch(error => {
658 console.error('Error:', error);
659 alert('Failed to send email.');
660 });
661 }
662
663 function renderUpsellSection() {
664 if (!targetNode) return;
665
666 $(".plugin-rating").remove(); // Remove previous upsell section
667
668
669 const thnkMsgHeading = rating < 5 ? 'We appreciate it!' : 'We’re glad that you liked us! 😍';
670 const thnkMsgDsc = rating < 5 ? 'A heartfelt gratitude for managing the time to share your thoughts with us' : 'If you don’t mind, could you take 30 seconds to review us on WordPress? Your feedback will help us improve and grow. Thank you in advance! 🙏';
671
672 let upsellHtml = `
673 <div class="plugin-rating">
674 ${turnOffRattingHelp ? `
675 <div class="rating-chat-content">
676 ${!isEmbedpressFeedbackSubmited ? `
677 ${((rating && rating == 5) || showThank) ? `
678 <div class="thankyou-msg-container">
679
680 <h5 class="help-message">${thnkMsgHeading}</h5>
681 <p class="thank-you-message">${thnkMsgDsc}</p>
682
683 ${rating == 5 ? `
684 <button class="rating-button">
685 Rate the Plugin
686 <svg width="10" height="10" viewBox="0 0 10 10" fill="none" xmlns="http://www.w3.org/2000/svg">
687 <path d="M3.75 2.083 6.25 5l-2.5 2.917" stroke="#5B4E96" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round" />
688 </svg>
689 </button>
690 ` : ''}
691 </div>
692 ` : rating && rating < 5 ? `
693 <div class="feedback-submit-container">
694 <h5 class="help-message">Help us make it better!</h5>
695 <p class="form-description">Please share what went wrong with The EmbedPress so that we can improve further*</p>
696 <form id="feedback-form">
697 <div class="form-group">
698 <textarea name="message" placeholder="Describe your issue in details" type="text" rows="4" class="form-control" required></textarea>
699 </div>
700 <div class="form-group">
701 <button class="submit-button" type="submit">Send</button>
702 </div>
703 </form>
704 </div>
705 ` : `
706 <h4>Rate EmbedPress</h4>
707 <div class="stars">
708 ${[1, 2, 3, 4, 5].map(i => `
709 <svg class="star" data-rating="${i}" width="20" height="18.667" viewBox="0 0 20 18.667" fill="none" xmlns="http://www.w3.org/2000/svg"
710 style={{ cursor: "pointer", transition: "fill 0.2s ease-in-out" }}>
711 <g clip-path="url(#a)">
712 <path d="m7.3 5.709-4.963.72-.087.017a.777.777 0 0 0-.343 1.309l3.595 3.499-.848 4.943-.009.087a.777.777 0 0 0 1.139.733l4.437-2.333 4.428 2.333.077.036a.777.777 0 0 0 1.053-.855l-.849-4.944 3.596-3.5.061-.067a.777.777 0 0 0-.493-1.259l-4.961-.72-2.218-4.495a.777.777 0 0 0-1.396 0z"/>
713 </g>
714 <defs><clipPath id="a"><path fill="#fff" d="M.888 0h18.667v18.667H.888z"/></clipPath></defs>
715 </svg>
716 `).join('')}
717 </div>
718 `}
719 ` : ''}
720
721 <p style="font-weight: 500">Need help? We're here</p>
722 <a href="https://embedpress.com/?support=chat" target="_blank" class="chat-button">
723 <svg width="13" height="12" viewBox="0 0 13 12" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#a)" fill="#fff"><path d="M7.93.727H1.555C.97.727.5 1.198.5 1.782V6c0 .584.471 1.055 1.055 1.055h.351V8.11c0 .254.263.438.52.31.008-.008.022-.008.029-.015 1.934-1.297 1.5-1.008 1.933-1.294a.35.35 0 0 1 .19-.056H7.93c.583 0 1.054-.47 1.054-1.055V1.782c0-.584-.47-1.055-1.054-1.055M5.117 4.946h-2.86c-.463 0-.465-.703 0-.703h2.86c.464 0 .466.703 0 .703m2.11-1.406h-4.97c-.463 0-.465-.704 0-.704h4.97c.463 0 .465.704 0 .704" /><path d="M11.445 3.54H9.687V6c0 .97-.787 1.758-1.757 1.758H4.684l-.668.443v.612c0 .584.47 1.055 1.054 1.055h3.457l2.018 1.35c.276.153.549-.033.549-.296V9.868h.351c.584 0 1.055-.471 1.055-1.055V4.594c0-.583-.471-1.054-1.055-1.054" /></g><defs><clipPath id="a"><path fill="#fff" d="M.5 0h12v12H.5z" /></clipPath></defs></svg>
724 Let’s Chat
725 </a>
726 </div>` : ''}
727
728 ${!isProActive ? `
729 <div class="upgrade-box">
730 <h5>Want to explore more?</h5>
731 <p>Dive in and discover all the premium features</p>
732 <a href="https://embedpress.com/#pricing" target="_blank" class="upgrade-link">Upgrade to PRO</a>
733 </div>` : ''}
734 </div>
735 `;
736
737 $(upsellHtml).insertAfter(targetNode);
738
739
740
741 let currentRating = 0; // Store the selected rating
742 $(".star").attr("fill", "#FFD700");
743
744 $(".star").on("mouseenter", function() {
745 let hoverRating = $(this).data("rating");
746
747 console.log(hoverRating);
748
749 $(".star").each(function() {
750 $(this).attr("fill", $(this).data("rating") <= hoverRating ? "#FFD700" : "#B1B8C2");
751 });
752 });
753
754 $(".star").on("mouseleave", function() {
755 $(".star").each(function() {
756 $(this).attr("fill", $(this).data("rating") <= currentRating ? "#FFD700" : "#B1B8C2");
757 });
758 });
759
760 $(".star").on("click", function() {
761 currentRating = $(this).data("rating");
762
763 $(".star").each(function() {
764 $(this).attr("fill", $(this).data("rating") <= currentRating ? "#FFD700" : "#B1B8C2");
765 });
766
767 handleRating(currentRating);
768 });
769
770
771
772 $(".rating-button").on("click", function() {
773 window.open('https://wordpress.org/support/plugin/embedpress/reviews/#new-post')
774 });
775
776 $("#feedback-form").on("submit", handleSubmit);
777 }
778
779 function addUpsellSection(node) {
780 if (!node) return;
781
782 targetNode = node; // Store reference to the correct node
783 if (!$(".plugin-rating").length) {
784 console.log("�
785 Elementor Panel Found! Adding Upsell Section...");
786 renderUpsellSection();
787 }
788 }
789
790 // MutationObserver to detect Elementor panel changes
791 const observer = new MutationObserver((mutations) => {
792 mutations.forEach((mutation) => {
793 mutation.addedNodes.forEach((node) => {
794 if ($(node).hasClass("elementor-controls-stack")) {
795 const elementorControls = node.querySelector("#elementor-controls:has(.elementor-control-embedpress_elementor_content_settings, .elementor-control-embedpress_pdf_content_settings, .elementor-control-embedpress_document_content_settings, .elementor-control-embedpress_calendar_content_settings)");
796
797 if (elementorControls) {
798 addUpsellSection(elementorControls);
799 }
800 }
801 });
802 });
803 });
804
805 // Start observing Elementor panel for changes
806 const elementorPanel = document.querySelector(".elementor-panel");
807 if (elementorPanel) {
808 observer.observe(elementorPanel, {
809 childList: true,
810 subtree: true,
811 });
812 console.log("🔍 Observer started on Elementor Panel");
813 } else {
814 console.log("❌ Elementor panel not found, observer not started.");
815 }
816 });
817 });
818 </script>
819
820 <?php
821 }
822 }
823