2016-09-05 46 views
4

我在wordpress中向Visual Composer圖標框添加了新圖標,但是我得到以下2個錯誤,任何人都知道如何解決?下面是我的functions.php代碼文件向視覺作曲家添加自定義字體圖標

// Add new custom font to Font Family selection in icon box module 
function myprefix_add_new_icon_set_to_iconbox() { 
    $param = WPBMap::getParam('vcex_icon_box', 'icon_type'); 
    $param['value'][__('CUSTOM ICONS NAME', 'total')] = 'my_custom_icons'; 
    vc_update_shortcode_param('vcex_icon_box', $param); 
} 
add_filter('init', 'myprefix_add_new_icon_set_to_iconbox', 40); 

// Add font picker setting to icon box module when you select your font family from the dropdown 
function myprefix_add_font_picker() { 
    vc_add_param('vcex_icon_box', array(
      'type' => 'iconpicker', 
      'heading' => esc_html__('Icon', 'total'), 
      'param_name' => 'my_custom_icons', 
      'settings' => array(
       'emptyIcon' => true, 
       'type' => 'my_custom_icons', 
       'iconsPerPage' => 20, 
      ), 
      'dependency' => array(
       'element' => 'icon_type', 
       'value' => 'my_custom_icons', 
      ), 
      'group' => esc_html__('Icon', 'total'), 
     ) 
    ); 
} 
add_filter('vc_after_init', 'myprefix_add_font_picker', 40); 

// Add array of your fonts so they can be displayed in the font selector 
function my_icon_array() { 
    return array(
     array(
      'bg-icon-twitter' => 'Twitter', 
      'bg-icon-user' => 'User' 
     )); 
} 
add_filter('vc_iconpicker-type-my_custom_icons', 'my_icon_array'); 

注意:爲簡碼

錯誤的名稱:vcex_icon_box。名稱需要 /home/.../plugins/js_composer/include/classes/core/class-wpb-map.php 上線472

警告:

無法使用標量值作爲 /home/.../plugins/js_composer/include/classes/core/class-wpb-map.php 陣列上管線367

回答

2

錯誤1由以下事實引起你沒有您的安裝中名爲「vcex_icon_box」的簡碼。嘗試使用「vc_icon」。

此外,如果您使用vc_icon,則需要將依賴項元素更改爲type而不是icon_type

對於錯誤2,WPBMap::getParam('vcex_icon_box', 'icon_type');返回一個標量值,然後您可以將其視爲一個數組。

作爲一個調試提示,它是一個好主意,測試函數的輸出,以便您瞭解您所得到的。

VC文檔也不是最大的。