From 51cbadaa0ea7417355d1c9d0a0d07514c8488b92 Mon Sep 17 00:00:00 2001 From: Anthony Talarico Date: Mon, 16 May 2016 12:00:42 -0400 Subject: [PATCH] adding test for elements in shortcode builder, adding !wp_script_is --- classes/glmPluginSupport.php | 10 +++++++--- js/shortcodeBuilder.js | 5 +++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/classes/glmPluginSupport.php b/classes/glmPluginSupport.php index 16f96523..634816ac 100644 --- a/classes/glmPluginSupport.php +++ b/classes/glmPluginSupport.php @@ -614,14 +614,18 @@ class GlmPluginSupport public function glmMembersShortcode(){ - // load shortcodeBuilder.js when the shortcode function has been fired - add_action('admin_print_styles-post.php', 'custom_js_css'); - add_action('admin_print_styles-post-new.php', 'custom_js_css'); + // load shortcodeBuilder.js when the shortcode function has been fired if it hasn't been enqueued yet + if( ! wp_script_is( 'jquery-ui-dialog', 'enqueued' ) ){ + wp_enqueue_script('jquery-ui-dialog', false, array('jquery'), false, true); + wp_enqueue_style('jquery-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css'); + } function custom_js_css() { wp_enqueue_script('your-meta-box', GLM_MEMBERS_PLUGIN_URL. '/js/shortcodeBuilder.js', array('jquery'), null, true); } + add_action('admin_print_styles-post.php', 'custom_js_css'); + add_action('admin_print_styles-post-new.php', 'custom_js_css'); reset($this->config['addOns']); foreach ($this->config['addOns'] as $a) { $cssFile = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH.$a['slug'].'/css/admin.css'; diff --git a/js/shortcodeBuilder.js b/js/shortcodeBuilder.js index 34b0be10..8e794fc0 100644 --- a/js/shortcodeBuilder.js +++ b/js/shortcodeBuilder.js @@ -18,8 +18,9 @@ jQuery(document).ready(function ($) { $("#shortcodeDropdown").on("change", function () { // reset the dropdowns and checkbox if when switching shortcodes document.getElementById('category-scDropdown').options[0].selected = 'selected'; - document.getElementById('blank-start-scDropdown').options[0].selected = 'selected'; - if(document.getElementById('id-scDropdown').length > 0) + if($('#blank-start-scDropdown').length) + document.getElementById('blank-start-scDropdown').options[0].selected = 'selected'; + if($('#id-scDropdown').length) document.getElementById('id-scDropdown').options[0].selected = 'selected'; UncheckAll(); -- 2.17.1