Yoast SEO: Search Index Purge - Version 1.0.0

Version Description

Download this release

Release Info

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

Version 1.0.0

readme.txt ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Yoast SEO: Search Index Purge ===
2
+ Contributors: yoast, joostdevalk, tacoverdo, omarreiss, atimmer, jipmoors
3
+ Donate link: https://yoa.st/1up
4
+ License: GPLv3
5
+ 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.
13
+
14
+ == Description ==
15
+
16
+ The purpose of this SEO plugin is to purge attachment URLs out of Google's index as fast as possible. This helps sites
17
+ that might have suffered from having too many thin content pages in the search index by removing them in the fastest
18
+ way possible.
19
+
20
+ ## What does this plugin do?
21
+ This plugin makes all your attachment URLs return an HTTP 410 status. It then creates an XML sitemap with a recent last
22
+ modified date, containing all those URLs. The XML sitemap with recent post modified date makes Google spider _all_ those
23
+ URLs again. The 410 status code makes sure Google takes them out of its search results in the fastest way possible.
24
+
25
+ With a nice trick, we also show end users the actual attachment image, so the user experience is not as poor as when
26
+ they see an error page.
27
+
28
+ ## Yoast SEO required
29
+ This plugin is an extension to [Yoast SEO](https://wordpress.org/plugins/wordpress-seo/). It requires it to work.
30
+
31
+ ## How long should you run this plugin?
32
+ After 6 months the attachment URLs should be gone from the search results. If you then remove the plugin, and keep
33
+ Yoast SEO's redirect setting on "Yes", you have the best long term behavior for attachment URLs: to redirect to the
34
+ actual attachment.
35
+
36
+ ## Does Google condone this?
37
+ This method has been discussed with and OK'd by Google.
38
+
39
+ == Installation ==
40
+
41
+ === From within WordPress ===
42
+
43
+ 1. Visit 'Plugins > Add New'
44
+ 1. Search for 'Yoast SEO: Search Index Purge'
45
+ 1. Activate Yoast SEO: Search Index Purge from your Plugins page.
46
+ 1. Go to "after activation" below.
47
+
48
+ === Manually ===
49
+
50
+ 1. Upload the `yoast-seo-search-index-purge` folder to the `/wp-content/plugins/` directory
51
+ 1. Activate the Yoast SEO: Search Index Purge plugin through the 'Plugins' menu in WordPress
52
+ 1. Go to "after activation" below.
53
+
54
+ === After activation ===
55
+
56
+ == Frequently Asked Questions ==
57
+
58
+ You'll find answers to many of your questions on [kb.yoast.com](https://yoa.st/1va).
59
+
60
+ == Screenshots ==
61
+
62
+ 1. The plugin takes over the Search Appearance → Media settings from Yoast SEO.
63
+
64
+ == Changelog ==
65
+
66
+ = 1.0 =
67
+ Release date: May 30th, 2018
68
+
69
+ Initial version.
src/Yoast_Purge_Attachment_Page_Server.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Serves a 410 page on attachment pages.
5
+ */
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
+
13
+ /**
14
+ * Registers to WordPress.
15
+ */
16
+ public function register_hooks() {
17
+ // We need to do this earlier than Yoast SEO redirects the attachment.
18
+ add_action( 'template_redirect', array( $this, 'serve' ), -10 );
19
+ add_action( 'wpseo_attachment_redirect_url', '__return_null' );
20
+ }
21
+
22
+ /**
23
+ * Renders a file with a specific mime type to the browser.
24
+ *
25
+ * @param string $filepath Path to the file to render.
26
+ * @param string $mime_type Mime type to render it with.
27
+ */
28
+ public function render_file( $filepath, $mime_type ) {
29
+ // Open the attachment in a binary mode.
30
+ $file = fopen( $filepath, 'rb' );
31
+
32
+ // Send the right headers.
33
+ header( 'Content-Type: ' . $mime_type );
34
+ header( 'Content-Length: ' . filesize( $filepath ) );
35
+
36
+ // Doing this instead of file_get_contents -> echo prevents PHP memory exhaustion.
37
+ fpassthru( $file );
38
+ }
39
+
40
+ /**
41
+ * Renders the current attached file to the browser.
42
+ */
43
+ public function render_attached_file() {
44
+ $attachment = get_post( get_queried_object_id() );
45
+ $filepath = get_attached_file( $attachment->ID );
46
+ $mime_type = $attachment->post_mime_type;
47
+
48
+ if ( $this->is_image( $mime_type ) ) {
49
+ $this->render_file( $filepath, $mime_type );
50
+ }
51
+ else {
52
+ $this->set_404();
53
+ }
54
+ }
55
+
56
+ /**
57
+ * Serve a 410 for attachment pages.
58
+ */
59
+ public function serve() {
60
+ if ( is_attachment() ) {
61
+ status_header( 410 );
62
+ $this->render_attached_file();
63
+ }
64
+ }
65
+
66
+ /**
67
+ * Determines if a mime type is for an image.
68
+ *
69
+ * @param string $mime_type The mime type to check.
70
+ *
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
+ /**
78
+ * Sets the 404 status in WordPress to true.
79
+ */
80
+ protected function set_404() {
81
+ global $wp_query;
82
+ $wp_query->is_404 = true;
83
+ }
84
+ }
src/Yoast_Purge_Attachment_Sitemap.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ final class Yoast_Purge_Attachment_Sitemap {
5
+
6
+ /** @var Yoast_Purge_Options */
7
+ protected $options;
8
+
9
+ /**
10
+ * Initializes.
11
+ *
12
+ * @param Yoast_Purge_Options $options The options class.
13
+ */
14
+ public function __construct( Yoast_Purge_Options $options ) {
15
+ $this->options = $options;
16
+ }
17
+
18
+ /**
19
+ * Registers hooks to WordPress.
20
+ */
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
+ /**
27
+ * Adds a provider to the list of Yoast SEO Sitemap providers.
28
+ *
29
+ * @param array $providers List of external sitemap providers.
30
+ *
31
+ * @return array List of external sitemap providers without our provider added.
32
+ */
33
+ public function add_provider( $providers ) {
34
+ require_once YOAST_PURGE_PLUGIN_DIR . '/src/Yoast_Purge_Attachment_Sitemap_Provider.php';
35
+
36
+ $providers[] = new Yoast_Purge_Attachment_Sitemap_Provider( $this->options );
37
+
38
+ return $providers;
39
+ }
40
+
41
+ /**
42
+ * Because Yoast SEO will mark the sitemap as invalid if the first provider
43
+ * doesn't return any links we need to change the type of the request so we
44
+ * make sure that our provider can handle the attachment sitemap.
45
+ *
46
+ * @param string $type The unmodified type for the sitemap.
47
+ * @return string The modified type for the sitemap.
48
+ */
49
+ public function change_type( $type ) {
50
+ if ( $type === 'attachment' ) {
51
+ $type = 'purge_attachment';
52
+ }
53
+
54
+ return $type;
55
+ }
56
+ }
src/Yoast_Purge_Attachment_Sitemap_Provider.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.
11
+ *
12
+ * @param Yoast_Purge_Options $options The options class.
13
+ */
14
+ public function __construct( Yoast_Purge_Options $options ) {
15
+ $this->options = $options;
16
+ }
17
+
18
+ /**
19
+ * Determines whether this provider can handle the given type.
20
+ *
21
+ * @param string $type The type that could be handled.
22
+ *
23
+ * @return bool Whether this provider can handle the given type.
24
+ */
25
+ public function handles_type( $type ) {
26
+ return $type === 'purge_attachment';
27
+ }
28
+
29
+ /**
30
+ * Determines whether the given post type is valid for this provider.
31
+ *
32
+ * @param string $post_type The type to check.
33
+ *
34
+ * @return bool Whether this provider can handle the post type.
35
+ */
36
+ public function is_valid_post_type( $post_type ) {
37
+ return $post_type === 'attachment';
38
+ }
39
+
40
+ /**
41
+ * Returns the sitemap data for a given post.
42
+ *
43
+ * We only overwrite the last modified date because we want to hardcode it
44
+ * to the activation date of this plugin.
45
+ *
46
+ * @param stdClass $post The post data for which to build the sitemap item.
47
+ *
48
+ * @return array The data for the sitemap link.
49
+ */
50
+ public function get_url( $post ) {
51
+ $link = parent::get_url( $post );
52
+
53
+ $link['mod'] = date( 'Y-m-d H:i:s', $this->options->get_activation_date() );
54
+
55
+ return $link;
56
+ }
57
+
58
+ /**
59
+ * Returns the sitemap links for attachments.
60
+ *
61
+ * We could do an extra check on type here, but that should already be
62
+ * handled by `handles_type`.
63
+ *
64
+ * @param string $type The type we are building for.
65
+ * @param int $max_entries The maximum amount of entries per page.
66
+ * @param int $current_page The current page we are on.
67
+ *
68
+ * @return array List of links that should be rendered.
69
+ */
70
+ public function get_sitemap_links( $type, $max_entries, $current_page ) {
71
+ return parent::get_sitemap_links( 'attachment', $max_entries, $current_page );
72
+ }
73
+
74
+ }
src/Yoast_Purge_Control_Yoast_SEO_Settings.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ }
src/Yoast_Purge_Media_Settings_Tab_Content.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * This class will override the Media content tab content.
5
+ */
6
+ class Yoast_Purge_Media_Settings_Tab_Content {
7
+ /**
8
+ * Registers the WordPress hooks and filters.
9
+ */
10
+ public function register_hooks() {
11
+ add_filter( 'wpseo_option_tab-metas_media', array( $this, 'get_content' ) );
12
+ }
13
+
14
+ /**
15
+ * Retrieves the content that needs to be shown instead of the default Media configuration tab.
16
+ */
17
+ public function get_content() {
18
+ $content = '';
19
+
20
+ $content .= sprintf(
21
+ '<h1>%s</h1>',
22
+ __( 'These settings are being overridden by the Search Index Purge plugin.', 'yoast-search-index-purge' )
23
+ );
24
+
25
+ $content .= sprintf(
26
+ '<p>%s</p>',
27
+ __( 'You are actively purging attachment URLs out of Google\'s search index.', 'yoast-search-index-purge' )
28
+ );
29
+
30
+ $content .= sprintf(
31
+ '<p>%s</p>',
32
+ sprintf(
33
+ /* translators: %1$s expands to the link to the article, %2$s expands to the closing tag of the link */
34
+ __( 'Read more about the %1$sSearch Index Purge plugin%2$s.', 'yoast-search-index-purge' ),
35
+ '<a href="' . esc_attr( WPSEO_Shortlinker::get( 'https://yoa.st/2r8' ) ) . '" target="_blank" rel="noopener nofollow">',
36
+ '</a>'
37
+ )
38
+ );
39
+
40
+ return $content;
41
+ }
42
+ }
src/Yoast_Purge_Options.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.
13
+ *
14
+ * @return int The activation date.
15
+ */
16
+ public function get_activation_date() {
17
+ return get_option( self::KEY_ACTIVATION_DATE, null );
18
+ }
19
+
20
+ /**
21
+ * Sets the activation date of the plugin.
22
+ *
23
+ * @param int $value The activation date as a unix timestamp.
24
+ *
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
+ */
36
+ public function get_purge_attachment_pages() {
37
+ $saved = get_option( self::KEY_PURGE_ATTACHMENT_PAGES, null );
38
+
39
+ if ( $saved === null ) {
40
+ return null;
41
+ }
42
+
43
+ return $saved === 'true';
44
+ }
45
+
46
+ /**
47
+ * Returns whether or not attachment paged should be purged.
48
+ *
49
+ * @return bool Whether or not attachment pages should be purged.
50
+ */
51
+ public function is_attachment_page_purging_active() {
52
+ return $this->get_purge_attachment_pages();
53
+ }
54
+
55
+ /**
56
+ * Sets whether attachment pages should be purged.
57
+ *
58
+ * @param bool $value Whether attachment pages should be purged.
59
+ *
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
+ /**
69
+ * Sets the database options to the default options.
70
+ */
71
+ public function set_default_options() {
72
+ $activation_date = $this->get_activation_date();
73
+ if ( $activation_date === null ) {
74
+ $this->set_activation_date( time() );
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
+ }
82
+ }
src/Yoast_Purge_Plugin.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * The main class to initialize everything.
5
+ */
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
+ /**
20
+ * Initializes the 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() ) {
35
+ $this->integrations = array_merge(
36
+ $this->integrations,
37
+ array(
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
+ }
44
+ }
45
+
46
+ /**
47
+ * Registers hooks to WordPress.
48
+ */
49
+ public function register_hooks() {
50
+ // Always show notifications, even if the rest cannot be activated.
51
+ $this->requirement_checker->register_hooks();
52
+ if ( ! $this->requirement_checker->has_required_version() ) {
53
+ return;
54
+ }
55
+
56
+ foreach ( $this->integrations as $integration ) {
57
+ $integration->register_hooks();
58
+ }
59
+ }
60
+
61
+ /**
62
+ * Retrieves the registered integrations.
63
+ *
64
+ * @return array
65
+ */
66
+ public function get_integrations() {
67
+ return $this->integrations;
68
+ }
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
+ }
src/Yoast_Purge_Require_Yoast_SEO_Version.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * The class to check for environment requirements.
5
+ */
6
+ final class Yoast_Purge_Require_Yoast_SEO_Version {
7
+ /**
8
+ * Registers hooks to WordPress.
9
+ */
10
+ public function register_hooks() {
11
+ $hook = 'admin_notices';
12
+ if ( $this->use_multisite_notifications() ) {
13
+ $hook = 'network_' . $hook;
14
+ }
15
+
16
+ add_action( $hook, array( $this, 'show_admin_notices' ) );
17
+ }
18
+
19
+ /**
20
+ * Checks if the required version is present and active.
21
+ *
22
+ * @return bool True if Yoast SEO has an acceptable version installed and activated.
23
+ */
24
+ public function has_required_version() {
25
+ return $this->is_yoast_seo_up_to_date();
26
+ }
27
+
28
+ /**
29
+ * Shows any queued admin notices.
30
+ *
31
+ * @return void
32
+ */
33
+ public function show_admin_notices() {
34
+ if ( $this->is_iframe_request() ) {
35
+ return;
36
+ }
37
+
38
+ if ( ! $this->has_required_version() ) {
39
+ $this->display_admin_error( sprintf(
40
+ /* translators: %1$s expands to Yoast SEO. */
41
+ esc_html__(
42
+ 'Please upgrade the %1$s plugin to the latest version to allow the Yoast SEO: Search Index Purge plugin to work.',
43
+ 'yoast-search-index-purge'
44
+ ),
45
+ 'Yoast SEO'
46
+ ) );
47
+ }
48
+ }
49
+
50
+ /**
51
+ * Checks if the current request is an iFrame request.
52
+ *
53
+ * @return bool True if this request is an iFrame request.
54
+ */
55
+ private function is_iframe_request() {
56
+ return defined( 'IFRAME_REQUEST' ) && IFRAME_REQUEST !== false;
57
+ }
58
+
59
+ /**
60
+ * Displays an admin error.
61
+ *
62
+ * @param string $message Notice to display.
63
+ *
64
+ * @return void
65
+ */
66
+ private function display_admin_error( $message ) {
67
+ echo '<div class="error"><p>' . $message . '</p></div>';
68
+ }
69
+
70
+ /**
71
+ * Checks if Yoast SEO is active.
72
+ *
73
+ * @return bool True if Yoast SEO is active.
74
+ */
75
+ private function is_yoast_seo_active() {
76
+ return defined( 'WPSEO_VERSION' );
77
+ }
78
+
79
+ /**
80
+ * Checks if Yoast SEO is at a minimum required version.
81
+ *
82
+ * @return bool True if Yoast SEO is at a minimal required version.
83
+ */
84
+ private function is_yoast_seo_up_to_date() {
85
+ return $this->is_yoast_seo_active() && version_compare( WPSEO_VERSION, '7.5.3', '>=' );
86
+ }
87
+
88
+ /**
89
+ * Checks whether we should use multisite notifications or not.
90
+ *
91
+ * @return bool True if we want to use multisite notifications.
92
+ */
93
+ private function use_multisite_notifications() {
94
+ return is_multisite() && is_network_admin();
95
+ }
96
+ }
yoast-seo-search-index-purge.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yoast SEO: Search index purge
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
+ * @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
15
+ * Author URI: https://yoa.st/1uk
16
+ * Depends: Yoast SEO
17
+ * Text Domain: yoast-search-index-purge
18
+ * Domain Path: /languages/
19
+ * License: GPL v3
20
+ *
21
+ * This program is free software: you can redistribute it and/or modify
22
+ * it under the terms of the GNU General Public License as published by
23
+ * the Free Software Foundation, either version 3 of the License, or
24
+ * (at your option) any later version.
25
+ *
26
+ * This program is distributed in the hope that it will be useful,
27
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
28
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29
+ * GNU General Public License for more details.
30
+ *
31
+ * You should have received a copy of the GNU General Public License
32
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
33
+ */
34
+
35
+ if ( ! function_exists( 'add_filter' ) ) {
36
+ header( 'Status: 403 Forbidden' );
37
+ header( 'HTTP/1.1 403 Forbidden' );
38
+ exit();
39
+ }
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';
46
+ require_once YOAST_PURGE_PLUGIN_DIR . '/src/Yoast_Purge_Control_Yoast_SEO_Settings.php';
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' ) );