PHP WordPress Error - Catchable fatal error: Object of class WP_Term could not be converted to string

PHP WordPress Error - Catchable fatal error: Object of class WP_Term could not be converted to string

我正在使用的一个 wordpress 网站有一个子主题,当我尝试登录时会出现错误。主要主题是 Genesis。一周前一切正常,我无法弄清楚这段代码有什么问题。

错误显示为Catchable fatal error: Object of class WP_Term could not be converted to string in /home/usr234/public_html/wp-content/themes/outreach-pro/lib/cstomize-setting.php on line 408

是否可以将数组解析为字符串?

这是cstomize中的函数-setting.php

add_action('admin_init', 'ms_category_images');
function ms_category_images() {
$ms_tags =  get_tags();
$ms_taxonomies = get_taxonomies();

if (is_array($ms_taxonomies)) { 
    foreach ($ms_taxonomies as $ms_taxonomy) {
        add_filter( 'manage_edit-' . $ms_taxonomy . '_columns', 'ms_taxonomy_columns' );
        add_filter( 'manage_' . $ms_taxonomy . '_custom_column', 'ms_taxonomy_column', 10, 3 );
       }
    }
if (is_array($ms_tags)) { 
    foreach ($ms_tags as $ms_taxonomy) {
    **//line no 408 is the one below**
    add_filter( 'manage_edit-' . $ms_taxonomy . '_columns', 'ms_taxonomy_columns' ); //line no 408
    add_filter( 'manage_' . $ms_taxonomy . '_custom_column', 'ms_taxonomy_column', 10, 3 );
    }
}

错误是因为 $ms_tags 是对象数组而不是名称数组。处理 $ms_tags 的代码应更改如下:

if (is_array($ms_tags)) { 
    foreach ($ms_tags as $ms_taxonomy) {
        add_filter( 'manage_edit-' . $ms_taxonomy->slug . '_columns', 'ms_taxonomy_columns' ); //line no 408
        add_filter( 'manage_' . $ms_taxonomy->slug . '_custom_column', 'ms_taxonomy_column', 10, 3 );
    }
}