diff --git a/inc/fields/class-shortcode-ui-field-post-select.php b/inc/fields/class-shortcode-ui-field-post-select.php index 0a62a26f..b2efc0a0 100644 --- a/inc/fields/class-shortcode-ui-field-post-select.php +++ b/inc/fields/class-shortcode-ui-field-post-select.php @@ -58,15 +58,15 @@ public function action_shortcode_ui_loaded_editor() { ?> - + labels->singular_name ); + $text .= sprintf( '- %1$s (%2$s)', get_post_field( 'post_name', $post_id ), $post_type_obj->labels->singular_name ); } + array_push( $response['items'], array( 'id' => $post_id, diff --git a/inc/fields/class-shortcode-ui-field-term-select.php b/inc/fields/class-shortcode-ui-field-term-select.php index a6cb13d3..8e064d86 100644 --- a/inc/fields/class-shortcode-ui-field-term-select.php +++ b/inc/fields/class-shortcode-ui-field-term-select.php @@ -67,15 +67,15 @@ public function action_shortcode_ui_loaded_editor() { ?> - + 'count', + ] ) ); if ( empty( $num_results ) ) { wp_send_json_error(); @@ -161,13 +164,29 @@ public function action_wp_ajax_shortcode_ui_term_field() { $args['offset'] = ( $page - 1 ) * $response['items_per_page']; } + $is_multiple_taxonomies = count( $args['taxonomy'] ) > 1; + $taxonomies = []; + if ( $is_multiple_taxonomies ) + { + foreach ( $args['taxonomy'] as $tax_slug ) + { + $taxonomies[ $tax_slug ] = get_taxonomy( $tax_slug ); + } + } + $results = get_terms( $args ); foreach ( $results as $result ) { + $text = html_entity_decode( $result->name ); + + if ( $is_multiple_taxonomies ) { + $text .= sprintf( ' - %1%s (%2$s)', $result->slug, $taxonomies[ $result->taxonomy ]->labels->singular_name ); + } + array_push( $response['items'], array( 'id' => $result->term_id, - 'text' => html_entity_decode( $result->name ), + 'text' => $text, ) ); }