| 1399 | * bbPress Dashboard Right Now Widget |
| 1400 | * |
| 1401 | * Adds a dashboard widget with forum statistics |
| 1402 | * |
| 1403 | * @todo Check for updates and show notice |
| 1404 | * |
| 1405 | * @since bbPress (r2770) |
| 1406 | * |
| 1407 | * @uses bbp_get_statistics() To get the forum statistics |
| 1408 | * @uses current_user_can() To check if the user is capable of doing things |
| 1409 | * @uses get_admin_url() To get the administration url |
| 1410 | * @uses add_query_arg() To add custom args to the url |
| 1411 | * @uses do_action() Calls 'bbp_dashboard_widget_right_now_content_table_end' |
| 1412 | * below the content table |
| 1413 | * @uses do_action() Calls 'bbp_dashboard_widget_right_now_table_end' |
| 1414 | * below the discussion table |
| 1415 | * @uses do_action() Calls 'bbp_dashboard_widget_right_now_discussion_table_end' |
| 1416 | * below the discussion table |
| 1417 | * @uses do_action() Calls 'bbp_dashboard_widget_right_now_end' below the widget |
| 1418 | */ |
| 1419 | function bbp_dashboard_widget_right_now() { |
| 1420 | global $bbp; |
| 1421 | |
| 1422 | // Get the statistics and extract them |
| 1423 | extract( bbp_get_statistics(), EXTR_SKIP ); ?> |
| 1424 | |
| 1425 | <div class="table table_content"> |
| 1426 | |
| 1427 | <p class="sub"><?php _e( 'Content', 'bbpress' ); ?></p> |
| 1428 | |
| 1429 | <table> |
| 1430 | |
| 1431 | <tr class="first"> |
| 1432 | |
| 1433 | <?php |
| 1434 | $num = $forum_count; |
| 1435 | $text = _n( 'Forum', 'Forums', $forum_count, 'bbpress' ); |
| 1436 | if ( current_user_can( 'publish_forums' ) ) { |
| 1437 | $link = add_query_arg( array( 'post_type' => $bbp->forum_id ), get_admin_url( null, 'edit.php' ) ); |
| 1438 | $num = '<a href="' . $link . '">' . $num . '</a>'; |
| 1439 | $text = '<a href="' . $link . '">' . $text . '</a>'; |
| 1440 | } |
| 1441 | ?> |
| 1442 | |
| 1443 | <td class="first b b-forums"><?php echo $num; ?></td> |
| 1444 | <td class="t forums"><?php echo $text; ?></td> |
| 1445 | |
| 1446 | </tr> |
| 1447 | |
| 1448 | <tr> |
| 1449 | |
| 1450 | <?php |
| 1451 | $num = $topic_count; |
| 1452 | $text = _n( 'Topic', 'Topics', $topic_count, 'bbpress' ); |
| 1453 | if ( current_user_can( 'publish_topics' ) ) { |
| 1454 | $link = add_query_arg( array( 'post_type' => $bbp->topic_id ), get_admin_url( null, 'edit.php' ) ); |
| 1455 | $num = '<a href="' . $link . '">' . $num . '</a>'; |
| 1456 | $text = '<a href="' . $link . '">' . $text . '</a>'; |
| 1457 | } |
| 1458 | ?> |
| 1459 | |
| 1460 | <td class="first b b-topics"><?php echo $num; ?></td> |
| 1461 | <td class="t topics"><?php echo $text; ?></td> |
| 1462 | |
| 1463 | </tr> |
| 1464 | |
| 1465 | <tr> |
| 1466 | |
| 1467 | <?php |
| 1468 | $num = $reply_count; |
| 1469 | $text = _n( 'Reply', 'Replies', $reply_count, 'bbpress' ); |
| 1470 | if ( current_user_can( 'publish_replies' ) ) { |
| 1471 | $link = add_query_arg( array( 'post_type' => $bbp->reply_id ), get_admin_url( null, 'edit.php' ) ); |
| 1472 | $num = '<a href="' . $link . '">' . $num . '</a>'; |
| 1473 | $text = '<a href="' . $link . '">' . $text . '</a>'; |
| 1474 | } |
| 1475 | ?> |
| 1476 | |
| 1477 | <td class="first b b-replies"><?php echo $num; ?></td> |
| 1478 | <td class="t replies"><?php echo $text; ?></td> |
| 1479 | |
| 1480 | </tr> |
| 1481 | |
| 1482 | <tr> |
| 1483 | |
| 1484 | <?php |
| 1485 | $num = $topic_tag_count; |
| 1486 | $text = _n( 'Topic Tag', 'Topic Tags', $topic_tag_count, 'bbpress' ); |
| 1487 | if ( current_user_can( 'manage_topic_tags' ) ) { |
| 1488 | $link = add_query_arg( array( 'taxonomy' => $bbp->topic_tag_id, 'post_type' => $bbp->topic_id ), get_admin_url( null, 'edit-tags.php' ) ); |
| 1489 | $num = '<a href="' . $link . '">' . $num . '</a>'; |
| 1490 | $text = '<a href="' . $link . '">' . $text . '</a>'; |
| 1491 | } |
| 1492 | ?> |
| 1493 | |
| 1494 | <td class="first b b-topic_tags"><span class="total-count"><?php echo $num; ?></a></td> |
| 1495 | <td class="t topic_tags"><?php echo $text; ?></td> |
| 1496 | |
| 1497 | </tr> |
| 1498 | |
| 1499 | <?php do_action( 'bbp_dashboard_widget_right_now_content_table_end' ); ?> |
| 1500 | |
| 1501 | </table> |
| 1502 | |
| 1503 | </div> |
| 1504 | |
| 1505 | |
| 1506 | <div class="table table_discussion"> |
| 1507 | |
| 1508 | <p class="sub"><?php _e( 'Discussion', 'bbpress' ); ?></p> |
| 1509 | |
| 1510 | <table> |
| 1511 | |
| 1512 | <tr class="first"> |
| 1513 | |
| 1514 | <?php |
| 1515 | $num = $user_count; |
| 1516 | $text = _n( 'User', 'Users', $user_count, 'bbpress' ); |
| 1517 | if ( current_user_can( 'edit_users' ) ) { |
| 1518 | $link = get_admin_url( null, 'users.php' ); |
| 1519 | $num = '<a href="' . $link . '">' . $num . '</a>'; |
| 1520 | $text = '<a href="' . $link . '">' . $text . '</a>'; |
| 1521 | } |
| 1522 | ?> |
| 1523 | |
| 1524 | <td class="b b-users"><span class="total-count"><?php echo $num; ?></a></td> |
| 1525 | <td class="last t users"><?php echo $text; ?></td> |
| 1526 | |
| 1527 | </tr> |
| 1528 | |
| 1529 | <?php if ( isset( $hidden_topic_count ) ) : ?> |
| 1530 | |
| 1531 | <tr> |
| 1532 | |
| 1533 | <?php |
| 1534 | $num = $hidden_topic_count; |
| 1535 | $text = _n( 'Hidden Topic', 'Hidden Topics', $hidden_topic_count, 'bbpress' ); |
| 1536 | $link = add_query_arg( array( 'post_type' => $bbp->topic_id ), get_admin_url( null, 'edit.php' ) ); |
| 1537 | $num = '<a href="' . $link . '" title="' . esc_attr( $hidden_topic_title ) . '">' . $num . '</a>'; |
| 1538 | $text = '<a class="waiting" href="' . $link . '" title="' . esc_attr( $hidden_topic_title ) . '">' . $text . '</a>'; |
| 1539 | ?> |
| 1540 | |
| 1541 | <td class="b b-hidden-topics"><?php echo $num; ?></td> |
| 1542 | <td class="last t hidden-replies"><?php echo $text; ?></td> |
| 1543 | |
| 1544 | </tr> |
| 1545 | |
| 1546 | <?php endif; ?> |
| 1547 | |
| 1548 | <?php if ( isset( $hidden_reply_count ) ) : ?> |
| 1549 | |
| 1550 | <tr> |
| 1551 | |
| 1552 | <?php |
| 1553 | $num = $hidden_reply_count; |
| 1554 | $text = _n( 'Hidden Reply', 'Hidden Replies', $hidden_reply_count, 'bbpress' ); |
| 1555 | $link = add_query_arg( array( 'post_type' => $bbp->reply_id ), get_admin_url( null, 'edit.php' ) ); |
| 1556 | $num = '<a href="' . $link . '" title="' . esc_attr( $hidden_reply_title ) . '">' . $num . '</a>'; |
| 1557 | $text = '<a class="waiting" href="' . $link . '" title="' . esc_attr( $hidden_reply_title ) . '">' . $text . '</a>'; |
| 1558 | ?> |
| 1559 | |
| 1560 | <td class="b b-hidden-replies"><?php echo $num; ?></td> |
| 1561 | <td class="last t hidden-replies"><?php echo $text; ?></td> |
| 1562 | |
| 1563 | </tr> |
| 1564 | |
| 1565 | <?php endif; ?> |
| 1566 | |
| 1567 | <?php if ( isset( $empty_topic_tag_count ) ) : ?> |
| 1568 | |
| 1569 | <tr> |
| 1570 | |
| 1571 | <?php |
| 1572 | $num = $empty_topic_tag_count; |
| 1573 | $text = _n( 'Empty Topic Tag', 'Empty Topic Tags', $empty_topic_tag_count, 'bbpress' ); |
| 1574 | $link = add_query_arg( array( 'taxonomy' => $bbp->topic_tag_id, 'post_type' => $bbp->topic_id ), get_admin_url( null, 'edit-tags.php' ) ); |
| 1575 | $num = '<a href="' . $link . '">' . $num . '</a>'; |
| 1576 | $text = '<a class="waiting" href="' . $link . '">' . $text . '</a>'; |
| 1577 | ?> |
| 1578 | |
| 1579 | <td class="b b-hidden-topic-tags"><?php echo $num; ?></td> |
| 1580 | <td class="last t hidden-topic-tags"><?php echo $text; ?></td> |
| 1581 | |
| 1582 | </tr> |
| 1583 | |
| 1584 | <?php endif; ?> |
| 1585 | |
| 1586 | <?php |
| 1587 | |
| 1588 | do_action( 'bbp_dashboard_widget_right_now_table_end' ); |
| 1589 | do_action( 'bbp_dashboard_widget_right_now_discussion_table_end' ); |
| 1590 | |
| 1591 | ?> |
| 1592 | |
| 1593 | </table> |
| 1594 | |
| 1595 | </div> |
| 1596 | |
| 1597 | <?php if ( current_user_can( 'update_plugins' ) ) : ?> |
| 1598 | |
| 1599 | <div class="versions"> |
| 1600 | |
| 1601 | <p> |
| 1602 | |
| 1603 | <?php printf( __( 'You are using <span class="b">bbPress %s</span>.', 'bbpress' ), BBP_VERSION ); ?> |
| 1604 | |
| 1605 | </p> |
| 1606 | |
| 1607 | <br class="clear" /> |
| 1608 | |
| 1609 | </div> |
| 1610 | |
| 1611 | <?php endif; ?> |
| 1612 | |
| 1613 | <?php |
| 1614 | |
| 1615 | do_action( 'bbp_dashboard_widget_right_now_end' ); |
| 1616 | } |
| 1617 | |
| 1618 | /** |