How do I detect ClassicPress (vs WordPress) and the latest version?

How do I code a simple ClassicPress detection code in PHP?

I have this now for WordPress:

<?php
$wp_rec_version_check = version_compare( '6.1.1', $wp_version, '<=' );

How do I detect if ClassicPress is installed, and how do I get its version? Is there a $cp_version global available?

My goal is to have something similar to this:

<?php
if ( function_exists( 'is_classicpress' ) && version_compare( 'x.x.x', $cp_version, '<=' ) ) {
    echo 'You should install the latest version of ClassicPress';
}

You can use classicpress_version():

<?php
if ( function_exists( 'classicpress_version' ) && version_compare( 'x.x.x', classicpress_version(), '<=' ) ) {
    echo 'You should install the latest version of ClassicPress';
}

Edit: the global is $cp_version.

2 Likes

Thanks, Simone.

What does classicpress_version() return? Same thing as $cp_version?

Yes, it just return $cp_version (code).

1 Like

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