Making WordPress.org


Ignore:
Timestamp:
10/28/2014 08:45:54 PM (11 years ago)
Author:
coffee2code
Message:

Code Reference: display prominent callout above content to flag deprecated items when applicable

fixes #449.
props nicolealleyinteractivecom.

File:
1 edited

Legend:

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

    r938 r943  
    720720
    721721    /**
     722     * Retrieve deprecated flag
     723     *
     724     * @param int $post_id
     725     *
     726     * @return string
     727     */
     728    function get_deprecated( $post_id = null ) {
     729        if ( empty( $post_id ) ) {
     730            $post_id = get_the_ID();
     731        }
     732
     733        $types          = explode( '-', get_post_type( $post_id ) );
     734        $type           = array_pop( $types );
     735        $tags           = get_post_meta( $post_id, '_wp-parser_tags', true );
     736        $all_deprecated = wp_filter_object_list( $tags, array( 'name' => 'deprecated' ) );
     737
     738        if ( empty( $all_deprecated ) ) {
     739            return '';
     740        }
     741
     742        $deprecated  = array_shift( $all_deprecated );
     743        // Multi-@deprecated may have been defined, with the second actually having the deprecation text.
     744        if ( empty( $deprecated['content'] ) ) {
     745            $deprecated  = array_shift( $all_deprecated );
     746        }
     747        $description = empty( $deprecated['content'] ) ? '' : esc_html( $deprecated['content'] );
     748
     749        return "<div class='deprecated'>"
     750            . wp_kses_post( sprintf( __( 'Warning: This %s has been deprecated. %s', 'wporg' ), $type, $description ) )
     751            . '</div>';
     752    }
     753
     754    /**
    722755     * Retrieve URL to source file archive.
    723756     *
Note: See TracChangeset for help on using the changeset viewer.