WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. Pat Hawks
    Member
    Posted 1 year 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.

    http://wordpress.org/extend/plugins/jetpack/

  2. designsimply
    Member
    Plugin Contributor

    Posted 1 year 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

About this Topic