block_asset_uri( 'index.js' ) ); } protected function get_block_register_params(): array { return array( 'editor_script_handles' => array( self::JS_SCRIPT_KEY ), 'attributes' => array( 'align' => array( 'type' => 'string', 'default' => 'center', ), ) ); } protected function get_block_name(): string { return 'video-block-meta'; } protected function get_view_name(): string { return 'video-block-meta'; } protected function after_view_rendered( $view_content, $attributes, $content, $block ) { global $wp_embed; $post_id = get_the_ID(); if ( ! $post_id ) { return $view_content; } // If the embed didn't work, clean up the cache if ( ! preg_match( '/(\s+)?<(\s+)?iframe/im', $view_content ) ) { $last_url = str_replace( '&', '&', $wp_embed->last_url ); $last_attr = $wp_embed->last_attr; $key_suffix = md5( $last_url . serialize( $last_attr ) ); $cachekey = '_oembed_' . $key_suffix; update_post_meta( $post_id, $cachekey, '' ); } return $view_content; } }