Plugin’s hook for any API call vcv:api. To add element you need to pass a path to manifest.json file and URL to the base directory of your element (see WordPress plugin example.)
<?php add_action( 'vcv:api', function ($api) { $api->elements->add( '/var/www/absolute/path/to/element/myelement/manifest.json', 'http://mywordpress/url/to/element/basedirectory' ); } );
Code example with 3 elements:
<?php add_action( /** * @param $api \VisualComposer\Modules\Api\Factory */ 'vcv:api', function ($api) { $elementsToRegister = [ 'logoSuperTest', 'textTest', 'imageGalleryWithTestZoom', ]; $pluginBaseUrl = rtrim(plugins_url(basename(__DIR__)), '\\/'); /** @var \VisualComposer\Modules\Elements\ApiController $elementsApi */ $elementsApi = $api->elements; foreach ($elementsToRegister as $tag) { $manifestPath = __DIR__ . '/elements/' . $tag . '/manifest.json'; $elementBaseUrl = $pluginBaseUrl . '/elements/' . $tag; $elementsApi->add($manifestPath, $elementBaseUrl); } } );