我正在使用WP在localhost中开发一个站点,并且要修改某些特征,我需要在“项目选项”元框中进行此操作,但未显示。我收到此消息:警告:call_user_func()期望参数1为有效的回调,找不到函数'trx_addons_meta_box_show'或在已删除 /wp-admin/includes/template.php中无效的函数名称1304
我是一个初学者,所以我真的不太了解php语言,只有html。我曾尝试寻找类似的问题,但仍然无法解决。
// Add meta box
if (!function_exists('trx_addons_meta_box_add')) {
add_action('add_meta_boxes', 'trx_addons_meta_box_add');
function trx_addons_meta_box_add() {
global $post_type;
if (trx_addons_meta_box_is_registered($post_type)) {
add_meta_box('trx_addons_meta_box',
esc_html__('Item Options', 'trx_addons'),
'trx_addons_meta_box_show',
$post_type,
apply_filters('trx_addons_filter_add_meta_box_context',
'advanced', $post_type),
apply_filters('trx_addons_filter_add_meta_box_priority',
'default', $post_type)
);
}
// Custom theme-specific meta-boxes
$boxes = apply_filters('trx_addons_filter_override_options',
array());
if (is_array($boxes)) {
foreach ($boxes as $box) {
$box = trx_addons_array_merge(array('', // id
'', // title
'', // callback
null, // screen
'advanced', // context
'default', // priority
null // callbacks
),
$box);
add_meta_box($box[0], $box[1], $box[2], $box[3],
$box[4], $box[5], $box[6]);
}
}
}
}// get_hidden_meta_boxes() doesn't apply in the block editor.
$hidden_class = ( ! $screen->is_block_editor() &&
in_array( $box['id'], $hidden ) ) ? ' hide-if-js' : '';
echo '<div id="' . $box['id'] . '" class="postbox '
. postbox_classes( $box['id'], $page ) . $hidden_class . '" ' . '>'
. "\n";
if ( 'dashboard_browser_nag' != $box['id'] ) {
$widget_title = $box['title'];
if ( is_array( $box['args'] ) && isset(
$box['args']['__widget_basename'] ) ) {
$widget_title = $box['args'] .
['__widget_basename'];
// Do not pass this parameter to the user
callback function.
unset( $box['args']['__widget_basename'] );
}
echo '<button type="button" class="handlediv"
aria-expanded="true">';
echo '<span class="screen-reader-text">' .
sprintf( __( 'Toggle panel: %s' ), $widget_title ) . '</span>';
echo '<span class="toggle-indicator" aria-
hidden="true"></span>';
echo '</button>';
}
echo '<h2 class="hndle">';
if ( 'dashboard_php_nag' === $box['id'] ) {
echo '<span aria-hidden="true" class="dashicons
dashicons-warning"></span>';
echo '<span class="screen-reader-text">' . __(
'Warning:' ) . ' </span>';
}
echo "<span>{$box['title']}</span>";
echo "</h2>\n";
echo '<div class="inside">' . "\n";
if ( WP_DEBUG && ! $block_compatible && 'edit' ===
$screen->parent_base && ! $screen->is_block_editor() && ! isset(
$_GET['meta-box-loader'] ) ) {
$plugin = _get_plugin_from_callback(
$box['callback'] );
if ( $plugin ) {
?>
<div class="error inline">
<p>
<?php
/* translators: %s: the name of
the plugin that generated this meta box. */
printf( __( "This meta box, from
the %s plugin, isn't compatible with the block editor." ), "
<strong>{$plugin['Name']}</strong>" );
?>
</p>
</div>
<?php
}
}
call_user_func( $box['callback'], $object, $box );
echo "</div>\n";
echo "</div>\n";
}
然后我在一个名为plugin.options.meta-box.php的文件中找到了
// Add meta box
if (!function_exists('trx_addons_meta_box_add')) {
add_action('add_meta_boxes', 'trx_addons_meta_box_add');
function trx_addons_meta_box_add() {
global $post_type;
if (trx_addons_meta_box_is_registered($post_type)) {
add_meta_box('trx_addons_meta_box',
esc_html__('Item Options', 'trx_addons'),
'trx_addons_meta_box_show',
$post_type,
apply_filters('trx_addons_filter_add_meta_box_context',
'advanced', $post_type),
apply_filters('trx_addons_filter_add_meta_box_priority',
'default', $post_type)
);
}