WordPress.org

Making WordPress.org

Changeset 2162


Ignore:
Timestamp:
12/03/2015 09:33:54 PM (4 years ago)
Author:
ocean90
Message:

Handbook/Glossary: Apply the the_content filter later and wrap the entry with a div.

Prevents breaking the HTML markup if the last item is not a <p></p> element.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/handbook/inc/glossary.php

    r16 r2162  
    8585        $glossary = new WP_Query( array( 'post_status' => 'publish', 'post_type' => 'glossary', 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC' ) );
    8686
    87         $content = '<style> .glossary-entry { margin-top: -50px; padding-top: 50px; } </style>';
     87        $content = "<style> .glossary-entry { margin-top: -50px; padding-top: 50px; } </style>\n";
    8888        foreach ( $glossary->posts as $post ) {
    89             $entry = trim( apply_filters( 'the_content', '<strong>' . apply_filters( 'the_title', $post->post_title ) . ':</strong> ' . $post->post_content ) );
     89            $entry = '<strong>' . apply_filters( 'the_title', $post->post_title ) . ':</strong> ' . $post->post_content;
     90
    9091            $edit = get_edit_post_link( $post );
    91             if ( $edit )
    92                     $edit = ' - <a href="' . $edit . '">edit</a>';
    93             // if ( '<p>' === substr( $entry, 0, 3 ) && '</p>' === substr( $entry, -4 ) )
    94             $entry = '<p class="glossary-entry" id="' . $post->post_name . '">' . substr( substr( $entry, 3 ), 0, -4 ) . ' <a href="' . get_permalink( $post ) . '">#</a>' . $edit . '</p>';
     92            if ( $edit ) {
     93                $edit = ' - <a href="' . esc_url( $edit ) . '">edit</a>';
     94            }
     95            $entry .= ' <a href="' . esc_url( get_permalink( $post ) ) . '">#</a>' . $edit;
     96
     97            $entry = apply_filters( 'the_content', $entry );
     98            $entry = '<div class="glossary-entry" id="' . esc_attr( $post->post_name ) . '">' . $entry . '</div>' . "\n";
    9599
    96100            $content .= $entry;
Note: See TracChangeset for help on using the changeset viewer.