Skip to content

Commit e8fc494

Browse files
TimBroddinmatticbot
authored andcommitted
Subscriber page: add Launchpad tasks & task list (#33948)
* Add subscriber-related tasks to launchpad New tasks related to subscribers have been added to the launchpad. The tasks added are 'import_subscribers', 'share_site' and 'add_subscribe_block' which allow users to import existing subscribers, share site and add subscribe block to the theme respectively. Logic for checking if the subscribe block has been added to the template part content has also been included, marking the task as complete when the block is found. * Add subscriber-related tasks to launchpad New tasks related to subscribers have been added to the launchpad. The tasks added are 'import_subscribers', 'share_site' and 'add_subscribe_block' which allow users to import existing subscribers, share site and add subscribe block to the theme respectively. Logic for checking if the subscribe block has been added to the template part content has also been included, marking the task as complete when the block is found. * Extend subscribe block check to all saved templates * Add check for FSE * Update projects/packages/jetpack-mu-wpcom/src/features/launchpad/launchpad-task-definitions.php Co-authored-by: daledupreez <[email protected]> * Change wording * Update projects/packages/jetpack-mu-wpcom/src/features/launchpad/launchpad.php Co-authored-by: daledupreez <[email protected]> * Rebase * Bump version of jetpack-mu-wpcom and mu-wpcom-plugin * Update versions * Update projects/packages/jetpack-mu-wpcom/changelog/add-subscriber-launchpad-tasks Co-authored-by: Ivan Ottinger <[email protected]> --------- Co-authored-by: daledupreez <[email protected]> Co-authored-by: Ivan Ottinger <[email protected]> Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/6787147353
1 parent db7cffc commit e8fc494

File tree

6 files changed

+78
-3
lines changed

6 files changed

+78
-3
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [4.17.0-alpha] - unreleased
9+
10+
This is an alpha version! The changes listed here are not final.
11+
12+
### Added
13+
- Added Subscribers page Launchpad tasks
14+
815
## [4.16.2] - 2023-11-03
916
### Fixed
1017
- Launchpad hooks: Made more resilient against non-array values. [#33923]
@@ -418,6 +425,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
418425

419426
- Testing initial package release.
420427

428+
[4.17.0-alpha]: https://github.com/Automattic/jetpack-mu-wpcom/compare/v4.16.2...v4.17.0-alpha
421429
[4.16.2]: https://github.com/Automattic/jetpack-mu-wpcom/compare/v4.16.1...v4.16.2
422430
[4.16.1]: https://github.com/Automattic/jetpack-mu-wpcom/compare/v4.16.0...v4.16.1
423431
[4.16.0]: https://github.com/Automattic/jetpack-mu-wpcom/compare/v4.15.1...v4.16.0

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
},
3939
"autotagger": true,
4040
"branch-alias": {
41-
"dev-trunk": "4.16.x-dev"
41+
"dev-trunk": "4.17.x-dev"
4242
},
4343
"textdomain": "jetpack-mu-wpcom",
4444
"version-constants": {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"name": "@automattic/jetpack-mu-wpcom",
4-
"version": "4.16.2",
4+
"version": "4.17.0-alpha",
55
"description": "Enhances your site with features powered by WordPress.com",
66
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/jetpack-mu-wpcom/#readme",
77
"bugs": {

src/class-jetpack-mu-wpcom.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*/
1515
class Jetpack_Mu_Wpcom {
1616

17-
const PACKAGE_VERSION = '4.16.2';
17+
const PACKAGE_VERSION = '4.17.0-alpha';
1818
const PKG_DIR = __DIR__ . '/../';
1919

2020
/**

src/features/launchpad/launchpad-task-definitions.php

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,27 @@ function wpcom_launchpad_get_task_definitions() {
552552
return '/site-monitoring/' . $data['site_slug_encoded'];
553553
},
554554
),
555+
'import_subscribers' => array(
556+
'get_title' => function () {
557+
return __( 'Import existing subscribers', 'jetpack-mu-wpcom' );
558+
},
559+
'id_map' => 'subscribers_added',
560+
'is_complete_callback' => 'wpcom_launchpad_is_task_option_completed',
561+
'is_visible_callback' => '__return_true',
562+
'get_calypso_path' => function ( $task, $default, $data ) {
563+
return '/subscribers/' . $data['site_slug_encoded'] . '#add-subscribers';
564+
},
565+
),
566+
'add_subscribe_block' => array(
567+
'get_title' => function () {
568+
return __( 'Add the Subscribe Block to your site', 'jetpack-mu-wpcom' );
569+
},
570+
'is_complete_callback' => 'wpcom_launchpad_is_task_option_completed',
571+
'is_visible_callback' => 'wpcom_launchpad_is_add_subscribe_block_visible',
572+
'get_calypso_path' => function ( $task, $default, $data ) {
573+
return '/site-editor/' . $data['site_slug_encoded'];
574+
},
575+
),
555576
);
556577

557578
$extended_task_definitions = apply_filters( 'wpcom_launchpad_extended_task_definitions', array() );
@@ -1768,6 +1789,44 @@ function wpcom_launchpad_edit_page_check( $post_id, $post ) {
17681789
}
17691790
add_action( 'post_updated', 'wpcom_launchpad_edit_page_check', 10, 3 );
17701791

1792+
/**
1793+
* Determine `add_subscribe_block` task visibility. The task is visible if using a FSE theme.
1794+
*
1795+
* @return bool True if we should show the task, false otherwise.
1796+
*/
1797+
function wpcom_launchpad_is_add_subscribe_block_visible() {
1798+
return is_callable( array( '\Automattic\Jetpack\Blocks', 'is_fse_theme' ) ) && \Automattic\Jetpack\Blocks::is_fse_theme();
1799+
}
1800+
1801+
/**
1802+
* When a template or template part is saved, check if the subscribe block is in the content.
1803+
*
1804+
* @param int $post_id The ID of the post being updated.
1805+
* @param WP_Post $post The post object.
1806+
*
1807+
* @return bool True if the task is completed, false otherwise.
1808+
*/
1809+
function wpcom_launchpad_add_subscribe_block_check( $post_id, $post ) {
1810+
// If this is just a revision, don't proceed.
1811+
if ( wp_is_post_revision( $post_id ) ) {
1812+
return;
1813+
}
1814+
1815+
// Check if it's a published template or template part.
1816+
if ( $post->post_status !== 'publish' || ( $post->post_type !== 'wp_template' && $post->post_type !== 'wp_template_part' ) ) {
1817+
return;
1818+
}
1819+
1820+
// Check if our subscribe block is in the template or template part content.
1821+
if ( has_block( 'jetpack/subscriptions', $post->post_content ) ) {
1822+
// Run your specific function if the subscribe block is found.
1823+
wpcom_mark_launchpad_task_complete( 'add_subscribe_block' );
1824+
}
1825+
}
1826+
1827+
// Hook the function to the save_post action for all post types.
1828+
add_action( 'save_post', 'wpcom_launchpad_add_subscribe_block_check', 10, 2 );
1829+
17711830
/**
17721831
* Returns if the site has domain or bundle purchases.
17731832
*

src/features/launchpad/launchpad.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,14 @@ function wpcom_launchpad_get_task_list_definitions() {
211211
),
212212
'is_enabled_callback' => 'wpcom_launchpad_is_hosting_flow_enabled',
213213
),
214+
'subscribers' => array(
215+
'title' => 'Subscribers',
216+
'task_ids' => array(
217+
'import_subscribers',
218+
'add_subscribe_block',
219+
'share_site',
220+
),
221+
),
214222
);
215223

216224
$extended_task_list_definitions = apply_filters( 'wpcom_launchpad_extended_task_list_definitions', array() );

0 commit comments

Comments
 (0)