508 | | // All public taxonomies |
509 | | $taxonomies = get_taxonomies( array( 'public' => true ) ); |
510 | | foreach ( (array) $taxonomies as $taxonomy ) { |
511 | | if ( is_object_in_taxonomy( $post->post_type, $taxonomy ) ) { |
512 | | foreach ( (array) get_the_terms( $post->ID, $taxonomy ) as $term ) { |
513 | | if ( empty( $term->slug ) ) { |
514 | | continue; |
515 | | } |
| 508 | /** |
| 509 | * Filters the showing of taxonomy term classes. |
| 510 | * |
| 511 | * @since 4.7.0 |
| 512 | * |
| 513 | * @param bool $status Default to show taxonomy term classes. |
| 514 | * @param WP_Post $post Post Object. |
| 515 | */ |
| 516 | if ( apply_filters( 'get_post_class_taxonomy', true, $post ) ) { |
| 517 | // All public taxonomies with show_term_classes turned on. |
| 518 | $taxonomies = get_taxonomies( array( |
| 519 | 'public' => true, |
| 520 | 'show_term_classes' => true, |
| 521 | ) ); |
517 | | $term_class = sanitize_html_class( $term->slug, $term->term_id ); |
518 | | if ( is_numeric( $term_class ) || ! trim( $term_class, '-' ) ) { |
519 | | $term_class = $term->term_id; |
520 | | } |
| 523 | foreach ( (array) $taxonomies as $taxonomy ) { |
| 524 | if ( is_object_in_taxonomy( $post->post_type, $taxonomy ) ) { |
| 525 | foreach ( (array) get_the_terms( $post->ID, $taxonomy ) as $term ) { |
| 526 | if ( empty( $term->slug ) ) { |
| 527 | continue; |
| 528 | } |
522 | | // 'post_tag' uses the 'tag' prefix for backward compatibility. |
523 | | if ( 'post_tag' == $taxonomy ) { |
524 | | $classes[] = 'tag-' . $term_class; |
525 | | } else { |
526 | | $classes[] = sanitize_html_class( $taxonomy . '-' . $term_class, $taxonomy . '-' . $term->term_id ); |
| 530 | $term_class = sanitize_html_class( $term->slug, $term->term_id ); |
| 531 | if ( is_numeric( $term_class ) || ! trim( $term_class, '-' ) ) { |
| 532 | $term_class = $term->term_id; |
| 533 | } |
| 534 | |
| 535 | // 'post_tag' uses the 'tag' prefix for backward compatibility. |
| 536 | if ( 'post_tag' == $taxonomy ) { |
| 537 | $classes[] = 'tag-' . $term_class; |
| 538 | } else { |
| 539 | $classes[] = sanitize_html_class( $taxonomy . '-' . $term_class, $taxonomy . '-' . $term->term_id ); |
| 540 | } |