Skip to content

Instantly share code, notes, and snippets.

@wp-kitten
Created April 22, 2015 12:50
Show Gist options
  • Save wp-kitten/dd4086adc560885f87f3 to your computer and use it in GitHub Desktop.
Save wp-kitten/dd4086adc560885f87f3 to your computer and use it in GitHub Desktop.
WPK Visual Composer: register elements
/*
Plugin Name: WPK Elements
Plugin URI: http://coderevision.com/wpk-elements
Description: Provides shortcodes for Visual Composer plugin
Version: 1.0.0
Author: wp.kytten
Author URI: http://coderevision.com
License: GPL 3
Text Domain: wpk-elements
*/
// usage: [wpk_subscribe link="#" target="_blank"]Subcribe[/wpk_subscribe]
function wpk_subscribe_link_shortcode($atts, $content = null) {
$link = '';
$target = '_blank';
extract(shortcode_atts(array(
'link' => '#',
'target' => '_blank',
), $atts));
return '<div class="button"><a href="'.$link.'" target="'.$target.'">'.$content.'</a></div>';
}
add_shortcode('wpk_subscribe', 'wpk_subscribe_link_shortcode');
add_action( 'vc_before_init', 'wpkRegister_wpkSubscribe' );
function wpkRegisterShortcode_wpkSubscribe() {
vc_map( array(
"name" => __( "Wpk Subscribe", "wpk-elements" ),
"base" => "wpk_subscribe",
"class" => "",
"category" => __( "WPK Elements", "wpk-elements"),
// 'admin_enqueue_js' => array(get_template_directory_uri().'/vc_extend/file.js'),
// 'admin_enqueue_css' => array(get_template_directory_uri().'/vc_extend/file.css'),
"params" => array(
array(
"type" => "textarea_html",
"holder" => "div",
"class" => "",
"heading" => __( "RSS Feed URL", "wpk-elements" ),
"param_name" => "link",
"value" => __( "#", "wpk-elements" ),
"description" => __( "Description for foo param.", "wpk-elements" )
),
array(
"type" => "dropdown",
"heading" => __("Link target"),
"param_name" => "target",
"admin_label" => true,
"value" => array(
'_self' => '_self',
'_blank' => '_blank',
),
"std" => '_self',
"description" => __("The description")
),
array(
"type" => "textarea",
"holder" => "div",
"class" => "",
"heading" => __( "Text content", "wpk-elements" ),
"param_name" => "content",
"value" => __( "Subscribe", "wpk-elements" ),
"description" => __( "Description for foo param.", "wpk-elements" )
),
)
) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment