Make WordPress Core

Ticket #30783: 30783.diff

File 30783.diff, 2.8 KB (added by dshanske, 9 years ago)

Add Microformats2 support.

  • pluggable.php

     
    22922292        if ( ! $args['found_avatar'] || $args['force_default'] ) {
    22932293                $class[] = 'avatar-default';
    22942294        }
     2295        if ( current_theme_suports( 'microformats2' ) ) {
     2296                $class[] = 'u-photo';
     2297        }
    22952298
    22962299        if ( $args['class'] ) {
    22972300                if ( is_array( $args['class'] ) ) {
  • post-template.php

     
    466466                        $classes[] = 'status-sticky';
    467467                }
    468468        }
     469        // Backward compatibility for old behavior.
     470        if ( ! current_theme_supports( 'microformats2' ) ) {
     471                // hentry for hAtom compliance
     472                $classes[] = 'hentry';
     473        }
     474        else {
     475                // Add Microformats 2 on pages that contain multiple hentry/h-entrys.
     476                if ( ! is_single() ) {
     477                        $classes[] = 'h-entry';
     478                        $classes[] = 'hentry';
     479                }
     480        }
    469481
    470         // hentry for hAtom compliance
    471         $classes[] = 'hentry';
    472 
    473482        // All public taxonomies
    474483        $taxonomies = get_taxonomies( array( 'public' => true ) );
    475484        foreach ( (array) $taxonomies as $taxonomy ) {
     
    563572        if ( is_single() ) {
    564573                $post_id = $wp_query->get_queried_object_id();
    565574                $post = $wp_query->get_queried_object();
    566 
    567575                $classes[] = 'single';
    568576                if ( isset( $post->post_type ) ) {
    569577                        $classes[] = 'single-' . sanitize_html_class($post->post_type, $post_id);
     
    705713                elseif ( is_post_type_archive() )
    706714                        $classes[] = 'post-type-paged-' . $page;
    707715        }
     716        // Support Microformats2 behavior.
     717        if ( current_theme_supports( 'microformats2' ) ) {
     718                if ( is_single() ) {
     719                        $classes[] = 'h-entry';
     720                        $classes[] = 'hentry';
     721                }
     722                else {
     723                        $classes[] = 'h-feed';
     724                        $classes[] = 'hfeed';
     725    }
     726        }
    708727
    709728        if ( ! empty( $class ) ) {
    710729                if ( !is_array( $class ) )
  • comment-template.php

     
    209209                $return = $author;
    210210        else
    211211                $return = "<a href='$url' rel='external nofollow' class='url'>$author</a>";
     212                if ( current_theme_supports( 'microformats2' ) ) {
     213                        $return = "<a href='$url' rel='external nofollow' class='url u-url'>$author</a>";
     214                }
    212215
    213216        /**
    214217         * Filter the comment author's link for display.
     
    428431        // Get the comment type (comment, trackback),
    429432        $classes[] = ( empty( $comment->comment_type ) ) ? 'comment' : $comment->comment_type;
    430433
     434        // Microformats2 Support.
     435        if ( current_theme_supports( 'microformats2' ) ) {
     436                $classes[] = 'p-comment';
     437                $classes[] = 'h-entry';
     438        }
     439
    431440        // Add classes for comment authors that are registered users.
    432441        if ( $comment->user_id > 0 && $user = get_userdata( $comment->user_id ) ) {
    433442                $classes[] = 'byuser';