Skip to content

Commit

Permalink
refactor: tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
adekbadek committed Apr 8, 2024
1 parent fac9f06 commit f18f18e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
2 changes: 2 additions & 0 deletions includes/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ public static function enqueue_scripts() {

/**
* Has experimental auditing features?
*
* @return bool True if experimental auditing features are enabled.
*/
public static function use_experimental_auditing_features() {
$user_slug = defined( 'NEWSPACK_NETWORK_EXPERIMENTAL_AUDITING_USER' ) ? NEWSPACK_NETWORK_EXPERIMENTAL_AUDITING_USER : false;
Expand Down
4 changes: 2 additions & 2 deletions includes/cli/backfillers/class-reader-registered.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected function get_processed_item_output( $event ) {
*/
public function get_events() {
$roles_to_sync = \Newspack_Network\Utils\Users::get_synced_user_roles();
if ( $roles_to_sync === [] ) {
if ( empty( $roles_to_sync ) ) {
WP_CLI::error( 'Incompatible Newspack plugin version or no roles to sync.' );
}
// Get all users registered between specified dates.
Expand All @@ -55,7 +55,7 @@ public function get_events() {
]
);

WP_CLI::line( sprintf( 'Found %s users eligible for sync.', count( $users ) ) );
WP_CLI::line( sprintf( 'Found %s user(s) eligible for sync.', count( $users ) ) );

$this->maybe_initialize_progress_bar( 'Processing users', count( $users ) );

Expand Down
2 changes: 1 addition & 1 deletion includes/cli/class-misc.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static function fix_roles( array $args, array $assoc_args ) {
],
[
'key' => 'wp_capabilities',
'value' => 'a:0:{}',
'value' => 'a:0:{}',
'compare' => '=',
],
],
Expand Down
10 changes: 5 additions & 5 deletions includes/hub/admin/class-membership-plans.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public static function render() {
*/
public static function fetch_collection_from_api( $node, $collection_endpoint, $collection_endpoint_id ) {
$endpoint = sprintf( '%s/wp-json/%s', $node->get_url(), $collection_endpoint );
if ( \Newspack_Network\Admin::use_experimental_auditing_features() ) {
if ( Network_Admin::use_experimental_auditing_features() ) {
$endpoint = add_query_arg( 'include_active_members_emails', 1, $endpoint );
}
$response = wp_remote_get( // phpcs:ignore
Expand Down Expand Up @@ -113,7 +113,7 @@ public static function get_membership_plans_from_network() {
$by_network_pass_id = [];
$membership_plans = [];

if ( \Newspack_Network\Admin::use_experimental_auditing_features() ) {
if ( Network_Admin::use_experimental_auditing_features() ) {
$local_membership_plans = self::get_local_membership_plans();
foreach ( $local_membership_plans as $local_plan ) {
if ( $local_plan['network_pass_id'] ) {
Expand All @@ -133,7 +133,7 @@ public static function get_membership_plans_from_network() {
$network_pass_id = $meta->value;
}
}
if ( $network_pass_id && \Newspack_Network\Admin::use_experimental_auditing_features() ) {
if ( $network_pass_id && Network_Admin::use_experimental_auditing_features() ) {
if ( ! isset( $by_network_pass_id[ $network_pass_id ] ) ) {
$by_network_pass_id[ $network_pass_id ] = [];
}
Expand All @@ -149,7 +149,7 @@ public static function get_membership_plans_from_network() {
}
}

if ( \Newspack_Network\Admin::use_experimental_auditing_features() ) {
if ( Network_Admin::use_experimental_auditing_features() ) {
$discrepancies = [];
foreach ( $by_network_pass_id as $plan_network_pass_id => $by_site ) {
$shared_emails = array_intersect( ...array_values( $by_site ) );
Expand Down Expand Up @@ -195,7 +195,7 @@ public static function get_local_membership_plans() {
'network_pass_id' => get_post_meta( $plan->post->ID, \Newspack_Network\Woocommerce_Memberships\Admin::NETWORK_ID_META_KEY, true ),
'active_members_count' => $plan->get_memberships_count( 'active' ),
];
if ( \Newspack_Network\Admin::use_experimental_auditing_features() ) {
if ( Network_Admin::use_experimental_auditing_features() ) {
$plan_data['active_members_emails'] = \Newspack_Network\Woocommerce_Memberships\Admin::get_active_members_emails( $plan );
}
$membership_plans[] = $plan_data;
Expand Down

0 comments on commit f18f18e

Please sign in to comment.