td_api_block::update_key

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

Usage:

<?php td_api_block::update_key( $id, $key, $value ) ?>

Parameters:

$id (string) (required)

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

$key (string) (required)

  • parameter to be replaced, in the following table you can see all parameters but only one can be used because via this method, so you can update only one parameter:
Key name
Type
Description
map_in_visual_composer boolean enable/disable the block appearance in Visual Composer
name string the block title, appears on Visual Composer
base string the base …
class string the block main css class
controls string full or …
category string Blocks …
icon string the icon css class, used to set a unique icon for each block via css, 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

$value (mixed) (required)

  • the data which will replace the parameter existing one, its type depends on the selected parameter.

Examples:

In the following example we’ll update the existing Block 1 , the ‘file’ key data will be replaced, 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:

td_api_block::update_key('td_block_1', 'file', $this->plugin_path . '/includes/shortcodes/td_block_1.php');