rozanchetta

wordpress - CPTs no Box "Agora" do Painel

Sep 25th, 2011
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.55 KB | None | 0 0
  1. <?php
  2. /* Adiciona os CPTs ao Box "Agora" no Painel de Administração */
  3. function wph_right_now_content_table_end() {
  4. $args = array(
  5. 'public' => true ,
  6. '_builtin' => false
  7. );
  8. $output = 'object';
  9. $operator = 'and';
  10.  
  11. $post_types = get_post_types( $args , $output , $operator );
  12. foreach( $post_types as $post_type ) {
  13. $num_posts = wp_count_posts( $post_type->name );
  14. $num = number_format_i18n( $num_posts->publish );
  15. $text = _n( $post_type->labels->singular_name, $post_type->labels->name , intval( $num_posts->publish ) );
  16. if ( current_user_can( 'edit_posts' ) ) {
  17. $num = "<a href='edit.php?post_type=$post_type->name'>$num</a>";
  18. $text = "<a href='edit.php?post_type=$post_type->name'>$text</a>";
  19. }
  20. echo '<tr><td class="first b b-' . $post_type->name . '">' . $num . '</td>';
  21. echo '<td class="t ' . $post_type->name . '">' . $text . '</td></tr>';
  22. }
  23. $taxonomies = get_taxonomies( $args , $output , $operator );
  24. foreach( $taxonomies as $taxonomy ) {
  25. $num_terms  = wp_count_terms( $taxonomy->name );
  26. $num = number_format_i18n( $num_terms );
  27. $text = _n( $taxonomy->labels->singular_name, $taxonomy->labels->name , intval( $num_terms ));
  28. if ( current_user_can( 'manage_categories' ) ) {
  29. $num = "<a href='edit-tags.php?taxonomy=$taxonomy->name'>$num</a>";
  30. $text = "<a href='edit-tags.php?taxonomy=$taxonomy->name'>$text</a>";
  31. }
  32. echo '<tr><td class="first b b-' . $taxonomy->name . '">' . $num . '</td>';
  33. echo '<td class="t ' . $taxonomy->name . '">' . $text . '</td></tr>';
  34. }
  35. }
  36. add_action( 'right_now_content_table_end' , 'wph_right_now_content_table_end' );
Advertisement
Add Comment
Please, Sign In to add comment