Changeset 2816
- Timestamp:
- 03/25/2016 06:28:58 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/template-tags.php
r2766 r2816 742 742 743 743 /** 744 * Retrieve deprecated flag744 * Retrieve deprecated notice. 745 745 * 746 746 * @param int $post_id … … 749 749 */ 750 750 function get_deprecated( $post_id = null ) { 751 if ( empty( $post_id )) {751 if ( ! $post_id ) { 752 752 $post_id = get_the_ID(); 753 753 } … … 757 757 $tags = get_post_meta( $post_id, '_wp-parser_tags', true ); 758 758 $deprecated = wp_filter_object_list( $tags, array( 'name' => 'deprecated' ) ); 759 760 if ( empty( $deprecated ) ) { 759 $deprecated = array_shift( $deprecated ); 760 761 if ( ! $deprecated ) { 761 762 return ''; 762 763 } 764 765 $deprecation_info = ''; 763 766 764 767 $referral = wp_filter_object_list( $tags, array( 'name' => 'see' ) ); 765 768 $referral = array_shift( $referral ); 766 769 770 // Construct message pointing visitor to preferred alternative, as provided 771 // via @see, if present. 767 772 if ( ! empty( $referral['refers'] ) ) { 768 773 $refers = sanitize_text_field( $referral['refers'] ); 769 774 770 if ( ! empty( $refers ) ) { 771 /* translators: 1: Linked internal element name */ 772 $alternative_string = sprintf( __( ' Use %s instead.', 'wporg' ), \DevHub_Formatting::link_internal_element( $refers ) ); 773 } 774 } else { 775 $alternative_string = ''; 776 } 777 778 /* translators: 1: String for alternative function (if one exists) */ 775 if ( $refers ) { 776 // For some reason, the parser may have dropped the parentheses, so add them. 777 if ( in_array( $type, array( 'function', 'method' ) ) && false === strpos( $refers, '()' ) ) { 778 $refers .= '()'; 779 } 780 /* translators: %s: Linked internal element name */ 781 $deprecation_info = ' ' . sprintf( __( 'Use %s instead.', 'wporg' ), \DevHub_Formatting::link_internal_element( $refers ) ); 782 } 783 } 784 785 // If no alternative resource was referenced, use the deprecation string, if 786 // present. 787 if ( ! $deprecation_info && ! empty( $deprecated['content'] ) ) { 788 $deprecation_info = ' ' . sanitize_text_field ( $deprecated['content'] ); 789 // Many deprecation strings use the syntax "Use function()" instead of the 790 // preferred "Use function() instead." Add it in if missing. 791 if ( false === strpos( $deprecation_info, 'instead' ) ) { 792 $deprecation_info .= ' instead.'; // Not making translatable since rest of string is not translatable. 793 } 794 } 795 796 /* translators: 1: parsed post post, 2: String for alternative function (if one exists) */ 779 797 $contents = sprintf( __( 'This %1$s has been deprecated.%2$s', 'wporg' ), 780 798 $type, 781 $ alternative_string799 $deprecation_info 782 800 ); 783 801
Note: See TracChangeset
for help on using the changeset viewer.