Check if Cornerstone is loaded

Greetings!

I had put in a ticket back in July (https://theme.co/apex/forum/t/cannot-redefine-property-inflector-on-cornerstone-load/37728) for a client site where Cornerstone is not loading. I think I might have an idea as to what causes it – we have a custom plugin that provides different views of a page depending on their access level (this is all done through Restrict Content Pro), and I think that when you select Edit in Cornerstone, it is trying to load Cornerstone twice…once for each view.

I wonder if it would be possible to add some code to check whether Cornerstone has already loaded, so I can create a conditional on RCP that would prevent a second attempt to load Cornerstone – or something else, if you have any better ideas.

Any help you could provide would be great!

Hey @launchcatapult,

Regretfully, there’s currently don’t see a hook for this. I’ll post this in our issue tracker as an enhancement or feature request. Just note though that we could not give an ETA nor I guarantee this will be supported but please stay tuned.

Thanks.

Hi @launchcatapult,

Thanks for your patience. I came across the issue in our tracker and wanted to chime in over here. Here is some code that demonstrates a few ways you can detect if Cornerstone is active in a given context.

$is_cornerstone_preview_frame = did_action( 'cs_before_preview_frame');
$is_cornerstone_preview_render_request = did_action('cs_element_rendering');

Hopefully this helps you get to the bottom of solving the issue between Cornerstone and your customization.