summaryrefslogtreecommitdiff
blob: 963f90ce8eb6c0a5074b06454d8c3371b22e43e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
/**
 * Sitemap shortcode.
 *
 * Usage: [sitemap]
 */

add_shortcode( 'sitemap', 'jetpack_sitemap_shortcode' );

/**
 * Renders a tree of pages.
 *
 * @since 4.5.0
 *
 * @return string
 */
function jetpack_sitemap_shortcode() {
	$tree = wp_list_pages(
		array(
			'title_li' => '<b><a href="/">' . esc_html( get_bloginfo( 'name' ) ) . '</a></b>',
			'exclude'  => get_option( 'page_on_front' ),
			'echo'     => false,
		)
	);
	return empty( $tree )
		? ''
		: '<ul class="jetpack-sitemap-shortcode">' . $tree . '</ul>';
}