php 向WPB页面构建器添加新的自定义元素
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 向WPB页面构建器添加新的自定义元素相关的知识,希望对你有一定的参考价值。
<?php
/**
* Shortcode Description here
*
* @param [array] $atts shortcode attributes.
* @param [string] $content shortcod contents.
* @return [string] html code of the shortcode.
*/
function prefix_shortcode_name_func( $atts, $content = null ) {
global $wpdb;
extract( shortcode_atts( array(
'shortcode_settings' => 'shortcode_default_value',
), $atts ) );
return $prefix_shortcode_name;
}
add_shortcode( 'prefix_shortcode_name', 'prefix_shortcode_name_func' );
/**
* Add the shortcode to WP Page Builder elements
*
* @return void
*/
function prefix_shortcode_settings() {
vc_map( array(
'name' => __( 'Winner Slider', 'theme_prefix' ),
'base' => 'wcc_winner_slider',
'category' => __( 'Contest Creator', 'theme_prefix' ),
'params' => array(
array(
'type' => 'dropdown',
'heading' => __( 'Shortcode Settings', 'theme_prefix' ),
'param_name' => 'shortcode_settings',
'description' => __( 'Shortcode Settings Description', 'theme_prefix' ),
'value' => array( 1, 2, 3, 4 ), // field values
)
),
) );
}
add_action( 'vc_before_init', 'prefix_shortcode_settings' );
以上是关于php 向WPB页面构建器添加新的自定义元素的主要内容,如果未能解决你的问题,请参考以下文章
在界面构建器中设计的自定义视图未显示
php 将新的自定义帖子类型添加到Wordpress
根据 WooCommerce 中的自定义字段值将文本添加到订单摘要
python 用于向Gnome 3的“应用程序”菜单添加新的自定义应用程序的快速终端脚本。
添加具有订单详细信息功能的自定义按钮 - Magento 2
如何向 WooCommerce Checkout 页面中的自定义选择框添加验证并应用 select2 样式。