Skip to:
Content

bbPress.org

Changeset 5121


Ignore:
Timestamp:
10/04/2013 06:52:57 PM (8 years ago)
Author:
johnjamesjacoby
Message:

Improve function locations introduced in r5120. Ensures template and helper functions are in template.php. See #2426.

Location:
trunk/includes/users
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/users/functions.php

    r5120 r5121  
    157157    return apply_filters( 'bbp_current_author_ua', $retval );
    158158}
    159 
    160 /** Anonymous Fields **********************************************************/
    161 
    162 /**
    163  * Performs a series of checks to ensure the current user should see the
    164  * anonymous user form fields.
    165  *
    166  * @since bbPress (r5119)
    167  *
    168  * @uses bbp_is_anonymous()
    169  * @uses bbp_is_topic_edit()
    170  * @uses bbp_is_topic_anonymous()
    171  * @uses bbp_is_reply_edit()
    172  * @uses bbp_is_reply_anonymous()
    173  *
    174  * @return bool
    175  */
    176 function bbp_current_user_can_access_anonymous_user_form() {
    177 
    178     // Users need to earn access
    179     $retval = false;
    180 
    181     // User is not logged in, and anonymous posting is allowed
    182     if ( bbp_is_anonymous() ) {
    183         $retval = true;
    184 
    185     // User is editing a topic, and topic is authored by anonymous user
    186     } elseif ( bbp_is_topic_edit() && bbp_is_topic_anonymous() ) {
    187         $retval = true;
    188 
    189     // User is editing a reply, and reply is authored by anonymous user
    190     } elseif ( bbp_is_reply_edit() && bbp_is_reply_anonymous() ) {
    191         $retval = true;
    192     }
    193 
    194     // Allow access to be filtered
    195     return (bool) apply_filters( 'bbp_current_user_can_access_anonymous_user_form', (bool) $retval );
    196 }
    197 
    198 /**
    199  * Output the author disylay-name of a topic or reply.
    200  *
    201  * Convenience function to ensure proper template functions are called
    202  * and correct filters are executed. Used primarily to display topic
    203  * and reply author information in the anonymous form template-part.
    204  *
    205  * @since bbPress (r5119)
    206  *
    207  * @param int $post_id
    208  * @uses bbp_get_author_display_name() to get the author name
    209  */
    210 function bbp_author_display_name( $post_id = 0 ) {
    211     echo bbp_get_author_display_name( $post_id );
    212 }
    213 
    214     /**
    215      * Return the author name of a topic or reply.
    216      *
    217      * Convenience function to ensure proper template functions are called
    218      * and correct filters are executed. Used primarily to display topic
    219      * and reply author information in the anonymous form template-part.
    220      *
    221      * @since bbPress (r5119)
    222      *
    223      * @param int $post_id
    224      *
    225      * @uses bbp_is_topic_edit()
    226      * @uses bbp_get_topic_author_display_name()
    227      * @uses bbp_is_reply_edit()
    228      * @uses bbp_get_reply_author_display_name()
    229      * @uses bbp_current_anonymous_user_data()
    230      *
    231      * @return string The name of the author
    232      */
    233     function bbp_get_author_display_name( $post_id = 0 ) {
    234 
    235         // Define local variable(s)
    236         $retval = '';
    237 
    238         // Topic edit
    239         if ( bbp_is_topic_edit() ) {
    240             $retval = bbp_get_topic_author_display_name( $post_id );
    241 
    242         // Reply edit
    243         } elseif ( bbp_is_reply_edit() ) {
    244             $retval = bbp_get_reply_author_display_name( $post_id );
    245 
    246         // Not an edit, so rely on current user cookie data
    247         } else {
    248             $retval = bbp_current_anonymous_user_data( 'name' );
    249         }
    250 
    251         return apply_filters( 'bbp_get_author_display_name', $retval, $post_id );
    252     }
    253 
    254 /**
    255  * Output the author email of a topic or reply.
    256  *
    257  * Convenience function to ensure proper template functions are called
    258  * and correct filters are executed. Used primarily to display topic
    259  * and reply author information in the anonymous user form template-part.
    260  *
    261  * @since bbPress (r5119)
    262  *
    263  * @param int $post_id
    264  * @uses bbp_get_author_email() to get the author email
    265  */
    266 function bbp_author_email( $post_id = 0 ) {
    267     echo bbp_get_author_email( $post_id );
    268 }
    269 
    270     /**
    271      * Return the author email of a topic or reply.
    272      *
    273      * Convenience function to ensure proper template functions are called
    274      * and correct filters are executed. Used primarily to display topic
    275      * and reply author information in the anonymous user form template-part.
    276      *
    277      * @since bbPress (r5119)
    278      *
    279      * @param int $post_id
    280      *
    281      * @uses bbp_is_topic_edit()
    282      * @uses bbp_get_topic_author_email()
    283      * @uses bbp_is_reply_edit()
    284      * @uses bbp_get_reply_author_email()
    285      * @uses bbp_current_anonymous_user_data()
    286      *
    287      * @return string The email of the author
    288      */
    289     function bbp_get_author_email( $post_id = 0 ) {
    290 
    291         // Define local variable(s)
    292         $retval = '';
    293 
    294         // Topic edit
    295         if ( bbp_is_topic_edit() ) {
    296             $retval = bbp_get_topic_author_email( $post_id );
    297 
    298         // Reply edit
    299         } elseif ( bbp_is_reply_edit() ) {
    300             $retval = bbp_get_reply_author_email( $post_id );
    301 
    302         // Not an edit, so rely on current user cookie data
    303         } else {
    304             $retval = bbp_current_anonymous_user_data( 'email' );
    305         }
    306 
    307         return apply_filters( 'bbp_get_author_email', $retval, $post_id );
    308     }
    309 
    310 /**
    311  * Output the author url of a topic or reply.
    312  *
    313  * Convenience function to ensure proper template functions are called
    314  * and correct filters are executed. Used primarily to display topic
    315  * and reply author information in the anonymous user form template-part.
    316  *
    317  * @since bbPress (r5119)
    318  *
    319  * @param int $post_id
    320  * @uses bbp_get_author_url() to get the author url
    321  */
    322 function bbp_author_url( $post_id = 0 ) {
    323     echo bbp_get_author_url( $post_id );
    324 }
    325 
    326     /**
    327      * Return the author url of a topic or reply.
    328      *
    329      * Convenience function to ensure proper template functions are called
    330      * and correct filters are executed. Used primarily to display topic
    331      * and reply author information in the anonymous user form template-part.
    332      *
    333      * @since bbPress (r5119)
    334      *
    335      * @param int $post_id
    336      *
    337      * @uses bbp_is_topic_edit()
    338      * @uses bbp_get_topic_author_url()
    339      * @uses bbp_is_reply_edit()
    340      * @uses bbp_get_reply_author_url()
    341      * @uses bbp_current_anonymous_user_data()
    342      *
    343      * @return string The url of the author
    344      */
    345     function bbp_get_author_url( $post_id = 0 ) {
    346 
    347         // Define local variable(s)
    348         $retval = '';
    349 
    350         // Topic edit
    351         if ( bbp_is_topic_edit() ) {
    352             $retval = bbp_get_topic_author_url( $post_id );
    353 
    354         // Reply edit
    355         } elseif ( bbp_is_reply_edit() ) {
    356             $retval = bbp_get_reply_author_url( $post_id );
    357 
    358         // Not an edit, so rely on current user cookie data
    359         } else {
    360             $retval = bbp_current_anonymous_user_data( 'url' );
    361         }
    362 
    363         return apply_filters( 'bbp_get_author_url', $retval, $post_id );
    364     }
    365159
    366160/** Post Counts ***************************************************************/
  • trunk/includes/users/template.php

    r5088 r5121  
    610610
    611611        return apply_filters( 'bbp_get_author_ip', $author_ip, $r );
     612    }
     613
     614/** Anonymous Fields **********************************************************/
     615   
     616/**
     617 * Output the author disylay-name of a topic or reply.
     618 *
     619 * Convenience function to ensure proper template functions are called
     620 * and correct filters are executed. Used primarily to display topic
     621 * and reply author information in the anonymous form template-part.
     622 *
     623 * @since bbPress (r5119)
     624 *
     625 * @param int $post_id
     626 * @uses bbp_get_author_display_name() to get the author name
     627 */
     628function bbp_author_display_name( $post_id = 0 ) {
     629    echo bbp_get_author_display_name( $post_id );
     630}
     631
     632    /**
     633     * Return the author name of a topic or reply.
     634     *
     635     * Convenience function to ensure proper template functions are called
     636     * and correct filters are executed. Used primarily to display topic
     637     * and reply author information in the anonymous form template-part.
     638     *
     639     * @since bbPress (r5119)
     640     *
     641     * @param int $post_id
     642     *
     643     * @uses bbp_is_topic_edit()
     644     * @uses bbp_get_topic_author_display_name()
     645     * @uses bbp_is_reply_edit()
     646     * @uses bbp_get_reply_author_display_name()
     647     * @uses bbp_current_anonymous_user_data()
     648     *
     649     * @return string The name of the author
     650     */
     651    function bbp_get_author_display_name( $post_id = 0 ) {
     652
     653        // Define local variable(s)
     654        $retval = '';
     655
     656        // Topic edit
     657        if ( bbp_is_topic_edit() ) {
     658            $retval = bbp_get_topic_author_display_name( $post_id );
     659
     660        // Reply edit
     661        } elseif ( bbp_is_reply_edit() ) {
     662            $retval = bbp_get_reply_author_display_name( $post_id );
     663
     664        // Not an edit, so rely on current user cookie data
     665        } else {
     666            $retval = bbp_current_anonymous_user_data( 'name' );
     667        }
     668
     669        return apply_filters( 'bbp_get_author_display_name', $retval, $post_id );
     670    }
     671
     672/**
     673 * Output the author email of a topic or reply.
     674 *
     675 * Convenience function to ensure proper template functions are called
     676 * and correct filters are executed. Used primarily to display topic
     677 * and reply author information in the anonymous user form template-part.
     678 *
     679 * @since bbPress (r5119)
     680 *
     681 * @param int $post_id
     682 * @uses bbp_get_author_email() to get the author email
     683 */
     684function bbp_author_email( $post_id = 0 ) {
     685    echo bbp_get_author_email( $post_id );
     686}
     687
     688    /**
     689     * Return the author email of a topic or reply.
     690     *
     691     * Convenience function to ensure proper template functions are called
     692     * and correct filters are executed. Used primarily to display topic
     693     * and reply author information in the anonymous user form template-part.
     694     *
     695     * @since bbPress (r5119)
     696     *
     697     * @param int $post_id
     698     *
     699     * @uses bbp_is_topic_edit()
     700     * @uses bbp_get_topic_author_email()
     701     * @uses bbp_is_reply_edit()
     702     * @uses bbp_get_reply_author_email()
     703     * @uses bbp_current_anonymous_user_data()
     704     *
     705     * @return string The email of the author
     706     */
     707    function bbp_get_author_email( $post_id = 0 ) {
     708
     709        // Define local variable(s)
     710        $retval = '';
     711
     712        // Topic edit
     713        if ( bbp_is_topic_edit() ) {
     714            $retval = bbp_get_topic_author_email( $post_id );
     715
     716        // Reply edit
     717        } elseif ( bbp_is_reply_edit() ) {
     718            $retval = bbp_get_reply_author_email( $post_id );
     719
     720        // Not an edit, so rely on current user cookie data
     721        } else {
     722            $retval = bbp_current_anonymous_user_data( 'email' );
     723        }
     724
     725        return apply_filters( 'bbp_get_author_email', $retval, $post_id );
     726    }
     727
     728/**
     729 * Output the author url of a topic or reply.
     730 *
     731 * Convenience function to ensure proper template functions are called
     732 * and correct filters are executed. Used primarily to display topic
     733 * and reply author information in the anonymous user form template-part.
     734 *
     735 * @since bbPress (r5119)
     736 *
     737 * @param int $post_id
     738 * @uses bbp_get_author_url() to get the author url
     739 */
     740function bbp_author_url( $post_id = 0 ) {
     741    echo bbp_get_author_url( $post_id );
     742}
     743
     744    /**
     745     * Return the author url of a topic or reply.
     746     *
     747     * Convenience function to ensure proper template functions are called
     748     * and correct filters are executed. Used primarily to display topic
     749     * and reply author information in the anonymous user form template-part.
     750     *
     751     * @since bbPress (r5119)
     752     *
     753     * @param int $post_id
     754     *
     755     * @uses bbp_is_topic_edit()
     756     * @uses bbp_get_topic_author_url()
     757     * @uses bbp_is_reply_edit()
     758     * @uses bbp_get_reply_author_url()
     759     * @uses bbp_current_anonymous_user_data()
     760     *
     761     * @return string The url of the author
     762     */
     763    function bbp_get_author_url( $post_id = 0 ) {
     764
     765        // Define local variable(s)
     766        $retval = '';
     767
     768        // Topic edit
     769        if ( bbp_is_topic_edit() ) {
     770            $retval = bbp_get_topic_author_url( $post_id );
     771
     772        // Reply edit
     773        } elseif ( bbp_is_reply_edit() ) {
     774            $retval = bbp_get_reply_author_url( $post_id );
     775
     776        // Not an edit, so rely on current user cookie data
     777        } else {
     778            $retval = bbp_current_anonymous_user_data( 'url' );
     779        }
     780
     781        return apply_filters( 'bbp_get_author_url', $retval, $post_id );
    612782    }
    613783
     
    11641334    }
    11651335
    1166 /** Topics Created ************************************************************/
     1336/** Replies Created ***********************************************************/
    11671337
    11681338/**
     
    17931963    return (bool) apply_filters( 'bbp_current_user_can_access_create_reply_form', (bool) $retval );
    17941964}
     1965
     1966/**
     1967 * Performs a series of checks to ensure the current user should see the
     1968 * anonymous user form fields.
     1969 *
     1970 * @since bbPress (r5119)
     1971 *
     1972 * @uses bbp_is_anonymous()
     1973 * @uses bbp_is_topic_edit()
     1974 * @uses bbp_is_topic_anonymous()
     1975 * @uses bbp_is_reply_edit()
     1976 * @uses bbp_is_reply_anonymous()
     1977 *
     1978 * @return bool
     1979 */
     1980function bbp_current_user_can_access_anonymous_user_form() {
     1981
     1982    // Users need to earn access
     1983    $retval = false;
     1984
     1985    // User is not logged in, and anonymous posting is allowed
     1986    if ( bbp_is_anonymous() ) {
     1987        $retval = true;
     1988
     1989    // User is editing a topic, and topic is authored by anonymous user
     1990    } elseif ( bbp_is_topic_edit() && bbp_is_topic_anonymous() ) {
     1991        $retval = true;
     1992
     1993    // User is editing a reply, and reply is authored by anonymous user
     1994    } elseif ( bbp_is_reply_edit() && bbp_is_reply_anonymous() ) {
     1995        $retval = true;
     1996    }
     1997
     1998    // Allow access to be filtered
     1999    return (bool) apply_filters( 'bbp_current_user_can_access_anonymous_user_form', (bool) $retval );
     2000}
Note: See TracChangeset for help on using the changeset viewer.