pinterest.php
40 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Pinterest Block. |
| 4 | * |
| 5 | * @since 8.0.0 |
| 6 | * |
| 7 | * @package Jetpack |
| 8 | */ |
| 9 | |
| 10 | namespace Automattic\Jetpack\Extensions\Pinterest; |
| 11 | |
| 12 | const FEATURE_NAME = 'pinterest'; |
| 13 | const BLOCK_NAME = 'jetpack/' . FEATURE_NAME; |
| 14 | |
| 15 | /** |
| 16 | * Registers the block for use in Gutenberg |
| 17 | * This is done via an action so that we can disable |
| 18 | * registration if we need to. |
| 19 | */ |
| 20 | function register_block() { |
| 21 | jetpack_register_block( |
| 22 | BLOCK_NAME, |
| 23 | array( 'render_callback' => __NAMESPACE__ . '\load_assets' ) |
| 24 | ); |
| 25 | } |
| 26 | add_action( 'init', __NAMESPACE__ . '\register_block' ); |
| 27 | |
| 28 | /** |
| 29 | * Pinterest block registration/dependency declaration. |
| 30 | * |
| 31 | * @param array $attr Array containing the Pinterest block attributes. |
| 32 | * @param string $content String containing the Pinterest block content. |
| 33 | * |
| 34 | * @return string |
| 35 | */ |
| 36 | function load_assets( $attr, $content ) { |
| 37 | wp_enqueue_script( 'pinterest-pinit', 'https://assets.pinterest.com/js/pinit.js', array(), JETPACK__VERSION, true ); |
| 38 | return $content; |
| 39 | } |
| 40 |