| 1 |
<?php |
| 2 |
/** |
| 3 |
* Instagram Gallery Block. |
| 4 |
* |
| 5 |
* @since 8.5.0 |
| 6 |
* |
| 7 |
* @package automattic/jetpack |
| 8 |
*/ |
| 9 |
|
| 10 |
namespace Automattic\Jetpack\Extensions\Instagram_Gallery; |
| 11 |
|
| 12 |
use Automattic\Jetpack\Blocks; |
| 13 |
use Automattic\Jetpack\External_Connections; |
| 14 |
use Jetpack; |
| 15 |
|
| 16 |
if ( ! defined( 'ABSPATH' ) ) { |
| 17 |
exit( 0 ); |
| 18 |
} |
| 19 |
|
| 20 |
/** |
| 21 |
* Registers the block for use in Gutenberg |
| 22 |
* This is done via an action so that we can disable |
| 23 |
* registration if we need to. |
| 24 |
*/ |
| 25 |
function register_block() { |
| 26 |
if ( ( defined( 'IS_WPCOM' ) && IS_WPCOM ) || Jetpack::is_connection_ready() ) { |
| 27 |
Blocks::jetpack_register_block( |
| 28 |
__DIR__, |
| 29 |
array( 'render_callback' => __NAMESPACE__ . '\render_block' ) |
| 30 |
); |
| 31 |
|
| 32 |
External_Connections::add_settings_for_service( |
| 33 |
'writing', |
| 34 |
array( |
| 35 |
'service' => 'instagram-basic-display', |
| 36 |
'title' => __( 'Instagram', 'jetpack' ), |
| 37 |
'description' => __( 'Display your more recent images from Instagram.', 'jetpack' ), |
| 38 |
'support_link' => array( |
| 39 |
'wpcom' => 'https://wordpress.com/support/latest-instagram-posts/', |
| 40 |
'jetpack' => 'latest-instagram-posts-block', |
| 41 |
), |
| 42 |
) |
| 43 |
); |
| 44 |
} |
| 45 |
} |
| 46 |
add_action( 'init', __NAMESPACE__ . '\register_block' ); |
| 47 |
|
| 48 |
/** |
| 49 |
* Instagram Gallery block render callback. |
| 50 |
* |
| 51 |
* The render implementation lives in render.php and is only loaded when the |
| 52 |
* block is actually rendered, keeping it out of the eager front-end path. |
| 53 |
* |
| 54 |
* @param array $attributes Array containing the Instagram Gallery block attributes. |
| 55 |
* @param string $content The Instagram Gallery block content. |
| 56 |
* |
| 57 |
* @return string |
| 58 |
*/ |
| 59 |
function render_block( $attributes, $content ) { |
| 60 |
require_once __DIR__ . '/render.php'; |
| 61 |
return render_block_implementation( $attributes, $content ); |
| 62 |
} |
| 63 |
|