danyaneh
1/31/2018 - 9:07 AM

Adds new custom element to WPB Page builder

Adds new custom element to WPB Page builder

<?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' );