├── LICENSE ├── README.md └── grunt-plugin.php /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 phoenixMag00 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | JSON Sitemap Generator for Grunt UnCSS with WordPress 2 | ===================================================== 3 | 4 | JSON Sitemap Generator for Grunt UnCSS with WordPress 5 | 6 | Get a complete JSON Sitemap for use with the Grunt-UnCSS with Wordpress tutorial by Liam Gladdy (http://www.gladdy.co.uk/blog/2014/04/13/using-uncss-and-grunt-uncss-with-wordpress/). Forked off 7 | his original gist found here: https://gist.github.com/lgladdy/10586308 8 | 9 | Upload to your plugins folder and activate. Then go to: http://yourdomain.com?show_sitemap -------------------------------------------------------------------------------- /grunt-plugin.php: -------------------------------------------------------------------------------- 1 | 'any', 'posts_per_page' => '-1', 'post_status' => 'publish')); 27 | 28 | while ($the_query->have_posts()) { 29 | 30 | $the_query->the_post(); 31 | 32 | $urls[] = get_permalink(); 33 | 34 | } 35 | 36 | //Authors 37 | 38 | $authors = get_users(); 39 | 40 | foreach ($authors as $author) { 41 | 42 | $urls[] = get_author_posts_url( $author->ID ); 43 | 44 | } 45 | 46 | //Every term imaginable, even the empty ones (categories, custom taxonomies, tags, etc.) 47 | 48 | $args = array( 49 | 'public' => true, 50 | ); 51 | 52 | $taxonomies=get_taxonomies($args,'names'); 53 | 54 | $args = array( 'hide_empty=0' ); 55 | 56 | $terms = get_terms($taxonomies, $args); 57 | 58 | foreach ($terms as $term) { 59 | 60 | $urls[] = get_term_link( $term ); 61 | } 62 | 63 | //Getting a list of Archive URLs seems like it should be easier...probably missing something on the Codex, but this works. 64 | 65 | $args = array( 66 | 'type' => 'monthly', 67 | 'format' => 'custom', 68 | 'before' => '', 69 | 'after' => '', 70 | 'show_post_count' => false, 71 | 'echo' => 0 72 | ); 73 | 74 | $archive_links_raw = wp_get_archives($args); 75 | 76 | $archive_links_pattern = "/(?i)\b((?:https?:\/\/|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'\".,<>?«»“”‘’]))/"; 77 | 78 | preg_match_all($archive_links_pattern, $archive_links_raw, $cleaned_archive_links); 79 | 80 | $cleaned_archive_links = $cleaned_archive_links[1]; 81 | 82 | foreach ($cleaned_archive_links as $cleaned_archive_link) { 83 | 84 | $urls[] = $cleaned_archive_link; 85 | 86 | } 87 | 88 | //Add in a search result page for '.' 89 | 90 | $main_url = get_site_url(); 91 | 92 | $urls[] = $main_url . '/?s=.'; 93 | 94 | //Force a search with no results 95 | 96 | $urls[] = $main_url . '/?s=asdfasdfasdfasdf'; 97 | 98 | //Force a 404 page 99 | 100 | $urls[] = $main_url . '/asdfasdfasdfasdf'; 101 | 102 | //Return all of the urls captured above and encode to json for UnCSS 103 | 104 | die(json_encode($urls)); 105 | 106 | } 107 | 108 | } 109 | ?> --------------------------------------------------------------------------------