diff --git a/includes/vendor/amp/includes/class-amp-post-template.php b/includes/vendor/amp/includes/class-amp-post-template.php index b243eba4c..710174f88 100644 --- a/includes/vendor/amp/includes/class-amp-post-template.php +++ b/includes/vendor/amp/includes/class-amp-post-template.php @@ -19,6 +19,8 @@ require_once( AMP__VENDOR__DIR__ . '/includes/sanitizers/class-amp-allowed-tags-generated.php' ); require_once( AMP__VENDOR__DIR__ . '/includes/sanitizers/class-amp-tag-and-attribute-sanitizer.php' ); require_once( AMP__VENDOR__DIR__ . '/includes/sanitizers/class-amp-gallery-block-sanitizer.php' ); +require_once( AMP__VENDOR__DIR__ . '/includes/sanitizers/class-amp-block-sanitizer.php' ); + require_once( AMP__VENDOR__DIR__ . '/includes/embeds/class-amp-twitter-embed.php' ); require_once( AMP__VENDOR__DIR__ . '/includes/embeds/class-amp-youtube-embed.php' ); require_once( AMP__VENDOR__DIR__ . '/includes/embeds/class-amp-dailymotion-embed.php' ); @@ -30,6 +32,7 @@ require_once( AMP__VENDOR__DIR__ . '/includes/embeds/class-amp-soundcloud-embed.php' ); require_once( AMP__VENDOR__DIR__ . '/includes/embeds/class-amp-pinterest-embed.php' ); require_once( AMP__VENDOR__DIR__ . '/includes/embeds/class-amp-wistia-embed.php' ); +require_once( AMP__VENDOR__DIR__ . '/includes/embeds/class-amp-core-block-handler.php' ); class AMP_Post_Template { const SITE_ICON_SIZE = 32; @@ -262,6 +265,7 @@ private function build_post_content() { $amp_content = new AMP_Content( $new_post_content, apply_filters( 'amp_content_embed_handlers', array( + 'AMP_Core_Block_Handler' => array(), 'AMP_Twitter_Embed_Handler' => array(), 'AMP_YouTube_Embed_Handler' => array(), 'AMP_DailyMotion_Embed_Handler' => array(), @@ -285,6 +289,7 @@ private function build_post_content() { 'AMP_Iframe_Sanitizer' => array( 'add_placeholder' => true, ), + 'AMP_Block_Sanitizer' => array(), ), $this->post ), array( 'content_max_width' => $this->get( 'content_max_width' ), diff --git a/includes/vendor/amp/includes/embeds/class-amp-core-block-handler.php b/includes/vendor/amp/includes/embeds/class-amp-core-block-handler.php new file mode 100644 index 000000000..0a671dc7d --- /dev/null +++ b/includes/vendor/amp/includes/embeds/class-amp-core-block-handler.php @@ -0,0 +1,117 @@ +get_registered( $this->block_name ); + + if ( $block ) { + $this->original_categories_callback = $block->render_callback; + $block->render_callback = array( $this, 'render' ); + } + } + } + + /** + * Unregister embed. + */ + public function unregister_embed() { + if ( class_exists( 'WP_Block_Type_Registry' ) ) { + $registry = \WP_Block_Type_Registry::get_instance(); + $block = $registry->get_registered( $this->block_name ); + + if ( $block && ! empty( $this->original_categories_callback ) ) { + $block->render_callback = $this->original_categories_callback; + $this->original_categories_callback = null; + } + } + } + + /** + * Render Gutenberg block. This is essentially the same method as the original. + * Difference is excluding the disallowed JS script, adding
tags, and using on:change for