Skip to content
Closed
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: added

Podcast: Whitelist `podcast_show_launched_tracked` for Jetpack Sync so its `added_option` event reaches WPcom, where a downstream listener surfaces the launch in the customer's Activity Log UI.
15 changes: 15 additions & 0 deletions projects/packages/podcast/src/class-tracks.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,21 @@ public static function init(): void {
add_action( 'update_option_podcasting_show_urls', array( __CLASS__, 'record_show_url_updated' ), 10, 3 );

add_filter( 'rest_request_after_callbacks', array( __CLASS__, 'record_settings_saved' ), 10, 3 );

add_filter( 'jetpack_sync_options_whitelist', array( __CLASS__, 'allow_show_launched_option_sync' ) );
}

/**
* Whitelist `podcast_show_launched_tracked` for Jetpack Sync so its
* `added_option` event reaches WPcom, where a listener surfaces the
* launch in the customer's Activity Log UI.
*
* @param array $options Whitelisted option names.
* @return array
*/
public static function allow_show_launched_option_sync( $options ): array {
$options[] = 'podcast_show_launched_tracked';
return $options;
}

/**
Expand Down
16 changes: 16 additions & 0 deletions projects/packages/podcast/tests/php/Tracks_Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,4 +333,20 @@ public function test_settings_saved_suppressed_when_response_is_an_error() {

$this->assertEmpty( $this->events_named( 'wpcom_podcasting_settings_saved' ) );
}

public function test_allow_show_launched_option_sync_appends_option() {
$this->assertContains(
'podcast_show_launched_tracked',
Tracks::allow_show_launched_option_sync( array( 'blogname' ) )
);
}

public function test_init_registers_sync_whitelist_filter() {
Tracks::init();

$this->assertContains(
'podcast_show_launched_tracked',
apply_filters( 'jetpack_sync_options_whitelist', array() )
);
}
}
Loading