wpbakery page builder — трабл с кастомными элементами
-
Привет всем. Столкнулся с такой проблемой: не отображаются кастомные элементы в wpbakery page builder. Добавляю как обычно. На прошлых сайтах все норм отрабатывает. Юзаю посление версии wp и wpbakery page builder.
functions.phpadd_action( 'vpb_before_init', 'vc_before_init_actions' ); function vc_before_init_actions() { require_once( get_template_directory().'/vc_templates/ar_pricing_table.php' ); }
сам элемент
<?php /* Element Description: AR Custom Title */ // Element Class class vcPricingTable extends WPBakeryShortCode { // Element Init function __construct() { add_action( 'init', array( $this, 'vc_PricingTable_mapping' ) ); add_shortcode( 'vc_PricingTable', array( $this, 'vc_PricingTable_html' ) ); } // Element Mapping public function vc_PricingTable_mapping() { // Stop all if VC is not enabled if ( !defined( 'WPB_VC_VERSION' ) ) { return; } // Map the block with vc_map() vc_map( array( 'name' => __('Ar Pricing Table', 'text-domain'), 'base' => 'vc_PricingTable', 'description' => __('Pricing Table', 'text-domain'), 'category' => __('Ar Elements', 'text-domain'), 'icon' => get_template_directory_uri().'/assets/img/ar-icon.png', 'params' => array( array( 'type' => 'textfield', 'holder' => 'h3', 'class' => 'ar_pricing_table_title', 'heading' => __( 'Title', 'text-domain' ), 'param_name' => 'ar_pricing_table_title', 'value' => __( '', 'text-domain' ), 'description' => __( 'Add your title', 'text-domain' ), 'admin_label' => false, 'weight' => 0, 'group' => 'AR Group', ), array( 'type' => 'textfield', 'holder' => 'h3', 'class' => 'ar_pricing_table_price', 'heading' => __( 'Price', 'text-domain' ), 'param_name' => 'ar_pricing_table_price', 'value' => __( '', 'text-domain' ), 'description' => __( 'Add your price', 'text-domain' ), 'admin_label' => false, 'weight' => 0, 'group' => 'AR Group', ), array( 'type' => 'textfield', 'holder' => 'h3', 'class' => 'ar_pricing_table_currency', 'heading' => __( 'Currency', 'text-domain' ), 'param_name' => 'ar_pricing_table_currency', 'value' => __( '', 'text-domain' ), 'description' => __( 'Add your currency', 'text-domain' ), 'admin_label' => false, 'weight' => 0, 'group' => 'AR Group', ), array( 'type' => 'textfield', 'holder' => 'h3', 'class' => 'ar_pricing_table_sub_price', 'heading' => __( 'Sub price', 'text-domain' ), 'param_name' => 'ar_pricing_table_sub_price', 'value' => __( '', 'text-domain' ), 'description' => __( 'Add your sub price title', 'text-domain' ), 'admin_label' => false, 'weight' => 0, 'group' => 'AR Group', ), array( 'type' => 'iconpicker', 'holder' => 'h3', 'class' => 'ar_pricing_table_icon', 'heading' => __( 'Icon', 'text-domain' ), 'param_name' => 'ar_pricing_table_icon', 'value' => __( '', 'text-domain' ), 'description' => __( 'Add your price icon', 'text-domain' ), 'admin_label' => false, 'weight' => 0, 'group' => 'AR Group', ), array( 'type' => 'param_group', 'value' => __( 'Lorem Ipsum', 'text-domain' ), 'heading' => __( 'Price Items', 'text-domain' ), 'param_name' => 'ar_pricing_table_items', 'params' => array( array( 'type' => 'textfield', 'value' => '', 'heading' => 'Enter your price value', 'param_name' => 'ar_pricing_table_items_value', ) ) ), array( 'type' => 'vc_link', 'class' => 'ar_pricing_table_link', 'heading' => __( 'Link To', 'text-domain' ), 'param_name' => 'ar_pricing_table_link', 'value' => __( 'Your Link', 'text-domain' ), 'dependency' => array( 'element' => 'link', 'value' => array('custom'), ), 'admin_label' => false, 'weight' => 0, 'group' => 'AR Group', ), ), ) ); } // Element HTML public function vc_PricingTable_html( $atts ) { // Params extraction extract( shortcode_atts( array( 'ar_pricing_table_title' => '', 'ar_pricing_table_price' => '', 'ar_pricing_table_currency' => '', 'ar_pricing_table_sub_price' => '', 'ar_pricing_table_icon' => '', 'ar_pricing_table_items' => '', 'ar_pricing_table_link' => '', ), $atts ) ); $ar_pricing_table_link = ($ar_pricing_table_link=='||') ? '' : $ar_pricing_table_link; $ar_pricing_table_link = vc_build_link( $ar_pricing_table_link ); $ar_rates_link = $ar_pricing_table_link['url']; $ar_rates_title = ($ar_pricing_table_link['title'] == '') ? '' : 'title="'.$ar_pricing_table_link['title'].'"'; $ar_target_link = ($ar_pricing_table_link['target'] == '') ? '' : 'target="'.$ar_pricing_table_link['target'].'"'; $price_item = vc_param_group_parse_atts($atts['ar_pricing_table_items']); $price_value = array(); foreach($price_item as $data){ $new_price = $data; $new_price['ar_pricing_table_items_value'] = isset($new_price['ar_pricing_table_items_value']) ? $new_price['ar_pricing_table_items_value'] : ''; $price_value[] = $new_price; } $html = '<section class="prices"> <div class="prices-item"> <div class="item-top"> <div class="item__title"> '.$ar_pricing_table_title.' </div> <div class="item-top-price price_sup"> '.$ar_pricing_table_price.' <span class="ar_pricing_table_price"> '.$ar_pricing_table_currency.' </span> </div> <div class="item-top-liter"> '.$ar_pricing_table_sub_price.' </div> <div class="item-img"> <i class="'.$ar_pricing_table_icon.'"></i> </div> </div> <div class="item-bottom">'; // Fill $html var with data foreach($price_value as $price): $html .='<div class="item-bottom-inner"> <p class="item-bottom__text"> '.$price['ar_pricing_table_items_value'].' </div>'; endforeach; wp_reset_query(); $html .=' <div class="item-bottom-inner"> <p class="item-bottom__text"> <a class="btn" href="'.$ar_rates_link.'"><span>Замовити</span><i class="icon-arrow-circle-right"></i></a> </div> </div> </div> </section>'; return $html; } } // End Element Class // Element Class Init new vcPricingTable(); ?>
В чем может быть проблема? Спасибо за помощь.
Просмотр 1 ответа (всего 1)
Просмотр 1 ответа (всего 1)
- Тема «wpbakery page builder — трабл с кастомными элементами» закрыта для новых ответов.