Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 3
CRAP
n/a
0 / 0
Automattic\Jetpack\Jetpack_Mu_Wpcom\Timeline\register_block
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
2
Automattic\Jetpack\Jetpack_Mu_Wpcom\Timeline\load_assets
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
Automattic\Jetpack\Jetpack_Mu_Wpcom\Timeline\enqueue_block_editor_assets
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2/**
3 * Timeline Block
4 *
5 * @package automattic/jetpack-mu-wpcom
6 */
7
8namespace Automattic\Jetpack\Jetpack_Mu_Wpcom\Timeline;
9
10require_once __DIR__ . '/../../../utils.php';
11
12/**
13 * Registers the block for use in Gutenberg
14 * This is done via an action so that we can disable
15 * registration if we need to.
16 */
17function register_block() {
18    register_block_type(
19        'jetpack/timeline',
20        array(
21            'render_callback' => __NAMESPACE__ . '\load_assets',
22        )
23    );
24}
25add_action( 'init', __NAMESPACE__ . '\register_block' );
26
27/**
28 * Load assets on frontend.
29 *
30 * @param array  $attr    Array containing the Timeline block attributes.
31 * @param string $content String containing the Timeline block content.
32 *
33 * @return string
34 */
35function load_assets( $attr, $content ) {
36    // A block's view assets will not be required in wp-admin.
37    if ( ! is_admin() ) {
38        \jetpack_mu_wpcom_enqueue_assets( 'wpcom-blocks-timeline-view', array( 'js', 'css' ) );
39    }
40
41    return $content;
42}
43
44/**
45 * Load assets on the editor.
46 */
47function enqueue_block_editor_assets() {
48    \jetpack_mu_wpcom_enqueue_assets( 'wpcom-blocks-timeline-editor', array( 'js', 'css' ) );
49}
50add_action( 'enqueue_block_editor_assets', __NAMESPACE__ . '\enqueue_block_editor_assets' );