Condition to check if the Pro builder is loaded

Is there a way to check if the Pro builder is loaded? I have a simple custom shortcode that prints out some content to the front end. I dont want this code to fire if the builder is loaded - only if the front end of the site is. How can this be done?

Something like this:

function footer_stuff(){
    if (is_the_pro_builder) {
        // do nothing
    } else {
        echo '<div class="wrapper-class">';
            global $variable_name; 
            print $variable_name->getBodyString("body_1"); 
            print $variable_name->close();
            echo '</div>';
    }
}
add_shortcode( 'get_footer_stuff', 'footer_stuff' );

Hi @simeoned,

Regretfully, supporting the custom coding issue is beyond the scope of theme support. I would suggest you hire a developer who can assist you to do the customization or you can avail of our newly launched service called One, where the customization questions are answered.

Thanks

“…supporting the custom coding issue is beyond the scope of theme support”

Well, that’s not what I’m asking you to do. I’m simply asking if there exists any way to check if we are inside of the builder or not. That is something that, if it existed, should be in your public facing documentation. It is also a reasonable question you or anyone in the community could just answer easily.

Also, you guys answer custom coding questions all the time. It is all over the forums… often. But again, I’m not asking you to “support my custom code” or write anything on my behalf. I provided the code block above to provide some context of how something like what I am asking for would be used. The relevant portion to the questions is only on line 2 of that example:

if (is_the_pro_builder) 

I’m simply asking if this kind of functionality exists. So, ya know, does it?

Hi @simeoned,

Please try the code below. That will let you know if a specific ID has builder data.

$post = get_post( 123 );
if ( CS()->common()->uses_cornerstone( $post ) ) {
  // do something
}

Hope that helps.

Thank you.

@marc_a thanks for the reply with some relevant information. I appreciate that.

The particular use case for what I am trying to do is not really about checking a particular post in the way you have described here. It will be more global than that… that is, it is related to some code I am placing in the footer so it has potential to be sitewide. You see what I mean?

I just want to be able to do one thing if I am looking at a page (any page) in cornerstone and another thing if not. Just a way to detect if the current page is being loaded in cornerstone.

I used your code a moment ago and I see what you are driving at. I’m not sure I am being entirely clear about what I am trying to do with this though. I don’t want to check if Cornerstone was used to build a page… that is too broad. Every page uses it. I want to execute code only in the front end and not if I am editing the page in CS. The reason for this is that the code I am executing works fine when loading the site in the front end but it breaks the builder because of a variable scope issue - that issue is known and not what I am trying to solve.

I just don’t want the code to execute if I am loading a page in the CS builder itself. Please let me know your thoughts.

Hi @simeoned,

Regretfully there is no such way to detect the page is loaded into the builder or not.

Thanks

Man, that’s really too bad. That would be very useful. If a feature like this becomes available, it would be great to know.

Thanks for checking and replying with an answer that was meaningful and not just pawning it off as “out of scope”. Keep up the good work guys

You are welcome @simeoned

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.