2017-05-24 50 views
1

我正在添加額外元框以在前端內部標籤中調用。這裏面添加添加新的產品page.But它給錯誤說:警告:爲woocommerce添加額外元框錯誤

call_user_func()預計參數1是一個有效的回調, 類的WC_Meta_Box_Product_Features_Advantages「在 C未發現:\ WAMP \ WWW \ mysite的\可溼性粉劑管理員\包括\的template.php上線1048

截圖: enter image description here

我只是跟着加入的方式簡短描述meta框。因此,我創建了這個位置的類文件:

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的\可溼性粉劑內容\ plugins \ woocommerce \ includes \ admin \ class-wc-admin-meta-boxes.php裏面的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'); 

回答

1

你應該在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'); 
}