Yoast_GA_Dashboards_Data

This class is used to store and get the data of the dashboards.

Defined (1)

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

/admin/dashboards/class-admin-dashboards-data.php  
  1. class Yoast_GA_Dashboards_Data { 
  2.  
  3. /** 
  4. * Get a data object 
  5. * @param string $type 
  6. * @return array 
  7. */ 
  8. public static function get( $type ) { 
  9. $option = get_option( 'yst_ga_' . $type ); 
  10.  
  11. if ( false === $option ) { 
  12. // Option does not exist, abort 
  13. return array(); 
  14.  
  15. // @TODO loop through transient to get the correct date range 
  16.  
  17. return $option; 
  18.  
  19. /** 
  20. * Save a data object 
  21. * @param string $type 
  22. * @param array $value 
  23. * @param string $start_date 
  24. * @param string $end_date 
  25. * @param string $store_as 
  26. * @return bool 
  27. */ 
  28. public static function set( $type, $value, $start_date, $end_date, $store_as ) { 
  29. $store = array( 
  30. 'store_as' => $store_as,  
  31. 'type' => $type,  
  32. 'start_date' => $start_date,  
  33. 'end_date' => $end_date,  
  34. 'value' => $value,  
  35. ); 
  36.  
  37. return update_option( 'yst_ga_' . $type, $store ); 
  38.  
  39. /** 
  40. * Reset an option of the GA dashboards storage engine 
  41. * @param string $type 
  42. * @return bool 
  43. */ 
  44. public static function reset( $type ) { 
  45. return update_option( 'yst_ga_' . $type, array() );