PageRenderTime 57ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/google-sitemap-generator/sitemap.php

https://gitlab.com/endomorphosis/reservationtelco
PHP | 297 lines | 148 code | 45 blank | 104 comment | 39 complexity | 5c42dd8478d337574695d9eb9ee11b4f MD5 | raw file
  1. <?php
  2. /*
  3. $Id: sitemap.php 246883 2010-05-29 07:28:03Z arnee $
  4. Google XML Sitemaps Generator for WordPress
  5. ==============================================================================
  6. This generator will create a sitemaps.org compliant sitemap of your WordPress blog.
  7. Currently homepage, posts, static pages, categories, archives and author pages are supported.
  8. The priority of a post depends on its comments. You can choose the way the priority
  9. is calculated in the options screen.
  10. Feel free to visit my website under www.arnebrachhold.de!
  11. For aditional details like installation instructions, please check the readme.txt and documentation.txt files.
  12. Have fun!
  13. Arne
  14. Info for WordPress:
  15. ==============================================================================
  16. Plugin Name: Google XML Sitemaps
  17. Plugin URI: http://www.arnebrachhold.de/redir/sitemap-home/
  18. 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.
  19. Version: 3.2.4
  20. Author: Arne Brachhold
  21. Author URI: http://www.arnebrachhold.de/
  22. Text Domain: sitemap
  23. Domain Path: /lang/
  24. */
  25. /**
  26. * Loader class for the Google Sitemap Generator
  27. *
  28. * This class takes care of the sitemap plugin and tries to load the different parts as late as possible.
  29. * On normal requests, only this small class is loaded. When the sitemap needs to be rebuild, the generator itself is loaded.
  30. * The last stage is the user interface which is loaded when the administration page is requested.
  31. */
  32. class GoogleSitemapGeneratorLoader {
  33. /**
  34. * Enabled the sitemap plugin with registering all required hooks
  35. *
  36. * If the sm_command and sm_key GET params are given, the function will init the generator to rebuild the sitemap.
  37. */
  38. function Enable() {
  39. //Check for 3.0 multisite, NOT supported yet!
  40. if((defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE) || (function_exists('is_multisite') && is_multisite())) {
  41. if(function_exists('is_super_admin') && is_super_admin()) {
  42. add_action('admin_notices', array('GoogleSitemapGeneratorLoader', 'AddMultisiteWarning'));
  43. }
  44. return;
  45. }
  46. //Register the sitemap creator to wordpress...
  47. add_action('admin_menu', array('GoogleSitemapGeneratorLoader', 'RegisterAdminPage'));
  48. //Nice icon for Admin Menu (requires Ozh Admin Drop Down Plugin)
  49. add_filter('ozh_adminmenu_icon', array('GoogleSitemapGeneratorLoader', 'RegisterAdminIcon'));
  50. //Additional links on the plugin page
  51. add_filter('plugin_row_meta', array('GoogleSitemapGeneratorLoader', 'RegisterPluginLinks'),10,2);
  52. //Existing posts was deleted
  53. add_action('delete_post', array('GoogleSitemapGeneratorLoader', 'CallCheckForAutoBuild'),9999,1);
  54. //Existing post was published
  55. add_action('publish_post', array('GoogleSitemapGeneratorLoader', 'CallCheckForAutoBuild'),9999,1);
  56. //Existing page was published
  57. add_action('publish_page', array('GoogleSitemapGeneratorLoader', 'CallCheckForAutoBuild'),9999,1);
  58. //WP Cron hook
  59. add_action('sm_build_cron', array('GoogleSitemapGeneratorLoader', 'CallBuildSitemap'),1,0);
  60. //External build hook
  61. add_action('sm_rebuild', array('GoogleSitemapGeneratorLoader', 'CallBuildNowRequest'),1,0);
  62. //Robots.txt request
  63. add_action('do_robots', array('GoogleSitemapGeneratorLoader', 'CallDoRobots'),100,0);
  64. //Help topics for context sensitive help
  65. add_filter('contextual_help_list', array('GoogleSitemapGeneratorLoader', 'CallHtmlShowHelpList'),9999,2);
  66. //Check if this is a BUILD-NOW request (key will be checked later)
  67. if(!empty($_GET["sm_command"]) && !empty($_GET["sm_key"])) {
  68. GoogleSitemapGeneratorLoader::CallCheckForManualBuild();
  69. }
  70. //Check if the result of a ping request should be shown
  71. if(!empty($_GET["sm_ping_service"])) {
  72. GoogleSitemapGeneratorLoader::CallShowPingResult();
  73. }
  74. }
  75. /**
  76. * Outputs the warning bar if multisite mode is activated
  77. */
  78. function AddMultisiteWarning() {
  79. echo "<div id='sm-multisite-warning' class='error fade'><p><strong>".__('Google XML Sitemaps is not multisite compatible.','sitemap')."</strong><br /> ".sprintf(__('Unfortunately the Google XML Sitemaps plugin was not tested with the multisite feature of WordPress 3.0 yet. The plugin will not be active until you disable the multisite mode. Otherwise go to <a href="%1$s">active plugins</a> and deactivate the Google XML Sitemaps plugin to make this message disappear.','sitemap'), "plugins.php?plugin_status=active")."</p></div>";
  80. }
  81. /**
  82. * Registers the plugin in the admin menu system
  83. */
  84. function RegisterAdminPage() {
  85. if (function_exists('add_options_page')) {
  86. add_options_page(__('XML-Sitemap Generator','sitemap'), __('XML-Sitemap','sitemap'), 'level_10', GoogleSitemapGeneratorLoader::GetBaseName(), array('GoogleSitemapGeneratorLoader','CallHtmlShowOptionsPage'));
  87. }
  88. }
  89. function RegisterAdminIcon($hook) {
  90. if ( $hook == GoogleSitemapGeneratorLoader::GetBaseName() && function_exists('plugins_url')) {
  91. return plugins_url('img/icon-arne.gif',GoogleSitemapGeneratorLoader::GetBaseName());
  92. }
  93. return $hook;
  94. }
  95. function RegisterPluginLinks($links, $file) {
  96. $base = GoogleSitemapGeneratorLoader::GetBaseName();
  97. if ($file == $base) {
  98. $links[] = '<a href="options-general.php?page=' . GoogleSitemapGeneratorLoader::GetBaseName() .'">' . __('Settings','sitemap') . '</a>';
  99. $links[] = '<a href="http://www.arnebrachhold.de/redir/sitemap-plist-faq/">' . __('FAQ','sitemap') . '</a>';
  100. $links[] = '<a href="http://www.arnebrachhold.de/redir/sitemap-plist-support/">' . __('Support','sitemap') . '</a>';
  101. $links[] = '<a href="http://www.arnebrachhold.de/redir/sitemap-plist-donate/">' . __('Donate','sitemap') . '</a>';
  102. }
  103. return $links;
  104. }
  105. /**
  106. * Invokes the HtmlShowOptionsPage method of the generator
  107. */
  108. function CallHtmlShowOptionsPage() {
  109. if(GoogleSitemapGeneratorLoader::LoadPlugin()) {
  110. $gs = &GoogleSitemapGenerator::GetInstance();
  111. $gs->HtmlShowOptionsPage();
  112. }
  113. }
  114. /**
  115. * Invokes the CheckForAutoBuild method of the generator
  116. */
  117. function CallCheckForAutoBuild($args) {
  118. if(GoogleSitemapGeneratorLoader::LoadPlugin()) {
  119. $gs = &GoogleSitemapGenerator::GetInstance();
  120. $gs->CheckForAutoBuild($args);
  121. }
  122. }
  123. /**
  124. * Invokes the CheckForAutoBuild method of the generator
  125. */
  126. function CallBuildNowRequest() {
  127. if(GoogleSitemapGeneratorLoader::LoadPlugin()) {
  128. $gs = &GoogleSitemapGenerator::GetInstance();
  129. $gs->BuildNowRequest();
  130. }
  131. }
  132. /**
  133. * Invokes the BuildSitemap method of the generator
  134. */
  135. function CallBuildSitemap() {
  136. if(GoogleSitemapGeneratorLoader::LoadPlugin()) {
  137. $gs = &GoogleSitemapGenerator::GetInstance();
  138. $gs->BuildSitemap();
  139. }
  140. }
  141. /**
  142. * Invokes the CheckForManualBuild method of the generator
  143. */
  144. function CallCheckForManualBuild() {
  145. if(GoogleSitemapGeneratorLoader::LoadPlugin()) {
  146. $gs = &GoogleSitemapGenerator::GetInstance();
  147. $gs->CheckForManualBuild();
  148. }
  149. }
  150. /**
  151. * Invokes the ShowPingResult method of the generator
  152. */
  153. function CallShowPingResult() {
  154. if(GoogleSitemapGeneratorLoader::LoadPlugin()) {
  155. $gs = &GoogleSitemapGenerator::GetInstance();
  156. $gs->ShowPingResult();
  157. }
  158. }
  159. function CallHtmlShowHelpList($filterVal,$screen) {
  160. $id = get_plugin_page_hookname(GoogleSitemapGeneratorLoader::GetBaseName(),'options-general.php');
  161. if($screen == $id) {
  162. $links = array(
  163. __('Plugin Homepage','sitemap')=>'http://www.arnebrachhold.de/redir/sitemap-help-home/',
  164. __('My Sitemaps FAQ','sitemap')=>'http://www.arnebrachhold.de/redir/sitemap-help-faq/'
  165. );
  166. $filterVal[$id] = '';
  167. $i=0;
  168. foreach($links AS $text=>$url) {
  169. $filterVal[$id].='<a href="' . $url . '">' . $text . '</a>' . ($i < (count($links)-1)?'<br />':'') ;
  170. $i++;
  171. }
  172. }
  173. return $filterVal;
  174. }
  175. function CallDoRobots() {
  176. if(GoogleSitemapGeneratorLoader::LoadPlugin()) {
  177. $gs = &GoogleSitemapGenerator::GetInstance();
  178. $gs->DoRobots();
  179. }
  180. }
  181. /**
  182. * Loads the actual generator class and tries to raise the memory and time limits if not already done by WP
  183. *
  184. * @return boolean true if run successfully
  185. */
  186. function LoadPlugin() {
  187. $mem = abs(intval(@ini_get('memory_limit')));
  188. if($mem && $mem < 64) {
  189. @ini_set('memory_limit', '64M');
  190. }
  191. $time = abs(intval(@ini_get("max_execution_time")));
  192. if($time != 0 && $time < 120) {
  193. @set_time_limit(120);
  194. }
  195. if(!class_exists("GoogleSitemapGenerator")) {
  196. $path = trailingslashit(dirname(__FILE__));
  197. if(!file_exists( $path . 'sitemap-core.php')) return false;
  198. require_once($path. 'sitemap-core.php');
  199. }
  200. GoogleSitemapGenerator::Enable();
  201. return true;
  202. }
  203. /**
  204. * Returns the plugin basename of the plugin (using __FILE__)
  205. *
  206. * @return string The plugin basename, "sitemap" for example
  207. */
  208. function GetBaseName() {
  209. return plugin_basename(__FILE__);
  210. }
  211. /**
  212. * Returns the name of this loader script, using __FILE__
  213. *
  214. * @return string The __FILE__ value of this loader script
  215. */
  216. function GetPluginFile() {
  217. return __FILE__;
  218. }
  219. /**
  220. * Returns the plugin version
  221. *
  222. * Uses the WP API to get the meta data from the top of this file (comment)
  223. *
  224. * @return string The version like 3.1.1
  225. */
  226. function GetVersion() {
  227. if(!isset($GLOBALS["sm_version"])) {
  228. if(!function_exists('get_plugin_data')) {
  229. if(file_exists(ABSPATH . 'wp-admin/includes/plugin.php')) require_once(ABSPATH . 'wp-admin/includes/plugin.php'); //2.3+
  230. else if(file_exists(ABSPATH . 'wp-admin/admin-functions.php')) require_once(ABSPATH . 'wp-admin/admin-functions.php'); //2.1
  231. else return "0.ERROR";
  232. }
  233. $data = get_plugin_data(__FILE__, false, false);
  234. $GLOBALS["sm_version"] = $data['Version'];
  235. }
  236. return $GLOBALS["sm_version"];
  237. }
  238. }
  239. //Enable the plugin for the init hook, but only if WP is loaded. Calling this php file directly will do nothing.
  240. if(defined('ABSPATH') && defined('WPINC')) {
  241. add_action("init",array("GoogleSitemapGeneratorLoader","Enable"),1000,0);
  242. }
  243. ?>