I’m creating my own custom block for WPBakery:
add_action('init', function() {
class vcCatalogBlock extends WPBakeryShortCode
{
function __construct()
{
add_action('vc_before_init', [$this, 'vc_mapping']);
add_shortcode('vc_catalog_block', [$this, 'vc_catalog_block']);
}
public function vc_mapping()
{
vc_map(
array(
'name' => 'VC Catalog Block',
'base' => 'vc_catalog_block',
'description' => 'Company Catalog',
'category' => 'Blocks',
'icon' => '',
'params' => array(
array(
'type' => 'dropdown',
'heading' => "Select conference",
'param_name' => 'conference_id',
'value' => $this->get_conferences(),
'admin_label' => true,
),
)
)
);
}
public function get_conferences()
{
$result = wp_remote_post(CRM_SITE_URL . '/api/conference/list');
}
}
new vcCatalogBlock();
});
The vc_mapping method works on all pages! For what? This method should only work where the WPBakery visual editor is used (enabled).
Since in the vc_mapping method I access an external API, this request occurs on all admin pages!