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

feat(ras): add flag to setup CLI command to skip default campaign setup #3132

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

dkoo
Copy link
Contributor

@dkoo dkoo commented May 23, 2024

All Submissions:

Changes proposed in this Pull Request:

#3051 added the option to skip Campaigns default prompt + segment setup during RAS onboarding. This adds the same option to the wp newspack ras setup CLI command. It also tweaks that command so that if a required plugin isn't installed, the script will just install it instead of failing with an error.

How to test the changes in this Pull Request:

  1. On a fresh test site, install this version of the plugin and run wp newspack setup to complete the initial site setup.
  2. After setup, complete the following steps which currently can't be automated:
  • Enable an ESP and at least one subscription list in Newspack > Engagement > Newsletters
  • Install and activate WooCommerce and WooCommerce Subscriptions
  1. Run wp newspack ras setup --skip-campaigns. After it completes, visit Newspack > Engagement > Reader Activation in the admin and confirm that it's enabled and that you can view/edit advanced settings despite skipping the prerequisites.
Screenshot 2024-05-23 at 11 20 18 AM
  1. Also make sure that RAS sign-in and My Account features are enabled on the front-end.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@dkoo dkoo added [Status] Needs Review The issue or pull request needs to be reviewed enhancement labels May 23, 2024
@dkoo dkoo self-assigned this May 23, 2024
@dkoo dkoo requested a review from a team as a code owner May 23, 2024 17:21
WP_CLI::error( __( 'Newspack Newsletters provider not set.', 'newspack-plugin' ) );
}

$result = \Newspack_Popups_Presets::activate_ras_presets();

$result = $skip_campaigns ? Reader_Activation::update_setting( 'enabled', true ) : \Newspack_Popups_Presets::activate_ras_presets();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This CLI command should always enable RAS, regardless of the skip-campaigns flag.

image

sprintf(
// Translators: 'with' or 'without' default prompts.
__( 'RAS enabled %s default prompts.', 'newspack-plugin' ),
$skip_campaigns ? 'without' : 'with'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"with" and "without" are should be translatable:

Suggested change
$skip_campaigns ? 'without' : 'with'
$skip_campaigns ? __('without', 'newspack-plugin') : __('with', 'newspack-plugin')

However, this might be making too many assumptions about language structure. I think a safer bet would be to have two separate no-placeholder strings instead of a conditional placeholder value.

if ( Reader_Activation::is_ras_campaign_configured() ) {
public static function cli_setup_ras( $args, $assoc_args ) {
$skip_campaigns = ! empty( $assoc_args['skip-campaigns'] );
if ( ! $skip_campaigns && Reader_Activation::is_ras_campaign_configured() ) {
WP_CLI::error( __( 'RAS is already configured for this site.', 'newspack-plugin' ) );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not error out, but only warn about the campaigns being already configured. See comment below – this CLI command should always allow to enable RAS.

}

if ( \is_wp_error( \Newspack_Newsletters_Subscription::get_lists() ) ) {
if ( ! $skip_campaigns && \is_wp_error( \Newspack_Newsletters_Subscription::get_lists() ) ) {
WP_CLI::error( __( 'Newspack Newsletters provider not set.', 'newspack-plugin' ) );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message should rather inform about the inability to get lists, instead of making an assumption about how get_lists relates to a provider being set or not.

}

if ( \is_wp_error( \Newspack_Newsletters_Subscription::get_lists() ) ) {
if ( ! $skip_campaigns && \is_wp_error( \Newspack_Newsletters_Subscription::get_lists() ) ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why should $skip_campaigns factor in to this check? AFAIK Newsletters should always be set up properly for RAS to fully work.

@adekbadek adekbadek added [Status] Needs changes or feedback The issue or pull request needs action from the original creator and removed [Status] Needs Review The issue or pull request needs to be reviewed labels Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement [Status] Needs changes or feedback The issue or pull request needs action from the original creator
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants