diff --git a/CHANGELOG.md b/CHANGELOG.md index 9def8fd7..ce48c8c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to `WP Curate` will be documented in this file. +## 1.4.0 - 2023-10-30 + +- Bug fix: prevents error if `termRelations` attribute is not set. + ## 1.3.0 - 2023-10-26 - Only show the blocks and register the meta on supported post types. diff --git a/src/class-plugin-curated-posts.php b/src/class-plugin-curated-posts.php index 3b6a9d78..f2cb9e5d 100644 --- a/src/class-plugin-curated-posts.php +++ b/src/class-plugin-curated-posts.php @@ -56,10 +56,11 @@ public function with_query_context( array $context, array $attributes, WP_Block_ foreach ( $attributes['terms'] as $taxonomy => $terms ) { if ( taxonomy_exists( $taxonomy ) && is_array( $terms ) && count( $terms ) > 0 ) { + $operator = isset( $attributes['termRelations'] ) && is_array( $attributes['termRelations'] ) ? $attributes['termRelations'][ $taxonomy ] ?? 'AND' : 'AND'; $args['tax_query'][] = [ 'taxonomy' => $taxonomy, 'terms' => array_column( $terms, 'id' ), - 'operator' => is_array( $attributes['termRelations'] ) ? $attributes['termRelations'][ $taxonomy ] ?? 'AND' : 'AND', + 'operator' => $operator, ]; } } diff --git a/wp-curate.php b/wp-curate.php index f72c32ea..b2958a35 100644 --- a/wp-curate.php +++ b/wp-curate.php @@ -3,7 +3,7 @@ * Plugin Name: WP Curate * Plugin URI: https://github.com/alleyinteractive/wp-curate * Description: Plugin to curate homepages and other landing pages - * Version: 1.3.0 + * Version: 1.4.0 * Author: Alley Interactive * Author URI: https://github.com/alleyinteractive/wp-curate * Requires at least: 6.3