Version Description
- Added ability to have categories show on single post pages
- Improved the code structure
Download this release
Release Info
Developer | Mat Lipe |
Plugin | Advanced Sidebar Menu |
Version | 3.2.0 |
Comparing to | |
See all releases |
Code changes from version 3.0.2 to 3.2.0
- advanced-sidebar-menu.js +9 -4
- advanced-sidebar-menu.php +19 -3
- functions.php +78 -4
- readme.txt +12 -2
- views/category_list.php +15 -15
- widgets/category.widget.php +119 -34
- widgets/page.widget.php +5 -5
advanced-sidebar-menu.js
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
|
2 |
-
|
3 |
-
<script type="text/javascript">
|
4 |
//This will change the style display to block
|
5 |
//For the element that is sent to it
|
6 |
//Use the id or inline tags for this
|
7 |
-
function
|
|
|
8 |
//If the toggle has already been clicked to show
|
9 |
//This will hide it
|
10 |
if( document.getElementById( this_element_id ).style.display == 'none' ){
|
@@ -14,6 +14,11 @@ function reveal_element( this_element_id ){
|
|
14 |
} else {
|
15 |
document.getElementById( this_element_id ).style.display = 'none';
|
16 |
}
|
|
|
17 |
}
|
18 |
|
19 |
-
|
|
|
|
|
|
|
|
1 |
|
2 |
+
|
|
|
3 |
//This will change the style display to block
|
4 |
//For the element that is sent to it
|
5 |
//Use the id or inline tags for this
|
6 |
+
function asm_reveal_element( this_element_id ){
|
7 |
+
|
8 |
//If the toggle has already been clicked to show
|
9 |
//This will hide it
|
10 |
if( document.getElementById( this_element_id ).style.display == 'none' ){
|
14 |
} else {
|
15 |
document.getElementById( this_element_id ).style.display = 'none';
|
16 |
}
|
17 |
+
|
18 |
}
|
19 |
|
20 |
+
|
21 |
+
|
22 |
+
|
23 |
+
|
24 |
+
|
advanced-sidebar-menu.php
CHANGED
@@ -4,17 +4,21 @@ Plugin Name: Advanced Sidebar Menu
|
|
4 |
Plugin URI: http://lipeimagination.info
|
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 |
-
|
16 |
#-- Bring in the functions
|
17 |
require( 'functions.php' );
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
|
20 |
#-- Bring in the Widgets
|
@@ -27,6 +31,18 @@ define( 'ADVANCED_SIDEBAR_VIEWS_DIR', plugin_dir_path(__FILE__) . 'views/' );
|
|
27 |
define( 'ADVANCED_SIDEBAR_DIR', plugin_dir_path(__FILE__) );
|
28 |
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
|
32 |
|
4 |
Plugin URI: http://lipeimagination.info
|
5 |
Description: Creates dynamic menu based on child/parent relationship.
|
6 |
Author: Mat Lipe
|
7 |
+
Version: 3.2
|
8 |
Author URI: http://lipeimagination.info
|
9 |
+
Since: 6/3/12
|
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 |
+
#-- Version 3.2 notice
|
20 |
+
add_action( 'init', array( $asm, 'validate_3_2' ) );
|
21 |
+
|
22 |
|
23 |
|
24 |
#-- Bring in the Widgets
|
31 |
define( 'ADVANCED_SIDEBAR_DIR', plugin_dir_path(__FILE__) );
|
32 |
|
33 |
|
34 |
+
#-- Bring in the JQuery
|
35 |
+
add_action( 'admin_print_scripts', 'advanced_sidebar_menu_script');
|
36 |
+
function advanced_sidebar_menu_script(){
|
37 |
+
wp_enqueue_script(
|
38 |
+
apply_filters( 'asm_script', 'advanced-sidebar-menu-script' ), //Allows developers to overright the name of the script
|
39 |
+
plugins_url( 'advanced-sidebar-menu.js', __FILE__ ),
|
40 |
+
array('jquery'), //The scripts this depends on
|
41 |
+
'1.1.0' //The Version of your script
|
42 |
+
|
43 |
+
);
|
44 |
+
|
45 |
+
};
|
46 |
|
47 |
|
48 |
|
functions.php
CHANGED
@@ -4,16 +4,87 @@
|
|
4 |
/**
|
5 |
* These Functions are Specific to the Advanced Sidebar Menu
|
6 |
* @author Mat Lipe
|
7 |
-
* @since
|
8 |
*/
|
9 |
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
/**
|
12 |
* Allows for Overwritting files in the child theme
|
13 |
-
* @since
|
14 |
*/
|
15 |
|
16 |
-
function
|
17 |
|
18 |
if ( $theme_file = locate_template(array('advanced-sidebar-menu/'.$file)) ) {
|
19 |
$file = $theme_file;
|
@@ -22,4 +93,7 @@ function advanced_sidebar_menu_file_hyercy( $file ){
|
|
22 |
}
|
23 |
return $file;
|
24 |
|
25 |
-
}
|
|
|
|
|
|
4 |
/**
|
5 |
* These Functions are Specific to the Advanced Sidebar Menu
|
6 |
* @author Mat Lipe
|
7 |
+
* @since 6/3/12
|
8 |
*/
|
9 |
|
10 |
|
11 |
+
|
12 |
+
class advanced_sidebar_menu_functions{
|
13 |
+
protected $bad = array(); //for 3.2 version
|
14 |
+
protected $cat_file = ''; //for 3.2 version
|
15 |
+
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Validate the views for the new structure
|
19 |
+
* @since 6/3/12
|
20 |
+
*/
|
21 |
+
function validate_3_2(){
|
22 |
+
|
23 |
+
|
24 |
+
/** Note to self -- Remove this at the new version **/
|
25 |
+
if ( $cat_file = locate_template(array('advanced-sidebar-menu/category_list.php')) ) {
|
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->cat_file = get_bloginfo( 'stylesheet_directory' ) . 'advanced-sidebar-menu/category_list.php';
|
54 |
+
add_action( 'admin_notices', array( $this, 'notice_3_2') );
|
55 |
+
}
|
56 |
+
|
57 |
+
}
|
58 |
+
|
59 |
+
}
|
60 |
+
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Adds an admin notice if there are issues with the view
|
64 |
+
* @since 6/3/12
|
65 |
+
*/
|
66 |
+
function notice_3_2( ){
|
67 |
+
echo '<div class="error">';
|
68 |
+
echo 'To use version 3.2 of <b>Advanced Sidebar Menu</b> you must delete the following lines from <b>"' . $this->cat_file . '"</b><br>';
|
69 |
+
|
70 |
+
foreach( $this->bad as $line => $content ){
|
71 |
+
echo '<b>line' . $line . ': </b> '. $content . '<br>';
|
72 |
+
}
|
73 |
+
|
74 |
+
echo '</div>';
|
75 |
+
|
76 |
+
}
|
77 |
+
|
78 |
+
|
79 |
+
|
80 |
+
|
81 |
+
|
82 |
/**
|
83 |
* Allows for Overwritting files in the child theme
|
84 |
+
* @since 6/3/12
|
85 |
*/
|
86 |
|
87 |
+
static function file_hyercy( $file ){
|
88 |
|
89 |
if ( $theme_file = locate_template(array('advanced-sidebar-menu/'.$file)) ) {
|
90 |
$file = $theme_file;
|
93 |
}
|
94 |
return $file;
|
95 |
|
96 |
+
}
|
97 |
+
|
98 |
+
} //End class
|
99 |
+
|
readme.txt
CHANGED
@@ -4,8 +4,8 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=paypa
|
|
4 |
Tags: menus, sidebar menu, heirchy, category menu, pages menu
|
5 |
Requires at least: 3.1
|
6 |
Tested up to: 3.3.2
|
7 |
-
Stable tag: 3.0
|
8 |
-
Version: 3.0
|
9 |
|
10 |
== Description ==
|
11 |
|
@@ -58,6 +58,11 @@ You may want to use something like margins to set the levels apart.
|
|
58 |
|
59 |
== Changelog ==
|
60 |
|
|
|
|
|
|
|
|
|
|
|
61 |
= 3.0.2 =
|
62 |
*Bugfixes
|
63 |
|
@@ -106,6 +111,11 @@ You may want to use something like margins to set the levels apart.
|
|
106 |
|
107 |
== Upgrade Notice ==
|
108 |
|
|
|
|
|
|
|
|
|
|
|
109 |
= 3.0 =
|
110 |
This Version will add a widget for displaying categories as well,
|
111 |
better functionality, a cleaner output, and the ability to customize the output/css
|
4 |
Tags: menus, sidebar menu, heirchy, category menu, pages menu
|
5 |
Requires at least: 3.1
|
6 |
Tested up to: 3.3.2
|
7 |
+
Stable tag: 3.2.0
|
8 |
+
Version: 3.2.0
|
9 |
|
10 |
== Description ==
|
11 |
|
58 |
|
59 |
== Changelog ==
|
60 |
|
61 |
+
= 3.2.0 =
|
62 |
+
* Added ability to have categories show on single post pages
|
63 |
+
* Improved the code structure
|
64 |
+
|
65 |
+
|
66 |
= 3.0.2 =
|
67 |
*Bugfixes
|
68 |
|
111 |
|
112 |
== Upgrade Notice ==
|
113 |
|
114 |
+
= 3.2 =
|
115 |
+
This will add the ability to display the categories on single post pages.
|
116 |
+
If you are using the category_list.php view you will most likely get an error message to remove a couple lines.
|
117 |
+
These lines are no longer needed for the structure in this new version.
|
118 |
+
|
119 |
= 3.0 =
|
120 |
This Version will add a widget for displaying categories as well,
|
121 |
better functionality, a cleaner output, and the ability to customize the output/css
|
views/category_list.php
CHANGED
@@ -3,28 +3,23 @@
|
|
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
|
12 |
*/
|
13 |
|
14 |
|
15 |
|
16 |
-
echo '<div id="'.$args['widget_id'].'" class="advanced-sidebar-menu widget advanced-sidebar-category">
|
17 |
-
<div class="widget-wrap">';
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
#-- if the checkbox to include parent is checked
|
22 |
if( $instance['include_parent'] == 'checked' && !in_array($top_cat, $exclude) ){
|
23 |
|
24 |
echo '<ul class="parent-sidebar-menu">';
|
25 |
wp_list_categories( 'title_li=&include=' . $top_cat);
|
26 |
|
27 |
-
$parent =
|
28 |
}
|
29 |
|
30 |
if( !empty($all) ){
|
@@ -64,14 +59,19 @@ echo '<div id="'.$args['widget_id'].'" class="advanced-sidebar-menu widget advan
|
|
64 |
echo '</ul><!-- End #child-sidebar-menu -->';
|
65 |
|
66 |
} //End if display all is not checked
|
67 |
-
|
68 |
-
#-- if a parent category was displayed
|
69 |
-
if( isset($parent) ){
|
70 |
-
echo '</ul><!-- End #parent-sidebar-menu -->';
|
71 |
-
}
|
72 |
|
73 |
} //End if the are child categories
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
|
75 |
-
//End the Widget Area
|
76 |
-
echo '</div></div><!-- END #advanced-sidebar-cat-menu -->';
|
77 |
|
3 |
/**
|
4 |
* The Ouput of tad Advanced Sidebar Categories Widget
|
5 |
* @author Mat Lipe
|
6 |
+
* @since 6/3/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 or it will break on update
|
12 |
*/
|
13 |
|
14 |
|
15 |
|
|
|
|
|
|
|
|
|
|
|
16 |
#-- if the checkbox to include parent is checked
|
17 |
if( $instance['include_parent'] == 'checked' && !in_array($top_cat, $exclude) ){
|
18 |
|
19 |
echo '<ul class="parent-sidebar-menu">';
|
20 |
wp_list_categories( 'title_li=&include=' . $top_cat);
|
21 |
|
22 |
+
$parent = 'yes';
|
23 |
}
|
24 |
|
25 |
if( !empty($all) ){
|
59 |
echo '</ul><!-- End #child-sidebar-menu -->';
|
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( isset($parent) ){
|
69 |
+
echo '</ul><!-- End #parent-sidebar-menu -->';
|
70 |
+
|
71 |
+
unset( $parent); //for next time
|
72 |
+
}
|
73 |
+
|
74 |
+
|
75 |
+
|
76 |
|
|
|
|
|
77 |
|
widgets/category.widget.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
* Creates a Widget of parent Child Categories
|
6 |
*
|
7 |
* @author mat lipe
|
8 |
-
* @since
|
9 |
* @package Advanced Sidebar Menu
|
10 |
*
|
11 |
*/
|
@@ -18,7 +18,7 @@ class advanced_sidebar_menu_category extends WP_Widget {
|
|
18 |
#-----------------------------------------------------------------------------------------------------------------------------------
|
19 |
// this creates the widget form for the dashboard
|
20 |
function form( $instance ) {
|
21 |
-
|
22 |
?>
|
23 |
|
24 |
|
@@ -28,7 +28,7 @@ class advanced_sidebar_menu_category extends WP_Widget {
|
|
28 |
<?php echo $instance['include_parent']; ?>/></p>
|
29 |
|
30 |
|
31 |
-
<p> Include Parent Even With No Children<input id="<?php echo $this->get_field_name('include_childless_parent'); ?>"
|
32 |
name="<?php echo $this->get_field_name('include_childless_parent'); ?>" type="checkbox" value="checked"
|
33 |
<?php echo $instance['include_childless_parent']; ?>/></p>
|
34 |
|
@@ -36,12 +36,41 @@ 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> Categories to Exclude, Comma Separated:<input id="<?php echo $this->get_field_name('exclude'); ?>"
|
40 |
name="<?php echo $this->get_field_name('exclude'); ?>" type="text" value="<?php echo $instance['exclude']; ?>"/></p>
|
41 |
|
42 |
<p> Always Display Child Categories <input id="<?php echo $this->get_field_name('display_all'); ?>"
|
43 |
name="<?php echo $this->get_field_name('display_all'); ?>" type="checkbox" value="checked"
|
44 |
-
onclick="javascript:
|
45 |
<?php echo $instance['display_all']; ?>/></p>
|
46 |
|
47 |
<span id="levels-<?php echo $this->get_field_name('levels'); ?>" style="<?php
|
@@ -74,6 +103,8 @@ class advanced_sidebar_menu_category extends WP_Widget {
|
|
74 |
$instance['display_all'] = strip_tags($new_instance['display_all']);
|
75 |
$instance['levels'] = strip_tags($new_instance['levels']);
|
76 |
$instance['css'] = strip_tags($new_instance['css']);
|
|
|
|
|
77 |
return $instance;
|
78 |
}
|
79 |
|
@@ -83,10 +114,9 @@ class advanced_sidebar_menu_category extends WP_Widget {
|
|
83 |
function advanced_sidebar_menu_category( ) {
|
84 |
/* Widget settings. */
|
85 |
$widget_ops = array( 'classname' => 'sidebar-menu-category', 'description' => 'Creates a menu of all the Categories using the child/parent relationship' );
|
86 |
-
|
87 |
-
|
88 |
/* Create the widget. */
|
89 |
-
$this->WP_Widget( 'advanced_sidebar_menu_category', 'Advanced Sidebar Categories Menu', $widget_ops );
|
90 |
}
|
91 |
|
92 |
|
@@ -94,48 +124,103 @@ class advanced_sidebar_menu_category extends WP_Widget {
|
|
94 |
|
95 |
// adds the output to the widget area on the page
|
96 |
function widget($args, $instance) {
|
97 |
-
if( is_category() ){
|
98 |
-
|
99 |
-
|
100 |
#-- Create a usable array of the excluded pages
|
101 |
$exclude = explode(',', $instance['exclude']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
|
103 |
-
|
104 |
-
$
|
105 |
-
|
|
|
106 |
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
|
113 |
|
114 |
-
|
115 |
-
|
116 |
|
117 |
-
|
118 |
-
|
119 |
|
120 |
|
121 |
-
|
122 |
-
|
123 |
|
124 |
-
|
125 |
-
if( $instance['css'] == 'checked' ){
|
126 |
-
echo '<style type="text/css">';
|
127 |
-
include( advanced_sidebar_menu_file_hyercy( 'sidebar-menu.css' ) );
|
128 |
-
echo '</style>';
|
129 |
-
}
|
130 |
|
131 |
-
|
132 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
|
|
|
134 |
|
135 |
|
136 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
|
138 |
-
|
139 |
|
140 |
} #== /widget()
|
141 |
|
5 |
* Creates a Widget of parent Child Categories
|
6 |
*
|
7 |
* @author mat lipe
|
8 |
+
* @since 6/3/12
|
9 |
* @package Advanced Sidebar Menu
|
10 |
*
|
11 |
*/
|
18 |
#-----------------------------------------------------------------------------------------------------------------------------------
|
19 |
// this creates the widget form for the dashboard
|
20 |
function form( $instance ) {
|
21 |
+
// require( ADVANCED_SIDEBAR_DIR . 'advanced-sidebar-menu.js' );
|
22 |
?>
|
23 |
|
24 |
|
28 |
<?php echo $instance['include_parent']; ?>/></p>
|
29 |
|
30 |
|
31 |
+
<p> Include Parent Even With No Children <input id="<?php echo $this->get_field_name('include_childless_parent'); ?>"
|
32 |
name="<?php echo $this->get_field_name('include_childless_parent'); ?>" type="checkbox" value="checked"
|
33 |
<?php echo $instance['include_childless_parent']; ?>/></p>
|
34 |
|
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 Post Page's <input id="<?php echo $this->get_field_name('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>
|
43 |
+
|
44 |
+
<span id="new-widget-<?php echo $this->get_field_name('new_widget'); ?>" style="<?php
|
45 |
+
if( $instance['single'] == checked ){
|
46 |
+
echo 'display:block';
|
47 |
+
} else {
|
48 |
+
echo 'display:none';
|
49 |
+
} ?>">
|
50 |
+
<p>Display Each Single Post's Category
|
51 |
+
<select id="<?php echo $this->get_field_name('new_widget'); ?>"
|
52 |
+
name="<?php echo $this->get_field_name('new_widget'); ?>">
|
53 |
+
<?php
|
54 |
+
if( $instance['new_widget'] == 'widget' ){
|
55 |
+
echo '<option value="widget" selected> In a new widget </option>';
|
56 |
+
echo '<option value="list"> In another list in the same widget </option>';
|
57 |
+
} else {
|
58 |
+
echo '<option value="widget"> In a new widget </option>';
|
59 |
+
echo '<option value="list" selected> In another list in the same widget </option>';
|
60 |
+
}
|
61 |
+
|
62 |
+
?></select>
|
63 |
+
</p>
|
64 |
+
</span>
|
65 |
+
|
66 |
+
|
67 |
+
|
68 |
<p> Categories to Exclude, Comma Separated:<input id="<?php echo $this->get_field_name('exclude'); ?>"
|
69 |
name="<?php echo $this->get_field_name('exclude'); ?>" type="text" value="<?php echo $instance['exclude']; ?>"/></p>
|
70 |
|
71 |
<p> Always Display Child Categories <input id="<?php echo $this->get_field_name('display_all'); ?>"
|
72 |
name="<?php echo $this->get_field_name('display_all'); ?>" type="checkbox" value="checked"
|
73 |
+
onclick="javascript:asm_reveal_element( 'levels-<?php echo $this->get_field_name('levels'); ?>' )"
|
74 |
<?php echo $instance['display_all']; ?>/></p>
|
75 |
|
76 |
<span id="levels-<?php echo $this->get_field_name('levels'); ?>" style="<?php
|
103 |
$instance['display_all'] = strip_tags($new_instance['display_all']);
|
104 |
$instance['levels'] = strip_tags($new_instance['levels']);
|
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 |
|
114 |
function advanced_sidebar_menu_category( ) {
|
115 |
/* Widget settings. */
|
116 |
$widget_ops = array( 'classname' => 'sidebar-menu-category', 'description' => 'Creates a menu of all the Categories using the child/parent relationship' );
|
117 |
+
$control_ops = array( 'width' => 290 );
|
|
|
118 |
/* Create the widget. */
|
119 |
+
$this->WP_Widget( 'advanced_sidebar_menu_category', 'Advanced Sidebar Categories Menu', $widget_ops, $control_ops );
|
120 |
}
|
121 |
|
122 |
|
124 |
|
125 |
// adds the output to the widget area on the page
|
126 |
function widget($args, $instance) {
|
|
|
|
|
|
|
127 |
#-- Create a usable array of the excluded pages
|
128 |
$exclude = explode(',', $instance['exclude']);
|
129 |
+
$cat_ids = array();
|
130 |
+
$asm_cat_widget_count = false; //keeps track of how many widgets this created
|
131 |
+
$count = null;
|
132 |
+
|
133 |
+
|
134 |
+
//If on a single page create an array of each category and create a list for each
|
135 |
+
if( is_single() && ($instance['single'] == 'checked') ){
|
136 |
+
$category_array = get_the_category();
|
137 |
+
foreach( get_the_category() as $id => $cat ){
|
138 |
+
$cat_ids[] = $cat->term_id;
|
139 |
+
}
|
140 |
+
//IF on a category page get the id of the category
|
141 |
+
} elseif( is_category() ){
|
142 |
+
$cat_ids[] = get_query_var('cat');
|
143 |
+
}
|
144 |
+
|
145 |
+
//print_r( get_the_category() );
|
146 |
+
|
147 |
+
///print_r( $cat_ids );
|
148 |
+
|
149 |
+
//Bring in the Styling
|
150 |
+
if( $instance['css'] == 'checked' ){
|
151 |
+
echo '<style type="text/css">';
|
152 |
+
include( advanced_sidebar_menu_functions::file_hyercy( 'sidebar-menu.css' ) );
|
153 |
+
echo '</style>';
|
154 |
+
}
|
155 |
|
156 |
+
//Go through each category there will be only one if this is a category page mulitple possible if this is single
|
157 |
+
foreach( $cat_ids as $cat_id ){
|
158 |
+
$cat_ancestors = array ();
|
159 |
+
$cat_ancestors[] = $cat_id ;
|
160 |
|
161 |
+
do {
|
162 |
+
$cat_id = get_category($cat_id );
|
163 |
+
$cat_id = $cat_id->parent;
|
164 |
+
$cat_ancestors[] = $cat_id ; }
|
165 |
+
while ($cat_id );
|
166 |
|
167 |
|
168 |
+
$cat_ancestors = array_reverse( $cat_ancestors );
|
169 |
+
$top_cat = $cat_ancestors [1];
|
170 |
|
171 |
+
//Check for children
|
172 |
+
$all = get_categories( array( 'child_of' => $top_cat ) );
|
173 |
|
174 |
|
175 |
+
//If there are any child categories or the include childless parent is checked
|
176 |
+
if( !empty($all ) || ($instance['include_childless_parent'] == 'checked' && !in_array($top_cat, $exclude)) ){
|
177 |
|
178 |
+
|
|
|
|
|
|
|
|
|
|
|
179 |
|
180 |
+
#!! Bring in the output from either the child theme or this folder
|
181 |
+
|
182 |
+
//Creates a new widget for each category the single page has if the options are selected to do so
|
183 |
+
if( !$asm_once || ($instance['new_widget'] == 'widget') ){
|
184 |
+
|
185 |
+
echo '<div id="'.$args['widget_id']. $count .'" class="advanced-sidebar-menu widget advanced-sidebar-category">
|
186 |
+
<div class="widget-wrap">';
|
187 |
+
|
188 |
+
$count++;
|
189 |
+
$asm_once = true;
|
190 |
+
$close = true;
|
191 |
+
if($instance['new_widget'] == 'list'){ $close = false;} //If this is a list leave it open for possible late ones
|
192 |
+
|
193 |
+
} else {
|
194 |
+
$close = false;
|
195 |
+
}
|
196 |
+
|
197 |
+
|
198 |
+
//Bring in the view
|
199 |
+
require( advanced_sidebar_menu_functions::file_hyercy( 'category_list.php' ) );
|
200 |
+
|
201 |
+
|
202 |
+
if( $close ){
|
203 |
+
//End the Widget Area
|
204 |
+
echo '</div>
|
205 |
+
</div><!-- END #advanced-sidebar-cat-menu -->';
|
206 |
+
}
|
207 |
|
208 |
+
|
209 |
|
210 |
|
211 |
+
} //End if any children or include childless parent
|
212 |
+
} //End of each cat loop
|
213 |
+
|
214 |
+
|
215 |
+
//IF we were waiting for all the individual lists to complete
|
216 |
+
if( !$close && $asm_once ){
|
217 |
+
//End the Widget Area
|
218 |
+
echo '</div>
|
219 |
+
</div><!-- END #advanced-sidebar-cat-menu -->';
|
220 |
+
|
221 |
+
}
|
222 |
|
223 |
+
|
224 |
|
225 |
} #== /widget()
|
226 |
|
widgets/page.widget.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
* Creates a Widget of parent Child Pages
|
6 |
*
|
7 |
* @author mat lipe
|
8 |
-
* @since
|
9 |
* @package Advanced Sidebar Menu
|
10 |
*
|
11 |
*/
|
@@ -16,7 +16,7 @@ class advanced_sidebar_menu_page extends WP_Widget {
|
|
16 |
#-----------------------------------------------------------------------------------------------------------------------------------
|
17 |
// this creates the widget form for the dashboard
|
18 |
function form( $instance ) {
|
19 |
-
|
20 |
?>
|
21 |
|
22 |
|
@@ -39,7 +39,7 @@ class advanced_sidebar_menu_page extends WP_Widget {
|
|
39 |
|
40 |
<p> Always Display Child Pages <input id="<?php echo $this->get_field_name('display_all'); ?>"
|
41 |
name="<?php echo $this->get_field_name('display_all'); ?>" type="checkbox" value="checked"
|
42 |
-
onclick="javascript:
|
43 |
<?php echo $instance['display_all']; ?>/></p>
|
44 |
|
45 |
<span id="levels-<?php echo $this->get_field_name('levels'); ?>" style="<?php
|
@@ -131,7 +131,7 @@ class advanced_sidebar_menu_page extends WP_Widget {
|
|
131 |
|
132 |
if( $instance['css'] == 'checked' ){
|
133 |
echo '<style type="text/css">';
|
134 |
-
include(
|
135 |
|
136 |
echo '</style>';
|
137 |
|
@@ -140,7 +140,7 @@ class advanced_sidebar_menu_page extends WP_Widget {
|
|
140 |
|
141 |
|
142 |
#-- Bring in the output
|
143 |
-
require(
|
144 |
|
145 |
}
|
146 |
}
|
5 |
* Creates a Widget of parent Child Pages
|
6 |
*
|
7 |
* @author mat lipe
|
8 |
+
* @since 6/3/12
|
9 |
* @package Advanced Sidebar Menu
|
10 |
*
|
11 |
*/
|
16 |
#-----------------------------------------------------------------------------------------------------------------------------------
|
17 |
// this creates the widget form for the dashboard
|
18 |
function form( $instance ) {
|
19 |
+
// require( ADVANCED_SIDEBAR_DIR . 'advanced-sidebar-menu.js' );
|
20 |
?>
|
21 |
|
22 |
|
39 |
|
40 |
<p> Always Display Child Pages <input id="<?php echo $this->get_field_name('display_all'); ?>"
|
41 |
name="<?php echo $this->get_field_name('display_all'); ?>" type="checkbox" value="checked"
|
42 |
+
onclick="javascript:asm_reveal_element( 'levels-<?php echo $this->get_field_name('levels'); ?>' )"
|
43 |
<?php echo $instance['display_all']; ?>/></p>
|
44 |
|
45 |
<span id="levels-<?php echo $this->get_field_name('levels'); ?>" style="<?php
|
131 |
|
132 |
if( $instance['css'] == 'checked' ){
|
133 |
echo '<style type="text/css">';
|
134 |
+
include( advanced_sidebar_menu_functions::file_hyercy('sidebar-menu.css' ) );
|
135 |
|
136 |
echo '</style>';
|
137 |
|
140 |
|
141 |
|
142 |
#-- Bring in the output
|
143 |
+
require( advanced_sidebar_menu_functions::file_hyercy( 'page_list.php' ) );
|
144 |
|
145 |
}
|
146 |
}
|