I’ve been working with the Site Origin Page Builder plugin a lot lately, which is wonderful and I highly recommend it for WordPress CMS development. I found myself in need of a basic SiteOrigin Page Builder conditional function to check whether the current post or page content was created with the default WordPress editor or the page builder tool. After digging through the plugin code I came up with the following clean approach.

Conditional Function

Provides a simple way to check if the current WordPress page/post was created with the SiteOrigin Page Builder plugin editor.

/**
 * SiteOrigin Page Builder Content Check
 *
 * Conditionally check if the current page/post was created with
 * the SiteOrigin Page Builder editor.
 *
 * @return boolean
 */
function content_is_pagebuilder() {
    global $post;

    // consider empty content the WP editor
    if ( empty( $post ) ) 
        return false;

    // does pagebuilder content exist in custom fields?
    $panels_data = get_post_meta( $post->ID, 'panels_data', true );

    return ( empty( $panels_data ) ) ? false : true;
}

post_class() Hook

The implementation adds a dynamic class to the output of the post_class() function. This is how I find myself using this logic in my themes, primarily to style the layout of a theme template based on whether or not the page content was created with TinyMCE or the Page Builder editor.

/**
 * SiteOrigin Page Builder post_class() Additions
 *
 * Conditionally check if the current page/post was created with
 * the SiteOrigin Page Builder widget and append a class to the
 * post_class() function
 *
 * @return  boolean
 * @author  Kevin Leary
 */
function pagebuilder_post_class( $classes ) {
    global $post;

    // consider empty content the WP editor
    if ( empty( $post ) ) {
        $is_pagebuilder_content = false;
    } else {
        $panels_data = get_post_meta( $post->ID, 'panels_data', true );
        $is_pagebuilder_content = ( empty( $panels_data ) ) ? false : true;
    }

    // add class to post_class()
    $classes[] = ( $is_pagebuilder_content ) ? 'editor-pagebuilder' : 'editor-tinymce';

    return $classes;
}
add_filter( 'post_class', 'pagebuilder_post_class' );

As with any WordPress function, drop either of these into your theme’s functions.php file. Hopefully this helps!