Code snippet to show current php version inside “At a Glance” box in admin

wordpress.stackexchange https://wordpress.stackexchange.com/questions/387688

  •  20-05-2021
  •  | 
  •  

Вопрос

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.

Это было полезно?

Решение

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' );
Лицензировано под: CC-BY-SA с атрибуция
Не связан с wordpress.stackexchange
scroll top