SINCE 4.6
<?php vc_map_get_defaults($tag) ?>
Get all attributes and their default values of any element.
Params
| Param name | Type | Required | Description |
| $tag | String | Yes | The base tag name of the element shortcode. |
Example
You can get the default params of the ‘Copyright’ element, and create a new element ‘Copyright Update’ with the same params.
<?php
add_action( 'vc_after_init', 'register_custom_copyright_shortcode' );
function register_custom_copyright_shortcode() {
vc_map( [
'name' => __( 'Custom Copyright', 'your-text-domain' ),
'base' => 'custom_copyright',
'params' => [
[
'type' => 'textfield',
'heading' => __( 'Prefix', 'your-text-domain' ),
'param_name' => 'prefix',
'value' => __( '©', 'your-text-domain' ),
],
[
'type' => 'textfield',
'heading' => __( 'Postfix', 'your-text-domain' ),
'param_name' => 'postfix',
'value' => __( 'All rights reserved.', 'your-text-domain' ),
],
[
'type' => 'dropdown',
'heading' => __( 'Alignment', 'your-text-domain' ),
'param_name' => 'align',
'value' => [
__( 'Left', 'your-text-domain' ) => 'left',
__( 'Center', 'your-text-domain' ) => 'center',
__( 'Right', 'your-text-domain' ) => 'right',
],
'std' => 'center',
],
[
'type' => 'css_editor',
'heading' => __( 'CSS', 'your-text-domain' ),
'param_name' => 'css',
'group' => __( 'Design Options', 'your-text-domain' ),
],
],
] );
add_shortcode( 'custom_copyright', function( $atts ) {
$atts = vc_map_get_attributes( 'custom_copyright' );
$style = vc_shortcode_custom_css_class( $atts['css'], ' ' );
return sprintf(
'<div class="custom-copyright text-%1$s%2$s">%3$s %4$s</div>',
esc_attr( $atts['align'] ),
esc_attr( $style ),
esc_html( $atts['prefix'] ),
esc_html( $atts['postfix'] )
);
} );
?>
Code Explanation
We created a new “Copyright Custom” element based on a native “Copyright” element.