Skip to:
Content

bbPress.org


Ignore:
Timestamp:
11/20/2013 07:50:55 PM (13 years ago)
Author:
johnjamesjacoby
Message:

Forum Subscriptions - Allow users to subscribe to new topics in specific forums.

  • Code largely lifted from existing Topics Subscriptions, and is based largely on forum-subscriptions.2.diff from mordauk, with edits for code consistency across bbPress components.
  • Refactor existing ambiguous function names into base functions for both forum and topic subscriptions.
  • Include new functions for getting and outputting subscriptions.
  • Modify user-subscriptions.php to show subscribed forums. This includes a modification to content-single-forum.php to include the "Unsubscribe" link if looking at a user profile page.
  • Modify templates/default/bbpress-functions.php to enqueue new JS file to handle forum subscription ajax.
  • Rename HTML element classes from bbp-topic-action to bbp-row-actions to better accommodate forum subscriptions (and any future actions.)
  • BuddyPress tested, JJJ approved.
  • See #2299. Props mordauk, netweb for the considerable effort.
  • More to do here, largely from forum-subscriptions.3.diff
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/topics/template.php

    r5130 r5156  
    18081808        }
    18091809
     1810/** Topic Subscriptions *******************************************************/
     1811
     1812/**
     1813 * Output the topic subscription link
     1814 *
     1815 * @since bbPress (rxxxx)
     1816 *
     1817 * @uses bbp_get_topic_subscription_link()
     1818 */
     1819function bbp_topic_subscription_link( $args = array() ) {
     1820        echo bbp_get_topic_subscription_link( $args );
     1821}
     1822
     1823        /**
     1824         * Get the forum subscription link
     1825         *
     1826         * A custom wrapper for bbp_get_user_subscribe_link()
     1827         *
     1828         * @since bbPress (rxxxx)
     1829         *
     1830         * @uses bbp_parse_args()
     1831         * @uses bbp_get_user_subscribe_link()
     1832         * @uses apply_filters() Calls 'bbp_get_topic_subscribe_link'
     1833         */
     1834        function bbp_get_topic_subscription_link( $args = array() ) {
     1835
     1836                // No link
     1837                $retval = false;
     1838
     1839                // Parse the arguments
     1840                $r = bbp_parse_args( $args, array(
     1841                        'user_id'     => 0,
     1842                        'topic_id'    => 0,
     1843                        'before'      => ' | ',
     1844                        'after'       => '',
     1845                        'subscribe'   => __( 'Subscribe',   'bbpress' ),
     1846                        'unsubscribe' => __( 'Unsubscribe', 'bbpress' )
     1847                ), 'get_forum_subscribe_link' );
     1848
     1849                // Get the link
     1850                $retval = bbp_get_user_subscribe_link( $r );
     1851
     1852                return apply_filters( 'bbp_get_topic_subscribe_link', $retval, $r );
     1853        }
     1854
     1855/** Topic Favorites ***********************************************************/
     1856
     1857/**
     1858 * Output the topic favorite link
     1859 *
     1860 * @since bbPress (rxxxx)
     1861 *
     1862 * @uses bbp_get_topic_favorite_link()
     1863 */
     1864function bbp_topic_favorite_link( $args = array() ) {
     1865        echo bbp_get_topic_favorite_link( $args );
     1866}
     1867
     1868        /**
     1869         * Get the forum favorite link
     1870         *
     1871         * A custom wrapper for bbp_get_user_favorite_link()
     1872         *
     1873         * @since bbPress (rxxxx)
     1874         *
     1875         * @uses bbp_parse_args()
     1876         * @uses bbp_get_user_favorites_link()
     1877         * @uses apply_filters() Calls 'bbp_get_topic_favorite_link'
     1878         */
     1879        function bbp_get_topic_favorite_link( $args = array() ) {
     1880
     1881                // No link
     1882                $retval = false;
     1883
     1884                // Parse the arguments
     1885                $r = bbp_parse_args( $args, array(
     1886                        'user_id'   => 0,
     1887                        'topic_id'  => 0,
     1888                        'before'    => '',
     1889                        'after'     => '',
     1890                        'favorite'  => __( 'Favorite',   'bbpress' ),
     1891                        'favorited' => __( 'Unfavorite', 'bbpress' )
     1892                ), 'get_forum_favorite_link' );
     1893
     1894                // Get the link
     1895                $retval = bbp_get_user_favorites_link( $r );
     1896
     1897                return apply_filters( 'bbp_get_topic_favorite_link', $retval, $r );
     1898        }
     1899
    18101900/** Topic Last Reply **********************************************************/
    18111901
Note: See TracChangeset for help on using the changeset viewer.