register_scripts_and_styles(); $register_params = $instance->get_block_register_params(); $register_params = array_merge( $register_params, array( 'render_callback' => array( $instance, 'render' ), ) ); register_block_type( 'videopress-hq/' . $instance->get_block_name(), $register_params ); } protected function block_asset_uri( $asset ) { return get_template_directory_uri() . '/assets/js/blocks/' . $this->get_block_name() . '/' . $asset; } protected function after_view_rendered( $view_content, $attributes, $content, $block ) { return $view_content; } public function render( $attributes, $content, $block ) { if ( ! is_array( $attributes ) ) { $attributes = array(); } $view_vars = $this->get_view_vars( $attributes, $content, $block ); $view_vars = array_merge( $view_vars, array( 'attributes' => $attributes ) ); $view_content = $this->get_view_content( $this->get_view_name(), $view_vars ); return $this->after_view_rendered( $view_content, $attributes, $content, $block ); } private function get_view_content( $view, $template_args = array() ) { global $wp_embed; ob_start(); extract( $template_args ); include VPHQ_ROOT . '/server-blocks/views/' . $view . '.php'; $view_content = ob_get_clean(); // If the page contains embed, they should be ran manually through wp_embed, see https://github.com/WordPress/gutenberg/issues/19114 . $view_content = $wp_embed->run_shortcode( $view_content ); $view_content = $wp_embed->autoembed( $view_content ); return do_blocks( $view_content ); } }