Skip to content

Commit

Permalink
Merge pull request #168 from PRX/category-description
Browse files Browse the repository at this point in the history
Use category body field as description only when description is empty
  • Loading branch information
brandonhundt authored Mar 5, 2024
2 parents c43f8ca + 12bedb8 commit 1b11d12
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,13 @@ function pri_fgd2wp_pre_insert_taxonomy_term( $custom_field_values, $new_term_id
switch ( $custom_field_name ) {
case 'category-body':
if ( $custom_field_values && ! empty( $custom_field_values[0] ) ) {
$args['description'] = get_term_field( 'description', $new_term_id, 'category', 'raw' ) . ' ' . $custom_field_values[0]['field_body_value'];
wp_update_term( $new_term_id, 'category', $args );
$cat_description = get_term_field( 'description', $new_term_id, 'category', 'raw' );
$cat_description_is_valid = is_string( $cat_description ) && ! empty( trim( $cat_description ) );
if ( ! $cat_description_is_valid && ! empty( $custom_field_values[0]['field_body_value'] ) ) {
$args['description'] = $custom_field_values[0]['field_body_value'];
wp_update_term( $new_term_id, 'category', $args );
}

$custom_field_values = array();
}
break;
Expand Down

0 comments on commit 1b11d12

Please sign in to comment.