MonsterInsights_Report

The Google Analytics for WordPress by MonsterInsights MonsterInsights Report class.

Defined (1)

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

/includes/admin/abstract-report.php  
  1. abstract class MonsterInsights_Report { 
  2.  
  3. public $report_name; 
  4.  
  5. public $report_hook; 
  6.  
  7. public $range; 
  8.  
  9. /** 
  10. * Holds the GA client object if using oAuth. 
  11. * @access public 
  12. * @since 6.0.0 
  13. * @var MonsterInsights_GA_Client $client GA client object. 
  14. */ 
  15. public $client; 
  16.  
  17. /** 
  18. * Primary class constructor. 
  19. * @access public 
  20. * @since 6.0.0 
  21. */ 
  22. public function __construct( $range = array() ) { 
  23.  
  24. $this->range = monsterinsights_get_report_date_range(); 
  25.  
  26. // filter to add tab for this report 
  27. add_filter( 'monsterinsights_get_reports', array( $this, 'add_report' ), 10, 1 ); 
  28.  
  29. // filter to show the view for this report 
  30. add_action( 'monsterinsights_tab_reports_' . $this->report_hook, array( $this, 'show_report' ), 10, 1 ); 
  31.  
  32. add_action( 'monsterinsights_add_aggregate_data', array( $this, 'add_report_data' ), 10, 2 ); 
  33. add_action( 'monsterinsights_delete_aggregate_data', array( $this, 'delete_report_data' ), 10, 2 ); 
  34.  
  35.  
  36. // Adds the report to the array of reports. 
  37. public function add_report( $reports ) { 
  38. $reports[ $this->report_hook ] = $this->report_name; 
  39. return $reports; 
  40.  
  41. abstract public function add_report_data( $client, $id ); // Adds/Refreshes the data 
  42. abstract public function get_report_data(); // Gets the data 
  43. abstract public function delete_report_data(); // Removes report data 
  44. abstract public function show_report(); // Outputs the report. 
  45.  
  46. /** 
  47. * Get the start and and date for aggregation functionality. 
  48. * @return array 
  49. */ 
  50. protected function get_date_range() { 
  51. return $this->range; 
  52.  
  53. /** 
  54. * Get the api limit for aggregation functionality. 
  55. * By default Google will return 1000 rows at most. They will return less in certain circumstances. 
  56. * For example, the countries query will never return more than 300 rows as there's not more than 300 values 
  57. * for ga:countries dimension. If you are a large site you might need to use this filter to lower the number requested.  
  58. * We only request 300, as it's the max number for the largest report we need (by country maxes at 300 countries). 
  59. * In the future, we'll likely have each report use the limit returned in this function, or a report-set default limit,  
  60. * whichever is lower. 
  61. * @return int 
  62. */ 
  63. protected function get_api_max_limit() { 
  64. return apply_filters( 'monsterinsights_reporting_get_max_api_limit', 300 );