comment_type()
最后更新于:2021-11-25 21:28:46
comment_type( string|false$commenttxt=false, string|false$trackbacktxt=false, string|false$pingbacktxt=false)Displays the comment type of the current comment.
参数
- $commenttxt
-
(string|false) (Optional) String to display for comment type.
Default value: false
- $trackbacktxt
-
(string|false) (Optional) String to display for trackback type.
Default value: false
- $pingbacktxt
-
(string|false) (Optional) String to display for pingback type.
Default value: false
源文件
文件: gc-includes/comment-template.php
function comment_type( $commenttxt = false, $trackbacktxt = false, $pingbacktxt = false ) {
if ( false === $commenttxt ) {
$commenttxt = _x( 'Comment', 'noun' );
}
if ( false === $trackbacktxt ) {
$trackbacktxt = __( 'Trackback' );
}
if ( false === $pingbacktxt ) {
$pingbacktxt = __( 'Pingback' );
}
$type = get_comment_type();
switch ( $type ) {
case 'trackback':
echo $trackbacktxt;
break;
case 'pingback':
echo $pingbacktxt;
break;
default:
echo $commenttxt;
}
}