PluginProbe
Lasso Lite – Affiliate Link Manager & Product Displays / 158
Lasso Lite – Affiliate Link Manager & Product Displays v158
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 158, at admin/views/footer.php

588 lines 21.7 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 if (res && res.success) {
337 jQuery('#lasso-intercom-promotions').collapse('hide');
338 }
339 });
340 });
341
342 // ? Redirect to Lasso dashboard and show modal connect to Lasso
343 if (window.location.href.indexOf( 'post_type=surl&page=surl-dashboard&is-connect=1' ) !== -1) {
344 jQuery("#enable-support").modal('show');
345 var newUrl = window.location.href.replace('&is-connect=1', '');
346 window.history.replaceState(null, null, newUrl);
347 }
348 </script>
349 <?php endif; ?>
350
351 <?php if ( $amazon_page_slug !== $current_page && Helper::show_amazon_credentials_notice() ) : ?>
352 <script>
353 jQuery(function () {
354 lasso_lite_helper.inject_to_template(
355 jQuery("#lasso_lite_notifications"),
356 'amazon-credentials-update-jsrender',
357 {
358 amazon_settings_url: '<?php echo esc_js( Page::get_lite_page_url( Enum::PAGE_SETTINGS_AMAZON ) ); ?>'
359 },
360 false
361 );
362 jQuery('#lasso-amazon-credentials-update').collapse('show');
363
364 jQuery(document).on('click', '#lasso-amazon-credentials-update button.close', function() {
365 jQuery.ajax({
366 url: '<?php echo $ajax_url; // phpcs:ignore ?>',
367 type: 'post',
368 data: {
369 action: 'lasso_lite_dismiss_notice',
370 nonce: lassoLiteOptionsData.optionsNonce,
371 option_name: '<?php echo esc_js( Constant::LASSO_OPTION_AMAZON_CREDENTIALS_NOTICE_DISMISSED ); ?>',
372 },
373 }).done(function(res) {
374 if (res.success) {
375 jQuery('#lasso-amazon-credentials-update').collapse('hide');
376 jQuery(document).trigger('lasso_lite_amazon_credentials_notice_dismissed', [res.data]);
377 }
378 });
379 });
380 });
381 </script>
382 <?php endif; ?>
383
384 <?php if ( ! $lasso_lite_setting->is_setting_onboarding_page() && Estimate_Earning::should_show_orphan_earnings_banner() ) : ?>
385 <script>
386 window.__lassoLiteDeferExistingAccountCheck = true;
387 jQuery(function () {
388 try {
389 // ISO year-week (aligned with weekly estimate cron); dismiss hides until next week.
390 var lassoLiteEarningsWeekKey = function (date) {
391 var d = new Date(date.getTime());
392 d.setHours(0, 0, 0, 0);
393 d.setDate(d.getDate() + 4 - (d.getDay() || 7));
394 var yearStart = new Date(d.getFullYear(), 0, 1);
395 var weekNo = Math.ceil((((d - yearStart) / 86400000) + 1) / 7);
396 return d.getFullYear() + '-W' + String(weekNo).padStart(2, '0');
397 };
398 var weekKey = lassoLiteEarningsWeekKey(new Date());
399 try {
400 localStorage.removeItem('lasso_lite_earnings_notification_dismissed_month');
401 } catch (e) {}
402 var dismissedWeek = localStorage.getItem('lasso_lite_earnings_notification_dismissed_week');
403 if (dismissedWeek === weekKey) {
404 window.lassoLiteCheckExistingAccount();
405 return;
406 }
407
408 if (!window.lassoLiteOptionsData || !lassoLiteOptionsData.ajax_url) return;
409 if (!lassoLiteOptionsData.optionsNonce) return;
410
411 var useCache = '1';
412 try {
413 var url = new URL(window.location.href);
414 useCache = (url.searchParams.get('use_cache') || '1');
415 } catch (e) {}
416
417 jQuery.ajax({
418 url: lassoLiteOptionsData.ajax_url,
419 type: 'post',
420 dataType: 'json',
421 data: {
422 action: 'lasso_lite_get_earnings_estimate',
423 nonce: lassoLiteOptionsData.optionsNonce,
424 use_cache: useCache
425 }
426 }).done(function (res) {
427 if (!res || !res.success || !res.data) return;
428 var data = res.data.data ? res.data.data : res.data;
429 var payout = parseFloat(data.estimated_payout);
430 if (!payout || payout <= 0) return;
431
432 var tplData = {
433 earnings_display: data.earnings_display || data.payout_30d,
434 signup_url: '<?php echo esc_js( Constant::LASSO_PLUS_SIGNUP_URL ); ?>'
435 };
436
437 lasso_lite_helper.inject_to_template(
438 jQuery("#lasso_lite_notifications"),
439 'earnings-notification-jsrender',
440 tplData,
441 false
442 );
443 jQuery('#lasso-earnings-notification').addClass('show').collapse('show');
444 }).always(function () {
445 window.lassoLiteCheckExistingAccount();
446 });
447
448 jQuery(document).on('click', '#lasso-earnings-notification button.close', function(e) {
449 try {
450 localStorage.setItem('lasso_lite_earnings_notification_dismissed_week', weekKey);
451 } catch (err) {}
452 jQuery('#lasso-earnings-notification').collapse('hide');
453 });
454 } catch (e) {}
455 });
456 </script>
457 <?php endif; ?>
458
459 <!-- JS errors detection -->
460 <script
461 src="https://browser.sentry-cdn.com/7.9.0/bundle.tracing.min.js"
462 integrity="sha384-a80B6QRSQ+pPpoX+H79BVaE52KTvYkQDL+lD8+TajwMxswO+ywB3p99gWNraTNrt"
463 crossorigin="anonymous"
464 ></script>
465
466 <script>
467 var license_active = '<?php echo $license_active ? 1 : 0; // phpcs:ignore ?>';
468 let lasso_path = '<?php echo SIMPLE_URLS_URL; // phpcs:ignore ?>';
469 let post_type = 'post_type=<?php echo SIMPLE_URLS_SLUG; // phpcs:ignore ?>';
470 Sentry.init({
471 dsn: '<?php echo Constant::SENTRY_DSN; // phpcs:ignore ?>',
472 release: '<?php echo LASSO_LITE_VERSION; // phpcs:ignore ?>',
473 ignoreErrors: [
474 'ResizeObserver loop limit exceeded',
475 'ResizeObserver loop completed with undelivered notifications',
476 '__ez is not defined',
477 '_ezaq is not defined',
478 'Can\'t find variable: _ezaq',
479 'wpColorPickerL10n is not defined',
480 'window.jQuery(...).wpColorPicker is not a function',
481 ],
482 integrations: [new Sentry.Integrations.BrowserTracing()],
483 tracesSampleRate: 1.0,
484 beforeSend(event, hint) {
485 try {
486 let is_lasso_lite_error = false;
487 let event_id = event.event_id;
488 let frames = event.exception.values[0].stacktrace.frames;
489 for(let i = 0; i < frames.length; i++) {
490 if(frames[i].filename.includes(lasso_path) || frames[i].filename.includes(post_type)) {
491 is_lasso_lite_error = true;
492 break;
493 }
494 }
495
496 if(is_lasso_lite_error) {
497 return event;
498 }
499 } catch (error) {
500 console.log(error);
501 }
502 }
503 });
504
505 Sentry.configureScope(function(scope) {
506 scope.setUser({
507 email: '<?php echo $user_email; ?>',
508 });
509 scope.setTag('site_id', '<?php echo Helper::get_option( Constant::SITE_ID_KEY ); ?>');
510 scope.setTag('wp_version', '
511 <?php
512 global $wp_version;
513 echo esc_js( $wp_version );
514 ?>
515 ');
516 });
517
518 </script>
519 <script>
520 // Expose APP_ID and a reusable loader so other scripts can init Intercom after AJAX
521 var APP_ID = '<?php echo Constant::LASSO_INTERCOM_APP_ID; // phpcs:ignore ?>';
522 window.lassoInitIntercom = function(intercomParams, options) {
523 try {
524 // Ensure app_id always present in settings
525 if (!intercomParams) intercomParams = {};
526 if (!intercomParams.app_id) intercomParams.app_id = APP_ID;
527 window.intercomSettings = intercomParams;
528 var shouldShow = !options || options.show !== false;
529 var onReady = function() {
530 try {
531 window.Intercom('reattach_activator');
532 window.Intercom('update', window.intercomSettings);
533 if (shouldShow) {
534 window.Intercom('show');
535 }
536 } catch (e) {}
537 };
538 if (typeof window.Intercom === 'function') {
539 onReady();
540 return;
541 }
542 var s = document.createElement('script');
543 s.type = 'text/javascript';
544 s.async = true;
545 s.src = 'https://widget.intercom.io/widget/' + APP_ID;
546 s.onload = onReady;
547 var x = document.getElementsByTagName('script')[0];
548 x.parentNode.insertBefore(s, x);
549 } catch (e) {}
550 }
551 </script>
552 <!-- PHP errors detection -->
553 <?php
554 echo Helper::wrapper_js_render( 'setup-pregress-jsrender', Helper::get_path_views_folder() . 'components/setup-progress-jsrender.html' );
555 ?>
556 <?php
557 if ( $intercom_jwt && ! $lasso_lite_setting->is_setting_onboarding_page() ) {
558 $intercom_user_id = Helper::get_intercom_user_id( $user_email, $intercom_jwt );
559 $user = get_user_by( 'email', $user_email );
560 $user_name = isset( $user->display_name ) ? $user->display_name : get_bloginfo( 'name' );
561 $classic_editor = Helper::is_classic_editor() ? 1 : 0;
562 $email_support = $settings[ Enum::EMAIL_SUPPORT ] ?? $user_email;
563 $email_support = strtolower( trim( $email_support ) );
564 $user_hash = $settings[ Enum::USER_HASH ] ?? '';
565 $lasso_lite_user = 1;
566 if ( Helper::is_lasso_pro_plugin_active() ) {
567 $lasso_lite_user = 0;
568 }
569 ?>
570
571 <script>
572 var isClassicEditor = '<?php echo $classic_editor; // phpcs:ignore ?>' == 1 ? true : false;
573 var lasso_lite_user = '<?php echo $lasso_lite_user; // phpcs:ignore ?>' == 1 ? true : false;
574 var intercomParams = {
575 app_id: APP_ID,
576 name: '<?php echo addslashes( $user_name ); // phpcs:ignore ?>',
577 user_id: '<?php echo esc_js( $intercom_user_id ); // phpcs:ignore ?>',
578 email: '<?php echo esc_js( $email_support ); // phpcs:ignore ?>',
579 lasso_version: parseInt('<?php echo LASSO_LITE_VERSION; // phpcs:ignore ?>'),
580 classic_editor: isClassicEditor,
581 wp_admin_url: '<?php echo admin_url(); // phpcs:ignore ?>',
582 lasso_lite_user: lasso_lite_user,
583 intercom_user_jwt: '<?php echo $intercom_jwt; ?>'
584 };
585 window.lassoInitIntercom(intercomParams, { show: false });
586 </script>
587 <?php } ?>
588