52 lines
1.0 KiB
PHP
52 lines
1.0 KiB
PHP
<?php
|
|
/**
|
|
* Like Block.
|
|
*
|
|
* @since 12.9
|
|
*
|
|
* @package automattic/jetpack
|
|
*/
|
|
|
|
namespace Automattic\Jetpack\Extensions\Like;
|
|
|
|
use Automattic\Jetpack\Blocks;
|
|
use Jetpack_Gutenberg;
|
|
|
|
/**
|
|
* 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_block() {
|
|
Blocks::jetpack_register_block(
|
|
__DIR__,
|
|
array(
|
|
'api_version' => 3,
|
|
'render_callback' => __NAMESPACE__ . '\render_block',
|
|
)
|
|
);
|
|
}
|
|
add_action( 'init', __NAMESPACE__ . '\register_block' );
|
|
|
|
/**
|
|
* Like block render function.
|
|
*
|
|
* @param array $attr Array containing the Like block attributes.
|
|
*
|
|
* @return string
|
|
*/
|
|
function render_block( $attr ) {
|
|
/*
|
|
* Enqueue necessary scripts and styles.
|
|
*/
|
|
Jetpack_Gutenberg::load_assets_as_required( __DIR__ );
|
|
|
|
$output = 'This is where the like button will go.';
|
|
|
|
return sprintf(
|
|
'<div class="%1$s">%2$s</div>',
|
|
esc_attr( Blocks::classes( Blocks::get_block_feature( __DIR__ ), $attr ) ),
|
|
$output
|
|
);
|
|
}
|