Usage
$all_shortcodes = PageBuilderSandwich::get_all_shortcodes()
Parameters
None.
Returns
Array. An array of all the detected shortcode tags.
$all_shortcodes = PageBuilderSandwich::get_all_shortcodes()
None.
Array. An array of all the detected shortcode tags.
Called right before the editor saves the contents. You can use this to place additional data to send during saving (this doesn’t save the data, just sends it via Ajax to the backend)
payload
FormData object. The data sent via Ajax for saving.
wp.hooks.addAction( 'pbs.save.payload', function( payload ) {
// Add data to be sent during saving.
payload.append( 'my_data', 'My Data' );
}
Called when the PBS editor finishes loading (not called when the user clicks on the start editing button)
Do something after PBS loads
wp.hooks.addAction( 'pbs.init', function() {
console.log( 'PBS is ready!' );
}
Triggered when the user changes between the different responsive views.
None.
If you are a theme developer, including PBS in your theme can greatly increase the value of your product.
Contact us at [email protected], let’s collaborate!
You can prevent PB Sandwich from showing up in the front-end using the pbs_is_editable_by_user filter.
For example, to stop PB Sandwich from showing up in a Custom Post Type identified by the slug slider, you can add this piece of code in your functions.php
add_filter( 'pbs_is_editable_by_user', 'stop_pbs_in_sliders' );
function stop_pbs_in_sliders( $editable ) {
if ( is_singular( 'slider' ) ) {
return false;
}
return $editable;
}
To stop PB Sandwich for a specific page/post, you can use the post ID to check:
add_filter( 'pbs_is_editable_by_user', 'stop_pbs_for_123' );
function stop_pbs_for_123( $editable ) {
global $post;
if ( is_singular() && ! empty( $post ) ) {
if ( '123' === $post->ID ) {
return false;
}
}
return $editable;
}
Check whether PBS is turned on and in editing mode.
if ( PBSEditor.isEditing() ) {
// Do something when editing.
}
None.
Boolean. True when currently editing, false when not editing.
Called after the content is saved. This is called when a save was initiated from the PBS editor.
None
PageBuilderSandwich::is_editable_by_user()
None.
Boolean. True if PBS can edit the post, false otherwise.
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:
Refer to the Javascript Actions and Javascript Filters categories on the left menu to browse all the hooks.
For those curious, we’re using https://github.com/carldanley/WP-JS-Hooks to add those nifty hook calls in Javascript