Check whether page is published with page-builder enabled.

Hello, first of all, excellent plugin. My Clients love it.

We’re in the process of migrating our hard-coded page templates over to BB. Our method has been to write a conditional :

<?php if ( in_array('fl-builder', body_class() ) ) {
        the_content();
    }
    else
    {
        // old hard-coded template
    } ?>

This works great if we’re satisfied with the changes, but they have to go through a approval process, so we want to set our BB template to draft, and still serve the old content.

I’m doubtful, but is there a way we can check that the page has been published with a BB template? It seems that once BB is initiated on the page, it will retain that body class.

Secondly (and related), we’re having trouble removing BB from a page once it’s been initiated. If we click on ‘text editor’ and get the message that it will disable BB, after updating the page, BB is re-initiated. There doesn’t seem to be any way to keep BB from taking over once it’s initiated.

Thanks, and keep up the great work!

Hey Peter,

I’m glad to hear your clients are loving the builder!

What you’re trying to do should be possible, but you’ll need some different code. Instead of checking for the body class in your if statement, try using…

if ( FLBuilderModel::is_builder_enabled() ) {
    // A builder layout has been published. 
}

That will return false if the current page is in “Text Editor” mode and true if in “Builder Mode”.

Secondly (and related), we’re having trouble removing BB from a page once it’s been initiated. If we click on ‘text editor’ and get the message that it will disable BB, after updating the page, BB is re-initiated. There doesn’t seem to be any way to keep BB from taking over once it’s initiated.

That broke in a recent update. We’ll be pushing a maintenance update tonight that contains a fix.

Let me know if you have any questions.

Justin

Great-thanks!