Created
January 31, 2018 09:07
-
-
Save daniloparrajr/c6fd11e99cafcd9ee10a3b9261068672 to your computer and use it in GitHub Desktop.
Adds new custom element to WPB Page builder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment