Ticket #1926: 1926.diff
File 1926.diff, 3.5 KB (added by , 9 years ago) |
---|
-
inc/template-tags.php
765 765 // Since data stored in meta. 766 766 $since_meta = get_post_meta( $post_id, '_wp-parser_tags', true ); 767 767 768 $since_tags = wp_filter_object_list( $since_meta, array( 'name' => 'since' ) ); 769 $deprecated = wp_filter_object_list( $since_meta, array( 'name' => 'deprecated' ) ); 770 771 // If deprecated, add the since version to the term and meta lists. 772 if ( ! empty( $deprecated ) ) { 773 $deprecated = array_shift( $deprecated ); 774 775 if ( $term = get_term_by( 'name', $deprecated['content'], 'wp-parser-since' ) ) { 776 // Terms. 777 $since_terms[] = $term; 778 779 // Meta. 780 $since_tags[] = $deprecated; 781 } 782 } 783 768 784 $data = array(); 769 785 770 786 // Pair the term data with meta data. 771 787 foreach ( $since_terms as $since_term ) { 772 foreach ( $since_ metaas $meta ) {788 foreach ( $since_tags as $meta ) { 773 789 if ( is_array( $meta ) && $since_term->name == $meta['content'] ) { 774 $description = empty( $meta['description'] ) ? '' : '<span class="since-description">' . \DevHub_Formatting::format_param_description( $meta['description'] ) . '</span>'; 790 // Handle deprecation notice if deprecated. 791 if ( empty( $meta['description'] ) ) { 792 if ( ! empty( $deprecated ) ) { 793 $description = get_deprecated( $post_id, false ); 794 } else { 795 $description = ''; 796 } 797 } else { 798 $description = '<span class="since-description">' . \DevHub_Formatting::format_param_description( $meta['description'] ) . '</span>'; 799 } 775 800 776 801 $data[ $since_term->name ] = array( 777 802 'version' => $since_term->name, … … 781 806 } 782 807 } 783 808 } 809 784 810 return $data; 785 811 } 786 812 … … 819 845 /** 820 846 * Retrieve deprecated notice. 821 847 * 822 * @param int $post_id 823 * 824 * @return string 848 * @param int $post_id Optional. Post ID. Default is the ID of the global `$post`. 849 * @param bool $formatted Optional. Whether to format the deprecation message. Default true. 850 * @return string Deprecated notice. If `$formatted` is true, will be output in markup 851 * for a callout box. 825 852 */ 826 function get_deprecated( $post_id = null ) {853 function get_deprecated( $post_id = null, $formatted = true ) { 827 854 if ( ! $post_id ) { 828 855 $post_id = get_the_ID(); 829 856 } … … 875 902 $deprecation_info 876 903 ); 877 904 878 // Use the 'warning' callout box if it's available. Otherwise, fall back to a theme-supported div class. 879 if ( class_exists( 'WPorg_Handbook_Callout_Boxes' ) ) { 880 $callout = new \WPorg_Handbook_Callout_Boxes(); 881 $message = $callout->warning_shortcode( array(), $contents ); 905 if ( true === $formatted ) { 906 // Use the 'warning' callout box if it's available. Otherwise, fall back to a theme-supported div class. 907 if ( class_exists( 'WPorg_Handbook_Callout_Boxes' ) ) { 908 $callout = new \WPorg_Handbook_Callout_Boxes(); 909 $message = $callout->warning_shortcode( array(), $contents ); 910 } else { 911 $message = '<div class="deprecated">'; 912 /** This filter is documented in wp-includes/post-template.php */ 913 $message .= apply_filters( 'the_content', $contents ); 914 $message .= '</div>'; 915 } 882 916 } else { 883 $message = '<div class="deprecated">'; 884 /** This filter is documented in wp-includes/post-template.php */ 885 $message .= apply_filters( 'the_content', $contents ); 886 $message .= '</div>'; 917 $message = $contents; 887 918 } 888 919 889 920 return $message;