__NAMESPACE__ . '\render_block' ) ); } add_action( 'init', __NAMESPACE__ . '\register_block' ); /** * Render the widget and associated JS * * @param array $attr The block attributes. */ function render_block( $attr ) { $content = '
'; if ( empty( $attr['url'] ) ) { if ( ! current_user_can( 'edit_posts' ) ) { return; } return Jetpack_Gutenberg::notice( __( 'The block will not be shown to your site visitors until a Tock business name is set.', 'jetpack' ), 'warning', Blocks::classes( Blocks::get_block_feature( __DIR__ ), $attr ) ); } wp_enqueue_script( 'tock-widget', 'https://www.exploretock.com/tock.js', array(), JETPACK__VERSION, true ); // Add CSS to hide direct link. Jetpack_Gutenberg::load_assets_as_required( __DIR__ ); wp_add_inline_script( 'tock-widget', "!function(t,o){if(!t.tock){var e=t.tock=function(){e.callMethod? e.callMethod.apply(e,arguments):e.queue.push(arguments)};t._tock||(t._tock=e), e.push=e,e.loaded=!0,e.version='1.0',e.queue=[];}}(window,document); tock('init', '" . esc_js( $attr['url'] ) . "');", 'before' ); return sprintf( '
%2$s
', esc_attr( Blocks::classes( Blocks::get_block_feature( __DIR__ ), $attr ) ), $content ); }