Skip to content

Commit

Permalink
Extract admin bar selector from translated string; remove todo
Browse files Browse the repository at this point in the history
  • Loading branch information
westonruter committed May 21, 2019
1 parent ae3c140 commit ee9fbb5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions includes/sanitizers/class-amp-style-sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2646,7 +2646,8 @@ private function remove_admin_bar_if_css_excluded() {
return;
}

$admin_bar = $this->dom->getElementById( 'wpadminbar' );
$admin_bar_id = 'wpadminbar';
$admin_bar = $this->dom->getElementById( $admin_bar_id );
if ( ! $admin_bar ) {
return;
}
Expand All @@ -2667,8 +2668,13 @@ private function remove_admin_bar_if_css_excluded() {
}

if ( ! $included ) {
$comment_text = sprintf(
/* translators: %s: CSS selector for admin bar element */
__( 'Admin bar (%s) was removed to preserve AMP validity due to excessive CSS.', 'amp' ),
'#' . $admin_bar_id
);
$admin_bar->parentNode->replaceChild(
$this->dom->createComment( ' ' . __( 'Admin bar (#wpadminbar) was removed to preserve AMP validity due to excessive CSS.', 'amp' ) . ' ' ),
$this->dom->createComment( ' ' . $comment_text . ' ' ),
$admin_bar
);
}
Expand Down Expand Up @@ -2932,7 +2938,7 @@ function( $id ) {
$pending_stylesheet['stylesheet'] = implode( '', $stylesheet_parts );
$pending_stylesheet['original_size'] = $original_size;
$pending_stylesheet['included'] = null; // To be determined below.
$pending_stylesheet['size'] = strlen( $pending_stylesheet['stylesheet'] ); // @todo Should this use mb_strlen()?
$pending_stylesheet['size'] = strlen( $pending_stylesheet['stylesheet'] );
$pending_stylesheet['hash'] = md5( $pending_stylesheet['stylesheet'] );

// If this stylesheet is a duplicate of something that came before, mark the previous as not included automatically.
Expand Down

0 comments on commit ee9fbb5

Please sign in to comment.