Skip to content

Commit

Permalink
fix: safer approach to comment metering fix (#3067)
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiulodro authored Apr 15, 2024
1 parent a5b1e86 commit e73657d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions includes/plugins/wc-memberships/class-metering.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Metering {
*/
public static function init() {
add_action( 'init', [ __CLASS__, 'register_meta' ] );
add_action( 'wp', [ __CLASS__, 'handle_restriction' ], 11 );
add_action( 'wp', [ __CLASS__, 'handle_restriction' ], 9 );
add_action( 'wp_footer', [ __CLASS__, 'enqueue_scripts' ] );
add_filter( 'newspack_reader_activity_article_view', [ __CLASS__, 'get_article_view' ], 20 );
}
Expand Down Expand Up @@ -131,7 +131,8 @@ public static function handle_restriction() {
// Remove the default restriction handler from 'SkyVerge\WooCommerce\Memberships\Restrictions\Posts::restrict_post'.
if ( self::is_metering() ) {
$restriction_instance = \wc_memberships()->get_restrictions_instance()->get_posts_restrictions_instance();
\remove_action( 'the_post', spl_object_hash( $restriction_instance ) . 'restrict_post', 0 );
\remove_action( 'wp', spl_object_hash( $restriction_instance ) . 'handle_restriction_modes' );
\add_filter( 'wc_memberships_restrictable_comment_types', '__return_empty_array' );
}

// Add inline gate to the footer so it can be handled by the frontend.
Expand Down

0 comments on commit e73657d

Please sign in to comment.