Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 17th, 2012  |  syntax: None  |  size: 1.00 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. function custom_post_dashboard() {
  3.  
  4.         $dashboard_custom_post_types= Array(
  5.                 //'投稿タイプ名',
  6.                 'foo',
  7.                 'bar',
  8.                 'hoge',
  9.         );
  10.  
  11.         foreach($dashboard_custom_post_types as $custom_post_type) {
  12.                 global $wp_post_types;
  13.                 $num_post_type = wp_count_posts($custom_post_type);
  14.                 $num = number_format_i18n($num_post_type->publish);
  15.                 $text = _n( $wp_post_types[$custom_post_type]->labels->singular_name, $wp_post_types[$custom_post_type]->labels->name, $num_post_type->publish );
  16.                 $capability = $wp_post_types[$custom_post_type]->cap->edit_posts;
  17.  
  18.                 if (current_user_can($capability)) {
  19.                         $num = "<a href='edit.php?post_type=" . $custom_post_type . "'>$num</a>";
  20.                         $text = "<a href='edit.php?post_type=" . $custom_post_type . "'>$text</a>";
  21.                 }
  22.  
  23.                 echo '<tr>';
  24.                 echo '<td class="first b b_' . $custom_post_type . '">' . $num . '</td>';
  25.                 echo '<td class="t ' . $custom_post_type . '">' . $text . '</td>';
  26.                 echo '</tr>';
  27.         }
  28. }
  29. add_action('right_now_content_table_end', 'custom_post_dashboard');
  30. ?>