kollapsminoriteten/wp-content/plugins/jetpack/extensions/blocks/sharing-buttons/sharing-buttons.php

42 lines
963 B
PHP
Raw Normal View History

2020-03-03 18:49:45 +01:00
<?php
/**
2023-12-07 09:44:11 +01:00
* Sharing Buttons Block.
2020-03-03 18:49:45 +01:00
*
2023-12-07 09:44:11 +01:00
* @since 11.x
2020-03-03 18:49:45 +01:00
*
2021-04-27 08:32:47 +02:00
* @package automattic/jetpack
2020-03-03 18:49:45 +01:00
*/
2023-12-07 09:44:11 +01:00
namespace Automattic\Jetpack\Extensions\Sharing_Buttons;
2020-05-06 17:20:49 +02:00
2020-11-18 09:10:44 +01:00
use Automattic\Jetpack\Blocks;
2020-05-06 17:20:49 +02:00
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() {
2020-11-18 09:10:44 +01:00
Blocks::jetpack_register_block(
2023-09-26 10:24:36 +02:00
__DIR__,
2020-05-06 17:20:49 +02:00
array( 'render_callback' => __NAMESPACE__ . '\load_assets' )
);
}
add_action( 'init', __NAMESPACE__ . '\register_block' );
2020-03-03 18:49:45 +01:00
/**
2023-12-07 09:44:11 +01:00
* Sharing Buttons block registration/dependency declaration.
2020-03-03 18:49:45 +01:00
*
2023-12-07 09:44:11 +01:00
* @param array $attr Array containing the Sharing Buttons block attributes.
* @param string $content String containing the Sharing Buttons block content.
2020-03-03 18:49:45 +01:00
*
* @return string
*/
2020-05-06 17:20:49 +02:00
function load_assets( $attr, $content ) {
2023-12-07 09:44:11 +01:00
/*
* Enqueue necessary scripts and styles.
*/
2023-09-26 10:24:36 +02:00
Jetpack_Gutenberg::load_assets_as_required( __DIR__ );
2020-03-03 18:49:45 +01:00
return $content;
}