Making WordPress.org


Ignore:
Timestamp:
01/30/2016 09:37:19 PM (8 years ago)
Author:
drewapicture
Message:

DevHub: Like with private access messages, use callout box styles for the deprecated message container (if available).

If the Handbook plugin is unavailable, fall back to basic theme-support styles.

See #1551.

File:
1 edited

Legend:

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

    r2431 r2435  
    834834        $type           = array_pop( $types );
    835835        $tags           = get_post_meta( $post_id, '_wp-parser_tags', true );
    836         $all_deprecated = wp_filter_object_list( $tags, array( 'name' => 'deprecated' ) );
    837 
    838         if ( empty( $all_deprecated ) ) {
     836        $deprecated = wp_filter_object_list( $tags, array( 'name' => 'deprecated' ) );
     837
     838        if ( empty( $deprecated ) ) {
    839839            return '';
    840840        }
    841841
    842         $deprecated  = array_shift( $all_deprecated );
    843         // Multi-@deprecated may have been defined, with the second actually having the deprecation text.
    844         if ( empty( $deprecated['content'] ) ) {
    845             $deprecated  = array_shift( $all_deprecated );
    846         }
    847         $description = empty( $deprecated['content'] ) ? '' : esc_html( $deprecated['content'] );
    848 
    849         return "<div class='deprecated'>"
    850             . wp_kses_post( sprintf( __( 'Warning: This %s has been deprecated. %s', 'wporg' ), $type, $description ) )
    851             . '</div>';
     842        $referral = array_shift( wp_filter_object_list( $tags, array( 'name' => 'see' ) ) );
     843
     844        if ( ! empty( $referral['refers'] ) ) {
     845            $refers = sanitize_text_field( $referral['refers'] );
     846
     847            if ( ! empty( $refers ) ) {
     848                /* translators: 1: Linked internal element name */
     849                $alternative_string = sprintf( __( ' Use %s instead.', 'wporg' ), \DevHub_Formatting::link_internal_element( $refers ) );
     850            }
     851        } else {
     852            $alternative_string = '';
     853        }
     854
     855        /* translators: 1: String for alternative function (if one exists) */
     856        $contents = sprintf( __( 'This %1$s has been deprecated.%2$s', 'wporg' ),
     857            $type,
     858            $alternative_string
     859        );
     860
     861        // Use the 'warning' callout box if it's available. Otherwise, fall back to a theme-supported div class.
     862        if ( class_exists( 'WPorg_Handbook_Callout_Boxes' ) ) {
     863            $callout = new \WPorg_Handbook_Callout_Boxes();
     864            $message = $callout->warning_shortcode( array(), $contents );
     865        } else {
     866            $message  = '<div class="deprecated">';
     867            /** This filter is documented in wp-includes/post-template.php */
     868            $message .= apply_filters( 'the_content', $contents );
     869            $message .= '</div>';
     870        }
     871
     872        return $message;
    852873    }
    853874
     
    13931414        /* translators: 1: String for alternative function (if one exists) */
    13941415        $contents = sprintf( __( 'This function&#8217;s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.%s', 'wporg' ),
    1395                 $alternative_string
     1416            $alternative_string
    13961417        );
    13971418
     
    14021423        } else {
    14031424            $message  = '<div class="private-access">';
     1425            /** This filter is documented in wp-includes/post-template.php */
    14041426            $message .= apply_filters( 'the_content', $contents );
    14051427            $message .= '</div>';
Note: See TracChangeset for help on using the changeset viewer.