PluginProbe
Lasso Lite – Affiliate Link Manager & Product Displays / 151
Lasso Lite – Affiliate Link Manager & Product Displays v151
158 157 155 156 154 153 152 151 150 149 148 trunk 0.9.9 104 105 106 107 108 109 110 111 112 113 114 115 All 57 releases
simple-urls / admin / views / footer.php

footer.php in Lasso Lite – Affiliate Link Manager & Product Displays 151, at admin/views/footer.php

583 lines 21.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Footer HTML
4 *
5 * @package Footer
6 */
7 use LassoLite\Admin\Constant;
8
9 use LassoLite\Classes\Enum;
10 use LassoLite\Classes\Estimate_Earning;
11 use LassoLite\Classes\Helper;
12 use LassoLite\Classes\License;
13 use LassoLite\Classes\Page;
14 use LassoLite\Classes\Setting;
15
16 $current_page = $_GET['page'] ?? '';
17 $import_page_slug = Helper::add_prefix_page( Enum::PAGE_IMPORT );
18 $amazon_page_slug = Helper::add_prefix_page( Enum::PAGE_SETTINGS_AMAZON );
19 $ajax_url = admin_url( 'admin-ajax.php' );
20
21 $user_email = get_option( 'admin_email' ); // phpcs:ignore
22 $user_email = get_option( 'lasso_license_email', $user_email );
23
24 $settings = Setting::get_settings();
25 $support_enable = $settings[ Enum::SUPPORT_ENABLED ] ?? 0;
26 $general_disable_notification = (bool) $settings['general_disable_notification'];
27 $customer_flow_enabled = (int) $settings[ Enum::CUSTOMER_FLOW_ENABLED ];
28
29 $lasso_lite_setting = new Setting();
30 $plugins_for_import = $lasso_lite_setting->check_plugins_for_import();
31 $import_page_link = Page::get_lite_page_url( Enum::PAGE_IMPORT );
32 $license_active = License::get_license_status();
33 $is_connected_aff = intval( Helper::get_option( Constant::LASSO_OPTION_IS_CONNECTED_AFFILIATE, '0' ) );
34 $is_show_upsell = ! $license_active && 0 === $is_connected_aff;
35 $intercom_jwt = $settings[ Enum::INTERCOM_JWT ] ?? '';
36
37 // Normalize email before Intercom usage.
38 $user_email = strtolower( trim( $user_email ) );
39 $checksum_file = SIMPLE_URLS_DIR . '/checksum.txt';
40 $commit_hash = file_exists( $checksum_file ) && is_readable( $checksum_file ) ? trim( (string) file_get_contents( $checksum_file ) ) : ''; // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
41 if ( '' !== $commit_hash ) {
42 $commit_hash = 'lasso-lite-rc-' . $commit_hash;
43 }
44
45 ?>
46 <input type="hidden" id="license_status" value="<?php echo $license_active; ?>">
47
48 <?php
49 if ( ! $lasso_lite_setting->is_setting_onboarding_page() ) {
50 $is_connected_aff = intval( Helper::get_option( Constant::LASSO_OPTION_IS_CONNECTED_AFFILIATE, '0' ) );
51 $lasso_account_email = Helper::get_option( Constant::LASSO_ACCOUNT_EMAIL, '' );
52 $lasso_account_user_id = intval( Helper::get_option( Constant::LASSO_ACCOUNT_USER_ID, 0 ) );
53 $is_lasso_connected = ! empty( $lasso_account_email ) || $lasso_account_user_id > 0 || $is_connected_aff > 0;
54 $prefill_email = get_option( 'admin_email' );
55
56 $lasso_logo_url = esc_url( rtrim( SIMPLE_URLS_URL, '/' ) . '/admin/assets/images/lasso-logo.svg' );
57 $footer_links = array(
58 array(
59 'label' => 'About',
60 'href' => 'https://getlasso.co/about/',
61 ),
62 array(
63 'label' => 'Help Center',
64 'href' => 'https://support.getlasso.co/',
65 ),
66 array(
67 'label' => 'Go Pro',
68 'href' => Constant::LASSO_UPGRADE_URL,
69 ),
70 );
71
72 $render_footer_brand_social = function () use ( $lasso_logo_url ) {
73 ?>
74 <div class="lasso-footer-brand">
75 <a href="https://getlasso.co" target="_blank" rel="noopener">
76 <img src="<?php echo $lasso_logo_url; ?>" alt="Lasso Logo" class="lasso-footer-logo">
77 </a>
78 <div class="lasso-footer-social">
79 <a href="https://twitter.com/lassowp" target="_blank" rel="noopener nofollow" title="Twitter">
80 <i class="fa-brands fa-twitter"></i>
81 </a>
82 <a href="https://www.linkedin.com/company/lasso-analytics/" target="_blank" rel="noopener nofollow" title="LinkedIn">
83 <i class="fa-brands fa-linkedin-in"></i>
84 </a>
85 <a href="https://www.instagram.com/getlassoco/" target="_blank" rel="noopener nofollow" title="Instagram">
86 <i class="fa-brands fa-instagram"></i>
87 </a>
88 <a href="https://www.youtube.com/@getlasso" target="_blank" rel="noopener nofollow" title="YouTube">
89 <i class="fa-brands fa-youtube"></i>
90 </a>
91 </div>
92 </div>
93 <?php
94 };
95
96 $render_footer_links = function ( $link_class = '' ) use ( $footer_links ) {
97 foreach ( $footer_links as $link ) {
98 $href = esc_url( $link['href'] );
99 $label = esc_html( $link['label'] );
100 ?>
101 <a <?php echo $link_class ? 'class="' . esc_attr( $link_class ) . '"' : ''; ?> href="<?php echo $href; ?>" target="_blank" rel="noopener">
102 <?php echo $label; ?>
103 </a>
104 <?php
105 }
106 };
107 ?>
108
109 <footer class="lasso-plugin-footer <?php echo $is_lasso_connected ? 'lasso-plugin-footer--default-only' : 'lasso-plugin-footer--with-cta'; ?>">
110 <div class="lasso-plugin-footer-version">
111 <?php print 'Version ' . LASSO_LITE_VERSION; // phpcs:ignore ?>
112 <?php if ( '' !== $commit_hash ) : ?>
113 <span class="d-block mt-1"><?php echo esc_html( $commit_hash ); ?></span>
114 <?php endif; ?>
115 </div>
116
117 <?php if ( ! $is_lasso_connected ) : ?>
118 <div class="lasso-footer-cta-content">
119 <div class="lasso-plugin-footer-version">
120 <?php print 'Version ' . LASSO_LITE_VERSION; // phpcs:ignore ?>
121 <?php if ( '' !== $commit_hash ) : ?>
122 <span class="d-block mt-1"><?php echo esc_html( $commit_hash ); ?></span>
123 <?php endif; ?>
124 </div>
125
126 <div class="lasso-footer-cta">
127 <div class="lasso-footer-cta-inner">
128 <h2 class="lasso-footer-cta-title">Create Your Free Account</h2>
129 <p class="lasso-footer-cta-subtitle">Access free click tracking, private brand deals, and more.</p>
130
131 <div id="lasso-signup-wrapper" class="lasso-footer-signup-wrapper">
132 <button id="btn-google-signup" class="lasso-signup-btn lasso-signup-btn-google w-100 mb-3">
133 <svg width="20" height="20" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
134 <path d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z" fill="#4285F4"/>
135 <path d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z" fill="#34A853"/>
136 <path d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z" fill="#FBBC05"/>
137 <path d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z" fill="#EA4335"/>
138 </svg>
139 Sign Up with Google
140 </button>
141
142 <button id="btn-email-signup-toggle" class="lasso-signup-btn w-100 mb-3">
143 Sign Up with Email
144 <svg aria-hidden="true" focusable="false" width="6px" height="8px" viewBox="0 0 8 12" xmlns="http://www.w3.org/2000/svg">
145 <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
146 <g transform="translate(-148.000000, -32.000000)" fill="#7c3aed">
147 <polygon points="148 33.4 149.4 32 155.4 38 149.4 44 148 42.6 152.6 38"></polygon>
148 </g>
149 </g>
150 </svg>
151 </button>
152
153 <div id="lasso-email-signup-form" class="footer-form d-none">
154 <div class="lasso-signup-divider mb-3">
155 <span>or</span>
156 </div>
157
158 <div class="form-group mb-3">
159 <label for="lasso-signup-email" class="d-block text-left mb-2">Email</label>
160 <input
161 type="email"
162 id="lasso-signup-email"
163 class="form-control"
164 placeholder="Enter your email"
165 value="<?php echo esc_attr( $prefill_email ); ?>"
166 >
167 <div id="lasso-email-error" class="lasso-field-error d-none"></div>
168 </div>
169
170 <div class="form-group mb-3">
171 <label for="lasso-signup-password" class="d-block text-left mb-2">Password</label>
172 <div class="lasso-password-wrapper">
173 <input
174 type="password"
175 id="lasso-signup-password"
176 class="form-control"
177 placeholder="Enter your password"
178 >
179 <button type="button" id="lasso-toggle-password" class="lasso-password-toggle">
180 <svg id="lasso-eye-icon" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
181 <path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path>
182 <circle cx="12" cy="12" r="3"></circle>
183 </svg>
184 <svg id="lasso-eye-off-icon" class="d-none" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
185 <path d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"></path>
186 <line x1="1" y1="1" x2="23" y2="23"></line>
187 </svg>
188 </button>
189 </div>
190 <div id="lasso-password-error" class="lasso-field-error d-none"></div>
191 </div>
192
193 <div id="lasso-general-error" class="lasso-general-error d-none mb-3"></div>
194
195 <button id="btn-create-account" class="lasso-signup-btn w-100">
196 Create your account
197 </button>
198 </div>
199 </div>
200
201 <div class="lasso-footer-cta-footer">
202 <?php $render_footer_brand_social(); ?>
203 <?php $render_footer_links( 'lasso-footer-nav-link' ); ?>
204 </div>
205 </div>
206 </div>
207 </div>
208
209 <input type="hidden" id="footer-prefill-email" value="<?php echo esc_attr( $prefill_email ); ?>">
210 <input type="hidden" id="footer-lasso-hub-url" value="<?php echo esc_attr( Constant::get_lasso_hub_url() ); ?>">
211 <?php endif; ?>
212
213 <?php if ( $is_lasso_connected ) : ?>
214 <div class="lasso-footer-default">
215 <div class="lasso-footer-inner">
216 <?php $render_footer_brand_social(); ?>
217 <div class="lasso-footer-links">
218 <?php $render_footer_links(); ?>
219 </div>
220 </div>
221 </div>
222 <?php endif; ?>
223 </footer>
224 <?php } ?>
225
226 <script>
227 // Check existing account via admin-ajax so it's visible in DevTools Network.
228 window.lassoLiteCheckExistingAccount = function () {
229 try {
230 if (window.__lassoLiteExistingAccountCheckRan) return;
231 window.__lassoLiteExistingAccountCheckRan = true;
232
233 if (!window.lassoLiteOptionsData || !lassoLiteOptionsData.ajax_url) return;
234 if (!lassoLiteOptionsData.optionsNonce) return;
235
236 // Only run when we don't already have a synced user_id.
237 var userId = parseInt((lassoLiteOptionsData.userId || 0), 10) || 0;
238 if (userId > 0) return;
239
240 jQuery.ajax({
241 url: lassoLiteOptionsData.ajax_url,
242 type: 'POST',
243 dataType: 'json',
244 data: {
245 action: 'lasso_lite_check_existing_account',
246 nonce: lassoLiteOptionsData.optionsNonce
247 }
248 });
249 } catch (e) {}
250 };
251
252 jQuery(function () {
253 if ( ! window.__lassoLiteDeferExistingAccountCheck ) {
254 window.lassoLiteCheckExistingAccount();
255 }
256 });
257 </script>
258
259 <div class="modal fade" id="modal-save-animation" data-backdrop="static" tabindex="-1" role="dialog">
260 <div class="modal-dialog" role="document">
261 <div class="modal-content p-5 shadow text-center">
262 <h3></h3>
263 <p>Saving your changes now.</p>
264 <div class="progress">
265 <div class="progress-bar progress-bar-striped progress-bar-animated green-bg" role="progressbar" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100" style="width: 75%"></div>
266 </div>
267 </div>
268 </div>
269 </div>
270
271 <div id="up-sell-modal">
272 <p class="large">This is a premium feature.</p>
273 <a href="<?php echo esc_url( Constant::LASSO_UPGRADE_URL ); ?>" target="_blank">Upgrade to Lasso Pro</a>
274 </div>
275
276 <?php if ( ! $lasso_lite_setting->is_setting_onboarding_page() && empty( $intercom_jwt ) ) { ?>
277 <div id="support-launcher">
278 <i class="fas fa-question icon-default"></i>
279 <i class="fas fa-times icon-close"></i>
280 </div>
281 <?php } ?>
282
283 <?php
284 echo Helper::wrapper_js_render( 'import-suggestion-jsrender', Helper::get_path_views_folder() . 'notifications/import-suggestion-jsrender.html' );
285 ?>
286 <?php
287 echo Helper::wrapper_js_render( 'earnings-notification-jsrender', Helper::get_path_views_folder() . 'notifications/earnings-notification-jsrender.html' );
288 ?>
289 <?php
290 echo Helper::wrapper_js_render( 'amazon-credentials-update-jsrender', Helper::get_path_views_folder() . 'notifications/amazon-credentials-update-jsrender.html' );
291 ?>
292
293 <!-- MODALS -->
294 <?php
295 if ( ! $customer_flow_enabled ) {
296 require_once SIMPLE_URLS_DIR . '/admin/views/modals/customer-flow-confirm.php';
297 }
298 ?>
299
300 <?php
301 // ? Show notification for import plugin
302 if ( '' !== $plugins_for_import && ! $general_disable_notification && $import_page_slug !== $current_page && Helper::is_importable() ) :
303 ?>
304 <script>
305 let json_data = [{ import_page_link: '<?php echo $import_page_link; ?>' }];
306 lasso_lite_helper.inject_to_template(jQuery("#lasso_lite_notifications"), 'import-suggestion-jsrender', json_data);
307 </script>
308 <?php endif; ?>
309
310 <?php
311 $template_path = '';
312 if ( $is_show_upsell ) {
313 if ( ! $support_enable && ! $lasso_lite_setting->is_setting_onboarding_page() ) {
314 $template_path = '/admin/views/notifications/promotions-no-intercom-jsrender.html';
315 } else {
316 $template_path = '/admin/views/notifications/promotions-intercom-jsrender.html';
317 }
318 }
319
320 ?>
321
322 <?php if ( 0 !== intval( Helper::get_option( Constant::LASSO_OPTION_AFFILIATE_PROMOTIONS, '1' ) ) && $is_show_upsell && '' !== $template_path ) : ?>
323 <script>
324 var notificationHtml = `<?php include SIMPLE_URLS_DIR . $template_path; ?>`;
325 jQuery("#lasso_lite_notifications").append(notificationHtml);
326 jQuery('#lasso-intercom-promotions button.close').click(function() {
327 let btn = jQuery(this);
328 jQuery.ajax({
329 url: '<?php echo $ajax_url; // phpcs:ignore ?>',
330 type: 'post',
331 data: {
332 action: 'lasso_lite_disable_affiliate_promotions',
333 nonce: lassoLiteOptionsData.optionsNonce,
334 },
335 }).done(function(res) {
336 jQuery('#lasso-intercom-promotions').collapse('hide');
337 });
338 });
339
340 // ? Redirect to Lasso dashboard and show modal connect to Lasso
341 if (window.location.href.indexOf( 'post_type=surl&page=surl-dashboard&is-connect=1' ) !== -1) {
342 jQuery("#enable-support").modal('show');
343 var newUrl = window.location.href.replace('&is-connect=1', '');
344 window.history.replaceState(null, null, newUrl);
345 }
346 </script>
347 <?php endif; ?>
348
349 <?php if ( $amazon_page_slug !== $current_page && Helper::show_amazon_credentials_notice() ) : ?>
350 <script>
351 jQuery(function () {
352 lasso_lite_helper.inject_to_template(
353 jQuery("#lasso_lite_notifications"),
354 'amazon-credentials-update-jsrender',
355 {
356 amazon_settings_url: '<?php echo esc_js( Page::get_lite_page_url( Enum::PAGE_SETTINGS_AMAZON ) ); ?>'
357 },
358 false
359 );
360 jQuery('#lasso-amazon-credentials-update').collapse('show');
361
362 jQuery(document).on('click', '#lasso-amazon-credentials-update button.close', function() {
363 jQuery.ajax({
364 url: '<?php echo $ajax_url; // phpcs:ignore ?>',
365 type: 'post',
366 data: {
367 action: 'lasso_lite_dismiss_notice',
368 nonce: lassoLiteOptionsData.optionsNonce,
369 option_name: '<?php echo esc_js( Constant::LASSO_OPTION_AMAZON_CREDENTIALS_NOTICE_DISMISSED ); ?>',
370 },
371 }).done(function() {
372 jQuery('#lasso-amazon-credentials-update').collapse('hide');
373 });
374 });
375 });
376 </script>
377 <?php endif; ?>
378
379 <?php if ( ! $lasso_lite_setting->is_setting_onboarding_page() && Estimate_Earning::should_show_orphan_earnings_banner() ) : ?>
380 <script>
381 window.__lassoLiteDeferExistingAccountCheck = true;
382 jQuery(function () {
383 try {
384 // ISO year-week (aligned with weekly estimate cron); dismiss hides until next week.
385 var lassoLiteEarningsWeekKey = function (date) {
386 var d = new Date(date.getTime());
387 d.setHours(0, 0, 0, 0);
388 d.setDate(d.getDate() + 4 - (d.getDay() || 7));
389 var yearStart = new Date(d.getFullYear(), 0, 1);
390 var weekNo = Math.ceil((((d - yearStart) / 86400000) + 1) / 7);
391 return d.getFullYear() + '-W' + String(weekNo).padStart(2, '0');
392 };
393 var weekKey = lassoLiteEarningsWeekKey(new Date());
394 try {
395 localStorage.removeItem('lasso_lite_earnings_notification_dismissed_month');
396 } catch (e) {}
397 var dismissedWeek = localStorage.getItem('lasso_lite_earnings_notification_dismissed_week');
398 if (dismissedWeek === weekKey) {
399 window.lassoLiteCheckExistingAccount();
400 return;
401 }
402
403 if (!window.lassoLiteOptionsData || !lassoLiteOptionsData.ajax_url) return;
404 if (!lassoLiteOptionsData.optionsNonce) return;
405
406 var useCache = '1';
407 try {
408 var url = new URL(window.location.href);
409 useCache = (url.searchParams.get('use_cache') || '1');
410 } catch (e) {}
411
412 jQuery.ajax({
413 url: lassoLiteOptionsData.ajax_url,
414 type: 'post',
415 dataType: 'json',
416 data: {
417 action: 'lasso_lite_get_earnings_estimate',
418 nonce: lassoLiteOptionsData.optionsNonce,
419 use_cache: useCache
420 }
421 }).done(function (res) {
422 if (!res || !res.success || !res.data) return;
423 var data = res.data.data ? res.data.data : res.data;
424 var payout = parseFloat(data.estimated_payout);
425 if (!payout || payout <= 0) return;
426
427 var tplData = {
428 earnings_display: data.earnings_display || data.payout_30d,
429 signup_url: '<?php echo esc_js( Constant::LASSO_PLUS_SIGNUP_URL ); ?>'
430 };
431
432 lasso_lite_helper.inject_to_template(
433 jQuery("#lasso_lite_notifications"),
434 'earnings-notification-jsrender',
435 tplData,
436 false
437 );
438 jQuery('#lasso-earnings-notification').addClass('show').collapse('show');
439 }).always(function () {
440 window.lassoLiteCheckExistingAccount();
441 });
442
443 jQuery(document).on('click', '#lasso-earnings-notification button.close', function(e) {
444 try {
445 localStorage.setItem('lasso_lite_earnings_notification_dismissed_week', weekKey);
446 } catch (err) {}
447 jQuery('#lasso-earnings-notification').collapse('hide');
448 });
449 } catch (e) {}
450 });
451 </script>
452 <?php endif; ?>
453
454 <!-- JS errors detection -->
455 <script
456 src="https://browser.sentry-cdn.com/7.9.0/bundle.tracing.min.js"
457 integrity="sha384-a80B6QRSQ+pPpoX+H79BVaE52KTvYkQDL+lD8+TajwMxswO+ywB3p99gWNraTNrt"
458 crossorigin="anonymous"
459 ></script>
460
461 <script>
462 var license_active = '<?php echo $license_active ? 1 : 0; // phpcs:ignore ?>';
463 let lasso_path = '<?php echo SIMPLE_URLS_URL; // phpcs:ignore ?>';
464 let post_type = 'post_type=<?php echo SIMPLE_URLS_SLUG; // phpcs:ignore ?>';
465 Sentry.init({
466 dsn: '<?php echo Constant::SENTRY_DSN; // phpcs:ignore ?>',
467 release: '<?php echo LASSO_LITE_VERSION; // phpcs:ignore ?>',
468 ignoreErrors: [
469 'ResizeObserver loop limit exceeded',
470 'ResizeObserver loop completed with undelivered notifications',
471 '__ez is not defined',
472 '_ezaq is not defined',
473 'Can\'t find variable: _ezaq',
474 'wpColorPickerL10n is not defined',
475 'window.jQuery(...).wpColorPicker is not a function',
476 ],
477 integrations: [new Sentry.Integrations.BrowserTracing()],
478 tracesSampleRate: 1.0,
479 beforeSend(event, hint) {
480 try {
481 let is_lasso_lite_error = false;
482 let event_id = event.event_id;
483 let frames = event.exception.values[0].stacktrace.frames;
484 for(let i = 0; i < frames.length; i++) {
485 if(frames[i].filename.includes(lasso_path) || frames[i].filename.includes(post_type)) {
486 is_lasso_lite_error = true;
487 break;
488 }
489 }
490
491 if(is_lasso_lite_error) {
492 return event;
493 }
494 } catch (error) {
495 console.log(error);
496 }
497 }
498 });
499
500 Sentry.configureScope(function(scope) {
501 scope.setUser({
502 email: '<?php echo $user_email; ?>',
503 });
504 scope.setTag('site_id', '<?php echo Helper::get_option( Constant::SITE_ID_KEY ); ?>');
505 scope.setTag('wp_version', '
506 <?php
507 global $wp_version;
508 echo esc_js( $wp_version );
509 ?>
510 ');
511 });
512
513 </script>
514 <script>
515 // Expose APP_ID and a reusable loader so other scripts can init Intercom after AJAX
516 var APP_ID = '<?php echo Constant::LASSO_INTERCOM_APP_ID; // phpcs:ignore ?>';
517 window.lassoInitIntercom = function(intercomParams, options) {
518 try {
519 // Ensure app_id always present in settings
520 if (!intercomParams) intercomParams = {};
521 if (!intercomParams.app_id) intercomParams.app_id = APP_ID;
522 window.intercomSettings = intercomParams;
523 var shouldShow = !options || options.show !== false;
524 var onReady = function() {
525 try {
526 window.Intercom('reattach_activator');
527 window.Intercom('update', window.intercomSettings);
528 if (shouldShow) {
529 window.Intercom('show');
530 }
531 } catch (e) {}
532 };
533 if (typeof window.Intercom === 'function') {
534 onReady();
535 return;
536 }
537 var s = document.createElement('script');
538 s.type = 'text/javascript';
539 s.async = true;
540 s.src = 'https://widget.intercom.io/widget/' + APP_ID;
541 s.onload = onReady;
542 var x = document.getElementsByTagName('script')[0];
543 x.parentNode.insertBefore(s, x);
544 } catch (e) {}
545 }
546 </script>
547 <!-- PHP errors detection -->
548 <?php
549 echo Helper::wrapper_js_render( 'setup-pregress-jsrender', Helper::get_path_views_folder() . 'components/setup-progress-jsrender.html' );
550 ?>
551 <?php
552 if ( $intercom_jwt && ! $lasso_lite_setting->is_setting_onboarding_page() ) {
553 $intercom_user_id = Helper::get_intercom_user_id( $user_email, $intercom_jwt );
554 $user = get_user_by( 'email', $user_email );
555 $user_name = isset( $user->display_name ) ? $user->display_name : get_bloginfo( 'name' );
556 $classic_editor = Helper::is_classic_editor() ? 1 : 0;
557 $email_support = $settings[ Enum::EMAIL_SUPPORT ] ?? $user_email;
558 $email_support = strtolower( trim( $email_support ) );
559 $user_hash = $settings[ Enum::USER_HASH ] ?? '';
560 $lasso_lite_user = 1;
561 if ( Helper::is_lasso_pro_plugin_active() ) {
562 $lasso_lite_user = 0;
563 }
564 ?>
565
566 <script>
567 var isClassicEditor = '<?php echo $classic_editor; // phpcs:ignore ?>' == 1 ? true : false;
568 var lasso_lite_user = '<?php echo $lasso_lite_user; // phpcs:ignore ?>' == 1 ? true : false;
569 var intercomParams = {
570 app_id: APP_ID,
571 name: '<?php echo addslashes( $user_name ); // phpcs:ignore ?>',
572 user_id: '<?php echo esc_js( $intercom_user_id ); // phpcs:ignore ?>',
573 email: '<?php echo esc_js( $email_support ); // phpcs:ignore ?>',
574 lasso_version: parseInt('<?php echo LASSO_LITE_VERSION; // phpcs:ignore ?>'),
575 classic_editor: isClassicEditor,
576 wp_admin_url: '<?php echo admin_url(); // phpcs:ignore ?>',
577 lasso_lite_user: lasso_lite_user,
578 intercom_user_jwt: '<?php echo $intercom_jwt; ?>'
579 };
580 window.lassoInitIntercom(intercomParams, { show: false });
581 </script>
582 <?php } ?>
583