From: Steve Sutton Date: Tue, 5 Jul 2016 15:59:10 +0000 (-0400) Subject: Only do these for category shortcodes X-Git-Tag: v2.1.16^2~4 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=33886122c121b35e2ce47ab965b65b310ba5fa92;p=WP-Plugins%2Fglm-member-db.git Only do these for category shortcodes This gets tricky if the have other shortcodes in the text. --- diff --git a/js/shortcodeBuilder.js b/js/shortcodeBuilder.js index 4febe96a..772bd685 100644 --- a/js/shortcodeBuilder.js +++ b/js/shortcodeBuilder.js @@ -141,14 +141,16 @@ jQuery(document).ready(function ($) { if(editor_shortcodes){ // get the number of instances of shortcodes with the category option var number_of_categories = (editor_shortcodes.match(/glm-members-list category="(.*?)"/g) || []).length; - $('#glmRemoveShortCode').show(); - $('#generate').hide(); + if ( number_of_categories ) { + $('#glmRemoveShortCode').show(); + $('#generate').hide(); + } } else { $('#glmRemoveShortCode').hide(); $('#generate').show(); } - if ( editor_shortcodes ) { + if ( editor_shortcodes && number_of_categories) { if ( editor_shortcodes.match( /glm-members-list .* amenity-groups="(.*?)"/ ) !== null ) { amenityGroups = editor_shortcodes.match( /glm-members-list .* amenity-groups="(.*?)"/ )[1]; groups_id = amenityGroups.split(','); @@ -688,7 +690,7 @@ jQuery(document).ready(function ($) { var view = document.getElementById('view-scDropdown'); var groups = document.getElementById('amenitygroup-scDropdown'); - if ( editor_shortcodes ) { + if ( editor_shortcodes && number_of_categories) { if ( number_of_categories ) { $('#shortcodeDropdown').val('glm-members-list'); $('#shortcodeDropdown').change(); @@ -703,7 +705,7 @@ jQuery(document).ready(function ($) { $('#shortcodeDropdown').change(); $('#shortcodeDropdown').hide(); } - if ( scd && !editor_shortcodes ) { + if ( scd && !editor_shortcodes && !number_of_categories) { window.onload = document.getElementById('shortcodeDropdown').options[0].selected = 'selected'; } if ( catscd ) {