-
Notifications
You must be signed in to change notification settings - Fork 25
Adding Theme Support
You can add theme support (via the add_theme_support
function). Actually adding the theme support is simple:
add_theme_support( 'wds-simple-page-builder' );
If theme support is registered, you can use the current_theme_supports( 'wds-simple-page-builder' )
check or require_if_theme_supports( 'wds-simple-page-builder', '/path/to/file/ )
to require a file if Page Builder is supported by the theme.
You can also register the initial settings. This works like wds_register_page_builder_options
. If the current theme supports wds-simple-page-builder
, you can use wds_page_builder_theme_support
to initialize those settings.
###Example
function wds_setup_theme() {
add_theme_support( 'wds-simple-page-builder' );
wds_page_builder_theme_support( array(
'hide_options' => 'disabled', // set to true to hide them completely
'parts_dir' => 'pagebuilder', // directory the template parts are saved in
'parts_prefix' => 'part', // the template part prefix, e.g. part-template.php
'use_wrap' => 'on', // Whether to use a wrapper container. 'on' is TRUE
'container' => 'section', // HTML container for Page Builder template parts
'container_class' => 'pagebuilder-part', // can use multiple classes, separated by a space
'post_types' => array( 'page', ), // add any other supported post types here
) );
}
add_action( 'after_setup_theme', 'wds_setup_theme' );
####Note
Because we're registering settings, and because the function(s) are triggered late (after_setup_theme
), it may require a few refreshes for your changes to show up when you register them this way. Likewise, it might take a few refreshes if you change the settings later on. Passing disabled
to the hide_options
parameter (instead of passing true
or leaving it blank) is helpful to see what the saved settings are currently. If you no longer need to display the settings you can remove that parameter or pass true
to hide_options
.
Still missing something? Let us know if you think this wiki is missing some information or could use some more details! Open an issue in the issue tracker with the information you're looking for and we'll make sure that information gets added!