php Visual Composer - thêm控件
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php Visual Composer - thêm控件相关的知识,希望对你有一定的参考价值。
//Thêm vào functions.php
// Before VC Init
add_action( 'vc_before_init', 'my_custom_vc_elements' );
function my_custom_vc_elements() {
require_once( get_template_directory().'/vc-elements/my-first-custom-element.php' );
}
/*
Element Description: VC Info Box
*/
// Element Class
class vcInfoBox extends WPBakeryShortCode {
// Element Init
function __construct() {
add_action( 'init', array( $this, 'vc_infobox_mapping' ) );
add_shortcode( 'vc_infobox', array( $this, 'vc_infobox_html' ) );
}
// Element Mapping
public function vc_infobox_mapping() {
// Stop all if VC is not enabled
if ( !defined( 'WPB_VC_VERSION' ) ) {
return;
}
// Map the block with vc_map()
vc_map(
array(
'name' => __('VC Infobox', 'text-domain'),
'base' => 'vc_infobox',
'description' => __('Another simple VC box', 'text-domain'),
'category' => __('My Custom Elements', 'text-domain'),
'icon' => get_template_directory_uri().'/assets/img/vc-icon.png',
'params' => array(
array(
'type' => 'textfield',
'holder' => 'h3',
'class' => 'title-class',
'heading' => __( 'Title', 'text-domain' ),
'param_name' => 'title',
'value' => __( 'Default value', 'text-domain' ),
'description' => __( 'Box Title', 'text-domain' ),
'admin_label' => false,
'weight' => 0,
'group' => 'Custom Group',
),
array(
'type' => 'textarea',
'holder' => 'div',
'class' => 'text-class',
'heading' => __( 'Text', 'text-domain' ),
'param_name' => 'text',
'value' => __( 'Default value', 'text-domain' ),
'description' => __( 'Box Text', 'text-domain' ),
'admin_label' => false,
'weight' => 0,
'group' => 'Custom Group',
)
)
)
);
}
// Element HTML
public function vc_infobox_html( $atts ) {
$atts = vc_map_get_attributes( "vc_infobox", $atts );
extract( $atts );
// Fill $html var with data
$html = '
<div class="vc-infobox-wrap">
<h2 class="vc-infobox-title">' . $title . '</h2>
<div class="vc-infobox-text">' . $text . '</div>
</div>';
return $html;
}
} // End Element Class
// Element Class Init
new vcInfoBox();
以上是关于php Visual Composer - thêm控件的主要内容,如果未能解决你的问题,请参考以下文章
php Visual Composer Prestashop插件
php Visual Composer - 删除我们不使用的VC元素
php 联系Form 7 w / Visual Composer Grid
php 联系Form 7 w / Visual Composer Grid
将 PHP 代码插入 Visual Composer
在页面上呈现Visual Composer短代码