1

如何将设置发送到前端?我需要向 vc_row 添加类。

在此处输入图像描述

/** * 行的肯伯恩斯效应。*/

add_action('vc_after_init', 'ken_burns_effect_add_option_to_vc_row');

function ken_burns_effect_add_option_to_vc_row() {
    // Ken Burns Effect Attributes
    $ken_burns_effect_attributes = 
    array(
        array(
            'type' => 'checkbox',
            'heading' => __( 'Ken Burns for image background', 'ken_burns_effect' ),
            'param_name' => 'enable_ken_burns_effect',
            'value' => array(
                __( 'Yes', 'ken_burns_effect' ) => 'yes',
            ),
            'description' => 'Check this box if you want to enable ken burns effect for this row.',
        ),
        array(
            'type' => 'dropdown',
            'heading' => __( 'Direction', 'ken_burns_effect' ),
            'param_name' => 'direction_ken_burns_effect',
            'value' => array(
                'Zoom In' => 'zoom_in',
                'Zoom Out' => 'zoom_out',
            ),
            'description' => __( '', 'ken_burns_effect' ),
            'dependency' => array(
                'element' => 'enable_ken_burns_effect',
                'value' => array( 'yes' ),
            ),
        ), 
        array(
            'type' => 'textfield',
            'heading' => __( 'Transition speed', 'ken_burns_effect' ),
            'param_name' => 'transition_speed_ken_burns_effect',
            'value' => '',
            'description' => __( '', 'ken_burns_effect' ),
            'dependency' => array(
                'element' => 'enable_ken_burns_effect',
                'value' => array( 'yes' ),
            ),
        ),
    );
    vc_add_params( 'vc_row', $ken_burns_effect_attributes);
}
4

1 回答 1

0

您必须vc_row.php通过将其复制到您的主题或插件来覆盖它。您可以查看他们关于如何设置覆盖目录的文档:https ://kb.wpbakery.com/docs/inner-api/vc_set_shortcodes_templates_dir/

然后,您可以在内部使用您的自定义参数,vc_row.php例如param_name

$enable_ken_burns_effect;
$direction_ken_burns_effect;
$transition_speed_ken_burns_effect;

请记住,vc_row_inner.php如果你想在那里使用选项,你也必须覆盖。section和 也是如此columns

于 2021-04-07T09:10:32.103 回答