jssb_process_request

The Jetpack - Status Board jssb process request function.

Description

jssb_process_request(); 

Usage

  1. if ( !function_exists( 'jssb_process_request' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'jetpack-status-board/jetpack-status-board.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = jssb_process_request(); 
  7.  

Defined (1)

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

/jetpack-status-board.php  
  1. function jssb_process_request() { 
  2. global $wp_query; 
  3. if ( ! isset( $wp_query->query_vars['jssb-stats'] ) ) 
  4. return; 
  5.  
  6. if ( ! isset( $wp_query->query_vars['jssb-verify'] ) ) { 
  7. jssb_output( array( 'graph' =>  
  8. array( 'title' => 'Jetpack Stats Error',  
  9. error =>  
  10. array( 'message' => 'No Verification Token',  
  11. 'detail' => 'Please use the supplied link in wp-admin to add this graph to Status Board' ) ) ) ); 
  12.  
  13. if ( $wp_query->query_vars['jssb-verify'] && $wp_query->query_vars['jssb-verify'] != md5( get_settings('admin_email') ) ) { 
  14. jssb_output( array( 'graph' =>  
  15. array( 'title' => 'Jetpack Stats Error',  
  16. error =>  
  17. array( 'message' => 'Invalid Verification Token',  
  18. 'detail' => 'Please use the supplied link in wp-admin to add this graph to Status Board' ) ) ) ); 
  19.  
  20. $stats = array(); 
  21. $days = 7; 
  22. while ( $days >= 0 ) { 
  23. $end = ( $days > 0 ) ? date( 'Y-m-d', strtotime( '-' . $days . 'day' ) ) : date( 'Y-m-d' ); 
  24. $daily_visits = stats_get_csv( 'views', array( 'days' => 1, 'end' => $end ) ); 
  25.  
  26. $views = ( ! empty( $daily_visits[0]['views'] ) ) ? $daily_visits[0]['views'] : 0; 
  27. $stats[] = array( 'title' => date( 'n\/j', strtotime( $end ) ), 'value' => $views ); 
  28. $days--; 
  29.  
  30. $data = array(); 
  31. $data['graph']['title'] = get_bloginfo( 'name' ); 
  32. $data['graph']['total'] = true; 
  33. $data['graph']['datasequences'][] = array( 'title' => __( 'Daily Views', 'js-statusboard-txt' ), 'datapoints' => $stats ); 
  34.  
  35. jssb_output( apply_filters( 'jssb_output', $data ) );