From a13d3dd9de03decd61781ee853c5f6d1d4723bdd Mon Sep 17 00:00:00 2001 From: jareddreyerss Date: Tue, 26 Mar 2024 14:20:14 +1300 Subject: [PATCH] Removal of ping from google site maps See https://developers.google.com/search/blog/2023/06/sitemaps-lastmod-ping for context. Accordingly removed all references to notification config and/or ping. --- _config/googlesitemaps.yml | 1 - docs/en/index.md | 11 ++--- src/Extensions/GoogleSitemapExtension.php | 18 ------- src/GoogleSitemap.php | 58 +---------------------- 4 files changed, 5 insertions(+), 83 deletions(-) diff --git a/_config/googlesitemaps.yml b/_config/googlesitemaps.yml index 88eba5b..199a399 100644 --- a/_config/googlesitemaps.yml +++ b/_config/googlesitemaps.yml @@ -4,7 +4,6 @@ Name: googlesitemaps Wilr\GoogleSitemaps\GoogleSitemap: enabled: true objects_per_sitemap: 1000 - google_notification_enabled: false use_show_in_search: true --- Only: diff --git a/docs/en/index.md b/docs/en/index.md index a517d52..97a1ab0 100644 --- a/docs/en/index.md +++ b/docs/en/index.md @@ -38,14 +38,10 @@ After: googlesitemaps Wilr\GoogleSitemaps\GoogleSitemap: enabled: true objects_per_sitemap: 1000 - google_notification_enabled: false use_show_in_search: true ``` -You can now alter any of those properties to set your needs. A popular option -is to turn on automatic pinging so that Google is notified of any updates to -your page. You can set this in the file we created in the last paragraph by -editing the `google_notification_enabled` option to true +You can now alter any of those properties to set your needs. ```yml --- @@ -54,9 +50,8 @@ After: googlesitemaps --- Wilr\GoogleSitemaps\GoogleSitemap: enabled: true - objects_per_sitemap: 1000 - google_notification_enabled: true - use_show_in_search: true + objects_per_sitemap: 1000 + use_show_in_search: true ``` ### Including DataObjects diff --git a/src/Extensions/GoogleSitemapExtension.php b/src/Extensions/GoogleSitemapExtension.php index c91ea1e..8d16e3e 100644 --- a/src/Extensions/GoogleSitemapExtension.php +++ b/src/Extensions/GoogleSitemapExtension.php @@ -73,24 +73,6 @@ public function canIncludeInGoogleSitemap() return $can; } - - /** - * @return void - */ - public function onAfterPublish() - { - GoogleSitemap::ping(); - } - - /** - * @return void - */ - public function onAfterUnpublish() - { - GoogleSitemap::ping(); - } - - /** * The default value of the priority field depends on the depth of the page in * the site tree, so it must be calculated dynamically. diff --git a/src/GoogleSitemap.php b/src/GoogleSitemap.php index f2d41a1..bc64272 100644 --- a/src/GoogleSitemap.php +++ b/src/GoogleSitemap.php @@ -29,17 +29,8 @@ * The GoogleSitemap handle requests to 'sitemap.xml' the other two classes are * used to render the sitemap. * - * You can notify ("ping") Google about a changed sitemap automatically whenever - * a new page is published or unpublished. - * - * By default, Google is not notified, and will pick up your new sitemap - * whenever the GoogleBot visits your website. - * - * To Enable notification of Google after every publish set google_notification_enabled - * to true in the googlesitemaps.yml config file. - * - * This file is usually located in the _config folder of your project folder. - * e.g mysite/_config/googlesitemaps.yml + * The config file is usually located in the _config folder of your project folder. + * e.g. app/_config/googlesitemaps.yml * * * --- @@ -49,7 +40,6 @@ * Wilr\GoogleSitemaps\GoogleSitemap: * enabled: true * objects_per_sitemap: 1000 - * google_notification_enabled: true * use_show_in_search: true * * @@ -84,15 +74,6 @@ class GoogleSitemap */ private static $exclude_redirector_pages = true; - /** - * @config - * - * @var array - */ - private static $search_indexes = [ - 'google' => 'http://www.google.com/webmasters/sitemaps/ping?sitemap=' - ]; - /** * Decorates the given DataObject with {@link GoogleSitemapDecorator} * and pushes the class name to the registered DataObjects. @@ -452,41 +433,6 @@ public static function get_sitemaps() return static::inst()->getSitemaps(); } - /** - * Notifies search indexes about changes to your sitemap. This behavior is disabled - * by default, to enable, read the documentation provided in the docs folder. - * - * After notifications have been enabled, every publish / unpublish of a page. - * will notify enabled search indexes of the update. - * - * If the site is in development mode no ping will be sent. - * - * @return boolean - */ - public static function ping() - { - if (!self::enabled() || Director::isDev()) { - return false; - } - - $location = urlencode(Controller::join_links( - Director::absoluteBaseURL(), - 'sitemap.xml' - )); - - $response = true; - - foreach (self::config()->search_indexes as $name => $url) { - $configName = $name . '_notification_enabled'; - - if (self::config()->$configName) { - $response = $response && file_get_contents($url . $location); - } - } - - return $response; - } - /** * Is GoogleSitemap enabled? *