td_api_block::update

Available on: Newsmag V1.8+, Newspaper V5+
This api call is used to update the parameters of an existing block.

Usage:

<?php td_api_block::update( $id, $params_array ) ?>

Parameters:

$id (string) (required)

  • the block id – has to match with one of the blocks which are already registered in the theme

$params_array (array) (required)

  • an array which contains the parameters of the block
  • most of the parameters are passed to the vc_map function of visual composer
Key name
Type
Description
map_in_visual_composer boolean enable/disable the block appearance in Visual Composer
name string the block title, it appears in Visual Composer
base string shortcode tag. For [my_shortcode] shortcode base is my_shortcode
class string CSS class which will be added to the shortcode’s content element in the page edit screen in Visual Composer backend edit mode
controls string undocumented VC parameter. Default: “full”
category string category which best suites to describe functionality of this shortcode. Default category: Blocks. You can add your own category, simply enter new category title here
icon string URL or CSS class with icon image, the icon is displayed in Visual Composer
file string the path for the block template file
params array the array of parameters received from the block settings panel

Examples:

In the following example we’ll update the existing Block 1 , you can see how the code looks on plugin, you have to modify the file path to match with the plugin current folder, , we use the variables which were introduced in the Plugin Method section, the “param” key also comes with a modification:

td_api_block::update('td_block_1',
    array(
        'map_in_visual_composer' => true,
        "name" => 'Block 1',
        "base" => 'td_block_1',
        "class" => 'td_block_1',
        "controls" => "full",
        "category" => 'Blocks',
        'icon' => 'icon-pagebuilder-td_block_1',
        'file' => td_global::$get_template_directory . '/includes/shortcodes/td_block_1.php',
        "params" => array_merge(
              td_config::get_map_block_general_array(),
              td_config::get_map_filter_array(),
              td_config::get_map_block_ajax_filter_array(),
              td_config::get_map_block_pagination_array()
        ) 
    ) 
);