0byt3m1n1
Path:
/
home1
/
aserty
/
public_html
/
appartsoft.info
/
wp-content
/
plugins
/
sitemap-mage
/
[
Home
]
File: sitemap-mage.php
<?php /* Plugin Name: Sitemap Mage Plugin URI: http://wpmage.com/ Version: 1.0.2 Author: <a href="http://wpmage.com/">WP Mage Team</a> Description: Creates a Page containing a list of links to all published pages */ function sitemapMageInstall() { global $wpdb; $sitemapMageOptions = get_option ( 'sitemapMage' ); if ($sitemapMageOptions == '' or $sitemapMageOptions == NULL) { $post = array('post_content' => __(buildSiteMapLinks()), 'post_name' => 'sitemap-page', 'post_status' => 'publish', 'post_title' => __('Sitemap'), 'post_type' => 'page', 'comment_status' => 'closed' ); $postID = wp_insert_post( $post ); $sitemapMageOptions['postID'] = $postID; update_option('sitemapMage',$sitemapMageOptions); } } function buildSiteMapLinks() { global $wpdb; $countsql = "SELECT COUNT(*) AS noPosts FROM " . $wpdb->posts . " WHERE post_type='post' AND post_status = 'publish'"; $noPostsObj = $wpdb->get_results ( $countsql, ARRAY_A ); $noPosts = $noPostsObj [0] ['noPosts']; if (! $noPosts) { return false; } $sitemapLinks = NULL; $sql = "SELECT post_name,post_title,ID FROM " . $wpdb->posts . " WHERE post_type='post' AND post_title != '' AND post_status='publish'"; for($i = 0;$i <= $noPosts; $i ++) { $limitedsql = $sql . " ORDER BY ID ASC LIMIT $i,1"; $post = $wpdb->get_results ( $limitedsql ); $post = $post[0]; if ($post->post_title != '') { $permalink = NULL; $permalink = get_permalink ( $post->ID ); $sitemapLinks .= '<a href="' . $permalink . '">' . rtrim(trim($post->post_title),"\n") . "</a><br />"; } } return $sitemapLinks; } function sitemapMageUninstall() { $sitemapMageOptions = get_option ( 'sitemapMage' ); $pageID = $sitemapMageOptions['postID']; wp_delete_post($pageID); delete_option('sitemapMage'); } function sitemapMageAddPublishedPost() { global $wpdb; $sitemapMageOptions = get_option ( 'sitemapMage' ); $pageID = $sitemapMageOptions['postID']; $content = array ('post_content' => buildSiteMapLinks() ); $wpdb->update ( $wpdb->posts, $content, array ('ID' => $pageID ) ); } if(isset($_POST['regenrate']) && $_POST['regenrate'] == 'yes') { $sitemapMageOptions = get_option ( 'sitemapMage' ); $pageID = $sitemapMageOptions['postID']; $content = array ('post_content' => buildSiteMapLinks() ); $wpdb->update ( $wpdb->posts, $content, array ('ID' => $pageID ) ); $smmsg = '<div id="message" class="updated fade"><p><strong>Sitemap Page regenerated.</strong></p></div>'; } function sitemapMageOptions() { global $smmsg; echo $smmsg; echo "<h2>Sitemap Mage</h2>"; echo "<p>Sitemap Mage will build a page called Sitemap, listing all published posts, which can be sent to Search Engines for quick spidering. It is in no way related to a Google Sitemap XML file.</p> <p><strong>Note:</strong> Sitemap Mage produces a page for Search Engines, not Humans. As a result, it's not pretty, styled, categorised and there are no bells and whistles, options and complications. It's just a simple list of links to published posts.</p> <p>Deactivating this plugin will delete tghe page and Sitemap Mage options. Activating will rebuild the page.</p>"; echo '<form method="post" action="http://' . $_SERVER ['HTTP_HOST'] . $_SERVER ['REQUEST_URI'] . '">'; echo '<input type="submit" value="Regenerate Sitemap Page" />'; echo '<input type="hidden" name="regenrate" value="yes" />'; echo "</form>"; } register_activation_hook ( __FILE__, 'sitemapMageInstall' ); register_deactivation_hook( __FILE__, 'sitemapMageUninstall' ); function sitemapMageAdminPage() { add_submenu_page ( 'options-general.php', 'Sitemap Mage', 'Sitemap Mage', 5, 'sitemap-mage.php', 'sitemapMageOptions' ); } add_action ( 'admin_menu', 'sitemapMageAdminPage' ); //add_action ( 'publish_post', 'sitemapMageAddPublishedPost' ); ?>