Making WordPress.org

Ticket #1551: 1551.diff

File 1551.diff, 3.9 KB (added by DrewAPicture, 9 years ago)
  • inc/template-tags.php

     
    833833                $types          = explode( '-', get_post_type( $post_id ) );
    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' ) );
     836                $deprecated = wp_filter_object_list( $tags, array( 'name' => 'deprecated' ) );
    837837
    838                 if ( empty( $all_deprecated ) ) {
     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 );
     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 = '';
    846853                }
    847                 $description = empty( $deprecated['content'] ) ? '' : esc_html( $deprecated['content'] );
    848854
    849                 return "<div class='deprecated'>"
    850                         . wp_kses_post( sprintf( __( 'Warning: This %s has been deprecated. %s', 'wporg' ), $type, $description ) )
    851                         . '</div>';
     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                        $message .= '<p>' . $contents . '</p>';
     868                        $message .= '</div>';
     869                }
     870
     871                return $message;
    852872        }
    853873
    854874        /**
     
    13921412
    13931413                /* translators: 1: String for alternative function (if one exists) */
    13941414                $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
     1415                        $alternative_string
    13961416                );
    13971417
    13981418                // Use the 'alert' callout box if it's available. Otherwise, fall back to a theme-supported div class.
  • scss/main.scss

     
    10101010                        padding: 20px;
    10111011                }
    10121012                .deprecated {
    1013                         background-color: #be2423;
    1014                         border: 1px solid #a4322f;
     1013                        background-color: #fbeaea;
     1014                        border: 1px solid #dc3232;
    10151015                        padding: 20px;
    1016                         color: #ffffff;
    10171016                }
    10181017                .deprecated-method {
    10191018                        color: #be2423;
  • stylesheets/main.css

     
    12131213  padding: 20px;
    12141214}
    12151215.devhub-wrap .wp-parser-class .deprecated, .devhub-wrap .wp-parser-function .deprecated, .devhub-wrap .wp-parser-hook .deprecated, .devhub-wrap .wp-parser-method .deprecated {
    1216   background-color: #be2423;
    1217   border: 1px solid #a4322f;
     1216  background-color: #fbeaea;
     1217  border: 1px solid #dc3232;
    12181218  padding: 20px;
    1219   color: #ffffff;
    12201219}
    12211220.devhub-wrap .wp-parser-class .deprecated-method, .devhub-wrap .wp-parser-function .deprecated-method, .devhub-wrap .wp-parser-hook .deprecated-method, .devhub-wrap .wp-parser-method .deprecated-method {
    12221221  color: #be2423;