Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:ampproject/amp-wp into add/inval…
Browse files Browse the repository at this point in the history
…id-markup-reason

* 'develop' of github.com:ampproject/amp-wp:
  Pull the built `block-libray` package from Gutenberg SVN if it does not exists (#3847)
  Update dependency @babel/plugin-transform-react-jsx to v7.7.4 (#3688)
  Update dependency @babel/plugin-proposal-class-properties to v7… (#3687)
  Update dependency @babel/cli to v7.7.4 (#3685)
  Update dependency browserslist to v4.7.3 (#3792)
  Update dependency postcss to v7.0.23 (#3791)
  Update dependency autoprefixer to v9.7.2 (#3679)
  For the Gallery block, use the recommended amp-lightbox-gallery
  • Loading branch information
westonruter committed Nov 30, 2019
2 parents 22b1869 + 12c1d47 commit 8550fd7
Show file tree
Hide file tree
Showing 6 changed files with 255 additions and 158 deletions.
5 changes: 5 additions & 0 deletions .dev-lib
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ function after_wp_install {
echo -n "Installing Gutenberg..."
gutenberg_plugin_svn_url=https://plugins.svn.wordpress.org/gutenberg/trunk/
svn export -q "$gutenberg_plugin_svn_url" "$WP_CORE_DIR/src/wp-content/plugins/gutenberg"

if [ ! -s "$WP_CORE_DIR/src/wp-includes/css/dist/block-library/style.css" ]; then
svn export -q --force https://plugins.svn.wordpress.org/gutenberg/trunk/build/block-library/ "$WP_CORE_DIR/src/wp-includes/css/dist/block-library"
fi

echo "done"
fi

Expand Down
36 changes: 0 additions & 36 deletions includes/sanitizers/class-amp-base-sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@ abstract class AMP_Base_Sanitizer {
*/
const FALLBACK_HEIGHT = 400;

/**
* Value for <amp-image-lightbox> ID.
*
* @since 1.0
*
* @const string
*/
const AMP_IMAGE_LIGHTBOX_ID = 'amp-image-lightbox';

/**
* Placeholder for default args, to be set in child classes.
*
Expand Down Expand Up @@ -703,33 +694,6 @@ public function filter_attachment_layout_attributes( $node, $new_attributes, $la
return $new_attributes;
}

/**
* Add <amp-image-lightbox> element to body tag if it doesn't exist yet.
*/
public function maybe_add_amp_image_lightbox_node() {

$nodes = $this->dom->getElementById( self::AMP_IMAGE_LIGHTBOX_ID );
if ( null !== $nodes ) {
return;
}

$nodes = $this->dom->getElementsByTagName( 'body' );
if ( ! $nodes->length ) {
return;
}
$body_node = $nodes->item( 0 );
$amp_image_lightbox = AMP_DOM_Utils::create_node(
$this->dom,
'amp-image-lightbox',
[
'id' => self::AMP_IMAGE_LIGHTBOX_ID,
'layout' => 'nodisplay',
'data-close-button-aria-label' => __( 'Close', 'amp' ),
]
);
$body_node->appendChild( $amp_image_lightbox );
}

/**
* Parse a style string into an associative array of style attributes.
*
Expand Down
11 changes: 1 addition & 10 deletions includes/sanitizers/class-amp-gallery-block-sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ public function sanitize() {
// If lightbox is set, we should add lightbox feature to the gallery images.
if ( $is_amp_lightbox ) {
$this->add_lightbox_attributes_to_image_nodes( $node );
$this->maybe_add_amp_image_lightbox_node();
}

// If amp-carousel is not set, nothing else to do here.
Expand Down Expand Up @@ -145,18 +144,10 @@ protected function add_lightbox_attributes_to_image_nodes( $element ) {
if ( 0 === $num_images ) {
return;
}
$attributes = [
'data-amp-lightbox' => '',
'on' => 'tap:' . self::AMP_IMAGE_LIGHTBOX_ID,
'role' => 'button',
'tabindex' => 0,
];

for ( $j = $num_images - 1; $j >= 0; $j-- ) {
$image_node = $images->item( $j );
foreach ( $attributes as $att => $value ) {
$image_node->setAttribute( $att, $value );
}
$image_node->setAttribute( 'lightbox', '' );
}
}

Expand Down
Loading

0 comments on commit 8550fd7

Please sign in to comment.