Jetpack by WordPress.com
Using Photon in plugins (2 posts)

  1. Pat Hawks
    Posted 3 years ago #

    What is the best way for a plugin developer to detect Photon support?

    if (function_exists('jetpack_photon_url')) ?

    I don't want to just start writing raw URLs, since the Photon terms of service state that Photon should only be used by sites that have Jetpack enabled.


  2. designsimply
    Plugin Contributor

    Posted 3 years ago #

    Thanks for asking about this! If the Photon module is not active, the user has made a choice to not activate it and plugins should respect that choice.

    First, to determine if Jetpack is installed and can generate photon URLs, use the function you've already posted in your original question:

    function_exists( ‘jetpack_photon_url' )

    Then, to determine if Photon is an active Jetpack module, use this:

    class_exists( 'Jetpack' ) && method_exists( 'Jetpack', 'get_active_modules' ) && in_array( 'photon', Jetpack::get_active_modules() )

    I have also updated the Photon support page with this info: http://developer.wordpress.com/docs/photon/

    Aside: I paraphrased this from a conversation I had with the Jetpack developers. So, props
    mdawaffe, viper007bond, and tmoorewp. :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Jetpack by WordPress.com
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic