Created
October 7, 2021 22:48
-
-
Save KustomDeveloper/d73e47f4d2f792db18e3aa0dcca9b263 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
/*Add CTA Wp Bakery Component*/ | |
class VcHubspotCta extends WPBakeryShortCode { | |
function __construct() { | |
add_action( 'init', array( $this, 'create_shortcode' ), 999 ); | |
add_shortcode( 'vc_hubspot_cta', array( $this, 'render_shortcode' ) ); | |
} | |
public function create_shortcode() { | |
// Stop all if VC is not enabled | |
if ( !defined( 'WPB_VC_VERSION' ) ) { | |
return; | |
} | |
// Map blockquote with vc_map() | |
vc_map( array( | |
'name' => __('Hubspot CTA', 'kd'), | |
'base' => 'vc_hubspot_cta', | |
'description' => __( '', 'kd' ), | |
'category' => __( 'kd Modules', 'kd'), | |
'params' => array( | |
// Main Hubspot CTA Field | |
array( | |
'type' => 'textfield', | |
// 'holder' => 'div', | |
'heading' => __( 'Hubspot CTA', 'kd' ), | |
'param_name' => 'hubspot_cta', | |
'value' => __( '', 'kd' ), | |
'description' => __( 'Add Hubspot CTA', 'kd' ), | |
), | |
// Add an extra classname to each CTA | |
array( | |
'type' => 'textfield', | |
'heading' => __( 'Extra class name', 'kd' ), | |
'param_name' => 'extra_class', | |
'value' => __( '', 'kd' ), | |
'description' => __( 'Style particular content element differently - add a class name and refer to it in custom CSS.', 'kd' ), | |
'group' => __( 'Extra', 'kd'), | |
), | |
), | |
)); | |
} | |
public function render_shortcode( $atts, $content, $tag ) { | |
$atts = (shortcode_atts(array( | |
'hubspot_cta' => '', | |
'extra_class' => '', | |
'element_id' => '' | |
), $atts)); | |
//Cta | |
$hubspot_cta = $atts['hubspot_cta']; | |
//Class and Id | |
$extra_class = esc_attr($atts['extra_class']); | |
$element_id = esc_attr($atts['element_id']); | |
//Output | |
$output = ''; | |
$output .= "<div class='vc-hubspot-cta" . $extra_class . "'>"; | |
$output .= $hubspot_cta . '</div>'; | |
return $output; | |
} | |
} | |
new VcHubspotCta(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment