Skip to content
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
9 changes: 9 additions & 0 deletions includes/content-gate/class-content-gate.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ public static function init() {
include __DIR__ . '/class-metering.php';
}

/**
* Whether the first-party Newspack feature is enabled.
*
* @return bool
*/
public static function is_newspack_feature_enabled() {
return defined( 'NEWSPACK_CONTENT_GATES' ) && NEWSPACK_CONTENT_GATES;
}

/**
* Restrict the post.
*
Expand Down
3 changes: 2 additions & 1 deletion includes/content-gate/class-metering.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@ public static function is_logged_in_metering_allowed( $post_id = null ) {
}

// Aggregate metering by gate priority, if available.
$user_meta_key = self::METERING_META_KEY . '_' . ( $priority ? $priority : $gate_post_id );
$suffix = Content_Gate::is_newspack_feature_enabled() && $priority ? $priority : $gate_post_id;
$user_meta_key = self::METERING_META_KEY . '_' . $suffix;

$updated_user_data = false;
$user_metering_data = \get_user_meta( get_current_user_id(), $user_meta_key, true );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function add_page() {
* @return bool
*/
public function is_feature_enabled() {
return defined( 'NEWSPACK_CONTENT_GATES' ) && NEWSPACK_CONTENT_GATES;
return Content_Gate::is_newspack_feature_enabled();
}

/**
Expand Down