From 24791b17c85ac129519c088ffedc8ad559aaa6cb Mon Sep 17 00:00:00 2001 From: Pablo Amato Date: Mon, 24 Oct 2016 17:38:59 -0300 Subject: [PATCH 1/2] Enqueue Tour JS if needed Use wp_enqueue_script instead of outputting the js. Was triggering an undefined function JS error if 'lasso' was loaded in footer --- public/includes/assets.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/public/includes/assets.php b/public/includes/assets.php index dbc1be5..5fe8fb5 100644 --- a/public/includes/assets.php +++ b/public/includes/assets.php @@ -184,7 +184,12 @@ public function scripts(){ wp_enqueue_script('lasso', LASSO_URL. "/public/assets/js/lasso{$postfix}.js", array('jquery'), LASSO_VERSION, true); } wp_localize_script('lasso', 'lasso_editor', apply_filters('lasso_localized_objects', $objects ) ); - + + //enqueue js if tour is not hidden + $tour_hidden = get_user_meta( get_current_user_ID(), 'lasso_hide_tour', true ); + if ( lasso_user_can() && !$tour_hidden ){ + wp_enqueue_script('lasso', LASSO_URL. "/public/assets/js/tour.js", array('jquery', 'lasso'), LASSO_VERSION, true); + } } From ad9e4aaf2a58e612c814f2b16105c0cd14423a25 Mon Sep 17 00:00:00 2001 From: Pablo Amato Date: Tue, 25 Oct 2016 18:27:25 -0300 Subject: [PATCH 2/2] update JS handler --- public/includes/assets.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/includes/assets.php b/public/includes/assets.php index 5fe8fb5..c11e474 100644 --- a/public/includes/assets.php +++ b/public/includes/assets.php @@ -188,7 +188,7 @@ public function scripts(){ //enqueue js if tour is not hidden $tour_hidden = get_user_meta( get_current_user_ID(), 'lasso_hide_tour', true ); if ( lasso_user_can() && !$tour_hidden ){ - wp_enqueue_script('lasso', LASSO_URL. "/public/assets/js/tour.js", array('jquery', 'lasso'), LASSO_VERSION, true); + wp_enqueue_script('lasso-tour', LASSO_URL. "/public/assets/js/tour.js", array('jquery', 'lasso'), LASSO_VERSION, true); } }