# jetpack/16.3-a.7/extensions/blocks/premium-content/subscriber-view/subscriber-view.php

Jetpack – WP Security, Backup, Speed, &amp; Growth, version 16.3-a.7. 58 lines.

- Page: https://pluginprobe.com/plugins/jetpack/16.3-a.7/code/extensions/blocks/premium-content/subscriber-view/subscriber-view.php
- Raw: https://pluginprobe.com/plugins/jetpack/16.3-a.7/raw/extensions/blocks/premium-content/subscriber-view/subscriber-view.php
- Modified: 2024-09-16T15:58:12+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/jetpack/16.3-a.7/code/extensions/blocks/premium-content/subscriber-view/subscriber-view.php#L10-L20`.

```php
<?php
/**
 * Premium Content Subscriber View Child Block.
 *
 * @package automattic/jetpack
 */

namespace Automattic\Jetpack\Extensions\Premium_Content;

use Automattic\Jetpack\Blocks;
use Jetpack_Gutenberg;

const SUBSCRIBER_VIEW_NAME = 'premium-content/subscriber-view';

require_once dirname( __DIR__ ) . '/_inc/access-check.php';

/**
 * Registers the block for use in Gutenberg
 * This is done via an action so that we can disable
 * registration if we need to.
 */
function register_subscriber_view_block() {
	Blocks::jetpack_register_block(
		SUBSCRIBER_VIEW_NAME,
		array(
			'render_callback' => __NAMESPACE__ . '\render_subscriber_view_block',
			'uses_context'    => array( 'premium-content/planId', 'premium-content/planIds' ),
		)
	);
}
add_action( 'init', __NAMESPACE__ . '\register_subscriber_view_block' );

/**
 * Render callback.
 *
 * @param array  $attributes Array containing the block attributes.
 * @param string $content    String containing the block content.
 * @param object $block      Object containing the full block.
 *
 * @return string
 */
function render_subscriber_view_block( $attributes, $content, $block = null ) {
	if ( ! pre_render_checks() ) {
		return '';
	}

	$visitor_has_access = current_visitor_can_access( $attributes, $block );

	if ( $visitor_has_access ) {
		Jetpack_Gutenberg::load_styles_as_required( SUBSCRIBER_VIEW_NAME );

		// The viewer has access to premium content, so the viewer can see the subscriber view content.
		return $content;
	}

	return '';
}

```
