Check if Jetpack Modules Are Enabled

You may have code that relies on certain JetPack functions. If so, there’s a simple way to check if the module you need is enabled:

if ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'photon' ) ) :
endif;

Here’s some popular module names you might be looking for:

  • carousel
  • comments
  • contact-form
  • custom-css
  • enhanced-distribution
  • gplus-authorship
  • gravatar-hovercards
  • infinite-scroll
  • json-api
  • latex
  • likes
  • markdown
  • minileven
  • monitor
  • notes
  • omnisearch
  • photon
  • post-by-email
  • publicize
  • related-posts
  • sharedaddy
  • shortcodes
  • shortlinks
  • sso
  • stats
  • subscriptions
  • tiled-gallery
  • vaultpress
  • videopress
  • widget-visibility
  • widgets

This post was edited and updated when JetPack introduced the is_module_active function.

About Devin

I am a developer based in Austin, Texas. I run a little theme shop called DevPress and help manage a WooCommerce shop with Universal Yums. Find me on twitter @devinsays.

6 Responses

  1. This will still evaluate to true if Jetpack is de-activated after the option has been set at some point. Adding a check for the class seems to help:

    if ( class_exists( 'Jetpack', false ) ) {
    $jetpack_active_modules = get_option('jetpack_active_modules');
    if ( $jetpack_active_modules && in_array( 'sharedaddy', $jetpack_active_modules ) ) {
    // We're good to go!
    }
    }

  2. We just committed a new function to Jetpack Trunk, and it should be enabled in the next release, Jetpack::is_module_active()

    http://plugins.trac.wordpress.org/changeset/716884

    Then you can just call:

    if( class_exists( ‘Jetpack’ ) && Jetpack::is_module_active( ‘contact-form’ ) ) {}

    Or at least, you will once the next version releases, and the user has their Jetpack updated. :) If you’d like to preserve the backward compatability, you can just do:

    if( class_exists( ‘Jetpack’ ) && in_array( ‘contact-form’, Jetpack::get_active_modules() ) {}

Leave a Reply