Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
13.33% covered (danger)
13.33%
2 / 15
33.33% covered (danger)
33.33%
1 / 3
CRAP
n/a
0 / 0
Automattic\Jetpack\Extensions\Podcast_Player\register_block
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
2
Automattic\Jetpack\Extensions\Podcast_Player\render_block
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
Automattic\Jetpack\Extensions\Podcast_Player\render_email
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2/**
3 * Podcast Player Block.
4 *
5 * @since 8.4.0
6 *
7 * @package automattic/jetpack
8 */
9
10namespace Automattic\Jetpack\Extensions\Podcast_Player;
11
12use Automattic\Jetpack\Blocks;
13
14if ( ! defined( 'ABSPATH' ) ) {
15    exit( 0 );
16}
17
18/**
19 * Registers the block for use in Gutenberg. This is done via an action so that
20 * we can disable registration if we need to.
21 */
22function register_block() {
23    Blocks::jetpack_register_block(
24        __DIR__,
25        array(
26            'render_callback'       => __NAMESPACE__ . '\render_block',
27            // Since Gutenberg #31873.
28            'style'                 => 'wp-mediaelement',
29            'render_email_callback' => __NAMESPACE__ . '\render_email',
30        )
31    );
32}
33add_action( 'init', __NAMESPACE__ . '\register_block' );
34
35/**
36 * Podcast Player block registration/dependency declaration.
37 *
38 * The render implementation lives in render.php and is only loaded when the
39 * block is actually rendered, keeping it out of the eager front-end path.
40 *
41 * @param array  $attributes Array containing the Podcast Player block attributes.
42 * @param string $content    Fallback content - a direct link to RSS, as rendered by save.js.
43 * @return string
44 */
45function render_block( $attributes, $content ) {
46    require_once __DIR__ . '/render.php';
47    return render_block_implementation( $attributes, $content );
48}
49
50/**
51 * Render podcast player block for email.
52 *
53 * The render implementation lives in render.php and is only loaded when the
54 * block is actually rendered, keeping it out of the eager front-end path.
55 *
56 * @since 15.0
57 *
58 * @param string $block_content     The original block HTML content.
59 * @param array  $parsed_block      The parsed block data including attributes.
60 * @param object $rendering_context Email rendering context.
61 *
62 * @return string
63 */
64function render_email( $block_content, array $parsed_block, $rendering_context ) {
65    require_once __DIR__ . '/render.php';
66    return render_email_implementation( $block_content, $parsed_block, $rendering_context );
67}