tagDiv API – Custom widget and block

Posted in: Newspaper
Post count: 5

Hi, I managed to create a custom block with the tagDiv API and I want to create a widget accordingly with the same settings, however the documentation only mentions there is a possibility to do that but no explanation how.

So how should i add custom widget with your API?

My new block code in the main file is: http://pastebin.com/azsHRgv2

Post count: 23312

Hello miguel_a,

Unfortunately, the API implementation addresses only for the advanced user and it is not cover by our support and also, we cannot provide custom services for API implementation, sorry! If you want to display more levels in our theme and you are not aware to the steps in this regard, please consider hiring a freelancer/developer to do this for you because we cannot provide custom services at the moment, sorry! All the information about API implementation method you should find in our documentation here -> https://forum.tagdiv.com/the-theme-api/
Usually, we recommend developers from studio.envato.com

Thank you for your understanding!

Post count: 5

I am a developer and as a developer I naturally expect proper documentation. Of course I can register a widget on my own not using your API without a problem, but as you have an API and you promote it as an advantage of you theme, I would expect a documented API way to register a widget.

As you can see here: https://forum.tagdiv.com/api-blocks-introduction/ the widgets are mentioned however undocumented. So again, like I said, I registered a new block into the VC, which is working just fine, however ir does not automatically appear in the Widgets menu. And trust me, I am not going to reverse engineer your whole API, just because you forgot to write documentation for something…

So are you going to help me here or add the information into the API documentation?

Post count: 5

Oh and BTW, your own example plugin, the td-api-plugin, does not register nor provide a way to register a widget.

Post count: 6535

Hi

We’re sorry for for this inconveniences but indeed we have some missing information in our documentation. We will try to update it in shortest time possible meanwhile follow the steps below to solve this.
As a new registered block to appear in Widgets section it’s need to be registered in td_page_builder_widgets.php like here: http://screencast.com/t/lGsS5MDc
In my case I’ve registered the block named: td_block_111 and the result can be seen here: http://screencast.com/t/ix5QK3mR

class td_block111_widget extends td_block_widget {
    var $td_block_id = 'td_block_111'; // change only the block id, the rest is autogenerated
}
add_action('widgets_init', create_function('', 'return register_widget("td_block111_widget");'));

I hope this help.
Thanks!

  • This reply was modified 10 years by Andrei L..
Post count: 5

Hi Andrei,

thanks for the response. I’ve figured this on my own in the meantime when digging though the the API files, I’m in a rush:)

Now, this doesn’t work – it throws a Fatal error, when I put it into the plugin file. This is because the plugins are initiated before the themes, so I had to put it into a separete file and load that file on in a hook like this:

class uep_api_plugin {
/* vars and functions are here */

add_action(‘td_wp_booster_loaded’, array($this, ‘hook_uep_booster_after’));

public function hook_uep_booster_after() {
include_once(dirname(__FILE__) . ‘/widgets/td_widget_tagcloud.php’);
}

}

IMHO this is a little complicated. Have you considered allowing developers register a widget with some boolean parameter in the td_api_block::add() method?

Something like:
td_api_block::add(‘td_block_tagcloud’,
array(
‘map_in_visual_composer’ => true,
‘register_widget’ => true,
)
);

…And then creating and registering a class for each widget in the array?

Cheers

Post count: 6535

Hi

We certainly plan to extend the theme flexibility in the future updates. I’ve added your suggestion on our list and when the time comes our developers will consider it. This may take some time because we have a long implementation list and we take them one by one. Thanks for your suggestion, have a nice day.

Meanwhile you can use the indicated code in functions.php file. The code should work fine even if you’re using a plugin to add the new widget.

Thanks!

Post count: 5

Ok, Andrei, thanks for feedback.

Cheers

Viewing 8 posts - 1 through 8 (of 8 total)
The forum ‘Newspaper’ is closed to new topics and replies.