我有一個公共職能附加分類法自定義帖子類型。當調試設置爲true時,我在Wordpress中獲取此錯誤代碼:WordPress的add_action未定義偏移0在plugin.php行925和943
Notice: Undefined offset: 0 in C:\xampp\htdocs\yanjep-dev\wp-includes\plugin.php on line 925
Notice: Undefined offset: 0 in C:\xampp\htdocs\yanjep-dev\wp-includes\plugin.php on line 943
這樣每個重複9次。
我已經分離出的問題在這裏的ADD_ACTION功能:
add_action('init',
call_user_func_array('register_taxonomy', array($taxonomy_name, $post_type_name, $args))
);
整個功能是在這裏:使用XAMPP
public function add_taxonomy($name, $args = array(), $labels = array())
{
if(! empty($name))
{
// We need to know the post type name, so the new taxonomy can be attached to it.
$post_type_name = $this->post_type_name;
// Taxonomy properties
$taxonomy_name = strtolower(str_replace(' ', '_', $name));
$taxonomy_labels = $labels;
$taxonomy_args = $args;
if(! taxonomy_exists($taxonomy_name))
{
//Capitilize the words and make it plural
$name = ucwords(str_replace('_', ' ', $name));
$plural = $name . 's';
// Default labels, overwrite them with the given labels.
$labels = array_merge(
// Default
array(
'name' => _x($plural, 'taxonomy general name'),
'singular_name' => _x($name, 'taxonomy singular name'),
'search_items' => __('Search ' . $plural),
'all_items' => __('All ' . $plural),
'parent_item' => __('Parent ' . $name),
'parent_item_colon' => __('Parent ' . $name . ':'),
'edit_item' => __('Edit ' . $name),
'update_item' => __('Update ' . $name),
'add_new_item' => __('Add New ' . $name),
'new_item_name' => __('New ' . $name . ' Name'),
'menu_name' => __($name),
),
// Given labels
$taxonomy_labels
);
// Default arguments, overwitten with the given arguments
$args = array_merge(
// Default
array(
'label' => $plural,
'labels' => $labels,
'public' => true,
'show_ui' => true,
'show_in_nav_menus' => true,
'_builtin' => false,
),
// Given
$taxonomy_args
);
// Add the taxonomy to the post type
add_action('init',
call_user_func_array('register_taxonomy', array($taxonomy_name, $post_type_name, $args))
);
}
else
{
add_action('init', array($this, 'add_taxonomy_to_post_type'));
}
}
}
我在本地工作。如果我評論這一行動,通知消失。我知道這與爭論的數量有關,但我無法解決它。
任何幫助表示讚賞。