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

fix(ras): do not require Woo plugins if using NRH #3614

Merged
merged 3 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading