revue.php
56 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Revue Block. |
| 4 | * |
| 5 | * @since 8.3.0 |
| 6 | * |
| 7 | * @package automattic/jetpack |
| 8 | */ |
| 9 | |
| 10 | namespace Automattic\Jetpack\Extensions\Revue; |
| 11 | |
| 12 | use Automattic\Jetpack\Blocks; |
| 13 | use Jetpack_Gutenberg; |
| 14 | |
| 15 | const FEATURE_NAME = 'revue'; |
| 16 | const BLOCK_NAME = 'jetpack/' . FEATURE_NAME; |
| 17 | |
| 18 | // @TODO Due to Revue being shut down as of 18th Jan 2023, this whole block should be removed a couple of months later. |
| 19 | /** |
| 20 | * Registers the block for use in Gutenberg |
| 21 | * This is done via an action so that we can disable |
| 22 | * registration if we need to. |
| 23 | */ |
| 24 | function register_block() { |
| 25 | Blocks::jetpack_register_block( |
| 26 | BLOCK_NAME, |
| 27 | array( 'render_callback' => __NAMESPACE__ . '\render_block' ) |
| 28 | ); |
| 29 | } |
| 30 | add_action( 'init', __NAMESPACE__ . '\register_block' ); |
| 31 | |
| 32 | /** |
| 33 | * Revue block render callback. |
| 34 | * |
| 35 | * @param array $attributes Array containing the Revue block attributes. |
| 36 | * |
| 37 | * @return string |
| 38 | */ |
| 39 | function render_block( $attributes ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
| 40 | if ( current_user_can( 'manage_options' ) ) { |
| 41 | $message = esc_html__( 'Revue is shutting down. The Revue signup form will no longer be displayed to your visitors and as such this block should be removed.', 'jetpack' ); |
| 42 | $message .= '<br/><br/>'; |
| 43 | $message .= sprintf( |
| 44 | ' <a href="%1$s" target="_blank" rel="noopener noreferrer">%2$s</a>', |
| 45 | esc_url( 'https://wordpress.com/go/digital-marketing/migrate-from-revue-newsletter/' ), |
| 46 | esc_html__( 'You can migrate from Revue to the WordPress.com Newsletter - find out more here.', 'jetpack' ) |
| 47 | ); |
| 48 | |
| 49 | return Jetpack_Gutenberg::notice( |
| 50 | $message, |
| 51 | 'warning', |
| 52 | Blocks::classes( FEATURE_NAME, $attributes ) |
| 53 | ); |
| 54 | } |
| 55 | } |
| 56 |