Skip to content

Commit

Permalink
Add filter for modifying Jetpack connect from arg
Browse files Browse the repository at this point in the history
  • Loading branch information
ebinnion committed Dec 7, 2017
1 parent 7081143 commit 3f6d719
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,21 @@ function my_cta_button_url() {
}
```

### Customizing the from tracking argument

By default, when a site is connected to WordPress.com, a `from` argument gets appeneded to the connection URL which is used to track where the connection came from. Originally, this argument was simply `from=jpo`, but recently we started appending the version number to allow differentiating between versions. This looked like, `from=jpo-1.7.1`.

While that has helped, we've found that it didn't all use cases. So, we are adding the `jpo_tracking_from_arg` filter which will allow hosts that use Jetpack Onboarding to fine-tune the `from` argument.

Here is some example usage:

```php
add_filter( 'jpo_tracking_from_arg', 'modify_jpo_from', 10, 2 );
function modify_jpo_from( $from, $version ) {
return sprintf( 'jpo-%d-my-cool-host', $version );
}
```

## Inserting the JPO wizard onto other pages

By default, JPO runs in the welcome panel, but you can run it by inserting a div with the id 'jpo-welcome-panel' into any other page, like this:
Expand Down
4 changes: 3 additions & 1 deletion class.jetpack-onboarding-end-points.php
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,9 @@ static function configure_jetpack() {

$connect_url = add_query_arg( 'host', JETPACK_ONBOARDING_VENDOR_CODE, $connect_url );
$connect_url = add_query_arg( 'product', JETPACK_ONBOARDING_PRODUCT_CODE, $connect_url );
$connect_url = add_query_arg( 'from', 'jpo-' . self::VERSION, $connect_url );

$from_arg = apply_filters( 'jpo_tracking_from_arg', sprintf( 'jpo-%s', self::VERSION ), self::VERSION );
$connect_url = add_query_arg( 'from', $from_arg, $connect_url );

wp_send_json_success( array('next' => $connect_url) );
} else {
Expand Down

0 comments on commit 3f6d719

Please sign in to comment.