Custom Menu Wizard Widget - Version 3.0.4

Version Description

  • bugfix : corrected the display of the "No Current Item!" warning in the "assist"
  • bugfix : corrected the enabling/disabling of a couple of fields in the widget form, and tweaked the indentation for better responsiveness
  • bugfix : corrected the options setup when in accessibility mode with javascript enabled
  • addition : added a warning about the accuracy of the shortcode when javascript is disabled
  • addition : extended the All Root Items inclusion to be a selectable number of levels (as per the Exclusions by Level)
Download this release

Release Info

Developer wizzud
Plugin Icon 128x128 Custom Menu Wizard Widget
Version 3.0.4
Comparing to
See all releases

Code changes from version 3.0.3 to 3.0.4

custom-menu-wizard.css CHANGED
@@ -17,8 +17,8 @@
17
  .widget-custom-menu-wizard-onchange .cmw-colour-grey input {color:#7F7F7F}
18
  .widget-custom-menu-wizard-onchange small.cmw-colour-grey {vertical-align:top;}
19
  .widget-custom-menu-wizard-onchange .cmw-display-none {display:none;}
20
- .widget-custom-menu-wizard-onchange .cmw-followed-by {margin-right:1em;}
21
- .widget-custom-menu-wizard-onchange .cmw-indented {margin-left:1em;}
22
  .widget-custom-menu-wizard-onchange .cmw-maxwidth-twothirds {max-width:66% !important;}
23
  .widget-custom-menu-wizard-onchange .cmw-off-the-page {display:none; position:absolute; left:-5000px; top:-5000px;}
24
  .widget-custom-menu-wizard-onchange .cmw-pseudo-para {margin:1em 0;}
@@ -45,7 +45,8 @@ a.widget-custom-menu-wizard-fieldset.cmw-collapsed-fieldset:active {background-p
45
  .no-js a.widget-custom-menu-wizard-fieldset.cmw-collapsed-fieldset:active {background-position:100% -112px;}
46
  .no-js .widget-custom-menu-wizard-onchange .cmw-start-fieldset-collapsed {display:block;}
47
  .no-js a.widget-custom-menu-wizard-fieldset {background-image:none;}
48
- .no-js .widget-custom-menu-wizard-assist {display:none;}
 
49
  /*...customizer tweaks...*/
50
  .wp-customizer .widget-custom-menu-wizard-onchange input[type="text"] {margin:1px 0;}
51
  /*...warnings...*/
17
  .widget-custom-menu-wizard-onchange .cmw-colour-grey input {color:#7F7F7F}
18
  .widget-custom-menu-wizard-onchange small.cmw-colour-grey {vertical-align:top;}
19
  .widget-custom-menu-wizard-onchange .cmw-display-none {display:none;}
20
+ .widget-custom-menu-wizard-onchange .cmw-followed-by:after {content:""; display:inline-block; width:1em;}
21
+ .widget-custom-menu-wizard-onchange .cmw-indented {margin-left:1em; text-indent:-1em;}
22
  .widget-custom-menu-wizard-onchange .cmw-maxwidth-twothirds {max-width:66% !important;}
23
  .widget-custom-menu-wizard-onchange .cmw-off-the-page {display:none; position:absolute; left:-5000px; top:-5000px;}
24
  .widget-custom-menu-wizard-onchange .cmw-pseudo-para {margin:1em 0;}
45
  .no-js a.widget-custom-menu-wizard-fieldset.cmw-collapsed-fieldset:active {background-position:100% -112px;}
46
  .no-js .widget-custom-menu-wizard-onchange .cmw-start-fieldset-collapsed {display:block;}
47
  .no-js a.widget-custom-menu-wizard-fieldset {background-image:none;}
48
+ .no-js .widget-custom-menu-wizard-assist,
49
+ .js .widget-custom-menu-wizard-onchange .cmw-shortcode-nojs {display:none;}
50
  /*...customizer tweaks...*/
51
  .wp-customizer .widget-custom-menu-wizard-onchange input[type="text"] {margin:1px 0;}
52
  /*...warnings...*/
custom-menu-wizard.js CHANGED
@@ -74,6 +74,26 @@ jQuery(function($){
74
  findOnchange = function(below, above){
75
  return (!below ? above : below)[!below ? 'closest' : 'find'](widgetCustomMenuWizardClass('onchange', 1));
76
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  /**
78
  * gets the widget's field values
79
  * @param {object} oc jQuery of the widget's onchange wrapper
@@ -83,7 +103,7 @@ jQuery(function($){
83
  var settings = {},
84
  legacyVersion = oc.data('cmwDialogVersion') === '2.1.0',
85
  csv = {items:1, exclude:1},
86
- keepAsString = $.extend({branch_start:1, exclude_level:1}, csv);
87
  $.each(oc.find(':input').serializeArray(), function(i, v){
88
  var name = v.name.replace(/.*\[([^\]]+)\]$/, '$1'),
89
  val = !keepAsString[name] && /^-?\d+$/.test(v.value) ? parseInt(v.value, 10) : v.value;
@@ -645,7 +665,7 @@ jQuery(function($){
645
  }
646
  });
647
 
648
- oc.find('.cmw-exclude-level').each(function(){
649
  var self = $(this),
650
  options = self.find('option'),
651
  ct = (options.length - 1) / 3,
@@ -665,29 +685,23 @@ jQuery(function($){
665
  });
666
 
667
  //do the easy levels...
668
- oc.find('.cmw-level').each(function(){
669
  var self = $(this),
670
- ct = self.find('option').length;
 
 
 
 
 
671
  if(self.val() > maxLevel){
672
- self.val(1);
673
  }
674
- self.find('option').slice(maxLevel).remove();
 
 
675
  while(ct < maxLevel){
676
  ++ct;
677
- self.append( $('<option/>', {value:ct}).text(ct) );
678
- }
679
- });
680
- oc.find('.cmw-depth,.cmw-fallback-depth').each(function(){
681
- var self = $(this),
682
- ct = self.find('option').length,
683
- txt = ' ' + self.data().cmwTextLevels;
684
- if(self.val() > maxLevel){
685
- self.val(0);
686
- }
687
- self.find('option').slice(maxLevel + 1).remove();
688
- while(ct <= maxLevel){
689
  self.append( $('<option/>', {value:ct}).text(ct + txt) );
690
- ++ct;
691
  }
692
  });
693
  }, //end cmwAssist.setLevels()
@@ -701,7 +715,8 @@ jQuery(function($){
701
  byItems = oc.find('.cmw-byitems').prop('checked'),
702
  notByBranch = byItems || !byBranchCheckbox.prop('checked'),
703
  menuItems = oc.find('.cmw-assist-items'),
704
- selectedItem = parseInt(menuItems.val(), 10);
 
705
  //change of menu? : make sure the correct optgroup of menu items is used...
706
  if(target.hasClass('cmw-select-menu')){
707
  selectedItem = swapItems(menuItems, selectedItem, target[0].selectedIndex);
@@ -728,12 +743,13 @@ jQuery(function($){
728
  oc.find('.cmw-ancestors').val( target.val() );
729
  }
730
 
 
731
  $.each( //disable if...
732
  { '-ss' : byItems, //...is Items
733
- '-ud' : oc.find('.cmw-depth').val() < 1, //...is Unlimited Depth
734
  'not-br' : notByBranch, //...is NOT Branch
735
  'not-br-ci' : notByBranch || !!selectedItem, //...is NOT Branch:Current Item
736
- 'not-fb-pc' : !{'parent':1, 'current':1}[oc.find('.cmw-fallback').val()] //...is NOT fallback to parent or current
737
  },
738
  function(k, v){
739
  oc.find('.cmw-disableif' + k).toggleClass('cmw-colour-grey', v).find('input,select').prop('disabled', v);
@@ -807,6 +823,10 @@ jQuery(function($){
807
  args.ancestor_siblings = settings.ancestor_siblings;
808
  }
809
  }
 
 
 
 
810
  //exclusions by id...
811
  if(settings._exclude){
812
  args.exclude = [settings._exclude];
@@ -833,7 +853,7 @@ jQuery(function($){
833
  args.title_from = n;
834
  }
835
  //switches...
836
- for(n in {allow_all_root:1, siblings:1, include_root:1, flat_output:1, ol_root:1, ol_sub:1}){
837
  if(settings[n]){
838
  args[n] = 1;
839
  }
@@ -911,16 +931,12 @@ jQuery(function($){
911
 
912
  //ticks and crosses (need to be run against the full set of items)...
913
  exclusions = filterTickCross(items, settings, 'cross');
 
 
914
  if(byItems){
915
- //primary filter : items...
916
  items = filterTickCross(items, settings, 'tick');
917
  }
918
 
919
- //if current item is definitely needed and is not present, cop out...
920
- if(items.length && !currentItemLI.length && (!!settings.contains_current || ciBranch)){
921
- items = $([]);
922
- }
923
-
924
  //primary filter : branch...
925
  if(byBranch && items.length){
926
  topOfBranch = ciBranch ? currentItemLI : items.filter('[data-itemid=' + settings.branch + ']');
@@ -942,6 +958,13 @@ jQuery(function($){
942
  items = items.not( j.join(',') );
943
  }
944
 
 
 
 
 
 
 
 
945
  //check for current item after primary...
946
  if(settings.contains_current === 'primary' && items.length && !currentItemLI.is(items)){
947
  items = $([]);
@@ -1049,6 +1072,7 @@ jQuery(function($){
1049
  }
1050
 
1051
  //branch inclusions...
 
1052
  if(byBranch && items.length){
1053
  //branch ancestors, possibly with their siblings : but only if the original branch item is either
1054
  //in items or is below lastVisibleLevel; ALSO, do not show ancestors below lastVisibleLevel!
@@ -1098,10 +1122,14 @@ jQuery(function($){
1098
  }
1099
  }
1100
  //other inclusions...
1101
- if(items.length && settings.include_root){
1102
- j = items.length;
1103
- items = items.add( topOfMenu.find('.level-1') );
1104
- hasIncl += items.length - j;
 
 
 
 
1105
  }
1106
 
1107
  //check for current item after inclusions...
@@ -1111,25 +1139,18 @@ jQuery(function($){
1111
 
1112
  //exclusions...
1113
  if(items.length && exclusions.length){
 
1114
  j = items.length;
1115
  items = items.not(exclusions);
1116
  hasExcl += j - items.length;
1117
  }
1118
  if(items.length && !!settings.exclude_level){
1119
- k = settings.exclude_level.match(/^(\d+)(\+|-)?$/);
1120
- k = k ? [parseInt(k[1], 10), k[2] || ''] : [];
1121
- if(k[0] > 0){
1122
- for(j = [], i = 1; i <= maxLevel; i++){
1123
- if( i === k[0] || (k[1] === '-' && i < k[0]) || (k[1] === '+' && i > k[0]) ){
1124
- j.push('.level-' + i);
1125
- }
1126
- }
1127
- if(j.length){
1128
- //filter to remove...
1129
- k = items.length;
1130
- items = items.not( j.join(',') );
1131
- hasExcl += k - items.length;
1132
- }
1133
  }
1134
  }
1135
 
@@ -1156,7 +1177,7 @@ jQuery(function($){
1156
  //show/hide the fall back message...
1157
  dialog.find('.cmw-demo-fallback').data('fellback', fallback).toggleClass('updated', !!fallback);
1158
  //show/hide the 'select current item' prompt...
1159
- dialog.find('.cmw-demo-setcurrent').toggleClass('error', !currentItemLI.length && (settings.contains_current || ciBranch));
1160
  //...and the inclusions/exclusions messages...
1161
  i = {inclusions:hasIncl, exclusions:hasExcl};
1162
  for(j in i){
@@ -1203,7 +1224,7 @@ jQuery(function($){
1203
  theSelect = oc.find('.cmw-depth');
1204
  level = theSelect.val();
1205
  ct = theSelect.find('option').length;
1206
- txt = ' ' + theSelect.data().cmwTextLevels;
1207
  if(level > maxLevel){
1208
  theSelect.val(0); //=unlimited
1209
  }
@@ -1521,4 +1542,8 @@ jQuery(function($){
1521
  return false;
1522
  });
1523
 
 
 
 
 
1524
  });
74
  findOnchange = function(below, above){
75
  return (!below ? above : below)[!below ? 'closest' : 'find'](widgetCustomMenuWizardClass('onchange', 1));
76
  },
77
+ /**
78
+ * given an option in the form of one-or-more digits, optionally followed by a plus or minus, return the relevant classes
79
+ * @param {string} option A setting, eg. settings.exclude_level
80
+ * @param {integer} maxLevel Maximum number of levels available
81
+ * @return {string} CSV of classes, eg. '.level-1,'level-2' for option='2-' (or option='1+' if maxLevel=2)
82
+ */
83
+ getLevelClasses = function(option, maxLevel){
84
+ var rtn = [],
85
+ k = option.match(/^(\d+)(\+|-)?$/),
86
+ i;
87
+ k = k ? [parseInt(k[1], 10), k[2] || ''] : [];
88
+ if(k[0] > 0){
89
+ for(i = 1; i <= maxLevel; i++){
90
+ if( i === k[0] || (k[1] === '-' && i < k[0]) || (k[1] === '+' && i > k[0]) ){
91
+ rtn.push('.level-' + i);
92
+ }
93
+ }
94
+ }
95
+ return rtn.join(',');
96
+ },
97
  /**
98
  * gets the widget's field values
99
  * @param {object} oc jQuery of the widget's onchange wrapper
103
  var settings = {},
104
  legacyVersion = oc.data('cmwDialogVersion') === '2.1.0',
105
  csv = {items:1, exclude:1},
106
+ keepAsString = $.extend({branch_start:1, exclude_level:1, include_level:1}, csv);
107
  $.each(oc.find(':input').serializeArray(), function(i, v){
108
  var name = v.name.replace(/.*\[([^\]]+)\]$/, '$1'),
109
  val = !keepAsString[name] && /^-?\d+$/.test(v.value) ? parseInt(v.value, 10) : v.value;
665
  }
666
  });
667
 
668
+ oc.find('.cmw-include-level,.cmw-exclude-level').each(function(){
669
  var self = $(this),
670
  options = self.find('option'),
671
  ct = (options.length - 1) / 3,
685
  });
686
 
687
  //do the easy levels...
688
+ oc.find('.cmw-set-levels').each(function(){
689
  var self = $(this),
690
+ data = self.data(),
691
+ txt = data.cmwTextLevels || '',
692
+ leave = data.cmwSetLevels || 0,
693
+ opts = self.find('option'),
694
+ ct = opts.length - leave;
695
+ //if current value exceeds maxLevel, reset to first option...
696
  if(self.val() > maxLevel){
697
+ self.val( opts.eq(0).val() );
698
  }
699
+ //remove anything above maxLevel...
700
+ self.find('option').slice(leave + maxLevel).remove();
701
+ //append enough new options to bring up to maxLevel...
702
  while(ct < maxLevel){
703
  ++ct;
 
 
 
 
 
 
 
 
 
 
 
 
704
  self.append( $('<option/>', {value:ct}).text(ct + txt) );
 
705
  }
706
  });
707
  }, //end cmwAssist.setLevels()
715
  byItems = oc.find('.cmw-byitems').prop('checked'),
716
  notByBranch = byItems || !byBranchCheckbox.prop('checked'),
717
  menuItems = oc.find('.cmw-assist-items'),
718
+ selectedItem = parseInt(menuItems.val(), 10),
719
+ fallback;
720
  //change of menu? : make sure the correct optgroup of menu items is used...
721
  if(target.hasClass('cmw-select-menu')){
722
  selectedItem = swapItems(menuItems, selectedItem, target[0].selectedIndex);
743
  oc.find('.cmw-ancestors').val( target.val() );
744
  }
745
 
746
+ fallback = oc.find('.cmw-fallback').val();
747
  $.each( //disable if...
748
  { '-ss' : byItems, //...is Items
749
+ '-ud' : byItems || oc.find('.cmw-depth').val() < 1, //...is Unlimited Depth
750
  'not-br' : notByBranch, //...is NOT Branch
751
  'not-br-ci' : notByBranch || !!selectedItem, //...is NOT Branch:Current Item
752
+ 'not-fb-pc' : notByBranch || !!selectedItem || (fallback !== 'parent' && fallback !== 'current') //...is NOT fallback to parent or current
753
  },
754
  function(k, v){
755
  oc.find('.cmw-disableif' + k).toggleClass('cmw-colour-grey', v).find('input,select').prop('disabled', v);
823
  args.ancestor_siblings = settings.ancestor_siblings;
824
  }
825
  }
826
+ //inclusions by level...
827
+ if(settings.include_level){
828
+ args.include_level = [settings.include_level];
829
+ }
830
  //exclusions by id...
831
  if(settings._exclude){
832
  args.exclude = [settings._exclude];
853
  args.title_from = n;
854
  }
855
  //switches...
856
+ for(n in {allow_all_root:1, siblings:1, flat_output:1, ol_root:1, ol_sub:1}){
857
  if(settings[n]){
858
  args[n] = 1;
859
  }
931
 
932
  //ticks and crosses (need to be run against the full set of items)...
933
  exclusions = filterTickCross(items, settings, 'cross');
934
+
935
+ //primary filter : items...
936
  if(byItems){
 
937
  items = filterTickCross(items, settings, 'tick');
938
  }
939
 
 
 
 
 
 
940
  //primary filter : branch...
941
  if(byBranch && items.length){
942
  topOfBranch = ciBranch ? currentItemLI : items.filter('[data-itemid=' + settings.branch + ']');
958
  items = items.not( j.join(',') );
959
  }
960
 
961
+ //check for current item in menu...
962
+ //NB: this used to be done (pre 3.0.4) in front of the branch primary filter, but that filter setup may now
963
+ // be needed, so this check has moved down so that all primary filters are done before checking
964
+ if(settings.contains_current === 'menu' && items.length && !currentItemLI.length){
965
+ items = $([]);
966
+ }
967
+
968
  //check for current item after primary...
969
  if(settings.contains_current === 'primary' && items.length && !currentItemLI.is(items)){
970
  items = $([]);
1072
  }
1073
 
1074
  //branch inclusions...
1075
+ //NB: only applicable if there are already items
1076
  if(byBranch && items.length){
1077
  //branch ancestors, possibly with their siblings : but only if the original branch item is either
1078
  //in items or is below lastVisibleLevel; ALSO, do not show ancestors below lastVisibleLevel!
1122
  }
1123
  }
1124
  //other inclusions...
1125
+ if(items.length && !!settings.include_level){
1126
+ k = getLevelClasses(settings.include_level, maxLevel);
1127
+ if(k){
1128
+ //find and add...
1129
+ j = items.length;
1130
+ items = items.add( topOfMenu.find(k) );
1131
+ hasIncl += items.length - j;
1132
+ }
1133
  }
1134
 
1135
  //check for current item after inclusions...
1139
 
1140
  //exclusions...
1141
  if(items.length && exclusions.length){
1142
+ //filter to remove...
1143
  j = items.length;
1144
  items = items.not(exclusions);
1145
  hasExcl += j - items.length;
1146
  }
1147
  if(items.length && !!settings.exclude_level){
1148
+ k = getLevelClasses(settings.exclude_level, maxLevel);
1149
+ if(k){
1150
+ //filter to remove...
1151
+ j = items.length;
1152
+ items = items.not(k);
1153
+ hasExcl += j - items.length;
 
 
 
 
 
 
 
 
1154
  }
1155
  }
1156
 
1177
  //show/hide the fall back message...
1178
  dialog.find('.cmw-demo-fallback').data('fellback', fallback).toggleClass('updated', !!fallback);
1179
  //show/hide the 'select current item' prompt...
1180
+ dialog.find('.cmw-demo-setcurrent').toggleClass('error', !currentItemLI.length && (!!settings.contains_current || ciBranch));
1181
  //...and the inclusions/exclusions messages...
1182
  i = {inclusions:hasIncl, exclusions:hasExcl};
1183
  for(j in i){
1224
  theSelect = oc.find('.cmw-depth');
1225
  level = theSelect.val();
1226
  ct = theSelect.find('option').length;
1227
+ txt = theSelect.data().cmwTextLevels;
1228
  if(level > maxLevel){
1229
  theSelect.val(0); //=unlimited
1230
  }
1542
  return false;
1543
  });
1544
 
1545
+ //editing in accessibility mode...
1546
+ if(!!window.Custom_Menu_Wizard_Widget){
1547
+ $(window.Custom_Menu_Wizard_Widget.trigger || []).trigger('change');
1548
+ }
1549
  });
custom-menu-wizard.min.js CHANGED
@@ -1,52 +1,52 @@
1
  /*Source: custom-menu-wizard.js
2
- *Compiled: 2014-07-24, Google Closure Compiler...
3
  *STATISTICS
4
- * - originalSize: 61383
5
- * - originalGzipSize: 15232
6
- * - compressedSize: 22368
7
- * - compressedGzipSize: 7100
8
  */
9
- jQuery(function(f){var z,y=function(a,b){return(b?".":"")+"widget-custom-menu-wizard-"+a},D=function(a){var b=f(this).data().cmwDialogVersion.replace(/\./g,""),b=/^\d+$/.test(b)?"v"+b:b;z[b]?z[b].update(a?a.target:this):z.update(a?a.target:this)},E=function(a,b,d){var c="tick"===d?b._items_sep:b._exclude_sep,g=[],l="tick"===d?"_items":"_exclude",l=b[l]?f.grep(b[l].split(c),function(b){return/\+$/.test(b)?(g.push(parseInt(b,10)),!b):!!b}):[],l=c+l.join(c)+c,g=c+g.join(c)+c;a=a.each(function(){var b=
10
- f(this),a=b.data(),s=-1<g.indexOf(c+a.itemid+c),a=s||-1<l.indexOf(c+a.itemid+c);b.toggleClass("cmw-has-"+d,a).toggleClass("cmw-inherit-"+d,s)});return a.filter(".cmw-inherit-"+d).find("li").removeClass("cmw-has-"+d+" cmw-inherit-"+d).add(a.filter(".cmw-has-"+d))},B=function(a,b){return(a?a:b)[a?"find":"closest"](y("onchange",1))},H=function(a){var b={},d="2.1.0"===a.data("cmwDialogVersion"),c={items:1,exclude:1},g=f.extend({branch_start:1,exclude_level:1},c);f.each(a.find(":input").serializeArray(),
11
- function(l,e){var k=e.name.replace(/.*\[([^\]]+)\]$/,"$1"),s=!g[k]&&/^-?\d+$/.test(e.value)?parseInt(e.value,10):e.value;b[k]=s;"hide_empty"===k?b[k]=!!a.data().cmwV36plus||s:c[k]&&(b["_"+k+"_sep"]=!s||/(^\d+\+?$|,)/.test(f.trim(s))?",":" ",s=f.map(s.split(/[,\s]+/),function(b){var a=!d&&/\+$/.test(b);b=b?parseInt(b,10):0;return isNaN(b)||1>b?null:a?b+"+":b}),b["_"+k]=s.join(b["_"+k+"_sep"]))});return b},I=function(a,b){var d=a.find(".cmw-demo-themenu-ul"),c=d.find(".picked"),g="",l=b.hide_title?
12
- "":b.title,e=0,k=a.find(".cmw-demo-theoutput-wrap").empty(),s=["menu-widget"],u={};if(c.length&&k.length){(l=d.find(".title-from-item").children(".cmw-item").text()||"")||b.hide_title||(l=b.title||"");for(c.each(function(a){var c=f(this),d=c.data(),l=d.trace?d.trace.toString().split(","):[];a=d.itemid.toString();var k=1,c=c.children(".cmw-item");if(!b.flat_output)for(u[a]=1,a=0;a<l.length;a++)u[l[a]]&&k++;if(e)if(k>e)g+=b.ol_sub?"<ol>":"<ul>";else{for(;e>k;)--e,g+="</li>"+(b.ol_sub?"</ol>":"</ul>");
13
- g+="</li>"}g+='<li class="cmw-level-'+k+(d.included||"")+'"><a href="#'+c.data("indx")+'">'+c.text()+"</a>";e=k});1<e;)--e,g+="</li>"+(b.ol_sub?"</ol>":"</ul>");g+="</li>";s.push(a.find(".cmw-demo-fallback").data("fellback"));g=(b.ol_root?"<ol":"<ul")+' class="'+f.trim(s.join(" "))+'">'+g+(b.ol_root?"</ol>":"</ul>");k.html(g);k.find("li").filter(function(){return!!f(this).children("ul, ol").length}).addClass("cmw-has-submenu")}k.length&&l&&(c.length||!b.hide_empty)&&k.prepend("<h3>"+l+"</h3>")},J=
14
- function(a,b,d){var c;a.find("optgroup").filter(function(){var b=f(this).data().cmwOptgroupIndex===d;b||f(this).remove();return b}).length||(c=f("#"+a.attr("id")+"_ignore").find("optgroup").eq(d).clone(),c.length&&(0<b&&(b=0),a.append(c).val(b)));return b},K=function(a){a=f(this);var b=a.data(),d=!b.cmwAbsolute,c=a.closest(".ui-dialog"),g=c.find(".ui-dialog-content"),l=parseInt(c.css("top"),10)+(d?1:-1)*f(document).scrollTop();b.cmwAbsolute=d;b.cmwMaxHeight||(b.cmwMaxHeight=g.dialog("option","maxHeight"));
15
- a.button("option","icons",{primary:d?"ui-icon-circle-close":"ui-icon-circle-check"});c.toggleClass("cmw-assistance-dialog-fixed",!d);g.dialog("option",{maxHeight:d?!d:b.cmwMaxHeight});c.css("top",l);return!1},L=function(a){var b=f(this);a=["current-menu-item","current-menu-parent","current-menu-ancestor"];var d=b.closest(".ui-dialog-content"),c=d.find(".cmw-demo-themenu-ul"),b=b.find("span").not("."+a[0]).parentsUntil(c,"li"),g,l=function(){this.title=this.title+" "+g.replace(" "," & ").replace(/-/g,
16
- " ")};c.find("."+a.join(",.")).removeClass(a.join(" ")).each(function(){this.title=this.title.replace(/\s.*$/,"")});for(c=0;c<b.length;c++)g=1===c?a.join(" "):a[0],b.eq(c).children(".cmw-item").find("span").addClass(g).each(l),1<a.length&&a.shift();D.call(f(d.data().cmwOnchange).get(0));return!1},M=function(a){f(this).closest(".ui-dialog-content").find(".cmw-item").eq(this.href.split("#")[1]).not(":has(.current-menu-item)").trigger("click");this.blur();return!1},N=function(a){a=f(this);var b=a.hasClass("cmw-tick")?
17
- "tick":"cross",d=a.parent();a=d.closest(".cmw-demo-themenu-ul");var c=d.hasClass("cmw-inherit-"+b),g=c||d.hasClass("cmw-has-"+b),l=g?f([]):d.parentsUntil(a,".cmw-inherit-"+b),e=f(d.closest(".ui-dialog-content").data().cmwOnchange).find("tick"===b?".cmw-setitems":".cmw-exclusions"),k;e.length&&(k=a.find(".cmw-has-"+b)[c||l.length?"not":"add"](d),!g||d.children("ul").length&&!a.parent().hasClass("cmw-version-210")?g&&!c&&(k=k.not(d.find(".cmw-has-"+b))):k=k.not(d),k=k.add(l.find("li").not(d)),k=k.map(function(){var a=
18
- this===d[0]||this===l.get(0)?g:f(this).hasClass("cmw-inherit-"+b);return f(this).data().itemid+(a?"+":"")}).get().join(/(,|^\d+\+?$)/.test(f.trim(e.val())||",")?",":" "),e.val(k).trigger("change"));this.blur();return!1},O=function(a){var b={autoOpen:!1,width:Math.min(.9*f(window).width(),600),maxHeight:f(window).height()-40,modal:!1,containment:"window",create:function(){var b=f(this).closest(".ui-dialog");if(b.hasClass("cmw-assistance-dialog-fixed"))f("<button/>").addClass("cmw-dialog-fixed-absolute").button({label:a.cmwDialogFixed,
19
- icons:{primary:"ui-icon-circle-check"}}).appendTo(b.find(".ui-dialog-titlebar")).on("click",K)},dialogClass:"cmw-assistance-dialog cmw-assistance-dialog-fixed"},d=f.map(["SetCurrent","Inclusions","Exclusions","Fallback"],function(b){return'<div class="cmw-demo-'+b.toLowerCase()+' cmw-demo-small">'+(a["cmwDialog"+b]||"")+"</div>"}),d=f("<div/>",{id:a.cmwDialogId}).addClass(y("dialog")).append(f("<div/>").addClass("cmw-demo-themenu cmw-version-"+a.cmwDialogVersion.replace(/\./g,"")).html('<em class="cmw-demo-small">'+
20
- a.cmwDialogPrompt+"</em>")).append(f("<div/>").addClass("cmw-demo-theoutput").html('<em class="cmw-demo-small">'+a.cmwDialogOutput+'</em><em class="cmw-demo-plugin-version cmw-demo-small">v'+a.cmwDialogVersion+"</em>"+d.shift()+'<div class="cmw-demo-theoutput-wrap ui-corner-all"></div>'+d.join(""))).append(f("<div/>").addClass("cmw-demo-theshortcode").html('<code class="ui-corner-all"></code><div class="cmw-find-shortcodes"><a href="#" class="button-secondary '+y("find-shortcodes")+'" data-nonce="'+
21
- (a.cmwDialogNonce||"")+'" title="'+a.cmwDialogShortcodes+'"><span class="spinner"></span><span>[&hellip;]</span></a></div><div class="cmw-demo-found-shortcodes cmw-demo-small ui-corner-all"></div>'));d.dialog(b);d.find(".cmw-demo-themenu").on("click",".cmw-tick,.cmw-cross",N).on("click",".cmw-item",L);d.find(".cmw-demo-theoutput").on("click","a",M);return d},F=function(a,b){a.dialog("option","title","CMW : "+(b.find(".cmw-widget-title").val()||a.data().cmwUntitled)+" ["+b.find(".cmw-select-menu").find("option:selected").text()+
22
- "]")},G=function(a){var b=f(a.data().cmwOnchange),d=parseInt(b.find(".cmw-select-menu").val(),10),c=a.find(".cmw-demo-themenu-ul"),g=[],l=0,e="",k=function(b){return 1<b?'<a href="#" class="'+y("colexp")+' ui-icon ui-icon-triangle-1-e" style="left:-'+(2.4*(b-2)+2)+'em;">&nbsp;</a>':""};if(!c.length||c.data("menuid")!==d){for(b.find(".cmw-assist-items optgroup").find("option").each(function(b){for(var a=f(this),c=a.data().cmwLevel;c<g.length;)e+="</li></ul>"+k(g.length),g.pop();c>g.length?e+="<ul>":
23
- (e+="</li>",g.pop());e+='<li class="level-'+c+'" data-itemid="'+this.value+'" data-level="'+c+'" data-trace="'+g.join(",")+'">';e+='<a href="#" class="cmw-cross ui-corner-all"></a>';e+='<a class="cmw-item ui-corner-all" href="#" data-indx="'+b+'"><span class="ui-corner-all" title="#'+this.value+'">'+f.trim(a.text());e+='</span></a><a href="#" class="cmw-tick ui-corner-all"></a>';g.push(this.value);c>l&&(l=c)});g.length;)e+="</li></ul>"+k(g.length),g.pop();c.remove();a.find(".cmw-demo-themenu").append(f(e).addClass("cmw-demo-themenu-ul").data({maxLevel:l,
24
- menuid:d}))}};z={setLevels:function(a,b){if(b){var d=a.find(".cmw-branch-start"),c=d.val();d.find("optgroup").each(function(a){var c=f(this),d=c.find("option"),k=d.length,s=c.data();if(a)for(d.slice(b).remove();k<b;)++k,c.append(f("<option/>",{value:k}).text(k));else for(k=(k+1)/2,k>b&&d.each(function(a,c){Math.abs(c.value)>=b&&f(c).remove()});k<b;)c.prepend(f("<option/>",{value:-k}).text(-k+(1<k?"":" ("+s.cmwTextParent+")"))).append(f("<option/>",{value:"+"+k}).text("+"+k+(1<k?"":" ("+s.cmwTextChildren+
25
- ")"))),++k});/^\d+$/.test(c)?c>b&&d.val("1"):""!==c&&Math.abs(c)>=b&&d.val("");a.find(".cmw-ancestors,.cmw-ancestor-siblings").each(function(){var a=f(this),c=(a.find("option").length+1)/2,d=a.val(),k=Math.max(2,b);Math.abs(d)>=b&&a.val(0>d?1-b:b-1);c!==k&&a.find("optgroup").each(function(b,a){var d=f(a),g=d.data().cmwTextForOption,e;c>k&&d.find("option").slice(k-c).remove();for(e=c;e<k;e++)d.append(f("<option/>",{value:b?e:-e}).text(g.replace("%d",b?e:-e)))})});a.find(".cmw-exclude-level").each(function(){var a=
26
- f(this),c=a.find("option"),d=(c.length-1)/3,k=a.val(),s=c.eq(2).text(),u=c.eq(3).text();for(c.slice(3*b+1).remove();d<b;)++d,a.append(f("<option/>",{value:d}).text(d)).append(f("<option/>",{value:d+"-"}).text(s.replace(/\d+/,d))).append(f("<option/>",{value:d+"+"}).text(u.replace(/\d+/,d)));parseInt(k,10)>b&&a.val("")});a.find(".cmw-level").each(function(){var a=f(this),c=a.find("option").length;a.val()>b&&a.val(1);for(a.find("option").slice(b).remove();c<b;)++c,a.append(f("<option/>",{value:c}).text(c))});
27
- a.find(".cmw-depth,.cmw-fallback-depth").each(function(){var a=f(this),c=a.find("option").length,d=" "+a.data().cmwTextLevels;a.val()>b&&a.val(0);for(a.find("option").slice(b+1).remove();c<=b;)a.append(f("<option/>",{value:c}).text(c+d)),++c})}},setFields:function(a,b){var d=b.find(".cmw-bybranch"),c=b.find(".cmw-byitems").prop("checked"),g=c||!d.prop("checked"),l=b.find(".cmw-assist-items"),e=parseInt(l.val(),10);a.hasClass("cmw-select-menu")?(e=J(l,e,a[0].selectedIndex),this.setLevels(b,(l.find("optgroup").data()||
28
- {}).cmwMaxLevel)):a.hasClass("cmw-level")?(g=!0,c=!g,b.find(".cmw-bylevel").prop("checked",g)):a.is(l)?(g=c=!1,d.prop("checked",!g)):a.hasClass("cmw-setitems")?(g=c=!0,b.find(".cmw-byitems").prop("checked",c)):a.hasClass("cmw-ancestors")&&"0"===a.val()?b.find(".cmw-ancestor-siblings").val("0"):a.hasClass("cmw-ancestor-siblings")&&"0"!==a.val()&&"0"===b.find(".cmw-ancestors").val()&&b.find(".cmw-ancestors").val(a.val());f.each({"-ss":c,"-ud":1>b.find(".cmw-depth").val(),"not-br":g,"not-br-ci":g||!!e,
29
- "not-fb-pc":!{parent:1,current:1}[b.find(".cmw-fallback").val()]},function(a,c){b.find(".cmw-disableif"+a).toggleClass("cmw-colour-grey",c).find("input,select").prop("disabled",c)})},shortcode:function(a){var b={menu:a.menu},d="branch"===a.filter,c="items"===a.filter,g;a.title&&!a.hide_title&&(b.title=[a.title]);!d&&!c&&1<a.level&&(b.level=a.level);d&&(b.branch=a.branch||"current",a.branch_start&&(b.start_at=[a.branch_start]),"level"===a.start_mode&&(b.start_mode="level"));c&&(b.items=[a._items]);
30
- 0<a.depth&&(b.depth=a.depth);a.depth_rel_current&&0<a.depth&&(b.depth_rel_current=1);d&&!a.branch&&a.fallback&&(b.fallback=[a.fallback],"quit"!==a.fallback&&(a.fallback_siblings&&b.fallback.push("+siblings"),a.fallback_depth&&b.fallback.push(a.fallback_depth)));d&&a.ancestors&&(b.ancestors=a.ancestors,a.ancestor_siblings&&(b.ancestor_siblings=a.ancestor_siblings));a._exclude&&(b.exclude=[a._exclude]);a.exclude_level&&(b.exclude_level=[a.exclude_level]);c=[];a.title_from_current?c.push("current"):
31
- a.title_from_current_root&&c.push("current-root");d&&a.title_from_branch?c.push("branch"):d&&a.title_from_branch_root&&c.push("branch-root");c.length&&(b.title_from=c);for(c in{allow_all_root:1,siblings:1,include_root:1,flat_output:1,ol_root:1,ol_sub:1})a[c]&&(b[c]=1);d={contains_current:"",container:"div",container_id:"",container_class:"",menu_class:"menu-widget",widget_class:""};for(c in d)a[c]!==d[c]&&(b[c]=[a[c]]);d={wrap_link:"before",wrap_link_text:"link_before"};for(c in d)(g=a[d[c]].toString().match(/^<(\w+)/))&&
32
- g[1]&&(b[c]=[g[1]]);d=[];for(c in b)d.push(f.isArray(b[c])?c+'="'+b[c].join(",")+'"':c+"="+b[c]);return"[cmwizard "+d.join(" ")+"/]"},update:function(a){var b=f(a);a=B(0,b);var d=f("#"+a.data().cmwDialogId),c=-1,g=9999,l=0,e=0,k="",s,u,r,v,x,m,t,h,y,A,z,w,C,q,p,n;b.hasClass("cmw-listen")&&this.setFields(b,a);m=H(a);if(d.length&&d.dialog("isOpen")){d.dialog("moveToTop");b.hasClass("cmw-select-menu")&&G(d);b="branch"===m.filter;u="items"===m.filter;s=!b&&!u;v=b&&!m.branch;t=d.find(".cmw-demo-themenu-ul");
33
- x=t.data().maxLevel;w=t.find(".current-menu-item").closest("li");C=w.length?w.data().level:-1;h=t.find("li").removeData("included").removeClass("title-from-item");A=m.depth;z=m.depth_rel_current;y=E(h,m,"cross");u&&(h=E(h,m,"tick"));h.length&&!w.length&&(m.contains_current||v)&&(h=f([]));b&&h.length&&(q=v?w:h.filter("[data-itemid="+m.branch+"]"),q.length?(c=q.data().level||0,h=q.add(q.find("li")),r=q):h=f([]));if(s&&h.length&&1<m.level){p=1;for(n=[];p<m.level;p++)n.push(".level-"+p);h=h.not(n.join(","))}"primary"===
34
- m.contains_current&&h.length&&!w.is(h)&&(h=f([]));if(s&&h.length&&A&&(p=z&&C>=m.level?C:m.level,p+=A,p<=x)){for(n=[];p<=x;p++)n.push(".level-"+p);h=h.not(n.join(","))}if(b&&h.length&&(n=parseInt(m.branch_start,10),n=isNaN(n)||!n?c:m.branch_start.match(/^(\+|-)/)?Math.max(1,c+n):n,v&&m.fallback&&!w.find("li").length&&(k="cmw-fellback-to-"+m.fallback,"quit"===m.fallback?n=x+1:(n="current"===m.fallback||2>c?c:c-1,m.fallback_depth&&(A=m.fallback_depth,z=1))),n>x?h=f([]):(n<c&&(q=q.parentsUntil(t,"li.level-"+
35
- n)),"level"===m.start_mode&&n<=c&&(1<n||m.allow_all_root)?h=q.parent().find("li"):n<c&&(h=q.add(q.find("li"))),k&&m.fallback_siblings&&h.length&&(1<n||m.allow_all_root)&&(h=h.add(q.siblings("li.level-"+n)))),h.length)){c=n;q=9999;A&&(q=z&&C>=c&&h.filter(w).length?C:c,q+=A,g=q-1);p=1;for(n=[];p<=x;p++)p>=c&&p<q&&n.push(".level-"+p);h=h.filter(n.join(","))}"secondary"===m.contains_current&&h.length&&!w.is(h)&&(h=f([]));if(b&&h.length){n=r.data().level;if(m.ancestors&&(r.is(h)||n>g)){p=m.ancestors;0>
36
- p&&(p=Math.max(1,n+p));c=m.ancestor_siblings;0>c&&(c=Math.max(1,n+c));n=[];for(q=[];p<=x;p++)p<=g&&(n.push(".level-"+p),0<c&&p>=c&&q.push(".level-"+p));p=h.length;n=r.parentsUntil(t,n.join(","));h=h.add(n.not(h).data("included"," cmw-an-included-ancestor"));q.length&&(h=h.add(n.filter(q.join(",")).siblings("li").not(h).data("included"," cmw-an-included-ancestor-sibling")));l+=h.length-p}m.siblings&&r.is(h)&&(n=h.length,h=h.add(r.siblings("li").data("included"," cmw-an-included-sibling")),l+=h.length-
37
- n)}h.length&&m.include_root&&(n=h.length,h=h.add(t.find(".level-1")),l+=h.length-n);"inclusions"===m.contains_current&&h.length&&!w.is(h)&&(h=f([]));h.length&&y.length&&(n=h.length,h=h.not(y),e+=n-h.length);if(h.length&&m.exclude_level&&(q=(q=m.exclude_level.match(/^(\d+)(\+|-)?$/))?[parseInt(q[1],10),q[2]||""]:[],0<q[0])){n=[];for(p=1;p<=x;p++)(p===q[0]||"-"===q[1]&&p<q[0]||"+"===q[1]&&p>q[0])&&n.push(".level-"+p);n.length&&(q=h.length,h=h.not(n.join(",")),e+=q-h.length)}"output"===m.contains_current&&
38
- h.length&&!w.is(h)&&(h=f([]));m.title_from_current&&w.length?w.addClass("title-from-item"):m.title_from_current_root&&w.length?w.closest(".level-1").addClass("title-from-item"):b&&r&&(m.title_from_branch?r.addClass("title-from-item"):m.title_from_branch_root&&r.closest(".level-1").addClass("title-from-item"));d.find(".cmw-demo-fallback").data("fellback",k).toggleClass("updated",!!k);d.find(".cmw-demo-setcurrent").toggleClass("error",!w.length&&(m.contains_current||v));p={inclusions:l,exclusions:e};
39
- for(n in p)q=d.find(".cmw-demo-"+n),q.text(q.text().replace(/\d+$/,p[n])).toggleClass("updated",0<p[n]);t.toggleClass("cmw-demo-filteritems",u).find(".picked").not(h.addClass("picked")).removeClass("picked");F(d,a);I(d,m)}a.add(d).find("code").text(this.shortcode(m))},v210:{setLevels:function(a,b){var d=a.find(".cmw-start-level"),c=d.val(),g=d.find("option").length,l;c>b&&d.val(1);for(d.find("option").slice(b).remove();g<b;)++g,d.append(f("<option/>",{value:g}).text(g));d=a.find(".cmw-depth");c=d.val();
40
- g=d.find("option").length;l=" "+d.data().cmwTextLevels;c>b&&d.val(0);for(d.find("option").slice(b+1).remove();g<=b;)d.append(f("<option/>",{value:g}).text(g+l)),++g},setFields:function(a,b){var d=b.find(".cmw-showall").prop("checked"),c=b.find(".cmw-showspecific").prop("checked"),g=b.find(".cmw-assist-items"),l=parseInt(g.val(),10);a.hasClass("cmw-select-menu")&&(l=J(g,l,a[0].selectedIndex),this.setLevels(b,(g.find("optgroup").data()||{}).cmwMaxLevel));f.each({"":d||c,"-ss":c,"not-rp":d||c||0<=l,
41
- "not-ci":d||c||!!l},function(a,c){b.find(".cmw-disableif"+a).toggleClass("cmw-colour-grey",c).find("input,select").prop("disabled",c)})},shortcode:function(a){var b={menu:a.menu},d=0<a.filter,c=!!a.filter&&!d,g;a.title&&(b.title=[a.title]);if(d)switch(a.filter_item){case 0:b.children_of=["current"];break;case -1:b.children_of=["parent"];break;case -2:b.children_of=["root"];break;default:b.children_of=a.filter_item}c&&(b.items=[a._items]);d&&0>a.filter_item&&a.fallback_no_ancestor&&(b.fallback_parent=
42
- a.fallback_include_parent_siblings?["siblings"]:a.fallback_include_parent?["parent"]:1);d&&!a.filter_item&&a.fallback_no_children&&(b.fallback_current=a.fallback_nc_include_parent_siblings?["siblings"]:a.fallback_nc_include_parent?["parent"]:1);1<a.start_level&&(b.start_level=a.start_level);0<a.depth&&(b.depth=a.depth);a.depth_rel_current&&0<a.depth&&(b.depth_rel_current=1);c=[];d&&(a.include_parent_siblings?c.push("siblings"):a.include_parent&&c.push("parent"),a.include_ancestors&&c.push("ancestors"),
43
- c.length&&(b.include=c));c=[];d&&a.title_from_parent&&c.push("parent");a.title_from_current&&c.push("current");c.length&&(b.title_from=c);for(c in{flat_output:1,contains_current:1,ol_root:1,ol_sub:1})a[c]&&(b[c]=1);d={container:"div",container_id:"",container_class:"",menu_class:"menu-widget",widget_class:""};for(c in d)a[c]!==d[c]&&(b[c]=[a[c]]);d={wrap_link:"before",wrap_link_text:"link_before"};for(c in d)(g=a[d[c]].toString().match(/^<(\w+)/))&&g[1]&&(b[c]=[g[1]]);d=[];for(c in b)d.push(f.isArray(b[c])?
44
- c+'="'+b[c].join(" ")+'"':c+"="+b[c]);return"[custom_menu_wizard "+d.join(" ")+"]"},update:function(a){var b=f(a);a=B(0,b);var d=f("#"+a.data().cmwDialogId),c,g,l,e,k,s,u,r,v,x,m,t,h;b.hasClass("cmw-listen")&&this.setFields(b,a);if(d.length&&d.dialog("isOpen")){d.dialog("moveToTop");b.hasClass("cmw-select-menu")&&G(d);e=H(a);c=!e.filter;b=0<e.filter;g=!c&&!b;k=e.include_parent;s=e.include_parent_siblings;u=d.find(".cmw-demo-themenu-ul");l=u.data().maxLevel;v=u.find(".current-menu-item").closest("li");
45
- x=v.length?v.data().level:-1;r=u.find("li").removeData("included").removeClass("title-from-item");g&&(r=E(r,e,"tick"));r.length&&!v.length&&(e.contains_current||b&&1>e.filter_item)&&(r=f([]));r.length&&b&&(0<e.filter_item?t=r.filter("[data-itemid="+e.filter_item+"]"):e.filter_item?1===x&&e.fallback_no_ancestor?(t=v,k=k||e.fallback_include_parent,s=s||e.fallback_include_parent_siblings,m="cmw-fellback-to-current"):t=1===x?u:-1>e.filter_item?u.find(".current-menu-ancestor").eq(0).closest("li"):u.find(".current-menu-parent").closest("li"):
46
- v.find("li").length?t=v:e.fallback_no_children&&(t=u.find(".current-menu-parent").closest("li"),t.length||(t=u),k=k||e.fallback_nc_include_parent,s=s||e.fallback_nc_include_parent_siblings,m="cmw-fellback-to-parent"));if(r.length)if(c)for(h=e.depth_rel_current&&e.depth&&v.length&&x>=e.start_level?x+e.depth-1:e.depth?e.start_level+e.depth-1:9999,c=1;c<=l;c++){if(c<e.start_level||c>h)r=r.not(".level-"+c)}else t&&t.length?(h=e.depth_rel_current&&e.depth&&v.length&&t.has(v[0]).length?x-1+e.depth:e.depth?
47
- Math.max((t.data().level||0)+e.depth,e.start_level+e.depth-1):9999,r=t.find("li").filter(function(){var a=f(this).data().level;return a>=e.start_level&&a<=h})):b&&(r=f([]));r.length&&b&&t&&t.is("li")&&(s&&(r=r.add(t.siblings("li").data("included"," cmw-an-included-parent-sibling")),k=!0),e.include_ancestors&&(r=r.add(t.parentsUntil(u,"li").data("included"," cmw-an-included-ancestor")),k=!0),k&&(r=r.add(t.data("included"," cmw-the-included-parent"))));!r.length||!e.contains_current||v.length&&r.filter(v).length||
48
- (r=f([]));e.title_from_parent&&r.length&&t&&t.is("li")?t.addClass("title-from-item"):e.title_from_current&&r.length&&v.addClass("title-from-item");m=r.length?m:"";d.find(".cmw-demo-fallback").data("fellback",m).toggleClass("updated",!!m);d.find(".cmw-demo-setcurrent").toggleClass("error",!v.length&&(e.contains_current||b&&1>e.filter_item));u.toggleClass("cmw-demo-filteritems",g).find(".picked").not(r.addClass("picked")).removeClass("picked");F(d,a);I(d,e);d.find("code").text(this.shortcode(e))}}}};
49
- f(document).on("change",y("onchange",1),D).on("click",y("assist",1),function(a){a=f(this);a=B(0,a);var b=a.data(),d=f("#"+b.cmwDialogId);d.length||(d=O(b).data({cmwOnchange:"#"+a.attr("id"),cmwUntitled:"["+b.cmwDialogUntitled+"]"}));d.dialog("isOpen")?d.dialog("close"):(G(d),F(d,a),d.dialog("open"),D.call(a[0]));this.blur();return!1}).on("click",y("fieldset",1),function(a){a=f(this);var b=a.next(".cmw-fieldset-state"),d=!b.prop("checked");b.length&&(b.prop("checked",d),a.toggleClass("cmw-collapsed-fieldset",
50
- d),b.next("div")[d?"slideUp":"slideDown"]());this.blur();return!1}).on("click",".widget-action,.widget-control-close",function(a){a=f(this).closest("div.widget");var b=a.parent();b.hasClass("customize-control-widget_form")&&!b.hasClass("expanded")||B(a).each(function(){var a=f("#"+f(this).data().cmwDialogId);a.length&&a.dialog("isOpen")&&a.dialog("close")})}).on("click",".widget-control-remove",function(a){B(f(this).closest("div.widget")).each(function(){var a=f("#"+f(this).data().cmwDialogId);a.length&&
51
- (a.dialog("destroy"),a.remove())})}).on("click",y("colexp",1),function(a){a=/1-e/.test(this.className)?"slideUp":"slideDown";f(this).toggleClass("ui-icon-triangle-1-s ui-icon-triangle-1-e").prev("ul")[a]();return!1}).on("click",y("find-shortcodes",1),function(a){a=f(this);var b=a.parent().parent();ajaxurl&&!b.hasClass("cmw-ajax-fetching")&&(b.hasClass("cmw-ajax-showing")?b.removeClass("cmw-ajax-showing"):(b.addClass("cmw-ajax-fetching"),f.post(ajaxurl,{action:"cmw-find-shortcodes",_wpnonce:a.data().nonce}).done(function(a){a&&
52
- "0"!==a&&(b.find(".cmw-demo-found-shortcodes").html(f(a).find("response_data").text()),b.addClass("cmw-ajax-showing"))}).always(function(a){b.removeClass("cmw-ajax-fetching")})));this.blur();return!1}).on("click",y("legacy-close",1),function(){f(this).parent().remove();return!1})});
1
  /*Source: custom-menu-wizard.js
2
+ *Compiled: 2014-08-29, Google Closure Compiler...
3
  *STATISTICS
4
+ * - originalSize: 62564
5
+ * - originalGzipSize: 15695
6
+ * - compressedSize: 22446
7
+ * - compressedGzipSize: 7165
8
  */
9
+ jQuery(function(g){var z,y=function(a,b){return(b?".":"")+"widget-custom-menu-wizard-"+a},D=function(a){var b=g(this).data().cmwDialogVersion.replace(/\./g,""),b=/^\d+$/.test(b)?"v"+b:b;z[b]?z[b].update(a?a.target:this):z.update(a?a.target:this)},E=function(a,b,d){var c="tick"===d?b._items_sep:b._exclude_sep,f=[],l="tick"===d?"_items":"_exclude",l=b[l]?g.grep(b[l].split(c),function(b){return/\+$/.test(b)?(f.push(parseInt(b,10)),!b):!!b}):[],l=c+l.join(c)+c,f=c+f.join(c)+c;a=a.each(function(){var b=
10
+ g(this),a=b.data(),q=-1<f.indexOf(c+a.itemid+c),a=q||-1<l.indexOf(c+a.itemid+c);b.toggleClass("cmw-has-"+d,a).toggleClass("cmw-inherit-"+d,q)});return a.filter(".cmw-inherit-"+d).find("li").removeClass("cmw-has-"+d+" cmw-inherit-"+d).add(a.filter(".cmw-has-"+d))},B=function(a,b){return(a?a:b)[a?"find":"closest"](y("onchange",1))},H=function(a,b){var d=[],c=a.match(/^(\d+)(\+|-)?$/),f,c=c?[parseInt(c[1],10),c[2]||""]:[];if(0<c[0])for(f=1;f<=b;f++)(f===c[0]||"-"===c[1]&&f<c[0]||"+"===c[1]&&f>c[0])&&
11
+ d.push(".level-"+f);return d.join(",")},I=function(a){var b={},d="2.1.0"===a.data("cmwDialogVersion"),c={items:1,exclude:1},f=g.extend({branch_start:1,exclude_level:1,include_level:1},c);g.each(a.find(":input").serializeArray(),function(l,e){var k=e.name.replace(/.*\[([^\]]+)\]$/,"$1"),q=!f[k]&&/^-?\d+$/.test(e.value)?parseInt(e.value,10):e.value;b[k]=q;"hide_empty"===k?b[k]=!!a.data().cmwV36plus||q:c[k]&&(b["_"+k+"_sep"]=!q||/(^\d+\+?$|,)/.test(g.trim(q))?",":" ",q=g.map(q.split(/[,\s]+/),function(b){var a=
12
+ !d&&/\+$/.test(b);b=b?parseInt(b,10):0;return isNaN(b)||1>b?null:a?b+"+":b}),b["_"+k]=q.join(b["_"+k+"_sep"]))});return b},J=function(a,b){var d=a.find(".cmw-demo-themenu-ul"),c=d.find(".picked"),f="",l=b.hide_title?"":b.title,e=0,k=a.find(".cmw-demo-theoutput-wrap").empty(),q=["menu-widget"],u={};if(c.length&&k.length){(l=d.find(".title-from-item").children(".cmw-item").text()||"")||b.hide_title||(l=b.title||"");for(c.each(function(a){var c=g(this),d=c.data(),k=d.trace?d.trace.toString().split(","):
13
+ [];a=d.itemid.toString();var l=1,c=c.children(".cmw-item");if(!b.flat_output)for(u[a]=1,a=0;a<k.length;a++)u[k[a]]&&l++;if(e)if(l>e)f+=b.ol_sub?"<ol>":"<ul>";else{for(;e>l;)--e,f+="</li>"+(b.ol_sub?"</ol>":"</ul>");f+="</li>"}f+='<li class="cmw-level-'+l+(d.included||"")+'"><a href="#'+c.data("indx")+'">'+c.text()+"</a>";e=l});1<e;)--e,f+="</li>"+(b.ol_sub?"</ol>":"</ul>");f+="</li>";q.push(a.find(".cmw-demo-fallback").data("fellback"));f=(b.ol_root?"<ol":"<ul")+' class="'+g.trim(q.join(" "))+'">'+
14
+ f+(b.ol_root?"</ol>":"</ul>");k.html(f);k.find("li").filter(function(){return!!g(this).children("ul, ol").length}).addClass("cmw-has-submenu")}k.length&&l&&(c.length||!b.hide_empty)&&k.prepend("<h3>"+l+"</h3>")},K=function(a,b,d){var c;a.find("optgroup").filter(function(){var b=g(this).data().cmwOptgroupIndex===d;b||g(this).remove();return b}).length||(c=g("#"+a.attr("id")+"_ignore").find("optgroup").eq(d).clone(),c.length&&(0<b&&(b=0),a.append(c).val(b)));return b},L=function(a){a=g(this);var b=
15
+ a.data(),d=!b.cmwAbsolute,c=a.closest(".ui-dialog"),f=c.find(".ui-dialog-content"),l=parseInt(c.css("top"),10)+(d?1:-1)*g(document).scrollTop();b.cmwAbsolute=d;b.cmwMaxHeight||(b.cmwMaxHeight=f.dialog("option","maxHeight"));a.button("option","icons",{primary:d?"ui-icon-circle-close":"ui-icon-circle-check"});c.toggleClass("cmw-assistance-dialog-fixed",!d);f.dialog("option",{maxHeight:d?!d:b.cmwMaxHeight});c.css("top",l);return!1},M=function(a){var b=g(this);a=["current-menu-item","current-menu-parent",
16
+ "current-menu-ancestor"];var d=b.closest(".ui-dialog-content"),c=d.find(".cmw-demo-themenu-ul"),b=b.find("span").not("."+a[0]).parentsUntil(c,"li"),f,l=function(){this.title=this.title+" "+f.replace(" "," & ").replace(/-/g," ")};c.find("."+a.join(",.")).removeClass(a.join(" ")).each(function(){this.title=this.title.replace(/\s.*$/,"")});for(c=0;c<b.length;c++)f=1===c?a.join(" "):a[0],b.eq(c).children(".cmw-item").find("span").addClass(f).each(l),1<a.length&&a.shift();D.call(g(d.data().cmwOnchange).get(0));
17
+ return!1},N=function(a){g(this).closest(".ui-dialog-content").find(".cmw-item").eq(this.href.split("#")[1]).not(":has(.current-menu-item)").trigger("click");this.blur();return!1},O=function(a){a=g(this);var b=a.hasClass("cmw-tick")?"tick":"cross",d=a.parent();a=d.closest(".cmw-demo-themenu-ul");var c=d.hasClass("cmw-inherit-"+b),f=c||d.hasClass("cmw-has-"+b),l=f?g([]):d.parentsUntil(a,".cmw-inherit-"+b),e=g(d.closest(".ui-dialog-content").data().cmwOnchange).find("tick"===b?".cmw-setitems":".cmw-exclusions"),
18
+ k;e.length&&(k=a.find(".cmw-has-"+b)[c||l.length?"not":"add"](d),!f||d.children("ul").length&&!a.parent().hasClass("cmw-version-210")?f&&!c&&(k=k.not(d.find(".cmw-has-"+b))):k=k.not(d),k=k.add(l.find("li").not(d)),k=k.map(function(){var a=this===d[0]||this===l.get(0)?f:g(this).hasClass("cmw-inherit-"+b);return g(this).data().itemid+(a?"+":"")}).get().join(/(,|^\d+\+?$)/.test(g.trim(e.val())||",")?",":" "),e.val(k).trigger("change"));this.blur();return!1},P=function(a){var b={autoOpen:!1,width:Math.min(.9*
19
+ g(window).width(),600),maxHeight:g(window).height()-40,modal:!1,containment:"window",create:function(){var b=g(this).closest(".ui-dialog");if(b.hasClass("cmw-assistance-dialog-fixed"))g("<button/>").addClass("cmw-dialog-fixed-absolute").button({label:a.cmwDialogFixed,icons:{primary:"ui-icon-circle-check"}}).appendTo(b.find(".ui-dialog-titlebar")).on("click",L)},dialogClass:"cmw-assistance-dialog cmw-assistance-dialog-fixed"},d=g.map(["SetCurrent","Inclusions","Exclusions","Fallback"],function(b){return'<div class="cmw-demo-'+
20
+ b.toLowerCase()+' cmw-demo-small">'+(a["cmwDialog"+b]||"")+"</div>"}),d=g("<div/>",{id:a.cmwDialogId}).addClass(y("dialog")).append(g("<div/>").addClass("cmw-demo-themenu cmw-version-"+a.cmwDialogVersion.replace(/\./g,"")).html('<em class="cmw-demo-small">'+a.cmwDialogPrompt+"</em>")).append(g("<div/>").addClass("cmw-demo-theoutput").html('<em class="cmw-demo-small">'+a.cmwDialogOutput+'</em><em class="cmw-demo-plugin-version cmw-demo-small">v'+a.cmwDialogVersion+"</em>"+d.shift()+'<div class="cmw-demo-theoutput-wrap ui-corner-all"></div>'+
21
+ d.join(""))).append(g("<div/>").addClass("cmw-demo-theshortcode").html('<code class="ui-corner-all"></code><div class="cmw-find-shortcodes"><a href="#" class="button-secondary '+y("find-shortcodes")+'" data-nonce="'+(a.cmwDialogNonce||"")+'" title="'+a.cmwDialogShortcodes+'"><span class="spinner"></span><span>[&hellip;]</span></a></div><div class="cmw-demo-found-shortcodes cmw-demo-small ui-corner-all"></div>'));d.dialog(b);d.find(".cmw-demo-themenu").on("click",".cmw-tick,.cmw-cross",O).on("click",
22
+ ".cmw-item",M);d.find(".cmw-demo-theoutput").on("click","a",N);return d},F=function(a,b){a.dialog("option","title","CMW : "+(b.find(".cmw-widget-title").val()||a.data().cmwUntitled)+" ["+b.find(".cmw-select-menu").find("option:selected").text()+"]")},G=function(a){var b=g(a.data().cmwOnchange),d=parseInt(b.find(".cmw-select-menu").val(),10),c=a.find(".cmw-demo-themenu-ul"),f=[],l=0,e="",k=function(b){return 1<b?'<a href="#" class="'+y("colexp")+' ui-icon ui-icon-triangle-1-e" style="left:-'+(2.4*
23
+ (b-2)+2)+'em;">&nbsp;</a>':""};if(!c.length||c.data("menuid")!==d){for(b.find(".cmw-assist-items optgroup").find("option").each(function(b){for(var a=g(this),c=a.data().cmwLevel;c<f.length;)e+="</li></ul>"+k(f.length),f.pop();c>f.length?e+="<ul>":(e+="</li>",f.pop());e+='<li class="level-'+c+'" data-itemid="'+this.value+'" data-level="'+c+'" data-trace="'+f.join(",")+'">';e+='<a href="#" class="cmw-cross ui-corner-all"></a>';e+='<a class="cmw-item ui-corner-all" href="#" data-indx="'+b+'"><span class="ui-corner-all" title="#'+
24
+ this.value+'">'+g.trim(a.text());e+='</span></a><a href="#" class="cmw-tick ui-corner-all"></a>';f.push(this.value);c>l&&(l=c)});f.length;)e+="</li></ul>"+k(f.length),f.pop();c.remove();a.find(".cmw-demo-themenu").append(g(e).addClass("cmw-demo-themenu-ul").data({maxLevel:l,menuid:d}))}};z={setLevels:function(a,b){if(b){var d=a.find(".cmw-branch-start"),c=d.val();d.find("optgroup").each(function(a){var c=g(this),d=c.find("option"),k=d.length,q=c.data();if(a)for(d.slice(b).remove();k<b;)++k,c.append(g("<option/>",
25
+ {value:k}).text(k));else for(k=(k+1)/2,k>b&&d.each(function(a,c){Math.abs(c.value)>=b&&g(c).remove()});k<b;)c.prepend(g("<option/>",{value:-k}).text(-k+(1<k?"":" ("+q.cmwTextParent+")"))).append(g("<option/>",{value:"+"+k}).text("+"+k+(1<k?"":" ("+q.cmwTextChildren+")"))),++k});/^\d+$/.test(c)?c>b&&d.val("1"):""!==c&&Math.abs(c)>=b&&d.val("");a.find(".cmw-ancestors,.cmw-ancestor-siblings").each(function(){var a=g(this),c=(a.find("option").length+1)/2,d=a.val(),k=Math.max(2,b);Math.abs(d)>=b&&a.val(0>
26
+ d?1-b:b-1);c!==k&&a.find("optgroup").each(function(b,a){var d=g(a),f=d.data().cmwTextForOption,e;c>k&&d.find("option").slice(k-c).remove();for(e=c;e<k;e++)d.append(g("<option/>",{value:b?e:-e}).text(f.replace("%d",b?e:-e)))})});a.find(".cmw-include-level,.cmw-exclude-level").each(function(){var a=g(this),c=a.find("option"),d=(c.length-1)/3,k=a.val(),q=c.eq(2).text(),u=c.eq(3).text();for(c.slice(3*b+1).remove();d<b;)++d,a.append(g("<option/>",{value:d}).text(d)).append(g("<option/>",{value:d+"-"}).text(q.replace(/\d+/,
27
+ d))).append(g("<option/>",{value:d+"+"}).text(u.replace(/\d+/,d)));parseInt(k,10)>b&&a.val("")});a.find(".cmw-set-levels").each(function(){var a=g(this),c=a.data(),d=c.cmwTextLevels||"",c=c.cmwSetLevels||0,k=a.find("option"),q=k.length-c;a.val()>b&&a.val(k.eq(0).val());for(a.find("option").slice(c+b).remove();q<b;)++q,a.append(g("<option/>",{value:q}).text(q+d))})}},setFields:function(a,b){var d=b.find(".cmw-bybranch"),c=b.find(".cmw-byitems").prop("checked"),f=c||!d.prop("checked"),l=b.find(".cmw-assist-items"),
28
+ e=parseInt(l.val(),10);a.hasClass("cmw-select-menu")?(e=K(l,e,a[0].selectedIndex),this.setLevels(b,(l.find("optgroup").data()||{}).cmwMaxLevel)):a.hasClass("cmw-level")?(f=!0,c=!f,b.find(".cmw-bylevel").prop("checked",f)):a.is(l)?(f=c=!1,d.prop("checked",!f)):a.hasClass("cmw-setitems")?(f=c=!0,b.find(".cmw-byitems").prop("checked",c)):a.hasClass("cmw-ancestors")&&"0"===a.val()?b.find(".cmw-ancestor-siblings").val("0"):a.hasClass("cmw-ancestor-siblings")&&"0"!==a.val()&&"0"===b.find(".cmw-ancestors").val()&&
29
+ b.find(".cmw-ancestors").val(a.val());d=b.find(".cmw-fallback").val();g.each({"-ss":c,"-ud":c||1>b.find(".cmw-depth").val(),"not-br":f,"not-br-ci":f||!!e,"not-fb-pc":f||!!e||"parent"!==d&&"current"!==d},function(a,c){b.find(".cmw-disableif"+a).toggleClass("cmw-colour-grey",c).find("input,select").prop("disabled",c)})},shortcode:function(a){var b={menu:a.menu},d="branch"===a.filter,c="items"===a.filter,f;a.title&&!a.hide_title&&(b.title=[a.title]);!d&&!c&&1<a.level&&(b.level=a.level);d&&(b.branch=
30
+ a.branch||"current",a.branch_start&&(b.start_at=[a.branch_start]),"level"===a.start_mode&&(b.start_mode="level"));c&&(b.items=[a._items]);0<a.depth&&(b.depth=a.depth);a.depth_rel_current&&0<a.depth&&(b.depth_rel_current=1);d&&!a.branch&&a.fallback&&(b.fallback=[a.fallback],"quit"!==a.fallback&&(a.fallback_siblings&&b.fallback.push("+siblings"),a.fallback_depth&&b.fallback.push(a.fallback_depth)));d&&a.ancestors&&(b.ancestors=a.ancestors,a.ancestor_siblings&&(b.ancestor_siblings=a.ancestor_siblings));
31
+ a.include_level&&(b.include_level=[a.include_level]);a._exclude&&(b.exclude=[a._exclude]);a.exclude_level&&(b.exclude_level=[a.exclude_level]);c=[];a.title_from_current?c.push("current"):a.title_from_current_root&&c.push("current-root");d&&a.title_from_branch?c.push("branch"):d&&a.title_from_branch_root&&c.push("branch-root");c.length&&(b.title_from=c);for(c in{allow_all_root:1,siblings:1,flat_output:1,ol_root:1,ol_sub:1})a[c]&&(b[c]=1);d={contains_current:"",container:"div",container_id:"",container_class:"",
32
+ menu_class:"menu-widget",widget_class:""};for(c in d)a[c]!==d[c]&&(b[c]=[a[c]]);d={wrap_link:"before",wrap_link_text:"link_before"};for(c in d)(f=a[d[c]].toString().match(/^<(\w+)/))&&f[1]&&(b[c]=[f[1]]);d=[];for(c in b)d.push(g.isArray(b[c])?c+'="'+b[c].join(",")+'"':c+"="+b[c]);return"[cmwizard "+d.join(" ")+"/]"},update:function(a){var b=g(a);a=B(0,b);var d=g("#"+a.data().cmwDialogId),c=-1,f=9999,l=0,e=0,k="",q,u,p,v,w,m,s,h,y,A,z,x,C,t,r,n;b.hasClass("cmw-listen")&&this.setFields(b,a);m=I(a);
33
+ if(d.length&&d.dialog("isOpen")){d.dialog("moveToTop");b.hasClass("cmw-select-menu")&&G(d);b="branch"===m.filter;u="items"===m.filter;q=!b&&!u;v=b&&!m.branch;s=d.find(".cmw-demo-themenu-ul");w=s.data().maxLevel;x=s.find(".current-menu-item").closest("li");C=x.length?x.data().level:-1;h=s.find("li").removeData("included").removeClass("title-from-item");A=m.depth;z=m.depth_rel_current;y=E(h,m,"cross");u&&(h=E(h,m,"tick"));b&&h.length&&(t=v?x:h.filter("[data-itemid="+m.branch+"]"),t.length?(c=t.data().level||
34
+ 0,h=t.add(t.find("li")),p=t):h=g([]));if(q&&h.length&&1<m.level){r=1;for(n=[];r<m.level;r++)n.push(".level-"+r);h=h.not(n.join(","))}"menu"===m.contains_current&&h.length&&!x.length&&(h=g([]));"primary"===m.contains_current&&h.length&&!x.is(h)&&(h=g([]));if(q&&h.length&&A&&(r=z&&C>=m.level?C:m.level,r+=A,r<=w)){for(n=[];r<=w;r++)n.push(".level-"+r);h=h.not(n.join(","))}if(b&&h.length&&(n=parseInt(m.branch_start,10),n=isNaN(n)||!n?c:m.branch_start.match(/^(\+|-)/)?Math.max(1,c+n):n,v&&m.fallback&&
35
+ !x.find("li").length&&(k="cmw-fellback-to-"+m.fallback,"quit"===m.fallback?n=w+1:(n="current"===m.fallback||2>c?c:c-1,m.fallback_depth&&(A=m.fallback_depth,z=1))),n>w?h=g([]):(n<c&&(t=t.parentsUntil(s,"li.level-"+n)),"level"===m.start_mode&&n<=c&&(1<n||m.allow_all_root)?h=t.parent().find("li"):n<c&&(h=t.add(t.find("li"))),k&&m.fallback_siblings&&h.length&&(1<n||m.allow_all_root)&&(h=h.add(t.siblings("li.level-"+n)))),h.length)){c=n;t=9999;A&&(t=z&&C>=c&&h.filter(x).length?C:c,t+=A,f=t-1);r=1;for(n=
36
+ [];r<=w;r++)r>=c&&r<t&&n.push(".level-"+r);h=h.filter(n.join(","))}"secondary"===m.contains_current&&h.length&&!x.is(h)&&(h=g([]));if(b&&h.length){n=p.data().level;if(m.ancestors&&(p.is(h)||n>f)){r=m.ancestors;0>r&&(r=Math.max(1,n+r));c=m.ancestor_siblings;0>c&&(c=Math.max(1,n+c));n=[];for(t=[];r<=w;r++)r<=f&&(n.push(".level-"+r),0<c&&r>=c&&t.push(".level-"+r));r=h.length;n=p.parentsUntil(s,n.join(","));h=h.add(n.not(h).data("included"," cmw-an-included-ancestor"));t.length&&(h=h.add(n.filter(t.join(",")).siblings("li").not(h).data("included",
37
+ " cmw-an-included-ancestor-sibling")));l+=h.length-r}m.siblings&&p.is(h)&&(n=h.length,h=h.add(p.siblings("li").data("included"," cmw-an-included-sibling")),l+=h.length-n)}h.length&&m.include_level&&(t=H(m.include_level,w))&&(n=h.length,h=h.add(s.find(t)),l+=h.length-n);"inclusions"===m.contains_current&&h.length&&!x.is(h)&&(h=g([]));h.length&&y.length&&(n=h.length,h=h.not(y),e+=n-h.length);h.length&&m.exclude_level&&(t=H(m.exclude_level,w))&&(n=h.length,h=h.not(t),e+=n-h.length);"output"===m.contains_current&&
38
+ h.length&&!x.is(h)&&(h=g([]));m.title_from_current&&x.length?x.addClass("title-from-item"):m.title_from_current_root&&x.length?x.closest(".level-1").addClass("title-from-item"):b&&p&&(m.title_from_branch?p.addClass("title-from-item"):m.title_from_branch_root&&p.closest(".level-1").addClass("title-from-item"));d.find(".cmw-demo-fallback").data("fellback",k).toggleClass("updated",!!k);d.find(".cmw-demo-setcurrent").toggleClass("error",!x.length&&(!!m.contains_current||v));r={inclusions:l,exclusions:e};
39
+ for(n in r)t=d.find(".cmw-demo-"+n),t.text(t.text().replace(/\d+$/,r[n])).toggleClass("updated",0<r[n]);s.toggleClass("cmw-demo-filteritems",u).find(".picked").not(h.addClass("picked")).removeClass("picked");F(d,a);J(d,m)}a.add(d).find("code").text(this.shortcode(m))},v210:{setLevels:function(a,b){var d=a.find(".cmw-start-level"),c=d.val(),f=d.find("option").length,l;c>b&&d.val(1);for(d.find("option").slice(b).remove();f<b;)++f,d.append(g("<option/>",{value:f}).text(f));d=a.find(".cmw-depth");c=d.val();
40
+ f=d.find("option").length;l=d.data().cmwTextLevels;c>b&&d.val(0);for(d.find("option").slice(b+1).remove();f<=b;)d.append(g("<option/>",{value:f}).text(f+l)),++f},setFields:function(a,b){var d=b.find(".cmw-showall").prop("checked"),c=b.find(".cmw-showspecific").prop("checked"),f=b.find(".cmw-assist-items"),l=parseInt(f.val(),10);a.hasClass("cmw-select-menu")&&(l=K(f,l,a[0].selectedIndex),this.setLevels(b,(f.find("optgroup").data()||{}).cmwMaxLevel));g.each({"":d||c,"-ss":c,"not-rp":d||c||0<=l,"not-ci":d||
41
+ c||!!l},function(a,c){b.find(".cmw-disableif"+a).toggleClass("cmw-colour-grey",c).find("input,select").prop("disabled",c)})},shortcode:function(a){var b={menu:a.menu},d=0<a.filter,c=!!a.filter&&!d,f;a.title&&(b.title=[a.title]);if(d)switch(a.filter_item){case 0:b.children_of=["current"];break;case -1:b.children_of=["parent"];break;case -2:b.children_of=["root"];break;default:b.children_of=a.filter_item}c&&(b.items=[a._items]);d&&0>a.filter_item&&a.fallback_no_ancestor&&(b.fallback_parent=a.fallback_include_parent_siblings?
42
+ ["siblings"]:a.fallback_include_parent?["parent"]:1);d&&!a.filter_item&&a.fallback_no_children&&(b.fallback_current=a.fallback_nc_include_parent_siblings?["siblings"]:a.fallback_nc_include_parent?["parent"]:1);1<a.start_level&&(b.start_level=a.start_level);0<a.depth&&(b.depth=a.depth);a.depth_rel_current&&0<a.depth&&(b.depth_rel_current=1);c=[];d&&(a.include_parent_siblings?c.push("siblings"):a.include_parent&&c.push("parent"),a.include_ancestors&&c.push("ancestors"),c.length&&(b.include=c));c=[];
43
+ d&&a.title_from_parent&&c.push("parent");a.title_from_current&&c.push("current");c.length&&(b.title_from=c);for(c in{flat_output:1,contains_current:1,ol_root:1,ol_sub:1})a[c]&&(b[c]=1);d={container:"div",container_id:"",container_class:"",menu_class:"menu-widget",widget_class:""};for(c in d)a[c]!==d[c]&&(b[c]=[a[c]]);d={wrap_link:"before",wrap_link_text:"link_before"};for(c in d)(f=a[d[c]].toString().match(/^<(\w+)/))&&f[1]&&(b[c]=[f[1]]);d=[];for(c in b)d.push(g.isArray(b[c])?c+'="'+b[c].join(" ")+
44
+ '"':c+"="+b[c]);return"[custom_menu_wizard "+d.join(" ")+"]"},update:function(a){var b=g(a);a=B(0,b);var d=g("#"+a.data().cmwDialogId),c,f,l,e,k,q,u,p,v,w,m,s,h;b.hasClass("cmw-listen")&&this.setFields(b,a);if(d.length&&d.dialog("isOpen")){d.dialog("moveToTop");b.hasClass("cmw-select-menu")&&G(d);e=I(a);c=!e.filter;b=0<e.filter;f=!c&&!b;k=e.include_parent;q=e.include_parent_siblings;u=d.find(".cmw-demo-themenu-ul");l=u.data().maxLevel;v=u.find(".current-menu-item").closest("li");w=v.length?v.data().level:
45
+ -1;p=u.find("li").removeData("included").removeClass("title-from-item");f&&(p=E(p,e,"tick"));p.length&&!v.length&&(e.contains_current||b&&1>e.filter_item)&&(p=g([]));p.length&&b&&(0<e.filter_item?s=p.filter("[data-itemid="+e.filter_item+"]"):e.filter_item?1===w&&e.fallback_no_ancestor?(s=v,k=k||e.fallback_include_parent,q=q||e.fallback_include_parent_siblings,m="cmw-fellback-to-current"):s=1===w?u:-1>e.filter_item?u.find(".current-menu-ancestor").eq(0).closest("li"):u.find(".current-menu-parent").closest("li"):
46
+ v.find("li").length?s=v:e.fallback_no_children&&(s=u.find(".current-menu-parent").closest("li"),s.length||(s=u),k=k||e.fallback_nc_include_parent,q=q||e.fallback_nc_include_parent_siblings,m="cmw-fellback-to-parent"));if(p.length)if(c)for(h=e.depth_rel_current&&e.depth&&v.length&&w>=e.start_level?w+e.depth-1:e.depth?e.start_level+e.depth-1:9999,c=1;c<=l;c++){if(c<e.start_level||c>h)p=p.not(".level-"+c)}else s&&s.length?(h=e.depth_rel_current&&e.depth&&v.length&&s.has(v[0]).length?w-1+e.depth:e.depth?
47
+ Math.max((s.data().level||0)+e.depth,e.start_level+e.depth-1):9999,p=s.find("li").filter(function(){var a=g(this).data().level;return a>=e.start_level&&a<=h})):b&&(p=g([]));p.length&&b&&s&&s.is("li")&&(q&&(p=p.add(s.siblings("li").data("included"," cmw-an-included-parent-sibling")),k=!0),e.include_ancestors&&(p=p.add(s.parentsUntil(u,"li").data("included"," cmw-an-included-ancestor")),k=!0),k&&(p=p.add(s.data("included"," cmw-the-included-parent"))));!p.length||!e.contains_current||v.length&&p.filter(v).length||
48
+ (p=g([]));e.title_from_parent&&p.length&&s&&s.is("li")?s.addClass("title-from-item"):e.title_from_current&&p.length&&v.addClass("title-from-item");m=p.length?m:"";d.find(".cmw-demo-fallback").data("fellback",m).toggleClass("updated",!!m);d.find(".cmw-demo-setcurrent").toggleClass("error",!v.length&&(e.contains_current||b&&1>e.filter_item));u.toggleClass("cmw-demo-filteritems",f).find(".picked").not(p.addClass("picked")).removeClass("picked");F(d,a);J(d,e);d.find("code").text(this.shortcode(e))}}}};
49
+ g(document).on("change",y("onchange",1),D).on("click",y("assist",1),function(a){a=g(this);a=B(0,a);var b=a.data(),d=g("#"+b.cmwDialogId);d.length||(d=P(b).data({cmwOnchange:"#"+a.attr("id"),cmwUntitled:"["+b.cmwDialogUntitled+"]"}));d.dialog("isOpen")?d.dialog("close"):(G(d),F(d,a),d.dialog("open"),D.call(a[0]));this.blur();return!1}).on("click",y("fieldset",1),function(a){a=g(this);var b=a.next(".cmw-fieldset-state"),d=!b.prop("checked");b.length&&(b.prop("checked",d),a.toggleClass("cmw-collapsed-fieldset",
50
+ d),b.next("div")[d?"slideUp":"slideDown"]());this.blur();return!1}).on("click",".widget-action,.widget-control-close",function(a){a=g(this).closest("div.widget");var b=a.parent();b.hasClass("customize-control-widget_form")&&!b.hasClass("expanded")||B(a).each(function(){var a=g("#"+g(this).data().cmwDialogId);a.length&&a.dialog("isOpen")&&a.dialog("close")})}).on("click",".widget-control-remove",function(a){B(g(this).closest("div.widget")).each(function(){var a=g("#"+g(this).data().cmwDialogId);a.length&&
51
+ (a.dialog("destroy"),a.remove())})}).on("click",y("colexp",1),function(a){a=/1-e/.test(this.className)?"slideUp":"slideDown";g(this).toggleClass("ui-icon-triangle-1-s ui-icon-triangle-1-e").prev("ul")[a]();return!1}).on("click",y("find-shortcodes",1),function(a){a=g(this);var b=a.parent().parent();ajaxurl&&!b.hasClass("cmw-ajax-fetching")&&(b.hasClass("cmw-ajax-showing")?b.removeClass("cmw-ajax-showing"):(b.addClass("cmw-ajax-fetching"),g.post(ajaxurl,{action:"cmw-find-shortcodes",_wpnonce:a.data().nonce}).done(function(a){a&&
52
+ "0"!==a&&(b.find(".cmw-demo-found-shortcodes").html(g(a).find("response_data").text()),b.addClass("cmw-ajax-showing"))}).always(function(a){b.removeClass("cmw-ajax-fetching")})));this.blur();return!1}).on("click",y("legacy-close",1),function(){g(this).parent().remove();return!1});window.Custom_Menu_Wizard_Widget&&g(window.Custom_Menu_Wizard_Widget.trigger||[]).trigger("change")});
custom-menu-wizard.php CHANGED
@@ -3,13 +3,19 @@
3
  * Plugin Name: Custom Menu Wizard
4
  * Plugin URI: http://wordpress.org/plugins/custom-menu-wizard/
5
  * Description: Show any part of a custom menu in a Widget, or in content using a Shortcode. Customise the output with extra classes or html; filter by current menu item or a specific item; set a depth, show the parent(s), change the list style, etc. Use the included emulator to assist with the filter settings.
6
- * Version: 3.0.3
7
  * Author: Roger Barrett
8
  * Author URI: http://www.wizzud.com/
9
  * License: GPL2+
10
  */
11
  defined( 'ABSPATH' ) or exit();
12
  /*
 
 
 
 
 
 
13
  * v3.0.3 change log
14
  * - removed all occurrences of "Plugin " followed by "Name" from everywhere except the main plugin file (this one!) to avoid update() incorrectly reporting "invalid header" when activating straight from installation (rather than from the Plugin admin page)
15
  * - tweak : eliminate the over-use of get_title() when determining the widget title
@@ -126,7 +132,8 @@ if( !class_exists( 'Custom_Menu_Wizard_Plugin' ) ){
126
  //declare the main plugin class...
127
  class Custom_Menu_Wizard_Plugin {
128
 
129
- public static $version = '3.0.3';
 
130
  protected static $instance;
131
 
132
  /**
@@ -136,6 +143,7 @@ if( !class_exists( 'Custom_Menu_Wizard_Plugin' ) ){
136
 
137
  add_action( 'widgets_init', array( &$this, 'widget_and_shortcode' ) );
138
  add_action( 'wp_ajax_cmw-find-shortcodes', array( &$this, 'ajax_find_shortcodes' ) );
 
139
  add_action( 'admin_print_styles-widgets.php', array( &$this, 'enqueue_styles' ) );
140
  add_action( 'admin_print_scripts-widgets.php', array( &$this, 'enqueue_scripts' ) );
141
  add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
@@ -169,8 +177,8 @@ if( !class_exists( 'Custom_Menu_Wizard_Plugin' ) ){
169
  */
170
  public function enqueue_scripts(){
171
 
172
- $min = defined( 'WP_DEBUG' ) && WP_DEBUG ? '' : '.min';
173
- wp_enqueue_script( 'custom-menu-wizard-plugin-script', plugins_url( "/custom-menu-wizard$min.js", __FILE__ ), array('jquery-ui-dialog'), self::$version, true );
174
 
175
  } //end enqueue_scripts()
176
 
@@ -192,7 +200,17 @@ if( !class_exists( 'Custom_Menu_Wizard_Plugin' ) ){
192
  wp_enqueue_style( 'jquery-ui' );
193
 
194
  } //end enqueue_styles()
195
-
 
 
 
 
 
 
 
 
 
 
196
  /**
197
  * hooked into in_plugin_update_message-custom-menu-wizard action : request read changelog before updating
198
  * @param array $plugin_data Plugin metadata
@@ -387,12 +405,14 @@ if( !class_exists( 'Custom_Menu_Wizard_Plugin' ) ){
387
  * deprecated:
388
  * - children_of : now branch, and limited to current[-item] or digits; parent|current-parent|root|current-ancestor all require conversion
389
  * - start_level : now level (integer) for a by-level filter, or start_at (string) for a by-branch filter (determining branch_start)
 
390
  * changed:
391
  * - contains_current : was a switch, now a string (empty or menu|primary|secondary|output); switch ON = 'output'
392
  * - include : now accepts siblings, ancestors and/or ancestor-siblings (csv); parent is gone, and hyphen separator no longer allowed
393
  * - title_from : should now be csv, hyphen separator no longer allowed
394
  * added:
395
  * - title_tag & findme
 
396
  *
397
  * default (ie. no options) is:
398
  * - show all
@@ -434,7 +454,8 @@ if( !class_exists( 'Custom_Menu_Wizard_Plugin' ) ){
434
  //inclusions...
435
  'ancestors' => 0, //integer (negative = relative)
436
  'ancestor_siblings' => 0, //integer (negative = relative)
437
- 'include_root' => 0, //switch (means *all* root items!)
 
438
  'siblings' => 0, //switch
439
  //exclusions...
440
  'exclude' => '', // csv of menu item ids (an id may have a '+' appended, for inheritance, eg. '23+')
@@ -537,6 +558,12 @@ if( !class_exists( 'Custom_Menu_Wizard_Plugin' ) ){
537
  }
538
 
539
  if( $ok ){
 
 
 
 
 
 
540
  //fallback => fallback and fallback_siblings and fallback_depth...
541
  //allows "X", "X,Y" or "X,Y,Z" where comma could be space, and X|Y|Z could be "quit"|"current"|"parent", or "+siblings", or digit(s)
542
  //but "quit", "current" or "parent" must be present (others are optional)
3
  * Plugin Name: Custom Menu Wizard
4
  * Plugin URI: http://wordpress.org/plugins/custom-menu-wizard/
5
  * Description: Show any part of a custom menu in a Widget, or in content using a Shortcode. Customise the output with extra classes or html; filter by current menu item or a specific item; set a depth, show the parent(s), change the list style, etc. Use the included emulator to assist with the filter settings.
6
+ * Version: 3.0.4
7
  * Author: Roger Barrett
8
  * Author URI: http://www.wizzud.com/
9
  * License: GPL2+
10
  */
11
  defined( 'ABSPATH' ) or exit();
12
  /*
13
+ * v3.0.4 change log
14
+ * - fixed bug in the display of the "No Current Item!" warning in the "assist"
15
+ * - corrected the enabling/disabling of a couple of fields in the widget form, and tweaked the indentation for better responsiveness
16
+ * - fixed a bug with accessibility mode when javascript is enabled, and added a warning about the accuracy of the shortcode when javascript is disabled
17
+ * - extended the All Root Items inclusion to be a selectable number of levels (as per the Exclusions by Level)
18
+ *
19
  * v3.0.3 change log
20
  * - removed all occurrences of "Plugin " followed by "Name" from everywhere except the main plugin file (this one!) to avoid update() incorrectly reporting "invalid header" when activating straight from installation (rather than from the Plugin admin page)
21
  * - tweak : eliminate the over-use of get_title() when determining the widget title
132
  //declare the main plugin class...
133
  class Custom_Menu_Wizard_Plugin {
134
 
135
+ public static $version = '3.0.4';
136
+ public static $script_handle = 'custom-menu-wizard-plugin-script';
137
  protected static $instance;
138
 
139
  /**
143
 
144
  add_action( 'widgets_init', array( &$this, 'widget_and_shortcode' ) );
145
  add_action( 'wp_ajax_cmw-find-shortcodes', array( &$this, 'ajax_find_shortcodes' ) );
146
+ add_action( 'admin_enqueue_scripts', array( &$this, 'register_scripts' ) );
147
  add_action( 'admin_print_styles-widgets.php', array( &$this, 'enqueue_styles' ) );
148
  add_action( 'admin_print_scripts-widgets.php', array( &$this, 'enqueue_scripts' ) );
149
  add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
177
  */
178
  public function enqueue_scripts(){
179
 
180
+ //script is pre-registered - see this->register_scripts() - so that it can be localized if need be (like for accessibility mode)
181
+ wp_enqueue_script( self::$script_handle );
182
 
183
  } //end enqueue_scripts()
184
 
200
  wp_enqueue_style( 'jquery-ui' );
201
 
202
  } //end enqueue_styles()
203
+
204
+ /**
205
+ * hooked into admin_enqueue_scripts : registers the plugin script
206
+ */
207
+ public function register_scripts(){
208
+
209
+ $min = defined( 'WP_DEBUG' ) && WP_DEBUG ? '' : '.min';
210
+ wp_register_script( self::$script_handle, plugins_url( "/custom-menu-wizard$min.js", __FILE__ ), array('jquery-ui-dialog'), self::$version, true );
211
+
212
+ } //end register_scripts()
213
+
214
  /**
215
  * hooked into in_plugin_update_message-custom-menu-wizard action : request read changelog before updating
216
  * @param array $plugin_data Plugin metadata
405
  * deprecated:
406
  * - children_of : now branch, and limited to current[-item] or digits; parent|current-parent|root|current-ancestor all require conversion
407
  * - start_level : now level (integer) for a by-level filter, or start_at (string) for a by-branch filter (determining branch_start)
408
+ * - include_root : (as of v3.0.4) replaced by include_level (like exclude_level); include_root On equiv. is include_level == '1'
409
  * changed:
410
  * - contains_current : was a switch, now a string (empty or menu|primary|secondary|output); switch ON = 'output'
411
  * - include : now accepts siblings, ancestors and/or ancestor-siblings (csv); parent is gone, and hyphen separator no longer allowed
412
  * - title_from : should now be csv, hyphen separator no longer allowed
413
  * added:
414
  * - title_tag & findme
415
+ * - include_level (v3.0.4)
416
  *
417
  * default (ie. no options) is:
418
  * - show all
454
  //inclusions...
455
  'ancestors' => 0, //integer (negative = relative)
456
  'ancestor_siblings' => 0, //integer (negative = relative)
457
+ 'include_root' => 0, //switch (means *all* root items!) v3.0.4 DEPRECATED still allowed (for back compat.), equiv. is include_level='1'
458
+ 'include_level' => '', // v3.0.4 digit, possibly appended with a '+' or '-', eg. '2', '2+', or '2-'
459
  'siblings' => 0, //switch
460
  //exclusions...
461
  'exclude' => '', // csv of menu item ids (an id may have a '+' appended, for inheritance, eg. '23+')
558
  }
559
 
560
  if( $ok ){
561
+ //include_level, and the deprecated include_root switch...
562
+ //if level is empty but root is set, set include_level to '1'...
563
+ if( empty( $instance['include_level'] ) && $instance['include_root'] ){
564
+ $instance['include_level'] = '1';
565
+ }
566
+ unset( $instance['include_root'] );
567
  //fallback => fallback and fallback_siblings and fallback_depth...
568
  //allows "X", "X,Y" or "X,Y,Z" where comma could be space, and X|Y|Z could be "quit"|"current"|"parent", or "+siblings", or digit(s)
569
  //but "quit", "current" or "parent" must be present (others are optional)
include/class.walker.php CHANGED
@@ -165,7 +165,7 @@ class Custom_Menu_Wizard_Walker extends Walker_Nav_Menu {
165
  // - 1st found : current & ancestor = d001
166
  // - 2nd found : current & parent & ancestor = c002
167
  // - 3rd found : just current = a003
168
- // - 4th found : just current & parent = b004
169
  // - 5th found : just current = a005
170
  //reverse sort keys alphabetically and a003 comes out on bottom, so third found gets used! (copes with 999 "current" items; should be enough!)
171
  $j = $item->current_item_ancestor ? ( $item->current_item_parent ? 'c' : 'd') : ( $item->current_item_parent ? 'b' : 'a' );
@@ -271,6 +271,54 @@ class Custom_Menu_Wizard_Walker extends Walker_Nav_Menu {
271
 
272
  }
273
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
274
  /**
275
  * returns the menu item id if an item's parent
276
  *
@@ -304,9 +352,45 @@ class Custom_Menu_Wizard_Walker extends Walker_Nav_Menu {
304
 
305
  } //end _cmw_include_siblings_of()
306
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
307
  /**
308
  * current : recursively set the keep flag if within specified level/depth
309
  * if item passed in is eligible, sets that item as kept and runs through its kids recursively
 
 
310
  *
311
  * @param integer $itemID Menu item ID
312
  */
@@ -365,6 +449,13 @@ class Custom_Menu_Wizard_Walker extends Walker_Nav_Menu {
365
  */
366
  private function _cmw_walk( &$args, $elements ){
367
 
 
 
 
 
 
 
 
368
  $cmw =& $args->_custom_menu_wizard;
369
 
370
  $cmw['_walker']['fellback'] = false;
@@ -383,19 +474,6 @@ class Custom_Menu_Wizard_Walker extends Walker_Nav_Menu {
383
  //no-kids fallback?...
384
  $canFallback = $find_current && in_array( $cmw['fallback'], array('current', 'parent', 'quit') );
385
 
386
- $id_field = $this->db_fields['id']; //eg. = 'db_id'
387
- $parent_field = $this->db_fields['parent']; //eg. = 'menu_item_parent'
388
-
389
- $unlimited = 65532;
390
- $topOfBranch = -1;
391
-
392
- $continue = true;
393
- //no point doing much more if we need the current item and we haven't found it...
394
- //handles contains_current == 'menu'...
395
- if( empty( $currentItem ) && ( $find_current || !empty( $cmw['contains_current'] ) ) ){
396
- $continue = false;
397
- }
398
-
399
  //PRIMARY FILTERS...
400
  if( $continue ){
401
  //levels...
@@ -408,19 +486,26 @@ class Custom_Menu_Wizard_Walker extends Walker_Nav_Menu {
408
  }
409
  //branch...
410
  if( $find_branch ){
 
411
  $topOfBranch = $find_current
412
- ? $currentItem
413
- : ( isset( $this->_cmw_tree[ $cmw['branch'] ] )
414
- ? $cmw['branch']
415
- : -1
416
- );
417
  $theBranchItem = $topOfBranch;
418
  $continue = $topOfBranch > 0;
419
  }
420
  } //end PRIMARIES
421
 
422
  //check for current item...
423
- if( $continue && ( $cmw['contains_current'] == 'primary' ) ){
 
 
 
 
 
 
 
 
 
424
  if( $find_level ){
425
  $continue = $this->_cmw_tree[ $currentItem ]['level'] >= $cmw['level'];
426
  }
@@ -586,14 +671,17 @@ class Custom_Menu_Wizard_Walker extends Walker_Nav_Menu {
586
  $this->_cmw_include_siblings_of( $theBranchItem );
587
  }
588
  }
589
- if( $cmw['include_root'] ){
590
- //all root items...
591
- foreach( $this->_cmw_levels[1] as $itemID ){
592
- if( !$this->_cmw_tree[ $itemID ]['keep'] ){
593
- $this->_cmw_tree[ $itemID ]['keep'] = true;
594
- $this->_cmw_tree[ $itemID ]['classes'][] = 'cmw-an-included-root-item';
595
- $this->_cmw_tree[0]['keepCount']++;
 
 
596
  }
 
597
  }
598
  }
599
  } //end INCLUSIONS
@@ -605,37 +693,7 @@ class Custom_Menu_Wizard_Walker extends Walker_Nav_Menu {
605
 
606
  //EXCLUSIONS...
607
  if( $continue){
608
- if( !empty( $cmw['__exclude'] )){
609
- foreach( $cmw['__exclude'] as $itemID ){
610
- if( $itemID > 0 && isset( $this->_cmw_tree[ $itemID ] ) && $this->_cmw_tree[ $itemID ]['keep'] ){
611
- $this->_cmw_tree[ $itemID ]['keep'] = false;
612
- $this->_cmw_tree[0]['keepCount']--;
613
- }
614
- }
615
- $continue = $this->_cmw_tree[0]['keepCount'] > 0;
616
- }
617
- if( $continue && !empty( $cmw['exclude_level'] ) && preg_match( '/^(\d+)(\+|-)?$/', $cmw['exclude_level'], $i ) > 0 ){
618
- if( empty( $i[2] ) ){
619
- $i = $i[1];
620
- $j = $i + 1;
621
- }elseif( $i[2] == '+' ){
622
- $i = $i[1];
623
- $j = count( $this->_cmw_levels );
624
- }else{
625
- $j = $i[1] + 1;
626
- $i = 1;
627
- }
628
- while( $i > 0 && isset( $this->_cmw_levels[ $i ] ) && $i < $j ){
629
- foreach( $this->_cmw_levels[ $i ] as $itemID ){
630
- if( $this->_cmw_tree[ $itemID ]['keep'] ){
631
- $this->_cmw_tree[ $itemID ]['keep'] = false;
632
- $this->_cmw_tree[0]['keepCount']--;
633
- }
634
- }
635
- $i++;
636
- }
637
- $continue = $this->_cmw_tree[0]['keepCount'] > 0;
638
- }
639
  } //end EXCLUSIONS
640
 
641
  //check for current item...
165
  // - 1st found : current & ancestor = d001
166
  // - 2nd found : current & parent & ancestor = c002
167
  // - 3rd found : just current = a003
168
+ // - 4th found : current & parent = b004
169
  // - 5th found : just current = a005
170
  //reverse sort keys alphabetically and a003 comes out on bottom, so third found gets used! (copes with 999 "current" items; should be enough!)
171
  $j = $item->current_item_ancestor ? ( $item->current_item_parent ? 'c' : 'd') : ( $item->current_item_parent ? 'b' : 'a' );
271
 
272
  }
273
 
274
+ /**
275
+ * clear any keep flags currently set in the tree
276
+ */
277
+ private function _cmw_clear_down_tree(){
278
+
279
+ if( $this->_cmw_tree[0]['keepCount'] > 0 ){
280
+ foreach( $this->_cmw_tree as $k => $v ){
281
+ $this->_cmw_tree[ $k ]['keep'] = false;
282
+ $this->_cmw_tree[ $k ]['classes'] = array();
283
+ }
284
+ $this->_cmw_tree[0]['keepCount'] = 0;
285
+ }
286
+
287
+ }
288
+
289
+ /**
290
+ * resolve digit(s) optionally followed by a plus/minus into a 'from' level an a 'to' level
291
+ * IMPORTANT : 'from' is inclusive, 'to' is exclusive, so a for() would be for( $i = $rtn['from']; $i < $rtn['to']; $i++ )
292
+ *
293
+ * @param {string} $option Level with optional +/- appended
294
+ * @return {array} False if $option doesn't parse
295
+ */
296
+ private function _cmw_decipher_plusminus_level( $option ){
297
+
298
+ $rtn = array();
299
+ if( !empty( $option ) && preg_match( '/^(\d+)(\+|-)?$/', $option, $m ) > 0 ){
300
+ $m[1] = intval( $m[1] );
301
+ if( $m[1] > 0 ){
302
+ if( empty( $m[2] ) ){
303
+ //no plus/minus : 'from' is the level, 'to' is the next level...
304
+ $rtn['from'] = $m[1];
305
+ $rtn['to'] = $m[1] + 1;
306
+ }elseif( $m[2] == '+' ){
307
+ //plus : 'from' is the level, 'to' is the number of levels
308
+ //NB: there is an artificial level zero, so if the menu has 10 levels, a count of levels will give 11!
309
+ $rtn['from'] = $m[1];
310
+ $rtn['to'] = count( $this->_cmw_levels );
311
+ }else{
312
+ //minus : 'from' is level 1, 'to' is the level plus 1
313
+ $rtn['from'] = 1;
314
+ $rtn['to'] = $m[1] + 1;
315
+ }
316
+ }
317
+ }
318
+ return empty( $rtn ) ? false : $rtn;
319
+
320
+ }
321
+
322
  /**
323
  * returns the menu item id if an item's parent
324
  *
352
 
353
  } //end _cmw_include_siblings_of()
354
 
355
+ /**
356
+ * runs exclusions, if there are any
357
+ *
358
+ * @param {array} $cmw Settings
359
+ * @return {boolean} keepCount > 0?
360
+ */
361
+ private function _cmw_run_exclusions( &$cmw ){
362
+
363
+ $rtn = $this->_cmw_tree[0]['keepCount'] > 0;
364
+ if( $rtn && !empty( $cmw['__exclude'] )){
365
+ foreach( $cmw['__exclude'] as $itemID ){
366
+ if( $itemID > 0 && isset( $this->_cmw_tree[ $itemID ] ) && $this->_cmw_tree[ $itemID ]['keep'] ){
367
+ $this->_cmw_tree[ $itemID ]['keep'] = false;
368
+ $this->_cmw_tree[0]['keepCount']--;
369
+ }
370
+ }
371
+ $rtn = $this->_cmw_tree[0]['keepCount'] > 0;
372
+ }
373
+ if( $rtn && ( $fromTo = $this->_cmw_decipher_plusminus_level( $cmw['exclude_level'] ) ) !== false ){
374
+ while( isset( $this->_cmw_levels[ $fromTo['from'] ] ) && $fromTo['from'] < $fromTo['to'] ){
375
+ foreach( $this->_cmw_levels[ $fromTo['from'] ] as $itemID ){
376
+ if( $this->_cmw_tree[ $itemID ]['keep'] ){
377
+ $this->_cmw_tree[ $itemID ]['keep'] = false;
378
+ $this->_cmw_tree[0]['keepCount']--;
379
+ }
380
+ }
381
+ $fromTo['from']++;
382
+ }
383
+ $rtn = $this->_cmw_tree[0]['keepCount'] > 0;
384
+ }
385
+ return $rtn;
386
+
387
+ }
388
+
389
  /**
390
  * current : recursively set the keep flag if within specified level/depth
391
  * if item passed in is eligible, sets that item as kept and runs through its kids recursively
392
+ * uses _cmw_lowest & _cmw_highest : note that _cmw_lowest is the lowest level in the structure - *not*
393
+ * the numerically lowest value of level - and that both are inclusive!
394
  *
395
  * @param integer $itemID Menu item ID
396
  */
449
  */
450
  private function _cmw_walk( &$args, $elements ){
451
 
452
+ $id_field = $this->db_fields['id']; //eg. = 'db_id'
453
+ $parent_field = $this->db_fields['parent']; //eg. = 'menu_item_parent'
454
+
455
+ $unlimited = 65532;
456
+ $topOfBranch = -1;
457
+ $continue = true;
458
+
459
  $cmw =& $args->_custom_menu_wizard;
460
 
461
  $cmw['_walker']['fellback'] = false;
474
  //no-kids fallback?...
475
  $canFallback = $find_current && in_array( $cmw['fallback'], array('current', 'parent', 'quit') );
476
 
 
 
 
 
 
 
 
 
 
 
 
 
 
477
  //PRIMARY FILTERS...
478
  if( $continue ){
479
  //levels...
486
  }
487
  //branch...
488
  if( $find_branch ){
489
+ //topOfBranch gets set to -1 if it can't be determined...
490
  $topOfBranch = $find_current
491
+ ? ( empty( $currentItem ) ? -1 : $currentItem )
492
+ : ( isset( $this->_cmw_tree[ $cmw['branch'] ] ) ? $cmw['branch'] : -1 );
 
 
 
493
  $theBranchItem = $topOfBranch;
494
  $continue = $topOfBranch > 0;
495
  }
496
  } //end PRIMARIES
497
 
498
  //check for current item...
499
+ //v3.0.4 : do this here (rather than above the primary filters) because I might need
500
+ // $theBranchItem later on
501
+ //NB: check is for *any* requirement for current item, not just 'menu', because I don't want to have to
502
+ // continually check for $currentItem being non-empty ($find_current is already coped with in the primaries)
503
+ if( $continue && !empty( $cmw['contains_current'] ) ){
504
+ $continue = !empty( $currentItem );
505
+ }
506
+
507
+ //check for current item...
508
+ if( $continue && $cmw['contains_current'] == 'primary' ){
509
  if( $find_level ){
510
  $continue = $this->_cmw_tree[ $currentItem ]['level'] >= $cmw['level'];
511
  }
671
  $this->_cmw_include_siblings_of( $theBranchItem );
672
  }
673
  }
674
+ //include_level (replacement/extension of include_root, as of v3.0.4)...
675
+ if( ( $fromTo = $this->_cmw_decipher_plusminus_level( $cmw['include_level'] ) ) !== false ){
676
+ while( isset( $this->_cmw_levels[ $fromTo['from'] ] ) && $fromTo['from'] < $fromTo['to'] ){
677
+ foreach( $this->_cmw_levels[ $fromTo['from'] ] as $itemID ){
678
+ if( !$this->_cmw_tree[ $itemID ]['keep'] ){
679
+ $this->_cmw_tree[ $itemID ]['keep'] = true;
680
+ $this->_cmw_tree[ $itemID ]['classes'][] = 'cmw-an-included-level';
681
+ $this->_cmw_tree[0]['keepCount']++;
682
+ }
683
  }
684
+ $fromTo['from']++;
685
  }
686
  }
687
  } //end INCLUSIONS
693
 
694
  //EXCLUSIONS...
695
  if( $continue){
696
+ $continue = $this->_cmw_run_exclusions( $cmw );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
697
  } //end EXCLUSIONS
698
 
699
  //check for current item...
include/class.widget.php CHANGED
@@ -124,10 +124,10 @@ class Custom_Menu_Wizard_Widget extends WP_Widget {
124
 
125
  //set up some simple booleans for use at the disableif___ classes...
126
  $isByItems = $instance['filter'] == 'items'; // disableif-ss (IS Items filter)
127
- $isUnlimitedDepth = empty( $instance['depth'] ); // disableif-ud (IS unlimited depth)
128
  $isNotByBranch = $instance['filter'] != 'branch'; // disableifnot-br (is NOT Branch filter)
129
  $isNotBranchCurrentItem = $isNotByBranch || !empty( $instance['branch'] ); // disableifnot-br-ci (is NOT "Branch:Current Item")
130
- $isNotFallbackParentCurrent = !in_array( $instance['fallback'], array('parent', 'current') ); //disableifnot-fb-pc (is NOT set to fall back to parent or current)
131
 
132
  //NB the 'onchange' wrapper holds any text required by the "assist"
133
  ?>
@@ -185,137 +185,122 @@ class Custom_Menu_Wizard_Widget extends WP_Widget {
185
  <?php $this->cmw_assist_link(); ?>
186
  <strong><?php _e('Primary Filter'); ?></strong>
187
 
188
- <br />
189
- <label class="cmw-verticalalign-baseline">
190
- <input id="<?php echo $this->get_field_id('filter'); ?>_0" class="cmw-bylevel cmw-listen"
191
- <?php $this->cmw_disableif(); ?> name="<?php echo $this->get_field_name('filter'); ?>"
192
- type="radio" value="" <?php checked( $instance['filter'], '' ); ?>
193
- /><?php _e('Level:'); ?></label>
194
- <select id="<?php echo $this->get_field_id('level'); ?>" class="cmw-level cmw-listen"
195
- <?php $this->cmw_disableif(); ?> name="<?php echo $this->get_field_name('level'); ?>">
196
- <?php for( $i = 1, $j = $instance['level'] > $menus['selectedLevels'] ? 1 : $instance['level']; $i <= $menus['selectedLevels']; $i++ ){ ?>
197
- <option value="<?php echo $i; ?>" <?php selected( $j, $i ); ?>><?php echo $i > 1 ? $i : $i . __(' (root)'); ?></option>
198
- <?php } ?>
199
- </select>
 
 
200
 
201
- <br />
202
- <label class="cmw-verticalalign-baseline">
203
- <input id="<?php echo $this->get_field_id('filter'); ?>_1" class="cmw-bybranch cmw-listen"
204
- <?php $this->cmw_disableif(); ?> name="<?php echo $this->get_field_name('filter'); ?>"
205
- type="radio" value="branch" <?php checked( $instance['filter'], 'branch' ); ?>
206
- /><?php _e('Branch:'); ?></label>
207
- <select id="<?php echo $this->get_field_id('branch'); ?>" class="cmw-branches cmw-assist-items cmw-listen"
208
- <?php $this->cmw_disableif(); ?> name="<?php echo $this->get_field_name('branch'); ?>">
209
- <option value="0" <?php selected( $instance['branch'], 0 ); ?>><?php _e('Current Item'); ?></option>
210
- <?php echo $menus['selectedOptgroup']; ?>
211
- </select>
212
- <select id="<?php echo $this->get_field_id('branch_ignore'); ?>" class='cmw-off-the-page' disabled="disabled"
213
- name="<?php echo $this->get_field_name('branch_ignore'); ?>">
214
- <?php echo $menus['optgroups']; ?>
215
- </select>
 
216
 
217
- <br />
218
- <label class="cmw-verticalalign-baseline">
219
- <input id="<?php echo $this->get_field_id('filter'); ?>_2" class="cmw-byitems cmw-listen"
220
- <?php $this->cmw_disableif(); ?> name="<?php echo $this->get_field_name('filter'); ?>"
221
- type="radio" value="items" <?php checked( $instance['filter'], 'items' ); ?>
222
- /><?php _e('Items:'); ?></label>
223
- <?php $this->cmw_formfield_textbox( $instance, 'items',
224
- array(
225
- 'fclass' => 'cmw-maxwidth-twothirds cmw-setitems cmw-listen'
226
- ) ); ?>
 
227
  </div>
228
 
229
  <div class="cmw-disableif-ss<?php $this->cmw_disableif( 'push', $isByItems ); ?>">
230
  <?php $this->cmw_assist_link(); ?>
231
  <strong><?php _e('Secondary Filter'); ?></strong>
232
 
233
- <br />
234
- <label class="cmw-disableifnot-br<?php $this->cmw_disableif( 'push', $isNotByBranch ); ?>"><?php _e('Starting at:'); ?>
235
- <select id="<?php echo $this->get_field_id('branch_start'); ?>" class="cmw-branch-start cmw-listen"
236
- <?php $this->cmw_disableif(); ?> name="<?php echo $this->get_field_name('branch_start'); ?>">
237
- <optgroup label="<?php _e('relative...'); ?>" data-cmw-text-children="<?php _e('children'); ?>"
238
- data-cmw-text-parent="<?php _e('parent'); ?>">
239
- <?php echo implode( '', $relGroup ); ?>
240
- </optgroup>
241
- <optgroup label="<?php _e('absolute...'); ?>">
242
- <?php echo implode( '', $absGroup ); ?>
243
- </optgroup>
244
- </select></label><!-- end .cmw-disableifnot-br --><?php $this->cmw_disableif( 'pop' ); ?>
245
-
246
  <div class="cmw-indented">
247
- <label class="cmw-followed-by">
248
- <input id="<?php echo $this->get_field_id('start_mode'); ?>_0"
249
- name="<?php echo $this->get_field_name('start_mode'); ?>"
250
- <?php $this->cmw_disableif(); ?> type="radio" value="" <?php checked( $instance['start_mode'] !== 'level' ); ?>
251
- /><?php printf( __('Item %1$s(if possible)%2$s'), '<small>', '</small>' ); ?></label>
252
-
253
- <label class="cmw-whitespace-nowrap">
254
- <input id="<?php echo $this->get_field_id('start_mode'); ?>_1" name="<?php echo $this->get_field_name('start_mode'); ?>"
255
- <?php $this->cmw_disableif(); ?> type="radio" value="level" <?php checked( $instance['start_mode'] === 'level' ); ?>
256
- /><?php _e('Level'); ?></label>
 
257
 
258
  <br />
259
- <?php $this->cmw_formfield_checkbox( $instance, 'allow_all_root',
260
- array(
261
- 'label' => __('Allow all Root Items'),
262
- 'lclass' => 'cmw-disableifnot-br',
263
- 'disableif' => $isNotByBranch
264
- ) ); ?>
 
 
 
 
 
 
 
 
 
 
 
 
265
  </div>
266
 
267
- <label><?php _e('For Depth:'); ?>
268
- <select id="<?php echo $this->get_field_id('depth'); ?>" data-cmw-text-levels="<?php _e('levels'); ?>"
269
- <?php $this->cmw_disableif(); ?> class="cmw-depth cmw-listen" name="<?php echo $this->get_field_name('depth'); ?>">
270
- <option value="0" <?php selected( $instance['depth'] > $menus['selectedLevels'] ? 0 : $instance['depth'], 0 ); ?>><?php _e('unlimited'); ?></option>
271
- <?php for( $i = 1; $i <= $menus['selectedLevels']; $i++ ){ ?>
272
- <option value="<?php echo $i; ?>" <?php selected( $instance['depth'], $i ); ?>><?php printf( _n('%d level', '%d levels', $i), $i ); ?></option>
273
- <?php } ?>
274
- </select></label>
275
-
276
  <div class="cmw-indented">
 
 
 
 
 
 
 
 
 
 
 
277
  <?php $this->cmw_formfield_checkbox( $instance, 'depth_rel_current',
278
- array(
279
- 'label' => __('Relative to Current Item'),
280
- 'lclass' => 'cmw-disableif-ud',
281
- 'disableif' => $isUnlimitedDepth
282
- ) ); ?>
283
  </div>
284
  </div><!-- end .cmw-disableif-ss --><?php $this->cmw_disableif( 'pop' ); ?>
285
 
286
  <div>
287
  <?php $this->cmw_assist_link(); ?>
288
  <strong><?php _e('Inclusions'); ?></strong>
289
- <br />
290
- <label class="cmw-disableifnot-br<?php $this->cmw_disableif( 'push', $isNotByBranch ); ?>"><?php _e('Branch Ancestors:'); ?>
291
- <select id="<?php echo $this->get_field_id('ancestors'); ?>" class="cmw-ancestors cmw-listen"
292
- <?php $this->cmw_disableif(); ?> name="<?php echo $this->get_field_name('ancestors'); ?>"
293
- data-cmw-text-tolevel="<?php _e('to level'); ?>">
294
- <option value="0" <?php selected( $j, 0 ); ?>>&nbsp;</option>
295
- <?php
296
- $j = $instance['ancestors'];
297
- $j = max( min( $j, $menus['selectedLevels'] - 1 ), 1 - $menus['selectedLevels'] ); ?>
298
- <optgroup label="<?php _e('relative...'); ?>" data-cmw-text-for-option=" <?php _e('%d levels'); ?>">
299
- <option value="-1" <?php selected( $j, -1 ); ?>><?php printf( __('%d level (parent)'), -1 ); ?></option>
300
- <?php for( $i = -2; $i > 0 - $menus['selectedLevels']; $i-- ){ ?>
301
- <option value="<?php echo $i; ?>" <?php selected( $j, $i ); ?>><?php printf( __('%d levels'), $i ); ?></option>
302
- <?php } ?>
303
- </optgroup>
304
- <optgroup label="<?php _e('absolute...'); ?>" data-cmw-text-for-option="<?php _e('to level %d'); ?> ">
305
- <option value="1" <?php selected( $j, 1 ); ?>><?php printf( __('to level %d (root)'), 1 ); ?></option>
306
- <?php for( $i = 2; $i < $menus['selectedLevels']; $i++ ){ ?>
307
- <option value="<?php echo $i; ?>" <?php selected( $j, $i ); ?>><?php printf( __('to level %d'), $i ); ?></option>
308
- <?php } ?>
309
- </optgroup>
310
- </select></label><!-- end .cmw-disableifnot-br --><?php $this->cmw_disableif( 'pop' ); ?>
311
 
312
- <div class="cmw-indented cmw-disableifnot-br<?php $this->cmw_disableif( 'push', $isNotByBranch ); ?>">
313
- <label><?php _e('... with Siblings:'); ?>
314
- <select id="<?php echo $this->get_field_id('ancestor_siblings'); ?>" class="cmw-ancestor-siblings cmw-listen"
315
- <?php $this->cmw_disableif(); ?> name="<?php echo $this->get_field_name('ancestor_siblings'); ?>">
 
316
  <option value="0" <?php selected( $j, 0 ); ?>>&nbsp;</option>
317
  <?php
318
- $j = $instance['ancestor_siblings'];
319
  $j = max( min( $j, $menus['selectedLevels'] - 1 ), 1 - $menus['selectedLevels'] ); ?>
320
  <optgroup label="<?php _e('relative...'); ?>" data-cmw-text-for-option=" <?php _e('%d levels'); ?>">
321
  <option value="-1" <?php selected( $j, -1 ); ?>><?php printf( __('%d level (parent)'), -1 ); ?></option>
@@ -329,8 +314,32 @@ class Custom_Menu_Wizard_Widget extends WP_Widget {
329
  <option value="<?php echo $i; ?>" <?php selected( $j, $i ); ?>><?php printf( __('to level %d'), $i ); ?></option>
330
  <?php } ?>
331
  </optgroup>
332
- </select></label>
333
- </div><!-- end .cmw-disableifnot-br --><?php $this->cmw_disableif( 'pop' ); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
334
 
335
  <?php $this->cmw_formfield_checkbox( $instance, 'siblings',
336
  array(
@@ -339,34 +348,46 @@ class Custom_Menu_Wizard_Widget extends WP_Widget {
339
  'disableif' => $isNotByBranch
340
  ) ); ?>
341
 
342
- <br />
343
- <?php $this->cmw_formfield_checkbox( $instance, 'include_root',
344
- array(
345
- 'label' => __('All Root Items')
346
- ) ); ?>
 
 
 
 
 
 
 
 
347
  </div>
348
 
349
  <div>
350
  <?php $this->cmw_assist_link(); ?>
351
  <strong><?php _e('Exclusions'); ?></strong>
352
- <br />
353
- <?php $this->cmw_formfield_textbox( $instance, 'exclude',
354
- array(
355
- 'label' => __('Item Ids:'),
356
- 'fclass' => 'cmw-maxwidth-twothirds cmw-exclusions'
357
- ) ); ?>
358
- <br />
359
- <label><?php _e('By Level:'); ?>
360
- <select id="<?php echo $this->get_field_id('exclude_level'); ?>" class="cmw-exclude-level"
361
- name="<?php echo $this->get_field_name('exclude_level'); ?>">
362
- <?php $j = intval($instance['exclude_level']) > $menus['selectedLevels'] ? '' : $instance['exclude_level']; ?>
363
- <option value="" <?php selected( $j, '' ); ?>>&nbsp;</option>
364
- <?php for( $i = 1; $i <= $menus['selectedLevels']; $i++ ){ ?>
365
- <option value="<?php echo $i; ?>" <?php selected( $j, "$i" ); ?>><?php echo $i; ?></option>
366
- <option value="<?php echo $i . '-'; ?>" <?php selected( $j, $i . '-' ); ?>>&nbsp;&nbsp;&nbsp;<?php echo $i . __(' and above'); ?></option>
367
- <option value="<?php echo $i . '+'; ?>" <?php selected( $j, $i . '+' ); ?>>&nbsp;&nbsp;&nbsp;<?php echo $i . __(' and below'); ?></option>
368
- <?php } ?>
369
- </select></label>
 
 
 
 
370
  </div>
371
 
372
  <div>
@@ -395,32 +416,36 @@ class Custom_Menu_Wizard_Widget extends WP_Widget {
395
  <div class="cmw-disableifnot-br-ci<?php $this->cmw_disableif( 'push', $isNotBranchCurrentItem ); ?>">
396
  <?php $this->cmw_assist_link(); ?>
397
 
398
- <label for="<?php echo $this->get_field_id('fallback'); ?>"><?php _e('If Current Item has no children:'); ?></label>
399
- <select id="<?php echo $this->get_field_id('fallback'); ?>" class="cmw-fallback cmw-listen"
400
- <?php $this->cmw_disableif(); ?> name="<?php echo $this->get_field_name('fallback'); ?>">
401
- <option value="" <?php selected( $instance['fallback'], '' ); ?>>&nbsp;</option>
402
- <option value="parent" <?php selected( $instance['fallback'], 'parent' ); ?>><?php _e('Start at : -1 (parent)'); ?></option>
403
- <option value="current" <?php selected( $instance['fallback'], 'current' ); ?>><?php _e('Start at : the Current Item'); ?></option>
404
- <option value="quit" <?php selected( $instance['fallback'], 'quit' ); ?>><?php _e('No output!'); ?></option>
405
- </select>
406
-
407
- <div class="cmw-indented cmw-disableifnot-fb-pc<?php $this->cmw_disableif( 'push', $isNotFallbackParentCurrent ); ?>">
408
- <?php $this->cmw_formfield_checkbox( $instance, 'fallback_siblings',
409
- array(
410
- 'label' => '&hellip;' . __('and Include its Siblings')
411
- ) ); ?>
412
 
413
  <br />
414
- <label><?php _e('For Depth:'); ?>
415
- <select id="<?php echo $this->get_field_id('fallback_depth'); ?>" data-cmw-text-levels="<?php _e('levels'); ?>"
416
- <?php $this->cmw_disableif(); ?> class="cmw-fallback-depth" name="<?php echo $this->get_field_name('fallback_depth'); ?>">
417
- <option value="0" <?php selected( $instance['fallback_depth'] > $menus['selectedLevels'] ? 0 : $instance['fallback_depth'], 0 ); ?>>&nbsp;</option>
418
- <?php for( $i = 1; $i <= $menus['selectedLevels']; $i++ ){ ?>
419
- <option value="<?php echo $i; ?>" <?php selected( $instance['fallback_depth'], $i ); ?>><?php printf( _n('%d level', '%d levels', $i), $i ); ?></option>
420
- <?php } ?>
421
- </select></label>
422
- <span class="cmw-small-block"><em class="cmw-colour-grey"><?php _e('Fallback Depth is Relative to Current Item!'); ?></em></span>
423
- </div><!-- end .cmw-disableifnot-fb-pc --><?php $this->cmw_disableif( 'pop' ); ?>
 
 
 
 
 
 
 
 
 
424
 
425
  </div><!-- end .cmw-disableifnot-br-ci --><?php $this->cmw_disableif( 'pop' ); ?>
426
 
@@ -448,30 +473,33 @@ class Custom_Menu_Wizard_Widget extends WP_Widget {
448
 
449
  <div>
450
  Set Title from:
451
- <br>
452
- <?php $this->cmw_formfield_checkbox( $instance, 'title_from_current',
453
- array(
454
- 'label' => __('Current Item'),
455
- 'lclass' => 'cmw-followed-by'
456
- ) ); ?>
457
- <?php $this->cmw_formfield_checkbox( $instance, 'title_from_current_root',
458
- array(
459
- 'label' => '&hellip;' . __('or its Root'),
460
- 'lclass' => 'cmw-whitespace-nowrap'
461
- ) ); ?>
462
- <br />
463
- <?php $this->cmw_formfield_checkbox( $instance, 'title_from_branch',
464
- array(
465
- 'label' => __('Branch'),
466
- 'lclass' => 'cmw-followed-by cmw-disableifnot-br',
467
- 'disableif' => $isNotByBranch
468
  ) ); ?>
469
- <?php $this->cmw_formfield_checkbox( $instance, 'title_from_branch_root',
470
- array(
471
- 'label' => '&hellip;' . __('or its Root'),
472
- 'lclass' => 'cmw-whitespace-nowrap cmw-disableifnot-br',
473
- 'disableif' => $isNotByBranch
474
- ) ); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
475
  </div>
476
 
477
  <div>
@@ -603,6 +631,7 @@ class Custom_Menu_Wizard_Widget extends WP_Widget {
603
 
604
  <?php $this->cmw_close_a_field_section(); ?>
605
 
 
606
  <div class="cmw-shortcode-wrap"><code class="widget-<?php echo $this->id_base; ?>-shortcode ui-corner-all"
607
  title="<?php _e('shortcode'); ?>"><?php echo $this->cmw_shortcode( array_merge( $instance, array( 'menu' => $menus['selectedMenu'] ) ) ); ?></code></div>
608
 
@@ -610,9 +639,7 @@ class Custom_Menu_Wizard_Widget extends WP_Widget {
610
  <?php
611
 
612
  if( $this->_cmw_accessibility ){
613
- ?>
614
- <script type="text/javascript">jQuery(function($){ $('#<?php echo $this->get_field_id('menu'); ?>').trigger('change'); });</script>
615
- <?php
616
  }
617
 
618
  } //end form()
@@ -1193,7 +1220,7 @@ class Custom_Menu_Wizard_Widget extends WP_Widget {
1193
  'flat_output' => 0,
1194
  'hide_title' => 0,
1195
  'siblings' => 0, //v3.0.0 replaces include_parent_siblings
1196
- 'include_root' => 0, //v3.0.0
1197
  'title_from_branch' => 0, //v3.0.0 replaces title_from_parent
1198
  'title_from_branch_root' => 0, //v3.0.0 added
1199
  'title_from_current' => 0,
@@ -1245,6 +1272,7 @@ class Custom_Menu_Wizard_Widget extends WP_Widget {
1245
  'container_class' => '',
1246
  'exclude_level' => '', //v3.0.0 (1 or more digits, possibly with an appended '-' or '+')
1247
  'fallback' => '', //v3.0.0 replace fallback_no_children ('', 'parent', 'current', 'quit')
 
1248
  'menu_class' => 'menu-widget',
1249
  'widget_class' => '',
1250
  'cmwv' => ''
@@ -1308,6 +1336,13 @@ class Custom_Menu_Wizard_Widget extends WP_Widget {
1308
  }
1309
  }
1310
 
 
 
 
 
 
 
 
1311
  //holds information determined by the walker...
1312
  $this->_cmw_walker = array();
1313
 
@@ -1386,6 +1421,10 @@ class Custom_Menu_Wizard_Widget extends WP_Widget {
1386
  $args['ancestor_siblings'] = $instance['ancestor_siblings'];
1387
  }
1388
  }
 
 
 
 
1389
  //exclusions by id...
1390
  if( !empty( $instance['_exclude'] ) ){
1391
  $args['exclude'] = $instance['_exclude'];
@@ -1410,7 +1449,7 @@ class Custom_Menu_Wizard_Widget extends WP_Widget {
1410
  $args['title_from'] = $n;
1411
  }
1412
  //switches...
1413
- foreach( array('allow_all_root', 'siblings', 'include_root', 'flat_output', 'ol_root', 'ol_sub') as $n ){
1414
  if( $instance[ $n ] ){
1415
  $args[ $n ] = 1;
1416
  }
@@ -1601,7 +1640,7 @@ class Custom_Menu_Wizard_Widget extends WP_Widget {
1601
 
1602
  <p class="cmw-disableif-ss<?php $this->cmw_disableif( 'push', $isShowSpecific ); ?>">
1603
  <label for="<?php echo $this->get_field_id('depth'); ?>"><?php _e('For Depth:'); ?></label>
1604
- <select id="<?php echo $this->get_field_id('depth'); ?>" class="cmw-depth" data-cmw-text-levels="<?php _e('levels'); ?>"
1605
  name="<?php echo $this->get_field_name('depth'); ?>" <?php $this->cmw_disableif(); ?>>
1606
  <option value="0" <?php selected( $instance['depth'] > $menus['selectedLevels'] ? 0 : $instance['depth'], 0 ); ?>><?php _e('unlimited'); ?></option>
1607
  <?php
124
 
125
  //set up some simple booleans for use at the disableif___ classes...
126
  $isByItems = $instance['filter'] == 'items'; // disableif-ss (IS Items filter)
127
+ $isUnlimitedDepth = $isByItems || empty( $instance['depth'] ); // disableif-ud (IS unlimited depth)
128
  $isNotByBranch = $instance['filter'] != 'branch'; // disableifnot-br (is NOT Branch filter)
129
  $isNotBranchCurrentItem = $isNotByBranch || !empty( $instance['branch'] ); // disableifnot-br-ci (is NOT "Branch:Current Item")
130
+ $isNotFallbackParentCurrent = $isNotBranchCurrentItem || !in_array( $instance['fallback'], array('parent', 'current') ); //disableifnot-fb-pc (is NOT set to fall back to parent or current)
131
 
132
  //NB the 'onchange' wrapper holds any text required by the "assist"
133
  ?>
185
  <?php $this->cmw_assist_link(); ?>
186
  <strong><?php _e('Primary Filter'); ?></strong>
187
 
188
+ <div class="cmw-indented">
189
+ <label class="cmw-verticalalign-baseline">
190
+ <input id="<?php echo $this->get_field_id('filter'); ?>_0" class="cmw-bylevel cmw-listen"
191
+ <?php $this->cmw_disableif(); ?> name="<?php echo $this->get_field_name('filter'); ?>"
192
+ type="radio" value="" <?php checked( $instance['filter'], '' ); ?>
193
+ /><?php _e('Level:'); ?></label>
194
+ <select id="<?php echo $this->get_field_id('level'); ?>" class="cmw-level cmw-set-levels cmw-listen"
195
+ <?php $this->cmw_disableif(); ?> data-cmw-set-levels="0"
196
+ name="<?php echo $this->get_field_name('level'); ?>">
197
+ <?php for( $i = 1, $j = $instance['level'] > $menus['selectedLevels'] ? 1 : $instance['level']; $i <= $menus['selectedLevels']; $i++ ){ ?>
198
+ <option value="<?php echo $i; ?>" <?php selected( $j, $i ); ?>><?php echo $i > 1 ? $i : $i . __(' (root)'); ?></option>
199
+ <?php } ?>
200
+ </select>
201
+ </div>
202
 
203
+ <div class="cmw-indented">
204
+ <label class="cmw-verticalalign-baseline">
205
+ <input id="<?php echo $this->get_field_id('filter'); ?>_1" class="cmw-bybranch cmw-listen"
206
+ <?php $this->cmw_disableif(); ?> name="<?php echo $this->get_field_name('filter'); ?>"
207
+ type="radio" value="branch" <?php checked( $instance['filter'], 'branch' ); ?>
208
+ /><?php _e('Branch:'); ?></label>
209
+ <select id="<?php echo $this->get_field_id('branch'); ?>" class="cmw-branches cmw-assist-items cmw-listen"
210
+ <?php $this->cmw_disableif(); ?> name="<?php echo $this->get_field_name('branch'); ?>">
211
+ <option value="0" <?php selected( $instance['branch'], 0 ); ?>><?php _e('Current Item'); ?></option>
212
+ <?php echo $menus['selectedOptgroup']; ?>
213
+ </select>
214
+ <select id="<?php echo $this->get_field_id('branch_ignore'); ?>" class='cmw-off-the-page' disabled="disabled"
215
+ name="<?php echo $this->get_field_name('branch_ignore'); ?>">
216
+ <?php echo $menus['optgroups']; ?>
217
+ </select>
218
+ </div>
219
 
220
+ <div class="cmw-indented">
221
+ <label class="cmw-verticalalign-baseline">
222
+ <input id="<?php echo $this->get_field_id('filter'); ?>_2" class="cmw-byitems cmw-listen"
223
+ <?php $this->cmw_disableif(); ?> name="<?php echo $this->get_field_name('filter'); ?>"
224
+ type="radio" value="items" <?php checked( $instance['filter'], 'items' ); ?>
225
+ /><?php _e('Items:'); ?></label>
226
+ <?php $this->cmw_formfield_textbox( $instance, 'items',
227
+ array(
228
+ 'fclass' => 'cmw-maxwidth-twothirds cmw-setitems cmw-listen'
229
+ ) ); ?>
230
+ </div>
231
  </div>
232
 
233
  <div class="cmw-disableif-ss<?php $this->cmw_disableif( 'push', $isByItems ); ?>">
234
  <?php $this->cmw_assist_link(); ?>
235
  <strong><?php _e('Secondary Filter'); ?></strong>
236
 
 
 
 
 
 
 
 
 
 
 
 
 
 
237
  <div class="cmw-indented">
238
+ <label class="cmw-disableifnot-br<?php $this->cmw_disableif( 'push', $isNotByBranch ); ?>"><?php _e('Starting at:'); ?>
239
+ <select id="<?php echo $this->get_field_id('branch_start'); ?>" class="cmw-branch-start cmw-listen"
240
+ <?php $this->cmw_disableif(); ?> name="<?php echo $this->get_field_name('branch_start'); ?>">
241
+ <optgroup label="<?php _e('relative...'); ?>" data-cmw-text-children="<?php _e('children'); ?>"
242
+ data-cmw-text-parent="<?php _e('parent'); ?>">
243
+ <?php echo implode( '', $relGroup ); ?>
244
+ </optgroup>
245
+ <optgroup label="<?php _e('absolute...'); ?>">
246
+ <?php echo implode( '', $absGroup ); ?>
247
+ </optgroup>
248
+ </select></label><!-- end .cmw-disableifnot-br --><?php $this->cmw_disableif( 'pop' ); ?>
249
 
250
  <br />
251
+ <span class="cmw-disableifnot-br<?php $this->cmw_disableif( 'push', $isNotByBranch ); ?>">
252
+ <label class="cmw-followed-by">
253
+ <input id="<?php echo $this->get_field_id('start_mode'); ?>_0"
254
+ name="<?php echo $this->get_field_name('start_mode'); ?>"
255
+ <?php $this->cmw_disableif(); ?> type="radio" value="" <?php checked( $instance['start_mode'] !== 'level' ); ?>
256
+ /><?php printf( __('Item %1$s(if possible)%2$s'), '<small>', '</small>' ); ?></label>
257
+
258
+ <label class="cmw-followed-by cmw-whitespace-nowrap">
259
+ <input id="<?php echo $this->get_field_id('start_mode'); ?>_1" name="<?php echo $this->get_field_name('start_mode'); ?>"
260
+ <?php $this->cmw_disableif(); ?> type="radio" value="level" <?php checked( $instance['start_mode'] === 'level' ); ?>
261
+ /><?php _e('Level'); ?></label>
262
+
263
+ <?php $this->cmw_formfield_checkbox( $instance, 'allow_all_root',
264
+ array(
265
+ 'label' => __('Allow all Root Items'),
266
+ 'lclass' => 'cmw-whitespace-nowrap'
267
+ ) ); ?>
268
+ </span><!-- end .cmw-disableifnot-br --><?php $this->cmw_disableif( 'pop' ); ?>
269
  </div>
270
 
 
 
 
 
 
 
 
 
 
271
  <div class="cmw-indented">
272
+ <label class="cmw-followed-by"><?php _e('For Depth:'); ?>
273
+ <select id="<?php echo $this->get_field_id('depth'); ?>" data-cmw-text-levels="<?php _e(' levels'); ?>"
274
+ data-cmw-set-levels="1" <?php $this->cmw_disableif(); ?>
275
+ class="cmw-depth cmw-set-levels cmw-listen" name="<?php echo $this->get_field_name('depth'); ?>">
276
+ <option value="0" <?php selected( $instance['depth'] > $menus['selectedLevels'] ? 0 : $instance['depth'], 0 ); ?>><?php _e('unlimited'); ?></option>
277
+ <?php for( $i = 1; $i <= $menus['selectedLevels']; $i++ ){ ?>
278
+ <option value="<?php echo $i; ?>" <?php selected( $instance['depth'], $i ); ?>><?php printf( _n('%d level', '%d levels', $i), $i ); ?></option>
279
+ <?php } ?>
280
+ </select></label>
281
+
282
+
283
  <?php $this->cmw_formfield_checkbox( $instance, 'depth_rel_current',
284
+ array(
285
+ 'label' => __('Relative to Current Item'),
286
+ 'lclass' => 'cmw-disableif-ud cmw-whitespace-nowrap',
287
+ 'disableif' => $isUnlimitedDepth
288
+ ) ); ?>
289
  </div>
290
  </div><!-- end .cmw-disableif-ss --><?php $this->cmw_disableif( 'pop' ); ?>
291
 
292
  <div>
293
  <?php $this->cmw_assist_link(); ?>
294
  <strong><?php _e('Inclusions'); ?></strong>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
295
 
296
+ <div class="cmw-indented">
297
+ <label class="cmw-disableifnot-br<?php $this->cmw_disableif( 'push', $isNotByBranch ); ?>"><?php _e('Branch Ancestors:'); ?>
298
+ <select id="<?php echo $this->get_field_id('ancestors'); ?>" class="cmw-ancestors cmw-listen"
299
+ <?php $this->cmw_disableif(); ?> name="<?php echo $this->get_field_name('ancestors'); ?>"
300
+ data-cmw-text-tolevel="<?php _e('to level'); ?>">
301
  <option value="0" <?php selected( $j, 0 ); ?>>&nbsp;</option>
302
  <?php
303
+ $j = $instance['ancestors'];
304
  $j = max( min( $j, $menus['selectedLevels'] - 1 ), 1 - $menus['selectedLevels'] ); ?>
305
  <optgroup label="<?php _e('relative...'); ?>" data-cmw-text-for-option=" <?php _e('%d levels'); ?>">
306
  <option value="-1" <?php selected( $j, -1 ); ?>><?php printf( __('%d level (parent)'), -1 ); ?></option>
314
  <option value="<?php echo $i; ?>" <?php selected( $j, $i ); ?>><?php printf( __('to level %d'), $i ); ?></option>
315
  <?php } ?>
316
  </optgroup>
317
+ </select></label><!-- end .cmw-disableifnot-br --><?php $this->cmw_disableif( 'pop' ); ?>
318
+
319
+ <br />
320
+ <span class="cmw-disableifnot-br<?php $this->cmw_disableif( 'push', $isNotByBranch ); ?>">
321
+ <label><?php _e('... with Siblings:'); ?>
322
+ <select id="<?php echo $this->get_field_id('ancestor_siblings'); ?>" class="cmw-ancestor-siblings cmw-listen"
323
+ <?php $this->cmw_disableif(); ?> name="<?php echo $this->get_field_name('ancestor_siblings'); ?>">
324
+ <option value="0" <?php selected( $j, 0 ); ?>>&nbsp;</option>
325
+ <?php
326
+ $j = $instance['ancestor_siblings'];
327
+ $j = max( min( $j, $menus['selectedLevels'] - 1 ), 1 - $menus['selectedLevels'] ); ?>
328
+ <optgroup label="<?php _e('relative...'); ?>" data-cmw-text-for-option=" <?php _e('%d levels'); ?>">
329
+ <option value="-1" <?php selected( $j, -1 ); ?>><?php printf( __('%d level (parent)'), -1 ); ?></option>
330
+ <?php for( $i = -2; $i > 0 - $menus['selectedLevels']; $i-- ){ ?>
331
+ <option value="<?php echo $i; ?>" <?php selected( $j, $i ); ?>><?php printf( __('%d levels'), $i ); ?></option>
332
+ <?php } ?>
333
+ </optgroup>
334
+ <optgroup label="<?php _e('absolute...'); ?>" data-cmw-text-for-option="<?php _e('to level %d'); ?> ">
335
+ <option value="1" <?php selected( $j, 1 ); ?>><?php printf( __('to level %d (root)'), 1 ); ?></option>
336
+ <?php for( $i = 2; $i < $menus['selectedLevels']; $i++ ){ ?>
337
+ <option value="<?php echo $i; ?>" <?php selected( $j, $i ); ?>><?php printf( __('to level %d'), $i ); ?></option>
338
+ <?php } ?>
339
+ </optgroup>
340
+ </select></label>
341
+ </span><!-- end .cmw-disableifnot-br --><?php $this->cmw_disableif( 'pop' ); ?>
342
+ </div>
343
 
344
  <?php $this->cmw_formfield_checkbox( $instance, 'siblings',
345
  array(
348
  'disableif' => $isNotByBranch
349
  ) ); ?>
350
 
351
+ <div class="cmw-indented">
352
+ <label><?php _e('Level:'); ?>
353
+ <select id="<?php echo $this->get_field_id('include_level'); ?>" class="cmw-include-level"
354
+ name="<?php echo $this->get_field_name('include_level'); ?>">
355
+ <?php $j = intval($instance['include_level']) > $menus['selectedLevels'] ? '' : $instance['include_level']; ?>
356
+ <option value="" <?php selected( $j, '' ); ?>>&nbsp;</option>
357
+ <?php for( $i = 1; $i <= $menus['selectedLevels']; $i++ ){ ?>
358
+ <option value="<?php echo $i; ?>" <?php selected( $j, "$i" ); ?>><?php echo $i; ?></option>
359
+ <option value="<?php echo $i . '-'; ?>" <?php selected( $j, $i . '-' ); ?>>&nbsp;&nbsp;&nbsp;<?php echo $i . __(' and above'); ?></option>
360
+ <option value="<?php echo $i . '+'; ?>" <?php selected( $j, $i . '+' ); ?>>&nbsp;&nbsp;&nbsp;<?php echo $i . __(' and below'); ?></option>
361
+ <?php } ?>
362
+ </select></label>
363
+ </div>
364
  </div>
365
 
366
  <div>
367
  <?php $this->cmw_assist_link(); ?>
368
  <strong><?php _e('Exclusions'); ?></strong>
369
+
370
+ <div class="cmw-indented">
371
+ <?php $this->cmw_formfield_textbox( $instance, 'exclude',
372
+ array(
373
+ 'label' => __('Item Ids:'),
374
+ 'fclass' => 'cmw-maxwidth-twothirds cmw-exclusions'
375
+ ) ); ?>
376
+ </div>
377
+
378
+ <div class="cmw-indented">
379
+ <label><?php _e('Level:'); ?>
380
+ <select id="<?php echo $this->get_field_id('exclude_level'); ?>" class="cmw-exclude-level"
381
+ name="<?php echo $this->get_field_name('exclude_level'); ?>">
382
+ <?php $j = intval($instance['exclude_level']) > $menus['selectedLevels'] ? '' : $instance['exclude_level']; ?>
383
+ <option value="" <?php selected( $j, '' ); ?>>&nbsp;</option>
384
+ <?php for( $i = 1; $i <= $menus['selectedLevels']; $i++ ){ ?>
385
+ <option value="<?php echo $i; ?>" <?php selected( $j, "$i" ); ?>><?php echo $i; ?></option>
386
+ <option value="<?php echo $i . '-'; ?>" <?php selected( $j, $i . '-' ); ?>>&nbsp;&nbsp;&nbsp;<?php echo $i . __(' and above'); ?></option>
387
+ <option value="<?php echo $i . '+'; ?>" <?php selected( $j, $i . '+' ); ?>>&nbsp;&nbsp;&nbsp;<?php echo $i . __(' and below'); ?></option>
388
+ <?php } ?>
389
+ </select></label>
390
+ </div>
391
  </div>
392
 
393
  <div>
416
  <div class="cmw-disableifnot-br-ci<?php $this->cmw_disableif( 'push', $isNotBranchCurrentItem ); ?>">
417
  <?php $this->cmw_assist_link(); ?>
418
 
419
+ <div class="cmw-indented">
420
+ <label for="<?php echo $this->get_field_id('fallback'); ?>"><?php _e('If Current Item has no children:'); ?></label>
421
+ <select id="<?php echo $this->get_field_id('fallback'); ?>" class="cmw-fallback cmw-listen"
422
+ <?php $this->cmw_disableif(); ?> name="<?php echo $this->get_field_name('fallback'); ?>">
423
+ <option value="" <?php selected( $instance['fallback'], '' ); ?>>&nbsp;</option>
424
+ <option value="parent" <?php selected( $instance['fallback'], 'parent' ); ?>><?php _e('Start at : -1 (parent)'); ?></option>
425
+ <option value="current" <?php selected( $instance['fallback'], 'current' ); ?>><?php _e('Start at : the Current Item'); ?></option>
426
+ <option value="quit" <?php selected( $instance['fallback'], 'quit' ); ?>><?php _e('No output!'); ?></option>
427
+ </select>
 
 
 
 
 
428
 
429
  <br />
430
+ <span class="cmw-disableifnot-fb-pc<?php $this->cmw_disableif( 'push', $isNotFallbackParentCurrent ); ?>">
431
+ <?php $this->cmw_formfield_checkbox( $instance, 'fallback_siblings',
432
+ array(
433
+ 'label' => '&hellip;' . __('and Include its Siblings')
434
+ ) ); ?>
435
+
436
+ <br />
437
+ <label><?php _e('For Depth:'); ?>
438
+ <select id="<?php echo $this->get_field_id('fallback_depth'); ?>" data-cmw-text-levels="<?php _e(' levels'); ?>"
439
+ data-cmw-set-levels="1" <?php $this->cmw_disableif(); ?>
440
+ class="cmw-set-levels" name="<?php echo $this->get_field_name('fallback_depth'); ?>">
441
+ <option value="0" <?php selected( $instance['fallback_depth'] > $menus['selectedLevels'] ? 0 : $instance['fallback_depth'], 0 ); ?>>&nbsp;</option>
442
+ <?php for( $i = 1; $i <= $menus['selectedLevels']; $i++ ){ ?>
443
+ <option value="<?php echo $i; ?>" <?php selected( $instance['fallback_depth'], $i ); ?>><?php printf( _n('%d level', '%d levels', $i), $i ); ?></option>
444
+ <?php } ?>
445
+ </select></label>
446
+ <span class="cmw-small-block cmw-indented"><em class="cmw-colour-grey"><?php _e('Fallback Depth is Relative to Current Item!'); ?></em></span>
447
+ </span><!-- end .cmw-disableifnot-fb-pc --><?php $this->cmw_disableif( 'pop' ); ?>
448
+ </div>
449
 
450
  </div><!-- end .cmw-disableifnot-br-ci --><?php $this->cmw_disableif( 'pop' ); ?>
451
 
473
 
474
  <div>
475
  Set Title from:
476
+
477
+ <div class="cmw-indented">
478
+ <?php $this->cmw_formfield_checkbox( $instance, 'title_from_current',
479
+ array(
480
+ 'label' => __('Current Item'),
481
+ 'lclass' => 'cmw-followed-by'
 
 
 
 
 
 
 
 
 
 
 
482
  ) ); ?>
483
+ <?php $this->cmw_formfield_checkbox( $instance, 'title_from_current_root',
484
+ array(
485
+ 'label' => '&hellip;' . __('or its Root'),
486
+ 'lclass' => 'cmw-whitespace-nowrap'
487
+ ) ); ?>
488
+ </div>
489
+ <div class="cmw-indented">
490
+ <?php $this->cmw_formfield_checkbox( $instance, 'title_from_branch',
491
+ array(
492
+ 'label' => __('Branch'),
493
+ 'lclass' => 'cmw-followed-by cmw-disableifnot-br',
494
+ 'disableif' => $isNotByBranch
495
+ ) ); ?>
496
+ <?php $this->cmw_formfield_checkbox( $instance, 'title_from_branch_root',
497
+ array(
498
+ 'label' => '&hellip;' . __('or its Root'),
499
+ 'lclass' => 'cmw-whitespace-nowrap cmw-disableifnot-br',
500
+ 'disableif' => $isNotByBranch
501
+ ) ); ?>
502
+ </div>
503
  </div>
504
 
505
  <div>
631
 
632
  <?php $this->cmw_close_a_field_section(); ?>
633
 
634
+ <div class="cmw-shortcode-nojs cmw-small-block"><?php _e('With Javascript disabled, the shortcode below is only guaranteed to be accurate when you <em>initially enter</em> Edit mode!'); ?></div>
635
  <div class="cmw-shortcode-wrap"><code class="widget-<?php echo $this->id_base; ?>-shortcode ui-corner-all"
636
  title="<?php _e('shortcode'); ?>"><?php echo $this->cmw_shortcode( array_merge( $instance, array( 'menu' => $menus['selectedMenu'] ) ) ); ?></code></div>
637
 
639
  <?php
640
 
641
  if( $this->_cmw_accessibility ){
642
+ wp_localize_script( Custom_Menu_Wizard_Plugin::$script_handle, __CLASS__, array( 'trigger' => '#' . $this->get_field_id('menu') ) );
 
 
643
  }
644
 
645
  } //end form()
1220
  'flat_output' => 0,
1221
  'hide_title' => 0,
1222
  'siblings' => 0, //v3.0.0 replaces include_parent_siblings
1223
+ 'include_root' => 0, //v3.0.0 ; v3.0.4 replaced/expanded by include_level DEPRECATED
1224
  'title_from_branch' => 0, //v3.0.0 replaces title_from_parent
1225
  'title_from_branch_root' => 0, //v3.0.0 added
1226
  'title_from_current' => 0,
1272
  'container_class' => '',
1273
  'exclude_level' => '', //v3.0.0 (1 or more digits, possibly with an appended '-' or '+')
1274
  'fallback' => '', //v3.0.0 replace fallback_no_children ('', 'parent', 'current', 'quit')
1275
+ 'include_level' => '', //v3.0.4 (1 or more digits, possibly with an appended '-' or '+')
1276
  'menu_class' => 'menu-widget',
1277
  'widget_class' => '',
1278
  'cmwv' => ''
1336
  }
1337
  }
1338
 
1339
+ //v3.0.4 : v3.0.* back compat...
1340
+ //include_root was a boolean, but has been replaced with include_level, and the equiv. of include_root On is include_level=1...
1341
+ if( $instance['include_root'] && empty( $instance['include_level'] ) ){
1342
+ $instance['include_level'] = '1';
1343
+ }
1344
+ unset( $instance['include_root'] );
1345
+
1346
  //holds information determined by the walker...
1347
  $this->_cmw_walker = array();
1348
 
1421
  $args['ancestor_siblings'] = $instance['ancestor_siblings'];
1422
  }
1423
  }
1424
+ //inclusions by level...
1425
+ if( !empty( $instance['include_level'] ) ){
1426
+ $args['include_level'] = array( $instance['include_level'] );
1427
+ }
1428
  //exclusions by id...
1429
  if( !empty( $instance['_exclude'] ) ){
1430
  $args['exclude'] = $instance['_exclude'];
1449
  $args['title_from'] = $n;
1450
  }
1451
  //switches...
1452
+ foreach( array('allow_all_root', 'siblings', 'flat_output', 'ol_root', 'ol_sub') as $n ){
1453
  if( $instance[ $n ] ){
1454
  $args[ $n ] = 1;
1455
  }
1640
 
1641
  <p class="cmw-disableif-ss<?php $this->cmw_disableif( 'push', $isShowSpecific ); ?>">
1642
  <label for="<?php echo $this->get_field_id('depth'); ?>"><?php _e('For Depth:'); ?></label>
1643
+ <select id="<?php echo $this->get_field_id('depth'); ?>" class="cmw-depth" data-cmw-text-levels="<?php _e(' levels'); ?>"
1644
  name="<?php echo $this->get_field_name('depth'); ?>" <?php $this->cmw_disableif(); ?>>
1645
  <option value="0" <?php selected( $instance['depth'] > $menus['selectedLevels'] ? 0 : $instance['depth'], 0 ); ?>><?php _e('unlimited'); ?></option>
1646
  <?php
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: wizzud
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=KP2LVCBXNCEB4
4
  Tags: menu,widget,widgets,navigation,nav,custom menus,custom menu,partial menu,current item,current page,menu level,menu branch,menu shortcode,menu widget,advanced,enhanced
5
  Requires at least: 3.6
6
- Tested up to: 3.9
7
- Stable tag: 3.0.3
8
  License: GPLv2 or Later
9
 
10
  Show branches or levels of your menu in a widget, or in content using a shortcode, with full customisation.
@@ -202,9 +202,10 @@ or below the `Starting at` level, and do not include any items that would break
202
  Include any siblings of the item selected as the `Branch` filter (ie. any items at the same level and within
203
  the same branch as the `Branch` item).
204
 
205
- * **All Root Items** *checkbox*
206
 
207
- This is not restricted by other previous filter settings, and simply adds all the top level menu items into the mix.
 
208
 
209
  ***Exclusions***
210
 
@@ -223,7 +224,7 @@ or below the `Starting at` level, and do not include any items that would break
223
  the "C" branch, then you could set `Level` to "1 (root)" and `Exclusions` to, say, "12+", where "12" is the menu item id for "C" and
224
  the "+" indicates that all the descendants of "C" should also be excluded.
225
 
226
- * **By Level** *select*
227
 
228
  This allows an entire level of items to be excluded, optionally also excluding all levels either above or below it.
229
 
@@ -432,10 +433,6 @@ and its relevant descendants, but also all that item's siblings *and their desce
432
  *switch, off by default, 1 to enable* : See widget's `Relative to Current Item` option, under *Secondary Filter*,
433
  [Filters Section](http://wordpress.org/plugins/custom-menu-wizard/other_notes/#Filters-Section) above.
434
 
435
- = include_root =
436
- *switch, off by default, 1 to enable* : Sets the widget's Include `All Root Items` option. See widget's `All Root Items`
437
- option, under *Inclusions*, [Filters Section](http://wordpress.org/plugins/custom-menu-wizard/other_notes/#Filters-Section) above.
438
-
439
  = ancestors =
440
  *integer, default 0 (off)* : Sets an absolute level (positive integer), or a relative number of levels (negative integer), for which
441
  the ancestors of the `Branch` filter item should be included. See widget's `Branch Ancestors` option, under *Inclusions*,
@@ -450,13 +447,21 @@ the siblings of ancestors of the `Branch` filter item should be included. See wi
450
  *switch, off by default, 1 to enable* : See widget's `Branch Siblings` option, under *Inclusions*,
451
  [Filters Section](http://wordpress.org/plugins/custom-menu-wizard/other_notes/#Filters-Section) above. (only relevant to a `Branch` filter)
452
 
 
 
 
 
 
 
 
 
453
  = exclude =
454
  *string* : Comma-separated list of meu item ids, where an id can optionally be followed by a '+' to include all its descendants (eg. "23+").
455
 
456
  = exclude_level =
457
  *string* : A level (1, 2, 3, etc), optionally followed by a "+" or "-" to include all subsequent (lower) or prior (higher)
458
  levels respectively. For example, "2" will exclude all items at level 2, whereas "2-" would exclude all level 1 **and** level 2 items,
459
- and "2+" would exlude all items at level 2 or greater.
460
 
461
  = contains_current =
462
  *string* : Accepted values : "menu", "primary", "secondary", "inclusions", or "output". See widget's *Qualifier* options,
@@ -669,6 +674,13 @@ Note that output from this shortcode extension is restricted to users with edit_
669
 
670
  == Changelog ==
671
 
 
 
 
 
 
 
 
672
  = 3.0.3 =
673
  * bugfix : removed all occurrences of "Plugin " followed by "Name" from everywhere except the main plugin file to avoid update() reporting Invalid Header when activating straight from installation (rather than from the Plugins page)
674
  * tweak : eliminate the over-use of get_title() when determining the widget title
@@ -781,6 +793,10 @@ Note that output from this shortcode extension is restricted to users with edit_
781
 
782
  == Upgrade Notice ==
783
 
 
 
 
 
784
  = 3.0.3 =
785
  Fixed problem with WordPress's update() reporting Invalid Header when activating immediately following installation (as opposed to activating via Plugins page).
786
  Tweaked the generated shortcode to add a self-terminating forward slash. Please note that this tweak is merely a metter of "good practice" : there is no need to update your existing, working, shortcodes!
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=KP2LVCBXNCEB4
4
  Tags: menu,widget,widgets,navigation,nav,custom menus,custom menu,partial menu,current item,current page,menu level,menu branch,menu shortcode,menu widget,advanced,enhanced
5
  Requires at least: 3.6
6
+ Tested up to: 4.0
7
+ Stable tag: 3.0.4
8
  License: GPLv2 or Later
9
 
10
  Show branches or levels of your menu in a widget, or in content using a shortcode, with full customisation.
202
  Include any siblings of the item selected as the `Branch` filter (ie. any items at the same level and within
203
  the same branch as the `Branch` item).
204
 
205
+ * **Level** *select*
206
 
207
+ This allows an entire level of items to be included, optionally also including all levels either above or below it.
208
+ This replaces the `All Root Items` checkbox (pre v3.0.4), which only allowed for the inclusion of the root level items.
209
 
210
  ***Exclusions***
211
 
224
  the "C" branch, then you could set `Level` to "1 (root)" and `Exclusions` to, say, "12+", where "12" is the menu item id for "C" and
225
  the "+" indicates that all the descendants of "C" should also be excluded.
226
 
227
+ * **Level** *select*
228
 
229
  This allows an entire level of items to be excluded, optionally also excluding all levels either above or below it.
230
 
433
  *switch, off by default, 1 to enable* : See widget's `Relative to Current Item` option, under *Secondary Filter*,
434
  [Filters Section](http://wordpress.org/plugins/custom-menu-wizard/other_notes/#Filters-Section) above.
435
 
 
 
 
 
436
  = ancestors =
437
  *integer, default 0 (off)* : Sets an absolute level (positive integer), or a relative number of levels (negative integer), for which
438
  the ancestors of the `Branch` filter item should be included. See widget's `Branch Ancestors` option, under *Inclusions*,
447
  *switch, off by default, 1 to enable* : See widget's `Branch Siblings` option, under *Inclusions*,
448
  [Filters Section](http://wordpress.org/plugins/custom-menu-wizard/other_notes/#Filters-Section) above. (only relevant to a `Branch` filter)
449
 
450
+ = include_level =
451
+ *string* : A level (1, 2, 3, etc), optionally followed by a "+" or "-" to include all subsequent (lower) or prior (higher)
452
+ levels respectively. For example, "2" will include all items at level 2, whereas "2-" would include all level 1 **and** level 2 items,
453
+ and "2+" would include all items at level 2 or greater.
454
+
455
+ Note that prior to v3.0.4, this was `include_root` (a switch), which only included the root level : `include_root` is still accepted, even
456
+ though now deprecated, and is equivalent to setting `include_level` to "1". However, if `include_level` is specified then it takes precedence.
457
+
458
  = exclude =
459
  *string* : Comma-separated list of meu item ids, where an id can optionally be followed by a '+' to include all its descendants (eg. "23+").
460
 
461
  = exclude_level =
462
  *string* : A level (1, 2, 3, etc), optionally followed by a "+" or "-" to include all subsequent (lower) or prior (higher)
463
  levels respectively. For example, "2" will exclude all items at level 2, whereas "2-" would exclude all level 1 **and** level 2 items,
464
+ and "2+" would exclude all items at level 2 or greater.
465
 
466
  = contains_current =
467
  *string* : Accepted values : "menu", "primary", "secondary", "inclusions", or "output". See widget's *Qualifier* options,
674
 
675
  == Changelog ==
676
 
677
+ = 3.0.4 =
678
+ * bugfix : corrected the display of the "No Current Item!" warning in the "assist"
679
+ * bugfix : corrected the enabling/disabling of a couple of fields in the widget form, and tweaked the indentation for better responsiveness
680
+ * bugfix : corrected the options setup when in accessibility mode with javascript enabled
681
+ * addition : added a warning about the accuracy of the shortcode when javascript is disabled
682
+ * addition : extended the All Root Items inclusion to be a selectable number of levels (as per the Exclusions by Level)
683
+
684
  = 3.0.3 =
685
  * bugfix : removed all occurrences of "Plugin " followed by "Name" from everywhere except the main plugin file to avoid update() reporting Invalid Header when activating straight from installation (rather than from the Plugins page)
686
  * tweak : eliminate the over-use of get_title() when determining the widget title
793
 
794
  == Upgrade Notice ==
795
 
796
+ = 3.0.4 =
797
+ Fixed a couple of minor bugs with the "assist" and the widget form, and corrected a bug with accessibility mode when javascript is enabled.
798
+ Extended Include Root Items to allow selection by level, as is provided for Exclusions by Level (eg. include_root=1 is now include_level="1").
799
+
800
  = 3.0.3 =
801
  Fixed problem with WordPress's update() reporting Invalid Header when activating immediately following installation (as opposed to activating via Plugins page).
802
  Tweaked the generated shortcode to add a self-terminating forward slash. Please note that this tweak is merely a metter of "good practice" : there is no need to update your existing, working, shortcodes!