Skip to content

Commit

Permalink
feat: ⚡ added term meta
Browse files Browse the repository at this point in the history
  • Loading branch information
Elisa Losito committed Dec 10, 2020
1 parent 2d53452 commit 10a9099
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
14 changes: 14 additions & 0 deletions Malini/Decorators/WithTaxonomies.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ public function decorate(Post $post, array $options = []): Post
$terms = [];
foreach ($post_taxonomies as $taxonomy) {
$terms_by_taxonomy = get_the_terms($wp_post->ID, $taxonomy);
if (isset($options['options']) && in_array('add_term_meta', $options['options'])) {
$terms_by_taxonomy = array_map(
function($term) {
$term_meta = get_term_meta($term->term_id);
if (!empty($term_meta)) {
foreach ($term_meta as $key => $value) {
$term->{$key} = $value;
}
}
return $term;
},
$terms_by_taxonomy
);
}
if (is_array($terms_by_taxonomy)) {
if (isset($options['options']) && in_array('show_taxonomy_key', $options['options'])) {
$terms[$taxonomy] = $terms_by_taxonomy;
Expand Down
2 changes: 1 addition & 1 deletion Malini/Malini.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class Malini
{
public const VERSION = '1.1.1';
public const VERSION = '1.1.2';

protected static $instance = null;

Expand Down
2 changes: 1 addition & 1 deletion malini.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Plugin Name: Malini
* Plugin URI: https://github.com/caffeinalab/malini
* Description: Malini is an extensible content decoration and normalization library for WordPress entities.
* Version: 1.1.1
* Version: 1.1.2
* Author: Caffeina
* Author URI: https://caffeina.com
* Text Domain: malini
Expand Down

0 comments on commit 10a9099

Please sign in to comment.