Making WordPress.org


Ignore:
Timestamp:
12/11/2014 11:29:10 PM (12 years ago)
Author:
coffee2code
Message:

developer.wordpress.org: introduce get_summary() and use it.

Abstracts the fact the summary (aka short description) is stored in post_excerpt, primarily to force display of special characters.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/template-tags.php

    r1023 r1036  
    991991
    992992        /**
     993         * Gets the summary.
     994         *
     995         * The summary (aka short description) is stored in the 'post_excerpt' field.
     996         *
     997         * @param  null|WP_Post Optional. The post. Default null.
     998         * @return string
     999         */
     1000        function get_summary( $post = null ) {
     1001                $post = get_post( $post );
     1002
     1003                $summary = $post->post_excerpt;
     1004
     1005                if ( $summary ) {
     1006                        add_filter( 'the_excerpt', 'htmlentities', 9 ); // Run before wpautop
     1007                        $summary = apply_filters( 'the_excerpt', apply_filters( 'get_the_excerpt', $summary ) );
     1008                        remove_filter( 'the_excerpt', 'htmlentities', 9 );
     1009                }
     1010
     1011                return $summary;
     1012        }
     1013
     1014        /**
    9931015         * Gets the long description.
    9941016         *
Note: See TracChangeset for help on using the changeset viewer.