Skip to content

Commit

Permalink
fix(ras): do not require Woo plugins if using NRH (#3614)
Browse files Browse the repository at this point in the history
* fix(ras): do not require Woo plugins if using NRH

* fix: check for Atomic site ID in plugin install message

* refactor: use Manager helper method for checking Atomic hosted status
  • Loading branch information
dkoo authored Dec 12, 2024
1 parent ec69167 commit 363a834
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
22 changes: 17 additions & 5 deletions includes/reader-activation/class-reader-activation.php
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,22 @@ public static function is_reader_revenue_ready() {
return $ready;
}

/**
* Get an array of required plugins for satisfying Reader Revenue prerequisites.
* WooCommerce and Woo Subscriptions are required for Newspack, but not for NRH.
*/
public static function get_reader_revenue_required_plugins() {
$required_plugins = [
'newspack-blocks' => class_exists( '\Newspack_Blocks' ),
];

if ( Donations::is_platform_wc() ) {
$required_plugins['woocommerce'] = class_exists( 'WooCommerce' );
$required_plugins['woocommerce-subscriptions'] = class_exists( 'WCS_Query' );
}
return $required_plugins;
}

/**
* Are the Legal Pages settings configured?
* Allows for blank values.
Expand Down Expand Up @@ -762,11 +778,7 @@ public static function get_prerequisites_status() {
],
'reader_revenue' => [
'active' => self::is_reader_revenue_ready(),
'plugins' => [
'newspack-blocks' => class_exists( '\Newspack_Blocks' ),
'woocommerce' => function_exists( 'WC' ),
'woocommerce-subscriptions' => class_exists( 'WC_Subscriptions_Product' ),
],
'plugins' => self::get_reader_revenue_required_plugins(),
'label' => __( 'Reader Revenue', 'newspack-plugin' ),
'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' ),
Expand Down
2 changes: 1 addition & 1 deletion includes/wizards/class-wizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public function enqueue_scripts_and_styles() {
'is_debug_mode' => Newspack::is_debug_mode(),
'has_completed_setup' => get_option( NEWSPACK_SETUP_COMPLETE ),
'site_title' => get_option( 'blogname' ),
'is_atomic' => defined( 'ATOMIC_SITE_ID' ) && ATOMIC_SITE_ID,
'is_managed' => method_exists( 'Newspack_Manager', 'is_connected_to_manager' ) && \Newspack_Manager::is_connected_to_manager(),
];

wp_localize_script( 'newspack_data', 'newspack_urls', $urls );
Expand Down
4 changes: 2 additions & 2 deletions src/components/src/plugin-installer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class PluginInstaller extends Component {
render() {
const { autoInstall, isSmall, withoutFooterButton } = this.props;
const { pluginInfo } = this.state;
const { is_atomic: isAtomic } = window;
const { is_managed: isManaged } = window.newspack_aux_data || {};
const slugs = Object.keys( pluginInfo );

// Store all plugin status info for installer button text value based on current status.
Expand Down Expand Up @@ -201,7 +201,7 @@ class PluginInstaller extends Component {
} else if ( ! installable ) {
actionText = (
<span className="newspack-plugin-installer__status">
{ isAtomic
{ isManaged
? __( 'Contact Newspack support to install', 'newspack-plugin' )
: __( 'Plugin must be installed manually', 'newspack-plugin' ) }
<span className="newspack-checkbox-icon" />
Expand Down

0 comments on commit 363a834

Please sign in to comment.