PluginProbe
Raychat / trunk
Raychat vtrunk
trunk 2.2.0 2.2.1
raychat / templates / script.php

script.php in Raychat trunk, at templates/script.php

63 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if (!defined('ABSPATH')) exit;
4
5 ?>
6
7 <?php if (get_option("version_id") === "version_2") { ?>
8
9 <script type="text/javascript">
10 // �
11 CHANGED: Escaped PHP output to prevent potential script injection
12 window.RAYCHAT_TOKEN = "<?php echo esc_js($widget_id); // �
13 CHANGED ?>";
14
15 (function() {
16 var d = document;
17 var s = d.createElement("script");
18 s.src = "https://widget-react.raychat.io/install/widget.js";
19 s.async = true;
20 d.getElementsByTagName("head")[0].appendChild(s);
21 })();
22 </script>
23
24 <?php } else { ?>
25
26 <script type="text/javascript">
27 !function() {
28 function t() {
29 var t = document.createElement("script");
30 t.type = "text/javascript";
31 t.async = true;
32
33 // �
34 CHANGED: Added better readability and `const` keyword in newer syntax would be better if not supporting legacy browsers
35 var token = localStorage.getItem("rayToken");
36 var srcBase = "https://app.raychat.io/scripts/js/";
37 var widgetId = "<?php echo esc_js($widget_id); // �
38 CHANGED ?>";
39
40 t.src = token
41 ? srcBase + widgetId + "?rid=" + encodeURIComponent(token) + "&href=" + encodeURIComponent(window.location.href) // �
42 CHANGED: encoded href
43 : srcBase + widgetId;
44
45 var e = document.getElementsByTagName("script")[0];
46 e.parentNode.insertBefore(t, e);
47 }
48
49 var e = document, a = window;
50 // �
51 CHANGED: Slight formatting and readability
52 if (e.readyState === "complete") {
53 t();
54 } else if (a.attachEvent) {
55 a.attachEvent("onload", t);
56 } else {
57 a.addEventListener("load", t, false);
58 }
59 }();
60 </script>
61
62 <?php } ?>
63