Check if Conditional Blocks is Active

Developers who are creating integrations with Conditional Blocks should always remember to check within their code if the Conditional Blocks plugin is active.

Both the free and paid version share the same code structure. It’s worth noting that only one of the plugins can be active at any given time. Each plugin is standalone (not like typical add-on plugins).

Therefore, developer integrations between both versions can be streamlined. You don’t have to worry if the user has installed Conditional Blocks free or Conditional Blocks Pro.

Get the Conditional Blocks version

Since v3.0.1, we’ve included a new constant that will return the current version.

CONDITIONAL_BLOCKS_VERSIONCode language: PHP (php)

Snippet example

We recommend your custom integration checks if Conditional Blocks has the version constant defined, and if the minimum version is required for your integration.

if ( defined( 'CONDITIONAL_BLOCKS_VERSION' ) && version_compare( '3.0.0', CONDITIONAL_BLOCKS_VERSION, '<=' ) ) {
	// Code that requires Conditional Blocks.
}
Code language: PHP (php)

You can then put your custom conditions inside the code block to run the code safely.

Was this page helpful?