jetpack_stats_post_table

Set header for column that allows to go to WordPress.com to see an entry's stats.

Description

jetpack_stats_post_table( (array) $columns ); 

Parameters (1)

0. $columns (array)
An array of column names.

Usage

  1. if ( !function_exists( 'jetpack_stats_post_table' ) ) { 
  2. require_once '/modules/stats.php'; 
  3.  
  4. // An array of column names. 
  5. $columns = array(); 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = jetpack_stats_post_table($columns); 
  9.  

Defined (1)

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

/modules/stats.php  
  1. function jetpack_stats_post_table( $columns ) { // Adds a stats link on the edit posts page 
  2. if ( ! current_user_can( 'view_stats' ) || ! Jetpack::is_user_connected() ) { 
  3. return $columns; 
  4. // Array-Fu to add before comments 
  5. $pos = array_search( 'comments', array_keys( $columns ) ); 
  6. if ( ! is_int( $pos ) ) { 
  7. return $columns; 
  8. $chunks = array_chunk( $columns, $pos, true ); 
  9. $chunks[0]['stats'] = esc_html__( 'Stats', 'jetpack' ); 
  10.  
  11. return call_user_func_array( 'array_merge', $chunks );