Skip to content

Commit

Permalink
feat: conditionally load wizards if setup complete
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredrethman committed Nov 26, 2024
1 parent e9df3a2 commit 97ac4a6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 30 deletions.
47 changes: 25 additions & 22 deletions includes/class-wizards.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,36 +29,39 @@ class Wizards {
*/
public static function init() {
self::$wizards = [
'site-design' => new Site_Design_Wizard(),
'reader-revenue' => new Reader_Revenue_Wizard(),
'syndication' => new Syndication_Wizard(),
'analytics' => new Analytics_Wizard(),
'components-demo' => new Components_Demo(),
'seo' => new SEO_Wizard(),
'health-check' => new Health_Check_Wizard(),
'engagement' => new Engagement_Wizard(),
'connections' => new Connections_Wizard(),
'settings' => new Settings(),
'site-design' => new Site_Design_Wizard(),
'reader-revenue' => new Reader_Revenue_Wizard(),
'syndication' => new Syndication_Wizard(),
'analytics' => new Analytics_Wizard(),
'components-demo' => new Components_Demo(),
'seo' => new SEO_Wizard(),
'health-check' => new Health_Check_Wizard(),
'engagement' => new Engagement_Wizard(),
'connections' => new Connections_Wizard(),
'settings' => new Settings(),
// v2 Information Architecture.
'newspack-dashboard' => new Newspack_Dashboard(),
'setup' => new Setup_Wizard(),
'newspack-settings' => new Newspack_Settings(
'setup' => new Setup_Wizard(),
];

if ( Newspack::is_setup_complete() ) {
static::$wizards['newspack-dashboard'] = new Newspack_Dashboard();
static::$wizards['newspack-settings'] = new Newspack_Settings(
[
'sections' => [
'custom-events' => 'Newspack\Wizards\Newspack\Custom_Events_Section',
'social-pixels' => 'Newspack\Wizards\Newspack\Pixels_Section',
'recirculation' => 'Newspack\Wizards\Newspack\Recirculation_Section',
],
]
),
'advertising-display-ads' => new Advertising_Display_Ads(),
'advertising-sponsors' => new Advertising_Sponsors(),
'audience' => new Audience_Wizard(),
'audience-campaigns' => new Audience_Campaigns(),
'listings' => new Listings_Wizard(),
'network' => new Network_Wizard(),
'newsletters' => new Newsletters_Wizard(),
];
);
static::$wizards['advertising-display-ads'] = new Advertising_Display_Ads();
static::$wizards['advertising-sponsors'] = new Advertising_Sponsors();
static::$wizards['audience'] = new Audience_Wizard();
static::$wizards['audience-campaigns'] = new Audience_Campaigns();
static::$wizards['listings'] = new Listings_Wizard();
static::$wizards['network'] = new Network_Wizard();
static::$wizards['newsletters'] = new Newsletters_Wizard();
}

// Allow custom menu order.
add_filter( 'custom_menu_order', '__return_true' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ class Advertising_Display_Ads extends Wizard {
* Constructor.
*/
public function __construct() {
if ( ! Newspack::is_setup_complete() ) {
return;
}
parent::__construct();
add_action( 'rest_api_init', array( $this, 'register_api_endpoints' ) );
}
Expand Down
5 changes: 0 additions & 5 deletions includes/wizards/audience/class-audience-wizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ class Audience_Wizard extends Wizard {
* Audience Configuration Constructor.
*/
public function __construct() {

if ( ! Newspack::is_setup_complete() ) {
return;
}

parent::__construct();
add_action( 'rest_api_init', [ $this, 'register_api_endpoints' ] );

Expand Down

0 comments on commit 97ac4a6

Please sign in to comment.