扩展WordPress 3.8站点活动仪表板小工具以包含更多评论

时间:2013-12-19 作者:Dave Warfel

新的Site Activity dashboard小部件默认显示5条注释。我想展示10个。

我可以看到核心的代码/wp-admin/includes/dashboard.php 调用函数的位置wp_dashboard_site_activity, 和用途wp_dashboard_recent_comments ( $total_items = 5 ). 但我不知道该如何连接到这个函数来更新它。

我知道如何创建自定义功能插件&;编辑functions.php, 我只是不确定要使用的语法和/或挂钩。

非常感谢您的帮助。谢谢

1 个回复
最合适的回答,由SO网友:Sven 整理而成

似乎还没有针对此的过滤器,但您可以取消注册默认活动小部件,并注册(在您的函数中,或者更好地在Dave Warfel推荐的插件中)具有自定义设置的类似活动小部件:

// unregister the default activity widget
add_action(\'wp_dashboard_setup\', \'remove_dashboard_widgets\' );
function remove_dashboard_widgets() {

    global $wp_meta_boxes;
    unset($wp_meta_boxes[\'dashboard\'][\'normal\'][\'core\'][\'dashboard_activity\']);

}

// register your custom activity widget
add_action(\'wp_dashboard_setup\', \'add_custom_dashboard_activity\' );
function add_custom_dashboard_activity() {
    wp_add_dashboard_widget(\'custom_dashboard_activity\', \'Activity\', \'custom_wp_dashboard_site_activity\');
}

function custom_wp_dashboard_site_activity() {

    echo \'<div id="activity-widget">\';

    $future_posts = wp_dashboard_recent_posts( array(
        \'display\' => 2,
        \'max\'     => 5,
        \'status\'  => \'future\',
        \'order\'   => \'ASC\',
        \'title\'   => __( \'Publishing Soon\' ),
        \'id\'      => \'future-posts\',
    ) );

    $recent_posts = wp_dashboard_recent_posts( array(
        \'display\' => 2,
        \'max\'     => 5,
        \'status\'  => \'publish\',
        \'order\'   => \'DESC\',
        \'title\'   => __( \'Recently Published\' ),
        \'id\'      => \'published-posts\',
    ) );

    $recent_comments = wp_dashboard_recent_comments( 10 );

    if ( !$future_posts && !$recent_posts && !$recent_comments ) {
        echo \'<div class="no-activity">\';
        echo \'<p class="smiley"></p>\';
        echo \'<p>\' . __( \'No activity yet!\' ) . \'</p>\';
        echo \'</div>\';
    }

    echo \'</div>\';

}

结束

相关推荐

Filters on Login Page

我正在尝试使用修改登录页built in filters. add\\u操作按预期工作,但我无法使筛选器工作。这是我函数中的代码。php:add_filter( \'login_form_top\', \'filter_top_login\' ); function filter_top_login( $content ) { return \'This is what I want it to say!\'; } 但当我加载wp登录时,它似乎没有做任何