bbp_dashboard_widget_right_now

BbPress Dashboard Right Now Widget.

Description

bbp_dashboard_widget_right_now(); 

Adds a dashboard widget with forum statistics


Usage

  1. if ( !function_exists( 'bbp_dashboard_widget_right_now' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/admin/metaboxes.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bbp_dashboard_widget_right_now(); 
  7.  

Defined (1)

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

/includes/admin/metaboxes.php  
  1. function bbp_dashboard_widget_right_now() { 
  2.  
  3. // Get the statistics 
  4. $r = bbp_get_statistics(); ?> 
  5.  
  6. <div class="table table_content"> 
  7.  
  8. <p class="sub"><?php esc_html_e( 'Discussion', bbpress ); ?></p> 
  9.  
  10. <table> 
  11.  
  12. <tr class="first"> 
  13.  
  14. <?php 
  15. $num = $r['forum_count']; 
  16. $text = _n( 'Forum', 'Forums', $r['forum_count'], bbpress ); 
  17. if ( current_user_can( 'publish_forums' ) ) { 
  18. $link = add_query_arg( array( 'post_type' => bbp_get_forum_post_type() ), get_admin_url( null, 'edit.php' ) ); 
  19. $num = '<a href="' . esc_url( $link ) . '">' . $num . '</a>'; 
  20. $text = '<a href="' . esc_url( $link ) . '">' . $text . '</a>'; 
  21. ?> 
  22.  
  23. <td class="first b b-forums"><?php echo $num; ?></td> 
  24. <td class="t forums"><?php echo $text; ?></td> 
  25.  
  26. </tr> 
  27.  
  28. <tr> 
  29.  
  30. <?php 
  31. $num = $r['topic_count']; 
  32. $text = _n( 'Topic', 'Topics', $r['topic_count'], bbpress ); 
  33. if ( current_user_can( 'publish_topics' ) ) { 
  34. $link = add_query_arg( array( 'post_type' => bbp_get_topic_post_type() ), get_admin_url( null, 'edit.php' ) ); 
  35. $num = '<a href="' . esc_url( $link ) . '">' . $num . '</a>'; 
  36. $text = '<a href="' . esc_url( $link ) . '">' . $text . '</a>'; 
  37. ?> 
  38.  
  39. <td class="first b b-topics"><?php echo $num; ?></td> 
  40. <td class="t topics"><?php echo $text; ?></td> 
  41.  
  42. </tr> 
  43.  
  44. <tr> 
  45.  
  46. <?php 
  47. $num = $r['reply_count']; 
  48. $text = _n( 'Reply', 'Replies', $r['reply_count'], bbpress ); 
  49. if ( current_user_can( 'publish_replies' ) ) { 
  50. $link = add_query_arg( array( 'post_type' => bbp_get_reply_post_type() ), get_admin_url( null, 'edit.php' ) ); 
  51. $num = '<a href="' . esc_url( $link ) . '">' . $num . '</a>'; 
  52. $text = '<a href="' . esc_url( $link ) . '">' . $text . '</a>'; 
  53. ?> 
  54.  
  55. <td class="first b b-replies"><?php echo $num; ?></td> 
  56. <td class="t replies"><?php echo $text; ?></td> 
  57.  
  58. </tr> 
  59.  
  60. <?php if ( bbp_allow_topic_tags() ) : ?> 
  61.  
  62. <tr> 
  63.  
  64. <?php 
  65. $num = $r['topic_tag_count']; 
  66. $text = _n( 'Topic Tag', 'Topic Tags', $r['topic_tag_count'], bbpress ); 
  67. if ( current_user_can( 'manage_topic_tags' ) ) { 
  68. $link = add_query_arg( array( 'taxonomy' => bbp_get_topic_tag_tax_id(), 'post_type' => bbp_get_topic_post_type() ), get_admin_url( null, 'edit-tags.php' ) ); 
  69. $num = '<a href="' . esc_url( $link ) . '">' . $num . '</a>'; 
  70. $text = '<a href="' . esc_url( $link ) . '">' . $text . '</a>'; 
  71. ?> 
  72.  
  73. <td class="first b b-topic_tags"><span class="total-count"><?php echo $num; ?></span></td> 
  74. <td class="t topic_tags"><?php echo $text; ?></td> 
  75.  
  76. </tr> 
  77.  
  78. <?php endif; ?> 
  79.  
  80.  
  81. </table> 
  82.  
  83. </div> 
  84.  
  85.  
  86. <div class="table table_discussion"> 
  87.  
  88. <p class="sub"><?php esc_html_e( 'Users & Moderation', bbpress ); ?></p> 
  89.  
  90. <table> 
  91.  
  92. <tr class="first"> 
  93.  
  94. <?php 
  95. $num = $r['user_count']; 
  96. $text = _n( 'User', 'Users', $r['user_count'], bbpress ); 
  97. if ( current_user_can( 'edit_users' ) ) { 
  98. $link = get_admin_url( null, 'users.php' ); 
  99. $num = '<a href="' . esc_url( $link ) . '">' . $num . '</a>'; 
  100. $text = '<a href="' . esc_url( $link ) . '">' . $text . '</a>'; 
  101. ?> 
  102.  
  103. <td class="b b-users"><span class="total-count"><?php echo $num; ?></span></td> 
  104. <td class="last t users"><?php echo $text; ?></td> 
  105.  
  106. </tr> 
  107.  
  108. <?php if ( isset( $r['topic_count_hidden'] ) ) : ?> 
  109.  
  110. <tr> 
  111.  
  112. <?php 
  113. $num = $r['topic_count_hidden']; 
  114. $text = _n( 'Hidden Topic', 'Hidden Topics', $r['topic_count_hidden'], bbpress ); 
  115. $link = add_query_arg( array( 'post_type' => bbp_get_topic_post_type() ), get_admin_url( null, 'edit.php' ) ); 
  116. if ( '0' !== $num ) { 
  117. $link = add_query_arg( array( 'post_status' => bbp_get_spam_status_id() ), $link ); 
  118. $num = '<a href="' . esc_url( $link ) . '" title="' . esc_attr( $r['hidden_topic_title'] ) . '">' . $num . '</a>'; 
  119. $text = '<a class="waiting" href="' . esc_url( $link ) . '" title="' . esc_attr( $r['hidden_topic_title'] ) . '">' . $text . '</a>'; 
  120. ?> 
  121.  
  122. <td class="b b-hidden-topics"><?php echo $num; ?></td> 
  123. <td class="last t hidden-replies"><?php echo $text; ?></td> 
  124.  
  125. </tr> 
  126.  
  127. <?php endif; ?> 
  128.  
  129. <?php if ( isset( $r['reply_count_hidden'] ) ) : ?> 
  130.  
  131. <tr> 
  132.  
  133. <?php 
  134. $num = $r['reply_count_hidden']; 
  135. $text = _n( 'Hidden Reply', 'Hidden Replies', $r['reply_count_hidden'], bbpress ); 
  136. $link = add_query_arg( array( 'post_type' => bbp_get_reply_post_type() ), get_admin_url( null, 'edit.php' ) ); 
  137. if ( '0' !== $num ) { 
  138. $link = add_query_arg( array( 'post_status' => bbp_get_spam_status_id() ), $link ); 
  139. $num = '<a href="' . esc_url( $link ) . '" title="' . esc_attr( $r['hidden_reply_title'] ) . '">' . $num . '</a>'; 
  140. $text = '<a class="waiting" href="' . esc_url( $link ) . '" title="' . esc_attr( $r['hidden_reply_title'] ) . '">' . $text . '</a>'; 
  141. ?> 
  142.  
  143. <td class="b b-hidden-replies"><?php echo $num; ?></td> 
  144. <td class="last t hidden-replies"><?php echo $text; ?></td> 
  145.  
  146. </tr> 
  147.  
  148. <?php endif; ?> 
  149.  
  150. <?php if ( bbp_allow_topic_tags() && isset( $r['empty_topic_tag_count'] ) ) : ?> 
  151.  
  152. <tr> 
  153.  
  154. <?php 
  155. $num = $r['empty_topic_tag_count']; 
  156. $text = _n( 'Empty Topic Tag', 'Empty Topic Tags', $r['empty_topic_tag_count'], bbpress ); 
  157. $link = add_query_arg( array( 'taxonomy' => bbp_get_topic_tag_tax_id(), 'post_type' => bbp_get_topic_post_type() ), get_admin_url( null, 'edit-tags.php' ) ); 
  158. $num = '<a href="' . esc_url( $link ) . '">' . $num . '</a>'; 
  159. $text = '<a class="waiting" href="' . esc_url( $link ) . '">' . $text . '</a>'; 
  160. ?> 
  161.  
  162. <td class="b b-hidden-topic-tags"><?php echo $num; ?></td> 
  163. <td class="last t hidden-topic-tags"><?php echo $text; ?></td> 
  164.  
  165. </tr> 
  166.  
  167. <?php endif; ?> 
  168.  
  169.  
  170. </table> 
  171.  
  172. </div> 
  173.  
  174.  
  175. <div class="versions"> 
  176.  
  177. <span id="wp-version-message"> 
  178. <?php printf( __( 'You are using <span class="b">bbPress %s</span>.', bbpress ), bbp_get_version() ); ?> 
  179. </span> 
  180.  
  181. </div> 
  182.  
  183. <br class="clear" /> 
  184.  
  185. <?php 
  186.