From 7ada62bad298af4a72f0fc9fd4fea025d7a4ffc4 Mon Sep 17 00:00:00 2001
From: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com>
Date: Mon, 9 Jan 2023 12:05:00 +1100
Subject: [PATCH 1/2] =?UTF-8?q?Migration=20guide=20=E2=80=94=20update=20ca?=
=?UTF-8?q?nonical=20URL=20snippet.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../migration-guide-version-1-to-version-2.md | 25 +++++++++++++++++++
docs/snippets.md | 18 ++++++-------
2 files changed, 34 insertions(+), 9 deletions(-)
create mode 100644 docs/migration-guide-version-1-to-version-2.md
diff --git a/docs/migration-guide-version-1-to-version-2.md b/docs/migration-guide-version-1-to-version-2.md
new file mode 100644
index 000000000..26bed1bc0
--- /dev/null
+++ b/docs/migration-guide-version-1-to-version-2.md
@@ -0,0 +1,25 @@
+## Migration Guide Version 1 to Version 2.
+
+Version 2 of Distributor includes a number of breaking changes that will require updates to custom code you may have written for distributor.
+
+### Remove canonical links for both Internal and External Connections
+
+The code snippet required to prevent sites from displaying the source post as canonical URLs for distributed posts has changed.
+
+If you have implemented this using the code snippet from our tutorial file, please update your code to the following:
+
+```php
+/**
+ * Stop Distributor from changing the canonical links.
+ *
+ * This removes Distributor's canonical functionality from both Internal and
+ * External Connections.
+ *
+ * This accounts for sites using either WordPress or Yoast SEO to generate the
+ * canonical URL.
+ */
+add_action( 'plugins_loaded', function() {
+ add_action( 'get_canonical_url', '\\Distributor\\Hooks\\get_canonical_url', 10, 2 );
+ add_action( 'wpseo_canonical', '\\Distributor\\Hooks\\wpseo_canonical', 10, 2 );
+} );
+```
diff --git a/docs/snippets.md b/docs/snippets.md
index 9ca9b0f34..86fa4679f 100644
--- a/docs/snippets.md
+++ b/docs/snippets.md
@@ -62,16 +62,16 @@ function client_prefix_filter_authorized_sites( array $authorized_sites, string
/**
* Stop Distributor from changing the canonical links.
*
- * This removes Distributor's canonical functionality from
- * both Internal and External Connections and for those sites
- * that use Yoast SEO.
+ * This removes Distributor's canonical functionality from both Internal and
+ * External Connections.
+ *
+ * This accounts for sites using either WordPress or Yoast SEO to generate the
+ * canonical URL.
*/
-add_action( 'template_redirect', function () {
- remove_filter( 'get_canonical_url', array( '\Distributor\InternalConnections\NetworkSiteConnection', 'canonical_url' ), 10, 2 );
- remove_filter( 'wpseo_canonical', array( '\Distributor\InternalConnections\NetworkSiteConnection', 'wpseo_canonical_url' ) );
- remove_filter( 'get_canonical_url', array( '\Distributor\ExternalConnections\WordPressExternalConnection', 'canonical_url' ), 10, 2 );
- remove_filter( 'wpseo_canonical', array( '\Distributor\ExternalConnections\WordPressExternalConnection', 'wpseo_canonical_url' ) );
-}, 20 );
+add_action( 'plugins_loaded', function() {
+ add_action( 'get_canonical_url', '\\Distributor\\Hooks\\get_canonical_url', 10, 2 );
+ add_action( 'wpseo_canonical', '\\Distributor\\Hooks\\wpseo_canonical', 10, 2 );
+} );
```
### Push original publication date
From 9f4b8a00e668b34ea54847a17fa49d3d32f42b66 Mon Sep 17 00:00:00 2001
From: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com>
Date: Mon, 9 Jan 2023 12:13:00 +1100
Subject: [PATCH 2/2] Call out migration guide on docs home page.
---
.github/hookdoc-tmpl/README.md | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/.github/hookdoc-tmpl/README.md b/.github/hookdoc-tmpl/README.md
index 7044e6689..0701d2f6b 100644
--- a/.github/hookdoc-tmpl/README.md
+++ b/.github/hookdoc-tmpl/README.md
@@ -4,6 +4,10 @@ This resource is generated documentation on actions and filters found in the Dis
For more information about using Distributor with WordPress, please see the [Distributor website](https://distributorplugin.com/).
+## Migrating to version 2.0
+
+Version 2.0 of Distributor contains breaking changes. Please review the migration guide tutorial and follow any steps required.
+
To report an issue with Distributor or contribute back to the project, please visit the [GitHub repository](https://github.com/10up/distributor/).