WP Bakery嵌套简码vc_map

时间:2018-08-13 20:19:50

标签: wordpress shortcode visual-composer

我正在按照此示例创建用于一些短代码的容器,该容器使我可以包装多个子页面构建器元素。 https://kb.wpbakery.com/docs/developers-how-tos/nested-shortcodes-container/

如果我使用示例代码,则它可以按预期工作,并允许我在新容器内添加元素,但是当我将代码应用于我的短代码时,我没有选择添加内部元素的选项。我猜这与简码https://wordpress.org/plugins/infusionsoft-official-opt-in-forms/

有关

这是我的代码

//Register "container" content element. It will hold all your inner (child) content elements
    vc_map( array(
        "name" => __("InfusionSoft Blocker", "zzone"),
        "base" => "inf_infusionsoft_locked",
        "as_parent" => array('except'), // Use only|except attributes to limit child shortcodes (separate multiple values with comma)
        "content_element" => true,
        "show_settings_on_create" => true,
        "is_container" => true,
            "params" => array(
        // add params same as with any other content element
        array(
            "type" => "textfield",
            "heading" => __("Optin ID", "zzone"),
            "param_name" => "optin_id",
            "value" => 'optin_1',
            "description" => __("Example: optin_1", "my-text-domain")
        )
    ),
        "js_view" => 'VcColumnView'
    ) );
    //Your "container" content element should extend WPBakeryShortCodesContainer class to inherit all required functionality
    if ( class_exists( 'WPBakeryShortCodesContainer' ) ) {
        class WPBakeryShortCode_InfusionSoft_Blocker extends WPBakeryShortCodesContainer {
        }
    }

1 个答案:

答案 0 :(得分:1)

扩展WPBakeryShortCodesContainer时,必须将类命名为WPBakeryShortCode_[shortcode_base]

所以您的代码应如下所示:

if ( class_exists( 'WPBakeryShortCodesContainer' ) ) {
    class WPBakeryShortCode_inf_infusionsoft_locked extends WPBakeryShortCodesContainer {}
}

提示:"as_parent" => array('except')将显示每个简码。如果您不希望自己的短代码嵌套自己,请设置"as_parent" => array('except' => 'inf_infusionsoft_locked')