PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.1
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.1
16.3 16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 All 508 releases
← All changes | modules/memberships/class-jetpack-memberships.php +3 -42 16.3 → 16.3-a.1 View file →
@@ -710,17 +710,8 @@
710 710 if ( empty( $post_access_level ) || ! is_string( $post_access_level ) ) {
711 711 $post_access_level = Abstract_Token_Subscription_Service::POST_ACCESS_LEVEL_EVERYBODY;
712 712 }
713 713
714 - // Only the editor switches a Paywall post to subscribers; REST, WP-CLI and importer saves don't.
715 - // The block's name constant isn't loaded everywhere this runs, hence the literal.
716 - if (
717 - Abstract_Token_Subscription_Service::POST_ACCESS_LEVEL_EVERYBODY === $post_access_level
718 - && has_block( 'jetpack/paywall', $post_id )
719 - ) {
720 - $post_access_level = Abstract_Token_Subscription_Service::POST_ACCESS_LEVEL_SUBSCRIBERS;
721 - }
722 -
723 714 self::$post_access_level_cache[ $cache_key ] = $post_access_level;
724 715
725 716 return $post_access_level;
726 717 }
@@ -825,31 +816,8 @@
825 816 *
826 817 * @return bool Whether the post can be viewed
827 818 */
828 819 public static function user_can_view_post( $post_id = null ) {
829 - return self::check_post_access( $post_id, true );
830 - }
831 -
832 - /**
833 - * Check the post's subscription requirement without granting access for editing it.
834 - *
835 - * @since $$next-version$$
836 - *
837 - * @param int|null $post_id Explicit post ID, or the loop post when omitted.
838 - * @return bool Whether the visitor meets the post's subscription requirement.
839 - */
840 - public static function user_has_subscription_access( $post_id = null ) {
841 - return self::check_post_access( $post_id, false );
842 - }
843 -
844 - /**
845 - * Evaluate and cache post access with or without the editorial exception.
846 - *
847 - * @param int|null $post_id Post to check.
848 - * @param bool $allow_editor_access Whether editing the post can grant access.
849 - * @return bool Whether access is granted.
850 - */
851 - private static function check_post_access( $post_id, $allow_editor_access ) {
852 820 $user_id = get_current_user_id();
853 821 if ( null === $post_id ) {
854 822 $post_id = get_the_ID();
855 823 }
@@ -857,9 +825,9 @@
857 825 if ( false === $post_id ) {
858 826 $post_id = 0;
859 827 }
860 828
861 - $cache_key = sprintf( '%d_%d_%d', $user_id, $post_id, (int) $allow_editor_access );
829 + $cache_key = sprintf( '%d_%d', $user_id, $post_id );
862 830 if ( isset( self::$user_can_view_post_cache[ $cache_key ] ) ) {
863 831 return self::$user_can_view_post_cache[ $cache_key ];
864 832 }
865 833
@@ -869,9 +837,9 @@
869 837 return true;
870 838 }
871 839
872 840 // we are sending the post to subscribers so the user is a subscriber
873 - if ( $allow_editor_access && defined( 'WPCOM_SENDING_POST_TO_SUBSCRIBERS' ) && WPCOM_SENDING_POST_TO_SUBSCRIBERS && Abstract_Token_Subscription_Service::POST_ACCESS_LEVEL_SUBSCRIBERS === $post_access_level ) {
841 + if ( defined( 'WPCOM_SENDING_POST_TO_SUBSCRIBERS' ) && WPCOM_SENDING_POST_TO_SUBSCRIBERS && Abstract_Token_Subscription_Service::POST_ACCESS_LEVEL_SUBSCRIBERS === $post_access_level ) {
874 842 self::$user_can_view_post_cache[ $cache_key ] = true;
875 843 return true;
876 844 }
877 845
@@ -890,16 +858,9 @@
890 858 // We downgrade the post level to subscribers-only
891 859 $post_access_level = Abstract_Token_Subscription_Service::POST_ACCESS_LEVEL_SUBSCRIBERS;
892 860 }
893 861
894 - // Pass the post explicitly: callers outside the loop have no get_the_ID() to fall back on.
895 - if ( $allow_editor_access ) {
896 - // @phan-suppress-next-line PhanParamTooMany -- Concrete services accept the optional $post_id; interface omits it on purpose.
897 - $can_view_post = $paywall->visitor_can_view_content( $all_newsletters_plan_ids, $post_access_level, $post_id );
898 - } else {
899 - $can_view_post = is_callable( array( $paywall, 'visitor_has_subscription_access' ) )
900 - && $paywall->visitor_has_subscription_access( $all_newsletters_plan_ids, $post_access_level, $post_id );
901 - }
862 + $can_view_post = $paywall->visitor_can_view_content( $all_newsletters_plan_ids, $post_access_level );
902 863
903 864 self::$user_can_view_post_cache[ $cache_key ] = $can_view_post;
904 865 return $can_view_post;
905 866 }