how to add more than one item?
// Before VC Init
add_action( 'vc_before_init', 'vc_before_init_actions' );
function vc_before_init_actions() {
//.. Code from other Tutorials ..//
// Require new custom Element
require_once( get_template_directory().'/vc-elements/sponsor-offer.php' );
}
<?php
/*
Element Description: VC Info Box
*/
// Element Class
class vcInfoBox extends WPBakeryShortCode {
// Element Init
function __construct() {
add_action( 'init', array( $this, 'vc_infobox_mapping' ) );
add_shortcode( 'vc_infobox', array( $this, 'vc_infobox_html' ) );
}
// Element Mapping
public function vc_infobox_mapping() {
// Stop all if VC is not enabled
if ( !defined( 'WPB_VC_VERSION' ) ) {
return;
}
// Map the block with vc_map()
vc_map(
array(
'name' => __('Oferta Sponsorowana', 'text-domain'),
'base' => 'vc_infobox',
'description' => __('Another simple VC box', 'text-domain'),
'category' => __('My Custom Elements', 'text-domain'),
'params' => array(
array(
'type' => 'textfield',
'holder' => 'label',
'class' => 'title-class',
'heading' => __( 'Label Oferty', 'text-domain' ),
'param_name' => 'label',
'admin_label' => false,
'weight' => 0,
'group' => 'Custom Group',
),
array(
'type' => 'textfield',
'holder' => 'h3',
'class' => 'title-class',
'heading' => __( 'Title', 'text-domain' ),
'param_name' => 'title',
'value' => __( 'Tytuł', 'text-domain' ),
'admin_label' => false,
'weight' => 0,
'group' => 'Custom Group',
),
array(
'type' => 'textfield',
'holder' => 'img',
'class' => 'title-class',
'heading' => __( 'Obrazek', 'text-domain' ),
'param_name' => 'images',
'value' => __( 'Link do obrazka', 'text-domain' ),
'admin_label' => false,
'weight' => 0,
'group' => 'Custom Group',
),
array(
'type' => 'textarea',
'holder' => 'div',
'class' => 'text-class',
'heading' => __( 'Text', 'text-domain' ),
'param_name' => 'text',
'value' => __( 'Opis...', 'text-domain' ),
'admin_label' => false,
'weight' => 0,
'group' => 'Custom Group',
),
array(
'type' => 'textfield',
'holder' => 'img',
'class' => 'title-class',
'heading' => __( 'Link zewnętrzny', 'text-domain' ),
'param_name' => 'link',
'value' => __( 'Proszę podać link zewnętrzny', 'text-domain' ),
'admin_label' => false,
'weight' => 0,
'group' => 'Custom Group',
)
)
)
);
}
// Element HTML
public function vc_infobox_html( $atts ) {
// Params extraction
extract(
shortcode_atts(
array(
'title' => '',
'text' => '',
'images' => '',
'link' => '',
'label' => '',
),
$atts
)
);
// Fill $html var with data
$html = '
<div class="so_label">
<span class="so_label-name">' . $label . '</span>
</div>
<div class="special-offer">
<div class="so_content">
<div class="so_logo">
</div>
<div class="so_description">
<span class="so_title">' . $title . '</span>
<p class="so_text">' . $text . '</p>
</div>
</div>
<div class="so_button">
Wyślij wniosek
</div>
</div>';
return $html;
}
} // End Element Class
// Element Class Init
new vcInfoBox();
?>