Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/jetpack/extensio.../blocks/subscrip...
File: subscriptions.php
);
[1000] Fix | Delete
}
[1001] Fix | Delete
return $the_content;
[1002] Fix | Delete
}
[1003] Fix | Delete
[1004] Fix | Delete
$paywalled_content = get_paywall_content();
[1005] Fix | Delete
[1006] Fix | Delete
if ( has_block( \Automattic\Jetpack\Extensions\Paywall\BLOCK_NAME ) ) {
[1007] Fix | Delete
if ( strpos( $the_content, \Automattic\Jetpack\Extensions\Paywall\BLOCK_HTML ) ) {
[1008] Fix | Delete
return strstr( $the_content, \Automattic\Jetpack\Extensions\Paywall\BLOCK_HTML, true ) . $paywalled_content;
[1009] Fix | Delete
}
[1010] Fix | Delete
// WordPress generates excerpts by either rendering or stripping blocks before invoking the `the_content` filter.
[1011] Fix | Delete
// In the context of generating an excerpt, the Paywall block specifically renders THE_EXCERPT_BLOCK.
[1012] Fix | Delete
if ( strpos( $the_content, \Automattic\Jetpack\Extensions\Paywall\THE_EXCERPT_BLOCK ) ) {
[1013] Fix | Delete
return strstr( $the_content, \Automattic\Jetpack\Extensions\Paywall\THE_EXCERPT_BLOCK, true );
[1014] Fix | Delete
}
[1015] Fix | Delete
}
[1016] Fix | Delete
[1017] Fix | Delete
return $paywalled_content;
[1018] Fix | Delete
}
[1019] Fix | Delete
[1020] Fix | Delete
/**
[1021] Fix | Delete
* Gate access to comments. We want to close comments on private sites.
[1022] Fix | Delete
*
[1023] Fix | Delete
* @param bool $default_comments_open Default state of the comments_open filter.
[1024] Fix | Delete
* @param int $post_id Current post id.
[1025] Fix | Delete
*
[1026] Fix | Delete
* @return bool
[1027] Fix | Delete
*/
[1028] Fix | Delete
function maybe_close_comments( $default_comments_open, $post_id ) {
[1029] Fix | Delete
if ( ! $default_comments_open || ! $post_id ) {
[1030] Fix | Delete
return $default_comments_open;
[1031] Fix | Delete
}
[1032] Fix | Delete
[1033] Fix | Delete
require_once JETPACK__PLUGIN_DIR . 'modules/memberships/class-jetpack-memberships.php';
[1034] Fix | Delete
return Jetpack_Memberships::user_can_view_post();
[1035] Fix | Delete
}
[1036] Fix | Delete
[1037] Fix | Delete
/**
[1038] Fix | Delete
* Gate access to existing comments
[1039] Fix | Delete
*
[1040] Fix | Delete
* @param string $comment The comment.
[1041] Fix | Delete
*
[1042] Fix | Delete
* @return string
[1043] Fix | Delete
*/
[1044] Fix | Delete
function maybe_gate_existing_comments( $comment ) {
[1045] Fix | Delete
if ( empty( $comment ) ) {
[1046] Fix | Delete
return $comment;
[1047] Fix | Delete
}
[1048] Fix | Delete
[1049] Fix | Delete
require_once JETPACK__PLUGIN_DIR . 'modules/memberships/class-jetpack-memberships.php';
[1050] Fix | Delete
if ( Jetpack_Memberships::user_can_view_post() ) {
[1051] Fix | Delete
return $comment;
[1052] Fix | Delete
}
[1053] Fix | Delete
return '';
[1054] Fix | Delete
}
[1055] Fix | Delete
[1056] Fix | Delete
/**
[1057] Fix | Delete
* Is the Jetpack_Token_Subscription_Service class loaded
[1058] Fix | Delete
*
[1059] Fix | Delete
* @return bool
[1060] Fix | Delete
*/
[1061] Fix | Delete
function is_jetpack_token_subscription_service_loaded(): bool {
[1062] Fix | Delete
return class_exists( 'Automattic\Jetpack\Extensions\Premium_Content\Subscription_Service\Jetpack_Token_Subscription_Service' );
[1063] Fix | Delete
}
[1064] Fix | Delete
[1065] Fix | Delete
/**
[1066] Fix | Delete
* Adds support for WP Super cache and Boost cache
[1067] Fix | Delete
*/
[1068] Fix | Delete
function maybe_prevent_super_cache_caching() {
[1069] Fix | Delete
// Prevents cached page to be served if the Membership cookie is present
[1070] Fix | Delete
if ( is_jetpack_token_subscription_service_loaded() ) {
[1071] Fix | Delete
do_action( 'wpsc_add_cookie', Jetpack_Token_Subscription_Service::JWT_AUTH_TOKEN_COOKIE_NAME );
[1072] Fix | Delete
}
[1073] Fix | Delete
[1074] Fix | Delete
if ( is_user_auth() ) {
[1075] Fix | Delete
// Do not cache the page if user is auth with Membership token
[1076] Fix | Delete
if ( ! defined( 'DONOTCACHEPAGE' ) ) {
[1077] Fix | Delete
define( 'DONOTCACHEPAGE', true );
[1078] Fix | Delete
}
[1079] Fix | Delete
}
[1080] Fix | Delete
}
[1081] Fix | Delete
[1082] Fix | Delete
/**
[1083] Fix | Delete
* Returns paywall content blocks
[1084] Fix | Delete
*
[1085] Fix | Delete
* @return string
[1086] Fix | Delete
*/
[1087] Fix | Delete
function get_paywall_content() {
[1088] Fix | Delete
if ( Jetpack_Memberships::user_is_pending_subscriber() ) {
[1089] Fix | Delete
return get_paywall_blocks_subscribe_pending();
[1090] Fix | Delete
}
[1091] Fix | Delete
if ( doing_filter( 'get_the_excerpt' ) ) {
[1092] Fix | Delete
return '';
[1093] Fix | Delete
}
[1094] Fix | Delete
return get_paywall_blocks();
[1095] Fix | Delete
}
[1096] Fix | Delete
[1097] Fix | Delete
/**
[1098] Fix | Delete
* Returns the current URL.
[1099] Fix | Delete
*
[1100] Fix | Delete
* TODO: Copied from https://github.com/Automattic/jetpack/blob/bb885061dc3ee7a80a78a5f0116ab3fcebfddb09/projects/packages/boost-core/src/lib/class-url.php#L39
[1101] Fix | Delete
* TODO: Move to a shared package
[1102] Fix | Delete
*
[1103] Fix | Delete
* @return string
[1104] Fix | Delete
*/
[1105] Fix | Delete
function get_current_url() {
[1106] Fix | Delete
// Fallback to the site URL if we're unable to determine the URL from $_SERVER global.
[1107] Fix | Delete
$current_url = site_url();
[1108] Fix | Delete
[1109] Fix | Delete
if ( isset( $_SERVER ) && is_array( $_SERVER ) ) {
[1110] Fix | Delete
// phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Sanitization happens at the end
[1111] Fix | Delete
$scheme = isset( $_SERVER['HTTPS'] ) && 'on' === $_SERVER['HTTPS'] ? 'https' : 'http';
[1112] Fix | Delete
$host = ! empty( $_SERVER['HTTP_HOST'] ) ? wp_unslash( $_SERVER['HTTP_HOST'] ) : null;
[1113] Fix | Delete
$path = ! empty( $_SERVER['REQUEST_URI'] ) ? wp_unslash( $_SERVER['REQUEST_URI'] ) : '';
[1114] Fix | Delete
[1115] Fix | Delete
// Support for local plugin development and testing using ngrok.
[1116] Fix | Delete
if ( ! empty( $_SERVER['HTTP_X_ORIGINAL_HOST'] ) && str_contains( $_SERVER['HTTP_X_ORIGINAL_HOST'], 'ngrok.io' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput -- This is validating.
[1117] Fix | Delete
$host = wp_unslash( $_SERVER['HTTP_X_ORIGINAL_HOST'] );
[1118] Fix | Delete
}
[1119] Fix | Delete
// phpcs:enable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
[1120] Fix | Delete
[1121] Fix | Delete
if ( $host ) {
[1122] Fix | Delete
$current_url = esc_url_raw( sprintf( '%s://%s%s', $scheme, $host, $path ) );
[1123] Fix | Delete
}
[1124] Fix | Delete
}
[1125] Fix | Delete
[1126] Fix | Delete
return $current_url;
[1127] Fix | Delete
}
[1128] Fix | Delete
[1129] Fix | Delete
/**
[1130] Fix | Delete
* Get the submit button text based on the subscription status.
[1131] Fix | Delete
*
[1132] Fix | Delete
* @param array $data Array containing block view data.
[1133] Fix | Delete
*
[1134] Fix | Delete
* @return string
[1135] Fix | Delete
*/
[1136] Fix | Delete
function get_submit_button_text( $data ) {
[1137] Fix | Delete
if ( ! Jetpack_Memberships::is_current_user_subscribed() ) {
[1138] Fix | Delete
return $data['submit_button_text'];
[1139] Fix | Delete
}
[1140] Fix | Delete
if ( ! Jetpack_Memberships::user_can_view_post() ) {
[1141] Fix | Delete
return $data['submit_button_text_upgrade'];
[1142] Fix | Delete
}
[1143] Fix | Delete
return '✓ ' . $data['submit_button_text_subscribed'];
[1144] Fix | Delete
}
[1145] Fix | Delete
[1146] Fix | Delete
/**
[1147] Fix | Delete
* Returns true if there are no more tiers to upgrade to.
[1148] Fix | Delete
*
[1149] Fix | Delete
* @return boolean
[1150] Fix | Delete
*/
[1151] Fix | Delete
function is_top_subscription() {
[1152] Fix | Delete
if ( ! Jetpack_Memberships::is_current_user_subscribed() ) {
[1153] Fix | Delete
return false;
[1154] Fix | Delete
}
[1155] Fix | Delete
if ( ! Jetpack_Memberships::user_can_view_post() ) {
[1156] Fix | Delete
return false;
[1157] Fix | Delete
}
[1158] Fix | Delete
return true;
[1159] Fix | Delete
}
[1160] Fix | Delete
[1161] Fix | Delete
/**
[1162] Fix | Delete
* Sanitize the submit button text.
[1163] Fix | Delete
*
[1164] Fix | Delete
* @param string $text String containing the submit button text.
[1165] Fix | Delete
*
[1166] Fix | Delete
* @return string
[1167] Fix | Delete
*/
[1168] Fix | Delete
function sanitize_submit_text( $text ) {
[1169] Fix | Delete
return wp_kses(
[1170] Fix | Delete
html_entity_decode( $text, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401 ),
[1171] Fix | Delete
Jetpack_Subscriptions_Widget::$allowed_html_tags_for_submit_button
[1172] Fix | Delete
);
[1173] Fix | Delete
}
[1174] Fix | Delete
[1175] Fix | Delete
/**
[1176] Fix | Delete
* Returns paywall content blocks if user is not authenticated
[1177] Fix | Delete
*
[1178] Fix | Delete
* @return string
[1179] Fix | Delete
*/
[1180] Fix | Delete
function get_paywall_blocks() {
[1181] Fix | Delete
$custom_paywall = apply_filters( 'jetpack_custom_paywall_blocks', false );
[1182] Fix | Delete
if ( ! empty( $custom_paywall ) ) {
[1183] Fix | Delete
return $custom_paywall;
[1184] Fix | Delete
}
[1185] Fix | Delete
[1186] Fix | Delete
if ( ! Request::is_frontend() ) { // emails
[1187] Fix | Delete
return get_paywall_simple();
[1188] Fix | Delete
}
[1189] Fix | Delete
[1190] Fix | Delete
require_once JETPACK__PLUGIN_DIR . 'modules/memberships/class-jetpack-memberships.php';
[1191] Fix | Delete
$is_paid_post = is_paid_post();
[1192] Fix | Delete
$is_paid_subscriber = Jetpack_Memberships::user_is_paid_subscriber();
[1193] Fix | Delete
[1194] Fix | Delete
$access_heading = $is_paid_subscriber
[1195] Fix | Delete
? esc_html__( 'Upgrade to continue reading', 'jetpack' )
[1196] Fix | Delete
: esc_html__( 'Subscribe to continue reading', 'jetpack' );
[1197] Fix | Delete
[1198] Fix | Delete
$subscribe_text = $is_paid_post
[1199] Fix | Delete
// translators: %s is the name of the site.
[1200] Fix | Delete
? (
[1201] Fix | Delete
$is_paid_subscriber
[1202] Fix | Delete
? esc_html__( 'Upgrade to get access to the rest of this post and other exclusive content.', 'jetpack' )
[1203] Fix | Delete
: esc_html__( 'Become a paid subscriber to get access to the rest of this post and other exclusive content.', 'jetpack' )
[1204] Fix | Delete
)
[1205] Fix | Delete
// translators: %s is the name of the site.
[1206] Fix | Delete
: esc_html__( 'Subscribe to get access to the rest of this post and other subscriber-only content.', 'jetpack' );
[1207] Fix | Delete
[1208] Fix | Delete
$login_block = '';
[1209] Fix | Delete
[1210] Fix | Delete
if ( is_user_auth() ) {
[1211] Fix | Delete
if ( ( new Host() )->is_wpcom_simple() ) {
[1212] Fix | Delete
// We cannot use wpcom_logmein_redirect_url since it returns redirect URL when user is already logged in.
[1213] Fix | Delete
$login_link = add_query_arg(
[1214] Fix | Delete
array(
[1215] Fix | Delete
'redirect_to' => rawurlencode( get_current_url() ),
[1216] Fix | Delete
'blog_id' => get_current_blog_id(),
[1217] Fix | Delete
),
[1218] Fix | Delete
'https://wordpress.com/log-in/link'
[1219] Fix | Delete
);
[1220] Fix | Delete
$switch_accounts_link = wp_logout_url( $login_link );
[1221] Fix | Delete
$login_block = '<!-- wp:paragraph {"align":"center","style":{"typography":{"fontSize":"14px"}}} -->
[1222] Fix | Delete
<p class="has-text-align-center" style="font-size:14px">
[1223] Fix | Delete
<a href="' . $switch_accounts_link . '">' . __( 'Switch accounts', 'jetpack' ) . '</a>
[1224] Fix | Delete
</p>
[1225] Fix | Delete
<!-- /wp:paragraph -->';
[1226] Fix | Delete
}
[1227] Fix | Delete
} else {
[1228] Fix | Delete
$access_question = $is_paid_post ? esc_html__( 'Already a paid subscriber?', 'jetpack' ) : esc_html__( 'Already a subscriber?', 'jetpack' );
[1229] Fix | Delete
$login_block = '<!-- wp:group {"style":{"typography":{"fontSize":"14px"}},"layout":{"type":"flex","justifyContent":"center"}} -->
[1230] Fix | Delete
<div class="wp-block-group" style="font-size:14px">
[1231] Fix | Delete
<!-- wp:jetpack/subscriber-login {"logInLabel":"' . $access_question . '"} /-->
[1232] Fix | Delete
</div>
[1233] Fix | Delete
<!-- /wp:group -->';
[1234] Fix | Delete
}
[1235] Fix | Delete
[1236] Fix | Delete
$lock_svg = plugins_url( 'images/lock-paywall.svg', JETPACK__PLUGIN_FILE );
[1237] Fix | Delete
[1238] Fix | Delete
return '
[1239] Fix | Delete
<!-- wp:group {"style":{"border":{"width":"1px","radius":"4px"},"spacing":{"padding":{"top":"32px","bottom":"32px","left":"32px","right":"32px"}}},"borderColor":"primary","className":"jetpack-subscribe-paywall","layout":{"type":"constrained","contentSize":"400px"}} -->
[1240] Fix | Delete
<div class="wp-block-group jetpack-subscribe-paywall has-border-color has-primary-border-color" style="border-width:1px;border-radius:4px;padding-top:32px;padding-right:32px;padding-bottom:32px;padding-left:32px">
[1241] Fix | Delete
<!-- wp:image {"align":"center","width":24,"height":24,"sizeSlug":"large","linkDestination":"none"} -->
[1242] Fix | Delete
<figure class="wp-block-image aligncenter size-large is-resized"><img src="' . $lock_svg . '" alt="" width="24" height="24"/></figure>
[1243] Fix | Delete
<!-- /wp:image -->
[1244] Fix | Delete
[1245] Fix | Delete
<!-- wp:heading {"textAlign":"center","style":{"typography":{"fontStyle":"normal","fontWeight":"600","fontSize":"24px"},"layout":{"selfStretch":"fit"}}} -->
[1246] Fix | Delete
<h2 class="wp-block-heading has-text-align-center" style="font-size:24px;font-style:normal;font-weight:600">' . $access_heading . '</h2>
[1247] Fix | Delete
<!-- /wp:heading -->
[1248] Fix | Delete
[1249] Fix | Delete
<!-- wp:paragraph {"align":"center","style":{"typography":{"fontSize":"14px"},"spacing":{"margin":{"top":"10px","bottom":"10px"}}}} -->
[1250] Fix | Delete
<p class="has-text-align-center" style="margin-top:10px;margin-bottom:10px;font-size:14px">' . $subscribe_text . '</p>
[1251] Fix | Delete
<!-- /wp:paragraph -->
[1252] Fix | Delete
[1253] Fix | Delete
<!-- wp:jetpack/subscriptions {"borderRadius":50,"borderColor":"primary","className":"is-style-compact","isPaidSubscriber":' . ( $is_paid_subscriber ? 'true' : 'false' ) . '} /-->
[1254] Fix | Delete
' . $login_block . '
[1255] Fix | Delete
</div>
[1256] Fix | Delete
<!-- /wp:group -->
[1257] Fix | Delete
';
[1258] Fix | Delete
}
[1259] Fix | Delete
[1260] Fix | Delete
/**
[1261] Fix | Delete
* Returns true if user is auth for subscriptions check, otherwise returns false.
[1262] Fix | Delete
*
[1263] Fix | Delete
* @return bool
[1264] Fix | Delete
*/
[1265] Fix | Delete
function is_user_auth(): bool {
[1266] Fix | Delete
if ( ( new Host() )->is_wpcom_simple() && is_user_logged_in() ) {
[1267] Fix | Delete
return true;
[1268] Fix | Delete
}
[1269] Fix | Delete
if ( current_user_can( 'manage_options' ) ) {
[1270] Fix | Delete
return true;
[1271] Fix | Delete
}
[1272] Fix | Delete
[1273] Fix | Delete
if ( is_jetpack_token_subscription_service_loaded() ) {
[1274] Fix | Delete
if ( Jetpack_Token_Subscription_Service::has_token_from_cookie() ) {
[1275] Fix | Delete
return true;
[1276] Fix | Delete
}
[1277] Fix | Delete
}
[1278] Fix | Delete
return false;
[1279] Fix | Delete
}
[1280] Fix | Delete
[1281] Fix | Delete
/**
[1282] Fix | Delete
* Returns `true` if the post is a paid post.
[1283] Fix | Delete
*/
[1284] Fix | Delete
function is_paid_post(): bool {
[1285] Fix | Delete
require_once JETPACK__PLUGIN_DIR . 'modules/memberships/class-jetpack-memberships.php';
[1286] Fix | Delete
[1287] Fix | Delete
// Make sure Stripe is connected and the post is marked for paid subscribers.
[1288] Fix | Delete
if ( Jetpack_Memberships::has_connected_account() && is_jetpack_token_subscription_service_loaded() ) {
[1289] Fix | Delete
return Jetpack_Memberships::get_post_access_level() === Jetpack_Token_Subscription_Service::POST_ACCESS_LEVEL_PAID_SUBSCRIBERS;
[1290] Fix | Delete
}
[1291] Fix | Delete
[1292] Fix | Delete
return false;
[1293] Fix | Delete
}
[1294] Fix | Delete
[1295] Fix | Delete
/**
[1296] Fix | Delete
* Returns true if the post is a subscribers post.
[1297] Fix | Delete
*/
[1298] Fix | Delete
function is_subscribers_post(): bool {
[1299] Fix | Delete
require_once JETPACK__PLUGIN_DIR . 'modules/memberships/class-jetpack-memberships.php';
[1300] Fix | Delete
[1301] Fix | Delete
// Make sure Stripe is connected and the post is marked for paid subscribers.
[1302] Fix | Delete
if ( Jetpack_Memberships::has_connected_account() && is_jetpack_token_subscription_service_loaded() ) {
[1303] Fix | Delete
return Jetpack_Memberships::get_post_access_level() === Jetpack_Token_Subscription_Service::POST_ACCESS_LEVEL_SUBSCRIBERS;
[1304] Fix | Delete
}
[1305] Fix | Delete
[1306] Fix | Delete
return false;
[1307] Fix | Delete
}
[1308] Fix | Delete
[1309] Fix | Delete
/**
[1310] Fix | Delete
* Returns paywall content blocks when email confirmation is pending
[1311] Fix | Delete
*
[1312] Fix | Delete
* @return string
[1313] Fix | Delete
*/
[1314] Fix | Delete
function get_paywall_blocks_subscribe_pending() {
[1315] Fix | Delete
$subscribe_email = Jetpack_Memberships::get_current_user_email();
[1316] Fix | Delete
[1317] Fix | Delete
/** This filter is documented in \Automattic\Jetpack\Forms\ContactForm\Contact_Form */
[1318] Fix | Delete
if ( is_wpcom() || false !== apply_filters( 'jetpack_auto_fill_logged_in_user', false ) ) {
[1319] Fix | Delete
$current_user = wp_get_current_user();
[1320] Fix | Delete
if ( ! empty( $current_user->user_email ) ) {
[1321] Fix | Delete
$subscribe_email = $current_user->user_email;
[1322] Fix | Delete
}
[1323] Fix | Delete
}
[1324] Fix | Delete
[1325] Fix | Delete
$access_heading = esc_html__( 'Confirm your subscription to continue reading', 'jetpack' );
[1326] Fix | Delete
[1327] Fix | Delete
/* translators: %s: email address */
[1328] Fix | Delete
$subscribe_text = sprintf( esc_html__( 'Head to your inbox and confirm your email address %s.', 'jetpack' ), $subscribe_email );
[1329] Fix | Delete
[1330] Fix | Delete
$lock_svg = plugins_url( 'images/lock-paywall.svg', JETPACK__PLUGIN_FILE );
[1331] Fix | Delete
[1332] Fix | Delete
return '
[1333] Fix | Delete
<!-- wp:group {"style":{"border":{"width":"1px","radius":"4px"},"spacing":{"padding":{"top":"32px","bottom":"32px","left":"32px","right":"32px"}}},"borderColor":"primary","className":"jetpack-subscribe-paywall","layout":{"type":"constrained","contentSize":"400px"}} -->
[1334] Fix | Delete
<div class="wp-block-group jetpack-subscribe-paywall has-border-color has-primary-border-color" style="border-width:1px;border-radius:4px;padding-top:32px;padding-right:32px;padding-bottom:32px;padding-left:32px">
[1335] Fix | Delete
<!-- wp:image {"align":"center","width":24,"height":24,"sizeSlug":"large","linkDestination":"none"} -->
[1336] Fix | Delete
<figure class="wp-block-image aligncenter size-large is-resized"><img src="' . $lock_svg . '" alt="" width="24" height="24"/></figure>
[1337] Fix | Delete
<!-- /wp:image -->
[1338] Fix | Delete
[1339] Fix | Delete
<!-- wp:heading {"textAlign":"center","style":{"typography":{"fontStyle":"normal","fontWeight":"600","fontSize":"24px", "maxWidth":"initial"},"layout":{"selfStretch":"fit"}}} -->
[1340] Fix | Delete
<h2 class="wp-block-heading has-text-align-center" style="font-size:24px;font-style:normal;font-weight:600;max-width:initial">' . $access_heading . '</h2>
[1341] Fix | Delete
<!-- /wp:heading -->
[1342] Fix | Delete
[1343] Fix | Delete
<!-- wp:paragraph {"align":"center","style":{"typography":{"fontSize":"14px"},"spacing":{"margin":{"top":"10px","bottom":"10px"}}}} -->
[1344] Fix | Delete
<p class="has-text-align-center" style="margin-top:10px;margin-bottom:10px;font-size:14px">' . $subscribe_text . '</p>
[1345] Fix | Delete
<!-- /wp:paragraph -->
[1346] Fix | Delete
</div>
[1347] Fix | Delete
<!-- /wp:group -->
[1348] Fix | Delete
';
[1349] Fix | Delete
}
[1350] Fix | Delete
[1351] Fix | Delete
/**
[1352] Fix | Delete
* Return content for non frontend views like Reader, emails.
[1353] Fix | Delete
*/
[1354] Fix | Delete
function get_paywall_simple(): string {
[1355] Fix | Delete
$is_paid_post = is_paid_post();
[1356] Fix | Delete
$is_subscribers_post = is_subscribers_post();
[1357] Fix | Delete
$is_subscriber = is_jetpack_memberships_loaded() && Jetpack_Memberships::is_current_user_subscribed();
[1358] Fix | Delete
$paywall_heading = esc_html__( 'Subscribe to keep reading', 'jetpack' );
[1359] Fix | Delete
[1360] Fix | Delete
if ( $is_subscribers_post && ! $is_subscriber ) {
[1361] Fix | Delete
$paywall_description = esc_html__( "It's a subscribers only post. Subscribe to get access to the rest of this post and other subscriber-only content.", 'jetpack' );
[1362] Fix | Delete
$paywall_action_btn = esc_html__( 'Subscribe', 'jetpack' );
[1363] Fix | Delete
} elseif ( $is_paid_post && $is_subscriber ) {
[1364] Fix | Delete
$paywall_description = esc_html__( "You're currently a free subscriber. Upgrade your subscription to get access to the rest of this post and other paid-subscriber only content.", 'jetpack' );
[1365] Fix | Delete
$paywall_action_btn = esc_html__( 'Upgrade subscription', 'jetpack' );
[1366] Fix | Delete
} else {
[1367] Fix | Delete
// - For paid post when the user is not a subscriber.
[1368] Fix | Delete
// - Default for all other cases.
[1369] Fix | Delete
$paywall_description = esc_html__( 'Become a paid subscriber to get access to the rest of this post and other exclusive content.', 'jetpack' );
[1370] Fix | Delete
$paywall_action_btn = esc_html__( 'Subscribe', 'jetpack' );
[1371] Fix | Delete
}
[1372] Fix | Delete
[1373] Fix | Delete
return '
[1374] Fix | Delete
<!-- wp:columns -->
[1375] Fix | Delete
<div class="wp-block-columns jetpack-paywall-simple" style="display: inline-block; width: 90%">
[1376] Fix | Delete
<!-- wp:column -->
[1377] Fix | Delete
<div class="wp-block-column" style="background-color: #F6F7F7; padding: 32px; 24px;">
[1378] Fix | Delete
<!-- wp:heading -->
[1379] Fix | Delete
<h2 class="has-text-align-center" style="margin: 0 0 12px; font-weight: 600;">' . $paywall_heading . '</h2>
[1380] Fix | Delete
<!-- /wp:heading -->
[1381] Fix | Delete
<!-- wp:paragraph -->
[1382] Fix | Delete
<p class="has-text-align-center"
[1383] Fix | Delete
style="text-align: center;
[1384] Fix | Delete
color: #50575E;
[1385] Fix | Delete
font-weight: 400;
[1386] Fix | Delete
font-size: 16px;
[1387] Fix | Delete
font-family: \'SF Pro Text\', sans-serif;
[1388] Fix | Delete
line-height: 28.8px;">
[1389] Fix | Delete
' . $paywall_description . '
[1390] Fix | Delete
</p>
[1391] Fix | Delete
<!-- /wp:paragraph -->
[1392] Fix | Delete
<!-- wp:buttons -->
[1393] Fix | Delete
<div class="wp-block-buttons" style="text-align: center;">
[1394] Fix | Delete
<!-- wp:button -->
[1395] Fix | Delete
<div class="wp-block-button" style="display: inline-block; margin: 10px 0; border-style: none; padding: 0;">
[1396] Fix | Delete
<a href="' . esc_url( get_post_permalink() ) . '" class="wp-block-button__link wp-element-button"
[1397] Fix | Delete
data-wpcom-track data-tracks-link-desc="paywall-email-click"
[1398] Fix | Delete
style="display: inline-block;
[1399] Fix | Delete
padding: 12px 15px;
[1400] Fix | Delete
background-color: #3858e9;
[1401] Fix | Delete
color: #FFFFFF;
[1402] Fix | Delete
text-decoration: none;
[1403] Fix | Delete
border-radius: 5px;
[1404] Fix | Delete
font-family: \'SF Pro Display\', sans-serif;
[1405] Fix | Delete
font-weight: 500;
[1406] Fix | Delete
font-size: 16px;
[1407] Fix | Delete
text-align: center;">' . $paywall_action_btn . '</a>
[1408] Fix | Delete
</div>
[1409] Fix | Delete
<!-- /wp:button -->
[1410] Fix | Delete
</div>
[1411] Fix | Delete
<!-- /wp:buttons -->
[1412] Fix | Delete
</div>
[1413] Fix | Delete
<!-- /wp:column -->
[1414] Fix | Delete
</div>
[1415] Fix | Delete
<!-- /wp:columns -->
[1416] Fix | Delete
';
[1417] Fix | Delete
}
[1418] Fix | Delete
[1419] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function