gglnltcs_print_results

The BestWebSoft Google Analytics gglnltcs print results function.

Description

Parameters (3)

0. $results
The results.
1. $gglnltcs_metrics_data
The gglnltcs metrics data.
2. $gglnltcs_dimensions_data
The gglnltcs dimensions data.

Usage

  1. if ( !function_exists( 'gglnltcs_print_results' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bestwebsoft-google-analytics/bws-google-analytics.php'; 
  3.  
  4. // The results. 
  5. $results = null; 
  6.  
  7. // The gglnltcs metrics data. 
  8. $gglnltcs_metrics_data = null; 
  9.  
  10. // The gglnltcs dimensions data. 
  11. $gglnltcs_dimensions_data = null; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = gglnltcs_print_results($results, $gglnltcs_metrics_data, $gglnltcs_dimensions_data); 
  15.  

Defined (1)

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

/bws-google-analytics.php  
  1. function gglnltcs_print_results( $results, $gglnltcs_metrics_data, $gglnltcs_dimensions_data ) { 
  2. /** Print results */ 
  3. if ( count( $results->getRows() ) > 0 ) { 
  4. $i = 0; 
  5. $table = '<table class="gglnltcs-results gglnltcs">'; 
  6. $table .= '<tr><th><h3>' . __( 'Results', 'gglnltcs' ) . '</h3></th><td><table class="gglnltcs-table-header gglnltcs" >'; 
  7. $second_table = '<td><div class="gglnltcs-table-body gglnltcs"><table>'; 
  8. foreach ( $results->getColumnHeaders() as $header ) { 
  9. $table .= '<tr>'; 
  10. $table .= '<td>'; 
  11. $table .= isset( $gglnltcs_metrics_data[ $header->name ] ) ? $gglnltcs_metrics_data[ $header->name ]['label'] : $gglnltcs_dimensions_data[ $header->name ]['label']; 
  12. $table .= '</td></tr>'; 
  13. $second_table .= '<tr class="gglnltcs-row-' . ltrim( $header->name, 'ga:' ) . '">'; 
  14. if ( $header->name == 'ga:month' ) { 
  15. $monthes = array( 
  16. '01' => __( 'Jan', 'gglnltcs' ),  
  17. '02' => __( 'Feb', 'gglnltcs' ),  
  18. '03' => __( 'Mar', 'gglnltcs' ),  
  19. '04' => __( 'Apr', 'gglnltcs' ),  
  20. '05' => __( 'May', 'gglnltcs' ),  
  21. '06' => __( 'Jun', 'gglnltcs' ),  
  22. '07' => __( 'Jul', 'gglnltcs' ),  
  23. '08' => __( 'Aug', 'gglnltcs' ),  
  24. '09' => __( 'Sep', 'gglnltcs' ),  
  25. '10' => __( 'Oct', 'gglnltcs' ),  
  26. '11' => __( 'Nov', 'gglnltcs' ),  
  27. '12' => __( 'Dec', 'gglnltcs' ),  
  28. ); 
  29. foreach ( $results->getRows() as $row ) { 
  30. $second_table .= '<td>' . $monthes[ $row[ $i ] ] . '</td>'; 
  31. } else { 
  32. foreach ( $results->getRows() as $row ) { 
  33. $cell = floatval( $row[ $i ] ); 
  34. if ( $header->name == 'ga:avgTimeOnSite' ) { 
  35. $cell = gmdate( 'H : i : s', $cell ); 
  36. } else { 
  37. $cell = round( $cell, 2 ); 
  38. $cell = $cell + 0; 
  39. $second_table .= '<td>' . $cell; 
  40. if ( $header->name == 'ga:visitBounceRate' ) { 
  41. if ( $cell != 0 ) { 
  42. $second_table .= '%'; 
  43. $second_table .= '</td>'; 
  44. $second_table .= '</td></tr>'; 
  45. $i++; 
  46. } /** close foreach. */ 
  47. $table .= '</table></td>'; 
  48. $second_table .= '</table></div></td></tr></table>'; 
  49. $table = array( $table ); 
  50. $table[] = $second_table; 
  51. } else { 
  52. $table .= '<table class="gglnltcs-results gglnltcs"> 
  53. <tr> 
  54. <th><h3>' . _e( 'Results', 'gglnltcs' ) . '</h3></th> 
  55. <td><div class="gglnltcs-bad-results">No results found.<div></td> 
  56. </tr> 
  57. </table>'; 
  58. return $table;