stats_dashboard_widget_control

Stats Dashboard Widget Control.

Description

stats_dashboard_widget_control(); 

Usage

  1. if ( !function_exists( 'stats_dashboard_widget_control' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'jetpack-by-wordpress-com/modules/stats.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = stats_dashboard_widget_control(); 
  7.  

Defined (1)

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

/modules/stats.php  
  1. function stats_dashboard_widget_control() { 
  2. $periods = array( 
  3. '1' => __( 'day', jetpack ),  
  4. '7' => __( 'week', jetpack ),  
  5. '31' => __( 'month', jetpack ),  
  6. ); 
  7. $intervals = array( 
  8. '1' => __( 'the past day', jetpack ),  
  9. '7' => __( 'the past week', jetpack ),  
  10. '31' => __( 'the past month', jetpack ),  
  11. '90' => __( 'the past quarter', jetpack ),  
  12. '365' => __( 'the past year', jetpack ),  
  13. ); 
  14. $defaults = array( 
  15. 'top' => 1,  
  16. 'search' => 7,  
  17. ); 
  18.  
  19.  
  20. if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['widget_id'] ) && 'dashboard_stats' == $_POST['widget_id'] ) { 
  21. if ( isset( $periods[ $_POST['chart'] ] ) ) 
  22. $options['chart'] = $_POST['chart']; 
  23. foreach ( array( 'top', 'search' ) as $key ) { 
  24. if ( isset( $intervals[ $_POST[$key] ] ) ) 
  25. $options[$key] = $_POST[$key]; 
  26. else 
  27. $options[$key] = $defaults[$key]; 
  28. update_option( 'stats_dashboard_widget', $options ); 
  29. ?> 
  30. <p> 
  31. <label for="chart"><?php _e( 'Chart stats by' , jetpack ); ?></label> 
  32. <select id="chart" name="chart"> 
  33. <?php 
  34. foreach ( $periods as $val => $label ) { 
  35. ?> 
  36. <option value="<?php echo $val; ?>"<?php selected( $val, $options['chart'] ); ?>><?php echo esc_html( $label ); ?></option> 
  37. <?php 
  38. ?> 
  39. </select>. 
  40. </p> 
  41.  
  42. <p> 
  43. <label for="top"><?php _e( 'Show top posts over', jetpack ); ?></label> 
  44. <select id="top" name="top"> 
  45. <?php 
  46. foreach ( $intervals as $val => $label ) { 
  47. ?> 
  48. <option value="<?php echo $val; ?>"<?php selected( $val, $options['top'] ); ?>><?php echo esc_html( $label ); ?></option> 
  49. <?php 
  50. ?> 
  51. </select>. 
  52. </p> 
  53.  
  54. <p> 
  55. <label for="search"><?php _e( 'Show top search terms over', jetpack ); ?></label> 
  56. <select id="search" name="search"> 
  57. <?php 
  58. foreach ( $intervals as $val => $label ) { 
  59. ?> 
  60. <option value="<?php echo $val; ?>"<?php selected( $val, $options['search'] ); ?>><?php echo esc_html( $label ); ?></option> 
  61. <?php 
  62. ?> 
  63. </select>. 
  64. </p> 
  65. <?php