Skip to:
Content

bbPress.org


Ignore:
Timestamp:
01/06/2011 08:25:58 AM (16 years ago)
Author:
johnjamesjacoby
Message:

"...pursuing a career in the custodial arts." phpDoc fixes and code clean-up. Props GautamGupta via Google Code-in

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-themes/bbp-twentyten/functions.php

    r2740 r2758  
    22
    33/**
    4  * bbp_twentyten_enqueue_styles ()
    5  *
     4 * bbPress Theme Functions
     5 *
     6 * @package bbPress
     7 * @subpackage Theme
     8 */
     9
     10/**
    611 * Load the theme CSS
     12 *
     13 * @uses is_admin() To check if it's the admin section
     14 * @uses wp_enqueue_style() To enqueue the styles
    715 */
    816function bbp_twentyten_enqueue_styles () {
    … …  
    1624        wp_enqueue_style( 'bbp-twentyten-bbpress', get_stylesheet_directory_uri() . '/css/bbpress.css', 'bbp-twentyten-default', 20100312, 'screen' );
    1725}
    18 add_action( 'init', 'bbp_twentyten_enqueue_styles' );
    19 
    20 /**
    21  * bbp_twentyten_dim_favorite ()
    22  *
     26
     27/**
    2328 * Add or remove a topic from a user's favorites
    2429 *
    25  * @package bbPress
    26  * @subpackage bbPress TwentyTen
    27  * @since bbPress (r2652)
    28  *
    29  * @return void
     30 * @since bbPress (r2652)
     31 *
     32 * @uses bbp_get_current_user_id() To get the current user id
     33 * @uses current_user_can() To check if the current user can edit the user
     34 * @uses get_post() To get the topic
     35 * @uses check_ajax_referer() To verify the nonce & check the referer
     36 * @uses bbp_is_user_favorite() To check if the topic is user's favorite
     37 * @uses bbp_remove_user_favorite() To remove the topic from user's favorites
     38 * @uses bbp_add_user_favorite() To add the topic from user's favorites
    3039 */
    3140function bbp_twentyten_dim_favorite () {
    32         global $current_user;
    33 
    34         $current_user = wp_get_current_user();
    35         $user_id      = $current_user->ID;
    36         $id           = intval( $_POST['id'] );
     41        $user_id = bbp_get_current_user_id();
     42        $id      = intval( $_POST['id'] );
    3743
    3844        if ( !current_user_can( 'edit_user', $user_id ) )
    … …  
    5460        die( '0' );
    5561}
    56 add_action( 'wp_ajax_dim-favorite', 'bbp_twentyten_dim_favorite' );
    57 
    58 /**
    59  * bbp_twentyten_dim_subscription ()
    60  *
     62
     63/**
    6164 * Subscribe/Unsubscribe a user from a topic
    6265 *
    63  * @package bbPress
    64  * @subpackage bbPress TwentyTen
    6566 * @since bbPress (r2668)
    6667 *
    67  * @return void
     68 * @uses bbp_is_subscriptions_active() To check if the subscriptions are active
     69 * @uses bbp_get_current_user_id() To get the current user id
     70 * @uses current_user_can() To check if the current user can edit the user
     71 * @uses get_post() To get the topic
     72 * @uses check_ajax_referer() To verify the nonce & check the referer
     73 * @uses bbp_is_user_subscribed() To check if the topic is in user's
     74 *                                 subscriptions
     75 * @uses bbp_remove_user_subscriptions() To remove the topic from user's
     76 *                                        subscriptions
     77 * @uses bbp_add_user_subscriptions() To add the topic from user's subscriptions
    6878 */
    6979function bbp_twentyten_dim_subscription () {
    70         global $current_user;
    71 
    7280        if ( !bbp_is_subscriptions_active() )
    7381                return;
    7482
    75         $current_user = wp_get_current_user();
    76         $user_id      = $current_user->ID;
    77         $id           = intval( $_POST['id'] );
     83        $user_id = bbp_get_current_user_id();
     84        $id      = intval( $_POST['id'] );
    7885
    7986        if ( !current_user_can( 'edit_user', $user_id ) )
    … …  
    95102        die( '0' );
    96103}
    97 add_action( 'wp_ajax_dim-subscription', 'bbp_twentyten_dim_subscription' );
    98 
    99 /**
    100  * bbp_twentyten_enqueue_scripts ()
    101  *
     104
     105/**
    102106 * Enqueue the required Javascript files
    103107 *
    104  * @package bbPress
    105  * @subpackage bbPress TwentyTen
    106  * @since bbPress (r2652)
    107  *
    108  * @return void
     108 * @since bbPress (r2652)
     109 *
     110 * @uses bbp_is_topic() To check if it's the topic page
     111 * @uses get_stylesheet_directory_uri() To get the stylesheet directory uri
     112 * @uses bbp_is_user_profile_edit() To check if it's the profile edit page
     113 * @uses wp_enqueue_script() To enqueue the scripts
    109114 */
    110115function bbp_twentyten_enqueue_scripts () {
    … …  
    115120                wp_enqueue_script( 'user-profile' );
    116121}
    117 add_action( 'wp_enqueue_scripts', 'bbp_twentyten_enqueue_scripts' );
    118 
    119 /**
    120  * bbp_twentyten_scripts ()
    121  *
     122
     123/**
    122124 * Put some scripts in the header, like AJAX url for wp-lists
    123125 *
    124  * @package bbPress
    125  * @subpackage bbPress TwentyTen
    126  * @since bbPress (r2652)
    127  *
    128  * @return void
     126 * @since bbPress (r2652)
     127 *
     128 * @uses bbp_is_topic() To check if it's the topic page
     129 * @uses admin_url() To get the admin url
     130 * @uses bbp_is_user_profile_edit() To check if it's the profile edit page
    129131 */
    130132function bbp_twentyten_scripts () {
    … …  
    148150        endif;
    149151}
    150 add_filter( 'wp_head', 'bbp_twentyten_scripts', -1 );
    151 
    152 /**
    153  * bbp_twentyten_topic_script_localization ()
    154  *
     152
     153/**
    155154 * Load localizations for topic script.
    156155 *
    157156 * These localizations require information that may not be loaded even by init.
    158157 *
    159  * @package bbPress
    160  * @subpackage bbPress TwentyTen
    161  * @since bbPress (r2652)
    162  *
    163  * @return void
     158 * @since bbPress (r2652)
     159 *
     160 * @uses bbp_is_topic() To check if it's the topic page
     161 * @uses bbp_get_current_user_id() To get the current user id
     162 * @uses bbp_get_topic_id() To get the topic id
     163 * @uses bbp_get_favorites_permalink() To get the favorites permalink
     164 * @uses bbp_is_user_favorite() To check if the topic is in user's favorites
     165 * @uses bbp_is_subscriptions_active() To check if the subscriptions are active
     166 * @uses bbp_is_user_subscribed() To check if the user is subscribed to topic
     167 * @uses bbp_get_topic_permalink() To get the topic permalink
     168 * @uses wp_localize_script() To localize the script
    164169 */
    165170function bbp_twentyten_topic_script_localization () {
    … …  
    167172                return;
    168173
    169         global $current_user;
    170 
    171         $current_user = wp_get_current_user();
    172         $user_id      = $current_user->ID;
     174        $user_id = bbp_get_current_user_id();
    173175
    174176        $localizations = array(
    … …  
    197199        wp_localize_script( 'bbp_topic', 'bbpTopicJS', $localizations );
    198200}
    199 add_filter( 'wp_enqueue_scripts', 'bbp_twentyten_topic_script_localization' );
     201
     202/* Actions */
     203add_action( 'init',                     'bbp_twentyten_enqueue_styles'               );
     204add_action( 'wp_ajax_dim-favorite',     'bbp_twentyten_dim_favorite'                 );
     205add_action( 'wp_ajax_dim-subscription', 'bbp_twentyten_dim_subscription'             );
     206add_action( 'wp_enqueue_scripts',       'bbp_twentyten_enqueue_scripts'              );
     207add_filter( 'wp_head',                  'bbp_twentyten_scripts',                  -1 );
     208add_filter( 'wp_enqueue_scripts',       'bbp_twentyten_topic_script_localization'    );
    200209
    201210?>
Note: See TracChangeset for help on using the changeset viewer.