web/wp-content/plugins/google-sitemap-generator/sitemap.php
changeset 194 32102edaa81b
parent 136 bde1974c263b
equal deleted inserted replaced
193:2f6f6f7551ca 194:32102edaa81b
     1 <?php
     1 <?php
     2 
     2 
     3 /*
     3 /*
     4  $Id: sitemap.php 175664 2009-11-20 21:21:09Z arnee $
     4  $Id: sitemap.php 583238 2012-08-08 21:10:26Z arnee $
     5 
     5 
     6  Google XML Sitemaps Generator for WordPress
     6  Google XML Sitemaps Generator for WordPress
     7  ==============================================================================
     7  ==============================================================================
     8  
     8  
     9  This generator will create a sitemaps.org compliant sitemap of your WordPress blog.
     9  This generator will create a sitemaps.org compliant sitemap of your WordPress blog.
    22 
    22 
    23  Info for WordPress:
    23  Info for WordPress:
    24  ==============================================================================
    24  ==============================================================================
    25  Plugin Name: Google XML Sitemaps
    25  Plugin Name: Google XML Sitemaps
    26  Plugin URI: http://www.arnebrachhold.de/redir/sitemap-home/
    26  Plugin URI: http://www.arnebrachhold.de/redir/sitemap-home/
    27  Description: This plugin will generate a sitemaps.org compatible sitemap of your WordPress blog which is supported by Ask.com, Google, MSN Search and YAHOO. <a href="options-general.php?page=sitemap.php">Configuration Page</a>
    27  Description: This plugin will generate a special XML sitemap which will help search engines like Google, Yahoo, Bing and Ask.com to better index your blog.
    28  Version: 3.2
    28  Version: 3.2.8
    29  Author: Arne Brachhold
    29  Author: Arne Brachhold
    30  Author URI: http://www.arnebrachhold.de/
    30  Author URI: http://www.arnebrachhold.de/
       
    31  Text Domain: sitemap
       
    32  Domain Path: /lang/
       
    33  
    31 */
    34 */
    32 
    35 
    33 /**
    36 /**
    34  * Loader class for the Google Sitemap Generator
    37  * Loader class for the Google Sitemap Generator
    35  *
    38  *
    42 	 * Enabled the sitemap plugin with registering all required hooks
    45 	 * Enabled the sitemap plugin with registering all required hooks
    43 	 *
    46 	 *
    44 	 * If the sm_command and sm_key GET params are given, the function will init the generator to rebuild the sitemap.
    47 	 * If the sm_command and sm_key GET params are given, the function will init the generator to rebuild the sitemap.
    45 	 */
    48 	 */
    46 	function Enable() {
    49 	function Enable() {
       
    50 
       
    51 		//Check for 3.0 multisite, NOT supported yet!
       
    52 		if((defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE) || (function_exists('is_multisite') && is_multisite())) {
       
    53 			if(function_exists('is_super_admin') && is_super_admin()) {
       
    54 				add_action('admin_notices',  array('GoogleSitemapGeneratorLoader', 'AddMultisiteWarning'));
       
    55 			}	
       
    56 			
       
    57 			return;
       
    58 		}
    47 		
    59 		
    48 		//Register the sitemap creator to wordpress...
    60 		//Register the sitemap creator to wordpress...
    49 		add_action('admin_menu', array('GoogleSitemapGeneratorLoader', 'RegisterAdminPage'));
    61 		add_action('admin_menu', array('GoogleSitemapGeneratorLoader', 'RegisterAdminPage'));
    50 		
    62 		
    51 		//Nice icon for Admin Menu (requires Ozh Admin Drop Down Plugin)
    63 		//Nice icon for Admin Menu (requires Ozh Admin Drop Down Plugin)
    83 		//Check if the result of a ping request should be shown
    95 		//Check if the result of a ping request should be shown
    84 		if(!empty($_GET["sm_ping_service"])) {
    96 		if(!empty($_GET["sm_ping_service"])) {
    85 			GoogleSitemapGeneratorLoader::CallShowPingResult();
    97 			GoogleSitemapGeneratorLoader::CallShowPingResult();
    86 		}
    98 		}
    87 	}
    99 	}
       
   100 	
       
   101 	/**
       
   102 	 * Outputs the warning bar if multisite mode is activated
       
   103 	 */
       
   104 	function AddMultisiteWarning() {
       
   105 		echo "<div id='sm-multisite-warning' class='error fade'><p><strong>".__('This version of Google XML Sitemaps is not multisite compatible.','sitemap')."</strong><br /> ".sprintf(__('Unfortunately this version of the Google XML Sitemaps plugin was not tested with the multisite feature of WordPress 3.0 yet. <br />The plugin will not be active until you disable the multisite mode. <br />Or you can <a href="%1$s">try the new beta</a> which supports all the new WordPress features!','sitemap'), "http://www.arnebrachhold.de/redir/sitemap-info-beta/")."</p></div>";
       
   106 	}
    88 
   107 
    89 	/**
   108 	/**
    90 	 * Registers the plugin in the admin menu system
   109 	 * Registers the plugin in the admin menu system
    91 	 */
   110 	 */
    92 	function RegisterAdminPage() {
   111 	function RegisterAdminPage() {
    93 		
   112 		
    94 		if (function_exists('add_options_page')) {
   113 		if (function_exists('add_options_page')) {
    95 			add_options_page(__('XML-Sitemap Generator','sitemap'), __('XML-Sitemap','sitemap'), 10, GoogleSitemapGeneratorLoader::GetBaseName(), array('GoogleSitemapGeneratorLoader','CallHtmlShowOptionsPage'));
   114 			add_options_page(__('XML-Sitemap Generator','sitemap'), __('XML-Sitemap','sitemap'), 'level_10', GoogleSitemapGeneratorLoader::GetBaseName(), array('GoogleSitemapGeneratorLoader','CallHtmlShowOptionsPage'));
    96 		}
   115 		}
    97 	}
   116 	}
    98 	
   117 	
    99 	function RegisterAdminIcon($hook) {
   118 	function RegisterAdminIcon($hook) {
   100 		if ( $hook == GoogleSitemapGeneratorLoader::GetBaseName() && function_exists('plugins_url')) {
   119 		if ( $hook == GoogleSitemapGeneratorLoader::GetBaseName() && function_exists('plugins_url')) {
   104 	}
   123 	}
   105 	
   124 	
   106 	function RegisterPluginLinks($links, $file) {
   125 	function RegisterPluginLinks($links, $file) {
   107 		$base = GoogleSitemapGeneratorLoader::GetBaseName();
   126 		$base = GoogleSitemapGeneratorLoader::GetBaseName();
   108 		if ($file == $base) {
   127 		if ($file == $base) {
   109 			$links[] = '<a href="options-general.php?page=' . GoogleSitemapGeneratorLoader::GetBaseName() .'">' . __('Settings') . '</a>';
   128 			$links[] = '<a href="options-general.php?page=' . GoogleSitemapGeneratorLoader::GetBaseName() .'">' . __('Settings','sitemap') . '</a>';
   110 			$links[] = '<a href="http://www.arnebrachhold.de/redir/sitemap-plist-faq/">' . __('FAQ') . '</a>';
   129 			$links[] = '<a href="http://www.arnebrachhold.de/redir/sitemap-plist-faq/">' . __('FAQ','sitemap') . '</a>';
   111 			$links[] = '<a href="http://www.arnebrachhold.de/redir/sitemap-plist-support/">' . __('Support') . '</a>';
   130 			$links[] = '<a href="http://www.arnebrachhold.de/redir/sitemap-plist-support/">' . __('Support','sitemap') . '</a>';
   112 			$links[] = '<a href="http://www.arnebrachhold.de/redir/sitemap-plist-donate/">' . __('Donate') . '</a>';
   131 			$links[] = '<a href="http://www.arnebrachhold.de/redir/sitemap-plist-donate/">' . __('Donate','sitemap') . '</a>';
   113 		}
   132 		}
   114 		return $links;
   133 		return $links;
   115 	}
   134 	}
   116 	
   135 	
   117 	/**
   136 	/**
   118 	 * Invokes the HtmlShowOptionsPage method of the generator
   137 	 * Invokes the HtmlShowOptionsPage method of the generator
   119 	 */
   138 	 */
   120 	function CallHtmlShowOptionsPage() {
   139 	function CallHtmlShowOptionsPage() {
   121 		if(GoogleSitemapGeneratorLoader::LoadPlugin()) {
   140 		if(GoogleSitemapGeneratorLoader::LoadPlugin()) {
   122 			$gs = GoogleSitemapGenerator::GetInstance();
   141 			$gs = &GoogleSitemapGenerator::GetInstance();
   123 			$gs->HtmlShowOptionsPage();
   142 			$gs->HtmlShowOptionsPage();
   124 		}
   143 		}
   125 	}
   144 	}
   126 	
   145 	
   127 	/**
   146 	/**
   128 	 * Invokes the CheckForAutoBuild method of the generator
   147 	 * Invokes the CheckForAutoBuild method of the generator
   129 	 */
   148 	 */
   130 	function CallCheckForAutoBuild($args) {
   149 	function CallCheckForAutoBuild($args) {
   131 		if(GoogleSitemapGeneratorLoader::LoadPlugin()) {
   150 		if(GoogleSitemapGeneratorLoader::LoadPlugin()) {
   132 			$gs = GoogleSitemapGenerator::GetInstance();
   151 			$gs = &GoogleSitemapGenerator::GetInstance();
   133 			$gs->CheckForAutoBuild($args);
   152 			$gs->CheckForAutoBuild($args);
   134 		}
   153 		}
   135 	}
   154 	}
   136 	
   155 	
   137 	/**
   156 	/**
   138 	 * Invokes the CheckForAutoBuild method of the generator
   157 	 * Invokes the CheckForAutoBuild method of the generator
   139 	 */
   158 	 */
   140 	function CallBuildNowRequest() {
   159 	function CallBuildNowRequest() {
   141 		if(GoogleSitemapGeneratorLoader::LoadPlugin()) {
   160 		if(GoogleSitemapGeneratorLoader::LoadPlugin()) {
   142 			$gs = GoogleSitemapGenerator::GetInstance();
   161 			$gs = &GoogleSitemapGenerator::GetInstance();
   143 			$gs->BuildNowRequest();
   162 			$gs->BuildNowRequest();
   144 		}
   163 		}
   145 	}
   164 	}
   146 	
   165 	
   147 	/**
   166 	/**
   148 	 * Invokes the BuildSitemap method of the generator
   167 	 * Invokes the BuildSitemap method of the generator
   149 	 */
   168 	 */
   150 	function CallBuildSitemap() {
   169 	function CallBuildSitemap() {
   151 		if(GoogleSitemapGeneratorLoader::LoadPlugin()) {
   170 		if(GoogleSitemapGeneratorLoader::LoadPlugin()) {
   152 			$gs = GoogleSitemapGenerator::GetInstance();
   171 			$gs = &GoogleSitemapGenerator::GetInstance();
   153 			$gs->BuildSitemap();
   172 			$gs->BuildSitemap();
   154 		}
   173 		}
   155 	}
   174 	}
   156 	
   175 	
   157 	/**
   176 	/**
   158 	 * Invokes the CheckForManualBuild method of the generator
   177 	 * Invokes the CheckForManualBuild method of the generator
   159 	 */
   178 	 */
   160 	function CallCheckForManualBuild() {
   179 	function CallCheckForManualBuild() {
   161 		if(GoogleSitemapGeneratorLoader::LoadPlugin()) {
   180 		if(GoogleSitemapGeneratorLoader::LoadPlugin()) {
   162 			$gs = GoogleSitemapGenerator::GetInstance();
   181 			$gs = &GoogleSitemapGenerator::GetInstance();
   163 			$gs->CheckForManualBuild();
   182 			$gs->CheckForManualBuild();
   164 		}
   183 		}
   165 	}
   184 	}
   166 	
   185 	
   167 	/**
   186 	/**
   168 	 * Invokes the ShowPingResult method of the generator
   187 	 * Invokes the ShowPingResult method of the generator
   169 	 */
   188 	 */
   170 	function CallShowPingResult() {
   189 	function CallShowPingResult() {
   171 		if(GoogleSitemapGeneratorLoader::LoadPlugin()) {
   190 		if(GoogleSitemapGeneratorLoader::LoadPlugin()) {
   172 			$gs = GoogleSitemapGenerator::GetInstance();
   191 			$gs = &GoogleSitemapGenerator::GetInstance();
   173 			$gs->ShowPingResult();
   192 			$gs->ShowPingResult();
   174 		}
   193 		}
   175 	}
   194 	}
   176 	
   195 	
   177 
   196 
   178 	function CallHtmlShowHelpList($filterVal,$screen) {
   197 	function CallHtmlShowHelpList($filterVal,$screen) {
   179 		if($screen == "settings_page_sitemap") {
   198 		
       
   199 		$id = get_plugin_page_hookname(GoogleSitemapGeneratorLoader::GetBaseName(),'options-general.php');		
       
   200 		
       
   201 		if($screen == $id) {
   180 			$links = array(
   202 			$links = array(
   181 				__('Plugin Homepage','sitemap')=>'http://www.arnebrachhold.de/redir/sitemap-help-home/',
   203 				__('Plugin Homepage','sitemap')=>'http://www.arnebrachhold.de/redir/sitemap-help-home/',
   182 				__('Sitemap FAQ')=>'http://www.arnebrachhold.de/redir/sitemap-help-faq/'
   204 				__('My Sitemaps FAQ','sitemap')=>'http://www.arnebrachhold.de/redir/sitemap-help-faq/'
   183 			);
   205 			);
   184 			
   206 			
   185 			$filterVal["settings_page_sitemap"] = '';
   207 			$filterVal[$id] = '';
   186 			
   208 			
   187 			$i=0;
   209 			$i=0;
   188 			foreach($links AS $text=>$url) {
   210 			foreach($links AS $text=>$url) {
   189 				$filterVal["settings_page_sitemap"].='<a href="' . $url . '">' . $text . '</a>' . ($i < (count($links)-1)?'<br />':'') ;
   211 				$filterVal[$id].='<a href="' . $url . '">' . $text . '</a>' . ($i < (count($links)-1)?'<br />':'') ;
   190 				$i++;
   212 				$i++;
   191 			}
   213 			}
   192 		}
   214 		}
   193 		return $filterVal;
   215 		return $filterVal;
   194 	}
   216 	}
   195 	
   217 	
   196 	function CallDoRobots() {
   218 	function CallDoRobots() {
   197 		if(GoogleSitemapGeneratorLoader::LoadPlugin()) {
   219 		if(GoogleSitemapGeneratorLoader::LoadPlugin()) {
   198 			$gs = GoogleSitemapGenerator::GetInstance();
   220 			$gs = &GoogleSitemapGenerator::GetInstance();
   199 			$gs->DoRobots();
   221 			$gs->DoRobots();
   200 		}
   222 		}
   201 	}
   223 	}
   202 	
   224 	
   203 	/**
   225 	/**
   206 	 * @return boolean true if run successfully
   228 	 * @return boolean true if run successfully
   207 	 */
   229 	 */
   208 	function LoadPlugin() {
   230 	function LoadPlugin() {
   209 		
   231 		
   210 		$mem = abs(intval(@ini_get('memory_limit')));
   232 		$mem = abs(intval(@ini_get('memory_limit')));
   211 		if($mem && $mem < 32) {
   233 		if($mem && $mem < 64) {
   212 			@ini_set('memory_limit', '32M');
   234 			@ini_set('memory_limit', '64M');
   213 		}
   235 		}
   214 		
   236 		
   215 		$time = abs(intval(@ini_get("max_execution_time")));
   237 		$time = abs(intval(@ini_get("max_execution_time")));
   216 		if($time != 0 && $time < 120) {
   238 		if($time != 0 && $time < 120) {
   217 			@set_time_limit(120);
   239 			@set_time_limit(120);
   253 	 * Uses the WP API to get the meta data from the top of this file (comment)
   275 	 * Uses the WP API to get the meta data from the top of this file (comment)
   254 	 *
   276 	 *
   255 	 * @return string The version like 3.1.1
   277 	 * @return string The version like 3.1.1
   256 	 */
   278 	 */
   257 	function GetVersion() {
   279 	function GetVersion() {
   258 		if(!function_exists('get_plugin_data')) {
   280 		if(!isset($GLOBALS["sm_version"])) {
   259 			if(file_exists(ABSPATH . 'wp-admin/includes/plugin.php')) require_once(ABSPATH . 'wp-admin/includes/plugin.php'); //2.3+
   281 			if(!function_exists('get_plugin_data')) {
   260 			else if(file_exists(ABSPATH . 'wp-admin/admin-functions.php')) require_once(ABSPATH . 'wp-admin/admin-functions.php'); //2.1
   282 				if(file_exists(ABSPATH . 'wp-admin/includes/plugin.php')) require_once(ABSPATH . 'wp-admin/includes/plugin.php'); //2.3+
   261 			else return "0.ERROR";
   283 				else if(file_exists(ABSPATH . 'wp-admin/admin-functions.php')) require_once(ABSPATH . 'wp-admin/admin-functions.php'); //2.1
   262 		}
   284 				else return "0.ERROR";
   263 		$data = get_plugin_data(__FILE__);
   285 			}
   264 		return $data['Version'];
   286 			$data = get_plugin_data(__FILE__, false, false);
   265 	}
   287 			$GLOBALS["sm_version"] = $data['Version'];
   266 	
   288 		}
   267 
   289 		return $GLOBALS["sm_version"];
       
   290 	}
   268 }
   291 }
   269 
   292 
   270 //Enable the plugin for the init hook, but only if WP is loaded. Calling this php file directly will do nothing.
   293 //Enable the plugin for the init hook, but only if WP is loaded. Calling this php file directly will do nothing.
   271 if(defined('ABSPATH') && defined('WPINC')) {
   294 if(defined('ABSPATH') && defined('WPINC')) {
   272 	add_action("init",array("GoogleSitemapGeneratorLoader","Enable"),1000,0);
   295 	add_action("init",array("GoogleSitemapGeneratorLoader","Enable"),1000,0);