Javascript Hooks

Javascript Hooks

Javascript Hooks

The bulk of Page Builder Sandwich is Javascript, and we’ve added a bunch of methods so that developers can extend and add more functionality to our page builder.

To make things easier to developers, we’ve patterned things to how WordPress does things – via hooks!

In WordPress, you typically use the functions add_filter() and add_action() to modify or add to the behavior of WP. Similarly in PBS, you can use wp.hooks.addFilter() and wp.hooks.addAction().

The way you use them is also the same: use filters to modify stuff, and use actions to perform additional stuff. Those two function calls are essentially the same as with their PHP counterparts, except they run in Javascript.

So as not to be confused between PHP hooks and Javascript hooks, we’ve named the Javascript hooks with a “period-case” (invented word). PHP hooks all use snake case:

  • pbs.save.payload – “period-case”, a JS hook
  • pbs_save_content_data – snake case, a PHP hook

Refer to the Javascript Actions and Javascript Filters categories on the left menu to browse all the hooks.

Credits

For those curious, we’re using  https://github.com/carldanley/WP-JS-Hooks to add those nifty hook calls in Javascript

Still need help? Contact Us

Share this page!

Facebook
Twitter
LinkedIn
WhatsApp
Telegram
Skype

The Author

Contact Us