Created
August 20, 2019 13:04
-
-
Save gilzow/22370227bc6ef0636036bc658c3e675f to your computer and use it in GitHub Desktop.
referenced blockquotes code
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 | |
/* | |
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