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