PluginProbe
Lasso Lite – Affiliate Link Manager & Product Displays / 116
Lasso Lite – Affiliate Link Manager & Product Displays v116
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
← All changes | pages/class-hook.php +25 -745 158116 View file →
@@ -9,16 +9,13 @@
9 9
10 10 use LassoLite\Admin\Constant;
11 11
12 12 use LassoLite\Classes\Amazon_Api;
13 -use LassoLite\Classes\Beacon_Proxy;
14 13 use LassoLite\Classes\Enum;
15 14 use LassoLite\Classes\Helper;
16 15 use LassoLite\Classes\Page;
17 16 use LassoLite\Classes\Setting;
18 17 use LassoLite\Classes\Shortcode;
19 -use LassoLite\Classes\License;
20 -use LassoLite\Classes\Realtime_Click;
21 18
22 19 /**
23 20 * Hook.
24 21 */
@@ -43,11 +40,8 @@
43 40 public function register_hooks() {
44 41 add_action( 'admin_init', array( $this, 'amazon_api_pre_populated_automatically' ) );
45 42 add_action( 'init', array( $this, 'register_taxonomy' ) );
46 43 add_action( 'admin_menu', array( $this, 'build_admin_menu' ), 2 );
47 - add_action( 'init', array( $this, 'lasso_register_connect_snippet_rewrite' ) );
48 - add_action( 'init', array( $this, 'maybe_flush_vanity_rewrites_on_upgrade' ), 20 );
49 - add_action( 'upgrader_process_complete', array( $this, 'lasso_connect_snippet_flush_on_upgrade' ), 10, 2 );
50 44
51 45 $lasso_shortcode = new Shortcode();
52 46 add_shortcode( 'lasso', array( $lasso_shortcode, 'lasso_lite_core_shortcode' ) );
53 47 add_filter( 'pre_do_shortcode_tag', array( $this, 'filter_pre_do_shortcode_lasso_lite' ), 10, 4 );
@@ -55,9 +49,8 @@
55 49 add_action( 'wp_head', array( $this, 'lasso_custom_css' ) ); // ? frontend
56 50 add_action( 'admin_head', array( $this, 'lasso_custom_css' ) ); // ? admin
57 51 add_action( 'admin_head', array( $this, 'lasso_custom_menu' ) ); // ? admin
58 52 add_action( 'wp_enqueue_scripts', array( $this, 'add_scripts_frontend' ) ); // ? frontend
59 - add_filter( 'body_class', array( $this, 'filter_body_class_lasso_lite_version' ) ); // ? frontend
60 53
61 54 add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts' ) );
62 55 add_action( 'admin_enqueue_scripts', array( $this, 'add_styles' ) );
63 56
@@ -64,14 +57,10 @@
64 57 // ? re-order submenu pages
65 58 add_filter( 'custom_menu_order', array( $this, 'lasso_order_submenu' ) );
66 59
67 60 // ? lasso gutenberg block
68 - add_action( 'enqueue_block_assets', array( $this, 'lasso_block_editor_css_variables' ) );
69 61 add_action( 'enqueue_block_editor_assets', array( $this, 'lasso_lite_gutenberg_block' ) );
70 62
71 - // ? Elementor
72 - add_action( 'elementor/init', array( $this, 'elementor_init' ) );
73 -
74 63 // ? add Lasso button into TinyMCE
75 64 add_filter( 'mce_external_plugins', array( $this, 'lasso_add_tinymce_plugin' ) );
76 65 add_filter( 'mce_buttons', array( $this, 'lasso_lite_register_my_tc_button' ) );
77 66
@@ -81,19 +70,11 @@
81 70
82 71 add_filter( 'rest_pre_echo_response', array( $this, 'update_post_type_gutenberg' ), 200, 3 );
83 72
84 73 add_filter( 'wp_link_query', array( $this, 'update_post_type_classic_editor' ), 10, 1 );
74 + add_filter( 'admin_footer_text', array( $this, 'admin_footer' ), 100, 2 );
85 75 add_filter( 'update_footer', '__return_empty_string', 11 );
86 76
87 - // ? WP Rocket
88 - add_filter( 'rocket_exclude_js', array( $this, 'exclude_lasso_performance_js_from_rocket_cache' ) );
89 -
90 - add_filter( 'query_vars', array( $this, 'lasso_connect_snippet_query_var' ) );
91 -
92 - // Serve vanity JS path /js/snippet.min.js via plugin handler (run as early as possible)
93 - add_action( 'template_redirect', array( $this, 'serve_connect_snippet' ), 0 );
94 - add_action( 'template_redirect', array( $this, 'serve_beacon_proxy' ), 0 );
95 -
96 77 $setting = new Setting();
97 78 if ( $setting->is_surls_page() ) {
98 79 // ? plugin: Pretty Links Pro
99 80 if ( class_exists( 'PrliUpdateController' ) ) {
@@ -123,9 +104,9 @@
123 104 remove_action( 'init', array( $WooZone, 'initThePlugin' ), 5 ); // phpcs:ignore
124 105 }
125 106
126 107 // ? plugin: Client Portal
127 - $lasso_page = Helper::GET()['page'] ?? ''; // phpcs:ignore
108 + $lasso_page = $_GET['page'] ?? ''; // phpcs:ignore
128 109 if ( class_exists( 'CCGClientPortal' ) && Helper::add_prefix_page( Enum::PAGE_DASHBOARD ) === $lasso_page ) {
129 110 global $zohopwp; // phpcs:ignore
130 111 remove_action( 'admin_menu', array( $zohopwp, 'ccgclientportal_admin_menu' ) ); // phpcs:ignore
131 112 }
@@ -177,16 +158,8 @@
177 158
178 159 if ( Helper::is_gravity_perks_plugin_active() ) {
179 160 remove_action( 'admin_print_footer_scripts', array( 'GWPerks', 'welcome_pointer_script' ), 10 ); // phpcs:ignore
180 161 }
181 -
182 - $license_active = License::get_license_status();
183 - if ( false === $license_active ) {
184 - add_action( 'admin_notices', array( $this, 'lasso_lite_custom_dashboard_banner' ) );
185 - }
186 -
187 - add_action( 'wp_footer', array( $this, 'lasso_lite_event_tracking' ) );
188 - add_action( 'admin_footer', array( $this, 'open_links_in_new_tab' ) );
189 162 }
190 163
191 164
192 165 /**
@@ -226,15 +199,13 @@
226 199 wp_redirect( Page::get_page_url() ); // phpcs:ignore
227 200 exit;
228 201 }
229 202
230 - // ? Reset onboarding for testing (one-shot: strip QA param so step persistence works on reload)
203 + // ? Reset onboarding for testing
231 204 $reset_onboarding = Helper::GET()[ Enum::RESET_WELCOME_PAGE ] ?? '';
232 205 if ( $reset_onboarding ) {
233 - Helper::reset_onboarding_for_testing();
234 -
235 - wp_safe_redirect( remove_query_arg( Enum::RESET_WELCOME_PAGE ) ); // phpcs:ignore WordPress.Security.SafeRedirect.wp_redirect_wp_redirect
236 - exit;
206 + Helper::update_option( Enum::IS_VISITED_WELCOME_PAGE, 0 );
207 + update_option( Enum::LASSO_LITE_ACTIVE, 1 );
237 208 }
238 209
239 210 // ? Reset request review for testing
240 211 $reset_review = Helper::GET()[ Enum::RESET_REQUEST_REVIEW ] ?? '';
@@ -245,9 +216,9 @@
245 216 }
246 217
247 218 // ? The new Lasso Lite active should be redirect to welcome page
248 219 $onboarding_page = Helper::add_prefix_page( Enum::PAGE_ONBOARDING );
249 - $should_redirect_to_welcome_page = self::should_redirect_to_welcome_page();
220 + $should_redirect_to_welcome_page = get_option( Enum::LASSO_LITE_ACTIVE ) && ! Helper::get_option( Enum::IS_VISITED_WELCOME_PAGE );
250 221 if ( SIMPLE_URLS_SLUG === $post_type && $onboarding_page !== $get_page && $should_redirect_to_welcome_page ) {
251 222 wp_redirect( Page::get_page_url( $onboarding_page ) ); // phpcs:ignore
252 223 exit;
253 224 } elseif ( $onboarding_page === $get_page && ! $should_redirect_to_welcome_page ) {
@@ -350,12 +321,8 @@
350 321 Helper::enqueue_style( 'lasso-dashboard', 'lasso-dashboard.css' );
351 322 Helper::enqueue_style( 'lasso-lite-custom', 'lite-custom.css' );
352 323 }
353 324
354 - if ( $setting->is_setting_amazon_page() ) {
355 - Helper::enqueue_style( 'settings-amazon-modal', 'settings-amazon-modal.css', array( SIMPLE_URLS_SLUG . '-lasso-lite-custom' ) );
356 - }
357 -
358 325 if ( $setting->is_setting_display_page() || $setting->is_setting_onboarding_page() ) {
359 326 Helper::enqueue_style( 'spectrum', 'spectrum.min.css' );
360 327 }
361 328
@@ -365,16 +332,10 @@
365 332 Helper::enqueue_style( 'lasso-display-modal', 'lasso-display-modal.css' );
366 333 Helper::enqueue_style( 'simple-pagination', 'simplePagination.css' );
367 334 Helper::enqueue_style( 'lasso-quill', 'quill.snow.css' );
368 335 Helper::enqueue_style( 'lasso-lite', 'lasso-lite.css' );
369 - Helper::enqueue_style( 'lasso-modal-css', 'lasso-modal.css' );
370 336 }
371 337
372 - global $pagenow; // phpcs:ignore
373 - if ( 'index.php' === $pagenow && $this->should_show_dashboard_promo_banner() ) {
374 - Helper::enqueue_style( 'lasso-lite-admin', 'lasso-lite-admin.css' );
375 - }
376 -
377 338 // @codingStandardsIgnoreEnd
378 339 }
379 340
380 341 /**
@@ -383,9 +344,8 @@
383 344 public function add_scripts() {
384 345 if ( ! Helper::is_lite_using_new_ui() ) {
385 346 return;
386 347 }
387 - global $pagenow; // phpcs:ignore
388 348
389 349 $get = Helper::GET(); // phpcs:ignore
390 350 $page = $get['page'] ?? false;
391 351 $setting = new Setting();
@@ -396,48 +356,24 @@
396 356 $data_passed_to_js = array(
397 357 'ajax_url' => admin_url( 'admin-ajax.php' ),
398 358 'site_url' => site_url(),
399 359 'plugin_url' => SIMPLE_URLS_URL,
400 - 'lasso_link' => Constant::LASSO_LINK,
401 - 'lasso_hub_url' => Constant::get_lasso_hub_url(),
402 - 'upgrade_url' => Constant::LASSO_UPGRADE_URL,
403 360 'rewrite_slug_default' => Enum::REWRITE_SLUG_DEFAULT,
404 361 'simple_urls_slug' => SIMPLE_URLS_SLUG,
405 362 'page_url_details' => Enum::PAGE_URL_DETAILS,
406 363 'setup_progress' => Helper::get_setup_progress_information(),
407 - 'optionsNonce' => wp_create_nonce( Constant::LASSO_LITE_NONCE . wp_salt() ),
364 + 'optionsNonce' => wp_create_nonce( 'lasso_settings_save' ),
408 365 'should_open_support_modal' => $support_enabled,
409 366 'amazon_tracking_id_regex' => Amazon_Api::TRACKING_ID_REGEX,
410 367 'is_onboard_page' => $setting->is_setting_onboarding_page(),
411 - 'onboarding_current_step' => $setting->is_setting_onboarding_page()
412 - ? Helper::get_onboarding_current_step( Helper::should_show_import_page() )
413 - : 'welcome',
414 368 'block_customize' => Constant::BLOCK_CUSTOMIZE,
415 - 'userId' => Helper::get_option( Constant::LASSO_ACCOUNT_USER_ID ),
416 369 );
417 - $data_passed_to_js['realtime'] = Realtime_Click::get_js_config();
418 370
419 - if ( $setting->is_setting_amazon_page() ) {
420 - // Amazon settings only: edit.php?post_type=surl&page=surl-settings-amazon
421 - $data_passed_to_js['lite_account_existing_always_post'] = true;
422 - $data_passed_to_js['lite_amazon_settings_post_signup_verify_creators'] = true;
423 - }
424 -
425 371 if ( SIMPLE_URLS_SLUG === $post_type ) {
426 372 wp_dequeue_script( 'up_admin_script' ); // ? fix js conflict with plugin: Download plugin
427 373 }
428 374
429 375 // @codingStandardsIgnoreStart
430 - if ( 'index.php' === $pagenow && $this->should_show_dashboard_promo_banner() ) {
431 - $data_passed_to_js = array(
432 - 'ajax_url' => admin_url( 'admin-ajax.php' ),
433 - 'optionsNonce' => wp_create_nonce( Constant::LASSO_LITE_NONCE . wp_salt() ),
434 - );
435 - wp_enqueue_script( 'jquery' );
436 - wp_localize_script( 'jquery', 'lassoLiteOptionsData', $data_passed_to_js );
437 - Helper::enqueue_script( 'lasso-lite-admin-js', 'lasso-lite-admin.js', array( 'jquery' ), false );
438 - }
439 -
440 376 if ( $setting->is_wordpress_post() || $setting->is_surls_page() || $setting->is_custom_post() ) {
441 377 wp_enqueue_script( 'jquery-migrate' ); // ? fix jQuery(...).live is not a function
442 378 wp_enqueue_script( 'jquery' );
443 379 wp_enqueue_script( 'jquery-effects-core' );
@@ -451,14 +387,8 @@
451 387 Helper::enqueue_script( 'lasso-icons-brands', 'brands.min.js', array( 'jquery' ) );
452 388 Helper::enqueue_script( 'circle-progress', 'circle-progress.min.js', array( 'jquery' ) );
453 389
454 390 Helper::enqueue_script( 'lasso-quill', 'quill.min.js' );
455 - Helper::enqueue_script( 'lasso-modal-js', 'lasso-modal.js' );
456 -
457 - if ( ! Helper::is_classic_editor() && ( $setting->is_wordpress_post() || $setting->is_custom_post() ) ) {
458 - Helper::enqueue_script( 'lasso-lite-display-modal', 'lasso-lite-display-modal.js' );
459 - }
460 -
461 391 wp_enqueue_media();
462 392 Helper::enqueue_script( 'moment-js', 'moment.min.js', array( 'jquery' ) );
463 393 Helper::enqueue_script( 'select2-js', 'select2.full.min.js', array( 'jquery' ) );
464 394 Helper::enqueue_script( SIMPLE_URLS_SLUG . '-jq-auto-complete-js', 'jquery-autocomplete.js' );
@@ -472,12 +402,8 @@
472 402 wp_localize_script( 'jquery', 'lassoLiteOptionsData', $data_passed_to_js );
473 403 Helper::enqueue_script( 'lasso-helper', 'lasso-helper.js', array( 'jquery' ) );
474 404 Helper::enqueue_script( 'url-add', 'url-add.js', array( 'jquery' ) );
475 405 Helper::enqueue_script( 'support', 'support.js', array( 'jquery' ) );
476 -
477 - if ( ! $setting->is_setting_onboarding_page() && ! $setting->is_setting_amazon_page() ) {
478 - Helper::enqueue_script( 'lasso-signup', 'lasso-signup.js', array( 'jquery' ) );
479 - }
480 406
481 407 if ( SIMPLE_URLS_SLUG . '-' . Enum::PAGE_URL_DETAILS === $page ) {
482 408 Helper::enqueue_script( 'url-details', 'url-details.js', array( 'jquery' ) );
483 409 }
@@ -486,25 +412,14 @@
486 412 if ( $setting->is_dashboard_page() ) {
487 413 Helper::enqueue_script( 'dashboard', 'dashboard.js', array( 'jquery' ) );
488 414 }
489 415
490 - if ( $setting->is_opportunities_page() ) {
491 - Helper::enqueue_script( 'opportunities', 'opportunities.js', array( 'jquery' ) );
492 - }
493 -
494 - if ( $setting->is_tables_page() ) {
495 - Helper::enqueue_script( 'tables', 'tables.js', array( 'jquery' ) );
496 - }
497 -
498 416 if ( $setting->is_setting_display_page() || $setting->is_setting_onboarding_page() ) {
499 417 Helper::enqueue_script( 'spectrum-js', 'spectrum.min.js', array( 'jquery' ) );
500 418 Helper::enqueue_script( 'settings-display-js', 'settings-display.js', array( 'jquery' ) );
501 419 }
502 420
503 - if ( $setting->is_setting_amazon_page() ) {
504 - Helper::enqueue_script( 'lasso-signup', 'lasso-signup.js', array( 'jquery' ) );
505 - Helper::enqueue_script( 'settings-amazon', 'settings-amazon.js', array( 'jquery', SIMPLE_URLS_SLUG . '-lasso-signup' ) );
506 - } elseif ( $setting->is_setting_onboarding_page() ) {
421 + if ( $setting->is_setting_amazon_page() || $setting->is_setting_onboarding_page() ) {
507 422 Helper::enqueue_script( 'settings-amazon', 'settings-amazon.js', array( 'jquery' ) );
508 423 }
509 424
510 425 if ( $setting->is_import_page() || $setting->is_setting_onboarding_page() ) {
@@ -514,9 +429,8 @@
514 429 if ( $setting->is_setting_onboarding_page() ) {
515 430 Helper::enqueue_script( 'onboarding-js', 'onboarding.js', array( 'jquery' ) );
516 431 Helper::enqueue_script( 'settings-js', 'settings.js', array( 'jquery' ) );
517 432 Helper::enqueue_script( 'settings-display-js', 'settings-display.js', array( 'jquery' ) );
518 - Helper::enqueue_script( 'lasso-signup', 'lasso-signup.js', array( 'jquery' ) );
519 433 }
520 434
521 435 if ( $setting->is_setting_general_page() ) {
522 436 Helper::enqueue_script( 'settings-general', 'settings-general.js', array( 'jquery' ) );
@@ -521,12 +435,8 @@
521 435 if ( $setting->is_setting_general_page() ) {
522 436 Helper::enqueue_script( 'settings-general', 'settings-general.js', array( 'jquery' ) );
523 437 }
524 438
525 - if ( $setting->is_setting_page() ) {
526 - Helper::enqueue_script( 'settings-unsaved-guard', 'settings-unsaved-guard.js', array( 'jquery', SIMPLE_URLS_SLUG . '-lasso-helper' ) );
527 - }
528 -
529 439 if ( $setting->is_group_detail_page() || $setting->is_group_page() ) {
530 440 Helper::enqueue_script( 'groups', 'groups.js', array( 'jquery' ) );
531 441 }
532 442
@@ -547,10 +457,23 @@
547 457 if ( ! Helper::is_lite_using_new_ui() ) {
548 458 return;
549 459 }
550 460
461 + $settings = Setting::get_settings();
462 +
551 463 // @codingStandardsIgnoreStart
552 - echo '<style type="text/css">' . Helper::get_lasso_display_css_variables( true ) . '</style>';
464 + echo '<style type="text/css">
465 + :root{
466 + --lasso-main: ' . $settings['display_color_main'] . ' !important;
467 + --lasso-title: ' . $settings['display_color_title'] . ' !important;
468 + --lasso-button: ' . $settings['display_color_button'] . ' !important;
469 + --lasso-secondary-button: ' . $settings['display_color_secondary_button'] . ' !important;
470 + --lasso-button-text: ' . $settings['display_color_button_text'] . ' !important;
471 + --lasso-background: ' . $settings['display_color_background'] . ' !important;
472 + --lasso-pros: ' . $settings['display_color_pros'] . ' !important;
473 + --lasso-cons: ' . $settings['display_color_cons'] . ' !important;
474 + }
475 + </style>';
553 476
554 477 // fix fontawesome js render svg (from other plugins) instead of using css
555 478 echo '
556 479 <script type="text/javascript">
@@ -610,20 +533,8 @@
610 533 'manage_options',
611 534 Constant::LASSO_SUPPORT_URL,
612 535 );
613 536
614 - $new_submenu[93] = array(
615 - 'Analytics',
616 - 'manage_options',
617 - Constant::LASSO_ANALYTICS_URL,
618 - );
619 -
620 - $new_submenu[95] = array(
621 - 'Marketplace',
622 - 'manage_options',
623 - Constant::LASSO_AFFILIATE_PLUS_URL,
624 - );
625 -
626 537 $new_submenu[100] = array(
627 538 '<b class="green">Upgrade to Pro</b>',
628 539 'manage_options',
629 540 Constant::LASSO_UPGRADE_URL,
@@ -635,41 +546,13 @@
635 546 $submenu[ $menu_key ] = $new_submenu;
636 547 }
637 548
638 549 /**
639 - * Lasso display styles + color variables inside the block editor iframe (WP 7+).
640 - *
641 - * admin_enqueue_scripts only loads into the parent editor chrome; shortcode HTML
642 - * preview renders in the editor canvas iframe and needs enqueue_block_assets.
643 - *
644 - * @codeCoverageIgnore Coverage ignore.
645 - */
646 - public function lasso_block_editor_css_variables() {
647 - if ( ! is_admin() || Helper::is_lasso_pro_installed() || ! Helper::is_lite_using_new_ui() ) {
648 - return;
649 - }
650 -
651 - $setting = new Setting();
652 - if ( ! $setting->is_wordpress_post() && ! $setting->is_custom_post() ) {
653 - return;
654 - }
655 -
656 - Helper::enqueue_style( 'bootstrap-grid-css', 'bootstrap-grid.min.css' );
657 - Helper::enqueue_style( 'lasso-lite', 'lasso-lite.css' );
658 - wp_add_inline_style( SIMPLE_URLS_SLUG . '-lasso-lite', Helper::get_lasso_display_css_variables( true ) );
659 - }
660 -
661 - /**
662 550 * Load lasso js file in Gutenberg editor
663 551 */
664 552 public function lasso_lite_gutenberg_block() {
665 553 if ( ! Helper::is_lasso_pro_installed() ) {
666 - Helper::enqueue_script(
667 - 'lasso-lite-gutenberg-block',
668 - 'lasso-lite-gutenberg-block.js',
669 - array( 'wp-blocks', 'wp-block-editor', 'wp-element', 'wp-components', 'wp-compose' ),
670 - true
671 - );
554 + Helper::enqueue_script( 'lasso-lite-gutenberg-block', 'lasso-lite-gutenberg-block.js', array( 'wp-blocks', 'wp-editor' ), true );
672 555 Helper::enqueue_script( 'display-add', 'display-add.js', array( 'jquery' ) );
673 556 Helper::enqueue_script( 'url-add', 'url-add.js', array( 'jquery' ) );
674 557 }
675 558 }
@@ -682,9 +565,9 @@
682 565 public function lasso_add_tinymce_plugin( $plugin_array ) {
683 566 if ( ! Helper::is_lasso_pro_plugin_active() ) {
684 567 $lasso_setting = new Setting();
685 568 if ( Helper::is_classic_editor() && ( $lasso_setting->is_wordpress_post() || $lasso_setting->is_custom_post() ) ) {
686 - $plugin_array['lasso_lite_tc_button'] = SIMPLE_URLS_URL . '/admin/assets/js/lasso-lite-display-modal.js?v=' . strval( @filemtime( SIMPLE_URLS_DIR . '/admin/assets/js/lasso-lite-display-modal.js' ) ); // phpcs:ignore
569 + $plugin_array['lasso_lite_tc_button'] = SIMPLE_URLS_URL . '/admin/assets/js/lasso-lite-display-modal.js?v=' . strval( @filemtime( SIMPLE_URLS_DIR . '/admin/assets/js/lasso-display-modal.js' ) ); // phpcs:ignore
687 570 Helper::enqueue_script( 'display-add', 'display-add.js', array( 'jquery' ) );
688 571 Helper::enqueue_script( 'url-add', 'url-add.js', array( 'jquery' ) );
689 572 }
690 573 }
@@ -716,9 +599,9 @@
716 599 if ( $lasso_setting->is_wordpress_post() || $lasso_setting->is_custom_post() ) {
717 600 $current_screen = get_current_screen();
718 601 // ? Check to make sure render html only block editor Gutenberg
719 602 if ( ( method_exists( $current_screen, 'is_block_editor' ) && $current_screen->is_block_editor() )
720 - || ( function_exists( 'is_gutenberg_page' ) && is_gutenberg_page() )
603 + || ( function_exists( 'is_gutenberg_page' ) ) && is_gutenberg_page()
721 604 ) {
722 605 echo Helper::get_display_modal_html(); // phpcs:ignore
723 606 }
724 607 }
@@ -943,609 +826,6 @@
943 826 );
944 827 }
945 828
946 829 return $text;
947 - }
948 -
949 - /**
950 - * Open Affiliate+ in new tab
951 - */
952 - public function open_links_in_new_tab() {
953 - ?>
954 - <script type="text/javascript">
955 - jQuery(document).ready(function($) {
956 - $('a[href="https://app.getlasso.co/plus/"]').attr('target', '_blank');
957 - });
958 - </script>
959 - <?php
960 - }
961 -
962 - /**
963 - * Whether Lite onboarding should redirect admin users to the welcome flow.
964 - *
965 - * @return bool
966 - */
967 - public static function should_redirect_to_welcome_page() {
968 - return (bool) get_option( Enum::LASSO_LITE_ACTIVE ) && ! Helper::get_option( Enum::IS_VISITED_WELCOME_PAGE );
969 - }
970 -
971 - /**
972 - * Whether the affiliate promo dashboard banner should render.
973 - *
974 - * @return bool
975 - */
976 - private function should_show_dashboard_promo_banner() {
977 - global $pagenow;
978 -
979 - if ( 'index.php' !== $pagenow || ! Helper::is_lite_using_new_ui() ) {
980 - return false;
981 - }
982 -
983 - $license_active = License::get_license_status();
984 - $is_connected_aff = intval( Helper::get_option( Constant::LASSO_OPTION_IS_CONNECTED_AFFILIATE, '0' ) );
985 -
986 - return ! $license_active
987 - && 0 === $is_connected_aff
988 - && ! intval( Helper::get_option( Constant::LASSO_OPTION_DISMISS_PROMOTIONS, 0 ) );
989 - }
990 -
991 - /**
992 - * Show Performance promotion
993 - *
994 - * @return void
995 - */
996 - public function lasso_lite_custom_dashboard_banner() {
997 - if ( ! $this->should_show_dashboard_promo_banner() ) {
998 - echo ''; // phpcs:ignore
999 - return;
1000 - }
1001 -
1002 - $setting_data = Setting::get_settings();
1003 - $support_enabled = $setting_data[ Enum::SUPPORT_ENABLED ] ?? false;
1004 - if ( ! $support_enabled ) {
1005 - $template_path = '/admin/views/notifications/affiliate-promotions-no-intercom.php';
1006 - } else {
1007 - $template_path = '/admin/views/notifications/affiliate-promotions-intercom.php';
1008 - }
1009 -
1010 - $html = Helper::include_with_variables(
1011 - SIMPLE_URLS_DIR . $template_path,
1012 - array(
1013 - 'dismiss' => 0,
1014 - 'option_name' => Constant::LASSO_OPTION_DISMISS_PROMOTIONS,
1015 - )
1016 - );
1017 -
1018 - echo $html; // phpcs:ignore
1019 - }
1020 -
1021 - /**
1022 - * Print JS script for Lasso event tracking.
1023 - */
1024 - public function lasso_lite_event_tracking() {
1025 - if ( is_admin() || strpos( Helper::get_server_param( 'REQUEST_URI' ), 'wp-admin' )
1026 - || strpos( Helper::get_server_param( 'REQUEST_URI' ), 'elementor-preview' )
1027 - || Helper::is_lasso_pro_installed()
1028 - ) {
1029 - return;
1030 - }
1031 -
1032 - $process_lasso_event_tracking = apply_filters( 'lasso_lite_event_tracking', true );
1033 -
1034 - if ( ! $process_lasso_event_tracking ) {
1035 - return;
1036 - }
1037 -
1038 - $lasso_options = Setting::get_settings();
1039 - $is_ip_anonymization = false;
1040 - $lsid = Helper::build_lsid();
1041 - $realtime_ingest = null;
1042 - if ( Realtime_Click::is_ingest_enabled() ) {
1043 - $ingest_secret = Realtime_Click::get_ingest_secret();
1044 - $channel_id = Realtime_Click::get_channel_id();
1045 - if ( is_string( $ingest_secret ) && '' !== $ingest_secret && is_string( $channel_id ) && '' !== $channel_id ) {
1046 - $beacon = Realtime_Click::get_beacon_credentials( $channel_id, $ingest_secret );
1047 - $realtime_ingest = array(
1048 - 'ajaxUrl' => admin_url( 'admin-ajax.php' ),
1049 - 'action' => 'lasso_lite_realtime_ingest',
1050 - 'channelId' => $channel_id,
1051 - 'beaconToken' => $beacon['token'],
1052 - 'beaconBucket' => $beacon['bucket'],
1053 - );
1054 - }
1055 - }
1056 -
1057 - $current_date = gmdate( 'Ymd' );
1058 - $js_version = LASSO_LITE_VERSION . '.' . $current_date;
1059 -
1060 - // Prefer clean path when permalinks are enabled; fall back to query when using Plain
1061 - $snippet_query = Helper::get_snippet_query();
1062 - $performance_url_hash = add_query_arg(
1063 - array(
1064 - $snippet_query => '1',
1065 - 'ver' => $js_version,
1066 - ),
1067 - home_url( '/' )
1068 - );
1069 -
1070 - $default_js_domain = 'https://js.codedrink.com';
1071 -
1072 - $dynamic_js_domain = Helper::get_option( 'js_domain', $default_js_domain );
1073 - $full_dynamic_js_domain = Helper::get_option( 'full_js_domain', "$dynamic_js_domain/snippet.min.js" );
1074 -
1075 - $dynamic_performance_url_external = $full_dynamic_js_domain . '?ver=' . $js_version; // load external js
1076 -
1077 - // @codeCoverageIgnoreStart
1078 - if ( $lasso_options['performance_event_tracking'] ) :
1079 - ?>
1080 -
1081 - <script type="text/javascript">
1082 - (function () {
1083 - // Prevent double-insert
1084 - if (window.LS_AFF_IS_LOADED || window.__LS_SEQ_LOADER__) {
1085 - return;
1086 - }
1087 - window.__LS_SEQ_LOADER__ = true;
1088 - var lsSources = [
1089 - <?php echo wp_json_encode( $dynamic_performance_url_external ); ?>,
1090 - <?php echo wp_json_encode( $performance_url_hash ); ?>
1091 - ];
1092 -
1093 - var lsScriptLoadTimeoutMs = 2500;
1094 - var lsIndex = 0, lsTimeoutMs = lsScriptLoadTimeoutMs;
1095 -
1096 - function lsLoadNext() {
1097 - if (window.LS_AFF_IS_LOADED || lsIndex >= lsSources.length) {
1098 - return;
1099 - }
1100 -
1101 - var lsUrl = lsSources[lsIndex++];
1102 - var lsScript = document.createElement('script');
1103 - lsScript.src = lsUrl;
1104 - lsScript.onerror = function () {
1105 - try { lsScript.remove(); } catch (_) {}
1106 - if (!window.LS_AFF_IS_LOADED) lsLoadNext();
1107 - };
1108 - var lsTimer = setTimeout(function () {
1109 - if (!window.LS_AFF_IS_LOADED) {
1110 - try { lsScript.remove(); } catch (_) {}
1111 - lsLoadNext();
1112 - }
1113 - }, lsTimeoutMs);
1114 - lsScript.onload = (function (orig) {
1115 - return function () {
1116 - clearTimeout(lsTimer);
1117 - if (orig) orig();
1118 - };
1119 - })(lsScript.onload);
1120 - (document.head || document.documentElement).appendChild(lsScript);
1121 - }
1122 -
1123 - lsLoadNext();
1124 - })();
1125 - </script>
1126 - <script type="text/javascript">
1127 - (function(){
1128 - <?php if ( null !== $realtime_ingest ) : ?>
1129 - window.LASSO_LITE_REALTIME_INGEST = <?php echo wp_json_encode( $realtime_ingest ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>;
1130 - <?php endif; ?>
1131 - var lsInitialized = false;
1132 - function lsDoInit(detail){
1133 - if (lsInitialized) return;
1134 - lsInitialized = true;
1135 - try {
1136 - (detail && detail.init ? detail : (window.LSAFFEvents || {})).init({
1137 - 'lsid': '<?php echo $lsid; // phpcs:ignore ?>',
1138 - 'pid': '<?php echo get_the_ID(); // phpcs:ignore ?>',
1139 - 'ipa': '<?php echo $is_ip_anonymization; // phpcs:ignore ?>',
1140 - 'performance': '1',
1141 - 'matching': '<?php echo $lasso_options['auto_upgrade_eligible_links'] ? 1 : 0; ?>',
1142 - });
1143 - } catch (err) {
1144 - }
1145 - }
1146 -
1147 - var lsPollCount = 0;
1148 - var lsMaxPollAttempts = 50;
1149 - var lsPollTimer = null;
1150 - function lsStartPolling() {
1151 - if (lsPollTimer) return;
1152 - lsPollTimer = setInterval(function(){
1153 - if (lsInitialized) { clearInterval(lsPollTimer); return; }
1154 - if (window.LSAFFEvents && typeof window.LSAFFEvents.init === 'function') {
1155 - lsDoInit(window.LSAFFEvents);
1156 - clearInterval(lsPollTimer);
1157 - return;
1158 - }
1159 - lsPollCount++;
1160 - if (lsPollCount > lsMaxPollAttempts) { // ~5s at 100ms
1161 - clearInterval(lsPollTimer);
1162 - }
1163 - }, 100);
1164 - }
1165 -
1166 - if (window.LSAFFEvents && typeof window.LSAFFEvents.init === 'function') {
1167 - lsDoInit(window.LSAFFEvents);
1168 - } else {
1169 - document.addEventListener('LSAFFEventLoaded', function(e){
1170 - lsDoInit(e.detail);
1171 - }, { once: true });
1172 - lsStartPolling();
1173 - }
1174 - })();
1175 - </script>
1176 - <?php
1177 - endif;
1178 - // @codeCoverageIgnoreEnd
1179 - }
1180 -
1181 - /**
1182 - * Elementor Init Hook
1183 - *
1184 - * @codeCoverageIgnore Coverage ignore.
1185 - */
1186 - public function elementor_init() {
1187 - // ? This runs on elementor/init only — Pro owns Elementor when affiliate-plugin is active.
1188 - if ( Helper::is_lasso_pro_installed() ) {
1189 - return;
1190 - }
1191 -
1192 - // ? Do not gate on is_plugin_active( 'elementor/elementor.php' ): custom paths / load order can false-negative while Elementor is clearly bootstrapped (this hook).
1193 - if ( class_exists( 'Elementor\Widget_Base' ) && class_exists( 'Elementor\Controls_Manager' ) ) {
1194 - add_action( 'elementor/widgets/register', array( $this, 'register_widget_lasso_shortcode' ) );
1195 - add_action( 'elementor/editor/before_enqueue_styles', array( $this, 'elementor_editor_styles' ) );
1196 - add_action( 'elementor/editor/before_enqueue_scripts', array( $this, 'elementor_editor_scripts' ) );
1197 - }
1198 -
1199 - // ? Move the scan post into the "elementor/document/after_save" action
1200 - add_action( 'elementor/document/after_save', array( $this, 'after_elementor_document_save' ), 10, 1 );
1201 - }
1202 -
1203 - /**
1204 - * Register lasso widget
1205 - *
1206 - * @param object $widgets_manager Widget manager.
1207 - *
1208 - * @codeCoverageIgnore Coverage ignore.
1209 - */
1210 - public function register_widget_lasso_shortcode( $widgets_manager ) {
1211 - require_once SIMPLE_URLS_PLUGIN_PATH . '/libs/elementor/widgets/lasso-shortcode.php';
1212 - $widgets_manager->register( new \Widget_Lasso_Shortcode() );
1213 - }
1214 -
1215 - /**
1216 - * Elementor load css
1217 - *
1218 - * @codeCoverageIgnore Coverage ignore.
1219 - */
1220 - public function elementor_editor_styles() {
1221 - wp_enqueue_style( 'wp-pointer' );
1222 - Helper::enqueue_style( 'lasso-elementor', 'lasso-elementor.css' );
1223 - }
1224 -
1225 - /**
1226 - * Elementor editor scripts (parity with Pro wp-pointer).
1227 - *
1228 - * @codeCoverageIgnore Coverage ignore.
1229 - */
1230 - public function elementor_editor_scripts() {
1231 - wp_enqueue_script( 'wp-pointer' );
1232 - if ( ! Helper::is_lite_using_new_ui() ) {
1233 - return;
1234 - }
1235 - wp_enqueue_script( 'jquery' );
1236 - Helper::enqueue_script( 'lasso-modal-js', 'lasso-modal.js', array( 'jquery' ), true );
1237 - Helper::enqueue_script( 'lasso-elementor', 'lasso-elementor.js', array( 'jquery', SIMPLE_URLS_SLUG . '-lasso-modal-js' ), true );
1238 - Helper::enqueue_script( 'lasso-lite-display-modal', 'lasso-lite-display-modal.js', array( 'jquery', SIMPLE_URLS_SLUG . '-lasso-elementor' ), true );
1239 - }
1240 -
1241 - /**
1242 - * Move the scan post into the "elementor/document/after_save" action
1243 - *
1244 - * @param object $document Elementor document.
1245 - *
1246 - * @codeCoverageIgnore Coverage ignore.
1247 - */
1248 - public function after_elementor_document_save( $document ) {
1249 - $post = $document->get_post();
1250 - }
1251 -
1252 - /**
1253 - * Exclude Lasso performance JS from WP Rocket cache
1254 - *
1255 - * @param array $excluded_js Excluded JS.
1256 - * @return array
1257 - */
1258 - public function exclude_lasso_performance_js_from_rocket_cache( $excluded_js ) {
1259 - $excluded_js[] = 'lasso-performance.min.js';
1260 - return $excluded_js;
1261 - }
1262 -
1263 - /**
1264 - * Check is Elementor editor page
1265 - *
1266 - * @return bool
1267 - */
1268 - public static function is_editor() {
1269 - $http_referer = Helper::get_server_param( 'HTTP_REFERER' );
1270 - $query_str = wp_parse_url( $http_referer, PHP_URL_QUERY );
1271 - parse_str( $query_str, $query_params );
1272 -
1273 - return isset( $query_params['action'] ) && 'elementor' === $query_params['action'];
1274 - }
1275 -
1276 - /**
1277 - * Register rewrite rule for /js/connect-snippet.min.js
1278 - */
1279 - public static function lasso_register_connect_snippet_rewrite() {
1280 - $snippet_query = Helper::get_snippet_query();
1281 - add_rewrite_rule( '^js/snippet\.min\.js$', 'index.php?' . $snippet_query . '=1', 'top' );
1282 -
1283 - $beacon_path = ltrim( LASSO_BEACON_VANITY_PATH, '/' );
1284 - $beacon_rule = '^' . preg_quote( $beacon_path, '/' ) . '$';
1285 - add_rewrite_rule( $beacon_rule, 'index.php?' . LASSO_BEACON_QUERY . '=1', 'top' );
1286 - }
1287 -
1288 - /**
1289 - * Flush rewrites after plugin upgrades via WP upgrader
1290 - *
1291 - * @param object $upgrader Upgrader instance.
1292 - * @param array $options Upgrader options.
1293 - * @return void
1294 - */
1295 - public function lasso_connect_snippet_flush_on_upgrade( $upgrader, $options ) {
1296 - if ( empty( $options['type'] ) || 'plugin' !== $options['type'] ) {
1297 - return;
1298 - }
1299 -
1300 - // ? Supported actions: update (bulk/single) and install (upload .zip)
1301 - $action = isset( $options['action'] ) ? $options['action'] : '';
1302 - if ( ! in_array( $action, array( 'update', 'install' ), true ) ) {
1303 - return;
1304 - }
1305 -
1306 - $targets = array();
1307 - if ( ! empty( $options['plugins'] ) && is_array( $options['plugins'] ) ) {
1308 - $targets = $options['plugins'];
1309 - } elseif ( ! empty( $options['plugin'] ) && is_string( $options['plugin'] ) ) {
1310 - $targets = array( $options['plugin'] );
1311 - }
1312 -
1313 - // ? Fallback detection using Plugin_Upgrader->new_plugin_data when targets are missing
1314 - if ( empty( $targets ) && is_object( $upgrader ) && $upgrader instanceof \Plugin_Upgrader ) {
1315 - $plugin_data = isset( $upgrader->new_plugin_data ) ? $upgrader->new_plugin_data : array();
1316 - $plugin_name = is_array( $plugin_data ) && isset( $plugin_data['Name'] ) ? $plugin_data['Name'] : '';
1317 - if ( 'Lasso Lite' === $plugin_name ) {
1318 - $this->lasso_register_connect_snippet_rewrite();
1319 - flush_rewrite_rules();
1320 - return;
1321 - }
1322 - }
1323 -
1324 - if ( empty( $targets ) ) {
1325 - return;
1326 - }
1327 -
1328 - $plugin_file = plugin_basename( SIMPLE_URLS_PLUGIN_PATH . '/plugin.php' );
1329 - if ( in_array( $plugin_file, $targets, true ) ) {
1330 - $this->lasso_register_connect_snippet_rewrite();
1331 - flush_rewrite_rules();
1332 - }
1333 - }
1334 -
1335 - /**
1336 - * One-time rewrite flush after upgrade so /js/e is persisted (upgrader runs old code).
1337 - *
1338 - * @return void
1339 - */
1340 - public function maybe_flush_vanity_rewrites_on_upgrade() {
1341 - if ( '1' !== (string) Helper::get_option( 'pending_vanity_rewrite_flush', '0' ) ) {
1342 - return;
1343 - }
1344 -
1345 - self::lasso_register_connect_snippet_rewrite();
1346 - flush_rewrite_rules();
1347 - Helper::update_option( 'pending_vanity_rewrite_flush', '0' );
1348 - }
1349 -
1350 - /**
1351 - * Allow lasso_connect_snippet as query var
1352 - *
1353 - * @param array $vars Query vars.
1354 - * @return array
1355 - */
1356 - public function lasso_connect_snippet_query_var( $vars ) {
1357 - $snippet_query = Helper::get_snippet_query();
1358 - $vars[] = $snippet_query;
1359 - $vars[] = LASSO_BEACON_QUERY;
1360 - return $vars;
1361 - }
1362 -
1363 - /**
1364 - * Serve vanity JS: /js/connect-snippet.min.js
1365 - *
1366 - * Outputs the connect-snippet.min.js from plugin assets with proper caching headers.
1367 - */
1368 - public function serve_connect_snippet() {
1369 - $snippet_query = Helper::get_snippet_query();
1370 - // Allow serving by pretty path even if rewrite rules aren't flushed yet
1371 - $req_uri = Helper::get_server_param( 'REQUEST_URI' );
1372 - $req_path = is_string( $req_uri ) ? wp_parse_url( $req_uri, PHP_URL_PATH ) : '';
1373 - $is_snippet_path = is_string( $req_path ) && rtrim( $req_path, '/' ) === LASSO_SNIPPET_VANITY_PATH_LITE;
1374 - if ( intval( get_query_var( $snippet_query ) ) !== 1 && ! $is_snippet_path ) {
1375 - return;
1376 - }
1377 -
1378 - $file_path = LASSO_CONNECT_SNIPPET_FILE_LITE;
1379 - if ( ! file_exists( $file_path ) ) {
1380 - status_header( 404 );
1381 - exit;
1382 - }
1383 -
1384 - // Headers
1385 - header( 'Content-Type: application/javascript; charset=UTF-8' );
1386 - header( 'X-Content-Type-Options: nosniff' );
1387 -
1388 - // Cache headers with support for 304
1389 - $last_modified = gmdate( 'D, d M Y H:i:s', filemtime( $file_path ) ) . ' GMT';
1390 - $etag = 'W/"' . md5( $last_modified . filesize( $file_path ) ) . '"';
1391 -
1392 - header( 'Last-Modified: ' . $last_modified );
1393 - header( 'ETag: ' . $etag );
1394 -
1395 - // Cache: If version query is present, cache for 1 day; else short TTL
1396 - $ver = isset( $_GET['ver'] ) ? sanitize_text_field( wp_unslash( $_GET['ver'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
1397 - if ( ! empty( $ver ) ) {
1398 - header( 'Cache-Control: public, max-age=86400' );
1399 - } else {
1400 - header( 'Cache-Control: public, max-age=300' );
1401 - }
1402 -
1403 - // Handle conditional requests
1404 - $if_none_match = isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) ? sanitize_text_field( trim( wp_unslash( $_SERVER['HTTP_IF_NONE_MATCH'] ) ) ) : '';
1405 - $if_modified_since = isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ? sanitize_text_field( trim( wp_unslash( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) ) : '';
1406 -
1407 - if ( $if_none_match === $etag || $if_modified_since === $last_modified ) {
1408 - status_header( 304 );
1409 - exit;
1410 - }
1411 -
1412 - ob_start();
1413 - $read_result = @readfile( $file_path );
1414 - if ( false === $read_result ) {
1415 - if ( ob_get_length() ) {
1416 - ob_end_clean();
1417 - }
1418 - status_header( 500 );
1419 - exit;
1420 - }
1421 - ob_end_flush();
1422 - exit;
1423 - }
1424 -
1425 - /**
1426 - * Resolve a beacon proxy request when path or query var matches.
1427 - *
1428 - * @param string|null $raw_body Optional body override for tests; null reads php://input.
1429 - * @return array{status:int,body:string}|null Null when not a beacon request.
1430 - */
1431 - public function resolve_beacon_proxy_request( $raw_body = null ) {
1432 - $req_uri = Helper::get_server_param( 'REQUEST_URI' );
1433 - $req_path = is_string( $req_uri ) ? wp_parse_url( $req_uri, PHP_URL_PATH ) : '';
1434 - $is_path = is_string( $req_path ) && rtrim( $req_path, '/' ) === LASSO_BEACON_VANITY_PATH;
1435 - $is_query = 1 === intval( get_query_var( LASSO_BEACON_QUERY ) );
1436 - if ( ! $is_path && ! $is_query ) {
1437 - return null;
1438 - }
1439 -
1440 - $method = Helper::get_server_param( 'REQUEST_METHOD' );
1441 - if ( null === $raw_body ) {
1442 - $raw_body = Beacon_Proxy::read_bounded_body();
1443 - }
1444 -
1445 - return $this->handle_beacon_proxy( $method ? $method : 'GET', $raw_body );
1446 - }
1447 -
1448 - /**
1449 - * Send beacon proxy HTTP response (no exit).
1450 - *
1451 - * @param array{status:int,body:string} $result Response from handle_beacon_proxy.
1452 - * @return void
1453 - */
1454 - public function emit_beacon_proxy_response( $result ) {
1455 - status_header( intval( $result['status'] ) );
1456 - header( 'Content-Type: text/plain; charset=UTF-8' );
1457 - header( 'Cache-Control: no-store' );
1458 - if ( '' !== $result['body'] ) {
1459 - echo $result['body']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1460 - }
1461 - }
1462 -
1463 - /**
1464 - * First-party POST /js/e → codedrink.com/js/e (EasyPrivacy).
1465 - */
1466 - public function serve_beacon_proxy() {
1467 - $result = $this->resolve_beacon_proxy_request();
1468 - if ( null === $result ) {
1469 - return;
1470 - }
1471 -
1472 - $this->emit_beacon_proxy_response( $result );
1473 - exit;
1474 - }
1475 -
1476 - /**
1477 - * Plan and forward a beacon request (testable core of serve_beacon_proxy).
1478 - *
1479 - * @param string $method HTTP method.
1480 - * @param string $raw_body Raw request body.
1481 - * @return array{status:int,body:string}
1482 - */
1483 - public function handle_beacon_proxy( $method, $raw_body ) {
1484 - $plan = Beacon_Proxy::plan( $method, is_string( $raw_body ) ? $raw_body : '' );
1485 -
1486 - if ( empty( $plan['ok'] ) ) {
1487 - return array(
1488 - 'status' => intval( $plan['status'] ),
1489 - 'body' => '',
1490 - );
1491 - }
1492 -
1493 - $response = wp_remote_post(
1494 - $plan['upstream'],
1495 - array(
1496 - 'timeout' => 3,
1497 - 'sslverify' => true,
1498 - 'headers' => array(
1499 - 'Content-Type' => 'text/plain; charset=utf-8',
1500 - ),
1501 - 'body' => $plan['body'],
1502 - )
1503 - );
1504 -
1505 - if ( is_wp_error( $response ) ) {
1506 - return array(
1507 - 'status' => 200,
1508 - 'body' => '',
1509 - );
1510 - }
1511 -
1512 - $status = intval( wp_remote_retrieve_response_code( $response ) );
1513 - if ( $status < 200 || $status > 299 ) {
1514 - return array(
1515 - 'status' => 200,
1516 - 'body' => '',
1517 - );
1518 - }
1519 -
1520 - return array(
1521 - 'status' => $status,
1522 - 'body' => (string) wp_remote_retrieve_body( $response ),
1523 - );
1524 - }
1525 -
1526 - /**
1527 - * Add stable frontend body class from LASSO_LITE_VERSION (e.g. lasso-lite-v145).
1528 - *
1529 - * @param array<int, string> $classes Body classes.
1530 - * @return array<int, string>
1531 - */
1532 - public function filter_body_class_lasso_lite_version( $classes ) {
1533 - $extra = $this->get_lasso_lite_version_body_class();
1534 - if ( '' !== $extra ) {
1535 - $classes[] = $extra;
1536 - }
1537 - return $classes;
1538 - }
1539 -
1540 - /**
1541 - * CSS-safe class segment: lasso-lite-v{version}.
1542 - *
1543 - * @return string
1544 - */
1545 - private function get_lasso_lite_version_body_class() {
1546 - if ( ! defined( 'LASSO_LITE_VERSION' ) ) {
1547 - return '';
1548 - }
1549 - return 'lasso-lite-v' . sanitize_html_class( str_replace( '.', '-', (string) LASSO_LITE_VERSION ) );
1550 830 }
1551 831 }