'ampify_categories_block', 'core/archives' => 'ampify_archives_block', ); /** * Register embed. */ public function register_embed() { add_filter( 'render_block', array( $this, 'filter_rendered_block' ), 0, 2 ); } /** * Unregister embed. */ public function unregister_embed() { remove_filter( 'render_block', array( $this, 'filter_rendered_block' ), 0 ); } /** * Filters the content of a single block to make it AMP valid. * * @param string $block_content The block content about to be appended. * @param array $block The full block, including name and attributes. * @return string Filtered block content. */ public function filter_rendered_block( $block_content, $block ) { if ( ! isset( $block['blockName'] ) ) { return $block_content; } if ( isset( $this->block_ampify_methods[ $block['blockName'] ] ) ) { $block_content = call_user_func( array( $this, $this->block_ampify_methods[ $block['blockName'] ] ), $block_content ); } elseif ( 'core/image' === $block['blockName'] || 'core/audio' === $block['blockName'] ) { /* * While the video block placeholder just outputs an empty video element, the placeholders for image and * audio blocks output empty and