在Wordpress仪表板中,我希望能够添加关闭注释列的选项。我可以通过函数实现吗。php?我找到了一个插件,它可以做很多事情,但由于我需要这个小东西,我想让它轻一点。
我真的希望有人知道这一点。谢谢
要实现这一点,您应该过滤manage_edit-comments_columns
filter 删除核心注释列,并添加自定义注释列,使复选框显示在屏幕选项选项卡中。
对于注释的输出,您需要comment_content
从comment
用于中的显示输出manage_comments_custom_column
hook.
这是上述代码的一个示例:
add_filter( \'manage_edit-comments_columns\', function( $columns ) {
// Remove core comment column.
unset( $columns[\'comment\'] );
// Custom "Comment" column to add to screen options and output.
$custom_column = [ \'WPSE356451_add_comment\' => \'Comment\' ];
$columns = array_slice( $columns, 0, 2, true ) + $custom_column + array_slice( $columns, 2, NULL, true );
return $columns;
} );
add_action( \'manage_comments_custom_column\', function( $column, $comment_ID ) {
global $comment;
// Check for custom comment column and handle output.
if ( \'WPSE356451_add_comment\' === $column ) {
echo $comment->comment_content;
}
}, 10, 2 );
这里有一个gist for the code above, 和直接plugin .zip for download.我在谷歌上搜索了这个问题,似乎找不到解决方案。。。在评论中,我试图从评论日期/时间中删除超链接,当您将鼠标悬停在评论日期上方时,它会将超链接(示例/#comment-210)链接到以下评论。。。我可以在函数中输入什么。php删除链接,我想保留日期/时间文本。。