When is is_admin() available?

I see a lot of plugins that consist of a class that is instantiated in the same file, eg:

class My_Plugin {

function __construct() {
add_action(‘init’, array( __CLASS__, ‘baz’ ) );

static function baz() {
// some stuff that should happen in admin


new My_Plugin();

Now, it would work to wrap the inner workings of each function in a conditional, but could I wrap the add_action() statements in if( is_admin() ) instead, and keep from bloating the site’s respective lists of filters?

Read more here:: When is is_admin() available?

Leave a Reply

Your email address will not be published. Required fields are marked *