Skip to content

Commit

Permalink
Subscriber page: add Launchpad tasks & task list (#33948)
Browse files Browse the repository at this point in the history
* 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 <dale@automattic.com>

* Change wording

* Update projects/packages/jetpack-mu-wpcom/src/features/launchpad/launchpad.php

Co-authored-by: daledupreez <dale@automattic.com>

* 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 <25105483+ivan-ottinger@users.noreply.github.com>

---------

Co-authored-by: daledupreez <dale@automattic.com>
Co-authored-by: Ivan Ottinger <25105483+ivan-ottinger@users.noreply.github.com>

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/6787147353
  • Loading branch information
TimBroddin authored and matticbot committed Nov 7, 2023
1 parent 5692179 commit 0756b4c
Show file tree
Hide file tree
Showing 15 changed files with 104 additions and 25 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 1.7.8-alpha - unreleased

This is an alpha version! The changes listed here are not final.

## 1.7.7 - 2023-11-03

## 1.7.6 - 2023-10-31
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "wordpress-plugin",
"license": "GPL-2.0-or-later",
"require": {
"automattic/jetpack-mu-wpcom": "^4.16.2"
"automattic/jetpack-mu-wpcom": "^4.17.0-alpha"
},
"require-dev": {
"yoast/phpunit-polyfills": "1.1.0",
Expand Down Expand Up @@ -37,6 +37,6 @@
]
},
"config": {
"autoloader-suffix": "d9d132a783958a00a2c7cccff60ca42d_jetpack_mu_wpcom_pluginⓥ1_7_7"
"autoloader-suffix": "d9d132a783958a00a2c7cccff60ca42d_jetpack_mu_wpcom_pluginⓥ1_7_8_alpha"
}
}
10 changes: 5 additions & 5 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion mu-wpcom-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* Plugin Name: WordPress.com Features
* Description: Test plugin for the jetpack-mu-wpcom package
* Version: 1.7.7
* Version: 1.7.8-alpha
* Author: Automattic
* License: GPLv2 or later
* Text Domain: jetpack-mu-wpcom-plugin
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@automattic/jetpack-mu-wpcom-plugin",
"version": "1.7.7",
"version": "1.7.8-alpha",
"description": "Test plugin for the jetpack-mu-wpcom package",
"homepage": "https://jetpack.com",
"bugs": {
Expand Down
2 changes: 1 addition & 1 deletion vendor/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInitd9d132a783958a00a2c7cccff60ca42d_jetpack_mu_wpcom_pluginⓥ1_7_7::getLoader();
return ComposerAutoloaderInitd9d132a783958a00a2c7cccff60ca42d_jetpack_mu_wpcom_pluginⓥ1_7_8_alpha::getLoader();
8 changes: 8 additions & 0 deletions vendor/automattic/jetpack-mu-wpcom/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [4.17.0-alpha] - unreleased

This is an alpha version! The changes listed here are not final.

### Added
- Added Subscribers page Launchpad tasks

## [4.16.2] - 2023-11-03
### Fixed
- Launchpad hooks: Made more resilient against non-array values. [#33923]
Expand Down Expand Up @@ -418,6 +425,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Testing initial package release.

[4.17.0-alpha]: https://github.com/Automattic/jetpack-mu-wpcom/compare/v4.16.2...v4.17.0-alpha
[4.16.2]: https://github.com/Automattic/jetpack-mu-wpcom/compare/v4.16.1...v4.16.2
[4.16.1]: https://github.com/Automattic/jetpack-mu-wpcom/compare/v4.16.0...v4.16.1
[4.16.0]: https://github.com/Automattic/jetpack-mu-wpcom/compare/v4.15.1...v4.16.0
Expand Down
2 changes: 1 addition & 1 deletion vendor/automattic/jetpack-mu-wpcom/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
},
"autotagger": true,
"branch-alias": {
"dev-trunk": "4.16.x-dev"
"dev-trunk": "4.17.x-dev"
},
"textdomain": "jetpack-mu-wpcom",
"version-constants": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
class Jetpack_Mu_Wpcom {

const PACKAGE_VERSION = '4.16.2';
const PACKAGE_VERSION = '4.17.0-alpha';
const PKG_DIR = __DIR__ . '/../';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,27 @@ function wpcom_launchpad_get_task_definitions() {
return '/site-monitoring/' . $data['site_slug_encoded'];
},
),
'import_subscribers' => array(
'get_title' => function () {
return __( 'Import existing subscribers', 'jetpack-mu-wpcom' );
},
'id_map' => 'subscribers_added',
'is_complete_callback' => 'wpcom_launchpad_is_task_option_completed',
'is_visible_callback' => '__return_true',
'get_calypso_path' => function ( $task, $default, $data ) {
return '/subscribers/' . $data['site_slug_encoded'] . '#add-subscribers';
},
),
'add_subscribe_block' => array(
'get_title' => function () {
return __( 'Add the Subscribe Block to your site', 'jetpack-mu-wpcom' );
},
'is_complete_callback' => 'wpcom_launchpad_is_task_option_completed',
'is_visible_callback' => 'wpcom_launchpad_is_add_subscribe_block_visible',
'get_calypso_path' => function ( $task, $default, $data ) {
return '/site-editor/' . $data['site_slug_encoded'];
},
),
);

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

/**
* Determine `add_subscribe_block` task visibility. The task is visible if using a FSE theme.
*
* @return bool True if we should show the task, false otherwise.
*/
function wpcom_launchpad_is_add_subscribe_block_visible() {
return is_callable( array( '\Automattic\Jetpack\Blocks', 'is_fse_theme' ) ) && \Automattic\Jetpack\Blocks::is_fse_theme();
}

/**
* When a template or template part is saved, check if the subscribe block is in the content.
*
* @param int $post_id The ID of the post being updated.
* @param WP_Post $post The post object.
*
* @return bool True if the task is completed, false otherwise.
*/
function wpcom_launchpad_add_subscribe_block_check( $post_id, $post ) {
// If this is just a revision, don't proceed.
if ( wp_is_post_revision( $post_id ) ) {
return;
}

// Check if it's a published template or template part.
if ( $post->post_status !== 'publish' || ( $post->post_type !== 'wp_template' && $post->post_type !== 'wp_template_part' ) ) {
return;
}

// Check if our subscribe block is in the template or template part content.
if ( has_block( 'jetpack/subscriptions', $post->post_content ) ) {
// Run your specific function if the subscribe block is found.
wpcom_mark_launchpad_task_complete( 'add_subscribe_block' );
}
}

// Hook the function to the save_post action for all post types.
add_action( 'save_post', 'wpcom_launchpad_add_subscribe_block_check', 10, 2 );

/**
* Returns if the site has domain or bundle purchases.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,14 @@ function wpcom_launchpad_get_task_list_definitions() {
),
'is_enabled_callback' => 'wpcom_launchpad_is_hosting_flow_enabled',
),
'subscribers' => array(
'title' => 'Subscribers',
'task_ids' => array(
'import_subscribers',
'add_subscribe_block',
'share_site',
),
),
);

$extended_task_list_definitions = apply_filters( 'wpcom_launchpad_extended_task_list_definitions', array() );
Expand Down
8 changes: 4 additions & 4 deletions vendor/composer/autoload_real.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// autoload_real.php @generated by Composer

class ComposerAutoloaderInitd9d132a783958a00a2c7cccff60ca42d_jetpack_mu_wpcom_pluginⓥ1_7_7
class ComposerAutoloaderInitd9d132a783958a00a2c7cccff60ca42d_jetpack_mu_wpcom_pluginⓥ1_7_8_alpha
{
private static $loader;

Expand All @@ -22,12 +22,12 @@ public static function getLoader()
return self::$loader;
}

spl_autoload_register(array('ComposerAutoloaderInitd9d132a783958a00a2c7cccff60ca42d_jetpack_mu_wpcom_pluginⓥ1_7_7', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInitd9d132a783958a00a2c7cccff60ca42d_jetpack_mu_wpcom_pluginⓥ1_7_8_alpha', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInitd9d132a783958a00a2c7cccff60ca42d_jetpack_mu_wpcom_pluginⓥ1_7_7', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInitd9d132a783958a00a2c7cccff60ca42d_jetpack_mu_wpcom_pluginⓥ1_7_8_alpha', 'loadClassLoader'));

require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitd9d132a783958a00a2c7cccff60ca42d_jetpack_mu_wpcom_pluginⓥ1_7_7::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInitd9d132a783958a00a2c7cccff60ca42d_jetpack_mu_wpcom_pluginⓥ1_7_8_alpha::getInitializer($loader));

$loader->setClassMapAuthoritative(true);
$loader->register(true);
Expand Down
4 changes: 2 additions & 2 deletions vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Composer\Autoload;

class ComposerStaticInitd9d132a783958a00a2c7cccff60ca42d_jetpack_mu_wpcom_pluginⓥ1_7_7
class ComposerStaticInitd9d132a783958a00a2c7cccff60ca42d_jetpack_mu_wpcom_pluginⓥ1_7_8_alpha
{
public static $classMap = array (
'Automattic\\Jetpack\\Jetpack_Mu_Wpcom' => __DIR__ . '/..' . '/automattic/jetpack-mu-wpcom/src/class-jetpack-mu-wpcom.php',
Expand All @@ -18,7 +18,7 @@ class ComposerStaticInitd9d132a783958a00a2c7cccff60ca42d_jetpack_mu_wpcom_plugin
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->classMap = ComposerStaticInitd9d132a783958a00a2c7cccff60ca42d_jetpack_mu_wpcom_pluginⓥ1_7_7::$classMap;
$loader->classMap = ComposerStaticInitd9d132a783958a00a2c7cccff60ca42d_jetpack_mu_wpcom_pluginⓥ1_7_8_alpha::$classMap;

}, null, ClassLoader::class);
}
Expand Down
8 changes: 4 additions & 4 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
"packages": [
{
"name": "automattic/jetpack-mu-wpcom",
"version": "4.16.2",
"version_normalized": "4.16.2.0",
"version": "4.17.0-alpha.1699373155",
"version_normalized": "4.17.0.0-alpha1699373155",
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-mu-wpcom",
"reference": "89493169b734a0394ab60d75d683ccdb00b37fb2"
"reference": "32d6afe3875e2d3745aa13deb1acda8286198255"
},
"require-dev": {
"automattic/jetpack-changelogger": "^3.3.11",
Expand All @@ -25,7 +25,7 @@
},
"autotagger": true,
"branch-alias": {
"dev-trunk": "4.16.x-dev"
"dev-trunk": "4.17.x-dev"
},
"textdomain": "jetpack-mu-wpcom",
"version-constants": {
Expand Down
6 changes: 3 additions & 3 deletions vendor/composer/installed.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
),
'versions' => array(
'automattic/jetpack-mu-wpcom' => array(
'pretty_version' => '4.16.2',
'version' => '4.16.2.0',
'reference' => '89493169b734a0394ab60d75d683ccdb00b37fb2',
'pretty_version' => '4.17.0-alpha.1699373155',
'version' => '4.17.0.0-alpha1699373155',
'reference' => '32d6afe3875e2d3745aa13deb1acda8286198255',
'type' => 'jetpack-library',
'install_path' => __DIR__ . '/../automattic/jetpack-mu-wpcom',
'aliases' => array(),
Expand Down

0 comments on commit 0756b4c

Please sign in to comment.