Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection: add partner codes to connection URLs & deprecate Partner package #33832

Merged
merged 21 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
a33e644
Connection: add partner codes are added to connection URLs
jeherve Oct 27, 2023
ea43d76
Stop initializing the Partner package in the Jetpack plugin
jeherve Oct 27, 2023
f137a6c
Add changelog
jeherve Oct 27, 2023
a5e5ecf
Merge remote-tracking branch 'origin/trunk' into fix/connection-partn…
jeherve Oct 30, 2023
1468125
Move Partner package classes to the Connection package
jeherve Oct 30, 2023
e992f50
Update references
jeherve Oct 30, 2023
248b98d
Move tests
jeherve Oct 30, 2023
6aff68c
Update references
jeherve Oct 30, 2023
1fc7556
Mark Partner package as deprecated
jeherve Oct 30, 2023
ede516e
Stop loading the Partner package as a dependency
jeherve Oct 30, 2023
3393ec0
changelog
jeherve Oct 30, 2023
857c749
Bump JITM package everywhere where it is required.
jeherve Oct 30, 2023
eef2143
Avoid test pollution
jeherve Oct 30, 2023
5ef3fef
Revert teardown
jeherve Oct 30, 2023
475fb09
Merge remote-tracking branch 'origin/trunk' into fix/connection-partn…
jeherve Oct 31, 2023
3da653a
Fix the Partner package unit tests.
sergeymitr Oct 31, 2023
1a896ac
Merge remote-tracking branch 'origin/trunk' into fix/connection-partn…
jeherve Nov 14, 2023
8b12c99
Merge remote-tracking branch 'origin/trunk' into fix/connection-partn…
jeherve Nov 14, 2023
d529be4
Update lock file
jeherve Nov 14, 2023
3e9e927
Merge remote-tracking branch 'origin/trunk' into fix/connection-partn…
jeherve Nov 15, 2023
4a17fec
Merge branch 'trunk' into fix/connection-partner-standalone-sites
sergeymitr Nov 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Connection: ensure that partner partners are passed on during the connection process, regardless of the plugin you use to connect.
37 changes: 37 additions & 0 deletions projects/packages/connection/docs/partner-tools.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Partner Tools

The Connection package includes 2 classes, `Automattic\Jetpack\Partner` and `Automattic\Jetpack\Partner_Coupon`, that provide support functions for Jetpack hosting partners.

### Usage for hosting partners

As a hosting partner you will need to set either the subsidiary id or the affiliate code. Both can be set via an option or a filter (but please do not set them using an option and filter simultaneously as this may not result in the desired effect).

The most straight forward way to set these is by using an option:

```php
// Set or update subsidiary id. Note that subsidiary id is a string that will be filtered
// with WordPress' sanitize_key() so make sure it conforms to the regex [^a-z0-9_\-].
update_option( 'jetpack_partner_subsidiary_id', '<subsidiary id here>', true );

// Set or update the affiliate code.
update_option( 'jetpack_affiliate_code', '<affiliate code here>', true );
```

Another way to set these is via a filter. This requires creating a function that returns the desired value.

```php
// Set the subsidairy id. Note that subsidiary id is a string that will be filtered
// with WordPress' sanitize_key() so make sure it conforms to the regex [^a-z0-9_\-].
function subsidiary_filter( ) {
return '<subsidiary id here>';
}

add_filter( 'jetpack_partner_subsidiary_id', 'subsidiary_filter' );

// Set the affiliate code.
function affiliate_filter( ) {
return '<affiliate code here>';
}

add_filter( 'jetpack_affiliate_code', 'affiliate_filter' );
```
9 changes: 8 additions & 1 deletion projects/packages/connection/src/class-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Automattic\Jetpack\A8c_Mc_Stats;
use Automattic\Jetpack\Constants;
use Automattic\Jetpack\Heartbeat;
use Automattic\Jetpack\Partner;
use Automattic\Jetpack\Roles;
use Automattic\Jetpack\Status;
use Automattic\Jetpack\Status\Host;
Expand Down Expand Up @@ -138,6 +139,9 @@ public static function configure() {

// Initialize token locks.
new Tokens_Locks();

// Initial Partner management.
Partner::init();
}

/**
Expand Down Expand Up @@ -1924,7 +1928,10 @@ public function get_authorization_url( $user = null, $redirect = null ) {

$api_url = $this->api_url( 'authorize' );

return add_query_arg( $body, $api_url );
$url = add_query_arg( $body, $api_url );

/** This filter is documented in plugins/jetpack/class-jetpack.php */
return apply_filters( 'jetpack_build_authorize_url', $url );
}

/**
Expand Down
Loading
Loading