Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/jetpack/extensio.../blocks/paywall
File: paywall.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Paywall Block.
[2] Fix | Delete
*
[3] Fix | Delete
* @since 12.5
[4] Fix | Delete
*
[5] Fix | Delete
* @package automattic/jetpack
[6] Fix | Delete
*/
[7] Fix | Delete
[8] Fix | Delete
namespace Automattic\Jetpack\Extensions\Paywall;
[9] Fix | Delete
[10] Fix | Delete
use Automattic\Jetpack\Blocks;
[11] Fix | Delete
[12] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[13] Fix | Delete
exit( 0 );
[14] Fix | Delete
}
[15] Fix | Delete
[16] Fix | Delete
const FEATURE_NAME = 'paywall';
[17] Fix | Delete
const BLOCK_NAME = 'jetpack/' . FEATURE_NAME;
[18] Fix | Delete
const BLOCK_HTML = '<!-- wp:' . BLOCK_NAME . ' /-->';
[19] Fix | Delete
const THE_EXCERPT_BLOCK = '[[[[[' . BLOCK_NAME . ']]]]]';
[20] Fix | Delete
[21] Fix | Delete
/**
[22] Fix | Delete
* Registers the block for use in Gutenberg
[23] Fix | Delete
* This is done via an action so that we can disable
[24] Fix | Delete
* registration if we need to.
[25] Fix | Delete
*/
[26] Fix | Delete
function register_block() {
[27] Fix | Delete
if ( ! \Jetpack::is_module_active( 'subscriptions' ) ) {
[28] Fix | Delete
return;
[29] Fix | Delete
}
[30] Fix | Delete
if ( ! class_exists( '\Jetpack_Memberships' ) ) {
[31] Fix | Delete
return;
[32] Fix | Delete
}
[33] Fix | Delete
[34] Fix | Delete
Blocks::jetpack_register_block(
[35] Fix | Delete
__DIR__,
[36] Fix | Delete
array(
[37] Fix | Delete
'render_callback' => __NAMESPACE__ . '\render_block',
[38] Fix | Delete
)
[39] Fix | Delete
);
[40] Fix | Delete
}
[41] Fix | Delete
add_action( 'init', __NAMESPACE__ . '\register_block' );
[42] Fix | Delete
[43] Fix | Delete
/**
[44] Fix | Delete
* Paywall block render callback.
[45] Fix | Delete
*
[46] Fix | Delete
* @return string
[47] Fix | Delete
*/
[48] Fix | Delete
function render_block() {
[49] Fix | Delete
if ( doing_filter( 'get_the_excerpt' ) ) {
[50] Fix | Delete
if ( \Jetpack_Memberships::user_can_view_post() ) {
[51] Fix | Delete
return '';
[52] Fix | Delete
}
[53] Fix | Delete
return THE_EXCERPT_BLOCK;
[54] Fix | Delete
}
[55] Fix | Delete
return '';
[56] Fix | Delete
}
[57] Fix | Delete
[58] Fix | Delete
/**
[59] Fix | Delete
* Adds the Paywall block to excerpt allowed blocks.
[60] Fix | Delete
*
[61] Fix | Delete
* @param array $allowed_blocks The allowed blocks.
[62] Fix | Delete
*
[63] Fix | Delete
* @return array The allowed blocks.
[64] Fix | Delete
*/
[65] Fix | Delete
function excerpt_allowed_blocks( $allowed_blocks ) {
[66] Fix | Delete
return array_merge( $allowed_blocks, array( Blocks::get_block_name( __DIR__ ) ) );
[67] Fix | Delete
}
[68] Fix | Delete
add_filter( 'excerpt_allowed_blocks', __NAMESPACE__ . '\excerpt_allowed_blocks' );
[69] Fix | Delete
[70] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function