| 1 |
<?php |
| 2 |
/* |
| 3 |
Plugin Name: Page-list |
| 4 |
Plugin URI: http://web-profile.com.ua/wordpress/plugins/page-list/ |
| 5 |
Description: Show list of pages with [pagelist], [subpages] and [siblings] shortcodes. |
| 6 |
Version: 1.4 |
| 7 |
Author: webvitaly |
| 8 |
Author Email: webvitaly(at)gmail.com |
| 9 |
Author URI: http://web-profile.com.ua/wordpress/ |
| 10 |
|
| 11 |
Future features: |
| 12 |
- add support exclude="current,5"; |
| 13 |
- exclude_by_alias; |
| 14 |
- exclude_front_page; |
| 15 |
- exclude_post_page; |
| 16 |
*/ |
| 17 |
|
| 18 |
if ( !function_exists('pagelist_shortcode') ) { |
| 19 |
function pagelist_shortcode( $atts ) { |
| 20 |
global $post; |
| 21 |
$return = ''; |
| 22 |
extract( shortcode_atts( array( |
| 23 |
'depth' => '0', |
| 24 |
'child_of' => '0', |
| 25 |
'exclude' => '0', |
| 26 |
'exclude_tree' => '', |
| 27 |
'include' => '0', |
| 28 |
'title_li' => '', |
| 29 |
'number' => '', |
| 30 |
'offset' => '', |
| 31 |
'meta_key' => '', |
| 32 |
'meta_value' => '', |
| 33 |
'show_date' => '', |
| 34 |
'sort_column' => 'menu_order, post_title', |
| 35 |
'sort_order' => 'ASC', |
| 36 |
'link_before' => '', |
| 37 |
'link_after' => '', |
| 38 |
'class' => '' |
| 39 |
), $atts ) ); |
| 40 |
|
| 41 |
if( $child_of == 'current' || $child_of == 'this' ){ |
| 42 |
$child_of = $post->ID; |
| 43 |
} |
| 44 |
if( $child_of == 'parent' ){ |
| 45 |
$child_of = $post->post_parent; |
| 46 |
} |
| 47 |
if( $exclude == 'current' || $exclude == 'this' ){ |
| 48 |
$exclude = $post->ID; |
| 49 |
} |
| 50 |
|
| 51 |
$page_list_args = array( |
| 52 |
'depth' => $depth, |
| 53 |
'child_of' => $child_of, |
| 54 |
'exclude' => $exclude, |
| 55 |
'exclude_tree' => $exclude_tree, |
| 56 |
'include' => $include, |
| 57 |
'title_li' => $title_li, |
| 58 |
'number' => $number, |
| 59 |
'offset' => $offset, |
| 60 |
'meta_key' => $meta_key, |
| 61 |
'meta_value' => $meta_value, |
| 62 |
'show_date' => $show_date, |
| 63 |
'date_format' => get_option('date_format'), |
| 64 |
'echo' => 0, |
| 65 |
'authors' => '', |
| 66 |
'sort_column' => $sort_column, |
| 67 |
'sort_order' => $sort_order, |
| 68 |
'link_before' => $link_before, |
| 69 |
'link_after' => $link_after, |
| 70 |
'walker' => '' |
| 71 |
); |
| 72 |
$list_pages = wp_list_pages( $page_list_args ); |
| 73 |
|
| 74 |
if ($list_pages) { |
| 75 |
$return = "\n".'<!-- powered by Page-list plugin ver. 1.4 (wordpress.org/extend/plugins/page-list/) -->'."\n"; |
| 76 |
$return .= '<ul class="page-list '.$class.'">'."\n".$list_pages."\n".'</ul>'; |
| 77 |
}else{ |
| 78 |
$return = ''; |
| 79 |
} |
| 80 |
return $return; |
| 81 |
} |
| 82 |
add_shortcode( 'pagelist', 'pagelist_shortcode' ); |
| 83 |
add_shortcode( 'page-list', 'pagelist_shortcode' ); |
| 84 |
add_shortcode( 'sitemap', 'pagelist_shortcode' ); |
| 85 |
} |
| 86 |
|
| 87 |
if ( !function_exists('subpages_shortcode') ) { |
| 88 |
function subpages_shortcode( $atts ) { |
| 89 |
global $post; |
| 90 |
$return = ''; |
| 91 |
extract( shortcode_atts( array( |
| 92 |
'depth' => '0', |
| 93 |
//'child_of' => '0', |
| 94 |
'exclude' => '0', |
| 95 |
'exclude_tree' => '', |
| 96 |
'include' => '0', |
| 97 |
'title_li' => '', |
| 98 |
'number' => '', |
| 99 |
'offset' => '', |
| 100 |
'meta_key' => '', |
| 101 |
'meta_value' => '', |
| 102 |
'show_date' => '', |
| 103 |
'sort_column' => 'menu_order, post_title', |
| 104 |
'sort_order' => 'ASC', |
| 105 |
'link_before' => '', |
| 106 |
'link_after' => '', |
| 107 |
'class' => '' |
| 108 |
), $atts ) ); |
| 109 |
|
| 110 |
$page_list_args = array( |
| 111 |
'depth' => $depth, |
| 112 |
'child_of' => $post->ID, |
| 113 |
'exclude' => $exclude, |
| 114 |
'exclude_tree' => $exclude_tree, |
| 115 |
'include' => $include, |
| 116 |
'title_li' => $title_li, |
| 117 |
'number' => $number, |
| 118 |
'offset' => $offset, |
| 119 |
'meta_key' => $meta_key, |
| 120 |
'meta_value' => $meta_value, |
| 121 |
'show_date' => $show_date, |
| 122 |
'date_format' => get_option('date_format'), |
| 123 |
'echo' => 0, |
| 124 |
'authors' => '', |
| 125 |
'sort_column' => $sort_column, |
| 126 |
'sort_order' => $sort_order, |
| 127 |
'link_before' => $link_before, |
| 128 |
'link_after' => $link_after, |
| 129 |
'walker' => '' |
| 130 |
); |
| 131 |
$list_pages = wp_list_pages( $page_list_args ); |
| 132 |
|
| 133 |
if ($list_pages) { |
| 134 |
$return = "\n".'<!-- powered by Page-list plugin ver. 1.4 (wordpress.org/extend/plugins/page-list/) -->'."\n"; |
| 135 |
$return .= '<ul class="page-list subpages-page-list '.$class.'">'."\n".$list_pages."\n".'</ul>'; |
| 136 |
}else{ |
| 137 |
$return = ''; |
| 138 |
} |
| 139 |
return $return; |
| 140 |
} |
| 141 |
add_shortcode( 'subpages', 'subpages_shortcode' ); |
| 142 |
add_shortcode( 'sub-pages', 'subpages_shortcode' ); |
| 143 |
add_shortcode( 'children', 'subpages_shortcode' ); |
| 144 |
} |
| 145 |
|
| 146 |
if ( !function_exists('siblings_shortcode') ) { |
| 147 |
function siblings_shortcode( $atts ) { |
| 148 |
global $post; |
| 149 |
$return = ''; |
| 150 |
extract( shortcode_atts( array( |
| 151 |
'depth' => '0', |
| 152 |
//'child_of' => '0', |
| 153 |
'exclude' => '0', |
| 154 |
'exclude_tree' => '', |
| 155 |
'include' => '0', |
| 156 |
'title_li' => '', |
| 157 |
'number' => '', |
| 158 |
'offset' => '', |
| 159 |
'meta_key' => '', |
| 160 |
'meta_value' => '', |
| 161 |
'show_date' => '', |
| 162 |
'sort_column' => 'menu_order, post_title', |
| 163 |
'sort_order' => 'ASC', |
| 164 |
'link_before' => '', |
| 165 |
'link_after' => '', |
| 166 |
'class' => '' |
| 167 |
), $atts ) ); |
| 168 |
|
| 169 |
if( $exclude == 'current' || $exclude == 'this' ){ |
| 170 |
$exclude = $post->ID; |
| 171 |
} |
| 172 |
|
| 173 |
$page_list_args = array( |
| 174 |
'depth' => $depth, |
| 175 |
'child_of' => $post->post_parent, |
| 176 |
'exclude' => $exclude, |
| 177 |
'exclude_tree' => $exclude_tree, |
| 178 |
'include' => $include, |
| 179 |
'title_li' => $title_li, |
| 180 |
'number' => $number, |
| 181 |
'offset' => $offset, |
| 182 |
'meta_key' => $meta_key, |
| 183 |
'meta_value' => $meta_value, |
| 184 |
'show_date' => $show_date, |
| 185 |
'date_format' => get_option('date_format'), |
| 186 |
'echo' => 0, |
| 187 |
'authors' => '', |
| 188 |
'sort_column' => $sort_column, |
| 189 |
'sort_order' => $sort_order, |
| 190 |
'link_before' => $link_before, |
| 191 |
'link_after' => $link_after, |
| 192 |
'walker' => '' |
| 193 |
); |
| 194 |
$list_pages = wp_list_pages( $page_list_args ); |
| 195 |
|
| 196 |
if ($list_pages) { |
| 197 |
$return = "\n".'<!-- powered by Page-list plugin ver. 1.4 (wordpress.org/extend/plugins/page-list/) -->'."\n"; |
| 198 |
$return .= '<ul class="page-list siblings-page-list '.$class.'">'."\n".$list_pages."\n".'</ul>'; |
| 199 |
}else{ |
| 200 |
$return = ''; |
| 201 |
} |
| 202 |
return $return; |
| 203 |
} |
| 204 |
add_shortcode( 'siblings', 'siblings_shortcode' ); |
| 205 |
} |
| 206 |
|