2

私のコード:

    // Add language dropdown to visual composer settings
    if (function_exists('vc_add_param')) {
        vc_add_param('vc_row', array(
            'type' => 'dropdown',
            'heading' => "Language",
            'param_name' => 'language',
            'value' => array("English", "Russian"),
            'description' => __("Select Language", "discprofile"),
            'weight' => 1, //  default 0 (unsorted, appened to bottom, 1- append to top)
        ));
    }

    // Set custom html_template to display data-lang attribute
    if (function_exists('vc_map')) {

        // setup custom attributes
        $attributes = array(
            'html_template' => 'vc_templates/vc_row.php'
        );

        // Update 'vc_row' to include custom vc_row template and remap shortcode
        $params = vc_map_update('vc_row', $attributes);

        // Remove default vc_row
        vc_remove_element('vc_row');

        // Remap shortcode with custom template
        vc_map($params['vc_row']);
    }

vc_add_param() は機能しますが、コードの 2 番目の部分で次のエラーがスローされます。

( ! ) 致命的なエラー: vc_map オブジェクトが正しくありません。/Users/mike/Sites/Fun/wordpress/web/app/plugins/js_composer/include/helpers/helpers_api.php の 26 行目に base 属性が必要です

これらは、私が以前に見たリソースです。

関連ドキュメント:

どんな助けでも大歓迎です。

4

2 に答える 2

0

実際、関数vc_map_updateはショートコードのパラメーターのみを返しますが、すべての設定は返しません。

vc_get_shortcode要素全体を返す関数を使用する必要があります。

と:$element = vc_get_shortcode('vc_row');

vc_map_updateまた、明らかに更新されるため、要素を置き換える必要はありません。

于 2016-12-07T15:15:20.543 に答える