Skip to content

Commit

Permalink
Merge pull request #87 from alleyinteractive/fix/undefined-term-relat…
Browse files Browse the repository at this point in the history
…ions

Fix: Undefined Attribute Key Error
  • Loading branch information
efuller authored Oct 30, 2023
2 parents 47460e3 + c38a911 commit 816e53a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion src/class-plugin-curated-posts.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
];
}
}
Expand Down
2 changes: 1 addition & 1 deletion wp-curate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 816e53a

Please sign in to comment.