Skip to content

Instantly share code, notes, and snippets.

@gilzow
Created August 20, 2019 13:04
Show Gist options
  • Save gilzow/22370227bc6ef0636036bc658c3e675f to your computer and use it in GitHub Desktop.
Save gilzow/22370227bc6ef0636036bc658c3e675f to your computer and use it in GitHub Desktop.
referenced blockquotes code
<?php
/*
Element Description: VC Info Box
*/
// Element Class
class vcblockquote extends WPBakeryShortCode {
// Element Init
function __construct() {
add_action( 'init', array( $this, 'vc_blockquote_mapping' ) );
add_shortcode( 'vc_blockquote', array( $this, 'vc_blockquote_html' ) );
}
// Element Mapping
public function vc_blockquote_mapping() {
// Stop all if VC is not enabled
if ( !defined( 'WPB_VC_VERSION' ) ) {
return;
}
// Map the block with vc_map()
vc_map(
array(
'name' => __('Blockquote', 'text-domain'),
'base' => 'vc_blockquote',
'description' => __('Blockquote', 'text-domain'),
'category' => __('My Custom Elements', 'text-domain'),
'params' => array(
array(
"type" => "dropdown",
"admin_label" => TRUE,
"class" => "",
"value" => array("Light" => "", "Dark" => "blockquote-dark"),
"heading" => __( "Style", 'style' ),
"param_name" => "style",
"description" => "Select light or dark style"
),
array(
"type" => "textarea_html",
"admin_label" => TRUE,
"heading" => "Quote",
"param_name" => "content",
"description" => "A short quote."
),
array(
"type" => "textfield",
"admin_label" => TRUE,
"heading" => "Attribution",
"param_name" => "attribution",
"description" => "Who this quote is attributed to."
),
)
)
);
}
// Element HTML
public function vc_blockquote_html( $atts, $content = null ) {
extract( shortcode_atts( array (
'style' => '',
'attribution' => ''
), $atts) );
return "<div class='blockquote_container'><blockquote class='${style}'>${content}<cite class='attribution'>${attribution}</cite></blockquote></div>";
}
} // End Element Class
// Element Class Init
new vcblockquote();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment