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

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