Advertisement
designbymerovingi

Show reference column in myCRED Log

Dec 1st, 2014
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.01 KB | None | 0 0
  1. /**
  2.  * Add Column Header
  3.  * Add in the custom log column header on the main log page in the
  4.  * admin area.
  5.  * @version 1.0
  6.  */
  7. add_filter( 'mycred_log_column_headers', 'mycred_pro_admin_log_columns', 10, 2 );
  8. function mycred_pro_admin_log_columns( $columns, $module ) {
  9.  
  10.     // Only appliable for admin area
  11.     if ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || ! is_admin() ) return $columns;
  12.  
  13.     // Only applicable for myCRED Log page and not personal log
  14.     if ( isset( $module->args['ctype'] ) && isset( $_GET['page'] ) && $_GET['page'] != $module->args['ctype'] . '_history' )
  15.         $columns['column-ref'] = 'Reference';
  16.  
  17.     return $columns;
  18.  
  19. }
  20.  
  21. /**
  22.  * Render Ref Column
  23.  * Renders the result of the reference column.
  24.  * @version 1.0
  25.  */
  26. add_filter( 'mycred_log_column-ref', 'mycred_pro_custom_log_column', 10, 2 );
  27. function mycred_pro_custom_log_column( $content, $entry ) {
  28.  
  29.     $refs = mycred_get_all_references();
  30.     if ( isset( $refs[ $entry->ref ] ) )
  31.         return $refs[ $entry->ref ];
  32.  
  33.     return $entry->ref;
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement