Version Description
bugfix : clearing the container field failed to remove the container from the output
addition : in the "assist", added automatic selection of the shortcode text when it is clicked
addition : remove WordPress's menu-item-has-children class (introduced in v3.7) when the filtered item no longer has children
change : tweaked styles and javascript in admin for WordPress v3.8
Download this release
Release Info
Developer | wizzud |
Plugin | Custom Menu Wizard Widget |
Version | 2.0.4 |
Comparing to | |
See all releases |
Code changes from version 2.0.3 to 2.0.4
- custom-menu-wizard.css +6 -3
- custom-menu-wizard.js +32 -41
- custom-menu-wizard.min.js +23 -23
- custom-menu-wizard.php +16 -5
- readme.txt +17 -2
custom-menu-wizard.css
CHANGED
@@ -1,17 +1,20 @@
|
|
1 |
/**
|
2 |
* custom-menu-wizard.css
|
3 |
-
* Version: 2.0.
|
4 |
*/
|
5 |
/*widget admin style...*/
|
6 |
/*NB .widget-content class is not present in accessibility mode*/
|
7 |
.js .widget-content .widget-custom-menu-wizard-onchange .cmw-start-fieldset-collapsed {display:none;}
|
|
|
8 |
.widget-custom-menu-wizard-onchange .cmw-colour-grey {color:#999999;}
|
9 |
.widget-custom-menu-wizard-onchange .cmw-pad-left-1 {padding-left:1em;}
|
10 |
.widget-custom-menu-wizard-onchange .cmw-off-the-page {display:none; position:absolute; left:-5000px; top:-5000px;}
|
11 |
.widget-custom-menu-wizard-onchange .cmw-toggle-assist {float:right; line-height:1; margin-left:1em;}
|
12 |
-
.widget-custom-menu-wizard-collapsible-fieldset
|
|
|
13 |
.widget-custom-menu-wizard-collapsible-fieldset h3 {font-size:1em; margin:0; padding:2px 0.5em;}
|
14 |
-
.widget-custom-menu-wizard-collapsible-fieldset
|
|
|
15 |
.js .widget-content .widget-custom-menu-wizard-collapsible-fieldset div.cmw-collapsed-fieldset {background-position:0 0;}
|
16 |
.widget-custom-menu-wizard-disableifnot-rp, .widget-custom-menu-wizard-disableifnot-ci {line-height:1.3333;}
|
17 |
.widget-custom-menu-wizard-childrenof optgroup option {padding-left:0.75em;}
|
1 |
/**
|
2 |
* custom-menu-wizard.css
|
3 |
+
* Version: 2.0.4
|
4 |
*/
|
5 |
/*widget admin style...*/
|
6 |
/*NB .widget-content class is not present in accessibility mode*/
|
7 |
.js .widget-content .widget-custom-menu-wizard-onchange .cmw-start-fieldset-collapsed {display:none;}
|
8 |
+
.widget-custom-menu-wizard-onchange {margin:0 0 0.5em;}
|
9 |
.widget-custom-menu-wizard-onchange .cmw-colour-grey {color:#999999;}
|
10 |
.widget-custom-menu-wizard-onchange .cmw-pad-left-1 {padding-left:1em;}
|
11 |
.widget-custom-menu-wizard-onchange .cmw-off-the-page {display:none; position:absolute; left:-5000px; top:-5000px;}
|
12 |
.widget-custom-menu-wizard-onchange .cmw-toggle-assist {float:right; line-height:1; margin-left:1em;}
|
13 |
+
.widget-custom-menu-wizard-collapsible-fieldset .hidden-field {display:none;}
|
14 |
+
.widget-custom-menu-wizard-collapsible-fieldset {margin:0.5em 0 0; cursor:pointer; border-left-width:0; border-right-width:0; border-radius:0; text-align:center; background-color:#ffffff;}
|
15 |
.widget-custom-menu-wizard-collapsible-fieldset h3 {font-size:1em; margin:0; padding:2px 0.5em;}
|
16 |
+
.widget-custom-menu-wizard-collapsible-fieldset h4 {font-size:1em; margin:0.75em 0;}
|
17 |
+
.widget-custom-menu-wizard-collapsible-fieldset div {background-color:transparent; background-repeat:no-repeat; background-position:0 -36px; height:16px; width:16px; float:right; margin-top:0.75em; outline:0 none;}
|
18 |
.js .widget-content .widget-custom-menu-wizard-collapsible-fieldset div.cmw-collapsed-fieldset {background-position:0 0;}
|
19 |
.widget-custom-menu-wizard-disableifnot-rp, .widget-custom-menu-wizard-disableifnot-ci {line-height:1.3333;}
|
20 |
.widget-custom-menu-wizard-childrenof optgroup option {padding-left:0.75em;}
|
custom-menu-wizard.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
/* Plugin Name: Custom Menu Wizard
|
2 |
-
* Version: 2.0.
|
3 |
* Author: Roger Barrett
|
4 |
*
|
5 |
* Script for controlling this widget's options (in Admin -> Widgets)
|
@@ -119,6 +119,26 @@ jQuery(function($){
|
|
119 |
this.blur();
|
120 |
return false;
|
121 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
/**
|
123 |
* creates a new list of menu items and inserts it into the dialog content in place of any previous one
|
124 |
* @param {Object} dialog jQuery object of the dialog
|
@@ -167,6 +187,7 @@ jQuery(function($){
|
|
167 |
.append( $('<div/>').addClass('cmw-demo-theshortcode').html('<code class="ui-corner-all">[custom_menu_wizard]</code>') );
|
168 |
dialog.find('.cmw-demo-themenu').on('click', 'a', assist.clickMenu);
|
169 |
dialog.find('.cmw-demo-themenu').on('change', 'input', assist.changeMenu);
|
|
|
170 |
dialog.find('.cmw-demo-theoutput').on('click', 'a', assist.clickOutput);
|
171 |
dialog.dialog({autoOpen:false, width:Math.min($(window).width() * 0.8, 600), modal:false});
|
172 |
}
|
@@ -564,46 +585,16 @@ jQuery(function($){
|
|
564 |
dialog.dialog('close');
|
565 |
}
|
566 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
567 |
});
|
568 |
|
569 |
-
//1. when a widget is opened or saved, trigger change on the filter_item select
|
570 |
-
//2. when a widget is deleted, destroy its dialog
|
571 |
-
//To achieve this I've elected to modify WP's window.wpWidgets object and intercept some of its methods
|
572 |
-
// - for (1), the fixLabels() method, which handily gets called whenever a widget is opened or saved
|
573 |
-
// - for (2), the save() method
|
574 |
-
if(window.wpWidgets){
|
575 |
-
if(window.wpWidgets.fixLabels && !window.wpWidgets._cmw_fixLabels){
|
576 |
-
//save the original...
|
577 |
-
window.wpWidgets._cmw_fixLabels = window.wpWidgets.fixLabels;
|
578 |
-
//replace the original...
|
579 |
-
window.wpWidgets.fixLabels = function(widget){
|
580 |
-
//trigger change on selectmenu...
|
581 |
-
widget.find('.widget-custom-menu-wizard-selectmenu').trigger('change');
|
582 |
-
//run the original...
|
583 |
-
window.wpWidgets._cmw_fixLabels(widget);
|
584 |
-
};
|
585 |
-
}
|
586 |
-
if(window.wpWidgets.save && !window.wpWidgets._cmw_save){
|
587 |
-
//save the original...
|
588 |
-
window.wpWidgets._cmw_save = window.wpWidgets.save;
|
589 |
-
//replace the original...
|
590 |
-
window.wpWidgets.save = function(widget, del, animate, order){
|
591 |
-
//destroy dialog if deleting the widget...
|
592 |
-
if(del){
|
593 |
-
widget.find('.widget-custom-menu-wizard-onchange').each(function(){
|
594 |
-
var dialog = $('#' + $(this).data().cmwDialogId);
|
595 |
-
if(dialog.length){
|
596 |
-
dialog.dialog('destroy');
|
597 |
-
dialog.remove();
|
598 |
-
}
|
599 |
-
});
|
600 |
-
}
|
601 |
-
//run the original...
|
602 |
-
window.wpWidgets._cmw_save(widget, del, animate, order);
|
603 |
-
};
|
604 |
-
}
|
605 |
-
}else{
|
606 |
-
//one-off fallback...
|
607 |
-
$(dotPrefix + '-selectmenu').trigger('change');
|
608 |
-
}
|
609 |
});
|
1 |
/* Plugin Name: Custom Menu Wizard
|
2 |
+
* Version: 2.0.4
|
3 |
* Author: Roger Barrett
|
4 |
*
|
5 |
* Script for controlling this widget's options (in Admin -> Widgets)
|
119 |
this.blur();
|
120 |
return false;
|
121 |
},
|
122 |
+
/**
|
123 |
+
* click handler for the shortcode : selects the text contained in the shortcode's CODE element
|
124 |
+
* @this {Element} The CODE element
|
125 |
+
* @param {Object} e Event object
|
126 |
+
*/
|
127 |
+
clickShortcode : function(e){
|
128 |
+
var doc = document,
|
129 |
+
range, selection;
|
130 |
+
if (doc.body.createTextRange){ //ms
|
131 |
+
range = doc.body.createTextRange();
|
132 |
+
range.moveToElementText(this);
|
133 |
+
range.select();
|
134 |
+
}else if(window.getSelection){ //all others
|
135 |
+
selection = window.getSelection();
|
136 |
+
range = doc.createRange();
|
137 |
+
range.selectNodeContents(this);
|
138 |
+
selection.removeAllRanges();
|
139 |
+
selection.addRange(range);
|
140 |
+
}
|
141 |
+
},
|
142 |
/**
|
143 |
* creates a new list of menu items and inserts it into the dialog content in place of any previous one
|
144 |
* @param {Object} dialog jQuery object of the dialog
|
187 |
.append( $('<div/>').addClass('cmw-demo-theshortcode').html('<code class="ui-corner-all">[custom_menu_wizard]</code>') );
|
188 |
dialog.find('.cmw-demo-themenu').on('click', 'a', assist.clickMenu);
|
189 |
dialog.find('.cmw-demo-themenu').on('change', 'input', assist.changeMenu);
|
190 |
+
dialog.find('.cmw-demo-theshortcode').on('click', 'code', assist.clickShortcode);
|
191 |
dialog.find('.cmw-demo-theoutput').on('click', 'a', assist.clickOutput);
|
192 |
dialog.dialog({autoOpen:false, width:Math.min($(window).width() * 0.8, 600), modal:false});
|
193 |
}
|
585 |
dialog.dialog('close');
|
586 |
}
|
587 |
});
|
588 |
+
})
|
589 |
+
//when a widget is deleted, remove its dialog...
|
590 |
+
.on('click', '.widget-control-remove', function(e){
|
591 |
+
$(this).closest('div.widget').find('.widget-custom-menu-wizard-onchange').each(function(){
|
592 |
+
var dialog = $('#' + $(this).data().cmwDialogId);
|
593 |
+
if(dialog.length){
|
594 |
+
dialog.dialog('destroy');
|
595 |
+
dialog.remove();
|
596 |
+
}
|
597 |
+
});
|
598 |
});
|
599 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
600 |
});
|
custom-menu-wizard.min.js
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
/* Plugin Name: Custom Menu Wizard
|
2 |
-
* Version: 2.0.
|
3 |
* Author: Roger Barrett
|
4 |
*
|
5 |
* Script for controlling this widget's options (in Admin -> Widgets)
|
6 |
*/
|
7 |
-
jQuery(function(f){var n={getDialog:function(
|
8 |
-
return a},buildRecurse:function(
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
a);b&&b>k.maxLevel&&(k.maxLevel=b)}))},init:function(
|
13 |
-
|
14 |
-
modal:!1}));
|
15 |
-
a.
|
16 |
-
e.push("ancestors"),e.length&&(
|
17 |
-
b[1]&&(
|
18 |
-
(m=h.find(".current-menu-item").text()||"");m||
|
19 |
-
(d.ol_sub?"</ol>":"</ul>");e+="</li>";p.push(
|
20 |
-
n.createMenu(
|
21 |
-
0
|
22 |
-
(l=k),e=e||
|
23 |
-
|
24 |
-
|
25 |
-
return!1}).on("change",".widget-custom-menu-wizard-listen",function(){var
|
26 |
-
f("#"+
|
27 |
-
".widget-action, .widget-control-close",function(){f(this).closest("div.widget").find(".widget-custom-menu-wizard-onchange").each(function(){var
|
28 |
-
|
1 |
/* Plugin Name: Custom Menu Wizard
|
2 |
+
* Version: 2.0.4
|
3 |
* Author: Roger Barrett
|
4 |
*
|
5 |
* Script for controlling this widget's options (in Admin -> Widgets)
|
6 |
*/
|
7 |
+
jQuery(function(f){var n={getDialog:function(d){return f("#"+d.find(".widget-custom-menu-wizard-onchange").data().cmwDialogId)},getSettings:function(d){var a={};f.each(d.serializeArray(),function(b,d){var c=d.name.replace(/.*\[([^\]]+)\]$/,"$1"),e="items"!==c&&/^-?\d+$/.test(d.value)?parseInt(d.value,10):d.value;a[c]=e;"items"===c&&(a._items_sep=!e||/(^\d+$|,)/.test(f.trim(e))?",":" ",e=f.map(e.split(/[,\s]+/),function(a){a=a?parseInt(a,10):0;return isNaN(a)||1>a?null:a}),a._items=e.join(a._items_sep))});
|
8 |
+
return a},buildRecurse:function(d,a,b){var f="",c,e;a=(a||0)+1;b=b||"";for(c in d)e=c.split("|")[0],f+='<li class="level-'+a+'" data-itemid="'+e+'" data-level="'+a+'" data-trace="'+b+'">',f+='<a class="ui-corner-all" href="#"><span class="ui-corner-all" title="#'+e+'">'+c.replace(/^\d+\|/,""),f+='</span></a><input type="checkbox" value="'+e+'" />',d[c]&&(f+="<ul>"+n.buildRecurse(d[c],a,e+(b?",":"")+b)+"</ul>"),f+="</li>";return f},changeMenu:function(d){d=f(this);var a=f(d.closest(".ui-dialog-content").data().cmwTriggerChange).closest("form").find(".widget-custom-menu-wizard-setitems"),
|
9 |
+
b=f.trim(a.val()),b=!b||/(^\d+$|,)/.test(b)?",":" ";a.val(d.closest(".cmw-demo-themenu").find("input").map(function(){return this.checked?this.value:null}).get().join(b)).trigger("change")},clickMenu:function(d){var a=f(this);d=["current-menu-item","current-menu-parent","current-menu-ancestor"];var b=a.closest(".ui-dialog-content"),g=b.find(".cmw-demo-themenu"),a=a.find("span").not("."+d[0]).parentsUntil(g,"li"),c,e=function(){this.title=this.title+" "+c.replace(" "," & ").replace(/-/g," ")};g.find("."+
|
10 |
+
d.join(",.")).removeClass(d.join(" ")).each(function(){this.title=this.title.replace(/\s.*$/,"")});for(g=0;g<a.length;g++)c=1===g?d.join(" "):d[0],a.eq(g).children("a").find("span").addClass(c).each(e),1<d.length&&d.shift();f(b.data().cmwTriggerChange).trigger("change");return!1},clickOutput:function(d){d=this.href.split("#")[1];f(this).closest(".ui-dialog-content").find(".cmw-demo-themenu a").eq(d).not(":has(.current-menu-item)").trigger("click");this.blur();return!1},clickShortcode:function(d){var a=
|
11 |
+
document;a.body.createTextRange?(a=a.body.createTextRange(),a.moveToElementText(this),a.select()):window.getSelection&&(d=window.getSelection(),a=a.createRange(),a.selectNodeContents(this),d.removeAllRanges(),d.addRange(a))},createMenu:function(d,a){var b=d.data(),g=d.find(".cmw-demo-themenu"),c=a.find(".widget-custom-menu-wizard-selectmenu"),e=parseInt(c.val(),10),m=g.find("ul").eq(0),k=g.data(),h;m.length&&m.data("menuid")===e||(h=f("<ul>"+n.buildRecurse(a.find(".widget-custom-menu-wizard-childrenof optgroup").data().cmwItems||
|
12 |
+
{})+"</ul>"),m.remove(),d.dialog("option","title",b.cmwTitlePrefix+c.find("option:selected").text()),k.maxLevel=0,g.append(h.data("menuid",e)).find("a").each(function(a){var b=f(this).parent("li").data().level;f(this).data("indx",a);b&&b>k.maxLevel&&(k.maxLevel=b)}))},init:function(d){var a=f(this);d=a.closest(".widget-custom-menu-wizard-onchange").data();var b=f("#"+d.cmwDialogId),a=a.closest("form");b.length||(b=f("<div/>",{id:d.cmwDialogId}).addClass("widget-custom-menu-wizard-dialog").data({cmwTriggerChange:d.cmwDialogTrigger,
|
13 |
+
cmwTitlePrefix:d.cmwDialogTitle}).append(f("<div/>").addClass("cmw-demo-theoutput").html("<strong>"+d.cmwDialogOutput+'</strong> …<div class="cmw-demo-theoutput-wrap ui-corner-all"></div><div class="cmw-demo-fallback"><small>'+d.cmwDialogFallback+"</small></div>")).append(f("<div/>").addClass("cmw-demo-themenu").html("<small><em>"+d.cmwDialogPrompt+"</em></small>")).append(f("<div/>").addClass("cmw-demo-theshortcode").html('<code class="ui-corner-all">[custom_menu_wizard]</code>')),b.find(".cmw-demo-themenu").on("click",
|
14 |
+
"a",n.clickMenu),b.find(".cmw-demo-themenu").on("change","input",n.changeMenu),b.find(".cmw-demo-theshortcode").on("click","code",n.clickShortcode),b.find(".cmw-demo-theoutput").on("click","a",n.clickOutput),b.dialog({autoOpen:!1,width:Math.min(0.8*f(window).width(),600),modal:!1}));b.dialog("isOpen")?b.dialog("close"):(n.createMenu(b,a),b.dialog("open"),f(d.cmwDialogTrigger).trigger("change"));this.blur();return!1},shortcode:function(d,a){var b={menu:[a.menu]},g,c,e;a.title&&(b.title=a.title);if(0<
|
15 |
+
a.filter)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]}0>a.filter&&(b.items=a._items);0<a.filter&&0>a.filter_item&&a.fallback_no_ancestor&&(b.fallback_parent=a.fallback_include_parent_siblings?"siblings":a.fallback_include_parent?"parent":[1]);0<a.filter&&!a.filter_item&&a.fallback_no_children&&(b.fallback_current=a.fallback_nc_include_parent_siblings?"siblings":a.fallback_nc_include_parent?
|
16 |
+
"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]);e=[];0<a.filter&&(a.include_parent_siblings?e.push("siblings"):a.include_parent&&e.push("parent"),a.include_ancestors&&e.push("ancestors"),e.length&&(b.include=e.join(" ")));e=[];0<a.filter&&a.title_from_parent&&e.push("parent");a.title_from_current&&e.push("current");e.length&&(b.title_from=e.join(" "));for(e in{flat_output:1,contains_current:1,ol_root:1,
|
17 |
+
ol_sub:1})a[e]&&(b[e]=[1]);g={container:"div",container_id:"",container_class:"",menu_class:"menu-widget",widget_class:""};for(e in g)a[e]!==g[e]&&(b[e]=a[e]);g={wrap_link:"before",wrap_link_text:"link_before"};for(e in g)(c=a[g[e]].toString().match(/^<(\w+)/))&&c[1]&&(b[e]=c[1]);g=[];for(e in b)g.push(f.isArray(b[e])?e+"="+b[e][0]:e+'="'+b[e]+'"');n.getDialog(d).find("code").text("[custom_menu_wizard "+g.join(" ")+"]")},show:function(d,a,b){a=a||f(this).closest("form");b=b||n.getSettings(a);d=n.getDialog(a);
|
18 |
+
var g=d.find(".cmw-demo-themenu"),c=g.find(".picked"),e="",m="",k=0,h=d.find(".cmw-demo-theoutput-wrap").empty(),p=["menu-widget"],q={};if(c.length&&h.length){0<b.filter&&b.title_from_parent&&(m=g.find(".the-parent").children("a").text()||"");!m&&b.title_from_current&&(m=g.find(".current-menu-item").text()||"");m||b.hide_title||(m=b.title||"");for(c.each(function(a){var c=f(this),d=c.data(),h=d.trace?d.trace.toString().split(","):[];a=d.itemid.toString();var g=1,c=c.children("a");if(!b.flat_output)for(q[a]=
|
19 |
+
1,a=0;a<h.length;a++)q[h[a]]&&g++;if(k)if(g>k)e+=b.ol_sub?"<ol>":"<ul>";else{for(;k>g;)--k,e+="</li>"+(b.ol_sub?"</ol>":"</ul>");e+="</li>"}e+='<li class="cmw-level-'+g+(d.included||"")+'"><a href="#'+c.data("indx")+'">'+c.text()+"</a>";k=g});1<k;)--k,e+="</li>"+(b.ol_sub?"</ol>":"</ul>");e+="</li>";p.push(d.find(".cmw-demo-fallback").data("fellback"));e=(b.ol_root?"<ol":"<ul")+' class="'+f.trim(p.join(" "))+'">'+e+(b.ol_root?"</ol>":"</ul>");h.html(e);m&&h.prepend("<h3>"+m+"</h3>");h.find("li").filter(function(){return!!f(this).children("ul, ol").length}).addClass("cmw-has-submenu")}n.shortcode(a,
|
20 |
+
b)},update:function(d){var a=f(this).closest("form"),b=n.getDialog(a),g,c,e,m,k,h,p,q,r,l,s;if(b.length&&b.dialog("isOpen")){f(d.target).hasClass("widget-custom-menu-wizard-selectmenu")&&n.createMenu(b,a);c=n.getSettings(a);e=c.include_parent;m=c.include_parent_siblings;k=b.find(".cmw-demo-themenu");g=k.data().maxLevel;p=k.find(".current-menu-item").closest("li");q=p.length?p.data().level:-1;h=k.find("li").removeData("included").removeClass("the-parent");0>c.filter&&(h=h.filter(function(){var a=f(this).children("input"),
|
21 |
+
b=-1<(c._items_sep+c._items+c._items_sep).indexOf(c._items_sep+a[0].value+c._items_sep);a.prop("checked",b);return b}),c._items||(h=f([])));h.length&&!p.length&&(c.contains_current||0<c.filter&&1>c.filter_item)&&(h=f([]));h.length&&0<c.filter&&(0<c.filter_item?l=h.filter("[data-itemid="+c.filter_item+"]"):c.filter_item?1===q&&c.fallback_no_ancestor?(l=p,e=e||c.fallback_include_parent,m=m||c.fallback_include_parent_siblings,r="cmw-fellback-to-current"):l=1===q?k:-1>c.filter_item?k.find(".current-menu-ancestor").eq(0).closest("li"):
|
22 |
+
k.find(".current-menu-parent").closest("li"):p.find("li").length?l=p:c.fallback_no_children&&(l=k.find(".current-menu-parent").closest("li"),l.length||(l=k),e=e||c.fallback_nc_include_parent,m=m||c.fallback_nc_include_parent_siblings,r="cmw-fellback-to-parent"));if(h.length)if(c.filter)l&&l.length?(s=c.depth_rel_current&&c.depth&&p.length&&l.has(p[0]).length?q-1+c.depth:c.depth?Math.max((l.data().level||0)+c.depth,c.start_level+c.depth-1):9999,h=l.find("li").filter(function(){var a=f(this).data().level;
|
23 |
+
return a>=c.start_level&&a<=s})):0<c.filter&&(h=f([]));else for(s=c.depth_rel_current&&c.depth&&p.length&&q>=c.start_level?q+c.depth-1:c.depth?c.start_level+c.depth-1:9999,q=1;q<=g;q++)if(q<c.start_level||q>s)h=h.not(".level-"+q);h.length&&0<c.filter&&l&&l.is("li")&&(m&&(h=h.add(l.siblings("li").data("included"," cmw-an-included-parent-sibling")),e=!0),c.include_ancestors&&(h=h.add(l.parentsUntil(k,"li").data("included"," cmw-an-included-ancestor")),e=!0),e&&(h=h.add(l.data("included"," cmw-the-included-parent"))));
|
24 |
+
!h.length||!c.contains_current||p.length&&h.filter(p).length||(h=f([]));h.length&&l&&l.is("li")&&l.addClass("the-parent");r=h.length?r:"";b.find(".cmw-demo-fallback").data("fellback",r).toggleClass("cmw-demo-fellback",!!r);k.toggleClass("cmw-demo-filteritems",0>c.filter).find(".picked").not(h.addClass("picked")).removeClass("picked");n.show.call(this,d,a,c)}}};f(document).on("click",".widget-custom-menu-wizard-collapsible-fieldset",function(){var d=f(this),a=d.find("input").eq(0),b=!a.prop("checked");
|
25 |
+
a.length&&(a.prop("checked",b),d.find("div").toggleClass("cmw-collapsed-fieldset",b),d.next("div")[b?"slideUp":"slideDown"]());this.blur();return!1}).on("change",".widget-custom-menu-wizard-listen",function(){var d=f(this.form),a=d.find(".widget-custom-menu-wizard-selectmenu"),b=d.find(".widget-custom-menu-wizard-showall").prop("checked"),g=d.find(".widget-custom-menu-wizard-showspecific").prop("checked"),d=d.find(".widget-custom-menu-wizard-childrenof"),c=parseInt(d.val(),10),e;a.is(this)&&(a=this.selectedIndex,
|
26 |
+
d.find("optgroup").filter(function(){var b=f(this).data("cmwOptgroupIndex")===a;b||f(this).remove();return b}).length||(e=f("#"+d.attr("id")+"_ignore").find("optgroup").eq(a).clone(),e.length&&(0<c&&(c=0,d.val(c)),e.find("option[selected]").removeAttr("selected").prop("selected",!1),d.append(e))));f.each({"":b||g,"-ss":g,"not-rp":b||g||0<=c,"not-ci":b||g||!!c},function(a,b){f(".widget-custom-menu-wizard-disableif"+a,this.form).toggleClass("cmw-colour-grey",b).find("input,select").prop("disabled",
|
27 |
+
b)})}).on("change",".widget-custom-menu-wizard-onchange",n.update).on("click",".widget-custom-menu-wizard-toggle-assist",n.init).on("click",".widget-action, .widget-control-close",function(){f(this).closest("div.widget").find(".widget-custom-menu-wizard-onchange").each(function(){var d=f("#"+f(this).data().cmwDialogId);d.length&&d.dialog("isOpen")&&d.dialog("close")})}).on("click",".widget-control-remove",function(d){f(this).closest("div.widget").find(".widget-custom-menu-wizard-onchange").each(function(){var a=
|
28 |
+
f("#"+f(this).data().cmwDialogId);a.length&&(a.dialog("destroy"),a.remove())})})});
|
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: 2.0.
|
7 |
* Author: Roger Barrett
|
8 |
* Author URI: http://www.wizzud.com/
|
9 |
* License: GPL2+
|
10 |
*/
|
11 |
|
12 |
/*
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
* v2.0.3 change log:
|
14 |
* - fixed bug with missing global when enqueuing scripts and styles for admin page
|
15 |
*
|
@@ -59,7 +65,7 @@
|
|
59 |
* - moved the setting of 'disabled' attributes on INPUTs/SELECTs from PHP into javascript
|
60 |
*/
|
61 |
|
62 |
-
$Custom_Menu_Wizard_Widget_Version = '2.0.
|
63 |
|
64 |
/**
|
65 |
* registers the widget and adds the shortcode
|
@@ -144,7 +150,7 @@ function custom_menu_wizard_update_message($plugin_data, $r){
|
|
144 |
//show if not empty...
|
145 |
if(!empty($readme)){
|
146 |
?>
|
147 |
-
<div style="font-weight:normal;background-color:#fff0c0;border:1px solid #
|
148 |
<div style="margin:0.5em 0.5em 0.5em 1em;max-height:12em;overflow:auto;">
|
149 |
<?php echo $readme; ?>
|
150 |
</div>
|
@@ -515,6 +521,9 @@ class Custom_Menu_Wizard_Walker extends Walker_Nav_Menu {
|
|
515 |
//add the submenu class?...
|
516 |
if( $v['kids'] > 0 ){
|
517 |
$elements[ $i ]->classes[] = 'cmw-has-submenu';
|
|
|
|
|
|
|
518 |
}
|
519 |
//add the level class...
|
520 |
$elements[ $i ]->classes[] = 'cmw-level-' . $v['level'];
|
@@ -700,7 +709,7 @@ class Custom_Menu_Wizard_Walker extends Walker_Nav_Menu {
|
|
700 |
}
|
701 |
//strings...
|
702 |
foreach( $this->_cmw_strings as $k=>$v ){
|
703 |
-
$instance[ $k ] =
|
704 |
}
|
705 |
//html strings...
|
706 |
foreach( $this->_cmw_html as $k=>$v ){
|
@@ -1310,6 +1319,8 @@ class Custom_Menu_Wizard_Walker extends Walker_Nav_Menu {
|
|
1310 |
</p>
|
1311 |
<?php $this->_close_a_field_section(); ?>
|
1312 |
|
|
|
|
|
1313 |
</div>
|
1314 |
|
1315 |
<?php
|
@@ -1328,7 +1339,7 @@ class Custom_Menu_Wizard_Walker extends Walker_Nav_Menu {
|
|
1328 |
<input id="<?php echo $this->get_field_id($fname); ?>" class="hidden-field" name="<?php echo $this->get_field_name($fname); ?>"
|
1329 |
type="checkbox" value="1" <?php checked( $instance[$fname] ); ?> />
|
1330 |
<div style="background-image:url(images/arrows.png);" class="<?php echo $instance[$fname] ? 'cmw-collapsed-fieldset' : ''; ?>"></div>
|
1331 |
-
<
|
1332 |
</div>
|
1333 |
<div class="<?php echo $instance[$fname] ? 'cmw-start-fieldset-collapsed' : ''; ?>">
|
1334 |
<?php
|
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: 2.0.4
|
7 |
* Author: Roger Barrett
|
8 |
* Author URI: http://www.wizzud.com/
|
9 |
* License: GPL2+
|
10 |
*/
|
11 |
|
12 |
/*
|
13 |
+
* v2.0.4 change log:
|
14 |
+
* - fixed bug where clearing the container field failed to remove the container from the output
|
15 |
+
* - remove WordPress's menu-item-has-children class (WP v3.7+) when the filtered item no longer has children
|
16 |
+
* - added automatic selection of the shortcode text when it is clicked
|
17 |
+
* - tweaked admin styling and javascript for WordPress v3.8
|
18 |
+
*
|
19 |
* v2.0.3 change log:
|
20 |
* - fixed bug with missing global when enqueuing scripts and styles for admin page
|
21 |
*
|
65 |
* - moved the setting of 'disabled' attributes on INPUTs/SELECTs from PHP into javascript
|
66 |
*/
|
67 |
|
68 |
+
$Custom_Menu_Wizard_Widget_Version = '2.0.4';
|
69 |
|
70 |
/**
|
71 |
* registers the widget and adds the shortcode
|
150 |
//show if not empty...
|
151 |
if(!empty($readme)){
|
152 |
?>
|
153 |
+
<div style="font-weight:normal;background-color:#fff0c0;border:1px solid #d54e21;border-radius:0.5em;margin:0.1em 0;">
|
154 |
<div style="margin:0.5em 0.5em 0.5em 1em;max-height:12em;overflow:auto;">
|
155 |
<?php echo $readme; ?>
|
156 |
</div>
|
521 |
//add the submenu class?...
|
522 |
if( $v['kids'] > 0 ){
|
523 |
$elements[ $i ]->classes[] = 'cmw-has-submenu';
|
524 |
+
}else{
|
525 |
+
//3.7 adds a menu-item-has-children class to (original) menu items that have kids : remove it as the item is now childless...
|
526 |
+
$elements[ $i ]->classes = array_diff( $elements[ $i ]->classes, array('menu-item-has-children') );
|
527 |
}
|
528 |
//add the level class...
|
529 |
$elements[ $i ]->classes[] = 'cmw-level-' . $v['level'];
|
709 |
}
|
710 |
//strings...
|
711 |
foreach( $this->_cmw_strings as $k=>$v ){
|
712 |
+
$instance[ $k ] = isset( $instance[ $k ] ) ? trim( $instance[ $k ] ) : $v; //bug in 2.0.2 fixed!
|
713 |
}
|
714 |
//html strings...
|
715 |
foreach( $this->_cmw_html as $k=>$v ){
|
1319 |
</p>
|
1320 |
<?php $this->_close_a_field_section(); ?>
|
1321 |
|
1322 |
+
<script type="text/javascript">jQuery(function($){$('#<?php echo $this->get_field_id('menu'); ?>').trigger('change');})</script>
|
1323 |
+
|
1324 |
</div>
|
1325 |
|
1326 |
<?php
|
1339 |
<input id="<?php echo $this->get_field_id($fname); ?>" class="hidden-field" name="<?php echo $this->get_field_name($fname); ?>"
|
1340 |
type="checkbox" value="1" <?php checked( $instance[$fname] ); ?> />
|
1341 |
<div style="background-image:url(images/arrows.png);" class="<?php echo $instance[$fname] ? 'cmw-collapsed-fieldset' : ''; ?>"></div>
|
1342 |
+
<h4><?php _e( $text ); ?></h4>
|
1343 |
</div>
|
1344 |
<div class="<?php echo $instance[$fname] ? 'cmw-start-fieldset-collapsed' : ''; ?>">
|
1345 |
<?php
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Contributors: wizzud
|
3 |
Tags: menu,widget,widgets,navigation,nav,custom menus,custom menu,partial menu,menu level,menu branch
|
4 |
Requires at least: 3.0.1
|
5 |
-
Tested up to: 3.
|
6 |
-
Stable tag: 2.0.
|
7 |
License: GPLv2 or Later
|
8 |
|
9 |
Show branches or levels of your menu in a widget, or in content using a shortcode, with full customisation.
|
@@ -489,6 +489,16 @@ It was a close call, but since the Output options can extend the final list - an
|
|
489 |
|
490 |
== Changelog ==
|
491 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
492 |
= 2.0.3 =
|
493 |
|
494 |
* bugfix : missing global when enqueuing scripts and styles for admin
|
@@ -579,6 +589,11 @@ Initial release
|
|
579 |
|
580 |
== Upgrade Notice ==
|
581 |
|
|
|
|
|
|
|
|
|
|
|
582 |
= 2.0.3 =
|
583 |
|
584 |
Fixed a minor bug with a missing global when enqueuing script and style for the admin.
|
2 |
Contributors: wizzud
|
3 |
Tags: menu,widget,widgets,navigation,nav,custom menus,custom menu,partial menu,menu level,menu branch
|
4 |
Requires at least: 3.0.1
|
5 |
+
Tested up to: 3.8
|
6 |
+
Stable tag: 2.0.4
|
7 |
License: GPLv2 or Later
|
8 |
|
9 |
Show branches or levels of your menu in a widget, or in content using a shortcode, with full customisation.
|
489 |
|
490 |
== Changelog ==
|
491 |
|
492 |
+
= 2.0.4 =
|
493 |
+
|
494 |
+
* bugfix : clearing the container field failed to remove the container from the output
|
495 |
+
|
496 |
+
* addition : in the "assist", added automatic selection of the shortcode text when it is clicked
|
497 |
+
|
498 |
+
* addition : remove WordPress's menu-item-has-children class (introduced in v3.7) when the filtered item no longer has children
|
499 |
+
|
500 |
+
* change : tweaked styles and javascript in admin for WordPress v3.8
|
501 |
+
|
502 |
= 2.0.3 =
|
503 |
|
504 |
* bugfix : missing global when enqueuing scripts and styles for admin
|
589 |
|
590 |
== Upgrade Notice ==
|
591 |
|
592 |
+
= 2.0.4 =
|
593 |
+
|
594 |
+
Fixed a bug that prevented the container field being removed, and added removal of the menu-item-has-children class when the filtered item no longer has children.
|
595 |
+
The admin widget styling and javascript have been tweaked to accommodate WordPress 3.8.
|
596 |
+
|
597 |
= 2.0.3 =
|
598 |
|
599 |
Fixed a minor bug with a missing global when enqueuing script and style for the admin.
|