Skip to:
Content

bbPress.org


Ignore:
Timestamp:
05/22/2012 08:00:55 AM (14 years ago)
Author:
johnjamesjacoby
Message:

User Options:

  • Introduce bbp-user-options.php to handle all user option related code.
  • Add $user_options array to main bbPress class to allow for easy, static, per-user option overrides.
  • Tweak action order for option and user_option overrides in bbp-core-hooks.php.
  • Replace all appropriate user_meta calls with user_option calls to automatically prefix keys with blog ID.
  • Update favorites, subscriptions, and topic/reply count option keys to be per-blog in multisite configurations.
  • Fixes #1826.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-includes/bbp-user-template.php

    r3860 r3911  
    15301530}
    15311531
    1532 /** Post Counts ***************************************************************/
    1533 
    1534 /**
    1535  * Output a users topic count
    1536  *
    1537  * @since bbPress (r3632)
    1538  *
    1539  * @param int $user_id
    1540  * @uses bbp_get_user_topic_count()
    1541  * @return string
    1542  */
    1543 function bbp_user_topic_count( $user_id = 0 ) {
    1544         echo bbp_get_user_topic_count( $user_id );
    1545 }
    1546         /**
    1547          * Return a users reply count
    1548          *
    1549          * @since bbPress (r3632)
    1550          *
    1551          * @param int $user_id
    1552          * @uses bbp_get_user_id()
    1553          * @uses get_user_meta()
    1554          * @uses apply_filters()
    1555          * @return string
    1556          */
    1557         function bbp_get_user_topic_count( $user_id = 0 ) {
    1558 
    1559                 // Validate user id
    1560                 $user_id = bbp_get_user_id( $user_id );
    1561                 if ( empty( $user_id ) )
    1562                         return false;
    1563 
    1564                 $count = get_user_meta( $user_id, '_bbp_topic_count', true );
    1565 
    1566                 return apply_filters( 'bbp_get_user_topic_count', (int) $count, $user_id );
    1567         }
    1568 
    1569 /**
    1570  * Output a users reply count
    1571  *
    1572  * @since bbPress (r3632)
    1573  *
    1574  * @param int $user_id
    1575  * @uses bbp_get_user_reply_count()
    1576  * @return string
    1577  */
    1578 function bbp_user_reply_count( $user_id = 0 ) {
    1579         echo bbp_get_user_reply_count( $user_id );
    1580 }
    1581         /**
    1582          * Return a users reply count
    1583          *
    1584          * @since bbPress (r3632)
    1585          *
    1586          * @param int $user_id
    1587          * @uses bbp_get_user_id()
    1588          * @uses get_user_meta()
    1589          * @uses apply_filters()
    1590          * @return string
    1591          */
    1592         function bbp_get_user_reply_count( $user_id = 0 ) {
    1593 
    1594                 // Validate user id
    1595                 $user_id = bbp_get_user_id( $user_id );
    1596                 if ( empty( $user_id ) )
    1597                         return false;
    1598 
    1599                 $count = get_user_meta( $user_id, '_bbp_reply_count', true );
    1600 
    1601                 return apply_filters( 'bbp_get_user_reply_count', (int) $count, $user_id );
    1602         }
    1603 
    1604 /**
    1605  * Output a users total post count
    1606  *
    1607  * @since bbPress (r3632)
    1608  *
    1609  * @param int $user_id
    1610  * @uses bbp_get_user_post_count()
    1611  * @return string
    1612  */
    1613 function bbp_user_post_count( $user_id = 0 ) {
    1614         echo bbp_get_user_post_count( $user_id );
    1615 }
    1616         /**
    1617          * Return a users total post count
    1618          *
    1619          * @since bbPress (r3632)
    1620          *
    1621          * @param int $user_id
    1622          * @uses bbp_get_user_id()
    1623          * @uses get_user_meta()
    1624          * @uses apply_filters()
    1625          * @return string
    1626          */
    1627         function bbp_get_user_post_count( $user_id = 0 ) {
    1628 
    1629                 // Validate user id
    1630                 $user_id = bbp_get_user_id( $user_id );
    1631                 if ( empty( $user_id ) )
    1632                         return false;
    1633 
    1634                 $topics  = get_user_meta( $user_id, '_bbp_topic_count', true );
    1635                 $replies = get_user_meta( $user_id, '_bbp_reply_count', true );
    1636                 $count   = (int) $topics + (int) $replies;
    1637 
    1638                 return apply_filters( 'bbp_get_user_post_count', (int) $count, $user_id );
    1639         }
    1640 
    16411532?>
Note: See TracChangeset for help on using the changeset viewer.