Yoast_GA_Utils

Utilities class.

Defined (1)

The class is defined in the following location(s).

/includes/class-utils.php  
  1. class Yoast_GA_Utils { 
  2.  
  3. /** 
  4. * Check if WordPress SEO or WordPress SEO Premium is active 
  5. * @return bool 
  6. */ 
  7. public static function wp_seo_active() { 
  8. $wp_seo_active = false; 
  9.  
  10. // Makes sure is_plugin_active is available when called from front end 
  11. include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); 
  12. if ( is_plugin_active( 'wordpress-seo/wp-seo.php' ) || is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' ) ) { 
  13. $wp_seo_active = true; 
  14.  
  15. return $wp_seo_active; 
  16.  
  17. /** 
  18. * Calculate the date difference, return the amount of hours between the two dates 
  19. * @param integer $last_run datetime 
  20. * @param integer $now datetime 
  21. * @return int 
  22. */ 
  23. public static function hours_between( $last_run, $now ) { 
  24. $seconds = max( ( $now - $last_run ), 1 ); 
  25. $hours = ( $seconds / 3600 ); 
  26.  
  27. return floor( $hours ); 
  28.