WordPress.org

Make WordPress Core

Ticket #2477: pluggable-functions-comments.diff

File pluggable-functions-comments.diff, 6.0 KB (added by masquerade, 12 years ago)
  • wp-includes/pluggable-functions.php

     
    44         plugins are loaded. */
    55
    66if ( !function_exists('set_current_user') ) :
     7/**
     8 * Populates global user information for any user
     9 * Set $id to null and specify a name if you do not know a user's ID
     10 * @param int $id ID of the user you would like to include
     11 * @param string $name (optional) Name of the user to populate data with
     12 * @return object WP_User instance
     13 */
    714function set_current_user($id, $name = '') {
    815        global $user_login, $userdata, $user_level, $user_ID, $user_email, $user_url, $user_pass_md5, $user_identity, $current_user;
    916
     
    2936
    3037
    3138if ( !function_exists('get_currentuserinfo') ) :
     39/**
     40 * Populate global variables with information about the currently logged in user
     41 */
    3242function get_currentuserinfo() {
    3343        global $user_login, $userdata, $user_level, $user_ID, $user_email, $user_url, $user_pass_md5, $user_identity, $current_user;
    3444
     
    5565endif;
    5666
    5767if ( !function_exists('get_userdata') ) :
     68/**
     69 * Get an object containing data about a user
     70 * @param int $user_id
     71 * @return object user data
     72 */
    5873function get_userdata( $user_id ) {
    5974        global $wpdb;
    6075        $user_id = (int) $user_id;
     
    102117endif;
    103118
    104119if ( !function_exists('update_user_cache') ) :
     120/**
     121 * Updates a users cache when overridden by a plugin, core function does nothing
     122 */
    105123function update_user_cache() {
    106124        return true;
    107125}
    108126endif;
    109127
    110128if ( !function_exists('get_userdatabylogin') ) :
     129/**
     130 * Grabs some info about a user based on their login name
     131 * @param string $user_login
     132 * @return object user info
     133 */
    111134function get_userdatabylogin($user_login) {
    112135        global $wpdb;
    113136        $user_login = sanitize_user( $user_login );
     
    156179endif;
    157180
    158181if ( !function_exists('wp_mail') ) :
     182/**
     183 * Function to send mail, similar to PHP's mail
     184 * @param string $to outgoing email address
     185 * @param string $subject subjecct of the mail
     186 * @param string $message body of the mail
     187 * @param string $headers (optional) Additional headers
     188 * @return bool
     189 */
    159190function wp_mail($to, $subject, $message, $headers = '') {
    160191        if( $headers == '' ) {
    161192                $headers = "MIME-Version: 1.0\n" .
     
    168199endif;
    169200
    170201if ( !function_exists('wp_login') ) :
     202/**
     203 * Checks a users login information and logs them in if it checks out
     204 * @param string $username
     205 * @param string $password
     206 * @param bool $already_md5 (optional, default false)
     207 * @return bool
     208 */
    171209function wp_login($username, $password, $already_md5 = false) {
    172210        global $wpdb, $error;
    173211
     
    200238endif;
    201239
    202240if ( !function_exists('is_user_logged_in') ) :
     241/**
     242 * Function to check if the current visitor is a logged in user
     243 * @return bool
     244 */
    203245function is_user_logged_in() {
    204246        global $current_user;
    205247
     
    210252endif;
    211253
    212254if ( !function_exists('auth_redirect') ) :
     255/**
     256 * Checks if a user is logged in, if not it redirects them to the login page
     257 */
    213258function auth_redirect() {
    214         // Checks if a user is logged in, if not redirects them to the login page
    215259        if ( (!empty($_COOKIE[USER_COOKIE]) &&
    216260                                !wp_login($_COOKIE[USER_COOKIE], $_COOKIE[PASS_COOKIE], true)) ||
    217261                         (empty($_COOKIE[USER_COOKIE])) ) {
     
    224268endif;
    225269
    226270if ( !function_exists('check_admin_referer') ) :
     271/**
     272 * Makes sure that a user was referred from another admin page, to avoid security exploits
     273 */
    227274function check_admin_referer() {
    228275        $adminurl = strtolower(get_settings('siteurl')).'/wp-admin';
    229276        $referer = strtolower($_SERVER['HTTP_REFERER']);
     
    236283// Cookie safe redirect.  Works around IIS Set-Cookie bug.
    237284// http://support.microsoft.com/kb/q176113/
    238285if ( !function_exists('wp_redirect') ) :
     286/**
     287 * Redirects to another page, with a workaround for the ISS Set-Cookie bug
     288 * @param string $location
     289 */
    239290function wp_redirect($location) {
    240291        global $is_IIS;
    241292
     
    249300endif;
    250301
    251302if ( !function_exists('wp_setcookie') ) :
     303/**
     304 * Sets a cookie for a user who just logged in
     305 * @param string $username
     306 * @param string $password
     307 * @param bool $already_md5
     308 * @param string $home (optional) Will be used instead of COOKIEPATH if set
     309 * @param string $siteurl (optional) Will be used instead of SITECOOKIEPATH if set
     310 * @param bool $remember remember that the user is logged in
     311 */
    252312function wp_setcookie($username, $password, $already_md5 = false, $home = '', $siteurl = '', $remember = false) {
    253313        if ( !$already_md5 )
    254314                $password = md5( md5($password) ); // Double hash the password in the cookie.
     
    282342endif;
    283343
    284344if ( !function_exists('wp_clearcookie') ) :
     345/**
     346 * Unsets a user's login cookies, effectively logging them out
     347 */
    285348function wp_clearcookie() {
    286349        setcookie(USER_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN);
    287350        setcookie(PASS_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN);
     
    291354endif;
    292355
    293356if ( ! function_exists('wp_notify_postauthor') ) :
     357/**
     358 * Notify an author of a comment/trackback/pingback to one of their posts
     359 * @param int $comment_id
     360 * @param string $comment_type
     361 * @return bool success
     362 */
    294363function wp_notify_postauthor($comment_id, $comment_type='') {
    295364        global $wpdb;
    296365   
     
    363432}
    364433endif;
    365434
    366 /* wp_notify_moderator
    367    notifies the moderator of the blog (usually the admin)
    368    about a new comment that waits for approval
    369    always returns true
     435if ( !function_exists('wp_notify_moderator') ) :
     436/**
     437 * Notifies the moderator of the blog about a new comment that is awaiting approval
     438 * @param int $comment_id
     439 * @return true
    370440 */
    371 if ( !function_exists('wp_notify_moderator') ) :
    372441function wp_notify_moderator($comment_id) {
    373442        global $wpdb;
    374443
     
    407476endif;
    408477
    409478if ( !function_exists('wp_new_user_notification') ) :
     479/**
     480 * Notify the blog admin of a new user
     481 * @param int $user_id
     482 * @param string $plaintext_pass (optional)
     483 */
    410484function wp_new_user_notification($user_id, $plaintext_pass = '') {
    411485        $user = new WP_User($user_id);
    412486