以下是将垃圾计数修改为999的三种不同方法,例如:
方法#1views_edit-comments
过滤器:
add_filter( \'views_edit-comments\', function( $views )
{
$trash_count = 999; // <-- Adjust this count
// Override the \'trash\' link:
$views[\'trash\'] = sprintf(
"<a href=%s>%s <span class=\'count\'>(<span class=\'trash-count\'>%d</span>)</span></a>",
esc_url( admin_url( \'edit-comments.php?comment_status=trash\') ),
__( \'Trash\' ),
$trash_count
);
return $views;
} );
方法2
comment_status_links
过滤器:
add_filter( \'comment_status_links\', function( $status_links )
{
$trash_count = 999; // <-- Adjust this count
// Override the \'trash\' link:
$status_links[\'trash\'] = sprintf(
"<a href=%s>%s <span class=\'count\'>(<span class=\'trash-count\'>%d</span>)</span></a>",
esc_url( admin_url( \'edit-comments.php?comment_status=trash\') ),
__( \'Trash\' ),
$trash_count
);
return $status_links;
} );
方法3这里我们针对
edit-comments.php
屏幕并调整
wp_count_comments()
功能:
add_filter( \'load-edit-comments.php\', function()
{
add_filter( \'wp_count_comments\', function( $stats, $post_id )
{
static $instance = 0;
if( 2 === $instance++ )
{
$stats = wp_count_comments( $stats, $post_id );
// Set the trash count to 999
if ( is_object( $stats ) && property_exists( $stats, \'trash\' ) )
$stats->trash = 999; // <-- Adjust this count
}
return $stats;
}, 10, 2 );
} );
类似地,对于待定和垃圾邮件计数。