Advertisement
emcniece

Advanced Sitemap Generator shortcode overhaul

Jan 28th, 2013
439
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.70 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: Advanced Sitemap Generator
  4. Plugin URI: http://www.csschopper.com/
  5. Description: powerfull plugin to show all your pages and post on front end in a sitemap.
  6. Version: 1.0.3
  7. Author: Deepak Tripathi
  8. Author URI: http://www.csschopper.com/
  9. Author Email: deepak@sparxtechnologies.com
  10. License: GPL
  11. */
  12.  
  13.  
  14. // Hook for adding admin menus
  15. add_action('admin_menu', 'custom_function');
  16.  
  17. function custom_function()
  18. {
  19.     add_options_page('sitemap', 'sitemap', 'manage_options', 'sitemapgenerator', 'sitemapfunction');
  20. }
  21.  
  22. function sitemapfunction()
  23. {
  24.     ?>
  25. <div><h2>Sitemap Setting</h2></div>
  26.   <p>This plugin is the most powerfull plugin which easily display you post and page through shortcode on front end.You just need to put shortcode([sitemap]) on your page/post.</p>
  27.       <p>If you want to exclude pages then put ([sitemap excludepage="1,4"]) where 1,4 are the page id seperated by the comma's.</p>
  28.       <p>If you want to exclude categories then put ([sitemap excludepage="1,4" excludecat="6,3"]) where 6,3 are the category id seperated by the comma's.</p>
  29.       <p>If you want to exclude post then put ([sitemap excludepage="1,4" excludecat="6,3" excludepost="1,183"]) where 1,183 are the post id seperated by the comma's.</p>
  30.   </p> </br></br>
  31.    <div>
  32.        <h2>Screenshot1</h2>
  33.   <div><img src="<?php echo plugins_url() ?>/advanced-sitemap-generator/images/screenshot-1.jpg" width="1100"/></div>
  34.    </br><hr></br>
  35.   <h2>Screenshot2</h2>
  36.   <div><img src="<?php echo plugins_url() ?>/advanced-sitemap-generator/images/screenshot-2.jpg" width="1100"/></div>
  37.   </br><hr></br></br>
  38.   </div>
  39.  
  40. <?php
  41.    
  42. }
  43. add_shortcode( 'sitemap', 'sitemap_function' );
  44.  
  45. function sitemap_function($atts)
  46. {
  47.     extract(shortcode_atts(array(
  48.         "excludepage"   => 0,
  49.         "excludecat"    => 0,
  50.         "excludepost"   => 0,
  51.     ), $atts));
  52.  
  53.     $args=array(
  54.         'exclude'   => $atts[excludepage],
  55.         'title_li'  => '',
  56.         'echo'      => false
  57.     );
  58.    
  59.     $output =  '<div class="manage-pagepost"><ul class="manage_page"><h3>Pages</h3>';
  60.    
  61.     $output .= wp_list_pages($args);
  62.    
  63.     $output .= '</ul><ul class="manage_post"><h3>posts</h3>';
  64.    
  65.     for($i=0;$i<count($arr);$i++){
  66.         $arr_new[]='-'.$arr[$i];
  67.     }
  68.    
  69.     $arr=explode(',',$atts[excludecat]);
  70.     $excludecat=implode(',',$arr_new);
  71.     $str=explode(',',$atts[excludepost]);
  72.     $args = array(
  73.         'post_type' => 'post',
  74.         'cat' => $excludecat,
  75.         'post__not_in' => $str 
  76.     );
  77.    
  78.     query_posts($args);
  79.     if (have_posts()) {
  80.         while (have_posts()) { the_post();
  81.             $output .= '<li><a href="'.get_permalink().'">'.get_the_title().'</a></li>';
  82.  
  83.         } // while have_posts()
  84.     } // if have_posts
  85.    
  86.     wp_reset_query();
  87.     $output .= '</ul></div>';
  88.    
  89.     return $output;
  90. }
  91. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement