2020-03-03 18:49:45 +01:00
< ? php
/**
* Revue Block .
*
* @ since 8.3 . 0
*
2021-04-27 08:32:47 +02:00
* @ package automattic / jetpack
2020-03-03 18:49:45 +01:00
*/
2020-05-06 17:20:49 +02:00
namespace Automattic\Jetpack\Extensions\Revue ;
2020-10-20 18:05:12 +02:00
use Automattic\Jetpack\Blocks ;
2020-05-06 17:20:49 +02:00
use Jetpack_Gutenberg ;
const FEATURE_NAME = 'revue' ;
const BLOCK_NAME = 'jetpack/' . FEATURE_NAME ;
2023-01-25 20:43:46 +01:00
// @TODO Due to Revue being shut down as of 18th Jan 2023, this whole block should be removed a couple of months later.
2020-05-06 17:20:49 +02:00
/**
* 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 (
2020-05-06 17:20:49 +02:00
BLOCK_NAME ,
array ( 'render_callback' => __NAMESPACE__ . '\render_block' )
);
}
add_action ( 'init' , __NAMESPACE__ . '\register_block' );
2020-03-03 18:49:45 +01:00
/**
* Revue block render callback .
*
* @ param array $attributes Array containing the Revue block attributes .
*
* @ return string
*/
2023-01-25 20:43:46 +01:00
function render_block ( $attributes ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
if ( current_user_can ( 'manage_options' ) ) {
$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' );
$message .= '<br/><br/>' ;
$message .= sprintf (
' <a href="%1$s" target="_blank" rel="noopener noreferrer">%2$s</a>' ,
esc_url ( 'https://wordpress.com/go/digital-marketing/migrate-from-revue-newsletter/' ),
esc_html__ ( 'You can migrate from Revue to the WordPress.com Newsletter - find out more here.' , 'jetpack' )
);
return Jetpack_Gutenberg :: notice (
$message ,
'warning' ,
Blocks :: classes ( FEATURE_NAME , $attributes )
);
2020-03-03 18:49:45 +01:00
}
}