From 3ce926cb51aa3a79fa23f80b7829f66af430fbdc Mon Sep 17 00:00:00 2001 From: prcdevgitbot Date: Wed, 20 Mar 2024 15:39:09 +0000 Subject: [PATCH] See https://github.com/pewresearch/pewresearch-org/commit/f444a3218edc0c1a29940f3509f43fa4babe1daf from refs/heads/release/5.0 --- blocks/logo/src/edit.jsx | 6 +++--- blocks/post-taxonomy-terms/post-taxonomy-terms.php | 12 ++++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/blocks/logo/src/edit.jsx b/blocks/logo/src/edit.jsx index 30e4938eb..ab3d0833c 100644 --- a/blocks/logo/src/edit.jsx +++ b/blocks/logo/src/edit.jsx @@ -48,11 +48,11 @@ function LogoInner({ onLoad, className, width }) { const svgLoad = (svg) => { const svgEl = svg(); - const [width, height] = svgEl.props.viewBox.split(' ').slice(2); + const [w, h] = svgEl.props.viewBox.split(' ').slice(2); - console.log('svgEl', svgEl, svgEl.props.viewBox, width, height); + console.log('svgEl', svgEl, svgEl.props.viewBox, w, h); - onLoad(width, height); + onLoad(w, h); }; switch (selectedStyle[1]) { diff --git a/blocks/post-taxonomy-terms/post-taxonomy-terms.php b/blocks/post-taxonomy-terms/post-taxonomy-terms.php index 9fa2c65d3..6695529ac 100644 --- a/blocks/post-taxonomy-terms/post-taxonomy-terms.php +++ b/blocks/post-taxonomy-terms/post-taxonomy-terms.php @@ -55,8 +55,16 @@ public function render_block_callback( $attributes, $content, $block ) { )), 'style' => array_key_exists('separator', $attributes) ? '--separator: "' . $attributes['separator'] . '"' : null, )); - - $post_terms = wp_get_post_terms( get_the_ID(), $taxonomy, array( 'number' => $per_page ) ); + $post_id = get_the_ID(); + $parent_id = wp_get_post_parent_id($post_id); + $post_terms = wp_get_post_terms( $post_id, $taxonomy, array( 'number' => $per_page ) ); + // If this is a category taxonomy block we need to check if the only term being returned is "uncategorized" and if so, we need to return an empty array so that the block will look for the parent post's terms, if available. + if ( 'category' === $taxonomy && 1 === count($post_terms) && 'uncategorized' === $post_terms[0]->slug ) { + $post_terms = array(); + } + if ( 0 !== $parent_id && empty($post_terms) ) { + $post_terms = wp_get_post_terms( $parent_id, $taxonomy, array( 'number' => $per_page ) ); + } $markup = ''; if ( !empty($post_terms) && !is_wp_error($post_terms) ) { $markup .= '