Как добавить собственный шорткод в WPBakery Visual Composer? - PullRequest
0 голосов
/ 03 сентября 2018

Я пытаюсь реализовать собственный шорткод для шорткода WPBakery через мою дочернюю тему, я использую код, как показано ниже:

В моей функции. Php

if ( function_exists( 'vc_set_shortcodes_templates_dir' ) ) {
            $dir = get_stylesheet_directory() . '/vc_templates';
            vc_set_shortcodes_templates_dir( $dir );
        }

if(function_exists('vc_map')){
vc_map( array(
    "name" => esc_html__("SK Empty Space","salih"),
    "base" => "sk_empty_space",
    "class" => "",
    "category" => esc_html__("SK", "salih"),
    "icon" => "",
    "params" => array(
        array(
            "type" => "textfield",
            "holder" => "div",
            "class" => "",
            "heading" => esc_html__("Space","salih"),
            "param_name" => "space",
            "value" => "",
            "description" => esc_html__('Enter empty space as margin in px', 'pexr')
        ),
        array(
            "type" => "textfield",
            "holder" => "div",
            "class" => "",
            "heading" => esc_html__("Extra class name","salih"),
            "param_name" => "el_class",
            "value" => "",
            "description" => esc_html__('If you wish to style particular content element differently, then use this field to add a class name and then refer to it in your css file.', 'salih')
        ),
        array(
            'type' => 'css_editor',
            'heading' => esc_html__( 'CSS box', 'salih' ),
            'param_name' => 'css',
            'group' => esc_html__( 'Design Options', 'salih' ),
        )
    )
) );

}

класс WPBakeryShortCode_sk_empty_space extends WPBakeryShortCode {}

и в папке vc_templates sk_empty_space.php что-то вроде этого:

    extract(shortcode_atts(array(
    'space' => '',
    'el_class' => '',
), $atts));

$class = array('');
$class[] = $el_class;

?>

<div class="clearfix"></div>
<div style="width: 100%; float: left; margin-bottom: <?php echo esc_attr( $space ); ?>;"></div>
<div class="clearfix"></div>

но что бы я ни делал, кажется, что файл шаблона не работает с этой функцией, я вижу уведомление в передней части, например:

Примечание: отсутствует файл шаблона для sk_empty_space шорткода. Убедитесь, что у вас есть файл wp-content/themes/your_theme/vc_templates/sk_empty_space.php в папке вашей темы. в D: \ Ampps \ www \ covenant.local \ wp-content \ plugins \ js_composer \ include \ classes \ shortcodes \ shortcodes.php в строке 482

Как я могу это исправить? Я искал в документах WPBakery, в соответствии с документом приведенный выше код является правильным, Есть ли что-то, что я пропускаю выше короткого кода.

Я использую приведенный выше код в дочерней теме functions.php, а шаблоны в папке vc_templates

...