Version Description
Download this release
Release Info
Developer | Mat Lipe |
Plugin | Advanced Sidebar Menu |
Version | 3.4.1 |
Comparing to | |
See all releases |
Code changes from version 3.2.5 to 3.4.1
- advanced-sidebar-menu.php +4 -8
- functions.php +164 -45
- readme.txt +9 -3
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
- views/category_list.php +29 -41
- views/page_list.php +21 -38
- widgets/category.widget.php +23 -11
- widgets/page.widget.php +42 -17
advanced-sidebar-menu.php
CHANGED
@@ -4,27 +4,23 @@ Plugin Name: Advanced Sidebar Menu
|
|
4 |
Plugin URI: http://lipeimagination.info/wordpress/advanced-sidebar-menu/
|
5 |
Description: Creates dynamic menu based on child/parent relationship.
|
6 |
Author: Mat Lipe
|
7 |
-
Version: 3.
|
8 |
Author URI: http://lipeimagination.info
|
9 |
-
Since:
|
10 |
Email: mat@lipeimagination.info
|
11 |
-
|
12 |
*/
|
13 |
|
14 |
-
|
15 |
#-- Bring in the functions
|
16 |
require( 'functions.php' );
|
17 |
$asm = new advanced_sidebar_menu_functions();
|
18 |
|
19 |
-
|
20 |
-
add_action( 'init', array( $asm, '
|
21 |
-
|
22 |
|
23 |
|
24 |
#-- Bring in the Widgets
|
25 |
require( 'widgets/init.php' );
|
26 |
|
27 |
-
|
28 |
#-- Define Constants
|
29 |
define( 'ADVANCED_SIDEBAR_WIDGETS_DIR', plugin_dir_path(__FILE__) . 'widgets/' );
|
30 |
define( 'ADVANCED_SIDEBAR_VIEWS_DIR', plugin_dir_path(__FILE__) . 'views/' );
|
4 |
Plugin URI: http://lipeimagination.info/wordpress/advanced-sidebar-menu/
|
5 |
Description: Creates dynamic menu based on child/parent relationship.
|
6 |
Author: Mat Lipe
|
7 |
+
Version: 3.4.0
|
8 |
Author URI: http://lipeimagination.info
|
9 |
+
Since: 10.5.12
|
10 |
Email: mat@lipeimagination.info
|
|
|
11 |
*/
|
12 |
|
|
|
13 |
#-- Bring in the functions
|
14 |
require( 'functions.php' );
|
15 |
$asm = new advanced_sidebar_menu_functions();
|
16 |
|
17 |
+
//Validate the new version
|
18 |
+
add_action( 'init', array( $asm, 'validate_3_3' ) );
|
|
|
19 |
|
20 |
|
21 |
#-- Bring in the Widgets
|
22 |
require( 'widgets/init.php' );
|
23 |
|
|
|
24 |
#-- Define Constants
|
25 |
define( 'ADVANCED_SIDEBAR_WIDGETS_DIR', plugin_dir_path(__FILE__) . 'widgets/' );
|
26 |
define( 'ADVANCED_SIDEBAR_VIEWS_DIR', plugin_dir_path(__FILE__) . 'views/' );
|
functions.php
CHANGED
@@ -4,68 +4,53 @@
|
|
4 |
/**
|
5 |
* These Functions are Specific to the Advanced Sidebar Menu
|
6 |
* @author Mat Lipe
|
7 |
-
* @since
|
8 |
*/
|
9 |
|
10 |
|
11 |
|
12 |
class advanced_sidebar_menu_functions{
|
13 |
-
protected $bad = array(); //for 3.
|
14 |
-
protected $
|
15 |
|
16 |
|
17 |
/**
|
18 |
* Validate the views for the new structure
|
19 |
-
* @since
|
20 |
*/
|
21 |
-
function
|
22 |
-
|
23 |
-
|
24 |
/** Note to self -- Remove this at the new version **/
|
25 |
-
if ( $
|
26 |
-
|
27 |
-
$data = explode("\n", file_get_contents( $cat_file )); //create array separate by new line
|
28 |
-
|
29 |
-
//print_r( $data );
|
30 |
-
|
31 |
foreach( $data as $line => $content ){
|
32 |
-
|
33 |
$line++;
|
34 |
-
|
35 |
-
if( strpos( $content, " class=\"advanced-sidebar-menu widget advanced-sidebar-category\">" ) ){
|
36 |
$bad[$line] = htmlentities( $content );
|
37 |
}
|
38 |
-
|
39 |
-
if( strpos( $content, "<div class=\"widget-wrap\">';" ) ){
|
40 |
$bad[$line] = htmlentities( $content );
|
41 |
}
|
42 |
-
|
43 |
-
|
44 |
-
if( strpos( $content, "</div></div><!-- END #advanced-sidebar-cat-menu -->';" ) ){
|
45 |
|
46 |
$bad[$line] = htmlentities( $content );
|
47 |
}
|
48 |
-
|
49 |
}
|
50 |
-
|
51 |
if( !empty( $bad ) ){
|
52 |
$this->bad = $bad;
|
53 |
-
$this->
|
54 |
-
add_action( 'admin_notices', array( $this, '
|
55 |
}
|
56 |
-
|
57 |
}
|
58 |
-
|
59 |
}
|
60 |
|
61 |
|
62 |
/**
|
63 |
* Adds an admin notice if there are issues with the view
|
64 |
-
* @since
|
65 |
*/
|
66 |
-
function
|
67 |
echo '<div class="error">';
|
68 |
-
echo 'To use version 3.
|
69 |
|
70 |
foreach( $this->bad as $line => $content ){
|
71 |
echo '<b>line' . $line . ': </b> '. $content . '<br>';
|
@@ -74,26 +59,160 @@ function notice_3_2( ){
|
|
74 |
echo '</div>';
|
75 |
|
76 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
|
78 |
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
* @since 6/3/12
|
85 |
-
*/
|
86 |
|
87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
|
89 |
-
if ( $theme_file = locate_template(array('advanced-sidebar-menu/'.$file)) ) {
|
90 |
-
$file = $theme_file;
|
91 |
-
} else {
|
92 |
-
$file = ADVANCED_SIDEBAR_VIEWS_DIR . $file;
|
93 |
}
|
94 |
-
return $file;
|
95 |
-
|
96 |
-
}
|
97 |
|
98 |
} //End class
|
99 |
|
4 |
/**
|
5 |
* These Functions are Specific to the Advanced Sidebar Menu
|
6 |
* @author Mat Lipe
|
7 |
+
* @since 10.5.12
|
8 |
*/
|
9 |
|
10 |
|
11 |
|
12 |
class advanced_sidebar_menu_functions{
|
13 |
+
protected $bad = array(); //for 3.3 version
|
14 |
+
protected $bad_file = ''; //for 3.3 version
|
15 |
|
16 |
|
17 |
/**
|
18 |
* Validate the views for the new structure
|
19 |
+
* @since 7/16/12
|
20 |
*/
|
21 |
+
function validate_3_3(){
|
|
|
|
|
22 |
/** Note to self -- Remove this at the new version **/
|
23 |
+
if ( $page_file = locate_template(array('advanced-sidebar-menu/page_list.php')) ) {
|
24 |
+
$data = explode("\n", file_get_contents( $page_file )); //create array separate by new line
|
|
|
|
|
|
|
|
|
25 |
foreach( $data as $line => $content ){
|
|
|
26 |
$line++;
|
27 |
+
if( strpos( $content, 'class="advanced-sidebar-menu widget advanced-sidebar-page">' ) ){
|
|
|
28 |
$bad[$line] = htmlentities( $content );
|
29 |
}
|
30 |
+
if( strpos( $content, "<div class=\"widget-wrap\">" ) ){
|
|
|
31 |
$bad[$line] = htmlentities( $content );
|
32 |
}
|
33 |
+
if( strpos( $content, "</div></div><!-- end of very-custom-menu -->" ) ){
|
|
|
|
|
34 |
|
35 |
$bad[$line] = htmlentities( $content );
|
36 |
}
|
|
|
37 |
}
|
|
|
38 |
if( !empty( $bad ) ){
|
39 |
$this->bad = $bad;
|
40 |
+
$this->bad_file = get_bloginfo( 'stylesheet_directory' ) . '/advanced-sidebar-menu/page_list.php';
|
41 |
+
add_action( 'admin_notices', array( $this, 'notice_3_3') );
|
42 |
}
|
|
|
43 |
}
|
|
|
44 |
}
|
45 |
|
46 |
|
47 |
/**
|
48 |
* Adds an admin notice if there are issues with the view
|
49 |
+
* @since 7/16/12
|
50 |
*/
|
51 |
+
function notice_3_3( ){
|
52 |
echo '<div class="error">';
|
53 |
+
echo 'To use version 3.3 of <b>Advanced Sidebar Menu</b> you must delete the following lines from <b>"' . $this->bad_file . '"</b><br>';
|
54 |
|
55 |
foreach( $this->bad as $line => $content ){
|
56 |
echo '<b>line' . $line . ': </b> '. $content . '<br>';
|
59 |
echo '</div>';
|
60 |
|
61 |
}
|
62 |
+
|
63 |
+
|
64 |
+
|
65 |
+
|
66 |
+
|
67 |
+
private $instance; //The widget instance
|
68 |
+
private $top_id; //Either the top cat or page
|
69 |
+
private $exclude;
|
70 |
+
private $ancestors; //For the category ancestors
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Sets the instance of this widget to this class
|
74 |
+
* @param array $instance the widgets instance
|
75 |
+
* @since 7/16/12
|
76 |
+
*/
|
77 |
+
function set_widget_vars( $instance, $top_id, $exclude, $ancestors = array() ){
|
78 |
+
$this->instance = $instance;
|
79 |
+
$this->top_id = $top_id;
|
80 |
+
$this->exclude = $exclude;
|
81 |
+
$this->ancestors = $ancestors;
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
*
|
86 |
+
* IF this is a top level category
|
87 |
+
* @param obj $cat the cat object
|
88 |
+
*/
|
89 |
+
function first_level_category( $cat ){
|
90 |
+
if( !in_array($cat->cat_ID, $this->exclude) && $cat->parent == $this->top_id){
|
91 |
+
return true;
|
92 |
+
} else {
|
93 |
+
return false;
|
94 |
+
}
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* If the cat is a second level cat
|
99 |
+
* @param obj $cat the cat
|
100 |
+
* @since 7/16/12
|
101 |
+
*/
|
102 |
+
function second_level_cat( $cat ){
|
103 |
+
//if this is the currrent cat or a parent of the current cat
|
104 |
+
if( $cat->cat_ID == get_query_var('cat' ) || in_array( $cat->cat_ID, $this->ancestors )){
|
105 |
+
$all_children = array();
|
106 |
+
$all_children = get_categories( array( 'child_of' => $child_cat->cat_ID ) );
|
107 |
+
if( !empty( $all_children ) ){
|
108 |
+
return true;
|
109 |
+
} else {
|
110 |
+
return false;
|
111 |
+
}
|
112 |
+
|
113 |
+
} else {
|
114 |
+
return false;
|
115 |
+
}
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Determines if all the children should be included
|
120 |
+
* @since 7/16/12
|
121 |
+
* @return bool
|
122 |
+
*/
|
123 |
+
function display_all(){
|
124 |
+
if( $this->instance['display_all'] == 'checked' ){
|
125 |
+
return true;
|
126 |
+
} else {
|
127 |
+
return false;
|
128 |
+
}
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
*
|
133 |
+
* Returns and array of all the children of a page
|
134 |
+
* @param int $pID the id of the page
|
135 |
+
* @since 10.5.12
|
136 |
+
*/
|
137 |
+
function page_children( $pID ){
|
138 |
+
global $wpdb, $table_prefix;
|
139 |
+
return $wpdb->get_results( "SELECT ID FROM ".$table_prefix."posts WHERE post_parent = ".$pID." AND post_status='publish'" );
|
140 |
+
|
141 |
+
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
*
|
145 |
+
* Determines if this is an ancestor or the current post
|
146 |
+
* @param obj $pID the post object
|
147 |
+
* @since 7/19/12
|
148 |
+
*/
|
149 |
+
function page_ancestor( $pID ){
|
150 |
+
global $post;
|
151 |
+
if($pID->ID == $post->ID or $pID->ID == $post->post_parent or @in_array($pID->ID, $post->ancestors) ){
|
152 |
+
return true;
|
153 |
+
} else {
|
154 |
+
return false;
|
155 |
+
}
|
156 |
+
}
|
157 |
+
|
158 |
+
|
159 |
+
/**
|
160 |
+
* Determines if the parent page or cat should be included
|
161 |
+
* @since 7/16/12
|
162 |
+
* @return bool
|
163 |
+
*/
|
164 |
+
function include_parent(){
|
165 |
+
if( ($this->instance['include_parent'] == 'checked') && (!in_array($this->top_id, $this->exclude)) ){
|
166 |
+
return true;
|
167 |
+
} else {
|
168 |
+
return false;
|
169 |
+
}
|
170 |
+
}
|
171 |
+
|
172 |
+
|
173 |
+
/**
|
174 |
+
* Echos the title of the widget to the page
|
175 |
+
* @since 7/16/12
|
176 |
+
*/
|
177 |
+
function title(){
|
178 |
+
if( $this->instance['title'] != '' ){
|
179 |
+
echo '<h4 class="widgettitle">' . $this->instance['title'] . '</h4>';
|
180 |
+
}
|
181 |
+
|
182 |
+
}
|
183 |
+
|
184 |
+
|
185 |
+
/**
|
186 |
+
*
|
187 |
+
* Checks is this id is excluded or not
|
188 |
+
* @param int $id the id to check
|
189 |
+
* @return bool
|
190 |
+
*/
|
191 |
+
function exclude( $id ){
|
192 |
+
if( !in_array( $id, $this->exclude ) ){
|
193 |
+
return true;
|
194 |
+
} else {
|
195 |
+
return false;
|
196 |
+
}
|
197 |
+
}
|
198 |
+
|
199 |
|
200 |
|
201 |
+
/**
|
202 |
+
* Allows for Overwritting files in the child theme
|
203 |
+
* @since 6/3/12
|
204 |
+
* @param string $file the name of the file to overwrite
|
205 |
+
*/
|
|
|
|
|
206 |
|
207 |
+
static function file_hyercy( $file ){
|
208 |
+
if ( $theme_file = locate_template(array('advanced-sidebar-menu/'.$file)) ) {
|
209 |
+
$file = $theme_file;
|
210 |
+
} else {
|
211 |
+
$file = ADVANCED_SIDEBAR_VIEWS_DIR . $file;
|
212 |
+
}
|
213 |
+
return $file;
|
214 |
|
|
|
|
|
|
|
|
|
215 |
}
|
|
|
|
|
|
|
216 |
|
217 |
} //End class
|
218 |
|
readme.txt
CHANGED
@@ -3,9 +3,9 @@ Contributors: Mat Lipe
|
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=paypal%40lipeimagination%2einfo&lc=US&item_name=Advanced%20Sidebar%20Menu&no_note=0¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHostedGuest
|
4 |
Tags: menus, sidebar menu, heirchy, category menu, pages menu
|
5 |
Requires at least: 3.1
|
6 |
-
Tested up to: 3.4.
|
7 |
-
Stable tag: 3.
|
8 |
-
Version: 3.
|
9 |
|
10 |
== Description ==
|
11 |
|
@@ -85,6 +85,12 @@ You may want to use something like margins to set the levels apart.
|
|
85 |
|
86 |
|
87 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
= 3.3.0 =
|
89 |
* Added the ability to have a widget title
|
90 |
* Redesigned the entire structure to prepare for future changes
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=paypal%40lipeimagination%2einfo&lc=US&item_name=Advanced%20Sidebar%20Menu&no_note=0¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHostedGuest
|
4 |
Tags: menus, sidebar menu, heirchy, category menu, pages menu
|
5 |
Requires at least: 3.1
|
6 |
+
Tested up to: 3.4.2
|
7 |
+
Stable tag: 3.4.1
|
8 |
+
Version: 3.4.1
|
9 |
|
10 |
== Description ==
|
11 |
|
85 |
|
86 |
|
87 |
== Changelog ==
|
88 |
+
= 3.4.0 =
|
89 |
+
* Added filter support for custom post types
|
90 |
+
|
91 |
+
= 3.3.1 =
|
92 |
+
* Added unlimited number of levels displayed once on the grandchild level of pages
|
93 |
+
|
94 |
= 3.3.0 =
|
95 |
* Added the ability to have a widget title
|
96 |
* Redesigned the entire structure to prepare for future changes
|
screenshot-1.png
DELETED
Binary file
|
screenshot-2.png
DELETED
Binary file
|
views/category_list.php
CHANGED
@@ -3,56 +3,52 @@
|
|
3 |
/**
|
4 |
* The Ouput of tad Advanced Sidebar Categories Widget
|
5 |
* @author Mat Lipe
|
6 |
-
* @since
|
7 |
*
|
8 |
*
|
9 |
* @uses to edit create a file named category_list.php and put in a folder in the your child theme called 'advanced-sidebar-menu
|
10 |
* @uses copy the contents of the file into that file and edit at will
|
11 |
-
* @param Do not edit this file or it will break on update
|
12 |
*/
|
13 |
|
14 |
|
|
|
|
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
}
|
24 |
-
|
25 |
-
if( !empty($all) ){
|
26 |
-
|
27 |
echo '<ul class="child-sidebar-menu">';
|
28 |
|
29 |
#-- If they want all the child categories displayed always
|
30 |
-
if( $
|
31 |
wp_list_categories('title_li=&child_of=' . $top_cat .'&depth=' .$instance['levels'] );
|
32 |
-
|
|
|
33 |
} else {
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
|
|
|
|
39 |
//List the child category and the children if it is the current one
|
40 |
wp_list_categories('title_li=&include=' . $child_cat->cat_ID . '&depth=1' );
|
41 |
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
$all_children = get_categories( array( 'child_of' => $child_cat->cat_ID ) );
|
46 |
-
|
47 |
-
if( !empty( $all_children ) ){
|
48 |
#-- Create a new menu with all the children under it
|
49 |
echo '<ul class="grandchild-sidebar-menu">';
|
50 |
-
|
51 |
-
wp_list_categories("title_li=&exclude=".$instance['exclude']."&depth=3&child_of=" .$child_cat->cat_ID );
|
52 |
-
|
53 |
echo '</ul>';
|
54 |
-
|
55 |
-
|
56 |
}
|
57 |
} //End foreach
|
58 |
|
@@ -60,18 +56,10 @@
|
|
60 |
|
61 |
} //End if display all is not checked
|
62 |
|
63 |
-
|
64 |
} //End if the are child categories
|
65 |
|
66 |
|
67 |
#-- if a parent category was displayed
|
68 |
-
if(
|
69 |
echo '</ul><!-- End #parent-sidebar-menu -->';
|
70 |
-
|
71 |
-
unset( $parent); //for next time
|
72 |
-
}
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
3 |
/**
|
4 |
* The Ouput of tad Advanced Sidebar Categories Widget
|
5 |
* @author Mat Lipe
|
6 |
+
* @since 7/16/12
|
7 |
*
|
8 |
*
|
9 |
* @uses to edit create a file named category_list.php and put in a folder in the your child theme called 'advanced-sidebar-menu
|
10 |
* @uses copy the contents of the file into that file and edit at will
|
11 |
+
* @param Do not edit this file in this location or it will break on update
|
12 |
*/
|
13 |
|
14 |
|
15 |
+
//Displays the title
|
16 |
+
$asm->title();
|
17 |
|
18 |
+
//Include the parent page if chosen
|
19 |
+
if( $asm->include_parent() ){
|
20 |
+
echo '<ul class="parent-sidebar-menu">';
|
21 |
+
wp_list_categories( 'title_li=&include=' . $top_cat);
|
22 |
+
}
|
23 |
+
//If there are children to display
|
24 |
+
if( !empty($all_categories) ){
|
|
|
|
|
|
|
|
|
25 |
echo '<ul class="child-sidebar-menu">';
|
26 |
|
27 |
#-- If they want all the child categories displayed always
|
28 |
+
if( $asm->display_all() ){
|
29 |
wp_list_categories('title_li=&child_of=' . $top_cat .'&depth=' .$instance['levels'] );
|
30 |
+
echo '</ul><!-- End #child-sidebar-menu -->';
|
31 |
+
|
32 |
} else {
|
33 |
+
|
34 |
+
#-- to Display the categories based a parent child relationship
|
35 |
+
foreach( $all_categories as $child_cat ){
|
36 |
+
|
37 |
+
//IF this is a child category of the top one
|
38 |
+
if( $asm->first_level_category( $child_cat ) ){
|
39 |
+
|
40 |
//List the child category and the children if it is the current one
|
41 |
wp_list_categories('title_li=&include=' . $child_cat->cat_ID . '&depth=1' );
|
42 |
|
43 |
+
|
44 |
+
//If there are children of this cat and it is a parent or child or the current cat
|
45 |
+
if( $asm->second_level_cat( $child_cat ) ){
|
|
|
|
|
|
|
46 |
#-- Create a new menu with all the children under it
|
47 |
echo '<ul class="grandchild-sidebar-menu">';
|
48 |
+
wp_list_categories("title_li=&exclude=".$instance['exclude']."&depth=3&child_of=" .$child_cat->cat_ID );
|
|
|
|
|
49 |
echo '</ul>';
|
50 |
+
|
51 |
+
}
|
52 |
}
|
53 |
} //End foreach
|
54 |
|
56 |
|
57 |
} //End if display all is not checked
|
58 |
|
|
|
59 |
} //End if the are child categories
|
60 |
|
61 |
|
62 |
#-- if a parent category was displayed
|
63 |
+
if( $asm->include_parent() ){
|
64 |
echo '</ul><!-- End #parent-sidebar-menu -->';
|
65 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
views/page_list.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
/**
|
6 |
* The Ouput of tad Advanced Sidebar Page Widget
|
7 |
* @author Mat Lipe
|
8 |
-
* @since
|
9 |
*
|
10 |
*
|
11 |
* @uses to edit, create a file named page_list.php and put in a folder in the your theme called 'advanced-sidebar-menu
|
@@ -13,56 +13,43 @@
|
|
13 |
* @uses Do not edit this file in its original location or it will break on upgrade
|
14 |
*/
|
15 |
|
|
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
#-- if the checkbox to include parent is checked
|
23 |
-
if( $instance['include_parent'] == 'checked' ){
|
24 |
-
echo '<ul class="parent-sidebar-menu" >';
|
25 |
-
|
26 |
-
#-- If the page is not excluded from the menu
|
27 |
-
if( !in_array($top_parent, $exclude) ){
|
28 |
-
#-- list the parent page
|
29 |
-
wp_list_pages("sort_column=menu_order&title_li=&echo=1&depth=1&include=".$top_parent);
|
30 |
-
}
|
31 |
-
|
32 |
-
}
|
33 |
-
|
34 |
-
|
35 |
|
36 |
|
37 |
//If there are children start the Child Sidebar Menu
|
38 |
-
if( $
|
39 |
echo '<ul class="child-sidebar-menu">';
|
40 |
|
41 |
#-- If they want all the pages displayed always
|
42 |
-
if( $
|
43 |
-
|
|
|
44 |
} else {
|
45 |
|
46 |
#-- Display children of current page's parent only
|
47 |
foreach($result as $pID){
|
48 |
|
49 |
#-- If the page is not in the excluded ones
|
50 |
-
if(
|
51 |
#--echo the current page from the $result
|
52 |
-
wp_list_pages("sort_column=menu_order&title_li=&echo=1&depth=1&include=".$pID->ID);
|
53 |
}
|
54 |
|
55 |
#-- if the link that was just listed is the current page we are on
|
56 |
-
if(
|
57 |
|
58 |
-
//
|
59 |
-
$grandkids = $
|
60 |
if( $grandkids ){
|
61 |
-
|
62 |
#-- Create a new menu with all the children under it
|
63 |
echo '<ul class="grandchild-sidebar-menu">';
|
64 |
-
|
65 |
-
wp_list_pages("sort_column=menu_order&title_li=&echo=1&exclude=".$instance['exclude']."&depth=3&child_of=".$pID->ID);
|
66 |
|
67 |
echo '</ul>';
|
68 |
}
|
@@ -74,14 +61,10 @@ if( $result != FALSE ){
|
|
74 |
echo '</ul><!-- End child-sidebar-menu -->';
|
75 |
|
76 |
}
|
|
|
|
|
|
|
|
|
77 |
|
78 |
|
79 |
-
#-- If there was a menu close it off
|
80 |
-
if($child_pages != false || ($instance['include_childless_parent'] == 'checked') ){
|
81 |
-
|
82 |
-
if( $instance['include_parent'] == 'checked' ) {
|
83 |
-
echo '</ul>';
|
84 |
-
}
|
85 |
-
echo '</div></div><!-- end of very-custom-menu -->';
|
86 |
-
}
|
87 |
|
5 |
/**
|
6 |
* The Ouput of tad Advanced Sidebar Page Widget
|
7 |
* @author Mat Lipe
|
8 |
+
* @since 10.05.12
|
9 |
*
|
10 |
*
|
11 |
* @uses to edit, create a file named page_list.php and put in a folder in the your theme called 'advanced-sidebar-menu
|
13 |
* @uses Do not edit this file in its original location or it will break on upgrade
|
14 |
*/
|
15 |
|
16 |
+
$asm->title();
|
17 |
|
18 |
+
#-- list the parent page if chosen
|
19 |
+
if( $asm->include_parent() ){
|
20 |
+
echo '<ul class="parent-sidebar-menu" >';
|
21 |
+
wp_list_pages("post_type=".$post_type."&sort_column=menu_order&title_li=&echo=1&depth=1&include=".$top_parent);
|
22 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
|
25 |
//If there are children start the Child Sidebar Menu
|
26 |
+
if( $child_pages ){
|
27 |
echo '<ul class="child-sidebar-menu">';
|
28 |
|
29 |
#-- If they want all the pages displayed always
|
30 |
+
if( $asm->display_all() ){
|
31 |
+
|
32 |
+
wp_list_pages("post_type=".$post_type."&sort_column=menu_order&title_li=&echo=1&child_of=".$top_parent."&depth=".$instance['levels']."&exclude=".$instance['exclude']);
|
33 |
} else {
|
34 |
|
35 |
#-- Display children of current page's parent only
|
36 |
foreach($result as $pID){
|
37 |
|
38 |
#-- If the page is not in the excluded ones
|
39 |
+
if( $asm->exclude( $pID->ID) ){
|
40 |
#--echo the current page from the $result
|
41 |
+
wp_list_pages("post_type=".$post_type."&sort_column=menu_order&title_li=&echo=1&depth=1&include=".$pID->ID);
|
42 |
}
|
43 |
|
44 |
#-- if the link that was just listed is the current page we are on
|
45 |
+
if( $asm->page_ancestor( $pID ) ){
|
46 |
|
47 |
+
//Get the children of this page
|
48 |
+
$grandkids = $asm->page_children($pID->ID );
|
49 |
if( $grandkids ){
|
|
|
50 |
#-- Create a new menu with all the children under it
|
51 |
echo '<ul class="grandchild-sidebar-menu">';
|
52 |
+
wp_list_pages("post_type=".$post_type."&sort_column=menu_order&title_li=&echo=1&exclude=".$instance['exclude']."&child_of=".$pID->ID);
|
|
|
53 |
|
54 |
echo '</ul>';
|
55 |
}
|
61 |
echo '</ul><!-- End child-sidebar-menu -->';
|
62 |
|
63 |
}
|
64 |
+
if( $asm->include_parent() ) {
|
65 |
+
echo '</ul><!-- .parent-sidebar-menu -->';
|
66 |
+
}
|
67 |
+
|
68 |
|
69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
|
widgets/category.widget.php
CHANGED
@@ -20,7 +20,9 @@ class advanced_sidebar_menu_category extends WP_Widget {
|
|
20 |
function form( $instance ) {
|
21 |
// require( ADVANCED_SIDEBAR_DIR . 'advanced-sidebar-menu.js' );
|
22 |
?>
|
23 |
-
|
|
|
|
|
24 |
|
25 |
|
26 |
<p> Include Parent Category <input id="<?php echo $this->get_field_name('include_parent'); ?>"
|
@@ -36,7 +38,7 @@ class advanced_sidebar_menu_category extends WP_Widget {
|
|
36 |
name="<?php echo $this->get_field_name('css'); ?>" type="checkbox" value="checked"
|
37 |
<?php echo $instance['css']; ?>/></p>
|
38 |
|
39 |
-
<p> Display Categories on Single
|
40 |
name="<?php echo $this->get_field_name('single'); ?>" type="checkbox" value="checked"
|
41 |
onclick="javascript:asm_reveal_element( 'new-widget-<?php echo $this->get_field_name('new_widget'); ?>' )"
|
42 |
<?php echo $instance['single']; ?>/></p>
|
@@ -105,6 +107,8 @@ class advanced_sidebar_menu_category extends WP_Widget {
|
|
105 |
$instance['css'] = strip_tags($new_instance['css']);
|
106 |
$instance['single'] = strip_tags($new_instance['single']); //Display on single pages
|
107 |
$instance['new_widget'] = strip_tags($new_instance['new_widget']); //Create a new widget for each single category
|
|
|
|
|
108 |
return $instance;
|
109 |
}
|
110 |
|
@@ -122,8 +126,14 @@ class advanced_sidebar_menu_category extends WP_Widget {
|
|
122 |
|
123 |
#---------------------------------------------------------------------------------------------------------------------------
|
124 |
|
125 |
-
|
|
|
|
|
|
|
|
|
126 |
function widget($args, $instance) {
|
|
|
|
|
127 |
#-- Create a usable array of the excluded pages
|
128 |
$exclude = explode(',', $instance['exclude']);
|
129 |
$cat_ids = $already_top = array();
|
@@ -181,18 +191,20 @@ class advanced_sidebar_menu_category extends WP_Widget {
|
|
181 |
|
182 |
|
183 |
//Check for children
|
184 |
-
$
|
185 |
-
|
|
|
|
|
186 |
|
187 |
//If there are any child categories or the include childless parent is checked
|
188 |
-
if( !empty($
|
189 |
|
190 |
|
191 |
//Creates a new widget for each category the single page has if the options are selected to do so
|
192 |
if( !$asm_once || ($instance['new_widget'] == 'widget') ){
|
193 |
|
194 |
-
|
195 |
-
|
196 |
|
197 |
$count++; // To change the id of the widget if there are multiple
|
198 |
$asm_once = true; //There has been a div
|
@@ -204,14 +216,14 @@ class advanced_sidebar_menu_category extends WP_Widget {
|
|
204 |
}
|
205 |
|
206 |
|
|
|
207 |
//Bring in the view
|
208 |
-
|
209 |
|
210 |
|
211 |
if( $close ){
|
212 |
//End the Widget Area
|
213 |
-
|
214 |
-
</div><!-- END #advanced-sidebar-cat-menu -->';
|
215 |
}
|
216 |
|
217 |
|
20 |
function form( $instance ) {
|
21 |
// require( ADVANCED_SIDEBAR_DIR . 'advanced-sidebar-menu.js' );
|
22 |
?>
|
23 |
+
<p> Title <br>
|
24 |
+
<input id="<?php echo $this->get_field_name('title'); ?>"
|
25 |
+
name="<?php echo $this->get_field_name('title'); ?>" size="50" type="text" value="<?php echo $instance['title']; ?>"/></p>
|
26 |
|
27 |
|
28 |
<p> Include Parent Category <input id="<?php echo $this->get_field_name('include_parent'); ?>"
|
38 |
name="<?php echo $this->get_field_name('css'); ?>" type="checkbox" value="checked"
|
39 |
<?php echo $instance['css']; ?>/></p>
|
40 |
|
41 |
+
<p> Display Categories on Single Posts <input id="<?php echo $this->get_field_name('single'); ?>"
|
42 |
name="<?php echo $this->get_field_name('single'); ?>" type="checkbox" value="checked"
|
43 |
onclick="javascript:asm_reveal_element( 'new-widget-<?php echo $this->get_field_name('new_widget'); ?>' )"
|
44 |
<?php echo $instance['single']; ?>/></p>
|
107 |
$instance['css'] = strip_tags($new_instance['css']);
|
108 |
$instance['single'] = strip_tags($new_instance['single']); //Display on single pages
|
109 |
$instance['new_widget'] = strip_tags($new_instance['new_widget']); //Create a new widget for each single category
|
110 |
+
$instance['title'] = strip_tags($new_instance['title']);
|
111 |
+
|
112 |
return $instance;
|
113 |
}
|
114 |
|
126 |
|
127 |
#---------------------------------------------------------------------------------------------------------------------------
|
128 |
|
129 |
+
/**
|
130 |
+
* Outputs the categories widget to the page
|
131 |
+
* @since 10.5.12
|
132 |
+
*
|
133 |
+
*/
|
134 |
function widget($args, $instance) {
|
135 |
+
global $asm;
|
136 |
+
extract( $args);
|
137 |
#-- Create a usable array of the excluded pages
|
138 |
$exclude = explode(',', $instance['exclude']);
|
139 |
$cat_ids = $already_top = array();
|
191 |
|
192 |
|
193 |
//Check for children
|
194 |
+
$all_categories = get_categories( array( 'child_of' => $top_cat ) );
|
195 |
+
|
196 |
+
//for depreciation
|
197 |
+
$all = $all_categories;
|
198 |
|
199 |
//If there are any child categories or the include childless parent is checked
|
200 |
+
if( !empty($all_categories ) || ($instance['include_childless_parent'] == 'checked' && !in_array($top_cat, $exclude)) ){
|
201 |
|
202 |
|
203 |
//Creates a new widget for each category the single page has if the options are selected to do so
|
204 |
if( !$asm_once || ($instance['new_widget'] == 'widget') ){
|
205 |
|
206 |
+
//Start the menu
|
207 |
+
echo $before_widget;
|
208 |
|
209 |
$count++; // To change the id of the widget if there are multiple
|
210 |
$asm_once = true; //There has been a div
|
216 |
}
|
217 |
|
218 |
|
219 |
+
$asm->set_widget_vars( $instance, $top_cat, $exclude, $cat_ancestors );
|
220 |
//Bring in the view
|
221 |
+
require( $asm->file_hyercy( 'category_list.php' ) );
|
222 |
|
223 |
|
224 |
if( $close ){
|
225 |
//End the Widget Area
|
226 |
+
echo $after_widget;
|
|
|
227 |
}
|
228 |
|
229 |
|
widgets/page.widget.php
CHANGED
@@ -11,6 +11,7 @@
|
|
11 |
*/
|
12 |
|
13 |
|
|
|
14 |
class advanced_sidebar_menu_page extends WP_Widget {
|
15 |
|
16 |
#-----------------------------------------------------------------------------------------------------------------------------------
|
@@ -18,24 +19,28 @@ class advanced_sidebar_menu_page extends WP_Widget {
|
|
18 |
function form( $instance ) {
|
19 |
// require( ADVANCED_SIDEBAR_DIR . 'advanced-sidebar-menu.js' );
|
20 |
?>
|
|
|
|
|
|
|
|
|
21 |
|
22 |
-
<p> Include Parent Page <input id="<?php echo $this->get_field_name('include_parent'); ?>"
|
23 |
name="<?php echo $this->get_field_name('include_parent'); ?>" type="checkbox" value="checked"
|
24 |
<?php echo $instance['include_parent']; ?>/></p>
|
25 |
|
26 |
|
27 |
-
<p> Include Parent Even With No Children<input id="<?php echo $this->get_field_name('include_childless_parent'); ?>"
|
28 |
name="<?php echo $this->get_field_name('include_childless_parent'); ?>" type="checkbox" value="checked"
|
29 |
<?php echo $instance['include_childless_parent']; ?>/></p>
|
30 |
|
31 |
-
<p> Use Built in Styling <input id="<?php echo $this->get_field_name('css'); ?>"
|
32 |
name="<?php echo $this->get_field_name('css'); ?>" type="checkbox" value="checked"
|
33 |
<?php echo $instance['css']; ?>/></p>
|
34 |
|
35 |
-
<p> Pages to Exclude, Comma Separated
|
36 |
name="<?php echo $this->get_field_name('exclude'); ?>" type="text" value="<?php echo $instance['exclude']; ?>"/></p>
|
37 |
|
38 |
-
<p> Always Display Child Pages <input id="<?php echo $this->get_field_name('display_all'); ?>"
|
39 |
name="<?php echo $this->get_field_name('display_all'); ?>" type="checkbox" value="checked"
|
40 |
onclick="javascript:asm_reveal_element( 'levels-<?php echo $this->get_field_name('levels'); ?>' )"
|
41 |
<?php echo $instance['display_all']; ?>/></p>
|
@@ -46,7 +51,7 @@ class advanced_sidebar_menu_page extends WP_Widget {
|
|
46 |
} else {
|
47 |
echo 'display:none';
|
48 |
} ?>">
|
49 |
-
<p> Levels to Display <select id="<?php echo $this->get_field_name('levels'); ?>"
|
50 |
name="<?php echo $this->get_field_name('levels'); ?>">
|
51 |
<?php
|
52 |
for( $i= 1; $i<6; $i++ ){
|
@@ -70,6 +75,7 @@ class advanced_sidebar_menu_page extends WP_Widget {
|
|
70 |
$instance['display_all'] = strip_tags($new_instance['display_all']);
|
71 |
$instance['levels'] = strip_tags($new_instance['levels']);
|
72 |
$instance['css'] = strip_tags($new_instance['css']);
|
|
|
73 |
return $instance;
|
74 |
}
|
75 |
|
@@ -79,20 +85,37 @@ class advanced_sidebar_menu_page extends WP_Widget {
|
|
79 |
function advanced_sidebar_menu_page( ) {
|
80 |
/* Widget settings. */
|
81 |
$widget_ops = array( 'classname' => 'sidebar-menu', 'description' => 'Creates a menu of all the pages using the child/parent relationship' );
|
82 |
-
|
83 |
|
84 |
/* Create the widget. */
|
85 |
-
$this->WP_Widget( 'advanced_sidebar_menu', 'Advanced Sidebar Pages Menu', $widget_ops);
|
86 |
}
|
87 |
|
88 |
|
89 |
#---------------------------------------------------------------------------------------------------------------------------
|
90 |
|
91 |
-
|
|
|
|
|
|
|
|
|
|
|
92 |
function widget($args, $instance) {
|
93 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
|
95 |
-
global $wpdb, $post, $table_prefix;
|
96 |
|
97 |
#-- Create a usable array of the excluded pages
|
98 |
$exclude = explode(',', $instance['exclude']);
|
@@ -104,11 +127,11 @@ class advanced_sidebar_menu_page extends WP_Widget {
|
|
104 |
#--------- If this is the parent ------------------------------------------------
|
105 |
$top_parent = $post->ID;
|
106 |
}
|
107 |
-
|
108 |
/**
|
109 |
* Must be done this way to prevent doubling up of pages
|
110 |
*/
|
111 |
-
$child_pages = $wpdb->get_results( "SELECT ID FROM ".$table_prefix."posts WHERE post_parent = $top_parent AND
|
112 |
|
113 |
//for depreciation
|
114 |
$p = $top_parent;
|
@@ -123,10 +146,12 @@ class advanced_sidebar_menu_page extends WP_Widget {
|
|
123 |
echo '</style>';
|
124 |
}
|
125 |
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
|
|
|
|
130 |
}
|
131 |
}
|
132 |
} #== /widget()
|
11 |
*/
|
12 |
|
13 |
|
14 |
+
|
15 |
class advanced_sidebar_menu_page extends WP_Widget {
|
16 |
|
17 |
#-----------------------------------------------------------------------------------------------------------------------------------
|
19 |
function form( $instance ) {
|
20 |
// require( ADVANCED_SIDEBAR_DIR . 'advanced-sidebar-menu.js' );
|
21 |
?>
|
22 |
+
|
23 |
+
<p> Title <br>
|
24 |
+
<input id="<?php echo $this->get_field_name('title'); ?>"
|
25 |
+
name="<?php echo $this->get_field_name('title'); ?>" size="50" type="text" value="<?php echo $instance['title']; ?>"/></p>
|
26 |
|
27 |
+
<p> Include Parent Page: <input id="<?php echo $this->get_field_name('include_parent'); ?>"
|
28 |
name="<?php echo $this->get_field_name('include_parent'); ?>" type="checkbox" value="checked"
|
29 |
<?php echo $instance['include_parent']; ?>/></p>
|
30 |
|
31 |
|
32 |
+
<p> Include Parent Even With No Children: <input id="<?php echo $this->get_field_name('include_childless_parent'); ?>"
|
33 |
name="<?php echo $this->get_field_name('include_childless_parent'); ?>" type="checkbox" value="checked"
|
34 |
<?php echo $instance['include_childless_parent']; ?>/></p>
|
35 |
|
36 |
+
<p> Use Built in Styling: <input id="<?php echo $this->get_field_name('css'); ?>"
|
37 |
name="<?php echo $this->get_field_name('css'); ?>" type="checkbox" value="checked"
|
38 |
<?php echo $instance['css']; ?>/></p>
|
39 |
|
40 |
+
<p> Pages to Exclude, Comma Separated: <input id="<?php echo $this->get_field_name('exclude'); ?>"
|
41 |
name="<?php echo $this->get_field_name('exclude'); ?>" type="text" value="<?php echo $instance['exclude']; ?>"/></p>
|
42 |
|
43 |
+
<p> Always Display Child Pages: <input id="<?php echo $this->get_field_name('display_all'); ?>"
|
44 |
name="<?php echo $this->get_field_name('display_all'); ?>" type="checkbox" value="checked"
|
45 |
onclick="javascript:asm_reveal_element( 'levels-<?php echo $this->get_field_name('levels'); ?>' )"
|
46 |
<?php echo $instance['display_all']; ?>/></p>
|
51 |
} else {
|
52 |
echo 'display:none';
|
53 |
} ?>">
|
54 |
+
<p> Levels to Display: <select id="<?php echo $this->get_field_name('levels'); ?>"
|
55 |
name="<?php echo $this->get_field_name('levels'); ?>">
|
56 |
<?php
|
57 |
for( $i= 1; $i<6; $i++ ){
|
75 |
$instance['display_all'] = strip_tags($new_instance['display_all']);
|
76 |
$instance['levels'] = strip_tags($new_instance['levels']);
|
77 |
$instance['css'] = strip_tags($new_instance['css']);
|
78 |
+
$instance['title'] = strip_tags($new_instance['title']);
|
79 |
return $instance;
|
80 |
}
|
81 |
|
85 |
function advanced_sidebar_menu_page( ) {
|
86 |
/* Widget settings. */
|
87 |
$widget_ops = array( 'classname' => 'sidebar-menu', 'description' => 'Creates a menu of all the pages using the child/parent relationship' );
|
88 |
+
$control_ops = array( 'width' => 290 );
|
89 |
|
90 |
/* Create the widget. */
|
91 |
+
$this->WP_Widget( 'advanced_sidebar_menu', 'Advanced Sidebar Pages Menu', $widget_ops, $control_ops);
|
92 |
}
|
93 |
|
94 |
|
95 |
#---------------------------------------------------------------------------------------------------------------------------
|
96 |
|
97 |
+
/**
|
98 |
+
* Outputs the page list
|
99 |
+
* @see WP_Widget::widget()
|
100 |
+
* @uses for custom post types send the type to the filter titled 'advanced_sidebar_menu_post_type'
|
101 |
+
* @since 10.5.12
|
102 |
+
*/
|
103 |
function widget($args, $instance) {
|
104 |
+
$single_type = 'page'; //default use is for pages
|
105 |
+
|
106 |
+
//Filter this one with a 'single' for a custom post type will default to working for pages only
|
107 |
+
$post_type = apply_filters('advanced_sidebar_menu_post_type', 'page' );
|
108 |
+
|
109 |
+
|
110 |
+
if( $post_type != 'page' ){
|
111 |
+
$single_type = 'single';
|
112 |
+
}
|
113 |
+
|
114 |
+
if( call_user_func('is_'.$single_type) ){
|
115 |
+
|
116 |
+
extract($args);
|
117 |
|
118 |
+
global $wpdb, $post, $table_prefix, $asm;
|
119 |
|
120 |
#-- Create a usable array of the excluded pages
|
121 |
$exclude = explode(',', $instance['exclude']);
|
127 |
#--------- If this is the parent ------------------------------------------------
|
128 |
$top_parent = $post->ID;
|
129 |
}
|
130 |
+
|
131 |
/**
|
132 |
* Must be done this way to prevent doubling up of pages
|
133 |
*/
|
134 |
+
$child_pages = $wpdb->get_results( "SELECT ID FROM ".$table_prefix."posts WHERE post_parent = $top_parent AND post_status='publish' Order by menu_order" );
|
135 |
|
136 |
//for depreciation
|
137 |
$p = $top_parent;
|
146 |
echo '</style>';
|
147 |
}
|
148 |
|
149 |
+
//Start the menu
|
150 |
+
echo $before_widget;
|
151 |
+
$asm->set_widget_vars( $instance, $top_parent, $exclude );
|
152 |
+
#-- Bring in the view
|
153 |
+
require( $asm->file_hyercy( 'page_list.php' ) );
|
154 |
+
echo $after_widget;
|
155 |
}
|
156 |
}
|
157 |
} #== /widget()
|