Skip to content

Commit

Permalink
Merge pull request #3500 from Automattic/feat/ia-audience
Browse files Browse the repository at this point in the history
feat(ia): audience configuration boilerplate
  • Loading branch information
jaredrethman authored Nov 20, 2024
2 parents 3ef3e83 + d70a121 commit ed1837a
Show file tree
Hide file tree
Showing 29 changed files with 1,500 additions and 833 deletions.
2 changes: 1 addition & 1 deletion includes/class-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static function enqueue_block_editor_assets() {
[
'has_newsletters' => class_exists( 'Newspack_Newsletters_Subscription' ),
'has_reader_activation' => Reader_Activation::is_enabled(),
'newsletters_url' => Wizards::get_wizard( 'engagement' )->newsletters_settings_url(),
'newsletters_url' => Wizards::get_wizard( 'newsletters' )->newsletters_settings_url(),
'has_google_oauth' => Google_OAuth::is_oauth_configured(),
'google_logo_svg' => file_get_contents( dirname( NEWSPACK_PLUGIN_FILE ) . '/src/blocks/reader-registration/icons/google.svg' ),
'reader_activation_terms' => Reader_Activation::get_setting( 'terms_text' ),
Expand Down
4 changes: 4 additions & 0 deletions includes/class-newspack.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ private function includes() {
// Advertising Wizard.
include_once NEWSPACK_ABSPATH . 'includes/wizards/advertising/class-advertising-display-ads.php';
include_once NEWSPACK_ABSPATH . 'includes/wizards/advertising/class-advertising-sponsors.php';

// Audience Wizard.
include_once NEWSPACK_ABSPATH . 'includes/wizards/audience/class-audience-configuration.php';
include_once NEWSPACK_ABSPATH . 'includes/wizards/audience/class-audience-campaigns.php';

// Network Wizard.
include_once NEWSPACK_ABSPATH . 'includes/wizards/class-network-wizard.php';
Expand Down
2 changes: 2 additions & 0 deletions includes/class-wizards.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public static function init() {
),
'advertising-display-ads' => new Advertising_Display_Ads(),
'advertising-sponsors' => new Advertising_Sponsors(),
'audience-configuration' => new Audience_Configuration(),
'audience-campaigns' => new Audience_Campaigns(),
'listings' => new Listings_Wizard(),
'network' => new Network_Wizard(),
'newsletters' => new Newsletters_Wizard(),
Expand Down
7 changes: 4 additions & 3 deletions includes/reader-activation/class-reader-activation.php
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ public static function get_prerequisites_status() {
'description' => __( 'Connect to your ESP to register readers with their email addresses and send newsletters.', 'newspack-plugin' ),
'instructions' => __( 'Connect to your email service provider (ESP) and enable at least one subscription list.', 'newspack-plugin' ),
'help_url' => 'https://help.newspack.com/engagement/reader-activation-system',
'href' => \admin_url( '/admin.php?page=newspack-engagement-wizard#/newsletters' ),
'href' => \admin_url( 'edit.php?post_type=newspack_nl_cpt&page=newspack-newsletters' ),
'action_text' => __( 'ESP settings' ),
],
'emails' => [
Expand Down Expand Up @@ -536,7 +536,7 @@ public static function get_prerequisites_status() {
'description' => __( 'Connecting to a Google reCAPTCHA account enables enhanced anti-spam for all Newspack sign-up blocks.', 'newspack-plugin' ),
'instructions' => __( 'Enable reCAPTCHA and enter your account credentials.', 'newspack-plugin' ),
'help_url' => 'https://help.newspack.com/engagement/reader-activation-system',
'href' => \admin_url( '/admin.php?page=newspack-connections-wizard&scrollTo=recaptcha' ),
'href' => \admin_url( '/admin.php?page=newspack-settings&scrollTo=newspack-settings-recaptcha' ),
'action_text' => __( 'reCAPTCHA settings' ),
],
'reader_revenue' => [
Expand All @@ -550,6 +550,7 @@ public static function get_prerequisites_status() {
'description' => __( 'Setting suggested donation amounts is required for enabling a streamlined donation experience.', 'newspack-plugin' ),
'instructions' => __( 'Set platform to "Newspack" or "News Revenue Hub" and configure your default donation settings. If using News Revenue Hub, set an Organization ID and a Donor Landing Page in News Revenue Hub Settings.', 'newspack-plugin' ),
'help_url' => 'https://help.newspack.com/engagement/reader-activation-system',
// @TODO: Update when platform is added.
'href' => \admin_url( '/admin.php?page=newspack-reader-revenue-wizard' ),
'action_text' => __( 'Reader Revenue settings' ),
],
Expand All @@ -562,7 +563,7 @@ public static function get_prerequisites_status() {
'label' => __( 'Reader Activation Campaign', 'newspack-plugin' ),
'description' => __( 'Building a set of prompts with default segments and settings allows for an improved experience optimized for Reader Activation.', 'newspack-plugin' ),
'help_url' => 'https://help.newspack.com/engagement/reader-activation-system',
'href' => self::is_ras_campaign_configured() ? \admin_url( '/admin.php?page=newspack-popups-wizard#/campaigns' ) : \admin_url( '/admin.php?page=newspack-engagement-wizard#/reader-activation/campaign' ),
'href' => self::is_ras_campaign_configured() ? admin_url( '/admin.php?page=newspack-audience-campaigns' ) : admin_url( '/admin.php?page=newspack-audience-configuration#/campaign' ),
'action_enabled' => self::is_ras_ready_to_configure(),
'action_text' => __( 'Reader Activation campaign', 'newspack-plugin' ),
'disabled_text' => __( 'Waiting for all settings to be ready', 'newspack-plugin' ),
Expand Down
66 changes: 66 additions & 0 deletions includes/wizards/audience/class-audience-campaigns.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php
/**
* Audience Campaigns Wizard
*
* @package Newspack
*/

namespace Newspack;

defined( 'ABSPATH' ) || exit;

/**
* Audience Campaigns Wizard.
*/
class Audience_Campaigns extends Wizard {

/**
* Admin page slug.
*
* @var string
*/
protected $slug = 'newspack-audience-campaigns';

/**
* Parent slug.
*
* @var string
*/
protected $parent_slug = 'newspack-audience-configuration';

/**
* Get the name for this wizard.
*
* @return string The wizard name.
*/
public function get_name() {
return esc_html__( 'Audience Development / Campaigns', 'newspack-plugin' );
}

/**
* Enqueue scripts and styles.
*/
public function enqueue_scripts_and_styles() {
if ( ! $this->is_wizard_page() ) {
return;
}

parent::enqueue_scripts_and_styles();

wp_enqueue_script( 'newspack-wizards' );
}

/**
* Add Audience top-level and Campaigns subpage to the /wp-admin menu.
*/
public function add_page() {
add_submenu_page(
$this->parent_slug,
$this->get_name(),
esc_html__( 'Campaigns', 'newspack-plugin' ),
$this->capability,
$this->slug,
[ $this, 'render_wizard' ]
);
}
}
Loading

0 comments on commit ed1837a

Please sign in to comment.