Question

Could somebody provide a code snippet which would show current php version inside the "At a glance" box win Wordpress admin? There are plugins but I'd like to do it with a code.

Was it helpful?

Solution

This one will add php version at the bottom of 'at a glance' metabox, where goes wordpress version with active theme name.

function update_right_now_text_callback($content){
    $php_version = __('PHP version: ') . phpversion();
    return $php_version . ' | ' . $content;
}

add_filter( 'update_right_now_text', 'update_right_now_text_callback' );

If you want to add it as content list item for some reason, this snippet work:

function dashboard_glance_items_callback( $data = [] ) {
    $data[]      = 'PHP version: ' . phpversion();
    return $data;
}

add_filter( 'dashboard_glance_items', 'dashboard_glance_items_callback' );
Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top