PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.2
Jetpack – WP Security, Backup, Speed, & Growth v16.2
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 13.7.2 13.8.3 13.9.2 14.0.1 14.1.1 All 503 releases
jetpack / extensions / blocks / related-posts / render.php

render.php in Jetpack – WP Security, Backup, Speed, & Growth 16.2, at extensions/blocks/related-posts/render.php

51 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Related Posts block render implementation.
4 *
5 * Loaded lazily from related-posts.php only when the block is rendered, to keep
6 * the render body out of the eager front-end PHP/opcache footprint.
7 *
8 * @package automattic/jetpack
9 */
10
11 namespace Automattic\Jetpack\Extensions\RelatedPosts;
12
13 use Automattic\Jetpack\Modules;
14 use Automattic\Jetpack\Status\Host;
15 use WP_Block;
16
17 if ( ! defined( 'ABSPATH' ) ) {
18 exit( 0 );
19 }
20
21 /**
22 * Related Posts block render callback.
23 *
24 * @param array $attributes Array containing the Button block attributes.
25 * @param string $content The block content.
26 * @param WP_Block $block The block object.
27 *
28 * @return string
29 */
30 function render_block_implementation( $attributes, $content, $block ) {
31 // If the Related Posts module is not active, don't render the block.
32 if (
33 ! ( new Host() )->is_wpcom_simple()
34 && ! ( new Modules() )->is_active( 'related-posts' )
35 ) {
36 return '';
37 }
38
39 // If the Related Posts option is turned off, don't render the block.
40 $options = \Jetpack_Options::get_option( 'relatedposts', array() );
41 if ( empty( $options['enabled'] ) || ! $options['enabled'] ) {
42 return '';
43 }
44
45 if ( ! class_exists( 'Jetpack_RelatedPosts' ) ) {
46 require_once JETPACK__PLUGIN_DIR . 'modules/related-posts/jetpack-related-posts.php';
47 }
48
49 return \Jetpack_RelatedPosts::init()->render_block( $attributes, $content, $block );
50 }
51