钩子文档

activity_box_end

💡 云策文档标注

概述

activity_box_end 是一个 WordPress 动作钩子,在仪表盘的 'At a Glance' 小部件末尾触发,允许开发者添加自定义内容。此钩子原名 'Right Now',在 3.8.0 版本前使用。

关键要点

  • 钩子名称:activity_box_end
  • 触发位置:仪表盘 'At a Glance' 小部件的末尾
  • 主要用途:添加自定义通知或信息到小部件中
  • 相关函数:wp_dashboard_right_now() 用于显示站点基本统计信息
  • 引入版本:WordPress 2.0.0

代码示例

public function wpdocsGetPhpMysqlVersion() {
    $php_version = phpversion();
    $sql_info = mysqli_get_server_info( mysqli_connect( DB_HOST, DB_USER, DB_PASSWORD, DB_NAME ) );
    $remove = '/^5.5.5-/i';
    $sql_version = preg_replace($remove, '', $sql_info);

    echo 'PHP version: ' . $php_version . '. ';
    echo 'MySQL version: ' . $sql_version . '.';
}
add_action( 'activity_box_end', 'wpdocsGetPhpMysqlVersion' );

📄 原文内容

Fires at the end of the ‘At a Glance’ dashboard widget.

Description

Prior to 3.8.0, the widget was named ‘Right Now’.

More Information

This action adds content to the end of At a Glance widget on the Dashboard. Useful for adding your own notices / information.

Source

do_action( 'activity_box_end' );

Changelog

Version Description
2.0.0 Introduced.

User Contributed Notes

  1. Skip to note 2 content

    Add PHP and MySQL versions at the end of glance widget

    public function wpdocsGetPhpMysqlVersion() {
            $php_version = phpversion();
            $sql_info = mysqli_get_server_info( mysqli_connect( DB_HOST, DB_USER, DB_PASSWORD, DB_NAME ) );   
            $remove ='/^5.5.5-/i';
            $sql_version = preg_replace($remove,'',$sql_info);
    
            echo 'PHP version: ' . $php_version . '. ';
            echo 'MySQL version: ' . $sql_version . '.';
    }
    add_action( 'activity_box_end', 'wpdocsGetPhpMysqlVersion' );