Skip to content

Commit

Permalink
Merge pull request #340 from material-components/fse/lint
Browse files Browse the repository at this point in the history
Rename global vars
  • Loading branch information
PatelUtkarsh committed Apr 11, 2022
2 parents ac0d085 + aa53820 commit 3870322
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
42 changes: 21 additions & 21 deletions theme/template-parts/blocks/card-query.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,52 +43,52 @@
if ( empty( $block ) || ! isset( $block->context['postId'] ) ) {
return '';
}
$post_ID = $block->context['postId']; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
$post = get_post( $post_ID ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
$post_link = get_the_permalink( $post );
$post_content = wp_trim_words( get_the_excerpt( $post ), $content_length, ' […]' );
$post_id_card = $block->context['postId'];
$post_card = get_post( $post_id_card );
$post_link = get_the_permalink( $post_card );
$post_content = wp_trim_words( get_the_excerpt( $post_card ), $content_length, ' […]' );
?>
<div class="post-card__container">
<div id="<?php echo esc_attr( $post_ID ); ?>" <?php post_class( "mdc-card post-card $classes" ); ?>>
<div id="<?php echo esc_attr( $post_id_card ); ?>" <?php post_class( "mdc-card post-card $classes" ); ?>>
<a class="mdc-card__link" href="<?php echo esc_url( $post_link ); ?>">
<div class="mdc-card__primary-action post-card__primary-action">
<?php if ( has_post_thumbnail( $post ) && $show_featured_image ) : ?>
<?php if ( has_post_thumbnail( $post_card ) && $show_featured_image ) : ?>
<div class="mdc-card__media mdc-card__media--16-9 post-card__media">
<?php echo get_the_post_thumbnail( $post ); ?>
<?php echo get_the_post_thumbnail( $post_card ); ?>
</div>
<?php endif; ?>
<div class="post-card__primary">
<?php if ( $show_post_title ) : ?>
<?php if ( is_sticky( $post_ID ) ) : ?>
<?php if ( is_sticky( $post_id_card ) ) : ?>
<h2
class="post-card__title mdc-typography mdc-typography--headline6"
aria-label="
<?php
printf(
/* translators: Post title */
esc_attr__( 'Sticky post: %s', 'material-design-google' ),
esc_attr( get_the_title( $post ) )
esc_attr( get_the_title( $post_card ) )
);
?>
"
>
<i class="material-icons" aria-hidden="true">push_pin</i>
<?php echo esc_html( get_the_title( $post ) ); ?>
<?php echo esc_html( get_the_title( $post_card ) ); ?>
</h2>
<?php else : ?>
<h2 class="post-card__title mdc-typography mdc-typography--headline6">
<?php echo esc_html( get_the_title( $post ) ); ?>
<?php echo esc_html( get_the_title( $post_card ) ); ?>
</h2>
<?php endif; ?>
<?php endif; ?>

<?php if ( ! empty( $show_date ) ) : ?>
<time
class="post-card__subtitle mdc-typography mdc-typography--subtitle2"><?php echo esc_html( get_the_time( 'F j, Y', $post ) ); ?></time>
class="post-card__subtitle mdc-typography mdc-typography--subtitle2"><?php echo esc_html( get_the_time( 'F j, Y', $post_card ) ); ?></time>
<?php endif; ?>
</div>
</div>
<?php if ( ! empty( $show_excerpt ) && has_excerpt( $post ) ) : ?>
<?php if ( ! empty( $show_excerpt ) && has_excerpt( $post_card ) ) : ?>
<div
class="post-card__secondary mdc-typography mdc-typography--body2"><p><?php echo wp_kses_post( $post_content ); ?></p></div>
<?php endif; ?>
Expand All @@ -99,7 +99,7 @@ class="post-card__secondary mdc-typography mdc-typography--body2"><p><?php echo
<?php if ( ! empty( $show_author ) ) : ?>
<a
class="mdc-button mdc-card__action mdc-card__action--button"
href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID', $post->post_author ) ) ); ?>"
href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID', $post_card->post_author ) ) ); ?>"
aria-label="
<?php
printf(
Expand All @@ -108,19 +108,19 @@ class="mdc-button mdc-card__action mdc-card__action--button"
'Author: %s',
'material-design-google'
),
esc_attr( get_the_author_meta( 'display_name', $post->post_author ) )
esc_attr( get_the_author_meta( 'display_name', $post_card->post_author ) )
);
?>
"
>
<span class="mdc-button__ripple"></span>
<?php echo get_avatar( get_the_author_meta( 'ID', $post->post_author ), 18 ); ?>
<?php echo esc_html( apply_filters( 'the_author', get_the_author_meta( 'display_name', $post->post_author ) ) ); ?>
<?php echo get_avatar( get_the_author_meta( 'ID', $post_card->post_author ), 18 ); ?>
<?php echo esc_html( apply_filters( 'the_author', get_the_author_meta( 'display_name', $post_card->post_author ) ) ); ?>
</a>
<?php endif; ?>

<?php if ( ! empty( $show_comments ) && ( comments_open( $post_ID ) || ( 0 < get_comments_number( $post_ID ) ) ) ) : ?>
<a href="<?php echo esc_url( get_comments_link( $post_ID ) ); ?>" class="mdc-button mdc-card__action mdc-card__action--button">
<?php if ( ! empty( $show_comments ) && ( comments_open( $post_id_card ) || ( 0 < get_comments_number( $post_id_card ) ) ) ) : ?>
<a href="<?php echo esc_url( get_comments_link( $post_id_card ) ); ?>" class="mdc-button mdc-card__action mdc-card__action--button">
<span class="mdc-button__ripple"></span>
<i class="material-icons mdc-button__icon" aria-hidden="true">comment</i>
<?php
Expand All @@ -130,11 +130,11 @@ class="mdc-button mdc-card__action mdc-card__action--button"
_nx( // phpcs:disable
'One Comment', // phpcs:disable
'%s Comments',
get_comments_number( $post_ID ),
get_comments_number( $post_id_card ),
'comments title',
'material-design-google'
),
number_format_i18n( get_comments_number( $post_ID ) )
number_format_i18n( get_comments_number( $post_id_card ) )
)
);
?>
Expand Down
14 changes: 7 additions & 7 deletions theme/template-parts/blocks/image-card-query.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
* Image list layout
*/

$block = isset( $args['block'] ) ? $args['block'] : [];
$attributes = isset( $args['attributes'] ) ? $args['attributes'] : [];
$post_ID = $block->context['postId']; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
$post_link = get_the_permalink( $post );
if ( has_post_thumbnail( $post_ID ) ) {
$thumbnail = get_the_post_thumbnail_url( $post_ID );
$block = isset( $args['block'] ) ? $args['block'] : [];
$attributes = isset( $args['attributes'] ) ? $args['attributes'] : [];
$post_id_image_card = $block->context['postId'];
$post_link = get_the_permalink( $post_id_image_card );
if ( has_post_thumbnail( $post_id_image_card ) ) {
$thumbnail = get_the_post_thumbnail_url( $post_id_image_card );
} else {
$thumbnail = get_template_directory_uri() . '/assets/images/placeholder.png';
}
Expand All @@ -36,7 +36,7 @@
<a href="<?php echo esc_url( $post_link ); ?>">
<img class="mdc-image-list__image" src="<?php echo esc_url( $thumbnail ); ?>" alt="">
<div class="mdc-image-list__supporting">
<?php echo esc_html( get_the_title( $post_ID ) ); ?>
<?php echo esc_html( get_the_title( $post_id_image_card ) ); ?>
</div>
</a>
</div>

0 comments on commit 3870322

Please sign in to comment.