title: Detect Yoast SEO plugin
body: <p>I want to detect Yoast SEO. I already use this function:</p>
  
  <pre><code>function active( $plugin ) {
      $network_active = false;
      if ( is_multisite() ) {
          $plugins = get_site_option( 'active_sitewide_plugins' );
          if ( isset( $plugins[$plugin] ) ) {
              $network_active = true;
          }
      }
      return in_array( $plugin, get_option( 'active_plugins' ) ) || $network_active;
  }
  
  if ( active( 'wordpress-seo/wp-seo.php' ) {
  </code></pre>
  
  <p>And that works fine. But if Yoast ever thinks of renaming <code>wordpress-seo/wp-seo.php</code>, this function becomes useless. So we need to add an backup, something which is hard to change, like the <code>WPSEO_VERSION</code> constant:</p>
  
  <pre><code>if ( active( 'wordpress-seo/wp-seo.php' ) {
      // activate
  } elseif( defined( 'WPSEO_VERSION' )) {
      // activate
  } else {
      // deactivate
  }
  </code></pre>
  
  <p>This line <code>if( defined( 'WPSEO_VERSION' )) {</code> for some reason does not detect Yoast.. how is that possible?</p>
  
  <p>Thanks everyone.</p>