Skip to content

Commit

Permalink
Remove dirty AMP support; rename Disabled to Classic
Browse files Browse the repository at this point in the history
  • Loading branch information
westonruter committed Jun 6, 2018
1 parent 555c079 commit 5bae33e
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 39 deletions.
38 changes: 0 additions & 38 deletions includes/admin/class-amp-editor-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,6 @@ public function init() {
if ( function_exists( 'gutenberg_init' ) ) {
add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_block_editor_assets' ) );
add_filter( 'wp_kses_allowed_html', array( $this, 'whitelist_block_atts_in_wp_kses_allowed_html' ), 10, 2 );

/*
* Dirty AMP is currently disabled per <https://github.com/Automattic/amp-wp/issues/1192>.
* Note that when not in native/canonical mode, AMP-specific Gutenberg blocks will not be
* registered for use, and so users will not be likely attempting to serve AMP content in
* non-AMP responses. When/if dirty AMP is allowed, the following can be re-enabled:
*
* add_filter( 'the_content', array( $this, 'tally_content_requiring_amp_scripts' ) );
* add_action( 'wp_print_footer_scripts', array( $this, 'print_dirty_amp_scripts' ) );
*/
}
}

Expand Down Expand Up @@ -155,32 +145,4 @@ public function enqueue_block_editor_assets() {
) ) )
);
}

/**
* Tally the AMP component scripts that are needed in a dirty AMP document.
*
* @param string $content Content.
* @return string Content (unmodified).
*/
public function tally_content_requiring_amp_scripts( $content ) {
if ( ! is_amp_endpoint() ) {
$pattern = sprintf( '/<(%s)\b.*?>/s', join( '|', $this->amp_blocks ) );
if ( preg_match_all( $pattern, $content, $matches ) ) {
$this->content_required_amp_scripts = array_merge(
$this->content_required_amp_scripts,
$matches[1]
);
}
}
return $content;
}

/**
* Print AMP scripts required for AMP components used in a non-AMP document (dirty AMP).
*/
public function print_dirty_amp_scripts() {
if ( ! is_amp_endpoint() && ! empty( $this->content_required_amp_scripts ) ) {
wp_scripts()->do_items( $this->content_required_amp_scripts );
}
}
}
2 changes: 1 addition & 1 deletion includes/options/class-amp-options-menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function render_theme_support() {
<dt>
<input type="radio" id="theme_support_disabled" name="<?php echo esc_attr( AMP_Options_Manager::OPTION_NAME . '[theme_support]' ); ?>" value="disabled" <?php checked( $theme_support, 'disabled' ); ?> <?php disabled( ! $theme_support_mutable ); ?>>
<label for="theme_support_disabled">
<strong><?php esc_html_e( 'Disabled', 'amp' ); ?></strong>
<strong><?php esc_html_e( 'Classic', 'amp' ); ?></strong>
</label>
</dt>
<dd>
Expand Down

0 comments on commit 5bae33e

Please sign in to comment.