__NAMESPACE__ . '\load_assets' )
);
}
add_action( 'init', __NAMESPACE__ . '\register_block' );
/**
* Nextdoor block registration/dependency declaration.
*
* @param array $attr Array containing the Nextdoor block attributes.
* @return string
*/
function load_assets( $attr ) {
if ( ! isset( $attr['url'] ) ) {
return;
}
$url = Jetpack_Gutenberg::validate_block_embed_url(
$attr['url'],
array( '/^http[s]?:\/\/((?:www\.)?nextdoor(?:.*)?\/(?:embed)\/\S*)/i' ),
true
);
if ( empty( $url ) ) {
return;
}
$url = preg_replace( '#/embed/#', '/p/', $url );
/*
* Enqueue necessary scripts and styles.
*/
Jetpack_Gutenberg::load_assets_as_required( __DIR__ );
$block_id = wp_unique_id( 'nextdoor-block-' );
$link_markup = '' . esc_html( $url ) . '';
$block_classes = Blocks::classes( Blocks::get_block_feature( __DIR__ ), $attr );
$html =
'' .
$link_markup .
'';
return $html;
}