Best practice to detect ClassicPress via a plugin?

For my own plugins I want all of them be fully compatible with ClassicPress. I KNOW they are technically all compatible - but I mean the user guiding etc., also strings, labels, texts for the user.

Since I want the best user experience possible, I need to change some strings in help texts etc. depending on WP or CP being there. And for that I need a fully reliable and future proof way to detect if someone runs WP or ClassicPress.

Is there any function or method you consider best practice?

Thanks in advance!

Best way to detect ClassicPress is the following

function is_classicpress() {  	
    if ( function_exists( 'classicpress_version' ) ) {
        return true;
    } else {
        return false;
    }
}
3 Likes

Perfect, thank you! :slight_smile:

No worries!

And I give up, I can’t make it look pretty. I tried :man_shrugging:

function is_classicpress() { 
     if ( function_exists( 'classicpress_version' ) ) {
          return true;
     } else {
          return false;
     }
}
4 Likes

Thank you! How did you fight with the text editor to let you do that?

A code block opens with ```

and then the code block starts on a new line. You close the block again on a new line with ```

The only issue is the tabs, which doesn’t work, so it is a lot of ramming on the spacebar :wink:

5 Likes

Uh! Makes sense, thank you :slight_smile:

Sometimes I wish I didn’t understand code like this, as it means I’m spending wayyy too much time inside a computer. But understand I do, lol. And I was actually just thinking of this very if/and code about an hour ago. Karma. TY for code block open ``` – that should come in handy at some point.

OK, back to learning React. Now that’s a heavy lift. :slight_smile:

2 Likes