我正在添加额外的元框,以便在前端的标签内调用。这是在添加新产品page.But中添加的,它给出了错误信息:警告:
C:\wamp\www\mysite\wp-admin\includes\template.php ()期望参数1是一个有效的回调,在第1048行的call_user_func中找不到类'WC_Meta_Box_Product_Features_Advantages‘
截图:

我只是遵循简短的描述元框添加的方式。因此,我在这个位置创建了一个类文件:
C:\wamp\www\mysite\wp-content\plugins\woocommerce\includes\admin\meta-boxes\class-wc-meta-box-features-advantages-.php内容看起来如下:
<?php
/**
* Product Features Advantages
*
* Replaces the standard excerpt box.
*
* @author WooThemes
* @category Admin
* @package WooCommerce/Admin/Meta Boxes
* @version 2.1.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* WC_Meta_Box_Product_Features_Advantages Class.
*/
class WC_Meta_Box_Product_Features_Advantages {
/**
* Output the metabox.
*
* @param WP_Post $post
*/
public static function output( $post ) {
$settings = array(
'textarea_name' => 'features_advantages',
'quicktags' => array( 'buttons' => 'em,strong,link' ),
'tinymce' => array(
'theme_advanced_buttons1' => 'bold,italic,strikethrough,separator,bullist,numlist,separator,blockquote,separator,justifyleft,justifycenter,justifyright,separator,link,unlink,separator,undo,redo,separator',
'theme_advanced_buttons2' => '',
),
'editor_css' => '<style>#wp-excerpt-editor-container .wp-editor-area{height:175px; width:100%;}</style>',
);
wp_editor( htmlspecialchars_decode( $post->post_excerpt ), 'features_advantages', apply_filters( 'woocommerce_product_features_advantages_editor_settings', $settings ) );
}
}这里还添加了几行代码: C:\wamp\www\mysite\wp-content\plugins\woocommerce\includes\admin\class-wc-admin-meta-boxes.php few add_meta_boxes()函数。
add_meta_box( 'features_advantages', __( 'Product Features and Advantages', 'woocommerce' ), 'WC_Meta_Box_Product_Features_Advantages::output', 'product', 'normal' );和remove_meta_boxes()中的这一行
remove_meta_box( 'features_advantages', 'product', 'normal' );发布于 2017-05-24 09:06:24
您应该添加functions.php文件而不是插件文件夹。
将此代码添加到当前活动主题functions.php中:
add_action( 'add_meta_boxes', 'product_details_add' );
add_action( 'save_post', 'product_details_save' );
function product_details_add() {
add_meta_box( 'product_details', 'Product Details', 'product_details_call', 'product', 'normal', 'high' );
}
function product_details_call( $post ) {
// Use nonce for verification
wp_nonce_field( plugin_basename( __FILE__ ), 'product_details_noncename' );
$field_value = get_post_meta( $post->ID, 'product_details_meta', false );
wp_editor( $field_value[0], 'product_details_meta' );
}https://stackoverflow.com/questions/44153234
复制相似问题