Version Description
- bugfix : only show the allow_all_root setting in the shortcode equivalent if the primary filter is by branch
- addition : work-around for when a theme inadvertently(!) de-registers the widget, which then prevents the shortcode working
Download this release
Release Info
Developer | wizzud |
Plugin | Custom Menu Wizard Widget |
Version | 3.1.1 |
Comparing to | |
See all releases |
Code changes from version 3.1.0 to 3.1.1
- custom-menu-wizard.js +5 -1
- custom-menu-wizard.min.js +8 -8
- custom-menu-wizard.php +45 -7
- include/class.widget.php +9 -1
- readme.txt +9 -1
custom-menu-wizard.js
CHANGED
@@ -1023,6 +1023,10 @@ jQuery(function($){
|
|
1023 |
if(settings.start_mode === 'level'){
|
1024 |
args.start_mode = 'level';
|
1025 |
}
|
|
|
|
|
|
|
|
|
1026 |
}
|
1027 |
//specifying items set byItems, overriding byLevel & byBranch...
|
1028 |
if(byItems){
|
@@ -1089,7 +1093,7 @@ jQuery(function($){
|
|
1089 |
args.title_from = n;
|
1090 |
}
|
1091 |
//switches...
|
1092 |
-
for(n in {
|
1093 |
if(settings[n]){
|
1094 |
args[n] = 1;
|
1095 |
}
|
1023 |
if(settings.start_mode === 'level'){
|
1024 |
args.start_mode = 'level';
|
1025 |
}
|
1026 |
+
//allow_all_root is only applicable to byBranch...
|
1027 |
+
if( settings.allow_all_root ){
|
1028 |
+
args.allow_all_root = 1;
|
1029 |
+
}
|
1030 |
}
|
1031 |
//specifying items set byItems, overriding byLevel & byBranch...
|
1032 |
if(byItems){
|
1093 |
args.title_from = n;
|
1094 |
}
|
1095 |
//switches...
|
1096 |
+
for(n in {siblings:1, flat_output:1, ol_root:1, ol_sub:1, fallback_ci_parent:1}){
|
1097 |
if(settings[n]){
|
1098 |
args[n] = 1;
|
1099 |
}
|
custom-menu-wizard.min.js
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
/*Source: custom-menu-wizard.js
|
2 |
-
*Compiled: 2014-10-
|
3 |
*STATISTICS
|
4 |
-
* - originalSize:
|
5 |
-
* - originalGzipSize:
|
6 |
-
* - compressedSize:
|
7 |
-
* - compressedGzipSize:
|
8 |
*/
|
9 |
jQuery(function(g){var w,K=/(\w+)\s*=\s*"([^"]*)"(?:\s|$)|(\w+)\s*=\s*\'([^\']*)\'(?:\s|$)|(\w+)\s*=\s*([^\s\'"]+)(?:\s|$)/g,u=function(b,a){return(a?".":"")+"widget-custom-menu-wizard-"+b},z=function(b){var a=g(this).data().cmwDialogVersion.replace(/\./g,""),a=/^\d+$/.test(a)?"v"+a:a;w[a]?w[a].update(b?b.target:this):w.update(b?b.target:this)},B=function(b,a){var c=!1===b,d=c?{}:b.data(),e={},l=!c&&"2.1.0"===d.cmwDialogVersion,f={items:1,exclude:1},m=g.extend({branch_start:1,exclude_level:1,include_level:1},
|
10 |
f);g.each(c?a:b.find(":input").serializeArray(),function(a,b){var h=b.name.replace(/.*\[([^\]]+)\]$/,"$1"),p=!m[h]&&/^-?\d+$/.test(b.value)?parseInt(b.value,10):b.value;e[h]=p;"hide_empty"===h?e[h]=c||!!d.cmwV36plus||p:f[h]&&(e["_"+h+"_sep"]=!p||/(^\d+\+?$|,)/.test(g.trim(p))?",":" ",p=g.map(p.split(/[,\s]+/),function(a){var b=!l&&/\+$/.test(a);a=a?parseInt(a,10):0;return isNaN(a)||1>a?null:b?a+"+":a}),e["_"+h]=p.join(e["_"+h+"_sep"]))});return e},C=function(b,a,c,d){var e=d.switch_if;return d.switch_at===
|
@@ -32,9 +32,9 @@ menuid:c}))}};w={setLevels:function(b,a){if(a){var c=b.find(".cmw-branch-start")
|
|
32 |
g(this),c=b.find("option"),d=(c.length-1)/3,m=b.val(),q=c.eq(2).text(),s=c.eq(3).text();for(c.slice(3*a+1).remove();d<a;)++d,b.append(g("<option/>",{value:d}).text(d)).append(g("<option/>",{value:d+"-"}).text(q.replace(/\d+/,d))).append(g("<option/>",{value:d+"+"}).text(s.replace(/\d+/,d)));parseInt(m,10)>a&&b.val("")});b.find(".cmw-set-levels").each(function(){var b=g(this),c=b.data(),d=c.cmwTextLevels||"",c=c.cmwSetLevels||0,m=b.find("option"),q=m.length-c;b.val()>a&&b.val(m.eq(0).val());for(b.find("option").slice(c+
|
33 |
a).remove();q<a;)++q,b.append(g("<option/>",{value:q}).text(q+d))})}},setFields:function(b,a){var c=a.find(".cmw-bybranch"),d=a.find(".cmw-byitems").prop("checked"),e=d||!c.prop("checked"),l=a.find(".cmw-assist-items"),f=parseInt(l.val(),10);b.hasClass("cmw-select-menu")?(f=O(l,f,b[0].selectedIndex),this.setLevels(a,(l.find("optgroup").data()||{}).cmwMaxLevel)):b.hasClass("cmw-level")?(e=!0,d=!e,a.find(".cmw-bylevel").prop("checked",e)):b.is(l)?(e=d=!1,c.prop("checked",!e)):b.hasClass("cmw-setitems")?
|
34 |
(e=d=!0,a.find(".cmw-byitems").prop("checked",d)):b.hasClass("cmw-ancestors")&&"0"===b.val()?a.find(".cmw-ancestor-siblings").val("0"):b.hasClass("cmw-ancestor-siblings")&&"0"!==b.val()&&"0"===a.find(".cmw-ancestors").val()&&a.find(".cmw-ancestors").val(b.val());c=a.find(".cmw-fallback").val();g.each({"-ss":d,"-ud":d||1>a.find(".cmw-depth").val(),"not-br":e,"not-br-ci":e||!!f,"not-fb-pc":e||!!f||"parent"!==c&&"current"!==c,"not-sw":!!a.find(".cmw-switchable").filter(function(){return!g(this).val()}).length},
|
35 |
-
function(b,c){a.find(".cmw-disableif"+b).toggleClass("cmw-colour-grey",c)})},shortcode:function(b){var a={menu:b.menu},c="branch"===b.filter,d="items"===b.filter,e,l;b.title&&!b.hide_title&&(a.title=[b.title]);!c&&!d&&1<b.level&&(a.level=b.level);c&&(a.branch=b.branch||"current",b.branch_start&&(a.start_at=[b.branch_start]),"level"===b.start_mode&&(a.start_mode="level"));d&&(a.items=[b._items]);0<b.depth&&(a.depth=b.depth);b.depth_rel_current&&0<b.depth&&(a.depth_rel_current=
|
36 |
-
(a.fallback=[b.fallback],"quit"!==b.fallback&&(b.fallback_siblings&&a.fallback.push("+siblings"),b.fallback_depth&&a.fallback.push(b.fallback_depth)));c&&b.ancestors&&(a.ancestors=b.ancestors,b.ancestor_siblings&&(a.ancestor_siblings=b.ancestor_siblings));b.include_level&&(a.include_level=[b.include_level]);b._exclude&&(a.exclude=[b._exclude]);b.exclude_level&&(a.exclude_level=[b.exclude_level]);d=[];b.title_from_current?d.push("current"):b.title_from_current_root&&d.push("current-root");
|
37 |
-
d.push("branch"):c&&b.title_from_branch_root&&d.push("branch-root");d.length&&(a.title_from=d);for(d in{
|
38 |
(a.alternative=[b.switch_if,b.switch_at],l=L(b.switch_to));c=[];for(d in a)c.push(g.isArray(a[d])?d+'="'+a[d].join(",")+'"':d+"="+a[d]);return"[cmwizard "+c.join(" ")+(l?"]"+l+"[/cmwizard]":"/]")},structureUpdate:function(b,a,c){var d=-1,e=9999,l=0,f=0,m="",q=null,s,h,p,n,t="menu",r="branch"===a.filter,u="items"===a.filter,x=!r&&!u,w=r&&!a.branch,E=!c&&!!a.switch_if&&!!a.switch_at,A=b.find(".cmw-demo-themenu-ul"),y=A.data().maxLevel,v=A.find(".current-menu-item").closest("li"),G=v.length?v.data().level:
|
39 |
-1,k=A.find("li").removeData("included").removeClass("title-from-item"),F=a.depth,z=a.depth_rel_current,B=H(k,a,"cross");h=k.length&&v.is(k);a.contains_current!==t||h||(k=g([]));if(E&&C(t,h,k.length,a)&&(q=D(a,b),!1!==q))return q;t="primary";u&&k.length&&(k=H(k,a,"tick"));r&&k.length&&(p=w?v:k.filter("[data-itemid="+a.branch+"]"),p.length?(d=p.data().level||0,k=p.add(p.find("li")),s=p):k=g([]));if(x&&k.length&&1<a.level){h=1;for(n=[];h<a.level;h++)n.push(".level-"+h);k=k.not(n.join(","))}h=k.length&&
|
40 |
v.is(k);a.contains_current!==t||h||(k=g([]));if(E&&C(t,h,k.length,a)&&(q=D(a,b),!1!==q))return q;t="secondary";if(x&&k.length&&F&&(h=z&&G>=a.level?G:a.level,h+=F,h<=y)){for(n=[];h<=y;h++)n.push(".level-"+h);k=k.not(n.join(","))}if(r&&k.length&&(n=parseInt(a.branch_start,10),n=isNaN(n)||!n?d:a.branch_start.match(/^(\+|-)/)?Math.max(1,d+n):n,w&&a.fallback&&!v.find("li").length&&(m="cmw-fellback-to-"+a.fallback,"quit"===a.fallback?n=y+1:(n="current"===a.fallback||2>d?d:d-1,a.fallback_depth&&(F=a.fallback_depth,
|
1 |
/*Source: custom-menu-wizard.js
|
2 |
+
*Compiled: 2014-10-16, Google Closure Compiler...
|
3 |
*STATISTICS
|
4 |
+
* - originalSize: 75825
|
5 |
+
* - originalGzipSize: 19193
|
6 |
+
* - compressedSize: 26173
|
7 |
+
* - compressedGzipSize: 8395
|
8 |
*/
|
9 |
jQuery(function(g){var w,K=/(\w+)\s*=\s*"([^"]*)"(?:\s|$)|(\w+)\s*=\s*\'([^\']*)\'(?:\s|$)|(\w+)\s*=\s*([^\s\'"]+)(?:\s|$)/g,u=function(b,a){return(a?".":"")+"widget-custom-menu-wizard-"+b},z=function(b){var a=g(this).data().cmwDialogVersion.replace(/\./g,""),a=/^\d+$/.test(a)?"v"+a:a;w[a]?w[a].update(b?b.target:this):w.update(b?b.target:this)},B=function(b,a){var c=!1===b,d=c?{}:b.data(),e={},l=!c&&"2.1.0"===d.cmwDialogVersion,f={items:1,exclude:1},m=g.extend({branch_start:1,exclude_level:1,include_level:1},
|
10 |
f);g.each(c?a:b.find(":input").serializeArray(),function(a,b){var h=b.name.replace(/.*\[([^\]]+)\]$/,"$1"),p=!m[h]&&/^-?\d+$/.test(b.value)?parseInt(b.value,10):b.value;e[h]=p;"hide_empty"===h?e[h]=c||!!d.cmwV36plus||p:f[h]&&(e["_"+h+"_sep"]=!p||/(^\d+\+?$|,)/.test(g.trim(p))?",":" ",p=g.map(p.split(/[,\s]+/),function(a){var b=!l&&/\+$/.test(a);a=a?parseInt(a,10):0;return isNaN(a)||1>a?null:b?a+"+":a}),e["_"+h]=p.join(e["_"+h+"_sep"]))});return e},C=function(b,a,c,d){var e=d.switch_if;return d.switch_at===
|
32 |
g(this),c=b.find("option"),d=(c.length-1)/3,m=b.val(),q=c.eq(2).text(),s=c.eq(3).text();for(c.slice(3*a+1).remove();d<a;)++d,b.append(g("<option/>",{value:d}).text(d)).append(g("<option/>",{value:d+"-"}).text(q.replace(/\d+/,d))).append(g("<option/>",{value:d+"+"}).text(s.replace(/\d+/,d)));parseInt(m,10)>a&&b.val("")});b.find(".cmw-set-levels").each(function(){var b=g(this),c=b.data(),d=c.cmwTextLevels||"",c=c.cmwSetLevels||0,m=b.find("option"),q=m.length-c;b.val()>a&&b.val(m.eq(0).val());for(b.find("option").slice(c+
|
33 |
a).remove();q<a;)++q,b.append(g("<option/>",{value:q}).text(q+d))})}},setFields:function(b,a){var c=a.find(".cmw-bybranch"),d=a.find(".cmw-byitems").prop("checked"),e=d||!c.prop("checked"),l=a.find(".cmw-assist-items"),f=parseInt(l.val(),10);b.hasClass("cmw-select-menu")?(f=O(l,f,b[0].selectedIndex),this.setLevels(a,(l.find("optgroup").data()||{}).cmwMaxLevel)):b.hasClass("cmw-level")?(e=!0,d=!e,a.find(".cmw-bylevel").prop("checked",e)):b.is(l)?(e=d=!1,c.prop("checked",!e)):b.hasClass("cmw-setitems")?
|
34 |
(e=d=!0,a.find(".cmw-byitems").prop("checked",d)):b.hasClass("cmw-ancestors")&&"0"===b.val()?a.find(".cmw-ancestor-siblings").val("0"):b.hasClass("cmw-ancestor-siblings")&&"0"!==b.val()&&"0"===a.find(".cmw-ancestors").val()&&a.find(".cmw-ancestors").val(b.val());c=a.find(".cmw-fallback").val();g.each({"-ss":d,"-ud":d||1>a.find(".cmw-depth").val(),"not-br":e,"not-br-ci":e||!!f,"not-fb-pc":e||!!f||"parent"!==c&&"current"!==c,"not-sw":!!a.find(".cmw-switchable").filter(function(){return!g(this).val()}).length},
|
35 |
+
function(b,c){a.find(".cmw-disableif"+b).toggleClass("cmw-colour-grey",c)})},shortcode:function(b){var a={menu:b.menu},c="branch"===b.filter,d="items"===b.filter,e,l;b.title&&!b.hide_title&&(a.title=[b.title]);!c&&!d&&1<b.level&&(a.level=b.level);c&&(a.branch=b.branch||"current",b.branch_start&&(a.start_at=[b.branch_start]),"level"===b.start_mode&&(a.start_mode="level"),b.allow_all_root&&(a.allow_all_root=1));d&&(a.items=[b._items]);0<b.depth&&(a.depth=b.depth);b.depth_rel_current&&0<b.depth&&(a.depth_rel_current=
|
36 |
+
1);c&&!b.branch&&b.fallback&&(a.fallback=[b.fallback],"quit"!==b.fallback&&(b.fallback_siblings&&a.fallback.push("+siblings"),b.fallback_depth&&a.fallback.push(b.fallback_depth)));c&&b.ancestors&&(a.ancestors=b.ancestors,b.ancestor_siblings&&(a.ancestor_siblings=b.ancestor_siblings));b.include_level&&(a.include_level=[b.include_level]);b._exclude&&(a.exclude=[b._exclude]);b.exclude_level&&(a.exclude_level=[b.exclude_level]);d=[];b.title_from_current?d.push("current"):b.title_from_current_root&&d.push("current-root");
|
37 |
+
c&&b.title_from_branch?d.push("branch"):c&&b.title_from_branch_root&&d.push("branch-root");d.length&&(a.title_from=d);for(d in{siblings:1,flat_output:1,ol_root:1,ol_sub:1,fallback_ci_parent:1})b[d]&&(a[d]=1);c={contains_current:"",container:"div",container_id:"",container_class:"",menu_class:"menu-widget",widget_class:""};for(d in c)b[d]!==c[d]&&(a[d]=[b[d]]);c={wrap_link:"before",wrap_link_text:"link_before"};for(d in c)(e=b[c[d]].toString().match(/^<(\w+)/))&&e[1]&&(a[d]=[e[1]]);b.switch_if&&b.switch_at&&
|
38 |
(a.alternative=[b.switch_if,b.switch_at],l=L(b.switch_to));c=[];for(d in a)c.push(g.isArray(a[d])?d+'="'+a[d].join(",")+'"':d+"="+a[d]);return"[cmwizard "+c.join(" ")+(l?"]"+l+"[/cmwizard]":"/]")},structureUpdate:function(b,a,c){var d=-1,e=9999,l=0,f=0,m="",q=null,s,h,p,n,t="menu",r="branch"===a.filter,u="items"===a.filter,x=!r&&!u,w=r&&!a.branch,E=!c&&!!a.switch_if&&!!a.switch_at,A=b.find(".cmw-demo-themenu-ul"),y=A.data().maxLevel,v=A.find(".current-menu-item").closest("li"),G=v.length?v.data().level:
|
39 |
-1,k=A.find("li").removeData("included").removeClass("title-from-item"),F=a.depth,z=a.depth_rel_current,B=H(k,a,"cross");h=k.length&&v.is(k);a.contains_current!==t||h||(k=g([]));if(E&&C(t,h,k.length,a)&&(q=D(a,b),!1!==q))return q;t="primary";u&&k.length&&(k=H(k,a,"tick"));r&&k.length&&(p=w?v:k.filter("[data-itemid="+a.branch+"]"),p.length?(d=p.data().level||0,k=p.add(p.find("li")),s=p):k=g([]));if(x&&k.length&&1<a.level){h=1;for(n=[];h<a.level;h++)n.push(".level-"+h);k=k.not(n.join(","))}h=k.length&&
|
40 |
v.is(k);a.contains_current!==t||h||(k=g([]));if(E&&C(t,h,k.length,a)&&(q=D(a,b),!1!==q))return q;t="secondary";if(x&&k.length&&F&&(h=z&&G>=a.level?G:a.level,h+=F,h<=y)){for(n=[];h<=y;h++)n.push(".level-"+h);k=k.not(n.join(","))}if(r&&k.length&&(n=parseInt(a.branch_start,10),n=isNaN(n)||!n?d:a.branch_start.match(/^(\+|-)/)?Math.max(1,d+n):n,w&&a.fallback&&!v.find("li").length&&(m="cmw-fellback-to-"+a.fallback,"quit"===a.fallback?n=y+1:(n="current"===a.fallback||2>d?d:d-1,a.fallback_depth&&(F=a.fallback_depth,
|
custom-menu-wizard.php
CHANGED
@@ -3,13 +3,17 @@
|
|
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.1.
|
7 |
* Author: Roger Barrett
|
8 |
* Author URI: http://www.wizzud.com/
|
9 |
* License: GPL2+
|
10 |
*/
|
11 |
defined( 'ABSPATH' ) or exit();
|
12 |
/*
|
|
|
|
|
|
|
|
|
13 |
* v3.1.0 change log
|
14 |
* - added an Alternative section which takes a cmwizard shortcode and conditionally applies it as an entirely new widget configuration
|
15 |
* - added fallback determination (has to be enabled) for no current item found as using items marked as current_item_parent (first found)
|
@@ -139,8 +143,9 @@ if( !class_exists( 'Custom_Menu_Wizard_Plugin' ) ){
|
|
139 |
//declare the main plugin class...
|
140 |
class Custom_Menu_Wizard_Plugin {
|
141 |
|
142 |
-
public static $version = '3.1.
|
143 |
public static $script_handle = 'custom-menu-wizard-plugin-script';
|
|
|
144 |
protected static $instance;
|
145 |
|
146 |
/**
|
@@ -404,7 +409,7 @@ if( !class_exists( 'Custom_Menu_Wizard_Plugin' ) ){
|
|
404 |
public function widget_and_shortcode(){
|
405 |
|
406 |
//register the widget class...
|
407 |
-
register_widget(
|
408 |
//add shortcode...
|
409 |
add_shortcode( 'cmwizard', array( &$this, 'shortcode' ) );
|
410 |
//add shortcode, v2.1.0 version (deprecated!)...
|
@@ -486,6 +491,25 @@ if( !class_exists( 'Custom_Menu_Wizard_Plugin' ) ){
|
|
486 |
}
|
487 |
|
488 |
if( $ok ){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
489 |
//handle widget_class here because we have full control over $before_widget...
|
490 |
$before_widget_class = array(
|
491 |
'widget_custom_menu_wizard',
|
@@ -524,10 +548,10 @@ if( !class_exists( 'Custom_Menu_Wizard_Plugin' ) ){
|
|
524 |
'after_title' => '</' . $instance['title_tag'] . '>'
|
525 |
);
|
526 |
unset( $instance['title_tag'] );
|
527 |
-
|
528 |
ob_start();
|
529 |
the_widget(
|
530 |
-
|
531 |
apply_filters(
|
532 |
'custom_menu_wizard_shortcode_settings',
|
533 |
array_merge( $instance, array('cmwv' => self::$version) )
|
@@ -620,7 +644,7 @@ if( !class_exists( 'Custom_Menu_Wizard_Plugin' ) ){
|
|
620 |
);
|
621 |
|
622 |
//if not decoding a main shortcode then we're looking at an alternative, and alternatives can't be
|
623 |
-
//nested,
|
624 |
if( !$doShortcode ){
|
625 |
unset( $instance['findme'], $instance['title_tag'], $instance['alternative'] );
|
626 |
}
|
@@ -797,7 +821,8 @@ if( !class_exists( 'Custom_Menu_Wizard_Plugin' ) ){
|
|
797 |
*/
|
798 |
public function encode_shortcode( $shortcode = '' ){
|
799 |
|
800 |
-
if(
|
|
|
801 |
$instance = $this->shortcode_instance( shortcode_parse_atts( trim( $m[1] ) ), 'cmwizard' );
|
802 |
if( !empty( $instance ) ){
|
803 |
$instance['cmwv'] = self::$version;
|
@@ -808,6 +833,19 @@ if( !class_exists( 'Custom_Menu_Wizard_Plugin' ) ){
|
|
808 |
|
809 |
} //end encode_shortcode()
|
810 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
811 |
/**
|
812 |
* shortcode processing for [custom_menu_wizard option="" option="" ...] (as of v2.1.0)
|
813 |
* see wp-includes/widgets.php for the_widget() code
|
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.1.1
|
7 |
* Author: Roger Barrett
|
8 |
* Author URI: http://www.wizzud.com/
|
9 |
* License: GPL2+
|
10 |
*/
|
11 |
defined( 'ABSPATH' ) or exit();
|
12 |
/*
|
13 |
+
* v3.1.1 change log
|
14 |
+
* - fixed bug : only show the allow_all_root setting in the shortcode equivalent if the primary filter is by branch
|
15 |
+
* - added work-around for occasions when a theme causes de-registration of the widget which prevents the shortcode working in content
|
16 |
+
*
|
17 |
* v3.1.0 change log
|
18 |
* - added an Alternative section which takes a cmwizard shortcode and conditionally applies it as an entirely new widget configuration
|
19 |
* - added fallback determination (has to be enabled) for no current item found as using items marked as current_item_parent (first found)
|
143 |
//declare the main plugin class...
|
144 |
class Custom_Menu_Wizard_Plugin {
|
145 |
|
146 |
+
public static $version = '3.1.1';
|
147 |
public static $script_handle = 'custom-menu-wizard-plugin-script';
|
148 |
+
public static $widget_class = 'Custom_Menu_Wizard_Widget';
|
149 |
protected static $instance;
|
150 |
|
151 |
/**
|
409 |
public function widget_and_shortcode(){
|
410 |
|
411 |
//register the widget class...
|
412 |
+
register_widget( self::$widget_class );
|
413 |
//add shortcode...
|
414 |
add_shortcode( 'cmwizard', array( &$this, 'shortcode' ) );
|
415 |
//add shortcode, v2.1.0 version (deprecated!)...
|
491 |
}
|
492 |
|
493 |
if( $ok ){
|
494 |
+
|
495 |
+
//if widget isn't registered(!), try re-registering; if still not registered, cop out...
|
496 |
+
if( !$this->widget_registered() ){
|
497 |
+
if( did_action( 'widgets_init' ) > 0 ){
|
498 |
+
if( apply_filters( 'custom_menu_wizard_widget_reregister', true ) ){
|
499 |
+
//re-register the widget...
|
500 |
+
register_widget( self::$widget_class );
|
501 |
+
if( !$this->widget_registered() ){
|
502 |
+
return WP_DEBUG ? __('[cmwizard PROBLEM="widget de-registered, and failed to re-register!"/]') : $html;
|
503 |
+
}
|
504 |
+
}else{
|
505 |
+
return WP_DEBUG ? __('[cmwizard PROBLEM="widget de-registered, and not allowed to re-register!"/]') : $html;
|
506 |
+
}
|
507 |
+
}else{
|
508 |
+
//hasn't had a chance to register yet!...
|
509 |
+
return WP_DEBUG ? __('[cmwizard PROBLEM="widgets have not been initialised yet!"/]') : $html;
|
510 |
+
}
|
511 |
+
}
|
512 |
+
|
513 |
//handle widget_class here because we have full control over $before_widget...
|
514 |
$before_widget_class = array(
|
515 |
'widget_custom_menu_wizard',
|
548 |
'after_title' => '</' . $instance['title_tag'] . '>'
|
549 |
);
|
550 |
unset( $instance['title_tag'] );
|
551 |
+
|
552 |
ob_start();
|
553 |
the_widget(
|
554 |
+
self::$widget_class,
|
555 |
apply_filters(
|
556 |
'custom_menu_wizard_shortcode_settings',
|
557 |
array_merge( $instance, array('cmwv' => self::$version) )
|
644 |
);
|
645 |
|
646 |
//if not decoding a main shortcode then we're looking at an alternative, and alternatives can't be
|
647 |
+
//nested, nor can they run findme or change the title's tag element...
|
648 |
if( !$doShortcode ){
|
649 |
unset( $instance['findme'], $instance['title_tag'], $instance['alternative'] );
|
650 |
}
|
821 |
*/
|
822 |
public function encode_shortcode( $shortcode = '' ){
|
823 |
|
824 |
+
if( class_exists( self::$widget_class ) &&
|
825 |
+
preg_match( '/^cmwizard\s?(.*)$/', rtrim( ltrim( $shortcode, '[ ' ), '] /' ), $m ) > 0 ){
|
826 |
$instance = $this->shortcode_instance( shortcode_parse_atts( trim( $m[1] ) ), 'cmwizard' );
|
827 |
if( !empty( $instance ) ){
|
828 |
$instance['cmwv'] = self::$version;
|
833 |
|
834 |
} //end encode_shortcode()
|
835 |
|
836 |
+
/**
|
837 |
+
* checks that the widget is registered
|
838 |
+
*
|
839 |
+
* @return boolean True if registered
|
840 |
+
*/
|
841 |
+
public function widget_registered(){
|
842 |
+
global $wp_widget_factory;
|
843 |
+
|
844 |
+
return ( isset( $wp_widget_factory->widgets[ self::$widget_class ] ) &&
|
845 |
+
is_a( $wp_widget_factory->widgets[ self::$widget_class ], self::$widget_class ) );
|
846 |
+
|
847 |
+
}
|
848 |
+
|
849 |
/**
|
850 |
* shortcode processing for [custom_menu_wizard option="" option="" ...] (as of v2.1.0)
|
851 |
* see wp-includes/widgets.php for the_widget() code
|
include/class.widget.php
CHANGED
@@ -1462,6 +1462,14 @@ class Custom_Menu_Wizard_Widget extends WP_Widget {
|
|
1462 |
if( $instance['start_mode'] == 'level' ){
|
1463 |
$args['start_mode'] = 'level';
|
1464 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1465 |
}
|
1466 |
//specifying items set byItems, overriding byLevel & byBranch...
|
1467 |
if( $byItems ){
|
@@ -1526,7 +1534,7 @@ class Custom_Menu_Wizard_Widget extends WP_Widget {
|
|
1526 |
$args['title_from'] = $n;
|
1527 |
}
|
1528 |
//switches...
|
1529 |
-
foreach( array('
|
1530 |
if( $instance[ $n ] ){
|
1531 |
$args[ $n ] = 1;
|
1532 |
}
|
1462 |
if( $instance['start_mode'] == 'level' ){
|
1463 |
$args['start_mode'] = 'level';
|
1464 |
}
|
1465 |
+
//allow_all_root is only applicable to byBranch...
|
1466 |
+
//NB this could be refined further, in that it only comes into play if
|
1467 |
+
// (a) start_mode is set to level, or
|
1468 |
+
// (b) there is a no-kids fallback set that produces output AND asks for siblings
|
1469 |
+
//but that gets a bit fussy so I'm leaving it as-is.
|
1470 |
+
if( $instance['allow_all_root'] ){
|
1471 |
+
$args['allow_all_root'] = 1;
|
1472 |
+
}
|
1473 |
}
|
1474 |
//specifying items set byItems, overriding byLevel & byBranch...
|
1475 |
if( $byItems ){
|
1534 |
$args['title_from'] = $n;
|
1535 |
}
|
1536 |
//switches...
|
1537 |
+
foreach( array('siblings', 'flat_output', 'ol_root', 'ol_sub', 'fallback_ci_parent') as $n ){
|
1538 |
if( $instance[ $n ] ){
|
1539 |
$args[ $n ] = 1;
|
1540 |
}
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
|
|
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.1.
|
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.
|
@@ -769,6 +769,10 @@ Note that output from this shortcode extension is restricted to users with edit_
|
|
769 |
|
770 |
== Changelog ==
|
771 |
|
|
|
|
|
|
|
|
|
772 |
= 3.1.0 =
|
773 |
* addition : new Alternative section which takes a cmwizard shortcode and conditionally applies it as an entirely new widget configuration
|
774 |
* addition : new fallback switch which enables an item marked as current_item_parent to be used as current item when no other current item is found
|
@@ -895,6 +899,10 @@ Note that output from this shortcode extension is restricted to users with edit_
|
|
895 |
|
896 |
== Upgrade Notice ==
|
897 |
|
|
|
|
|
|
|
|
|
898 |
= 3.1.0 =
|
899 |
Added an Alternative section which gives a dual-scenario capability, such as "show Config A, but if a current item is present then show Config B"
|
900 |
Added a new option to enable a "last resort" determination of current item as being an item marked as the parent of a current item, even though no current item is actually present.
|
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.1.1
|
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.
|
769 |
|
770 |
== Changelog ==
|
771 |
|
772 |
+
= 3.1.1 =
|
773 |
+
* bugfix : only show the allow_all_root setting in the shortcode equivalent if the primary filter is by branch
|
774 |
+
* addition : work-around for when a theme inadvertently(!) de-registers the widget, which then prevents the shortcode working
|
775 |
+
|
776 |
= 3.1.0 =
|
777 |
* addition : new Alternative section which takes a cmwizard shortcode and conditionally applies it as an entirely new widget configuration
|
778 |
* addition : new fallback switch which enables an item marked as current_item_parent to be used as current item when no other current item is found
|
899 |
|
900 |
== Upgrade Notice ==
|
901 |
|
902 |
+
= 3.1.1 =
|
903 |
+
Added a work-around for when a theme inadvertently(!) de-registers the widget, which then prevents the shortcode working.
|
904 |
+
Fixed a trivial bug where the allow_all_root setting was being unnecessarily shown in the widget's shortcode equivalent.
|
905 |
+
|
906 |
= 3.1.0 =
|
907 |
Added an Alternative section which gives a dual-scenario capability, such as "show Config A, but if a current item is present then show Config B"
|
908 |
Added a new option to enable a "last resort" determination of current item as being an item marked as the parent of a current item, even though no current item is actually present.
|