Make WordPress Core

Ticket #34362: 34362.diff

File 34362.diff, 2.0 KB (added by jgrodel, 10 years ago)
  • src/wp-includes/comment-template.php

    diff --git src/wp-includes/comment-template.php src/wp-includes/comment-template.php
    index ada53c8..dd6a627 100644
    function get_comment_type( $comment_ID = 0 ) { 
    10291029}
    10301030
    10311031/**
    1032  * Display the comment type of the current comment.
     1032 * Generates a display name for the comment type of the current comment.
    10331033 *
    10341034 * @since 0.71
    10351035 *
    10361036 * @param string $commenttxt   Optional. String to display for comment type. Default false.
    10371037 * @param string $trackbacktxt Optional. String to display for trackback type. Default false.
    10381038 * @param string $pingbacktxt  Optional. String to display for pingback type. Default false.
     1039 * @param bool   $echo         Optional. Whether to echo or return the output. Default true.
     1040 * @return string|null         Null when echo is truthy (default), a string otherwise
    10391041 */
    1040 function comment_type( $commenttxt = false, $trackbacktxt = false, $pingbacktxt = false ) {
    1041         if ( false === $commenttxt ) $commenttxt = _x( 'Comment', 'noun' );
    1042         if ( false === $trackbacktxt ) $trackbacktxt = __( 'Trackback' );
    1043         if ( false === $pingbacktxt ) $pingbacktxt = __( 'Pingback' );
     1042function comment_type(
     1043        $commenttxt = false,
     1044        $trackbacktxt = false,
     1045        $pingbacktxt = false,
     1046        $echo = true
     1047) {
     1048
    10441049        $type = get_comment_type();
    10451050        switch( $type ) {
    10461051                case 'trackback' :
    1047                         echo $trackbacktxt;
     1052                        if ( false === $trackbacktxt ) {
     1053                                $display_name = __( 'Trackback' );
     1054                        } else {
     1055                                $display_name = $trackbacktxt;
     1056                        }
    10481057                        break;
    10491058                case 'pingback' :
    1050                         echo $pingbacktxt;
     1059                        if ( false === $pingbacktxt ) {
     1060                                $display_name = __( 'Pingback' );
     1061                        } else {
     1062                                $display_name = $pingbacktxt;
     1063                        }
    10511064                        break;
    10521065                default :
    1053                         echo $commenttxt;
     1066                        if ( false === $commenttxt ) {
     1067                                $display_name = _x( 'Comment', 'noun' );
     1068                        } else {
     1069                                $display_name = $commenttxt;
     1070                        }
     1071        }
     1072
     1073        $display_name = apply_filters( 'comment_type_display_name', $display_name );
     1074
     1075        if ($echo) {
     1076                echo $display_name;
     1077        } else {
     1078                return $display_name;
    10541079        }
    10551080}
    10561081