Skip to:
Content

bbPress.org

Ticket #1438: stats-admin.diff

File stats-admin.diff, 11.9 KB (added by GautamGupta, 14 years ago)

Requires the patch in #1427

  • bbp-admin/bbp-admin.php

     
    4040                /** General Actions *******************************************/
    4141
    4242                // Add notice if not using a bbPress theme
    43                 add_action( 'admin_notices',               array( $this, 'activation_notice'       )        );
     43                add_action( 'admin_notices',               array( $this, 'activation_notice'          )        );
    4444
    4545                // Add link to settings page
    46                 add_filter( 'plugin_action_links',         array( $this, 'add_settings_link'       ), 10, 2 );
     46                add_filter( 'plugin_action_links',         array( $this, 'add_settings_link'          ), 10, 2 );
    4747
    4848                // Add menu item to settings menu
    49                 add_action( 'admin_menu',                  array( $this, 'admin_menus'             )        );
     49                add_action( 'admin_menu',                  array( $this, 'admin_menus'                )        );
    5050
    5151                // Add the settings
    52                 add_action( 'admin_init',                  array( $this, 'register_admin_settings' )        );
     52                add_action( 'admin_init',                  array( $this, 'register_admin_settings'    )        );
    5353
    5454                // Attach the bbPress admin init action to the WordPress admin init action.
    55                 add_action( 'admin_init',                  array( $this, 'init'                    )        );
     55                add_action( 'admin_init',                  array( $this, 'init'                       )        );
    5656
    5757                // Add some general styling to the admin area
    58                 add_action( 'admin_head',                  array( $this, 'admin_head'              )        );
     58                add_action( 'admin_head',                  array( $this, 'admin_head'                 )        );
    5959
    6060                // Register bbPress admin style
    61                 add_action( 'admin_init',                  array( $this, 'register_admin_style'    )        );
     61                add_action( 'admin_init',                  array( $this, 'register_admin_style'       )        );
    6262
     63                // Forums 'Right now' Dashboard widget
     64                add_action( 'wp_dashboard_setup',          array( $this, 'dashboard_widget_right_now' )        );
     65
    6366                /** User Actions **********************************************/
    6467
    6568                // User profile edit/display actions
     
    248251        }
    249252
    250253        /**
     254         * Add the 'Right now in Forums' dashboard widget
     255         *
     256         * @since bbPress (r2770)
     257         *
     258         * @uses wp_add_dashboard_widget() To add the dashboard widget
     259         */
     260        function dashboard_widget_right_now() {
     261                wp_add_dashboard_widget( 'bbp_dashboard_right_now', __( 'Right Now in Forums', 'bbpress' ), 'bbp_dashboard_widget_right_now' );
     262        }
     263
     264        /**
    251265         * Add the forum attributes metabox
    252266         *
    253267         * @since bbPress (r2746)
     
    13801394        $menu[25] = array( '', 'read', 'separator1', '', 'wp-menu-separator' );
    13811395}
    13821396
     1397
    13831398/**
     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 */
     1419function 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/**
    13841619 * Forum metabox
    13851620 *
    13861621 * The metabox that holds all of the additional forum information
     
    14531688                </p>
    14541689
    14551690                <hr />
    1456                
     1691
    14571692                <p>
    14581693                        <strong class="label"><?php _e( 'Parent:', 'bbpress' ); ?></strong>
    14591694                        <label class="screen-reader-text" for="parent_id"><?php _e( 'Forum Parent', 'bbpress' ); ?></label>
  • bbp-css/admin.css

     
    16981698        background: #ececec;
    16991699        border-bottom-color: #ececec;
    17001700}
     1701
     1702/* =bbPress 'Right Now in Forums' Dashboard Widget
     1703-------------------------------------------------------------- */
     1704
     1705#bbp_dashboard_right_now p.sub,
     1706#bbp_dashboard_right_now .table, #bbp_dashboard_right_now .versions {
     1707        margin: -12px;
     1708}
     1709
     1710#bbp_dashboard_right_now .inside {
     1711        font-size: 12px;
     1712        padding-top: 20px;
     1713}
     1714
     1715#bbp_dashboard_right_now p.sub {
     1716        font-style: italic;
     1717        font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
     1718        padding: 5px 10px 15px;
     1719        color: #777;
     1720        font-size: 13px;
     1721        position: absolute;
     1722        top: -17px;
     1723        left: 15px;
     1724}
     1725
     1726#bbp_dashboard_right_now .table {
     1727        margin: 0 -9px;
     1728        padding: 0 10px;
     1729        position: relative;
     1730}
     1731
     1732#bbp_dashboard_right_now .table_content {
     1733        float: left;
     1734        border-top: #ececec 1px solid;
     1735        width: 45%;
     1736}
     1737
     1738#bbp_dashboard_right_now .table_discussion {
     1739        float: right;
     1740        border-top: #ececec 1px solid;
     1741        width: 45%;
     1742}
     1743
     1744#bbp_dashboard_right_now table td {
     1745        padding: 3px 0;
     1746        white-space: nowrap;
     1747}
     1748
     1749#bbp_dashboard_right_now table tr.first td {
     1750        border-top: none;
     1751}
     1752
     1753#bbp_dashboard_right_now td.b {
     1754        padding-right: 6px;
     1755        text-align: right;
     1756        font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
     1757        font-size: 14px;
     1758        width: 1%;
     1759}
     1760
     1761#bbp_dashboard_right_now td.b a {
     1762        font-size: 18px;
     1763}
     1764
     1765#bbp_dashboard_right_now td.b a:hover {
     1766        color: #d54e21;
     1767}
     1768
     1769#bbp_dashboard_right_now .t {
     1770        font-size: 12px;
     1771        padding-right: 12px;
     1772        padding-top: 6px;
     1773        color: #777;
     1774}
     1775
     1776#bbp_dashboard_right_now .t a {
     1777        white-space: nowrap;
     1778}
     1779
     1780#bbp_dashboard_right_now .spam {
     1781        color: red;
     1782}
     1783
     1784#bbp_dashboard_right_now .waiting {
     1785        color: #e66f00;
     1786}
     1787
     1788#bbp_dashboard_right_now .approved {
     1789        color: green;
     1790}
     1791
     1792#bbp_dashboard_right_now .versions {
     1793        padding: 6px 10px 12px;
     1794        clear: both;
     1795}
     1796
     1797#bbp_dashboard_right_now .versions .b {
     1798        font-weight: bold;
     1799}
     1800
     1801#bbp_dashboard_right_now a.button {
     1802        float: right;
     1803        clear: right;
     1804        position: relative;
     1805        top: -5px;
     1806}