Skip to:
Content

bbPress.org


Ignore:
Timestamp:
05/09/2011 04:18:51 AM (15 years ago)
Author:
johnjamesjacoby
Message:

Switch author IP address from anonymous only to a meta value on every topic and reply. Includes additional template tags, theme compat adjustments, and admin meta box adjustments. Fixes #1505.

File:
1 edited

Legend:

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

    r3095 r3120  
    413413
    414414        return apply_filters( 'bbp_get_admin_link', $before . '<a href="' . $uri . '">' . $text . '</a>' . $after, $args );
     415    }
     416
     417/** User IP *******************************************************************/
     418
     419/**
     420 * Output the author IP address of a post
     421 *
     422 * @since bbPress (r3120)
     423 *
     424 * @param mixed $args Optional. If it is an integer, it is used as post id.
     425 * @uses bbp_get_author_ip() To get the post author link
     426 */
     427function bbp_author_ip( $args = '' ) {
     428    echo bbp_get_author_ip( $args );
     429}
     430    /**
     431     * Return the author IP address of a post
     432     *
     433     * @since bbPress (r3120)
     434     *
     435     * @param mixed $args Optional. If an integer, it is used as reply id.
     436     * @uses get_post_meta() To check if it's a topic page
     437     * @return string Author link of reply
     438     */
     439    function bbp_get_author_ip( $args = '' ) {
     440
     441        // Default arguments
     442        $defaults = array(
     443            'post_id' => 0,
     444            'before'  => '<span class="bbp-author-ip">(',
     445            'after'   => ')</span>'
     446        );
     447
     448        $r = wp_parse_args( $args, $defaults );
     449        extract( $r );
     450
     451        // Used as post id
     452        if ( is_numeric( $args ) )
     453            $post_id = $args;
     454
     455        // Get the author IP meta value
     456        if ( $author_ip = get_post_meta( $post_id, '_bbp_author_ip', true ) )
     457            $author_ip = $before . $author_ip . $after;
     458
     459        // No IP address
     460        else
     461            $author_ip = '';
     462
     463        return apply_filters( 'bbp_get_author_ip', $author_ip, $args );
    415464    }
    416465
Note: See TracChangeset for help on using the changeset viewer.