Advanced Customizations

4 min read Updated

Add these snippets to a child theme, a custom plugin, or the Code Snippets plugin.

Full-Width Containers Using CSS

Page Builder uses JavaScript for Full Width and Full Width Stretched rows. JavaScript lets full-width rows work with any theme. When both of these filters return a value, Page Builder uses CSS instead of JavaScript to stretch full-width rows.

This example matches the content container of the SiteOrigin Corp theme:

add_filter( 'siteorigin_panels_theme_container_width', function( $container ) {
	return '1140px';
} );
add_filter( 'siteorigin_panels_theme_container_selector', function( $selector ) {
	return '.site-content .corp-container';
} );

siteorigin_panels_theme_container_width
Return the width of your theme’s content container.

siteorigin_panels_theme_container_selector
Return a CSS selector that matches your theme’s content container. Add a parent selector if you need one to target it.

Change both values to match your theme.

Full Width Rows With Caching and Optimization Plugins

Page Builder stretches Full Width and Full Width Stretched rows with a small script that runs on page load. A caching or optimization plugin can delay JavaScript until the visitor first interacts with the page, and the rows then stay at the content width until that moment. LiteSpeed Cache delays scripts when Load JS Deferred is set to Delayed, and WP Rocket does it with Delay JavaScript execution. To keep the rows stretching on page load, exclude the script and its settings from the delay. Add these two lines to your plugin’s exclusion list:

siteorigin-panels/js/styling
panelsStyles
  • LiteSpeed Cache: LiteSpeed CachePage OptimizationTuning, in JS Deferred / Delayed Excludes.
  • WP Rocket: WP RocketFile Optimization, in Excluded JavaScript Files under Delay JavaScript execution. Add jquery.min.js as a third line, because the script needs jQuery and WP Rocket delays jQuery by default.

Clear your caching plugin’s cache afterwards. A theme that uses the Full-Width Containers Using CSS filters above stretches rows without the script and needs no exclusion.

LazyLoad

If you use the LazyLoad script, Page Builder can prepare row, column and widget background images for lazy loading. Add this PHP to your site:

add_filter( 'siteorigin_lazyload_compat', '__return_true' );

For a background image from the Media Library, Page Builder then adds the lazy class and puts the image in a data-bg attribute, so the LazyLoad script can load it. It doesn’t do this for parallax backgrounds, or when Background Image Opacity is below 100%. Page Builder turns this on for you when WP Rocket lazy loads images.

Other lazy load scripts may need the image in the style attribute too. Add a second filter:

add_filter( 'siteorigin_lazyload_compat', '__return_true' ); // This filter is required.
add_filter( 'siteorigin_lazy_load_inline_background', '__return_true' );

Add Custom Column Sizes

This filter adds your own sizes to the Column Presets in the row dialog. The array key is the number of columns. In the example, the key 2 adds a 70/30 preset for two-column rows.

For a different number of columns, change the key. For example, $sizes[ 3 ][] = array( 50.3, 31.1, 18.6 ); adds a three-column preset: Column A at 50.3%, Column B at 31.1% and Column C at 18.6%.

add_filter( 'siteorigin_panels_column_sizes', function( $sizes ) {
	$sizes[ 2 ][] = array( 70, 30 );
	return $sizes;
} );

Disable the Classic Editor Admin Notice

SettingsPage BuilderGeneralUse Classic Editor for New Posts is enabled by default. While it is enabled, Page Builder shows a notice when you add a new post of a Page Builder post type. The notice tells you about the setting and where to change it. Each user can dismiss it. This filter hides it for everyone:

add_filter( 'so_panels_show_classic_admin_notice', '__return_false' );

Disable the Add Page Editor Menu

Page Builder adds an editor menu to the Add Page button, with SiteOrigin Page Builder and Block Editor choices. This filter removes the menu for all post types:

add_filter( 'so_panels_show_add_new_dropdown_for_type', '__return_false' );

The filter also receives the post type as a second argument, so you can remove the menu for one post type only.

Remove the Page Builder News Dashboard Widget

function so_remove_dashboard_news() {
	remove_meta_box( 'so-dashboard-news', 'dashboard', 'normal' );
}
add_action( 'admin_menu', 'so_remove_dashboard_news' );

Remove the Astra SiteOrigin Page Builder Compatibility File

add_action( 'wp_enqueue_scripts', 'dequeue_site_origin_compatibility', 20 );
if ( ! function_exists( 'dequeue_site_origin_compatibility' ) ) {
    function dequeue_site_origin_compatibility() {
    	wp_dequeue_style( 'astra-site-origin' );
    }
}

Remove the Sydney Theme Default Row Padding

The Sydney theme adds 100px top and bottom padding to rows that have no padding set. This snippet changes that default to 0.

function so_sydney_padding_override( $attr, $style ) {
	if ( empty( $style['padding'] ) ) {
		$attr['style'] .= 'padding: 0; ';
	}
	return $attr;
}
add_filter( 'siteorigin_panels_row_style_attributes', 'so_sydney_padding_override', 15, 2 );

Disable the SiteOrigin Installer

To hide the SiteOrigin Installer, disable SettingsPage BuilderGeneralInstaller. To turn it off in code, use this filter:

add_filter( 'siteorigin_add_installer', '__return_false', 11 );