Yoast_GA_Dashboards_Table_Generate

Dashboards table inherited class.

Defined (1)

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

/admin/dashboards/drivers/class-admin-dashboards-table-generate.php  
  1. class Yoast_GA_Dashboards_Table_Generate extends Yoast_GA_Dashboards_Driver_Generate { 
  2.  
  3. /** 
  4. * @var string - The ID of requested dimension 
  5. */ 
  6. protected $dimension_id; 
  7.  
  8. /** 
  9. * Construct will set all values and generate the date for response 
  10. */ 
  11. public function __construct() { 
  12. parent::__construct(); 
  13.  
  14. $this->set_dimension_id(); 
  15.  
  16. $this->generate(); 
  17.  
  18. /** 
  19. * Putting $this->data and $this->mapping and give them back as a json encoded string 
  20. * @return string 
  21. */ 
  22. public function get_json() { 
  23. $return = array( 
  24. 'data' => $this->escape_strings_array( $this->data ),  
  25. ); 
  26.  
  27. return json_encode( $return ); 
  28.  
  29. /** 
  30. * Filtering the current data to eliminate all values which are not in given period 
  31. * @param integer $google_data 
  32. * @return integer 
  33. */ 
  34. protected function filter_google_data( $google_data ) { 
  35. return $google_data['value']; 
  36.  
  37. /** 
  38. * Setting the dimension_id for current request. Based on dimension_id the graph_type will be set, this to 
  39. * handle the request correctly 
  40. */ 
  41. private function set_dimension_id() { 
  42. $this->dimension_id = filter_input( INPUT_GET, 'dimension_id' ); 
  43.  
  44. if ( ! empty( $this->dimension_id ) ) { 
  45. $this->graph_type = 'ga:dimension' . $this->dimension_id; 
  46. else { 
  47. $this->graph_type = $this->graph_type; 
  48.  
  49. /** 
  50. * Generate the data for the frontend based on the $google_data 
  51. */ 
  52. private function generate() { 
  53. $google_data = $this->get_google_data(); 
  54. $this->data = is_array( $google_data ) ? array_values( $google_data ) : array(); 
  55.