Yoast SEO: Search Index Purge - Version 1.1.0

Version Description

Download this release

Release Info

Developer atimmer
Plugin Icon 128x128 Yoast SEO: Search Index Purge
Version 1.1.0
Comparing to
See all releases

Code changes from version 1.0.0 to 1.1.0

readme.txt CHANGED
@@ -6,7 +6,7 @@ License URI: http://www.gnu.org/licenses/gpl.html
6
  Tags: SEO, XML sitemap, Google Search Console, Content analysis, Readability
7
  Requires at least: 4.8
8
  Tested up to: 4.9.6
9
- Stable tag: 1.0.0
10
  Requires PHP: 5.2.4
11
 
12
  Remove attachment URLs from Google's index as fast as possible to prevent thin content penalties.
@@ -63,7 +63,17 @@ You'll find answers to many of your questions on [kb.yoast.com](https://yoa.st/1
63
 
64
  == Changelog ==
65
 
 
 
 
 
 
 
 
 
 
 
66
  = 1.0 =
67
  Release date: May 30th, 2018
68
 
69
- Initial version.
6
  Tags: SEO, XML sitemap, Google Search Console, Content analysis, Readability
7
  Requires at least: 4.8
8
  Tested up to: 4.9.6
9
+ Stable tag: 1.1.0
10
  Requires PHP: 5.2.4
11
 
12
  Remove attachment URLs from Google's index as fast as possible to prevent thin content penalties.
63
 
64
  == Changelog ==
65
 
66
+ = 1.1 =
67
+ Release date: June 27th, 2018
68
+
69
+ Enhancements:
70
+ * Excludes attachments from the purge sitemap that were added after activating this plugin.
71
+
72
+ Bugfixes:
73
+ * Fixes a bug where the Attachement sitemap has the wrong "Last modified" date, this should be the time the plugin was activated.
74
+ * Fixes a bug where the "Redirect attachment URLs to the attachment itself?" can become "No" when saving other settings in Yoast SEO.
75
+
76
  = 1.0 =
77
  Release date: May 30th, 2018
78
 
79
+ Initial version.
src/Yoast_Purge_Attachment_Page_Server.php CHANGED
@@ -1,4 +1,11 @@
1
  <?php
 
 
 
 
 
 
 
2
 
3
  /**
4
  * Serves a 410 page on attachment pages.
@@ -6,7 +13,9 @@
6
  final class Yoast_Purge_Attachment_Page_Server {
7
 
8
  /**
9
- * @var array Valid image mime types.
 
 
10
  */
11
  private $valid_image_types = array( 'image/jpeg', 'image/gif', 'image/png' );
12
 
@@ -71,7 +80,7 @@ final class Yoast_Purge_Attachment_Page_Server {
71
  * @return bool Whether or not the given mime type is for an image.
72
  */
73
  private function is_image( $mime_type ) {
74
- return in_array( $mime_type, $this->valid_image_types );
75
  }
76
 
77
  /**
1
  <?php
2
+ /**
3
+ * Yoast SEO: Search index purge plugin file.
4
+ *
5
+ * @package WPSEO\Main
6
+ * @copyright Copyright (C) 2018, Yoast BV - support@yoast.com
7
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License, version 3 or higher
8
+ */
9
 
10
  /**
11
  * Serves a 410 page on attachment pages.
13
  final class Yoast_Purge_Attachment_Page_Server {
14
 
15
  /**
16
+ * Valid image mime types.
17
+ *
18
+ * @var array
19
  */
20
  private $valid_image_types = array( 'image/jpeg', 'image/gif', 'image/png' );
21
 
80
  * @return bool Whether or not the given mime type is for an image.
81
  */
82
  private function is_image( $mime_type ) {
83
+ return in_array( $mime_type, $this->valid_image_types, true );
84
  }
85
 
86
  /**
src/Yoast_Purge_Attachment_Sitemap.php CHANGED
@@ -1,10 +1,23 @@
1
  <?php
 
 
 
 
 
 
 
2
 
3
-
 
 
4
  final class Yoast_Purge_Attachment_Sitemap {
5
 
6
- /** @var Yoast_Purge_Options */
7
- protected $options;
 
 
 
 
8
 
9
  /**
10
  * Initializes.
@@ -21,6 +34,69 @@ final class Yoast_Purge_Attachment_Sitemap {
21
  public function register_hooks() {
22
  add_filter( 'wpseo_sitemaps_providers', array( $this, 'add_provider' ) );
23
  add_filter( 'wpseo_build_sitemap_post_type', array( $this, 'change_type' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  }
25
 
26
  /**
1
  <?php
2
+ /**
3
+ * Yoast SEO: Search index purge plugin file.
4
+ *
5
+ * @package WPSEO\Main
6
+ * @copyright Copyright (C) 2018, Yoast BV - support@yoast.com
7
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License, version 3 or higher
8
+ */
9
 
10
+ /**
11
+ * Override attachment sitemap integration.
12
+ */
13
  final class Yoast_Purge_Attachment_Sitemap {
14
 
15
+ /**
16
+ * Yoast Purge options handler.
17
+ *
18
+ * @var Yoast_Purge_Options
19
+ */
20
+ private $options;
21
 
22
  /**
23
  * Initializes.
34
  public function register_hooks() {
35
  add_filter( 'wpseo_sitemaps_providers', array( $this, 'add_provider' ) );
36
  add_filter( 'wpseo_build_sitemap_post_type', array( $this, 'change_type' ) );
37
+
38
+ // Exclude attachments that were added after activation.
39
+ add_filter( 'wpseo_typecount_where', array( $this, 'typecount_where_filter' ), 10, 2 );
40
+ add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'exclude_newly_added_attachments' ), 10, 2 );
41
+ }
42
+
43
+ /**
44
+ * Modifies the sitemap count for attachments added after activating the plugin.
45
+ *
46
+ * @param string $where SQL part, defaults to empty string.
47
+ * @param string $post_type Post type name.
48
+ *
49
+ * @return string Adjusted WHERE query part.
50
+ */
51
+ public function typecount_where_filter( $where, $post_type ) {
52
+ global $wpdb;
53
+
54
+ // Only hook into attachment sitemaps.
55
+ if ( $post_type !== 'attachment' ) {
56
+ return $where;
57
+ }
58
+
59
+ // Only count items added before activating.
60
+ $where .= $wpdb->prepare(
61
+ " AND {$wpdb->posts}.post_date <= %s",
62
+ date( 'Y-m-d H:i:s', $this->options->get_activation_date() )
63
+ );
64
+
65
+ return $where;
66
+ }
67
+
68
+ /**
69
+ * Excludes attachments from the sitemap that were added after activating.
70
+ *
71
+ * @param array $excluded List of excluded post ids.
72
+ *
73
+ * @return array Modified list of excluded post ids.
74
+ */
75
+ public function exclude_newly_added_attachments( $excluded ) {
76
+ // Add newly added attachments to the list.
77
+ $timestamp = $this->options->get_activation_date();
78
+
79
+ $wp_query = new WP_Query(
80
+ array(
81
+ 'post_type' => 'attachment',
82
+ 'post_status' => 'any',
83
+ 'posts_per_page' => '100000',
84
+ 'date_query' => array(
85
+ 'after' => date( 'Y-m-d H:i:s', $timestamp ),
86
+ ),
87
+ 'fields' => 'ids',
88
+ )
89
+ );
90
+
91
+ if ( empty( $wp_query->posts ) ) {
92
+ return $excluded;
93
+ }
94
+
95
+ // Make sure the variable is an array.
96
+ $excluded = (array) $excluded;
97
+
98
+ // Combine the two into a complete list.
99
+ return array_unique( array_merge( $excluded, $wp_query->posts ) );
100
  }
101
 
102
  /**
src/Yoast_Purge_Attachment_Sitemap_Provider.php CHANGED
@@ -1,10 +1,23 @@
1
  <?php
 
 
 
 
 
 
 
2
 
3
-
 
 
4
  final class Yoast_Purge_Attachment_Sitemap_Provider extends WPSEO_Post_Type_Sitemap_Provider {
5
 
6
- /** @var Yoast_Purge_Options */
7
- protected $options;
 
 
 
 
8
 
9
  /**
10
  * Initializes.
@@ -71,4 +84,31 @@ final class Yoast_Purge_Attachment_Sitemap_Provider extends WPSEO_Post_Type_Site
71
  return parent::get_sitemap_links( 'attachment', $max_entries, $current_page );
72
  }
73
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  }
1
  <?php
2
+ /**
3
+ * Yoast SEO: Search index purge plugin file.
4
+ *
5
+ * @package WPSEO\Main
6
+ * @copyright Copyright (C) 2018, Yoast BV - support@yoast.com
7
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License, version 3 or higher
8
+ */
9
 
10
+ /**
11
+ * Sitemap attachment provider.
12
+ */
13
  final class Yoast_Purge_Attachment_Sitemap_Provider extends WPSEO_Post_Type_Sitemap_Provider {
14
 
15
+ /**
16
+ * Yoast Purge options handler.
17
+ *
18
+ * @var Yoast_Purge_Options
19
+ */
20
+ private $options;
21
 
22
  /**
23
  * Initializes.
84
  return parent::get_sitemap_links( 'attachment', $max_entries, $current_page );
85
  }
86
 
87
+ /**
88
+ * Retrieves the index links for the sitemap to put in the index.
89
+ *
90
+ * @param int $max_entries Entries per sitemap.
91
+ *
92
+ * @return array List of sitemap index links.
93
+ */
94
+ public function get_index_links( $max_entries ) {
95
+ $index_links = parent::get_index_links( $max_entries );
96
+
97
+ $index_links = array_map( array( $this, 'set_modification_date' ), $index_links );
98
+
99
+ return $index_links;
100
+ }
101
+
102
+ /**
103
+ * Overwrites the modification date with the plugin activation date.
104
+ *
105
+ * @param array $entry Sitemap link index.
106
+ *
107
+ * @return array Modified sitemap link index.
108
+ */
109
+ public function set_modification_date( $entry ) {
110
+ $entry['lastmod'] = date( 'Y-m-d H:i:s', $this->options->get_activation_date() );
111
+
112
+ return $entry;
113
+ }
114
  }
src/Yoast_Purge_Control_Yoast_SEO_Settings.php CHANGED
@@ -1,18 +1,44 @@
1
  <?php
 
 
 
 
 
 
 
2
 
3
  /**
4
  * This class ensures the Yoast SEO Settings are being set as needed.
5
  */
6
  class Yoast_Purge_Control_Yoast_SEO_Settings {
7
  /**
8
- * Ensures the settings are set as we recommend them to be.
 
 
9
  */
10
- public function enforce_settings() {
11
- // Disable the attachment pages and redirect them to the attachment itself.
12
- WPSEO_Options::set( 'disable-attachment', true );
13
 
14
- // Make sure the Purge messages will never be shown again.
15
- WPSEO_Options::set( 'is-media-purge-relevant', false );
 
 
 
 
 
 
 
16
 
 
 
 
 
 
 
 
 
 
 
17
  }
18
  }
1
  <?php
2
+ /**
3
+ * Yoast SEO: Search index purge plugin file.
4
+ *
5
+ * @package WPSEO\Main
6
+ * @copyright Copyright (C) 2018, Yoast BV - support@yoast.com
7
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License, version 3 or higher
8
+ */
9
 
10
  /**
11
  * This class ensures the Yoast SEO Settings are being set as needed.
12
  */
13
  class Yoast_Purge_Control_Yoast_SEO_Settings {
14
  /**
15
+ * Adds WordPress hooks and filters.
16
+ *
17
+ * @return void
18
  */
19
+ public function register_hooks() {
20
+ add_filter( 'wpseo_option_tab-metas_media', array( $this, 'add_hidden_settings' ) );
21
+ }
22
 
23
+ /**
24
+ * Adds the setting to the media tab to make sure it is not overwritten with empty -> false.
25
+ *
26
+ * @param string|null $input The current content of the filter value.
27
+ *
28
+ * @return string|null The unmodified content of the filter value.
29
+ */
30
+ public function add_hidden_settings( $input ) {
31
+ echo '<input type="hidden" name="wpseo_titles[disable-attachment]" value="on">';
32
 
33
+ return $input;
34
+ }
35
+
36
+ /**
37
+ * Ensures the settings are set as we recommend them to be.
38
+ *
39
+ * @deprecated 1.1.0
40
+ */
41
+ public function enforce_settings() {
42
+ // Intentionally left empty.
43
  }
44
  }
src/Yoast_Purge_Media_Settings_Tab_Content.php CHANGED
@@ -1,4 +1,11 @@
1
  <?php
 
 
 
 
 
 
 
2
 
3
  /**
4
  * This class will override the Media content tab content.
1
  <?php
2
+ /**
3
+ * Yoast SEO: Search index purge plugin file.
4
+ *
5
+ * @package WPSEO\Main
6
+ * @copyright Copyright (C) 2018, Yoast BV - support@yoast.com
7
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License, version 3 or higher
8
+ */
9
 
10
  /**
11
  * This class will override the Media content tab content.
src/Yoast_Purge_Options.php CHANGED
@@ -1,12 +1,51 @@
1
  <?php
 
 
 
 
 
 
 
2
 
3
  /**
4
  * Handels retrieving and saving options for the plugin.
5
  */
6
  final class Yoast_Purge_Options {
7
 
 
 
 
 
 
8
  const KEY_ACTIVATION_DATE = 'yoast-index-purge-activation-date';
 
 
 
 
 
 
9
  const KEY_PURGE_ATTACHMENT_PAGES = 'yoast-index-purge-attachment-pages';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
  /**
12
  * Returns the activation date of the plugin as a unix timestamp.
@@ -25,11 +64,11 @@ final class Yoast_Purge_Options {
25
  * @return bool Whether or not the value was updated.
26
  */
27
  public function set_activation_date( $value ) {
28
- return update_option( self::KEY_ACTIVATION_DATE, $value );
29
  }
30
 
31
  /**
32
- * Returns whether or not attachment paged should be purged.
33
  *
34
  * @return bool Whether or not attachment pages should be purged.
35
  */
@@ -60,9 +99,9 @@ final class Yoast_Purge_Options {
60
  * @return bool Whether or not the value was updated.
61
  */
62
  public function set_purge_attachment_pages( $value ) {
63
- $value = $value ? 'true' : 'false';
64
 
65
- return update_option( self::KEY_PURGE_ATTACHMENT_PAGES, $value );
66
  }
67
 
68
  /**
@@ -75,7 +114,7 @@ final class Yoast_Purge_Options {
75
  }
76
 
77
  $purge_attachment_pages = $this->get_purge_attachment_pages();
78
- if ( $purge_attachment_pages === null) {
79
  $this->set_purge_attachment_pages( true );
80
  }
81
  }
1
  <?php
2
+ /**
3
+ * Yoast SEO: Search index purge plugin file.
4
+ *
5
+ * @package WPSEO\Main
6
+ * @copyright Copyright (C) 2018, Yoast BV - support@yoast.com
7
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License, version 3 or higher
8
+ */
9
 
10
  /**
11
  * Handels retrieving and saving options for the plugin.
12
  */
13
  final class Yoast_Purge_Options {
14
 
15
+ /**
16
+ * Name of the option in which the plugin activation date is saved.
17
+ *
18
+ * @var string
19
+ */
20
  const KEY_ACTIVATION_DATE = 'yoast-index-purge-activation-date';
21
+
22
+ /**
23
+ * Name of the option which contains the toggle whether or not attachment pages should be purged.
24
+ *
25
+ * @var string
26
+ */
27
  const KEY_PURGE_ATTACHMENT_PAGES = 'yoast-index-purge-attachment-pages';
28
+ const KEY_VERSION = 'yoast-index-purge-version';
29
+
30
+ /**
31
+ * Retrieves the stored version.
32
+ *
33
+ * @return string The version saved in the database.
34
+ */
35
+ public function get_version() {
36
+ return get_option( self::KEY_VERSION, null );
37
+ }
38
+
39
+ /**
40
+ * Updates the version.
41
+ *
42
+ * @param string $version The version to set.
43
+ *
44
+ * @return void
45
+ */
46
+ public function set_version( $version ) {
47
+ update_option( self::KEY_VERSION, $version, true );
48
+ }
49
 
50
  /**
51
  * Returns the activation date of the plugin as a unix timestamp.
64
  * @return bool Whether or not the value was updated.
65
  */
66
  public function set_activation_date( $value ) {
67
+ return update_option( self::KEY_ACTIVATION_DATE, $value, true );
68
  }
69
 
70
  /**
71
+ * Returns whether or not attachment pages should be purged.
72
  *
73
  * @return bool Whether or not attachment pages should be purged.
74
  */
99
  * @return bool Whether or not the value was updated.
100
  */
101
  public function set_purge_attachment_pages( $value ) {
102
+ $value = ( $value === true ) ? 'true' : 'false';
103
 
104
+ return update_option( self::KEY_PURGE_ATTACHMENT_PAGES, $value, true );
105
  }
106
 
107
  /**
114
  }
115
 
116
  $purge_attachment_pages = $this->get_purge_attachment_pages();
117
+ if ( $purge_attachment_pages === null ) {
118
  $this->set_purge_attachment_pages( true );
119
  }
120
  }
src/Yoast_Purge_Plugin.php CHANGED
@@ -1,4 +1,11 @@
1
  <?php
 
 
 
 
 
 
 
2
 
3
  /**
4
  * The main class to initialize everything.
@@ -6,14 +13,24 @@
6
  final class Yoast_Purge_Plugin {
7
 
8
  /**
 
 
9
  * @var array
10
  */
11
  private $integrations = array();
12
 
13
- /** @var Yoast_Purge_Require_Yoast_SEO_Version */
 
 
 
 
14
  private $requirement_checker;
15
 
16
- /** @var Yoast_Purge_Options */
 
 
 
 
17
  private $options;
18
 
19
  /**
@@ -21,14 +38,16 @@ final class Yoast_Purge_Plugin {
21
  */
22
  public function __construct() {
23
  $this->requirement_checker = new Yoast_Purge_Require_Yoast_SEO_Version();
24
- $this->options = new Yoast_Purge_Options();
25
  }
26
 
27
  /**
28
  * Adds the integrations that the plugin needs.
29
  */
30
  public function add_integrations() {
31
- $this->integrations = array();
 
 
32
 
33
  // Add integrations that handle the purging of the attachment pages.
34
  if ( $this->options->is_attachment_page_purging_active() ) {
@@ -38,6 +57,7 @@ final class Yoast_Purge_Plugin {
38
  new Yoast_Purge_Attachment_Page_Server(),
39
  new Yoast_Purge_Media_Settings_Tab_Content(),
40
  new Yoast_Purge_Attachment_Sitemap( $this->options ),
 
41
  )
42
  );
43
  }
@@ -69,11 +89,10 @@ final class Yoast_Purge_Plugin {
69
 
70
  /**
71
  * Executes everything we need on activation.
 
 
72
  */
73
  public function activate() {
74
- $seo_settings = new Yoast_Purge_Control_Yoast_SEO_Settings();
75
- $seo_settings->enforce_settings();
76
-
77
- $this->options->set_default_options();
78
  }
79
  }
1
  <?php
2
+ /**
3
+ * Yoast SEO: Search index purge plugin file.
4
+ *
5
+ * @package WPSEO\Main
6
+ * @copyright Copyright (C) 2018, Yoast BV - support@yoast.com
7
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License, version 3 or higher
8
+ */
9
 
10
  /**
11
  * The main class to initialize everything.
13
  final class Yoast_Purge_Plugin {
14
 
15
  /**
16
+ * List of integrations.
17
+ *
18
  * @var array
19
  */
20
  private $integrations = array();
21
 
22
+ /**
23
+ * Yoast SEO requirement checker.
24
+ *
25
+ * @var Yoast_Purge_Require_Yoast_SEO_Version
26
+ */
27
  private $requirement_checker;
28
 
29
+ /**
30
+ * Yoast Purge options handler.
31
+ *
32
+ * @var Yoast_Purge_Options
33
+ */
34
  private $options;
35
 
36
  /**
38
  */
39
  public function __construct() {
40
  $this->requirement_checker = new Yoast_Purge_Require_Yoast_SEO_Version();
41
+ $this->options = new Yoast_Purge_Options();
42
  }
43
 
44
  /**
45
  * Adds the integrations that the plugin needs.
46
  */
47
  public function add_integrations() {
48
+ $this->integrations = array(
49
+ new Yoast_Purge_Upgrade( $this->options ),
50
+ );
51
 
52
  // Add integrations that handle the purging of the attachment pages.
53
  if ( $this->options->is_attachment_page_purging_active() ) {
57
  new Yoast_Purge_Attachment_Page_Server(),
58
  new Yoast_Purge_Media_Settings_Tab_Content(),
59
  new Yoast_Purge_Attachment_Sitemap( $this->options ),
60
+ new Yoast_Purge_Control_Yoast_SEO_Settings()
61
  )
62
  );
63
  }
89
 
90
  /**
91
  * Executes everything we need on activation.
92
+ *
93
+ * @deprecated 1.1.0
94
  */
95
  public function activate() {
96
+ // Intentionally left empty.
 
 
 
97
  }
98
  }
src/Yoast_Purge_Require_Yoast_SEO_Version.php CHANGED
@@ -1,4 +1,11 @@
1
  <?php
 
 
 
 
 
 
 
2
 
3
  /**
4
  * The class to check for environment requirements.
1
  <?php
2
+ /**
3
+ * Yoast SEO: Search index purge plugin file.
4
+ *
5
+ * @package WPSEO\Main
6
+ * @copyright Copyright (C) 2018, Yoast BV - support@yoast.com
7
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License, version 3 or higher
8
+ */
9
 
10
  /**
11
  * The class to check for environment requirements.
src/Yoast_Purge_Upgrade.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ final class Yoast_Purge_Upgrade {
4
+ /**
5
+ * @var Yoast_Purge_Options
6
+ */
7
+ private $options;
8
+
9
+ /**
10
+ * Yoast_Purge_Upgrade constructor.
11
+ *
12
+ * @param Yoast_Purge_Options $options
13
+ */
14
+ public function __construct( Yoast_Purge_Options $options ) {
15
+ $this->options = $options;
16
+ }
17
+
18
+ /**
19
+ * Registers WordPress hooks and filters.
20
+ *
21
+ * @return void
22
+ */
23
+ public function register_hooks() {
24
+ $this->run();
25
+ }
26
+
27
+ /**
28
+ * Runs upgrades, if applicable.
29
+ *
30
+ * @return void
31
+ */
32
+ private function run() {
33
+ // Always make sure the defaults are set - these are autoloaded.
34
+ $this->options->set_default_options();
35
+
36
+ $version = $this->options->get_version();
37
+ if ( $version === YOAST_PURGE_VERSION ) {
38
+ return;
39
+ }
40
+
41
+ if ( version_compare( $version, '1.0.0', '<' ) ) {
42
+ $this->upgrade_100();
43
+ }
44
+
45
+ $this->finish_up();
46
+ }
47
+
48
+ /**
49
+ * Completes the upgrade routine.
50
+ *
51
+ * @return void
52
+ */
53
+ private function finish_up() {
54
+ // Ensure the current version is set in the database.
55
+ $this->options->set_version( YOAST_PURGE_VERSION );
56
+
57
+ // Flush the sitemap cache, to make sure the changes are picked up.
58
+ WPSEO_Sitemaps_Cache::clear();
59
+ }
60
+
61
+ /**
62
+ * Upgrades to version 1.0.0
63
+ *
64
+ * @return void
65
+ */
66
+ private function upgrade_100() {
67
+ // Disable the attachment pages and redirect them to the attachment itself.
68
+ WPSEO_Options::set( 'disable-attachment', true );
69
+
70
+ // Make sure the Purge messages will never be shown again.
71
+ WPSEO_Options::set( 'is-media-purge-relevant', false );
72
+ }
73
+ }
yoast-seo-search-index-purge.php CHANGED
@@ -8,7 +8,7 @@
8
  *
9
  * @wordpress-plugin
10
  * Plugin Name: Yoast SEO: Search index purge
11
- * Version: 1.0.0
12
  * Plugin URI: https://wordpress.org/plugins/yoast-seo-search-index-purge/
13
  * Description: Remove attachment URLs from Google's index as fast as possible to prevent thin content penalties.
14
  * Author: Team Yoast
@@ -40,6 +40,7 @@ if ( ! function_exists( 'add_filter' ) ) {
40
 
41
  define( 'YOAST_PURGE_PLUGIN_DIR', dirname( __FILE__ ) );
42
  define( 'YOAST_PURGE_FILE', __FILE__ );
 
43
 
44
  require_once YOAST_PURGE_PLUGIN_DIR . '/src/Yoast_Purge_Attachment_Page_Server.php';
45
  require_once YOAST_PURGE_PLUGIN_DIR . '/src/Yoast_Purge_Attachment_Sitemap.php';
@@ -47,11 +48,11 @@ require_once YOAST_PURGE_PLUGIN_DIR . '/src/Yoast_Purge_Control_Yoast_SEO_Settin
47
  require_once YOAST_PURGE_PLUGIN_DIR . '/src/Yoast_Purge_Media_Settings_Tab_Content.php';
48
  require_once YOAST_PURGE_PLUGIN_DIR . '/src/Yoast_Purge_Options.php';
49
  require_once YOAST_PURGE_PLUGIN_DIR . '/src/Yoast_Purge_Plugin.php';
 
50
  require_once YOAST_PURGE_PLUGIN_DIR . '/src/Yoast_Purge_Require_Yoast_SEO_Version.php';
51
 
52
  global $yoast_purge_plugin;
53
  $yoast_purge_plugin = new Yoast_Purge_Plugin();
54
  $yoast_purge_plugin->add_integrations();
55
- add_action( 'plugins_loaded', array( $yoast_purge_plugin, 'register_hooks' ) );
56
 
57
- register_activation_hook( YOAST_PURGE_FILE, array( $yoast_purge_plugin, 'activate' ) );
8
  *
9
  * @wordpress-plugin
10
  * Plugin Name: Yoast SEO: Search index purge
11
+ * Version: 1.1.0
12
  * Plugin URI: https://wordpress.org/plugins/yoast-seo-search-index-purge/
13
  * Description: Remove attachment URLs from Google's index as fast as possible to prevent thin content penalties.
14
  * Author: Team Yoast
40
 
41
  define( 'YOAST_PURGE_PLUGIN_DIR', dirname( __FILE__ ) );
42
  define( 'YOAST_PURGE_FILE', __FILE__ );
43
+ define( 'YOAST_PURGE_VERSION', '1.1.0' );
44
 
45
  require_once YOAST_PURGE_PLUGIN_DIR . '/src/Yoast_Purge_Attachment_Page_Server.php';
46
  require_once YOAST_PURGE_PLUGIN_DIR . '/src/Yoast_Purge_Attachment_Sitemap.php';
48
  require_once YOAST_PURGE_PLUGIN_DIR . '/src/Yoast_Purge_Media_Settings_Tab_Content.php';
49
  require_once YOAST_PURGE_PLUGIN_DIR . '/src/Yoast_Purge_Options.php';
50
  require_once YOAST_PURGE_PLUGIN_DIR . '/src/Yoast_Purge_Plugin.php';
51
+ require_once YOAST_PURGE_PLUGIN_DIR . '/src/Yoast_Purge_Upgrade.php';
52
  require_once YOAST_PURGE_PLUGIN_DIR . '/src/Yoast_Purge_Require_Yoast_SEO_Version.php';
53
 
54
  global $yoast_purge_plugin;
55
  $yoast_purge_plugin = new Yoast_Purge_Plugin();
56
  $yoast_purge_plugin->add_integrations();
 
57
 
58
+ add_action( 'plugins_loaded', array( $yoast_purge_plugin, 'register_hooks' ), 20 );