Version Description
Download this release
Release Info
Developer | dgwyer |
Plugin | Simple Sitemap – Automatically Generate a Responsive Sitemap |
Version | 2.3 |
Comparing to | |
See all releases |
Code changes from version 2.2 to 2.3
- classes/shortcodes/simple-sitemap-group-shortcode.php +201 -0
- classes/shortcodes/simple-sitemap-shortcode.php +256 -0
- classes/simple-sitemap-links.php +67 -0
- classes/simple-sitemap-settings.php +187 -0
- css/simple-sitemap-admin.css +41 -0
- css/simple-sitemap.css +1 -0
- images/david.jpg +0 -0
- js/simple-sitemap-admin.js +24 -0
- readme.txt +17 -7
- simple-sitemap.php +41 -555
classes/shortcodes/simple-sitemap-group-shortcode.php
ADDED
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Class for the [simple-sitemap-group] shortcode
|
4 |
+
*/
|
5 |
+
|
6 |
+
class WPGO_Simple_Sitemap_Group_Shortcode {
|
7 |
+
|
8 |
+
protected $module_roots;
|
9 |
+
|
10 |
+
/* Main class constructor. */
|
11 |
+
public function __construct($module_roots) {
|
12 |
+
|
13 |
+
$this->module_roots = $module_roots;
|
14 |
+
add_shortcode( 'simple-sitemap-group', array( &$this, 'render' ) );
|
15 |
+
}
|
16 |
+
|
17 |
+
/* Shortcode function. */
|
18 |
+
public function render($atts) {
|
19 |
+
|
20 |
+
/* Get attributes from the shortcode. */
|
21 |
+
$atts = shortcode_atts( array(
|
22 |
+
'tax' => 'category', // single taxonomy
|
23 |
+
'container_tag' => 'ul',
|
24 |
+
'term_order' => 'asc',
|
25 |
+
'term_orderby' => 'name',
|
26 |
+
'show_excerpt' => 'false',
|
27 |
+
'title_tag' => '',
|
28 |
+
'excerpt_tag' => 'div',
|
29 |
+
'post_type_tag' => 'h2',
|
30 |
+
'show_label' => 'true',
|
31 |
+
'links' => 'true',
|
32 |
+
//'page_depth' => 0,
|
33 |
+
'order' => 'asc',
|
34 |
+
'orderby' => 'title',
|
35 |
+
'exclude' => ''
|
36 |
+
), $atts );
|
37 |
+
|
38 |
+
// escape tag names
|
39 |
+
$tax = esc_attr( $atts['tax'] );
|
40 |
+
$container_tag = tag_escape( $atts['container_tag'] );
|
41 |
+
$term_order = esc_attr( $atts['term_order'] );
|
42 |
+
$term_orderby = esc_attr( $atts['term_orderby'] );
|
43 |
+
$show_excerpt = esc_attr( $atts['show_excerpt'] );
|
44 |
+
$title_tag = tag_escape( $atts['title_tag'] );
|
45 |
+
$excerpt_tag = tag_escape( $atts['excerpt_tag'] );
|
46 |
+
$post_type_tag = tag_escape( $atts['post_type_tag'] );
|
47 |
+
$show_label = esc_attr( $atts['show_label'] );
|
48 |
+
$links = esc_attr( $atts['links'] );
|
49 |
+
//$page_depth = esc_attr( intval( $atts['page_depth'] ) );
|
50 |
+
$order = esc_attr( $atts['order'] );
|
51 |
+
$orderby = esc_attr( $atts['orderby'] );
|
52 |
+
$exclude = esc_attr( $atts['exclude'] );
|
53 |
+
$post_type = 'post';
|
54 |
+
|
55 |
+
// Format attributes as necessary
|
56 |
+
|
57 |
+
// force 'ul' or 'ol' to be used as the container tag
|
58 |
+
$allowed_container_tags = array('ul', 'ol');
|
59 |
+
if(!in_array($container_tag, $allowed_container_tags)) {
|
60 |
+
$container_tag = 'ul';
|
61 |
+
}
|
62 |
+
|
63 |
+
// convert comma separated strings to arrays
|
64 |
+
$exclude = array_map( 'trim', explode( ',', $exclude) ); // must be array to work in the post query
|
65 |
+
|
66 |
+
// get all public registered post types
|
67 |
+
$args = array(
|
68 |
+
'public' => true
|
69 |
+
);
|
70 |
+
$registered_post_types = get_post_types($args);
|
71 |
+
|
72 |
+
//echo "<pre>";
|
73 |
+
//print_r($registered_post_types);
|
74 |
+
//print_r($post_types);
|
75 |
+
//print_r($exclude);
|
76 |
+
//echo "</pre>";
|
77 |
+
|
78 |
+
$taxonomy_arr = get_object_taxonomies( $post_type );
|
79 |
+
|
80 |
+
// Start output caching (so that existing content in the [simple-sitemap] post doesn't get shoved to the bottom of the post
|
81 |
+
ob_start();
|
82 |
+
|
83 |
+
// sort via specified taxonomy
|
84 |
+
if ( !empty($tax) && in_array( $tax, $taxonomy_arr ) ) {
|
85 |
+
|
86 |
+
// conditionally show label for each post type
|
87 |
+
if( $show_label == 'true' ) {
|
88 |
+
$post_type_obj = get_post_type_object( $post_type );
|
89 |
+
$post_type_name = $post_type_obj->labels->name;
|
90 |
+
echo '<' . $post_type_tag . '>' . esc_html($post_type_name) . '</' . $post_type_tag . '>';
|
91 |
+
}
|
92 |
+
|
93 |
+
$term_attr = array(
|
94 |
+
'orderby' => $term_orderby,
|
95 |
+
'order' => $term_order
|
96 |
+
);
|
97 |
+
$terms = get_terms( $tax, $term_attr );
|
98 |
+
|
99 |
+
foreach($terms as $term) {
|
100 |
+
|
101 |
+
// generate sitemap container element class
|
102 |
+
$container_class = 'simple-sitemap-' . $post_type;
|
103 |
+
|
104 |
+
// bail if post type isn't valid
|
105 |
+
if( !array_key_exists( $post_type, $registered_post_types ) ) {
|
106 |
+
break;
|
107 |
+
}
|
108 |
+
|
109 |
+
// set opening and closing title tag
|
110 |
+
if( !empty($title_tag) ) {
|
111 |
+
$title_open = '<' . $title_tag . '>';
|
112 |
+
$title_close = '</' . $title_tag . '>';
|
113 |
+
}
|
114 |
+
else {
|
115 |
+
$title_open = $title_close = '';
|
116 |
+
}
|
117 |
+
|
118 |
+
$query_args = array(
|
119 |
+
'posts_per_page' => -1,
|
120 |
+
'post_type' => $post_type,
|
121 |
+
'order' => $order,
|
122 |
+
'orderby' => $orderby,
|
123 |
+
'post__not_in' => $exclude,
|
124 |
+
'tax_query' => array(
|
125 |
+
array(
|
126 |
+
'taxonomy' => $tax,
|
127 |
+
'field' => 'slug',
|
128 |
+
'terms' => $term
|
129 |
+
)
|
130 |
+
)
|
131 |
+
);
|
132 |
+
|
133 |
+
echo '<h3>' . $term->name . '</h3>';
|
134 |
+
|
135 |
+
//post query
|
136 |
+
$sitemap_query = new WP_Query( $query_args );
|
137 |
+
|
138 |
+
if ( $sitemap_query->have_posts() ) :
|
139 |
+
|
140 |
+
echo '<' . $container_tag . ' class="' . esc_attr($container_class) . '">';
|
141 |
+
|
142 |
+
// start of the loop
|
143 |
+
while ( $sitemap_query->have_posts() ) : $sitemap_query->the_post();
|
144 |
+
|
145 |
+
// title
|
146 |
+
$title_text = get_the_title();
|
147 |
+
|
148 |
+
if( !empty( $title_text ) ) {
|
149 |
+
if ( $links == 'true' ) {
|
150 |
+
$title = $title_open . '<a href="' . esc_url(get_permalink()) . '">' . esc_html($title_text) . '</a>' . $title_close;
|
151 |
+
} else {
|
152 |
+
$title = $title_open . esc_html($title_text) . $title_close;
|
153 |
+
}
|
154 |
+
}
|
155 |
+
else {
|
156 |
+
if ( $links == 'true' ) {
|
157 |
+
$title = $title_open . '<a href="' . esc_url(get_permalink()) . '">' . '(no title)' . '</a>' . $title_close;
|
158 |
+
} else {
|
159 |
+
$title = $title_open . '(no title)' . $title_close;
|
160 |
+
}
|
161 |
+
}
|
162 |
+
|
163 |
+
// excerpt
|
164 |
+
$excerpt = $show_excerpt == 'true' ? '<' . $excerpt_tag . '>' . esc_html(get_the_excerpt()) . '</' . $excerpt_tag . '>' : '';
|
165 |
+
|
166 |
+
// render list item
|
167 |
+
echo '<li>';
|
168 |
+
echo $title;
|
169 |
+
echo $excerpt;
|
170 |
+
echo '</li>';
|
171 |
+
|
172 |
+
endwhile; // end of post loop -->
|
173 |
+
|
174 |
+
echo '</' . $container_tag . '>';
|
175 |
+
|
176 |
+
// put pagination functions here
|
177 |
+
wp_reset_postdata();
|
178 |
+
|
179 |
+
else:
|
180 |
+
|
181 |
+
echo '<p>' . __( 'Sorry, no posts matched your criteria.', 'wpgo-simple-sitemap-pro' ) . '</p>';
|
182 |
+
|
183 |
+
endif;
|
184 |
+
}
|
185 |
+
}
|
186 |
+
else {
|
187 |
+
echo "No posts found.";
|
188 |
+
}
|
189 |
+
|
190 |
+
// ***********
|
191 |
+
// CONTENT END
|
192 |
+
// ***********
|
193 |
+
ob_start();
|
194 |
+
|
195 |
+
$sitemap = ob_get_contents();
|
196 |
+
ob_end_clean();
|
197 |
+
|
198 |
+
return wp_kses_post($sitemap);
|
199 |
+
}
|
200 |
+
|
201 |
+
} /* End class definition */
|
classes/shortcodes/simple-sitemap-shortcode.php
ADDED
@@ -0,0 +1,256 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Class for the [simple-sitemap] shortcode
|
4 |
+
*/
|
5 |
+
|
6 |
+
class WPGO_Simple_Sitemap_Shortcode {
|
7 |
+
|
8 |
+
protected $module_roots;
|
9 |
+
|
10 |
+
/* Main class constructor. */
|
11 |
+
public function __construct($module_roots) {
|
12 |
+
|
13 |
+
$this->module_roots = $module_roots;
|
14 |
+
add_shortcode( 'simple-sitemap', array( &$this, 'render' ) );
|
15 |
+
|
16 |
+
// Allow shortcodes to be used in widgets (the callbacks are WordPress functions)
|
17 |
+
add_filter( 'widget_text', 'shortcode_unautop' );
|
18 |
+
add_filter( 'widget_text', 'do_shortcode' );
|
19 |
+
}
|
20 |
+
|
21 |
+
/* Shortcode function. */
|
22 |
+
public function render($atts) {
|
23 |
+
|
24 |
+
/* Get attributes from the shortcode. */
|
25 |
+
$atts = shortcode_atts( array(
|
26 |
+
'types' => 'page',
|
27 |
+
'show_label' => 'true',
|
28 |
+
'show_excerpt' => 'false',
|
29 |
+
'container_tag' => 'ul',
|
30 |
+
'title_tag' => '',
|
31 |
+
'post_type_tag' => 'h2',
|
32 |
+
'excerpt_tag' => 'div',
|
33 |
+
'links' => 'true',
|
34 |
+
'page_depth' => 0,
|
35 |
+
'order' => 'asc',
|
36 |
+
'orderby' => 'title',
|
37 |
+
'exclude' => ''
|
38 |
+
), $atts, 'simple-sitemap' );
|
39 |
+
|
40 |
+
// Setup more readable attribute vars
|
41 |
+
|
42 |
+
$post_types = esc_attr( $atts['types'] );
|
43 |
+
$show_label = esc_attr( $atts['show_label'] );
|
44 |
+
$show_excerpt = esc_attr( $atts['show_excerpt'] );
|
45 |
+
$container_tag = tag_escape( $atts['container_tag'] );
|
46 |
+
$title_tag = tag_escape( $atts['title_tag'] );
|
47 |
+
$post_type_tag = tag_escape( $atts['post_type_tag'] );
|
48 |
+
$excerpt_tag = tag_escape( $atts['excerpt_tag'] );
|
49 |
+
$links = esc_attr( $atts['links'] );
|
50 |
+
$page_depth = esc_attr( intval( $atts['page_depth'] ) );
|
51 |
+
$order = esc_attr( $atts['order'] );
|
52 |
+
$orderby = esc_attr( $atts['orderby'] );
|
53 |
+
$exclude = esc_attr( $atts['exclude'] );
|
54 |
+
|
55 |
+
// Format attributes as necessary
|
56 |
+
|
57 |
+
// force 'ul' or 'ol' to be used as the container tag
|
58 |
+
$allowed_container_tags = array('ul', 'ol');
|
59 |
+
if(!in_array($container_tag, $allowed_container_tags)) {
|
60 |
+
$container_tag = 'ul';
|
61 |
+
}
|
62 |
+
|
63 |
+
//echo "<pre>";
|
64 |
+
//print_r($registered_post_types);
|
65 |
+
//print_r($post_types);
|
66 |
+
//print_r($exclude);
|
67 |
+
//print_r($container_tag);
|
68 |
+
//echo "</pre>";
|
69 |
+
|
70 |
+
// convert comma separated strings to arrays
|
71 |
+
$post_types = array_map( 'trim', explode( ',', $post_types ) );
|
72 |
+
$exclude = array_map( 'trim', explode( ',', $exclude) );
|
73 |
+
|
74 |
+
// get all public registered post types
|
75 |
+
$args = array(
|
76 |
+
'public' => true
|
77 |
+
);
|
78 |
+
$registered_post_types = get_post_types($args);
|
79 |
+
|
80 |
+
// Start output caching (so that existing content in the [simple-sitemap] post doesn't get shoved to the bottom of the post
|
81 |
+
ob_start();
|
82 |
+
|
83 |
+
foreach( $post_types as $post_type ) :
|
84 |
+
|
85 |
+
// generate sitemap container element class
|
86 |
+
$container_class = 'simple-sitemap-' . $post_type;
|
87 |
+
|
88 |
+
// bail if post type isn't valid
|
89 |
+
if( !array_key_exists( $post_type, $registered_post_types ) ) {
|
90 |
+
break;
|
91 |
+
}
|
92 |
+
|
93 |
+
// set opening and closing title tag
|
94 |
+
if( !empty($title_tag) ) {
|
95 |
+
$title_open = '<' . $title_tag . '>';
|
96 |
+
$title_close = '</' . $title_tag . '>';
|
97 |
+
}
|
98 |
+
else {
|
99 |
+
$title_open = $title_close = '';
|
100 |
+
}
|
101 |
+
|
102 |
+
// conditionally show label for each post type
|
103 |
+
if( $show_label == 'true' ) {
|
104 |
+
$post_type_obj = get_post_type_object( $post_type );
|
105 |
+
$post_type_name = $post_type_obj->labels->name;
|
106 |
+
echo '<' . $post_type_tag . '>' . esc_html($post_type_name) . '</' . $post_type_tag . '>';
|
107 |
+
}
|
108 |
+
|
109 |
+
$query_args = array(
|
110 |
+
'posts_per_page' => -1,
|
111 |
+
'post_type' => $post_type,
|
112 |
+
'order' => $order,
|
113 |
+
'orderby' => $orderby,
|
114 |
+
'post__not_in' => $exclude
|
115 |
+
);
|
116 |
+
|
117 |
+
// use custom rendering for 'page' post type to properly render sub pages
|
118 |
+
if( $post_type == 'page' ) {
|
119 |
+
$arr = array(
|
120 |
+
'title_tag' => $title_tag,
|
121 |
+
'links' => $links,
|
122 |
+
'title_open' => $title_open,
|
123 |
+
'title_close' => $title_close,
|
124 |
+
'page_depth' => $page_depth,
|
125 |
+
'exclude' => $exclude
|
126 |
+
);
|
127 |
+
echo '<' . $container_tag . ' class="' . esc_attr($container_class) . '">';
|
128 |
+
$this->list_pages($arr, $query_args);
|
129 |
+
echo '</' . $container_tag . '>';
|
130 |
+
continue;
|
131 |
+
}
|
132 |
+
|
133 |
+
//post query
|
134 |
+
$sitemap_query = new WP_Query( $query_args );
|
135 |
+
|
136 |
+
if ( $sitemap_query->have_posts() ) :
|
137 |
+
|
138 |
+
echo '<' . $container_tag . ' class="' . esc_attr($container_class) . '">';
|
139 |
+
|
140 |
+
// start of the loop
|
141 |
+
while ( $sitemap_query->have_posts() ) : $sitemap_query->the_post();
|
142 |
+
|
143 |
+
// title
|
144 |
+
$title_text = get_the_title();
|
145 |
+
|
146 |
+
if( !empty( $title_text ) ) {
|
147 |
+
if ( $links == 'true' ) {
|
148 |
+
$title = $title_open . '<a href="' . esc_url(get_permalink()) . '">' . esc_html($title_text) . '</a>' . $title_close;
|
149 |
+
} else {
|
150 |
+
$title = $title_open . esc_html($title_text) . $title_close;
|
151 |
+
}
|
152 |
+
}
|
153 |
+
else {
|
154 |
+
if ( $links == 'true' ) {
|
155 |
+
$title = $title_open . '<a href="' . esc_url(get_permalink()) . '">' . '(no title)' . '</a>' . $title_close;
|
156 |
+
} else {
|
157 |
+
$title = $title_open . '(no title)' . $title_close;
|
158 |
+
}
|
159 |
+
}
|
160 |
+
|
161 |
+
// excerpt
|
162 |
+
$excerpt = $show_excerpt == 'true' ? '<' . $excerpt_tag . '>' . esc_html(get_the_excerpt()) . '</' . $excerpt_tag . '>' : '';
|
163 |
+
|
164 |
+
// render list item
|
165 |
+
echo '<li>';
|
166 |
+
echo $title;
|
167 |
+
echo $excerpt;
|
168 |
+
echo '</li>';
|
169 |
+
|
170 |
+
endwhile; // end of post loop -->
|
171 |
+
|
172 |
+
echo '</' . $container_tag . '>';
|
173 |
+
|
174 |
+
// put pagination functions here
|
175 |
+
wp_reset_postdata();
|
176 |
+
|
177 |
+
else:
|
178 |
+
|
179 |
+
echo '<p>' . __( 'Sorry, no posts matched your criteria.', 'wpgo-simple-sitemap-pro' ) . '</p>';
|
180 |
+
|
181 |
+
endif;
|
182 |
+
|
183 |
+
endforeach;
|
184 |
+
|
185 |
+
// ***********
|
186 |
+
// CONTENT END
|
187 |
+
// ***********
|
188 |
+
|
189 |
+
$sitemap = ob_get_contents();
|
190 |
+
ob_end_clean();
|
191 |
+
|
192 |
+
return wp_kses_post($sitemap);
|
193 |
+
}
|
194 |
+
|
195 |
+
public function list_pages( $arr, $query_args ) {
|
196 |
+
|
197 |
+
$map_args = array(
|
198 |
+
'title' => 'post_title',
|
199 |
+
'date' => 'post_date',
|
200 |
+
'author' => 'post_author',
|
201 |
+
'modified' => 'post_modified'
|
202 |
+
);
|
203 |
+
|
204 |
+
// modify the query args for get_pages() if necessary
|
205 |
+
$orderby = array_key_exists( $query_args['orderby'], $map_args ) ? $map_args[$query_args['orderby']] : $query_args['orderby'];
|
206 |
+
|
207 |
+
$r = array(
|
208 |
+
'depth' => $arr['page_depth'],
|
209 |
+
'show_date' => '',
|
210 |
+
'date_format' => get_option( 'date_format' ),
|
211 |
+
'child_of' => 0,
|
212 |
+
'exclude' => $arr['exclude'],
|
213 |
+
'echo' => 1,
|
214 |
+
'authors' => '',
|
215 |
+
'sort_column' => $orderby,
|
216 |
+
'sort_order' => $query_args['order'],
|
217 |
+
'link_before' => '',
|
218 |
+
'link_after' => '',
|
219 |
+
'item_spacing' => '',
|
220 |
+
//'walker' => '',
|
221 |
+
);
|
222 |
+
|
223 |
+
$output = '';
|
224 |
+
$current_page = 0;
|
225 |
+
$r['exclude'] = preg_replace( '/[^0-9,]/', '', $r['exclude'] ); // sanitize, mostly to keep spaces out
|
226 |
+
|
227 |
+
// Query pages.
|
228 |
+
$r['hierarchical'] = 0;
|
229 |
+
$pages = get_pages( $r );
|
230 |
+
|
231 |
+
if ( ! empty( $pages ) ) {
|
232 |
+
global $wp_query;
|
233 |
+
if ( is_page() || is_attachment() || $wp_query->is_posts_page ) {
|
234 |
+
$current_page = get_queried_object_id();
|
235 |
+
} elseif ( is_singular() ) {
|
236 |
+
$queried_object = get_queried_object();
|
237 |
+
if ( is_post_type_hierarchical( $queried_object->post_type ) ) {
|
238 |
+
$current_page = $queried_object->ID;
|
239 |
+
}
|
240 |
+
}
|
241 |
+
|
242 |
+
$output .= walk_page_tree( $pages, $r['depth'], $current_page, $r );
|
243 |
+
}
|
244 |
+
|
245 |
+
// remove links
|
246 |
+
if( $arr['links'] != 'true' )
|
247 |
+
$output = preg_replace('/<a href=\"(.*?)\">(.*?)<\/a>/', "\\2", $output);
|
248 |
+
|
249 |
+
if ( $r['echo'] ) {
|
250 |
+
echo $output;
|
251 |
+
} else {
|
252 |
+
return $output;
|
253 |
+
}
|
254 |
+
}
|
255 |
+
|
256 |
+
} /* End class definition */
|
classes/simple-sitemap-links.php
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Main WordPress plugin index page links and admin notices
|
4 |
+
*/
|
5 |
+
|
6 |
+
class WPGO_Simple_Sitemap_Links {
|
7 |
+
|
8 |
+
protected $module_roots;
|
9 |
+
|
10 |
+
/* Main class constructor. */
|
11 |
+
public function __construct($module_roots) {
|
12 |
+
|
13 |
+
$this->module_roots = $module_roots;
|
14 |
+
|
15 |
+
add_filter( 'plugin_row_meta', array( &$this, 'plugin_action_links' ), 10, 2 );
|
16 |
+
add_filter( 'plugin_action_links', array( &$this, 'plugin_settings_link' ), 10, 2 );
|
17 |
+
register_activation_hook( __FILE__, array( &$this, 'set_admin_notice_transient' ) );
|
18 |
+
add_action( 'admin_notices', array( &$this, 'admin_notice' ) );
|
19 |
+
}
|
20 |
+
|
21 |
+
/* Admin Notice first time plugin is activated. */
|
22 |
+
public function admin_notice(){
|
23 |
+
|
24 |
+
/* Only display admin notice if transient exists */
|
25 |
+
if( get_transient( 'simple-sitemap-admin-notice' ) ){
|
26 |
+
?>
|
27 |
+
<div class="updated notice is-dismissible">
|
28 |
+
<p>Welcome to Simple Sitemap! To get started right away please visit the plugin <a href="<?php echo get_admin_url() . 'options-general.php?page=simple-sitemap/classes/simple-sitemap-settings.php'; ?>"><strong>settings & documentation</strong></a> page.</p>
|
29 |
+
</div>
|
30 |
+
<?php
|
31 |
+
// might not be needed to do this manually
|
32 |
+
delete_transient( 'simple-sitemap-admin-notice' );
|
33 |
+
}
|
34 |
+
}
|
35 |
+
|
36 |
+
/* Runs only when the plugin is activated. */
|
37 |
+
public function set_admin_notice_transient() {
|
38 |
+
// set transient to expire after 5 seconds
|
39 |
+
set_transient( 'simple-sitemap-admin-notice', true, 5 );
|
40 |
+
}
|
41 |
+
|
42 |
+
// Display a Settings link on the main Plugins page
|
43 |
+
public function plugin_action_links( $links, $file ) {
|
44 |
+
|
45 |
+
//if ( $file == plugin_basename( __FILE__ ) ) {
|
46 |
+
// add a link to pro plugin
|
47 |
+
//$links[] = '<a style="color:limegreen;" href="https://wpgoplugins.com/plugins/simple-sitemap-pro/" target="_blank" title="Upgrade to Pro - 100% money back guarantee"><span class="dashicons dashicons-awards"></span></a>';
|
48 |
+
//}
|
49 |
+
|
50 |
+
return $links;
|
51 |
+
}
|
52 |
+
|
53 |
+
// Display a Settings link on the main Plugins page
|
54 |
+
public function plugin_settings_link( $links, $file ) {
|
55 |
+
|
56 |
+
if ( $file == 'simple-sitemap/simple-sitemap.php') {
|
57 |
+
$pccf_links = '<a href="' . get_admin_url() . 'options-general.php?page=simple-sitemap/classes/simple-sitemap-settings.php">' . __( 'Getting Started' ) . '</a>';
|
58 |
+
array_unshift( $links, $pccf_links );
|
59 |
+
|
60 |
+
$pccf_links = '<a style="color:#60a559;" href="https://wpgoplugins.com/plugins/simple-sitemap-pro/" target="_blank" title="Try Simple Sitemap Pro today - 100% money back guarantee"><b>Upgrade to Pro</b></a>';
|
61 |
+
array_push( $links, $pccf_links );
|
62 |
+
}
|
63 |
+
|
64 |
+
return $links;
|
65 |
+
}
|
66 |
+
|
67 |
+
} /* End class definition */
|
classes/simple-sitemap-settings.php
ADDED
@@ -0,0 +1,187 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Plugins options page
|
4 |
+
*/
|
5 |
+
|
6 |
+
class WPGO_Simple_Sitemap_Settings {
|
7 |
+
|
8 |
+
protected $module_roots;
|
9 |
+
|
10 |
+
/* Main class constructor. */
|
11 |
+
public function __construct($module_roots) {
|
12 |
+
|
13 |
+
$this->module_roots = $module_roots;
|
14 |
+
|
15 |
+
add_action( 'admin_init', array( &$this, 'init' ) );
|
16 |
+
add_action( 'admin_menu', array( &$this, 'add_options_page' ) );
|
17 |
+
}
|
18 |
+
|
19 |
+
/* Init plugin options to white list our options. */
|
20 |
+
public function init() {
|
21 |
+
register_setting( 'wpss_plugin_options', 'wpss_options', array( &$this, 'validate_options' ) );
|
22 |
+
}
|
23 |
+
|
24 |
+
/* Sanitize and validate input. Accepts an array, return a sanitized array. */
|
25 |
+
public function validate_options( $input ) {
|
26 |
+
// Strip html from textboxes
|
27 |
+
// e.g. $input['textbox'] = wp_filter_nohtml_kses($input['textbox']);
|
28 |
+
//$input['txt_page_ids'] = sanitize_text_field( $input['txt_page_ids'] );
|
29 |
+
|
30 |
+
return $input;
|
31 |
+
}
|
32 |
+
|
33 |
+
/* Add menu page. */
|
34 |
+
public function add_options_page() {
|
35 |
+
add_options_page( __( 'Simple Sitemap Settings Page', 'simple-sitemap' ), __( 'Simple Sitemap', 'simple-sitemap' ), 'manage_options', __FILE__, array( &$this, 'render_form' ) );
|
36 |
+
}
|
37 |
+
|
38 |
+
/* Draw the menu page itself. */
|
39 |
+
public function render_form() {
|
40 |
+
?>
|
41 |
+
<div class="wrap">
|
42 |
+
|
43 |
+
<h2 style="float:left;"><?php _e( 'Simple Sitemap - Settings & Documentation', 'simple-sitemap' ); ?></h2>
|
44 |
+
<div style="float:right;padding:1px;background: rgba(57, 49, 76, 0.33);"><a style="display: block;line-height:0;" target="_blank" title="We love to develop WordPress plugins!" alt="WPGO Plugins Site" href="https://wpgoplugins.com/"><img src="<?php echo plugins_url(); ?>/simple-sitemap/images/wpgo_plugins_logo.png"></a></div>
|
45 |
+
|
46 |
+
<div style="clear:both;"></div>
|
47 |
+
|
48 |
+
<div class="ss-box" style="margin-top:30px;">
|
49 |
+
<h3 style="margin-top:5px;display:inline-block;">Available Shortcodes</h3><button id="shortcodes-btn" style="float:right;" class="button">Expand <span style="vertical-align:sub;width:16px;height:16px;font-size:16px;" class="dashicons dashicons-arrow-down-alt2"></span></button>
|
50 |
+
|
51 |
+
<div id="shortcodes-wrap">
|
52 |
+
<p style="margin:0;"><code>[simple-sitemap]</code> <?php printf( __( 'Display a list of posts for one or more post types.<br><br>', 'simple-sitemap' ) ); ?>
|
53 |
+
</p>
|
54 |
+
<p style="margin:0;"><code>[simple-sitemap-group]</code> <?php printf( __( 'Display a list of posts grouped category, OR tags.<br><br>', 'simple-sitemap' ) ); ?>
|
55 |
+
</p>
|
56 |
+
|
57 |
+
<p style="margin:0;"><code>[simple-sitemap-categories]</code> <span class="pro" title="Shortcode available in Simple Sitemap Pro"><a href="https://wpgoplugins.com/plugins/simple-sitemap-pro/" target="_blank">PRO</a></span> <?php printf( __( 'Display a list of post categories with various options available (such as post count).<br><br>', 'simple-sitemap' ) ); ?>
|
58 |
+
</p>
|
59 |
+
|
60 |
+
<p style="margin:0 0 40px 0;"><code>[simple-sitemap-child]</code> <span class="pro" title="Shortcode available in Simple Sitemap Pro"><a href="https://wpgoplugins.com/plugins/simple-sitemap-pro/" target="_blank">PRO</a></span> <?php printf( __( 'Display a list of child pages for a specific parent page.', 'simple-sitemap' ) ); ?>
|
61 |
+
</p>
|
62 |
+
</div>
|
63 |
+
</div>
|
64 |
+
|
65 |
+
<?php $pro_attribute = '<span class="pro" title="Shortcode attribute available in Simple Sitemap Pro"><a href="https://wpgoplugins.com/plugins/simple-sitemap-pro/" target="_blank">PRO</a></span>'; ?>
|
66 |
+
|
67 |
+
<div class="ss-box">
|
68 |
+
<h3 style="margin-top:5px;display:inline-block;">Shortcode Attributes & Default Values</h3><button id="attributes-btn" style="float:right;" class="button">Expand <span style="vertical-align:sub;width:16px;height:16px;font-size:16px;" class="dashicons dashicons-arrow-down-alt2"></span></button>
|
69 |
+
|
70 |
+
<div id="attributes-wrap">
|
71 |
+
|
72 |
+
<p>Note: Default values are always used for missing shortcode attributes. i.e. Override only the values you want to change.</p>
|
73 |
+
<p style="margin:20px 0 0 0;"><code><b>[simple-sitemap ... ]</b></code></p>
|
74 |
+
<ul class="shortcode-attributes">
|
75 |
+
<li><code>types="page"</code> - List of posts for each post type specified, in the order entered.</li>
|
76 |
+
<li><code>container_tag="ul"</code> - List type tag, ordered, or unordered.</li>
|
77 |
+
<li><code>title_tag=""</code> - Tag used to wrap each sitemap item in a specified tag.</li>
|
78 |
+
<li><code>post_type_tag="h2"</code> - Tag used to display the post type label.</li>
|
79 |
+
<li><code>show_excerpt="true"</code> - Optionally show post excerpt (if defined) under each sitemap item.</li>
|
80 |
+
<li><code>excerpt_tag=""</code> - Tag used to wrap the post excerpt text.</li>
|
81 |
+
<li><code>show_label="true"</code> - Optionally show post type label above the sitemap list of posts.</li>
|
82 |
+
<li><code>links="true"</code> - Show sitemap items as links or plain text.</li>
|
83 |
+
<li><code>page_depth="0"</code> - For the 'page' post type allow the indentation depth to be specified.</li>
|
84 |
+
<li><code>order="asc"</code> - List posts for each post type in ascending, or descending order.</li>
|
85 |
+
<li><code>orderby="title"</code> - Value to sort posts by (title, date, author etc.). See the full list <a href="https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters" target="_blank">here</a>.</li>
|
86 |
+
<li><code>exclude=""</code> - Comma separated list of post IDs to exclude from the sitemap.</li>
|
87 |
+
<li><code>include=""</code> <?php echo $pro_attribute; ?> - Comma separated list of post IDs to INCLUDE in the sitemap only. Other posts will be ignored.</li>
|
88 |
+
<li><code>render=""</code> <?php echo $pro_attribute; ?> - Set to "tab" to display posts in a tabbed layout!</li>
|
89 |
+
<li><code>list_icon="true"</code> <?php echo $pro_attribute; ?> - Optionally display HTML bullet icons.</li>
|
90 |
+
<li><code>separator="false"</code> <?php echo $pro_attribute; ?> - Optionally render separator lines inbetween sitemap items.</li>
|
91 |
+
<li><code>horizontal="false"</code> <?php echo $pro_attribute; ?> - Set to "true" to display sitemap items in a flat horizontal list. Great for adding a sitemap to the footer!</li>
|
92 |
+
<li><code>horizontal_separator=", "</code> <?php echo $pro_attribute; ?> - The character(s) used to separate sitemap items. Use with the 'horizontal' attribute.</li>
|
93 |
+
<li><code>image="false"</code> <?php echo $pro_attribute; ?> - Optionally show the post featured image (if defined) next to each sitemap item.</li>
|
94 |
+
</ul>
|
95 |
+
|
96 |
+
<p style="margin:30px 0 0 0;"><code><b>[simple-sitemap-group ... ]</b></code></p>
|
97 |
+
|
98 |
+
<ul class="shortcode-attributes">
|
99 |
+
<li><code>tax="category"</code> - List posts grouped by categories OR tags ('post_tag').</li>
|
100 |
+
<li><code>container_tag="ul"</code> - List type tag, ordered, or unordered.</li>
|
101 |
+
<li><code>term_order="asc"</code> - List taxonomy term labels in ascending, or descending order.</li>
|
102 |
+
<li><code>term_orderby="title"</code> - Order post taxonomy term labels by title etc.</li>
|
103 |
+
<li><code>show_excerpt="true"</code> - Optionally show post excerpt (if defined) under each sitemap item.</li>
|
104 |
+
<li><code>title_tag=""</code> - Tag used to wrap each sitemap item in a specified tag.</li>
|
105 |
+
<li><code>excerpt_tag=""</code> - Tag used to wrap the post excerpt text.</li>
|
106 |
+
<li><code>post_type_tag="h2"</code> - Tag used to display the post type label.</li>
|
107 |
+
<li><code>show_label="true"</code> - Optionally show post type label above the sitemap list of posts.</li>
|
108 |
+
<li><code>links="true"</code> - Show sitemap items as links or plain text.</li>
|
109 |
+
<li><code>order="asc"</code> - List posts for each post type in ascending, or descending order.</li>
|
110 |
+
<li><code>orderby="title"</code> - Value to sort posts by (title, date, author etc.). See the full list <a href="https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters" target="_blank">here</a>.</li>
|
111 |
+
<li><code>exclude=""</code> - Comma separated list of post IDs to exclude from the sitemap.</li>
|
112 |
+
<li><code>type="post"</code> <?php echo $pro_attribute; ?> - List posts grouped by taxonomy from ANY post type.</li>
|
113 |
+
<li><code>exclude_terms=""</code> <?php echo $pro_attribute; ?> - Comma separated list of taxonomy terms to exclude.</li>
|
114 |
+
<li><code>nofollow="0"</code> <?php echo $pro_attribute; ?> - Set to "1" to make sitemap links <a href="https://en.wikipedia.org/wiki/Nofollow" target="_blank">nofollow</a>.</li>
|
115 |
+
<li><code>visibility="all"</code> <?php echo $pro_attribute; ?> - List all posts, or just public ones (private posts will be ignored).</li>
|
116 |
+
<li><code>render=""</code> <?php echo $pro_attribute; ?> - Set to "tab" to display posts in a tabbed layout!</li>
|
117 |
+
<li><code>list_icon="true"</code> <?php echo $pro_attribute; ?> - Optionally display HTML bullet icons.</li>
|
118 |
+
<li><code>separator="false"</code> <?php echo $pro_attribute; ?> - Optionally render separator lines inbetween sitemap items.</li>
|
119 |
+
<li><code>horizontal="false"</code> <?php echo $pro_attribute; ?> - Set to "true" to display sitemap items in a flat horizontal list. Great for adding a sitemap to the footer!</li>
|
120 |
+
<li><code>horizontal_separator=", "</code> <?php echo $pro_attribute; ?> - The character(s) used to separate sitemap items. Use with the 'horizontal' attribute.</li>
|
121 |
+
<li><code>image="false"</code> <?php echo $pro_attribute; ?> - Optionally show the post featured image (if defined) next to each sitemap item.</li>
|
122 |
+
</ul>
|
123 |
+
|
124 |
+
<br><hr><br><?php printf( __( 'The following (public) registered post types are available: ', 'simple-sitemap' ) ); ?>
|
125 |
+
<?php
|
126 |
+
$post_type_args = array(
|
127 |
+
'public' => true
|
128 |
+
);
|
129 |
+
$registered_post_types = get_post_types($post_type_args);
|
130 |
+
$registered_post_types_str = implode(', ', $registered_post_types);
|
131 |
+
echo '<code>"' . $registered_post_types_str . '"</code>';
|
132 |
+
?><br><br>
|
133 |
+
</div>
|
134 |
+
</div>
|
135 |
+
|
136 |
+
<div style="margin-top:30px;"></div>
|
137 |
+
|
138 |
+
<hr>
|
139 |
+
|
140 |
+
<table class="form-table">
|
141 |
+
|
142 |
+
<tr valign="top">
|
143 |
+
<th scope="row">Like the plugin?</th>
|
144 |
+
<td>
|
145 |
+
<p>Then why not try Simple Sitemap Pro to access powerful additional features. Try risk free today with our <span style="font-weight: bold;">100% money back guarantee!</span></p>
|
146 |
+
<div style="margin-top:10px;"><input class="button" type="button" value="Upgrade to Pro" onClick="window.open('https://wpgoplugins.com/plugins/simple-sitemap-pro/')"></div>
|
147 |
+
</td>
|
148 |
+
</tr>
|
149 |
+
|
150 |
+
<tr valign="top">
|
151 |
+
<th scope="row">Buy me a coffee?</th>
|
152 |
+
<td>
|
153 |
+
<div style="float:left;"><a style="margin-right:10px;line-height:0;display:block;" href="https://wpgoplugins.com/plugins/simple-sitemap-pro/" target="_blank"><img style="width:75px;border-radius: 4px;border: 1px #b3bfcc solid;" src="<?php echo plugins_url(); ?>/simple-sitemap/images/david.jpg"></a></div>
|
154 |
+
<p style="margin-top:0;">Hi there, I'm David. I spend most of my time developing FREE WordPress plugins like this one!<br><br>If you like Simple Sitemap and use it on your website <b><em>please</em></b> consider making a <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FBAG4ZHA4TTUC" target="_blank">donation</a>, or purchase the <a href="https://wpgoplugins.com/plugins/simple-sitemap-pro/" target="_blank">pro version</a>, to help fund continued development.<br><br>Thanks for your support!<span style="margin-left:5px;" class="dashicons dashicons-smiley"></span></p>
|
155 |
+
</td>
|
156 |
+
</tr>
|
157 |
+
|
158 |
+
<tr valign="top">
|
159 |
+
<th scope="row">Read all about it!</th>
|
160 |
+
<td>
|
161 |
+
<p>Signup to our plugin newsletter for news and updates about our latest work, and what's coming.</p>
|
162 |
+
<div style="margin-top:10px;"><input class="button" type="button" value="Subscribe here..." onClick="window.open('http://eepurl.com/bXZmmD')"></div>
|
163 |
+
</td>
|
164 |
+
</tr>
|
165 |
+
|
166 |
+
<tr valign="top">
|
167 |
+
<th scope="row">Keep in touch...</th>
|
168 |
+
<td>
|
169 |
+
<div><p style="margin-bottom:10px;">Come and say hello. I'd love to hear from you!</p>
|
170 |
+
<span><a class="social-link" href="http://www.twitter.com/dgwyer" title="Follow us on Twitter" target="_blank"><img src="<?php echo plugins_url(); ?>/simple-sitemap/images/twitter.png" /></a></span>
|
171 |
+
<span><a class="social-link" href="https://www.facebook.com/wpgoplugins/" title="Our Facebook page" target="_blank"><img src="<?php echo plugins_url(); ?>/simple-sitemap/images/facebook.png" /></a></span>
|
172 |
+
<span><a class="social-link" href="https://www.youtube.com/channel/UCWzjTLWoyMgtIfpDgJavrTg" title="View our YouTube channel" target="_blank"><img src="<?php echo plugins_url(); ?>/simple-sitemap/images/yt.png" /></a></span>
|
173 |
+
<span><a style="text-decoration:none;" title="Need help with ANY aspect of WordPress? We're here to help!" href="https://wpgoplugins.com/need-help-with-wordpress/" target="_blank"><span style="margin-left:-2px;color:#d41515;font-size:39px;line-height:32px;width:39px;height:39px;" class="dashicons dashicons-sos"></span></a></span>
|
174 |
+
</div>
|
175 |
+
</td>
|
176 |
+
</tr>
|
177 |
+
|
178 |
+
<tr><td colspan="2" style="padding:0;"><div style="margin-bottom:20px;margin-top:15px;">Please <a href="https://wpgoplugins.com/contact" target="_blank">report</a> any plugin issues, or suggest additional features. <span style="font-weight:bold;">All feedback welcome!</span></div>
|
179 |
+
</td></tr>
|
180 |
+
|
181 |
+
</table>
|
182 |
+
|
183 |
+
</div>
|
184 |
+
<?php
|
185 |
+
}
|
186 |
+
|
187 |
+
} /* End class definition */
|
css/simple-sitemap-admin.css
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* Admin settings page styles. */
|
2 |
+
|
3 |
+
.pro {
|
4 |
+
background: #f5d53e;
|
5 |
+
margin: 0 0 0 0;
|
6 |
+
padding: 1px 3px;
|
7 |
+
font-weight: bold;
|
8 |
+
border-radius: 2px;
|
9 |
+
font-size: 10px;
|
10 |
+
color: #151515;
|
11 |
+
}
|
12 |
+
|
13 |
+
.pro a {
|
14 |
+
color: #151515;
|
15 |
+
text-decoration: none;
|
16 |
+
}
|
17 |
+
|
18 |
+
.shortcode-attributes {
|
19 |
+
list-style-type:disc;
|
20 |
+
}
|
21 |
+
|
22 |
+
.shortcode-attributes li {
|
23 |
+
margin-left: 25px;
|
24 |
+
}
|
25 |
+
|
26 |
+
.ss-box {
|
27 |
+
background:#fff;
|
28 |
+
border: 1px dashed #ccc;
|
29 |
+
font-size: 13px;
|
30 |
+
margin: 20px 0 10px 0;
|
31 |
+
padding: 10px 10px 5px 10px;
|
32 |
+
}
|
33 |
+
|
34 |
+
#shortcodes-wrap, #attributes-wrap {
|
35 |
+
display: none;
|
36 |
+
}
|
37 |
+
|
38 |
+
.social-link {
|
39 |
+
display: inline-block;
|
40 |
+
line-height: 0;
|
41 |
+
}
|
css/simple-sitemap.css
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
/* Styles for sitemap on front end. Only added to pages with sitemap shortcode on */
|
images/david.jpg
ADDED
Binary file
|
js/simple-sitemap-admin.js
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
jQuery(document).ready(function( $ ) {
|
2 |
+
|
3 |
+
$('#shortcodes-btn').on('click', function() {
|
4 |
+
var isHidden = $('#shortcodes-wrap').is( ":hidden" );
|
5 |
+
$('#shortcodes-wrap').toggle( function() {
|
6 |
+
if(isHidden) {
|
7 |
+
$('#shortcodes-btn').html('Collapse <span style="vertical-align:sub;width:16px;height:16px;font-size:16px;" class="dashicons dashicons-arrow-up-alt2"></span>');
|
8 |
+
} else {
|
9 |
+
$('#shortcodes-btn').html('Expand <span style="vertical-align:sub;width:16px;height:16px;font-size:16px;" class="dashicons dashicons-arrow-down-alt2"></span>');
|
10 |
+
}
|
11 |
+
});
|
12 |
+
});
|
13 |
+
|
14 |
+
$('#attributes-btn').on('click', function() {
|
15 |
+
var isHidden = $('#attributes-wrap').is( ":hidden" );
|
16 |
+
$('#attributes-wrap').toggle( function() {
|
17 |
+
if(isHidden) {
|
18 |
+
$('#attributes-btn').html('Collapse <span style="vertical-align:sub;width:16px;height:16px;font-size:16px;" class="dashicons dashicons-arrow-up-alt2"></span>');
|
19 |
+
} else {
|
20 |
+
$('#attributes-btn').html('Expand <span style="vertical-align:sub;width:16px;height:16px;font-size:16px;" class="dashicons dashicons-arrow-down-alt2"></span>');
|
21 |
+
}
|
22 |
+
});
|
23 |
+
});
|
24 |
+
});
|
readme.txt
CHANGED
@@ -1,17 +1,19 @@
|
|
1 |
-
=== Simple Sitemap ===
|
2 |
-
Contributors: dgwyer
|
3 |
Tags: seo sitemap, html, sitemap, html sitemap, seo, global, sort, shortcode, pages, posts, custom post types, post types, responsive, responsive sitemap
|
4 |
Requires at least: 3.0
|
5 |
-
Tested up to: 4.
|
6 |
-
Stable tag: 2.
|
7 |
|
8 |
-
The simplest
|
9 |
|
10 |
== Description ==
|
11 |
|
12 |
-
|
13 |
|
14 |
-
|
|
|
|
|
15 |
|
16 |
The sitemap shortcode has several attributes you can use to control how your sitemap is rendered including:
|
17 |
|
@@ -68,6 +70,14 @@ Please <a href="https://wordpress.org/support/view/plugin-reviews/simple-sitemap
|
|
68 |
|
69 |
== Changelog ==
|
70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
*2.2*
|
72 |
|
73 |
* Plugin settings page updated.
|
1 |
+
=== Simple Sitemap - Automatically Generate a Responsive Sitemap ===
|
2 |
+
Contributors: dgwyer, wpgoplugins
|
3 |
Tags: seo sitemap, html, sitemap, html sitemap, seo, global, sort, shortcode, pages, posts, custom post types, post types, responsive, responsive sitemap
|
4 |
Requires at least: 3.0
|
5 |
+
Tested up to: 4.9
|
6 |
+
Stable tag: 2.3
|
7 |
|
8 |
+
The simplest HTML5 sitemap available for WordPress! No setup required. Flexible customization options available.
|
9 |
|
10 |
== Description ==
|
11 |
|
12 |
+
Simple Sitemap helps improve your SEO ranking by automatically generating a HTML sitemap of all your content! There are flexible options to include only the content you want to include on your sitemap, and to format output.
|
13 |
|
14 |
+
It takes just seconds to add a sitemap to your website. Simply include the <code>[simple-sitemap]</code> on a page to display a dynamically generated sitemap. It's that easy!
|
15 |
+
|
16 |
+
Whatever your requirements, Simple Sitemap has you covered.
|
17 |
|
18 |
The sitemap shortcode has several attributes you can use to control how your sitemap is rendered including:
|
19 |
|
70 |
|
71 |
== Changelog ==
|
72 |
|
73 |
+
= 2.3, SEPTEMBER 25, 2017 =
|
74 |
+
|
75 |
+
* New 'container_tag' shortcode attribute added to all shortcodes to output the sitemap as an ordered list, or unordered list. See plugin settings page for more information.
|
76 |
+
* Updated plugin readme.txt.
|
77 |
+
* Settings page updated to include better shortcode information including the new <code>[simple-sitemap-group]</code> shortcode.
|
78 |
+
* Plugin code overhauled and refactored for future maintainability.
|
79 |
+
* Improved shortcode attribute validation checks.
|
80 |
+
|
81 |
*2.2*
|
82 |
|
83 |
* Plugin settings page updated.
|
simple-sitemap.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Simple Sitemap
|
4 |
Plugin URI: http://wordpress.org/plugins/simple-sitemap/
|
5 |
Description: HTML sitemap to display content as a single linked list of posts, pages, or custom post types. You can even display posts in groups sorted by taxonomy!
|
6 |
-
Version: 2.
|
7 |
Author: David Gwyer
|
8 |
Author URI: http://www.wpgoplugins.com
|
9 |
Text Domain: simple-sitemap
|
@@ -26,577 +26,63 @@ Text Domain: simple-sitemap
|
|
26 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
27 |
*/
|
28 |
|
29 |
-
|
30 |
|
31 |
-
|
32 |
-
add_shortcode( 'simple-sitemap-group', 'wpss_render_sitemap_group' );
|
33 |
-
add_action( 'admin_init', 'wpss_init' );
|
34 |
-
add_action( 'admin_menu', 'wpss_add_options_page' );
|
35 |
-
add_filter( 'plugin_row_meta', 'wpss_plugin_action_links', 10, 2 );
|
36 |
-
add_filter( 'plugin_action_links', 'wpss_plugin_settings_link', 10, 2 );
|
37 |
-
add_filter( 'widget_text', 'do_shortcode' ); // make sitemap shortcode work in text widgets
|
38 |
-
add_action( 'plugins_loaded', 'wpss_localize_plugin' );
|
39 |
-
add_action( 'admin_notices', 'wpss_admin_notice' );
|
40 |
-
register_activation_hook( __FILE__, 'wpss_admin_notice_set_transient' );
|
41 |
|
42 |
-
/*
|
43 |
-
function
|
44 |
|
45 |
-
|
46 |
-
set_transient( 'wpss-admin-notice', true, 5 );
|
47 |
-
}
|
48 |
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
/* Check transient, if available display notice */
|
53 |
-
if( get_transient( 'wpss-admin-notice' ) ){
|
54 |
-
?>
|
55 |
-
<div class="updated notice is-dismissible">
|
56 |
-
<p><a href="https://wpgoplugins.com/plugins/simple-sitemap-pro/" target="_blank"><strong>Simple Sitemap PRO</strong></a> is now available! *NEW* feature - New shortcode to list child pages of a specific parent page! Create multiple sitemaps each with a different set of child pages. <b>Try risk free today with our 100% money back guarantee! <span class="dashicons dashicons-smiley"></span></b></p>
|
57 |
-
</div>
|
58 |
-
<?php
|
59 |
-
/* Delete transient, only display this notice once. */
|
60 |
-
delete_transient( 'wpss-admin-notice' );
|
61 |
}
|
62 |
-
}
|
63 |
-
|
64 |
-
/* Init plugin options to white list our options. */
|
65 |
-
function wpss_init() {
|
66 |
-
register_setting( 'wpss_plugin_options', 'wpss_options', 'wpss_validate_options' );
|
67 |
-
}
|
68 |
-
|
69 |
-
/* Add menu page. */
|
70 |
-
function wpss_add_options_page() {
|
71 |
-
add_options_page( __( 'Simple Sitemap Options Page', 'simple-sitemap' ), __( 'Simple Sitemap', 'simple-sitemap' ), 'manage_options', __FILE__, 'wpss_render_form' );
|
72 |
-
}
|
73 |
-
|
74 |
-
/* Draw the menu page itself. */
|
75 |
-
function wpss_render_form() {
|
76 |
-
?>
|
77 |
-
<style>
|
78 |
-
a:focus{ box-shadow: none;}
|
79 |
-
.pcdm.dashicons { width: 32px; height: 32px; font-size: 32px; }
|
80 |
-
.pcdm.dashicons-yes { color: #1cc31c; }
|
81 |
-
.pcdm.dashicons-no { color: red; }
|
82 |
-
</style>
|
83 |
-
<div class="wrap">
|
84 |
-
<div style="display:flex;justify-content: space-between;">
|
85 |
-
<h2><?php _e( 'Simple Sitemap Options', 'simple-sitemap' ); ?></h2>
|
86 |
-
<div><a target="_blank" title="We love to develop WordPress plugins!" alt="WPGO Plugins Site" href="https://wpgoplugins.com/"><img src="<?php echo plugins_url(); ?>/wp-content-filter/images/wpgo_plugins_logo.png"></a></div>
|
87 |
-
</div>
|
88 |
-
|
89 |
-
<div style="background: #fff; width: 600px; padding-left: 20px;border: 2px #32cd32 solid;margin: 20px 0;">
|
90 |
-
<h2>*NEW* in Simple Sitemap Pro</h2>
|
91 |
-
<p><span style="font-weight:bold;">v0.6</span> - Remove sitemap links for ALL parent pages or specific ones only.</p>
|
92 |
-
<p><span style="font-weight:bold;">v0.7</span> - List child pages of a specific parent page. Easily create a sitemap list for each set of child pages.</p>
|
93 |
-
</div>
|
94 |
-
|
95 |
-
<table class="form-table">
|
96 |
-
|
97 |
-
<tr valign="top">
|
98 |
-
<th scope="row">Like the plugin?</th>
|
99 |
-
<td>
|
100 |
-
<p>Then why not upgrade to Pro and access powerful additional features. Try risk free today with our <span style="font-weight: bold;">100% money back guarantee!</span></p>
|
101 |
-
<div style="margin-top:10px;"><input class="button" type="button" value="Upgrade to Pro" onClick="window.open('https://wpgoplugins.com/plugins/simple-sitemap-pro/')"></div>
|
102 |
-
</td>
|
103 |
-
</tr>
|
104 |
-
|
105 |
-
<tr valign="top">
|
106 |
-
<th scope="row">Read all about it!</th>
|
107 |
-
<td>
|
108 |
-
<p>Signup to our plugin newsletter for news and updates about our latest work, and what's coming.</p>
|
109 |
-
<div style="margin-top:10px;"><input class="button" type="button" value="Subscribe here..." onClick="window.open('http://eepurl.com/bXZmmD')"></div>
|
110 |
-
</td>
|
111 |
-
</tr>
|
112 |
-
|
113 |
-
<tr valign="top">
|
114 |
-
<th scope="row">Buy me a coffee?</th>
|
115 |
-
<td>
|
116 |
-
<p>If you use this FREE Plugin on your website <b><em>please</em></b> consider making a <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FBAG4ZHA4TTUC" target="_blank">donation</a> to support continued development. Thank you.<span style="margin-left:5px;" class="dashicons dashicons-smiley"></span></p>
|
117 |
-
</td>
|
118 |
-
</tr>
|
119 |
-
|
120 |
-
<tr valign="top">
|
121 |
-
<th scope="row">Keep in touch...</th>
|
122 |
-
<td>
|
123 |
-
<div>
|
124 |
-
<span><a href="http://www.twitter.com/dgwyer" title="Follow us on Twitter" target="_blank"><img src="<?php echo plugins_url(); ?>/wp-content-filter/images/twitter.png" /></a></span>
|
125 |
-
<span><a href="https://www.facebook.com/wpgoplugins/" title="Our Facebook page" target="_blank"><img src="<?php echo plugins_url(); ?>/wp-content-filter/images/facebook.png" /></a></span>
|
126 |
-
<span><a href="https://www.youtube.com/channel/UCWzjTLWoyMgtIfpDgJavrTg" title="View our YouTube channel" target="_blank"><img src="<?php echo plugins_url(); ?>/wp-content-filter/images/yt.png" /></a></span>
|
127 |
-
<span><a style="text-decoration:none;" title="Need help with ANY aspect of WordPress? We're here to help!" href="https://wpgoplugins.com/need-help-with-wordpress/" target="_blank"><span style="margin-left:-2px;color:#d41515;font-size:39px;line-height:32px;width:39px;height:39px;" class="dashicons dashicons-sos"></span></a></span>
|
128 |
-
</div>
|
129 |
-
</td>
|
130 |
-
</tr>
|
131 |
-
|
132 |
-
<tr valign="top"><td colspan="2"><hr></td></tr>
|
133 |
-
|
134 |
-
</table>
|
135 |
-
|
136 |
-
<h2>Simple Sitemap Instructions</h2>
|
137 |
-
|
138 |
-
<div style="background:#fff;border: 1px dashed #ccc;font-size: 13px;margin: 20px 0 10px 0;padding: 5px 0 5px 8px;">
|
139 |
-
<?php printf( __( 'To display the Simple Sitemap on a post, page, or sidebar (via a Text widget), enter the following shortcode:<br><br>', 'simple-sitemap' ) ); ?> <code>[simple-sitemap]</code><br><br>
|
140 |
-
</div>
|
141 |
-
|
142 |
-
<h3><?php _e( 'Choose the Post Types to Display', 'simple-sitemap' ); ?></h3>
|
143 |
-
|
144 |
-
<p><?php _e( 'You now have full control over what post types are displayed as well as the order they are rendered.', 'simple-sitemap' ); ?></p>
|
145 |
-
|
146 |
-
<div style="background:#fff;border: 1px dashed #ccc;font-size: 13px;margin: 20px 0 10px 0;padding: 5px 0 5px 8px;">
|
147 |
-
<?php printf( __( 'Specify post types and order.<br>', 'simple-sitemap' ) ); ?>
|
148 |
-
<br><code>e.g. [simple-sitemap types="post, page, testimonial, download"]</code><br><br>
|
149 |
-
<b>default: types="post, page"</b>
|
150 |
-
<br><br><?php printf( __( 'Choose from any of the following registered post types currently available:<br><br>', 'simple-sitemap' ) ); ?>
|
151 |
-
<?php
|
152 |
-
$registered_post_types = get_post_types();
|
153 |
-
$registered_post_types_str = implode(', ', $registered_post_types);
|
154 |
-
echo '<code>' . $registered_post_types_str . '</code><br><br>';
|
155 |
-
?>
|
156 |
-
</div>
|
157 |
-
|
158 |
-
<h3><?php _e( 'Formatting the Sitemap Output', 'simple-sitemap' ); ?></h3>
|
159 |
-
|
160 |
-
<p><?php _e( 'You have various options for controlling how your sitemap displays.', 'simple-sitemap' ); ?></p>
|
161 |
-
|
162 |
-
<div style="background:#fff;border: 1px dashed #ccc;font-size: 13px;margin: 20px 0 10px 0;padding: 5px 0 5px 8px;">
|
163 |
-
<?php printf( __( 'Show a heading label for each post type as well as display a list of links or plain text. If you are outputting pages then you can also control page depth too (for page hierarchies).<br>', 'simple-sitemap' ) ); ?>
|
164 |
-
<br>For the <code>order</code> attribute specify <code>asc</code> for ascending, or <code>desc</code> for descending post sort order. As for the <code>orderby</code> attribute you can filter posts by any of the <code>orderby</code> paramters used in the <code>WP_Query</code> class such as <code>title</code>, <code>date</code>, <code>author</code>, <code>ID</code>, <code>menu_order</code> etc. See the full list <a href="https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters" target="_blank">here</a>. The <code>exclude</code> attribute simply takes a comma separated list of post IDs.
|
165 |
-
<br><br><code>e.g. [simple-sitemap show_label="true" links="true" page_depth="1" order="asc" orderby="title" exclude="1,2,3"]</code>
|
166 |
-
<br><br><b>defaults:<br>
|
167 |
-
show_label="true"<br>
|
168 |
-
links="true"<br>
|
169 |
-
page_depth="0"<br>
|
170 |
-
order="asc"<br>
|
171 |
-
orderby="title"<br>
|
172 |
-
exclude=""<br><br></b>
|
173 |
-
</div>
|
174 |
-
|
175 |
-
</div>
|
176 |
-
<?php
|
177 |
-
}
|
178 |
-
|
179 |
-
/* Shortcode function. */
|
180 |
-
function wpss_render_sitemap($args) {
|
181 |
-
|
182 |
-
/* Get slider attributes from the shortcode. */
|
183 |
-
extract( shortcode_atts( array(
|
184 |
-
'types' => 'page',
|
185 |
-
'show_excerpt' => 'false',
|
186 |
-
'title_tag' => '',
|
187 |
-
'excerpt_tag' => 'div',
|
188 |
-
'post_type_tag' => 'h2',
|
189 |
-
'show_label' => 'true',
|
190 |
-
'links' => 'true',
|
191 |
-
'page_depth' => 0,
|
192 |
-
'order' => 'asc',
|
193 |
-
'orderby' => 'title',
|
194 |
-
'exclude' => ''
|
195 |
-
), $args ) );
|
196 |
-
|
197 |
-
// escape tag names
|
198 |
-
$title_tag = tag_escape( $title_tag );
|
199 |
-
$excerpt_tag = tag_escape( $excerpt_tag );
|
200 |
-
$post_type_tag = tag_escape( $post_type_tag );
|
201 |
-
|
202 |
-
$page_depth = intval( $page_depth );
|
203 |
-
$post_types = $types; // allows the use of the shorter 'types' rather than 'post_types' in the shortcode
|
204 |
-
|
205 |
-
// Start output caching (so that existing content in the [simple-sitemap] post doesn't get shoved to the bottom of the post
|
206 |
-
ob_start();
|
207 |
-
|
208 |
-
// *************
|
209 |
-
// CONTENT START
|
210 |
-
// *************
|
211 |
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
//echo "<pre>";
|
217 |
-
//print_r($registered_post_types);
|
218 |
-
//print_r($post_types);
|
219 |
-
//print_r($exclude);
|
220 |
-
//echo "</pre>";
|
221 |
-
|
222 |
-
foreach( $post_types as $post_type ) :
|
223 |
-
|
224 |
-
// generate <ul> element class
|
225 |
-
$ul_class = 'simple-sitemap-' . $post_type;
|
226 |
-
|
227 |
-
// bail if post type isn't valid
|
228 |
-
if( !array_key_exists( $post_type, $registered_post_types ) ) {
|
229 |
-
break;
|
230 |
-
}
|
231 |
-
|
232 |
-
// set opening and closing title tag
|
233 |
-
if( !empty($title_tag) ) {
|
234 |
-
$title_open = '<' . $title_tag . '>';
|
235 |
-
$title_close = '</' . $title_tag . '>';
|
236 |
-
}
|
237 |
-
else {
|
238 |
-
$title_open = $title_close = '';
|
239 |
}
|
240 |
-
|
241 |
-
|
242 |
-
if( $show_label == 'true' ) {
|
243 |
-
$post_type_obj = get_post_type_object( $post_type );
|
244 |
-
$post_type_name = $post_type_obj->labels->name;
|
245 |
-
echo '<' . $post_type_tag . '>' . esc_html($post_type_name) . '</' . $post_type_tag . '>';
|
246 |
-
}
|
247 |
-
|
248 |
-
$query_args = array(
|
249 |
-
'posts_per_page' => -1,
|
250 |
-
'post_type' => $post_type,
|
251 |
-
'order' => $order,
|
252 |
-
'orderby' => $orderby,
|
253 |
-
'post__not_in' => $exclude
|
254 |
-
);
|
255 |
-
|
256 |
-
// use custom rendering for 'page' post type to properly render sub pages
|
257 |
-
if( $post_type == 'page' ) {
|
258 |
-
$arr = array(
|
259 |
-
'title_tag' => $title_tag,
|
260 |
-
'links' => $links,
|
261 |
-
'title_open' => $title_open,
|
262 |
-
'title_close' => $title_close,
|
263 |
-
'page_depth' => $page_depth,
|
264 |
-
'exclude' => $exclude
|
265 |
-
);
|
266 |
-
echo '<ul class="' . esc_attr($ul_class) . '">';
|
267 |
-
wpss_list_pages($arr, $query_args);
|
268 |
-
echo '</ul>';
|
269 |
-
continue;
|
270 |
-
}
|
271 |
-
|
272 |
-
//post query
|
273 |
-
$sitemap_query = new WP_Query( $query_args );
|
274 |
-
|
275 |
-
if ( $sitemap_query->have_posts() ) :
|
276 |
-
|
277 |
-
echo '<ul class="' . esc_attr($ul_class) . '">';
|
278 |
-
|
279 |
-
// start of the loop
|
280 |
-
while ( $sitemap_query->have_posts() ) : $sitemap_query->the_post();
|
281 |
-
|
282 |
-
// title
|
283 |
-
$title_text = get_the_title();
|
284 |
-
|
285 |
-
if( !empty( $title_text ) ) {
|
286 |
-
if ( $links == 'true' ) {
|
287 |
-
$title = $title_open . '<a href="' . esc_url(get_permalink()) . '">' . esc_html($title_text) . '</a>' . $title_close;
|
288 |
-
} else {
|
289 |
-
$title = $title_open . esc_html($title_text) . $title_close;
|
290 |
-
}
|
291 |
-
}
|
292 |
-
else {
|
293 |
-
if ( $links == 'true' ) {
|
294 |
-
$title = $title_open . '<a href="' . esc_url(get_permalink()) . '">' . '(no title)' . '</a>' . $title_close;
|
295 |
-
} else {
|
296 |
-
$title = $title_open . '(no title)' . $title_close;
|
297 |
-
}
|
298 |
-
}
|
299 |
-
|
300 |
-
// excerpt
|
301 |
-
$excerpt = $show_excerpt == 'true' ? '<' . $excerpt_tag . '>' . esc_html(get_the_excerpt()) . '</' . $excerpt_tag . '>' : '';
|
302 |
-
|
303 |
-
// render list item
|
304 |
-
echo '<li>';
|
305 |
-
echo $title;
|
306 |
-
echo $excerpt;
|
307 |
-
echo '</li>';
|
308 |
-
|
309 |
-
endwhile; // end of post loop -->
|
310 |
-
|
311 |
-
echo '</ul>';
|
312 |
-
|
313 |
-
// put pagination functions here
|
314 |
-
wp_reset_postdata();
|
315 |
-
|
316 |
-
else:
|
317 |
-
|
318 |
-
echo '<p>' . __( 'Sorry, no posts matched your criteria.', 'wpgo-simple-sitemap-pro' ) . '</p>';
|
319 |
-
|
320 |
-
endif;
|
321 |
-
|
322 |
-
endforeach;
|
323 |
-
|
324 |
-
// ***********
|
325 |
-
// CONTENT END
|
326 |
-
// ***********
|
327 |
-
|
328 |
-
$sitemap = ob_get_contents();
|
329 |
-
ob_end_clean();
|
330 |
-
|
331 |
-
return wp_kses_post($sitemap);
|
332 |
-
}
|
333 |
-
|
334 |
-
/* Shortcode function. */
|
335 |
-
function wpss_render_sitemap_group($args) {
|
336 |
-
|
337 |
-
/* Get slider attributes from the shortcode. */
|
338 |
-
extract( shortcode_atts( array(
|
339 |
-
'tax' => 'category', // single taxonomy
|
340 |
-
'term_order' => 'asc',
|
341 |
-
'term_orderby' => 'name',
|
342 |
-
'show_excerpt' => 'false',
|
343 |
-
'title_tag' => '',
|
344 |
-
'excerpt_tag' => 'div',
|
345 |
-
'post_type_tag' => 'h2',
|
346 |
-
'show_label' => 'true',
|
347 |
-
'links' => 'true',
|
348 |
-
'page_depth' => 0,
|
349 |
-
'order' => 'asc',
|
350 |
-
'orderby' => 'title',
|
351 |
-
'exclude' => ''
|
352 |
-
), $args ) );
|
353 |
-
|
354 |
-
// escape tag names
|
355 |
-
$title_tag = tag_escape( $title_tag );
|
356 |
-
$excerpt_tag = tag_escape( $excerpt_tag );
|
357 |
-
$post_type_tag = tag_escape( $post_type_tag );
|
358 |
-
|
359 |
-
$page_depth = intval( $page_depth );
|
360 |
-
$post_type = 'post';
|
361 |
-
|
362 |
-
// Start output caching (so that existing content in the [simple-sitemap] post doesn't get shoved to the bottom of the post
|
363 |
-
ob_start();
|
364 |
-
|
365 |
-
// *************
|
366 |
-
// CONTENT START
|
367 |
-
// *************
|
368 |
-
|
369 |
-
$exclude = array_map( 'trim', explode( ',', $exclude) ); // must be array to work in the post query
|
370 |
-
$registered_post_types = get_post_types();
|
371 |
-
|
372 |
-
//echo "<pre>";
|
373 |
-
//print_r($registered_post_types);
|
374 |
-
//print_r($post_types);
|
375 |
-
//print_r($exclude);
|
376 |
-
//echo "</pre>";
|
377 |
-
|
378 |
-
$taxonomy_arr = get_object_taxonomies( $post_type );
|
379 |
-
|
380 |
-
// sort via specified taxonomy
|
381 |
-
if ( !empty($tax) && in_array( $tax, $taxonomy_arr ) ) {
|
382 |
-
|
383 |
-
// conditionally show label for each post type
|
384 |
-
if( $show_label == 'true' ) {
|
385 |
-
$post_type_obj = get_post_type_object( $post_type );
|
386 |
-
$post_type_name = $post_type_obj->labels->name;
|
387 |
-
echo '<' . $post_type_tag . '>' . esc_html($post_type_name) . '</' . $post_type_tag . '>';
|
388 |
-
}
|
389 |
-
|
390 |
-
$term_attr = array(
|
391 |
-
'orderby' => $term_orderby,
|
392 |
-
'order' => $term_order
|
393 |
-
);
|
394 |
-
$terms = get_terms( $tax, $term_attr );
|
395 |
-
|
396 |
-
foreach($terms as $term) {
|
397 |
-
|
398 |
-
// generate <ul> element class
|
399 |
-
$ul_class = 'simple-sitemap-' . $post_type;
|
400 |
-
|
401 |
-
// bail if post type isn't valid
|
402 |
-
if( !array_key_exists( $post_type, $registered_post_types ) ) {
|
403 |
-
break;
|
404 |
-
}
|
405 |
-
|
406 |
-
// set opening and closing title tag
|
407 |
-
if( !empty($title_tag) ) {
|
408 |
-
$title_open = '<' . $title_tag . '>';
|
409 |
-
$title_close = '</' . $title_tag . '>';
|
410 |
-
}
|
411 |
-
else {
|
412 |
-
$title_open = $title_close = '';
|
413 |
-
}
|
414 |
-
|
415 |
-
$query_args = array(
|
416 |
-
'posts_per_page' => -1,
|
417 |
-
'post_type' => $post_type,
|
418 |
-
'order' => $order,
|
419 |
-
'orderby' => $orderby,
|
420 |
-
'post__not_in' => $exclude,
|
421 |
-
'tax_query' => array(
|
422 |
-
array(
|
423 |
-
'taxonomy' => $tax,
|
424 |
-
'field' => 'slug',
|
425 |
-
'terms' => $term
|
426 |
-
)
|
427 |
-
)
|
428 |
-
);
|
429 |
-
|
430 |
-
echo '<h4>' . $term->name . '</h4>';
|
431 |
-
|
432 |
-
//post query
|
433 |
-
$sitemap_query = new WP_Query( $query_args );
|
434 |
-
|
435 |
-
if ( $sitemap_query->have_posts() ) :
|
436 |
-
|
437 |
-
echo '<ul class="' . esc_attr($ul_class) . '">';
|
438 |
-
|
439 |
-
// start of the loop
|
440 |
-
while ( $sitemap_query->have_posts() ) : $sitemap_query->the_post();
|
441 |
-
|
442 |
-
// title
|
443 |
-
$title_text = get_the_title();
|
444 |
-
|
445 |
-
if( !empty( $title_text ) ) {
|
446 |
-
if ( $links == 'true' ) {
|
447 |
-
$title = $title_open . '<a href="' . esc_url(get_permalink()) . '">' . esc_html($title_text) . '</a>' . $title_close;
|
448 |
-
} else {
|
449 |
-
$title = $title_open . esc_html($title_text) . $title_close;
|
450 |
-
}
|
451 |
-
}
|
452 |
-
else {
|
453 |
-
if ( $links == 'true' ) {
|
454 |
-
$title = $title_open . '<a href="' . esc_url(get_permalink()) . '">' . '(no title)' . '</a>' . $title_close;
|
455 |
-
} else {
|
456 |
-
$title = $title_open . '(no title)' . $title_close;
|
457 |
-
}
|
458 |
-
}
|
459 |
-
|
460 |
-
// excerpt
|
461 |
-
$excerpt = $show_excerpt == 'true' ? '<' . $excerpt_tag . '>' . esc_html(get_the_excerpt()) . '</' . $excerpt_tag . '>' : '';
|
462 |
-
|
463 |
-
// render list item
|
464 |
-
echo '<li>';
|
465 |
-
echo $title;
|
466 |
-
echo $excerpt;
|
467 |
-
echo '</li>';
|
468 |
-
|
469 |
-
endwhile; // end of post loop -->
|
470 |
-
|
471 |
-
echo '</ul>';
|
472 |
-
|
473 |
-
// put pagination functions here
|
474 |
-
wp_reset_postdata();
|
475 |
-
|
476 |
-
else:
|
477 |
-
|
478 |
-
echo '<p>' . __( 'Sorry, no posts matched your criteria.', 'wpgo-simple-sitemap-pro' ) . '</p>';
|
479 |
-
|
480 |
-
endif;
|
481 |
-
}
|
482 |
-
}
|
483 |
-
else {
|
484 |
-
echo "No posts found.";
|
485 |
}
|
486 |
|
487 |
-
|
488 |
-
|
489 |
-
// ***********
|
490 |
-
ob_start();
|
491 |
-
|
492 |
-
$sitemap = ob_get_contents();
|
493 |
-
ob_end_clean();
|
494 |
-
|
495 |
-
return wp_kses_post($sitemap);
|
496 |
-
}
|
497 |
|
498 |
-
|
499 |
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
'author' => 'post_author',
|
504 |
-
'modified' => 'post_modified'
|
505 |
-
);
|
506 |
|
507 |
-
|
508 |
-
|
|
|
509 |
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
'date_format' => get_option( 'date_format' ),
|
514 |
-
'child_of' => 0,
|
515 |
-
'exclude' => $arr['exclude'],
|
516 |
-
'echo' => 1,
|
517 |
-
'authors' => '',
|
518 |
-
'sort_column' => $orderby,
|
519 |
-
'sort_order' => $query_args['order'],
|
520 |
-
'link_before' => '',
|
521 |
-
'link_after' => '',
|
522 |
-
'item_spacing' => '',
|
523 |
-
//'walker' => '',
|
524 |
-
);
|
525 |
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
// Query pages.
|
531 |
-
$r['hierarchical'] = 0;
|
532 |
-
$pages = get_pages( $r );
|
533 |
-
|
534 |
-
if ( ! empty( $pages ) ) {
|
535 |
-
global $wp_query;
|
536 |
-
if ( is_page() || is_attachment() || $wp_query->is_posts_page ) {
|
537 |
-
$current_page = get_queried_object_id();
|
538 |
-
} elseif ( is_singular() ) {
|
539 |
-
$queried_object = get_queried_object();
|
540 |
-
if ( is_post_type_hierarchical( $queried_object->post_type ) ) {
|
541 |
-
$current_page = $queried_object->ID;
|
542 |
-
}
|
543 |
-
}
|
544 |
-
|
545 |
-
$output .= walk_page_tree( $pages, $r['depth'], $current_page, $r );
|
546 |
-
}
|
547 |
-
|
548 |
-
// remove links
|
549 |
-
if( $arr['links'] != 'true' )
|
550 |
-
$output = preg_replace('/<a href=\"(.*?)\">(.*?)<\/a>/', "\\2", $output);
|
551 |
-
|
552 |
-
if ( $r['echo'] ) {
|
553 |
-
echo $output;
|
554 |
-
} else {
|
555 |
-
return $output;
|
556 |
}
|
557 |
-
}
|
558 |
-
|
559 |
-
// Display a Settings link on the main Plugins page
|
560 |
-
function wpss_plugin_action_links( $links, $file ) {
|
561 |
-
|
562 |
-
//if ( $file == plugin_basename( __FILE__ ) ) {
|
563 |
-
// add a link to pro plugin
|
564 |
-
//$links[] = '<a style="color:limegreen;" href="https://wpgoplugins.com/plugins/simple-sitemap-pro/" target="_blank" title="Upgrade to Pro - 100% money back guarantee"><span class="dashicons dashicons-awards"></span></a>';
|
565 |
-
//}
|
566 |
-
|
567 |
-
return $links;
|
568 |
-
}
|
569 |
|
570 |
-
|
571 |
-
|
|
|
|
|
572 |
|
573 |
-
|
574 |
-
$pccf_links = '<a href="' . get_admin_url() . 'options-general.php?page=simple-sitemap/simple-sitemap.php">' . __( 'Settings' ) . '</a>';
|
575 |
-
array_unshift( $links, $pccf_links );
|
576 |
}
|
577 |
|
578 |
-
|
579 |
-
$pccf_links = '<a style="color:#d54e21;" href="https://wpgoplugins.com/plugins/simple-sitemap-pro/" target="_blank" title="Go PRO - 100% money back guarantee"><span class="dashicons dashicons-megaphone"></span></a>';
|
580 |
-
array_push( $links, $pccf_links );
|
581 |
-
}
|
582 |
-
|
583 |
-
return $links;
|
584 |
-
}
|
585 |
-
|
586 |
-
/* Sanitize and validate input. Accepts an array, return a sanitized array. */
|
587 |
-
function wpss_validate_options( $input ) {
|
588 |
-
// Strip html from textboxes
|
589 |
-
// e.g. $input['textbox'] = wp_filter_nohtml_kses($input['textbox']);
|
590 |
-
|
591 |
-
$input['txt_page_ids'] = sanitize_text_field( $input['txt_page_ids'] );
|
592 |
-
|
593 |
-
return $input;
|
594 |
-
}
|
595 |
-
|
596 |
-
/**
|
597 |
-
* Add Plugin localization support.
|
598 |
-
*/
|
599 |
-
function wpss_localize_plugin() {
|
600 |
|
601 |
-
|
602 |
-
|
|
|
|
|
|
3 |
Plugin Name: Simple Sitemap
|
4 |
Plugin URI: http://wordpress.org/plugins/simple-sitemap/
|
5 |
Description: HTML sitemap to display content as a single linked list of posts, pages, or custom post types. You can even display posts in groups sorted by taxonomy!
|
6 |
+
Version: 2.3
|
7 |
Author: David Gwyer
|
8 |
Author URI: http://www.wpgoplugins.com
|
9 |
Text Domain: simple-sitemap
|
26 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
27 |
*/
|
28 |
|
29 |
+
class WPGO_Simple_Sitemap {
|
30 |
|
31 |
+
protected $module_roots;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
+
/* Main class constructor. */
|
34 |
+
public function __construct($module_roots) {
|
35 |
|
36 |
+
$this->module_roots = $module_roots;
|
|
|
|
|
37 |
|
38 |
+
add_action( 'plugins_loaded', array( &$this, 'load_supported_features' ), 12 );
|
39 |
+
add_action( 'plugins_loaded', array( &$this, 'localize_plugin' ) );
|
40 |
+
add_action( 'admin_enqueue_scripts', array( &$this, 'enqueue_admin_scripts' ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
+
/* Scripts just for the plugin settings page. */
|
44 |
+
public function enqueue_admin_scripts($hook) {
|
45 |
+
if($hook != 'settings_page_simple-sitemap/classes/simple-sitemap-settings') {
|
46 |
+
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
}
|
48 |
+
wp_enqueue_style( 'simple-sitemap-css', plugins_url('css/simple-sitemap-admin.css', __FILE__) );
|
49 |
+
wp_enqueue_script( 'simple-sitemap-js', plugins_url('js/simple-sitemap-admin.js', __FILE__) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
}
|
51 |
|
52 |
+
/* Check for specific CPT used in the current WPGO theme. */
|
53 |
+
public function load_supported_features() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
|
55 |
+
$root = $this->module_roots['dir'];
|
56 |
|
57 |
+
// [simple-sitemap] shortcode
|
58 |
+
require_once( $root . 'classes/shortcodes/simple-sitemap-shortcode.php' );
|
59 |
+
new WPGO_Simple_Sitemap_Shortcode($this->module_roots);
|
|
|
|
|
|
|
60 |
|
61 |
+
// [simple-sitemap-group] shortcode
|
62 |
+
require_once( $root . 'classes/shortcodes/simple-sitemap-group-shortcode.php' );
|
63 |
+
new WPGO_Simple_Sitemap_Group_Shortcode($this->module_roots);
|
64 |
|
65 |
+
// plugin docs/settings page
|
66 |
+
require_once( $root . 'classes/simple-sitemap-settings.php' );
|
67 |
+
new WPGO_Simple_Sitemap_Settings($this->module_roots);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
|
69 |
+
// links on the main plugin index page
|
70 |
+
require_once( $root . 'classes/simple-sitemap-links.php' );
|
71 |
+
new WPGO_Simple_Sitemap_Links($this->module_roots);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
|
74 |
+
/**
|
75 |
+
* Add Plugin localization support.
|
76 |
+
*/
|
77 |
+
public function localize_plugin() {
|
78 |
|
79 |
+
load_plugin_textdomain( 'simple-sitemap', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
|
|
|
|
|
80 |
}
|
81 |
|
82 |
+
} /* End class definition */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
|
84 |
+
$module_roots = array(
|
85 |
+
'dir' => plugin_dir_path( __FILE__ ),
|
86 |
+
'uri' => plugins_url( '', __FILE__ ),
|
87 |
+
);
|
88 |
+
new WPGO_Simple_Sitemap( $module_roots );
|